@tc96/cli 0.0.0-stage → 0.27.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/LICENSE +21 -0
- package/README.md +213 -2
- package/cli.js +1395 -0
- package/package.json +35 -4
- package/registry/agent-builder.json +503 -0
- package/registry/aggregate.json +4 -0
- package/registry/app-shell-1.json +81 -0
- package/registry/app-shell-2.json +89 -0
- package/registry/app-shell-3.json +109 -0
- package/registry/app-shell-4.json +104 -0
- package/registry/app-shell-5.json +106 -0
- package/registry/bulk-import-1.json +151 -0
- package/registry/card-1.json +104 -0
- package/registry/card-2.json +97 -0
- package/registry/card-3.json +104 -0
- package/registry/card-4.json +98 -0
- package/registry/card-5.json +85 -0
- package/registry/card-6.json +98 -0
- package/registry/card-7.json +104 -0
- package/registry/card-8.json +106 -0
- package/registry/card-9.json +92 -0
- package/registry/charts.json +30 -0
- package/registry/chat-assistant.json +110 -0
- package/registry/chats-panel.json +97 -0
- package/registry/checklist.json +307 -0
- package/registry/collection-layouts.json +836 -0
- package/registry/collection-views.json +836 -0
- package/registry/collection.json +831 -0
- package/registry/dashboard-1.json +160 -0
- package/registry/dashboard-2.json +153 -0
- package/registry/dashboard-3.json +154 -0
- package/registry/dashboard-4.json +168 -0
- package/registry/detail-sheet.json +54 -0
- package/registry/editable.json +36 -0
- package/registry/empty-state-1.json +40 -0
- package/registry/empty-state-2.json +39 -0
- package/registry/empty-state-3.json +61 -0
- package/registry/empty-state-4.json +39 -0
- package/registry/empty-state-5.json +47 -0
- package/registry/empty-state-6.json +40 -0
- package/registry/flow-canvas.json +198 -0
- package/registry/flow-inspector.json +151 -0
- package/registry/flow-step-library.json +112 -0
- package/registry/forgot-password-1.json +73 -0
- package/registry/forgot-password-2.json +73 -0
- package/registry/icon-row.json +52 -0
- package/registry/impact-map.json +75 -0
- package/registry/list-1.json +129 -0
- package/registry/list-2.json +117 -0
- package/registry/list-3.json +129 -0
- package/registry/list-4.json +105 -0
- package/registry/list-5.json +98 -0
- package/registry/list-6.json +92 -0
- package/registry/list.json +52 -0
- package/registry/login-1.json +89 -0
- package/registry/login-10.json +88 -0
- package/registry/login-2.json +81 -0
- package/registry/login-3.json +90 -0
- package/registry/login-4.json +81 -0
- package/registry/login-5.json +82 -0
- package/registry/login-6.json +88 -0
- package/registry/login-7.json +83 -0
- package/registry/login-8.json +81 -0
- package/registry/login-9.json +88 -0
- package/registry/lookup-create-1.json +157 -0
- package/registry/magic-link-6.json +79 -0
- package/registry/navbar-1.json +66 -0
- package/registry/navbar-2.json +48 -0
- package/registry/navbar-3.json +50 -0
- package/registry/navbar-4.json +39 -0
- package/registry/navbar-5.json +50 -0
- package/registry/next-steps-1.json +147 -0
- package/registry/onboarding-1.json +114 -0
- package/registry/onboarding-2.json +78 -0
- package/registry/onboarding-3.json +71 -0
- package/registry/otp-1.json +73 -0
- package/registry/properties.json +523 -0
- package/registry/record-dialog.json +88 -0
- package/registry/record-group.json +190 -0
- package/registry/record-preview.json +70 -0
- package/registry/record-status-list.json +70 -0
- package/registry/reset-password-1.json +92 -0
- package/registry/reset-password-2.json +98 -0
- package/registry/reset-password-6.json +91 -0
- package/registry/rich-text-editor.json +93 -0
- package/registry/run-monitor.json +198 -0
- package/registry/settings-1.json +119 -0
- package/registry/settings-10.json +218 -0
- package/registry/settings-11.json +129 -0
- package/registry/settings-12.json +130 -0
- package/registry/settings-13.json +130 -0
- package/registry/settings-14.json +173 -0
- package/registry/settings-15.json +149 -0
- package/registry/settings-16.json +129 -0
- package/registry/settings-17.json +117 -0
- package/registry/settings-18.json +117 -0
- package/registry/settings-19.json +125 -0
- package/registry/settings-2.json +123 -0
- package/registry/settings-20.json +112 -0
- package/registry/settings-21.json +116 -0
- package/registry/settings-22.json +118 -0
- package/registry/settings-23.json +118 -0
- package/registry/settings-3.json +123 -0
- package/registry/settings-4.json +116 -0
- package/registry/settings-5.json +119 -0
- package/registry/settings-6.json +125 -0
- package/registry/settings-7.json +128 -0
- package/registry/settings-8.json +116 -0
- package/registry/settings-9.json +118 -0
- package/registry/settings-shell.json +60 -0
- package/registry/settings.json +82 -0
- package/registry/signup-1.json +100 -0
- package/registry/signup-2.json +93 -0
- package/registry/signup-3.json +83 -0
- package/registry/signup-6.json +99 -0
- package/registry/state-surface.json +58 -0
- package/registry/stats-1.json +116 -0
- package/registry/stats-2.json +115 -0
- package/registry/stats-3.json +97 -0
- package/registry/stats-4.json +92 -0
- package/registry/stats-5.json +103 -0
- package/registry/stats-6.json +105 -0
- package/registry/stats-7.json +103 -0
- package/registry/stats.json +64 -0
- package/registry/timeline-1.json +97 -0
- package/registry/timeline-2.json +102 -0
- package/registry/timeline-3.json +68 -0
- package/registry/timeline-4.json +86 -0
- package/registry/ui/accordion.json +15 -0
- package/registry/ui/alert-dialog.json +14 -0
- package/registry/ui/alert.json +50 -0
- package/registry/ui/autocomplete.json +18 -0
- package/registry/ui/avatar.json +14 -0
- package/registry/ui/badge.json +51 -0
- package/registry/ui/breadcrumb.json +15 -0
- package/registry/ui/button.json +25 -0
- package/registry/ui/calendar.json +15 -0
- package/registry/ui/card.json +14 -0
- package/registry/ui/chat.json +115 -0
- package/registry/ui/checkbox-group.json +14 -0
- package/registry/ui/checkbox.json +14 -0
- package/registry/ui/collapsible.json +14 -0
- package/registry/ui/combobox.json +18 -0
- package/registry/ui/command.json +17 -0
- package/registry/ui/composer-clipboard.json +14 -0
- package/registry/ui/composer-document.json +14 -0
- package/registry/ui/composer-editor.json +16 -0
- package/registry/ui/composer-query.json +12 -0
- package/registry/ui/composer.json +17 -0
- package/registry/ui/context-menu.json +23 -0
- package/registry/ui/dialog.json +18 -0
- package/registry/ui/drawer.json +18 -0
- package/registry/ui/empty.json +14 -0
- package/registry/ui/field.json +22 -0
- package/registry/ui/fieldset.json +14 -0
- package/registry/ui/form.json +14 -0
- package/registry/ui/frame.json +12 -0
- package/registry/ui/gauge.json +31 -0
- package/registry/ui/group.json +17 -0
- package/registry/ui/icon-frame.json +31 -0
- package/registry/ui/input-group.json +17 -0
- package/registry/ui/input.json +14 -0
- package/registry/ui/kbd.json +12 -0
- package/registry/ui/label.json +14 -0
- package/registry/ui/menu.json +39 -0
- package/registry/ui/meter.json +14 -0
- package/registry/ui/number-field.json +17 -0
- package/registry/ui/otp-field.json +31 -0
- package/registry/ui/pagination.json +17 -0
- package/registry/ui/popover.json +14 -0
- package/registry/ui/preview-card.json +14 -0
- package/registry/ui/progress.json +14 -0
- package/registry/ui/radio-group.json +14 -0
- package/registry/ui/render-anchor.json +12 -0
- package/registry/ui/scroll-area.json +14 -0
- package/registry/ui/segmented-control.json +14 -0
- package/registry/ui/select.json +16 -0
- package/registry/ui/separator.json +14 -0
- package/registry/ui/sheet.json +18 -0
- package/registry/ui/sidebar.json +25 -0
- package/registry/ui/skeleton.json +24 -0
- package/registry/ui/slider.json +14 -0
- package/registry/ui/spinner.json +14 -0
- package/registry/ui/switch.json +14 -0
- package/registry/ui/table.json +14 -0
- package/registry/ui/tabs.json +16 -0
- package/registry/ui/text.json +31 -0
- package/registry/ui/textarea.json +14 -0
- package/registry/ui/toast.json +89 -0
- package/registry/ui/toggle-group.json +18 -0
- package/registry/ui/toggle.json +15 -0
- package/registry/ui/toolbar.json +14 -0
- package/registry/ui/tooltip.json +14 -0
- package/registry/ui/use-composer-editor.json +17 -0
- package/registry/ui/use-copy-to-clipboard.json +12 -0
- package/registry/ui/use-media-query.json +12 -0
- package/registry/view.json +831 -0
- package/registry/widgets.json +319 -0
- package/registry/wizard.json +89 -0
- package/registry/workflow-editor.json +460 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "list-4",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/list/list-4/index.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "export { List4 } from './list-4'\nexport type { List4Integration, List4Labels, List4Props } from './types'\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/list/list-4/index.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/list/list-4/labels.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "import { defaultListLoadLabels } from '../shared/labels'\nimport type { List4Labels } from './types'\n\nexport const defaultList4Labels: List4Labels = {\n ...defaultListLoadLabels,\n errorTitle: 'Não foi possível carregar as integrações',\n loading: 'Carregando integrações',\n connect: 'Conectar',\n connectTo: (name) => `Conectar ${name}`,\n connected: 'Conectado',\n emptyDescription: 'Nenhuma integração disponível no momento.',\n emptyTitle: 'Sem integrações',\n title: 'Integrações',\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/list/list-4/labels.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/list/list-4/list-4-skeleton.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "import { ListRowsSkeleton, ListSkeleton } from '../shared/list-load-state'\n\nexport function List4Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <ListSkeleton label={label}>\n <ListRowsSkeleton count={4} end=\"button\" />\n </ListSkeleton>\n )\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/list/list-4/list-4-skeleton.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/list/list-4/list-4.tsx",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import { Badge } from '@tc96/ui/badge'\nimport { Button } from '@tc96/ui/button'\nimport { getInitials } from '@tc96/ui/helpers/initials'\nimport { List } from '@tc96/ui/patterns/list/composition/list/list'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { cn } from '@tc96/utils'\nimport { listLoadState } from '../shared/list-load-state'\nimport { defaultList4Labels } from './labels'\nimport { List4Skeleton } from './list-4-skeleton'\nimport type { List4Props } from './types'\n\nexport function List4({\n error,\n onRetry,\n pending,\n className,\n integrations,\n labels: labelsProp,\n onConnect,\n}: Readonly<List4Props>) {\n const labels = { ...defaultList4Labels, ...labelsProp }\n const loadState = listLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton: <List4Skeleton label={labels.loading} />,\n })\n\n if (loadState)\n return (\n <section aria-label={labels.title} className={className}>\n {loadState}\n </section>\n )\n\n if (integrations.length === 0) {\n return (\n <StateSurface\n className={className}\n description={labels.emptyDescription}\n kind=\"empty\"\n title={labels.emptyTitle}\n />\n )\n }\n\n return (\n <ul aria-label={labels.title} className={cn('grid gap-2', className)}>\n {integrations.map((integration) => (\n <List\n actions={\n integration.connected ? (\n <Badge data-status=\"connected\" variant=\"success\">\n {labels.connected}\n </Badge>\n ) : onConnect ? (\n <Button\n aria-label={labels.connectTo(integration.name)}\n onClick={() => onConnect(integration.id)}\n size=\"sm\"\n variant=\"outline\"\n >\n {labels.connect}\n </Button>\n ) : null\n }\n description={integration.description}\n icon={\n <span aria-hidden=\"true\" className=\"font-medium text-xs\">\n {getInitials(integration.name)}\n </span>\n }\n key={integration.id}\n render={<li data-integration={integration.id} />}\n title={integration.name}\n />\n ))}\n </ul>\n )\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/list/list-4/list-4.tsx"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/list/list-4/types.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { ListLoadLabels, ListLoadProps } from '../shared/types'\nexport interface List4Integration {\n connected?: boolean\n description: string\n id: string\n name: string\n}\n\nexport interface List4Labels extends ListLoadLabels {\n connect: string\n connectTo: (name: string) => string\n connected: string\n emptyDescription: string\n emptyTitle: string\n title: string\n}\n\nexport interface List4Props extends ListLoadProps {\n className?: string\n integrations: readonly List4Integration[]\n labels?: Partial<List4Labels>\n onConnect?: (id: string) => void\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/list/list-4/types.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/list/shared/labels.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import type { ListLoadLabels } from './types'\n\nexport const defaultListLoadLabels: Pick<\n ListLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/labels.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/list/shared/list-load-state.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { ListLoadLabels, ListLoadProps } from './types'\n\nexport function ListSkeleton({\n children,\n className,\n label,\n}: Readonly<{ children: ReactNode; className?: string; label: string }>) {\n return (\n <output\n aria-busy=\"true\"\n aria-label={label}\n className={cn('block', className)}\n data-slot=\"list-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function listLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n ListLoadProps & { labels: ListLoadLabels; skeleton: ReactNode }\n>): ReactNode {\n if (pending) return skeleton\n if (error)\n return (\n <StateSurface\n actions={\n onRetry ? (\n <Button onClick={onRetry} size=\"sm\" variant=\"outline\">\n {labels.retry}\n </Button>\n ) : undefined\n }\n description={labels.errorDescription}\n kind=\"error\"\n title={labels.errorTitle}\n />\n )\n return null\n}\n\nexport function ListRowsSkeleton({\n count,\n end,\n}: Readonly<{ count: number; end: 'amount' | 'button' | 'icon' }>) {\n return (\n <div className=\"grid gap-2\">\n {Array.from({ length: count }, (_, index) => `row-${index}`).map((id) => (\n <div\n className=\"flex items-center gap-3 rounded-lg border px-3 py-3\"\n key={id}\n >\n <Skeleton className=\"size-8 shrink-0 rounded-md\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">\n <Skeleton className=\"h-4 w-36 max-w-full\" />\n <Skeleton className=\"h-3.5 w-52 max-w-full\" />\n </div>\n {end === 'amount' ? <Skeleton className=\"h-4 w-20 shrink-0\" /> : null}\n {end === 'button' ? <Skeleton className=\"h-8 w-24 shrink-0\" /> : null}\n {end === 'icon' ? <Skeleton className=\"size-8 shrink-0\" /> : null}\n </div>\n ))}\n </div>\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/list-load-state.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/list/shared/types.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "export interface ListLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface ListLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/types.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "helpers/initials.ts",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "/**\n * Builds the initials shown in an avatar fallback: the first letter of the\n * first words of a label, upper-cased.\n *\n * @param label - A person or entity name; surrounding and repeated whitespace is ignored.\n * @param size - How many words contribute a letter. Defaults to two.\n * @returns The initials, or an empty string for a blank label.\n */\nexport function getInitials(label: string, size = 2): string {\n return label\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, size)\n .map((part) => part[0])\n .join('')\n .toUpperCase()\n}\n\n/**\n * Picks the text of an avatar fallback: the explicit fallback a person carries,\n * or the initials of its label when there is none.\n *\n * @param person - Anything with a `label` and an optional `fallback`.\n * @param size - How many words contribute a letter when the label is used. Defaults to two.\n * @returns The fallback as given (only `undefined` falls through, so an empty\n * string is kept), otherwise the initials of the label.\n */\nexport function resolveInitials(\n person: { label: string; fallback?: string },\n size = 2,\n): string {\n return person.fallback ?? getInitials(person.label, size)\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/helpers/initials.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "patterns/list/composition/list/list.tsx",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { Text } from '@tc96/ui/text'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement } from 'react'\nimport type { ListProps } from '../../core'\nimport {\n listActionsClassName,\n listContentClassName,\n listDescriptionClassName,\n listRootVariants,\n} from '../../lib/variants'\n\nexport function List({\n actions,\n className,\n description,\n icon,\n iconColor,\n render,\n title,\n variant = 'outline',\n}: Readonly<ListProps>): ReactElement {\n return useRender({\n defaultTagName: 'div',\n props: {\n children: (\n <>\n <IconFrame color={iconColor} shape=\"rounded\" size=\"sm\">\n {icon}\n </IconFrame>\n <span className={listContentClassName} data-slot=\"list-content\">\n <Text data-slot=\"list-title\" size=\"sm\" truncate weight=\"medium\">\n {title}\n </Text>\n {description ? (\n <Text\n className={listDescriptionClassName}\n data-slot=\"list-description\"\n foreground=\"muted\"\n size=\"sm\"\n >\n {description}\n </Text>\n ) : null}\n </span>\n {actions ? (\n <span className={listActionsClassName} data-slot=\"list-actions\">\n {actions}\n </span>\n ) : null}\n </>\n ),\n className: cn(listRootVariants({ variant }), className),\n 'data-slot': 'list',\n 'data-variant': variant,\n },\n render,\n })\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/patterns/list/composition/list/list.tsx"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "patterns/list/core.ts",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import type { useRender } from '@base-ui/react/use-render'\nimport type { ReactNode } from 'react'\n\nexport const listVariants = ['outline', 'plain'] as const\n\nexport type ListVariant = (typeof listVariants)[number]\n\nexport interface ListProps {\n actions?: ReactNode\n className?: string\n description?: ReactNode\n icon: ReactNode\n iconColor?: string\n render?: useRender.ComponentProps<'div'>['render']\n title: ReactNode\n variant?: ListVariant\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/patterns/list/core.ts"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "patterns/list/lib/variants.ts",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import { cva } from 'class-variance-authority'\n\nexport const listRootVariants = cva(\n 'flex w-full min-w-0 items-center gap-3 px-3 py-3 text-start outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring [:is(a,button,label)&]:cursor-pointer [:is(a,button,label)&]:hover:bg-muted/50',\n {\n defaultVariants: { variant: 'outline' },\n variants: {\n variant: {\n outline: 'rounded-lg border [label&]:has-data-checked:border-primary',\n plain: '',\n },\n },\n },\n)\n\nexport const listContentClassName = 'flex min-w-0 flex-1 flex-col'\n\nexport const listDescriptionClassName = 'line-clamp-2'\n\nexport const listActionsClassName = 'flex shrink-0 items-center gap-1'\n",
|
|
75
|
+
"target": "~/packages/ui/src/patterns/list/lib/variants.ts"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
79
|
+
"type": "registry:file",
|
|
80
|
+
"content": "import {\n FileMagnifyingGlassIcon,\n LockIcon,\n MagnifyingGlassIcon,\n TrayIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '@tc96/ui/empty'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport {\n STATE_SURFACE_ICON_COLORS,\n STATE_SURFACE_ROLES,\n type StateSurfaceKind,\n type StateSurfaceProps,\n} from '../../core'\n\nconst KIND_ICONS = {\n empty: TrayIcon,\n error: WarningIcon,\n 'no-result': MagnifyingGlassIcon,\n 'not-found': FileMagnifyingGlassIcon,\n permission: LockIcon,\n} as const satisfies Record<StateSurfaceKind, typeof TrayIcon>\n\nexport function StateSurface({\n actions,\n className,\n description,\n icon,\n kind,\n title,\n}: StateSurfaceProps): ReactNode {\n const Icon = KIND_ICONS[kind]\n const iconColor = STATE_SURFACE_ICON_COLORS[kind]\n\n return (\n <Empty\n className={className}\n data-kind={kind}\n role={STATE_SURFACE_ROLES[kind]}\n >\n <EmptyHeader>\n {icon === null ? null : (\n <EmptyMedia>\n <IconFrame\n className={cn(!iconColor && 'bg-muted/60')}\n color={iconColor}\n shape=\"rounded\"\n size=\"xl\"\n >\n {icon === undefined ? <Icon aria-hidden=\"true\" /> : icon}\n </IconFrame>\n </EmptyMedia>\n )}\n <EmptyTitle>{title}</EmptyTitle>\n <EmptyDescription>{description}</EmptyDescription>\n </EmptyHeader>\n {actions ? (\n <EmptyContent className=\"flex-row flex-wrap justify-center gap-2\">\n {actions}\n </EmptyContent>\n ) : null}\n </Empty>\n )\n}\n",
|
|
81
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
85
|
+
"type": "registry:file",
|
|
86
|
+
"content": "import type { ReactNode } from 'react'\n\nexport const STATE_SURFACE_KINDS = [\n 'empty',\n 'no-result',\n 'error',\n 'permission',\n 'not-found',\n] as const\n\nexport type StateSurfaceKind = (typeof STATE_SURFACE_KINDS)[number]\n\nexport type StateGuardState = 'data' | 'loading' | StateSurfaceKind\n\nexport type StateSurfaceRole = 'alert' | 'status'\n\nexport const STATE_SURFACE_ROLES = {\n empty: 'status',\n error: 'alert',\n 'no-result': 'status',\n 'not-found': 'status',\n permission: 'alert',\n} as const satisfies Record<StateSurfaceKind, StateSurfaceRole>\n\nexport const STATE_SURFACE_ICON_COLORS: Partial<\n Record<StateSurfaceKind, string>\n> = {\n error: 'var(--destructive)',\n permission: 'var(--destructive)',\n}\n\nexport interface StateSurfaceProps {\n actions?: ReactNode\n className?: string\n description: ReactNode\n icon?: ReactNode\n kind: StateSurfaceKind\n title: ReactNode\n}\n\nexport type StateGuardProps = {\n children: ReactNode\n} & (\n | { state: 'data'; surface?: Omit<StateSurfaceProps, 'kind'> }\n | {\n state: 'loading'\n surface: Pick<StateSurfaceProps, 'className' | 'title'> & {\n description?: ReactNode\n }\n }\n | { state: StateSurfaceKind; surface: Omit<StateSurfaceProps, 'kind'> }\n)\n",
|
|
87
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"dependencies": [
|
|
91
|
+
"@base-ui/react@1.8.0",
|
|
92
|
+
"@phosphor-icons/react@2.1.10",
|
|
93
|
+
"class-variance-authority@0.7.1",
|
|
94
|
+
"react@19.1.1"
|
|
95
|
+
],
|
|
96
|
+
"registryDependencies": [
|
|
97
|
+
"@ui/badge",
|
|
98
|
+
"@ui/button",
|
|
99
|
+
"@ui/empty",
|
|
100
|
+
"@ui/icon-frame",
|
|
101
|
+
"@ui/skeleton",
|
|
102
|
+
"@ui/text"
|
|
103
|
+
],
|
|
104
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
105
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "list-5",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/list/list-5/index.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "export { List5 } from './list-5'\nexport type { List5Labels, List5Module, List5Props } from './types'\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/list/list-5/index.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/list/list-5/labels.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "import { defaultListLoadLabels } from '../shared/labels'\nimport type { List5Labels } from './types'\n\nexport const defaultList5Labels: List5Labels = {\n ...defaultListLoadLabels,\n errorTitle: 'Não foi possível carregar os módulos',\n loading: 'Carregando módulos',\n add: (name) => `Adicionar ${name}`,\n browseMore: 'Ver mais',\n title: 'Módulos disponíveis',\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/list/list-5/labels.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/list/list-5/list-5-skeleton.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "import { ListRowsSkeleton, ListSkeleton } from '../shared/list-load-state'\n\nexport function List5Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <ListSkeleton label={label}>\n <ListRowsSkeleton count={4} end=\"icon\" />\n </ListSkeleton>\n )\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/list/list-5/list-5-skeleton.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/list/list-5/list-5.tsx",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import { PlusIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { List } from '@tc96/ui/patterns/list/composition/list/list'\nimport { cn } from '@tc96/utils'\nimport { listLoadState } from '../shared/list-load-state'\nimport { defaultList5Labels } from './labels'\nimport { List5Skeleton } from './list-5-skeleton'\nimport type { List5Props } from './types'\n\nexport function List5({\n error,\n onRetry,\n pending,\n className,\n labels: labelsProp,\n modules,\n onAdd,\n onBrowseMore,\n}: Readonly<List5Props>) {\n const labels = { ...defaultList5Labels, ...labelsProp }\n const loadState = listLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton: <List5Skeleton label={labels.loading} />,\n })\n\n return (\n <div className={cn('grid gap-3', className)}>\n {loadState ?? (\n <ul aria-label={labels.title} className=\"grid gap-2\">\n {modules.map((module) => {\n const ModuleIcon = module.icon\n\n return (\n <List\n actions={\n onAdd ? (\n <Button\n aria-label={labels.add(module.name)}\n onClick={() => onAdd(module.id)}\n size=\"icon-sm\"\n variant=\"outline\"\n >\n <PlusIcon aria-hidden=\"true\" />\n </Button>\n ) : null\n }\n description={module.description}\n icon={<ModuleIcon aria-hidden=\"true\" />}\n key={module.id}\n render={<li data-module={module.id} />}\n title={module.name}\n />\n )\n })}\n </ul>\n )}\n {onBrowseMore ? (\n <Button onClick={onBrowseMore} size=\"sm\" variant=\"outline\">\n {labels.browseMore}\n </Button>\n ) : null}\n </div>\n )\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/list/list-5/list-5.tsx"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/list/list-5/types.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { Icon } from '@phosphor-icons/react'\nimport type { ListLoadLabels, ListLoadProps } from '../shared/types'\n\nexport interface List5Module {\n description: string\n icon: Icon\n id: string\n name: string\n}\n\nexport interface List5Labels extends ListLoadLabels {\n add: (name: string) => string\n browseMore: string\n title: string\n}\n\nexport interface List5Props extends ListLoadProps {\n className?: string\n labels?: Partial<List5Labels>\n modules: readonly List5Module[]\n onAdd?: (id: string) => void\n onBrowseMore?: () => void\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/list/list-5/types.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/list/shared/labels.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import type { ListLoadLabels } from './types'\n\nexport const defaultListLoadLabels: Pick<\n ListLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/labels.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/list/shared/list-load-state.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { ListLoadLabels, ListLoadProps } from './types'\n\nexport function ListSkeleton({\n children,\n className,\n label,\n}: Readonly<{ children: ReactNode; className?: string; label: string }>) {\n return (\n <output\n aria-busy=\"true\"\n aria-label={label}\n className={cn('block', className)}\n data-slot=\"list-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function listLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n ListLoadProps & { labels: ListLoadLabels; skeleton: ReactNode }\n>): ReactNode {\n if (pending) return skeleton\n if (error)\n return (\n <StateSurface\n actions={\n onRetry ? (\n <Button onClick={onRetry} size=\"sm\" variant=\"outline\">\n {labels.retry}\n </Button>\n ) : undefined\n }\n description={labels.errorDescription}\n kind=\"error\"\n title={labels.errorTitle}\n />\n )\n return null\n}\n\nexport function ListRowsSkeleton({\n count,\n end,\n}: Readonly<{ count: number; end: 'amount' | 'button' | 'icon' }>) {\n return (\n <div className=\"grid gap-2\">\n {Array.from({ length: count }, (_, index) => `row-${index}`).map((id) => (\n <div\n className=\"flex items-center gap-3 rounded-lg border px-3 py-3\"\n key={id}\n >\n <Skeleton className=\"size-8 shrink-0 rounded-md\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">\n <Skeleton className=\"h-4 w-36 max-w-full\" />\n <Skeleton className=\"h-3.5 w-52 max-w-full\" />\n </div>\n {end === 'amount' ? <Skeleton className=\"h-4 w-20 shrink-0\" /> : null}\n {end === 'button' ? <Skeleton className=\"h-8 w-24 shrink-0\" /> : null}\n {end === 'icon' ? <Skeleton className=\"size-8 shrink-0\" /> : null}\n </div>\n ))}\n </div>\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/list-load-state.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/list/shared/types.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "export interface ListLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface ListLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/types.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "patterns/list/composition/list/list.tsx",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { Text } from '@tc96/ui/text'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement } from 'react'\nimport type { ListProps } from '../../core'\nimport {\n listActionsClassName,\n listContentClassName,\n listDescriptionClassName,\n listRootVariants,\n} from '../../lib/variants'\n\nexport function List({\n actions,\n className,\n description,\n icon,\n iconColor,\n render,\n title,\n variant = 'outline',\n}: Readonly<ListProps>): ReactElement {\n return useRender({\n defaultTagName: 'div',\n props: {\n children: (\n <>\n <IconFrame color={iconColor} shape=\"rounded\" size=\"sm\">\n {icon}\n </IconFrame>\n <span className={listContentClassName} data-slot=\"list-content\">\n <Text data-slot=\"list-title\" size=\"sm\" truncate weight=\"medium\">\n {title}\n </Text>\n {description ? (\n <Text\n className={listDescriptionClassName}\n data-slot=\"list-description\"\n foreground=\"muted\"\n size=\"sm\"\n >\n {description}\n </Text>\n ) : null}\n </span>\n {actions ? (\n <span className={listActionsClassName} data-slot=\"list-actions\">\n {actions}\n </span>\n ) : null}\n </>\n ),\n className: cn(listRootVariants({ variant }), className),\n 'data-slot': 'list',\n 'data-variant': variant,\n },\n render,\n })\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/patterns/list/composition/list/list.tsx"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "patterns/list/core.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import type { useRender } from '@base-ui/react/use-render'\nimport type { ReactNode } from 'react'\n\nexport const listVariants = ['outline', 'plain'] as const\n\nexport type ListVariant = (typeof listVariants)[number]\n\nexport interface ListProps {\n actions?: ReactNode\n className?: string\n description?: ReactNode\n icon: ReactNode\n iconColor?: string\n render?: useRender.ComponentProps<'div'>['render']\n title: ReactNode\n variant?: ListVariant\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/patterns/list/core.ts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "patterns/list/lib/variants.ts",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import { cva } from 'class-variance-authority'\n\nexport const listRootVariants = cva(\n 'flex w-full min-w-0 items-center gap-3 px-3 py-3 text-start outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring [:is(a,button,label)&]:cursor-pointer [:is(a,button,label)&]:hover:bg-muted/50',\n {\n defaultVariants: { variant: 'outline' },\n variants: {\n variant: {\n outline: 'rounded-lg border [label&]:has-data-checked:border-primary',\n plain: '',\n },\n },\n },\n)\n\nexport const listContentClassName = 'flex min-w-0 flex-1 flex-col'\n\nexport const listDescriptionClassName = 'line-clamp-2'\n\nexport const listActionsClassName = 'flex shrink-0 items-center gap-1'\n",
|
|
69
|
+
"target": "~/packages/ui/src/patterns/list/lib/variants.ts"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import {\n FileMagnifyingGlassIcon,\n LockIcon,\n MagnifyingGlassIcon,\n TrayIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '@tc96/ui/empty'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport {\n STATE_SURFACE_ICON_COLORS,\n STATE_SURFACE_ROLES,\n type StateSurfaceKind,\n type StateSurfaceProps,\n} from '../../core'\n\nconst KIND_ICONS = {\n empty: TrayIcon,\n error: WarningIcon,\n 'no-result': MagnifyingGlassIcon,\n 'not-found': FileMagnifyingGlassIcon,\n permission: LockIcon,\n} as const satisfies Record<StateSurfaceKind, typeof TrayIcon>\n\nexport function StateSurface({\n actions,\n className,\n description,\n icon,\n kind,\n title,\n}: StateSurfaceProps): ReactNode {\n const Icon = KIND_ICONS[kind]\n const iconColor = STATE_SURFACE_ICON_COLORS[kind]\n\n return (\n <Empty\n className={className}\n data-kind={kind}\n role={STATE_SURFACE_ROLES[kind]}\n >\n <EmptyHeader>\n {icon === null ? null : (\n <EmptyMedia>\n <IconFrame\n className={cn(!iconColor && 'bg-muted/60')}\n color={iconColor}\n shape=\"rounded\"\n size=\"xl\"\n >\n {icon === undefined ? <Icon aria-hidden=\"true\" /> : icon}\n </IconFrame>\n </EmptyMedia>\n )}\n <EmptyTitle>{title}</EmptyTitle>\n <EmptyDescription>{description}</EmptyDescription>\n </EmptyHeader>\n {actions ? (\n <EmptyContent className=\"flex-row flex-wrap justify-center gap-2\">\n {actions}\n </EmptyContent>\n ) : null}\n </Empty>\n )\n}\n",
|
|
75
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
79
|
+
"type": "registry:file",
|
|
80
|
+
"content": "import type { ReactNode } from 'react'\n\nexport const STATE_SURFACE_KINDS = [\n 'empty',\n 'no-result',\n 'error',\n 'permission',\n 'not-found',\n] as const\n\nexport type StateSurfaceKind = (typeof STATE_SURFACE_KINDS)[number]\n\nexport type StateGuardState = 'data' | 'loading' | StateSurfaceKind\n\nexport type StateSurfaceRole = 'alert' | 'status'\n\nexport const STATE_SURFACE_ROLES = {\n empty: 'status',\n error: 'alert',\n 'no-result': 'status',\n 'not-found': 'status',\n permission: 'alert',\n} as const satisfies Record<StateSurfaceKind, StateSurfaceRole>\n\nexport const STATE_SURFACE_ICON_COLORS: Partial<\n Record<StateSurfaceKind, string>\n> = {\n error: 'var(--destructive)',\n permission: 'var(--destructive)',\n}\n\nexport interface StateSurfaceProps {\n actions?: ReactNode\n className?: string\n description: ReactNode\n icon?: ReactNode\n kind: StateSurfaceKind\n title: ReactNode\n}\n\nexport type StateGuardProps = {\n children: ReactNode\n} & (\n | { state: 'data'; surface?: Omit<StateSurfaceProps, 'kind'> }\n | {\n state: 'loading'\n surface: Pick<StateSurfaceProps, 'className' | 'title'> & {\n description?: ReactNode\n }\n }\n | { state: StateSurfaceKind; surface: Omit<StateSurfaceProps, 'kind'> }\n)\n",
|
|
81
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"dependencies": [
|
|
85
|
+
"@base-ui/react@1.8.0",
|
|
86
|
+
"@phosphor-icons/react@2.1.10",
|
|
87
|
+
"class-variance-authority@0.7.1",
|
|
88
|
+
"react@19.1.1"
|
|
89
|
+
],
|
|
90
|
+
"registryDependencies": [
|
|
91
|
+
"@ui/button",
|
|
92
|
+
"@ui/empty",
|
|
93
|
+
"@ui/icon-frame",
|
|
94
|
+
"@ui/skeleton",
|
|
95
|
+
"@ui/text"
|
|
96
|
+
],
|
|
97
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
98
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "list-6",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/list/list-6/index.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "export { List6 } from './list-6'\nexport type {\n List6Labels,\n List6Mover,\n List6MoverStatus,\n List6Props,\n} from './types'\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/list/list-6/index.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/list/list-6/labels.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "import { defaultListLoadLabels } from '../shared/labels'\nimport type { List6Labels } from './types'\n\nexport const defaultList6Labels: List6Labels = {\n ...defaultListLoadLabels,\n errorTitle: 'Não foi possível carregar os ativos',\n loading: 'Carregando ativos',\n columnChange: 'Variação',\n columnName: 'Ativo',\n columnPrice: 'Preço',\n columnStatus: 'Status',\n emptyDescription: 'Nenhum ativo para mostrar agora.',\n emptyTitle: 'Sem ativos',\n noResultDescription: 'Tente buscar por outro nome.',\n noResultTitle: 'Nenhum ativo encontrado',\n search: 'Buscar ativos',\n searchPlaceholder: 'Buscar ativos',\n statuses: {\n delayed: 'Atrasado',\n halted: 'Suspenso',\n live: 'Ao vivo',\n },\n title: 'Maiores variações',\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/list/list-6/labels.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/list/list-6/list-6-skeleton.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "import { Skeleton } from '@tc96/ui/skeleton'\nimport { ListSkeleton } from '../shared/list-load-state'\n\nexport function List6Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <ListSkeleton className=\"grid gap-2\" label={label}>\n <div className=\"grid grid-cols-4 gap-4 border-b py-2\">\n {['name', 'status', 'price', 'change'].map((id) => (\n <Skeleton className=\"h-3.5 w-16\" key={id} />\n ))}\n </div>\n {['a', 'b', 'c', 'd', 'e'].map((id) => (\n <div className=\"grid grid-cols-4 items-center gap-4 py-2\" key={id}>\n <div className=\"flex items-center gap-3\">\n <Skeleton className=\"size-6 shrink-0 rounded-md\" />\n <Skeleton className=\"h-4 w-24\" />\n </div>\n <Skeleton className=\"h-5 w-16 rounded-full\" />\n <Skeleton className=\"ms-auto h-4 w-20\" />\n <Skeleton className=\"ms-auto h-4 w-14\" />\n </div>\n ))}\n </ListSkeleton>\n )\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/list/list-6/list-6-skeleton.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/list/list-6/list-6.tsx",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import { MagnifyingGlassIcon } from '@phosphor-icons/react'\nimport { Badge } from '@tc96/ui/badge'\nimport { formatAmount } from '@tc96/ui/helpers/format'\nimport { getInitials } from '@tc96/ui/helpers/initials'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n} from '@tc96/ui/input-group'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '@tc96/ui/table'\nimport { cn } from '@tc96/utils'\nimport { listLoadState } from '../shared/list-load-state'\nimport { defaultList6Labels } from './labels'\nimport { List6Skeleton } from './list-6-skeleton'\nimport type { List6MoverStatus, List6Props } from './types'\n\nconst statusVariant = {\n delayed: 'warning',\n halted: 'error',\n live: 'success',\n} as const satisfies Record<List6MoverStatus, string>\n\nconst trendClassName = (change: number) =>\n change > 0\n ? 'text-success-foreground'\n : change < 0\n ? 'text-destructive-foreground'\n : 'text-muted-foreground'\n\nexport function List6({\n error,\n onRetry,\n pending,\n className,\n currency = 'BRL',\n labels: labelsProp,\n locale = 'pt-BR',\n movers,\n onQueryChange,\n query,\n}: Readonly<List6Props>) {\n const labels = { ...defaultList6Labels, ...labelsProp }\n const loadState = listLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton: <List6Skeleton label={labels.loading} />,\n })\n\n return (\n <div className={cn('grid gap-3', className)}>\n <InputGroup>\n <InputGroupAddon>\n <MagnifyingGlassIcon aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n aria-label={labels.search}\n onChange={(event) => onQueryChange(event.target.value)}\n placeholder={labels.searchPlaceholder}\n type=\"search\"\n value={query}\n />\n </InputGroup>\n {loadState ??\n (movers.length === 0 ? (\n <StateSurface\n description={\n query ? labels.noResultDescription : labels.emptyDescription\n }\n kind={query ? 'no-result' : 'empty'}\n title={query ? labels.noResultTitle : labels.emptyTitle}\n />\n ) : (\n <Table>\n <TableCaption className=\"sr-only\">{labels.title}</TableCaption>\n <TableHeader>\n <TableRow>\n <TableHead>{labels.columnName}</TableHead>\n <TableHead>{labels.columnStatus}</TableHead>\n <TableHead className=\"text-end\">{labels.columnPrice}</TableHead>\n <TableHead className=\"text-end\">\n {labels.columnChange}\n </TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {movers.map((mover) => (\n <TableRow data-mover={mover.id} key={mover.id}>\n <TableCell>\n <span className=\"flex items-center gap-3\">\n <IconFrame aria-hidden=\"true\" shape=\"rounded\" size=\"sm\">\n <span className=\"font-medium text-xs\">\n {getInitials(mover.name)}\n </span>\n </IconFrame>\n <span className=\"font-medium\">{mover.name}</span>\n </span>\n </TableCell>\n <TableCell>\n <Badge variant={statusVariant[mover.status]}>\n {labels.statuses[mover.status]}\n </Badge>\n </TableCell>\n <TableCell className=\"text-end tabular-nums\">\n {formatAmount(mover.price, { currency, locale })}\n </TableCell>\n <TableCell className=\"text-end tabular-nums\">\n <span\n className={trendClassName(mover.change)}\n data-trend={\n mover.change > 0\n ? 'up'\n : mover.change < 0\n ? 'down'\n : 'flat'\n }\n >\n {formatAmount(mover.change, {\n locale,\n signDisplay: 'exceptZero',\n style: 'percent',\n })}\n </span>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n ))}\n </div>\n )\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/list/list-6/list-6.tsx"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/list/list-6/types.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { ListLoadLabels, ListLoadProps } from '../shared/types'\nexport type List6MoverStatus = 'delayed' | 'halted' | 'live'\n\nexport interface List6Mover {\n change: number\n id: string\n name: string\n price: number\n status: List6MoverStatus\n}\n\nexport interface List6Labels extends ListLoadLabels {\n columnChange: string\n columnName: string\n columnPrice: string\n columnStatus: string\n emptyDescription: string\n emptyTitle: string\n noResultDescription: string\n noResultTitle: string\n search: string\n searchPlaceholder: string\n statuses: Record<List6MoverStatus, string>\n title: string\n}\n\nexport interface List6Props extends ListLoadProps {\n className?: string\n currency?: string\n labels?: Partial<List6Labels>\n locale?: string\n movers: readonly List6Mover[]\n onQueryChange: (query: string) => void\n query: string\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/list/list-6/types.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/list/shared/labels.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import type { ListLoadLabels } from './types'\n\nexport const defaultListLoadLabels: Pick<\n ListLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/labels.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/list/shared/list-load-state.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { ListLoadLabels, ListLoadProps } from './types'\n\nexport function ListSkeleton({\n children,\n className,\n label,\n}: Readonly<{ children: ReactNode; className?: string; label: string }>) {\n return (\n <output\n aria-busy=\"true\"\n aria-label={label}\n className={cn('block', className)}\n data-slot=\"list-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function listLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n ListLoadProps & { labels: ListLoadLabels; skeleton: ReactNode }\n>): ReactNode {\n if (pending) return skeleton\n if (error)\n return (\n <StateSurface\n actions={\n onRetry ? (\n <Button onClick={onRetry} size=\"sm\" variant=\"outline\">\n {labels.retry}\n </Button>\n ) : undefined\n }\n description={labels.errorDescription}\n kind=\"error\"\n title={labels.errorTitle}\n />\n )\n return null\n}\n\nexport function ListRowsSkeleton({\n count,\n end,\n}: Readonly<{ count: number; end: 'amount' | 'button' | 'icon' }>) {\n return (\n <div className=\"grid gap-2\">\n {Array.from({ length: count }, (_, index) => `row-${index}`).map((id) => (\n <div\n className=\"flex items-center gap-3 rounded-lg border px-3 py-3\"\n key={id}\n >\n <Skeleton className=\"size-8 shrink-0 rounded-md\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">\n <Skeleton className=\"h-4 w-36 max-w-full\" />\n <Skeleton className=\"h-3.5 w-52 max-w-full\" />\n </div>\n {end === 'amount' ? <Skeleton className=\"h-4 w-20 shrink-0\" /> : null}\n {end === 'button' ? <Skeleton className=\"h-8 w-24 shrink-0\" /> : null}\n {end === 'icon' ? <Skeleton className=\"size-8 shrink-0\" /> : null}\n </div>\n ))}\n </div>\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/list-load-state.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/list/shared/types.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "export interface ListLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface ListLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/list/shared/types.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "helpers/format.ts",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "/**\n * Options accepted by the amount formatters. They mirror the subset of\n * `Intl.NumberFormat` options the widgets need; `locale`, `currency` and\n * `style` have defaults, everything else is passed through untouched.\n */\nexport interface AmountFormatOptions {\n currency?: string\n locale?: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n minimumIntegerDigits?: number\n notation?: 'compact' | 'standard'\n signDisplay?: 'always' | 'auto' | 'exceptZero' | 'never'\n style?: 'currency' | 'decimal' | 'percent'\n}\n\n/** An amount split at its decimal separator; see {@link splitAmountAtDecimal}. */\nexport interface AmountParts {\n fraction: string\n integer: string\n}\n\n/** Locale used when `AmountFormatOptions.locale` is omitted. */\nexport const defaultAmountLocale = 'en-US'\n/** Currency used when `AmountFormatOptions.currency` is omitted. */\nexport const defaultAmountCurrency = 'USD'\n\nconst percentFractionDigits = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n}\n\n/**\n * Creates the `Intl.NumberFormat` behind {@link formatAmount}. Percentages\n * get two fraction digits unless `maximumFractionDigits` is set, and the\n * currency is only forwarded for the `currency` style.\n *\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns A reusable formatter for the resolved options.\n */\nexport function createAmountFormatter({\n currency = defaultAmountCurrency,\n locale = defaultAmountLocale,\n style = 'currency',\n ...options\n}: AmountFormatOptions = {}): Intl.NumberFormat {\n const usesPercentDefaults =\n style === 'percent' && options.maximumFractionDigits === undefined\n\n return new Intl.NumberFormat(locale, {\n ...options,\n ...(style === 'currency' ? { currency } : {}),\n ...(usesPercentDefaults ? percentFractionDigits : {}),\n style,\n })\n}\n\n/**\n * Formats a number as currency, decimal or percent. Percentages follow the\n * `Intl` convention: `0.0934` becomes `9.34%`.\n *\n * @param value - The amount to format. Percentages are ratios, not points.\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns The formatted amount for the locale.\n */\nexport function formatAmount(\n value: number,\n options?: AmountFormatOptions,\n): string {\n return createAmountFormatter(options).format(value)\n}\n\n/** Concatenates the values of `Intl.NumberFormat` parts back into text. */\nfunction joinParts(parts: readonly Intl.NumberFormatPart[]): string {\n return parts.map((part) => part.value).join('')\n}\n\n/**\n * Formats an amount and splits it at the decimal separator, so the fraction\n * (separator, digits and any trailing suffix such as `%`) can be rendered\n * with a lighter style than the integer part.\n *\n * @param value - The amount to format.\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns The integer part and the fraction; the fraction is empty when the\n * formatted amount has no decimal separator.\n */\nexport function splitAmountAtDecimal(\n value: number,\n options?: AmountFormatOptions,\n): AmountParts {\n const parts = createAmountFormatter(options).formatToParts(value)\n const decimalIndex = parts.findIndex((part) => part.type === 'decimal')\n\n if (decimalIndex === -1) return { fraction: '', integer: joinParts(parts) }\n\n return {\n fraction: joinParts(parts.slice(decimalIndex)),\n integer: joinParts(parts.slice(0, decimalIndex)),\n }\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/helpers/format.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "helpers/initials.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "/**\n * Builds the initials shown in an avatar fallback: the first letter of the\n * first words of a label, upper-cased.\n *\n * @param label - A person or entity name; surrounding and repeated whitespace is ignored.\n * @param size - How many words contribute a letter. Defaults to two.\n * @returns The initials, or an empty string for a blank label.\n */\nexport function getInitials(label: string, size = 2): string {\n return label\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, size)\n .map((part) => part[0])\n .join('')\n .toUpperCase()\n}\n\n/**\n * Picks the text of an avatar fallback: the explicit fallback a person carries,\n * or the initials of its label when there is none.\n *\n * @param person - Anything with a `label` and an optional `fallback`.\n * @param size - How many words contribute a letter when the label is used. Defaults to two.\n * @returns The fallback as given (only `undefined` falls through, so an empty\n * string is kept), otherwise the initials of the label.\n */\nexport function resolveInitials(\n person: { label: string; fallback?: string },\n size = 2,\n): string {\n return person.fallback ?? getInitials(person.label, size)\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/helpers/initials.ts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import {\n FileMagnifyingGlassIcon,\n LockIcon,\n MagnifyingGlassIcon,\n TrayIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '@tc96/ui/empty'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport {\n STATE_SURFACE_ICON_COLORS,\n STATE_SURFACE_ROLES,\n type StateSurfaceKind,\n type StateSurfaceProps,\n} from '../../core'\n\nconst KIND_ICONS = {\n empty: TrayIcon,\n error: WarningIcon,\n 'no-result': MagnifyingGlassIcon,\n 'not-found': FileMagnifyingGlassIcon,\n permission: LockIcon,\n} as const satisfies Record<StateSurfaceKind, typeof TrayIcon>\n\nexport function StateSurface({\n actions,\n className,\n description,\n icon,\n kind,\n title,\n}: StateSurfaceProps): ReactNode {\n const Icon = KIND_ICONS[kind]\n const iconColor = STATE_SURFACE_ICON_COLORS[kind]\n\n return (\n <Empty\n className={className}\n data-kind={kind}\n role={STATE_SURFACE_ROLES[kind]}\n >\n <EmptyHeader>\n {icon === null ? null : (\n <EmptyMedia>\n <IconFrame\n className={cn(!iconColor && 'bg-muted/60')}\n color={iconColor}\n shape=\"rounded\"\n size=\"xl\"\n >\n {icon === undefined ? <Icon aria-hidden=\"true\" /> : icon}\n </IconFrame>\n </EmptyMedia>\n )}\n <EmptyTitle>{title}</EmptyTitle>\n <EmptyDescription>{description}</EmptyDescription>\n </EmptyHeader>\n {actions ? (\n <EmptyContent className=\"flex-row flex-wrap justify-center gap-2\">\n {actions}\n </EmptyContent>\n ) : null}\n </Empty>\n )\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import type { ReactNode } from 'react'\n\nexport const STATE_SURFACE_KINDS = [\n 'empty',\n 'no-result',\n 'error',\n 'permission',\n 'not-found',\n] as const\n\nexport type StateSurfaceKind = (typeof STATE_SURFACE_KINDS)[number]\n\nexport type StateGuardState = 'data' | 'loading' | StateSurfaceKind\n\nexport type StateSurfaceRole = 'alert' | 'status'\n\nexport const STATE_SURFACE_ROLES = {\n empty: 'status',\n error: 'alert',\n 'no-result': 'status',\n 'not-found': 'status',\n permission: 'alert',\n} as const satisfies Record<StateSurfaceKind, StateSurfaceRole>\n\nexport const STATE_SURFACE_ICON_COLORS: Partial<\n Record<StateSurfaceKind, string>\n> = {\n error: 'var(--destructive)',\n permission: 'var(--destructive)',\n}\n\nexport interface StateSurfaceProps {\n actions?: ReactNode\n className?: string\n description: ReactNode\n icon?: ReactNode\n kind: StateSurfaceKind\n title: ReactNode\n}\n\nexport type StateGuardProps = {\n children: ReactNode\n} & (\n | { state: 'data'; surface?: Omit<StateSurfaceProps, 'kind'> }\n | {\n state: 'loading'\n surface: Pick<StateSurfaceProps, 'className' | 'title'> & {\n description?: ReactNode\n }\n }\n | { state: StateSurfaceKind; surface: Omit<StateSurfaceProps, 'kind'> }\n)\n",
|
|
75
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"dependencies": [
|
|
79
|
+
"@phosphor-icons/react@2.1.10",
|
|
80
|
+
"react@19.1.1"
|
|
81
|
+
],
|
|
82
|
+
"registryDependencies": [
|
|
83
|
+
"@ui/badge",
|
|
84
|
+
"@ui/button",
|
|
85
|
+
"@ui/empty",
|
|
86
|
+
"@ui/icon-frame",
|
|
87
|
+
"@ui/input-group",
|
|
88
|
+
"@ui/skeleton",
|
|
89
|
+
"@ui/table"
|
|
90
|
+
],
|
|
91
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
92
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "list",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "patterns/list/composition/index.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "export * from './list/index'\n",
|
|
9
|
+
"target": "~/packages/ui/src/patterns/list/composition/index.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "patterns/list/composition/list/index.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "export { List } from './list'\n",
|
|
15
|
+
"target": "~/packages/ui/src/patterns/list/composition/list/index.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "patterns/list/composition/list/list.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { Text } from '@tc96/ui/text'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement } from 'react'\nimport type { ListProps } from '../../core'\nimport {\n listActionsClassName,\n listContentClassName,\n listDescriptionClassName,\n listRootVariants,\n} from '../../lib/variants'\n\nexport function List({\n actions,\n className,\n description,\n icon,\n iconColor,\n render,\n title,\n variant = 'outline',\n}: Readonly<ListProps>): ReactElement {\n return useRender({\n defaultTagName: 'div',\n props: {\n children: (\n <>\n <IconFrame color={iconColor} shape=\"rounded\" size=\"sm\">\n {icon}\n </IconFrame>\n <span className={listContentClassName} data-slot=\"list-content\">\n <Text data-slot=\"list-title\" size=\"sm\" truncate weight=\"medium\">\n {title}\n </Text>\n {description ? (\n <Text\n className={listDescriptionClassName}\n data-slot=\"list-description\"\n foreground=\"muted\"\n size=\"sm\"\n >\n {description}\n </Text>\n ) : null}\n </span>\n {actions ? (\n <span className={listActionsClassName} data-slot=\"list-actions\">\n {actions}\n </span>\n ) : null}\n </>\n ),\n className: cn(listRootVariants({ variant }), className),\n 'data-slot': 'list',\n 'data-variant': variant,\n },\n render,\n })\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/patterns/list/composition/list/list.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "patterns/list/core.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import type { useRender } from '@base-ui/react/use-render'\nimport type { ReactNode } from 'react'\n\nexport const listVariants = ['outline', 'plain'] as const\n\nexport type ListVariant = (typeof listVariants)[number]\n\nexport interface ListProps {\n actions?: ReactNode\n className?: string\n description?: ReactNode\n icon: ReactNode\n iconColor?: string\n render?: useRender.ComponentProps<'div'>['render']\n title: ReactNode\n variant?: ListVariant\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/patterns/list/core.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "patterns/list/index.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "export * from './composition/index'\nexport {\n type ListProps,\n type ListVariant,\n listVariants,\n} from './core'\n",
|
|
33
|
+
"target": "~/packages/ui/src/patterns/list/index.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "patterns/list/lib/variants.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import { cva } from 'class-variance-authority'\n\nexport const listRootVariants = cva(\n 'flex w-full min-w-0 items-center gap-3 px-3 py-3 text-start outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring [:is(a,button,label)&]:cursor-pointer [:is(a,button,label)&]:hover:bg-muted/50',\n {\n defaultVariants: { variant: 'outline' },\n variants: {\n variant: {\n outline: 'rounded-lg border [label&]:has-data-checked:border-primary',\n plain: '',\n },\n },\n },\n)\n\nexport const listContentClassName = 'flex min-w-0 flex-1 flex-col'\n\nexport const listDescriptionClassName = 'line-clamp-2'\n\nexport const listActionsClassName = 'flex shrink-0 items-center gap-1'\n",
|
|
39
|
+
"target": "~/packages/ui/src/patterns/list/lib/variants.ts"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"dependencies": [
|
|
43
|
+
"@base-ui/react@1.8.0",
|
|
44
|
+
"class-variance-authority@0.7.1",
|
|
45
|
+
"react@19.1.1"
|
|
46
|
+
],
|
|
47
|
+
"registryDependencies": [
|
|
48
|
+
"@ui/icon-frame",
|
|
49
|
+
"@ui/text"
|
|
50
|
+
],
|
|
51
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
52
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "login-1",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/auth/login-1/index.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "export type {\n AuthBaseProps,\n AuthCommonLabels,\n AuthFieldErrors,\n AuthProvider,\n AuthRenderLink,\n} from '../shared/types'\nexport { Login1 } from './login-1'\nexport type { LoginLabels, LoginProps, LoginValues } from './types'\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/auth/login-1/index.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/auth/login-1/labels.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "import { defaultAuthCommonLabels } from '../shared/labels'\nimport type { LoginLabels } from './types'\n\nexport const defaultLoginLabels: LoginLabels = {\n ...defaultAuthCommonLabels,\n description: 'Informe seu e-mail e sua senha para acessar a conta.',\n forgotPassword: 'Esqueceu a senha?',\n noAccount: 'Não tem uma conta?',\n remember: 'Lembrar de mim',\n signup: 'Criar conta',\n submit: 'Entrar',\n title: 'Entrar',\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/auth/login-1/labels.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/auth/login-1/login-1.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { Checkbox } from '@tc96/ui/checkbox'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport { Form } from '@tc96/ui/form'\nimport { Input } from '@tc96/ui/input'\nimport { renderAnchor } from '@tc96/ui/render-anchor'\nimport { type ReactElement, useMemo, useRef } from 'react'\nimport { AuthCard } from '../shared/auth-card'\nimport { AuthPasswordField } from '../shared/auth-password-field'\nimport { AuthProviders } from '../shared/auth-providers'\nimport { resolveAuthLabels } from '../shared/labels'\nimport { toFormErrors } from '../shared/to-form-errors'\nimport { useFocusFirstInvalid } from '../shared/use-focus-first-invalid'\nimport { defaultLoginLabels } from './labels'\nimport type { LoginProps, LoginValues } from './types'\n\nfunction toLoginValues(values: Readonly<Record<string, unknown>>): LoginValues {\n return {\n email: String(values.email ?? ''),\n password: String(values.password ?? ''),\n remember: values.remember === true,\n }\n}\n\nexport function Login1({\n error,\n fieldErrors,\n forgotPasswordHref,\n labels: labelsProp,\n logo,\n onProviderSelect,\n onSubmit,\n pending = false,\n providers,\n renderLink = renderAnchor,\n signupHref,\n}: Readonly<LoginProps>): ReactElement {\n const labels = resolveAuthLabels(defaultLoginLabels, labelsProp)\n const formRef = useRef<HTMLFormElement>(null)\n const alertRef = useRef<HTMLDivElement>(null)\n const errors = useMemo(() => toFormErrors(fieldErrors), [fieldErrors])\n\n useFocusFirstInvalid({ alertRef, error, fieldErrors, formRef })\n\n return (\n <AuthCard\n alertRef={alertRef}\n description={labels.description}\n error={error}\n errorTitle={labels.errorTitle}\n footer={\n signupHref ? (\n <>\n <span>{labels.noAccount}</span>\n <Button\n className=\"underline\"\n render={renderLink(signupHref)}\n size=\"sm\"\n variant=\"link\"\n >\n {labels.signup}\n </Button>\n </>\n ) : undefined\n }\n logo={logo}\n title={labels.title}\n >\n <AuthProviders\n labels={labels}\n onSelect={onProviderSelect}\n pending={pending}\n providers={providers}\n />\n <Form\n aria-busy={pending}\n className=\"flex flex-col gap-4\"\n errors={errors}\n onFormSubmit={(values) => {\n if (pending) return\n onSubmit(toLoginValues(values))\n }}\n ref={formRef}\n >\n <Field name=\"email\">\n <FieldLabel>{labels.email}</FieldLabel>\n <Input autoComplete=\"username\" required type=\"email\" />\n <FieldError />\n </Field>\n <AuthPasswordField\n autoComplete=\"current-password\"\n hideLabel={labels.hidePassword}\n label={labels.password}\n labelAction={\n forgotPasswordHref ? (\n <Button\n className=\"underline\"\n render={renderLink(forgotPasswordHref)}\n size=\"sm\"\n variant=\"link\"\n >\n {labels.forgotPassword}\n </Button>\n ) : undefined\n }\n name=\"password\"\n showLabel={labels.showPassword}\n />\n <Field name=\"remember\">\n <FieldLabel>\n <Checkbox />\n {labels.remember}\n </FieldLabel>\n </Field>\n <Button className=\"w-full\" loading={pending} type=\"submit\">\n {labels.submit}\n </Button>\n </Form>\n </AuthCard>\n )\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/auth/login-1/login-1.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/auth/login-1/types.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import type {\n AuthBaseProps,\n AuthCommonLabels,\n AuthFieldErrors,\n AuthProvider,\n} from '../shared/types'\n\nexport interface LoginValues {\n email: string\n password: string\n remember: boolean\n}\n\nexport interface LoginLabels extends AuthCommonLabels {\n description: string\n forgotPassword: string\n noAccount: string\n remember: string\n signup: string\n submit: string\n title: string\n}\n\nexport interface LoginProps extends AuthBaseProps<LoginLabels> {\n fieldErrors?: AuthFieldErrors<LoginValues>\n forgotPasswordHref?: string\n onProviderSelect?: (id: string) => void\n onSubmit: (values: LoginValues) => void\n providers?: AuthProvider[]\n signupHref?: string\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/auth/login-1/types.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/auth/shared/auth-card.tsx",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "'use client'\n\nimport { Alert, AlertDescription, AlertTitle } from '@tc96/ui/alert'\nimport {\n Card,\n CardDescription,\n CardHeader,\n CardPanel,\n CardTitle,\n} from '@tc96/ui/card'\nimport type { ReactElement, ReactNode, Ref } from 'react'\n\nexport interface AuthCardProps {\n alertRef?: Ref<HTMLDivElement>\n children?: ReactNode\n description?: ReactNode\n error?: string\n errorTitle: string\n footer?: ReactNode\n logo?: ReactNode\n notice?: ReactNode\n title: ReactNode\n titleRef?: Ref<HTMLDivElement>\n}\n\nexport function AuthCard({\n alertRef,\n children,\n description,\n error,\n errorTitle,\n footer,\n logo,\n notice,\n title,\n titleRef,\n}: Readonly<AuthCardProps>): ReactElement {\n return (\n <main className=\"flex min-h-svh items-center justify-center p-4 sm:p-6\">\n <div className=\"flex w-full max-w-sm flex-col gap-6\">\n <Card>\n <CardHeader className=\"justify-items-center text-center\">\n {logo ? (\n <div className=\"mb-2 flex justify-center\">{logo}</div>\n ) : null}\n <CardTitle\n ref={titleRef}\n render={(props) => <h1 {...props} />}\n tabIndex={titleRef ? -1 : undefined}\n >\n {title}\n </CardTitle>\n {description ? (\n <CardDescription>{description}</CardDescription>\n ) : null}\n </CardHeader>\n <CardPanel className=\"flex flex-col gap-4\">\n {error ? (\n <Alert ref={alertRef} tabIndex={-1} variant=\"error\">\n <AlertTitle>{errorTitle}</AlertTitle>\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null}\n {children}\n </CardPanel>\n </Card>\n {footer ? (\n <div\n className=\"flex flex-wrap items-center justify-center gap-1 text-muted-foreground text-sm\"\n data-slot=\"auth-footer\"\n >\n {footer}\n </div>\n ) : null}\n {notice}\n </div>\n </main>\n )\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-card.tsx"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/auth/shared/auth-password-field.tsx",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "'use client'\n\nimport { EyeIcon, EyeSlashIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n} from '@tc96/ui/input-group'\nimport { type ReactElement, type ReactNode, useState } from 'react'\n\nexport interface AuthPasswordFieldProps {\n autoComplete: 'current-password' | 'new-password'\n children?: ReactNode\n hideLabel: string\n label: string\n labelAction?: ReactNode\n minLength?: number\n name: string\n onValueChange?: (value: string) => void\n required?: boolean\n showLabel: string\n}\n\nexport function AuthPasswordField({\n autoComplete,\n children,\n hideLabel,\n label,\n labelAction,\n minLength,\n name,\n onValueChange,\n required = true,\n showLabel,\n}: Readonly<AuthPasswordFieldProps>): ReactElement {\n const [visible, setVisible] = useState(false)\n const toggleLabel = visible ? hideLabel : showLabel\n return (\n <Field name={name}>\n {labelAction ? (\n <div className=\"flex w-full items-center justify-between gap-2\">\n <FieldLabel>{label}</FieldLabel>\n {labelAction}\n </div>\n ) : (\n <FieldLabel>{label}</FieldLabel>\n )}\n <InputGroup>\n <InputGroupInput\n autoComplete={autoComplete}\n minLength={minLength}\n onValueChange={onValueChange}\n required={required}\n type={visible ? 'text' : 'password'}\n />\n <InputGroupAddon align=\"inline-end\">\n <Button\n aria-label={toggleLabel}\n onClick={() => setVisible((current) => !current)}\n size=\"sm\"\n title={toggleLabel}\n type=\"button\"\n variant=\"ghost\"\n >\n {visible ? <EyeSlashIcon aria-hidden /> : <EyeIcon aria-hidden />}\n </Button>\n </InputGroupAddon>\n </InputGroup>\n <FieldError />\n {children}\n </Field>\n )\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-password-field.tsx"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/auth/shared/auth-providers.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { Separator } from '@tc96/ui/separator'\nimport type { ReactElement } from 'react'\nimport type { AuthCommonLabels, AuthProvider } from './types'\n\nexport interface AuthProvidersProps {\n labels: Pick<\n AuthCommonLabels,\n 'providerContinue' | 'providersGroup' | 'providersSeparator'\n >\n onSelect?: (id: string) => void\n pending?: boolean\n providers?: readonly AuthProvider[]\n}\n\nexport function AuthProviders({\n labels,\n onSelect,\n pending = false,\n providers,\n}: Readonly<AuthProvidersProps>): ReactElement | null {\n if (!providers?.length) return null\n return (\n <div className=\"flex flex-col gap-4\">\n <fieldset\n className={\n providers.length > 1\n ? 'grid min-w-0 gap-2 sm:grid-cols-2'\n : 'grid min-w-0 gap-2'\n }\n >\n <legend className=\"sr-only\">{labels.providersGroup}</legend>\n {providers.map((provider) => (\n <Button\n aria-label={labels.providerContinue(provider.label)}\n className=\"w-full\"\n disabled={pending}\n key={provider.id}\n onClick={() => {\n if (!pending) onSelect?.(provider.id)\n }}\n type=\"button\"\n variant=\"secondary\"\n >\n {provider.icon}\n {provider.label}\n </Button>\n ))}\n </fieldset>\n <div\n aria-hidden=\"true\"\n className=\"flex items-center gap-3 text-muted-foreground text-xs\"\n >\n <div className=\"flex-1\">\n <Separator />\n </div>\n <span>{labels.providersSeparator}</span>\n <div className=\"flex-1\">\n <Separator />\n </div>\n </div>\n </div>\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-providers.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/auth/shared/labels.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "import type { AuthCommonLabels, AuthNewPasswordLabels } from './types'\n\nexport const defaultAuthCommonLabels: AuthCommonLabels = {\n email: 'E-mail',\n errorTitle: 'Não foi possível continuar',\n hidePassword: 'Ocultar senha',\n password: 'Senha',\n providerContinue: (label) => `Continuar com ${label}`,\n providersGroup: 'Entrar com outro serviço',\n providersSeparator: 'ou continue com e-mail',\n showPassword: 'Mostrar senha',\n}\n\nexport const defaultAuthNewPasswordLabels: AuthNewPasswordLabels = {\n confirmPassword: 'Confirmar senha',\n passwordMismatch: 'As senhas não coincidem.',\n suggestionLowercase: 'minúscula',\n suggestionMet: 'atendida',\n suggestionMissing: 'faltando',\n suggestionNumber: 'número',\n suggestionSymbol: 'símbolo',\n suggestionUppercase: 'maiúscula',\n}\n\nexport function resolveAuthLabels<TLabels>(\n defaults: TLabels,\n labels?: Partial<TLabels>,\n): TLabels {\n return { ...defaults, ...labels }\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/labels.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/application/auth/shared/to-form-errors.ts",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "export function toFormErrors(\n fieldErrors?: Readonly<Partial<Record<string, string>>>,\n): Record<string, string> {\n const errors: Record<string, string> = {}\n for (const [name, message] of Object.entries(fieldErrors ?? {}))\n if (message) errors[name] = message\n return errors\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/to-form-errors.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/application/auth/shared/types.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type { ReactNode } from 'react'\n\nexport type AuthRenderLink = RenderLink\n\nexport interface AuthProvider {\n icon?: ReactNode\n id: string\n label: string\n}\n\nexport type AuthFieldErrors<TValues> = Partial<Record<keyof TValues, string>>\n\nexport type AuthPasswordSuggestion =\n | 'lowercase'\n | 'uppercase'\n | 'number'\n | 'symbol'\n\nexport interface AuthCommonLabels {\n email: string\n errorTitle: string\n hidePassword: string\n password: string\n providerContinue: (label: string) => string\n providersGroup: string\n providersSeparator: string\n showPassword: string\n}\n\nexport interface AuthNewPasswordLabels {\n confirmPassword: string\n passwordMismatch: string\n suggestionLowercase: string\n suggestionMet: string\n suggestionMissing: string\n suggestionNumber: string\n suggestionSymbol: string\n suggestionUppercase: string\n}\n\nexport interface AuthBaseProps<TLabels> {\n error?: string\n labels?: Partial<TLabels>\n logo?: ReactNode\n pending?: boolean\n renderLink?: AuthRenderLink\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/types.ts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "blocks/application/auth/shared/use-focus-first-invalid.ts",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "'use client'\n\nimport { type RefObject, useEffect, useRef } from 'react'\nimport { toFormErrors } from './to-form-errors'\n\nexport interface UseFocusFirstInvalidOptions {\n alertRef: RefObject<HTMLElement | null>\n error?: string\n fieldErrors?: Readonly<Partial<Record<string, string>>>\n formRef: RefObject<HTMLFormElement | null>\n}\n\nfunction findFirstNamedControl(\n form: HTMLFormElement | null,\n names: readonly string[],\n): HTMLElement | undefined {\n return Array.from(form?.elements ?? []).find(\n (element): element is HTMLElement =>\n element instanceof HTMLElement &&\n !(element instanceof HTMLInputElement && element.type === 'hidden') &&\n names.includes(element.getAttribute('name') ?? ''),\n )\n}\n\nexport function useFocusFirstInvalid({\n alertRef,\n error,\n fieldErrors,\n formRef,\n}: UseFocusFirstInvalidOptions): void {\n const invalidNames = Object.keys(toFormErrors(fieldErrors)).join('\\n')\n const hasError = Boolean(error)\n const previous = useRef({ hasError, invalidNames })\n\n useEffect(() => {\n const before = previous.current\n previous.current = { hasError, invalidNames }\n const hasFieldErrors = invalidNames !== ''\n const filled =\n (hasFieldErrors && before.invalidNames === '') ||\n (hasError && !before.hasError)\n if (!filled) return\n const field = hasFieldErrors\n ? findFirstNamedControl(formRef.current, invalidNames.split('\\n'))\n : undefined\n if (field) field.focus()\n else if (hasError) alertRef.current?.focus()\n }, [alertRef, formRef, hasError, invalidNames])\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/use-focus-first-invalid.ts"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"dependencies": [
|
|
73
|
+
"@phosphor-icons/react@2.1.10",
|
|
74
|
+
"react@19.1.1"
|
|
75
|
+
],
|
|
76
|
+
"registryDependencies": [
|
|
77
|
+
"@ui/alert",
|
|
78
|
+
"@ui/button",
|
|
79
|
+
"@ui/card",
|
|
80
|
+
"@ui/checkbox",
|
|
81
|
+
"@ui/field",
|
|
82
|
+
"@ui/form",
|
|
83
|
+
"@ui/input",
|
|
84
|
+
"@ui/input-group",
|
|
85
|
+
"@ui/render-anchor",
|
|
86
|
+
"@ui/separator"
|
|
87
|
+
],
|
|
88
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
89
|
+
}
|