@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.
Files changed (200) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -2
  3. package/cli.js +1395 -0
  4. package/package.json +35 -4
  5. package/registry/agent-builder.json +503 -0
  6. package/registry/aggregate.json +4 -0
  7. package/registry/app-shell-1.json +81 -0
  8. package/registry/app-shell-2.json +89 -0
  9. package/registry/app-shell-3.json +109 -0
  10. package/registry/app-shell-4.json +104 -0
  11. package/registry/app-shell-5.json +106 -0
  12. package/registry/bulk-import-1.json +151 -0
  13. package/registry/card-1.json +104 -0
  14. package/registry/card-2.json +97 -0
  15. package/registry/card-3.json +104 -0
  16. package/registry/card-4.json +98 -0
  17. package/registry/card-5.json +85 -0
  18. package/registry/card-6.json +98 -0
  19. package/registry/card-7.json +104 -0
  20. package/registry/card-8.json +106 -0
  21. package/registry/card-9.json +92 -0
  22. package/registry/charts.json +30 -0
  23. package/registry/chat-assistant.json +110 -0
  24. package/registry/chats-panel.json +97 -0
  25. package/registry/checklist.json +307 -0
  26. package/registry/collection-layouts.json +836 -0
  27. package/registry/collection-views.json +836 -0
  28. package/registry/collection.json +831 -0
  29. package/registry/dashboard-1.json +160 -0
  30. package/registry/dashboard-2.json +153 -0
  31. package/registry/dashboard-3.json +154 -0
  32. package/registry/dashboard-4.json +168 -0
  33. package/registry/detail-sheet.json +54 -0
  34. package/registry/editable.json +36 -0
  35. package/registry/empty-state-1.json +40 -0
  36. package/registry/empty-state-2.json +39 -0
  37. package/registry/empty-state-3.json +61 -0
  38. package/registry/empty-state-4.json +39 -0
  39. package/registry/empty-state-5.json +47 -0
  40. package/registry/empty-state-6.json +40 -0
  41. package/registry/flow-canvas.json +198 -0
  42. package/registry/flow-inspector.json +151 -0
  43. package/registry/flow-step-library.json +112 -0
  44. package/registry/forgot-password-1.json +73 -0
  45. package/registry/forgot-password-2.json +73 -0
  46. package/registry/icon-row.json +52 -0
  47. package/registry/impact-map.json +75 -0
  48. package/registry/list-1.json +129 -0
  49. package/registry/list-2.json +117 -0
  50. package/registry/list-3.json +129 -0
  51. package/registry/list-4.json +105 -0
  52. package/registry/list-5.json +98 -0
  53. package/registry/list-6.json +92 -0
  54. package/registry/list.json +52 -0
  55. package/registry/login-1.json +89 -0
  56. package/registry/login-10.json +88 -0
  57. package/registry/login-2.json +81 -0
  58. package/registry/login-3.json +90 -0
  59. package/registry/login-4.json +81 -0
  60. package/registry/login-5.json +82 -0
  61. package/registry/login-6.json +88 -0
  62. package/registry/login-7.json +83 -0
  63. package/registry/login-8.json +81 -0
  64. package/registry/login-9.json +88 -0
  65. package/registry/lookup-create-1.json +157 -0
  66. package/registry/magic-link-6.json +79 -0
  67. package/registry/navbar-1.json +66 -0
  68. package/registry/navbar-2.json +48 -0
  69. package/registry/navbar-3.json +50 -0
  70. package/registry/navbar-4.json +39 -0
  71. package/registry/navbar-5.json +50 -0
  72. package/registry/next-steps-1.json +147 -0
  73. package/registry/onboarding-1.json +114 -0
  74. package/registry/onboarding-2.json +78 -0
  75. package/registry/onboarding-3.json +71 -0
  76. package/registry/otp-1.json +73 -0
  77. package/registry/properties.json +523 -0
  78. package/registry/record-dialog.json +88 -0
  79. package/registry/record-group.json +190 -0
  80. package/registry/record-preview.json +70 -0
  81. package/registry/record-status-list.json +70 -0
  82. package/registry/reset-password-1.json +92 -0
  83. package/registry/reset-password-2.json +98 -0
  84. package/registry/reset-password-6.json +91 -0
  85. package/registry/rich-text-editor.json +93 -0
  86. package/registry/run-monitor.json +198 -0
  87. package/registry/settings-1.json +119 -0
  88. package/registry/settings-10.json +218 -0
  89. package/registry/settings-11.json +129 -0
  90. package/registry/settings-12.json +130 -0
  91. package/registry/settings-13.json +130 -0
  92. package/registry/settings-14.json +173 -0
  93. package/registry/settings-15.json +149 -0
  94. package/registry/settings-16.json +129 -0
  95. package/registry/settings-17.json +117 -0
  96. package/registry/settings-18.json +117 -0
  97. package/registry/settings-19.json +125 -0
  98. package/registry/settings-2.json +123 -0
  99. package/registry/settings-20.json +112 -0
  100. package/registry/settings-21.json +116 -0
  101. package/registry/settings-22.json +118 -0
  102. package/registry/settings-23.json +118 -0
  103. package/registry/settings-3.json +123 -0
  104. package/registry/settings-4.json +116 -0
  105. package/registry/settings-5.json +119 -0
  106. package/registry/settings-6.json +125 -0
  107. package/registry/settings-7.json +128 -0
  108. package/registry/settings-8.json +116 -0
  109. package/registry/settings-9.json +118 -0
  110. package/registry/settings-shell.json +60 -0
  111. package/registry/settings.json +82 -0
  112. package/registry/signup-1.json +100 -0
  113. package/registry/signup-2.json +93 -0
  114. package/registry/signup-3.json +83 -0
  115. package/registry/signup-6.json +99 -0
  116. package/registry/state-surface.json +58 -0
  117. package/registry/stats-1.json +116 -0
  118. package/registry/stats-2.json +115 -0
  119. package/registry/stats-3.json +97 -0
  120. package/registry/stats-4.json +92 -0
  121. package/registry/stats-5.json +103 -0
  122. package/registry/stats-6.json +105 -0
  123. package/registry/stats-7.json +103 -0
  124. package/registry/stats.json +64 -0
  125. package/registry/timeline-1.json +97 -0
  126. package/registry/timeline-2.json +102 -0
  127. package/registry/timeline-3.json +68 -0
  128. package/registry/timeline-4.json +86 -0
  129. package/registry/ui/accordion.json +15 -0
  130. package/registry/ui/alert-dialog.json +14 -0
  131. package/registry/ui/alert.json +50 -0
  132. package/registry/ui/autocomplete.json +18 -0
  133. package/registry/ui/avatar.json +14 -0
  134. package/registry/ui/badge.json +51 -0
  135. package/registry/ui/breadcrumb.json +15 -0
  136. package/registry/ui/button.json +25 -0
  137. package/registry/ui/calendar.json +15 -0
  138. package/registry/ui/card.json +14 -0
  139. package/registry/ui/chat.json +115 -0
  140. package/registry/ui/checkbox-group.json +14 -0
  141. package/registry/ui/checkbox.json +14 -0
  142. package/registry/ui/collapsible.json +14 -0
  143. package/registry/ui/combobox.json +18 -0
  144. package/registry/ui/command.json +17 -0
  145. package/registry/ui/composer-clipboard.json +14 -0
  146. package/registry/ui/composer-document.json +14 -0
  147. package/registry/ui/composer-editor.json +16 -0
  148. package/registry/ui/composer-query.json +12 -0
  149. package/registry/ui/composer.json +17 -0
  150. package/registry/ui/context-menu.json +23 -0
  151. package/registry/ui/dialog.json +18 -0
  152. package/registry/ui/drawer.json +18 -0
  153. package/registry/ui/empty.json +14 -0
  154. package/registry/ui/field.json +22 -0
  155. package/registry/ui/fieldset.json +14 -0
  156. package/registry/ui/form.json +14 -0
  157. package/registry/ui/frame.json +12 -0
  158. package/registry/ui/gauge.json +31 -0
  159. package/registry/ui/group.json +17 -0
  160. package/registry/ui/icon-frame.json +31 -0
  161. package/registry/ui/input-group.json +17 -0
  162. package/registry/ui/input.json +14 -0
  163. package/registry/ui/kbd.json +12 -0
  164. package/registry/ui/label.json +14 -0
  165. package/registry/ui/menu.json +39 -0
  166. package/registry/ui/meter.json +14 -0
  167. package/registry/ui/number-field.json +17 -0
  168. package/registry/ui/otp-field.json +31 -0
  169. package/registry/ui/pagination.json +17 -0
  170. package/registry/ui/popover.json +14 -0
  171. package/registry/ui/preview-card.json +14 -0
  172. package/registry/ui/progress.json +14 -0
  173. package/registry/ui/radio-group.json +14 -0
  174. package/registry/ui/render-anchor.json +12 -0
  175. package/registry/ui/scroll-area.json +14 -0
  176. package/registry/ui/segmented-control.json +14 -0
  177. package/registry/ui/select.json +16 -0
  178. package/registry/ui/separator.json +14 -0
  179. package/registry/ui/sheet.json +18 -0
  180. package/registry/ui/sidebar.json +25 -0
  181. package/registry/ui/skeleton.json +24 -0
  182. package/registry/ui/slider.json +14 -0
  183. package/registry/ui/spinner.json +14 -0
  184. package/registry/ui/switch.json +14 -0
  185. package/registry/ui/table.json +14 -0
  186. package/registry/ui/tabs.json +16 -0
  187. package/registry/ui/text.json +31 -0
  188. package/registry/ui/textarea.json +14 -0
  189. package/registry/ui/toast.json +89 -0
  190. package/registry/ui/toggle-group.json +18 -0
  191. package/registry/ui/toggle.json +15 -0
  192. package/registry/ui/toolbar.json +14 -0
  193. package/registry/ui/tooltip.json +14 -0
  194. package/registry/ui/use-composer-editor.json +17 -0
  195. package/registry/ui/use-copy-to-clipboard.json +12 -0
  196. package/registry/ui/use-media-query.json +12 -0
  197. package/registry/view.json +831 -0
  198. package/registry/widgets.json +319 -0
  199. package/registry/wizard.json +89 -0
  200. package/registry/workflow-editor.json +460 -0
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "stats-5",
3
+ "type": "registry:block",
4
+ "files": [
5
+ {
6
+ "path": "blocks/application/stats/shared/labels.ts",
7
+ "type": "registry:file",
8
+ "content": "import type { StatsLoadLabels } from './types'\n\nexport const defaultStatsLoadLabels: Pick<\n StatsLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n",
9
+ "target": "~/packages/ui/src/blocks/application/stats/shared/labels.ts"
10
+ },
11
+ {
12
+ "path": "blocks/application/stats/shared/stats-load-state.tsx",
13
+ "type": "registry:file",
14
+ "content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { StatsLoadLabels, StatsLoadProps } from './types'\n\nexport function StatsSkeleton({\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=\"stats-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function statsLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n StatsLoadProps & { labels: StatsLoadLabels; 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",
15
+ "target": "~/packages/ui/src/blocks/application/stats/shared/stats-load-state.tsx"
16
+ },
17
+ {
18
+ "path": "blocks/application/stats/shared/types.ts",
19
+ "type": "registry:file",
20
+ "content": "export interface StatsAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport interface StatsLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface StatsLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n",
21
+ "target": "~/packages/ui/src/blocks/application/stats/shared/types.ts"
22
+ },
23
+ {
24
+ "path": "blocks/application/stats/stats-5/index.ts",
25
+ "type": "registry:file",
26
+ "content": "export { Stats5 } from './stats-5'\nexport type {\n Stats5Format,\n Stats5Item,\n Stats5Labels,\n Stats5Props,\n} from './types'\n",
27
+ "target": "~/packages/ui/src/blocks/application/stats/stats-5/index.ts"
28
+ },
29
+ {
30
+ "path": "blocks/application/stats/stats-5/labels.ts",
31
+ "type": "registry:file",
32
+ "content": "import { defaultStatsLoadLabels } from '../shared/labels'\nimport type { Stats5Labels } from './types'\n\nexport const defaultStats5Labels: Stats5Labels = {\n ...defaultStatsLoadLabels,\n errorTitle: 'Não foi possível carregar as vendas',\n loading: 'Carregando vendas',\n down: 'Queda de',\n flat: 'Sem variação',\n title: 'Vendas e cancelamentos',\n up: 'Alta de',\n}\n",
33
+ "target": "~/packages/ui/src/blocks/application/stats/stats-5/labels.ts"
34
+ },
35
+ {
36
+ "path": "blocks/application/stats/stats-5/stats-5-skeleton.tsx",
37
+ "type": "registry:file",
38
+ "content": "import { Skeleton } from '@tc96/ui/skeleton'\nimport { StatsSkeleton } from '../shared/stats-load-state'\n\nexport function Stats5Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <StatsSkeleton label={label}>\n <div className=\"grid divide-y sm:grid-cols-3 sm:divide-x sm:divide-y-0\">\n {['a', 'b', 'c'].map((id) => (\n <div className=\"flex flex-col gap-3 p-6\" key={id}>\n <Skeleton className=\"h-4 w-28\" />\n <div className=\"flex items-center justify-between gap-2\">\n <Skeleton className=\"h-9 w-32\" />\n <Skeleton className=\"h-5 w-14 rounded-full\" />\n </div>\n </div>\n ))}\n </div>\n </StatsSkeleton>\n )\n}\n",
39
+ "target": "~/packages/ui/src/blocks/application/stats/stats-5/stats-5-skeleton.tsx"
40
+ },
41
+ {
42
+ "path": "blocks/application/stats/stats-5/stats-5.tsx",
43
+ "type": "registry:file",
44
+ "content": "import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from '@phosphor-icons/react'\nimport { Badge } from '@tc96/ui/badge'\nimport { formatAmount } from '@tc96/ui/helpers/format'\nimport { trendDirection } from '@tc96/ui/patterns/widgets/shared/trend-indicator'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport { statsLoadState } from '../shared/stats-load-state'\nimport { defaultStats5Labels } from './labels'\nimport { Stats5Skeleton } from './stats-5-skeleton'\nimport type { Stats5Item, Stats5Labels, Stats5Props } from './types'\n\nconst icons = { down: ArrowDownIcon, flat: MinusIcon, up: ArrowUpIcon }\n\ninterface TrendBadgeProps {\n labels: Stats5Labels\n locale: string\n lowerIsBetter?: boolean\n value: number\n}\n\nfunction TrendBadge({\n labels,\n locale,\n lowerIsBetter,\n value,\n}: Readonly<TrendBadgeProps>) {\n const direction = trendDirection(value)\n const Icon = icons[direction]\n const good = lowerIsBetter ? direction === 'down' : direction === 'up'\n const variant =\n direction === 'flat' ? 'secondary' : good ? 'success' : 'error'\n\n return (\n <Badge\n className=\"tabular-nums\"\n data-direction={direction}\n data-slot=\"stats-5-trend\"\n data-tone={direction === 'flat' ? 'neutral' : good ? 'good' : 'bad'}\n size=\"large\"\n variant={variant}\n >\n <Icon aria-hidden=\"true\" />\n <span className=\"sr-only\">{labels[direction]} </span>\n {formatAmount(Math.abs(value), { locale, style: 'percent' })}\n </Badge>\n )\n}\n\nexport function Stats5({\n error,\n onRetry,\n pending,\n className,\n currency = 'BRL',\n items,\n labels,\n locale = 'pt-BR',\n}: Readonly<Stats5Props>) {\n const text = { ...defaultStats5Labels, ...labels }\n const loadState = statsLoadState({\n error,\n labels: text,\n onRetry,\n pending,\n skeleton: <Stats5Skeleton label={text.loading} />,\n })\n const formatValue = (item: Stats5Item) =>\n formatAmount(item.value, {\n currency,\n locale,\n ...(item.format === 'percent' ? { maximumFractionDigits: 1 } : {}),\n style: item.format === 'number' ? 'decimal' : (item.format ?? 'currency'),\n })\n\n return (\n <WidgetShell aria-label={text.title} className={className}>\n {loadState ?? (\n <ul\n className=\"grid divide-y sm:grid-cols-3 sm:divide-x sm:divide-y-0\"\n data-slot=\"stats-5-list\"\n >\n {items.map((item) => (\n <li\n className=\"flex flex-col gap-3 p-6\"\n data-slot=\"stats-5-item\"\n key={item.id}\n >\n <span className=\"text-muted-foreground text-sm\">\n {item.label}\n </span>\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <span className=\"font-semibold text-3xl tabular-nums\">\n {formatValue(item)}\n </span>\n <TrendBadge\n labels={text}\n locale={locale}\n lowerIsBetter={item.lowerIsBetter}\n value={item.trend}\n />\n </div>\n </li>\n ))}\n </ul>\n )}\n </WidgetShell>\n )\n}\n",
45
+ "target": "~/packages/ui/src/blocks/application/stats/stats-5/stats-5.tsx"
46
+ },
47
+ {
48
+ "path": "blocks/application/stats/stats-5/types.ts",
49
+ "type": "registry:file",
50
+ "content": "import type { StatsLoadLabels, StatsLoadProps } from '../shared/types'\nexport type Stats5Format = 'currency' | 'number' | 'percent'\n\nexport interface Stats5Item {\n format?: Stats5Format\n id: string\n label: string\n lowerIsBetter?: boolean\n trend: number\n value: number\n}\n\nexport interface Stats5Labels extends StatsLoadLabels {\n down: string\n flat: string\n title: string\n up: string\n}\n\nexport interface Stats5Props extends StatsLoadProps {\n className?: string\n currency?: string\n items: Stats5Item[]\n labels?: Partial<Stats5Labels>\n locale?: string\n}\n",
51
+ "target": "~/packages/ui/src/blocks/application/stats/stats-5/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": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
61
+ "type": "registry:file",
62
+ "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",
63
+ "target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
64
+ },
65
+ {
66
+ "path": "patterns/surfaces/state/core.ts",
67
+ "type": "registry:file",
68
+ "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",
69
+ "target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
70
+ },
71
+ {
72
+ "path": "patterns/widgets/shared/trend-indicator.tsx",
73
+ "type": "registry:file",
74
+ "content": "import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from '@phosphor-icons/react'\nimport { Badge } from '@tc96/ui/badge'\nimport { type AmountFormatOptions, formatAmount } from '@tc96/ui/helpers/format'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement } from 'react'\nimport type { TrendDirection } from '../types'\n\nexport interface TrendIndicatorLabels {\n down: string\n flat: string\n up: string\n}\n\nexport interface TrendIndicatorProps {\n className?: string\n /** Padrão: percentual com duas casas; o valor é uma razão (`0.0044`). */\n format?: AmountFormatOptions\n /** Prefixo lido por leitores de tela, já que a direção é só visual. */\n labels?: TrendIndicatorLabels\n /** `badge` usa o Badge do COSS; `plain` é texto colorido, para gráficos. */\n variant?: 'badge' | 'plain'\n value: number\n}\n\nconst defaultLabels: TrendIndicatorLabels = {\n down: 'Queda de',\n flat: 'Sem variação',\n up: 'Alta de',\n}\n\nexport function trendDirection(value: number): TrendDirection {\n if (value > 0) return 'up'\n if (value < 0) return 'down'\n return 'flat'\n}\n\nconst icons = {\n down: ArrowDownIcon,\n flat: MinusIcon,\n up: ArrowUpIcon,\n} as const\n\nconst badgeVariants = {\n down: 'error',\n flat: 'secondary',\n up: 'success',\n} as const\n\nconst plainTones = {\n down: 'text-destructive-foreground',\n flat: 'text-muted-foreground',\n up: 'text-success-foreground',\n} as const\n\nexport function TrendIndicator({\n className,\n format = { style: 'percent' },\n labels = defaultLabels,\n variant = 'badge',\n value,\n}: Readonly<TrendIndicatorProps>): ReactElement {\n const direction = trendDirection(value)\n const Icon = icons[direction]\n const content = (\n <>\n <Icon aria-hidden=\"true\" />\n <span className=\"sr-only\">{labels[direction]} </span>\n {formatAmount(Math.abs(value), format)}\n </>\n )\n\n if (variant === 'plain') {\n return (\n <span\n className={cn(\n 'inline-flex items-center gap-1 font-medium text-sm tabular-nums [&_svg]:size-3.5 [&_svg]:shrink-0',\n plainTones[direction],\n className,\n )}\n data-direction={direction}\n data-slot=\"trend-indicator\"\n >\n {content}\n </span>\n )\n }\n\n return (\n <Badge\n className={cn('tabular-nums', className)}\n data-direction={direction}\n data-slot=\"trend-indicator\"\n size=\"large\"\n variant={badgeVariants[direction]}\n >\n {content}\n </Badge>\n )\n}\n",
75
+ "target": "~/packages/ui/src/patterns/widgets/shared/trend-indicator.tsx"
76
+ },
77
+ {
78
+ "path": "patterns/widgets/shared/widget-shell.tsx",
79
+ "type": "registry:file",
80
+ "content": "import { Card } from '@tc96/ui/card'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface WidgetShellProps extends ComponentProps<typeof Card> {}\n\nexport function WidgetShell({\n className,\n render = <section />,\n ...props\n}: Readonly<WidgetShellProps>): ReactElement {\n return (\n <Card\n className={cn('min-w-0 border-transparent', className)}\n render={render}\n {...props}\n />\n )\n}\n",
81
+ "target": "~/packages/ui/src/patterns/widgets/shared/widget-shell.tsx"
82
+ },
83
+ {
84
+ "path": "patterns/widgets/types/index.ts",
85
+ "type": "registry:file",
86
+ "content": "export type TrendDirection = 'down' | 'flat' | 'up'\n\nexport interface WidgetPeriodOption<TPeriod extends string = string> {\n label: string\n value: TPeriod\n}\n\n/** Cor semântica do tema do consumidor. */\nexport type WidgetTone = 'destructive' | 'info' | 'success' | 'warning'\n",
87
+ "target": "~/packages/ui/src/patterns/widgets/types/index.ts"
88
+ }
89
+ ],
90
+ "dependencies": [
91
+ "@phosphor-icons/react@2.1.10",
92
+ "react@19.1.1"
93
+ ],
94
+ "registryDependencies": [
95
+ "@ui/badge",
96
+ "@ui/button",
97
+ "@ui/card",
98
+ "@ui/empty",
99
+ "@ui/icon-frame",
100
+ "@ui/skeleton"
101
+ ],
102
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json"
103
+ }
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "stats-6",
3
+ "type": "registry:block",
4
+ "files": [
5
+ {
6
+ "path": "blocks/application/stats/shared/labels.ts",
7
+ "type": "registry:file",
8
+ "content": "import type { StatsLoadLabels } from './types'\n\nexport const defaultStatsLoadLabels: Pick<\n StatsLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n",
9
+ "target": "~/packages/ui/src/blocks/application/stats/shared/labels.ts"
10
+ },
11
+ {
12
+ "path": "blocks/application/stats/shared/stats-load-state.tsx",
13
+ "type": "registry:file",
14
+ "content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { StatsLoadLabels, StatsLoadProps } from './types'\n\nexport function StatsSkeleton({\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=\"stats-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function statsLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n StatsLoadProps & { labels: StatsLoadLabels; 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",
15
+ "target": "~/packages/ui/src/blocks/application/stats/shared/stats-load-state.tsx"
16
+ },
17
+ {
18
+ "path": "blocks/application/stats/shared/types.ts",
19
+ "type": "registry:file",
20
+ "content": "export interface StatsAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport interface StatsLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface StatsLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n",
21
+ "target": "~/packages/ui/src/blocks/application/stats/shared/types.ts"
22
+ },
23
+ {
24
+ "path": "blocks/application/stats/stats-6/index.ts",
25
+ "type": "registry:file",
26
+ "content": "export { Stats6 } from './stats-6'\nexport type {\n Stats6Labels,\n Stats6Period,\n Stats6Props,\n Stats6Sleeve,\n} from './types'\n",
27
+ "target": "~/packages/ui/src/blocks/application/stats/stats-6/index.ts"
28
+ },
29
+ {
30
+ "path": "blocks/application/stats/stats-6/labels.ts",
31
+ "type": "registry:file",
32
+ "content": "import { defaultStatsLoadLabels } from '../shared/labels'\nimport type { Stats6Labels } from './types'\n\nexport const defaultStats6Labels: Stats6Labels = {\n ...defaultStatsLoadLabels,\n errorTitle: 'Não foi possível carregar a carteira',\n loading: 'Carregando carteira',\n period: 'Período',\n periods: { day: 'Dia', month: 'Mês', week: 'Semana', year: 'Ano' },\n share: 'Participação',\n title: 'Alocação da carteira',\n}\n",
33
+ "target": "~/packages/ui/src/blocks/application/stats/stats-6/labels.ts"
34
+ },
35
+ {
36
+ "path": "blocks/application/stats/stats-6/stats-6-skeleton.tsx",
37
+ "type": "registry:file",
38
+ "content": "import { Card } from '@tc96/ui/card'\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { StatsSkeleton } from '../shared/stats-load-state'\n\nexport function Stats6Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <StatsSkeleton className=\"px-6 pb-6\" label={label}>\n <div className=\"grid gap-4 md:grid-cols-3\">\n {['a', 'b', 'c'].map((id) => (\n <Card key={id}>\n <div className=\"flex flex-col gap-3 p-6\">\n <Skeleton className=\"h-4 w-24\" />\n <Skeleton className=\"h-8 w-32\" />\n <Skeleton className=\"h-2 w-full rounded-full\" />\n </div>\n </Card>\n ))}\n </div>\n </StatsSkeleton>\n )\n}\n",
39
+ "target": "~/packages/ui/src/blocks/application/stats/stats-6/stats-6-skeleton.tsx"
40
+ },
41
+ {
42
+ "path": "blocks/application/stats/stats-6/stats-6.tsx",
43
+ "type": "registry:file",
44
+ "content": "import { Card, CardContent, CardHeader, CardTitle } from '@tc96/ui/card'\nimport { Gauge } from '@tc96/ui/gauge'\nimport { formatAmount } from '@tc96/ui/helpers/format'\nimport { TrendIndicator } from '@tc96/ui/patterns/widgets/shared/trend-indicator'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport { Tabs, TabsList, TabsTab } from '@tc96/ui/tabs'\nimport { useId } from 'react'\nimport { statsLoadState } from '../shared/stats-load-state'\nimport { defaultStats6Labels } from './labels'\nimport { Stats6Skeleton } from './stats-6-skeleton'\nimport type { Stats6Period, Stats6Props } from './types'\n\nconst defaultPeriods: Stats6Period[] = ['day', 'week', 'month', 'year']\n\nexport function Stats6({\n error,\n onRetry,\n pending,\n className,\n currency = 'BRL',\n labels,\n locale = 'pt-BR',\n onPeriodChange,\n period,\n periods = defaultPeriods,\n sleeves,\n}: Readonly<Stats6Props>) {\n const text = { ...defaultStats6Labels, ...labels }\n const baseId = useId()\n const loadState = statsLoadState({\n error,\n labels: text,\n onRetry,\n pending,\n skeleton: <Stats6Skeleton label={text.loading} />,\n })\n const percent = (ratio: number) =>\n formatAmount(ratio, { locale, maximumFractionDigits: 0, style: 'percent' })\n\n return (\n <WidgetShell\n aria-label={text.title}\n className={className}\n data-slot=\"stats-6\"\n >\n <CardHeader className=\"flex-row flex-wrap items-center justify-between gap-3\">\n <CardTitle>{text.title}</CardTitle>\n <Tabs\n onValueChange={(next) => onPeriodChange?.(next as Stats6Period)}\n value={period}\n >\n <TabsList aria-label={text.period}>\n {periods.map((value) => (\n <TabsTab key={value} value={value}>\n {text.periods[value]}\n </TabsTab>\n ))}\n </TabsList>\n </Tabs>\n </CardHeader>\n {loadState ?? (\n <CardContent>\n <ul className=\"grid gap-4 md:grid-cols-3\" data-slot=\"stats-6-list\">\n {sleeves.map((sleeve) => (\n <li key={sleeve.id}>\n <Card className=\"h-full\" data-slot=\"stats-6-sleeve\">\n <CardContent className=\"flex flex-col gap-4 p-5\">\n <span className=\"font-medium text-muted-foreground text-sm\">\n {sleeve.name}\n </span>\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <span className=\"font-semibold text-2xl tabular-nums\">\n {formatAmount(sleeve.amount, { currency, locale })}\n </span>\n <TrendIndicator\n format={{ locale, style: 'percent' }}\n value={sleeve.delta}\n />\n </div>\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <span\n className=\"font-medium text-foreground text-sm\"\n id={`${baseId}-${sleeve.id}-share`}\n >\n {text.share}\n </span>\n <span className=\"text-sm tabular-nums\">\n {percent(sleeve.share)}\n </span>\n </div>\n <Gauge\n aria-labelledby={`${baseId}-${sleeve.id}-share`}\n getAriaValueText={() => percent(sleeve.share)}\n max={1}\n value={sleeve.share}\n />\n </div>\n </CardContent>\n </Card>\n </li>\n ))}\n </ul>\n </CardContent>\n )}\n </WidgetShell>\n )\n}\n",
45
+ "target": "~/packages/ui/src/blocks/application/stats/stats-6/stats-6.tsx"
46
+ },
47
+ {
48
+ "path": "blocks/application/stats/stats-6/types.ts",
49
+ "type": "registry:file",
50
+ "content": "import type { StatsLoadLabels, StatsLoadProps } from '../shared/types'\nexport type Stats6Period = 'day' | 'week' | 'month' | 'year'\n\nexport interface Stats6Sleeve {\n amount: number\n delta: number\n id: string\n name: string\n share: number\n}\n\nexport interface Stats6Labels extends StatsLoadLabels {\n period: string\n periods: Record<Stats6Period, string>\n share: string\n title: string\n}\n\nexport interface Stats6Props extends StatsLoadProps {\n className?: string\n currency?: string\n labels?: Partial<Stats6Labels>\n locale?: string\n onPeriodChange?: (period: Stats6Period) => void\n period: Stats6Period\n periods?: Stats6Period[]\n sleeves: Stats6Sleeve[]\n}\n",
51
+ "target": "~/packages/ui/src/blocks/application/stats/stats-6/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": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
61
+ "type": "registry:file",
62
+ "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",
63
+ "target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
64
+ },
65
+ {
66
+ "path": "patterns/surfaces/state/core.ts",
67
+ "type": "registry:file",
68
+ "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",
69
+ "target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
70
+ },
71
+ {
72
+ "path": "patterns/widgets/shared/trend-indicator.tsx",
73
+ "type": "registry:file",
74
+ "content": "import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from '@phosphor-icons/react'\nimport { Badge } from '@tc96/ui/badge'\nimport { type AmountFormatOptions, formatAmount } from '@tc96/ui/helpers/format'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement } from 'react'\nimport type { TrendDirection } from '../types'\n\nexport interface TrendIndicatorLabels {\n down: string\n flat: string\n up: string\n}\n\nexport interface TrendIndicatorProps {\n className?: string\n /** Padrão: percentual com duas casas; o valor é uma razão (`0.0044`). */\n format?: AmountFormatOptions\n /** Prefixo lido por leitores de tela, já que a direção é só visual. */\n labels?: TrendIndicatorLabels\n /** `badge` usa o Badge do COSS; `plain` é texto colorido, para gráficos. */\n variant?: 'badge' | 'plain'\n value: number\n}\n\nconst defaultLabels: TrendIndicatorLabels = {\n down: 'Queda de',\n flat: 'Sem variação',\n up: 'Alta de',\n}\n\nexport function trendDirection(value: number): TrendDirection {\n if (value > 0) return 'up'\n if (value < 0) return 'down'\n return 'flat'\n}\n\nconst icons = {\n down: ArrowDownIcon,\n flat: MinusIcon,\n up: ArrowUpIcon,\n} as const\n\nconst badgeVariants = {\n down: 'error',\n flat: 'secondary',\n up: 'success',\n} as const\n\nconst plainTones = {\n down: 'text-destructive-foreground',\n flat: 'text-muted-foreground',\n up: 'text-success-foreground',\n} as const\n\nexport function TrendIndicator({\n className,\n format = { style: 'percent' },\n labels = defaultLabels,\n variant = 'badge',\n value,\n}: Readonly<TrendIndicatorProps>): ReactElement {\n const direction = trendDirection(value)\n const Icon = icons[direction]\n const content = (\n <>\n <Icon aria-hidden=\"true\" />\n <span className=\"sr-only\">{labels[direction]} </span>\n {formatAmount(Math.abs(value), format)}\n </>\n )\n\n if (variant === 'plain') {\n return (\n <span\n className={cn(\n 'inline-flex items-center gap-1 font-medium text-sm tabular-nums [&_svg]:size-3.5 [&_svg]:shrink-0',\n plainTones[direction],\n className,\n )}\n data-direction={direction}\n data-slot=\"trend-indicator\"\n >\n {content}\n </span>\n )\n }\n\n return (\n <Badge\n className={cn('tabular-nums', className)}\n data-direction={direction}\n data-slot=\"trend-indicator\"\n size=\"large\"\n variant={badgeVariants[direction]}\n >\n {content}\n </Badge>\n )\n}\n",
75
+ "target": "~/packages/ui/src/patterns/widgets/shared/trend-indicator.tsx"
76
+ },
77
+ {
78
+ "path": "patterns/widgets/shared/widget-shell.tsx",
79
+ "type": "registry:file",
80
+ "content": "import { Card } from '@tc96/ui/card'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface WidgetShellProps extends ComponentProps<typeof Card> {}\n\nexport function WidgetShell({\n className,\n render = <section />,\n ...props\n}: Readonly<WidgetShellProps>): ReactElement {\n return (\n <Card\n className={cn('min-w-0 border-transparent', className)}\n render={render}\n {...props}\n />\n )\n}\n",
81
+ "target": "~/packages/ui/src/patterns/widgets/shared/widget-shell.tsx"
82
+ },
83
+ {
84
+ "path": "patterns/widgets/types/index.ts",
85
+ "type": "registry:file",
86
+ "content": "export type TrendDirection = 'down' | 'flat' | 'up'\n\nexport interface WidgetPeriodOption<TPeriod extends string = string> {\n label: string\n value: TPeriod\n}\n\n/** Cor semântica do tema do consumidor. */\nexport type WidgetTone = 'destructive' | 'info' | 'success' | 'warning'\n",
87
+ "target": "~/packages/ui/src/patterns/widgets/types/index.ts"
88
+ }
89
+ ],
90
+ "dependencies": [
91
+ "@phosphor-icons/react@2.1.10",
92
+ "react@19.1.1"
93
+ ],
94
+ "registryDependencies": [
95
+ "@ui/badge",
96
+ "@ui/button",
97
+ "@ui/card",
98
+ "@ui/empty",
99
+ "@ui/gauge",
100
+ "@ui/icon-frame",
101
+ "@ui/skeleton",
102
+ "@ui/tabs"
103
+ ],
104
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json"
105
+ }
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "stats-7",
3
+ "type": "registry:block",
4
+ "files": [
5
+ {
6
+ "path": "blocks/application/stats/shared/labels.ts",
7
+ "type": "registry:file",
8
+ "content": "import type { StatsLoadLabels } from './types'\n\nexport const defaultStatsLoadLabels: Pick<\n StatsLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n",
9
+ "target": "~/packages/ui/src/blocks/application/stats/shared/labels.ts"
10
+ },
11
+ {
12
+ "path": "blocks/application/stats/shared/stats-load-state.tsx",
13
+ "type": "registry:file",
14
+ "content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { StatsLoadLabels, StatsLoadProps } from './types'\n\nexport function StatsSkeleton({\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=\"stats-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function statsLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n StatsLoadProps & { labels: StatsLoadLabels; 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",
15
+ "target": "~/packages/ui/src/blocks/application/stats/shared/stats-load-state.tsx"
16
+ },
17
+ {
18
+ "path": "blocks/application/stats/shared/types.ts",
19
+ "type": "registry:file",
20
+ "content": "export interface StatsAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport interface StatsLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface StatsLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n",
21
+ "target": "~/packages/ui/src/blocks/application/stats/shared/types.ts"
22
+ },
23
+ {
24
+ "path": "blocks/application/stats/stats-7/index.ts",
25
+ "type": "registry:file",
26
+ "content": "export { Stats7 } from './stats-7'\nexport type {\n Stats7Labels,\n Stats7Metric,\n Stats7Props,\n Stats7ValueKind,\n} from './types'\n",
27
+ "target": "~/packages/ui/src/blocks/application/stats/stats-7/index.ts"
28
+ },
29
+ {
30
+ "path": "blocks/application/stats/stats-7/labels.ts",
31
+ "type": "registry:file",
32
+ "content": "import { defaultStatsLoadLabels } from '../shared/labels'\nimport type { Stats7Labels } from './types'\n\nexport const defaultStats7Labels: Stats7Labels = {\n ...defaultStatsLoadLabels,\n emptyDescription: 'As métricas aparecem aqui quando houver dados.',\n emptyTitle: 'Nenhuma métrica ainda',\n errorTitle: 'Não foi possível carregar as métricas',\n loading: 'Carregando métricas',\n title: 'Métricas',\n}\n",
33
+ "target": "~/packages/ui/src/blocks/application/stats/stats-7/labels.ts"
34
+ },
35
+ {
36
+ "path": "blocks/application/stats/stats-7/stats-7-skeleton.tsx",
37
+ "type": "registry:file",
38
+ "content": "import { Card } from '@tc96/ui/card'\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { StatsSkeleton } from '../shared/stats-load-state'\n\nexport function Stats7Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <StatsSkeleton label={label}>\n <div className=\"grid gap-4 md:grid-cols-3\">\n {['a', 'b', 'c'].map((id) => (\n <Card key={id}>\n <div className=\"grid gap-4 p-5\">\n <Skeleton className=\"h-4 w-24\" />\n <div className=\"flex items-end justify-between gap-4\">\n <div className=\"grid gap-2\">\n <Skeleton className=\"h-3 w-20\" />\n <Skeleton className=\"h-7 w-24\" />\n </div>\n <Skeleton className=\"h-12 w-1/2 max-w-40\" />\n </div>\n </div>\n </Card>\n ))}\n </div>\n </StatsSkeleton>\n )\n}\n",
39
+ "target": "~/packages/ui/src/blocks/application/stats/stats-7/stats-7-skeleton.tsx"
40
+ },
41
+ {
42
+ "path": "blocks/application/stats/stats-7/stats-7.tsx",
43
+ "type": "registry:file",
44
+ "content": "import type { AmountFormatOptions } from '@tc96/ui/helpers/format'\nimport { AreaMetricWidget } from '@tc96/ui/patterns/stats/area-metric-widget'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { statsLoadState } from '../shared/stats-load-state'\nimport { defaultStats7Labels } from './labels'\nimport { Stats7Skeleton } from './stats-7-skeleton'\nimport type { Stats7Props, Stats7ValueKind } from './types'\n\nconst metricFormat = (\n kind: Stats7ValueKind,\n locale: string,\n currency: string,\n): AmountFormatOptions =>\n kind === 'currency'\n ? {\n currency,\n locale,\n maximumFractionDigits: 1,\n notation: 'compact',\n style: 'currency',\n }\n : kind === 'percent'\n ? { locale, maximumFractionDigits: 1, style: 'percent' }\n : { locale, maximumFractionDigits: 0, style: 'decimal' }\n\nexport function Stats7({\n className,\n currency = 'BRL',\n error,\n labels: labelsProp,\n locale = 'pt-BR',\n metrics,\n onRetry,\n pending,\n}: Readonly<Stats7Props>) {\n const labels = { ...defaultStats7Labels, ...labelsProp }\n const loadState = statsLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton: <Stats7Skeleton 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 (metrics.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 <section aria-label={labels.title} className={className}>\n <ul className=\"m-0 grid list-none gap-4 p-0 md:grid-cols-3\">\n {metrics.map((metric, index) => (\n <li className=\"min-w-0\" key={metric.id}>\n <AreaMetricWidget\n caption={metric.caption}\n color={`var(--chart-${(index % 5) + 1})`}\n data-stat={metric.id}\n format={metricFormat(metric.kind ?? 'number', locale, currency)}\n label={metric.label}\n points={metric.points}\n value={metric.value}\n />\n </li>\n ))}\n </ul>\n </section>\n )\n}\n",
45
+ "target": "~/packages/ui/src/blocks/application/stats/stats-7/stats-7.tsx"
46
+ },
47
+ {
48
+ "path": "blocks/application/stats/stats-7/types.ts",
49
+ "type": "registry:file",
50
+ "content": "import type { StatsLoadLabels, StatsLoadProps } from '../shared/types'\n\nexport type Stats7ValueKind = 'currency' | 'number' | 'percent'\n\nexport interface Stats7Metric {\n caption?: string\n id: string\n kind?: Stats7ValueKind\n label: string\n points: number[]\n value: number\n}\n\nexport interface Stats7Labels extends StatsLoadLabels {\n emptyDescription: string\n emptyTitle: string\n title: string\n}\n\nexport interface Stats7Props extends StatsLoadProps {\n className?: string\n currency?: string\n labels?: Partial<Stats7Labels>\n locale?: string\n metrics: Stats7Metric[]\n}\n",
51
+ "target": "~/packages/ui/src/blocks/application/stats/stats-7/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": "patterns/stats/area-metric-widget.tsx",
61
+ "type": "registry:file",
62
+ "content": "import { CardPanel } from '@tc96/ui/card'\nimport type { AmountFormatOptions } from '@tc96/ui/helpers/format'\nimport type { ComponentProps, ReactElement, ReactNode } from 'react'\nimport { useId } from 'react'\nimport { Area, AreaChart, ResponsiveContainer, YAxis } from 'recharts'\nimport { Amount } from '../widgets/shared/amount'\nimport { WidgetShell } from '../widgets/shared/widget-shell'\n\nexport interface AreaMetricWidgetProps\n extends Omit<ComponentProps<'div'>, 'children' | 'title'> {\n caption?: ReactNode\n color?: string\n format?: AmountFormatOptions\n label: ReactNode\n points: readonly number[]\n value: number | ReactNode\n}\n\nexport function AreaMetricWidget({\n caption,\n className,\n color = 'var(--chart-1)',\n format,\n label,\n points,\n value,\n ...props\n}: Readonly<AreaMetricWidgetProps>): ReactElement {\n const titleId = useId()\n const gradientId = `area-metric-${titleId.replace(/[^\\w-]/g, '')}`\n const data = points.map((point, index) => ({ index, value: point }))\n\n return (\n <WidgetShell\n aria-labelledby={titleId}\n className={className}\n data-widget=\"area-metric\"\n {...props}\n >\n <CardPanel className=\"grid gap-4 p-5\">\n <h3 className=\"truncate font-medium text-sm\" id={titleId}>\n {label}\n </h3>\n <div className=\"flex items-end justify-between gap-4\">\n <div className=\"grid min-w-0 gap-1\">\n {caption ? (\n <p className=\"truncate text-muted-foreground text-xs\">\n {caption}\n </p>\n ) : null}\n {typeof value === 'number' ? (\n <Amount\n className=\"font-semibold text-2xl leading-tight tracking-tight\"\n value={value}\n {...(format ? { format } : {})}\n />\n ) : (\n <span className=\"font-semibold text-2xl leading-tight tracking-tight tabular-nums\">\n {value}\n </span>\n )}\n </div>\n {data.length > 1 ? (\n <div\n aria-hidden=\"true\"\n className=\"h-12 w-1/2 max-w-40 shrink-0\"\n data-slot=\"area-metric-chart\"\n >\n <ResponsiveContainer\n height=\"100%\"\n initialDimension={{ height: 48, width: 160 }}\n width=\"100%\"\n >\n <AreaChart\n accessibilityLayer={false}\n data={data}\n margin={{ bottom: 0, left: 0, right: 0, top: 2 }}\n >\n <defs>\n <linearGradient id={gradientId} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={color} stopOpacity={0.4} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={0} />\n </linearGradient>\n </defs>\n <YAxis domain={['dataMin', 'dataMax']} hide />\n <Area\n dataKey=\"value\"\n fill={`url(#${gradientId})`}\n isAnimationActive={false}\n stroke={color}\n strokeWidth={1.5}\n type=\"monotone\"\n />\n </AreaChart>\n </ResponsiveContainer>\n </div>\n ) : null}\n </div>\n </CardPanel>\n </WidgetShell>\n )\n}\n",
63
+ "target": "~/packages/ui/src/patterns/stats/area-metric-widget.tsx"
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
+ "path": "patterns/widgets/shared/amount.tsx",
79
+ "type": "registry:file",
80
+ "content": "import {\n type AmountFormatOptions,\n splitAmountAtDecimal,\n} from '@tc96/ui/helpers/format'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface AmountProps extends Omit<ComponentProps<'span'>, 'children'> {\n /** Atenua o separador decimal, as casas e os sufixos. */\n dimFraction?: boolean\n format?: AmountFormatOptions\n value: number\n}\n\nexport function Amount({\n className,\n dimFraction = false,\n format,\n value,\n ...props\n}: Readonly<AmountProps>): ReactElement {\n const { fraction, integer } = splitAmountAtDecimal(value, format)\n\n return (\n <span\n className={cn('tabular-nums', className)}\n data-slot=\"amount\"\n {...props}\n >\n {integer}\n {fraction ? (\n <span className={dimFraction ? 'text-muted-foreground' : undefined}>\n {fraction}\n </span>\n ) : null}\n </span>\n )\n}\n",
81
+ "target": "~/packages/ui/src/patterns/widgets/shared/amount.tsx"
82
+ },
83
+ {
84
+ "path": "patterns/widgets/shared/widget-shell.tsx",
85
+ "type": "registry:file",
86
+ "content": "import { Card } from '@tc96/ui/card'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface WidgetShellProps extends ComponentProps<typeof Card> {}\n\nexport function WidgetShell({\n className,\n render = <section />,\n ...props\n}: Readonly<WidgetShellProps>): ReactElement {\n return (\n <Card\n className={cn('min-w-0 border-transparent', className)}\n render={render}\n {...props}\n />\n )\n}\n",
87
+ "target": "~/packages/ui/src/patterns/widgets/shared/widget-shell.tsx"
88
+ }
89
+ ],
90
+ "dependencies": [
91
+ "@phosphor-icons/react@2.1.10",
92
+ "react@19.1.1",
93
+ "recharts@3.10.1"
94
+ ],
95
+ "registryDependencies": [
96
+ "@ui/button",
97
+ "@ui/card",
98
+ "@ui/empty",
99
+ "@ui/icon-frame",
100
+ "@ui/skeleton"
101
+ ],
102
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json"
103
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "stats",
3
+ "type": "registry:block",
4
+ "files": [
5
+ {
6
+ "path": "helpers/format.ts",
7
+ "type": "registry:file",
8
+ "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",
9
+ "target": "~/packages/ui/src/helpers/format.ts"
10
+ },
11
+ {
12
+ "path": "patterns/stats/area-metric-widget.tsx",
13
+ "type": "registry:file",
14
+ "content": "import { CardPanel } from '@tc96/ui/card'\nimport type { AmountFormatOptions } from '@tc96/ui/helpers/format'\nimport type { ComponentProps, ReactElement, ReactNode } from 'react'\nimport { useId } from 'react'\nimport { Area, AreaChart, ResponsiveContainer, YAxis } from 'recharts'\nimport { Amount } from '../widgets/shared/amount'\nimport { WidgetShell } from '../widgets/shared/widget-shell'\n\nexport interface AreaMetricWidgetProps\n extends Omit<ComponentProps<'div'>, 'children' | 'title'> {\n caption?: ReactNode\n color?: string\n format?: AmountFormatOptions\n label: ReactNode\n points: readonly number[]\n value: number | ReactNode\n}\n\nexport function AreaMetricWidget({\n caption,\n className,\n color = 'var(--chart-1)',\n format,\n label,\n points,\n value,\n ...props\n}: Readonly<AreaMetricWidgetProps>): ReactElement {\n const titleId = useId()\n const gradientId = `area-metric-${titleId.replace(/[^\\w-]/g, '')}`\n const data = points.map((point, index) => ({ index, value: point }))\n\n return (\n <WidgetShell\n aria-labelledby={titleId}\n className={className}\n data-widget=\"area-metric\"\n {...props}\n >\n <CardPanel className=\"grid gap-4 p-5\">\n <h3 className=\"truncate font-medium text-sm\" id={titleId}>\n {label}\n </h3>\n <div className=\"flex items-end justify-between gap-4\">\n <div className=\"grid min-w-0 gap-1\">\n {caption ? (\n <p className=\"truncate text-muted-foreground text-xs\">\n {caption}\n </p>\n ) : null}\n {typeof value === 'number' ? (\n <Amount\n className=\"font-semibold text-2xl leading-tight tracking-tight\"\n value={value}\n {...(format ? { format } : {})}\n />\n ) : (\n <span className=\"font-semibold text-2xl leading-tight tracking-tight tabular-nums\">\n {value}\n </span>\n )}\n </div>\n {data.length > 1 ? (\n <div\n aria-hidden=\"true\"\n className=\"h-12 w-1/2 max-w-40 shrink-0\"\n data-slot=\"area-metric-chart\"\n >\n <ResponsiveContainer\n height=\"100%\"\n initialDimension={{ height: 48, width: 160 }}\n width=\"100%\"\n >\n <AreaChart\n accessibilityLayer={false}\n data={data}\n margin={{ bottom: 0, left: 0, right: 0, top: 2 }}\n >\n <defs>\n <linearGradient id={gradientId} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={color} stopOpacity={0.4} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={0} />\n </linearGradient>\n </defs>\n <YAxis domain={['dataMin', 'dataMax']} hide />\n <Area\n dataKey=\"value\"\n fill={`url(#${gradientId})`}\n isAnimationActive={false}\n stroke={color}\n strokeWidth={1.5}\n type=\"monotone\"\n />\n </AreaChart>\n </ResponsiveContainer>\n </div>\n ) : null}\n </div>\n </CardPanel>\n </WidgetShell>\n )\n}\n",
15
+ "target": "~/packages/ui/src/patterns/stats/area-metric-widget.tsx"
16
+ },
17
+ {
18
+ "path": "patterns/stats/index.ts",
19
+ "type": "registry:file",
20
+ "content": "export type { AreaMetricWidgetProps } from './area-metric-widget'\nexport { AreaMetricWidget } from './area-metric-widget'\nexport type { MetricWidgetProps } from './metric-widget'\nexport { MetricWidget } from './metric-widget'\n",
21
+ "target": "~/packages/ui/src/patterns/stats/index.ts"
22
+ },
23
+ {
24
+ "path": "patterns/stats/metric-widget.tsx",
25
+ "type": "registry:file",
26
+ "content": "import { CardPanel } from '@tc96/ui/card'\nimport type { AmountFormatOptions } from '@tc96/ui/helpers/format'\nimport type { ComponentProps, ReactElement, ReactNode } from 'react'\nimport { useId } from 'react'\nimport { Amount } from '../widgets/shared/amount'\nimport { TrendIndicator } from '../widgets/shared/trend-indicator'\nimport { WidgetShell } from '../widgets/shared/widget-shell'\n\nexport interface MetricWidgetProps\n extends Omit<ComponentProps<'div'>, 'children' | 'title'> {\n change?: number\n changeFormat?: AmountFormatOptions\n changeLabel?: ReactNode\n children?: ReactNode\n format?: AmountFormatOptions\n icon?: ReactNode\n label: ReactNode\n tone?: 'default' | 'inverted'\n value: number | ReactNode\n}\n\nexport function MetricWidget({\n change,\n changeFormat,\n changeLabel,\n children,\n className,\n format,\n icon,\n label,\n tone = 'default',\n value,\n ...props\n}: Readonly<MetricWidgetProps>): ReactElement {\n const titleId = useId()\n const card = (\n <WidgetShell\n aria-labelledby={titleId}\n className={className}\n data-tone={tone}\n data-widget=\"metric\"\n {...props}\n >\n <CardPanel className=\"grid gap-4 p-5\">\n <div className=\"flex items-center justify-between gap-3\">\n <h3 className=\"truncate text-muted-foreground text-sm\" id={titleId}>\n {label}\n </h3>\n {icon}\n </div>\n <div className=\"grid gap-2\">\n {typeof value === 'number' ? (\n <Amount\n className=\"font-medium text-4xl leading-tight tracking-tight\"\n dimFraction\n value={value}\n {...(format ? { format } : {})}\n />\n ) : (\n <span className=\"font-medium text-4xl leading-tight tracking-tight tabular-nums\">\n {value}\n </span>\n )}\n {change === undefined && !changeLabel ? null : (\n <div className=\"flex items-center gap-2 text-muted-foreground text-sm\">\n {change === undefined ? null : (\n <TrendIndicator\n value={change}\n {...(changeFormat ? { format: changeFormat } : {})}\n />\n )}\n {changeLabel}\n </div>\n )}\n </div>\n {children}\n </CardPanel>\n </WidgetShell>\n )\n\n return tone === 'inverted' ? (\n <div className=\"dark contents\" data-slot=\"metric-widget-scope\">\n {card}\n </div>\n ) : (\n card\n )\n}\n",
27
+ "target": "~/packages/ui/src/patterns/stats/metric-widget.tsx"
28
+ },
29
+ {
30
+ "path": "patterns/widgets/shared/amount.tsx",
31
+ "type": "registry:file",
32
+ "content": "import {\n type AmountFormatOptions,\n splitAmountAtDecimal,\n} from '@tc96/ui/helpers/format'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface AmountProps extends Omit<ComponentProps<'span'>, 'children'> {\n /** Atenua o separador decimal, as casas e os sufixos. */\n dimFraction?: boolean\n format?: AmountFormatOptions\n value: number\n}\n\nexport function Amount({\n className,\n dimFraction = false,\n format,\n value,\n ...props\n}: Readonly<AmountProps>): ReactElement {\n const { fraction, integer } = splitAmountAtDecimal(value, format)\n\n return (\n <span\n className={cn('tabular-nums', className)}\n data-slot=\"amount\"\n {...props}\n >\n {integer}\n {fraction ? (\n <span className={dimFraction ? 'text-muted-foreground' : undefined}>\n {fraction}\n </span>\n ) : null}\n </span>\n )\n}\n",
33
+ "target": "~/packages/ui/src/patterns/widgets/shared/amount.tsx"
34
+ },
35
+ {
36
+ "path": "patterns/widgets/shared/trend-indicator.tsx",
37
+ "type": "registry:file",
38
+ "content": "import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from '@phosphor-icons/react'\nimport { Badge } from '@tc96/ui/badge'\nimport { type AmountFormatOptions, formatAmount } from '@tc96/ui/helpers/format'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement } from 'react'\nimport type { TrendDirection } from '../types'\n\nexport interface TrendIndicatorLabels {\n down: string\n flat: string\n up: string\n}\n\nexport interface TrendIndicatorProps {\n className?: string\n /** Padrão: percentual com duas casas; o valor é uma razão (`0.0044`). */\n format?: AmountFormatOptions\n /** Prefixo lido por leitores de tela, já que a direção é só visual. */\n labels?: TrendIndicatorLabels\n /** `badge` usa o Badge do COSS; `plain` é texto colorido, para gráficos. */\n variant?: 'badge' | 'plain'\n value: number\n}\n\nconst defaultLabels: TrendIndicatorLabels = {\n down: 'Queda de',\n flat: 'Sem variação',\n up: 'Alta de',\n}\n\nexport function trendDirection(value: number): TrendDirection {\n if (value > 0) return 'up'\n if (value < 0) return 'down'\n return 'flat'\n}\n\nconst icons = {\n down: ArrowDownIcon,\n flat: MinusIcon,\n up: ArrowUpIcon,\n} as const\n\nconst badgeVariants = {\n down: 'error',\n flat: 'secondary',\n up: 'success',\n} as const\n\nconst plainTones = {\n down: 'text-destructive-foreground',\n flat: 'text-muted-foreground',\n up: 'text-success-foreground',\n} as const\n\nexport function TrendIndicator({\n className,\n format = { style: 'percent' },\n labels = defaultLabels,\n variant = 'badge',\n value,\n}: Readonly<TrendIndicatorProps>): ReactElement {\n const direction = trendDirection(value)\n const Icon = icons[direction]\n const content = (\n <>\n <Icon aria-hidden=\"true\" />\n <span className=\"sr-only\">{labels[direction]} </span>\n {formatAmount(Math.abs(value), format)}\n </>\n )\n\n if (variant === 'plain') {\n return (\n <span\n className={cn(\n 'inline-flex items-center gap-1 font-medium text-sm tabular-nums [&_svg]:size-3.5 [&_svg]:shrink-0',\n plainTones[direction],\n className,\n )}\n data-direction={direction}\n data-slot=\"trend-indicator\"\n >\n {content}\n </span>\n )\n }\n\n return (\n <Badge\n className={cn('tabular-nums', className)}\n data-direction={direction}\n data-slot=\"trend-indicator\"\n size=\"large\"\n variant={badgeVariants[direction]}\n >\n {content}\n </Badge>\n )\n}\n",
39
+ "target": "~/packages/ui/src/patterns/widgets/shared/trend-indicator.tsx"
40
+ },
41
+ {
42
+ "path": "patterns/widgets/shared/widget-shell.tsx",
43
+ "type": "registry:file",
44
+ "content": "import { Card } from '@tc96/ui/card'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface WidgetShellProps extends ComponentProps<typeof Card> {}\n\nexport function WidgetShell({\n className,\n render = <section />,\n ...props\n}: Readonly<WidgetShellProps>): ReactElement {\n return (\n <Card\n className={cn('min-w-0 border-transparent', className)}\n render={render}\n {...props}\n />\n )\n}\n",
45
+ "target": "~/packages/ui/src/patterns/widgets/shared/widget-shell.tsx"
46
+ },
47
+ {
48
+ "path": "patterns/widgets/types/index.ts",
49
+ "type": "registry:file",
50
+ "content": "export type TrendDirection = 'down' | 'flat' | 'up'\n\nexport interface WidgetPeriodOption<TPeriod extends string = string> {\n label: string\n value: TPeriod\n}\n\n/** Cor semântica do tema do consumidor. */\nexport type WidgetTone = 'destructive' | 'info' | 'success' | 'warning'\n",
51
+ "target": "~/packages/ui/src/patterns/widgets/types/index.ts"
52
+ }
53
+ ],
54
+ "dependencies": [
55
+ "@phosphor-icons/react@2.1.10",
56
+ "react@19.1.1",
57
+ "recharts@3.10.1"
58
+ ],
59
+ "registryDependencies": [
60
+ "@ui/badge",
61
+ "@ui/card"
62
+ ],
63
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json"
64
+ }