@spectrum-web-components/shared 1.1.0 → 1.1.1

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 (81) hide show
  1. package/package.json +3 -3
  2. package/src/first-focusable-in.d.ts +3 -0
  3. package/src/first-focusable-in.dev.js +15 -0
  4. package/src/first-focusable-in.dev.js.map +7 -0
  5. package/src/first-focusable-in.js +2 -0
  6. package/src/first-focusable-in.js.map +7 -0
  7. package/src/focus-visible.d.ts +29 -0
  8. package/src/focus-visible.dev.js +77 -0
  9. package/src/focus-visible.dev.js.map +7 -0
  10. package/src/focus-visible.js +2 -0
  11. package/src/focus-visible.js.map +7 -0
  12. package/src/focusable-selectors.d.ts +2 -0
  13. package/src/focusable-selectors.dev.js +15 -0
  14. package/src/focusable-selectors.dev.js.map +7 -0
  15. package/src/focusable-selectors.js +2 -0
  16. package/src/focusable-selectors.js.map +7 -0
  17. package/src/focusable.d.ts +56 -0
  18. package/src/focusable.dev.js +245 -0
  19. package/src/focusable.dev.js.map +7 -0
  20. package/src/focusable.js +2 -0
  21. package/src/focusable.js.map +7 -0
  22. package/src/get-active-element.d.ts +1 -0
  23. package/src/get-active-element.dev.js +5 -0
  24. package/src/get-active-element.dev.js.map +7 -0
  25. package/src/get-active-element.js +2 -0
  26. package/src/get-active-element.js.map +7 -0
  27. package/src/get-deep-element-from-point.d.ts +1 -0
  28. package/src/get-deep-element-from-point.dev.js +13 -0
  29. package/src/get-deep-element-from-point.dev.js.map +7 -0
  30. package/src/get-deep-element-from-point.js +2 -0
  31. package/src/get-deep-element-from-point.js.map +7 -0
  32. package/src/get-label-from-slot.d.ts +1 -0
  33. package/src/get-label-from-slot.dev.js +17 -0
  34. package/src/get-label-from-slot.dev.js.map +7 -0
  35. package/src/get-label-from-slot.js +2 -0
  36. package/src/get-label-from-slot.js.map +7 -0
  37. package/src/index.d.ts +12 -0
  38. package/src/index.dev.js +14 -0
  39. package/src/index.dev.js.map +7 -0
  40. package/src/index.js +2 -0
  41. package/src/index.js.map +7 -0
  42. package/src/like-anchor.d.ts +23 -0
  43. package/src/like-anchor.dev.js +63 -0
  44. package/src/like-anchor.dev.js.map +7 -0
  45. package/src/like-anchor.js +14 -0
  46. package/src/like-anchor.js.map +7 -0
  47. package/src/observe-slot-presence.d.ts +12 -0
  48. package/src/observe-slot-presence.dev.js +63 -0
  49. package/src/observe-slot-presence.dev.js.map +7 -0
  50. package/src/observe-slot-presence.js +2 -0
  51. package/src/observe-slot-presence.js.map +7 -0
  52. package/src/observe-slot-text.d.ts +11 -0
  53. package/src/observe-slot-text.dev.js +95 -0
  54. package/src/observe-slot-text.dev.js.map +7 -0
  55. package/src/observe-slot-text.js +2 -0
  56. package/src/observe-slot-text.js.map +7 -0
  57. package/src/platform.d.ts +10 -0
  58. package/src/platform.dev.js +39 -0
  59. package/src/platform.dev.js.map +7 -0
  60. package/src/platform.js +2 -0
  61. package/src/platform.js.map +7 -0
  62. package/src/random-id.d.ts +1 -0
  63. package/src/random-id.dev.js +8 -0
  64. package/src/random-id.dev.js.map +7 -0
  65. package/src/random-id.js +2 -0
  66. package/src/random-id.js.map +7 -0
  67. package/src/reparent-children.d.ts +4 -0
  68. package/src/reparent-children.dev.js +57 -0
  69. package/src/reparent-children.dev.js.map +7 -0
  70. package/src/reparent-children.js +2 -0
  71. package/src/reparent-children.js.map +7 -0
  72. package/test/focusable.test.js +25 -0
  73. package/test/focusable.test.js.map +7 -0
  74. package/test/observe-slot-presence.test.js +30 -0
  75. package/test/observe-slot-presence.test.js.map +7 -0
  76. package/test/observe-slot-text.test.js +27 -0
  77. package/test/observe-slot-text.test.js.map +7 -0
  78. package/test/random-id.test.js +25 -0
  79. package/test/random-id.test.js.map +7 -0
  80. package/test/reparent-children.test.js +254 -0
  81. package/test/reparent-children.test.js.map +7 -0
