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
7 changes: 7 additions & 0 deletions .changeset/data-table-menu-check-space.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions .changeset/search-clear-pointer.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions packages/parity/src/data-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
25 changes: 24 additions & 1 deletion packages/parity/src/recipes.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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');
});
});
36 changes: 24 additions & 12 deletions packages/react/src/data-table/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3747,9 +3747,14 @@ export function DataTable<TData extends object>({
value={option}
className={menuStyles.item()}
>
<ArkMenu.ItemIndicator>
<Check className={styles.menuCheck()} aria-hidden="true" />
</ArkMenu.ItemIndicator>
<span className={menuStyles.indicator()}>
<ArkMenu.ItemIndicator>
<Check
className={styles.menuCheck()}
aria-hidden="true"
/>
</ArkMenu.ItemIndicator>
</span>
<ArkMenu.ItemText className={menuStyles.label()}>
{t.densities[option]}
</ArkMenu.ItemText>
Expand Down Expand Up @@ -3787,9 +3792,14 @@ export function DataTable<TData extends object>({
class: indent ? styles.columnGroupItem() : undefined,
})}
>
<ArkMenu.ItemIndicator>
<Check className={styles.menuCheck()} aria-hidden="true" />
</ArkMenu.ItemIndicator>
<span className={menuStyles.indicator()}>
<ArkMenu.ItemIndicator>
<Check
className={styles.menuCheck()}
aria-hidden="true"
/>
</ArkMenu.ItemIndicator>
</span>
<ArkMenu.ItemText className={menuStyles.label()}>
{label(column)}
</ArkMenu.ItemText>
Expand Down Expand Up @@ -3819,12 +3829,14 @@ export function DataTable<TData extends object>({
closeOnSelect={false}
className={menuStyles.item()}
>
<ArkMenu.ItemIndicator>
<Check
className={styles.menuCheck()}
aria-hidden="true"
/>
</ArkMenu.ItemIndicator>
<span className={menuStyles.indicator()}>
<ArkMenu.ItemIndicator>
<Check
className={styles.menuCheck()}
aria-hidden="true"
/>
</ArkMenu.ItemIndicator>
</span>
<ArkMenu.ItemText className={menuStyles.label()}>
{def.header}
</ArkMenu.ItemText>
Expand Down
6 changes: 5 additions & 1 deletion packages/recipes/src/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/recipes/src/hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
24 changes: 15 additions & 9 deletions packages/vue/src/data-table/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3305,9 +3305,11 @@ const toolbarSize = sizeOverrides('sm') as RecipeConfig;
:value="option"
:class="menuStyles.item()"
>
<Menu.ItemIndicator>
<Check :class="styles.menuCheck()" aria-hidden="true" />
</Menu.ItemIndicator>
<span :class="menuStyles.indicator()">
<Menu.ItemIndicator>
<Check :class="styles.menuCheck()" aria-hidden="true" />
</Menu.ItemIndicator>
</span>
<Menu.ItemText :class="menuStyles.label()">{{
t.densities[option]
}}</Menu.ItemText>
Expand Down Expand Up @@ -3342,9 +3344,11 @@ const toolbarSize = sizeOverrides('sm') as RecipeConfig;
:class="menuStyles.item()"
@update:checked="setBlockVisible(block.leaves, $event)"
>
<Menu.ItemIndicator>
<Check :class="styles.menuCheck()" aria-hidden="true" />
</Menu.ItemIndicator>
<span :class="menuStyles.indicator()">
<Menu.ItemIndicator>
<Check :class="styles.menuCheck()" aria-hidden="true" />
</Menu.ItemIndicator>
</span>
<Menu.ItemText :class="menuStyles.label()">{{
block.def.header
}}</Menu.ItemText>
Expand All @@ -3362,9 +3366,11 @@ const toolbarSize = sizeOverrides('sm') as RecipeConfig;
"
@update:checked="column.toggleVisibility($event)"
>
<Menu.ItemIndicator>
<Check :class="styles.menuCheck()" aria-hidden="true" />
</Menu.ItemIndicator>
<span :class="menuStyles.indicator()">
<Menu.ItemIndicator>
<Check :class="styles.menuCheck()" aria-hidden="true" />
</Menu.ItemIndicator>
</span>
<Menu.ItemText :class="menuStyles.label()">{{
label(column)
}}</Menu.ItemText>
Expand Down
Loading