diff --git a/.changeset/data-table-menu-check-space.md b/.changeset/data-table-menu-check-space.md new file mode 100644 index 0000000..e5dafd5 --- /dev/null +++ b/.changeset/data-table-menu-check-space.md @@ -0,0 +1,7 @@ +--- +'@wirecore/wirelayer-vue': patch +'@wirecore/wirelayer-react': patch +--- + +DataTable: the column menu (`columnToggle`) and the density menu keep the space of the check mark for items without +one, like the Menu component – the labels of hidden columns no longer move to the left. diff --git a/.changeset/search-clear-pointer.md b/.changeset/search-clear-pointer.md new file mode 100644 index 0000000..a9f1e77 --- /dev/null +++ b/.changeset/search-clear-pointer.md @@ -0,0 +1,7 @@ +--- +'@wirecore/wirelayer-recipes': patch +'@wirecore/wirelayer-css': patch +--- + +Text fields with `type="search"` (DataTable search and find, LogViewer, JsonViewer, EmojiPicker, PdfViewer, Tree +search): the browser's own clear button (×) shows the pointer cursor, like the clear buttons of the text controls. diff --git a/packages/parity/src/data-table.test.ts b/packages/parity/src/data-table.test.ts index feb8a0c..4b6e727 100644 --- a/packages/parity/src/data-table.test.ts +++ b/packages/parity/src/data-table.test.ts @@ -2704,6 +2704,10 @@ describe.each(frameworks)('%s DataTable: reset, saved state, column settings', ( await user.click(screen.getByRole('button', { name: 'Columns' })); const since = await screen.findByRole('menuitemcheckbox', { name: 'Since' }); expect(since).toHaveAttribute('aria-checked', 'false'); + // The box of the check mark keeps its space without a check, so the labels line up + const box = (name: string) => screen.getByRole('menuitemcheckbox', { name }).firstElementChild; + expect(box('Since')).toHaveClass('size-4', 'shrink-0'); + expect(box('Name')).toHaveClass('size-4', 'shrink-0'); await user.click(since); await waitFor(() => expect(headers()).toEqual(['Name', 'Location', 'Load', 'Since'])); expect(handle!.generateCsv({ bom: false }).split('\r\n')[0]).toBe('Name,Location,Load,Since'); diff --git a/packages/parity/src/recipes.test.ts b/packages/parity/src/recipes.test.ts index 011142d..2314f59 100644 --- a/packages/parity/src/recipes.test.ts +++ b/packages/parity/src/recipes.test.ts @@ -1,7 +1,17 @@ import { screen, waitFor, within } from '@testing-library/dom'; import userEvent from '@testing-library/user-event'; import { describe, expect, it, vi } from 'vitest'; -import { button, buttonColorKey, tv, withRecipeOverrides } from '@wirecore/wirelayer-recipes'; +import { + button, + buttonColorKey, + input, + numberInput, + passwordInput, + textareaParts, + tree, + tv, + withRecipeOverrides, +} from '@wirecore/wirelayer-recipes'; import { el, frameworks, icon, render } from './harness.js'; // Own defaults and classes: RecipesProvider for every component below, `classes` for one component @@ -359,3 +369,16 @@ describe.each(frameworks)('%s Scheduler', (framework) => { expect(screen.getByRole('heading', { level: 3, name: 'Tuesday, March 16, 2027' })).toBeInTheDocument(); }); }); + +describe('clear buttons of the text controls', () => { + it.each(['sm', 'md', 'lg'] as const)('show the pointer, size %s (Input, NumberInput, PasswordInput)', (size) => { + for (const recipe of [input, numberInput, passwordInput]) + expect(recipe({ size }).clear().split(' ')).toContain('cursor-pointer'); + }); + + it('Textarea and the browser clear button of type="search" (Input, Tree search) show it too', () => { + expect(textareaParts().clear().split(' ')).toContain('cursor-pointer'); + expect(input().control().split(' ')).toContain('[&::-webkit-search-cancel-button]:cursor-pointer'); + expect(tree().search().split(' ')).toContain('[&::-webkit-search-cancel-button]:cursor-pointer'); + }); +}); diff --git a/packages/react/src/data-table/DataTable.tsx b/packages/react/src/data-table/DataTable.tsx index 8d65734..46fc52a 100644 --- a/packages/react/src/data-table/DataTable.tsx +++ b/packages/react/src/data-table/DataTable.tsx @@ -3747,9 +3747,14 @@ export function DataTable({ value={option} className={menuStyles.item()} > - - + + + + {t.densities[option]} @@ -3787,9 +3792,14 @@ export function DataTable({ class: indent ? styles.columnGroupItem() : undefined, })} > - - + + + + {label(column)} @@ -3819,12 +3829,14 @@ export function DataTable({ closeOnSelect={false} className={menuStyles.item()} > - - + + + + {def.header} diff --git a/packages/recipes/src/field.ts b/packages/recipes/src/field.ts index fcaf605..014a520 100644 --- a/packages/recipes/src/field.ts +++ b/packages/recipes/src/field.ts @@ -34,7 +34,11 @@ export const inputStatusParts = { export const input = tv({ slots: { base: 'flex w-full items-stretch overflow-hidden border border-line-strong bg-bg text-fg transition-colors focus-within:border-primary motion-reduce:transition-none', - control: 'min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted disabled:cursor-not-allowed', + control: [ + 'min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted disabled:cursor-not-allowed', + // The browser's own clear button of type="search" (DataTable search …) is a button, too + '[&::-webkit-search-cancel-button]:cursor-pointer', + ], icon: 'pointer-events-none shrink-0 self-center text-muted', statusIcon: 'pointer-events-none shrink-0 self-center text-danger', prefix: 'flex shrink-0 items-center border-e border-line-strong bg-bg-2 px-3 font-mono text-xs text-muted', diff --git a/packages/recipes/src/hierarchy.ts b/packages/recipes/src/hierarchy.ts index f709b17..284261f 100644 --- a/packages/recipes/src/hierarchy.ts +++ b/packages/recipes/src/hierarchy.ts @@ -53,7 +53,7 @@ export const tree = tv({ toolbar: 'flex flex-wrap items-center gap-1.5', search: [ 'h-8 min-w-0 flex-1 rounded-md border border-line-strong bg-bg px-2.5 text-sm text-fg outline-none', - 'placeholder:text-muted focus:border-primary', + 'placeholder:text-muted focus:border-primary [&::-webkit-search-cancel-button]:cursor-pointer', ], /** Row below a branch while its children load (indented like its children) */ loadingRow: 'flex h-8 items-center gap-2 pe-2 ps-[calc(var(--depth)*20px+32px)] text-sm text-muted', diff --git a/packages/vue/src/data-table/DataTable.vue b/packages/vue/src/data-table/DataTable.vue index 1cfd56d..e7b5b70 100644 --- a/packages/vue/src/data-table/DataTable.vue +++ b/packages/vue/src/data-table/DataTable.vue @@ -3305,9 +3305,11 @@ const toolbarSize = sizeOverrides('sm') as RecipeConfig; :value="option" :class="menuStyles.item()" > - - + + + + {{ t.densities[option] }} @@ -3342,9 +3344,11 @@ const toolbarSize = sizeOverrides('sm') as RecipeConfig; :class="menuStyles.item()" @update:checked="setBlockVisible(block.leaves, $event)" > - - + + + + {{ block.def.header }} @@ -3362,9 +3366,11 @@ const toolbarSize = sizeOverrides('sm') as RecipeConfig; " @update:checked="column.toggleVisibility($event)" > - - + + + + {{ label(column) }}