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
10 changes: 10 additions & 0 deletions .changeset/data-table-export-leaves.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@wirecore/wirelayer-vue': minor
'@wirecore/wirelayer-react': minor
---

DataTable: `exportRows="leaves"` – the CSV, Excel and print of a TreeTable (`getSubRows`) only have the rows without
children, e.g. when a parent only sums up its children ("Person – 2 licences" above the licences); still filtered and
sorted like the table (with `treeFilterMode="lenient"` only the leaves that match themselves). The methods take it as
option `rows` (`generateCsv({ rows: 'leaves' })`, also `generateXlsx`, `exportCsv`, `exportXlsx`, `print`), which wins
over the prop; `selectionOnly` is not affected. Default `all`, as before. Story _Tree export_.
10 changes: 10 additions & 0 deletions .changeset/dialog-autofocus-wrapper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@wirecore/wirelayer-recipes': patch
'@wirecore/wirelayer-vue': patch
'@wirecore/wirelayer-react': patch
---

Dialog: when it opens, `data-autofocus` and `autofocus` are resolved like `data-autoselect` and `focusFirst()` – also on
a wrapper such as a component's root, which then gives the focus to its first field (e.g. `<Listbox filter
data-autofocus>` focuses its search field). Ark skipped such a wrapper and focused the close button. Story _Initial
focus on a component_.
10 changes: 10 additions & 0 deletions .changeset/field-focus-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@wirecore/wirelayer-recipes': patch
'@wirecore/wirelayer-css': patch
---

Text fields and other form controls (Input, Textarea, Select, DatePicker, NumberInput, PasswordInput, Combobox,
TreeSelect, MultiSelect, editors, search fields …) show the keyboard focus more clearly: besides the primary border a
2 px primary ring right inside it, so the focused field differs from the resting one by a 3 px band (WCAG 2.4.13). It
sits inside the field, so neighbours and `overflow-hidden` do not cut it off; it covers the field's own surface, whose
contrast to primary the theme test already checks.
10 changes: 10 additions & 0 deletions .changeset/focus-ring-outline-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@wirecore/wirelayer-recipes': patch
'@wirecore/wirelayer-css': patch
---

Focus ring visible again in 22 parts: with Tailwind v4, `outline-none` sets `--tw-outline-style: none`, and the
`focus-visible:outline-2` ring took that style – active but invisible (WCAG 2.4.7). The redundant `outline-none` is gone
where a part draws its own focus ring: SidebarNav links, Stepper, Menubar, menu search, Gantt rows, CodeTabs,
CodeHighlight, Editor source, ScrollPanel, LogViewer, JsonViewer, ChatMessages, PdfViewer, FloatingPanel, ImageCropper,
AngleSlider, Knob, ColorPicker, SpeedDial and the form error summary. A test keeps it so.
10 changes: 10 additions & 0 deletions .changeset/segmented-control-icon-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@wirecore/wirelayer-recipes': patch
'@wirecore/wirelayer-css': patch
'@wirecore/wirelayer-vue': patch
'@wirecore/wirelayer-react': patch
---

SegmentedControlItem: `label` – the text of a segment without a default slot (children). With `icon` and `label` but no
slot the segment shows only the icon, centred (no gap), and the label names it for screen readers – e.g. a List/Tiles
switch. Segments with text are unchanged. Recipe variant `iconOnly`, slot `itemText`; story _Icon only_.
12 changes: 12 additions & 0 deletions .changeset/unsaved-changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@wirecore/wirelayer-recipes': minor
'@wirecore/wirelayer-vue': minor
'@wirecore/wirelayer-react': minor
---

Forms: `useUnsavedChanges(isDirty, { message? })` in `@wirecore/wirelayer-vue/form` and `@wirecore/wirelayer-react/form`
asks before the page is left with unsaved input. All registered forms share one list – leaving asks once with
`confirm()` however many forms changed; `beforeunload` only while one is changed; unmounting unregisters. Router
independent: `unsavedChangesGuard(to, from)` goes into the router (Vue Router: `router.beforeEach(unsavedChangesGuard)`),
only the query or hash changing does not ask; `confirmLeave()` for own links. New text `unsavedChanges.leave` in every
language.
24 changes: 24 additions & 0 deletions apps/storybook/src/Introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ const columns: DataTableColumn<Person>[] = [
`exportColumns` takes precedence over `exportHeader` and `exportValue`. In Excel the aggregate and the footer of a split
column go to its first part. The React Native DataTable exports the same way.

A TreeTable (`getSubRows`) exports all its rows by default. With `exportRows="leaves"` the CSV, Excel and print only
have the rows without children – for parents that just sum up their children ("Doe, Jane – 2 licences"); still
filtered and sorted like the table (with `treeFilterMode="lenient"` only the leaves that match themselves). The methods
take it as option: `generateCsv({ rows: 'leaves' })`. The selection (`selectionOnly`) is exported as it is.

## DataTable: hidden columns and saved state

A column with `hidden: true` starts hidden; the column menu (`columnToggle`) shows it. Hidden columns are neither
Expand All @@ -381,6 +386,25 @@ const columns: DataTableColumn<Person>[] = [

The React Native DataTable has no column menu: a column with `hidden` is not shown there.

## Forms: unsaved changes

`useUnsavedChanges(isDirty)` from `@wirecore/wirelayer-vue/form` (React: the hook of the same name from
`@wirecore/wirelayer-react/form`) asks before the page is left with unsaved input. Reload, closing the tab or another
address get the browser's own question; route changes ask once with `confirm()` – put `unsavedChangesGuard` into the
router. All forms of the page share one list, so two changed forms still ask once; a form unregisters when it unmounts.
Only the query or the hash changing does not ask. The text comes from the WireLayer translations (`unsavedChanges.leave`),
`{ message }` overrides it; `confirmLeave()` asks the same for own links and buttons.

```ts
// Each settings form (TanStack Form): changed while the values differ from the defaults
useUnsavedChanges(() => !form.state.isDefaultValue);
// After a successful save: the saved values become the defaults again
form.reset(values);

