@spectrum-web-components/shared 1.7.0 → 1.8.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 +2 -2
- package/src/first-focusable-in.d.ts +11 -0
- package/src/first-focusable-in.dev.js.map +1 -1
- package/src/first-focusable-in.js.map +1 -1
- package/src/focus-visible.d.ts +11 -0
- package/src/focus-visible.dev.js.map +1 -1
- package/src/focus-visible.js.map +1 -1
- package/src/focusable-selectors.d.ts +11 -0
- package/src/focusable-selectors.dev.js.map +1 -1
- package/src/focusable-selectors.js.map +1 -1
- package/src/focusable.d.ts +11 -0
- package/src/focusable.dev.js.map +1 -1
- package/src/focusable.js.map +1 -1
- package/src/get-active-element.d.ts +11 -0
- package/src/get-active-element.dev.js.map +1 -1
- package/src/get-active-element.js.map +1 -1
- package/src/get-deep-element-from-point.d.ts +11 -0
- package/src/get-deep-element-from-point.dev.js.map +1 -1
- package/src/get-deep-element-from-point.js.map +1 -1
- package/src/get-label-from-slot.d.ts +11 -0
- package/src/get-label-from-slot.dev.js.map +1 -1
- package/src/get-label-from-slot.js.map +1 -1
- package/src/index.d.ts +11 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js.map +1 -1
- package/src/like-anchor.d.ts +11 -0
- package/src/like-anchor.dev.js.map +1 -1
- package/src/like-anchor.js.map +1 -1
- package/src/observe-slot-presence.d.ts +11 -0
- package/src/observe-slot-presence.dev.js.map +2 -2
- package/src/observe-slot-presence.js.map +2 -2
- package/src/observe-slot-text.d.ts +11 -0
- package/src/observe-slot-text.dev.js.map +1 -1
- package/src/observe-slot-text.js.map +1 -1
- package/src/platform.d.ts +11 -0
- package/src/platform.dev.js.map +1 -1
- package/src/platform.js.map +1 -1
- package/src/random-id.d.ts +11 -0
- package/src/random-id.dev.js.map +1 -1
- package/src/random-id.js.map +1 -1
- package/src/reparent-children.dev.js.map +1 -1
- package/src/reparent-children.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
],
|
|
108
108
|
"dependencies": {
|
|
109
109
|
"@lit-labs/observers": "^2.0.2",
|
|
110
|
-
"@spectrum-web-components/base": "1.
|
|
110
|
+
"@spectrum-web-components/base": "1.8.0",
|
|
111
111
|
"focus-visible": "^5.1.0"
|
|
112
112
|
},
|
|
113
113
|
"types": "./src/index.d.ts",
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
import type { SpectrumElement } from '@spectrum-web-components/base';
|
|
2
13
|
export declare const firstFocusableIn: (root: HTMLElement | ShadowRoot) => SpectrumElement | null;
|
|
3
14
|
export declare const firstFocusableSlottedIn: (root: HTMLSlotElement) => SpectrumElement | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["first-focusable-in.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["first-focusable-in.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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
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
6
|
"names": ["userFocusableSelector", "root", "element"]
|
|
7
7
|
}
|
package/src/focus-visible.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
declare global {
|
|
2
13
|
interface Window {
|
|
3
14
|
applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["focus-visible.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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
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
6
|
"names": []
|
|
7
7
|
}
|
package/src/focus-visible.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["focus-visible.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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
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
6
|
"names": ["hasFocusVisible", "error", "SuperClass", "_a", "_b", "coordinateWithPolyfill", "instance", "coordinationHandler", "$endPolyfillCoordination", "FocusVisibleCoordinator"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export declare const userFocusableSelector: string;
|
|
2
13
|
export declare const focusableSelector: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["focusable-selectors.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Inspired from https://github.com/focus-trap/tabbable/blob/8acf516c29da42c928753950210b07ac32efc724/src/index.js#L6\nconst focusables = [\n 'input:not([inert])',\n 'select:not([inert])',\n 'textarea:not([inert])',\n 'a[href]:not([inert])',\n 'button:not([inert])',\n 'label:not([inert])',\n '[tabindex]:not([inert])',\n 'audio[controls]:not([inert])',\n 'video[controls]:not([inert])',\n '[contenteditable]:not([contenteditable=\"false\"]):not([inert])',\n 'details>summary:first-of-type:not([inert])',\n 'details:not([inert])',\n '[focusable]:not([focusable=\"false\"])', // custom dev use-case\n];\n\nconst userFocuable = ':not([tabindex=\"-1\"])';\n\nexport const userFocusableSelector =\n focusables.join(`${userFocuable}, `) + userFocuable;\n\nexport const focusableSelector = focusables.join(', ');\n"],
|
|
5
5
|
"mappings": ";AAaA,MAAM,aAAa;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AACJ;AAEA,MAAM,eAAe;AAEd,aAAM,wBACT,WAAW,KAAK,GAAG,YAAY,IAAI,IAAI;AAEpC,aAAM,oBAAoB,WAAW,KAAK,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["focusable-selectors.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Inspired from https://github.com/focus-trap/tabbable/blob/8acf516c29da42c928753950210b07ac32efc724/src/index.js#L6\nconst focusables = [\n 'input:not([inert])',\n 'select:not([inert])',\n 'textarea:not([inert])',\n 'a[href]:not([inert])',\n 'button:not([inert])',\n 'label:not([inert])',\n '[tabindex]:not([inert])',\n 'audio[controls]:not([inert])',\n 'video[controls]:not([inert])',\n '[contenteditable]:not([contenteditable=\"false\"]):not([inert])',\n 'details>summary:first-of-type:not([inert])',\n 'details:not([inert])',\n '[focusable]:not([focusable=\"false\"])', // custom dev use-case\n];\n\nconst userFocuable = ':not([tabindex=\"-1\"])';\n\nexport const userFocusableSelector =\n focusables.join(`${userFocuable}, `) + userFocuable;\n\nexport const focusableSelector = focusables.join(', ');\n"],
|
|
5
5
|
"mappings": "aAaA,MAAMA,EAAa,CACf,qBACA,sBACA,wBACA,uBACA,sBACA,qBACA,0BACA,+BACA,+BACA,gEACA,6CACA,uBACA,sCACJ,EAEMC,EAAe,wBAEd,aAAM,sBACTD,EAAW,KAAK,GAAGC,CAAY,IAAI,EAAIA,EAE9B,kBAAoBD,EAAW,KAAK,IAAI",
|
|
6
6
|
"names": ["focusables", "userFocuable"]
|
|
7
7
|
}
|
package/src/focusable.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
import { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';
|
|
2
13
|
type DisableableElement = HTMLElement & {
|
|
3
14
|
disabled?: boolean;
|
package/src/focusable.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["focusable.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 { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { FocusVisiblePolyfillMixin } from './focus-visible.dev.js'\n\ntype DisableableElement = HTMLElement & { disabled?: boolean };\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\n/**\n * Focusable base class handles tabindex setting into shadowed elements automatically.\n *\n * This implementation is based heavily on the aybolit delegate-focus-mixin at\n * https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js\n */\nexport class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {\n /**\n * Disable this control. It will not receive focus or events\n */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n /**\n * The tab index to apply to this control. See general documentation about\n * the tabindex HTML property\n *\n * @private\n */\n @property({ type: Number })\n public override get tabIndex(): number {\n if (this.focusElement === this) {\n const tabindex = this.hasAttribute('tabindex')\n ? Number(this.getAttribute('tabindex'))\n : NaN;\n return !isNaN(tabindex) ? tabindex : -1;\n }\n const tabIndexAttribute = parseFloat(\n this.hasAttribute('tabindex')\n ? (this.getAttribute('tabindex') as string) || '0'\n : '0'\n );\n // When `disabled` tabindex is -1.\n // When host tabindex -1, use that as the cache.\n if (this.disabled || tabIndexAttribute < 0) {\n return -1;\n }\n // When `focusElement` isn't available yet,\n // use host tabindex as the cache.\n if (!this.focusElement) {\n return tabIndexAttribute;\n }\n // All other times, use the tabindex of `focusElement`\n // as the cache for this value.\n // return this.focusElement.tabIndex;\n return this._tabIndex;\n }\n public override set tabIndex(tabIndex: number) {\n // Flipping `manipulatingTabindex` to true before a change\n // allows for that change NOT to effect the cached value of tabindex\n if (this.manipulatingTabindex) {\n this.manipulatingTabindex = false;\n return;\n }\n\n if (this.focusElement === this) {\n if (this.disabled) {\n this._tabIndex = tabIndex;\n } else if (tabIndex !== this._tabIndex) {\n this._tabIndex = tabIndex;\n const tabindex = '' + tabIndex;\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', tabindex);\n }\n return;\n }\n\n if (tabIndex === -1) {\n this.addEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n } else {\n // All code paths are about to address the host tabindex without side effect.\n this.manipulatingTabindex = true;\n this.removeEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n }\n\n if (tabIndex === -1 || this.disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n this.removeAttribute('focusable');\n\n if (this.selfManageFocusElement) {\n return;\n }\n\n if (tabIndex !== -1) {\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n } else {\n this.focusElement?.removeAttribute('tabindex');\n }\n return;\n }\n\n this.setAttribute('focusable', '');\n if (this.hasAttribute('tabindex')) {\n this.removeAttribute('tabindex');\n } else {\n // You can't remove an attribute that isn't there,\n // manually end the `manipulatingTabindex` guard.\n this.manipulatingTabindex = false;\n }\n\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n }\n private _tabIndex = 0;\n\n private onPointerdownManagementOfTabIndex(): void {\n if (this.tabIndex === -1) {\n setTimeout(() => {\n // Ensure this happens _after_ WebKit attempts to focus the :host.\n this.tabIndex = 0;\n this.focus({ preventScroll: true });\n this.tabIndex = -1;\n });\n }\n }\n\n private async manageFocusElementTabindex(tabIndex: number): Promise<void> {\n if (!this.focusElement) {\n // allow setting these values to be async when needed.\n await this.updateComplete;\n }\n if (tabIndex === null) {\n this.focusElement.removeAttribute('tabindex');\n } else {\n if (this.focusElement !== this) {\n this.focusElement.tabIndex = tabIndex;\n }\n }\n }\n\n private manipulatingTabindex = false;\n\n /**\n * @private\n */\n public get focusElement(): DisableableElement {\n throw new Error('Must implement focusElement getter!');\n }\n\n /**\n * @public\n * @returns {boolean} whether the component should manage its focusElement tab-index or not\n * Needed for action-menu to be supported in action-group in an accessible way\n */\n public get selfManageFocusElement(): boolean {\n return false;\n }\n\n public override focus(options?: FocusOptions): void {\n if (this.disabled || !this.focusElement) {\n return;\n }\n\n if (this.focusElement !== this) {\n this.focusElement.focus(options);\n } else {\n HTMLElement.prototype.focus.apply(this, [options]);\n }\n }\n\n public override blur(): void {\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.blur();\n } else {\n HTMLElement.prototype.blur.apply(this);\n }\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.click();\n } else {\n HTMLElement.prototype.click.apply(this);\n }\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focusElement.focus();\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (\n !this.hasAttribute('tabindex') ||\n this.getAttribute('tabindex') !== '-1'\n ) {\n this.setAttribute('focusable', '');\n }\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (changedProperties.has('disabled')) {\n this.handleDisabledChanged(\n this.disabled,\n changedProperties.get('disabled') as boolean\n );\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('disabled') && this.disabled) {\n this.blur();\n }\n }\n\n private async handleDisabledChanged(\n disabled: boolean,\n oldDisabled: boolean\n ): Promise<void> {\n const canSetDisabled = (): boolean =>\n this.focusElement !== this &&\n typeof this.focusElement.disabled !== 'undefined';\n if (disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = true;\n } else {\n this.setAttribute('aria-disabled', 'true');\n }\n } else if (oldDisabled) {\n this.manipulatingTabindex = true;\n if (this.focusElement === this) {\n this.setAttribute('tabindex', '' + this._tabIndex);\n } else {\n this.removeAttribute('tabindex');\n }\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = false;\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.autofocusReady;\n return complete;\n }\n\n private autofocusReady = Promise.resolve();\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.autofocus) {\n this.autofocusReady = new Promise(async (res) => {\n // If at connect time the [autofocus] content is placed within\n // content that needs to be \"hidden\" by default, it would need to wait\n // two rAFs for animations to be triggered on that content in\n // order for the [autofocus] to become \"visisble\" and have its\n // focus() capabilities enabled.\n //\n // Await this with `getUpdateComplete` so that the element cannot\n // become \"ready\" until `manageFocus` has occured.\n await nextFrame();\n await nextFrame();\n res();\n });\n this.updateComplete.then(() => {\n this.manageAutoFocus();\n });\n }\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { FocusVisiblePolyfillMixin } from './focus-visible.dev.js'\n\ntype DisableableElement = HTMLElement & { disabled?: boolean };\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\n/**\n * Focusable base class handles tabindex setting into shadowed elements automatically.\n *\n * This implementation is based heavily on the aybolit delegate-focus-mixin at\n * https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js\n */\nexport class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {\n /**\n * Disable this control. It will not receive focus or events\n */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n /**\n * The tab index to apply to this control. See general documentation about\n * the tabindex HTML property\n *\n * @private\n */\n @property({ type: Number })\n public override get tabIndex(): number {\n if (this.focusElement === this) {\n const tabindex = this.hasAttribute('tabindex')\n ? Number(this.getAttribute('tabindex'))\n : NaN;\n return !isNaN(tabindex) ? tabindex : -1;\n }\n const tabIndexAttribute = parseFloat(\n this.hasAttribute('tabindex')\n ? (this.getAttribute('tabindex') as string) || '0'\n : '0'\n );\n // When `disabled` tabindex is -1.\n // When host tabindex -1, use that as the cache.\n if (this.disabled || tabIndexAttribute < 0) {\n return -1;\n }\n // When `focusElement` isn't available yet,\n // use host tabindex as the cache.\n if (!this.focusElement) {\n return tabIndexAttribute;\n }\n // All other times, use the tabindex of `focusElement`\n // as the cache for this value.\n // return this.focusElement.tabIndex;\n return this._tabIndex;\n }\n public override set tabIndex(tabIndex: number) {\n // Flipping `manipulatingTabindex` to true before a change\n // allows for that change NOT to effect the cached value of tabindex\n if (this.manipulatingTabindex) {\n this.manipulatingTabindex = false;\n return;\n }\n\n if (this.focusElement === this) {\n if (this.disabled) {\n this._tabIndex = tabIndex;\n } else if (tabIndex !== this._tabIndex) {\n this._tabIndex = tabIndex;\n const tabindex = '' + tabIndex;\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', tabindex);\n }\n return;\n }\n\n if (tabIndex === -1) {\n this.addEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n } else {\n // All code paths are about to address the host tabindex without side effect.\n this.manipulatingTabindex = true;\n this.removeEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n }\n\n if (tabIndex === -1 || this.disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n this.removeAttribute('focusable');\n\n if (this.selfManageFocusElement) {\n return;\n }\n\n if (tabIndex !== -1) {\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n } else {\n this.focusElement?.removeAttribute('tabindex');\n }\n return;\n }\n\n this.setAttribute('focusable', '');\n if (this.hasAttribute('tabindex')) {\n this.removeAttribute('tabindex');\n } else {\n // You can't remove an attribute that isn't there,\n // manually end the `manipulatingTabindex` guard.\n this.manipulatingTabindex = false;\n }\n\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n }\n private _tabIndex = 0;\n\n private onPointerdownManagementOfTabIndex(): void {\n if (this.tabIndex === -1) {\n setTimeout(() => {\n // Ensure this happens _after_ WebKit attempts to focus the :host.\n this.tabIndex = 0;\n this.focus({ preventScroll: true });\n this.tabIndex = -1;\n });\n }\n }\n\n private async manageFocusElementTabindex(tabIndex: number): Promise<void> {\n if (!this.focusElement) {\n // allow setting these values to be async when needed.\n await this.updateComplete;\n }\n if (tabIndex === null) {\n this.focusElement.removeAttribute('tabindex');\n } else {\n if (this.focusElement !== this) {\n this.focusElement.tabIndex = tabIndex;\n }\n }\n }\n\n private manipulatingTabindex = false;\n\n /**\n * @private\n */\n public get focusElement(): DisableableElement {\n throw new Error('Must implement focusElement getter!');\n }\n\n /**\n * @public\n * @returns {boolean} whether the component should manage its focusElement tab-index or not\n * Needed for action-menu to be supported in action-group in an accessible way\n */\n public get selfManageFocusElement(): boolean {\n return false;\n }\n\n public override focus(options?: FocusOptions): void {\n if (this.disabled || !this.focusElement) {\n return;\n }\n\n if (this.focusElement !== this) {\n this.focusElement.focus(options);\n } else {\n HTMLElement.prototype.focus.apply(this, [options]);\n }\n }\n\n public override blur(): void {\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.blur();\n } else {\n HTMLElement.prototype.blur.apply(this);\n }\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.click();\n } else {\n HTMLElement.prototype.click.apply(this);\n }\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focusElement.focus();\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (\n !this.hasAttribute('tabindex') ||\n this.getAttribute('tabindex') !== '-1'\n ) {\n this.setAttribute('focusable', '');\n }\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (changedProperties.has('disabled')) {\n this.handleDisabledChanged(\n this.disabled,\n changedProperties.get('disabled') as boolean\n );\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('disabled') && this.disabled) {\n this.blur();\n }\n }\n\n private async handleDisabledChanged(\n disabled: boolean,\n oldDisabled: boolean\n ): Promise<void> {\n const canSetDisabled = (): boolean =>\n this.focusElement !== this &&\n typeof this.focusElement.disabled !== 'undefined';\n if (disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = true;\n } else {\n this.setAttribute('aria-disabled', 'true');\n }\n } else if (oldDisabled) {\n this.manipulatingTabindex = true;\n if (this.focusElement === this) {\n this.setAttribute('tabindex', '' + this._tabIndex);\n } else {\n this.removeAttribute('tabindex');\n }\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = false;\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.autofocusReady;\n return complete;\n }\n\n private autofocusReady = Promise.resolve();\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.autofocus) {\n this.autofocusReady = new Promise(async (res) => {\n // If at connect time the [autofocus] content is placed within\n // content that needs to be \"hidden\" by default, it would need to wait\n // two rAFs for animations to be triggered on that content in\n // order for the [autofocus] to become \"visisble\" and have its\n // focus() capabilities enabled.\n //\n // Await this with `getUpdateComplete` so that the element cannot\n // become \"ready\" until `manageFocus` has occured.\n await nextFrame();\n await nextFrame();\n res();\n });\n this.updateComplete.then(() => {\n this.manageAutoFocus();\n });\n }\n }\n}\n"],
|
|
5
5
|
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/focusable.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["focusable.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 { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { FocusVisiblePolyfillMixin } from './focus-visible.js';\n\ntype DisableableElement = HTMLElement & { disabled?: boolean };\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\n/**\n * Focusable base class handles tabindex setting into shadowed elements automatically.\n *\n * This implementation is based heavily on the aybolit delegate-focus-mixin at\n * https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js\n */\nexport class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {\n /**\n * Disable this control. It will not receive focus or events\n */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n /**\n * The tab index to apply to this control. See general documentation about\n * the tabindex HTML property\n *\n * @private\n */\n @property({ type: Number })\n public override get tabIndex(): number {\n if (this.focusElement === this) {\n const tabindex = this.hasAttribute('tabindex')\n ? Number(this.getAttribute('tabindex'))\n : NaN;\n return !isNaN(tabindex) ? tabindex : -1;\n }\n const tabIndexAttribute = parseFloat(\n this.hasAttribute('tabindex')\n ? (this.getAttribute('tabindex') as string) || '0'\n : '0'\n );\n // When `disabled` tabindex is -1.\n // When host tabindex -1, use that as the cache.\n if (this.disabled || tabIndexAttribute < 0) {\n return -1;\n }\n // When `focusElement` isn't available yet,\n // use host tabindex as the cache.\n if (!this.focusElement) {\n return tabIndexAttribute;\n }\n // All other times, use the tabindex of `focusElement`\n // as the cache for this value.\n // return this.focusElement.tabIndex;\n return this._tabIndex;\n }\n public override set tabIndex(tabIndex: number) {\n // Flipping `manipulatingTabindex` to true before a change\n // allows for that change NOT to effect the cached value of tabindex\n if (this.manipulatingTabindex) {\n this.manipulatingTabindex = false;\n return;\n }\n\n if (this.focusElement === this) {\n if (this.disabled) {\n this._tabIndex = tabIndex;\n } else if (tabIndex !== this._tabIndex) {\n this._tabIndex = tabIndex;\n const tabindex = '' + tabIndex;\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', tabindex);\n }\n return;\n }\n\n if (tabIndex === -1) {\n this.addEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n } else {\n // All code paths are about to address the host tabindex without side effect.\n this.manipulatingTabindex = true;\n this.removeEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n }\n\n if (tabIndex === -1 || this.disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n this.removeAttribute('focusable');\n\n if (this.selfManageFocusElement) {\n return;\n }\n\n if (tabIndex !== -1) {\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n } else {\n this.focusElement?.removeAttribute('tabindex');\n }\n return;\n }\n\n this.setAttribute('focusable', '');\n if (this.hasAttribute('tabindex')) {\n this.removeAttribute('tabindex');\n } else {\n // You can't remove an attribute that isn't there,\n // manually end the `manipulatingTabindex` guard.\n this.manipulatingTabindex = false;\n }\n\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n }\n private _tabIndex = 0;\n\n private onPointerdownManagementOfTabIndex(): void {\n if (this.tabIndex === -1) {\n setTimeout(() => {\n // Ensure this happens _after_ WebKit attempts to focus the :host.\n this.tabIndex = 0;\n this.focus({ preventScroll: true });\n this.tabIndex = -1;\n });\n }\n }\n\n private async manageFocusElementTabindex(tabIndex: number): Promise<void> {\n if (!this.focusElement) {\n // allow setting these values to be async when needed.\n await this.updateComplete;\n }\n if (tabIndex === null) {\n this.focusElement.removeAttribute('tabindex');\n } else {\n if (this.focusElement !== this) {\n this.focusElement.tabIndex = tabIndex;\n }\n }\n }\n\n private manipulatingTabindex = false;\n\n /**\n * @private\n */\n public get focusElement(): DisableableElement {\n throw new Error('Must implement focusElement getter!');\n }\n\n /**\n * @public\n * @returns {boolean} whether the component should manage its focusElement tab-index or not\n * Needed for action-menu to be supported in action-group in an accessible way\n */\n public get selfManageFocusElement(): boolean {\n return false;\n }\n\n public override focus(options?: FocusOptions): void {\n if (this.disabled || !this.focusElement) {\n return;\n }\n\n if (this.focusElement !== this) {\n this.focusElement.focus(options);\n } else {\n HTMLElement.prototype.focus.apply(this, [options]);\n }\n }\n\n public override blur(): void {\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.blur();\n } else {\n HTMLElement.prototype.blur.apply(this);\n }\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.click();\n } else {\n HTMLElement.prototype.click.apply(this);\n }\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focusElement.focus();\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (\n !this.hasAttribute('tabindex') ||\n this.getAttribute('tabindex') !== '-1'\n ) {\n this.setAttribute('focusable', '');\n }\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (changedProperties.has('disabled')) {\n this.handleDisabledChanged(\n this.disabled,\n changedProperties.get('disabled') as boolean\n );\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('disabled') && this.disabled) {\n this.blur();\n }\n }\n\n private async handleDisabledChanged(\n disabled: boolean,\n oldDisabled: boolean\n ): Promise<void> {\n const canSetDisabled = (): boolean =>\n this.focusElement !== this &&\n typeof this.focusElement.disabled !== 'undefined';\n if (disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = true;\n } else {\n this.setAttribute('aria-disabled', 'true');\n }\n } else if (oldDisabled) {\n this.manipulatingTabindex = true;\n if (this.focusElement === this) {\n this.setAttribute('tabindex', '' + this._tabIndex);\n } else {\n this.removeAttribute('tabindex');\n }\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = false;\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.autofocusReady;\n return complete;\n }\n\n private autofocusReady = Promise.resolve();\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.autofocus) {\n this.autofocusReady = new Promise(async (res) => {\n // If at connect time the [autofocus] content is placed within\n // content that needs to be \"hidden\" by default, it would need to wait\n // two rAFs for animations to be triggered on that content in\n // order for the [autofocus] to become \"visisble\" and have its\n // focus() capabilities enabled.\n //\n // Await this with `getUpdateComplete` so that the element cannot\n // become \"ready\" until `manageFocus` has occured.\n await nextFrame();\n await nextFrame();\n res();\n });\n this.updateComplete.then(() => {\n this.manageAutoFocus();\n });\n }\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { FocusVisiblePolyfillMixin } from './focus-visible.js';\n\ntype DisableableElement = HTMLElement & { disabled?: boolean };\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\n/**\n * Focusable base class handles tabindex setting into shadowed elements automatically.\n *\n * This implementation is based heavily on the aybolit delegate-focus-mixin at\n * https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js\n */\nexport class Focusable extends FocusVisiblePolyfillMixin(SpectrumElement) {\n /**\n * Disable this control. It will not receive focus or events\n */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n /**\n * The tab index to apply to this control. See general documentation about\n * the tabindex HTML property\n *\n * @private\n */\n @property({ type: Number })\n public override get tabIndex(): number {\n if (this.focusElement === this) {\n const tabindex = this.hasAttribute('tabindex')\n ? Number(this.getAttribute('tabindex'))\n : NaN;\n return !isNaN(tabindex) ? tabindex : -1;\n }\n const tabIndexAttribute = parseFloat(\n this.hasAttribute('tabindex')\n ? (this.getAttribute('tabindex') as string) || '0'\n : '0'\n );\n // When `disabled` tabindex is -1.\n // When host tabindex -1, use that as the cache.\n if (this.disabled || tabIndexAttribute < 0) {\n return -1;\n }\n // When `focusElement` isn't available yet,\n // use host tabindex as the cache.\n if (!this.focusElement) {\n return tabIndexAttribute;\n }\n // All other times, use the tabindex of `focusElement`\n // as the cache for this value.\n // return this.focusElement.tabIndex;\n return this._tabIndex;\n }\n public override set tabIndex(tabIndex: number) {\n // Flipping `manipulatingTabindex` to true before a change\n // allows for that change NOT to effect the cached value of tabindex\n if (this.manipulatingTabindex) {\n this.manipulatingTabindex = false;\n return;\n }\n\n if (this.focusElement === this) {\n if (this.disabled) {\n this._tabIndex = tabIndex;\n } else if (tabIndex !== this._tabIndex) {\n this._tabIndex = tabIndex;\n const tabindex = '' + tabIndex;\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', tabindex);\n }\n return;\n }\n\n if (tabIndex === -1) {\n this.addEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n } else {\n // All code paths are about to address the host tabindex without side effect.\n this.manipulatingTabindex = true;\n this.removeEventListener(\n 'pointerdown',\n this.onPointerdownManagementOfTabIndex\n );\n }\n\n if (tabIndex === -1 || this.disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n this.removeAttribute('focusable');\n\n if (this.selfManageFocusElement) {\n return;\n }\n\n if (tabIndex !== -1) {\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n } else {\n this.focusElement?.removeAttribute('tabindex');\n }\n return;\n }\n\n this.setAttribute('focusable', '');\n if (this.hasAttribute('tabindex')) {\n this.removeAttribute('tabindex');\n } else {\n // You can't remove an attribute that isn't there,\n // manually end the `manipulatingTabindex` guard.\n this.manipulatingTabindex = false;\n }\n\n this._tabIndex = tabIndex;\n this.manageFocusElementTabindex(tabIndex);\n }\n private _tabIndex = 0;\n\n private onPointerdownManagementOfTabIndex(): void {\n if (this.tabIndex === -1) {\n setTimeout(() => {\n // Ensure this happens _after_ WebKit attempts to focus the :host.\n this.tabIndex = 0;\n this.focus({ preventScroll: true });\n this.tabIndex = -1;\n });\n }\n }\n\n private async manageFocusElementTabindex(tabIndex: number): Promise<void> {\n if (!this.focusElement) {\n // allow setting these values to be async when needed.\n await this.updateComplete;\n }\n if (tabIndex === null) {\n this.focusElement.removeAttribute('tabindex');\n } else {\n if (this.focusElement !== this) {\n this.focusElement.tabIndex = tabIndex;\n }\n }\n }\n\n private manipulatingTabindex = false;\n\n /**\n * @private\n */\n public get focusElement(): DisableableElement {\n throw new Error('Must implement focusElement getter!');\n }\n\n /**\n * @public\n * @returns {boolean} whether the component should manage its focusElement tab-index or not\n * Needed for action-menu to be supported in action-group in an accessible way\n */\n public get selfManageFocusElement(): boolean {\n return false;\n }\n\n public override focus(options?: FocusOptions): void {\n if (this.disabled || !this.focusElement) {\n return;\n }\n\n if (this.focusElement !== this) {\n this.focusElement.focus(options);\n } else {\n HTMLElement.prototype.focus.apply(this, [options]);\n }\n }\n\n public override blur(): void {\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.blur();\n } else {\n HTMLElement.prototype.blur.apply(this);\n }\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n const focusElement = this.focusElement || this;\n if (focusElement !== this) {\n focusElement.click();\n } else {\n HTMLElement.prototype.click.apply(this);\n }\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focusElement.focus();\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (\n !this.hasAttribute('tabindex') ||\n this.getAttribute('tabindex') !== '-1'\n ) {\n this.setAttribute('focusable', '');\n }\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (changedProperties.has('disabled')) {\n this.handleDisabledChanged(\n this.disabled,\n changedProperties.get('disabled') as boolean\n );\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('disabled') && this.disabled) {\n this.blur();\n }\n }\n\n private async handleDisabledChanged(\n disabled: boolean,\n oldDisabled: boolean\n ): Promise<void> {\n const canSetDisabled = (): boolean =>\n this.focusElement !== this &&\n typeof this.focusElement.disabled !== 'undefined';\n if (disabled) {\n this.manipulatingTabindex = true;\n this.setAttribute('tabindex', '-1');\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = true;\n } else {\n this.setAttribute('aria-disabled', 'true');\n }\n } else if (oldDisabled) {\n this.manipulatingTabindex = true;\n if (this.focusElement === this) {\n this.setAttribute('tabindex', '' + this._tabIndex);\n } else {\n this.removeAttribute('tabindex');\n }\n await this.updateComplete;\n if (canSetDisabled()) {\n this.focusElement.disabled = false;\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.autofocusReady;\n return complete;\n }\n\n private autofocusReady = Promise.resolve();\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.autofocus) {\n this.autofocusReady = new Promise(async (res) => {\n // If at connect time the [autofocus] content is placed within\n // content that needs to be \"hidden\" by default, it would need to wait\n // two rAFs for animations to be triggered on that content in\n // order for the [autofocus] to become \"visisble\" and have its\n // focus() capabilities enabled.\n //\n // Await this with `getUpdateComplete` so that the element cannot\n // become \"ready\" until `manageFocus` has occured.\n await nextFrame();\n await nextFrame();\n res();\n });\n this.updateComplete.then(() => {\n this.manageAutoFocus();\n });\n }\n }\n}\n"],
|
|
5
5
|
"mappings": "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",
|
|
6
6
|
"names": ["SpectrumElement", "property", "FocusVisiblePolyfillMixin", "nextFrame", "res", "tabindex", "tabIndexAttribute", "tabIndex", "_a", "options", "focusElement", "changes", "changedProperties", "disabled", "oldDisabled", "canSetDisabled", "complete", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export declare const getActiveElement: (el: Node) => Element | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-active-element.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/* c8 ignore next 3 */\nexport const getActiveElement = (el: Node): Element | null => {\n return (el.getRootNode() as Document).activeElement;\n};\n"],
|
|
5
5
|
"mappings": ";AAaO,aAAM,mBAAmB,CAAC,OAA6B;AAC1D,SAAQ,GAAG,YAAY,EAAe;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-active-element.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/* c8 ignore next 3 */\nexport const getActiveElement = (el: Node): Element | null => {\n return (el.getRootNode() as Document).activeElement;\n};\n"],
|
|
5
5
|
"mappings": "aAaO,aAAM,iBAAoBA,GACrBA,EAAG,YAAY,EAAe",
|
|
6
6
|
"names": ["el"]
|
|
7
7
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export declare const getDeepElementFromPoint: (x: number, y: number) => Element | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-deep-element-from-point.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-deep-element-from-point.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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
5
|
"mappings": "aAYO,aAAM,wBAA0B,CACnCA,EACAC,IACiB,CACjB,IAAIC,EAAS,SAAS,iBAAiBF,EAAGC,CAAC,EAC3C,KAAOC,GAAA,MAAAA,EAAQ,YAAY,CACvB,MAAMC,EACFD,EAAO,WAGT,iBAAiBF,EAAGC,CAAC,EACvB,GAAI,CAACE,GAAeA,IAAgBD,EAChC,MAEJA,EAASC,CACb,CACA,OAAOD,CACX",
|
|
6
6
|
"names": ["x", "y", "target", "innerTarget"]
|
|
7
7
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export declare const getLabelFromSlot: (label: string, slotEl: HTMLSlotElement) => string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-label-from-slot.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) return null;\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],
|
|
5
5
|
"mappings": ";AAYO,aAAM,mBAAmB,CAC5B,OACA,WACgB;AAChB,MAAI,MAAO,QAAO;AAClB,QAAM,cAAc,OACf,cAAc,EACd,OAAO,CAAC,aAAqB,SAAe;AACzC,QAAI,KAAK,aAAa;AAClB,aAAO,cAAc,KAAK;AAAA,IAC9B,OAAO;AACH,aAAO;AAAA,IACX;AAAA,EACJ,GAAG,EAAE;AACT,MAAI,aAAa;AACb,WAAO,YAAY,KAAK;AAAA,EAC5B,OAAO;AACH,WAAO;AAAA,EACX;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-label-from-slot.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) return null;\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],
|
|
5
5
|
"mappings": "aAYO,aAAM,iBAAmB,CAC5BA,EACAC,IACgB,CAChB,GAAID,EAAO,OAAO,KAClB,MAAME,EAAcD,EACf,cAAc,EACd,OAAO,CAACE,EAAqBC,IACtBA,EAAK,YACED,EAAcC,EAAK,YAEnBD,EAEZ,EAAE,EACT,OAAID,EACOA,EAAY,KAAK,EAEjB,IAEf",
|
|
6
6
|
"names": ["label", "slotEl", "textContent", "accumulator", "node"]
|
|
7
7
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export * from './first-focusable-in.js';
|
|
2
13
|
export * from './focus-visible.js';
|
|
3
14
|
export * from './focusable.js';
|
package/src/index.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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 './focusable-selectors.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'\nexport * from './get-label-from-slot.dev.js'\nexport * from './random-id.dev.js'\n"],
|
|
5
5
|
"mappings": ";AAYA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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 './focusable-selectors.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';\nexport * from './get-label-from-slot.js';\nexport * from './random-id.js';\n"],
|
|
5
5
|
"mappings": "aAYA,WAAc,0BACd,WAAc,qBACd,WAAc,iBACd,WAAc,2BACd,WAAc,0BACd,WAAc,mBACd,WAAc,6BACd,WAAc,yBACd,WAAc,gBACd,WAAc,yBACd,WAAc,2BACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/like-anchor.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
import { ReactiveElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
13
|
type Constructor<T = Record<string, unknown>> = {
|
|
3
14
|
new (...args: any[]): T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["like-anchor.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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 /**\n * Causes the browser to treat the linked URL as a download.\n */\n @property()\n public download?: string;\n\n /**\n * An accessible label that describes the component.\n * It will be applied to aria-label, but not visually rendered.\n */\n @property()\n public label?: string;\n\n /**\n * The URL that the hyperlink points to.\n */\n @property()\n public href?: string;\n\n /**\n * Where to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>).\n */\n @property()\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n /**\n * How much of the referrer to send when following the link.\n */\n @property()\n public referrerpolicy?:\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'same-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n\n /**\n * The relationship of the linked URL as space-separated link types.\n */\n @property()\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 referrerpolicy=${ifDefined(this.referrerpolicy)}\n rel=${ifDefined(this.rel)}\n >${anchorContent}</a>`;\n }\n }\n return LikeAnchorElement;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;AAWA;AAAA,EACI;AAAA,OAGG;AACP,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AA0BnB,gBAAS,WACZ,aACoC;AAAA,EACpC,MAAM,0BAA0B,YAAY;AAAA,IA8CjC,aAAa;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,gBAAgB;AAAA,IACpB,GAAwC;AAEpC,aAAO;AAAA,yBAEM,EAAE;AAAA,4BACC,UAAU,SAAS,CAAC;AAAA,2BACrB,UAAU,KAAK,IAAI,CAAC;AAAA,+BAChB,UAAU,KAAK,QAAQ,CAAC;AAAA,6BAC1B,UAAU,KAAK,MAAM,CAAC;AAAA,iCAClB,UAAU,KAAK,KAAK,CAAC;AAAA,sCAChB,UAAU,UAAU,CAAC;AAAA,kCACzB,UAAU,aAAa,SAAS,MAAS,CAAC;AAAA,+BAC7C,UAAU,QAAQ,CAAC;AAAA,qCACb,UAAU,KAAK,cAAc,CAAC;AAAA,0BACzC,UAAU,KAAK,GAAG,CAAC;AAAA,mBAC1B,aAAa;AAAA,IACxB;AAAA,EACJ;AAlEW;AAAA,IADN,SAAS;AAAA,KAJR,kBAKK;AAOA;AAAA,IADN,SAAS;AAAA,KAXR,kBAYK;AAMA;AAAA,IADN,SAAS;AAAA,KAjBR,kBAkBK;AAMA;AAAA,IADN,SAAS;AAAA,KAvBR,kBAwBK;AAMA;AAAA,IADN,SAAS;AAAA,KA7BR,kBA8BK;AAcA;AAAA,IADN,SAAS;AAAA,KA3CR,kBA4CK;AA4BX,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/like-anchor.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["like-anchor.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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 /**\n * Causes the browser to treat the linked URL as a download.\n */\n @property()\n public download?: string;\n\n /**\n * An accessible label that describes the component.\n * It will be applied to aria-label, but not visually rendered.\n */\n @property()\n public label?: string;\n\n /**\n * The URL that the hyperlink points to.\n */\n @property()\n public href?: string;\n\n /**\n * Where to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>).\n */\n @property()\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n /**\n * How much of the referrer to send when following the link.\n */\n @property()\n public referrerpolicy?:\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'same-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n\n /**\n * The relationship of the linked URL as space-separated link types.\n */\n @property()\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 referrerpolicy=${ifDefined(this.referrerpolicy)}\n rel=${ifDefined(this.rel)}\n >${anchorContent}</a>`;\n }\n }\n return LikeAnchorElement;\n}\n"],
|
|
5
5
|
"mappings": "qNAWA,OACI,QAAAA,MAGG,gCACP,OAAS,YAAAC,MAAgB,kDACzB,OAAS,aAAAC,MAAiB,kDA0BnB,gBAAS,WACZC,EACoC,CACpC,MAAMC,UAA0BD,CAAY,CA8CjC,aAAa,CAChB,GAAAE,EACA,UAAAC,EACA,WAAAC,EACA,WAAAC,EACA,SAAAC,EAEA,cAAAC,EAAgBV,gBACpB,EAAwC,CAEpC,OAAOA;AAAA,yBAEMK,CAAE;AAAA,4BACCH,EAAUI,CAAS,CAAC;AAAA,2BACrBJ,EAAU,KAAK,IAAI,CAAC;AAAA,+BAChBA,EAAU,KAAK,QAAQ,CAAC;AAAA,6BAC1BA,EAAU,KAAK,MAAM,CAAC;AAAA,iCAClBA,EAAU,KAAK,KAAK,CAAC;AAAA,sCAChBA,EAAUM,CAAU,CAAC;AAAA,kCACzBN,EAAUK,EAAa,OAAS,MAAS,CAAC;AAAA,+BAC7CL,EAAUO,CAAQ,CAAC;AAAA,qCACbP,EAAU,KAAK,cAAc,CAAC;AAAA,0BACzCA,EAAU,KAAK,GAAG,CAAC;AAAA,mBAC1BQ,CAAa,MACxB,CACJ,CAlEW,OAAAC,EAAA,CADNV,EAAS,GAJRG,EAKK,wBAOAO,EAAA,CADNV,EAAS,GAXRG,EAYK,qBAMAO,EAAA,CADNV,EAAS,GAjBRG,EAkBK,oBAMAO,EAAA,CADNV,EAAS,GAvBRG,EAwBK,sBAMAO,EAAA,CADNV,EAAS,GA7BRG,EA8BK,8BAcAO,EAAA,CADNV,EAAS,GA3CRG,EA4CK,mBA4BJA,CACX",
|
|
6
6
|
"names": ["html", "property", "ifDefined", "constructor", "LikeAnchorElement", "id", "className", "ariaHidden", "labelledby", "tabindex", "anchorContent", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
import { ReactiveElement } from '@spectrum-web-components/base';
|
|
2
13
|
type Constructor<T = Record<string, unknown>> = {
|
|
3
14
|
new (...args: any[]): T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-presence.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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(`:scope > ${selector}`);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(`:scope > ${selector}`)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n };\n }\n return SlotPresenceObservingElement;\n}\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,0BAA0B;AAEnC,MAAM,uBAAuB,OAAO,sBAAsB;AAcnD,gBAAS,oBACZ,aACA,kBAC+C;AA/BnD;AAgCI,QAAM,oBAAoB,MAAM,QAAQ,gBAAgB,IAClD,mBACA,CAAC,gBAAgB;AAAA,EACvB,MAAM,sCACM,kBAmCC,2BAnCD,IAEZ;AAAA;AAAA,IAEI,eAAe,MAAa;AACxB,YAAM,IAAI;AA8Bd,WAAS,MAA8C,oBAAI,IAAI;AAW/D,WAAO,6BAA6B,MAAY;AAC5C,YAAI,UAAU;AACd,0BAAkB,QAAQ,CAAC,aAAa;AACpC,gBAAM,YAAY,CAAC,CAAC,KAAK,cAAc,YAAY,QAAQ,EAAE;AAC7D,gBAAM,gBACF,KAAK,oBAAoB,EAAE,IAAI,QAAQ,KAAK;AAChD,oBAAU,WAAW,kBAAkB;AACvC,eAAK,oBAAoB,EAAE;AAAA,YACvB;AAAA,YACA,CAAC,CAAC,KAAK,cAAc,YAAY,QAAQ,EAAE;AAAA,UAC/C;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;AAAA;AAAA;AAAA,IAKA,IAAW,uBAAgC;AACvC,UAAI,kBAAkB,WAAW,GAAG;AAChC,eACI,KAAK,oBAAoB,EAAE,IAAI,kBAAkB,CAAC,CAAC,KACnD;AAAA,MAER,OAAO;AACH,cAAM,IAAI;AAAA,UACN;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IAGO,uBAAuB,UAA2B;AACrD,UAAI,KAAK,oBAAoB,EAAE,IAAI,QAAQ,GAAG;AAC1C,eAAO,KAAK,oBAAoB,EAAE,IAAI,QAAQ,KAAK;AAAA,MACvD;AACA,YAAM,IAAI;AAAA,QACN,2BAA2B,QAAQ;AAAA,MACvC;AAAA,IACJ;AAAA,EAoBJ;AACA,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-presence.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing 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(`:scope > ${selector}`);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(`:scope > ${selector}`)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n };\n }\n return SlotPresenceObservingElement;\n}\n"],
|
|
5
|
+
"mappings": "aAYA,OAAS,sBAAAA,MAA0B,6CAEnC,MAAMC,EAAuB,OAAO,sBAAsB,EAcnD,gBAAS,oBACZC,EACAC,EAC+C,CA/BnD,IAAAC,EAAAC,EAgCI,MAAMC,EAAoB,MAAM,QAAQH,CAAgB,EAClDA,EACA,CAACA,CAAgB,EACvB,MAAMI,UACMF,EAAAH,EAmCCE,EAAAH,EAnCDI,EAEZ,CAEI,eAAeG,EAAa,CACxB,MAAMA,CAAI,EA8Bd,KAASJ,GAA8C,IAAI,IAW3D,KAAO,2BAA6B,IAAY,CAC5C,IAAIK,EAAU,GACdH,EAAkB,QAASI,GAAa,CACpC,MAAMC,EAAY,CAAC,CAAC,KAAK,cAAc,YAAYD,CAAQ,EAAE,EACvDE,EACF,KAAKX,CAAoB,EAAE,IAAIS,CAAQ,GAAK,GAChDD,EAAUA,GAAWG,IAAkBD,EACvC,KAAKV,CAAoB,EAAE,IACvBS,EACA,CAAC,CAAC,KAAK,cAAc,YAAYA,CAAQ,EAAE,CAC/C,CACJ,CAAC,EACGD,GACA,KAAK,eAAe,KAAK,IAAM,CAC3B,KAAK,cAAc,CACvB,CAAC,CAET,EAxDI,IAAIT,EAAmB,KAAM,CACzB,OAAQ,CACJ,UAAW,GACX,QAAS,EACb,EACA,SAAU,IAAM,CACZ,KAAK,2BAA2B,CACpC,CACJ,CAAC,EAED,KAAK,2BAA2B,CACpC,CAKA,IAAW,sBAAgC,CACvC,GAAIM,EAAkB,SAAW,EAC7B,OACI,KAAKL,CAAoB,EAAE,IAAIK,EAAkB,CAAC,CAAC,GACnD,GAGJ,MAAM,IAAI,MACN,8GACJ,CAER,CAGO,uBAAuBI,EAA2B,CACrD,GAAI,KAAKT,CAAoB,EAAE,IAAIS,CAAQ,EACvC,OAAO,KAAKT,CAAoB,EAAE,IAAIS,CAAQ,GAAK,GAEvD,MAAM,IAAI,MACN,2BAA2BA,CAAQ,2BACvC,CACJ,CAoBJ,CACA,OAAOH,CACX",
|
|
6
6
|
"names": ["MutationController", "slotContentIsPresent", "constructor", "lightDomSelector", "_a", "_b", "lightDomSelectors", "SlotPresenceObservingElement", "args", "changes", "selector", "nextValue", "previousValue"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
import { ReactiveElement } from '@spectrum-web-components/base';
|
|
2
13
|
type Constructor<T = Record<string, unknown>> = {
|
|
3
14
|
new (...args: any[]): T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-text.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { PropertyValues, ReactiveElement } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst assignedNodesList = Symbol('assignedNodes');\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 SlotTextObservingInterface {\n slotHasContent: boolean;\n manageTextObservedSlot(): void;\n}\n\nexport function ObserveSlotText<T extends Constructor<ReactiveElement>>(\n constructor: T,\n slotName?: string,\n excludedSelectors: string[] = []\n): T & Constructor<SlotTextObservingInterface> {\n const notExcluded = (el: HTMLElement) => (selector: string) => {\n return el.matches(selector);\n };\n\n class SlotTextObservingElement\n extends constructor\n implements SlotTextObservingInterface\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 characterData: true,\n subtree: true,\n },\n callback: (mutationsList: Array<MutationRecord>) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'characterData') {\n this.manageTextObservedSlot();\n return;\n }\n }\n },\n });\n }\n\n @property({ type: Boolean, attribute: false })\n public slotHasContent = false;\n\n @queryAssignedNodes({\n slot: slotName,\n flatten: true,\n })\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) return;\n const assignedNodes = [...this[assignedNodesList]].filter(\n (currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n return !excludedSelectors.some(notExcluded(node));\n }\n return node.textContent ? node.textContent.trim() : false;\n }\n );\n this.slotHasContent = assignedNodes.length > 0;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (!this.hasUpdated) {\n const { childNodes } = this;\n const textNodes = [...childNodes].filter((currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n const excluded = excludedSelectors.some(\n notExcluded(node)\n );\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exisit in a targeted slot if there was one supplied.\n slotName\n ? node.getAttribute('slot') === slotName\n : !node.hasAttribute('slot')\n : false;\n }\n return node.textContent ? node.textContent.trim() : false;\n });\n this.slotHasContent = textNodes.length > 0;\n }\n super.update(changedProperties);\n }\n\n protected override firstUpdated(\n changedProperties: PropertyValues\n ): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,0BAA0B;AAEnC,MAAM,oBAAoB,OAAO,eAAe;AAazC,gBAAS,gBACZ,aACA,UACA,oBAA8B,CAAC,GACY;AAnC/C;AAoCI,QAAM,cAAc,CAAC,OAAoB,CAAC,aAAqB;AAC3D,WAAO,GAAG,QAAQ,QAAQ;AAAA,EAC9B;AAAA,EAEA,MAAM,kCACM,kBA8BC,wBA9BD,IAEZ;AAAA;AAAA,IAEI,eAAe,MAAa;AACxB,YAAM,IAAI;AAmBd,WAAO,iBAAiB;AAjBpB,UAAI,mBAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,eAAe;AAAA,UACf,SAAS;AAAA,QACb;AAAA,QACA,UAAU,CAAC,kBAAyC;AAChD,qBAAW,YAAY,eAAe;AAClC,gBAAI,SAAS,SAAS,iBAAiB;AACnC,mBAAK,uBAAuB;AAC5B;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IAWO,yBAA+B;AAClC,UAAI,CAAC,KAAK,iBAAiB,EAAG;AAC9B,YAAM,gBAAgB,CAAC,GAAG,KAAK,iBAAiB,CAAC,EAAE;AAAA,QAC/C,CAAC,gBAAgB;AACb,gBAAM,OAAO;AACb,cAAI,KAAK,SAAS;AACd,mBAAO,CAAC,kBAAkB,KAAK,YAAY,IAAI,CAAC;AAAA,UACpD;AACA,iBAAO,KAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAAA,QACxD;AAAA,MACJ;AACA,WAAK,iBAAiB,cAAc,SAAS;AAAA,IACjD;AAAA,IAEmB,OAAO,mBAAyC;AAC/D,UAAI,CAAC,KAAK,YAAY;AAClB,cAAM,EAAE,WAAW,IAAI;AACvB,cAAM,YAAY,CAAC,GAAG,UAAU,EAAE,OAAO,CAAC,gBAAgB;AACtD,gBAAM,OAAO;AACb,cAAI,KAAK,SAAS;AACd,kBAAM,WAAW,kBAAkB;AAAA,cAC/B,YAAY,IAAI;AAAA,YACpB;AACA,mBAAO,CAAC;AAAA;AAAA;AAAA,cAGF,WACI,KAAK,aAAa,MAAM,MAAM,WAC9B,CAAC,KAAK,aAAa,MAAM;AAAA,gBAC7B;AAAA,UACV;AACA,iBAAO,KAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAAA,QACxD,CAAC;AACD,aAAK,iBAAiB,UAAU,SAAS;AAAA,MAC7C;AACA,YAAM,OAAO,iBAAiB;AAAA,IAClC;AAAA,IAEmB,aACf,mBACI;AACJ,YAAM,aAAa,iBAAiB;AACpC,WAAK,eAAe,KAAK,MAAM;AAC3B,aAAK,uBAAuB;AAAA,MAChC,CAAC;AAAA,IACL;AAAA,EACJ;AAtDW;AAAA,IADN,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,CAAC;AAAA,KAxB3C,yBAyBK;AAME;AAAA,IAJR,mBAAmB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,IACb,CAAC;AAAA,KA9BC,yBA+BO;AAiDb,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-text.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { PropertyValues, ReactiveElement } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst assignedNodesList = Symbol('assignedNodes');\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 SlotTextObservingInterface {\n slotHasContent: boolean;\n manageTextObservedSlot(): void;\n}\n\nexport function ObserveSlotText<T extends Constructor<ReactiveElement>>(\n constructor: T,\n slotName?: string,\n excludedSelectors: string[] = []\n): T & Constructor<SlotTextObservingInterface> {\n const notExcluded = (el: HTMLElement) => (selector: string) => {\n return el.matches(selector);\n };\n\n class SlotTextObservingElement\n extends constructor\n implements SlotTextObservingInterface\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 characterData: true,\n subtree: true,\n },\n callback: (mutationsList: Array<MutationRecord>) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'characterData') {\n this.manageTextObservedSlot();\n return;\n }\n }\n },\n });\n }\n\n @property({ type: Boolean, attribute: false })\n public slotHasContent = false;\n\n @queryAssignedNodes({\n slot: slotName,\n flatten: true,\n })\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) return;\n const assignedNodes = [...this[assignedNodesList]].filter(\n (currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n return !excludedSelectors.some(notExcluded(node));\n }\n return node.textContent ? node.textContent.trim() : false;\n }\n );\n this.slotHasContent = assignedNodes.length > 0;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (!this.hasUpdated) {\n const { childNodes } = this;\n const textNodes = [...childNodes].filter((currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n const excluded = excludedSelectors.some(\n notExcluded(node)\n );\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exisit in a targeted slot if there was one supplied.\n slotName\n ? node.getAttribute('slot') === slotName\n : !node.hasAttribute('slot')\n : false;\n }\n return node.textContent ? node.textContent.trim() : false;\n });\n this.slotHasContent = textNodes.length > 0;\n }\n super.update(changedProperties);\n }\n\n protected override firstUpdated(\n changedProperties: PropertyValues\n ): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],
|
|
5
5
|
"mappings": "qNAYA,OACI,YAAAA,EACA,sBAAAC,MACG,kDACP,OAAS,sBAAAC,MAA0B,6CAEnC,MAAMC,EAAoB,OAAO,eAAe,EAazC,gBAAS,gBACZC,EACAC,EACAC,EAA8B,CAAC,EACY,CAnC/C,IAAAC,EAAAC,EAoCI,MAAMC,EAAeC,GAAqBC,GAC/BD,EAAG,QAAQC,CAAQ,EAG9B,MAAMC,UACMJ,EAAAJ,EA8BCG,EAAAJ,EA9BDK,EAEZ,CAEI,eAAeK,EAAa,CACxB,MAAMA,CAAI,EAmBd,KAAO,eAAiB,GAjBpB,IAAIX,EAAmB,KAAM,CACzB,OAAQ,CACJ,cAAe,GACf,QAAS,EACb,EACA,SAAWY,GAAyC,CAChD,UAAWC,KAAYD,EACnB,GAAIC,EAAS,OAAS,gBAAiB,CACnC,KAAK,uBAAuB,EAC5B,MACJ,CAER,CACJ,CAAC,CACL,CAWO,wBAA+B,CAClC,GAAI,CAAC,KAAKZ,CAAiB,EAAG,OAC9B,MAAMa,EAAgB,CAAC,GAAG,KAAKb,CAAiB,CAAC,EAAE,OAC9Cc,GAAgB,CACb,MAAMC,EAAOD,EACb,OAAIC,EAAK,QACE,CAACZ,EAAkB,KAAKG,EAAYS,CAAI,CAAC,EAE7CA,EAAK,YAAcA,EAAK,YAAY,KAAK,EAAI,EACxD,CACJ,EACA,KAAK,eAAiBF,EAAc,OAAS,CACjD,CAEmB,OAAOG,EAAyC,CAC/D,GAAI,CAAC,KAAK,WAAY,CAClB,KAAM,CAAE,WAAAC,CAAW,EAAI,KACjBC,EAAY,CAAC,GAAGD,CAAU,EAAE,OAAQH,GAAgB,CACtD,MAAMC,EAAOD,EACb,OAAIC,EAAK,QACYZ,EAAkB,KAC/BG,EAAYS,CAAI,CACpB,EAOM,GAHAb,EACIa,EAAK,aAAa,MAAM,IAAMb,EAC9B,CAACa,EAAK,aAAa,MAAM,EAGhCA,EAAK,YAAcA,EAAK,YAAY,KAAK,EAAI,EACxD,CAAC,EACD,KAAK,eAAiBG,EAAU,OAAS,CAC7C,CACA,MAAM,OAAOF,CAAiB,CAClC,CAEmB,aACfA,EACI,CACJ,MAAM,aAAaA,CAAiB,EACpC,KAAK,eAAe,KAAK,IAAM,CAC3B,KAAK,uBAAuB,CAChC,CAAC,CACL,CACJ,CAtDW,OAAAG,EAAA,CADNtB,EAAS,CAAE,KAAM,QAAS,UAAW,EAAM,CAAC,GAxB3CY,EAyBK,8BAMEU,EAAA,CAJRrB,EAAmB,CAChB,KAAMI,EACN,QAAS,EACb,CAAC,GA9BCO,EA+BO,UAAAL,EAAA,GAiDNK,CACX",
|
|
6
6
|
"names": ["property", "queryAssignedNodes", "MutationController", "assignedNodesList", "constructor", "slotName", "excludedSelectors", "_a", "_b", "notExcluded", "el", "selector", "SlotTextObservingElement", "args", "mutationsList", "mutation", "assignedNodes", "currentNode", "node", "changedProperties", "childNodes", "textNodes", "__decorateClass"]
|
|
7
7
|
}
|
package/src/platform.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export declare function isMac(): boolean;
|
|
2
13
|
export declare function isIPhone(): boolean;
|
|
3
14
|
export declare function isIPad(): boolean;
|
package/src/platform.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["platform.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nfunction testUserAgent(re: RegExp): boolean {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator.userAgent)\n : false;\n}\n\nfunction testPlatform(re: RegExp): boolean {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator.platform)\n : false;\n}\n\n/* c8 ignore next 3 */\nexport function isMac(): boolean {\n return testPlatform(/^Mac/);\n}\n\nexport function isIPhone(): boolean {\n return testPlatform(/^iPhone/);\n}\n\nexport function isIPad(): boolean {\n return (\n testPlatform(/^iPad/) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1)\n );\n}\n\nexport function isIOS(): boolean {\n return isIPhone() || isIPad();\n}\n\n/* c8 ignore next 3 */\nexport function isAppleDevice(): boolean {\n return isMac() || isIOS();\n}\n\n/* c8 ignore next 3 */\nexport function isWebKit(): boolean {\n return testUserAgent(/AppleWebKit/) && !isChrome();\n}\n\n/* c8 ignore next 3 */\nexport function isChrome(): boolean {\n return testUserAgent(/Chrome/);\n}\n\nexport function isFirefox(): boolean {\n return testUserAgent(/Firefox/) && !isSeamonkey();\n}\n\nexport function isSeamonkey(): boolean {\n return testUserAgent(/Seamonkey/);\n}\n\nexport function isAndroid(): boolean {\n return testUserAgent(/Android/);\n}\n"],
|
|
5
5
|
"mappings": ";AAYA,SAAS,cAAc,IAAqB;AACxC,SAAO,OAAO,WAAW,eAAe,OAAO,aAAa,OACtD,GAAG,KAAK,OAAO,UAAU,SAAS,IAClC;AACV;AAEA,SAAS,aAAa,IAAqB;AACvC,SAAO,OAAO,WAAW,eAAe,OAAO,aAAa,OACtD,GAAG,KAAK,OAAO,UAAU,QAAQ,IACjC;AACV;AAGO,gBAAS,QAAiB;AAC7B,SAAO,aAAa,MAAM;AAC9B;AAEO,gBAAS,WAAoB;AAChC,SAAO,aAAa,SAAS;AACjC;AAEO,gBAAS,SAAkB;AAC9B,SACI,aAAa,OAAO;AAAA,EAEnB,MAAM,KAAK,UAAU,iBAAiB;AAE/C;AAEO,gBAAS,QAAiB;AAC7B,SAAO,SAAS,KAAK,OAAO;AAChC;AAGO,gBAAS,gBAAyB;AACrC,SAAO,MAAM,KAAK,MAAM;AAC5B;AAGO,gBAAS,WAAoB;AAChC,SAAO,cAAc,aAAa,KAAK,CAAC,SAAS;AACrD;AAGO,gBAAS,WAAoB;AAChC,SAAO,cAAc,QAAQ;AACjC;AAEO,gBAAS,YAAqB;AACjC,SAAO,cAAc,SAAS,KAAK,CAAC,YAAY;AACpD;AAEO,gBAAS,cAAuB;AACnC,SAAO,cAAc,WAAW;AACpC;AAEO,gBAAS,YAAqB;AACjC,SAAO,cAAc,SAAS;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/platform.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["platform.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nfunction testUserAgent(re: RegExp): boolean {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator.userAgent)\n : false;\n}\n\nfunction testPlatform(re: RegExp): boolean {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator.platform)\n : false;\n}\n\n/* c8 ignore next 3 */\nexport function isMac(): boolean {\n return testPlatform(/^Mac/);\n}\n\nexport function isIPhone(): boolean {\n return testPlatform(/^iPhone/);\n}\n\nexport function isIPad(): boolean {\n return (\n testPlatform(/^iPad/) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1)\n );\n}\n\nexport function isIOS(): boolean {\n return isIPhone() || isIPad();\n}\n\n/* c8 ignore next 3 */\nexport function isAppleDevice(): boolean {\n return isMac() || isIOS();\n}\n\n/* c8 ignore next 3 */\nexport function isWebKit(): boolean {\n return testUserAgent(/AppleWebKit/) && !isChrome();\n}\n\n/* c8 ignore next 3 */\nexport function isChrome(): boolean {\n return testUserAgent(/Chrome/);\n}\n\nexport function isFirefox(): boolean {\n return testUserAgent(/Firefox/) && !isSeamonkey();\n}\n\nexport function isSeamonkey(): boolean {\n return testUserAgent(/Seamonkey/);\n}\n\nexport function isAndroid(): boolean {\n return testUserAgent(/Android/);\n}\n"],
|
|
5
5
|
"mappings": "aAYA,SAASA,EAAcC,EAAqB,CACxC,OAAO,OAAO,QAAW,aAAe,OAAO,WAAa,KACtDA,EAAG,KAAK,OAAO,UAAU,SAAS,EAClC,EACV,CAEA,SAASC,EAAaD,EAAqB,CACvC,OAAO,OAAO,QAAW,aAAe,OAAO,WAAa,KACtDA,EAAG,KAAK,OAAO,UAAU,QAAQ,EACjC,EACV,CAGO,gBAAS,OAAiB,CAC7B,OAAOC,EAAa,MAAM,CAC9B,CAEO,gBAAS,UAAoB,CAChC,OAAOA,EAAa,SAAS,CACjC,CAEO,gBAAS,QAAkB,CAC9B,OACIA,EAAa,OAAO,GAEnB,MAAM,GAAK,UAAU,eAAiB,CAE/C,CAEO,gBAAS,OAAiB,CAC7B,OAAO,SAAS,GAAK,OAAO,CAChC,CAGO,gBAAS,eAAyB,CACrC,OAAO,MAAM,GAAK,MAAM,CAC5B,CAGO,gBAAS,UAAoB,CAChC,OAAOF,EAAc,aAAa,GAAK,CAAC,SAAS,CACrD,CAGO,gBAAS,UAAoB,CAChC,OAAOA,EAAc,QAAQ,CACjC,CAEO,gBAAS,WAAqB,CACjC,OAAOA,EAAc,SAAS,GAAK,CAAC,YAAY,CACpD,CAEO,gBAAS,aAAuB,CACnC,OAAOA,EAAc,WAAW,CACpC,CAEO,gBAAS,WAAqB,CACjC,OAAOA,EAAc,SAAS,CAClC",
|
|
6
6
|
"names": ["testUserAgent", "re", "testPlatform"]
|
|
7
7
|
}
|
package/src/random-id.d.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
*/
|
|
1
12
|
export declare function randomID(): string;
|
package/src/random-id.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["random-id.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// This gnarly-looking implementation returns the equivalent of crypto.randomUUID().slice(0, 8).\n// It uses getRandomValues() in order to be compatible with HTTP contexts.\nexport function randomID(): string {\n return Array.from(crypto.getRandomValues(new Uint8Array(4)), (b) =>\n `0${(b & 0xff).toString(16)}`.slice(-2)\n ).join('');\n}\n"],
|
|
5
5
|
"mappings": ";AAcO,gBAAS,WAAmB;AAC/B,SAAO,MAAM;AAAA,IAAK,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC;AAAA,IAAG,CAAC,MAC1D,KAAK,IAAI,KAAM,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE;AAAA,EAC1C,EAAE,KAAK,EAAE;AACb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/random-id.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["random-id.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// This gnarly-looking implementation returns the equivalent of crypto.randomUUID().slice(0, 8).\n// It uses getRandomValues() in order to be compatible with HTTP contexts.\nexport function randomID(): string {\n return Array.from(crypto.getRandomValues(new Uint8Array(4)), (b) =>\n `0${(b & 0xff).toString(16)}`.slice(-2)\n ).join('');\n}\n"],
|
|
5
5
|
"mappings": "aAcO,gBAAS,UAAmB,CAC/B,OAAO,MAAM,KAAK,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC,EAAIA,GAC1D,KAAKA,EAAI,KAAM,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE,CAC1C,EAAE,KAAK,EAAE,CACb",
|
|
6
6
|
"names": ["b"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["reparent-children.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nfunction restoreChildren<T extends Element>(\n placeholderItems: Comment[],\n srcElements: T[],\n cleanupCallbacks: ((el: T) => void)[] = []\n): T[] {\n for (let index = 0; index < srcElements.length; ++index) {\n const srcElement = srcElements[index];\n const placeholderItem = placeholderItems[index];\n const parentElement =\n placeholderItem.parentElement || placeholderItem.getRootNode();\n if (cleanupCallbacks[index]) {\n cleanupCallbacks[index](srcElement);\n }\n if (parentElement && parentElement !== placeholderItem) {\n parentElement.replaceChild(srcElement, placeholderItem);\n }\n delete placeholderItems[index];\n }\n return srcElements;\n}\n\nexport const reparentChildren = <T extends Element>(\n srcElements: T[],\n destination: Element,\n {\n position,\n prepareCallback,\n }: {\n position: InsertPosition;\n prepareCallback?: (el: T) => ((el: T) => void) | void;\n } = { position: 'beforeend' }\n): (() => T[]) => {\n let { length } = srcElements;\n if (length === 0) {\n return () => srcElements;\n }\n\n let step = 1;\n let index = 0;\n\n if (position === 'afterbegin' || position === 'afterend') {\n step = -1;\n index = length - 1;\n }\n\n const placeholderItems = new Array<Comment>(length);\n const cleanupCallbacks = new Array<(el: T) => void>(length);\n const placeholderTemplate: Comment = document.createComment(\n 'placeholder for reparented element'\n );\n\n do {\n const srcElement = srcElements[index];\n if (prepareCallback) {\n cleanupCallbacks[index] = prepareCallback(srcElement) as (\n el: T\n ) => void;\n }\n placeholderItems[index] = placeholderTemplate.cloneNode() as Comment;\n\n const parentElement =\n srcElement.parentElement || srcElement.getRootNode();\n if (parentElement && parentElement !== srcElement) {\n parentElement.replaceChild(placeholderItems[index], srcElement);\n }\n destination.insertAdjacentElement(position, srcElement);\n\n index += step;\n } while (--length > 0);\n\n return function (): T[] {\n return restoreChildren<T>(\n placeholderItems,\n srcElements,\n cleanupCallbacks\n );\n };\n};\n"],
|
|
5
5
|
"mappings": ";AAWA,SAAS,gBACL,kBACA,aACA,mBAAwC,CAAC,GACtC;AACH,WAAS,QAAQ,GAAG,QAAQ,YAAY,QAAQ,EAAE,OAAO;AACrD,UAAM,aAAa,YAAY,KAAK;AACpC,UAAM,kBAAkB,iBAAiB,KAAK;AAC9C,UAAM,gBACF,gBAAgB,iBAAiB,gBAAgB,YAAY;AACjE,QAAI,iBAAiB,KAAK,GAAG;AACzB,uBAAiB,KAAK,EAAE,UAAU;AAAA,IACtC;AACA,QAAI,iBAAiB,kBAAkB,iBAAiB;AACpD,oBAAc,aAAa,YAAY,eAAe;AAAA,IAC1D;AACA,WAAO,iBAAiB,KAAK;AAAA,EACjC;AACA,SAAO;AACX;AAEO,aAAM,mBAAmB,CAC5B,aACA,aACA;AAAA,EACI;AAAA,EACA;AACJ,IAGI,EAAE,UAAU,YAAY,MACd;AACd,MAAI,EAAE,OAAO,IAAI;AACjB,MAAI,WAAW,GAAG;AACd,WAAO,MAAM;AAAA,EACjB;AAEA,MAAI,OAAO;AACX,MAAI,QAAQ;AAEZ,MAAI,aAAa,gBAAgB,aAAa,YAAY;AACtD,WAAO;AACP,YAAQ,SAAS;AAAA,EACrB;AAEA,QAAM,mBAAmB,IAAI,MAAe,MAAM;AAClD,QAAM,mBAAmB,IAAI,MAAuB,MAAM;AAC1D,QAAM,sBAA+B,SAAS;AAAA,IAC1C;AAAA,EACJ;AAEA,KAAG;AACC,UAAM,aAAa,YAAY,KAAK;AACpC,QAAI,iBAAiB;AACjB,uBAAiB,KAAK,IAAI,gBAAgB,UAAU;AAAA,IAGxD;AACA,qBAAiB,KAAK,IAAI,oBAAoB,UAAU;AAExD,UAAM,gBACF,WAAW,iBAAiB,WAAW,YAAY;AACvD,QAAI,iBAAiB,kBAAkB,YAAY;AAC/C,oBAAc,aAAa,iBAAiB,KAAK,GAAG,UAAU;AAAA,IAClE;AACA,gBAAY,sBAAsB,UAAU,UAAU;AAEtD,aAAS;AAAA,EACb,SAAS,EAAE,SAAS;AAEpB,SAAO,WAAiB;AACpB,WAAO;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["reparent-children.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nfunction restoreChildren<T extends Element>(\n placeholderItems: Comment[],\n srcElements: T[],\n cleanupCallbacks: ((el: T) => void)[] = []\n): T[] {\n for (let index = 0; index < srcElements.length; ++index) {\n const srcElement = srcElements[index];\n const placeholderItem = placeholderItems[index];\n const parentElement =\n placeholderItem.parentElement || placeholderItem.getRootNode();\n if (cleanupCallbacks[index]) {\n cleanupCallbacks[index](srcElement);\n }\n if (parentElement && parentElement !== placeholderItem) {\n parentElement.replaceChild(srcElement, placeholderItem);\n }\n delete placeholderItems[index];\n }\n return srcElements;\n}\n\nexport const reparentChildren = <T extends Element>(\n srcElements: T[],\n destination: Element,\n {\n position,\n prepareCallback,\n }: {\n position: InsertPosition;\n prepareCallback?: (el: T) => ((el: T) => void) | void;\n } = { position: 'beforeend' }\n): (() => T[]) => {\n let { length } = srcElements;\n if (length === 0) {\n return () => srcElements;\n }\n\n let step = 1;\n let index = 0;\n\n if (position === 'afterbegin' || position === 'afterend') {\n step = -1;\n index = length - 1;\n }\n\n const placeholderItems = new Array<Comment>(length);\n const cleanupCallbacks = new Array<(el: T) => void>(length);\n const placeholderTemplate: Comment = document.createComment(\n 'placeholder for reparented element'\n );\n\n do {\n const srcElement = srcElements[index];\n if (prepareCallback) {\n cleanupCallbacks[index] = prepareCallback(srcElement) as (\n el: T\n ) => void;\n }\n placeholderItems[index] = placeholderTemplate.cloneNode() as Comment;\n\n const parentElement =\n srcElement.parentElement || srcElement.getRootNode();\n if (parentElement && parentElement !== srcElement) {\n parentElement.replaceChild(placeholderItems[index], srcElement);\n }\n destination.insertAdjacentElement(position, srcElement);\n\n index += step;\n } while (--length > 0);\n\n return function (): T[] {\n return restoreChildren<T>(\n placeholderItems,\n srcElements,\n cleanupCallbacks\n );\n };\n};\n"],
|
|
5
5
|
"mappings": "aAWA,SAASA,EACLC,EACAC,EACAC,EAAwC,CAAC,EACtC,CACH,QAASC,EAAQ,EAAGA,EAAQF,EAAY,OAAQ,EAAEE,EAAO,CACrD,MAAMC,EAAaH,EAAYE,CAAK,EAC9BE,EAAkBL,EAAiBG,CAAK,EACxCG,EACFD,EAAgB,eAAiBA,EAAgB,YAAY,EAC7DH,EAAiBC,CAAK,GACtBD,EAAiBC,CAAK,EAAEC,CAAU,EAElCE,GAAiBA,IAAkBD,GACnCC,EAAc,aAAaF,EAAYC,CAAe,EAE1D,OAAOL,EAAiBG,CAAK,CACjC,CACA,OAAOF,CACX,CAEO,aAAM,iBAAmB,CAC5BA,EACAM,EACA,CACI,SAAAC,EACA,gBAAAC,CACJ,EAGI,CAAE,SAAU,WAAY,IACd,CACd,GAAI,CAAE,OAAAC,CAAO,EAAIT,EACjB,GAAIS,IAAW,EACX,MAAO,IAAMT,EAGjB,IAAIU,EAAO,EACPR,EAAQ,GAERK,IAAa,cAAgBA,IAAa,cAC1CG,EAAO,GACPR,EAAQO,EAAS,GAGrB,MAAMV,EAAmB,IAAI,MAAeU,CAAM,EAC5CR,EAAmB,IAAI,MAAuBQ,CAAM,EACpDE,EAA+B,SAAS,cAC1C,oCACJ,EAEA,EAAG,CACC,MAAMR,EAAaH,EAAYE,CAAK,EAChCM,IACAP,EAAiBC,CAAK,EAAIM,EAAgBL,CAAU,GAIxDJ,EAAiBG,CAAK,EAAIS,EAAoB,UAAU,EAExD,MAAMN,EACFF,EAAW,eAAiBA,EAAW,YAAY,EACnDE,GAAiBA,IAAkBF,GACnCE,EAAc,aAAaN,EAAiBG,CAAK,EAAGC,CAAU,EAElEG,EAAY,sBAAsBC,EAAUJ,CAAU,EAEtDD,GAASQ,CACb,OAAS,EAAED,EAAS,GAEpB,OAAO,UAAiB,CACpB,OAAOX,EACHC,EACAC,EACAC,CACJ,CACJ,CACJ",
|
|
6
6
|
"names": ["restoreChildren", "placeholderItems", "srcElements", "cleanupCallbacks", "index", "srcElement", "placeholderItem", "parentElement", "destination", "position", "prepareCallback", "length", "step", "placeholderTemplate"]
|
|
7
7
|
}
|