Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 40 additions & 34 deletions e2e/phone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,37 +318,43 @@ test("touch long press selects, tap toggles, and swipes still act outside select
await expect(page.getByRole("dialog")).toHaveCount(0);
});

test("Scratchpad draft checkboxes own their full phone touch target", async ({
page,
}) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("scratchpad/?demo=60");
const note = page.locator(".scratchpad-current-document");
const box = note
.getByRole("checkbox", { name: "Mark task complete" })
.first();
await expect(box).toBeVisible();
const bounds = (await box.boundingBox())!;
expect(bounds.width).toBeGreaterThanOrEqual(44);
expect(bounds.height).toBeGreaterThanOrEqual(44);
await expect
.poll(() =>
box.evaluate((el) => {
const rect = el.getBoundingClientRect();
return [1, 43].every((x) =>
[1, 43].every(
(y) =>
document.elementFromPoint(rect.left + x, rect.top + y) === el,
),
);
}),
)
.toBe(true);
await box.tap({ position: { x: 1, y: 1 } });
await expect(
note.getByRole("checkbox", { name: "Mark task incomplete" }).first(),
).toBeChecked();
await expect(box).not.toBeChecked();
await expectNoHorizontalOverflow(page);
expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([]);
});
for (const hasTouch of [true, false]) {
test.describe(hasTouch ? "touch pointer" : "fine pointer", () => {
test.use({ hasTouch });
test("Scratchpad draft checkboxes own their full phone touch target", async ({
page,
}) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("scratchpad/?demo=60");
const note = page.locator(".scratchpad-current-document");
const box = note
.getByRole("checkbox", { name: "Mark task complete" })
.first();
await expect(box).toBeVisible();
const bounds = (await box.boundingBox())!;
expect(bounds.width).toBeGreaterThanOrEqual(44);
expect(bounds.height).toBeGreaterThanOrEqual(44);
await expect
.poll(() =>
box.evaluate((el) => {
const rect = el.getBoundingClientRect();
return [1, 43].every((x) =>
[1, 43].every(
(y) =>
document.elementFromPoint(rect.left + x, rect.top + y) === el,
),
);
}),
)
.toBe(true);
if (hasTouch) await box.tap({ position: { x: 1, y: 1 } });
else await box.click({ position: { x: 1, y: 1 } });
await expect(
note.getByRole("checkbox", { name: "Mark task incomplete" }).first(),
).toBeChecked();
await expect(box).not.toBeChecked();
await expectNoHorizontalOverflow(page);
expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([]);
});
});
}
154 changes: 144 additions & 10 deletions patches/@tasknotes__calendar@0.1.10.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,75 @@
diff --git a/dist/cjs/core.cjs b/dist/cjs/core.cjs
index 26a210211cd31a79c1559769ae989031e73e6090..2d1718cf66965e5ba21aff951854c81437a59b29 100644
--- a/dist/cjs/core.cjs
+++ b/dist/cjs/core.cjs
@@ -581,20 +581,21 @@ function layoutRow(items, days, order = defaultOrder) {
});
const levelEnds = [];
const placements = [];
+ let previousCol = -1;
+ let nextLevel = 0;
for (const n of sorted) {
const startCol = colOf(n.startDay);
const endCol = colOf(n.endDay);
if (endCol <= startCol) continue;
- let level = 0;
- for (; ; level++) {
- const occ = levelEnds[level] ??= [];
- let free = true;
- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false;
- if (free) {
- for (let c = startCol; c < endCol; c++) occ[c] = 1;
- break;
- }
+ // Starts are sorted. A level is free when its previous span has ended.
+ // Within one start column, every level we passed is still occupied.
+ if (startCol !== previousCol) {
+ previousCol = startCol;
+ nextLevel = 0;
}
+ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++;
+ const level = nextLevel++;
+ levelEnds[level] = endCol;
for (let c = startCol; c < endCol; c++) countByCol[c]++;
placements.push({
item: n,
diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs
index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57de64bc1b 100644
index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef6901912144198bb4ea0f 100644
--- a/dist/cjs/index.cjs
+++ b/dist/cjs/index.cjs
@@ -1504,7 +1504,7 @@ var ListView = class {
@@ -593,20 +593,21 @@ function layoutRow(items, days, order = defaultOrder) {
});
const levelEnds = [];
const placements = [];
+ let previousCol = -1;
+ let nextLevel = 0;
for (const n of sorted) {
const startCol = colOf(n.startDay);
const endCol = colOf(n.endDay);
if (endCol <= startCol) continue;
- let level = 0;
- for (; ; level++) {
- const occ = levelEnds[level] ??= [];
- let free = true;
- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false;
- if (free) {
- for (let c = startCol; c < endCol; c++) occ[c] = 1;
- break;
- }
- }
+ // Starts are sorted. A level is free when its previous span has ended.
+ // Within one start column, every level we passed is still occupied.
+ if (startCol !== previousCol) {
+ previousCol = startCol;
+ nextLevel = 0;
+ }
+ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++;
+ const level = nextLevel++;
+ levelEnds[level] = endCol;
for (let c = startCol; c < endCol; c++) countByCol[c]++;
placements.push({
item: n,
@@ -1504,7 +1505,7 @@ var ListView = class {
const inLead = /* @__PURE__ */ new Set();
const keep = /* @__PURE__ */ new Set();
let itemCount = 0;
Expand All @@ -11,7 +78,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57
for (const day of days) {
let items = this.itemsOn(day);
if (includes) {
@@ -1531,13 +1531,13 @@ var ListView = class {
@@ -1531,13 +1532,13 @@ var ListView = class {
section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows);
if (agenda && opts.listAddText !== null) section.append(this.addRow(day));
opts.dayHeaderDidMount?.({ ...arg, el: heading });
Expand All @@ -27,7 +94,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57
if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) {
if (prev) prev.after(section);
else this.body.prepend(section);
@@ -1568,18 +1568,29 @@ var ListView = class {
@@ -1568,18 +1569,29 @@ var ListView = class {
this.loader.observe(this.sentinel);
}
}
Expand Down Expand Up @@ -62,7 +129,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57
}
renderLead(items) {
const { ctx } = this;
@@ -1598,12 +1609,12 @@ var ListView = class {
@@ -1598,12 +1610,12 @@ var ListView = class {
const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot);
const rows = h(doc, "div", "tnc-list-rows", { role: "group" });
const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows);
Expand All @@ -78,10 +145,42 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57
addRow(day) {
const { ctx } = this;
diff --git a/dist/cjs/react.cjs b/dist/cjs/react.cjs
index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf91731ef242a 100644
index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a8befccf1 100644
--- a/dist/cjs/react.cjs
+++ b/dist/cjs/react.cjs
@@ -1412,7 +1412,7 @@ var ListView = class {
@@ -929,20 +929,21 @@ function layoutRow(items, days, order = defaultOrder) {
});
const levelEnds = [];
const placements = [];
+ let previousCol = -1;
+ let nextLevel = 0;
for (const n of sorted) {
const startCol = colOf(n.startDay);
const endCol = colOf(n.endDay);
if (endCol <= startCol) continue;
- let level = 0;
- for (; ; level++) {
- const occ = levelEnds[level] ??= [];
- let free = true;
- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false;
- if (free) {
- for (let c = startCol; c < endCol; c++) occ[c] = 1;
- break;
- }
- }
+ // Starts are sorted. A level is free when its previous span has ended.
+ // Within one start column, every level we passed is still occupied.
+ if (startCol !== previousCol) {
+ previousCol = startCol;
+ nextLevel = 0;
+ }
+ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++;
+ const level = nextLevel++;
+ levelEnds[level] = endCol;
for (let c = startCol; c < endCol; c++) countByCol[c]++;
placements.push({
item: n,
@@ -1412,7 +1413,7 @@ var ListView = class {
const inLead = /* @__PURE__ */ new Set();
const keep = /* @__PURE__ */ new Set();
let itemCount = 0;
Expand All @@ -90,7 +189,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf917
for (const day of days) {
let items = this.itemsOn(day);
if (includes) {
@@ -1439,13 +1439,13 @@ var ListView = class {
@@ -1439,13 +1440,13 @@ var ListView = class {
section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows);
if (agenda && opts.listAddText !== null) section.append(this.addRow(day));
opts.dayHeaderDidMount?.({ ...arg, el: heading });
Expand All @@ -106,7 +205,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf917
if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) {
if (prev) prev.after(section);
else this.body.prepend(section);
@@ -1476,18 +1476,29 @@ var ListView = class {
@@ -1476,18 +1477,29 @@ var ListView = class {
this.loader.observe(this.sentinel);
}
}
Expand Down Expand Up @@ -141,7 +240,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf917
}
renderLead(items) {
const { ctx } = this;
@@ -1506,12 +1517,12 @@ var ListView = class {
@@ -1506,12 +1518,12 @@ var ListView = class {
const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot);
const rows = h(doc, "div", "tnc-list-rows", { role: "group" });
const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows);
Expand Down Expand Up @@ -235,6 +334,41 @@ index c2b76d29621fe4cc981794d2d24147b580d35d87..5d9e7cab85e9731e569632a33ada6c14
}
addRow(day) {
const { ctx } = this;
diff --git a/dist/esm/chunk-66A6EMCU.js b/dist/esm/chunk-66A6EMCU.js
index 925e67d730fb732410ba9d81684710f2cee3dace..7ce9229a90a65fb313276376da5b3a19b4bd9868 100644
--- a/dist/esm/chunk-66A6EMCU.js
+++ b/dist/esm/chunk-66A6EMCU.js
@@ -516,20 +516,21 @@ function layoutRow(items, days, order = defaultOrder) {
});
const levelEnds = [];
const placements = [];
+ let previousCol = -1;
+ let nextLevel = 0;
for (const n of sorted) {
const startCol = colOf(n.startDay);
const endCol = colOf(n.endDay);
if (endCol <= startCol) continue;
- let level = 0;
- for (; ; level++) {
- const occ = levelEnds[level] ??= [];
- let free = true;
- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false;
- if (free) {
- for (let c = startCol; c < endCol; c++) occ[c] = 1;
- break;
- }
+ // Starts are sorted. A level is free when its previous span has ended.
+ // Within one start column, every level we passed is still occupied.
+ if (startCol !== previousCol) {
+ previousCol = startCol;
+ nextLevel = 0;
}
+ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++;
+ const level = nextLevel++;
+ levelEnds[level] = endCol;
for (let c = startCol; c < endCol; c++) countByCol[c]++;
placements.push({
item: n,
diff --git a/dist/types/dom/options.d.cts b/dist/types/dom/options.d.cts
index 0814ca846b4d4046235ac302844cf53f7bd1d7a3..ec19c098ee52b6bed4a1ec61e9a6125b33f1b028 100644
--- a/dist/types/dom/options.d.cts
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion scripts/bench-task-workflow.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ assert.ok(
const browser = await chromium.launch();
const rounds = Number(process.env.TASKNOTES_BENCH_ROUNDS ?? 7);
const results = {};
const focused = process.env.TASKNOTES_BENCH_FOCUS === "calendar-search";
const view = (slug) =>
"/views/" + encodeURIComponent("TaskNotes/Views/" + slug + ".base#" + slug);

Expand Down Expand Up @@ -69,8 +70,14 @@ async function sample(origin, size) {
["Scratchpad", "/scratchpad", ".scratchpad-document-stream"],
["Search", "/search", ".browse-fields"],
["Today", view("today"), ".task-row-title"],
])
]) {
if (
focused &&
!["Upcoming", "Calendar", "Search", "Today"].includes(name)
)
continue;
await measure(mode + " " + name, () => go(path, selector));
}

const prefix = mode + " ";
const project = page.locator(
Expand Down Expand Up @@ -99,6 +106,18 @@ async function sample(origin, size) {
});
await go("/search", "#task-search");
const search = page.getByRole("searchbox", { name: "Search tasks" });
if (focused) {
const chip = page
.locator(".browse-fields")
.getByRole("button", { name: "work", exact: true });
await chip.waitFor();
await measure(prefix + "choose tag", async () => {
await chip.click();
await ready(".search-results .task-row-title");
});
await page.getByRole("button", { name: "Clear search" }).click();
await chip.waitFor();
}
const row = page
.locator(".search-results .task-row-title")
.filter({ hasText: title });
Expand Down Expand Up @@ -154,6 +173,7 @@ async function sample(origin, size) {
count,
);
});
if (focused) continue;
await go(view("upcoming"), ".tnc-list-lead .task-row-title");
const lead = page.locator(".tnc-list-lead");
const group = lead.locator(".agenda-row-group").nth(80);
Expand Down
Loading
Loading