// Once, where the router is created (Vue Router; React Router: useBlocker with the same guard)
router.beforeEach(unsavedChangesGuard);
```

## AI assistants (MCP, llms.txt)

So that Claude, Cursor and others use the components correctly, the API is available as text and as an MCP server:
Expand Down
61 changes: 60 additions & 1 deletion packages/mcp/data/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -9563,6 +9563,12 @@
"optional": true,
"description": "Shows an export button; the CSV has the filtered and sorted rows of all pages (or the selection)"
},
{
"name": "exportRows",
"type": "'all' | 'leaves'",
"optional": true,
"description": "Rows of the CSV, Excel and print: `all` (default) or `leaves` – a TreeTable without the rows that have children (`getSubRows`), e.g. when a parent only sums up its children; still filtered and sorted like the table. The methods take it as option `rows`; `selectionOnly` is not affected"
},
{
"name": "csvSeparator",
"type": "string",
Expand Down Expand Up @@ -10280,6 +10286,12 @@
"optional": true,
"description": "Shows an export button; the CSV has the filtered and sorted rows of all pages (or the selection)"
},
{
"name": "exportRows",
"type": "'all' | 'leaves'",
"optional": true,
"description": "Rows of the CSV, Excel and print: `all` (default) or `leaves` – a TreeTable without the rows that have children (`getSubRows`), e.g. when a parent only sums up its children; still filtered and sorted like the table. The methods take it as option `rows`; `selectionOnly` is not affected"
},
{
"name": "csvSeparator",
"type": "string",
Expand Down Expand Up @@ -28749,6 +28761,12 @@
"optional": true,
"description": "Icon component before the label"
},
{
"name": "label",
"type": "string",
"optional": true,
"description": "Text of the segment without children; with `icon` (and no children) only the icon shows, this names it"
},
{
"name": "disabled",
"type": "boolean",
Expand Down Expand Up @@ -28776,6 +28794,12 @@
"optional": true,
"description": "Icon component before the label"
},
{
"name": "label",
"type": "string",
"optional": true,
"description": "Text of the segment without the default slot; with `icon` (and no slot) only the icon shows, this names it"
},
{
"name": "disabled",
"type": "boolean",
Expand Down Expand Up @@ -37584,6 +37608,11 @@
"subpath": "",
"description": "Asks for confirmation in the app-wide <ConfirmDialog />. Resolves with true (confirmed) or false (cancelled, Escape, a newer confirm())."
},
{
"name": "confirmLeave",
"subpath": "/form",
"description": ""
},
{
"name": "createDataController",
"subpath": "/data-table",
Expand Down Expand Up @@ -37849,6 +37878,11 @@
"subpath": "",
"description": ""
},
{
"name": "unsavedChangesGuard",
"subpath": "/form",
"description": ""
},
{
"name": "useClipboard",
"subpath": "",
Expand Down Expand Up @@ -38054,6 +38088,11 @@
"subpath": "",
"description": "Texts of the nearest LocaleProvider"
},
{
"name": "useUnsavedChanges",
"subpath": "/form",
"description": "Asks before the page is left while `isDirty()` – reload, closing the tab (the browser's question) and, with `unsavedChangesGuard` in the router, route changes. All forms of the page share one question. With TanStack Form: `useUnsavedChanges(() => !form.state.isDefaultValue)`, and `form.reset(values)` after a successful save."
},
{
"name": "useValidators",
"subpath": "/form",
Expand Down Expand Up @@ -38149,13 +38188,18 @@
{
"id": "introduction-datatable-export-csv-excel",
"title": "DataTable export (CSV, Excel)",
"text": "`exportFilename` shows the export button, `exportFormats` picks CSV, Excel (.xlsx) or both; `generateCsv()` and\n`generateXlsx()` return the file instead of downloading it. The export has the filtered and sorted rows of all pages (or\nthe selection) and the visible columns in their current order. Per column: `exportable: false` leaves it out,\n`exportHeader` and `exportValue` replace the name and the value, and `exportColumns` splits it into several columns at\nits position – the table keeps showing one column, and printing too:\n\n```ts\nconst columns: DataTableColumn<Person>[] = [\n {\n id: 'name',\n header: 'Name',\n accessor: (row) => `${row.lastName}, ${row.firstName}`, // shown: \"Doe, Jane\"\n exportColumns: [\n { header: 'First name', value: (row) => row.firstName },\n { header: 'Last name', value: (row) => row.lastName },\n ],\n },\n { id: 'club', header: 'Club' },\n];\n// CSV: First name;Last name;Club\n```\n\n`exportColumns` takes precedence over `exportHeader` and `exportValue`. In Excel the aggregate and the footer of a split\ncolumn go to its first part. The React Native DataTable exports the same way."
"text": "`exportFilename` shows the export button, `exportFormats` picks CSV, Excel (.xlsx) or both; `generateCsv()` and\n`generateXlsx()` return the file instead of downloading it. The export has the filtered and sorted rows of all pages (or\nthe selection) and the visible columns in their current order. Per column: `exportable: false` leaves it out,\n`exportHeader` and `exportValue` replace the name and the value, and `exportColumns` splits it into several columns at\nits position – the table keeps showing one column, and printing too:\n\n```ts\nconst columns: DataTableColumn<Person>[] = [\n {\n id: 'name',\n header: 'Name',\n accessor: (row) => `${row.lastName}, ${row.firstName}`, // shown: \"Doe, Jane\"\n exportColumns: [\n { header: 'First name', value: (row) => row.firstName },\n { header: 'Last name', value: (row) => row.lastName },\n ],\n },\n { id: 'club', header: 'Club' },\n];\n// CSV: First name;Last name;Club\n```\n\n`exportColumns` takes precedence over `exportHeader` and `exportValue`. In Excel the aggregate and the footer of a split\ncolumn go to its first part. The React Native DataTable exports the same way.\n\nA TreeTable (`getSubRows`) exports all its rows by default. With `exportRows=\"leaves\"` the CSV, Excel and print only\nhave the rows without children – for parents that just sum up their children (\"Doe, Jane – 2 licences\"); still\nfiltered and sorted like the table (with `treeFilterMode=\"lenient\"` only the leaves that match themselves). The methods\ntake it as option: `generateCsv({ rows: 'leaves' })`. The selection (`selectionOnly`) is exported as it is."
},
{
"id": "introduction-datatable-hidden-columns-and-saved-state",
"title": "DataTable: hidden columns and saved state",
"text": "A column with `hidden: true` starts hidden; the column menu (`columnToggle`) shows it. Hidden columns are neither\nexported nor printed. `hiddenColumns` (v-model) sets the hidden columns of the whole table – while it is set, its value\ndecides alone and `hidden` is not used. `hideable: false` wins over `hidden` (with a warning in development).\n\n`stateKey` saves sorting, filters, widths, order and the hidden columns in the browser (`stateStorage`: session or\nlocal) and restores them on the next visit; `stateExclude` leaves parts out. The saved state also lists the columns it\nknows (`knownColumns`): for those the user's choice stays, a column added later starts with its `hidden` value – an\noptional column does not suddenly appear for users with a saved state. A state saved before (without `knownColumns`)\ntreats every column with `hidden` as new.\n\n```ts\nconst columns: DataTableColumn<Person>[] = [\n { id: 'name', header: 'Name', accessor: (row) => `${row.lastName}, ${row.firstName}` },\n { id: 'firstName', header: 'First name', sortable: true, hidden: true, exportable: false },\n { id: 'lastName', header: 'Last name', sortable: true, hidden: true, exportable: false },\n];\n```\n\nThe React Native DataTable has no column menu: a column with `hidden` is not shown there."
},
{
"id": "introduction-forms-unsaved-changes",
"title": "Forms: unsaved changes",
"text": "`useUnsavedChanges(isDirty)` from `@wirecore/wirelayer-vue/form` (React: the hook of the same name from\n`@wirecore/wirelayer-react/form`) asks before the page is left with unsaved input. Reload, closing the tab or another\naddress get the browser's own question; route changes ask once with `confirm()` – put `unsavedChangesGuard` into the\nrouter. All forms of the page share one list, so two changed forms still ask once; a form unregisters when it unmounts.\nOnly the query or the hash changing does not ask. The text comes from the WireLayer translations (`unsavedChanges.leave`),\n`{ message }` overrides it; `confirmLeave()` asks the same for own links and buttons.\n\n```ts\n// Each settings form (TanStack Form): changed while the values differ from the defaults\nuseUnsavedChanges(() => !form.state.isDefaultValue);\n// After a successful save: the saved values become the defaults again\nform.reset(values);\n\n// Once, where the router is created (Vue Router; React Router: useBlocker with the same guard)\nrouter.beforeEach(unsavedChangesGuard);\n```"
},
{
"id": "introduction-ai-assistants-mcp-llms-txt",
"title": "AI assistants (MCP, llms.txt)",
Expand Down Expand Up @@ -52223,6 +52267,11 @@
"subpath": "",
"description": "Asks for confirmation in the app-wide <ConfirmDialog />. Resolves with true (confirmed) or false (cancelled, Escape, a newer confirm())."
},
{
"name": "confirmLeave",
"subpath": "/form",
"description": ""
},
{
"name": "createDataController",
"subpath": "/data-table",
Expand Down Expand Up @@ -52493,6 +52542,11 @@
"subpath": "",
"description": ""
},
{
"name": "unsavedChangesGuard",
"subpath": "/form",
"description": ""
},
{
"name": "useClipboard",
"subpath": "",
Expand Down Expand Up @@ -52698,6 +52752,11 @@
"subpath": "",
"description": "Texts of the nearest LocaleProvider; `const t = translations.dataTable` stays current, too"
},
{
"name": "useUnsavedChanges",
"subpath": "/form",
"description": "Asks before the page is left while `isDirty()` – reload, closing the tab (the browser's question) and, with `unsavedChangesGuard` in the router, route changes. All forms of the page share one question. With TanStack Form: `useUnsavedChanges(() => !form.state.isDefaultValue)`, and `form.reset(values)` after a successful save."
},
{
"name": "useValidators",
"subpath": "/form",
Expand Down
9 changes: 9 additions & 0 deletions packages/parity/e2e/overlays.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ test.describe('Dialog', () => {
await expect(page.getByRole('textbox', { name: 'Name' })).toBeFocused();
});

test('data-autofocus on a component root: its first field gets the focus when the dialog opens', async ({
page,
}) => {
await openStory(page, 'overlays-dialog--initial-focus-on-component');
await page.getByRole('button', { name: 'Add member' }).click();
await expect(page.getByRole('dialog', { name: 'Add member' })).toBeVisible();
await expect(page.getByLabel('Filter options')).toBeFocused();
});

test('traps focus while open and returns it to the trigger on Escape', async ({ page }) => {
await openStory(page, 'overlays-dialog--playground');
const trigger = page.getByRole('button', { name: 'Delete server' });
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/parity/src/app-extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ describe('focusFirst and autoselectElement', () => {
expect([(b as HTMLInputElement).selectionStart, (b as HTMLInputElement).selectionEnd]).toEqual([0, 3]);
expect(autoselectElement(mount('<div><input></div>'))).toBeUndefined();
});

it('autoselectElement: data-autofocus also on a wrapper, without selecting', () => {
const box = mount(
'<div><button>Close</button><div data-autofocus><input aria-label="Search" value="abc"></div></div>'
);
const search = autoselectElement(box)! as HTMLInputElement;
expect(search).toBe(box.querySelector('[aria-label=Search]'));
search.focus();
expect(search.selectionStart).toBe(search.selectionEnd);
});
});

describe('resolveTokens and watchTokens', () => {
Expand Down
Loading
Loading