feat(ui): add DataTable and Toaster, drop the legacy Table, fix overlay dialogs
DataTable replaces the 20-line Table scaffold entirely: columns, sorting, filtering, pagination, selection, bulk actions, comparison layout, sticky first column, custom HTML cells, and a remote source driven by a `request` output rather than a function prop (props travel as HTML attributes, so a function arrives as its own source text). Toaster replaces the hand-rolled status div: tone icons, actions, hover pause/resume and a progress bar. Overlays audit -- Modal and Drawer declared aria-modal="true" but nothing ever moved focus into the panel, so the @keydown handler on their root never ran and closeOnEscape did nothing. Focus, focus restore, a Tab trap and a body scroll lock now live in the reactive runtime, shared by both. ContextMenu placed pointer menus by subtracting a guessed 340x420 from the viewport, which pushed every menu that was not that size away from the pointer; it now positions at the pointer and lets the anchored clamp pull it back once it can be measured. The reactive runtime size budget moves 150k -> 175k to cover anchored overlays, dialog behaviour, the toaster and the DataTable client half. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1398,3 +1398,75 @@ test("strict-mode reserved prop names compile through safe local references", ()
|
||||
expect(output).toContain("(__p_private) ?");
|
||||
expect(output).not.toContain("const private:");
|
||||
});
|
||||
|
||||
// data-show holds an expression the client re-evaluates, so it must survive
|
||||
// compilation verbatim. Interpolating `{open || visible}` to the literal
|
||||
// "false" froze every overlay that used the braced form -- Drawer, Dropdown,
|
||||
// Popover, ContextMenu and Tooltip could never open.
|
||||
test("data-show keeps its expression instead of being interpolated away", () => {
|
||||
const source = `component Panel {
|
||||
props {
|
||||
open: boolean = false
|
||||
}
|
||||
state visible = false
|
||||
view {
|
||||
<div class="panel" data-show='{open || visible}'>body</div>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const code = compileWireFile(source, "Panel.wrn");
|
||||
expect(code).toContain(`data-show="open || visible"`);
|
||||
expect(code).not.toContain(`data-show="false"`);
|
||||
});
|
||||
|
||||
// Props and state are destructured into the same scope as the function body,
|
||||
// so a local that shares one of their names used to emit a redeclaration and
|
||||
// break the whole generated module with a parse error naming no source line.
|
||||
test("a local variable may shadow a prop without breaking the module", () => {
|
||||
const source = `component Sized {
|
||||
props {
|
||||
size: number = 10
|
||||
}
|
||||
state total = 0
|
||||
functions {
|
||||
client function recompute() {
|
||||
var size = 4
|
||||
var total = size * 2
|
||||
return total
|
||||
}
|
||||
}
|
||||
view {
|
||||
<div class="sized">{total}</div>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const code = compileWireFile(source, "Sized.wrn");
|
||||
// The alias must be dropped, not emitted alongside the local declaration.
|
||||
expect(code).not.toContain("const { size } = context.props;");
|
||||
expect(code).toContain("var size = 4");
|
||||
});
|
||||
|
||||
// A boolean attribute whose expression names a loop variable cannot be
|
||||
// resolved on the server -- __wireBooleanAttr runs at render time, where the
|
||||
// loop variable does not exist, and the generated module failed outright.
|
||||
test("a boolean attribute bound to a loop variable binds on the client", () => {
|
||||
const source = `component Picker {
|
||||
state rows = []
|
||||
functions {
|
||||
shared function isOn(row) {
|
||||
return row.on
|
||||
}
|
||||
}
|
||||
view {
|
||||
<ul>
|
||||
<li data-for="row in rows" data-key="row.id">
|
||||
<input type="checkbox" checked='{isOn(row)}' />
|
||||
</li>
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const code = compileWireFile(source, "Picker.wrn");
|
||||
expect(code).not.toContain('__wireBooleanAttr("checked"');
|
||||
expect(code).toContain("data-wrn-bind-");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user