@excom/data-table 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.
- package/.rush/temp/chunked-rush-logs/data-table.apply-exports.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/data-table.build_docs.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/data-table.build_package-metas.chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/all.log +1 -0
- package/.rush/temp/operation/apply-exports/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/state.json +3 -0
- package/.rush/temp/operation/build_docs/all.log +1 -0
- package/.rush/temp/operation/build_docs/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_docs/state.json +3 -0
- package/.rush/temp/operation/build_package-metas/all.log +1 -0
- package/.rush/temp/operation/build_package-metas/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_package-metas/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +3 -0
- package/config/rig.json +5 -0
- package/data-table.ts +396 -0
- package/data-th.ts +49 -0
- package/index.css +5 -0
- package/index.ts +23 -0
- package/package.json +44 -0
- package/rush-logs/data-table.apply-exports.cache.log +1 -0
- package/rush-logs/data-table.apply-exports.log +1 -0
- package/rush-logs/data-table.build_docs.cache.log +1 -0
- package/rush-logs/data-table.build_docs.log +1 -0
- package/rush-logs/data-table.build_package-metas.cache.log +1 -0
- package/rush-logs/data-table.build_package-metas.log +1 -0
- package/src/data-table.css +124 -0
- package/support/custom-elements.json +366 -0
- package/support/demos/filter.html +67 -0
- package/support/demos/simple.html +14 -0
- package/support/dist-docs/data-table.md +245 -0
- package/support/dist-docs/data-th.md +29 -0
- package/support/docs/INTERNAL.md +7 -0
- package/support/docs/README.md +74 -0
- package/support/package-meta.json +280 -0
- package/support/tests/data-table.test.ts +704 -0
- package/support/tests/filter.view.test.ts +33 -0
- package/support/tests/simple.view.test.ts +31 -0
- package/tsconfig.json +5 -0
|
@@ -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
|
+
const isFilteredOut = (tr: HTMLElement) =>
|
|
12
|
+
tr.style.getPropertyValue("--data-tr-display") === "none";
|
|
13
|
+
|
|
14
|
+
describe("filter view", () => {
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
document.body.innerHTML = "";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("filters rows as the user types", async () => {
|
|
20
|
+
const { root } = await mountView(readDemo(import.meta.url, "filter"));
|
|
21
|
+
const input = root.querySelector<HTMLInputElement>(
|
|
22
|
+
'input[name="filterValue"]',
|
|
23
|
+
)!;
|
|
24
|
+
input.value = "Bea";
|
|
25
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
26
|
+
await flush();
|
|
27
|
+
const rows = [...root.querySelectorAll("data-tbody data-tr")] as HTMLElement[];
|
|
28
|
+
const visible = rows.filter((row) => !isFilteredOut(row));
|
|
29
|
+
expect(visible.length).toBeGreaterThan(0);
|
|
30
|
+
expect(visible.every((row) => row.textContent?.includes("Bea"))).toBe(true);
|
|
31
|
+
expect(rows.some(isFilteredOut)).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "../../index";
|
|
2
|
+
import {
|
|
3
|
+
afterEach,
|
|
4
|
+
describe,
|
|
5
|
+
expect,
|
|
6
|
+
it,
|
|
7
|
+
wait,
|
|
8
|
+
} from "@excom/heft-rig/profiles/default/config/test-utils";
|
|
9
|
+
import { click, flush, mountView, readDemo } from "@excom/quark/support/tests/view-helpers";
|
|
10
|
+
|
|
11
|
+
const rowOrder = (tr: HTMLElement) =>
|
|
12
|
+
parseInt(tr.style.getPropertyValue("--data-tr-order") || "0", 10);
|
|
13
|
+
|
|
14
|
+
describe("simple view", () => {
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
document.body.innerHTML = "";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("renders rows and sorts by name", async () => {
|
|
20
|
+
const { root } = await mountView(readDemo(import.meta.url, "simple"));
|
|
21
|
+
await wait(0);
|
|
22
|
+
const rows = () =>
|
|
23
|
+
[...root.querySelectorAll("data-tbody data-tr")] as HTMLElement[];
|
|
24
|
+
const byOrder = () => [...rows()].sort((a, b) => rowOrder(a) - rowOrder(b));
|
|
25
|
+
expect(byOrder()[0].querySelector("data-td")?.textContent).toBe("Adam");
|
|
26
|
+
click(root.querySelector("data-th"));
|
|
27
|
+
await flush();
|
|
28
|
+
await wait(0);
|
|
29
|
+
expect(byOrder()[0].querySelector("data-td")?.textContent).toBe("Cynthia");
|
|
30
|
+
});
|
|
31
|
+
});
|