@excom/include-content 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.rush/temp/chunked-rush-logs/include-content.apply-exports.chunks.jsonl +1 -0
  2. package/.rush/temp/chunked-rush-logs/include-content.build_docs.chunks.jsonl +1 -0
  3. package/.rush/temp/chunked-rush-logs/include-content.build_package-metas.chunks.jsonl +1 -0
  4. package/.rush/temp/operation/apply-exports/all.log +1 -0
  5. package/.rush/temp/operation/apply-exports/log-chunks.jsonl +1 -0
  6. package/.rush/temp/operation/apply-exports/state.json +3 -0
  7. package/.rush/temp/operation/build_docs/all.log +1 -0
  8. package/.rush/temp/operation/build_docs/log-chunks.jsonl +1 -0
  9. package/.rush/temp/operation/build_docs/state.json +3 -0
  10. package/.rush/temp/operation/build_package-metas/all.log +1 -0
  11. package/.rush/temp/operation/build_package-metas/log-chunks.jsonl +1 -0
  12. package/.rush/temp/operation/build_package-metas/state.json +3 -0
  13. package/.rush/temp/shrinkwrap-deps.json +3 -0
  14. package/config/rig.json +5 -0
  15. package/include-content.ts +176 -0
  16. package/index.css +5 -0
  17. package/index.ts +17 -0
  18. package/package.json +45 -0
  19. package/rush-logs/include-content.apply-exports.cache.log +1 -0
  20. package/rush-logs/include-content.apply-exports.log +1 -0
  21. package/rush-logs/include-content.build_docs.cache.log +1 -0
  22. package/rush-logs/include-content.build_docs.log +1 -0
  23. package/rush-logs/include-content.build_package-metas.cache.log +1 -0
  24. package/rush-logs/include-content.build_package-metas.log +1 -0
  25. package/src/include-content.css +66 -0
  26. package/support/custom-elements.json +277 -0
  27. package/support/demos/lazy.html +19 -0
  28. package/support/demos/persist-content.html +23 -0
  29. package/support/demos/portal.html +8 -0
  30. package/support/demos/simple.html +16 -0
  31. package/support/demos/template-include.html +7 -0
  32. package/support/demos/template-ref.html +7 -0
  33. package/support/dist-docs/include-content.md +265 -0
  34. package/support/docs/README.md +64 -0
  35. package/support/package-meta.json +360 -0
  36. package/support/tests/include-content.test.ts +764 -0
  37. package/support/tests/lazy.view.test.ts +22 -0
  38. package/support/tests/persist-content.view.test.ts +33 -0
  39. package/support/tests/portal.view.test.ts +21 -0
  40. package/support/tests/simple.view.test.ts +23 -0
  41. package/support/tests/template-include.view.test.ts +35 -0
  42. package/support/tests/template-ref.view.test.ts +21 -0
  43. package/tsconfig.json +5 -0
