@majapisoftwares/ui 6.9.0 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -0
- package/docs/STANDARDS.md +16 -0
- package/package.json +2 -1
- package/scripts/check-standards.mjs +58 -6
- package/src/hooks/use-live-refresh.ts +28 -0
- package/src/lib/i18n.tsx +4 -0
- package/src/patterns/app-shell.tsx +130 -11
- package/src/patterns/data-table.tsx +25 -16
package/AGENTS.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
- Toda mudança na biblioteca que afete apps entra no mesmo commit no starter (`starters/next-app`) e no catálogo. O starter sempre depende da versão atual da biblioteca (o teste `npm run test:starter` falha se divergir) e deve compilar e passar lint/typecheck/build com ela.
|
|
5
5
|
- Todo app é bilíngue: inglês (`en`) e português (`pt-BR`). Textos de UI ficam em catálogos `defineMessages` com as duas línguas; nada de texto fixo em componentes. Use `Preferences`/`PreferenceControls` da biblioteca para idioma e tema.
|
|
6
6
|
- Mantenha o texto mínimo: sem descrições, avisos ou rótulos que não ajudem a tarefa.
|
|
7
|
+
- Navegação da página é do `AppShell`: passe `breadcrumbs` e não crie botões de voltar, breadcrumbs próprios nem títulos ou rótulos que repitam o nome da página (docs/STANDARDS.md, "Navegação da página"; o `check:standards` bloqueia).
|
|
8
|
+
- Telas com dados se atualizam sozinhas com `useLiveRefresh` (`hooks/use-live-refresh`); nunca botão de atualizar (docs/STANDARDS.md, "Dados ao vivo").
|
|
7
9
|
- `patterns/data-table` (TanStack Table, vindo da Numa) é a única tabela de dados: filtros por coluna, ordenação múltipla, colunas reordenáveis/ocultáveis/redimensionáveis, seleção, persistência e estados. Melhorias de tabela são feitas aqui e chegam a todos os apps por versão; apps não mantêm cópias próprias.
|
|
8
10
|
- Ao trazer componentes de outros apps, remova sobrescritas visuais (arredondamento, altura, sombra, padding, cores) e deixe os primitivos da biblioteca definirem o visual; containers usam os raios já adotados aqui (ex.: rounded-2xl em tabelas e listas).
|
|
9
11
|
- Seleção usa sempre o Select (Base UI) da biblioteca; não use select nativo nem NativeSelect (o check:standards bloqueia).
|
package/docs/STANDARDS.md
CHANGED
|
@@ -76,3 +76,19 @@ Adaptações: `MessageScrollerItem` usa `-m-2 p-2` (e `MessageScrollerContent`,
|
|
|
76
76
|
## Contextual tool navigation
|
|
77
77
|
|
|
78
78
|
AppShell navigation items accept optional `children` for one level of related tool views. Only the active tool expands. The current destination alone receives aria-current. Navigation closes the mobile sidebar after selection. Sidebar subitems have 44px touch targets on mobile. Use route navigation here; reserve FilterTabs for filters or views of the current dataset. Use `fillHeight` for contained table/chat pages and ordinary page flow for long forms and card collections.
|
|
79
|
+
|
|
80
|
+
## Navegação da página
|
|
81
|
+
|
|
82
|
+
Uma página tem um jeito só de subir: o breadcrumb do `AppShell`. Nunca dois controles para o mesmo destino.
|
|
83
|
+
|
|
84
|
+
- O app passa `breadcrumbs` (`{ label, href? }[]`, a página atual por último) e `onBreadcrumbNavigate`; o shell desenha o cabeçalho igual em todo app. Apps não montam breadcrumbs (`components/breadcrumb`) nem usam o slot `header`, que está obsoleto.
|
|
85
|
+
- A partir de `md`: a trilha inteira, sem botão de voltar. Nos telefones: só a página atual, numa linha, depois de uma seta de voltar para o pai com link mais próximo.
|
|
86
|
+
- Só pais de verdade ganham `href`. Um grupo que só reúne páginas irmãs (Configurações › Padrões) fica sem link: a sidebar abre essas páginas, e o telefone não mostra seta. Uma página que a sidebar abre não tem nenhum link no breadcrumb; só a página de um item tem.
|
|
87
|
+
- A página de um item (um quadro, uma sessão) fica abaixo da lista dele: `Quadros › Workbench launch`. Quando o caminho muda o lugar (uma sessão aberta de um quadro), a trilha mostra esse lugar (`Quadros › quadro › sessão`) em vez de um botão "Voltar ao quadro" no conteúdo.
|
|
88
|
+
- Páginas não têm botões nem links de voltar, nem `router.back()`. O nome da página aparece uma vez, no breadcrumb; o `h1` da página é `sr-only`. Nada no conteúdo repete esse nome: nem título, nem rótulo de campo (uma página com um campo Harness não se chama Harness). Enquanto o nome carrega, `label: null` mostra um Skeleton no lugar.
|
|
89
|
+
- Páginas fora do shell (`AuthLayout`: login, links abertos de fora) não têm breadcrumb e podem oferecer uma ação de retorno.
|
|
90
|
+
- `check:standards` bloqueia, no app: importar `components/breadcrumb`, link com seta para a esquerda ou rótulo `t.back…`, `router.back()`/`history.back()`, `h1` visível e botão de atualizar. Apps cobrem o resto com um teste e2e por rota: em desktop nenhum controle de voltar e, numa página da sidebar, nenhum link no breadcrumb; no telefone no máximo um voltar, no cabeçalho; nenhum botão de atualizar; e o nome da página não se repete no conteúdo.
|
|
91
|
+
|
|
92
|
+
## Dados ao vivo
|
|
93
|
+
|
|
94
|
+
Listas e telas com dados se atualizam sozinhas: `useLiveRefresh(load, ms)` (`hooks/use-live-refresh`) chama `load` a cada `ms` (5 s por padrão) com a página visível e logo que a pessoa volta para ela. Não há botão de atualizar. Leituras caras usam um intervalo maior (um scan na nuvem a cada minutos, não segundos), nunca um botão. Tentar de novo depois de uma falha (`onRetry`) continua, porque é outra coisa.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@majapisoftwares/ui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"description": "Shared Majapi UI and UX standards based on shadcn/ui",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"test:chat-quote": "tsx --test scripts/chat-quote.test.tsx",
|
|
47
47
|
"test:chat-markdown": "tsx --test scripts/chat-markdown.test.tsx",
|
|
48
48
|
"test:ai-elements": "tsx --test scripts/ai-elements.test.tsx",
|
|
49
|
+
"test:navigation": "tsx --test scripts/navigation.test.tsx",
|
|
49
50
|
"verify": "node scripts/verify.mjs"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
@@ -1,8 +1,54 @@
|
|
|
1
1
|
import { readdir, readFile } from "node:fs/promises";
|
|
2
2
|
import { resolve, relative } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
3
4
|
const consumer = process.argv[2];
|
|
4
5
|
const root = resolve(consumer ?? "src");
|
|
5
6
|
const violations = [];
|
|
7
|
+
|
|
8
|
+
// A link (or a Button rendering one) that goes back: a left arrow or a
|
|
9
|
+
// `back…` label. Inside the AppShell the breadcrumb is the way up, and the
|
|
10
|
+
// shell adds the phone's back arrow itself.
|
|
11
|
+
const backSign =
|
|
12
|
+
/\b(?:ArrowLeft|ChevronLeft|MoveLeft|CornerUpLeft|Undo2?)Icon\b|\bt\.back(?:[A-Z]\w*)?\b/;
|
|
13
|
+
export function backLink(text) {
|
|
14
|
+
for (const match of text.matchAll(/<(Button|Link|a|BreadcrumbLink)\b/g)) {
|
|
15
|
+
const close = text.indexOf(`</${match[1]}>`, match.index);
|
|
16
|
+
const block = text.slice(match.index, Math.min(close === -1 ? Infinity : close, match.index + 600));
|
|
17
|
+
if (/\bhref=|render=\{\s*<(?:Link|a)\b/.test(block) && backSign.test(block)) return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** What a consumer file breaks of the page-navigation rules (docs/STANDARDS.md, "Navegação da página"). */
|
|
23
|
+
export function navigationViolations(text) {
|
|
24
|
+
const found = [];
|
|
25
|
+
if (/from\s+["']@majapisoftwares\/ui\/components\/breadcrumb["']/.test(text))
|
|
26
|
+
found.push("pass breadcrumbs to AppShell; the shell draws the page's navigation");
|
|
27
|
+
// Pages outside the shell (AuthLayout) have no breadcrumb; their one way back is theirs to show.
|
|
28
|
+
if (/<AuthLayout\b/.test(text)) return found;
|
|
29
|
+
if (backLink(text) || /\b(?:router|history)\.back\(/.test(text))
|
|
30
|
+
found.push("no back buttons in pages; the AppShell breadcrumb links up (with a back arrow on phones)");
|
|
31
|
+
if (/<h1\b(?![^>]*\bsr-only\b)/.test(text))
|
|
32
|
+
found.push("the breadcrumb names the page; keep its h1 for screen readers (sr-only)");
|
|
33
|
+
if (refreshButton(text))
|
|
34
|
+
found.push("no refresh buttons; keep the screen current with useLiveRefresh (@majapisoftwares/ui/hooks/use-live-refresh)");
|
|
35
|
+
return found;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A Button that reloads what's on screen: a refresh label, or an icon-only
|
|
39
|
+
// button with a rotate icon. A retry after a failure, and actions with their
|
|
40
|
+
// own label (Sync now, Reconnect), aren't refresh buttons.
|
|
41
|
+
const rotateIcon = /\b(?:Refresh|Rotate)(?:Cw|Ccw)Icon\b/;
|
|
42
|
+
export function refreshButton(text) {
|
|
43
|
+
for (const match of text.matchAll(/<Button\b/g)) {
|
|
44
|
+
const close = text.indexOf("</Button>", match.index);
|
|
45
|
+
const block = text.slice(match.index, Math.min(close === -1 ? Infinity : close, match.index + 600));
|
|
46
|
+
if (/\b(?:t|ui|messages)\.retry\b/.test(block)) continue;
|
|
47
|
+
if (/\bt\.refresh\b/.test(block) || (/\bsize="icon[^"]*"/.test(block) && rotateIcon.test(block))) return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
6
52
|
async function visit(path) {
|
|
7
53
|
for (const entry of await readdir(path, { withFileTypes: true })) {
|
|
8
54
|
if (["node_modules", "dist", ".git"].includes(entry.name)) continue;
|
|
@@ -31,13 +77,19 @@ async function visit(path) {
|
|
|
31
77
|
violations.push(`${name}: use semantic tokens instead of local colors`);
|
|
32
78
|
if (consumer && /from\s+["'](?:sonner|@majapisoftwares\/ui\/components\/(?:sonner|snackbar))["']/.test(text))
|
|
33
79
|
violations.push(`${name}: notify with toast from @majapisoftwares/ui/components/toast`);
|
|
80
|
+
if (consumer)
|
|
81
|
+
for (const rule of navigationViolations(text)) violations.push(`${name}: ${rule}`);
|
|
34
82
|
if (!consumer && /from ["']@\//.test(text))
|
|
35
83
|
violations.push(`${name}: library internals must use portable imports`);
|
|
36
84
|
}
|
|
37
85
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
86
|
+
|
|
87
|
+
// Imported by its test: only a direct run checks a tree.
|
|
88
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
89
|
+
await visit(root);
|
|
90
|
+
if (violations.length) {
|
|
91
|
+
console.error(violations.join("\n"));
|
|
92
|
+
process.exitCode = 1;
|
|
93
|
+
} else
|
|
94
|
+
console.log(`UI standards passed (${consumer ? "consumer" : "library"}).`);
|
|
95
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Keeps a screen current, so it never needs a refresh button: calls `refresh`
|
|
7
|
+
* every `ms` while the page is visible, and right away when the person comes
|
|
8
|
+
* back to it (focus or a visible tab). The first load stays with the caller.
|
|
9
|
+
*/
|
|
10
|
+
export function useLiveRefresh(refresh: () => void, ms = 5000) {
|
|
11
|
+
const latest = useRef(refresh);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
latest.current = refresh;
|
|
14
|
+
});
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const run = () => {
|
|
17
|
+
if (!document.hidden) latest.current();
|
|
18
|
+
};
|
|
19
|
+
const timer = setInterval(run, ms);
|
|
20
|
+
document.addEventListener("visibilitychange", run);
|
|
21
|
+
window.addEventListener("focus", run);
|
|
22
|
+
return () => {
|
|
23
|
+
clearInterval(timer);
|
|
24
|
+
document.removeEventListener("visibilitychange", run);
|
|
25
|
+
window.removeEventListener("focus", run);
|
|
26
|
+
};
|
|
27
|
+
}, [ms]);
|
|
28
|
+
}
|
package/src/lib/i18n.tsx
CHANGED
|
@@ -68,6 +68,8 @@ export const uiMessages = defineMessages({
|
|
|
68
68
|
page: (page: number, total: number) => `Page ${page} of ${total}`,
|
|
69
69
|
rows: (count: number) => `${count} ${count === 1 ? "row" : "rows"}`,
|
|
70
70
|
close: "Close",
|
|
71
|
+
back: "Back",
|
|
72
|
+
backTo: (name: string) => `Back to ${name}`,
|
|
71
73
|
language: "Language",
|
|
72
74
|
toggleTheme: "Toggle theme",
|
|
73
75
|
more: "More",
|
|
@@ -158,6 +160,8 @@ export const uiMessages = defineMessages({
|
|
|
158
160
|
page: (page: number, total: number) => `Página ${page} de ${total}`,
|
|
159
161
|
rows: (count: number) => `${count} ${count === 1 ? "linha" : "linhas"}`,
|
|
160
162
|
close: "Fechar",
|
|
163
|
+
back: "Voltar",
|
|
164
|
+
backTo: (name: string) => `Voltar para ${name}`,
|
|
161
165
|
language: "Idioma",
|
|
162
166
|
toggleTheme: "Alternar tema",
|
|
163
167
|
more: "Mais",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import type
|
|
3
|
+
import { Fragment, type MouseEvent, type ReactNode } from "react";
|
|
4
4
|
import { cn } from "cn";
|
|
5
|
+
import { ArrowLeftIcon } from "lucide-react";
|
|
5
6
|
import {
|
|
6
7
|
Sidebar,
|
|
7
8
|
SidebarCollapse,
|
|
@@ -25,6 +26,17 @@ import {
|
|
|
25
26
|
} from "../components/ui/sidebar";
|
|
26
27
|
import { Separator } from "../components/ui/separator";
|
|
27
28
|
import { TooltipProvider } from "../components/ui/tooltip";
|
|
29
|
+
import { buttonVariants } from "../components/ui/button";
|
|
30
|
+
import { Skeleton } from "../components/ui/skeleton";
|
|
31
|
+
import {
|
|
32
|
+
Breadcrumb,
|
|
33
|
+
BreadcrumbItem,
|
|
34
|
+
BreadcrumbLink,
|
|
35
|
+
BreadcrumbList,
|
|
36
|
+
BreadcrumbPage,
|
|
37
|
+
BreadcrumbSeparator,
|
|
38
|
+
} from "../components/ui/breadcrumb";
|
|
39
|
+
import { useUiMessages } from "../lib/i18n";
|
|
28
40
|
|
|
29
41
|
export interface NavigationItem {
|
|
30
42
|
id: string;
|
|
@@ -41,6 +53,18 @@ export interface NavigationGroup {
|
|
|
41
53
|
items: NavigationItem[];
|
|
42
54
|
}
|
|
43
55
|
|
|
56
|
+
/** One step of the page's breadcrumb. */
|
|
57
|
+
export interface ShellBreadcrumb {
|
|
58
|
+
/** `null` while the name loads (a skeleton shows in its place). */
|
|
59
|
+
label: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* A page above this one. Only real parents get an href: on phones the
|
|
62
|
+
* nearest one becomes the header's back arrow. A group that only collects
|
|
63
|
+
* sibling pages (the sidebar opens them) has none.
|
|
64
|
+
*/
|
|
65
|
+
href?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
export interface AppShellProps {
|
|
45
69
|
/** Square logo; stays in place in every sidebar mode. */
|
|
46
70
|
logo: ReactNode;
|
|
@@ -49,7 +73,19 @@ export interface AppShellProps {
|
|
|
49
73
|
navigation: NavigationGroup[];
|
|
50
74
|
activeId: string;
|
|
51
75
|
onNavigate: (id: string) => void;
|
|
52
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Where the page sits, the current page last. The shell owns the page's
|
|
78
|
+
* navigation: from `md` up it shows the whole trail and no back button; on
|
|
79
|
+
* phones it shows the current page, after a back arrow to the nearest
|
|
80
|
+
* linked parent. Pages never add their own back buttons.
|
|
81
|
+
*/
|
|
82
|
+
breadcrumbs?: ShellBreadcrumb[];
|
|
83
|
+
/** Client-side navigation for breadcrumb links and the back arrow (e.g. `router.push`). Without it they are plain links. */
|
|
84
|
+
onBreadcrumbNavigate?: (href: string) => void;
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated Pass `breadcrumbs`: the shell draws them the same way in
|
|
87
|
+
* every app. Rendered only when `breadcrumbs` is not set.
|
|
88
|
+
*/
|
|
53
89
|
header?: ReactNode;
|
|
54
90
|
/** Rendered at the end of the header, e.g. locale or theme switchers. */
|
|
55
91
|
actions?: ReactNode;
|
|
@@ -96,6 +132,85 @@ function HeaderTrigger() {
|
|
|
96
132
|
);
|
|
97
133
|
}
|
|
98
134
|
|
|
135
|
+
const plainClick = (event: MouseEvent<HTMLElement>) =>
|
|
136
|
+
event.button === 0 &&
|
|
137
|
+
!event.metaKey &&
|
|
138
|
+
!event.ctrlKey &&
|
|
139
|
+
!event.shiftKey &&
|
|
140
|
+
!event.altKey;
|
|
141
|
+
|
|
142
|
+
function ShellBreadcrumbs({
|
|
143
|
+
items,
|
|
144
|
+
onNavigate,
|
|
145
|
+
}: {
|
|
146
|
+
items: ShellBreadcrumb[];
|
|
147
|
+
onNavigate?: (href: string) => void;
|
|
148
|
+
}) {
|
|
149
|
+
const t = useUiMessages();
|
|
150
|
+
const parent = items.slice(0, -1).reverse().find((item) => item.href);
|
|
151
|
+
const follow = (href: string) => (event: MouseEvent<HTMLElement>) => {
|
|
152
|
+
if (!onNavigate || !plainClick(event)) return;
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
onNavigate(href);
|
|
155
|
+
};
|
|
156
|
+
const name = (item: ShellBreadcrumb) =>
|
|
157
|
+
item.label ?? <Skeleton className="h-4 w-24" />;
|
|
158
|
+
return (
|
|
159
|
+
<div className="flex min-w-0 items-center gap-1">
|
|
160
|
+
{/* Phones only: one way back, in place of the parents' links. A link
|
|
161
|
+
(it navigates), styled as the ghost icon button. */}
|
|
162
|
+
{parent?.href ? (
|
|
163
|
+
<a
|
|
164
|
+
href={parent.href}
|
|
165
|
+
onClick={follow(parent.href)}
|
|
166
|
+
aria-label={parent.label ? t.backTo(parent.label) : t.back}
|
|
167
|
+
className={cn(
|
|
168
|
+
buttonVariants({ variant: "ghost", size: "icon-sm" }),
|
|
169
|
+
"-ml-1.5 shrink-0 md:hidden",
|
|
170
|
+
)}
|
|
171
|
+
>
|
|
172
|
+
<ArrowLeftIcon />
|
|
173
|
+
</a>
|
|
174
|
+
) : null}
|
|
175
|
+
<Breadcrumb className="min-w-0">
|
|
176
|
+
<BreadcrumbList className="flex-nowrap">
|
|
177
|
+
{items.map((item, index) => {
|
|
178
|
+
const last = index === items.length - 1;
|
|
179
|
+
return (
|
|
180
|
+
<Fragment key={index}>
|
|
181
|
+
{last ? (
|
|
182
|
+
<BreadcrumbItem className="min-w-0">
|
|
183
|
+
<BreadcrumbPage className="truncate">
|
|
184
|
+
{name(item)}
|
|
185
|
+
</BreadcrumbPage>
|
|
186
|
+
</BreadcrumbItem>
|
|
187
|
+
) : (
|
|
188
|
+
<>
|
|
189
|
+
<BreadcrumbItem className="hidden max-w-48 min-w-0 shrink-0 md:inline-flex">
|
|
190
|
+
{item.href ? (
|
|
191
|
+
<BreadcrumbLink
|
|
192
|
+
className="truncate"
|
|
193
|
+
href={item.href}
|
|
194
|
+
onClick={follow(item.href)}
|
|
195
|
+
>
|
|
196
|
+
{name(item)}
|
|
197
|
+
</BreadcrumbLink>
|
|
198
|
+
) : (
|
|
199
|
+
<span className="truncate">{name(item)}</span>
|
|
200
|
+
)}
|
|
201
|
+
</BreadcrumbItem>
|
|
202
|
+
<BreadcrumbSeparator className="hidden md:block" />
|
|
203
|
+
</>
|
|
204
|
+
)}
|
|
205
|
+
</Fragment>
|
|
206
|
+
);
|
|
207
|
+
})}
|
|
208
|
+
</BreadcrumbList>
|
|
209
|
+
</Breadcrumb>
|
|
210
|
+
</div>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
99
214
|
function ShellNavigation({
|
|
100
215
|
navigation,
|
|
101
216
|
activeId,
|
|
@@ -103,14 +218,7 @@ function ShellNavigation({
|
|
|
103
218
|
}: Pick<AppShellProps, "navigation" | "activeId" | "onNavigate">) {
|
|
104
219
|
const { isMobile, setOpenMobile } = useSidebar();
|
|
105
220
|
const navigate = (id: string, event: MouseEvent<HTMLElement>) => {
|
|
106
|
-
if (
|
|
107
|
-
event.button !== 0 ||
|
|
108
|
-
event.metaKey ||
|
|
109
|
-
event.ctrlKey ||
|
|
110
|
-
event.shiftKey ||
|
|
111
|
-
event.altKey
|
|
112
|
-
)
|
|
113
|
-
return;
|
|
221
|
+
if (!plainClick(event)) return;
|
|
114
222
|
event.preventDefault();
|
|
115
223
|
onNavigate(id);
|
|
116
224
|
if (isMobile) setOpenMobile(false);
|
|
@@ -174,6 +282,8 @@ export function AppShell({
|
|
|
174
282
|
navigation,
|
|
175
283
|
activeId,
|
|
176
284
|
onNavigate,
|
|
285
|
+
breadcrumbs,
|
|
286
|
+
onBreadcrumbNavigate,
|
|
177
287
|
header,
|
|
178
288
|
actions,
|
|
179
289
|
footer,
|
|
@@ -217,7 +327,16 @@ export function AppShell({
|
|
|
217
327
|
<SidebarInset className={fillHeight ? "h-svh min-h-0" : undefined}>
|
|
218
328
|
<header className="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4 md:px-6">
|
|
219
329
|
<HeaderTrigger />
|
|
220
|
-
<div className="min-w-0 flex-1">
|
|
330
|
+
<div className="min-w-0 flex-1">
|
|
331
|
+
{breadcrumbs?.length ? (
|
|
332
|
+
<ShellBreadcrumbs
|
|
333
|
+
items={breadcrumbs}
|
|
334
|
+
onNavigate={onBreadcrumbNavigate}
|
|
335
|
+
/>
|
|
336
|
+
) : (
|
|
337
|
+
header
|
|
338
|
+
)}
|
|
339
|
+
</div>
|
|
221
340
|
{actions ? (
|
|
222
341
|
<div className="flex items-center gap-2">{actions}</div>
|
|
223
342
|
) : null}
|
|
@@ -1473,8 +1473,9 @@ export function DataTable<TData extends RowData>(props: DataTableProps<TData>) {
|
|
|
1473
1473
|
>
|
|
1474
1474
|
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
|
1475
1475
|
{toolbarStartContent}
|
|
1476
|
-
|
|
1477
|
-
|
|
1476
|
+
{/* On a phone the search takes its own row and the actions wrap below it. */}
|
|
1477
|
+
<div className="flex min-w-0 flex-1 basis-80 flex-wrap items-center gap-2">
|
|
1478
|
+
<InputGroup className="min-w-0 flex-1 basis-64">
|
|
1478
1479
|
<InputGroupInput
|
|
1479
1480
|
value={globalFilter}
|
|
1480
1481
|
onChange={(event) => handleGlobalFilterChange(event.target.value)}
|
|
@@ -1483,18 +1484,23 @@ export function DataTable<TData extends RowData>(props: DataTableProps<TData>) {
|
|
|
1483
1484
|
<InputGroupAddon className="pl-2">
|
|
1484
1485
|
<SearchIcon />
|
|
1485
1486
|
</InputGroupAddon>
|
|
1486
|
-
<InputGroupAddon
|
|
1487
|
+
<InputGroupAddon
|
|
1488
|
+
align="inline-end"
|
|
1489
|
+
className="pr-2 whitespace-nowrap"
|
|
1490
|
+
>
|
|
1487
1491
|
{formatResultCount(filteredRowCount)}
|
|
1488
1492
|
</InputGroupAddon>
|
|
1489
1493
|
</InputGroup>
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1494
|
+
<div className="flex max-w-full flex-wrap items-center gap-2">
|
|
1495
|
+
{toolbarEndContent}
|
|
1496
|
+
<ColumnSettings
|
|
1497
|
+
defaultColumnOrder={defaultColumnOrder}
|
|
1498
|
+
lockedEndColumnIds={lockedEndColumnIds}
|
|
1499
|
+
lockedStartColumnIds={lockedStartColumnIds}
|
|
1500
|
+
onResetColumns={resetColumns}
|
|
1501
|
+
table={table}
|
|
1502
|
+
/>
|
|
1503
|
+
</div>
|
|
1498
1504
|
</div>
|
|
1499
1505
|
</div>
|
|
1500
1506
|
|
|
@@ -1550,12 +1556,12 @@ export function DataTable<TData extends RowData>(props: DataTableProps<TData>) {
|
|
|
1550
1556
|
)}
|
|
1551
1557
|
>
|
|
1552
1558
|
<Table
|
|
1553
|
-
containerClassName={
|
|
1559
|
+
containerClassName={cn(
|
|
1560
|
+
// The empty state sizes itself to the visible width (cqw).
|
|
1561
|
+
"@container",
|
|
1554
1562
|
// Bottom-only fade: a top fade would dissolve the sticky header.
|
|
1555
|
-
fillHeight
|
|
1556
|
-
|
|
1557
|
-
: undefined
|
|
1558
|
-
}
|
|
1563
|
+
fillHeight && "min-h-0 flex-1 overflow-auto scroll-fade-b",
|
|
1564
|
+
)}
|
|
1559
1565
|
style={{ minWidth: "100%", width: table.getTotalSize() }}
|
|
1560
1566
|
>
|
|
1561
1567
|
{/* Solid background: rows scroll underneath the sticky header. */}
|
|
@@ -1641,6 +1647,8 @@ export function DataTable<TData extends RowData>(props: DataTableProps<TData>) {
|
|
|
1641
1647
|
colSpan={table.getVisibleLeafColumns().length}
|
|
1642
1648
|
className="text-muted-foreground h-24 text-center"
|
|
1643
1649
|
>
|
|
1650
|
+
{/* A table wider than the screen: the message stays in view instead of centring on the full width. */}
|
|
1651
|
+
<div className="sticky left-3 w-[calc(100cqw-1.5rem)] whitespace-normal">
|
|
1644
1652
|
{isFiltered ? (
|
|
1645
1653
|
<Empty>
|
|
1646
1654
|
<EmptyHeader>
|
|
@@ -1670,6 +1678,7 @@ export function DataTable<TData extends RowData>(props: DataTableProps<TData>) {
|
|
|
1670
1678
|
</Empty>
|
|
1671
1679
|
))
|
|
1672
1680
|
)}
|
|
1681
|
+
</div>
|
|
1673
1682
|
</TableCell>
|
|
1674
1683
|
</TableRow>
|
|
1675
1684
|
)}
|