@@ -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
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ import "@spectrum-web-components/shared/src/focusable.js";
3
+ import { Focusable } from "@spectrum-web-components/shared/src/focusable.js";
4
+ import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
5
+ describe("Focusable", () => {
6
+ it("enforces the presense of a `focusElement`", async () => {
7
+ customElements.define("focusable-test", class extends Focusable {
8
+ });
9
+ try {
10
+ const el = await fixture(
11
+ html`
12
+ <focusable-test></focusable-test>
13
+ `
14
+ );
15
+ await elementUpdated(el);
16
+ const focusEl = el.focusElement;
17
+ expect(focusEl).to.exist;
18
+ } catch (error) {
19
+ expect(() => {
20
+ throw error;
21
+ }).to.throw("Must implement focusElement getter!");
22
+ }
23
+ });
24
+ });
25
+ //# sourceMappingURL=focusable.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["focusable.test.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/shared/src/focusable.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\ndescribe('Focusable', () => {\n it('enforces the presense of a `focusElement`', async () => {\n customElements.define('focusable-test', class extends Focusable {});\n try {\n const el = await fixture<Focusable>(\n html`\n <focusable-test></focusable-test>\n `\n );\n await elementUpdated(el);\n const focusEl = el.focusElement;\n expect(focusEl).to.exist;\n } catch (error) {\n expect(() => {\n throw error;\n }).to.throw('Must implement focusElement getter!');\n }\n });\n});\n"],
5
+ "mappings": ";AAYA,OAAO;AACP,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AAEtD,SAAS,aAAa,MAAM;AACxB,KAAG,6CAA6C,YAAY;AACxD,mBAAe,OAAO,kBAAkB,cAAc,UAAU;AAAA,IAAC,CAAC;AAClE,QAAI;AACA,YAAM,KAAK,MAAM;AAAA,QACb;AAAA;AAAA;AAAA,MAGJ;AACA,YAAM,eAAe,EAAE;AACvB,YAAM,UAAU,GAAG;AACnB,aAAO,OAAO,EAAE,GAAG;AAAA,IACvB,SAAS,OAAO;AACZ,aAAO,MAAM;AACT,cAAM;AAAA,MACV,CAAC,EAAE,GAAG,MAAM,qCAAqC;AAAA,IACrD;AAAA,EACJ,CAAC;AACL,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ import { ObserveSlotPresence } from "@spectrum-web-components/shared/src/observe-slot-presence.js";
3
+ import { LitElement } from "@spectrum-web-components/base";
4
+ import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
5
+ class ObserverTest extends ObserveSlotPresence(
6
+ LitElement,
7
+ '[slot="test-slot"]'
8
+ ) {
9
+ render() {
10
+ return html`
11
+ Test Element
12
+ `;
13
+ }
14
+ }
15
+ customElements.define("observe-presence-test", ObserverTest);
16
+ describe("ObserveSlotPresence", () => {
17
+ it("does no management when slot unavailable", async () => {
18
+ const el = await fixture(
19
+ html`
20
+ <observe-presence-test></observe-presence-test>
21
+ `
22
+ );
23
+ await elementUpdated(el);
24
+ expect(el.slotContentIsPresent).to.be.false;
25
+ el.innerHTML = '<div slot="test-slot"></div>';
26
+ await elementUpdated(el);
27
+ expect(el.slotContentIsPresent).to.be.true;
28
+ });
29
+ });
30
+ //# sourceMappingURL=observe-slot-presence.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["observe-slot-presence.test.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*/\n\nimport { ObserveSlotPresence } from '@spectrum-web-components/shared/src/observe-slot-presence.js';\nimport { LitElement, TemplateResult } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nclass ObserverTest extends ObserveSlotPresence(\n LitElement,\n '[slot=\"test-slot\"]'\n) {\n protected override render(): TemplateResult {\n return html`\n Test Element\n `;\n }\n}\n\ncustomElements.define('observe-presence-test', ObserverTest);\n\ndescribe('ObserveSlotPresence', () => {\n it('does no management when slot unavailable', async () => {\n const el = await fixture<ObserverTest>(\n html`\n <observe-presence-test></observe-presence-test>\n `\n );\n await elementUpdated(el);\n\n expect(el.slotContentIsPresent).to.be.false;\n\n el.innerHTML = '<div slot=\"test-slot\"></div>';\n await elementUpdated(el);\n\n expect(el.slotContentIsPresent).to.be.true;\n });\n});\n"],
5
+ "mappings": ";AAWA,SAAS,2BAA2B;AACpC,SAAS,kBAAkC;AAC3C,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AAEtD,MAAM,qBAAqB;AAAA,EACvB;AAAA,EACA;AACJ,EAAE;AAAA,EACqB,SAAyB;AACxC,WAAO;AAAA;AAAA;AAAA,EAGX;AACJ;AAEA,eAAe,OAAO,yBAAyB,YAAY;AAE3D,SAAS,uBAAuB,MAAM;AAClC,KAAG,4CAA4C,YAAY;AACvD,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AACA,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,oBAAoB,EAAE,GAAG,GAAG;AAEtC,OAAG,YAAY;AACf,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,oBAAoB,EAAE,GAAG,GAAG;AAAA,EAC1C,CAAC;AACL,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ import { ObserveSlotText } from "@spectrum-web-components/shared/src/observe-slot-text.js";
3
+ import { LitElement } from "@spectrum-web-components/base";
4
+ import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
5
+ class ObserverTest extends ObserveSlotText(LitElement) {
6
+ render() {
7
+ return html`
8
+ <slot @slotchange=${this.manageTextObservedSlot}></slot>
9
+ `;
10
+ }
11
+ }
12
+ customElements.define("observe-slot-test", ObserverTest);
13
+ describe("ObserveSlotText", () => {
14
+ it("does no management when slot unavailable", async () => {
15
+ const el = await fixture(
16
+ html`
17
+ <observe-slot-test></observe-slot-test>
18
+ `
19
+ );
20
+ await elementUpdated(el);
21
+ expect(el.slotHasContent).to.be.false;
22
+ el.textContent = `hi, i'm some text`;
23
+ await elementUpdated(el);
24
+ expect(el.slotHasContent).to.be.true;
25
+ });
26
+ });
27
+ //# sourceMappingURL=observe-slot-text.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["observe-slot-text.test.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { LitElement, TemplateResult } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nclass ObserverTest extends ObserveSlotText(LitElement) {\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.manageTextObservedSlot}></slot>\n `;\n }\n}\n\ncustomElements.define('observe-slot-test', ObserverTest);\n\ndescribe('ObserveSlotText', () => {\n it('does no management when slot unavailable', async () => {\n const el = await fixture<ObserverTest>(\n html`\n <observe-slot-test></observe-slot-test>\n `\n );\n await elementUpdated(el);\n\n expect(el.slotHasContent).to.be.false;\n\n el.textContent = `hi, i'm some text`;\n\n await elementUpdated(el);\n\n expect(el.slotHasContent).to.be.true;\n });\n});\n"],
5
+ "mappings": ";AAYA,SAAS,uBAAuB;AAChC,SAAS,kBAAkC;AAC3C,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AAEtD,MAAM,qBAAqB,gBAAgB,UAAU,EAAE;AAAA,EAChC,SAAyB;AACxC,WAAO;AAAA,gCACiB,KAAK,sBAAsB;AAAA;AAAA,EAEvD;AACJ;AAEA,eAAe,OAAO,qBAAqB,YAAY;AAEvD,SAAS,mBAAmB,MAAM;AAC9B,KAAG,4CAA4C,YAAY;AACvD,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AACA,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,cAAc,EAAE,GAAG,GAAG;AAEhC,OAAG,cAAc;AAEjB,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,cAAc,EAAE,GAAG,GAAG;AAAA,EACpC,CAAC;AACL,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ import { randomID } from "@spectrum-web-components/shared/src/random-id.js";
3
+ import { expect } from "@open-wc/testing";
4
+ describe("randomID()", () => {
5
+ it("creates unique strings of 8 hex characters", () => {
6
+ const n = 1e3;
7
+ const ids = Array.from({ length: n }, randomID);
8
+ const shape = ids.filter((id) => {
9
+ return typeof id === "string" && id.length === 8 && id.split("").every((char) => "0123456789abcdef".includes(char));
10
+ });
11
+ const unique = new Set(ids);
12
+ expect(shape).to.have.length(n);
13
+ expect(unique).to.have.length(n);
14
+ });
15
+ it("generates 100k IDs in less than a second", () => {
16
+ const n = 1e5;
17
+ const sec = 1e3;
18
+ const start = performance.now();
19
+ const ids = Array.from({ length: n }, randomID);
20
+ const time = performance.now() - start;
21
+ expect(ids).to.have.length(n);
22
+ expect(time).to.be.lessThan(sec);
23
+ });
24
+ });
25
+ //# sourceMappingURL=random-id.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["random-id.test.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\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\nimport { expect } from '@open-wc/testing';\n\ndescribe('randomID()', () => {\n it('creates unique strings of 8 hex characters', () => {\n const n = 1000;\n const ids = Array.from({ length: n }, randomID);\n const shape = ids.filter((id) => {\n return (\n typeof id === 'string' &&\n id.length === 8 &&\n id.split('').every((char) => '0123456789abcdef'.includes(char))\n );\n });\n const unique = new Set(ids);\n\n expect(shape).to.have.length(n);\n expect(unique).to.have.length(n);\n });\n it('generates 100k IDs in less than a second', () => {\n const n = 100000;\n const sec = 1000;\n const start = performance.now();\n const ids = Array.from({ length: n }, randomID);\n const time = performance.now() - start;\n\n expect(ids).to.have.length(n);\n expect(time).to.be.lessThan(sec);\n });\n});\n"],
5
+ "mappings": ";AAYA,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,SAAS,cAAc,MAAM;AACzB,KAAG,8CAA8C,MAAM;AACnD,UAAM,IAAI;AACV,UAAM,MAAM,MAAM,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ;AAC9C,UAAM,QAAQ,IAAI,OAAO,CAAC,OAAO;AAC7B,aACI,OAAO,OAAO,YACd,GAAG,WAAW,KACd,GAAG,MAAM,EAAE,EAAE,MAAM,CAAC,SAAS,mBAAmB,SAAS,IAAI,CAAC;AAAA,IAEtE,CAAC;AACD,UAAM,SAAS,IAAI,IAAI,GAAG;AAE1B,WAAO,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;AAC9B,WAAO,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;AAAA,EACnC,CAAC;AACD,KAAG,4CAA4C,MAAM;AACjD,UAAM,IAAI;AACV,UAAM,MAAM;AACZ,UAAM,QAAQ,YAAY,IAAI;AAC9B,UAAM,MAAM,MAAM,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ;AAC9C,UAAM,OAAO,YAAY,IAAI,IAAI;AAEjC,WAAO,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;AAC5B,WAAO,IAAI,EAAE,GAAG,GAAG,SAAS,GAAG;AAAA,EACnC,CAAC;AACL,CAAC;",
6
+ "names": []
7
+ }