@@ -0,0 +1,22 @@
1
+ import "../../index";
2
+ import {
3
+ afterEach,
4
+ describe,
5
+ expect,
6
+ it,
7
+ } from "@excom/heft-rig/profiles/default/config/test-utils";
8
+ import { mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
9
+
10
+ describe("lazy view", () => {
11
+ afterEach(() => {
12
+ document.body.innerHTML = "";
13
+ });
14
+
15
+ it("starts inactive with lazy-load and lazy-unload set", async () => {
16
+ const { root } = await mountView(readDemo(import.meta.url, "lazy"));
17
+ const include = root.querySelector("include-content")!;
18
+ expect(include.hasAttribute("lazy-load")).toBe(true);
19
+ expect(include.hasAttribute("lazy-unload")).toBe(true);
20
+ expect(include.hasAttribute("is-active")).toBe(false);
21
+ });
22
+ });
@@ -0,0 +1,33 @@
1
+ import "@excom/quark-sheet";
2
+ import "../../index";
3
+ import {
4
+ afterEach,
5
+ describe,
6
+ expect,
7
+ it,
8
+ } from "@excom/heft-rig/profiles/default/config/test-utils";
9
+ import { flush, mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
10
+
11
+ describe("persist-content view", () => {
12
+ afterEach(() => {
13
+ document.body.innerHTML = "";
14
+ });
15
+
16
+ it("keeps typed value across deactivate", async () => {
17
+ const { root } = await mountView(readDemo(import.meta.url, "persist-content"));
18
+ const include = root.querySelector("include-content")!;
19
+ const input = include.querySelector("input")!;
20
+ input.value = "kept";
21
+ const checkbox = root.querySelector<HTMLInputElement>(
22
+ 'input[name="is-active"]',
23
+ )!;
24
+ checkbox.checked = false;
25
+ checkbox.dispatchEvent(new Event("change", { bubbles: true }));
26
+ await flush();
27
+ expect(include.hasAttribute("is-active")).toBe(false);
28
+ checkbox.checked = true;
29
+ checkbox.dispatchEvent(new Event("change", { bubbles: true }));
30
+ await flush();
31
+ expect(include.querySelector("input")?.value).toBe("kept");
32
+ });
33
+ });
@@ -0,0 +1,21 @@
1
+ import "../../index";
2
+ import {
3
+ afterEach,
4
+ describe,
5
+ expect,
6
+ it,
7
+ } from "@excom/heft-rig/profiles/default/config/test-utils";
8
+ import { mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
9
+
10
+ describe("portal view", () => {
11
+ afterEach(() => {
12
+ document.body.innerHTML = "";
13
+ });
14
+
15
+ it("portals content into the aside", async () => {
16
+ const { root } = await mountView(readDemo(import.meta.url, "portal"));
17
+ expect(root.querySelector("#ic-portal-mount")?.textContent).toMatch(
18
+ /Portaled/,
19
+ );
20
+ });
21
+ });
@@ -0,0 +1,23 @@
1
+ import "../../index";
2
+ import {
3
+ afterEach,
4
+ describe,
5
+ expect,
6
+ it,
7
+ } from "@excom/heft-rig/profiles/default/config/test-utils";
8
+ import { flush, mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
9
+
10
+ describe("simple view", () => {
11
+ afterEach(() => {
12
+ document.body.innerHTML = "";
13
+ });
14
+
15
+ it("renders the template when activated", async () => {
16
+ const { root } = await mountView(readDemo(import.meta.url, "simple"));
17
+ const include = root.querySelector("include-content")!;
18
+ expect(include.hasAttribute("is-active")).toBe(false);
19
+ include.setAttribute("is-active", "");
20
+ await flush();
21
+ expect(include.textContent).toMatch(/HTML inserted/);
22
+ });
23
+ });
@@ -0,0 +1,35 @@
1
+ import "../../index";
2
+ import {
3
+ afterEach,
4
+ describe,
5
+ expect,
6
+ it,
7
+ spyFetch,
8
+ vi,
9
+ waitForEvent,
10
+ } from "@excom/heft-rig/profiles/default/config/test-utils";
11
+ import { mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
12
+
13
+ describe("template-include view", () => {
14
+ afterEach(() => {
15
+ document.body.innerHTML = "";
16
+ vi.restoreAllMocks();
17
+ vi.unstubAllGlobals();
18
+ });
19
+
20
+ it("includes a local template and a remote URL", async () => {
21
+ spyFetch({
22
+ body: "<p>A remote view piece.</p>",
23
+ headers: new Headers({ "content-type": "text/html" }),
24
+ });
25
+ const { root } = await mountView(
26
+ readDemo(import.meta.url, "template-include"),
27
+ );
28
+ const [local, remote] = root.querySelectorAll("include-content");
29
+ expect(local.textContent).toMatch(/reusable view piece/);
30
+ if (!remote.hasAttribute("did-load")) {
31
+ await waitForEvent(remote, "include-content-did-render");
32
+ }
33
+ expect(remote.textContent).toMatch(/remote view piece/);
34
+ });
35
+ });
@@ -0,0 +1,21 @@
1
+ import "../../index";
2
+ import {
3
+ afterEach,
4
+ describe,
5
+ expect,
6
+ it,
7
+ } from "@excom/heft-rig/profiles/default/config/test-utils";
8
+ import { mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
9
+
10
+ describe("template-ref view", () => {
11
+ afterEach(() => {
12
+ document.body.innerHTML = "";
13
+ });
14
+
15
+ it("renders the shared template into the active host", async () => {
16
+ const { root } = await mountView(readDemo(import.meta.url, "template-ref"));
17
+ const hosts = root.querySelectorAll("include-content");
18
+ expect(hosts[0].textContent).toMatch(/Shared template/);
19
+ expect(hosts[0].hasAttribute("is-active")).toBe(true);
20
+ });
21
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@excom/heft-rig/profiles/default/config/tsconfig.json",
3
+ "include": ["./*.ts"],
4
+ "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
5
+ }