@spectrum-web-components/shared 0.0.0-20241209155954

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +132 -0
  2. package/package.json +112 -0
  3. package/src/first-focusable-in.d.ts +3 -0
  4. package/src/first-focusable-in.dev.js +15 -0
  5. package/src/first-focusable-in.dev.js.map +7 -0
  6. package/src/first-focusable-in.js +2 -0
  7. package/src/first-focusable-in.js.map +7 -0
  8. package/src/focus-visible.d.ts +29 -0
  9. package/src/focus-visible.dev.js +77 -0
  10. package/src/focus-visible.dev.js.map +7 -0
  11. package/src/focus-visible.js +2 -0
  12. package/src/focus-visible.js.map +7 -0
  13. package/src/focusable-selectors.d.ts +2 -0
  14. package/src/focusable-selectors.dev.js +15 -0
  15. package/src/focusable-selectors.dev.js.map +7 -0
  16. package/src/focusable-selectors.js +2 -0
  17. package/src/focusable-selectors.js.map +7 -0
  18. package/src/focusable.d.ts +56 -0
  19. package/src/focusable.dev.js +245 -0
  20. package/src/focusable.dev.js.map +7 -0
  21. package/src/focusable.js +2 -0
  22. package/src/focusable.js.map +7 -0
  23. package/src/get-active-element.d.ts +1 -0
  24. package/src/get-active-element.dev.js +5 -0
  25. package/src/get-active-element.dev.js.map +7 -0
  26. package/src/get-active-element.js +2 -0
  27. package/src/get-active-element.js.map +7 -0
  28. package/src/get-deep-element-from-point.d.ts +1 -0
  29. package/src/get-deep-element-from-point.dev.js +13 -0
  30. package/src/get-deep-element-from-point.dev.js.map +7 -0
  31. package/src/get-deep-element-from-point.js +2 -0
  32. package/src/get-deep-element-from-point.js.map +7 -0
  33. package/src/get-label-from-slot.d.ts +1 -0
  34. package/src/get-label-from-slot.dev.js +17 -0
  35. package/src/get-label-from-slot.dev.js.map +7 -0
  36. package/src/get-label-from-slot.js +2 -0
  37. package/src/get-label-from-slot.js.map +7 -0
  38. package/src/index.d.ts +12 -0
  39. package/src/index.dev.js +14 -0
  40. package/src/index.dev.js.map +7 -0
  41. package/src/index.js +2 -0
  42. package/src/index.js.map +7 -0
  43. package/src/like-anchor.d.ts +23 -0
  44. package/src/like-anchor.dev.js +63 -0
  45. package/src/like-anchor.dev.js.map +7 -0
  46. package/src/like-anchor.js +14 -0
  47. package/src/like-anchor.js.map +7 -0
  48. package/src/observe-slot-presence.d.ts +12 -0
  49. package/src/observe-slot-presence.dev.js +63 -0
  50. package/src/observe-slot-presence.dev.js.map +7 -0
  51. package/src/observe-slot-presence.js +2 -0
  52. package/src/observe-slot-presence.js.map +7 -0
  53. package/src/observe-slot-text.d.ts +11 -0
  54. package/src/observe-slot-text.dev.js +95 -0
  55. package/src/observe-slot-text.dev.js.map +7 -0
  56. package/src/observe-slot-text.js +2 -0
  57. package/src/observe-slot-text.js.map +7 -0
  58. package/src/platform.d.ts +10 -0
  59. package/src/platform.dev.js +39 -0
  60. package/src/platform.dev.js.map +7 -0
  61. package/src/platform.js +2 -0
  62. package/src/platform.js.map +7 -0
  63. package/src/random-id.d.ts +1 -0
  64. package/src/random-id.dev.js +8 -0
  65. package/src/random-id.dev.js.map +7 -0
  66. package/src/random-id.js +2 -0
  67. package/src/random-id.js.map +7 -0
  68. package/src/reparent-children.d.ts +4 -0
  69. package/src/reparent-children.dev.js +57 -0
  70. package/src/reparent-children.dev.js.map +7 -0
  71. package/src/reparent-children.js +2 -0
  72. package/src/reparent-children.js.map +7 -0
