@raulaguila/maat-ui 0.0.0-stage → 0.3.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/README.md +55 -2
- package/dist/avatar.d.ts +11 -0
- package/dist/avatar.js +23 -0
- package/dist/badge.d.ts +7 -0
- package/dist/badge.js +33 -0
- package/dist/button.d.ts +8 -0
- package/dist/button.js +34 -0
- package/dist/card.d.ts +11 -0
- package/dist/card.js +25 -0
- package/dist/chart.d.ts +45 -0
- package/dist/chart.js +134 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +9 -0
- package/dist/cn.d.ts +2 -0
- package/dist/cn.js +5 -0
- package/dist/collapsible.d.ts +5 -0
- package/dist/collapsible.js +14 -0
- package/dist/confirm-dialog.d.ts +14 -0
- package/dist/confirm-dialog.js +44 -0
- package/dist/dialog.d.ts +17 -0
- package/dist/dialog.js +40 -0
- package/dist/dropdown-menu.d.ts +29 -0
- package/dist/dropdown-menu.js +51 -0
- package/dist/dropdown-select.d.ts +23 -0
- package/dist/dropdown-select.js +35 -0
- package/dist/empty-state.d.ts +11 -0
- package/dist/empty-state.js +10 -0
- package/dist/form-field.d.ts +13 -0
- package/dist/form-field.js +10 -0
- package/dist/icon-action.d.ts +11 -0
- package/dist/icon-action.js +7 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +31 -0
- package/dist/input.d.ts +3 -0
- package/dist/input.js +7 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +7 -0
- package/dist/labels.d.ts +23 -0
- package/dist/labels.js +10 -0
- package/dist/layout.d.ts +52 -0
- package/dist/layout.js +38 -0
- package/dist/page-tabs.d.ts +9 -0
- package/dist/page-tabs.js +17 -0
- package/dist/pagination.d.ts +9 -0
- package/dist/pagination.js +20 -0
- package/dist/password-input.d.ts +5 -0
- package/dist/password-input.js +18 -0
- package/dist/query-error-state.d.ts +6 -0
- package/dist/query-error-state.js +10 -0
- package/dist/searchable-choice.d.ts +18 -0
- package/dist/searchable-choice.js +25 -0
- package/dist/select.d.ts +17 -0
- package/dist/select.js +40 -0
- package/dist/sheet.d.ts +14 -0
- package/dist/sheet.js +39 -0
- package/dist/sidebar-controls.d.ts +18 -0
- package/dist/sidebar-controls.js +15 -0
- package/dist/skeleton.d.ts +2 -0
- package/dist/skeleton.js +6 -0
- package/dist/sonner.d.ts +3 -0
- package/dist/sonner.js +28 -0
- package/dist/switch.d.ts +10 -0
- package/dist/switch.js +9 -0
- package/dist/table.d.ts +12 -0
- package/dist/table.js +28 -0
- package/dist/tabs.d.ts +10 -0
- package/dist/tabs.js +29 -0
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.js +7 -0
- package/dist/tooltip.d.ts +6 -0
- package/dist/tooltip.js +17 -0
- package/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-variable.woff2 +0 -0
- package/fonts/ibmplexmono-OFL.txt +93 -0
- package/fonts/ibmplexsans-OFL.txt +93 -0
- package/fonts/source-serif-4-latin-normal-variable.woff2 +0 -0
- package/fonts/sourceserif4-OFL.txt +93 -0
- package/package.json +202 -4
- package/styles.css +386 -0
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Maat UI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
O pacote **@raulaguila/maat-ui** é a biblioteca de componentes da família Maat, formada por Seshat, Thoth e Khnum. A aplicação fornece rotas, ações, permissões e dados. O pacote fornece os controles, sua interação e as medidas de layout.
|
|
4
|
+
|
|
5
|
+
## Instalar e usar
|
|
6
|
+
|
|
7
|
+
O pacote público requer React 19, React DOM 19 e Tailwind CSS 4. Escolha a versão em cada frontend:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add --save-exact @raulaguila/maat-ui@0.3.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Inclua o `package.json` e o `pnpm-lock.yaml` no mesmo commit.
|
|
14
|
+
|
|
15
|
+
No CSS global, importe os estilos uma vez:
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
@import "tailwindcss";
|
|
19
|
+
@import "@raulaguila/maat-ui/styles.css";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
No elemento `html`, informe `data-brand="thoth"`, `"seshat"` ou `"khnum"`. Use a classe `dark` e o atributo opcional `data-density="compact"` para as preferências. As variáveis de tipografia aceitam fontes já carregadas pelo aplicativo. A marca identifica o produto, e as cores de ação e foco são comuns.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { PageHeader, PageBody, FormSections, FormSection, Label, Input } from "@raulaguila/maat-ui";
|
|
26
|
+
|
|
27
|
+
export function Profile() {
|
|
28
|
+
return <main>
|
|
29
|
+
<PageHeader title="Perfil" />
|
|
30
|
+
<PageBody><FormSections><FormSection title="Identidade">
|
|
31
|
+
<Label htmlFor="name">Nome</Label><Input id="name" />
|
|
32
|
+
</FormSection></FormSections></PageBody>
|
|
33
|
+
</main>;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Para localizar controles, envolva a aplicação em `FamilyUIProvider` com `labels={{ close, rows, of, previous, next }}`. O idioma inicial da biblioteca é português. Para importar um único módulo, use, por exemplo, `@raulaguila/maat-ui/button` ou `@raulaguila/maat-ui/layout`.
|
|
38
|
+
|
|
39
|
+
## Componentes
|
|
40
|
+
|
|
41
|
+
`PasswordInput` oferece visibilidade da senha e informa o estado de Caps Lock. `ConfirmDialog` aguarda ações assíncronas, mantém o foco inicial em Cancelar para ações destrutivas e aceita `formatError` para mensagens do produto. `EmptyState` aceita ação opcional e variante compacta. `QueryErrorState` mostra uma mensagem de erro e oferece nova tentativa quando recebe `onRetry`. As aplicações fornecem traduções por `FamilyUIProvider` e decidem quando a operação pode ser repetida.
|
|
42
|
+
|
|
43
|
+
O Seshat é a referência de apresentação. Quando o Thoth precisa de um controle adicional, ele usa os mesmos tokens, fontes e estados. Entre as extensões estão o seletor pesquisável, os grupos de campos, o painel recolhível e os gráficos. `IconAction` implementa o botão de ícone com nome acessível e tooltip. `PageTabs` mantém as abas endereçáveis pelo fragmento da URL.
|
|
44
|
+
|
|
45
|
+
Os módulos opcionais `@raulaguila/maat-ui/chart` (Recharts) e `@raulaguila/maat-ui/sonner` (Sonner e next-themes) têm entradas próprias. Instale os respectivos peers no produto que os utiliza.
|
|
46
|
+
|
|
47
|
+
Botões, campos, seleção, checkbox, switch, badges, avatares, abas, cartões, tabelas, paginação, menus, diálogos, painéis, tooltips e skeletons compartilham tamanhos e estados. `Sidebar`, `SidebarBody` e `SidebarFooter` mantêm um centro rolável e o rodapé na base. A aplicação fornece a marca e os itens do menu. `ManagementGroup` e `ManagementRow` agrupam itens com um título acessível. Use o contêiner `family-management` e as áreas `family-open`, `family-roles`, `family-stats` e `family-actions` para reorganizar as linhas pela largura disponível.
|
|
48
|
+
|
|
49
|
+
## Desenvolver e distribuir
|
|
50
|
+
|
|
51
|
+
1. Execute `pnpm install --frozen-lockfile`, `pnpm test` e `pnpm catalog`. O catálogo permite alternar os três produtos, tema e densidade e testar os componentes. `pnpm catalog:build` gera a versão estática.
|
|
52
|
+
2. Altere a versão seguindo SemVer. Uma remoção de componente, prop ou token público requer versão principal. Documente mudanças visuais que os consumidores devam conferir.
|
|
53
|
+
3. No npm, configure o publicador confiável GitHub Actions para o repositório `raulaguila/maat-ui` e o workflow `publish.yml`.
|
|
54
|
+
4. Faça commit da versão e envie a tag correspondente, por exemplo `v0.2.2`. O workflow de publicação verifica a versão da tag, executa os testes, compila o catálogo e publica o pacote no npm público e testa a instalação anônima.
|
|
55
|
+
|
|
56
|
+
As referências de validação são Perfil, Workspaces/Datasets e a sidebar, com mouse e teclado no desktop e alvos de 44 px no toque.
|
package/dist/avatar.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";
|
|
3
|
+
declare function Avatar({ className, size, ...props }: AvatarPrimitive.Root.Props & {
|
|
4
|
+
size?: "default" | "sm" | "lg";
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props): React.JSX.Element;
|
|
7
|
+
declare function AvatarFallback({ className, ...props }: AvatarPrimitive.Fallback.Props): React.JSX.Element;
|
|
8
|
+
declare function AvatarBadge({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
9
|
+
declare function AvatarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
10
|
+
declare function AvatarGroupCount({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
11
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge, };
|
package/dist/avatar.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
function Avatar({ className, size = "default", ...props }) {
|
|
6
|
+
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, className: cn("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten", className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
function AvatarImage({ className, ...props }) {
|
|
9
|
+
return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", className: cn("aspect-square size-full rounded-full object-cover", className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
function AvatarFallback({ className, ...props }) {
|
|
12
|
+
return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: cn("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs", className), ...props }));
|
|
13
|
+
}
|
|
14
|
+
function AvatarBadge({ className, ...props }) {
|
|
15
|
+
return (_jsx("span", { "data-slot": "avatar-badge", className: cn("absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none", "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden", "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", className), ...props }));
|
|
16
|
+
}
|
|
17
|
+
function AvatarGroup({ className, ...props }) {
|
|
18
|
+
return (_jsx("div", { "data-slot": "avatar-group", className: cn("group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background", className), ...props }));
|
|
19
|
+
}
|
|
20
|
+
function AvatarGroupCount({ className, ...props }) {
|
|
21
|
+
return (_jsx("div", { "data-slot": "avatar-group-count", className: cn("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", className), ...props }));
|
|
22
|
+
}
|
|
23
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge, };
|
package/dist/badge.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export { Badge, badgeVariants };
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
9
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
10
|
+
destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
11
|
+
outline: "border-border bg-muted text-foreground [a]:hover:bg-accent [a]:hover:text-muted-foreground",
|
|
12
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
13
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: "default",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
function Badge({ className, variant = "default", render, ...props }) {
|
|
21
|
+
return useRender({
|
|
22
|
+
defaultTagName: "span",
|
|
23
|
+
props: mergeProps({
|
|
24
|
+
className: cn(badgeVariants({ variant }), className),
|
|
25
|
+
}, props),
|
|
26
|
+
render,
|
|
27
|
+
state: {
|
|
28
|
+
slot: "badge",
|
|
29
|
+
variant,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export { Badge, badgeVariants };
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | "xs" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function Button({ className, variant, size, ...props }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>): import("react").JSX.Element;
|
|
8
|
+
export { Button, buttonVariants };
|
package/dist/button.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
const buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px active:not-aria-[haspopup]:scale-[0.99] disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary [background-image:var(--gradient-brand)] text-primary-foreground hover:brightness-95 active:brightness-90",
|
|
9
|
+
outline: "border-border bg-card hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
10
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
11
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
12
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
13
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
default: "h-[var(--control-h)] gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
17
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
18
|
+
sm: "h-[var(--control-h-sm)] gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
19
|
+
lg: "h-[var(--control-h-lg)] gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
20
|
+
icon: "size-[var(--control-h)]",
|
|
21
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
22
|
+
"icon-sm": "size-[var(--control-h-sm)] rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
23
|
+
"icon-lg": "size-[var(--control-h-lg)]",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: "default",
|
|
28
|
+
size: "default",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
function Button({ className, variant = "default", size = "default", ...props }) {
|
|
32
|
+
return (_jsx(ButtonPrimitive, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ...props }));
|
|
33
|
+
}
|
|
34
|
+
export { Button, buttonVariants };
|
package/dist/card.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Card({ className, size, ...props }: React.ComponentProps<"div"> & {
|
|
3
|
+
size?: "default" | "sm";
|
|
4
|
+
}): React.JSX.Element;
|
|
5
|
+
declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
6
|
+
declare function CardTitle({ className, ...props }: React.ComponentProps<"h2">): React.JSX.Element;
|
|
7
|
+
declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
8
|
+
declare function CardAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
9
|
+
declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
10
|
+
declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
11
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, };
|
package/dist/card.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "./cn.js";
|
|
3
|
+
function Card({ className, size = "default", ...props }) {
|
|
4
|
+
return (_jsx("div", { "data-slot": "card", "data-size": size, className: cn("group/card flex flex-col gap-4 overflow-hidden rounded-lg border bg-card py-4 text-sm text-card-foreground shadow-xs has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg", className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
function CardHeader({ className, ...props }) {
|
|
7
|
+
return (_jsx("div", { "data-slot": "card-header", className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-x-3 gap-y-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[minmax(0,1fr)_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:py-3", className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
// A heading: every card title names a section of its page.
|
|
10
|
+
function CardTitle({ className, ...props }) {
|
|
11
|
+
return (_jsx("h2", { "data-slot": "card-title", className: cn("font-heading text-base leading-snug font-semibold group-data-[size=sm]/card:text-sm", className), ...props }));
|
|
12
|
+
}
|
|
13
|
+
function CardDescription({ className, ...props }) {
|
|
14
|
+
return (_jsx("div", { "data-slot": "card-description", className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
15
|
+
}
|
|
16
|
+
function CardAction({ className, ...props }) {
|
|
17
|
+
return (_jsx("div", { "data-slot": "card-action", className: cn("col-start-2 row-span-2 row-start-1 flex flex-wrap items-center gap-2 self-center justify-self-end", className), ...props }));
|
|
18
|
+
}
|
|
19
|
+
function CardContent({ className, ...props }) {
|
|
20
|
+
return (_jsx("div", { "data-slot": "card-content", className: cn("px-4 group-data-[size=sm]/card:px-3", className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
function CardFooter({ className, ...props }) {
|
|
23
|
+
return (_jsx("div", { "data-slot": "card-footer", className: cn("flex items-center rounded-b-lg border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3", className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, };
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as RechartsPrimitive from "recharts";
|
|
3
|
+
import type { TooltipValueType } from "recharts";
|
|
4
|
+
declare const THEMES: {
|
|
5
|
+
readonly light: "";
|
|
6
|
+
readonly dark: ".dark";
|
|
7
|
+
};
|
|
8
|
+
type TooltipNameType = number | string;
|
|
9
|
+
export type ChartConfig = Record<string, {
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
icon?: React.ComponentType;
|
|
12
|
+
} & ({
|
|
13
|
+
color?: string;
|
|
14
|
+
theme?: never;
|
|
15
|
+
} | {
|
|
16
|
+
color?: never;
|
|
17
|
+
theme: Record<keyof typeof THEMES, string>;
|
|
18
|
+
})>;
|
|
19
|
+
declare function ChartContainer({ id, className, children, config, initialDimension, ...props }: React.ComponentProps<"div"> & {
|
|
20
|
+
config: ChartConfig;
|
|
21
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
22
|
+
initialDimension?: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
}): React.JSX.Element;
|
|
27
|
+
declare const ChartStyle: ({ id, config }: {
|
|
28
|
+
id: string;
|
|
29
|
+
config: ChartConfig;
|
|
30
|
+
}) => React.JSX.Element | null;
|
|
31
|
+
declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
|
|
32
|
+
declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, valueFormatter, }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> & React.ComponentProps<"div"> & {
|
|
33
|
+
hideLabel?: boolean;
|
|
34
|
+
hideIndicator?: boolean;
|
|
35
|
+
indicator?: "line" | "dot" | "dashed";
|
|
36
|
+
nameKey?: string;
|
|
37
|
+
labelKey?: string;
|
|
38
|
+
valueFormatter?: (value: number | string) => React.ReactNode;
|
|
39
|
+
} & Omit<RechartsPrimitive.DefaultTooltipContentProps<TooltipValueType, TooltipNameType>, "accessibilityLayer">): React.JSX.Element | null;
|
|
40
|
+
declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
41
|
+
declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<"div"> & {
|
|
42
|
+
hideIcon?: boolean;
|
|
43
|
+
nameKey?: string;
|
|
44
|
+
} & RechartsPrimitive.DefaultLegendContentProps): React.JSX.Element | null;
|
|
45
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as RechartsPrimitive from "recharts";
|
|
5
|
+
import { cn } from "./cn.js";
|
|
6
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
7
|
+
const THEMES = { light: "", dark: ".dark" };
|
|
8
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 };
|
|
9
|
+
const ChartContext = React.createContext(null);
|
|
10
|
+
function useChart() {
|
|
11
|
+
const context = React.useContext(ChartContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
function ChartContainer({ id, className, children, config, initialDimension = INITIAL_DIMENSION, ...props }) {
|
|
18
|
+
const uniqueId = React.useId();
|
|
19
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
|
|
20
|
+
return (_jsx(ChartContext.Provider, { value: { config }, children: _jsxs("div", { "data-slot": "chart", "data-chart": chartId, className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick-value]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className), ...props, children: [_jsx(ChartStyle, { id: chartId, config: config }), _jsx(RechartsPrimitive.ResponsiveContainer, { initialDimension: initialDimension, children: children })] }) }));
|
|
21
|
+
}
|
|
22
|
+
const ChartStyle = ({ id, config }) => {
|
|
23
|
+
const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);
|
|
24
|
+
if (!colorConfig.length) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return (_jsx("style", { dangerouslySetInnerHTML: {
|
|
28
|
+
__html: Object.entries(THEMES)
|
|
29
|
+
.map(([theme, prefix]) => `
|
|
30
|
+
${prefix} [data-chart=${id}] {
|
|
31
|
+
${colorConfig
|
|
32
|
+
.map(([key, itemConfig]) => {
|
|
33
|
+
const color = itemConfig.theme?.[theme] ??
|
|
34
|
+
itemConfig.color;
|
|
35
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
36
|
+
})
|
|
37
|
+
.join("\n")}
|
|
38
|
+
}
|
|
39
|
+
`)
|
|
40
|
+
.join("\n"),
|
|
41
|
+
} }));
|
|
42
|
+
};
|
|
43
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
44
|
+
function ChartTooltipContent({ active, payload, className, indicator = "dot", hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, valueFormatter, }) {
|
|
45
|
+
const { config } = useChart();
|
|
46
|
+
const tooltipLabel = React.useMemo(() => {
|
|
47
|
+
if (hideLabel || !payload?.length) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const [item] = payload;
|
|
51
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
|
|
52
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
53
|
+
const value = !labelKey && typeof label === "string"
|
|
54
|
+
? (config[label]?.label ?? label)
|
|
55
|
+
: itemConfig?.label;
|
|
56
|
+
if (labelFormatter) {
|
|
57
|
+
return (_jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) }));
|
|
58
|
+
}
|
|
59
|
+
if (!value) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return _jsx("div", { className: cn("font-medium", labelClassName), children: value });
|
|
63
|
+
}, [
|
|
64
|
+
label,
|
|
65
|
+
labelFormatter,
|
|
66
|
+
payload,
|
|
67
|
+
hideLabel,
|
|
68
|
+
labelClassName,
|
|
69
|
+
config,
|
|
70
|
+
labelKey,
|
|
71
|
+
]);
|
|
72
|
+
if (!active || !payload?.length) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
76
|
+
return (_jsxs("div", { className: cn("grid min-w-36 items-start gap-1.5 rounded-lg bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10", className), children: [!nestLabel ? tooltipLabel : null, _jsx("div", { className: "grid gap-1.5", children: payload
|
|
77
|
+
.filter((item) => item.type !== "none")
|
|
78
|
+
.map((item, index) => {
|
|
79
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
|
|
80
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
81
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color;
|
|
82
|
+
return (_jsx("div", { className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center"), children: formatter && item?.value !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (_jsxs(_Fragment, { children: [itemConfig?.icon ? (_jsx(itemConfig.icon, {})) : (!hideIndicator && (_jsx("div", { className: cn("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", {
|
|
83
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
84
|
+
"w-1": indicator === "line",
|
|
85
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
86
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
87
|
+
}), style: {
|
|
88
|
+
"--color-bg": indicatorColor,
|
|
89
|
+
"--color-border": indicatorColor,
|
|
90
|
+
} }))), _jsxs("div", { className: cn("flex flex-1 justify-between gap-3 leading-none", nestLabel ? "items-end" : "items-center"), children: [_jsxs("div", { className: "grid gap-1.5", children: [nestLabel ? tooltipLabel : null, _jsx("span", { className: "text-muted-foreground", children: itemConfig?.label ?? item.name })] }), item.value != null && (_jsx("span", { className: "font-mono font-medium text-foreground tabular-nums", children: valueFormatter
|
|
91
|
+
? valueFormatter(item.value)
|
|
92
|
+
: typeof item.value === "number"
|
|
93
|
+
? item.value.toLocaleString()
|
|
94
|
+
: String(item.value) }))] })] })) }, index));
|
|
95
|
+
}) })] }));
|
|
96
|
+
}
|
|
97
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
98
|
+
function ChartLegendContent({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey, }) {
|
|
99
|
+
const { config } = useChart();
|
|
100
|
+
if (!payload?.length) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return (_jsx("div", { className: cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className), children: payload
|
|
104
|
+
.filter((item) => item.type !== "none")
|
|
105
|
+
.map((item, index) => {
|
|
106
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`;
|
|
107
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
108
|
+
return (_jsxs("div", { className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"), children: [itemConfig?.icon && !hideIcon ? (_jsx(itemConfig.icon, {})) : (_jsx("div", { className: "h-2 w-2 shrink-0 rounded-[2px]", style: {
|
|
109
|
+
backgroundColor: item.color,
|
|
110
|
+
} })), itemConfig?.label] }, index));
|
|
111
|
+
}) }));
|
|
112
|
+
}
|
|
113
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
114
|
+
if (typeof payload !== "object" || payload === null) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const payloadPayload = "payload" in payload &&
|
|
118
|
+
typeof payload.payload === "object" &&
|
|
119
|
+
payload.payload !== null
|
|
120
|
+
? payload.payload
|
|
121
|
+
: undefined;
|
|
122
|
+
let configLabelKey = key;
|
|
123
|
+
if (key in payload &&
|
|
124
|
+
typeof payload[key] === "string") {
|
|
125
|
+
configLabelKey = payload[key];
|
|
126
|
+
}
|
|
127
|
+
else if (payloadPayload &&
|
|
128
|
+
key in payloadPayload &&
|
|
129
|
+
typeof payloadPayload[key] === "string") {
|
|
130
|
+
configLabelKey = payloadPayload[key];
|
|
131
|
+
}
|
|
132
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
133
|
+
}
|
|
134
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
import { CheckIcon, MinusIcon } from "lucide-react";
|
|
6
|
+
function Checkbox({ className, ...props }) {
|
|
7
|
+
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn("group/checkbox peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-[color-mix(in_oklab,var(--input-fill)_30%,transparent)] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-indeterminate:border-primary data-indeterminate:bg-primary data-indeterminate:text-primary-foreground", className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", className: "grid place-content-center text-current transition-none [&>svg]:size-3.5", children: [_jsx(CheckIcon, { className: "group-data-indeterminate/checkbox:hidden" }), _jsx(MinusIcon, { className: "hidden group-data-indeterminate/checkbox:block" })] }) }));
|
|
8
|
+
}
|
|
9
|
+
export { Checkbox };
|
package/dist/cn.d.ts
ADDED
package/dist/cn.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
2
|
+
declare function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props): import("react").JSX.Element;
|
|
3
|
+
declare function CollapsibleTrigger({ className, ...props }: CollapsiblePrimitive.Trigger.Props): import("react").JSX.Element;
|
|
4
|
+
declare function CollapsiblePanel({ className, ...props }: CollapsiblePrimitive.Panel.Props): import("react").JSX.Element;
|
|
5
|
+
export { Collapsible, CollapsibleTrigger, CollapsiblePanel };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
function Collapsible({ ...props }) {
|
|
6
|
+
return _jsx(CollapsiblePrimitive.Root, { "data-slot": "collapsible", ...props });
|
|
7
|
+
}
|
|
8
|
+
function CollapsibleTrigger({ className, ...props }) {
|
|
9
|
+
return (_jsx(CollapsiblePrimitive.Trigger, { "data-slot": "collapsible-trigger", className: cn("outline-none", className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
function CollapsiblePanel({ className, ...props }) {
|
|
12
|
+
return (_jsx(CollapsiblePrimitive.Panel, { "data-slot": "collapsible-panel", className: cn("h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-200 ease-out data-ending-style:h-0 data-starting-style:h-0", className), ...props }));
|
|
13
|
+
}
|
|
14
|
+
export { Collapsible, CollapsibleTrigger, CollapsiblePanel };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Explicit, translated feedback for partial batches; API errors stay sanitized. */
|
|
2
|
+
export declare class ConfirmationError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, destructive, onConfirm, formatError, }: {
|
|
5
|
+
open: boolean;
|
|
6
|
+
onOpenChange: (o: boolean) => void;
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
confirmLabel?: string;
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
destructive?: boolean;
|
|
12
|
+
onConfirm: () => void | Promise<void>;
|
|
13
|
+
formatError?: (error: unknown) => string;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "./dialog.js";
|
|
5
|
+
import { Loader2 } from "lucide-react";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { useFamilyLabels } from "./labels.js";
|
|
8
|
+
/** Explicit, translated feedback for partial batches; API errors stay sanitized. */
|
|
9
|
+
export class ConfirmationError extends Error {
|
|
10
|
+
}
|
|
11
|
+
export function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, destructive, onConfirm, formatError, }) {
|
|
12
|
+
const labels = useFamilyLabels();
|
|
13
|
+
const cancelButton = useRef(null);
|
|
14
|
+
const inFlight = useRef(false);
|
|
15
|
+
const [pending, setPending] = useState(false);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const cancel = cancelLabel ?? labels.cancel ?? "Cancelar";
|
|
18
|
+
const confirm = confirmLabel ?? labels.confirm ?? "Confirmar";
|
|
19
|
+
const changeOpen = (next) => {
|
|
20
|
+
if (inFlight.current)
|
|
21
|
+
return;
|
|
22
|
+
setError(null);
|
|
23
|
+
onOpenChange(next);
|
|
24
|
+
};
|
|
25
|
+
const submit = async () => {
|
|
26
|
+
if (inFlight.current)
|
|
27
|
+
return;
|
|
28
|
+
inFlight.current = true;
|
|
29
|
+
setPending(true);
|
|
30
|
+
setError(null);
|
|
31
|
+
try {
|
|
32
|
+
await onConfirm();
|
|
33
|
+
onOpenChange(false);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
setError(e instanceof ConfirmationError ? e.message : formatError?.(e) ?? labels.confirmFailed ?? "Não foi possível concluir a ação.");
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
inFlight.current = false;
|
|
40
|
+
setPending(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return (_jsx(Dialog, { open: open, onOpenChange: changeOpen, children: _jsxs(DialogContent, { initialFocus: destructive ? cancelButton : undefined, className: "sm:max-w-sm", "aria-busy": pending, showCloseButton: !pending, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: title }), description && _jsx(DialogDescription, { children: description })] }), error && _jsx("div", { role: "alert", className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: error }), _jsxs(DialogFooter, { children: [_jsx(Button, { ref: cancelButton, variant: "ghost", disabled: pending, onClick: () => changeOpen(false), children: cancel }), _jsxs(Button, { variant: destructive ? "destructive" : "default", disabled: pending, onClick: () => void submit(), children: [pending && _jsx(Loader2, { "aria-hidden": true, className: "size-4 animate-spin" }), pending ? (labels.confirming ?? "Aguarde…") : confirm] })] })] }) }));
|
|
44
|
+
}
|
package/dist/dialog.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
3
|
+
declare function Dialog({ ...props }: DialogPrimitive.Root.Props): React.JSX.Element;
|
|
4
|
+
declare function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props): React.JSX.Element;
|
|
5
|
+
declare function DialogPortal({ ...props }: DialogPrimitive.Portal.Props): React.JSX.Element;
|
|
6
|
+
declare function DialogClose({ ...props }: DialogPrimitive.Close.Props): React.JSX.Element;
|
|
7
|
+
declare function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props): React.JSX.Element;
|
|
8
|
+
declare function DialogContent({ className, children, showCloseButton, ...props }: DialogPrimitive.Popup.Props & {
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
12
|
+
declare function DialogFooter({ className, showCloseButton, children, ...props }: React.ComponentProps<"div"> & {
|
|
13
|
+
showCloseButton?: boolean;
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
declare function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props): React.JSX.Element;
|
|
16
|
+
declare function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props): React.JSX.Element;
|
|
17
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
|
package/dist/dialog.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
import { useFamilyLabels } from "./labels.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { XIcon } from "lucide-react";
|
|
8
|
+
function Dialog({ ...props }) {
|
|
9
|
+
return _jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
10
|
+
}
|
|
11
|
+
function DialogTrigger({ ...props }) {
|
|
12
|
+
return _jsx(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
13
|
+
}
|
|
14
|
+
function DialogPortal({ ...props }) {
|
|
15
|
+
return _jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
16
|
+
}
|
|
17
|
+
function DialogClose({ ...props }) {
|
|
18
|
+
return _jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
19
|
+
}
|
|
20
|
+
function DialogOverlay({ className, ...props }) {
|
|
21
|
+
return (_jsx(DialogPrimitive.Backdrop, { "data-slot": "dialog-overlay", className: cn("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", className), ...props }));
|
|
22
|
+
}
|
|
23
|
+
function DialogContent({ className, children, showCloseButton = true, ...props }) {
|
|
24
|
+
const { close } = useFamilyLabels();
|
|
25
|
+
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Popup, { "data-slot": "dialog-content", className: cn("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className), ...props, children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { "data-slot": "dialog-close", render: _jsx(Button, { variant: "ghost", className: "absolute top-2 right-2", size: "icon-sm" }), children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: close })] }))] })] }));
|
|
26
|
+
}
|
|
27
|
+
function DialogHeader({ className, ...props }) {
|
|
28
|
+
return (_jsx("div", { "data-slot": "dialog-header", className: cn("flex flex-col gap-2", className), ...props }));
|
|
29
|
+
}
|
|
30
|
+
function DialogFooter({ className, showCloseButton = false, children, ...props }) {
|
|
31
|
+
const { close } = useFamilyLabels();
|
|
32
|
+
return (_jsxs("div", { "data-slot": "dialog-footer", className: cn("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end", className), ...props, children: [children, showCloseButton && (_jsx(DialogPrimitive.Close, { render: _jsx(Button, { variant: "outline" }), children: close }))] }));
|
|
33
|
+
}
|
|
34
|
+
function DialogTitle({ className, ...props }) {
|
|
35
|
+
return (_jsx(DialogPrimitive.Title, { "data-slot": "dialog-title", className: cn("pr-8 font-heading text-base leading-snug font-medium", className), ...props }));
|
|
36
|
+
}
|
|
37
|
+
function DialogDescription({ className, ...props }) {
|
|
38
|
+
return (_jsx(DialogPrimitive.Description, { "data-slot": "dialog-description", className: cn("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", className), ...props }));
|
|
39
|
+
}
|
|
40
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
|
|
3
|
+
declare function DropdownMenu({ ...props }: MenuPrimitive.Root.Props): React.JSX.Element;
|
|
4
|
+
declare function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props): React.JSX.Element;
|
|
5
|
+
declare function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props): React.JSX.Element;
|
|
6
|
+
declare function DropdownMenuContent({ align, alignOffset, side, sideOffset, className, ...props }: MenuPrimitive.Popup.Props & Pick<MenuPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): React.JSX.Element;
|
|
7
|
+
declare function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props): React.JSX.Element;
|
|
8
|
+
declare function DropdownMenuLabel({ className, inset, ...props }: MenuPrimitive.GroupLabel.Props & {
|
|
9
|
+
inset?: boolean;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function DropdownMenuItem({ className, inset, variant, ...props }: MenuPrimitive.Item.Props & {
|
|
12
|
+
inset?: boolean;
|
|
13
|
+
variant?: "default" | "destructive";
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
declare function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props): React.JSX.Element;
|
|
16
|
+
declare function DropdownMenuSubTrigger({ className, inset, children, ...props }: MenuPrimitive.SubmenuTrigger.Props & {
|
|
17
|
+
inset?: boolean;
|
|
18
|
+
}): React.JSX.Element;
|
|
19
|
+
declare function DropdownMenuSubContent({ align, alignOffset, side, sideOffset, className, ...props }: React.ComponentProps<typeof DropdownMenuContent>): React.JSX.Element;
|
|
20
|
+
declare function DropdownMenuCheckboxItem({ className, children, checked, inset, ...props }: MenuPrimitive.CheckboxItem.Props & {
|
|
21
|
+
inset?: boolean;
|
|
22
|
+
}): React.JSX.Element;
|
|
23
|
+
declare function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props): React.JSX.Element;
|
|
24
|
+
declare function DropdownMenuRadioItem({ className, children, inset, ...props }: MenuPrimitive.RadioItem.Props & {
|
|
25
|
+
inset?: boolean;
|
|
26
|
+
}): React.JSX.Element;
|
|
27
|
+
declare function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props): React.JSX.Element;
|
|
28
|
+
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
29
|
+
export { DropdownMenu, DropdownMenuPortal, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, };
|