@@ -0,0 +1,14 @@
1
+ "use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var n=(s,r,p,i)=>{for(var t=i>1?void 0:i?f(r,p):r,a=s.length-1,l;a>=0;a--)(l=s[a])&&(t=(i?l(r,p,t):l(t))||t);return i&&t&&u(r,p,t),t};import{html as c}from"@spectrum-web-components/base";import{property as o}from"@spectrum-web-components/base/src/decorators.js";import{ifDefined as e}from"@spectrum-web-components/base/src/directives.js";export function LikeAnchor(s){class r extends s{renderAnchor({id:i,className:t,ariaHidden:a,labelledby:l,tabindex:d,anchorContent:g=c`<slot></slot>`}){return c`<a
2
+ id=${i}
3
+ class=${e(t)}
4
+ href=${e(this.href)}
5
+ download=${e(this.download)}
6
+ target=${e(this.target)}
7
+ aria-label=${e(this.label)}
8
+ aria-labelledby=${e(l)}
9
+ aria-hidden=${e(a?"true":void 0)}
10
+ tabindex=${e(d)}
11
+ referrerpolicy=${e(this.referrerpolicy)}
12
+ rel=${e(this.rel)}
13
+ >${g}</a>`}}return n([o()],r.prototype,"download",2),n([o()],r.prototype,"label",2),n([o()],r.prototype,"href",2),n([o()],r.prototype,"target",2),n([o()],r.prototype,"referrerpolicy",2),n([o()],r.prototype,"rel",2),r}
14
+ //# sourceMappingURL=like-anchor.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["like-anchor.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport {\n html,\n ReactiveElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\ntype RenderAnchorOptions = {\n id: string;\n className?: string;\n ariaHidden?: boolean;\n anchorContent?: TemplateResult | TemplateResult[];\n labelledby?: string;\n tabindex?: -1 | 0;\n};\n\nexport interface LikeAnchorInterface {\n download?: string;\n label?: string;\n href?: string;\n rel?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n renderAnchor(options: RenderAnchorOptions): TemplateResult;\n}\n\nexport function LikeAnchor<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<LikeAnchorInterface> {\n class LikeAnchorElement extends constructor {\n /**\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 &lt;iframe&gt;).\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
+ "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
+ "names": ["html", "property", "ifDefined", "constructor", "LikeAnchorElement", "id", "className", "ariaHidden", "labelledby", "tabindex", "anchorContent", "__decorateClass"]
7
+ }
@@ -0,0 +1,12 @@
1
+ import { ReactiveElement } from '@spectrum-web-components/base';
2
+ type Constructor<T = Record<string, unknown>> = {
3
+ new (...args: any[]): T;
4
+ prototype: T;
5
+ };
6
+ export interface SlotPresenceObservingInterface {
7
+ slotContentIsPresent: boolean;
8
+ getSlotContentPresence(selector: string): boolean;
9
+ managePresenceObservedSlot(): void;
10
+ }
11
+ export declare function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(constructor: T, lightDomSelector: string | string[]): T & Constructor<SlotPresenceObservingInterface>;
12
+ export {};
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ import { MutationController } from "@lit-labs/observers/mutation-controller.js";
3
+ const slotContentIsPresent = Symbol("slotContentIsPresent");
4
+ export function ObserveSlotPresence(constructor, lightDomSelector) {
5
+ var _a, _b;
6
+ const lightDomSelectors = Array.isArray(lightDomSelector) ? lightDomSelector : [lightDomSelector];
7
+ class SlotPresenceObservingElement extends (_b = constructor, _a = slotContentIsPresent, _b) {
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ constructor(...args) {
10
+ super(args);
11
+ this[_a] = /* @__PURE__ */ new Map();
12
+ this.managePresenceObservedSlot = () => {
13
+ let changes = false;
14
+ lightDomSelectors.forEach((selector) => {
15
+ const nextValue = !!this.querySelector(`:scope > ${selector}`);
16
+ const previousValue = this[slotContentIsPresent].get(selector) || false;
17
+ changes = changes || previousValue !== nextValue;
18
+ this[slotContentIsPresent].set(
19
+ selector,
20
+ !!this.querySelector(`:scope > ${selector}`)
21
+ );
22
+ });
23
+ if (changes) {
24
+ this.updateComplete.then(() => {
25
+ this.requestUpdate();
26
+ });
27
+ }
28
+ };
29
+ new MutationController(this, {
30
+ config: {
31
+ childList: true,
32
+ subtree: true
33
+ },
34
+ callback: () => {
35
+ this.managePresenceObservedSlot();
36
+ }
37
+ });
38
+ this.managePresenceObservedSlot();
39
+ }
40
+ /**
41
+ * @private
42
+ */
43
+ get slotContentIsPresent() {
44
+ if (lightDomSelectors.length === 1) {
45
+ return this[slotContentIsPresent].get(lightDomSelectors[0]) || false;
46
+ } else {
47
+ throw new Error(
48
+ "Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead."
49
+ );
50
+ }
51
+ }
52
+ getSlotContentPresence(selector) {
53
+ if (this[slotContentIsPresent].has(selector)) {
54
+ return this[slotContentIsPresent].get(selector) || false;
55
+ }
56
+ throw new Error(
57
+ `The provided selector \`${selector}\` is not being observed.`
58
+ );
59
+ }
60
+ }
61
+ return SlotPresenceObservingElement;
62
+ }
63
+ //# sourceMappingURL=observe-slot-presence.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["observe-slot-presence.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { ReactiveElement } from '@spectrum-web-components/base';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`: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": ";AAWA,SAAS,0BAA0B;AAEnC,MAAM,uBAAuB,OAAO,sBAAsB;AAcnD,gBAAS,oBACZ,aACA,kBAC+C;AA9BnD;AA+BI,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
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";import{MutationController as u}from"@lit-labs/observers/mutation-controller.js";const t=Symbol("slotContentIsPresent");export function ObserveSlotPresence(l,s){var o,i;const r=Array.isArray(s)?s:[s];class a extends(i=l,o=t,i){constructor(...e){super(e);this[o]=new Map;this.managePresenceObservedSlot=()=>{let e=!1;r.forEach(n=>{const c=!!this.querySelector(`:scope > ${n}`),g=this[t].get(n)||!1;e=e||g!==c,this[t].set(n,!!this.querySelector(`:scope > ${n}`))}),e&&this.updateComplete.then(()=>{this.requestUpdate()})};new u(this,{config:{childList:!0,subtree:!0},callback:()=>{this.managePresenceObservedSlot()}}),this.managePresenceObservedSlot()}get slotContentIsPresent(){if(r.length===1)return this[t].get(r[0])||!1;throw new Error("Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.")}getSlotContentPresence(e){if(this[t].has(e))return this[t].get(e)||!1;throw new Error(`The provided selector \`${e}\` is not being observed.`)}}return a}
2
+ //# sourceMappingURL=observe-slot-presence.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["observe-slot-presence.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { ReactiveElement } from '@spectrum-web-components/base';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`: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": "aAWA,OAAS,sBAAAA,MAA0B,6CAEnC,MAAMC,EAAuB,OAAO,sBAAsB,EAcnD,gBAAS,oBACZC,EACAC,EAC+C,CA9BnD,IAAAC,EAAAC,EA+BI,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
+ "names": ["MutationController", "slotContentIsPresent", "constructor", "lightDomSelector", "_a", "_b", "lightDomSelectors", "SlotPresenceObservingElement", "args", "changes", "selector", "nextValue", "previousValue"]
7
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactiveElement } from '@spectrum-web-components/base';
2
+ type Constructor<T = Record<string, unknown>> = {
3
+ new (...args: any[]): T;
4
+ prototype: T;
5
+ };
6
+ export interface SlotTextObservingInterface {
7
+ slotHasContent: boolean;
8
+ manageTextObservedSlot(): void;
9
+ }
10
+ export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string, excludedSelectors?: string[]): T & Constructor<SlotTextObservingInterface>;
11
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __decorateClass = (decorators, target, key, kind) => {
5
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
+ if (decorator = decorators[i])
8
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ property,
14
+ queryAssignedNodes
15
+ } from "@spectrum-web-components/base/src/decorators.js";
16
+ import { MutationController } from "@lit-labs/observers/mutation-controller.js";
17
+ const assignedNodesList = Symbol("assignedNodes");
18
+ export function ObserveSlotText(constructor, slotName, excludedSelectors = []) {
19
+ var _a, _b;
20
+ const notExcluded = (el) => (selector) => {
21
+ return el.matches(selector);
22
+ };
23
+ class SlotTextObservingElement extends (_b = constructor, _a = assignedNodesList, _b) {
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ constructor(...args) {
26
+ super(args);
27
+ this.slotHasContent = false;
28
+ new MutationController(this, {
29
+ config: {
30
+ characterData: true,
31
+ subtree: true
32
+ },
33
+ callback: (mutationsList) => {
34
+ for (const mutation of mutationsList) {
35
+ if (mutation.type === "characterData") {
36
+ this.manageTextObservedSlot();
37
+ return;
38
+ }
39
+ }
40
+ }
41
+ });
42
+ }
43
+ manageTextObservedSlot() {
44
+ if (!this[assignedNodesList]) return;
45
+ const assignedNodes = [...this[assignedNodesList]].filter(
46
+ (currentNode) => {
47
+ const node = currentNode;
48
+ if (node.tagName) {
49
+ return !excludedSelectors.some(notExcluded(node));
50
+ }
51
+ return node.textContent ? node.textContent.trim() : false;
52
+ }
53
+ );
54
+ this.slotHasContent = assignedNodes.length > 0;
55
+ }
56
+ update(changedProperties) {
57
+ if (!this.hasUpdated) {
58
+ const { childNodes } = this;
59
+ const textNodes = [...childNodes].filter((currentNode) => {
60
+ const node = currentNode;
61
+ if (node.tagName) {
62
+ const excluded = excludedSelectors.some(
63
+ notExcluded(node)
64
+ );
65
+ return !excluded ? (
66
+ // This pass happens at element upgrade and before slot rendering.
67
+ // Confirm it would exisit in a targeted slot if there was one supplied.
68
+ slotName ? node.getAttribute("slot") === slotName : !node.hasAttribute("slot")
69
+ ) : false;
70
+ }
71
+ return node.textContent ? node.textContent.trim() : false;
72
+ });
73
+ this.slotHasContent = textNodes.length > 0;
74
+ }
75
+ super.update(changedProperties);
76
+ }
77
+ firstUpdated(changedProperties) {
78
+ super.firstUpdated(changedProperties);
79
+ this.updateComplete.then(() => {
80
+ this.manageTextObservedSlot();
81
+ });
82
+ }
83
+ }
84
+ __decorateClass([
85
+ property({ type: Boolean, attribute: false })
86
+ ], SlotTextObservingElement.prototype, "slotHasContent", 2);
87
+ __decorateClass([
88
+ queryAssignedNodes({
89
+ slot: slotName,
90
+ flatten: true
91
+ })
92
+ ], SlotTextObservingElement.prototype, _a, 2);
93
+ return SlotTextObservingElement;
94
+ }
95
+ //# sourceMappingURL=observe-slot-text.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["observe-slot-text.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, 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
+ "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
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var h=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var u=(c,e,s,o)=>{for(var t=o>1?void 0:o?x(e,s):e,a=c.length-1,i;a>=0;a--)(i=c[a])&&(t=(o?i(e,s,t):i(t))||t);return o&&t&&h(e,s,t),t};import{property as T,queryAssignedNodes as b}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as v}from"@lit-labs/observers/mutation-controller.js";const p=Symbol("assignedNodes");export function ObserveSlotText(c,e,s=[]){var a,i;const o=f=>m=>f.matches(m);class t extends(i=c,a=p,i){constructor(...n){super(n);this.slotHasContent=!1;new v(this,{config:{characterData:!0,subtree:!0},callback:d=>{for(const r of d)if(r.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[p])return;const n=[...this[p]].filter(d=>{const r=d;return r.tagName?!s.some(o(r)):r.textContent?r.textContent.trim():!1});this.slotHasContent=n.length>0}update(n){if(!this.hasUpdated){const{childNodes:d}=this,r=[...d].filter(g=>{const l=g;return l.tagName?s.some(o(l))?!1:e?l.getAttribute("slot")===e:!l.hasAttribute("slot"):l.textContent?l.textContent.trim():!1});this.slotHasContent=r.length>0}super.update(n)}firstUpdated(n){super.firstUpdated(n),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return u([T({type:Boolean,attribute:!1})],t.prototype,"slotHasContent",2),u([b({slot:e,flatten:!0})],t.prototype,a,2),t}
2
+ //# sourceMappingURL=observe-slot-text.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["observe-slot-text.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, 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
+ "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
+ "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
+ }
@@ -0,0 +1,10 @@
1
+ export declare function isMac(): boolean;
2
+ export declare function isIPhone(): boolean;
3
+ export declare function isIPad(): boolean;
4
+ export declare function isIOS(): boolean;
5
+ export declare function isAppleDevice(): boolean;
6
+ export declare function isWebKit(): boolean;
7
+ export declare function isChrome(): boolean;
8
+ export declare function isFirefox(): boolean;
9
+ export declare function isSeamonkey(): boolean;
10
+ export declare function isAndroid(): boolean;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ function testUserAgent(re) {
3
+ return typeof window !== "undefined" && window.navigator != null ? re.test(window.navigator.userAgent) : false;
4
+ }
5
+ function testPlatform(re) {
6
+ return typeof window !== "undefined" && window.navigator != null ? re.test(window.navigator.platform) : false;
7
+ }
8
+ export function isMac() {
9
+ return testPlatform(/^Mac/);
10
+ }
11
+ export function isIPhone() {
12
+ return testPlatform(/^iPhone/);
13
+ }
14
+ export function isIPad() {
15
+ return testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
16
+ isMac() && navigator.maxTouchPoints > 1;
17
+ }
18
+ export function isIOS() {
19
+ return isIPhone() || isIPad();
20
+ }
21
+ export function isAppleDevice() {
22
+ return isMac() || isIOS();
23
+ }
24
+ export function isWebKit() {
25
+ return testUserAgent(/AppleWebKit/) && !isChrome();
26
+ }
27
+ export function isChrome() {
28
+ return testUserAgent(/Chrome/);
29
+ }
30
+ export function isFirefox() {
31
+ return testUserAgent(/Firefox/) && !isSeamonkey();
32
+ }
33
+ export function isSeamonkey() {
34
+ return testUserAgent(/Seamonkey/);
35
+ }
36
+ export function isAndroid() {
37
+ return testUserAgent(/Android/);
38
+ }
39
+ //# sourceMappingURL=platform.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["platform.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\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
+ "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
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";function n(o){return typeof window!="undefined"&&window.navigator!=null?o.test(window.navigator.userAgent):!1}function e(o){return typeof window!="undefined"&&window.navigator!=null?o.test(window.navigator.platform):!1}export function isMac(){return e(/^Mac/)}export function isIPhone(){return e(/^iPhone/)}export function isIPad(){return e(/^iPad/)||isMac()&&navigator.maxTouchPoints>1}export function isIOS(){return isIPhone()||isIPad()}export function isAppleDevice(){return isMac()||isIOS()}export function isWebKit(){return n(/AppleWebKit/)&&!isChrome()}export function isChrome(){return n(/Chrome/)}export function isFirefox(){return n(/Firefox/)&&!isSeamonkey()}export function isSeamonkey(){return n(/Seamonkey/)}export function isAndroid(){return n(/Android/)}
2
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["platform.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\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
+ "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
+ "names": ["testUserAgent", "re", "testPlatform"]
7
+ }
@@ -0,0 +1 @@
1
+ export declare function randomID(): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ export function randomID() {
3
+ return Array.from(
4
+ crypto.getRandomValues(new Uint8Array(4)),
5
+ (b) => `0${(b & 255).toString(16)}`.slice(-2)
6
+ ).join("");
7
+ }
8
+ //# sourceMappingURL=random-id.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["random-id.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\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
+ "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
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export function randomID(){return Array.from(crypto.getRandomValues(new Uint8Array(4)),r=>`0${(r&255).toString(16)}`.slice(-2)).join("")}
2
+ //# sourceMappingURL=random-id.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["random-id.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\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
+ "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
+ "names": ["b"]
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare const reparentChildren: <T extends Element>(srcElements: T[], destination: Element, { position, prepareCallback, }?: {
2
+ position: InsertPosition;
3
+ prepareCallback?: ((el: T) => void | ((el: T) => void)) | undefined;
4
+ }) => () => T[];
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ function restoreChildren(placeholderItems, srcElements, cleanupCallbacks = []) {
3
+ for (let index = 0; index < srcElements.length; ++index) {
4
+ const srcElement = srcElements[index];
5
+ const placeholderItem = placeholderItems[index];
6
+ const parentElement = placeholderItem.parentElement || placeholderItem.getRootNode();
7
+ if (cleanupCallbacks[index]) {
8
+ cleanupCallbacks[index](srcElement);
9
+ }
10
+ if (parentElement && parentElement !== placeholderItem) {
11
+ parentElement.replaceChild(srcElement, placeholderItem);
12
+ }
13
+ delete placeholderItems[index];
14
+ }
15
+ return srcElements;
16
+ }
17
+ export const reparentChildren = (srcElements, destination, {
18
+ position,
19
+ prepareCallback
20
+ } = { position: "beforeend" }) => {
21
+ let { length } = srcElements;
22
+ if (length === 0) {
23
+ return () => srcElements;
24
+ }
25
+ let step = 1;
26
+ let index = 0;
27
+ if (position === "afterbegin" || position === "afterend") {
28
+ step = -1;
29
+ index = length - 1;
30
+ }
31
+ const placeholderItems = new Array(length);
32
+ const cleanupCallbacks = new Array(length);
33
+ const placeholderTemplate = document.createComment(
34
+ "placeholder for reparented element"
35
+ );
36
+ do {
37
+ const srcElement = srcElements[index];
38
+ if (prepareCallback) {
39
+ cleanupCallbacks[index] = prepareCallback(srcElement);
40
+ }
41
+ placeholderItems[index] = placeholderTemplate.cloneNode();
42
+ const parentElement = srcElement.parentElement || srcElement.getRootNode();
43
+ if (parentElement && parentElement !== srcElement) {
44
+ parentElement.replaceChild(placeholderItems[index], srcElement);
45
+ }
46
+ destination.insertAdjacentElement(position, srcElement);
47
+ index += step;
48
+ } while (--length > 0);
49
+ return function() {
50
+ return restoreChildren(
51
+ placeholderItems,
52
+ srcElements,
53
+ cleanupCallbacks
54
+ );
55
+ };
56
+ };
57
+ //# sourceMappingURL=reparent-children.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["reparent-children.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*/\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
+ "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
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";function T(o,i,l=[]){for(let e=0;e<i.length;++e){const n=i[e],r=o[e],t=r.parentElement||r.getRootNode();l[e]&&l[e](n),t&&t!==r&&t.replaceChild(n,r),delete o[e]}return i}export const reparentChildren=(o,i,{position:l,prepareCallback:e}={position:"beforeend"})=>{let{length:n}=o;if(n===0)return()=>o;let r=1,t=0;(l==="afterbegin"||l==="afterend")&&(r=-1,t=n-1);const a=new Array(n),c=new Array(n),p=document.createComment("placeholder for reparented element");do{const d=o[t];e&&(c[t]=e(d)),a[t]=p.cloneNode();const m=d.parentElement||d.getRootNode();m&&m!==d&&m.replaceChild(a[t],d),i.insertAdjacentElement(l,d),t+=r}while(--n>0);return function(){return T(a,o,c)}};
2
+ //# sourceMappingURL=reparent-children.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["reparent-children.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*/\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
+ "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
+ "names": ["restoreChildren", "placeholderItems", "srcElements", "cleanupCallbacks", "index", "srcElement", "placeholderItem", "parentElement", "destination", "position", "prepareCallback", "length", "step", "placeholderTemplate"]
7
+ }