@tc96/cli 0.27.0 → 0.28.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 (108) hide show
  1. package/README.md +4 -4
  2. package/cli.js +82 -27
  3. package/package.json +1 -1
  4. package/registry/agenda-1.json +1297 -0
  5. package/registry/aggregate.json +1 -1
  6. package/registry/ai-chat-1.json +91 -0
  7. package/registry/checklist.json +21 -7
  8. package/registry/collection.json +624 -351
  9. package/registry/crm-1.json +1317 -0
  10. package/registry/crm-2.json +1400 -0
  11. package/registry/dashboard-5.json +167 -0
  12. package/registry/dashboard-6.json +143 -0
  13. package/registry/dashboard-7.json +188 -0
  14. package/registry/documents-1.json +1322 -0
  15. package/registry/finance-1.json +845 -0
  16. package/registry/finance-2.json +973 -0
  17. package/registry/finance-3.json +1436 -0
  18. package/registry/{workflow-editor.json → flow-1.json} +37 -37
  19. package/registry/{agent-builder.json → flow-2.json} +55 -55
  20. package/registry/{run-monitor.json → flow-3.json} +16 -16
  21. package/registry/{impact-map.json → flow-4.json} +16 -16
  22. package/registry/inbox-1.json +1184 -0
  23. package/registry/inventory-1.json +828 -0
  24. package/registry/inventory-2.json +956 -0
  25. package/registry/legal-1.json +1345 -0
  26. package/registry/legal-2.json +1279 -0
  27. package/registry/legal-3.json +1273 -0
  28. package/registry/legal-4.json +1273 -0
  29. package/registry/legal-5.json +1393 -0
  30. package/registry/legal-6.json +1309 -0
  31. package/registry/legal-7.json +1315 -0
  32. package/registry/legal-8.json +1358 -0
  33. package/registry/legal-9.json +1381 -0
  34. package/registry/marketing-1.json +833 -0
  35. package/registry/marketing-2.json +961 -0
  36. package/registry/navbar-1.json +6 -6
  37. package/registry/navbar-10.json +50 -0
  38. package/registry/navbar-11.json +48 -0
  39. package/registry/navbar-12.json +48 -0
  40. package/registry/navbar-6.json +48 -0
  41. package/registry/navbar-7.json +72 -0
  42. package/registry/navbar-8.json +50 -0
  43. package/registry/navbar-9.json +54 -0
  44. package/registry/projects-1.json +865 -0
  45. package/registry/projects-2.json +993 -0
  46. package/registry/projects-3.json +1346 -0
  47. package/registry/properties.json +65 -58
  48. package/registry/record-group.json +5 -1
  49. package/registry/revenue-1.json +834 -0
  50. package/registry/revenue-2.json +968 -0
  51. package/registry/revenue-3.json +821 -0
  52. package/registry/revenue-4.json +949 -0
  53. package/registry/rich-text-editor-1.json +172 -0
  54. package/registry/rich-text-editor-2.json +158 -0
  55. package/registry/rich-text-editor-3.json +198 -0
  56. package/registry/rich-text-editor-4.json +200 -0
  57. package/registry/rich-text-editor-5.json +237 -0
  58. package/registry/rich-text-editor.json +27 -7
  59. package/registry/{settings-1.json → settings-account-1.json} +17 -17
  60. package/registry/{settings-23.json → settings-account-2.json} +17 -17
  61. package/registry/{settings-7.json → settings-catalog-1.json} +17 -17
  62. package/registry/{settings-16.json → settings-catalog-10.json} +17 -17
  63. package/registry/{settings-8.json → settings-catalog-2.json} +17 -17
  64. package/registry/{settings-9.json → settings-catalog-3.json} +17 -17
  65. package/registry/{settings-10.json → settings-catalog-4.json} +29 -20
  66. package/registry/{settings-11.json → settings-catalog-5.json} +17 -17
  67. package/registry/{settings-12.json → settings-catalog-6.json} +17 -17
  68. package/registry/{settings-13.json → settings-catalog-7.json} +17 -17
  69. package/registry/{settings-14.json → settings-catalog-8.json} +29 -19
  70. package/registry/{settings-15.json → settings-catalog-9.json} +28 -18
  71. package/registry/{settings-19.json → settings-integration-1.json} +17 -17
  72. package/registry/settings-integration-2.json +122 -0
  73. package/registry/{settings-22.json → settings-integration-3.json} +17 -17
  74. package/registry/settings-integration-4.json +129 -0
  75. package/registry/settings-integration-5.json +122 -0
  76. package/registry/settings-integration-6.json +92 -0
  77. package/registry/{settings-21.json → settings-integration-7.json} +23 -17
  78. package/registry/settings-integration-8.json +593 -0
  79. package/registry/{settings-20.json → settings-notification-channel-1.json} +17 -17
  80. package/registry/{settings-2.json → settings-preference-1.json} +17 -17
  81. package/registry/{settings-3.json → settings-preference-2.json} +17 -17
  82. package/registry/{settings-4.json → settings-preference-3.json} +17 -17
  83. package/registry/{settings-18.json → settings-role-permission-1.json} +17 -17
  84. package/registry/{settings-17.json → settings-security-1.json} +17 -17
  85. package/registry/{settings-5.json → settings-workspace-1.json} +28 -28
  86. package/registry/{settings-6.json → settings-workspace-2.json} +31 -31
  87. package/registry/support-1.json +853 -0
  88. package/registry/support-2.json +981 -0
  89. package/registry/support-3.json +762 -0
  90. package/registry/support-4.json +538 -0
  91. package/registry/team-1.json +829 -0
  92. package/registry/team-2.json +957 -0
  93. package/registry/ui/gauge.json +1 -1
  94. package/registry/ui/menu.json +1 -1
  95. package/registry/ui/property-meta.json +16 -0
  96. package/registry/ui/property-tone.json +12 -0
  97. package/registry/ui/scroll-area.json +1 -1
  98. package/registry/ui/select.json +1 -1
  99. package/registry/view.json +624 -351
  100. package/registry/app-shell-5.json +0 -106
  101. package/registry/bulk-import-1.json +0 -151
  102. package/registry/collection-layouts.json +0 -836
  103. package/registry/collection-views.json +0 -836
  104. package/registry/detail-sheet.json +0 -54
  105. package/registry/icon-row.json +0 -52
  106. package/registry/lookup-create-1.json +0 -157
  107. package/registry/next-steps-1.json +0 -147
  108. package/registry/settings-shell.json +0 -60
@@ -0,0 +1,834 @@
1
+ {
2
+ "name": "revenue-1",
3
+ "type": "registry:block",
4
+ "files": [
5
+ {
6
+ "path": "blocks/data/revenue/revenue-1/index.ts",
7
+ "type": "registry:file",
8
+ "content": "export { Revenue1 } from './revenue-1'\nexport type {\n Revenue1Account,\n Revenue1ColumnId,\n Revenue1ColumnVisibility,\n Revenue1Condition,\n Revenue1ConditionOperator,\n Revenue1Density,\n Revenue1FilterField,\n Revenue1Health,\n Revenue1Labels,\n Revenue1LabelsOverride,\n Revenue1Person,\n Revenue1Props,\n Revenue1Renewal,\n Revenue1Risk,\n Revenue1RowAction,\n Revenue1Segment,\n Revenue1Sort,\n Revenue1SortKey,\n Revenue1Stage,\n Revenue1ToggleColumnId,\n Revenue1Urgency,\n Revenue1View,\n} from './types'\n",
9
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/index.ts"
10
+ },
11
+ {
12
+ "path": "blocks/data/revenue/revenue-1/labels.ts",
13
+ "type": "registry:file",
14
+ "content": "import {\n defaultGridLoadLabels,\n defaultGridViewLabels,\n} from '../../shared/grid/labels'\nimport type { Revenue1Labels, Revenue1LabelsOverride } from './types'\n\nexport const defaultRevenue1Labels: Revenue1Labels = {\n ...defaultGridLoadLabels,\n ...defaultGridViewLabels,\n assignOwner: 'Atribuir responsável',\n clearSelection: 'Limpar seleção',\n columns: {\n account: 'Conta',\n actions: 'Ações',\n arr: 'ARR',\n health: 'Saúde',\n renewal: 'Renovação',\n risk: 'Risco',\n stage: 'Etapa',\n },\n columnsMenu: 'Colunas',\n conditions: {\n addFilter: 'Filtros',\n clearFilters: 'Limpar filtros',\n condition: (field) => `Filtro de ${field}`,\n conditionActions: (field) => `Ações do filtro de ${field}`,\n editValue: (field) => `Valor de ${field}`,\n noFields: 'Nenhum campo encontrado',\n noValue: 'Buscar...',\n rangeFrom: 'De',\n rangeSeparator: 'e',\n rangeTo: 'Até',\n removeCondition: 'Remover filtro',\n searchFields: 'Buscar campos',\n valuePlaceholder: 'Digite um valor',\n },\n create: 'Nova transação',\n clearSort: 'Limpar ordenação',\n densities: {\n compact: 'Compacta',\n 'extra-tall': 'Extra alta',\n medium: 'Média',\n short: 'Padrão',\n tall: 'Alta',\n },\n density: 'Altura das linhas',\n filterCount: (label, count) => `${label} (${count})`,\n sortOption: (column, direction) =>\n `${column}: ${direction === 'asc' ? 'crescente' : 'decrescente'}`,\n due: (urgency, days) => {\n if (urgency === 'overdue') return `Venceu há ${Math.abs(days)} d`\n if (urgency === 'soon') return `Vence em ${days} d`\n return `Em ${days} d`\n },\n empty: 'Nenhuma renovação para exibir.',\n errorTitle: 'Não foi possível carregar as renovações',\n fields: {\n account: 'Conta',\n arr: 'ARR',\n health: 'Saúde (%)',\n owner: 'Responsável',\n renewal: 'Data de renovação',\n risk: 'Risco',\n segment: 'Segmento',\n stage: 'Etapa',\n },\n health: {\n 'at-risk': 'Em risco',\n healthy: 'Saudável',\n watchlist: 'Em observação',\n },\n healthScore: (percent, level) => `Saúde ${percent}, ${level}`,\n loading: 'Carregando renovações',\n moveStage: 'Mover etapa',\n newStage: 'Nova etapa',\n operators: {\n after: 'depois de',\n before: 'antes de',\n between: 'entre',\n contains: 'contém',\n eq: 'igual a',\n gt: 'maior que',\n is: 'é',\n 'is-any-of': 'é um de',\n 'is-not': 'não é',\n lt: 'menor que',\n },\n owner: 'Responsável',\n risks: {\n critical: 'Crítico',\n high: 'Alto',\n low: 'Baixo',\n medium: 'Médio',\n },\n rowActionsFor: (account) => `Ações de ${account}`,\n saveView: 'Salvar view',\n segments: {\n enterprise: 'Enterprise',\n 'mid-market': 'Mid-market',\n scale: 'Scale',\n },\n selectAccount: (account) => `Selecionar ${account}`,\n selectAll: 'Selecionar todas as renovações da página',\n selectedCount: (count) =>\n count === 1\n ? '1 renovação selecionada'\n : `${count} renovações selecionadas`,\n selectionActions: 'Ações das renovações selecionadas',\n settings: 'Configurações',\n sortBy: 'Ordenar por',\n stages: {\n 'commercial-review': 'Revisão comercial',\n 'legal-review': 'Revisão jurídica',\n preparing: 'Preparação',\n signed: 'Assinada',\n },\n summary: (dueSoon, atRisk, arrAtRisk) =>\n `${dueSoon} vencem em 30 dias · ${atRisk} em risco · ${arrAtRisk} de ARR em risco`,\n title: 'Revisão de renovações',\n toolbar: 'Controles das renovações',\n upside: (amount) => `+${amount} de potencial`,\n}\n\nexport function resolveRevenue1Labels(\n labels: Revenue1LabelsOverride | undefined,\n): Revenue1Labels {\n return {\n ...defaultRevenue1Labels,\n ...labels,\n columns: { ...defaultRevenue1Labels.columns, ...labels?.columns },\n densities: { ...defaultRevenue1Labels.densities, ...labels?.densities },\n conditions: { ...defaultRevenue1Labels.conditions, ...labels?.conditions },\n fields: { ...defaultRevenue1Labels.fields, ...labels?.fields },\n health: { ...defaultRevenue1Labels.health, ...labels?.health },\n operators: { ...defaultRevenue1Labels.operators, ...labels?.operators },\n risks: { ...defaultRevenue1Labels.risks, ...labels?.risks },\n segments: { ...defaultRevenue1Labels.segments, ...labels?.segments },\n stages: { ...defaultRevenue1Labels.stages, ...labels?.stages },\n }\n}\n",
15
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/labels.ts"
16
+ },
17
+ {
18
+ "path": "blocks/data/revenue/revenue-1/revenue-1-cells.tsx",
19
+ "type": "registry:file",
20
+ "content": "import { Avatar, AvatarFallback, AvatarImage } from '@tc96/ui/avatar'\nimport { getInitials } from '@tc96/ui/helpers/initials'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport type { PropertyOption } from '@tc96/ui/patterns/properties/core'\nimport { cn } from '@tc96/utils'\nimport type { GridFormatter } from '../../shared/grid/format'\nimport { DataSelect } from '../../shared/properties/data-properties'\nimport type {\n Revenue1Health,\n Revenue1Labels,\n Revenue1Renewal,\n Revenue1Risk,\n Revenue1Stage,\n Revenue1Urgency,\n} from './types'\n\nconst selectedText = 'group-data-[state=selected]:text-foreground'\n\nconst healthBars = {\n 'at-risk': 'bg-destructive',\n healthy: 'bg-success',\n watchlist: 'bg-warning',\n} as const satisfies Record<Revenue1Health, string>\n\nexport const revenue1RiskRank = {\n critical: 3,\n high: 2,\n low: 0,\n medium: 1,\n} as const satisfies Record<Revenue1Risk, number>\n\nexport const healthLevel = (health: number): Revenue1Health =>\n health < 0.55 ? 'at-risk' : health < 0.75 ? 'watchlist' : 'healthy'\n\nexport const urgencyOf = (days: number): Revenue1Urgency =>\n days < 0 ? 'overdue' : days <= 30 ? 'soon' : 'later'\n\nconst dueTone = (days: number) =>\n days <= 14\n ? 'text-destructive-foreground'\n : days <= 30\n ? 'text-warning-foreground'\n : 'text-foreground'\n\nexport function AccountCell({\n labels,\n renewal,\n}: Readonly<{ labels: Revenue1Labels; renewal: Revenue1Renewal }>) {\n const { account, owner } = renewal\n\n return (\n <div className=\"flex min-w-0 items-center gap-3\">\n <IconFrame shape=\"rounded\" size=\"sm\">\n {account.logoUrl ? (\n <img alt=\"\" className=\"size-5 object-contain\" src={account.logoUrl} />\n ) : (\n <span aria-hidden=\"true\" className=\"font-semibold text-sm\">\n {getInitials(account.name).slice(0, 1)}\n </span>\n )}\n </IconFrame>\n <span className=\"grid min-w-0 gap-0.5\">\n <span className=\"truncate font-medium\">{account.name}</span>\n <span className=\"flex min-w-0 items-center gap-1.5 text-muted-foreground text-xs\">\n <span aria-hidden=\"true\" className=\"text-foreground\">\n <Avatar className=\"size-4\">\n {owner.imageUrl ? (\n <AvatarImage alt=\"\" src={owner.imageUrl} />\n ) : null}\n <AvatarFallback className=\"text-[0.5rem]\">\n {getInitials(owner.label)}\n </AvatarFallback>\n </Avatar>\n </span>\n <span className=\"truncate\">{owner.label}</span>\n <span aria-hidden=\"true\">·</span>\n <span className=\"truncate\">{labels.segments[account.segment]}</span>\n </span>\n </span>\n </div>\n )\n}\n\nexport function RenewalCell({\n formatter,\n labels,\n renewal,\n}: Readonly<{\n formatter: GridFormatter\n labels: Revenue1Labels\n renewal: Revenue1Renewal\n}>) {\n const urgency = urgencyOf(renewal.dueInDays)\n\n return (\n <span className=\"grid min-w-0 gap-0.5\">\n <span\n className={cn(\n 'truncate font-medium',\n dueTone(renewal.dueInDays),\n selectedText,\n )}\n data-urgency={urgency}\n >\n {labels.due(urgency, renewal.dueInDays)}\n </span>\n <span className=\"truncate text-muted-foreground text-xs tabular-nums\">\n {formatter.date(renewal.renewalDate)}\n </span>\n </span>\n )\n}\n\nexport function ArrCell({\n formatter,\n labels,\n renewal,\n}: Readonly<{\n formatter: GridFormatter\n labels: Revenue1Labels\n renewal: Revenue1Renewal\n}>) {\n const hasUpside = renewal.upside > 0\n\n return (\n <span className=\"grid min-w-0 gap-0.5\">\n <span className=\"font-medium tabular-nums\">\n {formatter.money(renewal.arr)}\n </span>\n <span\n className={cn(\n 'truncate text-xs tabular-nums',\n hasUpside\n ? cn('text-success-foreground', selectedText)\n : 'text-muted-foreground',\n )}\n data-upside={hasUpside ? 'positive' : 'none'}\n >\n {labels.upside(formatter.money(renewal.upside))}\n </span>\n </span>\n )\n}\n\nexport function HealthCell({\n formatter,\n health,\n labels,\n}: Readonly<{\n formatter: GridFormatter\n health: number\n labels: Revenue1Labels\n}>) {\n const level = healthLevel(health)\n const percent = formatter.percent(health)\n\n return (\n <div className=\"grid min-w-0 gap-1\" data-health={level}>\n <div aria-hidden=\"true\" className=\"flex items-center gap-2\">\n <span className=\"block h-1.5 w-20 shrink-0 overflow-hidden rounded-full bg-muted\">\n <span\n className={cn('block h-full rounded-full', healthBars[level])}\n style={{ width: `${Math.min(Math.max(health, 0), 1) * 100}%` }}\n />\n </span>\n <span className=\"text-muted-foreground text-xs tabular-nums\">\n {percent}\n </span>\n </div>\n <span aria-hidden=\"true\" className=\"text-muted-foreground text-xs\">\n {labels.health[level]}\n </span>\n <span className=\"sr-only\">\n {labels.healthScore(percent, labels.health[level])}\n </span>\n </div>\n )\n}\n\nexport function StageCell({\n labels,\n options,\n stage,\n}: Readonly<{\n labels: Revenue1Labels\n options: readonly PropertyOption[]\n stage: Revenue1Stage\n}>) {\n return (\n <DataSelect\n ariaLabel={labels.columns.stage}\n options={options}\n value={stage}\n />\n )\n}\n\nexport function RiskCell({\n labels,\n options,\n risk,\n}: Readonly<{\n labels: Revenue1Labels\n options: readonly PropertyOption[]\n risk: Revenue1Risk\n}>) {\n return (\n <DataSelect\n ariaLabel={labels.columns.risk}\n options={options}\n value={risk}\n />\n )\n}\n",
21
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1-cells.tsx"
22
+ },
23
+ {
24
+ "path": "blocks/data/revenue/revenue-1/revenue-1-columns.tsx",
25
+ "type": "registry:file",
26
+ "content": "import { DotsThreeIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { Menu, MenuItem, MenuPopup, MenuTrigger } from '@tc96/ui/menu'\nimport type { UseDataGridOptions } from '@tc96/ui/patterns/data-grid/hooks/use-data-grid'\nimport { createSelectColumn } from '@tc96/ui/patterns/data-grid/lib/create-select-column'\nimport type { GridFormatter } from '../../shared/grid/format'\nimport { dataSelectOptions } from '../../shared/properties/data-properties'\nimport {\n AccountCell,\n ArrCell,\n HealthCell,\n RenewalCell,\n RiskCell,\n revenue1RiskRank,\n StageCell,\n} from './revenue-1-cells'\nimport {\n revenue1RiskAppearance,\n revenue1Risks,\n revenue1StageAppearance,\n revenue1Stages,\n} from './revenue-1-options'\nimport type {\n Revenue1ColumnId,\n Revenue1Labels,\n Revenue1Renewal,\n Revenue1RowAction,\n Revenue1Stage,\n} from './types'\n\nexport interface Revenue1ColumnsInput {\n formatter: GridFormatter\n labels: Revenue1Labels\n onRowAction?: (actionId: string, renewalId: string) => void\n rowActions?: Revenue1RowAction[]\n}\n\nexport const revenue1FilterOnlyColumns = ['owner', 'segment'] as const\n\nconst stageRank = {\n 'commercial-review': 1,\n 'legal-review': 2,\n preparing: 0,\n signed: 3,\n} as const satisfies Record<Revenue1Stage, number>\n\nexport function createRevenue1Columns({\n formatter,\n labels,\n onRowAction,\n rowActions,\n}: Readonly<Revenue1ColumnsInput>): UseDataGridOptions<Revenue1Renewal>['columns'] {\n const stageOptions = dataSelectOptions(\n revenue1Stages,\n labels.stages,\n revenue1StageAppearance,\n )\n const riskOptions = dataSelectOptions(\n revenue1Risks,\n labels.risks,\n revenue1RiskAppearance,\n )\n const title = (id: Revenue1ColumnId) => labels.columns[id]\n\n const columns: UseDataGridOptions<Revenue1Renewal>['columns'] = [\n createSelectColumn({\n getRowLabel: (renewal) => labels.selectAccount(renewal.account.name),\n selectAllLabel: labels.selectAll,\n showRowNumbers: false,\n }),\n {\n accessorFn: (renewal) => renewal.account.name,\n cell: ({ row }) => <AccountCell labels={labels} renewal={row.original} />,\n enableColumnFilter: false,\n enableHiding: false,\n header: title('account'),\n id: 'account',\n meta: { label: title('account') },\n size: 300,\n },\n {\n accessorFn: (renewal) => renewal.renewalDate,\n cell: ({ row }) => (\n <RenewalCell\n formatter={formatter}\n labels={labels}\n renewal={row.original}\n />\n ),\n enableColumnFilter: false,\n header: title('renewal'),\n id: 'renewal',\n meta: { label: title('renewal') },\n size: 150,\n },\n {\n accessorFn: (renewal) => renewal.arr,\n cell: ({ row }) => (\n <ArrCell formatter={formatter} labels={labels} renewal={row.original} />\n ),\n enableColumnFilter: false,\n header: title('arr'),\n id: 'arr',\n meta: { label: title('arr') },\n size: 190,\n },\n {\n accessorFn: (renewal) => Math.round(renewal.health * 100),\n cell: ({ row }) => (\n <HealthCell\n formatter={formatter}\n health={row.original.health}\n labels={labels}\n />\n ),\n enableColumnFilter: false,\n header: title('health'),\n id: 'health',\n meta: { label: title('health') },\n size: 150,\n },\n {\n accessorFn: (renewal) => renewal.stage,\n cell: ({ row }) => (\n <StageCell\n labels={labels}\n options={stageOptions}\n stage={row.original.stage}\n />\n ),\n enableColumnFilter: false,\n header: title('stage'),\n id: 'stage',\n meta: { label: title('stage') },\n size: 180,\n sortFn: (left, right) =>\n stageRank[left.original.stage] - stageRank[right.original.stage],\n },\n {\n accessorFn: (renewal) => renewal.risk,\n cell: ({ row }) => (\n <RiskCell\n labels={labels}\n options={riskOptions}\n risk={row.original.risk}\n />\n ),\n enableColumnFilter: false,\n header: title('risk'),\n id: 'risk',\n meta: { label: title('risk') },\n size: 120,\n sortFn: (left, right) =>\n revenue1RiskRank[left.original.risk] -\n revenue1RiskRank[right.original.risk],\n },\n {\n accessorFn: (renewal) => renewal.owner.id,\n enableColumnFilter: false,\n enableHiding: false,\n enableSorting: false,\n header: labels.fields.owner,\n id: 'owner',\n },\n {\n accessorFn: (renewal) => renewal.account.segment,\n enableColumnFilter: false,\n enableHiding: false,\n enableSorting: false,\n header: labels.fields.segment,\n id: 'segment',\n },\n ]\n\n if (onRowAction && rowActions?.length) {\n columns.push({\n cell: ({ row }) => (\n <Menu>\n <MenuTrigger\n aria-label={labels.rowActionsFor(row.original.account.name)}\n render={<Button size=\"icon-sm\" variant=\"ghost\" />}\n >\n <DotsThreeIcon aria-hidden=\"true\" />\n </MenuTrigger>\n <MenuPopup align=\"end\">\n {rowActions.map((action) => (\n <MenuItem\n key={action.id}\n onClick={() => onRowAction(action.id, row.original.id)}\n variant={action.destructive ? 'destructive' : undefined}\n >\n {action.label}\n </MenuItem>\n ))}\n </MenuPopup>\n </Menu>\n ),\n enableColumnFilter: false,\n enableHiding: false,\n enablePinning: false,\n enableResizing: false,\n enableSorting: false,\n header: () => <span className=\"sr-only\">{title('actions')}</span>,\n id: 'actions',\n meta: { align: 'end', label: title('actions') },\n size: 56,\n })\n }\n\n return columns\n}\n",
27
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1-columns.tsx"
28
+ },
29
+ {
30
+ "path": "blocks/data/revenue/revenue-1/revenue-1-options.ts",
31
+ "type": "registry:file",
32
+ "content": "import {\n CheckCircleIcon,\n HandshakeIcon,\n HourglassIcon,\n ScalesIcon,\n ShieldCheckIcon,\n WarningCircleIcon,\n WarningIcon,\n WarningOctagonIcon,\n} from '@phosphor-icons/react'\nimport type { DataOptionAppearance } from '../../shared/properties/types'\nimport type { Revenue1Risk, Revenue1Stage } from './types'\n\nexport const revenue1Stages: readonly Revenue1Stage[] = [\n 'preparing',\n 'commercial-review',\n 'legal-review',\n 'signed',\n]\n\nexport const revenue1Risks: readonly Revenue1Risk[] = [\n 'critical',\n 'high',\n 'medium',\n 'low',\n]\n\nexport const revenue1StageAppearance = {\n 'commercial-review': { icon: HandshakeIcon, tone: 'info' },\n 'legal-review': { icon: ScalesIcon, tone: 'warning' },\n preparing: { icon: HourglassIcon, tone: 'neutral' },\n signed: { icon: CheckCircleIcon, tone: 'success' },\n} as const satisfies Record<Revenue1Stage, DataOptionAppearance>\n\nexport const revenue1RiskAppearance = {\n critical: { icon: WarningOctagonIcon, tone: 'danger' },\n high: { icon: WarningIcon, tone: 'warning' },\n low: { icon: ShieldCheckIcon, tone: 'neutral' },\n medium: { icon: WarningCircleIcon, tone: 'info' },\n} as const satisfies Record<Revenue1Risk, DataOptionAppearance>\n",
33
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1-options.ts"
34
+ },
35
+ {
36
+ "path": "blocks/data/revenue/revenue-1/revenue-1-selection-actions.tsx",
37
+ "type": "registry:file",
38
+ "content": "import { ArrowRightIcon, UserPlusIcon } from '@phosphor-icons/react'\nimport type {\n ActionBarContext,\n ActionBarGroup,\n} from '@tc96/ui/patterns/action-bar/components/action-bar'\nimport type {\n Revenue1Labels,\n Revenue1Person,\n Revenue1Renewal,\n Revenue1Stage,\n} from './types'\n\nconst stages: readonly Revenue1Stage[] = [\n 'preparing',\n 'commercial-review',\n 'legal-review',\n 'signed',\n]\n\nconst idsOf = ({ selectedRows }: ActionBarContext<Revenue1Renewal>) =>\n selectedRows.map((renewal) => renewal.id)\n\nexport interface Revenue1SelectionActionsOptions {\n labels: Revenue1Labels\n onAssignOwner?: (renewalIds: string[], ownerId: string) => void\n onStageUpdate?: (renewalIds: string[], stage: Revenue1Stage) => void\n owners: readonly Revenue1Person[]\n}\n\nexport function createRevenue1SelectionActions({\n labels,\n onAssignOwner,\n onStageUpdate,\n owners,\n}: Revenue1SelectionActionsOptions): ActionBarGroup<Revenue1Renewal>[] {\n const items: ActionBarGroup<Revenue1Renewal>['items'] = []\n if (onAssignOwner && owners.length)\n items.push({\n icon: <UserPlusIcon aria-hidden=\"true\" />,\n id: 'assign-owner',\n label: labels.assignOwner,\n submenu: [\n {\n items: owners.map((owner) => ({\n id: owner.id,\n label: owner.label,\n onSelect: (context) => onAssignOwner(idsOf(context), owner.id),\n })),\n label: labels.owner,\n },\n ],\n })\n if (onStageUpdate)\n items.push({\n icon: <ArrowRightIcon aria-hidden=\"true\" />,\n id: 'move-stage',\n label: labels.moveStage,\n submenu: [\n {\n items: stages.map((stage) => ({\n id: stage,\n label: labels.stages[stage],\n onSelect: (context) => onStageUpdate(idsOf(context), stage),\n })),\n label: labels.newStage,\n },\n ],\n })\n return items.length ? [{ id: 'bulk', items }] : []\n}\n",
39
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1-selection-actions.tsx"
40
+ },
41
+ {
42
+ "path": "blocks/data/revenue/revenue-1/revenue-1-skeleton.tsx",
43
+ "type": "registry:file",
44
+ "content": "import { Skeleton } from '@tc96/ui/skeleton'\nimport { GridLoadSkeleton } from '../../shared/grid/grid-load-state'\n\nconst rows = ['a', 'b', 'c', 'd', 'e', 'f']\nconst columns = [\n 'select',\n 'account',\n 'renewal',\n 'arr',\n 'health',\n 'stage',\n 'risk',\n]\nconst grid = 'grid grid-cols-[1.5rem_3fr_1.5fr_1.5fr_1.5fr_1.5fr_1fr] gap-4'\n\nexport function Revenue1Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <GridLoadSkeleton className=\"grid gap-4\" label={label}>\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"flex items-center gap-2\">\n <Skeleton className=\"h-8 w-56\" />\n <Skeleton className=\"h-8 w-24\" />\n </div>\n <Skeleton className=\"h-8 w-32\" />\n </div>\n <div className=\"grid gap-2 rounded-md border\">\n <div className={`${grid} border-b p-3`}>\n {columns.map((id) => (\n <Skeleton className=\"h-3.5 w-full max-w-20\" key={id} />\n ))}\n </div>\n {rows.map((id) => (\n <div className={`${grid} items-center px-3 py-2`} key={id}>\n <Skeleton className=\"size-4 rounded-sm\" />\n <div className=\"flex items-center gap-3\">\n <Skeleton className=\"size-8 shrink-0 rounded-lg\" />\n <div className=\"grid gap-1.5\">\n <Skeleton className=\"h-4 w-24\" />\n <Skeleton className=\"h-3 w-36\" />\n </div>\n </div>\n <div className=\"grid gap-1.5\">\n <Skeleton className=\"h-4 w-20\" />\n <Skeleton className=\"h-3 w-24\" />\n </div>\n <div className=\"grid gap-1.5\">\n <Skeleton className=\"h-4 w-20\" />\n <Skeleton className=\"h-3 w-28\" />\n </div>\n <div className=\"grid gap-1.5\">\n <Skeleton className=\"h-1.5 w-20\" />\n <Skeleton className=\"h-3 w-16\" />\n </div>\n <Skeleton className=\"h-5 w-28 rounded-sm\" />\n <Skeleton className=\"h-5 w-14 rounded-sm\" />\n </div>\n ))}\n </div>\n </GridLoadSkeleton>\n )\n}\n",
45
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1-skeleton.tsx"
46
+ },
47
+ {
48
+ "path": "blocks/data/revenue/revenue-1/revenue-1-toolbar.tsx",
49
+ "type": "registry:file",
50
+ "content": "import { DataGridColumnsSubmenu } from '@tc96/ui/patterns/data-grid/components/data-grid-columns-submenu'\nimport { DataGridDensitySubmenu } from '@tc96/ui/patterns/data-grid/components/data-grid-density-submenu'\nimport { DataGridSortSubmenu } from '@tc96/ui/patterns/data-grid/components/data-grid-sort-submenu'\nimport type { UseDataGridReturn } from '@tc96/ui/patterns/data-grid/hooks/use-data-grid'\nimport { isConditionComplete } from '@tc96/ui/patterns/data-grid/lib/data-grid-conditions'\nimport {\n ViewSettingsMenu,\n ViewSettingsSection,\n} from '@tc96/ui/patterns/view-settings-menu/components/view-settings-menu'\nimport type { ReactNode } from 'react'\nimport { GridToolbar, GridToolbarButton } from '../../shared/grid/grid-toolbar'\nimport type {\n Revenue1Condition,\n Revenue1Labels,\n Revenue1Renewal,\n} from './types'\n\nexport interface Revenue1ToolbarProps {\n conditions: readonly Revenue1Condition[]\n labels: Revenue1Labels\n left: ReactNode\n onConditionsChange?: (conditions: Revenue1Condition[]) => void\n onCreate?: () => void\n onSaveView?: () => void\n table: UseDataGridReturn<Revenue1Renewal>['table']\n}\n\nexport function Revenue1Toolbar({\n conditions,\n labels,\n left,\n onConditionsChange,\n onCreate,\n onSaveView,\n table,\n}: Readonly<Revenue1ToolbarProps>) {\n const activeFilterCount = conditions.filter(isConditionComplete).length\n\n return (\n <GridToolbar\n aria-label={labels.toolbar}\n left={left}\n right={\n <>\n <ViewSettingsMenu\n activeFilterCount={activeFilterCount}\n clearLabel={labels.conditions.clearFilters}\n formatTriggerLabel={labels.filterCount}\n label={labels.settings}\n onClearFilters={() => onConditionsChange?.([])}\n onSavePreference={onSaveView}\n savePreferenceLabel={labels.saveView}\n >\n <ViewSettingsSection label={labels.settings}>\n <DataGridSortSubmenu\n clearLabel={labels.clearSort}\n getOptionLabel={labels.sortOption}\n label={labels.sortBy}\n table={table}\n />\n <DataGridDensitySubmenu\n densityLabels={labels.densities}\n label={labels.density}\n table={table}\n />\n <DataGridColumnsSubmenu\n label={labels.columnsMenu}\n table={table}\n />\n </ViewSettingsSection>\n </ViewSettingsMenu>\n {onCreate ? (\n <GridToolbarButton onClick={onCreate} variant=\"default\">\n {labels.create}\n </GridToolbarButton>\n ) : null}\n </>\n }\n />\n )\n}\n",
51
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1-toolbar.tsx"
52
+ },
53
+ {
54
+ "path": "blocks/data/revenue/revenue-1/revenue-1.tsx",
55
+ "type": "registry:file",
56
+ "content": "'use client'\n\nimport { ActionBar } from '@tc96/ui/patterns/action-bar/components/action-bar'\nimport { DataGrid } from '@tc96/ui/patterns/data-grid/components/data-grid'\nimport {\n type DataGridConditionFilterField,\n DataGridConditionFilters,\n} from '@tc96/ui/patterns/data-grid/components/data-grid-condition-filters'\nimport { useDataGrid } from '@tc96/ui/patterns/data-grid/hooks/use-data-grid'\nimport {\n createDataGridConditionFilterFn,\n type DataGridConditionField,\n} from '@tc96/ui/patterns/data-grid/lib/data-grid-conditions'\nimport {\n CollectionToolbarDescription,\n CollectionToolbarHeading,\n CollectionToolbarTitle,\n} from '@tc96/ui/patterns/toolbar/components/collection-toolbar-heading'\nimport { useCallback, useLayoutEffect, useMemo, useRef } from 'react'\nimport { createTableFormatter } from '../../shared/grid/format'\nimport { GridFrame } from '../../shared/grid/grid-frame'\nimport { gridLoadState } from '../../shared/grid/grid-load-state'\nimport {\n sortFromSorting,\n sortingFromSort,\n visibilityFromState,\n} from '../../shared/grid/grid-state'\nimport { GridToolbar } from '../../shared/grid/grid-toolbar'\nimport { GridViewSwitcher } from '../../shared/grid/grid-view-switcher'\nimport { resolveRevenue1Labels } from './labels'\nimport { healthLevel } from './revenue-1-cells'\nimport { createRevenue1Columns } from './revenue-1-columns'\nimport { createRevenue1SelectionActions } from './revenue-1-selection-actions'\nimport { Revenue1Skeleton } from './revenue-1-skeleton'\nimport { Revenue1Toolbar } from './revenue-1-toolbar'\nimport type {\n Revenue1Condition,\n Revenue1Person,\n Revenue1Props,\n Revenue1Renewal,\n Revenue1Risk,\n Revenue1Segment,\n Revenue1Stage,\n} from './types'\n\nconst segments: readonly Revenue1Segment[] = [\n 'enterprise',\n 'mid-market',\n 'scale',\n]\nconst stages: readonly Revenue1Stage[] = [\n 'preparing',\n 'commercial-review',\n 'legal-review',\n 'signed',\n]\nconst risks: readonly Revenue1Risk[] = ['critical', 'high', 'medium', 'low']\nconst noConditions: readonly Revenue1Condition[] = []\nconst hiddenFilterColumns = { owner: false, segment: false }\n\nfunction uniqueOwners(renewals: readonly Revenue1Renewal[]): Revenue1Person[] {\n const byId = new Map<string, Revenue1Person>()\n for (const renewal of renewals) byId.set(renewal.owner.id, renewal.owner)\n return [...byId.values()]\n}\n\nexport function Revenue1({\n activeViewId,\n className,\n columnVisibility,\n conditions = noConditions,\n currency,\n density = 'tall',\n error,\n labels: labelsProp,\n locale,\n onAssignOwner,\n onColumnVisibilityChange,\n onConditionsChange,\n onCreate,\n onDensityChange,\n onRetry,\n onRowAction,\n onSaveView,\n onSelectedIdsChange,\n onSortChange,\n onStageUpdate,\n onViewChange,\n onViewCreate,\n owners: ownersProp,\n pageSize = 10,\n pending,\n renewals,\n rowActions,\n selectedIds,\n sort,\n views,\n}: Readonly<Revenue1Props>) {\n const labels = useMemo(() => resolveRevenue1Labels(labelsProp), [labelsProp])\n const formatter = useMemo(\n () => createTableFormatter({ currency, locale }),\n [currency, locale],\n )\n const owners = useMemo(\n () => ownersProp ?? uniqueOwners(renewals),\n [ownersProp, renewals],\n )\n const rowActionRef = useRef(onRowAction)\n useLayoutEffect(() => {\n rowActionRef.current = onRowAction\n })\n const handleRowAction = useCallback(\n (actionId: string, renewalId: string) =>\n rowActionRef.current?.(actionId, renewalId),\n [],\n )\n const hasRowMenu = Boolean(onRowAction)\n const columns = useMemo(\n () =>\n createRevenue1Columns({\n formatter,\n labels,\n onRowAction: hasRowMenu ? handleRowAction : undefined,\n rowActions,\n }),\n [formatter, handleRowAction, hasRowMenu, labels, rowActions],\n )\n\n const fields = useMemo<DataGridConditionFilterField[]>(\n () => [\n { columnId: 'account', kind: 'text', label: labels.fields.account },\n {\n columnId: 'owner',\n kind: 'option',\n label: labels.fields.owner,\n options: owners.map((owner) => ({\n label: owner.label,\n value: owner.id,\n })),\n },\n {\n columnId: 'segment',\n kind: 'option',\n label: labels.fields.segment,\n options: segments.map((id) => ({\n label: labels.segments[id],\n value: id,\n })),\n },\n {\n columnId: 'stage',\n kind: 'option',\n label: labels.fields.stage,\n options: stages.map((id) => ({ label: labels.stages[id], value: id })),\n },\n {\n columnId: 'risk',\n kind: 'option',\n label: labels.fields.risk,\n options: risks.map((id) => ({ label: labels.risks[id], value: id })),\n },\n { columnId: 'arr', kind: 'number', label: labels.fields.arr },\n { columnId: 'health', kind: 'number', label: labels.fields.health },\n { columnId: 'renewal', kind: 'date', label: labels.fields.renewal },\n ],\n [labels, owners],\n )\n const globalFilterFn = useMemo(\n () => createDataGridConditionFilterFn<Revenue1Renewal>(fields),\n [fields],\n )\n const formatValue = useCallback(\n (field: DataGridConditionField, value: string) => {\n if (field.columnId === 'arr') return formatter.money(Number(value))\n if (field.columnId === 'renewal') return formatter.date(value)\n return (\n field.options?.find((option) => option.value === value)?.label ?? value\n )\n },\n [formatter],\n )\n\n const controlledSorting = useMemo(\n () => (sort === undefined ? undefined : sortingFromSort(sort)),\n [sort],\n )\n const controlledSelection = useMemo(\n () =>\n selectedIds === undefined\n ? undefined\n : Object.fromEntries(selectedIds.map((id) => [id, true as const])),\n [selectedIds],\n )\n const gridVisibility = useMemo(\n () =>\n columnVisibility === undefined\n ? undefined\n : { ...columnVisibility, ...hiddenFilterColumns },\n [columnVisibility],\n )\n\n const { table } = useDataGrid<Revenue1Renewal>({\n columns,\n columnVisibility: gridVisibility,\n data: renewals,\n density,\n enablePagination: true,\n enableRowSelection: true,\n getRowId: (renewal) => renewal.id,\n globalFilter: conditions,\n onColumnVisibilityChange: onColumnVisibilityChange\n ? (visibility) => {\n const { owner: _owner, segment: _segment, ...rest } = visibility\n onColumnVisibilityChange(visibilityFromState(rest))\n }\n : undefined,\n onDensityChange: onDensityChange\n ? (next) => onDensityChange(next)\n : undefined,\n onRowSelectionChange: onSelectedIdsChange\n ? (selection) =>\n onSelectedIdsChange(\n Object.keys(selection).filter((id) => selection[id]),\n )\n : undefined,\n onSortingChange: onSortChange\n ? (sorting) => onSortChange(sortFromSorting(sorting))\n : undefined,\n pageSize,\n rowSelection: controlledSelection,\n sorting: controlledSorting,\n tableOptions: {\n globalFilterFn,\n initialState: { columnVisibility: hiddenFilterColumns },\n },\n })\n\n const changeConditions = onConditionsChange\n ? (next: Revenue1Condition[]) => {\n table.setPageIndex(0)\n onConditionsChange(next)\n }\n : undefined\n\n const loadState = gridLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton: <Revenue1Skeleton label={labels.loading} />,\n })\n\n const visible = table.getFilteredRowModel().rows.map((row) => row.original)\n const atRisk = visible.filter(\n (renewal) =>\n renewal.risk === 'critical' || healthLevel(renewal.health) === 'at-risk',\n )\n const description = labels.summary(\n visible.filter((renewal) => renewal.dueInDays <= 30).length,\n atRisk.length,\n formatter.compactMoney(\n atRisk.reduce((total, renewal) => total + renewal.arr, 0),\n ),\n )\n const selectionActions = useMemo(\n () =>\n createRevenue1SelectionActions({\n labels,\n onAssignOwner,\n onStageUpdate,\n owners,\n }),\n [labels, onAssignOwner, onStageUpdate, owners],\n )\n\n const toolbarLeft = views?.length ? (\n <GridViewSwitcher\n activeViewId={activeViewId}\n labels={labels}\n locale={locale}\n onViewChange={onViewChange}\n onViewCreate={onViewCreate}\n views={views}\n />\n ) : (\n <CollectionToolbarHeading>\n <CollectionToolbarTitle>{labels.title}</CollectionToolbarTitle>\n <CollectionToolbarDescription>\n {loadState ? undefined : description}\n </CollectionToolbarDescription>\n </CollectionToolbarHeading>\n )\n\n return (\n <GridFrame\n className={className}\n data-block=\"revenue-1\"\n title={labels.title}\n toolbar={\n loadState ? (\n <GridToolbar aria-label={labels.toolbar} left={toolbarLeft} />\n ) : (\n <Revenue1Toolbar\n conditions={conditions}\n labels={labels}\n left={toolbarLeft}\n onConditionsChange={changeConditions}\n onCreate={onCreate}\n onSaveView={onSaveView}\n table={table}\n />\n )\n }\n >\n {loadState ?? (\n <>\n {changeConditions ? (\n <DataGridConditionFilters\n conditions={conditions}\n fields={fields}\n formatValue={formatValue}\n labels={labels.conditions}\n onConditionsChange={changeConditions}\n operatorLabels={labels.operators}\n />\n ) : null}\n <DataGrid\n aria-label={labels.title}\n emptyMessage={labels.empty}\n selectionActions={({\n clearSelection,\n selectedCount,\n selectedRows,\n }) => (\n <ActionBar\n actions={selectionActions}\n clearSelectionLabel={labels.clearSelection}\n formatSelection={labels.selectedCount}\n label={labels.selectionActions}\n onClearSelection={clearSelection}\n selectedCount={selectedCount}\n selectedRows={selectedRows}\n />\n )}\n table={table}\n />\n </>\n )}\n </GridFrame>\n )\n}\n",
57
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/revenue-1.tsx"
58
+ },
59
+ {
60
+ "path": "blocks/data/revenue/revenue-1/types.ts",
61
+ "type": "registry:file",
62
+ "content": "import type { DataGridConditionFilterLabels } from '@tc96/ui/patterns/data-grid/components/data-grid-condition-filters'\nimport type {\n DataGridCondition,\n DataGridConditionOperator,\n} from '@tc96/ui/patterns/data-grid/lib/data-grid-conditions'\nimport type {\n GridColumnVisibility,\n GridFormatProps,\n GridLoadLabels,\n GridLoadProps,\n GridPerson,\n GridSort,\n GridView,\n GridViewLabels,\n GridViewProps,\n} from '../../shared/grid/types'\n\nexport type Revenue1Segment = 'enterprise' | 'mid-market' | 'scale'\n\nexport type Revenue1Stage =\n | 'commercial-review'\n | 'legal-review'\n | 'preparing'\n | 'signed'\n\nexport type Revenue1Risk = 'critical' | 'high' | 'low' | 'medium'\n\nexport type Revenue1Health = 'at-risk' | 'healthy' | 'watchlist'\n\nexport type Revenue1Urgency = 'later' | 'overdue' | 'soon'\n\nexport type Revenue1Density =\n | 'compact'\n | 'extra-tall'\n | 'medium'\n | 'short'\n | 'tall'\n\nexport type Revenue1ToggleColumnId =\n | 'arr'\n | 'health'\n | 'renewal'\n | 'risk'\n | 'stage'\n\nexport type Revenue1ColumnId = Revenue1ToggleColumnId | 'account' | 'actions'\n\nexport type Revenue1FilterField =\n | 'account'\n | 'arr'\n | 'health'\n | 'owner'\n | 'renewal'\n | 'risk'\n | 'segment'\n | 'stage'\n\nexport type Revenue1SortKey = Exclude<Revenue1ColumnId, 'actions'>\n\nexport type Revenue1Person = GridPerson\n\nexport type Revenue1Condition = DataGridCondition\n\nexport type Revenue1ConditionOperator = DataGridConditionOperator\n\nexport type Revenue1View = GridView\n\nexport interface Revenue1Account {\n logoUrl?: string\n name: string\n segment: Revenue1Segment\n}\n\nexport interface Revenue1Renewal {\n account: Revenue1Account\n arr: number\n dueInDays: number\n health: number\n id: string\n owner: Revenue1Person\n renewalDate: string\n risk: Revenue1Risk\n stage: Revenue1Stage\n upside: number\n}\n\nexport interface Revenue1RowAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport type Revenue1Sort = GridSort<Revenue1SortKey>\n\nexport type Revenue1ColumnVisibility =\n GridColumnVisibility<Revenue1ToggleColumnId>\n\nexport interface Revenue1Labels extends GridLoadLabels, GridViewLabels {\n assignOwner: string\n clearSelection: string\n columns: Record<Revenue1ColumnId, string>\n columnsMenu: string\n conditions: DataGridConditionFilterLabels\n create: string\n density: string\n densities: Record<Revenue1Density, string>\n clearSort: string\n sortOption: (column: string, direction: 'asc' | 'desc') => string\n filterCount: (label: string, count: number) => string\n due: (urgency: Revenue1Urgency, days: number) => string\n empty: string\n fields: Record<Revenue1FilterField, string>\n health: Record<Revenue1Health, string>\n healthScore: (percent: string, level: string) => string\n moveStage: string\n newStage: string\n operators: Record<Revenue1ConditionOperator, string>\n owner: string\n risks: Record<Revenue1Risk, string>\n rowActionsFor: (account: string) => string\n saveView: string\n segments: Record<Revenue1Segment, string>\n selectAll: string\n selectAccount: (account: string) => string\n selectedCount: (count: number) => string\n selectionActions: string\n settings: string\n sortBy: string\n stages: Record<Revenue1Stage, string>\n summary: (dueSoon: number, atRisk: number, arrAtRisk: string) => string\n title: string\n toolbar: string\n upside: (amount: string) => string\n}\n\nexport type Revenue1LabelsOverride = Partial<\n Omit<\n Revenue1Labels,\n | 'columns'\n | 'conditions'\n | 'densities'\n | 'fields'\n | 'health'\n | 'operators'\n | 'risks'\n | 'segments'\n | 'stages'\n >\n> & {\n columns?: Partial<Revenue1Labels['columns']>\n conditions?: Partial<Revenue1Labels['conditions']>\n densities?: Partial<Revenue1Labels['densities']>\n fields?: Partial<Revenue1Labels['fields']>\n health?: Partial<Revenue1Labels['health']>\n operators?: Partial<Revenue1Labels['operators']>\n risks?: Partial<Revenue1Labels['risks']>\n segments?: Partial<Revenue1Labels['segments']>\n stages?: Partial<Revenue1Labels['stages']>\n}\n\nexport interface Revenue1Props\n extends GridFormatProps,\n GridLoadProps,\n GridViewProps {\n className?: string\n columnVisibility?: Revenue1ColumnVisibility\n conditions?: readonly Revenue1Condition[]\n density?: Revenue1Density\n labels?: Revenue1LabelsOverride\n onAssignOwner?: (renewalIds: string[], ownerId: string) => void\n onColumnVisibilityChange?: (visibility: Revenue1ColumnVisibility) => void\n onConditionsChange?: (conditions: Revenue1Condition[]) => void\n onCreate?: () => void\n onDensityChange?: (density: Revenue1Density) => void\n onRowAction?: (actionId: string, renewalId: string) => void\n onSaveView?: () => void\n onSelectedIdsChange?: (renewalIds: string[]) => void\n onSortChange?: (sort: Revenue1Sort | null) => void\n onStageUpdate?: (renewalIds: string[], stage: Revenue1Stage) => void\n owners?: Revenue1Person[]\n pageSize?: number\n renewals: Revenue1Renewal[]\n rowActions?: Revenue1RowAction[]\n selectedIds?: string[]\n sort?: Revenue1Sort | null\n}\n",
63
+ "target": "~/packages/ui/src/blocks/data/revenue/revenue-1/types.ts"
64
+ },
65
+ {
66
+ "path": "blocks/data/shared/grid/format.ts",
67
+ "type": "registry:file",
68
+ "content": "import { parseDateValue } from '@tc96/ui/helpers/date'\nimport { formatAmount } from '@tc96/ui/helpers/format'\nimport type { GridFormatProps } from './types'\n\nexport const defaultGridLocale = 'pt-BR'\nexport const defaultGridCurrency = 'BRL'\n\nexport function createTableFormatter({\n currency = defaultGridCurrency,\n locale = defaultGridLocale,\n}: GridFormatProps = {}) {\n const number = (amount: number, fractionDigits = 0) =>\n formatAmount(amount, {\n locale,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits,\n style: 'decimal',\n })\n\n const compact = (amount: number) =>\n formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n notation: 'compact',\n style: 'decimal',\n })\n\n const money = (amount: number, fractionDigits = 0) =>\n formatAmount(amount, {\n currency,\n locale,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits,\n style: 'currency',\n })\n\n const compactMoney = (amount: number) =>\n formatAmount(amount, {\n currency,\n locale,\n maximumFractionDigits: 1,\n notation: 'compact',\n style: 'currency',\n })\n\n const percent = (ratio: number, fractionDigits = 0) =>\n formatAmount(ratio, {\n locale,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits,\n style: 'percent',\n })\n\n const delta = (ratio: number) =>\n formatAmount(ratio, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n signDisplay: 'exceptZero',\n style: 'percent',\n })\n\n const date = (value: string, options?: Intl.DateTimeFormatOptions) =>\n new Intl.DateTimeFormat(\n locale,\n options ?? { day: 'numeric', month: 'short', year: 'numeric' },\n ).format(parseDateValue(value))\n\n const shortDate = (value: string) =>\n new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'short' })\n .formatToParts(parseDateValue(value))\n .filter((part) => part.type !== 'literal')\n .map((part) => part.value.replace(/\\.$/, ''))\n .join(' ')\n\n return {\n compact,\n compactMoney,\n date,\n delta,\n money,\n number,\n percent,\n shortDate,\n }\n}\n\nexport type GridFormatter = ReturnType<typeof createTableFormatter>\n",
69
+ "target": "~/packages/ui/src/blocks/data/shared/grid/format.ts"
70
+ },
71
+ {
72
+ "path": "blocks/data/shared/grid/grid-frame.tsx",
73
+ "type": "registry:file",
74
+ "content": "import { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactNode } from 'react'\n\nexport interface GridFrameProps\n extends Omit<ComponentProps<'section'>, 'title'> {\n title: string\n toolbar: ReactNode\n}\n\nexport function GridFrame({\n children,\n className,\n title,\n toolbar,\n ...props\n}: Readonly<GridFrameProps>) {\n return (\n <section\n aria-label={title}\n className={cn('grid gap-4', className)}\n {...props}\n >\n {toolbar}\n {children}\n </section>\n )\n}\n",
75
+ "target": "~/packages/ui/src/blocks/data/shared/grid/grid-frame.tsx"
76
+ },
77
+ {
78
+ "path": "blocks/data/shared/grid/grid-load-state.tsx",
79
+ "type": "registry:file",
80
+ "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 { GridLoadLabels, GridLoadProps } from './types'\n\nexport function GridLoadSkeleton({\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=\"table-skeleton\"\n >\n {children}\n </output>\n )\n}\n\nexport function gridLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n GridLoadProps & { labels: GridLoadLabels; 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",
81
+ "target": "~/packages/ui/src/blocks/data/shared/grid/grid-load-state.tsx"
82
+ },
83
+ {
84
+ "path": "blocks/data/shared/grid/grid-state.ts",
85
+ "type": "registry:file",
86
+ "content": "export type GridSorting = { desc: boolean; id: string }[]\n\nimport type { GridColumnVisibility, GridSort } from './types'\n\nexport function sortingFromSort<TKey extends string>(\n sort: GridSort<TKey> | null | undefined,\n): GridSorting {\n return sort ? [{ desc: sort.direction === 'desc', id: sort.key }] : []\n}\n\nexport function sortFromSorting<TKey extends string>(\n sorting: GridSorting,\n): GridSort<TKey> | null {\n const [first] = sorting\n return first\n ? { direction: first.desc ? 'desc' : 'asc', key: first.id as TKey }\n : null\n}\n\nexport function visibilityFromState<TKey extends string>(\n visibility: Record<string, boolean>,\n): GridColumnVisibility<TKey> {\n return { ...visibility } as GridColumnVisibility<TKey>\n}\n\nexport function pageSizeChoices(\n options: readonly number[],\n pageSize: number,\n): number[] {\n return [...new Set([...options, pageSize])].sort((a, b) => a - b)\n}\n",
87
+ "target": "~/packages/ui/src/blocks/data/shared/grid/grid-state.ts"
88
+ },
89
+ {
90
+ "path": "blocks/data/shared/grid/grid-toolbar.tsx",
91
+ "type": "registry:file",
92
+ "content": "import { Button, type ButtonProps } from '@tc96/ui/button'\nimport { CollectionToolbar } from '@tc96/ui/patterns/toolbar/components/collection-toolbar'\nimport { ToolbarButton } from '@tc96/ui/toolbar'\nimport type { ReactNode } from 'react'\n\nexport interface GridToolbarProps {\n 'aria-label': string\n left?: ReactNode\n right?: ReactNode\n}\n\nexport function GridToolbar(props: Readonly<GridToolbarProps>) {\n return <CollectionToolbar className=\"min-h-14 flex-wrap gap-y-3\" {...props} />\n}\n\nexport interface GridToolbarButtonProps {\n children: ReactNode\n disabled?: boolean\n onClick: () => void\n variant?: ButtonProps['variant']\n}\n\nexport function GridToolbarButton({\n children,\n disabled,\n onClick,\n variant = 'outline',\n}: Readonly<GridToolbarButtonProps>) {\n return (\n <ToolbarButton\n disabled={disabled}\n onClick={onClick}\n render={<Button type=\"button\" variant={variant} />}\n >\n {children}\n </ToolbarButton>\n )\n}\n",
93
+ "target": "~/packages/ui/src/blocks/data/shared/grid/grid-toolbar.tsx"
94
+ },
95
+ {
96
+ "path": "blocks/data/shared/grid/grid-view-switcher.tsx",
97
+ "type": "registry:file",
98
+ "content": "import {\n ViewSwitcherCreate,\n ViewSwitcherItem,\n ViewSwitcherItems,\n ViewSwitcherMenu,\n ViewSwitcherSearch,\n} from '@tc96/ui/patterns/view-switcher/components/view-switcher'\nimport { Separator } from '@tc96/ui/separator'\nimport { useState } from 'react'\nimport { defaultGridLocale } from './format'\nimport type { GridView, GridViewLabels } from './types'\n\nexport interface GridViewSwitcherProps {\n activeViewId?: string\n labels: GridViewLabels\n locale?: string\n onViewChange?: (viewId: string) => void\n onViewCreate?: () => void\n views: readonly GridView[]\n}\n\nexport function GridViewSwitcher({\n activeViewId,\n labels,\n locale = defaultGridLocale,\n onViewChange,\n onViewCreate,\n views,\n}: Readonly<GridViewSwitcherProps>) {\n const [query, setQuery] = useState('')\n const activeView = views.find((view) => view.id === activeViewId)\n const needle = query.trim().toLocaleLowerCase(locale)\n const visibleViews = views.filter((view) =>\n view.label.toLocaleLowerCase(locale).includes(needle),\n )\n\n return (\n <ViewSwitcherMenu label={activeView?.label ?? labels.viewSelect}>\n <ViewSwitcherSearch\n label={labels.viewSearch}\n onValueChange={setQuery}\n placeholder={labels.viewSearchPlaceholder}\n value={query}\n />\n {visibleViews.length ? (\n <ViewSwitcherItems label={labels.views}>\n {visibleViews.map((view) => (\n <ViewSwitcherItem\n key={view.id}\n label={view.label}\n onSelect={() => onViewChange?.(view.id)}\n selected={view.id === activeViewId}\n />\n ))}\n </ViewSwitcherItems>\n ) : (\n <p className=\"px-2 py-1.5 text-muted-foreground text-sm\">\n {labels.viewsEmpty}\n </p>\n )}\n {onViewCreate ? (\n <>\n <Separator />\n <ViewSwitcherCreate\n label={labels.viewCreate}\n onClick={onViewCreate}\n />\n </>\n ) : null}\n </ViewSwitcherMenu>\n )\n}\n",
99
+ "target": "~/packages/ui/src/blocks/data/shared/grid/grid-view-switcher.tsx"
100
+ },
101
+ {
102
+ "path": "blocks/data/shared/grid/labels.ts",
103
+ "type": "registry:file",
104
+ "content": "import type {\n GridLoadLabels,\n GridSettingsLabels,\n GridViewLabels,\n} from './types'\n\nexport const defaultGridLoadLabels: Pick<\n GridLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n\nexport const defaultGridViewLabels: GridViewLabels = {\n viewCreate: 'Criar nova view',\n viewSearch: 'Buscar views',\n viewSearchPlaceholder: 'Buscar views...',\n viewSelect: 'Selecionar view',\n views: 'Views',\n viewsEmpty: 'Nenhuma view encontrada',\n}\n\nexport const defaultGridSettingsLabels: GridSettingsLabels = {\n clearSort: 'Limpar ordenação',\n densities: {\n compact: 'Compacta',\n 'extra-tall': 'Extra alta',\n medium: 'Média',\n short: 'Padrão',\n tall: 'Alta',\n },\n settingsWithFilters: (settings, activeFilters) =>\n `${settings} (${activeFilters})`,\n sortOption: (column, direction) =>\n `${column}: ${direction === 'asc' ? 'crescente' : 'decrescente'}`,\n}\n",
105
+ "target": "~/packages/ui/src/blocks/data/shared/grid/labels.ts"
106
+ },
107
+ {
108
+ "path": "blocks/data/shared/grid/types.ts",
109
+ "type": "registry:file",
110
+ "content": "export interface GridPerson {\n id: string\n imageUrl?: string\n label: string\n}\n\nexport interface GridFormatProps {\n currency?: string\n locale?: string\n}\n\nexport interface GridLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface GridLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n\nexport type GridSortDirection = 'asc' | 'desc'\n\nexport interface GridSort<TKey extends string> {\n direction: GridSortDirection\n key: TKey\n}\n\nexport type GridColumnVisibility<TKey extends string> = Partial<\n Record<TKey, boolean>\n>\n\nexport interface GridView {\n id: string\n label: string\n}\n\nexport interface GridViewProps {\n activeViewId?: string\n onViewChange?: (viewId: string) => void\n onViewCreate?: () => void\n views?: GridView[]\n}\n\nexport interface GridViewLabels {\n viewCreate: string\n viewSearch: string\n viewSearchPlaceholder: string\n viewSelect: string\n views: string\n viewsEmpty: string\n}\n\nexport type GridDensity = 'compact' | 'extra-tall' | 'medium' | 'short' | 'tall'\n\nexport interface GridSettingsLabels {\n clearSort: string\n densities: Record<GridDensity, string>\n settingsWithFilters: (settings: string, activeFilters: number) => string\n sortOption: (column: string, direction: GridSortDirection) => string\n}\n",
111
+ "target": "~/packages/ui/src/blocks/data/shared/grid/types.ts"
112
+ },
113
+ {
114
+ "path": "blocks/data/shared/properties/data-properties.tsx",
115
+ "type": "registry:file",
116
+ "content": "'use client'\n\nimport type { PropertyOption } from '@tc96/ui/patterns/properties/core'\nimport { DateProperty } from '@tc96/ui/patterns/properties/display/date/date-property'\nimport { PersonProperty } from '@tc96/ui/patterns/properties/display/person/person-property'\nimport { SelectProperty } from '@tc96/ui/patterns/properties/display/select/select-property'\nimport type {\n DataOptionAppearance,\n DataPerson,\n DataPropertyVariant as PropertyVariant,\n} from './types'\n\nconst defaultDataLocale = 'pt-BR'\nconst defaultDataTimeZone = 'America/Sao_Paulo'\n\nexport function dataSelectOptions<TValue extends string>(\n values: readonly TValue[],\n labels: Record<TValue, string>,\n appearance: Record<TValue, DataOptionAppearance>,\n): PropertyOption[] {\n return values.map((value) => ({\n icon: appearance[value].icon,\n label: labels[value],\n tone: appearance[value].tone,\n value,\n weight: appearance[value].weight,\n }))\n}\n\nexport interface DataSelectProps<TValue extends string> {\n ariaLabel: string\n onChange?: (value: TValue) => void\n options: readonly PropertyOption[]\n value: TValue\n variant?: PropertyVariant\n}\n\nexport function DataSelect<TValue extends string>({\n ariaLabel,\n onChange,\n options,\n value,\n variant,\n}: Readonly<DataSelectProps<TValue>>) {\n return (\n <SelectProperty\n ariaLabel={ariaLabel}\n onValueChange={\n onChange\n ? (next) => {\n const option = options.find((item) => item.value === next)\n if (option) onChange(option.value as TValue)\n }\n : undefined\n }\n options={options}\n value={value}\n variant={variant}\n />\n )\n}\n\nexport interface DataOwnerProps {\n ariaLabel: string\n avatarOnly?: boolean\n onChange?: (ownerId: string) => void\n owners: readonly DataPerson[]\n placeholder: string\n value: string | null\n variant?: PropertyVariant\n}\n\nexport function DataOwner({\n ariaLabel,\n avatarOnly = false,\n onChange,\n owners,\n placeholder,\n value,\n variant,\n}: Readonly<DataOwnerProps>) {\n return (\n <PersonProperty\n ariaLabel={ariaLabel}\n display={avatarOnly ? 'avatar' : 'full'}\n onValueChange={onChange}\n options={owners.map((owner) => ({\n imageUrl: owner.imageUrl,\n label: owner.label,\n value: owner.id,\n }))}\n placeholder={placeholder}\n value={value}\n variant={variant}\n />\n )\n}\n\nexport interface DataDateProps {\n ariaLabel: string\n displayLabel?: string\n fallback: string\n locale?: string\n overdue?: boolean\n timeZone?: string\n value: string | null\n variant?: PropertyVariant\n withTime?: boolean\n}\n\nfunction formatDateWithTime(\n value: string | null,\n locale: string,\n timeZone: string,\n): string | undefined {\n if (!value) return undefined\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return undefined\n return new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n month: 'short',\n timeZone,\n }).format(date)\n}\n\nexport function DataDate({\n ariaLabel,\n displayLabel,\n fallback,\n locale = defaultDataLocale,\n overdue = false,\n timeZone = defaultDataTimeZone,\n value,\n variant,\n withTime = false,\n}: Readonly<DataDateProps>) {\n return (\n <DateProperty\n ariaLabel={ariaLabel}\n displayLabel={\n displayLabel ??\n (withTime ? formatDateWithTime(value, locale, timeZone) : undefined)\n }\n isOverdue={overdue}\n labels={{ fallback }}\n locale={locale}\n timeZone={timeZone}\n value={value}\n variant={variant}\n />\n )\n}\n",
117
+ "target": "~/packages/ui/src/blocks/data/shared/properties/data-properties.tsx"
118
+ },
119
+ {
120
+ "path": "blocks/data/shared/properties/types.ts",
121
+ "type": "registry:file",
122
+ "content": "import type { PropertyOption } from '@tc96/ui/patterns/properties/core'\n\nexport type DataPropertyVariant = 'badge' | 'plain'\n\nexport interface DataOptionAppearance {\n icon: NonNullable<PropertyOption['icon']>\n tone: NonNullable<PropertyOption['tone']>\n weight?: PropertyOption['weight']\n}\n\nexport interface DataPerson {\n id: string\n imageUrl?: string\n label: string\n}\n",
123
+ "target": "~/packages/ui/src/blocks/data/shared/properties/types.ts"
124
+ },
125
+ {
126
+ "path": "helpers/calendar-date.ts",
127
+ "type": "registry:file",
128
+ "content": "/** Span of days {@link calendarRange} produces around an anchor date. */\nexport type CalendarRangeMode = 'day' | 'month' | 'week'\n\n/**\n * A calendar day with no time and no time zone attached. `month` runs from\n * 1 to 12.\n */\nexport interface CalendarDate {\n day: number\n month: number\n year: number\n}\n\nconst DATE_KEY_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\n/**\n * Serializes a calendar date as `YYYY-MM-DD`, a stable key for maps and DOM\n * attributes.\n *\n * @param date - The calendar date to serialize.\n */\nexport function calendarDateKey(date: CalendarDate): string {\n const month = String(date.month).padStart(2, '0')\n const day = String(date.day).padStart(2, '0')\n\n return `${date.year}-${month}-${day}`\n}\n\n/**\n * Parses a `YYYY-MM-DD` key produced by {@link calendarDateKey}.\n *\n * @param key - The serialized date.\n * @returns The calendar date, or `null` when the text is malformed or names a\n * day that does not exist, such as February 30.\n */\nexport function parseCalendarDateKey(key: string): CalendarDate | null {\n const match = DATE_KEY_PATTERN.exec(key)\n if (!match) return null\n\n const candidate = {\n day: Number(match[3]),\n month: Number(match[2]),\n year: Number(match[1]),\n }\n\n return isSameCalendarDate(candidate, normalizeCalendarDate(candidate))\n ? candidate\n : null\n}\n\n/**\n * Reads the local calendar day of a `Date`, dropping its time.\n *\n * @param date - A valid date, such as the one a date picker selects.\n */\nexport function calendarDateFromDate(date: Date): CalendarDate {\n return {\n day: date.getDate(),\n month: date.getMonth() + 1,\n year: date.getFullYear(),\n }\n}\n\n/**\n * Builds the local midnight `Date` of a calendar date, the value a date\n * picker expects for a day.\n *\n * @param date - The calendar date to convert.\n */\nexport function calendarDateToDate(date: CalendarDate): Date {\n return new Date(date.year, date.month - 1, date.day)\n}\n\n/**\n * Moves a calendar date by a number of days, rolling over months and years.\n *\n * @param date - The starting date.\n * @param days - Days to add; negative values move backwards.\n */\nexport function addCalendarDays(\n date: CalendarDate,\n days: number,\n): CalendarDate {\n return normalizeCalendarDate({ ...date, day: date.day + days })\n}\n\n/**\n * Orders two calendar dates chronologically.\n *\n * @returns Negative when `a` is earlier, positive when later, zero when equal.\n */\nexport function compareCalendarDates(a: CalendarDate, b: CalendarDate): number {\n return a.year - b.year || a.month - b.month || a.day - b.day\n}\n\n/** Whether two calendar dates name the same day. */\nexport function isSameCalendarDate(a: CalendarDate, b: CalendarDate): boolean {\n return compareCalendarDates(a, b) === 0\n}\n\n/**\n * Day of the week of a calendar date.\n *\n * @returns `0` for Sunday through `6` for Saturday.\n */\nexport function calendarDayOfWeek(date: CalendarDate): number {\n return new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay()\n}\n\n/**\n * First day of the week that contains a calendar date.\n *\n * @param date - Any day of the week.\n * @param weekStartsOn - `0` when weeks start on Sunday, `1` on Monday.\n */\nexport function startOfWeek(\n date: CalendarDate,\n weekStartsOn: 0 | 1,\n): CalendarDate {\n const offset = (calendarDayOfWeek(date) - weekStartsOn + 7) % 7\n\n return addCalendarDays(date, -offset)\n}\n\n/**\n * Lists the days a calendar view shows for an anchor date. A month spans from\n * the first week containing the 1st to the last week containing the final day,\n * so adjacent days of neighbouring months are included.\n *\n * @param anchor - The date the view is centred on.\n * @param mode - Whether to list one day, one week or one month.\n * @param weekStartsOn - `0` when weeks start on Sunday, `1` on Monday.\n * @returns The visible days in chronological order.\n */\nexport function calendarRange(\n anchor: CalendarDate,\n mode: CalendarRangeMode,\n weekStartsOn: 0 | 1,\n): CalendarDate[] {\n if (mode === 'day') return [anchor]\n\n if (mode === 'week') {\n const first = startOfWeek(anchor, weekStartsOn)\n\n return Array.from({ length: 7 }, (_, index) =>\n addCalendarDays(first, index),\n )\n }\n\n const firstOfMonth = { ...anchor, day: 1 }\n const lastOfMonth = addCalendarDays(\n {\n ...normalizeCalendarDate({ ...anchor, day: 1, month: anchor.month + 1 }),\n },\n -1,\n )\n const first = startOfWeek(firstOfMonth, weekStartsOn)\n const last = addCalendarDays(startOfWeek(lastOfMonth, weekStartsOn), 6)\n const days: CalendarDate[] = []\n\n for (\n let day = first;\n compareCalendarDates(day, last) <= 0;\n day = addCalendarDays(day, 1)\n ) {\n days.push(day)\n }\n\n return days\n}\n\n/**\n * Normalizes an out-of-range day or month through `Date.UTC`, which rolls it\n * over into the right month and year. Arithmetic stays in year/month/day\n * rather than adding 86400 seconds to an instant, which would break across\n * daylight saving transitions.\n */\nfunction normalizeCalendarDate(date: CalendarDate): CalendarDate {\n const normalized = new Date(Date.UTC(date.year, date.month - 1, date.day))\n\n return {\n day: normalized.getUTCDate(),\n month: normalized.getUTCMonth() + 1,\n year: normalized.getUTCFullYear(),\n }\n}\n",
129
+ "target": "~/packages/ui/src/helpers/calendar-date.ts"
130
+ },
131
+ {
132
+ "path": "helpers/date.ts",
133
+ "type": "registry:file",
134
+ "content": "import type { CalendarDate } from './calendar-date'\nimport { toZonedDateTime } from './zoned-date-time'\n\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\nconst MILLISECONDS_IN_DAY = 86_400_000\n\nconst DATE_FORMAT_OPTIONS = {\n dateTime: { dateStyle: 'long', timeStyle: 'short' },\n long: { dateStyle: 'long' },\n medium: { dateStyle: 'medium' },\n numeric: { day: '2-digit', month: '2-digit', year: 'numeric' },\n short: { day: 'numeric', month: 'short' },\n weekdayAndDay: { day: 'numeric', weekday: 'long' },\n} satisfies Record<string, Intl.DateTimeFormatOptions>\n\nconst dateFormatters = new Map<string, Intl.DateTimeFormat>()\nconst relativeDayFormatters = new Map<string, Intl.RelativeTimeFormat>()\n\n/**\n * Type guard for a `Date` whose time is not `NaN`.\n *\n * @param value - Any value, typically the result of parsing user input.\n */\nexport function isValidDate(value: unknown): value is Date {\n return value instanceof Date && !Number.isNaN(value.getTime())\n}\n\n/**\n * Parses an ISO 8601 string, such as the value stored by a date property.\n *\n * @param value - The serialized date; empty values are treated as absent.\n * @returns The parsed date, or `null` when the value is absent or invalid.\n */\nexport function parseIsoDate(value: string | null | undefined): Date | null {\n if (!value) return null\n const date = new Date(value)\n return isValidDate(date) ? date : null\n}\n\n/**\n * Coerces a cell value into a `Date`. A date-only string (`2026-08-04`) is\n * read as local midnight, because `new Date('2026-08-04')` is UTC midnight and\n * would display as the previous day in any negative time zone.\n *\n * @param value - A `Date`, a date string or anything `String()` can serialize.\n * @returns A date that may be invalid; check it with {@link isValidDate}.\n */\nexport function parseDateValue(value: unknown): Date {\n if (value instanceof Date) return value\n const raw = String(value)\n return DATE_ONLY_PATTERN.test(raw)\n ? new Date(`${raw}T00:00:00`)\n : new Date(raw)\n}\n\n/**\n * Serializes the local calendar day of a date as noon UTC, so the day survives\n * a round trip through any time zone.\n *\n * @param date - A date whose local year, month and day are kept.\n * @returns An ISO string such as `2026-06-19T12:00:00.000Z`.\n */\nexport function serializeIsoDay(date: Date): string {\n return new Date(\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), 12),\n ).toISOString()\n}\n\n/**\n * Formats a date as day and abbreviated month, without the year.\n *\n * @param date - A valid date.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n * @param timeZone - An IANA time zone; when omitted the date is read in the\n * runtime's local zone, which suits local day markers.\n * @returns The formatted date, such as `Jun 19` or `19 de jun.`.\n */\nexport function formatShortDate(\n date: Date,\n locale: string,\n timeZone?: string,\n): string {\n return getDateFormatter('short', locale, timeZone).format(date)\n}\n\n/**\n * Formats a date as two-digit day and month with the full year, so a column\n * of dates aligns.\n *\n * @param date - A valid date.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n * @param timeZone - An IANA time zone; when omitted the date is read in the\n * runtime's local zone.\n * @returns The formatted date, such as `11/09/2026` or `09/11/2026`.\n */\nexport function formatNumericDate(\n date: Date,\n locale: string,\n timeZone?: string,\n): string {\n return getDateFormatter('numeric', locale, timeZone).format(date)\n}\n\n/**\n * Formats a date with day, abbreviated month and year, as a date picker\n * trigger shows it.\n *\n * @param date - A valid date.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n * @param timeZone - An IANA time zone; when omitted the date is read in the\n * runtime's local zone.\n * @returns The formatted date, such as `Oct 20, 2026` or `20 de out. de 2026`.\n */\nexport function formatMediumDate(\n date: Date,\n locale: string,\n timeZone?: string,\n): string {\n return getDateFormatter('medium', locale, timeZone).format(date)\n}\n\n/**\n * Formats a date with day, full month name and year.\n *\n * @param date - A valid date.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n * @param timeZone - An IANA time zone; when omitted the date is read in the\n * runtime's local zone.\n * @returns The formatted date, such as `October 20, 2026` or\n * `20 de outubro de 2026`.\n */\nexport function formatLongDate(\n date: Date,\n locale: string,\n timeZone?: string,\n): string {\n return getDateFormatter('long', locale, timeZone).format(date)\n}\n\n/**\n * Formats a date with day, full month name, year and time of day, as a\n * tooltip over a short or relative date shows it.\n *\n * @param date - A valid date.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n * @param timeZone - An IANA time zone; when omitted the date is read in the\n * runtime's local zone.\n * @returns The formatted date and time, such as `October 20, 2026 at 2:30 PM`\n * or `20 de outubro de 2026 às 14:30`.\n */\nexport function formatDateTime(\n date: Date,\n locale: string,\n timeZone?: string,\n): string {\n return getDateFormatter('dateTime', locale, timeZone).format(date)\n}\n\n/**\n * Formats the weekday name with the day of the month, as a day heading over a\n * list of time slots.\n *\n * @param date - A valid date.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n * @param timeZone - An IANA time zone; when omitted the date is read in the\n * runtime's local zone.\n * @returns The formatted day, such as `Tuesday 20` or `terça-feira, 20`.\n */\nexport function formatWeekdayAndDay(\n date: Date,\n locale: string,\n timeZone?: string,\n): string {\n return getDateFormatter('weekdayAndDay', locale, timeZone).format(date)\n}\n\n/**\n * Counts the civil days between two instants as seen on the wall clock of a\n * time zone, so an instant just after midnight in that zone counts as the\n * next day even when it is still the previous day in UTC.\n *\n * @param from - The reference instant, usually now.\n * @param to - The instant being measured, such as a due date.\n * @param timeZone - An IANA time zone.\n * @returns Negative when `to` falls on an earlier day than `from`.\n */\nexport function dayOffsetInTimeZone(\n from: Date,\n to: Date,\n timeZone: string,\n): number {\n return (\n dayNumber(toZonedDateTime(to, timeZone).date) -\n dayNumber(toZonedDateTime(from, timeZone).date)\n )\n}\n\n/**\n * Names a day relative to today (`Yesterday`, `Today`, `Tomorrow`, `In 3\n * days`) with the first letter upper-cased for the locale.\n *\n * @param dayOffset - Civil days from today; see {@link dayOffsetInTimeZone}.\n * @param locale - A BCP 47 locale tag such as `pt-BR`.\n */\nexport function formatRelativeDay(dayOffset: number, locale: string): string {\n const label = getRelativeDayFormatter(locale).format(dayOffset, 'day')\n return label.charAt(0).toLocaleUpperCase(locale) + label.slice(1)\n}\n\n/**\n * Moves a date by a number of local calendar days, keeping its time of day.\n *\n * @param date - The starting date; it is not mutated.\n * @param days - Days to add; negative values move backwards.\n */\nexport function addDays(date: Date, days: number): Date {\n const next = new Date(date)\n next.setDate(next.getDate() + days)\n return next\n}\n\n/**\n * Moves a date by a number of months. When the target month is shorter, the\n * day is clamped to its last day, so January 31 plus one month is the end of\n * February instead of early March.\n *\n * @param date - The starting date; it is not mutated.\n * @param months - Months to add; negative values move backwards.\n */\nexport function addMonths(date: Date, months: number): Date {\n const next = new Date(date)\n next.setDate(1)\n next.setMonth(next.getMonth() + months)\n const lastDay = new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate()\n next.setDate(Math.min(date.getDate(), lastDay))\n return next\n}\n\n/**\n * Moves a date by a number of years. February 29 becomes February 28 in a\n * common year.\n *\n * @param date - The starting date; it is not mutated.\n * @param years - Years to add; negative values move backwards.\n */\nexport function addYears(date: Date, years: number): Date {\n return addMonths(date, years * 12)\n}\n\n/** Building an `Intl` formatter costs ~50 formats, so one is kept per key. */\nfunction getDateFormatter(\n style: keyof typeof DATE_FORMAT_OPTIONS,\n locale: string,\n timeZone?: string,\n): Intl.DateTimeFormat {\n const key = `${style}|${locale}|${timeZone ?? ''}`\n const cached = dateFormatters.get(key)\n if (cached) return cached\n\n const formatter = new Intl.DateTimeFormat(locale, {\n ...DATE_FORMAT_OPTIONS[style],\n ...(timeZone ? { timeZone } : {}),\n })\n dateFormatters.set(key, formatter)\n\n return formatter\n}\n\nfunction getRelativeDayFormatter(locale: string): Intl.RelativeTimeFormat {\n const cached = relativeDayFormatters.get(locale)\n if (cached) return cached\n\n const formatter = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' })\n relativeDayFormatters.set(locale, formatter)\n\n return formatter\n}\n\n/** Days since the Unix epoch for a calendar date, ignoring time zones. */\nfunction dayNumber(date: CalendarDate): number {\n return Date.UTC(date.year, date.month - 1, date.day) / MILLISECONDS_IN_DAY\n}\n",
135
+ "target": "~/packages/ui/src/helpers/date.ts"
136
+ },
137
+ {
138
+ "path": "helpers/format.ts",
139
+ "type": "registry:file",
140
+ "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",
141
+ "target": "~/packages/ui/src/helpers/format.ts"
142
+ },
143
+ {
144
+ "path": "helpers/initials.ts",
145
+ "type": "registry:file",
146
+ "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",
147
+ "target": "~/packages/ui/src/helpers/initials.ts"
148
+ },
149
+ {
150
+ "path": "helpers/zoned-date-time.ts",
151
+ "type": "registry:file",
152
+ "content": "import type { CalendarDate } from './calendar-date'\n\n/**\n * A wall-clock reading in some time zone: the calendar day and the minutes\n * elapsed since local midnight.\n */\nexport interface ZonedDateTime {\n date: CalendarDate\n minutes: number\n}\n\nconst formatterCache = new Map<string, Intl.DateTimeFormat>()\n\n/**\n * Returns the formatter for a time zone. `Intl.DateTimeFormat` is expensive\n * to construct, so one instance per zone is kept for the life of the module.\n */\nfunction getFormatter(timeZone: string): Intl.DateTimeFormat {\n const cached = formatterCache.get(timeZone)\n if (cached) return cached\n\n const formatter = new Intl.DateTimeFormat('en-US', {\n day: '2-digit',\n hour: '2-digit',\n hourCycle: 'h23',\n minute: '2-digit',\n month: '2-digit',\n second: '2-digit',\n timeZone,\n year: 'numeric',\n })\n formatterCache.set(timeZone, formatter)\n\n return formatter\n}\n\n/** Numeric date and time fields of an instant, read in a time zone. */\ninterface WallClockParts {\n day: number\n hour: number\n minute: number\n month: number\n second: number\n year: number\n}\n\n/**\n * Reads the wall-clock fields of an instant in a time zone.\n *\n * @param instant - The UTC instant to project.\n * @param timeZone - An IANA time zone.\n */\nfunction wallClockPartsOf(instant: Date, timeZone: string): WallClockParts {\n const parts: Partial<WallClockParts> = {}\n\n for (const part of getFormatter(timeZone).formatToParts(instant)) {\n if (part.type === 'literal') continue\n if (part.type in partKeys)\n parts[partKeys[part.type as keyof typeof partKeys]] = Number(part.value)\n }\n\n return parts as WallClockParts\n}\n\nconst partKeys = {\n day: 'day',\n hour: 'hour',\n minute: 'minute',\n month: 'month',\n second: 'second',\n year: 'year',\n} as const\n\n/**\n * Projects a UTC instant onto the wall clock of a time zone.\n *\n * @param instant - The UTC instant to project.\n * @param timeZone - An IANA time zone.\n * @returns The calendar day and the minutes since local midnight.\n */\nexport function toZonedDateTime(\n instant: Date,\n timeZone: string,\n): ZonedDateTime {\n const parts = wallClockPartsOf(instant, timeZone)\n\n return {\n date: { day: parts.day, month: parts.month, year: parts.year },\n minutes: parts.hour * 60 + parts.minute,\n }\n}\n\n/**\n * Offset of a time zone from UTC at a given instant. The formatter stops at\n * seconds, so the instant is truncated to the second before comparing;\n * otherwise milliseconds would leak into the offset.\n *\n * @param instant - The UTC instant to measure at.\n * @param timeZone - An IANA time zone.\n * @returns The offset in milliseconds; positive east of UTC.\n */\nexport function getTimeZoneOffsetMs(instant: Date, timeZone: string): number {\n const parts = wallClockPartsOf(instant, timeZone)\n const wallAsUtc = Date.UTC(\n parts.year,\n parts.month - 1,\n parts.day,\n parts.hour,\n parts.minute,\n parts.second,\n )\n const truncated =\n instant.getTime() - (((instant.getTime() % 1000) + 1000) % 1000)\n\n return wallAsUtc - truncated\n}\n\n/**\n * Converts a wall-clock reading in a time zone back to a UTC instant without a\n * date library: the wall time is first treated as UTC and then corrected by the\n * zone offset. A second pass handles transition edges, since offsets only\n * change there: an ambiguous time (fall back) keeps the first offset found,\n * and a nonexistent time (spring forward) resolves to the instant after the\n * transition.\n *\n * @param zoned - The calendar day and minutes since local midnight.\n * @param timeZone - An IANA time zone.\n * @returns The UTC instant that shows that wall time in the zone.\n */\nexport function fromZonedDateTime(\n zoned: ZonedDateTime,\n timeZone: string,\n): Date {\n const { date, minutes } = zoned\n const guess = Date.UTC(date.year, date.month - 1, date.day, 0, minutes)\n const firstOffset = getTimeZoneOffsetMs(new Date(guess), timeZone)\n const candidate = guess - firstOffset\n const secondOffset = getTimeZoneOffsetMs(new Date(candidate), timeZone)\n\n if (firstOffset === secondOffset) return new Date(candidate)\n\n const corrected = guess - secondOffset\n const projected = toZonedDateTime(new Date(corrected), timeZone)\n const matchesWall =\n projected.minutes === ((minutes % 1440) + 1440) % 1440 &&\n projected.date.day === date.day &&\n projected.date.month === date.month &&\n projected.date.year === date.year\n\n return matchesWall ? new Date(corrected) : new Date(candidate)\n}\n",
153
+ "target": "~/packages/ui/src/helpers/zoned-date-time.ts"
154
+ },
155
+ {
156
+ "path": "patterns/action-bar/components/action-bar.tsx",
157
+ "type": "registry:file",
158
+ "content": "'use client'\n\nimport { DotsSixVerticalIcon, XIcon } from '@phosphor-icons/react'\nimport { Button, type ButtonProps } from '@tc96/ui/button'\nimport {\n Menu,\n MenuGroup,\n MenuGroupLabel,\n MenuItem,\n MenuPopup,\n MenuSeparator,\n MenuTrigger,\n} from '@tc96/ui/menu'\nimport { cn } from '@tc96/utils'\nimport { Fragment, type ReactNode } from 'react'\n\nexport interface ActionBarContext<TData = unknown> {\n selectedCount: number\n selectedRows: readonly TData[]\n}\n\nexport interface ActionBarItem<TData = unknown> {\n disabled?: boolean\n icon?: ReactNode\n id?: string\n label: string\n onSelect?: (context: ActionBarContext<TData>) => void\n shortcut?: string\n submenu?: ActionBarGroup<TData>[]\n variant?: 'default' | 'primary' | 'destructive'\n}\n\nexport interface ActionBarGroup<TData = unknown> {\n id?: string\n items: ActionBarItem<TData>[]\n label?: string\n}\n\nexport interface ActionBarProps<TData = unknown> {\n actions: ActionBarGroup<TData>[]\n className?: string\n clearSelectionLabel?: string\n formatSelection?: (count: number) => string\n label?: string\n notice?: string\n onClearSelection?: () => void\n selectedCount: number\n selectedRows?: readonly TData[]\n}\n\nfunction selectionLabel(count: number) {\n return `${count} selecionado${count === 1 ? '' : 's'}`\n}\n\nfunction actionKey<TData>(action: ActionBarItem<TData>) {\n return action.id ?? action.label\n}\n\nfunction groupKey<TData>(group: ActionBarGroup<TData>) {\n return (\n group.id ??\n group.label ??\n group.items.map((action) => actionKey(action)).join('|')\n )\n}\n\nfunction buttonAppearance(\n variant: ActionBarItem['variant'] = 'default',\n): Pick<ButtonProps, 'className' | 'variant'> {\n if (variant === 'primary') return { variant: 'default' }\n if (variant === 'destructive')\n return { className: 'text-destructive-foreground', variant: 'ghost' }\n return { variant: 'ghost' }\n}\n\nfunction ActionItem<TData>({\n action,\n context,\n}: Readonly<{\n action: ActionBarItem<TData>\n context: ActionBarContext<TData>\n}>): ReactNode {\n const content = (\n <>\n {action.icon}\n <span>{action.label}</span>\n {action.shortcut ? (\n <kbd className=\"ms-auto text-xs\">{action.shortcut}</kbd>\n ) : null}\n </>\n )\n\n if (action.submenu) {\n return (\n <Menu modal={false}>\n <MenuTrigger\n aria-label={action.label}\n disabled={action.disabled}\n render={\n <Button\n aria-label={action.label}\n disabled={action.disabled}\n size=\"sm\"\n {...buttonAppearance(action.variant)}\n />\n }\n >\n {content}\n </MenuTrigger>\n <MenuPopup align=\"center\" side=\"top\" sideOffset={8}>\n {action.submenu.map((group, groupIndex) => (\n <Fragment key={groupKey(group)}>\n {groupIndex > 0 ? <MenuSeparator /> : null}\n <MenuGroup>\n {group.label ? (\n <MenuGroupLabel>{group.label}</MenuGroupLabel>\n ) : null}\n {group.items.map((item) => (\n <MenuItem\n disabled={item.disabled}\n key={actionKey(item)}\n onClick={() => item.onSelect?.(context)}\n variant={\n item.variant === 'destructive' ? 'destructive' : 'default'\n }\n >\n {item.icon}\n <span>{item.label}</span>\n {item.shortcut ? (\n <kbd className=\"ms-auto text-xs\">{item.shortcut}</kbd>\n ) : null}\n </MenuItem>\n ))}\n </MenuGroup>\n </Fragment>\n ))}\n </MenuPopup>\n </Menu>\n )\n }\n\n return (\n <Button\n aria-label={action.label}\n disabled={action.disabled}\n onClick={() => action.onSelect?.(context)}\n size=\"sm\"\n title={action.label}\n {...buttonAppearance(action.variant)}\n >\n {content}\n </Button>\n )\n}\n\nexport function ActionBar<TData = unknown>({\n actions,\n className,\n clearSelectionLabel = 'Limpar seleção',\n formatSelection = selectionLabel,\n label = 'Ações dos itens selecionados',\n notice,\n onClearSelection,\n selectedCount,\n selectedRows = [],\n}: Readonly<ActionBarProps<TData>>): ReactNode {\n if (selectedCount < 1) return null\n\n const context: ActionBarContext<TData> = {\n selectedCount,\n selectedRows,\n }\n\n const bar = (\n <div\n aria-label={label}\n className={cn(\n 'flex min-h-11 w-fit max-w-full items-center gap-1 overflow-x-auto rounded-xl border bg-popover px-2 py-1 text-popover-foreground shadow-lg',\n className,\n )}\n data-slot=\"action-bar\"\n role=\"toolbar\"\n >\n <DotsSixVerticalIcon\n aria-hidden=\"true\"\n className=\"size-4 shrink-0 text-muted-foreground\"\n />\n <span className=\"px-1 font-medium text-sm\">\n {formatSelection(selectedCount)}\n </span>\n {actions.map((group, groupIndex) => (\n <div className=\"flex items-center gap-0.5\" key={groupKey(group)}>\n {groupIndex > 0 ? (\n <hr\n aria-orientation=\"vertical\"\n className=\"mx-1 h-5 w-px border-0 bg-border\"\n />\n ) : null}\n {group.items.map((action) => (\n <ActionItem\n action={action}\n context={context}\n key={actionKey(action)}\n />\n ))}\n </div>\n ))}\n {onClearSelection ? (\n <Button\n aria-label={clearSelectionLabel}\n onClick={onClearSelection}\n size=\"sm\"\n title={clearSelectionLabel}\n variant=\"ghost\"\n >\n <XIcon aria-hidden=\"true\" />\n </Button>\n ) : null}\n </div>\n )\n\n if (!notice) return bar\n\n return (\n <div className=\"flex w-fit max-w-full flex-col items-center gap-2\">\n <output\n className=\"block max-w-full rounded-md border bg-popover px-3 py-1.5 text-center text-muted-foreground text-sm shadow-sm\"\n data-slot=\"action-bar-notice\"\n >\n {notice}\n </output>\n {bar}\n </div>\n )\n}\n",
159
+ "target": "~/packages/ui/src/patterns/action-bar/components/action-bar.tsx"
160
+ },
161
+ {
162
+ "path": "patterns/action-bar/index.ts",
163
+ "type": "registry:file",
164
+ "content": "'use client'\n\nexport type {\n ActionBarContext,\n ActionBarGroup,\n ActionBarItem,\n ActionBarProps,\n} from './components/action-bar'\nexport { ActionBar } from './components/action-bar'\n",
165
+ "target": "~/packages/ui/src/patterns/action-bar/index.ts"
166
+ },
167
+ {
168
+ "path": "patterns/collection-pagination/components/collection-pagination.tsx",
169
+ "type": "registry:file",
170
+ "content": "'use client'\n\nimport {\n CaretDoubleLeftIcon,\n CaretDoubleRightIcon,\n CaretLeftIcon,\n CaretRightIcon,\n} from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport {\n Pagination,\n PaginationContent,\n PaginationItem,\n} from '@tc96/ui/pagination'\nimport {\n Select,\n SelectItem,\n SelectPopup,\n SelectTrigger,\n SelectValue,\n} from '@tc96/ui/select'\nimport { cn } from '@tc96/utils'\nimport type React from 'react'\nimport { useId } from 'react'\n\nexport interface CollectionPaginationButtonLabels {\n first: string\n previous: string\n next: string\n last: string\n}\n\nconst defaultButtonLabels: CollectionPaginationButtonLabels = {\n first: 'Primeira página',\n last: 'Última página',\n next: 'Próxima página',\n previous: 'Página anterior',\n}\n\nexport interface CollectionPaginationProps\n extends Omit<React.ComponentProps<'div'>, 'children' | 'onChange'> {\n /** Nome acessível da navegação, no vocabulário da coleção — `Paginação de contatos`. */\n label: string\n buttonLabels?: Partial<CollectionPaginationButtonLabels>\n formatRange?: (first: number, last: number, total: number) => string\n onPageChange: (page: number) => void\n onPageSizeChange?: (size: number) => void\n /** Página corrente, a partir de 1 — a mesma numeração dos contratos de listagem. */\n page: number\n pageCount: number\n pageSizeLabel?: string\n pageSizeOptions?: readonly number[]\n /** Com `total`, resume o recorte visível (`1–25 de 57`) à esquerda dos controles. */\n pageSize?: number\n total?: number\n}\n\n/**\n * A paginação de uma coleção, seja ela servida pelo servidor (contratos com\n * `pagination.page`) ou pelo modelo de paginação de uma tabela. O consumer\n * decide quando mostrá-la; o pacote fixa anatomia, rótulos e estados das pontas.\n */\nexport function CollectionPagination({\n buttonLabels: buttonLabelsProp,\n className,\n formatRange = defaultFormatRange,\n label,\n onPageChange,\n onPageSizeChange,\n page,\n pageCount,\n pageSize,\n pageSizeLabel,\n pageSizeOptions,\n total,\n ...props\n}: CollectionPaginationProps): React.ReactElement {\n const pageSizeLabelId = useId()\n const buttonLabels = { ...defaultButtonLabels, ...buttonLabelsProp }\n const lastPage = Math.max(pageCount, 1)\n const currentPage = Math.min(Math.max(page, 1), lastPage)\n const summary =\n total !== undefined && pageSize !== undefined\n ? summarizeRange(currentPage, pageSize, total, formatRange)\n : null\n\n const pager = (\n <Pagination aria-label={label} className=\"mx-0 ml-auto w-auto justify-end\">\n <PaginationContent>\n <PaginationItem>\n <Button\n aria-label={buttonLabels.first}\n disabled={currentPage <= 1}\n onClick={() => onPageChange(1)}\n size=\"icon-sm\"\n variant=\"ghost\"\n >\n <CaretDoubleLeftIcon aria-hidden=\"true\" />\n </Button>\n </PaginationItem>\n <PaginationItem>\n <Button\n aria-label={buttonLabels.previous}\n disabled={currentPage <= 1}\n onClick={() => onPageChange(currentPage - 1)}\n size=\"icon-sm\"\n variant=\"ghost\"\n >\n <CaretLeftIcon aria-hidden=\"true\" />\n </Button>\n </PaginationItem>\n <PaginationItem>\n <span\n aria-current=\"page\"\n className=\"whitespace-nowrap px-2 text-muted-foreground text-sm tabular-nums\"\n data-slot=\"collection-pagination-page\"\n >\n {currentPage} / {lastPage}\n </span>\n </PaginationItem>\n <PaginationItem>\n <Button\n aria-label={buttonLabels.next}\n disabled={currentPage >= lastPage}\n onClick={() => onPageChange(currentPage + 1)}\n size=\"icon-sm\"\n variant=\"ghost\"\n >\n <CaretRightIcon aria-hidden=\"true\" />\n </Button>\n </PaginationItem>\n <PaginationItem>\n <Button\n aria-label={buttonLabels.last}\n disabled={currentPage >= lastPage}\n onClick={() => onPageChange(lastPage)}\n size=\"icon-sm\"\n variant=\"ghost\"\n >\n <CaretDoubleRightIcon aria-hidden=\"true\" />\n </Button>\n </PaginationItem>\n </PaginationContent>\n </Pagination>\n )\n const summaryText = summary ? (\n <p\n aria-live=\"polite\"\n className=\"whitespace-nowrap px-2 text-muted-foreground text-sm tabular-nums\"\n >\n {summary}\n </p>\n ) : null\n const showsPageSize = Boolean(\n pageSizeOptions?.length && onPageSizeChange && pageSizeLabel,\n )\n\n return (\n <div\n className={cn(\n 'flex flex-wrap items-center justify-between gap-2 p-2',\n className,\n )}\n data-slot=\"collection-pagination\"\n {...props}\n >\n {showsPageSize && pageSizeOptions && onPageSizeChange ? (\n <>\n <div\n className=\"flex shrink-0 items-center gap-2 px-2\"\n data-slot=\"collection-pagination-page-size\"\n >\n <span\n className=\"whitespace-nowrap text-muted-foreground text-sm\"\n id={pageSizeLabelId}\n >\n {pageSizeLabel}\n </span>\n <Select\n items={pageSizeOptions.map((size) => ({\n label: String(size),\n value: size,\n }))}\n onValueChange={(size) => {\n if (size !== null) onPageSizeChange(size)\n }}\n value={pageSize ?? null}\n >\n <SelectTrigger\n aria-labelledby={pageSizeLabelId}\n className=\"min-w-0\"\n size=\"sm\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectPopup listProps={{ 'aria-labelledby': pageSizeLabelId }}>\n {pageSizeOptions.map((size) => (\n <SelectItem key={size} value={size}>\n {size}\n </SelectItem>\n ))}\n </SelectPopup>\n </Select>\n </div>\n <div className=\"ml-auto flex flex-wrap items-center gap-2\">\n {summaryText}\n {pager}\n </div>\n </>\n ) : (\n <>\n {summaryText}\n {pager}\n </>\n )}\n </div>\n )\n}\n\nfunction defaultFormatRange(first: number, last: number, total: number) {\n return total === 0 ? '0 de 0' : `${first}–${last} de ${total}`\n}\n\nfunction summarizeRange(\n page: number,\n pageSize: number,\n total: number,\n formatRange: (first: number, last: number, total: number) => string,\n): string {\n if (total === 0) return formatRange(0, 0, 0)\n const first = (page - 1) * pageSize + 1\n const last = Math.min(page * pageSize, total)\n return formatRange(first, last, total)\n}\n",
171
+ "target": "~/packages/ui/src/patterns/collection-pagination/components/collection-pagination.tsx"
172
+ },
173
+ {
174
+ "path": "patterns/collection-pagination/index.ts",
175
+ "type": "registry:file",
176
+ "content": "'use client'\n\nexport type {\n CollectionPaginationButtonLabels,\n CollectionPaginationProps,\n} from './components/collection-pagination'\nexport { CollectionPagination } from './components/collection-pagination'\n",
177
+ "target": "~/packages/ui/src/patterns/collection-pagination/index.ts"
178
+ },
179
+ {
180
+ "path": "patterns/collection/shared/components/editable-input-cell.tsx",
181
+ "type": "registry:file",
182
+ "content": "'use client'\n\nimport { Input } from '@tc96/ui/input'\nimport { cn } from '@tc96/utils'\nimport { type KeyboardEvent, useEffect, useId, useRef, useState } from 'react'\nimport {\n DEFAULT_EMPTY_CELL_LABEL,\n type EditableCellMeta,\n type EditableCellRow,\n type EditableCellValueChange,\n resolveEditableCellLabel,\n} from '../lib/editable-cell'\n\nexport interface EditableInputCellProps {\n alignClassName?: string\n cellSelector: string\n columnId: string\n meta: EditableCellMeta\n numeric: boolean\n onValueChange?: (change: EditableCellValueChange) => void\n row: EditableCellRow\n slot: string\n triggerAttribute: `data-${string}`\n value: string\n}\n\nexport function EditableInputCell({\n alignClassName,\n cellSelector,\n columnId,\n meta,\n numeric,\n onValueChange,\n row,\n slot,\n triggerAttribute,\n value,\n}: EditableInputCellProps) {\n const [draft, setDraft] = useState<string | null>(null)\n const messageId = useId()\n const rootRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const restoreFocusRef = useRef(false)\n const settledRef = useRef(false)\n const editing = draft !== null\n const draftError = draft === null ? undefined : meta.validate?.(draft, row)\n const message = draftError ?? meta.getCellError?.(row, columnId)\n const invalid = Boolean(message)\n const label = meta.label ?? columnId\n\n useEffect(() => {\n if (!editing) return\n inputRef.current?.focus()\n inputRef.current?.select()\n }, [editing])\n\n useEffect(() => {\n if (editing || !restoreFocusRef.current) return\n restoreFocusRef.current = false\n triggerRef.current?.focus()\n }, [editing])\n\n useEffect(() => {\n const cell = rootRef.current?.closest(cellSelector)\n if (!(invalid && cell)) return\n cell.setAttribute('data-invalid', '')\n return () => cell.removeAttribute('data-invalid')\n }, [cellSelector, invalid])\n\n const commit = () => {\n if (draft === null || draftError || settledRef.current) return false\n settledRef.current = true\n if (draft !== value && onValueChange) {\n onValueChange({ columnId, rowId: row.id, value: draft })\n }\n setDraft(null)\n return true\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n restoreFocusRef.current = commit()\n } else if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n settledRef.current = true\n restoreFocusRef.current = true\n setDraft(null)\n }\n }\n\n const display = value && meta.formatValue ? meta.formatValue(value) : value\n const triggerProps = { [triggerAttribute]: true }\n\n return (\n <div\n className=\"block w-full min-w-0\"\n data-invalid={invalid ? '' : undefined}\n data-slot={slot}\n ref={rootRef}\n >\n {draft === null ? (\n <button\n aria-describedby={invalid ? messageId : undefined}\n aria-invalid={invalid || undefined}\n aria-label={resolveEditableCellLabel(\n label,\n display ||\n meta.placeholder ||\n (meta.emptyLabel ?? DEFAULT_EMPTY_CELL_LABEL),\n meta,\n )}\n className={cn(\n 'block w-full min-w-0 cursor-text truncate rounded-sm px-1 outline-none focus-visible:ring-2 focus-visible:ring-ring',\n numeric && 'tabular-nums',\n alignClassName,\n )}\n {...triggerProps}\n onClick={() => {\n settledRef.current = false\n setDraft(value)\n }}\n ref={triggerRef}\n type=\"button\"\n >\n {display}\n </button>\n ) : (\n <Input\n aria-describedby={invalid ? messageId : undefined}\n aria-invalid={invalid || undefined}\n aria-label={label}\n className={cn(numeric && 'tabular-nums')}\n inputMode={numeric ? 'decimal' : undefined}\n onBlur={commit}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n ref={inputRef}\n size=\"sm\"\n value={draft}\n />\n )}\n {invalid ? (\n <p className=\"mt-1 text-destructive-foreground text-xs\" id={messageId}>\n {message}\n </p>\n ) : null}\n </div>\n )\n}\n",
183
+ "target": "~/packages/ui/src/patterns/collection/shared/components/editable-input-cell.tsx"
184
+ },
185
+ {
186
+ "path": "patterns/collection/shared/components/row-drag-handle.tsx",
187
+ "type": "registry:file",
188
+ "content": "'use client'\n\nimport { KeyboardSensor, PointerSensor } from '@dnd-kit/dom'\nimport { useSortable } from '@dnd-kit/react/sortable'\nimport { DotsSixVerticalIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { useCallback } from 'react'\nimport { useRowReorder } from '../hooks/use-row-reorder'\n\nconst ROW_DRAG_SENSORS = [\n PointerSensor,\n KeyboardSensor.configure({\n keyboardCodes: {\n cancel: ['Escape'],\n down: ['ArrowDown'],\n end: ['Space', 'Tab'],\n left: ['ArrowLeft'],\n right: ['ArrowRight'],\n start: ['Space'],\n up: ['ArrowUp'],\n },\n }),\n]\n\nexport interface RowDragHandleProps {\n dragType: string\n label: string\n rowId: string\n rowSelector: string\n slot: string\n}\n\nfunction InertRowDragHandle({\n label,\n slot,\n}: Pick<RowDragHandleProps, 'label' | 'slot'>) {\n return (\n <Button\n aria-label={label}\n className=\"touch-none\"\n data-slot={slot}\n disabled\n size=\"icon-xs\"\n type=\"button\"\n variant=\"ghost\"\n >\n <DotsSixVerticalIcon aria-hidden=\"true\" />\n </Button>\n )\n}\n\nfunction SortableRowDragHandle({\n dragType,\n index,\n label,\n rowId,\n rowSelector,\n slot,\n}: RowDragHandleProps & { index: number }) {\n const { handleRef, isDragSource, ref } = useSortable({\n accept: dragType,\n data: { type: dragType },\n group: dragType,\n id: rowId,\n index,\n sensors: ROW_DRAG_SENSORS,\n transition: null,\n type: dragType,\n })\n const setHandle = useCallback(\n (node: HTMLButtonElement | null) => {\n handleRef(node)\n ref(node?.closest<HTMLElement>(rowSelector) ?? null)\n },\n [handleRef, ref, rowSelector],\n )\n\n return (\n <Button\n aria-label={label}\n className=\"cursor-grab touch-none\"\n data-dragging={isDragSource || undefined}\n data-slot={slot}\n ref={setHandle}\n size=\"icon-xs\"\n type=\"button\"\n variant=\"ghost\"\n >\n <DotsSixVerticalIcon aria-hidden=\"true\" />\n </Button>\n )\n}\n\nexport function RowDragHandle(props: RowDragHandleProps) {\n const reorder = useRowReorder()\n const index = reorder?.indexByRowId.get(props.rowId)\n if (index === undefined)\n return <InertRowDragHandle label={props.label} slot={props.slot} />\n return <SortableRowDragHandle index={index} {...props} />\n}\n",
189
+ "target": "~/packages/ui/src/patterns/collection/shared/components/row-drag-handle.tsx"
190
+ },
191
+ {
192
+ "path": "patterns/collection/shared/components/row-reorder-provider.tsx",
193
+ "type": "registry:file",
194
+ "content": "'use client'\n\nimport type { Plugins } from '@dnd-kit/abstract'\nimport { Accessibility } from '@dnd-kit/dom'\nimport {\n DragDropProvider,\n type DragEndEvent,\n type DragOverEvent,\n type DragStartEvent,\n} from '@dnd-kit/react'\nimport { isSortable, isSortableOperation } from '@dnd-kit/react/sortable'\nimport { type ReactNode, useMemo } from 'react'\nimport { useLatestCallback } from '../hooks/use-latest-callback'\nimport { RowReorderContext } from '../hooks/use-row-reorder'\nimport {\n type RowDragAnnouncements,\n type RowMove,\n resolveRowMove,\n} from '../lib/row-reorder'\n\nexport interface RowReorderProviderProps {\n active: boolean\n announcements?: RowDragAnnouncements\n children: ReactNode\n getCollectionIndexes: () => readonly number[]\n indexByRowId: ReadonlyMap<string, number>\n onRowMove?: (move: RowMove) => void\n rowIds: readonly string[]\n}\n\nexport function RowReorderProvider({\n active,\n announcements,\n children,\n getCollectionIndexes,\n indexByRowId,\n onRowMove,\n rowIds,\n}: RowReorderProviderProps) {\n const context = useMemo(() => ({ indexByRowId }), [indexByRowId])\n const handleDragEnd = useLatestCallback((event: DragEndEvent) => {\n if (event.canceled || !isSortableOperation(event.operation)) return\n const { source, target } = event.operation\n if (!(source && target)) return\n const move = resolveRowMove({\n collectionIndexes: getCollectionIndexes(),\n rowIds,\n sourceId: String(source.id),\n targetIndex: target.index,\n })\n if (move) onRowMove?.(move)\n })\n const getAnnouncements = useLatestCallback(() => announcements)\n const getRowCount = useLatestCallback(() => rowIds.length)\n const hasAnnouncements = Boolean(announcements)\n const hasOverAnnouncement = Boolean(announcements?.over)\n const instructions = announcements?.instructions\n const plugins = useMemo(\n () =>\n hasAnnouncements\n ? createPlugins({\n getAnnouncements,\n getRowCount,\n hasOverAnnouncement,\n instructions,\n })\n : undefined,\n [\n getAnnouncements,\n getRowCount,\n hasAnnouncements,\n hasOverAnnouncement,\n instructions,\n ],\n )\n\n if (!active) return children\n\n return (\n <RowReorderContext value={context}>\n <DragDropProvider onDragEnd={handleDragEnd} plugins={plugins}>\n {children}\n </DragDropProvider>\n </RowReorderContext>\n )\n}\n\ninterface CreatePluginsInput {\n getAnnouncements: () => RowDragAnnouncements | undefined\n getRowCount: () => number\n hasOverAnnouncement: boolean\n instructions: string | undefined\n}\n\nfunction createPlugins({\n getAnnouncements,\n getRowCount,\n hasOverAnnouncement,\n instructions,\n}: CreatePluginsInput) {\n const configured = Accessibility.configure({\n announcements: {\n dragend: (event: DragEndEvent) => {\n const { operation } = event\n if (!isSortable(operation.source)) return\n return getAnnouncements()?.end({\n canceled: event.canceled,\n fromIndex: operation.source.initialIndex,\n rowCount: getRowCount(),\n rowId: String(operation.source.id),\n toIndex: operation.source.index,\n })\n },\n dragover: hasOverAnnouncement\n ? (event: DragOverEvent) => {\n const { operation } = event\n if (!isSortableOperation(operation)) return\n const { source, target } = operation\n if (!(source && target) || source.id === target.id) return\n return getAnnouncements()?.over?.({\n index: source.index,\n overIndex: target.index,\n overRowId: String(target.id),\n rowCount: getRowCount(),\n rowId: String(source.id),\n })\n }\n : undefined,\n dragstart: (event: DragStartEvent) => {\n const { operation } = event\n if (!isSortable(operation.source)) return\n return getAnnouncements()?.start({\n index: operation.source.index,\n rowCount: getRowCount(),\n rowId: String(operation.source.id),\n })\n },\n },\n ...(instructions\n ? { screenReaderInstructions: { draggable: instructions } }\n : {}),\n })\n return (defaults: Plugins): Plugins =>\n defaults.map((plugin) => (plugin === Accessibility ? configured : plugin))\n}\n",
195
+ "target": "~/packages/ui/src/patterns/collection/shared/components/row-reorder-provider.tsx"
196
+ },
197
+ {
198
+ "path": "patterns/collection/shared/components/selection-actions.tsx",
199
+ "type": "registry:file",
200
+ "content": "'use client'\n\nimport type { ReactNode } from 'react'\nimport type { ActionBarContext } from '../../../action-bar/components/action-bar'\n\nexport type SelectionActionsProp<TData> =\n | ReactNode\n | ((\n context: ActionBarContext<TData> & {\n clearSelection: () => void\n },\n ) => ReactNode)\n\nexport interface SelectionActionsTable<TData> {\n getSelectedRowModel: () => { rows: readonly { original: TData }[] }\n resetRowSelection: () => void\n}\n\nexport interface SelectionActionsProps<TData> {\n selectionActions?: SelectionActionsProp<TData>\n slot: string\n table: SelectionActionsTable<TData>\n}\n\nexport function SelectionActions<TData>({\n selectionActions,\n slot,\n table,\n}: SelectionActionsProps<TData>) {\n if (!selectionActions) return null\n const selectedRows = table\n .getSelectedRowModel()\n .rows.map((row) => row.original)\n if (selectedRows.length === 0) return null\n\n const content =\n typeof selectionActions === 'function'\n ? selectionActions({\n clearSelection: () => table.resetRowSelection(),\n selectedCount: selectedRows.length,\n selectedRows,\n })\n : selectionActions\n if (!content) return null\n\n return (\n <div\n className=\"pointer-events-none absolute inset-x-0 bottom-3 z-20 flex justify-center px-3\"\n data-slot={slot}\n >\n <div className=\"pointer-events-auto\">{content}</div>\n </div>\n )\n}\n",
201
+ "target": "~/packages/ui/src/patterns/collection/shared/components/selection-actions.tsx"
202
+ },
203
+ {
204
+ "path": "patterns/collection/shared/hooks/use-collapsed-groups.ts",
205
+ "type": "registry:file",
206
+ "content": "import { useRef, useState } from 'react'\n\ninterface UseCollapsedGroupsOptions {\n controlled?: readonly string[]\n defaultValue: readonly string[]\n onChange?: (groupIds: readonly string[]) => void\n}\n\nexport function useCollapsedGroups({\n controlled,\n defaultValue,\n onChange,\n}: UseCollapsedGroupsOptions) {\n const [uncontrolled, setUncontrolled] =\n useState<readonly string[]>(defaultValue)\n const uncontrolledRef = useRef(uncontrolled)\n const collapsedGroupIds = controlled ?? uncontrolled\n\n function setGroupCollapsed(group: string, collapsed: boolean) {\n const current = controlled ?? uncontrolledRef.current\n const others = current.filter((id) => id !== group)\n const next = collapsed ? [...others, group] : others\n if (!controlled) {\n uncontrolledRef.current = next\n setUncontrolled(next)\n }\n onChange?.(next)\n }\n\n return { collapsedGroupIds, setGroupCollapsed }\n}\n",
207
+ "target": "~/packages/ui/src/patterns/collection/shared/hooks/use-collapsed-groups.ts"
208
+ },
209
+ {
210
+ "path": "patterns/collection/shared/hooks/use-controllable-table-state.ts",
211
+ "type": "registry:file",
212
+ "content": "'use client'\n\nimport type { Updater } from '@tanstack/react-table'\nimport { useRef, useState } from 'react'\nimport { useLatestCallback } from './use-latest-callback'\n\nexport function useControllableTableState<TValue>(\n controlled: TValue | undefined,\n initial: () => TValue,\n onChange: ((value: TValue) => void) | undefined,\n): [TValue, (updater: Updater<TValue>) => void] {\n const [uncontrolled, setUncontrolled] = useState<TValue>(initial)\n const value = controlled ?? uncontrolled\n const valueRef = useRef(value)\n valueRef.current = value\n const handleChange = useLatestCallback((updater: Updater<TValue>) => {\n const next =\n typeof updater === 'function'\n ? (updater as (previous: TValue) => TValue)(valueRef.current)\n : updater\n if (controlled === undefined) {\n valueRef.current = next\n setUncontrolled(next)\n }\n onChange?.(next)\n })\n return [value, handleChange]\n}\n",
213
+ "target": "~/packages/ui/src/patterns/collection/shared/hooks/use-controllable-table-state.ts"
214
+ },
215
+ {
216
+ "path": "patterns/collection/shared/hooks/use-end-reached.ts",
217
+ "type": "registry:file",
218
+ "content": "import { type RefObject, useEffect, useRef } from 'react'\nimport { isNearEnd, shouldFireEndReached } from '../lib/end-reached'\nimport { useLatestCallback } from './use-latest-callback'\n\nexport interface EndReachedGeometry {\n bottomInset: number\n rowHeight: number\n}\n\ninterface UseEndReachedOptions {\n enabled: boolean\n loadingMore: boolean\n measure: (element: HTMLElement) => EndReachedGeometry\n onEndReached?: () => void\n rowCount: number\n scrollRef: RefObject<HTMLElement | null>\n threshold: number\n}\n\nexport function useEndReached({\n enabled,\n loadingMore,\n measure,\n onEndReached,\n rowCount,\n scrollRef,\n threshold,\n}: UseEndReachedOptions) {\n const firedForCountRef = useRef<number | undefined>(undefined)\n\n const check = useLatestCallback(() => {\n const element = scrollRef.current\n if (!(element && enabled)) return\n const geometry = measure(element)\n const nearEnd = isNearEnd({\n bottomInset: geometry.bottomInset,\n clientHeight: element.clientHeight,\n rowHeight: geometry.rowHeight,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n threshold,\n })\n const fire = shouldFireEndReached({\n firedForCount: firedForCountRef.current,\n loading: loadingMore,\n nearEnd,\n rowCount,\n })\n if (!fire) return\n firedForCountRef.current = rowCount\n onEndReached?.()\n })\n\n useEffect(() => {\n if (enabled && !loadingMore && rowCount > 0) check()\n }, [check, enabled, loadingMore, rowCount])\n\n useEffect(() => {\n const element = scrollRef.current\n if (!(element && enabled)) return\n element.addEventListener('scroll', check, { passive: true })\n return () => element.removeEventListener('scroll', check)\n }, [check, enabled, scrollRef])\n}\n",
219
+ "target": "~/packages/ui/src/patterns/collection/shared/hooks/use-end-reached.ts"
220
+ },
221
+ {
222
+ "path": "patterns/collection/shared/hooks/use-latest-callback.ts",
223
+ "type": "registry:file",
224
+ "content": "import { useCallback, useLayoutEffect, useRef } from 'react'\n\nexport function useLatestCallback<Args extends unknown[], Result>(\n callback: (...args: Args) => Result,\n) {\n const ref = useRef(callback)\n useLayoutEffect(() => {\n ref.current = callback\n })\n return useCallback((...args: Args) => ref.current(...args), [])\n}\n",
225
+ "target": "~/packages/ui/src/patterns/collection/shared/hooks/use-latest-callback.ts"
226
+ },
227
+ {
228
+ "path": "patterns/collection/shared/hooks/use-row-reorder.ts",
229
+ "type": "registry:file",
230
+ "content": "import { createContext, useContext } from 'react'\n\nexport interface RowReorderContextValue {\n indexByRowId: ReadonlyMap<string, number>\n}\n\nexport const RowReorderContext = createContext<RowReorderContextValue | null>(\n null,\n)\n\nexport function useRowReorder() {\n return useContext(RowReorderContext)\n}\n",
231
+ "target": "~/packages/ui/src/patterns/collection/shared/hooks/use-row-reorder.ts"
232
+ },
233
+ {
234
+ "path": "patterns/collection/shared/hooks/use-scrollbar-insets.ts",
235
+ "type": "registry:file",
236
+ "content": "'use client'\n\nimport { type RefObject, useEffect } from 'react'\n\nexport const scrollbarInsetStyle = {\n marginBlockEnd: 'calc(var(--scrollbar-inset-end, 0px) + 0.25rem)',\n marginBlockStart: 'calc(var(--scrollbar-inset-start, 0px) + 0.25rem)',\n} as const\n\nexport function useScrollbarInsets<TElement extends HTMLElement>(\n ref: RefObject<TElement | null>,\n startSelector: string,\n endSelector: string,\n hasEnd: boolean,\n): void {\n useEffect(() => {\n const root = ref.current\n if (!root) return\n const start = root.querySelector<HTMLElement>(startSelector)\n const end = hasEnd ? root.querySelector<HTMLElement>(endSelector) : null\n\n const measure = () => {\n root.style.setProperty(\n '--scrollbar-inset-start',\n `${start?.offsetHeight ?? 0}px`,\n )\n root.style.setProperty(\n '--scrollbar-inset-end',\n `${end?.offsetHeight ?? 0}px`,\n )\n }\n\n measure()\n if (typeof ResizeObserver === 'undefined') return\n const observer = new ResizeObserver(measure)\n if (start) observer.observe(start)\n if (end) observer.observe(end)\n return () => observer.disconnect()\n }, [endSelector, hasEnd, ref, startSelector])\n}\n",
237
+ "target": "~/packages/ui/src/patterns/collection/shared/hooks/use-scrollbar-insets.ts"
238
+ },
239
+ {
240
+ "path": "patterns/collection/shared/lib/editable-cell.ts",
241
+ "type": "registry:file",
242
+ "content": "export interface EditableCellRow {\n readonly id: string\n readonly index: number\n readonly original: unknown\n}\n\nexport interface EditableCellValueChange {\n columnId: string\n rowId: string\n value: string\n}\n\nexport interface EditableCellMeta {\n label?: string\n placeholder?: string\n getCellError?: (row: EditableCellRow, columnId: string) => string | undefined\n validate?: (value: string, row: EditableCellRow) => string | undefined\n formatValue?: (value: string) => string\n emptyLabel?: string\n getCellLabel?: (columnLabel: string, displayValue: string) => string\n}\n\nexport const DEFAULT_EMPTY_CELL_LABEL = 'Sem valor'\n\nexport function resolveEditableCellLabel(\n columnLabel: string,\n displayValue: string,\n meta: Pick<EditableCellMeta, 'getCellLabel'>,\n): string {\n return meta.getCellLabel\n ? meta.getCellLabel(columnLabel, displayValue)\n : `${columnLabel}: ${displayValue}`\n}\n",
243
+ "target": "~/packages/ui/src/patterns/collection/shared/lib/editable-cell.ts"
244
+ },
245
+ {
246
+ "path": "patterns/collection/shared/lib/end-reached.ts",
247
+ "type": "registry:file",
248
+ "content": "export const DEFAULT_END_REACHED_THRESHOLD = 5\n\ninterface NearEndInput {\n bottomInset: number\n clientHeight: number\n rowHeight: number\n scrollHeight: number\n scrollTop: number\n threshold: number\n}\n\nexport function isNearEnd({\n bottomInset,\n clientHeight,\n rowHeight,\n scrollHeight,\n scrollTop,\n threshold,\n}: NearEndInput) {\n if (clientHeight <= 0) return false\n const remaining = scrollHeight - scrollTop - clientHeight - bottomInset\n return remaining <= Math.max(0, threshold) * rowHeight\n}\n\ninterface FireEndReachedInput {\n firedForCount: number | undefined\n loading: boolean\n nearEnd: boolean\n rowCount: number\n}\n\nexport function shouldFireEndReached({\n firedForCount,\n loading,\n nearEnd,\n rowCount,\n}: FireEndReachedInput) {\n return nearEnd && !loading && rowCount > 0 && firedForCount !== rowCount\n}\n",
249
+ "target": "~/packages/ui/src/patterns/collection/shared/lib/end-reached.ts"
250
+ },
251
+ {
252
+ "path": "patterns/collection/shared/lib/format-value.ts",
253
+ "type": "registry:file",
254
+ "content": "import { isValidDate, parseDateValue } from '@tc96/ui/helpers/date'\n\nlet dateFormatter: Intl.DateTimeFormat | undefined\n\nexport function toStringValue(value: unknown): string {\n if (value === null || value === undefined) return ''\n return String(value)\n}\n\nexport function formatDate(value: unknown): string {\n if (!value) return ''\n const date = parseDateValue(value)\n if (!isValidDate(date)) return toStringValue(value)\n dateFormatter ??= new Intl.DateTimeFormat()\n return dateFormatter.format(date)\n}\n",
255
+ "target": "~/packages/ui/src/patterns/collection/shared/lib/format-value.ts"
256
+ },
257
+ {
258
+ "path": "patterns/collection/shared/lib/group-runs.ts",
259
+ "type": "registry:file",
260
+ "content": "import type { RowData } from '@tanstack/react-table'\n\ninterface GridRow<TData extends RowData> {\n readonly id: string\n readonly original: TData\n}\n\nexport interface GroupRuns {\n groupRowCount: number\n runStarts: boolean[]\n runsThrough: number[]\n}\n\nexport const EMPTY_GROUP_RUNS: GroupRuns = {\n groupRowCount: 0,\n runStarts: [],\n runsThrough: [],\n}\n\nexport function mapRowGroups<TData extends RowData>(\n collectionRows: readonly GridRow<TData>[],\n pageRows: readonly GridRow<TData>[],\n getRowGroup: (row: TData) => string | null,\n) {\n const groups = new Map<string, string | null>()\n for (const row of collectionRows) {\n groups.set(row.id, getRowGroup(row.original))\n }\n for (const row of pageRows) {\n if (!groups.has(row.id)) groups.set(row.id, getRowGroup(row.original))\n }\n return groups\n}\n\nexport function computeGroupRuns<TData extends RowData>(\n collectionRows: readonly GridRow<TData>[],\n groupByRowId: ReadonlyMap<string, string | null>,\n): GroupRuns {\n const runsThrough: number[] = []\n const runStarts: boolean[] = []\n let previousGroup: string | null = null\n let groupRowCount = 0\n for (const row of collectionRows) {\n const group = groupByRowId.get(row.id) ?? null\n const startsRun = Boolean(group && group !== previousGroup)\n if (group && startsRun) {\n groupRowCount += 1\n previousGroup = group\n }\n runsThrough.push(groupRowCount)\n runStarts.push(startsRun)\n }\n return { groupRowCount, runStarts, runsThrough }\n}\n\nexport function countGroupRows<TData extends RowData>(\n pageRows: readonly GridRow<TData>[],\n groupByRowId: ReadonlyMap<string, string | null>,\n) {\n const counts = new Map<string, number>()\n for (const row of pageRows) {\n const group = groupByRowId.get(row.id)\n if (group) counts.set(group, (counts.get(group) ?? 0) + 1)\n }\n return counts\n}\n\nexport function collectGroupRows<TRow extends GridRow<RowData>>(\n pageRows: readonly TRow[],\n groupByRowId: ReadonlyMap<string, string | null>,\n) {\n const rowsByGroup = new Map<string, TRow[]>()\n for (const row of pageRows) {\n const group = groupByRowId.get(row.id)\n if (!group) continue\n const rows = rowsByGroup.get(group)\n if (rows) rows.push(row)\n else rowsByGroup.set(group, [row])\n }\n return rowsByGroup\n}\n\nexport interface GroupSection<TRow> {\n group: string | null\n rows: TRow[]\n}\n\nexport function splitGroupSections<TRow extends GridRow<RowData>>(\n pageRows: readonly TRow[],\n groupByRowId: ReadonlyMap<string, string | null>,\n) {\n const sections: GroupSection<TRow>[] = []\n let current: GroupSection<TRow> | undefined\n for (const row of pageRows) {\n const group = groupByRowId.get(row.id) ?? null\n if (!current || (group && group !== current.group)) {\n current = { group, rows: [] }\n sections.push(current)\n }\n current.rows.push(row)\n }\n return sections\n}\n",
261
+ "target": "~/packages/ui/src/patterns/collection/shared/lib/group-runs.ts"
262
+ },
263
+ {
264
+ "path": "patterns/collection/shared/lib/row-reorder.ts",
265
+ "type": "registry:file",
266
+ "content": "export interface RowMove {\n rowId: string\n fromIndex: number\n toIndex: number\n overRowId: string\n}\n\nexport interface RowDragAnnouncements {\n instructions?: string\n start: (event: { rowId: string; index: number; rowCount: number }) => string\n over?: (event: {\n rowId: string\n index: number\n overRowId: string\n overIndex: number\n rowCount: number\n }) => string\n end: (event: {\n rowId: string\n fromIndex: number\n toIndex: number\n rowCount: number\n canceled: boolean\n }) => string\n}\n\ninterface RowReorderGate {\n enabled: boolean\n grouped: boolean\n loading: boolean\n sorted: boolean\n virtualized: boolean\n}\n\nexport function isRowReorderActive({\n enabled,\n grouped,\n loading,\n sorted,\n virtualized,\n}: RowReorderGate) {\n return enabled && !(grouped || loading || sorted || virtualized)\n}\n\ninterface ResolveRowMoveInput {\n collectionIndexes: readonly number[]\n rowIds: readonly string[]\n sourceId: string\n targetIndex: number\n}\n\nexport function resolveRowMove({\n collectionIndexes,\n rowIds,\n sourceId,\n targetIndex,\n}: ResolveRowMoveInput): RowMove | undefined {\n const sourceIndex = rowIds.indexOf(sourceId)\n const overRowId = rowIds[targetIndex]\n const fromIndex = collectionIndexes[sourceIndex]\n const toIndex = collectionIndexes[targetIndex]\n if (\n sourceIndex < 0 ||\n sourceIndex === targetIndex ||\n overRowId === undefined ||\n fromIndex === undefined ||\n toIndex === undefined\n ) {\n return undefined\n }\n return { fromIndex, overRowId, rowId: sourceId, toIndex }\n}\n",
267
+ "target": "~/packages/ui/src/patterns/collection/shared/lib/row-reorder.ts"
268
+ },
269
+ {
270
+ "path": "patterns/collection/types/collection.ts",
271
+ "type": "registry:file",
272
+ "content": "import type { ReactNode } from 'react'\n\nexport type CollectionGroupingId = string\nexport type CollectionDensity =\n | 'compact'\n | 'short'\n | 'medium'\n | 'tall'\n | 'extra-tall'\nexport type CollectionLayout =\n | 'calendar'\n | 'datagrid'\n | 'datatable'\n | 'gallery'\n | 'kanban'\n | 'list'\n\nexport interface CollectionOption {\n icon?: ReactNode\n id: string\n label: string\n}\n\nexport interface CollectionGroupingDimension<TRecord = unknown> {\n getGroupId: (record: TRecord) => string | null\n id: CollectionGroupingId\n label: string\n options: readonly CollectionOption[]\n setGroupId?: (record: TRecord, groupId: string | null) => TRecord\n /** Label for items whose getGroupId returns null. Defaults to a generic \"unassigned\". */\n unassignedLabel?: string\n}\n\nexport interface CollectionDefinition<TRecord = unknown> {\n getKey: (record: TRecord) => string | number\n getLabel: (record: TRecord) => string\n groupings: readonly CollectionGroupingDimension<TRecord>[]\n records: readonly TRecord[]\n}\n\nexport interface CollectionPreferences {\n /** `null` é a coleção sem agrupamento, que a Lista e o DataGrid sabem renderizar. */\n groupBy: CollectionGroupingId | null\n layout: CollectionLayout\n}\n\nexport interface CollectionRecordChange<TRecord = unknown> {\n grouping: CollectionGroupingId\n record: TRecord\n previousRecord: TRecord\n reason: 'grouping'\n}\n\nexport type CollectionPreferencesChangeReason = 'grouping' | 'layout'\n\nexport interface CollectionPreferencesChangeDetails {\n reason: CollectionPreferencesChangeReason\n}\n\nexport interface CollectionGroup<TRecord = unknown> extends CollectionOption {\n count: number\n grouping: CollectionGroupingId\n records: readonly TRecord[]\n value: string | null\n}\n",
273
+ "target": "~/packages/ui/src/patterns/collection/types/collection.ts"
274
+ },
275
+ {
276
+ "path": "patterns/data-grid/components/data-grid-add-row.tsx",
277
+ "type": "registry:file",
278
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport { PlusIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\n\nexport interface DataGridAddRowProps {\n ariaRowIndex: number\n label: string\n minWidth: number\n onAdd: () => void | Promise<void>\n}\n\nexport function DataGridAddRow({\n ariaRowIndex,\n label,\n minWidth,\n onAdd,\n}: DataGridAddRowProps) {\n return (\n <div\n className=\"sticky bottom-0 z-10 grid border-t bg-background\"\n data-slot=\"data-grid-add-row-group\"\n role=\"rowgroup\"\n >\n <div\n aria-rowindex={ariaRowIndex}\n className=\"flex min-h-9 w-full\"\n role=\"row\"\n style={{ minWidth }}\n tabIndex={-1}\n >\n <div\n className=\"flex grow items-center bg-muted/30\"\n role=\"gridcell\"\n tabIndex={-1}\n >\n <Button\n aria-label={label}\n className=\"h-full w-full justify-start rounded-none px-3\"\n onClick={() => void onAdd()}\n variant=\"ghost\"\n >\n <PlusIcon aria-hidden=\"true\" />\n {label}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n",
279
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-add-row.tsx"
280
+ },
281
+ {
282
+ "path": "patterns/data-grid/components/data-grid-body-cell.tsx",
283
+ "type": "registry:file",
284
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport { type Cell, flexRender, type RowData } from '@tanstack/react-table'\nimport { cn } from '@tc96/utils'\nimport { memo } from 'react'\nimport type { CellInteractions } from '../hooks/use-data-grid-cell-events'\nimport type { ColumnLayout } from '../lib/column-layout'\nimport { CELL_DENSITY } from '../lib/constants'\nimport type {\n DataGridFeatures,\n DataGridTableMeta,\n} from '../lib/data-grid-features'\nimport type { CollectionDensity } from '../types'\n\nexport interface DataGridBodyCellProps<TData extends RowData> {\n cell: Cell<DataGridFeatures, TData, unknown>\n columnIndex: number\n density: CollectionDensity\n interactions: CellInteractions\n isFocused: boolean\n isSelected: boolean\n layout: ColumnLayout | undefined\n rowExpanded?: boolean\n rowSelected: boolean\n showFocus: boolean\n canSelect: boolean\n meta: DataGridTableMeta | undefined\n}\n\nfunction DataGridBodyCellView<TData extends RowData>({\n cell,\n columnIndex,\n density,\n interactions,\n isFocused,\n isSelected,\n layout,\n showFocus,\n}: DataGridBodyCellProps<TData>) {\n const columnId = cell.column.id\n\n return (\n <div\n aria-colindex={columnIndex + 1}\n aria-selected={isSelected}\n className={cn(\n 'flex min-w-0 items-center overflow-hidden border-e outline-none last:border-e-0 data-[pinned]:bg-background data-[selected=true]:bg-primary/10 data-[focused=true]:ring-1 data-[focused=true]:ring-inset data-[focused=true]:ring-ring',\n CELL_DENSITY[density],\n )}\n data-column-id={columnId}\n data-focused={showFocus ? 'true' : undefined}\n data-pinned={layout?.pinned || undefined}\n data-selected={isSelected ? 'true' : undefined}\n data-slot=\"data-grid-cell\"\n onClick={interactions.onClick}\n onClickCapture={interactions.onClickCapture}\n onKeyDown={interactions.onKeyDown}\n onMouseDownCapture={interactions.onMouseDownCapture}\n onPointerDownCapture={interactions.onPointerDownCapture}\n role=\"gridcell\"\n style={layout?.style}\n tabIndex={isFocused ? 0 : -1}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </div>\n )\n}\n\nexport const DataGridBodyCell = memo(\n DataGridBodyCellView,\n) as typeof DataGridBodyCellView\n",
285
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-body-cell.tsx"
286
+ },
287
+ {
288
+ "path": "patterns/data-grid/components/data-grid-body.tsx",
289
+ "type": "registry:file",
290
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport type { VirtualItem } from '@tanstack/react-virtual'\nimport type { ReactNode } from 'react'\nimport type { BodyEntry, RowBodyEntry } from '../lib/body-entries'\nimport type { ColumnLayouts } from '../lib/column-layout'\nimport { ROW_HEIGHT } from '../lib/constants'\nimport type { DataGridColumn } from '../lib/data-grid-features'\nimport { resolveAriaExpanded } from '../lib/row-tree'\nimport type { CellSelection } from '../lib/selection'\nimport { createSkeletonRowIds } from '../lib/skeleton'\nimport type { CollectionDensity } from '../types'\nimport { DataGridEmptyRow } from './data-grid-empty-row'\nimport {\n type DataGridGroupCellContext,\n DataGridGroupRow,\n} from './data-grid-group-row'\nimport { DataGridRow } from './data-grid-row'\nimport {\n type DataGridRowSkeletonAnatomy,\n DataGridSkeletonRows,\n} from './data-grid-skeleton-rows'\n\nexport interface DataGridBodyProps<TData extends RowData> {\n columnIds: readonly string[]\n columnLayouts: ColumnLayouts\n columns: readonly DataGridColumn<TData>[]\n density: CollectionDensity\n emptyMessage: string\n entries: readonly BodyEntry<TData>[]\n expandable: boolean\n focusedColumnId?: string\n focusedRowId?: string\n getRowSelected?: (row: TData) => boolean\n hasInteracted: boolean\n headerRowCount: number\n loading: boolean\n labelColumnId?: string\n loadingMoreRowCount: number\n loadingMoreRowIndexOffset: number\n loadingAnatomy?: DataGridRowSkeletonAnatomy\n loadingCount: number\n loadingLabel: string\n minWidth: number\n onToggleGroup: (group: string, collapsed: boolean) => void\n getGroupToggleLabel?: (group: string, collapsed: boolean) => string\n pageRowCount: number\n renderGroupCell?: (context: DataGridGroupCellContext<TData>) => ReactNode\n selection: CellSelection\n totalSize?: number\n virtualItems: readonly VirtualItem[]\n virtualized: boolean\n}\n\nexport function DataGridBody<TData extends RowData>({\n columnIds,\n columnLayouts,\n columns,\n density,\n emptyMessage,\n entries,\n expandable,\n focusedColumnId,\n focusedRowId,\n getRowSelected,\n hasInteracted,\n headerRowCount,\n loading,\n labelColumnId,\n loadingMoreRowCount,\n loadingMoreRowIndexOffset,\n loadingAnatomy,\n loadingCount,\n loadingLabel,\n minWidth,\n onToggleGroup,\n pageRowCount,\n renderGroupCell,\n getGroupToggleLabel,\n selection,\n totalSize,\n virtualItems,\n virtualized,\n}: DataGridBodyProps<TData>) {\n function renderRow(\n entry: RowBodyEntry<TData>,\n virtual?: { size: number; start: number },\n ) {\n const { row } = entry\n const focusedHere = focusedRowId === row.id\n return (\n <DataGridRow\n ariaLevel={expandable ? row.depth + 1 : undefined}\n ariaRowIndex={entry.ariaRowIndex}\n expanded={resolveAriaExpanded({\n canExpand: expandable && row.getCanExpand(),\n expandable,\n expanded: expandable && row.getIsExpanded(),\n })}\n focusedColumnId={focusedHere ? focusedColumnId : undefined}\n interacted={focusedHere && hasInteracted}\n key={entry.key}\n row={row}\n selected={\n Boolean(getRowSelected?.(row.original)) || row.getIsSelected()\n }\n selectedColumnIds={selection.get(row.id)}\n virtualSize={virtual?.size}\n virtualStart={virtual?.start}\n />\n )\n }\n\n function renderContent() {\n if (loading) {\n return (\n <DataGridSkeletonRows\n label={loadingLabel}\n {...(loadingAnatomy ? { anatomy: loadingAnatomy } : {})}\n columnIds={columnIds}\n columnLayouts={columnLayouts}\n density={density}\n headerRowCount={headerRowCount}\n rowIds={createSkeletonRowIds(loadingCount)}\n />\n )\n }\n if (pageRowCount === 0) {\n return (\n <DataGridEmptyRow\n ariaRowIndex={headerRowCount + 1}\n message={emptyMessage}\n />\n )\n }\n if (virtualized) {\n return (\n <>\n {virtualItems.map((item) => {\n const entry = entries[item.index]\n return entry?.kind === 'row'\n ? renderRow(entry, { size: item.size, start: item.start })\n : null\n })}\n {renderLoadingMore(\n (totalSize ?? 0) - loadingMoreRowCount * ROW_HEIGHT[density],\n )}\n </>\n )\n }\n return (\n <>\n {entries.map((entry) =>\n entry.kind === 'group' ? (\n <DataGridGroupRow\n ariaRowIndex={entry.ariaRowIndex}\n collapsed={entry.collapsed}\n columnLayouts={columnLayouts}\n columns={columns}\n count={entry.count}\n group={entry.group}\n key={entry.key}\n labelColumnId={labelColumnId}\n getGroupToggleLabel={getGroupToggleLabel}\n onToggle={onToggleGroup}\n renderGroupCell={renderGroupCell}\n rows={entry.rows}\n />\n ) : (\n renderRow(entry)\n ),\n )}\n {renderLoadingMore()}\n </>\n )\n }\n\n function renderLoadingMore(virtualStart?: number) {\n if (loadingMoreRowCount === 0) return null\n return (\n <DataGridSkeletonRows\n label={loadingLabel}\n {...(loadingAnatomy ? { anatomy: loadingAnatomy } : {})}\n columnIds={columnIds}\n columnLayouts={columnLayouts}\n density={density}\n headerRowCount={headerRowCount}\n loadingMore\n rowIds={createSkeletonRowIds(loadingMoreRowCount)}\n rowIndexOffset={loadingMoreRowIndexOffset}\n virtualStart={virtualStart}\n />\n )\n }\n\n return (\n <div\n className=\"relative grid\"\n data-slot=\"data-grid-body\"\n data-virtualized={virtualized ? 'true' : undefined}\n role=\"rowgroup\"\n style={{ height: virtualized ? totalSize : undefined, minWidth }}\n >\n {renderContent()}\n </div>\n )\n}\n",
291
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-body.tsx"
292
+ },
293
+ {
294
+ "path": "patterns/data-grid/components/data-grid-cell.tsx",
295
+ "type": "registry:file",
296
+ "content": "'use client'\n\nimport { CheckIcon, MinusIcon } from '@phosphor-icons/react'\nimport type { CellContext, RowData } from '@tanstack/react-table'\nimport { Badge } from '@tc96/ui/badge'\nimport {\n Select,\n SelectItem,\n SelectPopup,\n SelectPrimitive,\n SelectValue,\n} from '@tc96/ui/select'\nimport { cn } from '@tc96/utils'\nimport {\n formatDate,\n toStringValue,\n} from '../../collection/shared/lib/format-value'\nimport { CELL_ALIGN } from '../lib/constants'\nimport type { DataGridFeatures } from '../lib/data-grid-features'\nimport type { DataGridColumnMeta, DataGridSelectOption } from '../types'\nimport { DataGridInputCell } from './data-grid-input-cell'\n\nconst optionToLabel = (option: DataGridSelectOption) => option.label\nconst optionToValue = (option: DataGridSelectOption) => option.value\n\nexport function DataGridCell<TData extends RowData>({\n context,\n}: {\n context: CellContext<DataGridFeatures, TData, unknown>\n}) {\n const { column, getValue, row, table } = context\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n const variant = meta.variant ?? 'text'\n const align = CELL_ALIGN[meta.align ?? 'start']\n const value = getValue()\n const canEdit =\n Boolean(meta.editable) &&\n Boolean(table.options.meta?.onDataGridCellValueChange)\n\n switch (variant) {\n case 'checkbox': {\n const checked = Boolean(value)\n return (\n <span className={cn('flex items-center text-muted-foreground', align)}>\n {checked ? (\n <CheckIcon aria-hidden=\"true\" className=\"size-4\" />\n ) : (\n <MinusIcon aria-hidden=\"true\" className=\"size-4 opacity-40\" />\n )}\n <span className=\"sr-only\">{checked ? 'Marcado' : 'Desmarcado'}</span>\n </span>\n )\n }\n\n case 'select': {\n const options = meta.options ?? []\n const selectedOption = options.find(\n (option) => option.value === toStringValue(value),\n )\n const onValueChange = table.options.meta?.onDataGridCellValueChange\n\n if (meta.editable && onValueChange && options.length > 0) {\n const accessibleValue =\n selectedOption?.label ??\n meta.placeholder ??\n meta.emptyLabel ??\n 'Sem valor'\n return (\n <Select\n itemToStringLabel={optionToLabel}\n itemToStringValue={optionToValue}\n items={options}\n onValueChange={(option) => {\n if (!option) return\n onValueChange({\n columnId: column.id,\n rowId: row.id,\n value: option.value,\n })\n }}\n value={selectedOption ?? null}\n >\n <SelectPrimitive.Trigger\n aria-label={\n meta.getCellLabel\n ? meta.getCellLabel(meta.label ?? column.id, accessibleValue)\n : `${meta.label ?? column.id}: ${accessibleValue}`\n }\n data-grid-select-trigger\n render={\n <Badge\n className=\"max-w-full\"\n render={<button type=\"button\" />}\n variant={meta.badgeVariant ?? 'secondary'}\n />\n }\n >\n <SelectValue\n className=\"min-w-0\"\n placeholder={meta.placeholder ?? 'Selecionar'}\n />\n </SelectPrimitive.Trigger>\n <SelectPopup alignItemWithTrigger={false}>\n {options.map((option) => (\n <SelectItem key={option.value} value={option}>\n {option.label}\n </SelectItem>\n ))}\n </SelectPopup>\n </Select>\n )\n }\n\n return (\n <span className={cn('block truncate px-1', align)}>\n {selectedOption?.label ?? toStringValue(value)}\n </span>\n )\n }\n\n case 'date': {\n return (\n <span className={cn('block truncate px-1', align)}>\n {formatDate(value)}\n </span>\n )\n }\n\n case 'badge': {\n if (value === null || value === undefined || value === '') {\n return (\n <span className=\"px-1 text-muted-foreground/72\">\n {meta.placeholder ?? ''}\n </span>\n )\n }\n const label =\n meta.options?.find((option) => option.value === toStringValue(value))\n ?.label ?? toStringValue(value)\n return (\n <span className={cn('flex', align)}>\n <Badge variant={meta.badgeVariant ?? 'secondary'}>{label}</Badge>\n </span>\n )\n }\n\n case 'number': {\n if (canEdit) return <DataGridInputCell context={context} numeric />\n return (\n <span className={cn('block truncate px-1 tabular-nums', align)}>\n {toStringValue(value)}\n </span>\n )\n }\n\n default: {\n if (canEdit && variant === 'text') {\n return <DataGridInputCell context={context} numeric={false} />\n }\n return (\n <span className={cn('block truncate px-1', align)}>\n {toStringValue(value)}\n </span>\n )\n }\n }\n}\n",
297
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-cell.tsx"
298
+ },
299
+ {
300
+ "path": "patterns/data-grid/components/data-grid-column-header.tsx",
301
+ "type": "registry:file",
302
+ "content": "'use client'\n\nimport { CaretDownIcon, CaretUpIcon } from '@phosphor-icons/react'\nimport { flexRender, type RowData } from '@tanstack/react-table'\nimport { Menu, MenuTrigger } from '@tc96/ui/menu'\nimport { cn } from '@tc96/utils'\nimport { HEADER_ALIGN } from '../lib/constants'\nimport type { DataGridHeader } from '../lib/data-grid-features'\nimport type { DataGridColumnMeta } from '../types'\nimport { DataGridColumnMenu } from './data-grid-column-menu'\nimport { DataGridColumnTypeIcon } from './data-grid-column-type-icon'\nimport { DataGridResizeHandle } from './data-grid-resize-handle'\n\nexport function DataGridColumnHeader<TData extends RowData>({\n header,\n}: {\n header: DataGridHeader<TData>\n}) {\n const { column } = header\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n const align = HEADER_ALIGN[meta.align ?? 'start']\n const sorted = column.getIsSorted()\n const table = header.getContext().table\n const visibleLeafColumns = table.getVisibleLeafColumns()\n const isLastColumn =\n visibleLeafColumns[visibleLeafColumns.length - 1]?.id === column.id\n const label = flexRender(column.columnDef.header, header.getContext())\n const showMenu =\n column.getCanSort() || column.getCanHide() || column.getCanPin()\n\n return (\n <div className={cn('flex size-full min-w-0 items-center gap-1', align)}>\n {showMenu ? (\n <Menu modal={false}>\n <MenuTrigger\n aria-label={`Opções da coluna ${meta.label ?? column.id}`}\n className={cn(\n 'flex size-full min-w-0 items-center gap-1.5 rounded-sm px-1 font-medium outline-none hover:bg-accent/40 focus-visible:ring-1 focus-visible:ring-ring data-popup-open:bg-accent/40',\n align,\n )}\n >\n {meta.type ? (\n <DataGridColumnTypeIcon aria-hidden=\"true\" type={meta.type} />\n ) : null}\n <span className=\"truncate\">{label}</span>\n {sorted === 'asc' ? (\n <CaretUpIcon\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 text-muted-foreground\"\n />\n ) : sorted === 'desc' ? (\n <CaretDownIcon\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 text-muted-foreground\"\n />\n ) : null}\n <CaretDownIcon\n aria-hidden=\"true\"\n className=\"ms-auto size-3.5 shrink-0 text-muted-foreground\"\n />\n </MenuTrigger>\n <DataGridColumnMenu column={column} table={table} />\n </Menu>\n ) : (\n <div\n className={cn(\n 'flex min-w-0 flex-1 items-center gap-1.5 truncate px-1 font-medium',\n align,\n )}\n >\n {meta.type ? (\n <DataGridColumnTypeIcon aria-hidden=\"true\" type={meta.type} />\n ) : null}\n <span className=\"truncate\">{label}</span>\n </div>\n )}\n\n {column.getCanResize() ? (\n <DataGridResizeHandle\n column={column}\n header={header}\n isLastColumn={isLastColumn}\n table={table}\n />\n ) : null}\n </div>\n )\n}\n",
303
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-column-header.tsx"
304
+ },
305
+ {
306
+ "path": "patterns/data-grid/components/data-grid-column-menu.tsx",
307
+ "type": "registry:file",
308
+ "content": "'use client'\n\nimport {\n ArrowLeftIcon,\n ArrowRightIcon,\n CaretDownIcon,\n CaretUpDownIcon,\n CaretUpIcon,\n EyeSlashIcon,\n PushPinIcon,\n PushPinSlashIcon,\n} from '@phosphor-icons/react'\nimport type { RowData } from '@tanstack/react-table'\nimport { MenuItem, MenuPopup, MenuSeparator } from '@tc96/ui/menu'\nimport type { DataGridColumn, DataGridTable } from '../lib/data-grid-features'\nimport { moveColumn } from '../lib/move-column'\n\nexport interface DataGridColumnMenuProps<TData extends RowData> {\n column: DataGridColumn<TData>\n table: DataGridTable<TData>\n}\n\nexport function DataGridColumnMenu<TData extends RowData>({\n column,\n table,\n}: DataGridColumnMenuProps<TData>) {\n const canSort = column.getCanSort()\n const canHide = column.getCanHide()\n const canPin = column.getCanPin()\n const sorted = column.getIsSorted()\n\n return (\n <MenuPopup align=\"end\">\n {canSort ? (\n <>\n <MenuItem onClick={() => column.toggleSorting(false)}>\n <CaretUpIcon aria-hidden=\"true\" />\n Ordem crescente\n </MenuItem>\n <MenuItem onClick={() => column.toggleSorting(true)}>\n <CaretDownIcon aria-hidden=\"true\" />\n Ordem decrescente\n </MenuItem>\n {sorted ? (\n <MenuItem onClick={() => column.clearSorting()}>\n <CaretUpDownIcon aria-hidden=\"true\" />\n Limpar ordenação\n </MenuItem>\n ) : null}\n <MenuSeparator />\n </>\n ) : null}\n <MenuItem onClick={() => moveColumn(table, column.id, -1)}>\n <ArrowLeftIcon aria-hidden=\"true\" />\n Mover para esquerda\n </MenuItem>\n <MenuItem onClick={() => moveColumn(table, column.id, 1)}>\n <ArrowRightIcon aria-hidden=\"true\" />\n Mover para direita\n </MenuItem>\n {canPin ? (\n <>\n <MenuSeparator />\n {column.getIsPinned() ? (\n <MenuItem onClick={() => column.pin(false)}>\n <PushPinSlashIcon aria-hidden=\"true\" />\n Desafixar coluna\n </MenuItem>\n ) : (\n <>\n <MenuItem onClick={() => column.pin('start')}>\n <PushPinIcon aria-hidden=\"true\" />\n Fixar à esquerda\n </MenuItem>\n <MenuItem onClick={() => column.pin('end')}>\n <PushPinIcon aria-hidden=\"true\" />\n Fixar à direita\n </MenuItem>\n </>\n )}\n </>\n ) : null}\n {canHide ? (\n <>\n <MenuSeparator />\n <MenuItem onClick={() => column.toggleVisibility(false)}>\n <EyeSlashIcon aria-hidden=\"true\" />\n Ocultar coluna\n </MenuItem>\n </>\n ) : null}\n </MenuPopup>\n )\n}\n",
309
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-column-menu.tsx"
310
+ },
311
+ {
312
+ "path": "patterns/data-grid/components/data-grid-column-type-icon.tsx",
313
+ "type": "registry:file",
314
+ "content": "'use client'\n\nimport {\n ArrowSquareOutIcon,\n CalculatorIcon,\n CalendarBlankIcon,\n CalendarPlusIcon,\n CheckSquareIcon,\n ClockCounterClockwiseIcon,\n CursorClickIcon,\n EnvelopeSimpleIcon,\n FingerprintIcon,\n HashIcon,\n LinkSimpleIcon,\n ListBulletsIcon,\n MapPinIcon,\n PaperclipIcon,\n PhoneIcon,\n type Icon as PhosphorIcon,\n RadioButtonIcon,\n SigmaIcon,\n TagSimpleIcon,\n TextHOneIcon,\n TextTIcon,\n UserGearIcon,\n UserIcon,\n UserPlusIcon,\n} from '@phosphor-icons/react'\nimport type { DataGridColumnType } from '../types'\n\nexport const DATA_GRID_COLUMN_TYPE_ICONS = {\n title: TextHOneIcon,\n text: TextTIcon,\n number: HashIcon,\n select: ListBulletsIcon,\n 'multi-select': TagSimpleIcon,\n status: RadioButtonIcon,\n date: CalendarBlankIcon,\n formula: SigmaIcon,\n relation: LinkSimpleIcon,\n rollup: CalculatorIcon,\n person: UserIcon,\n file: PaperclipIcon,\n checkbox: CheckSquareIcon,\n url: ArrowSquareOutIcon,\n email: EnvelopeSimpleIcon,\n phone: PhoneIcon,\n 'created-time': CalendarPlusIcon,\n 'created-by': UserPlusIcon,\n 'last-edited-time': ClockCounterClockwiseIcon,\n 'last-edited-by': UserGearIcon,\n button: CursorClickIcon,\n id: FingerprintIcon,\n place: MapPinIcon,\n} satisfies Record<DataGridColumnType, PhosphorIcon>\n\nexport function DataGridColumnTypeIcon({ type }: { type: DataGridColumnType }) {\n const Icon = DATA_GRID_COLUMN_TYPE_ICONS[type]\n\n return (\n <Icon\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 text-muted-foreground\"\n data-column-type={type}\n data-slot=\"data-grid-column-type-icon\"\n />\n )\n}\n",
315
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-column-type-icon.tsx"
316
+ },
317
+ {
318
+ "path": "patterns/data-grid/components/data-grid-columns-submenu.tsx",
319
+ "type": "registry:file",
320
+ "content": "'use client'\n\nimport { ColumnsIcon } from '@phosphor-icons/react'\nimport type { RowData } from '@tanstack/react-table'\nimport {\n MenuCheckboxItem,\n MenuSub,\n MenuSubPopup,\n MenuSubTrigger,\n} from '@tc96/ui/menu'\nimport type React from 'react'\nimport type { DataGridTable } from '../lib/data-grid-features'\nimport type { DataGridColumnMeta } from '../types'\n\nexport interface DataGridColumnsSubmenuProps<TData extends RowData> {\n label?: string\n table: DataGridTable<TData>\n}\n\nexport function DataGridColumnsSubmenu<TData extends RowData>({\n label = 'Colunas',\n table,\n}: DataGridColumnsSubmenuProps<TData>): React.ReactElement | null {\n const columns = table\n .getAllLeafColumns()\n .filter((column) => column.getCanHide())\n if (columns.length === 0) return null\n\n return (\n <MenuSub>\n <MenuSubTrigger>\n <ColumnsIcon aria-hidden=\"true\" />\n {label}\n </MenuSubTrigger>\n <MenuSubPopup>\n {columns.map((column) => {\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n return (\n <MenuCheckboxItem\n checked={column.getIsVisible()}\n closeOnClick={false}\n key={column.id}\n onCheckedChange={(checked) =>\n column.toggleVisibility(Boolean(checked))\n }\n >\n {meta.label ?? column.id}\n </MenuCheckboxItem>\n )\n })}\n </MenuSubPopup>\n </MenuSub>\n )\n}\n",
321
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-columns-submenu.tsx"
322
+ },
323
+ {
324
+ "path": "patterns/data-grid/components/data-grid-condition-filters.tsx",
325
+ "type": "registry:file",
326
+ "content": "'use client'\n\nimport { DotsThreeVerticalIcon, FunnelSimpleIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport {\n Command,\n CommandEmpty,\n CommandInput,\n CommandItem,\n CommandList,\n} from '@tc96/ui/command'\nimport { Group, GroupText } from '@tc96/ui/group'\nimport {\n Menu,\n MenuItem,\n MenuPopup,\n MenuRadioGroup,\n MenuRadioItem,\n MenuTrigger,\n} from '@tc96/ui/menu'\nimport { Popover, PopoverPopup, PopoverTrigger } from '@tc96/ui/popover'\nimport { cn } from '@tc96/utils'\nimport {\n type ComponentProps,\n type ReactElement,\n type ReactNode,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport {\n changeConditionOperator,\n createCondition,\n type DataGridCondition,\n type DataGridConditionField,\n type DataGridConditionOperator,\n getConditionOperators,\n} from '../lib/data-grid-conditions'\nimport {\n DataGridConditionValue,\n type DataGridConditionValueLabels,\n} from './data-grid-condition-value'\n\nexport interface DataGridConditionFilterField extends DataGridConditionField {\n icon?: ReactNode\n}\n\nexport interface DataGridConditionFilterLabels\n extends DataGridConditionValueLabels {\n addFilter: string\n clearFilters: string\n condition: (field: string) => string\n conditionActions: (field: string) => string\n noFields: string\n removeCondition: string\n searchFields: string\n}\n\nexport interface DataGridConditionFiltersProps\n extends Omit<ComponentProps<'div'>, 'children' | 'onChange'> {\n conditions: readonly DataGridCondition[]\n fields: readonly DataGridConditionFilterField[]\n formatValue?: (field: DataGridConditionField, value: string) => string\n labels: DataGridConditionFilterLabels\n onConditionsChange: (conditions: DataGridCondition[]) => void\n operatorLabels: Record<DataGridConditionOperator, string>\n}\n\ninterface FieldItem {\n label: string\n value: string\n}\n\ninterface ConditionChipProps {\n condition: DataGridCondition\n field: DataGridConditionFilterField\n formatValue: DataGridConditionFiltersProps['formatValue']\n labels: DataGridConditionFilterLabels\n onChange: (condition: DataGridCondition) => void\n onRemove: () => void\n operatorLabels: DataGridConditionFiltersProps['operatorLabels']\n}\n\nfunction ConditionChip({\n condition,\n field,\n formatValue,\n labels,\n onChange,\n onRemove,\n operatorLabels,\n}: ConditionChipProps) {\n return (\n <Group\n aria-label={labels.condition(field.label)}\n data-slot=\"data-grid-condition\"\n >\n <GroupText>\n {field.icon}\n {field.label}\n </GroupText>\n <Menu>\n <MenuTrigger render={<Button size=\"sm\" variant=\"outline\" />}>\n {operatorLabels[condition.operator]}\n </MenuTrigger>\n <MenuPopup align=\"start\">\n <MenuRadioGroup\n onValueChange={(next) =>\n onChange(\n changeConditionOperator(\n condition,\n next as DataGridConditionOperator,\n ),\n )\n }\n value={condition.operator}\n >\n {getConditionOperators(field.kind).map((operator) => (\n <MenuRadioItem key={operator} value={operator}>\n {operatorLabels[operator]}\n </MenuRadioItem>\n ))}\n </MenuRadioGroup>\n </MenuPopup>\n </Menu>\n <DataGridConditionValue\n condition={condition}\n field={field}\n formatValue={formatValue}\n labels={labels}\n onValueChange={(value) => onChange({ ...condition, value })}\n />\n <Menu>\n <MenuTrigger\n render={\n <Button\n aria-label={labels.conditionActions(field.label)}\n size=\"icon-sm\"\n variant=\"outline\"\n />\n }\n >\n <DotsThreeVerticalIcon aria-hidden=\"true\" />\n </MenuTrigger>\n <MenuPopup align=\"end\">\n <MenuItem onClick={onRemove}>{labels.removeCondition}</MenuItem>\n </MenuPopup>\n </Menu>\n </Group>\n )\n}\n\nexport function DataGridConditionFilters({\n className,\n conditions,\n fields,\n formatValue,\n labels,\n onConditionsChange,\n operatorLabels,\n ...props\n}: DataGridConditionFiltersProps): ReactElement {\n const [open, setOpen] = useState(false)\n const idPrefix = useId()\n const counter = useRef(0)\n const items = useMemo<FieldItem[]>(\n () =>\n fields.map((field) => ({ label: field.label, value: field.columnId })),\n [fields],\n )\n const fieldByColumn = useMemo(\n () => new Map(fields.map((field) => [field.columnId, field])),\n [fields],\n )\n\n const addCondition = (columnId: string) => {\n const field = fieldByColumn.get(columnId)\n if (!field) return\n counter.current += 1\n setOpen(false)\n onConditionsChange([\n ...conditions,\n createCondition(field, `${idPrefix}-${counter.current}`),\n ])\n }\n\n return (\n <div\n className={cn('flex flex-wrap items-center gap-2', className)}\n data-slot=\"data-grid-condition-filters\"\n {...props}\n >\n {conditions.map((condition) => {\n const field = fieldByColumn.get(condition.columnId)\n if (!field) return null\n return (\n <ConditionChip\n condition={condition}\n field={field}\n formatValue={formatValue}\n key={condition.id}\n labels={labels}\n onChange={(next) =>\n onConditionsChange(\n conditions.map((entry) =>\n entry.id === next.id ? next : entry,\n ),\n )\n }\n onRemove={() =>\n onConditionsChange(\n conditions.filter((entry) => entry.id !== condition.id),\n )\n }\n operatorLabels={operatorLabels}\n />\n )\n })}\n {fields.length > 0 ? (\n <Popover onOpenChange={setOpen} open={open}>\n <PopoverTrigger render={<Button size=\"sm\" variant=\"outline\" />}>\n <FunnelSimpleIcon aria-hidden=\"true\" />\n {labels.addFilter}\n </PopoverTrigger>\n <PopoverPopup\n align=\"start\"\n aria-label={labels.addFilter}\n className=\"w-64 **:data-[slot=popover-viewport]:p-1\"\n >\n <Command items={items}>\n <CommandInput\n aria-label={labels.searchFields}\n placeholder={labels.searchFields}\n />\n <CommandEmpty>{labels.noFields}</CommandEmpty>\n <CommandList>\n {(item: FieldItem) => (\n <CommandItem\n key={item.value}\n onClick={() => addCondition(item.value)}\n value={item}\n >\n {fieldByColumn.get(item.value)?.icon}\n {item.label}\n </CommandItem>\n )}\n </CommandList>\n </Command>\n </PopoverPopup>\n </Popover>\n ) : null}\n {conditions.length > 0 ? (\n <Button\n onClick={() => onConditionsChange([])}\n size=\"sm\"\n variant=\"ghost\"\n >\n {labels.clearFilters}\n </Button>\n ) : null}\n </div>\n )\n}\n",
327
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-condition-filters.tsx"
328
+ },
329
+ {
330
+ "path": "patterns/data-grid/components/data-grid-condition-value.tsx",
331
+ "type": "registry:file",
332
+ "content": "'use client'\n\nimport { Badge } from '@tc96/ui/badge'\nimport { Button } from '@tc96/ui/button'\nimport { Input } from '@tc96/ui/input'\nimport {\n Menu,\n MenuCheckboxItem,\n MenuPopup,\n MenuRadioGroup,\n MenuRadioItem,\n MenuTrigger,\n} from '@tc96/ui/menu'\nimport { Popover, PopoverPopup, PopoverTrigger } from '@tc96/ui/popover'\nimport { type ReactElement, useState } from 'react'\nimport type {\n DataGridCondition,\n DataGridConditionField,\n} from '../lib/data-grid-conditions'\n\nexport interface DataGridConditionValueLabels {\n editValue: (field: string) => string\n noValue: string\n rangeFrom: string\n rangeSeparator: string\n rangeTo: string\n valuePlaceholder: string\n}\n\nexport interface DataGridConditionValueProps {\n condition: DataGridCondition\n field: DataGridConditionField\n formatValue?: (field: DataGridConditionField, value: string) => string\n labels: DataGridConditionValueLabels\n onValueChange: (value: readonly string[]) => void\n}\n\nconst INPUT_TYPES = { date: 'date', number: 'number', text: 'text' } as const\n\nfunction labelOf(\n field: DataGridConditionField,\n value: string,\n formatValue: DataGridConditionValueProps['formatValue'],\n) {\n if (formatValue) return formatValue(field, value)\n return field.options?.find((option) => option.value === value)?.label ?? value\n}\n\nfunction ValueSummary({\n condition,\n field,\n formatValue,\n labels,\n}: Omit<DataGridConditionValueProps, 'onValueChange'>) {\n const entries = condition.value.filter((entry) => entry.trim() !== '')\n if (entries.length === 0) {\n return <span className=\"text-muted-foreground\">{labels.noValue}</span>\n }\n const texts = entries.map((entry) => labelOf(field, entry, formatValue))\n if (condition.operator === 'between' && texts.length === 2) {\n return (\n <>\n <span>{texts[0]}</span>\n <span className=\"text-muted-foreground\">{labels.rangeSeparator}</span>\n <span>{texts[1]}</span>\n </>\n )\n }\n if (condition.operator === 'is-any-of') {\n return (\n <>\n {texts.map((text) => (\n <Badge key={text} variant=\"secondary\">\n {text}\n </Badge>\n ))}\n </>\n )\n }\n return <span className=\"truncate\">{texts[0]}</span>\n}\n\nfunction OptionValue(props: DataGridConditionValueProps) {\n const { condition, field, labels, onValueChange } = props\n const options = field.options ?? []\n const multiple = condition.operator === 'is-any-of'\n\n return (\n <Menu>\n <MenuTrigger render={<Button size=\"sm\" variant=\"outline\" />}>\n <ValueSummary {...props} />\n </MenuTrigger>\n <MenuPopup align=\"start\" aria-label={labels.editValue(field.label)}>\n {multiple ? (\n options.map((option) => (\n <MenuCheckboxItem\n checked={condition.value.includes(option.value)}\n key={option.value}\n onCheckedChange={(checked) =>\n onValueChange(\n checked\n ? [...condition.value, option.value]\n : condition.value.filter((entry) => entry !== option.value),\n )\n }\n >\n {option.label}\n </MenuCheckboxItem>\n ))\n ) : (\n <MenuRadioGroup\n onValueChange={(next) => onValueChange([String(next)])}\n value={condition.value[0] ?? ''}\n >\n {options.map((option) => (\n <MenuRadioItem key={option.value} value={option.value}>\n {option.label}\n </MenuRadioItem>\n ))}\n </MenuRadioGroup>\n )}\n </MenuPopup>\n </Menu>\n )\n}\n\nfunction InputValue(props: DataGridConditionValueProps) {\n const { condition, field, labels, onValueChange } = props\n const [open, setOpen] = useState(false)\n const type = INPUT_TYPES[field.kind === 'option' ? 'text' : field.kind]\n const between = condition.operator === 'between'\n const [first = '', second = ''] = condition.value\n\n const closeOnEnter = (key: string) => {\n if (key === 'Enter') setOpen(false)\n }\n\n return (\n <Popover onOpenChange={setOpen} open={open}>\n <PopoverTrigger render={<Button size=\"sm\" variant=\"outline\" />}>\n <ValueSummary {...props} />\n </PopoverTrigger>\n <PopoverPopup align=\"start\" aria-label={labels.editValue(field.label)}>\n <div className=\"flex w-56 flex-col gap-2\">\n {between ? (\n <>\n <Input\n aria-label={labels.rangeFrom}\n onChange={(event) =>\n onValueChange([event.target.value, second])\n }\n onKeyDown={(event) => closeOnEnter(event.key)}\n size=\"sm\"\n type={type}\n value={first}\n />\n <Input\n aria-label={labels.rangeTo}\n onChange={(event) => onValueChange([first, event.target.value])}\n onKeyDown={(event) => closeOnEnter(event.key)}\n size=\"sm\"\n type={type}\n value={second}\n />\n </>\n ) : (\n <Input\n aria-label={labels.editValue(field.label)}\n onChange={(event) =>\n onValueChange(event.target.value ? [event.target.value] : [])\n }\n onKeyDown={(event) => closeOnEnter(event.key)}\n placeholder={labels.valuePlaceholder}\n size=\"sm\"\n type={type}\n value={first}\n />\n )}\n </div>\n </PopoverPopup>\n </Popover>\n )\n}\n\nexport function DataGridConditionValue(\n props: DataGridConditionValueProps,\n): ReactElement {\n return props.field.kind === 'option' ? (\n <OptionValue {...props} />\n ) : (\n <InputValue {...props} />\n )\n}\n",
333
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-condition-value.tsx"
334
+ },
335
+ {
336
+ "path": "patterns/data-grid/components/data-grid-density-submenu.tsx",
337
+ "type": "registry:file",
338
+ "content": "'use client'\n\nimport {\n ArrowsInLineVerticalIcon,\n ArrowsVerticalIcon,\n EqualsIcon,\n MinusIcon,\n} from '@phosphor-icons/react'\nimport type { RowData } from '@tanstack/react-table'\nimport {\n MenuRadioGroup,\n MenuRadioItem,\n MenuSub,\n MenuSubPopup,\n MenuSubTrigger,\n} from '@tc96/ui/menu'\nimport type React from 'react'\nimport type { DataGridTableMeta } from '../lib/data-grid-features'\nimport type { CollectionDensity } from '../types'\n\ninterface DensityOption {\n icon: React.ComponentType<React.ComponentProps<'svg'>>\n label: string\n value: CollectionDensity\n}\n\nconst DENSITIES: [DensityOption, ...DensityOption[]] = [\n { icon: MinusIcon, label: 'Compacta', value: 'compact' },\n { icon: EqualsIcon, label: 'Padrão', value: 'short' },\n { icon: EqualsIcon, label: 'Média', value: 'medium' },\n { icon: ArrowsVerticalIcon, label: 'Alta', value: 'tall' },\n { icon: ArrowsInLineVerticalIcon, label: 'Extra alta', value: 'extra-tall' },\n]\n\nexport interface DataGridDensityTable {\n readonly options: {\n readonly meta?: Pick<\n DataGridTableMeta,\n 'dataGridDensity' | 'onDataGridDensityChange'\n >\n }\n}\n\nexport interface DataGridDensitySubmenuProps<_TData extends RowData = RowData> {\n label?: string\n densityLabels?: Partial<Record<CollectionDensity, string>>\n table: DataGridDensityTable\n}\n\nexport function DataGridDensitySubmenu<TData extends RowData>({\n label = 'Altura das linhas',\n densityLabels,\n table,\n}: DataGridDensitySubmenuProps<TData>): React.ReactElement {\n const density = table.options.meta?.dataGridDensity ?? 'short'\n const selected =\n DENSITIES.find((option) => option.value === density) ?? DENSITIES[0]\n const SelectedIcon = selected.icon\n\n return (\n <MenuSub>\n <MenuSubTrigger>\n <SelectedIcon aria-hidden=\"true\" />\n {label}\n </MenuSubTrigger>\n <MenuSubPopup>\n <MenuRadioGroup\n onValueChange={(value) =>\n table.options.meta?.onDataGridDensityChange?.(\n value as CollectionDensity,\n )\n }\n value={density}\n >\n {DENSITIES.map((option) => (\n <MenuRadioItem key={option.value} value={option.value}>\n <option.icon aria-hidden=\"true\" />\n {densityLabels?.[option.value] ?? option.label}\n </MenuRadioItem>\n ))}\n </MenuRadioGroup>\n </MenuSubPopup>\n </MenuSub>\n )\n}\n",
339
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-density-submenu.tsx"
340
+ },
341
+ {
342
+ "path": "patterns/data-grid/components/data-grid-empty-row.tsx",
343
+ "type": "registry:file",
344
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nexport function DataGridEmptyRow({\n ariaRowIndex,\n message,\n}: {\n ariaRowIndex: number\n message: string\n}) {\n return (\n <div\n aria-rowindex={ariaRowIndex}\n className=\"flex min-h-24 items-center justify-center text-muted-foreground\"\n role=\"row\"\n tabIndex={-1}\n >\n <div aria-colindex={1} role=\"gridcell\" tabIndex={-1}>\n {message}\n </div>\n </div>\n )\n}\n",
345
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-empty-row.tsx"
346
+ },
347
+ {
348
+ "path": "patterns/data-grid/components/data-grid-expand-toggle.tsx",
349
+ "type": "registry:file",
350
+ "content": "'use client'\n\nimport { CaretDownIcon, CaretRightIcon } from '@phosphor-icons/react'\nimport type { Row, RowData } from '@tanstack/react-table'\nimport { Button } from '@tc96/ui/button'\nimport type { ReactNode } from 'react'\nimport type { DataGridFeatures } from '../lib/data-grid-features'\n\nconst DEFAULT_INDENT_PX = 20\n\nexport interface DataGridExpandToggleProps<TData extends RowData> {\n children?: ReactNode\n getLabel: (row: Row<DataGridFeatures, TData>, expanded: boolean) => string\n indent?: number\n row: Row<DataGridFeatures, TData>\n}\n\nexport function DataGridExpandToggle<TData extends RowData>({\n children,\n getLabel,\n indent = DEFAULT_INDENT_PX,\n row,\n}: DataGridExpandToggleProps<TData>) {\n const canExpand = row.getCanExpand()\n const expanded = row.getIsExpanded()\n\n return (\n <div\n className=\"flex min-w-0 items-center gap-1\"\n data-depth={row.depth}\n data-slot=\"data-grid-expand\"\n style={{ paddingInlineStart: row.depth * indent }}\n >\n {canExpand ? (\n <Button\n aria-expanded={expanded}\n aria-label={getLabel(row, expanded)}\n data-slot=\"data-grid-expand-toggle\"\n onClick={() => row.toggleExpanded()}\n size=\"icon-xs\"\n type=\"button\"\n variant=\"ghost\"\n >\n {expanded ? (\n <CaretDownIcon aria-hidden=\"true\" />\n ) : (\n <CaretRightIcon aria-hidden=\"true\" />\n )}\n </Button>\n ) : (\n <span aria-hidden=\"true\" className=\"size-7 shrink-0 sm:size-6\" />\n )}\n {children}\n </div>\n )\n}\n",
351
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-expand-toggle.tsx"
352
+ },
353
+ {
354
+ "path": "patterns/data-grid/components/data-grid-filter-menu.tsx",
355
+ "type": "registry:file",
356
+ "content": "'use client'\n\nimport { FunnelSimpleIcon } from '@phosphor-icons/react'\nimport type { RowData } from '@tanstack/react-table'\nimport { Button } from '@tc96/ui/button'\nimport { Input } from '@tc96/ui/input'\nimport { Popover, PopoverPopup, PopoverTrigger } from '@tc96/ui/popover'\nimport type React from 'react'\nimport type { DataGridTable } from '../lib/data-grid-features'\nimport type { DataGridColumnMeta } from '../types'\n\nexport interface DataGridFilterMenuProps<TData extends RowData> {\n className?: string\n label?: string\n table: DataGridTable<TData>\n}\n\nexport function DataGridFilterMenu<TData extends RowData>({\n className,\n label = 'Filtrar',\n table,\n}: DataGridFilterMenuProps<TData>): React.ReactElement | null {\n const columns = table\n .getAllLeafColumns()\n .filter((column) => column.getCanFilter())\n if (columns.length === 0) return null\n\n return (\n <Popover>\n <PopoverTrigger\n render={\n <Button\n aria-label={label}\n className={className}\n size=\"sm\"\n variant=\"ghost\"\n />\n }\n >\n <FunnelSimpleIcon aria-hidden=\"true\" />\n {label}\n </PopoverTrigger>\n <PopoverPopup align=\"end\" aria-label={label} className=\"w-72\">\n <div className=\"flex flex-col gap-3\" data-slot=\"data-grid-filter-menu\">\n <div>\n <h3 className=\"font-medium text-sm\">Filtrar por</h3>\n <p className=\"text-muted-foreground text-xs\">\n Preencha um ou mais campos.\n </p>\n </div>\n {columns.map((column) => {\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n const columnLabel = meta.label ?? column.id\n const inputId = `data-grid-filter-${column.id}`\n return (\n <label\n className=\"grid gap-1.5 text-sm\"\n htmlFor={inputId}\n key={column.id}\n >\n <span className=\"font-medium\">{columnLabel}</span>\n <Input\n aria-label={`Filtrar ${columnLabel}`}\n id={inputId}\n onChange={(event) => {\n const value = event.target.value\n column.setFilterValue(value || undefined)\n table.setPageIndex(0)\n }}\n placeholder={`Buscar em ${columnLabel.toLocaleLowerCase('pt-BR')}…`}\n value={String(column.getFilterValue() ?? '')}\n />\n </label>\n )\n })}\n {table.store.state.columnFilters.length > 0 ? (\n <Button\n onClick={() => table.resetColumnFilters()}\n size=\"sm\"\n variant=\"ghost\"\n >\n Limpar filtros\n </Button>\n ) : null}\n </div>\n </PopoverPopup>\n </Popover>\n )\n}\n",
357
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-filter-menu.tsx"
358
+ },
359
+ {
360
+ "path": "patterns/data-grid/components/data-grid-footer.tsx",
361
+ "type": "registry:file",
362
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport type { ReactNode } from 'react'\n\nexport function DataGridFooter({\n ariaRowIndex,\n children,\n columnCount,\n}: {\n ariaRowIndex: number\n children: ReactNode\n columnCount: number\n}) {\n return (\n <div\n aria-rowindex={ariaRowIndex}\n className=\"sticky bottom-0 z-10 border-t bg-background\"\n data-slot=\"data-grid-footer\"\n role=\"row\"\n tabIndex={-1}\n >\n <div aria-colspan={columnCount} role=\"gridcell\" tabIndex={-1}>\n {children}\n </div>\n </div>\n )\n}\n",
363
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-footer.tsx"
364
+ },
365
+ {
366
+ "path": "patterns/data-grid/components/data-grid-group-row.tsx",
367
+ "type": "registry:file",
368
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport { CaretDownIcon, CaretRightIcon } from '@phosphor-icons/react'\nimport type { Row, RowData } from '@tanstack/react-table'\nimport { Badge } from '@tc96/ui/badge'\nimport { Button } from '@tc96/ui/button'\nimport { cn } from '@tc96/utils'\nimport { memo, type ReactNode } from 'react'\nimport type { ColumnLayouts } from '../lib/column-layout'\nimport { CELL_ALIGN } from '../lib/constants'\nimport type {\n DataGridColumn,\n DataGridFeatures,\n} from '../lib/data-grid-features'\n\nexport interface DataGridGroupCellContext<TData extends RowData> {\n collapsed: boolean\n column: DataGridColumn<TData>\n count: number\n group: string\n rows: readonly Row<DataGridFeatures, TData>[]\n}\n\nexport interface DataGridGroupRowProps<TData extends RowData> {\n ariaRowIndex: number\n collapsed: boolean\n columnLayouts?: ColumnLayouts\n columns?: readonly DataGridColumn<TData>[]\n count: number\n group: string\n labelColumnId?: string\n onToggle: (group: string, collapsed: boolean) => void\n getGroupToggleLabel?: (group: string, collapsed: boolean) => string\n renderGroupCell?: (context: DataGridGroupCellContext<TData>) => ReactNode\n rows?: readonly Row<DataGridFeatures, TData>[]\n}\n\nconst defaultGroupToggleLabel = (group: string, collapsed: boolean) =>\n collapsed ? `Expandir ${group}` : `Recolher ${group}`\n\nfunction DataGridGroupLabel({\n collapsed,\n count,\n getGroupToggleLabel = defaultGroupToggleLabel,\n group,\n onToggle,\n}: Pick<\n DataGridGroupRowProps<RowData>,\n 'collapsed' | 'count' | 'getGroupToggleLabel' | 'group' | 'onToggle'\n>) {\n return (\n <>\n <Button\n aria-expanded={!collapsed}\n aria-label={getGroupToggleLabel(group, collapsed)}\n onClick={() => onToggle(group, !collapsed)}\n size=\"icon-sm\"\n variant=\"ghost\"\n >\n {collapsed ? (\n <CaretRightIcon aria-hidden=\"true\" />\n ) : (\n <CaretDownIcon aria-hidden=\"true\" />\n )}\n </Button>\n <span className=\"truncate\" data-slot=\"data-grid-group-label\">\n {group}\n </span>\n <Badge\n className=\"size-5 min-w-5 shrink-0 rounded-full p-0 text-xs tabular-nums sm:size-5 sm:min-w-5\"\n data-slot=\"data-grid-group-count\"\n variant=\"secondary\"\n >\n {count}\n </Badge>\n </>\n )\n}\n\nfunction DataGridGroupRowView<TData extends RowData>({\n ariaRowIndex,\n collapsed,\n columnLayouts,\n columns,\n count,\n getGroupToggleLabel,\n group,\n labelColumnId,\n onToggle,\n renderGroupCell,\n rows = [],\n}: DataGridGroupRowProps<TData>) {\n if (!(renderGroupCell && columns)) {\n return (\n <div\n aria-rowindex={ariaRowIndex}\n className=\"flex min-h-9 items-center border-b bg-muted/40 px-1 font-medium\"\n data-collapsed={collapsed ? 'true' : undefined}\n data-slot=\"data-grid-group-row\"\n role=\"row\"\n tabIndex={-1}\n >\n <div\n className=\"flex min-w-0 items-center gap-1\"\n role=\"gridcell\"\n tabIndex={-1}\n >\n <DataGridGroupLabel\n collapsed={collapsed}\n count={count}\n getGroupToggleLabel={getGroupToggleLabel}\n group={group}\n onToggle={onToggle}\n />\n </div>\n </div>\n )\n }\n\n return (\n <div\n aria-rowindex={ariaRowIndex}\n className=\"flex min-h-9 w-full items-center border-b bg-muted/40 font-medium\"\n data-collapsed={collapsed ? 'true' : undefined}\n data-slot=\"data-grid-group-row\"\n role=\"row\"\n tabIndex={-1}\n >\n {columns.map((column, columnIndex) => {\n const layout = columnLayouts?.get(column.id)\n const isLabelColumn = column.id === labelColumnId\n return (\n <div\n aria-colindex={columnIndex + 1}\n className={cn(\n 'flex min-h-9 min-w-0 items-center gap-1 self-stretch overflow-hidden px-2 data-[pinned]:bg-[color-mix(in_srgb,var(--muted)_40%,var(--background))]',\n CELL_ALIGN[column.columnDef.meta?.align ?? 'start'],\n )}\n data-column-id={column.id}\n data-pinned={layout?.pinned || undefined}\n data-slot=\"data-grid-group-cell\"\n key={column.id}\n role=\"gridcell\"\n style={layout?.style}\n tabIndex={-1}\n >\n {isLabelColumn ? (\n <DataGridGroupLabel\n collapsed={collapsed}\n count={count}\n getGroupToggleLabel={getGroupToggleLabel}\n group={group}\n onToggle={onToggle}\n />\n ) : (\n renderGroupCell({ collapsed, column, count, group, rows })\n )}\n </div>\n )\n })}\n </div>\n )\n}\n\nexport const DataGridGroupRow = memo(\n DataGridGroupRowView,\n) as typeof DataGridGroupRowView\n",
369
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-group-row.tsx"
370
+ },
371
+ {
372
+ "path": "patterns/data-grid/components/data-grid-header-rows.tsx",
373
+ "type": "registry:file",
374
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { type ColumnLayouts, resolveColumnLayout } from '../lib/column-layout'\nimport type { DataGridTable } from '../lib/data-grid-features'\nimport { DataGridColumnHeader } from './data-grid-column-header'\n\nexport interface DataGridHeaderRowsProps<TData extends RowData> {\n columnLayouts: ColumnLayouts\n fillColumnId?: string\n table: DataGridTable<TData>\n}\n\nexport function DataGridHeaderRows<TData extends RowData>({\n columnLayouts,\n fillColumnId,\n table,\n}: DataGridHeaderRowsProps<TData>) {\n const totalSize = table.getTotalSize()\n\n return (\n <div\n className=\"sticky top-0 z-10 grid border-b bg-[color-mix(in_srgb,var(--card),var(--color-black)_2%)] dark:bg-[color-mix(in_srgb,var(--card),var(--color-white)_2%)]\"\n data-slot=\"data-grid-header\"\n role=\"rowgroup\"\n style={{ minWidth: totalSize }}\n >\n {table.getHeaderGroups().map((headerGroup, rowIndex) => (\n <div\n aria-rowindex={rowIndex + 1}\n className=\"flex w-full\"\n data-slot=\"data-grid-header-row\"\n key={headerGroup.id}\n role=\"row\"\n style={{ minWidth: totalSize }}\n tabIndex={-1}\n >\n {headerGroup.headers.map((header, columnIndex) => {\n const sorted = header.column.getIsSorted()\n const layout =\n columnLayouts.get(header.column.id) ??\n resolveColumnLayout(header.column, fillColumnId)\n return (\n <div\n aria-colindex={columnIndex + 1}\n aria-sort={\n sorted === 'asc'\n ? 'ascending'\n : sorted === 'desc'\n ? 'descending'\n : header.column.getCanSort()\n ? 'none'\n : undefined\n }\n className=\"relative flex min-h-9 items-center border-e px-1.5 text-muted-foreground last:border-e-0 data-[pinned]:bg-[color-mix(in_srgb,var(--card),var(--color-black)_2%)] dark:data-[pinned]:bg-[color-mix(in_srgb,var(--card),var(--color-white)_2%)]\"\n data-column-id={header.column.id}\n data-pinned={layout?.pinned || undefined}\n data-slot=\"data-grid-header-cell\"\n key={header.id}\n role=\"columnheader\"\n style={layout?.style}\n tabIndex={-1}\n >\n {header.isPlaceholder ? null : (\n <DataGridColumnHeader header={header} />\n )}\n </div>\n )\n })}\n </div>\n ))}\n </div>\n )\n}\n",
375
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-header-rows.tsx"
376
+ },
377
+ {
378
+ "path": "patterns/data-grid/components/data-grid-input-cell.tsx",
379
+ "type": "registry:file",
380
+ "content": "'use client'\n\nimport type { CellContext, RowData } from '@tanstack/react-table'\nimport { EditableInputCell } from '../../collection/shared/components/editable-input-cell'\nimport { toStringValue } from '../../collection/shared/lib/format-value'\nimport { CELL_ALIGN, CELL_SELECTOR } from '../lib/constants'\nimport type { DataGridFeatures } from '../lib/data-grid-features'\nimport type { DataGridColumnMeta } from '../types'\n\nexport function DataGridInputCell<TData extends RowData>({\n context,\n numeric,\n}: {\n context: CellContext<DataGridFeatures, TData, unknown>\n numeric: boolean\n}) {\n const { column, getValue, row, table } = context\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n\n return (\n <EditableInputCell\n alignClassName={CELL_ALIGN[meta.align ?? 'start']}\n cellSelector={CELL_SELECTOR}\n columnId={column.id}\n meta={meta}\n numeric={numeric}\n onValueChange={table.options.meta?.onDataGridCellValueChange}\n row={row}\n slot=\"data-grid-input-cell\"\n triggerAttribute=\"data-grid-input-trigger\"\n value={toStringValue(getValue())}\n />\n )\n}\n",
381
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-input-cell.tsx"
382
+ },
383
+ {
384
+ "path": "patterns/data-grid/components/data-grid-pagination.tsx",
385
+ "type": "registry:file",
386
+ "content": "'use client'\n\nimport type { PaginationState } from '@tanstack/react-table'\nimport type React from 'react'\nimport {\n CollectionPagination,\n type CollectionPaginationProps,\n} from '../../collection-pagination/components/collection-pagination'\n\nexport interface PaginatedTable {\n readonly store: { readonly state: { pagination: PaginationState } }\n getPageCount: () => number\n getRowCount: () => number\n setPageIndex: (pageIndex: number) => void\n setPageSize?: (pageSize: number) => void\n}\n\nexport interface DataGridPaginationProps\n extends Omit<React.ComponentProps<'div'>, 'children'> {\n buttonLabels?: CollectionPaginationProps['buttonLabels']\n formatRange?: CollectionPaginationProps['formatRange']\n label?: string\n pageSizeLabel?: string\n pageSizeOptions?: readonly number[]\n table: PaginatedTable\n}\n\nexport function DataGridPagination({\n buttonLabels,\n formatRange,\n label = 'Paginação da tabela',\n pageSizeLabel,\n pageSizeOptions,\n table,\n ...props\n}: DataGridPaginationProps): React.ReactElement {\n const { pageIndex, pageSize } = table.store.state.pagination\n\n return (\n <CollectionPagination\n data-slot=\"data-grid-pagination\"\n buttonLabels={buttonLabels}\n formatRange={formatRange}\n label={label}\n onPageChange={(page) => table.setPageIndex(page - 1)}\n onPageSizeChange={\n table.setPageSize\n ? (size) => {\n table.setPageSize?.(size)\n table.setPageIndex(0)\n }\n : undefined\n }\n page={pageIndex + 1}\n pageCount={table.getPageCount()}\n pageSize={pageSize}\n pageSizeLabel={pageSizeLabel}\n pageSizeOptions={pageSizeOptions}\n total={table.getRowCount()}\n {...props}\n />\n )\n}\n",
387
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-pagination.tsx"
388
+ },
389
+ {
390
+ "path": "patterns/data-grid/components/data-grid-resize-handle.tsx",
391
+ "type": "registry:file",
392
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { cn } from '@tc96/utils'\nimport type {\n DataGridColumn,\n DataGridHeader,\n DataGridTable,\n} from '../lib/data-grid-features'\nimport { resolveColumnSizeBounds, resolveResizeKeySize } from '../lib/resize'\nimport type { DataGridColumnMeta } from '../types'\n\nexport interface DataGridResizeHandleProps<TData extends RowData> {\n column: DataGridColumn<TData>\n header: DataGridHeader<TData>\n isLastColumn: boolean\n table: DataGridTable<TData>\n}\n\nexport function DataGridResizeHandle<TData extends RowData>({\n column,\n header,\n isLastColumn,\n table,\n}: DataGridResizeHandleProps<TData>) {\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n const { max, min } = resolveColumnSizeBounds(column)\n\n return (\n <div\n aria-label={`Redimensionar coluna ${meta.label ?? column.id}`}\n aria-orientation=\"vertical\"\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={column.getSize()}\n className={cn(\n 'absolute top-0 z-20 h-full w-0.5 cursor-ew-resize touch-none select-none outline-none after:absolute after:inset-y-0 after:start-1/2 after:w-4 hover:bg-primary focus-visible:bg-primary',\n isLastColumn\n ? 'end-0 after:-translate-x-full'\n : '-end-px after:-translate-x-1/2',\n column.getIsResizing() ? 'bg-primary' : 'bg-border',\n )}\n onDoubleClick={() => column.resetSize()}\n onKeyDown={(event) => {\n const size = resolveResizeKeySize(column, event.key)\n if (size === undefined) return\n event.preventDefault()\n table.setColumnSizing((current) => ({\n ...current,\n [column.id]: size,\n }))\n }}\n onMouseDown={header.getResizeHandler()}\n onTouchStart={header.getResizeHandler()}\n role=\"separator\"\n tabIndex={0}\n />\n )\n}\n",
393
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-resize-handle.tsx"
394
+ },
395
+ {
396
+ "path": "patterns/data-grid/components/data-grid-row-drag-handle.tsx",
397
+ "type": "registry:file",
398
+ "content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { RowDragHandle } from '../../collection/shared/components/row-drag-handle'\nimport type { DataGridColumnDef } from '../lib/data-grid-features'\n\nconst ROW_DRAG_TYPE = 'data-grid-row'\nconst ROW_SELECTOR = '[data-slot=\"data-grid-row\"]'\n\nexport interface CreateRowDragColumnOptions<TData extends RowData> {\n getHandleLabel: (row: TData) => string\n headerLabel?: string\n size?: number\n}\n\nexport function createRowDragColumn<TData extends RowData>({\n getHandleLabel,\n headerLabel,\n size = 40,\n}: CreateRowDragColumnOptions<TData>): DataGridColumnDef<TData> {\n return {\n id: 'drag',\n meta: { align: 'center' },\n size,\n enableSorting: false,\n enableHiding: false,\n enablePinning: false,\n enableResizing: false,\n header: () =>\n headerLabel ? <span className=\"sr-only\">{headerLabel}</span> : null,\n cell: ({ row }) => (\n <RowDragHandle\n dragType={ROW_DRAG_TYPE}\n label={getHandleLabel(row.original)}\n rowId={row.id}\n rowSelector={ROW_SELECTOR}\n slot=\"data-grid-row-drag-handle\"\n />\n ),\n }\n}\n",
399
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-row-drag-handle.tsx"
400
+ },
401
+ {
402
+ "path": "patterns/data-grid/components/data-grid-row-reorder.tsx",
403
+ "type": "registry:file",
404
+ "content": "'use client'\n\nimport type { Row, RowData } from '@tanstack/react-table'\nimport type { ReactNode } from 'react'\nimport { RowReorderProvider } from '../../collection/shared/components/row-reorder-provider'\nimport { useLatestCallback } from '../../collection/shared/hooks/use-latest-callback'\nimport type { DataGridFeatures } from '../lib/data-grid-features'\nimport { resolveCollectionRowIndex } from '../lib/row-index'\nimport type { DataGridRowDragAnnouncements, DataGridRowMove } from '../types'\n\nexport interface DataGridRowReorderProps<TData extends RowData> {\n active: boolean\n announcements?: DataGridRowDragAnnouncements\n children: ReactNode\n indexByRowId: ReadonlyMap<string, number>\n onRowMove?: (move: DataGridRowMove) => void\n paginationRowOffset: number\n positions: ReadonlyMap<string, number>\n rows: readonly Row<DataGridFeatures, TData>[]\n}\n\nexport function DataGridRowReorder<TData extends RowData>({\n active,\n announcements,\n children,\n indexByRowId,\n onRowMove,\n paginationRowOffset,\n positions,\n rows,\n}: DataGridRowReorderProps<TData>) {\n const getCollectionIndexes = useLatestCallback(() =>\n rows.map((row, index) =>\n resolveCollectionRowIndex({\n fallbackIndex: index,\n paginationRowOffset,\n positions,\n row,\n }),\n ),\n )\n\n return (\n <RowReorderProvider\n active={active}\n announcements={announcements}\n getCollectionIndexes={getCollectionIndexes}\n indexByRowId={indexByRowId}\n onRowMove={onRowMove}\n rowIds={rows.map((row) => row.id)}\n >\n {children}\n </RowReorderProvider>\n )\n}\n",
405
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-row-reorder.tsx"
406
+ },
407
+ {
408
+ "path": "patterns/data-grid/components/data-grid-row.tsx",
409
+ "type": "registry:file",
410
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport type { Row, RowData } from '@tanstack/react-table'\nimport { cn } from '@tc96/utils'\nimport { memo, useCallback, useMemo } from 'react'\nimport { useDataGridRowContext } from '../hooks/use-data-grid-row-context'\nimport { ROW_DENSITY } from '../lib/constants'\nimport type { DataGridFeatures } from '../lib/data-grid-features'\nimport { DataGridBodyCell } from './data-grid-body-cell'\n\nexport interface DataGridRowProps<TData extends RowData> {\n ariaLevel?: number\n ariaRowIndex: number\n expanded?: boolean\n focusedColumnId?: string\n interacted: boolean\n row: Row<DataGridFeatures, TData>\n selected: boolean\n selectedColumnIds?: ReadonlySet<string>\n virtualSize?: number\n virtualStart?: number\n}\n\nfunction DataGridRowView<TData extends RowData>({\n ariaLevel,\n ariaRowIndex,\n expanded,\n focusedColumnId,\n interacted,\n row,\n selected,\n selectedColumnIds,\n virtualSize,\n virtualStart,\n}: DataGridRowProps<TData>) {\n const {\n columnLayouts,\n density,\n interactions,\n meta,\n rowReorder,\n rowSelectable,\n } = useDataGridRowContext()\n const rowId = row.id\n const registerRef = useCallback(\n (node: HTMLDivElement | null) => interactions.registerRow(rowId, node),\n [interactions, rowId],\n )\n const virtualStyle = useMemo(\n () =>\n virtualStart === undefined\n ? undefined\n : {\n height: virtualSize,\n transform: `translateY(${virtualStart}px)`,\n },\n [virtualSize, virtualStart],\n )\n\n return (\n <div\n aria-expanded={expanded}\n aria-level={ariaLevel}\n aria-rowindex={ariaRowIndex}\n aria-selected={rowSelectable ? selected : undefined}\n className={cn(\n 'group flex w-full border-b transition-colors last:border-b-0 hover:bg-accent/40 data-[state=selected]:bg-primary/10',\n ROW_DENSITY[density],\n virtualStyle && 'absolute start-0 top-0',\n rowReorder &&\n 'data-dnd-dragging:bg-background data-dnd-dragging:shadow-md',\n )}\n data-slot=\"data-grid-row\"\n data-state={selected ? 'selected' : undefined}\n ref={registerRef}\n role=\"row\"\n style={virtualStyle}\n tabIndex={-1}\n >\n {row.getVisibleCells().map((cell, columnIndex) => {\n const isFocused = focusedColumnId === cell.column.id\n return (\n <DataGridBodyCell\n canSelect={row.getCanSelect()}\n cell={cell}\n columnIndex={columnIndex}\n density={density}\n interactions={interactions}\n isFocused={isFocused}\n isSelected={selectedColumnIds?.has(cell.column.id) ?? false}\n key={cell.id}\n layout={columnLayouts.get(cell.column.id)}\n rowExpanded={expanded}\n rowSelected={selected}\n showFocus={isFocused && interacted}\n meta={meta}\n />\n )\n })}\n </div>\n )\n}\n\nexport const DataGridRow = memo(DataGridRowView) as typeof DataGridRowView\n",
411
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-row.tsx"
412
+ },
413
+ {
414
+ "path": "patterns/data-grid/components/data-grid-search.tsx",
415
+ "type": "registry:file",
416
+ "content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { Input } from '@tc96/ui/input'\nimport { cn } from '@tc96/utils'\nimport type React from 'react'\n\nexport interface DataGridSearchTable {\n readonly store: { readonly state: { globalFilter?: unknown } }\n setGlobalFilter: (value: string) => void\n setPageIndex: (pageIndex: number) => void\n}\n\nexport interface DataGridSearchProps<_TData extends RowData = RowData>\n extends Omit<\n React.ComponentProps<typeof Input>,\n 'onChange' | 'value' | 'type'\n > {\n table: DataGridSearchTable\n}\n\nexport function DataGridSearch<TData extends RowData>({\n 'aria-label': ariaLabel,\n className,\n placeholder = 'Buscar…',\n table,\n ...props\n}: DataGridSearchProps<TData>): React.ReactElement {\n const accessibleName = ariaLabel ?? placeholder\n\n return (\n <Input\n aria-label={accessibleName}\n className={cn('max-w-64', className)}\n data-slot=\"data-grid-search\"\n onChange={(event) => {\n table.setGlobalFilter(event.target.value)\n table.setPageIndex(0)\n }}\n placeholder={placeholder}\n type=\"search\"\n value={(table.store.state.globalFilter as string) ?? ''}\n {...props}\n />\n )\n}\n",
417
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-search.tsx"
418
+ },
419
+ {
420
+ "path": "patterns/data-grid/components/data-grid-selection-actions.tsx",
421
+ "type": "registry:file",
422
+ "content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport {\n SelectionActions,\n type SelectionActionsProp,\n} from '../../collection/shared/components/selection-actions'\nimport type { DataGridTable } from '../lib/data-grid-features'\n\nexport type DataGridSelectionActionsProp<TData extends RowData> =\n SelectionActionsProp<TData>\n\nexport interface DataGridSelectionActionsProps<TData extends RowData> {\n selectionActions?: DataGridSelectionActionsProp<TData>\n table: DataGridTable<TData>\n}\n\nexport function DataGridSelectionActions<TData extends RowData>({\n selectionActions,\n table,\n}: DataGridSelectionActionsProps<TData>) {\n return (\n <SelectionActions\n selectionActions={selectionActions}\n slot=\"data-grid-selection-actions\"\n table={table}\n />\n )\n}\n",
423
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-selection-actions.tsx"
424
+ },
425
+ {
426
+ "path": "patterns/data-grid/components/data-grid-selection-summary.tsx",
427
+ "type": "registry:file",
428
+ "content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { cn } from '@tc96/utils'\nimport type React from 'react'\nimport type { DataGridTable } from '../lib/data-grid-features'\n\nexport interface DataGridSelectionSummaryProps<TData extends RowData>\n extends Omit<React.ComponentProps<'span'>, 'children'> {\n table: DataGridTable<TData>\n}\n\nexport function DataGridSelectionSummary<TData extends RowData>({\n className,\n table,\n ...props\n}: DataGridSelectionSummaryProps<TData>): React.ReactElement {\n const count = table.getSelectedRowModel().rows.length\n return (\n <span\n aria-live=\"polite\"\n className={cn(\n 'px-2 text-muted-foreground text-sm tabular-nums',\n className,\n )}\n data-slot=\"data-grid-selection-summary\"\n {...props}\n >\n {count} {count === 1 ? 'selecionado' : 'selecionados'}\n </span>\n )\n}\n",
429
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-selection-summary.tsx"
430
+ },
431
+ {
432
+ "path": "patterns/data-grid/components/data-grid-skeleton-rows.tsx",
433
+ "type": "registry:file",
434
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: the WAI-ARIA grid pattern is used instead of table layout elements so the body can be virtualized\n\n'use client'\n\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { cn } from '@tc96/utils'\nimport type { ColumnLayouts } from '../lib/column-layout'\nimport { CELL_DENSITY, ROW_DENSITY, ROW_HEIGHT } from '../lib/constants'\nimport type { CollectionDensity } from '../types'\n\nexport interface DataGridRowSkeletonAnatomy {\n cell?: 'control' | 'text'\n}\n\nexport interface DataGridSkeletonRowsProps {\n anatomy?: DataGridRowSkeletonAnatomy\n columnIds: readonly string[]\n columnLayouts: ColumnLayouts\n density: CollectionDensity\n headerRowCount: number\n label: string\n loadingMore?: boolean\n rowIds: readonly string[]\n rowIndexOffset?: number\n virtualStart?: number\n}\n\nexport function DataGridSkeletonRows({\n anatomy = {},\n columnIds,\n columnLayouts,\n density,\n headerRowCount,\n label,\n loadingMore,\n rowIds,\n rowIndexOffset = 0,\n virtualStart,\n}: DataGridSkeletonRowsProps) {\n return rowIds.map((rowId, rowIndex) => (\n <div\n aria-rowindex={headerRowCount + rowIndexOffset + rowIndex + 1}\n className={cn(\n 'flex w-full border-b last:border-b-0',\n ROW_DENSITY[density],\n virtualStart !== undefined && 'absolute start-0 top-0',\n )}\n data-cell={anatomy.cell ?? 'text'}\n data-loading-more={loadingMore ? 'true' : undefined}\n key={rowId}\n role=\"row\"\n style={\n virtualStart === undefined\n ? undefined\n : {\n height: ROW_HEIGHT[density],\n transform: `translateY(${virtualStart + rowIndex * ROW_HEIGHT[density]}px)`,\n }\n }\n tabIndex={-1}\n >\n {columnIds.map((columnId, columnIndex) => {\n const layout = columnLayouts.get(columnId)\n return (\n <div\n aria-colindex={columnIndex + 1}\n className={cn(\n 'flex items-center border-e last:border-e-0 data-[pinned]:bg-background',\n CELL_DENSITY[density],\n )}\n data-column-id={columnId}\n data-pinned={layout?.pinned || undefined}\n key={columnId}\n role=\"gridcell\"\n style={layout?.style}\n tabIndex={-1}\n >\n {columnIndex === 0 ? (\n <output aria-busy=\"true\" className=\"sr-only\">\n {label}\n </output>\n ) : null}\n <Skeleton\n className={cn(\n 'w-full',\n anatomy.cell === 'control' ? 'h-6' : 'my-0.5 h-4',\n )}\n />\n </div>\n )\n })}\n </div>\n ))\n}\n",
435
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-skeleton-rows.tsx"
436
+ },
437
+ {
438
+ "path": "patterns/data-grid/components/data-grid-sort-submenu.tsx",
439
+ "type": "registry:file",
440
+ "content": "'use client'\n\nimport { ArrowsDownUpIcon } from '@phosphor-icons/react'\nimport type { RowData } from '@tanstack/react-table'\nimport {\n MenuItem,\n MenuSeparator,\n MenuSub,\n MenuSubPopup,\n MenuSubTrigger,\n} from '@tc96/ui/menu'\nimport type React from 'react'\nimport type { DataGridColumnMeta } from '../types'\n\nexport interface DataGridSortColumn {\n readonly id: string\n readonly columnDef: { readonly meta?: unknown }\n getCanSort: () => boolean\n toggleSorting: (desc?: boolean) => void\n}\n\nexport interface DataGridSortTable {\n getAllLeafColumns: () => readonly DataGridSortColumn[]\n resetSorting: () => void\n readonly store: { readonly state: { readonly sorting: readonly unknown[] } }\n}\n\nexport interface DataGridSortSubmenuProps<_TData extends RowData = RowData> {\n label?: string\n clearLabel?: string\n getOptionLabel?: (columnLabel: string, direction: 'asc' | 'desc') => string\n table: DataGridSortTable\n}\n\nconst defaultOptionLabel = (columnLabel: string, direction: 'asc' | 'desc') =>\n `${columnLabel}: ${direction === 'asc' ? 'crescente' : 'decrescente'}`\n\nexport function DataGridSortSubmenu<TData extends RowData>({\n label = 'Ordenar por',\n clearLabel = 'Limpar ordenação',\n getOptionLabel = defaultOptionLabel,\n table,\n}: DataGridSortSubmenuProps<TData>): React.ReactElement | null {\n const columns = table\n .getAllLeafColumns()\n .filter((column) => column.getCanSort())\n if (columns.length === 0) return null\n\n return (\n <MenuSub>\n <MenuSubTrigger>\n <ArrowsDownUpIcon aria-hidden=\"true\" />\n {label}\n </MenuSubTrigger>\n <MenuSubPopup>\n {columns.flatMap((column) => {\n const meta = (column.columnDef.meta ?? {}) as DataGridColumnMeta\n const columnLabel = meta.label ?? column.id\n return [\n <MenuItem\n key={`${column.id}-asc`}\n onClick={() => column.toggleSorting(false)}\n >\n {getOptionLabel(columnLabel, 'asc')}\n </MenuItem>,\n <MenuItem\n key={`${column.id}-desc`}\n onClick={() => column.toggleSorting(true)}\n >\n {getOptionLabel(columnLabel, 'desc')}\n </MenuItem>,\n ]\n })}\n {table.store.state.sorting.length > 0 ? (\n <>\n <MenuSeparator />\n <MenuItem onClick={() => table.resetSorting()}>\n {clearLabel}\n </MenuItem>\n </>\n ) : null}\n </MenuSubPopup>\n </MenuSub>\n )\n}\n",
441
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid-sort-submenu.tsx"
442
+ },
443
+ {
444
+ "path": "patterns/data-grid/components/data-grid.tsx",
445
+ "type": "registry:file",
446
+ "content": "// biome-ignore-all lint/a11y/useSemanticElements: a virtualizable spreadsheet uses the WAI-ARIA grid pattern instead of table layout elements\n\n'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { ScrollArea } from '@tc96/ui/scroll-area'\nimport { cn } from '@tc96/utils'\nimport { type ReactNode, useMemo, useRef } from 'react'\nimport { useCollapsedGroups } from '../../collection/shared/hooks/use-collapsed-groups'\nimport { useLatestCallback } from '../../collection/shared/hooks/use-latest-callback'\nimport {\n scrollbarInsetStyle,\n useScrollbarInsets,\n} from '../../collection/shared/hooks/use-scrollbar-insets'\nimport { DEFAULT_END_REACHED_THRESHOLD } from '../../collection/shared/lib/end-reached'\nimport { isRowReorderActive } from '../../collection/shared/lib/row-reorder'\nimport { useColumnLayouts } from '../hooks/use-column-layouts'\nimport { useDataGridCellEvents } from '../hooks/use-data-grid-cell-events'\nimport { useDataGridCellSelection } from '../hooks/use-data-grid-cell-selection'\nimport { useDataGridDragScroll } from '../hooks/use-data-grid-drag-scroll'\nimport { useDataGridEndReached } from '../hooks/use-data-grid-end-reached'\nimport { useDataGridFocus } from '../hooks/use-data-grid-focus'\nimport { DataGridRowContext } from '../hooks/use-data-grid-row-context'\nimport { useDataGridRows } from '../hooks/use-data-grid-rows'\nimport { useDataGridVirtualizer } from '../hooks/use-data-grid-virtualizer'\nimport {\n findFirstNavigableColumnIndex,\n indexColumns,\n resolveFillColumnId,\n} from '../lib/columns'\nimport { ROW_HEIGHT } from '../lib/constants'\nimport type { DataGridTable } from '../lib/data-grid-features'\nimport type {\n CollectionDensity,\n DataGridRowDragAnnouncements,\n DataGridRowMove,\n} from '../types'\nimport { DataGridAddRow } from './data-grid-add-row'\nimport { DataGridBody } from './data-grid-body'\nimport { DataGridFooter } from './data-grid-footer'\nimport type { DataGridGroupCellContext } from './data-grid-group-row'\nimport { DataGridHeaderRows } from './data-grid-header-rows'\nimport { DataGridPagination } from './data-grid-pagination'\nimport { DataGridRowReorder } from './data-grid-row-reorder'\nimport {\n DataGridSelectionActions,\n type DataGridSelectionActionsProp,\n} from './data-grid-selection-actions'\nimport type { DataGridRowSkeletonAnatomy } from './data-grid-skeleton-rows'\n\nexport interface DataGridProps<TData extends RowData> {\n table: DataGridTable<TData>\n showPagination?: boolean\n fillColumn?: string | false\n footer?: ReactNode\n density?: CollectionDensity\n loading?: boolean\n loadingAnatomy?: DataGridRowSkeletonAnatomy\n loadingCount?: number\n loadingLabel?: string\n loadingMore?: boolean\n loadingMoreRowCount?: number\n onEndReached?: () => void\n endReachedThreshold?: number\n emptyMessage?: string\n maxHeight?: number | string\n getRowGroup?: (row: TData) => string | null\n collapsedGroupIds?: readonly string[]\n defaultCollapsedGroupIds?: readonly string[]\n onCollapsedGroupIdsChange?: (groupIds: readonly string[]) => void\n renderGroupCell?: (context: DataGridGroupCellContext<TData>) => ReactNode\n getGroupToggleLabel?: (group: string, collapsed: boolean) => string\n onRowMove?: (move: DataGridRowMove) => void\n rowDragAnnouncements?: DataGridRowDragAnnouncements\n getRowSelected?: (row: TData) => boolean\n onRecordAdd?: () => void | Promise<void>\n addLabel?: string\n virtualize?: boolean\n overscan?: number\n className?: string\n selectionActions?: DataGridSelectionActionsProp<TData>\n 'aria-label'?: string\n}\n\nconst NO_GROUPS: readonly string[] = []\n\nexport function DataGrid<TData extends RowData>({\n table,\n showPagination,\n fillColumn,\n footer,\n density: densityProp,\n loading = false,\n loadingAnatomy,\n loadingCount = 5,\n loadingLabel = 'Carregando linha',\n loadingMore = false,\n loadingMoreRowCount = 3,\n onEndReached,\n endReachedThreshold = DEFAULT_END_REACHED_THRESHOLD,\n emptyMessage = 'Nenhum registro para exibir.',\n maxHeight,\n getRowGroup,\n collapsedGroupIds: controlledCollapsedGroupIds,\n defaultCollapsedGroupIds = NO_GROUPS,\n onCollapsedGroupIdsChange,\n renderGroupCell,\n getGroupToggleLabel,\n onRowMove,\n rowDragAnnouncements,\n getRowSelected,\n onRecordAdd,\n addLabel = 'Adicionar linha',\n virtualize = false,\n overscan = 8,\n className,\n selectionActions,\n 'aria-label': ariaLabel,\n}: DataGridProps<TData>) {\n const gridRef = useRef<HTMLDivElement>(null)\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const showsPagination = showPagination ?? !table.options.manualPagination\n const footerContent =\n footer ?? (showsPagination ? <DataGridPagination table={table} /> : null)\n const density = densityProp ?? table.options.meta?.dataGridDensity ?? 'short'\n const leafColumns = table.getVisibleLeafColumns()\n const fillColumnId = resolveFillColumnId(leafColumns, fillColumn)\n const columnIndexById = useMemo(\n () => indexColumns(leafColumns),\n [leafColumns],\n )\n const columnLayouts = useColumnLayouts(leafColumns, fillColumnId)\n const firstNavigableColumn = findFirstNavigableColumnIndex(leafColumns)\n\n const { collapsedGroupIds, setGroupCollapsed } = useCollapsedGroups({\n controlled: controlledCollapsedGroupIds,\n defaultValue: defaultCollapsedGroupIds,\n onChange: onCollapsedGroupIdsChange,\n })\n const onToggleGroup = useLatestCallback(setGroupCollapsed)\n const model = useDataGridRows({\n collapsedGroupIds,\n getRowGroup,\n table,\n withGroupRows: Boolean(renderGroupCell),\n })\n const { rows } = model\n\n const cellSelection = useDataGridCellSelection({\n availableColumnIds: columnIndexById,\n coreRowsById: table.getCoreRowModel().rowsById,\n availableRowIds: model.positions,\n firstColumnId: leafColumns[firstNavigableColumn]?.id,\n firstRowId: rows[0]?.id,\n visibleRowIds: model.rowIndexById,\n })\n const { focusCell, registry } = useDataGridFocus({\n focusedColumnId: cellSelection.focusedColumnId,\n focusedRowId: cellSelection.focusedRowId,\n hasInteracted: cellSelection.hasInteracted,\n })\n\n const shouldVirtualize =\n virtualize && !getRowGroup && !loading && rows.length > 0\n const virtualizer = useDataGridVirtualizer({\n density,\n enabled: shouldVirtualize,\n gridRef,\n hasBottomBar: Boolean(onRecordAdd || footerContent),\n maxHeight,\n overscan,\n rows,\n table,\n })\n const sorting = table.options.state?.sorting ?? table.atoms.sorting.get()\n const reorderActive = isRowReorderActive({\n enabled: Boolean(onRowMove),\n grouped: Boolean(getRowGroup),\n loading: loading,\n sorted: sorting.length > 0,\n virtualized: shouldVirtualize,\n })\n const expandable = Boolean(table.options.enableExpanding)\n const loadingMoreCount =\n loadingMore && !loading && model.pageRows.length > 0\n ? loadingMoreRowCount\n : 0\n useDataGridEndReached({\n density,\n enabled: Boolean(onEndReached) && !loading,\n gridRef,\n hasBottomBar: Boolean(onRecordAdd || footerContent),\n loadingMore: loadingMoreCount > 0,\n onEndReached,\n rowCount: table.options.data.length,\n threshold: endReachedThreshold,\n })\n const interactions = useDataGridCellEvents({\n columnIndexById,\n columns: leafColumns,\n firstNavigableColumn,\n focusCell,\n registry,\n rowIndexById: model.rowIndexById,\n rows,\n scrollRowIntoView: shouldVirtualize\n ? virtualizer.scrollRowIntoView\n : undefined,\n selectCell: cellSelection.selectCell,\n selection: cellSelection.selection,\n })\n const dragScroll = useDataGridDragScroll()\n\n const rowSelectable =\n Boolean(getRowSelected) || Boolean(table.options.enableRowSelection)\n const meta = table.options.meta\n const enableRowSelection = table.options.enableRowSelection\n const rowContext = useMemo(\n () => ({\n columnLayouts,\n columns: leafColumns,\n density,\n enableRowSelection,\n interactions,\n meta,\n rowReorder: reorderActive,\n rowSelectable,\n }),\n [\n columnLayouts,\n density,\n enableRowSelection,\n interactions,\n leafColumns,\n meta,\n reorderActive,\n rowSelectable,\n ],\n )\n\n const bodyRowCount = loading\n ? loadingCount\n : model.collectionRowCount === 0\n ? 1\n : model.collectionRowCount + model.groupRowCount\n useScrollbarInsets(\n scrollAreaRef,\n '[data-slot=\"data-grid-header\"]',\n footerContent\n ? '[data-slot=\"data-grid-footer\"]'\n : '[data-slot=\"data-grid-add-row-group\"]',\n Boolean(footerContent || onRecordAdd),\n )\n const ariaRowCount =\n model.headerRowCount +\n bodyRowCount +\n loadingMoreCount +\n (onRecordAdd ? 1 : 0) +\n (footerContent ? 1 : 0)\n const totalSize = table.getTotalSize()\n\n return (\n <div\n className={cn(\n 'relative flex min-h-0 min-w-0 flex-1 flex-col',\n fillColumnId ? 'w-full' : 'w-fit max-w-full',\n className,\n )}\n >\n <ScrollArea\n className={cn(\n 'relative size-auto min-h-0 flex-1 rounded-md border bg-background text-sm',\n fillColumnId ? 'w-full' : 'w-fit max-w-full',\n )}\n data-slot=\"data-grid\"\n ref={scrollAreaRef}\n verticalScrollbarProps={{ style: scrollbarInsetStyle }}\n viewportProps={{\n 'aria-busy': loading || loadingMoreCount > 0 || undefined,\n 'aria-colcount': leafColumns.length,\n 'aria-label': ariaLabel,\n 'aria-multiselectable': true,\n 'aria-rowcount': ariaRowCount,\n className:\n 'grid h-full cursor-grab select-none rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-[drag-scroll=dragging]:cursor-grabbing data-has-overflow-x:overscroll-x-contain data-has-overflow-y:overscroll-y-contain',\n 'data-density': density,\n 'data-drag-scroll': dragScroll.isDragScrolling\n ? 'dragging'\n : undefined,\n onClickCapture: dragScroll.onClickCapture,\n onLostPointerCapture: dragScroll.onLostPointerCapture,\n onPointerCancel: dragScroll.onPointerCancel,\n onPointerDownCapture: dragScroll.onPointerDownCapture,\n onPointerMove: dragScroll.onPointerMove,\n onPointerUp: dragScroll.onPointerUp,\n ref: gridRef,\n role: expandable ? 'treegrid' : 'grid',\n style: { maxHeight },\n tabIndex: rows.length > 0 && !loading ? -1 : 0,\n }}\n >\n <DataGridHeaderRows\n columnLayouts={columnLayouts}\n fillColumnId={fillColumnId}\n table={table}\n />\n <DataGridRowContext value={rowContext}>\n <DataGridRowReorder\n active={reorderActive}\n announcements={rowDragAnnouncements}\n indexByRowId={model.rowIndexById}\n onRowMove={onRowMove}\n paginationRowOffset={model.paginationRowOffset}\n positions={model.positions}\n rows={rows}\n >\n <DataGridBody\n columnIds={leafColumns.map((column) => column.id)}\n columnLayouts={columnLayouts}\n columns={leafColumns}\n density={density}\n emptyMessage={emptyMessage}\n entries={model.entries}\n expandable={expandable}\n focusedColumnId={cellSelection.focusedColumnId}\n focusedRowId={cellSelection.focusedRowId}\n getRowSelected={getRowSelected}\n hasInteracted={cellSelection.hasInteracted}\n headerRowCount={model.headerRowCount}\n loading={loading}\n labelColumnId={leafColumns[firstNavigableColumn]?.id}\n loadingMoreRowCount={loadingMoreCount}\n loadingMoreRowIndexOffset={bodyRowCount}\n {...(loadingAnatomy ? { loadingAnatomy } : {})}\n loadingCount={loadingCount}\n loadingLabel={loadingLabel}\n minWidth={totalSize}\n onToggleGroup={onToggleGroup}\n pageRowCount={model.pageRows.length}\n renderGroupCell={renderGroupCell}\n getGroupToggleLabel={getGroupToggleLabel}\n selection={cellSelection.selection}\n totalSize={\n virtualizer.totalSize + loadingMoreCount * ROW_HEIGHT[density]\n }\n virtualItems={virtualizer.virtualItems}\n virtualized={shouldVirtualize}\n />\n </DataGridRowReorder>\n </DataGridRowContext>\n {onRecordAdd ? (\n <DataGridAddRow\n ariaRowIndex={\n model.headerRowCount + bodyRowCount + loadingMoreCount + 1\n }\n label={addLabel}\n minWidth={totalSize}\n onAdd={onRecordAdd}\n />\n ) : null}\n {footerContent ? (\n <DataGridFooter\n ariaRowIndex={ariaRowCount}\n columnCount={leafColumns.length}\n >\n {footerContent}\n </DataGridFooter>\n ) : null}\n </ScrollArea>\n <DataGridSelectionActions\n selectionActions={selectionActions}\n table={table}\n />\n </div>\n )\n}\n",
447
+ "target": "~/packages/ui/src/patterns/data-grid/components/data-grid.tsx"
448
+ },
449
+ {
450
+ "path": "patterns/data-grid/hooks/use-column-layouts.ts",
451
+ "type": "registry:file",
452
+ "content": "import type { RowData } from '@tanstack/react-table'\nimport { useState } from 'react'\nimport { buildColumnLayouts } from '../lib/column-layout'\nimport type { DataGridColumn } from '../lib/data-grid-features'\n\nexport function useColumnLayouts<TData extends RowData>(\n columns: readonly DataGridColumn<TData>[],\n fillColumnId?: string,\n) {\n const [layouts, setLayouts] = useState(() =>\n buildColumnLayouts(columns, fillColumnId),\n )\n const next = buildColumnLayouts(columns, fillColumnId, layouts)\n if (next !== layouts) setLayouts(next)\n return next\n}\n",
453
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-column-layouts.ts"
454
+ },
455
+ {
456
+ "path": "patterns/data-grid/hooks/use-data-grid-cell-events.ts",
457
+ "type": "registry:file",
458
+ "content": "import type { Row, RowData } from '@tanstack/react-table'\nimport {\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n useMemo,\n useRef,\n} from 'react'\nimport { useLatestCallback } from '../../collection/shared/hooks/use-latest-callback'\nimport type { CellIdentity, CellRegistry } from '../lib/cell-registry'\nimport {\n PENDING_SELECT_CLICK_WINDOW_MS,\n SELECT_TRIGGER_SELECTOR,\n} from '../lib/constants'\nimport type {\n DataGridColumn,\n DataGridFeatures,\n} from '../lib/data-grid-features'\nimport { hasSelectTrigger } from '../lib/dom'\nimport { type CellSelection, isCellSelected } from '../lib/selection'\n\nexport interface CellInteractions {\n onClick: (event: MouseEvent<HTMLDivElement>) => void\n onClickCapture: (event: MouseEvent<HTMLDivElement>) => void\n onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void\n onMouseDownCapture: (event: MouseEvent<HTMLDivElement>) => void\n onPointerDownCapture: (event: PointerEvent<HTMLDivElement>) => void\n registerRow: CellRegistry['registerRow']\n}\n\ninterface UseDataGridCellEventsOptions<TData extends RowData> {\n columnIndexById: ReadonlyMap<string, number>\n columns: readonly DataGridColumn<TData>[]\n firstNavigableColumn: number\n focusCell: (rowId: string, columnId: string) => void\n registry: CellRegistry\n rowIndexById: ReadonlyMap<string, number>\n rows: readonly Row<DataGridFeatures, TData>[]\n scrollRowIntoView?: (rowIndex: number) => void\n selectCell: (rowId: string, columnId: string, extend?: boolean) => void\n selection: CellSelection\n}\n\ninterface PendingSelectClick extends CellIdentity {\n timestamp: number\n}\n\nexport function useDataGridCellEvents<TData extends RowData>({\n columnIndexById,\n columns,\n firstNavigableColumn,\n focusCell,\n registry,\n rowIndexById,\n rows,\n scrollRowIntoView,\n selectCell,\n selection,\n}: UseDataGridCellEventsOptions<TData>): CellInteractions {\n const pendingRef = useRef<PendingSelectClick | null>(null)\n\n const isPendingPointerSelect = (identity: CellIdentity) => {\n const pending = pendingRef.current\n return (\n pending?.rowId === identity.rowId &&\n pending.columnId === identity.columnId &&\n performance.now() - pending.timestamp < PENDING_SELECT_CLICK_WINDOW_MS\n )\n }\n\n const onKeyDown = useLatestCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget) return\n const identity = registry.identify(event.currentTarget)\n const rowIndex = identity && rowIndexById.get(identity.rowId)\n const columnIndex = identity && columnIndexById.get(identity.columnId)\n if (rowIndex === undefined || columnIndex === undefined) return\n\n let nextRow = rowIndex\n let nextColumn = columnIndex\n if (event.key === 'ArrowLeft') nextColumn -= 1\n else if (event.key === 'ArrowRight') nextColumn += 1\n else if (event.key === 'ArrowUp') nextRow -= 1\n else if (event.key === 'ArrowDown') nextRow += 1\n else if (event.key === 'Home') {\n nextColumn = firstNavigableColumn\n if (event.ctrlKey || event.metaKey) nextRow = 0\n } else if (event.key === 'End') {\n nextColumn = columns.length - 1\n if (event.ctrlKey || event.metaKey) nextRow = rows.length - 1\n } else return\n\n event.preventDefault()\n nextRow = Math.max(0, Math.min(rows.length - 1, nextRow))\n nextColumn = Math.max(\n firstNavigableColumn,\n Math.min(columns.length - 1, nextColumn),\n )\n if (scrollRowIntoView && nextRow !== rowIndex) scrollRowIntoView(nextRow)\n const nextRowId = rows[nextRow]?.id\n const nextColumnId = columns[nextColumn]?.id\n if (!(nextRowId && nextColumnId)) return\n selectCell(nextRowId, nextColumnId, event.shiftKey)\n focusCell(nextRowId, nextColumnId)\n },\n )\n\n const onPointerDownCapture = useLatestCallback(\n (event: PointerEvent<HTMLDivElement>) => {\n const identity = registry.identify(event.currentTarget)\n if (!identity) return\n const selected = isCellSelected(\n selection,\n identity.rowId,\n identity.columnId,\n )\n if (selected || !hasSelectTrigger(event.currentTarget)) return\n\n event.preventDefault()\n event.stopPropagation()\n pendingRef.current = { ...identity, timestamp: performance.now() }\n selectCell(identity.rowId, identity.columnId, event.shiftKey)\n },\n )\n\n const onMouseDownCapture = useLatestCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n const identity = registry.identify(event.currentTarget)\n if (!identity) return\n\n if (isPendingPointerSelect(identity)) {\n event.preventDefault()\n event.stopPropagation()\n return\n }\n\n const selected = isCellSelected(\n selection,\n identity.rowId,\n identity.columnId,\n )\n if (selected || !hasSelectTrigger(event.currentTarget)) return\n\n event.preventDefault()\n event.stopPropagation()\n pendingRef.current = { ...identity, timestamp: performance.now() }\n selectCell(identity.rowId, identity.columnId, event.shiftKey)\n },\n )\n\n const onClickCapture = useLatestCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n const identity = registry.identify(event.currentTarget)\n if (!identity) return\n\n if (isPendingPointerSelect(identity)) {\n event.preventDefault()\n event.stopPropagation()\n pendingRef.current = null\n return\n }\n\n const selected = isCellSelected(\n selection,\n identity.rowId,\n identity.columnId,\n )\n if (selected || !hasSelectTrigger(event.currentTarget)) return\n\n event.preventDefault()\n event.stopPropagation()\n selectCell(identity.rowId, identity.columnId, event.shiftKey)\n },\n )\n\n const onClick = useLatestCallback((event: MouseEvent<HTMLDivElement>) => {\n const identity = registry.identify(event.currentTarget)\n if (!identity) return\n const selected = isCellSelected(\n selection,\n identity.rowId,\n identity.columnId,\n )\n selectCell(identity.rowId, identity.columnId, event.shiftKey)\n if (!selected) return\n\n const trigger = event.currentTarget.querySelector<HTMLElement>(\n SELECT_TRIGGER_SELECTOR,\n )\n if (!trigger || trigger.contains(event.target as Node)) return\n trigger.click()\n })\n\n return useMemo(\n () => ({\n onClick,\n onClickCapture,\n onKeyDown,\n onMouseDownCapture,\n onPointerDownCapture,\n registerRow: registry.registerRow,\n }),\n [\n onClick,\n onClickCapture,\n onKeyDown,\n onMouseDownCapture,\n onPointerDownCapture,\n registry,\n ],\n )\n}\n",
459
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-cell-events.ts"
460
+ },
461
+ {
462
+ "path": "patterns/data-grid/hooks/use-data-grid-cell-selection.ts",
463
+ "type": "registry:file",
464
+ "content": "import { useMemo, useState } from 'react'\nimport {\n addCellToSelection,\n type CellSelection,\n EMPTY_SELECTION,\n pruneSelection,\n selectSingleCell,\n} from '../lib/selection'\n\ninterface FocusedCell {\n columnId?: string\n rowId?: string\n}\n\ninterface UseDataGridCellSelectionOptions {\n coreRowsById: object\n availableColumnIds: ReadonlyMap<string, number>\n availableRowIds: ReadonlyMap<string, number>\n firstColumnId?: string\n firstRowId?: string\n visibleRowIds: ReadonlyMap<string, number>\n}\n\nexport function useDataGridCellSelection({\n coreRowsById,\n availableColumnIds,\n availableRowIds,\n firstColumnId,\n firstRowId,\n visibleRowIds,\n}: UseDataGridCellSelectionOptions) {\n const [focusedCell, setFocusedCell] = useState<FocusedCell>({\n columnId: firstColumnId,\n rowId: firstRowId,\n })\n const [hasInteracted, setHasInteracted] = useState(false)\n const [selectedCells, setSelectedCells] =\n useState<CellSelection>(EMPTY_SELECTION)\n\n const [seenCoreRows, setSeenCoreRows] = useState(coreRowsById)\n if (seenCoreRows !== coreRowsById) {\n setSeenCoreRows(coreRowsById)\n setSelectedCells((current) =>\n pruneSelection(\n current,\n (rowId) => rowId in coreRowsById,\n () => true,\n ),\n )\n }\n\n const focusedCellIsAvailable =\n focusedCell.rowId !== undefined &&\n focusedCell.columnId !== undefined &&\n visibleRowIds.has(focusedCell.rowId) &&\n availableColumnIds.has(focusedCell.columnId)\n const activeFocusedCell: FocusedCell = focusedCellIsAvailable\n ? focusedCell\n : { columnId: firstColumnId, rowId: firstRowId }\n\n const selection = useMemo(\n () =>\n pruneSelection(\n selectedCells,\n (rowId) => availableRowIds.has(rowId),\n (columnId) => availableColumnIds.has(columnId),\n ),\n [availableColumnIds, availableRowIds, selectedCells],\n )\n\n function selectCell(rowId: string, columnId: string, extend = false) {\n setHasInteracted(true)\n setFocusedCell({ columnId, rowId })\n setSelectedCells((current) =>\n extend\n ? addCellToSelection(\n pruneSelection(\n current,\n (id) => availableRowIds.has(id),\n (id) => availableColumnIds.has(id),\n ),\n rowId,\n columnId,\n )\n : selectSingleCell(rowId, columnId),\n )\n }\n\n return {\n focusedColumnId: activeFocusedCell.columnId,\n focusedRowId: activeFocusedCell.rowId,\n hasInteracted,\n selectCell,\n selection,\n }\n}\n",
465
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-cell-selection.ts"
466
+ },
467
+ {
468
+ "path": "patterns/data-grid/hooks/use-data-grid-drag-scroll.ts",
469
+ "type": "registry:file",
470
+ "content": "import { type MouseEvent, type PointerEvent, useRef, useState } from 'react'\nimport {\n DRAG_CLICK_SUPPRESSION_MS,\n DRAG_SCROLL_THRESHOLD_PX,\n} from '../lib/constants'\nimport { isDragScrollExcludedTarget } from '../lib/dom'\n\ninterface DragScrollGesture {\n dragging: boolean\n pointerId: number\n startScrollLeft: number\n startX: number\n startY: number\n}\n\ninterface SuppressedDragClick {\n until: number\n x: number\n y: number\n}\n\nexport function useDataGridDragScroll() {\n const [isDragScrolling, setIsDragScrolling] = useState(false)\n const gestureRef = useRef<DragScrollGesture | null>(null)\n const suppressedClickRef = useRef<SuppressedDragClick | null>(null)\n\n function resetGesture(grid?: HTMLDivElement) {\n const gesture = gestureRef.current\n if (grid && gesture && grid.hasPointerCapture?.(gesture.pointerId)) {\n grid.releasePointerCapture(gesture.pointerId)\n }\n gestureRef.current = null\n setIsDragScrolling(false)\n }\n\n function onPointerDownCapture(event: PointerEvent<HTMLDivElement>) {\n if (\n event.button !== 0 ||\n event.pointerType === 'touch' ||\n isDragScrollExcludedTarget(event.target)\n ) {\n return\n }\n\n const grid = event.currentTarget\n if (grid.scrollWidth <= grid.clientWidth) return\n\n gestureRef.current = {\n dragging: false,\n pointerId: event.pointerId,\n startScrollLeft: grid.scrollLeft,\n startX: event.clientX,\n startY: event.clientY,\n }\n }\n\n function onPointerMove(event: PointerEvent<HTMLDivElement>) {\n const gesture = gestureRef.current\n if (!gesture || gesture.pointerId !== event.pointerId) return\n\n const deltaX = event.clientX - gesture.startX\n const deltaY = event.clientY - gesture.startY\n const horizontalMovement = Math.abs(deltaX)\n\n if (!gesture.dragging) {\n if (\n horizontalMovement < DRAG_SCROLL_THRESHOLD_PX ||\n horizontalMovement <= Math.abs(deltaY)\n ) {\n return\n }\n event.currentTarget.setPointerCapture?.(event.pointerId)\n gesture.dragging = true\n setIsDragScrolling(true)\n }\n\n event.preventDefault()\n event.currentTarget.scrollLeft = Math.max(\n 0,\n Math.min(\n event.currentTarget.scrollWidth - event.currentTarget.clientWidth,\n gesture.startScrollLeft - deltaX,\n ),\n )\n }\n\n function onPointerEnd(event: PointerEvent<HTMLDivElement>) {\n const gesture = gestureRef.current\n if (!gesture || gesture.pointerId !== event.pointerId) return\n if (gesture.dragging) {\n suppressedClickRef.current = {\n until: performance.now() + DRAG_CLICK_SUPPRESSION_MS,\n x: event.clientX,\n y: event.clientY,\n }\n }\n resetGesture(event.currentTarget)\n }\n\n function onClickCapture(event: MouseEvent<HTMLDivElement>) {\n const suppressed = suppressedClickRef.current\n if (!suppressed) return\n\n suppressedClickRef.current = null\n const isExpired = performance.now() > suppressed.until\n const isReleaseClick =\n Math.abs(event.clientX - suppressed.x) <= DRAG_SCROLL_THRESHOLD_PX &&\n Math.abs(event.clientY - suppressed.y) <= DRAG_SCROLL_THRESHOLD_PX\n if (isExpired || !isReleaseClick) return\n\n event.preventDefault()\n event.stopPropagation()\n }\n\n return {\n isDragScrolling,\n onClickCapture,\n onLostPointerCapture: onPointerEnd,\n onPointerCancel: onPointerEnd,\n onPointerDownCapture,\n onPointerMove,\n onPointerUp: onPointerEnd,\n }\n}\n",
471
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-drag-scroll.ts"
472
+ },
473
+ {
474
+ "path": "patterns/data-grid/hooks/use-data-grid-end-reached.ts",
475
+ "type": "registry:file",
476
+ "content": "import type { RefObject } from 'react'\nimport { useEndReached } from '../../collection/shared/hooks/use-end-reached'\nimport { BOTTOM_BAR_HEIGHT_PX, ROW_HEIGHT } from '../lib/constants'\nimport type { CollectionDensity } from '../types'\n\ninterface UseDataGridEndReachedOptions {\n density: CollectionDensity\n enabled: boolean\n gridRef: RefObject<HTMLDivElement | null>\n hasBottomBar: boolean\n loadingMore: boolean\n onEndReached?: () => void\n rowCount: number\n threshold: number\n}\n\nexport function useDataGridEndReached({\n density,\n enabled,\n gridRef,\n hasBottomBar,\n loadingMore,\n onEndReached,\n rowCount,\n threshold,\n}: UseDataGridEndReachedOptions) {\n useEndReached({\n enabled,\n loadingMore,\n measure: () => ({\n bottomInset: hasBottomBar ? BOTTOM_BAR_HEIGHT_PX : 0,\n rowHeight: ROW_HEIGHT[density],\n }),\n onEndReached,\n rowCount,\n scrollRef: gridRef,\n threshold,\n })\n}\n",
477
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-end-reached.ts"
478
+ },
479
+ {
480
+ "path": "patterns/data-grid/hooks/use-data-grid-focus.ts",
481
+ "type": "registry:file",
482
+ "content": "import { useCallback, useLayoutEffect, useState } from 'react'\nimport { createCellRegistry } from '../lib/cell-registry'\nimport { shouldPullFocus } from '../lib/dom'\n\ninterface UseDataGridFocusOptions {\n focusedColumnId?: string\n focusedRowId?: string\n hasInteracted: boolean\n}\n\nexport function useDataGridFocus({\n focusedColumnId,\n focusedRowId,\n hasInteracted,\n}: UseDataGridFocusOptions) {\n const [registry] = useState(createCellRegistry)\n\n useLayoutEffect(() => {\n if (!(hasInteracted && focusedRowId && focusedColumnId)) return\n const node = registry.get(focusedRowId, focusedColumnId)\n if (!node || node.contains(document.activeElement)) return\n queueMicrotask(() => {\n if (shouldPullFocus(node)) node.focus()\n })\n })\n\n const focusCell = useCallback(\n (rowId: string, columnId: string) => {\n queueMicrotask(() => registry.get(rowId, columnId)?.focus())\n },\n [registry],\n )\n\n return { focusCell, registry }\n}\n",
483
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-focus.ts"
484
+ },
485
+ {
486
+ "path": "patterns/data-grid/hooks/use-data-grid-row-context.ts",
487
+ "type": "registry:file",
488
+ "content": "import { createContext, useContext } from 'react'\nimport type { ColumnLayouts } from '../lib/column-layout'\nimport type { DataGridTableMeta } from '../lib/data-grid-features'\nimport type { CollectionDensity } from '../types'\nimport type { CellInteractions } from './use-data-grid-cell-events'\n\nexport type DataGridRowSelectionOption =\n | boolean\n | ((row: never) => boolean)\n | undefined\n\nexport interface DataGridRowContextValue {\n columnLayouts: ColumnLayouts\n columns: readonly { readonly id: string }[]\n enableRowSelection: DataGridRowSelectionOption\n meta: DataGridTableMeta | undefined\n density: CollectionDensity\n interactions: CellInteractions\n rowReorder: boolean\n rowSelectable: boolean\n}\n\nexport const DataGridRowContext = createContext<DataGridRowContextValue | null>(\n null,\n)\n\nexport function useDataGridRowContext() {\n const value = useContext(DataGridRowContext)\n if (!value) throw new Error('DataGridRow must render inside DataGrid')\n return value\n}\n",
489
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-row-context.ts"
490
+ },
491
+ {
492
+ "path": "patterns/data-grid/hooks/use-data-grid-rows.ts",
493
+ "type": "registry:file",
494
+ "content": "import type { RowData } from '@tanstack/react-table'\nimport { useMemo } from 'react'\nimport {\n collectGroupRows,\n computeGroupRuns,\n countGroupRows,\n EMPTY_GROUP_RUNS,\n mapRowGroups,\n} from '../../collection/shared/lib/group-runs'\nimport { buildBodyEntries } from '../lib/body-entries'\nimport type { DataGridTable } from '../lib/data-grid-features'\nimport { indexRowPositions, resolvePaginationRowOffset } from '../lib/row-index'\nimport { flattenExpandedRows } from '../lib/row-tree'\n\ninterface UseDataGridRowsOptions<TData extends RowData> {\n collapsedGroupIds: readonly string[]\n getRowGroup?: (row: TData) => string | null\n table: DataGridTable<TData>\n withGroupRows?: boolean\n}\n\nconst NO_GROUPS: ReadonlyMap<string, string | null> = new Map()\nconst NO_COUNTS: ReadonlyMap<string, number> = new Map()\nconst NO_GROUP_ROWS: ReadonlyMap<string, never[]> = new Map()\n\nexport function useDataGridRows<TData extends RowData>({\n collapsedGroupIds,\n getRowGroup,\n table,\n withGroupRows = false,\n}: UseDataGridRowsOptions<TData>) {\n const pageRows = table.getRowModel().rows\n const sortedRows = table.getSortedRowModel().rows\n const expandable = Boolean(table.options.enableExpanding)\n const expandedState =\n table.options.state?.expanded ?? table.atoms.expanded.get()\n const collectionRows = useMemo(\n () =>\n expandable ? flattenExpandedRows(sortedRows, expandedState) : sortedRows,\n [expandable, expandedState, sortedRows],\n )\n const headerRowCount = table.getHeaderGroups().length\n const paginationRowOffset = resolvePaginationRowOffset({\n expandable,\n manualPagination: Boolean(table.options.manualPagination),\n offset: table.options.meta?.dataGridPaginationRowOffset ?? 0,\n })\n\n const positions = useMemo(\n () => indexRowPositions(collectionRows),\n [collectionRows],\n )\n const groupByRowId = useMemo(\n () =>\n getRowGroup\n ? mapRowGroups(collectionRows, pageRows, getRowGroup)\n : NO_GROUPS,\n [collectionRows, getRowGroup, pageRows],\n )\n const groupRuns = useMemo(\n () =>\n getRowGroup\n ? computeGroupRuns(collectionRows, groupByRowId)\n : EMPTY_GROUP_RUNS,\n [collectionRows, getRowGroup, groupByRowId],\n )\n const groupCounts = useMemo(\n () => (getRowGroup ? countGroupRows(pageRows, groupByRowId) : NO_COUNTS),\n [getRowGroup, groupByRowId, pageRows],\n )\n const groupRows = useMemo(\n () =>\n getRowGroup && withGroupRows\n ? collectGroupRows(pageRows, groupByRowId)\n : NO_GROUP_ROWS,\n [getRowGroup, groupByRowId, pageRows, withGroupRows],\n )\n const collapsedGroups = useMemo(\n () => new Set(collapsedGroupIds),\n [collapsedGroupIds],\n )\n const rows = useMemo(\n () =>\n getRowGroup\n ? pageRows.filter((row) => {\n const group = groupByRowId.get(row.id)\n return !(group && collapsedGroups.has(group))\n })\n : pageRows,\n [collapsedGroups, getRowGroup, groupByRowId, pageRows],\n )\n const rowIndexById = useMemo(() => indexRowPositions(rows), [rows])\n const entries = useMemo(\n () =>\n buildBodyEntries({\n collapsedGroups,\n groupByRowId,\n groupCounts,\n groupRows,\n groupRuns,\n headerRowCount,\n pageRows,\n paginationRowOffset,\n positions,\n }),\n [\n collapsedGroups,\n groupByRowId,\n groupCounts,\n groupRows,\n groupRuns,\n headerRowCount,\n pageRows,\n paginationRowOffset,\n positions,\n ],\n )\n\n return {\n collectionRowCount: expandable\n ? collectionRows.length\n : table.getRowCount(),\n collectionRows,\n entries,\n groupRowCount: groupRuns.groupRowCount,\n headerRowCount,\n pageRows,\n paginationRowOffset,\n positions,\n rowIndexById,\n rows,\n }\n}\n",
495
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-rows.ts"
496
+ },
497
+ {
498
+ "path": "patterns/data-grid/hooks/use-data-grid-virtualizer.ts",
499
+ "type": "registry:file",
500
+ "content": "import type { Row, RowData } from '@tanstack/react-table'\nimport { observeElementRect, useVirtualizer } from '@tanstack/react-virtual'\nimport type { RefObject } from 'react'\nimport {\n BOTTOM_BAR_HEIGHT_PX,\n DEFAULT_MAX_HEIGHT_PX,\n FALLBACK_HEADER_HEIGHT_PX,\n HEADER_SELECTOR,\n ROW_HEIGHT,\n} from '../lib/constants'\nimport type { DataGridFeatures, DataGridTable } from '../lib/data-grid-features'\nimport { resolveVirtualScrollTop } from '../lib/virtual-scroll'\nimport type { CollectionDensity } from '../types'\n\ninterface UseDataGridVirtualizerOptions<TData extends RowData> {\n density: CollectionDensity\n enabled: boolean\n gridRef: RefObject<HTMLDivElement | null>\n hasBottomBar: boolean\n maxHeight?: number | string\n overscan: number\n rows: readonly Row<DataGridFeatures, TData>[]\n table: DataGridTable<TData>\n}\n\nexport function useDataGridVirtualizer<TData extends RowData>({\n density,\n enabled,\n gridRef,\n hasBottomBar,\n maxHeight,\n overscan,\n rows,\n table,\n}: UseDataGridVirtualizerOptions<TData>) {\n const fallbackHeight =\n typeof maxHeight === 'number' ? maxHeight : DEFAULT_MAX_HEIGHT_PX\n const rowVirtualizer = useVirtualizer({\n count: enabled ? rows.length : 0,\n estimateSize: () => ROW_HEIGHT[density],\n getItemKey: (index) => rows[index]?.id ?? index,\n getScrollElement: () => gridRef.current,\n initialRect:\n typeof maxHeight === 'number'\n ? { height: maxHeight, width: table.getTotalSize() }\n : undefined,\n observeElementRect: (instance, callback) =>\n observeElementRect(instance, (rect) =>\n callback({\n height: rect.height || fallbackHeight,\n width: rect.width || table.getTotalSize(),\n }),\n ),\n overscan,\n useFlushSync: false,\n })\n\n function scrollRowIntoView(rowIndex: number) {\n const grid = gridRef.current\n if (!grid) return\n const top = resolveVirtualScrollTop({\n bottomHeight: hasBottomBar ? BOTTOM_BAR_HEIGHT_PX : 0,\n headerHeight:\n grid.querySelector<HTMLElement>(HEADER_SELECTOR)?.clientHeight ||\n FALLBACK_HEADER_HEIGHT_PX,\n rowHeight: ROW_HEIGHT[density],\n rowIndex,\n scrollTop: grid.scrollTop,\n viewportHeight: grid.clientHeight || fallbackHeight,\n })\n if (top !== undefined) grid.scrollTo({ behavior: 'auto', top })\n }\n\n return {\n scrollRowIntoView,\n totalSize: rowVirtualizer.getTotalSize(),\n virtualItems: rowVirtualizer.getVirtualItems(),\n }\n}\n",
501
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid-virtualizer.ts"
502
+ },
503
+ {
504
+ "path": "patterns/data-grid/hooks/use-data-grid.ts",
505
+ "type": "registry:file",
506
+ "content": "'use client'\n\nimport {\n type ColumnFiltersState,\n type ColumnOrderState,\n type ColumnPinningState,\n type ColumnSizingState,\n type ColumnVisibilityState,\n type ExpandedState,\n type PaginationState,\n type ReactTable,\n type RowData,\n type RowSelectionState,\n type SortingState,\n type TableOptions,\n useTable,\n} from '@tanstack/react-table'\nimport { createElement, useMemo } from 'react'\nimport { useControllableTableState } from '../../collection/shared/hooks/use-controllable-table-state'\nimport { useLatestCallback } from '../../collection/shared/hooks/use-latest-callback'\nimport { DataGridCell } from '../components/data-grid-cell'\nimport {\n type DataGridColumnDef,\n type DataGridFeatures,\n type DataGridTableMeta,\n dataGridFeatures,\n} from '../lib/data-grid-features'\nimport type { CollectionDensity, DataGridCellValueChange } from '../types'\n\nexport interface UseDataGridOptions<TData extends RowData> {\n data: TData[]\n columns: DataGridColumnDef<TData>[]\n getRowId?: (row: TData, index: number) => string\n enableSorting?: boolean\n enableRowSelection?: boolean\n enableColumnResizing?: boolean\n enableColumnFilters?: boolean\n enablePagination?: boolean\n enableExpanding?: boolean\n getSubRows?: (row: TData, index: number) => TData[] | undefined\n expanded?: ExpandedState\n onExpandedChange?: (expanded: ExpandedState) => void\n sorting?: SortingState\n onSortingChange?: (sorting: SortingState) => void\n globalFilter?: unknown\n onGlobalFilterChange?: (globalFilter: unknown) => void\n columnFilters?: ColumnFiltersState\n onColumnFiltersChange?: (columnFilters: ColumnFiltersState) => void\n columnVisibility?: ColumnVisibilityState\n onColumnVisibilityChange?: (columnVisibility: ColumnVisibilityState) => void\n columnOrder?: ColumnOrderState\n onColumnOrderChange?: (columnOrder: ColumnOrderState) => void\n columnPinning?: ColumnPinningState\n onColumnPinningChange?: (columnPinning: ColumnPinningState) => void\n columnSizing?: ColumnSizingState\n onColumnSizingChange?: (columnSizing: ColumnSizingState) => void\n rowSelection?: RowSelectionState\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void\n pagination?: PaginationState\n onPaginationChange?: (pagination: PaginationState) => void\n pageSize?: number\n density?: CollectionDensity\n onDensityChange?: (density: CollectionDensity) => void\n onCellValueChange?: (change: DataGridCellValueChange) => void\n tableOptions?: Partial<TableOptions<DataGridFeatures, TData>>\n}\n\nexport interface UseDataGridReturn<TData extends RowData> {\n table: ReactTable<DataGridFeatures, TData>\n}\n\nexport function useDataGrid<TData extends RowData>({\n data,\n columns,\n getRowId,\n enableSorting = true,\n enableRowSelection = false,\n enableColumnResizing = true,\n enableColumnFilters = true,\n enablePagination = false,\n enableExpanding = false,\n getSubRows,\n expanded: controlledExpanded,\n onExpandedChange,\n sorting: controlledSorting,\n onSortingChange,\n globalFilter: controlledGlobalFilter,\n onGlobalFilterChange,\n columnFilters: controlledColumnFilters,\n onColumnFiltersChange,\n columnVisibility: controlledColumnVisibility,\n onColumnVisibilityChange,\n columnOrder: controlledColumnOrder,\n onColumnOrderChange,\n columnPinning: controlledColumnPinning,\n onColumnPinningChange,\n columnSizing: controlledColumnSizing,\n onColumnSizingChange,\n rowSelection: controlledRowSelection,\n onRowSelectionChange,\n pagination: controlledPagination,\n onPaginationChange,\n pageSize = 10,\n density: densityProp = 'short',\n onDensityChange,\n onCellValueChange,\n tableOptions,\n}: UseDataGridOptions<TData>): UseDataGridReturn<TData> {\n const initialState = tableOptions?.initialState\n const [sorting, setSorting] = useControllableTableState<SortingState>(\n controlledSorting,\n () => initialState?.sorting ?? [],\n onSortingChange,\n )\n const [globalFilter, setGlobalFilter] = useControllableTableState<unknown>(\n controlledGlobalFilter,\n () => initialState?.globalFilter ?? '',\n onGlobalFilterChange,\n )\n const [columnFilters, setColumnFilters] =\n useControllableTableState<ColumnFiltersState>(\n controlledColumnFilters,\n () => initialState?.columnFilters ?? [],\n onColumnFiltersChange,\n )\n const [columnVisibility, setColumnVisibility] =\n useControllableTableState<ColumnVisibilityState>(\n controlledColumnVisibility,\n () => initialState?.columnVisibility ?? {},\n onColumnVisibilityChange,\n )\n const [columnOrder, setColumnOrder] =\n useControllableTableState<ColumnOrderState>(\n controlledColumnOrder,\n () => initialState?.columnOrder ?? [],\n onColumnOrderChange,\n )\n const [columnPinning, setColumnPinning] =\n useControllableTableState<ColumnPinningState>(\n controlledColumnPinning,\n () => initialState?.columnPinning ?? { end: [], start: [] },\n onColumnPinningChange,\n )\n const [columnSizing, setColumnSizing] =\n useControllableTableState<ColumnSizingState>(\n controlledColumnSizing,\n () => initialState?.columnSizing ?? {},\n onColumnSizingChange,\n )\n const [rowSelection, setRowSelection] =\n useControllableTableState<RowSelectionState>(\n controlledRowSelection,\n () => initialState?.rowSelection ?? {},\n onRowSelectionChange,\n )\n const [pagination, setPagination] =\n useControllableTableState<PaginationState>(\n controlledPagination,\n () => ({\n pageIndex: initialState?.pagination?.pageIndex ?? 0,\n pageSize: initialState?.pagination?.pageSize ?? pageSize,\n }),\n onPaginationChange,\n )\n const [expanded, handleExpandedChange] =\n useControllableTableState<ExpandedState>(\n controlledExpanded,\n () => initialState?.expanded ?? {},\n onExpandedChange,\n )\n const [density, setDensity] = useControllableTableState<CollectionDensity>(\n onDensityChange ? densityProp : undefined,\n () => densityProp,\n onDensityChange,\n )\n\n const defaultColumn = useMemo<Partial<DataGridColumnDef<TData>>>(\n () => ({\n cell: (context) => createElement(DataGridCell<TData>, { context }),\n minSize: 80,\n }),\n [],\n )\n\n const consumerMeta = tableOptions?.meta\n const fallbackCellValueChange = consumerMeta?.onDataGridCellValueChange\n const hasCellValueChange = Boolean(\n onCellValueChange ?? fallbackCellValueChange,\n )\n const handleCellValueChange = useLatestCallback(\n (change: DataGridCellValueChange) =>\n (onCellValueChange ?? fallbackCellValueChange)?.(change),\n )\n const paginationRowOffset = enablePagination\n ? pagination.pageIndex * pagination.pageSize\n : 0\n const meta = useMemo<DataGridTableMeta>(\n () => ({\n ...consumerMeta,\n dataGridDensity: density,\n dataGridPaginationRowOffset: paginationRowOffset,\n onDataGridCellValueChange: hasCellValueChange\n ? handleCellValueChange\n : undefined,\n onDataGridDensityChange: setDensity,\n }),\n [\n consumerMeta,\n density,\n handleCellValueChange,\n hasCellValueChange,\n paginationRowOffset,\n setDensity,\n ],\n )\n\n const table = useTable<DataGridFeatures, TData>({\n features: dataGridFeatures,\n data,\n columns,\n defaultColumn,\n getRowId,\n state: {\n sorting,\n globalFilter,\n columnFilters,\n columnVisibility,\n columnOrder,\n columnPinning,\n columnSizing,\n rowSelection,\n expanded,\n ...(enablePagination ? { pagination } : {}),\n },\n enableSorting,\n enableRowSelection,\n enableColumnResizing,\n enableColumnFilters,\n enableExpanding,\n ...(enableExpanding\n ? { autoResetExpanded: false, getSubRows, paginateExpandedRows: false }\n : {}),\n columnResizeMode: 'onChange',\n globalFilterFn: 'includesString',\n onSortingChange: setSorting,\n onGlobalFilterChange: setGlobalFilter,\n onColumnFiltersChange: setColumnFilters,\n onColumnVisibilityChange: setColumnVisibility,\n onColumnOrderChange: setColumnOrder,\n onColumnPinningChange: setColumnPinning,\n onColumnSizingChange: setColumnSizing,\n onRowSelectionChange: setRowSelection,\n onExpandedChange: handleExpandedChange,\n onPaginationChange: setPagination,\n manualPagination: !enablePagination,\n ...tableOptions,\n meta,\n })\n\n return { table }\n}\n",
507
+ "target": "~/packages/ui/src/patterns/data-grid/hooks/use-data-grid.ts"
508
+ },
509
+ {
510
+ "path": "patterns/data-grid/index.ts",
511
+ "type": "registry:file",
512
+ "content": "export type { DataGridProps } from './components/data-grid'\nexport { DataGrid } from './components/data-grid'\nexport { DataGridCell } from './components/data-grid-cell'\nexport {\n DATA_GRID_COLUMN_TYPE_ICONS,\n DataGridColumnTypeIcon,\n} from './components/data-grid-column-type-icon'\nexport type { DataGridColumnsSubmenuProps } from './components/data-grid-columns-submenu'\nexport { DataGridColumnsSubmenu } from './components/data-grid-columns-submenu'\nexport type {\n DataGridConditionFilterField,\n DataGridConditionFilterLabels,\n DataGridConditionFiltersProps,\n} from './components/data-grid-condition-filters'\nexport { DataGridConditionFilters } from './components/data-grid-condition-filters'\nexport type {\n DataGridDensitySubmenuProps,\n DataGridDensityTable,\n} from './components/data-grid-density-submenu'\nexport { DataGridDensitySubmenu } from './components/data-grid-density-submenu'\nexport type { DataGridExpandToggleProps } from './components/data-grid-expand-toggle'\nexport { DataGridExpandToggle } from './components/data-grid-expand-toggle'\nexport type { DataGridFilterMenuProps } from './components/data-grid-filter-menu'\nexport { DataGridFilterMenu } from './components/data-grid-filter-menu'\nexport type { DataGridGroupCellContext } from './components/data-grid-group-row'\nexport type {\n DataGridPaginationProps,\n PaginatedTable,\n} from './components/data-grid-pagination'\nexport { DataGridPagination } from './components/data-grid-pagination'\nexport type { CreateRowDragColumnOptions } from './components/data-grid-row-drag-handle'\nexport { createRowDragColumn } from './components/data-grid-row-drag-handle'\nexport type {\n DataGridSearchProps,\n DataGridSearchTable,\n} from './components/data-grid-search'\nexport { DataGridSearch } from './components/data-grid-search'\nexport type { DataGridSelectionSummaryProps } from './components/data-grid-selection-summary'\nexport { DataGridSelectionSummary } from './components/data-grid-selection-summary'\nexport type { DataGridRowSkeletonAnatomy } from './components/data-grid-skeleton-rows'\nexport type {\n DataGridSortColumn,\n DataGridSortSubmenuProps,\n DataGridSortTable,\n} from './components/data-grid-sort-submenu'\nexport { DataGridSortSubmenu } from './components/data-grid-sort-submenu'\nexport type {\n UseDataGridOptions,\n UseDataGridReturn,\n} from './hooks/use-data-grid'\nexport { useDataGrid } from './hooks/use-data-grid'\nexport { createSelectColumn } from './lib/create-select-column'\nexport type {\n DataGridCondition,\n DataGridConditionField,\n DataGridConditionJoin,\n DataGridConditionKind,\n DataGridConditionOperator,\n MatchConditionsOptions,\n} from './lib/data-grid-conditions'\nexport {\n changeConditionOperator,\n createCondition,\n createDataGridConditionFilterFn,\n DATA_GRID_CONDITION_OPERATORS,\n getConditionOperators,\n isConditionComplete,\n matchesCondition,\n matchesConditions,\n normalizeConditionValue,\n} from './lib/data-grid-conditions'\nexport type {\n DataGridColumn,\n DataGridColumnDef,\n DataGridFeatures,\n DataGridHeader,\n DataGridTable,\n DataGridTableMeta,\n} from './lib/data-grid-features'\nexport { dataGridFeatures } from './lib/data-grid-features'\nexport type {\n DataGridAlign,\n DataGridCellRow,\n DataGridCellValueChange,\n DataGridCellVariant,\n DataGridColumnMeta,\n DataGridColumnType,\n DataGridRowDragAnnouncements,\n DataGridRowMove,\n DataGridSelectOption,\n} from './types'\nexport { DATA_GRID_COLUMN_TYPES } from './types'\n",
513
+ "target": "~/packages/ui/src/patterns/data-grid/index.ts"
514
+ },
515
+ {
516
+ "path": "patterns/data-grid/lib/body-entries.ts",
517
+ "type": "registry:file",
518
+ "content": "import type { Row, RowData } from '@tanstack/react-table'\nimport type { GroupRuns } from '../../collection/shared/lib/group-runs'\nimport type { DataGridFeatures } from './data-grid-features'\nimport { resolveCollectionRowIndex } from './row-index'\n\ntype GridRow<TData extends RowData> = Row<DataGridFeatures, TData>\n\nexport interface GroupBodyEntry<TData extends RowData> {\n ariaRowIndex: number\n collapsed: boolean\n count: number\n group: string\n key: string\n kind: 'group'\n rows: readonly GridRow<TData>[]\n}\n\nexport interface RowBodyEntry<TData extends RowData> {\n ariaRowIndex: number\n key: string\n kind: 'row'\n row: GridRow<TData>\n}\n\nexport type BodyEntry<TData extends RowData> =\n | GroupBodyEntry<TData>\n | RowBodyEntry<TData>\n\ninterface BodyEntriesInput<TData extends RowData> {\n collapsedGroups: ReadonlySet<string>\n groupByRowId: ReadonlyMap<string, string | null>\n groupCounts: ReadonlyMap<string, number>\n groupRows: ReadonlyMap<string, readonly GridRow<TData>[]>\n groupRuns: GroupRuns\n headerRowCount: number\n pageRows: readonly GridRow<TData>[]\n paginationRowOffset: number\n positions: ReadonlyMap<string, number>\n}\n\nconst NO_GROUP_ROWS: readonly never[] = []\n\nexport function buildBodyEntries<TData extends RowData>({\n collapsedGroups,\n groupByRowId,\n groupCounts,\n groupRows,\n groupRuns,\n headerRowCount,\n pageRows,\n paginationRowOffset,\n positions,\n}: BodyEntriesInput<TData>): BodyEntry<TData>[] {\n const entries: BodyEntry<TData>[] = []\n pageRows.forEach((row, rowIndex) => {\n const group = groupByRowId.get(row.id) ?? null\n const collectionIndex = resolveCollectionRowIndex({\n fallbackIndex: rowIndex,\n paginationRowOffset,\n positions,\n row,\n })\n const runPosition = positions.get(row.id) ?? -1\n const groupRunsBefore = groupRuns.runsThrough[runPosition] ?? 0\n const collapsed = group !== null && collapsedGroups.has(group)\n const startsGroup = Boolean(\n group && (groupRuns.runStarts[runPosition] || rowIndex === 0),\n )\n\n if (startsGroup && group) {\n entries.push({\n ariaRowIndex: headerRowCount + collectionIndex + groupRunsBefore,\n collapsed,\n count: groupCounts.get(group) ?? 0,\n group,\n key: `group-${group}-${row.id}`,\n kind: 'group',\n rows: groupRows.get(group) ?? NO_GROUP_ROWS,\n })\n }\n if (!collapsed) {\n entries.push({\n ariaRowIndex: headerRowCount + collectionIndex + groupRunsBefore + 1,\n key: row.id,\n kind: 'row',\n row,\n })\n }\n })\n return entries\n}\n",
519
+ "target": "~/packages/ui/src/patterns/data-grid/lib/body-entries.ts"
520
+ },
521
+ {
522
+ "path": "patterns/data-grid/lib/cell-registry.ts",
523
+ "type": "registry:file",
524
+ "content": "export interface CellIdentity {\n columnId: string\n rowId: string\n}\n\nexport interface CellRegistry {\n get: (rowId: string, columnId: string) => HTMLElement | undefined\n identify: (cell: HTMLElement) => CellIdentity | undefined\n registerRow: (rowId: string, node: HTMLElement | null) => void\n}\n\nexport function createCellRegistry(): CellRegistry {\n const rows = new Map<string, HTMLElement>()\n const rowIds = new Map<Element, string>()\n\n return {\n get: (rowId, columnId) => {\n const row = rows.get(rowId)\n if (!row) return undefined\n for (const child of Array.from(row.children)) {\n if (\n child instanceof HTMLElement &&\n child.dataset.columnId === columnId\n ) {\n return child\n }\n }\n return undefined\n },\n identify: (cell) => {\n const rowElement = cell.parentElement\n const rowId = rowElement ? rowIds.get(rowElement) : undefined\n const columnId = cell.dataset.columnId\n return rowId === undefined || columnId === undefined\n ? undefined\n : { columnId, rowId }\n },\n registerRow: (rowId, node) => {\n if (node) {\n rows.set(rowId, node)\n rowIds.set(node, rowId)\n return\n }\n const current = rows.get(rowId)\n if (current) rowIds.delete(current)\n rows.delete(rowId)\n },\n }\n}\n",
525
+ "target": "~/packages/ui/src/patterns/data-grid/lib/cell-registry.ts"
526
+ },
527
+ {
528
+ "path": "patterns/data-grid/lib/column-layout.ts",
529
+ "type": "registry:file",
530
+ "content": "import type { RowData } from '@tanstack/react-table'\nimport type { CSSProperties } from 'react'\nimport type { DataGridColumn } from './data-grid-features'\n\nexport interface ColumnLayout {\n pinned: false | 'start' | 'end'\n style: CSSProperties\n}\n\nexport type ColumnLayouts = ReadonlyMap<string, ColumnLayout>\n\nfunction columnStyle(size: number, fill: boolean): CSSProperties {\n return {\n flex: `${fill ? 1 : 0} 0 ${size}px`,\n minWidth: size,\n width: size,\n }\n}\n\nfunction pinnedColumnStyle<TData extends RowData>(\n column: DataGridColumn<TData>,\n pinned: ColumnLayout['pinned'],\n fillColumnId?: string,\n): CSSProperties {\n const base = columnStyle(\n column.getSize(),\n !pinned && column.id === fillColumnId,\n )\n if (pinned === 'start') {\n return {\n ...base,\n insetInlineStart: column.getStart('start'),\n position: 'sticky',\n zIndex: 5,\n }\n }\n if (pinned === 'end') {\n return {\n ...base,\n insetInlineEnd: column.getAfter('end'),\n position: 'sticky',\n zIndex: 5,\n }\n }\n return base\n}\n\nfunction sameStyle(a: CSSProperties, b: CSSProperties) {\n const keys = Object.keys(a) as (keyof CSSProperties)[]\n return (\n keys.length === Object.keys(b).length &&\n keys.every((key) => a[key] === b[key])\n )\n}\n\nexport function resolveColumnLayout<TData extends RowData>(\n column: DataGridColumn<TData>,\n fillColumnId?: string,\n): ColumnLayout {\n const pinned = column.getIsPinned()\n return { pinned, style: pinnedColumnStyle(column, pinned, fillColumnId) }\n}\n\nexport function buildColumnLayouts<TData extends RowData>(\n columns: readonly DataGridColumn<TData>[],\n fillColumnId?: string,\n previous?: ColumnLayouts,\n): ColumnLayouts {\n const layouts = new Map<string, ColumnLayout>()\n for (const column of columns) {\n const pinned = column.getIsPinned()\n const style = pinnedColumnStyle(column, pinned, fillColumnId)\n const before = previous?.get(column.id)\n layouts.set(\n column.id,\n before && before.pinned === pinned && sameStyle(before.style, style)\n ? before\n : { pinned, style },\n )\n }\n if (previous && previous.size === layouts.size) {\n const before = [...previous]\n const unchanged = [...layouts].every(\n ([id, layout], index) =>\n before[index]?.[0] === id && before[index]?.[1] === layout,\n )\n if (unchanged) return previous\n }\n return layouts\n}\n",
531
+ "target": "~/packages/ui/src/patterns/data-grid/lib/column-layout.ts"
532
+ },
533
+ {
534
+ "path": "patterns/data-grid/lib/columns.ts",
535
+ "type": "registry:file",
536
+ "content": "import type { RowData } from '@tanstack/react-table'\nimport { NON_NAVIGABLE_COLUMN_IDS } from './constants'\nimport type { DataGridColumn } from './data-grid-features'\n\nexport function isNavigableColumnId(columnId: string) {\n return !NON_NAVIGABLE_COLUMN_IDS.includes(columnId)\n}\n\nexport function findFirstNavigableColumnIndex<TData extends RowData>(\n columns: readonly DataGridColumn<TData>[],\n) {\n return Math.max(\n 0,\n columns.findIndex((column) => isNavigableColumnId(column.id)),\n )\n}\n\nexport function resolveFillColumnId<TData extends RowData>(\n columns: readonly DataGridColumn<TData>[],\n fillColumn: string | false | undefined,\n) {\n if (fillColumn === false) return undefined\n if (fillColumn !== undefined) return fillColumn\n for (let index = columns.length - 1; index >= 0; index -= 1) {\n const column = columns[index]\n if (column && !column.getIsPinned() && isNavigableColumnId(column.id)) {\n return column.id\n }\n }\n return undefined\n}\n\nexport function indexColumns<TData extends RowData>(\n columns: readonly DataGridColumn<TData>[],\n) {\n const indexes = new Map<string, number>()\n columns.forEach((column, index) => {\n indexes.set(column.id, index)\n })\n return indexes\n}\n",
537
+ "target": "~/packages/ui/src/patterns/data-grid/lib/columns.ts"
538
+ },
539
+ {
540
+ "path": "patterns/data-grid/lib/constants.ts",
541
+ "type": "registry:file",
542
+ "content": "import type { CollectionDensity, DataGridAlign } from '../types'\n\nexport const HEADER_ALIGN: Record<DataGridAlign, string> = {\n center: 'justify-center',\n end: 'justify-end',\n start: 'justify-start',\n}\n\nexport const CELL_ALIGN: Record<DataGridAlign, string> = {\n center: 'text-center justify-center',\n end: 'text-end justify-end',\n start: 'text-start justify-start',\n}\n\nexport const ROW_DENSITY: Record<CollectionDensity, string> = {\n compact: 'min-h-8',\n 'extra-tall': 'min-h-18',\n medium: 'min-h-11',\n short: 'min-h-9',\n tall: 'min-h-14',\n}\n\nexport const CELL_DENSITY: Record<CollectionDensity, string> = {\n compact: 'px-2 py-1',\n 'extra-tall': 'px-3 py-4',\n medium: 'px-2.5 py-2',\n short: 'px-2 py-1.5',\n tall: 'px-3 py-3',\n}\n\nexport const ROW_HEIGHT: Record<CollectionDensity, number> = {\n compact: 32,\n 'extra-tall': 72,\n medium: 44,\n short: 36,\n tall: 56,\n}\n\nexport const DEFAULT_MAX_HEIGHT_PX = 600\nexport const FALLBACK_HEADER_HEIGHT_PX = 36\nexport const BOTTOM_BAR_HEIGHT_PX = 36\n\nexport const DRAG_SCROLL_THRESHOLD_PX = 8\nexport const DRAG_CLICK_SUPPRESSION_MS = 500\nexport const PENDING_SELECT_CLICK_WINDOW_MS = 750\nexport const DRAG_SCROLL_EXCLUDED_TARGETS = [\n 'a',\n 'button',\n 'input',\n 'select',\n 'textarea',\n '[contenteditable=\"true\"]',\n '[data-grid-select-trigger]',\n '[role=\"button\"]',\n '[role=\"checkbox\"]',\n '[role=\"combobox\"]',\n '[role=\"columnheader\"]',\n '[role=\"menuitem\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"option\"]',\n '[role=\"separator\"]',\n].join(',')\n\nexport const SELECT_TRIGGER_SELECTOR = '[data-grid-select-trigger]'\nexport const CELL_SELECTOR = '[data-slot=\"data-grid-cell\"]'\nexport const HEADER_SELECTOR = '[data-slot=\"data-grid-header\"]'\n\nexport const RESIZE_STEP_PX = 8\nexport const DEFAULT_MIN_COLUMN_SIZE = 20\nexport const DEFAULT_MAX_COLUMN_SIZE = Number.MAX_SAFE_INTEGER\n\nexport const NON_NAVIGABLE_COLUMN_IDS: readonly string[] = [\n 'select',\n 'actions',\n 'drag',\n]\n",
543
+ "target": "~/packages/ui/src/patterns/data-grid/lib/constants.ts"
544
+ },
545
+ {
546
+ "path": "patterns/data-grid/lib/create-select-column.tsx",
547
+ "type": "registry:file",
548
+ "content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { Checkbox } from '@tc96/ui/checkbox'\nimport type { DataGridColumnDef } from './data-grid-features'\n\nexport function createSelectColumn<TData extends RowData>(\n options: {\n showRowNumbers?: boolean\n size?: number\n selectAllLabel?: string\n getRowLabel?: (row: TData) => string\n } = {},\n): DataGridColumnDef<TData> {\n const showRowNumbers = options.showRowNumbers ?? true\n\n return {\n id: 'select',\n meta: { align: 'center' },\n size: options.size ?? 44,\n enableSorting: false,\n enableHiding: false,\n enablePinning: false,\n enableResizing: false,\n header: ({ table }) => (\n <div className=\"flex items-center justify-center\">\n <Checkbox\n aria-label={options.selectAllLabel ?? 'Selecionar todos os registros'}\n checked={table.getIsAllPageRowsSelected()}\n indeterminate={\n table.getIsSomePageRowsSelected() &&\n !table.getIsAllPageRowsSelected()\n }\n onCheckedChange={(checked) =>\n table.toggleAllPageRowsSelected(Boolean(checked))\n }\n />\n </div>\n ),\n cell: ({ row }) => (\n <div className=\"group/marker relative flex size-full items-center justify-center\">\n {showRowNumbers ? (\n <span\n aria-hidden=\"true\"\n className=\"pointer-coarse:opacity-0 text-muted-foreground text-xs tabular-nums group-hover/marker:opacity-0 group-focus-within/marker:opacity-0 group-data-[state=selected]:opacity-0\"\n data-slot=\"data-grid-row-marker\"\n >\n {row.index + 1}\n </span>\n ) : null}\n <Checkbox\n aria-label={\n options.getRowLabel?.(row.original) ?? 'Selecionar registro'\n }\n checked={row.getIsSelected()}\n className={\n showRowNumbers\n ? 'pointer-coarse:opacity-100 absolute opacity-0 group-hover/marker:opacity-100 group-focus-within/marker:opacity-100 data-checked:opacity-100'\n : undefined\n }\n disabled={!row.getCanSelect()}\n onCheckedChange={(checked) => row.toggleSelected(Boolean(checked))}\n />\n </div>\n ),\n }\n}\n",
549
+ "target": "~/packages/ui/src/patterns/data-grid/lib/create-select-column.tsx"
550
+ },
551
+ {
552
+ "path": "patterns/data-grid/lib/data-grid-conditions.ts",
553
+ "type": "registry:file",
554
+ "content": "import type { FilterFn, RowData, TableFeatures } from '@tanstack/react-table'\nimport { isValidDate, parseDateValue } from '@tc96/ui/helpers/date'\nimport type { DataGridSelectOption } from '../types'\nimport type { DataGridFeatures } from './data-grid-features'\n\nexport const DATA_GRID_CONDITION_OPERATORS = {\n date: ['before', 'after', 'between'],\n number: ['eq', 'gt', 'lt', 'between'],\n option: ['is', 'is-not', 'is-any-of'],\n text: ['contains', 'is', 'is-not'],\n} as const\n\nexport type DataGridConditionKind = keyof typeof DATA_GRID_CONDITION_OPERATORS\n\nexport type DataGridConditionOperator =\n (typeof DATA_GRID_CONDITION_OPERATORS)[DataGridConditionKind][number]\n\nexport type DataGridConditionJoin = 'and' | 'or'\n\nexport interface DataGridConditionField {\n columnId: string\n kind: DataGridConditionKind\n label: string\n options?: readonly DataGridSelectOption[]\n}\n\nexport interface DataGridCondition {\n columnId: string\n id: string\n operator: DataGridConditionOperator\n value: readonly string[]\n}\n\nexport function getConditionOperators(\n kind: DataGridConditionKind,\n): readonly DataGridConditionOperator[] {\n return DATA_GRID_CONDITION_OPERATORS[kind]\n}\n\nexport function normalizeConditionValue(\n operator: DataGridConditionOperator,\n value: readonly string[],\n): readonly string[] {\n if (operator === 'between') return value.slice(0, 2)\n if (operator === 'is-any-of') return value\n return value.slice(0, 1)\n}\n\nexport function createCondition(\n field: DataGridConditionField,\n id: string,\n): DataGridCondition {\n const [operator] = getConditionOperators(field.kind)\n return {\n columnId: field.columnId,\n id,\n operator: operator ?? 'is',\n value: [],\n }\n}\n\nexport function changeConditionOperator(\n condition: DataGridCondition,\n operator: DataGridConditionOperator,\n): DataGridCondition {\n return {\n ...condition,\n operator,\n value: normalizeConditionValue(operator, condition.value),\n }\n}\n\nexport function isConditionComplete(condition: DataGridCondition): boolean {\n const filled = condition.value.filter((entry) => entry.trim() !== '')\n if (condition.operator === 'between') return filled.length === 2\n return filled.length > 0\n}\n\nconst normalizeText = (value: unknown) =>\n value === null || value === undefined\n ? ''\n : String(value).trim().toLocaleLowerCase()\n\nconst startOfDay = (value: unknown) => {\n if (value === null || value === undefined || value === '') return Number.NaN\n const date = parseDateValue(value)\n return isValidDate(date)\n ? new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime()\n : Number.NaN\n}\n\nconst toNumber = (value: unknown) =>\n value === null || value === undefined || value === ''\n ? Number.NaN\n : Number(value)\n\nconst isBetween = (value: number, first: number, second: number) =>\n Number.isFinite(value) &&\n value >= Math.min(first, second) &&\n value <= Math.max(first, second)\n\nfunction matchesText(condition: DataGridCondition, cell: unknown): boolean {\n const target = normalizeText(condition.value[0])\n const actual = normalizeText(cell)\n if (condition.operator === 'contains') return actual.includes(target)\n if (condition.operator === 'is-not') return actual !== target\n return actual === target\n}\n\nfunction matchesOption(condition: DataGridCondition, cell: unknown): boolean {\n const actual = cell === null || cell === undefined ? '' : String(cell)\n if (condition.operator === 'is-any-of')\n return condition.value.includes(actual)\n if (condition.operator === 'is-not') return actual !== condition.value[0]\n return actual === condition.value[0]\n}\n\nfunction matchesNumber(condition: DataGridCondition, cell: unknown): boolean {\n const actual = toNumber(cell)\n const [first, second] = condition.value.map(toNumber)\n if (first === undefined || !Number.isFinite(actual)) return false\n if (condition.operator === 'gt') return actual > first\n if (condition.operator === 'lt') return actual < first\n if (condition.operator === 'between') {\n return isBetween(actual, first, second ?? Number.NaN)\n }\n return actual === first\n}\n\nfunction matchesDate(condition: DataGridCondition, cell: unknown): boolean {\n const actual = startOfDay(cell)\n const [first, second] = condition.value.map(startOfDay)\n if (first === undefined || Number.isNaN(actual)) return false\n if (condition.operator === 'before') return actual < first\n if (condition.operator === 'after') return actual > first\n return isBetween(actual, first, second ?? Number.NaN)\n}\n\nexport function matchesCondition(\n condition: DataGridCondition,\n cell: unknown,\n kind: DataGridConditionKind,\n): boolean {\n if (kind === 'text') return matchesText(condition, cell)\n if (kind === 'option') return matchesOption(condition, cell)\n if (kind === 'number') return matchesNumber(condition, cell)\n return matchesDate(condition, cell)\n}\n\nexport interface MatchConditionsOptions {\n conditions: readonly DataGridCondition[]\n fields: readonly DataGridConditionField[]\n getValue: (columnId: string) => unknown\n join?: DataGridConditionJoin\n}\n\nexport function matchesConditions({\n conditions,\n fields,\n getValue,\n join = 'and',\n}: MatchConditionsOptions): boolean {\n const kinds = new Map(fields.map((field) => [field.columnId, field.kind]))\n const active = conditions.filter(\n (condition) =>\n isConditionComplete(condition) && kinds.has(condition.columnId),\n )\n if (active.length === 0) return true\n\n const test = (condition: DataGridCondition) => {\n const kind = kinds.get(condition.columnId)\n return kind !== undefined\n ? matchesCondition(condition, getValue(condition.columnId), kind)\n : true\n }\n return join === 'or' ? active.some(test) : active.every(test)\n}\n\nexport function createDataGridConditionFilterFn<\n TData extends RowData = RowData,\n TFeatures extends TableFeatures = DataGridFeatures,\n>(\n fields: readonly DataGridConditionField[],\n join: DataGridConditionJoin = 'and',\n): FilterFn<TFeatures, TData> {\n const filterFn: FilterFn<TFeatures, TData> = (row, _columnId, value) =>\n Array.isArray(value)\n ? matchesConditions({\n conditions: value,\n fields,\n getValue: (columnId) => row.getValue(columnId),\n join,\n })\n : true\n filterFn.autoRemove = (value) => !Array.isArray(value) || value.length === 0\n return filterFn\n}\n",
555
+ "target": "~/packages/ui/src/patterns/data-grid/lib/data-grid-conditions.ts"
556
+ },
557
+ {
558
+ "path": "patterns/data-grid/lib/data-grid-features.ts",
559
+ "type": "registry:file",
560
+ "content": "import {\n type Column,\n type ColumnDef,\n columnFilteringFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnResizingFeature,\n columnSizingFeature,\n columnVisibilityFeature,\n createExpandedRowModel,\n createFilteredRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n globalFilteringFeature,\n type Header,\n metaHelper,\n type RowData,\n rowExpandingFeature,\n rowPaginationFeature,\n rowSelectionFeature,\n rowSortingFeature,\n sortFns,\n type Table,\n tableFeatures,\n} from '@tanstack/react-table'\nimport type {\n CollectionDensity,\n DataGridCellValueChange,\n DataGridColumnMeta,\n} from '../types'\n\nexport interface DataGridTableMeta {\n dataGridDensity?: CollectionDensity\n dataGridPaginationRowOffset?: number\n onDataGridDensityChange?: (density: CollectionDensity) => void\n onDataGridCellValueChange?: (change: DataGridCellValueChange) => void\n}\n\nexport const dataGridFeatures = tableFeatures({\n columnFilteringFeature,\n globalFilteringFeature,\n rowSortingFeature,\n rowPaginationFeature,\n rowSelectionFeature,\n rowExpandingFeature,\n columnVisibilityFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnSizingFeature,\n columnResizingFeature,\n filteredRowModel: createFilteredRowModel(),\n sortedRowModel: createSortedRowModel(),\n expandedRowModel: createExpandedRowModel(),\n paginatedRowModel: createPaginatedRowModel(),\n filterFns,\n sortFns,\n columnMeta: metaHelper<DataGridColumnMeta>(),\n tableMeta: metaHelper<DataGridTableMeta>(),\n})\n\nexport type DataGridFeatures = typeof dataGridFeatures\n\nexport type DataGridTable<TData extends RowData> = Table<\n DataGridFeatures,\n TData\n>\n\nexport type DataGridColumnDef<TData extends RowData> = ColumnDef<\n DataGridFeatures,\n TData,\n unknown\n>\n\nexport type DataGridColumn<TData extends RowData> = Column<\n DataGridFeatures,\n TData,\n unknown\n>\n\nexport type DataGridHeader<TData extends RowData> = Header<\n DataGridFeatures,\n TData,\n unknown\n>\n",
561
+ "target": "~/packages/ui/src/patterns/data-grid/lib/data-grid-features.ts"
562
+ },
563
+ {
564
+ "path": "patterns/data-grid/lib/dom.ts",
565
+ "type": "registry:file",
566
+ "content": "import {\n CELL_SELECTOR,\n DRAG_SCROLL_EXCLUDED_TARGETS,\n SELECT_TRIGGER_SELECTOR,\n} from './constants'\n\nexport function shouldPullFocus(cell: HTMLElement) {\n const active = document.activeElement\n if (!active || active === document.body) return true\n if (cell.contains(active)) return false\n return Boolean(active.closest(CELL_SELECTOR))\n}\n\nexport function isDragScrollExcludedTarget(target: EventTarget | null) {\n return (\n target instanceof Element &&\n Boolean(target.closest(DRAG_SCROLL_EXCLUDED_TARGETS))\n )\n}\n\nexport function hasSelectTrigger(cell: Element) {\n return Boolean(cell.querySelector(SELECT_TRIGGER_SELECTOR))\n}\n",
567
+ "target": "~/packages/ui/src/patterns/data-grid/lib/dom.ts"
568
+ },
569
+ {
570
+ "path": "patterns/data-grid/lib/move-column.ts",
571
+ "type": "registry:file",
572
+ "content": "import type { RowData } from '@tanstack/react-table'\nimport type { DataGridTable } from './data-grid-features'\n\nexport function moveColumn<TData extends RowData>(\n table: DataGridTable<TData>,\n columnId: string,\n direction: -1 | 1,\n) {\n const leafIds = table.getAllLeafColumns().map((column) => column.id)\n const state = table.atoms.columnOrder.get()\n const order = state.length ? [...state] : leafIds\n const from = order.indexOf(columnId)\n const to = from + direction\n if (from === -1 || to < 0 || to >= order.length) return\n const [moved] = order.splice(from, 1)\n if (!moved) return\n order.splice(to, 0, moved)\n table.setColumnOrder(order)\n}\n",
573
+ "target": "~/packages/ui/src/patterns/data-grid/lib/move-column.ts"
574
+ },
575
+ {
576
+ "path": "patterns/data-grid/lib/resize.ts",
577
+ "type": "registry:file",
578
+ "content": "import type { RowData } from '@tanstack/react-table'\nimport {\n DEFAULT_MAX_COLUMN_SIZE,\n DEFAULT_MIN_COLUMN_SIZE,\n RESIZE_STEP_PX,\n} from './constants'\nimport type { DataGridColumn } from './data-grid-features'\n\nexport function resolveColumnSizeBounds<TData extends RowData>(\n column: DataGridColumn<TData>,\n) {\n return {\n max: column.columnDef.maxSize ?? DEFAULT_MAX_COLUMN_SIZE,\n min: column.columnDef.minSize ?? DEFAULT_MIN_COLUMN_SIZE,\n }\n}\n\nexport function resolveResizeKeySize<TData extends RowData>(\n column: DataGridColumn<TData>,\n key: string,\n) {\n const delta =\n key === 'ArrowLeft'\n ? -RESIZE_STEP_PX\n : key === 'ArrowRight'\n ? RESIZE_STEP_PX\n : 0\n if (!delta) return undefined\n const { max, min } = resolveColumnSizeBounds(column)\n return Math.min(max, Math.max(min, column.getSize() + delta))\n}\n",
579
+ "target": "~/packages/ui/src/patterns/data-grid/lib/resize.ts"
580
+ },
581
+ {
582
+ "path": "patterns/data-grid/lib/row-index.ts",
583
+ "type": "registry:file",
584
+ "content": "import type { Row, RowData } from '@tanstack/react-table'\nimport type { DataGridFeatures } from './data-grid-features'\n\nexport function indexRowPositions<TData extends RowData>(\n rows: readonly Row<DataGridFeatures, TData>[],\n) {\n const positions = new Map<string, number>()\n rows.forEach((row, position) => {\n positions.set(row.id, position)\n })\n return positions\n}\n\ninterface CollectionRowIndexInput<TData extends RowData> {\n fallbackIndex: number\n paginationRowOffset: number\n positions: ReadonlyMap<string, number>\n row: Row<DataGridFeatures, TData>\n}\n\nexport function resolveCollectionRowIndex<TData extends RowData>({\n fallbackIndex,\n paginationRowOffset,\n positions,\n row,\n}: CollectionRowIndexInput<TData>) {\n if (paginationRowOffset > 0) return paginationRowOffset + fallbackIndex\n return positions.get(row.id) ?? row.index ?? fallbackIndex\n}\n\ninterface PaginationRowOffsetInput {\n expandable: boolean\n manualPagination: boolean\n offset: number\n}\n\nexport function resolvePaginationRowOffset({\n expandable,\n manualPagination,\n offset,\n}: PaginationRowOffsetInput) {\n return expandable && !manualPagination ? 0 : offset\n}\n",
585
+ "target": "~/packages/ui/src/patterns/data-grid/lib/row-index.ts"
586
+ },
587
+ {
588
+ "path": "patterns/data-grid/lib/row-tree.ts",
589
+ "type": "registry:file",
590
+ "content": "import type { ExpandedState, Row, RowData } from '@tanstack/react-table'\nimport type { DataGridFeatures } from './data-grid-features'\n\ntype GridRow<TData extends RowData> = Row<DataGridFeatures, TData>\n\nexport function isRowIdExpanded(\n rowId: string,\n expanded: ExpandedState | undefined,\n) {\n if (expanded === true) return true\n return Boolean(expanded?.[rowId])\n}\n\nexport function flattenExpandedRows<TData extends RowData>(\n rows: readonly GridRow<TData>[],\n expanded: ExpandedState | undefined,\n) {\n const flat: GridRow<TData>[] = []\n const visit = (row: GridRow<TData>) => {\n flat.push(row)\n if (row.subRows.length > 0 && isRowIdExpanded(row.id, expanded)) {\n row.subRows.forEach(visit)\n }\n }\n rows.forEach(visit)\n return flat\n}\n\ninterface AriaExpandedInput {\n canExpand: boolean\n expandable: boolean\n expanded: boolean\n}\n\nexport function resolveAriaExpanded({\n canExpand,\n expandable,\n expanded,\n}: AriaExpandedInput) {\n return expandable && canExpand ? expanded : undefined\n}\n",
591
+ "target": "~/packages/ui/src/patterns/data-grid/lib/row-tree.ts"
592
+ },
593
+ {
594
+ "path": "patterns/data-grid/lib/selection.ts",
595
+ "type": "registry:file",
596
+ "content": "export type CellSelection = ReadonlyMap<string, ReadonlySet<string>>\n\nexport const EMPTY_SELECTION: CellSelection = new Map()\n\nexport function selectSingleCell(\n rowId: string,\n columnId: string,\n): CellSelection {\n return new Map([[rowId, new Set([columnId])]])\n}\n\nexport function addCellToSelection(\n selection: CellSelection,\n rowId: string,\n columnId: string,\n): CellSelection {\n const next = new Map(selection)\n next.set(rowId, new Set(selection.get(rowId)).add(columnId))\n return next\n}\n\nexport function isCellSelected(\n selection: CellSelection,\n rowId: string,\n columnId: string,\n) {\n return selection.get(rowId)?.has(columnId) ?? false\n}\n\nexport function pruneSelection(\n selection: CellSelection,\n isRowAvailable: (rowId: string) => boolean,\n isColumnAvailable: (columnId: string) => boolean,\n): CellSelection {\n if (selection.size === 0) return selection\n let changed = false\n const next = new Map<string, ReadonlySet<string>>()\n for (const [rowId, columnIds] of selection) {\n if (!isRowAvailable(rowId)) {\n changed = true\n continue\n }\n const kept = new Set<string>()\n for (const columnId of columnIds) {\n if (isColumnAvailable(columnId)) kept.add(columnId)\n }\n if (kept.size === columnIds.size) {\n next.set(rowId, columnIds)\n } else {\n changed = true\n if (kept.size > 0) next.set(rowId, kept)\n }\n }\n return changed ? next : selection\n}\n",
597
+ "target": "~/packages/ui/src/patterns/data-grid/lib/selection.ts"
598
+ },
599
+ {
600
+ "path": "patterns/data-grid/lib/skeleton.ts",
601
+ "type": "registry:file",
602
+ "content": "export function createSkeletonRowIds(count: number) {\n const ids: string[] = []\n for (let position = 1; position <= count; position += 1) {\n ids.push(`skeleton-${position}`)\n }\n return ids\n}\n",
603
+ "target": "~/packages/ui/src/patterns/data-grid/lib/skeleton.ts"
604
+ },
605
+ {
606
+ "path": "patterns/data-grid/lib/virtual-scroll.ts",
607
+ "type": "registry:file",
608
+ "content": "interface VirtualScrollInput {\n bottomHeight: number\n headerHeight: number\n rowHeight: number\n rowIndex: number\n scrollTop: number\n viewportHeight: number\n}\n\nexport function resolveVirtualScrollTop({\n bottomHeight,\n headerHeight,\n rowHeight,\n rowIndex,\n scrollTop,\n viewportHeight,\n}: VirtualScrollInput): number | undefined {\n const bodyViewportHeight = Math.max(\n rowHeight,\n viewportHeight - headerHeight - bottomHeight,\n )\n const rowStart = rowIndex * rowHeight\n const rowEnd = rowStart + rowHeight\n const bodyScrollStart = Math.max(0, scrollTop - headerHeight)\n\n if (rowStart < bodyScrollStart) return rowStart\n if (rowEnd > bodyScrollStart + bodyViewportHeight) {\n return rowEnd - bodyViewportHeight + headerHeight\n }\n return undefined\n}\n",
609
+ "target": "~/packages/ui/src/patterns/data-grid/lib/virtual-scroll.ts"
610
+ },
611
+ {
612
+ "path": "patterns/data-grid/types.ts",
613
+ "type": "registry:file",
614
+ "content": "import type {\n RowDragAnnouncements,\n RowMove,\n} from '../collection/shared/lib/row-reorder'\n\nexport type DataGridCellVariant =\n | 'text'\n | 'number'\n | 'select'\n | 'checkbox'\n | 'date'\n | 'badge'\n | 'custom'\n\nexport const DATA_GRID_COLUMN_TYPES = [\n 'title',\n 'text',\n 'number',\n 'select',\n 'multi-select',\n 'status',\n 'date',\n 'formula',\n 'relation',\n 'rollup',\n 'person',\n 'file',\n 'checkbox',\n 'url',\n 'email',\n 'phone',\n 'created-time',\n 'created-by',\n 'last-edited-time',\n 'last-edited-by',\n 'button',\n 'id',\n 'place',\n] as const\n\nexport type DataGridColumnType = (typeof DATA_GRID_COLUMN_TYPES)[number]\n\nexport type DataGridAlign = 'start' | 'center' | 'end'\n\nexport type { CollectionDensity } from '../collection/types/collection'\n\nexport interface DataGridSelectOption {\n label: string\n value: string\n}\n\nexport interface DataGridCellValueChange {\n columnId: string\n rowId: string\n value: string\n}\n\nexport interface DataGridCellRow {\n readonly id: string\n readonly index: number\n readonly original: unknown\n}\n\nexport type DataGridRowMove = RowMove\n\nexport type DataGridRowDragAnnouncements = RowDragAnnouncements\n\nexport interface DataGridColumnMeta {\n variant?: DataGridCellVariant\n type?: DataGridColumnType\n align?: DataGridAlign\n label?: string\n placeholder?: string\n options?: DataGridSelectOption[]\n editable?: boolean\n getCellError?: (row: DataGridCellRow, columnId: string) => string | undefined\n validate?: (value: string, row: DataGridCellRow) => string | undefined\n formatValue?: (value: string) => string\n emptyLabel?: string\n getCellLabel?: (columnLabel: string, displayValue: string) => string\n badgeVariant?:\n | 'primary'\n | 'secondary'\n | 'outline'\n | 'destructive'\n | 'success'\n | 'warning'\n | 'info'\n | 'error'\n}\n",
615
+ "target": "~/packages/ui/src/patterns/data-grid/types.ts"
616
+ },
617
+ {
618
+ "path": "patterns/properties/core.ts",
619
+ "type": "registry:file",
620
+ "content": "export {\n formatDateProperty,\n parseDatePropertyValue,\n serializeDatePropertyValue,\n} from './display/date/date-value'\nexport { formatDateRangeProperty } from './display/date-range/date-range-format'\nexport {\n defaultScheduleRecurrenceOptions,\n defaultScheduleReminderOptions,\n emptyScheduleValue,\n formatScheduleProperty,\n type ScheduleValue,\n scheduleRecurrenceLabel,\n} from './display/schedule/schedule-value'\nexport {\n type PropertyChangeContext,\n type PropertyIcon,\n type PropertyListChangeContext,\n type PropertyOption,\n type PropertyTone,\n propertyToneClassName,\n} from './shared/property-catalog'\nexport {\n type AttachmentPropertyLabels,\n type DatePropertyLabels,\n type DateRangePropertyLabels,\n defaultPropertyLabels,\n type EmailPropertyLabels,\n type PeoplePropertyLabels,\n type PhoneInputLabels,\n type PhonePropertyLabels,\n type PropertyCollectionLabels,\n type PropertyEntryListLabels,\n type PropertyLabels,\n type SchedulePropertyLabels,\n type SelectPropertyLabels,\n type TagsPropertyLabels,\n type TextPropertyLabels,\n} from './shared/property-labels'\nexport type { PropertyVariant } from './shared/property-surface'\n",
621
+ "target": "~/packages/ui/src/patterns/properties/core.ts"
622
+ },
623
+ {
624
+ "path": "patterns/properties/display/date-range/date-range-format.ts",
625
+ "type": "registry:file",
626
+ "content": "import type { DateRange } from '@daypicker/react'\nimport { formatShortDate, isValidDate } from '@tc96/ui/helpers/date'\nimport {\n type DateRangePropertyLabels,\n defaultPropertyLabels,\n} from '../../shared/property-labels'\n\nexport function formatDateRangeProperty(\n value: DateRange | undefined,\n fallback: string,\n locale: string,\n {\n from: fromLabel = defaultPropertyLabels.dateRange.from,\n until: untilLabel = defaultPropertyLabels.dateRange.until,\n }: Readonly<Partial<Pick<DateRangePropertyLabels, 'from' | 'until'>>> = {},\n): string {\n const from = formatEnd(value?.from, locale)\n const to = formatEnd(value?.to, locale)\n\n if (from && to) return `${from} – ${to}`\n if (from) return `${fromLabel} ${from}`\n if (to) return `${untilLabel} ${to}`\n return fallback\n}\n\nfunction formatEnd(date: Date | undefined, locale: string): string | null {\n return isValidDate(date) ? formatShortDate(date, locale) : null\n}\n",
627
+ "target": "~/packages/ui/src/patterns/properties/display/date-range/date-range-format.ts"
628
+ },
629
+ {
630
+ "path": "patterns/properties/display/date/date-property.tsx",
631
+ "type": "registry:file",
632
+ "content": "'use client'\n\nimport type { DayPickerLocale } from '@daypicker/react'\nimport { Calendar } from '@tc96/ui/calendar'\nimport { formatDateTime } from '@tc96/ui/helpers/date'\nimport { cn } from '@tc96/utils'\nimport { useState } from 'react'\nimport { emitChange, isEditable } from '../../shared/lib/property-change'\nimport {\n PropertyCalendarPopover,\n type PropertyCalendarProps,\n} from '../../shared/property-calendar-popover'\nimport type {\n PropertyChangeContext,\n PropertyPopoverDropdownPlacement,\n} from '../../shared/property-catalog'\nimport { propertyDisplayIcons } from '../../shared/property-display-meta'\nimport {\n type DatePropertyLabels,\n defaultPropertyAriaLabels,\n defaultPropertyLabels,\n resolvePropertyLabels,\n} from '../../shared/property-labels'\nimport {\n PropertySurface,\n type PropertyVariant,\n} from '../../shared/property-surface'\nimport { PropertyTooltip } from '../../shared/property-tooltip'\nimport {\n formatDateProperty,\n parseDatePropertyValue,\n serializeDatePropertyValue,\n} from './date-value'\n\nexport interface DatePropertyActionContext\n extends PropertyChangeContext<string | null> {\n date: Date | null\n}\n\nexport interface DatePropertyProps {\n value: string | null\n action?: (value: string | null, context: DatePropertyActionContext) => void\n allowClear?: boolean\n ariaLabel?: string\n calendarLocale?: DayPickerLocale\n calendarProps?: PropertyCalendarProps\n className?: string\n disabled?: boolean\n displayLabel?: string\n dropdownPlacement?: PropertyPopoverDropdownPlacement\n isOverdue?: boolean\n labels?: Partial<DatePropertyLabels>\n locale?: string\n readOnly?: boolean\n serializeDate?: (date: Date) => string\n timeZone?: string\n tooltip?: boolean\n variant?: PropertyVariant\n onValueChange?: (value: string | null) => void\n}\n\nfunction formatFullDate(\n value: string | null,\n locale: string,\n timeZone: string,\n): string | null {\n const date = parseDatePropertyValue(value)\n return date ? formatDateTime(date, locale, timeZone) : null\n}\n\nexport function DateProperty({\n action,\n allowClear = true,\n ariaLabel,\n calendarLocale,\n calendarProps,\n className,\n disabled = false,\n displayLabel,\n dropdownPlacement,\n isOverdue = false,\n labels: labelOverrides,\n locale = 'en-US',\n onValueChange,\n readOnly = false,\n serializeDate = serializeDatePropertyValue,\n timeZone = 'UTC',\n tooltip = false,\n value,\n variant = 'badge',\n}: Readonly<DatePropertyProps>) {\n const [open, setOpen] = useState(false)\n const selectedDate = parseDatePropertyValue(value)\n const accessibleLabel = ariaLabel ?? defaultPropertyAriaLabels.date\n const labels = resolvePropertyLabels(\n defaultPropertyLabels.date,\n labelOverrides,\n )\n\n const handleChange = (nextValue: string | null, date: Date | null) => {\n if (nextValue !== value) {\n emitChange({ action, onValueChange }, nextValue, {\n date,\n previousValue: value,\n })\n }\n setOpen(false)\n }\n\n if (!isEditable({ action, onValueChange, readOnly })) {\n return (\n <DatePropertyBadge\n className={className}\n displayLabel={displayLabel}\n isOverdue={isOverdue}\n labels={labels}\n locale={locale}\n timeZone={timeZone}\n tooltip={tooltip}\n value={value}\n variant={variant}\n />\n )\n }\n\n const label =\n displayLabel ?? formatDateProperty(value, labels.fallback, locale, timeZone)\n\n return (\n <PropertyCalendarPopover\n ariaLabel={accessibleLabel}\n className={cn(isOverdue && 'font-medium', className)}\n muted={!value}\n clear={\n allowClear\n ? { label: labels.clear, onClear: () => handleChange(null, null) }\n : undefined\n }\n disabled={disabled}\n dropdownPlacement={dropdownPlacement}\n icon={propertyDisplayIcons.date}\n label={label}\n onOpenChange={setOpen}\n open={open}\n overdue={isOverdue}\n tooltip={tooltip ? formatFullDate(value, locale, timeZone) : null}\n variant={variant}\n >\n <Calendar\n defaultMonth={selectedDate ?? undefined}\n locale={calendarLocale}\n mode=\"single\"\n selected={selectedDate ?? undefined}\n onSelect={(date) => {\n if (!date) return\n handleChange(serializeDate(date), date)\n }}\n {...calendarProps}\n />\n </PropertyCalendarPopover>\n )\n}\n\nexport function DatePropertyBadge({\n className,\n displayLabel,\n isOverdue = false,\n labels,\n locale = 'en-US',\n timeZone = 'UTC',\n tooltip = false,\n value,\n variant = 'badge',\n}: Readonly<\n Pick<\n DatePropertyProps,\n | 'className'\n | 'displayLabel'\n | 'isOverdue'\n | 'labels'\n | 'locale'\n | 'timeZone'\n | 'tooltip'\n | 'value'\n | 'variant'\n >\n>) {\n const fallback = labels?.fallback ?? defaultPropertyLabels.date.fallback\n const label =\n displayLabel ?? formatDateProperty(value, fallback, locale, timeZone)\n const fullDate = tooltip ? formatFullDate(value, locale, timeZone) : null\n\n const DateIcon = propertyDisplayIcons.date\n const surface = (\n <PropertySurface\n className={cn('max-w-full', isOverdue && 'font-medium', className)}\n data-overdue={isOverdue || undefined}\n data-slot=\"property-surface\"\n muted={!value}\n tabIndex={fullDate ? 0 : undefined}\n variant={variant}\n >\n <DateIcon aria-hidden className=\"size-4\" data-slot=\"property-icon\" />\n <span className=\"truncate\">{label}</span>\n </PropertySurface>\n )\n\n if (!fullDate) return surface\n\n return <PropertyTooltip content={fullDate} trigger={surface} />\n}\n",
633
+ "target": "~/packages/ui/src/patterns/properties/display/date/date-property.tsx"
634
+ },
635
+ {
636
+ "path": "patterns/properties/display/date/date-value.ts",
637
+ "type": "registry:file",
638
+ "content": "import {\n formatShortDate,\n parseIsoDate,\n serializeIsoDay,\n} from '@tc96/ui/helpers/date'\n\nexport function formatDateProperty(\n value: string | null,\n fallback: string,\n locale: string,\n timeZone: string,\n): string {\n const date = parseIsoDate(value)\n return date ? formatShortDate(date, locale, timeZone) : fallback\n}\n\nexport function parseDatePropertyValue(value: string | null): Date | null {\n return parseIsoDate(value)\n}\n\nexport function serializeDatePropertyValue(date: Date): string {\n return serializeIsoDay(date)\n}\n",
639
+ "target": "~/packages/ui/src/patterns/properties/display/date/date-value.ts"
640
+ },
641
+ {
642
+ "path": "patterns/properties/display/person/person-option-content.tsx",
643
+ "type": "registry:file",
644
+ "content": "'use client'\n\nimport { UserIcon } from '@phosphor-icons/react'\nimport { Avatar, AvatarFallback, AvatarImage } from '@tc96/ui/avatar'\nimport { resolveInitials } from '@tc96/ui/helpers/initials'\nimport type { PropertyOption } from '../../shared/property-catalog'\n\nexport type PersonAvatarSize = 'xs' | 'sm' | 'default' | 'lg' | 'xl'\n\nconst personAvatarSizeClassNames: Record<PersonAvatarSize, string | undefined> =\n {\n xs: '[--avatar-size:--spacing(4)] text-[0.625rem]',\n sm: '[--avatar-size:--spacing(6)] text-[0.625rem]',\n default: undefined,\n lg: '[--avatar-size:--spacing(10)]',\n xl: '[--avatar-size:--spacing(12)]',\n }\n\nexport interface PersonPropertyOption<TValue extends string = string>\n extends PropertyOption<TValue> {\n fallback?: string\n imageUrl?: string\n supportingLabel?: string\n}\n\nexport function PersonAvatar({\n option,\n size = 'sm',\n}: Readonly<{\n option: PersonPropertyOption | null\n size?: PersonAvatarSize\n}>) {\n const resolved = option ? resolveInitials(option) : null\n const fallback =\n size === 'xs' && resolved !== null\n ? (Array.from(resolved)[0] ?? '')\n : resolved\n return (\n <Avatar className={personAvatarSizeClassNames[size]} data-size={size}>\n {option?.imageUrl ? <AvatarImage alt=\"\" src={option.imageUrl} /> : null}\n <AvatarFallback className=\"border border-input\">\n {fallback ?? <UserIcon aria-hidden className=\"size-4\" />}\n </AvatarFallback>\n </Avatar>\n )\n}\n\nexport function PersonOptionContent({\n option,\n size,\n}: Readonly<{\n option: PersonPropertyOption\n size?: PersonAvatarSize\n}>) {\n return (\n <span className=\"flex min-w-0 items-center gap-1.5\">\n <PersonAvatar option={option} size={size} />\n <span className=\"min-w-0 truncate\">{option.label}</span>\n {option.supportingLabel ? (\n <span className=\"hidden text-muted-foreground text-xs in-data-[slot=combobox-chip]:text-foreground/72 sm:inline\">\n {option.supportingLabel}\n </span>\n ) : null}\n </span>\n )\n}\n",
645
+ "target": "~/packages/ui/src/patterns/properties/display/person/person-option-content.tsx"
646
+ },
647
+ {
648
+ "path": "patterns/properties/display/person/person-property.tsx",
649
+ "type": "registry:file",
650
+ "content": "'use client'\n\nimport { SelectItem } from '@tc96/ui/select'\nimport { cn } from '@tc96/utils'\nimport { emitChange, isEditable } from '../../shared/lib/property-change'\nimport { resolveOption } from '../../shared/lib/property-options'\nimport type {\n PropertyChangeContext,\n PropertySelectDropdownPlacement,\n} from '../../shared/property-catalog'\nimport { propertyDisplayIcons } from '../../shared/property-display-meta'\nimport {\n defaultPropertyAriaLabels,\n defaultPropertyPlaceholders,\n} from '../../shared/property-labels'\nimport {\n PropertySelectShell,\n propertySelectItemClassName,\n} from '../../shared/property-select-shell'\nimport {\n PropertySurface,\n type PropertyVariant,\n} from '../../shared/property-surface'\nimport {\n PersonAvatar,\n type PersonAvatarSize,\n PersonOptionContent,\n type PersonPropertyOption,\n} from './person-option-content'\n\nexport type { PersonPropertyOption }\n\nexport interface PersonPropertyActionContext<TValue extends string = string>\n extends PropertyChangeContext<TValue | null> {\n option: PersonPropertyOption<TValue>\n}\n\nexport interface PersonPropertyProps<TValue extends string = string> {\n value: TValue | null\n options: readonly PersonPropertyOption<TValue>[]\n action?: (value: TValue, context: PersonPropertyActionContext<TValue>) => void\n ariaLabel?: string\n avatarSize?: PersonAvatarSize\n className?: string\n disabled?: boolean\n display?: 'avatar' | 'full'\n dropdownPlacement?: PropertySelectDropdownPlacement\n placeholder?: string\n readOnly?: boolean\n variant?: PropertyVariant\n onValueChange?: (value: TValue) => void\n}\n\nexport function PersonProperty<TValue extends string = string>({\n action,\n ariaLabel,\n avatarSize = 'xs',\n className,\n disabled = false,\n display = 'full',\n dropdownPlacement,\n onValueChange,\n options,\n placeholder = defaultPropertyPlaceholders.person,\n readOnly = false,\n value,\n variant = 'badge',\n}: Readonly<PersonPropertyProps<TValue>>) {\n const selectedOption = value ? resolveOption(options, value) : null\n const accessibleLabel = ariaLabel ?? defaultPropertyAriaLabels.person\n\n return (\n <PropertySelectShell\n ariaLabel={`${accessibleLabel}: ${selectedOption?.label ?? placeholder}`}\n className={className}\n disabled={disabled}\n dropdownPlacement={dropdownPlacement}\n items={options}\n itemToStringLabel={(option) => option.label}\n itemToStringValue={(option) => option.value}\n onValueChange={(option) => {\n if (option && option.value !== value) {\n emitChange({ action, onValueChange }, option.value, {\n option,\n previousValue: value,\n })\n }\n }}\n muted={!selectedOption}\n readOnly={!isEditable({ action, onValueChange, readOnly })}\n renderValue={(option) => (\n <PersonPropertyContent\n avatarSize={avatarSize}\n display={display}\n option={option}\n placeholder={placeholder}\n />\n )}\n variant={variant}\n value={selectedOption}\n >\n {options.map((option) => (\n <SelectItem\n aria-label={option.label}\n key={option.value}\n className={propertySelectItemClassName}\n value={option}\n >\n <PersonPropertyContent option={option} placeholder={placeholder} />\n </SelectItem>\n ))}\n </PropertySelectShell>\n )\n}\n\nexport function PersonPropertyBadge<TValue extends string = string>({\n ariaLabel,\n className,\n display = 'full',\n option,\n placeholder = defaultPropertyPlaceholders.person,\n variant = 'badge',\n}: Readonly<{\n ariaLabel?: string\n className?: string\n display?: 'avatar' | 'full'\n option: PersonPropertyOption<TValue> | null\n placeholder?: string\n variant?: PropertyVariant\n}>) {\n return (\n <PropertySurface\n aria-label={ariaLabel}\n className={cn('max-w-full', className)}\n muted={!option}\n variant={variant}\n >\n <PersonPropertyContent\n avatarSize=\"xs\"\n display={display}\n option={option}\n placeholder={placeholder}\n />\n </PropertySurface>\n )\n}\n\nfunction PersonPropertyContent<TValue extends string = string>({\n avatarSize,\n display,\n option,\n placeholder,\n}: Readonly<{\n avatarSize?: PersonAvatarSize\n display?: 'avatar' | 'full'\n option: PersonPropertyOption<TValue> | null\n placeholder: string\n}>) {\n if (display === 'avatar') {\n return <PersonAvatar option={option} size={avatarSize} />\n }\n\n if (!option) {\n const AddIcon = propertyDisplayIcons.personAdd\n\n return (\n <span className=\"flex min-w-0 items-center gap-1.5 text-muted-foreground\">\n <AddIcon aria-hidden className=\"size-4\" />\n <span className=\"truncate\">{placeholder}</span>\n </span>\n )\n }\n\n return <PersonOptionContent option={option} size={avatarSize} />\n}\n",
651
+ "target": "~/packages/ui/src/patterns/properties/display/person/person-property.tsx"
652
+ },
653
+ {
654
+ "path": "patterns/properties/display/schedule/schedule-value.ts",
655
+ "type": "registry:file",
656
+ "content": "import type { PropertyOption } from '../../shared/property-catalog'\nimport {\n defaultPropertyLabels,\n type SchedulePropertyLabels,\n} from '../../shared/property-labels'\n\nexport interface ScheduleValue {\n allDay: boolean\n endTime: string\n frequency: string | null\n from: Date | null\n reminders: readonly string[]\n startTime: string\n until: string | null\n}\n\nexport const emptyScheduleValue: ScheduleValue = {\n allDay: true,\n endTime: '',\n frequency: null,\n from: null,\n reminders: [],\n startTime: '',\n until: null,\n}\n\nexport function scheduleRecurrenceOptions(\n labels: Pick<\n SchedulePropertyLabels,\n 'daily' | 'monthly' | 'weekdays' | 'weekly' | 'yearly'\n >,\n): readonly PropertyOption[] {\n return [\n { label: labels.daily, value: 'daily' },\n { label: labels.weekdays, value: 'weekdays' },\n { label: labels.weekly, value: 'weekly' },\n { label: labels.monthly, value: 'monthly' },\n { label: labels.yearly, value: 'yearly' },\n ]\n}\n\nexport function scheduleReminderOptions(\n labels: Pick<\n SchedulePropertyLabels,\n | 'oneDayBefore'\n | 'oneHourBefore'\n | 'tenMinutesBefore'\n | 'thirtyMinutesBefore'\n >,\n): readonly PropertyOption[] {\n return [\n { label: labels.tenMinutesBefore, value: '10' },\n { label: labels.thirtyMinutesBefore, value: '30' },\n { label: labels.oneHourBefore, value: '60' },\n { label: labels.oneDayBefore, value: '1440' },\n ]\n}\n\nexport const defaultScheduleRecurrenceOptions: readonly PropertyOption[] =\n scheduleRecurrenceOptions(defaultPropertyLabels.schedule)\n\nexport const defaultScheduleReminderOptions: readonly PropertyOption[] =\n scheduleReminderOptions(defaultPropertyLabels.schedule)\n\nexport function sortScheduleReminders(\n reminders: readonly string[],\n options: readonly PropertyOption[],\n): string[] {\n const rank = (reminder: string) => {\n const index = options.findIndex((option) => option.value === reminder)\n return index === -1 ? options.length : index\n }\n\n return [...reminders].sort((left, right) => rank(left) - rank(right))\n}\n\nexport function startOfLocalDay(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\nexport function addLocalDays(date: Date, days: number): Date {\n const next = startOfLocalDay(date)\n next.setDate(next.getDate() + days)\n return next\n}\n\nexport function formatScheduleDay(date: Date, locale: string): string {\n return new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'short' })\n .format(date)\n .replaceAll('.', '')\n}\n\nexport function formatScheduleProperty(\n value: ScheduleValue,\n fallback: string,\n locale: string,\n): string {\n if (!value.from) return fallback\n\n const parts = [formatScheduleDay(value.from, locale)]\n if (!value.allDay && value.startTime) {\n parts.push(\n value.endTime ? `${value.startTime} – ${value.endTime}` : value.startTime,\n )\n }\n\n return parts.join(' · ')\n}\n\nexport function scheduleRecurrenceLabel(\n frequency: string | null,\n options: readonly PropertyOption[],\n): string | null {\n if (!frequency) return null\n return options.find((option) => option.value === frequency)?.label ?? null\n}\n",
657
+ "target": "~/packages/ui/src/patterns/properties/display/schedule/schedule-value.ts"
658
+ },
659
+ {
660
+ "path": "patterns/properties/display/select/select-property.tsx",
661
+ "type": "registry:file",
662
+ "content": "'use client'\n\nimport { CircleDashedIcon } from '@phosphor-icons/react'\nimport { SelectGroup, SelectGroupLabel, SelectItem } from '@tc96/ui/select'\nimport { cn } from '@tc96/utils'\nimport { useState } from 'react'\nimport { emitChange, isEditable } from '../../shared/lib/property-change'\nimport {\n type PropertyChangeContext,\n type PropertyOption,\n type PropertySelectDropdownPlacement,\n propertyToneClassName,\n} from '../../shared/property-catalog'\nimport {\n defaultPropertyLabels,\n resolvePropertyLabels,\n type SelectPropertyLabels,\n} from '../../shared/property-labels'\nimport {\n PropertySelectShell,\n propertySelectItemClassName,\n} from '../../shared/property-select-shell'\nimport type { PropertyVariant } from '../../shared/property-surface'\n\nexport interface SelectPropertyGroup {\n label: string\n options: readonly PropertyOption[]\n}\n\ninterface SelectPropertyBaseProps {\n ariaLabel: string\n value: string | null\n action?: (\n value: string | null,\n context: PropertyChangeContext<string | null>,\n ) => void\n allowEmpty?: boolean\n className?: string\n disabled?: boolean\n dropdownPlacement?: PropertySelectDropdownPlacement\n labels?: Partial<SelectPropertyLabels>\n placeholder?: string\n readOnly?: boolean\n variant?: PropertyVariant\n onValueChange?: (value: string | null) => void\n}\n\nexport type SelectPropertyItems =\n | { groups?: undefined; options: readonly PropertyOption[] }\n | { groups: readonly SelectPropertyGroup[]; options?: undefined }\n\nexport type SelectPropertyProps = SelectPropertyBaseProps & SelectPropertyItems\n\nexport function SelectProperty({\n action,\n allowEmpty = false,\n ariaLabel,\n className,\n disabled = false,\n dropdownPlacement,\n groups,\n labels: labelOverrides,\n onValueChange,\n options,\n placeholder,\n readOnly = false,\n value,\n variant = 'badge',\n}: Readonly<SelectPropertyProps>) {\n const labels = resolvePropertyLabels(\n defaultPropertyLabels.select,\n labelOverrides,\n )\n const catalog = groups ? groups.flatMap((group) => group.options) : options\n const selectedOption =\n value === null ? undefined : catalog.find((o) => o.value === value)\n const emptyOption: PropertyOption | null = allowEmpty\n ? {\n icon: catalog.some((option) => option.icon)\n ? CircleDashedIcon\n : undefined,\n label: labels.emptyOption,\n tone: 'neutral',\n value: '',\n }\n : null\n const [chosenEmpty, setChosenEmpty] = useState(false)\n const [seenValue, setSeenValue] = useState(value)\n if (seenValue !== value) {\n setSeenValue(value)\n if (value !== null) setChosenEmpty(false)\n }\n const explicitEmpty = emptyOption !== null && value === null && chosenEmpty\n const absent = value === null && !explicitEmpty\n\n const currentLabel =\n selectedOption?.label ??\n (explicitEmpty\n ? emptyOption.label\n : value === null\n ? (placeholder ?? labels.fallback)\n : labels.fallback)\n\n const accessibleLabel = absent ? ariaLabel : `${ariaLabel}: ${currentLabel}`\n const items = emptyOption ? [emptyOption, ...catalog] : catalog\n\n return (\n <PropertySelectShell\n ariaLabel={accessibleLabel}\n className={className}\n disabled={disabled}\n dropdownPlacement={dropdownPlacement}\n items={items}\n itemToStringLabel={(option) => option.label}\n itemToStringValue={(option) => option.value}\n muted={absent}\n onValueChange={(option) => {\n if (!option) return\n const next = option.value === '' ? null : option.value\n setChosenEmpty(next === null)\n if (next === value) return\n emitChange({ action, onValueChange }, next, { previousValue: value })\n }}\n readOnly={!isEditable({ action, onValueChange, readOnly })}\n variant={variant}\n renderValue={() => (\n <SelectPropertyContent\n label={currentLabel}\n option={selectedOption ?? (explicitEmpty ? emptyOption : undefined)}\n />\n )}\n value={selectedOption ?? (explicitEmpty ? emptyOption : null)}\n >\n {emptyOption ? (\n <SelectItem className={propertySelectItemClassName} value={emptyOption}>\n <SelectPropertyContent\n label={emptyOption.label}\n option={emptyOption}\n />\n </SelectItem>\n ) : null}\n {groups\n ? groups.map((group) => (\n <SelectGroup key={group.label}>\n <SelectGroupLabel>{group.label}</SelectGroupLabel>\n {group.options.map((option) => (\n <SelectItem\n key={option.value}\n className={propertySelectItemClassName}\n value={option}\n >\n <SelectPropertyContent label={option.label} option={option} />\n </SelectItem>\n ))}\n </SelectGroup>\n ))\n : catalog.map((option) => (\n <SelectItem\n key={option.value}\n className={propertySelectItemClassName}\n value={option}\n >\n <SelectPropertyContent label={option.label} option={option} />\n </SelectItem>\n ))}\n </PropertySelectShell>\n )\n}\n\nfunction SelectPropertyContent({\n label,\n option,\n}: Readonly<{ label: string; option?: PropertyOption }>) {\n const Icon = option?.icon\n\n return (\n <span className=\"flex min-w-0 items-center gap-1.5\">\n {Icon ? (\n <Icon\n aria-hidden\n className={cn(\n 'size-4',\n option?.tone ? propertyToneClassName[option.tone] : undefined,\n )}\n data-slot=\"property-icon\"\n weight={option?.weight}\n />\n ) : null}\n <span className=\"truncate\">{label}</span>\n </span>\n )\n}\n",
663
+ "target": "~/packages/ui/src/patterns/properties/display/select/select-property.tsx"
664
+ },
665
+ {
666
+ "path": "patterns/properties/shared/lib/property-change.ts",
667
+ "type": "registry:file",
668
+ "content": "export interface PropertyChangeHandlers<TValue, TContext> {\n action?: (value: TValue, context: TContext) => void\n onValueChange?: (value: TValue) => void\n}\n\nexport function isEditable({\n action,\n onValueChange,\n readOnly = false,\n}: Readonly<{\n action?: unknown\n onValueChange?: unknown\n readOnly?: boolean\n}>): boolean {\n return !readOnly && Boolean(action ?? onValueChange)\n}\n\nexport function emitChange<TValue, TContext>(\n { action, onValueChange }: Readonly<PropertyChangeHandlers<TValue, TContext>>,\n value: TValue,\n context: TContext,\n): void {\n if (action) {\n action(value, context)\n return\n }\n onValueChange?.(value)\n}\n",
669
+ "target": "~/packages/ui/src/patterns/properties/shared/lib/property-change.ts"
670
+ },
671
+ {
672
+ "path": "patterns/properties/shared/lib/property-options.ts",
673
+ "type": "registry:file",
674
+ "content": "export interface OptionLike {\n label: string\n value: string\n}\n\nexport type ResolvedOption<TOption extends OptionLike> =\n | TOption\n | { label: TOption['value']; value: TOption['value'] }\n\nexport function resolveOption<TOption extends OptionLike>(\n options: readonly TOption[],\n value: TOption['value'],\n): ResolvedOption<TOption> {\n return (\n options.find((option) => option.value === value) ?? {\n label: value,\n value,\n }\n )\n}\n\nexport function resolveOptions<TOption extends OptionLike>(\n options: readonly TOption[],\n values: readonly TOption['value'][],\n): ResolvedOption<TOption>[] {\n return values.map((value) => resolveOption(options, value))\n}\n\nexport function diffValues<TValue>(\n previous: readonly TValue[],\n next: readonly TValue[],\n): { added: TValue | null; removed: TValue | null } {\n const previousValues = new Set(previous)\n const nextValues = new Set(next)\n\n return {\n added: next.find((value) => !previousValues.has(value)) ?? null,\n removed: previous.find((value) => !nextValues.has(value)) ?? null,\n }\n}\n\nexport function diffOptions<TOption extends OptionLike>(\n options: readonly TOption[],\n previous: readonly TOption['value'][],\n next: readonly TOption['value'][],\n): {\n added: ResolvedOption<TOption> | null\n removed: ResolvedOption<TOption> | null\n} {\n const { added, removed } = diffValues(previous, next)\n\n return {\n added: added === null ? null : resolveOption(options, added),\n removed: removed === null ? null : resolveOption(options, removed),\n }\n}\n",
675
+ "target": "~/packages/ui/src/patterns/properties/shared/lib/property-options.ts"
676
+ },
677
+ {
678
+ "path": "patterns/properties/shared/property-calendar-popover.tsx",
679
+ "type": "registry:file",
680
+ "content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport type { Calendar } from '@tc96/ui/calendar'\nimport { Popover, PopoverPopup, PopoverTrigger } from '@tc96/ui/popover'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactNode } from 'react'\nimport type {\n PropertyIcon,\n PropertyPopoverDropdownPlacement,\n} from './property-catalog'\nimport { PropertySurface, type PropertyVariant } from './property-surface'\nimport { PropertyTooltip } from './property-tooltip'\n\nexport type PropertyCalendarProps = Omit<\n ComponentProps<typeof Calendar>,\n 'defaultMonth' | 'mode' | 'onSelect' | 'selected'\n>\n\nexport interface PropertyCalendarPopoverProps {\n ariaLabel: string\n children: ReactNode\n icon: PropertyIcon\n label: string\n onOpenChange: (open: boolean) => void\n open: boolean\n align?: PropertyPopoverDropdownPlacement['align']\n className?: string\n clear?: { label: string; onClear: () => void }\n disabled?: boolean\n dropdownPlacement?: PropertyPopoverDropdownPlacement\n muted?: boolean\n overdue?: boolean\n tooltip?: ReactNode\n variant?: PropertyVariant\n}\n\nexport function PropertyCalendarPopover({\n align = 'start',\n ariaLabel,\n children,\n className,\n clear,\n disabled,\n dropdownPlacement,\n icon: Icon,\n label,\n muted = false,\n onOpenChange,\n open,\n overdue = false,\n tooltip,\n variant,\n}: Readonly<PropertyCalendarPopoverProps>) {\n const trigger = (\n <PopoverTrigger\n aria-label={`${ariaLabel}: ${label}`}\n disabled={disabled}\n render={\n <PropertySurface\n className={cn('max-w-full', className)}\n data-overdue={overdue || undefined}\n muted={muted}\n render={<button type=\"button\" />}\n variant={variant}\n />\n }\n >\n <Icon aria-hidden className=\"size-4\" data-slot=\"property-icon\" />\n <span className=\"truncate\">{label}</span>\n </PopoverTrigger>\n )\n\n return (\n <Popover onOpenChange={onOpenChange} open={open}>\n {tooltip ? (\n <PropertyTooltip content={tooltip} trigger={trigger} />\n ) : (\n trigger\n )}\n <PopoverPopup\n align={align}\n aria-label={ariaLabel}\n className=\"w-auto\"\n side=\"bottom\"\n {...dropdownPlacement}\n >\n {children}\n {clear ? (\n <div className=\"border-t p-2\">\n <Button\n className=\"w-full justify-start\"\n onClick={clear.onClear}\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n >\n {clear.label}\n </Button>\n </div>\n ) : null}\n </PopoverPopup>\n </Popover>\n )\n}\n",
681
+ "target": "~/packages/ui/src/patterns/properties/shared/property-calendar-popover.tsx"
682
+ },
683
+ {
684
+ "path": "patterns/properties/shared/property-catalog.ts",
685
+ "type": "registry:file",
686
+ "content": "import type { IconWeight } from '@phosphor-icons/react'\nimport type { ComboboxPopup } from '@tc96/ui/combobox'\nimport type { PropertyTone } from '@tc96/ui/lib/property-tone'\nimport type { PopoverPopup } from '@tc96/ui/popover'\nimport type { SelectPopup } from '@tc96/ui/select'\nimport type { ComponentProps, ComponentType, SVGProps } from 'react'\n\nexport {\n type PropertyTone,\n propertyToneClassName,\n} from '@tc96/ui/lib/property-tone'\n\nexport type PropertyIcon = ComponentType<\n SVGProps<SVGSVGElement> & { weight?: IconWeight }\n>\n\nexport interface PropertyOption<TValue extends string = string> {\n value: TValue\n label: string\n icon?: PropertyIcon\n tone?: PropertyTone\n weight?: IconWeight\n}\n\nexport interface PropertyChangeContext<TValue> {\n previousValue: TValue\n}\n\nexport interface PropertyListChangeContext<TItem, TValue> {\n added: TItem | null\n previousValue: readonly TValue[]\n removed: TItem | null\n}\n\nexport type PropertySelectDropdownPlacement = Pick<\n ComponentProps<typeof SelectPopup>,\n 'align' | 'alignItemWithTrigger' | 'alignOffset' | 'side' | 'sideOffset'\n>\n\nexport type PropertyMultiSelectDropdownPlacement = Pick<\n ComponentProps<typeof ComboboxPopup>,\n 'align' | 'alignOffset' | 'side' | 'sideOffset'\n>\n\nexport type PropertyPopoverDropdownPlacement = Pick<\n ComponentProps<typeof PopoverPopup>,\n 'align' | 'alignOffset' | 'side' | 'sideOffset'\n>\n",
687
+ "target": "~/packages/ui/src/patterns/properties/shared/property-catalog.ts"
688
+ },
689
+ {
690
+ "path": "patterns/properties/shared/property-display-meta.ts",
691
+ "type": "registry:file",
692
+ "content": "import {\n BuildingsIcon,\n CalendarBlankIcon,\n CalendarDotsIcon,\n CalendarIcon,\n CubeIcon,\n EnvelopeSimpleIcon,\n FileIcon,\n FileTextIcon,\n LinkIcon,\n PackageIcon,\n PhoneIcon,\n TagIcon,\n UserPlusIcon,\n WaveformIcon,\n} from '@phosphor-icons/react'\nimport type { PropertyIcon, PropertyOption } from './property-catalog'\n\nexport type AttachmentType = 'audio' | 'doc' | 'link' | 'pdf'\n\nexport type ReferencePropertyKind = 'account' | 'product' | 'record'\n\nexport type PropertyDisplayMeta = Required<\n Pick<PropertyOption, 'icon' | 'tone'>\n> &\n Pick<PropertyOption, 'weight'>\n\nexport const propertyDisplayIcons = {\n date: CalendarDotsIcon,\n dateRange: CalendarIcon,\n email: EnvelopeSimpleIcon,\n personAdd: UserPlusIcon,\n phone: PhoneIcon,\n schedule: CalendarBlankIcon,\n tags: TagIcon,\n} as const satisfies Record<string, PropertyIcon>\n\nexport const referenceKindIcons = {\n account: BuildingsIcon,\n product: PackageIcon,\n record: CubeIcon,\n} as const satisfies Record<ReferencePropertyKind, PropertyIcon>\n\nexport const attachmentTypeMeta = {\n audio: { icon: WaveformIcon, tone: 'warning' },\n doc: { icon: FileIcon, tone: 'info' },\n link: { icon: LinkIcon, tone: 'neutral' },\n pdf: { icon: FileTextIcon, tone: 'danger' },\n} as const satisfies Record<AttachmentType, PropertyDisplayMeta>\n",
693
+ "target": "~/packages/ui/src/patterns/properties/shared/property-display-meta.ts"
694
+ },
695
+ {
696
+ "path": "patterns/properties/shared/property-labels.ts",
697
+ "type": "registry:file",
698
+ "content": "export interface DatePropertyLabels {\n clear: string\n fallback: string\n}\n\nexport interface DateRangePropertyLabels {\n clear: string\n fallback: string\n from: string\n until: string\n}\n\nexport interface SchedulePropertyLabels {\n addReminder: string\n allDay: string\n back: string\n clearUntil: string\n daily: string\n end: string\n fallback: string\n frequency: string\n monthly: string\n nextWeek: string\n noDate: string\n noReminders: string\n noRepeat: string\n oneDayBefore: string\n oneHourBefore: string\n presets: string\n reminders: string\n removeReminder: string\n repeat: string\n start: string\n tenMinutesBefore: string\n thirtyMinutesBefore: string\n thisWeekend: string\n time: string\n today: string\n tomorrow: string\n until: string\n untilFallback: string\n weekdays: string\n weekly: string\n yearly: string\n}\n\nexport interface SelectPropertyLabels {\n emptyOption: string\n fallback: string\n}\n\nexport interface TextPropertyLabels {\n copy: string\n fallback: string\n add?: string\n inputPlaceholder?: string\n}\n\nexport interface PropertyEntryListLabels {\n add: string\n addAnother: string\n duplicate: string\n entries: readonly string[]\n invalid: string\n remove: string\n removeEntry: (entry: string) => string\n save: string\n inputPlaceholder?: string\n}\n\nexport type EmailPropertyLabels = PropertyEntryListLabels\n\nexport interface PhoneInputLabels {\n country: string\n countryEmpty: string\n countryList: string\n countrySearch: string\n}\n\nexport interface PhonePropertyLabels\n extends PropertyEntryListLabels,\n PhoneInputLabels {\n required: string\n}\n\nexport interface PeoplePropertyLabels {\n add: string\n empty: string\n loading: string\n remove: string\n}\n\nexport interface TagsPropertyLabels {\n add: string\n count: (count: number) => string\n empty: string\n loading: string\n remove: string\n}\n\nexport interface AttachmentPropertyLabels {\n remove: string\n}\n\nexport interface PropertyCollectionLabels {\n trigger: string\n}\n\nexport interface PropertyLabels {\n attachment: AttachmentPropertyLabels\n collection: PropertyCollectionLabels\n date: DatePropertyLabels\n dateRange: DateRangePropertyLabels\n email: EmailPropertyLabels\n people: PeoplePropertyLabels\n phone: PhonePropertyLabels\n phoneInput: PhoneInputLabels\n schedule: SchedulePropertyLabels\n select: SelectPropertyLabels\n tags: TagsPropertyLabels\n text: TextPropertyLabels\n}\n\nconst phoneInputLabels: PhoneInputLabels = {\n country: 'Country',\n countryEmpty: 'No country found.',\n countryList: 'Select country',\n countrySearch: 'Search country',\n}\n\nexport const defaultPropertyLabels: PropertyLabels = {\n attachment: { remove: 'Remove attachment' },\n collection: { trigger: 'Adjust properties' },\n date: { clear: 'Clear date', fallback: 'No date' },\n dateRange: {\n clear: 'Clear period',\n fallback: 'No period',\n from: 'From',\n until: 'Until',\n },\n email: {\n add: 'Add email',\n addAnother: 'Add another',\n duplicate: 'This email is already in the list.',\n entries: ['Primary', 'Secondary'],\n inputPlaceholder: 'name@example.com',\n invalid: 'Enter a valid email.',\n remove: 'Remove email',\n removeEntry: (entry) => `Remove ${entry} email`,\n save: 'Save',\n },\n people: {\n add: 'Add person',\n empty: 'No people found.',\n loading: 'Loading people…',\n remove: 'Remove',\n },\n phone: {\n ...phoneInputLabels,\n add: 'Add phone',\n addAnother: 'Add another',\n duplicate: 'This phone is already in the list.',\n entries: ['Primary', 'Secondary'],\n invalid: 'Enter a valid phone number.',\n remove: 'Remove phone',\n removeEntry: (entry) => `Remove ${entry} phone`,\n required: 'Enter a phone number.',\n save: 'Save',\n },\n phoneInput: phoneInputLabels,\n schedule: {\n addReminder: 'Add reminder',\n allDay: 'All day',\n back: 'Back',\n clearUntil: 'Clear date',\n daily: 'Daily',\n end: 'End',\n fallback: 'No date',\n frequency: 'Frequency',\n monthly: 'Monthly',\n nextWeek: 'Next week',\n noDate: 'No date',\n noReminders: 'No reminders found.',\n noRepeat: 'Does not repeat',\n oneDayBefore: '1 day before',\n oneHourBefore: '1 hour before',\n presets: 'Date shortcuts',\n reminders: 'Reminders',\n removeReminder: 'Remove reminder',\n repeat: 'Repeat',\n start: 'Start',\n tenMinutesBefore: '10 min before',\n thirtyMinutesBefore: '30 min before',\n thisWeekend: 'This weekend',\n time: 'Time',\n today: 'Today',\n tomorrow: 'Tomorrow',\n until: 'Until',\n untilFallback: 'No end',\n weekdays: 'Weekdays',\n weekly: 'Weekly',\n yearly: 'Yearly',\n },\n select: { emptyOption: 'None', fallback: '—' },\n tags: {\n add: 'Add tag',\n count: (count) => `${count} ${count === 1 ? 'Tag' : 'Tags'}`,\n empty: 'No tags found.',\n loading: 'Loading tags…',\n remove: 'Remove tag',\n },\n text: { copy: 'Copy', fallback: 'Not set' },\n}\n\nexport const defaultPropertyAriaLabels = {\n assigned: 'Assignee',\n date: 'Date',\n dateRange: 'Period',\n email: 'Emails',\n people: 'People',\n person: 'Person',\n phone: 'Phones',\n tags: 'Tags',\n} as const\n\nexport const defaultPropertyPlaceholders = {\n assigned: 'No assignee',\n email: 'No email',\n people: 'Add person',\n person: 'No assignee',\n phone: 'No phone',\n tags: 'Add a tag',\n} as const\n\nexport function resolvePropertyLabels<TLabels extends object>(\n defaults: TLabels,\n overrides: Partial<TLabels> | undefined,\n): TLabels {\n const resolved = { ...defaults }\n\n for (const [key, value] of Object.entries(overrides ?? {})) {\n if (value !== undefined) Object.assign(resolved, { [key]: value })\n }\n\n return resolved\n}\n",
699
+ "target": "~/packages/ui/src/patterns/properties/shared/property-labels.ts"
700
+ },
701
+ {
702
+ "path": "patterns/properties/shared/property-select-shell.tsx",
703
+ "type": "registry:file",
704
+ "content": "'use client'\n\nimport { Select, SelectPopup, SelectPrimitive } from '@tc96/ui/select'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { PropertySelectDropdownPlacement } from './property-catalog'\nimport { PropertySurface, type PropertyVariant } from './property-surface'\n\nexport interface PropertySelectShellProps<\n TOption extends { label: ReactNode; value: string },\n> {\n ariaLabel: string\n children: ReactNode\n className?: string\n disabled?: boolean\n dropdownPlacement?: PropertySelectDropdownPlacement\n items: readonly TOption[]\n itemToStringLabel: (option: TOption) => string\n itemToStringValue: (option: TOption) => string\n muted?: boolean\n onValueChange: (option: TOption | null) => void\n readOnly?: boolean\n renderValue: (option: TOption | null) => ReactNode\n value: TOption | null\n variant?: PropertyVariant\n}\n\nexport function PropertySelectShell<\n TOption extends { label: ReactNode; value: string },\n>({\n ariaLabel,\n children,\n className,\n disabled = false,\n dropdownPlacement,\n items,\n itemToStringLabel,\n itemToStringValue,\n muted = false,\n onValueChange,\n readOnly = false,\n renderValue,\n value,\n variant = 'badge',\n}: Readonly<PropertySelectShellProps<TOption>>) {\n if (readOnly) {\n return (\n <PropertySurface\n aria-label={ariaLabel}\n className={cn('max-w-full', className)}\n muted={muted}\n role=\"img\"\n variant={variant}\n >\n {renderValue(value)}\n </PropertySurface>\n )\n }\n\n return (\n <Select<TOption>\n itemToStringLabel={itemToStringLabel}\n itemToStringValue={itemToStringValue}\n items={[...items]}\n onValueChange={onValueChange}\n value={value}\n >\n <SelectPrimitive.Trigger\n aria-label={ariaLabel}\n disabled={disabled}\n render={\n <PropertySurface\n className={cn('max-w-full', className)}\n muted={muted}\n render={<button type=\"button\" />}\n variant={variant}\n />\n }\n >\n {renderValue(value)}\n </SelectPrimitive.Trigger>\n <SelectPopup {...dropdownPlacement}>{children}</SelectPopup>\n </Select>\n )\n}\n\nexport const propertySelectItemClassName =\n 'grid-cols-[minmax(0,1fr)_.75rem] gap-4 pe-2.5 *:row-start-1 [&>div]:col-start-1 [&>span]:col-start-2 [&>span]:-me-0.5'\n",
705
+ "target": "~/packages/ui/src/patterns/properties/shared/property-select-shell.tsx"
706
+ },
707
+ {
708
+ "path": "patterns/properties/shared/property-surface.tsx",
709
+ "type": "registry:file",
710
+ "content": "'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { Badge } from '@tc96/ui/badge'\nimport { cn } from '@tc96/utils'\nimport type React from 'react'\n\nexport type PropertyVariant = 'badge' | 'plain'\n\nexport const propertyBadgeClassName =\n 'h-6 min-w-6 px-[calc(--spacing(2.5)-1px)] text-sm sm:h-6 sm:min-w-6 sm:text-sm'\n\nexport interface PropertySurfaceProps extends useRender.ComponentProps<'span'> {\n variant?: PropertyVariant\n muted?: boolean\n}\n\nexport function PropertySurface({\n className,\n muted = false,\n render,\n variant = 'badge',\n ...props\n}: PropertySurfaceProps): React.ReactElement {\n const state = {\n 'data-slot': 'property-surface',\n 'data-variant': variant,\n ...(muted ? { 'data-empty': 'true' } : {}),\n ...(props['aria-label'] && !props.role && !render ? { role: 'img' } : {}),\n }\n const plain = useRender({\n defaultTagName: 'span',\n enabled: variant !== 'badge',\n props: mergeProps<'span'>(\n {\n className: cn(\n muted ? 'text-muted-foreground' : 'text-primary',\n 'inline-flex min-w-0 max-w-full items-center gap-1 whitespace-nowrap text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [button&,a&]:cursor-pointer',\n '[button&,a&]:-ms-1.5 [button&,a&]:-my-0.5 [button&,a&]:h-6 [button&,a&]:rounded-sm [button&,a&]:px-1.5',\n '[button&,a&]:hover:bg-secondary [button&,a&]:hover:text-secondary-foreground',\n '[button&,a&]:focus-visible:bg-secondary [button&,a&]:focus-visible:text-secondary-foreground',\n '[button&,a&]:data-popup-open:bg-secondary [button&,a&]:data-popup-open:text-secondary-foreground',\n className,\n ),\n ...state,\n },\n props,\n ),\n render,\n })\n\n if (plain) return plain\n\n return (\n <Badge\n className={cn(\n propertyBadgeClassName,\n !muted && 'text-primary',\n className,\n )}\n variant={muted ? 'outline' : 'secondary'}\n {...(render ? { render } : {})}\n {...state}\n {...props}\n />\n )\n}\n",
711
+ "target": "~/packages/ui/src/patterns/properties/shared/property-surface.tsx"
712
+ },
713
+ {
714
+ "path": "patterns/properties/shared/property-tooltip.tsx",
715
+ "type": "registry:file",
716
+ "content": "'use client'\n\nimport { Tooltip, TooltipPopup, TooltipTrigger } from '@tc96/ui/tooltip'\nimport { type ReactElement, type ReactNode, useId } from 'react'\n\nexport interface PropertyTooltipProps {\n content: ReactNode\n trigger: ReactElement\n}\n\nexport function PropertyTooltip({\n content,\n trigger,\n}: Readonly<PropertyTooltipProps>) {\n const descriptionId = useId()\n\n return (\n <Tooltip>\n <TooltipTrigger aria-describedby={descriptionId} render={trigger} />\n <span hidden id={descriptionId}>\n {content}\n </span>\n <TooltipPopup>{content}</TooltipPopup>\n </Tooltip>\n )\n}\n",
717
+ "target": "~/packages/ui/src/patterns/properties/shared/property-tooltip.tsx"
718
+ },
719
+ {
720
+ "path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
721
+ "type": "registry:file",
722
+ "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",
723
+ "target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
724
+ },
725
+ {
726
+ "path": "patterns/surfaces/state/core.ts",
727
+ "type": "registry:file",
728
+ "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",
729
+ "target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
730
+ },
731
+ {
732
+ "path": "patterns/toolbar/components/collection-toolbar-heading.tsx",
733
+ "type": "registry:file",
734
+ "content": "'use client'\n\nimport { Text } from '@tc96/ui/text'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement, ReactNode } from 'react'\n\nexport type CollectionToolbarHeadingProps = ComponentProps<'div'>\n\nexport interface CollectionToolbarTitleProps {\n children: ReactNode\n className?: string\n}\n\nexport interface CollectionToolbarDescriptionProps {\n children?: ReactNode\n className?: string\n}\n\nexport function CollectionToolbarHeading({\n className,\n ...props\n}: Readonly<CollectionToolbarHeadingProps>): ReactElement {\n return (\n <div\n className={cn('min-w-0', className)}\n data-slot=\"collection-toolbar-heading\"\n {...props}\n />\n )\n}\n\nexport function CollectionToolbarTitle({\n children,\n className,\n}: Readonly<CollectionToolbarTitleProps>): ReactElement {\n return (\n <Text\n className={cn('truncate leading-tight', className)}\n data-slot=\"collection-toolbar-title\"\n family=\"heading\"\n render={(props) => <h2 {...props} />}\n size=\"base\"\n weight=\"semibold\"\n >\n {children}\n </Text>\n )\n}\n\nexport function CollectionToolbarDescription({\n children,\n className,\n}: Readonly<CollectionToolbarDescriptionProps>): ReactElement | null {\n if (children == null || children === '') return null\n\n return (\n <Text\n className={cn('truncate leading-tight', className)}\n data-slot=\"collection-toolbar-description\"\n foreground=\"muted\"\n render={(props) => <p {...props} />}\n size=\"sm\"\n >\n {children}\n </Text>\n )\n}\n",
735
+ "target": "~/packages/ui/src/patterns/toolbar/components/collection-toolbar-heading.tsx"
736
+ },
737
+ {
738
+ "path": "patterns/toolbar/components/collection-toolbar-menu-trigger.tsx",
739
+ "type": "registry:file",
740
+ "content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { MenuTrigger } from '@tc96/ui/menu'\nimport { ToolbarButton } from '@tc96/ui/toolbar'\nimport type { ReactElement, ReactNode } from 'react'\n\ninterface CollectionToolbarMenuTriggerProps {\n children: ReactNode\n className?: string\n disabled?: boolean\n}\n\nexport function CollectionToolbarMenuTrigger({\n children,\n className,\n disabled = false,\n}: Readonly<CollectionToolbarMenuTriggerProps>): ReactElement {\n return (\n <MenuTrigger\n render={\n <ToolbarButton\n render={\n <Button\n className={className}\n disabled={disabled}\n type=\"button\"\n variant=\"ghost\"\n />\n }\n />\n }\n >\n {children}\n </MenuTrigger>\n )\n}\n",
741
+ "target": "~/packages/ui/src/patterns/toolbar/components/collection-toolbar-menu-trigger.tsx"
742
+ },
743
+ {
744
+ "path": "patterns/toolbar/components/collection-toolbar.tsx",
745
+ "type": "registry:file",
746
+ "content": "'use client'\n\nimport { ToolbarGroup, Toolbar as ToolbarPrimitive } from '@tc96/ui/toolbar'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement, ReactNode } from 'react'\n\nexport type CollectionToolbarMode = 'default' | 'plain'\n\nexport interface CollectionToolbarProps\n extends Omit<ComponentProps<typeof ToolbarPrimitive>, 'children'> {\n center?: ReactNode\n left?: ReactNode\n mode?: CollectionToolbarMode\n right?: ReactNode\n}\n\nexport type CollectionToolbarGroupProps = ComponentProps<typeof ToolbarGroup>\n\nexport function CollectionToolbar({\n 'aria-label': ariaLabel = 'Controles da coleção',\n center,\n className,\n left,\n mode = 'plain',\n right,\n ...props\n}: Readonly<CollectionToolbarProps>): ReactElement {\n const centered = center != null\n const spacer = centered ? (\n <div aria-hidden=\"true\" className=\"flex-1 basis-0\" />\n ) : null\n\n return (\n <ToolbarPrimitive\n aria-label={ariaLabel}\n className={cn(\n 'min-h-9 items-center justify-between md:min-h-10',\n mode === 'plain' && 'rounded-none border-0 bg-transparent p-0',\n className,\n )}\n data-mode={mode}\n {...props}\n >\n {left != null ? (\n <ToolbarGroup\n className={centered ? 'min-w-0 flex-1 basis-0' : 'min-w-0'}\n >\n {left}\n </ToolbarGroup>\n ) : (\n spacer\n )}\n {centered ? (\n <ToolbarGroup className=\"shrink-0\">{center}</ToolbarGroup>\n ) : null}\n {right != null ? (\n <ToolbarGroup\n className={centered ? 'flex-1 basis-0 justify-end' : 'ms-auto'}\n >\n {right}\n </ToolbarGroup>\n ) : (\n spacer\n )}\n </ToolbarPrimitive>\n )\n}\n\nexport function CollectionToolbarGroup(\n props: CollectionToolbarGroupProps,\n): ReactElement {\n return <ToolbarGroup {...props} />\n}\n",
747
+ "target": "~/packages/ui/src/patterns/toolbar/components/collection-toolbar.tsx"
748
+ },
749
+ {
750
+ "path": "patterns/toolbar/index.ts",
751
+ "type": "registry:file",
752
+ "content": "'use client'\n\nexport type {\n CollectionToolbarGroupProps,\n CollectionToolbarMode,\n CollectionToolbarProps,\n} from './components/collection-toolbar'\nexport {\n CollectionToolbar,\n CollectionToolbarGroup,\n} from './components/collection-toolbar'\nexport type {\n CollectionToolbarDescriptionProps,\n CollectionToolbarHeadingProps,\n CollectionToolbarTitleProps,\n} from './components/collection-toolbar-heading'\nexport {\n CollectionToolbarDescription,\n CollectionToolbarHeading,\n CollectionToolbarTitle,\n} from './components/collection-toolbar-heading'\n",
753
+ "target": "~/packages/ui/src/patterns/toolbar/index.ts"
754
+ },
755
+ {
756
+ "path": "patterns/view-settings-menu/components/view-settings-field-section.tsx",
757
+ "type": "registry:file",
758
+ "content": "'use client'\n\nimport type { Icon as PhosphorIcon } from '@phosphor-icons/react'\nimport { MenuCheckboxItem } from '@tc96/ui/menu'\nimport type { ReactElement, ReactNode } from 'react'\nimport { ViewSettingsSection } from './view-settings-menu'\n\nexport interface ViewSettingsField {\n icon?: PhosphorIcon\n id: string\n label: string\n typeLabel?: string\n visible: boolean\n}\n\nexport interface ViewSettingsFieldSectionProps {\n fields: readonly ViewSettingsField[]\n label: ReactNode\n onVisibleChange: (id: string, visible: boolean) => void\n}\n\nexport function ViewSettingsFieldSection({\n fields,\n label,\n onVisibleChange,\n}: Readonly<ViewSettingsFieldSectionProps>): ReactElement | null {\n if (fields.length === 0) return null\n\n return (\n <ViewSettingsSection\n label={\n <span className=\"flex justify-between gap-2\">\n {label}{' '}\n <span data-slot=\"view-settings-field-count\">{fields.length}</span>\n </span>\n }\n >\n {fields.map(\n ({ icon: Icon, id, label: fieldLabel, typeLabel, visible }) => (\n <MenuCheckboxItem\n checked={visible}\n closeOnClick={false}\n data-field={id}\n key={id}\n onCheckedChange={(checked) => onVisibleChange(id, checked)}\n variant=\"switch\"\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {Icon ? <Icon aria-hidden=\"true\" /> : null}\n <span className=\"truncate\">{fieldLabel}</span>\n {typeLabel ? (\n <span className=\"ms-auto shrink-0 text-muted-foreground text-xs\">\n {typeLabel}\n </span>\n ) : null}\n </span>\n </MenuCheckboxItem>\n ),\n )}\n </ViewSettingsSection>\n )\n}\n",
759
+ "target": "~/packages/ui/src/patterns/view-settings-menu/components/view-settings-field-section.tsx"
760
+ },
761
+ {
762
+ "path": "patterns/view-settings-menu/components/view-settings-menu.tsx",
763
+ "type": "registry:file",
764
+ "content": "'use client'\n\nimport {\n ArrowCounterClockwiseIcon,\n ArrowsCounterClockwiseIcon,\n FloppyDiskIcon,\n type Icon as PhosphorIcon,\n SlidersHorizontalIcon,\n} from '@phosphor-icons/react'\nimport {\n MenuGroup,\n MenuGroupLabel,\n MenuItem,\n MenuPopup,\n MenuPrimitive,\n MenuRadioGroup,\n Menu as MenuRoot,\n MenuSeparator,\n} from '@tc96/ui/menu'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement, ReactNode } from 'react'\nimport { CollectionToolbarMenuTrigger } from '../../toolbar/components/collection-toolbar-menu-trigger'\n\nexport interface ViewSettingsMode<TMode extends string = string> {\n icon: PhosphorIcon\n label: string\n value: TMode\n}\n\nexport interface ViewSettingsMenuProps<TMode extends string = string> {\n /** Some no rótulo do gatilho quando zero, na mesma gramática do `FilterMenu`. */\n activeFilterCount?: number\n children: ReactNode\n className?: string\n clearLabel?: string\n formatTriggerLabel?: (label: string, activeFilterCount: number) => string\n label?: string\n mode?: TMode\n /** Na ordem da coleção; com menos de dois modos, as tabs não aparecem. */\n modes?: readonly ViewSettingsMode<TMode>[]\n onClearFilters?: () => void\n onModeChange?: (mode: TMode) => void\n onReset?: () => void\n /** Sem handler o rodapé não compõe o item: guardar preferência é opcional. */\n onSavePreference?: () => void\n resetDisabled?: boolean\n resetLabel?: string\n savePreferenceDisabled?: boolean\n savePreferenceLabel?: string\n}\n\nexport interface ViewSettingsSectionProps {\n children: ReactNode\n label: ReactNode\n}\n\nconst defaultTriggerLabel = (label: string, count: number) =>\n `${label} (${count})`\n\nconst popupWidth = (modeCount: number) => {\n if (modeCount < 4) return 'w-80'\n return 'w-96'\n}\n\n/**\n * Superfície única de ajustes da view: filtro avançado e configuração deixam de\n * ser dois gatilhos vizinhos e passam a ser seções de um só menu.\n *\n * O pacote não decide quais modos ou seções existem — só a moldura, as tabs de\n * modo, a contagem no rótulo e o rodapé. A coleção fornece as opções.\n */\nexport function ViewSettingsMenu<TMode extends string = string>({\n activeFilterCount = 0,\n children,\n className,\n clearLabel = 'Limpar filtros',\n formatTriggerLabel = defaultTriggerLabel,\n label = 'Exibição',\n mode,\n modes = [],\n onClearFilters,\n onModeChange,\n onReset,\n onSavePreference,\n resetDisabled = false,\n resetLabel = 'Redefinir',\n savePreferenceDisabled = false,\n savePreferenceLabel = 'Salvar preferência',\n}: Readonly<ViewSettingsMenuProps<TMode>>): ReactElement {\n const normalizedActiveCount = Math.max(0, activeFilterCount)\n const triggerLabel = normalizedActiveCount\n ? formatTriggerLabel(label, normalizedActiveCount)\n : label\n const hasModeTabs = modes.length > 1\n\n return (\n <MenuRoot>\n <CollectionToolbarMenuTrigger className={className}>\n <SlidersHorizontalIcon aria-hidden=\"true\" />\n {triggerLabel}\n </CollectionToolbarMenuTrigger>\n <MenuPopup align=\"end\" className={popupWidth(modes.length)}>\n {hasModeTabs ? (\n <ViewSettingsModeTabs\n modes={modes}\n onModeChange={onModeChange}\n value={mode}\n />\n ) : null}\n {children}\n <MenuSeparator />\n {/* Limpar antes de guardar: descartar volta ao ponto de partida, guardar\n avança a partir dele — a ordem é a mesma sequência de decisão. */}\n {onClearFilters ? (\n <MenuItem\n closeOnClick={false}\n disabled={!normalizedActiveCount}\n onClick={onClearFilters}\n >\n <ArrowCounterClockwiseIcon aria-hidden=\"true\" />\n {clearLabel}\n </MenuItem>\n ) : null}\n {onReset ? (\n <MenuItem\n closeOnClick={false}\n disabled={resetDisabled}\n onClick={onReset}\n >\n <ArrowsCounterClockwiseIcon aria-hidden=\"true\" />\n {resetLabel}\n </MenuItem>\n ) : null}\n {onSavePreference ? (\n <MenuItem\n disabled={savePreferenceDisabled}\n onClick={onSavePreference}\n >\n <FloppyDiskIcon aria-hidden=\"true\" />\n {savePreferenceLabel}\n </MenuItem>\n ) : null}\n </MenuPopup>\n </MenuRoot>\n )\n}\n\nfunction ViewSettingsModeTabs<TMode extends string>({\n modes,\n onModeChange,\n value,\n}: Readonly<{\n modes: readonly ViewSettingsMode<TMode>[]\n onModeChange?: (mode: TMode) => void\n value?: TMode\n}>): ReactElement {\n const layout = modes.length < 4 ? 'inline' : 'stacked'\n\n return (\n <MenuRadioGroup\n className={cn(\n 'flex rounded-lg',\n layout === 'stacked' ? 'gap-1 p-1' : 'gap-0.5 p-0.5',\n )}\n onValueChange={(next: TMode) => onModeChange?.(next)}\n value={value}\n >\n {modes.map(({ icon: Icon, label, value: modeValue }) => (\n <MenuPrimitive.RadioItem\n className={cn(\n 'flex min-w-0 flex-auto cursor-default select-none items-center justify-center rounded-md text-muted-foreground outline-none data-checked:bg-background not-data-checked:data-highlighted:bg-accent data-highlighted:text-foreground data-checked:text-foreground data-checked:shadow-sm/5 dark:data-checked:bg-input [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0',\n layout === 'stacked'\n ? 'flex-col gap-1.5 px-2 py-2 text-xs'\n : 'min-h-7 gap-1.5 px-1.5 text-sm',\n )}\n closeOnClick\n data-layout={layout}\n data-slot=\"view-settings-mode-tab\"\n key={modeValue}\n value={modeValue}\n >\n <span className=\"inline-flex size-4 shrink-0 items-center justify-center rounded-sm bg-primary text-primary-foreground\">\n <Icon aria-hidden=\"true\" className=\"size-3\" />\n </span>\n <span className=\"truncate\">{label}</span>\n </MenuPrimitive.RadioItem>\n ))}\n </MenuRadioGroup>\n )\n}\n\n/** Divisão nomeada dentro do `ViewSettingsMenu`. */\nexport function ViewSettingsSection({\n children,\n label,\n}: Readonly<ViewSettingsSectionProps>): ReactElement {\n return (\n <MenuGroup>\n <MenuGroupLabel>{label}</MenuGroupLabel>\n {children}\n </MenuGroup>\n )\n}\n",
765
+ "target": "~/packages/ui/src/patterns/view-settings-menu/components/view-settings-menu.tsx"
766
+ },
767
+ {
768
+ "path": "patterns/view-settings-menu/components/view-settings-show-all-fields.tsx",
769
+ "type": "registry:file",
770
+ "content": "'use client'\n\nimport { EyeIcon } from '@phosphor-icons/react'\nimport { MenuItem } from '@tc96/ui/menu'\nimport type { ReactElement } from 'react'\n\nexport interface ViewSettingsShowAllFieldsProps {\n hiddenCount: number\n label?: string\n onShowAll: () => void\n}\n\nexport function ViewSettingsShowAllFields({\n hiddenCount,\n label = 'Mostrar todos os campos',\n onShowAll,\n}: Readonly<ViewSettingsShowAllFieldsProps>): ReactElement {\n return (\n <MenuItem\n closeOnClick={false}\n disabled={hiddenCount <= 0}\n onClick={onShowAll}\n >\n <EyeIcon aria-hidden=\"true\" />\n {label}\n </MenuItem>\n )\n}\n",
771
+ "target": "~/packages/ui/src/patterns/view-settings-menu/components/view-settings-show-all-fields.tsx"
772
+ },
773
+ {
774
+ "path": "patterns/view-settings-menu/components/view-settings-submenu.tsx",
775
+ "type": "registry:file",
776
+ "content": "'use client'\n\nimport type { Icon as PhosphorIcon } from '@phosphor-icons/react'\nimport {\n MenuRadioGroup,\n MenuRadioItem,\n MenuSub,\n MenuSubPopup,\n MenuSubTrigger,\n} from '@tc96/ui/menu'\nimport type { ReactElement, ReactNode } from 'react'\n\nexport interface ViewSettingsOption<TValue extends string = string> {\n icon?: ReactNode\n label: string\n value: TValue\n}\n\nexport interface ViewSettingsSubmenuProps<TValue extends string = string> {\n icon?: PhosphorIcon\n label: string\n onValueChange: (value: TValue) => void\n options: readonly ViewSettingsOption<TValue>[]\n value?: TValue\n}\n\nexport function ViewSettingsSubmenu<TValue extends string = string>({\n icon: Icon,\n label,\n onValueChange,\n options,\n value,\n}: Readonly<ViewSettingsSubmenuProps<TValue>>): ReactElement {\n const current = options.find((option) => option.value === value)\n\n return (\n <MenuSub>\n <MenuSubTrigger>\n {current?.icon ?? (Icon ? <Icon aria-hidden=\"true\" /> : null)}\n {label}\n <span\n className=\"flex-1 truncate text-end text-muted-foreground\"\n data-slot=\"view-settings-current-value\"\n >\n {current?.label}\n </span>\n </MenuSubTrigger>\n <MenuSubPopup>\n <MenuRadioGroup\n onValueChange={(next: TValue) => onValueChange(next)}\n value={value ?? null}\n >\n {options.map((option) => (\n <MenuRadioItem key={option.value} value={option.value}>\n {option.icon}\n {option.label}\n </MenuRadioItem>\n ))}\n </MenuRadioGroup>\n </MenuSubPopup>\n </MenuSub>\n )\n}\n",
777
+ "target": "~/packages/ui/src/patterns/view-settings-menu/components/view-settings-submenu.tsx"
778
+ },
779
+ {
780
+ "path": "patterns/view-settings-menu/index.ts",
781
+ "type": "registry:file",
782
+ "content": "'use client'\n\nexport type {\n ViewSettingsField,\n ViewSettingsFieldSectionProps,\n} from './components/view-settings-field-section'\nexport { ViewSettingsFieldSection } from './components/view-settings-field-section'\nexport type {\n ViewSettingsMenuProps,\n ViewSettingsMode,\n ViewSettingsSectionProps,\n} from './components/view-settings-menu'\nexport {\n ViewSettingsMenu,\n ViewSettingsSection,\n} from './components/view-settings-menu'\nexport type { ViewSettingsShowAllFieldsProps } from './components/view-settings-show-all-fields'\nexport { ViewSettingsShowAllFields } from './components/view-settings-show-all-fields'\nexport type {\n ViewSettingsOption,\n ViewSettingsSubmenuProps,\n} from './components/view-settings-submenu'\nexport { ViewSettingsSubmenu } from './components/view-settings-submenu'\n",
783
+ "target": "~/packages/ui/src/patterns/view-settings-menu/index.ts"
784
+ },
785
+ {
786
+ "path": "patterns/view-switcher/components/view-switcher.tsx",
787
+ "type": "registry:file",
788
+ "content": "'use client'\n\nimport { CaretDownIcon, DotsThreeIcon, PlusIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { Menu, MenuPopup, MenuTrigger } from '@tc96/ui/menu'\nimport {\n Popover,\n PopoverClose,\n PopoverPopup,\n PopoverTrigger,\n} from '@tc96/ui/popover'\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { ToolbarButton } from '@tc96/ui/toolbar'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement, ReactNode } from 'react'\nimport { createContext, useContext, useState } from 'react'\n\n/*\n * O seletor é um popover, não um menu: ele reúne um campo de busca e, em cada\n * view, um botão de opções, e um `role=\"menu\"` não pode conter nenhum dos dois.\n * Escolher uma view, criar outra ou usar uma opção fecha o popover.\n */\nconst ViewSwitcherCloseContext = createContext<() => void>(() => undefined)\n\nconst triggerVariants = {\n default: 'secondary',\n ghost: 'ghost',\n} as const\n\nexport type ViewSwitcherMenuVariant = keyof typeof triggerVariants\n\nexport interface ViewSwitcherMenuProps {\n children: ReactNode\n className?: string\n icon?: ReactNode\n label: string\n variant?: ViewSwitcherMenuVariant\n}\n\n/** Gatilho com a view ativa e popup alinhado ao início da toolbar. */\nexport function ViewSwitcherMenu({\n children,\n className,\n icon,\n label,\n variant = 'default',\n}: Readonly<ViewSwitcherMenuProps>): ReactElement {\n const [open, setOpen] = useState(false)\n\n return (\n <Popover onOpenChange={setOpen} open={open}>\n <PopoverTrigger\n render={\n <ToolbarButton\n render={\n <Button\n className={className}\n type=\"button\"\n variant={triggerVariants[variant]}\n />\n }\n />\n }\n >\n {icon ? <span className=\"shrink-0\">{icon}</span> : null}\n <span className=\"min-w-0 truncate font-medium\">{label}</span>\n <CaretDownIcon aria-hidden=\"true\" className=\"shrink-0\" />\n </PopoverTrigger>\n <PopoverPopup align=\"start\" aria-label={label} className=\"w-72\">\n <ViewSwitcherCloseContext.Provider value={() => setOpen(false)}>\n <div className=\"flex flex-col gap-1\">{children}</div>\n </ViewSwitcherCloseContext.Provider>\n </PopoverPopup>\n </Popover>\n )\n}\n\nexport interface ViewSwitcherSearchProps {\n label?: string\n onValueChange: (value: string) => void\n placeholder?: string\n value: string\n}\n\nexport function ViewSwitcherSearch({\n label = 'Buscar views',\n onValueChange,\n placeholder = 'Buscar views...',\n value,\n}: Readonly<ViewSwitcherSearchProps>): ReactElement {\n return (\n <div className=\"pb-1\" data-slot=\"view-switcher-search\">\n <input\n aria-label={label}\n className=\"h-8 w-full rounded-md bg-transparent px-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n onChange={(event) => onValueChange(event.target.value)}\n placeholder={placeholder}\n type=\"search\"\n value={value}\n />\n </div>\n )\n}\n\nexport interface ViewSwitcherItemsProps {\n children?: ReactNode\n label?: string\n loading?: boolean\n loadingItemCount?: number\n}\n\nexport function ViewSwitcherItems({\n children,\n label = 'Views',\n loading = false,\n loadingItemCount = 3,\n}: Readonly<ViewSwitcherItemsProps>): ReactElement {\n return (\n <fieldset\n aria-busy={loading || undefined}\n aria-label={label}\n className=\"m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0\"\n data-slot=\"view-switcher-items\"\n >\n {children}\n {loading\n ? Array.from(\n { length: loadingItemCount },\n (_, position) => `loading-${position + 1}`,\n ).map((key) => (\n <div\n aria-hidden=\"true\"\n className=\"flex h-8 items-center gap-1.5 px-2.5 sm:h-7\"\n key={key}\n >\n <Skeleton className=\"size-4 shrink-0 rounded-sm\" />\n <Skeleton className=\"h-3.5 flex-1\" />\n </div>\n ))\n : null}\n </fieldset>\n )\n}\n\nexport interface ViewSwitcherItemProps {\n 'aria-label'?: string\n count?: number | string\n icon?: ReactNode\n label: string\n onSelect: () => void\n options?: ReactNode\n optionsLabel?: string\n selected?: boolean\n}\n\nexport function ViewSwitcherItem({\n 'aria-label': ariaLabel,\n count,\n icon,\n label,\n onSelect,\n options,\n optionsLabel = `Opções de ${label}`,\n selected = false,\n}: Readonly<ViewSwitcherItemProps>): ReactElement {\n const close = useContext(ViewSwitcherCloseContext)\n\n return (\n <div\n className={cn(\n 'flex min-w-0 items-center rounded-md',\n selected && 'bg-accent/60',\n )}\n data-selected={selected ? '' : undefined}\n data-slot=\"view-switcher-item\"\n >\n <PopoverClose\n aria-current={selected ? 'true' : undefined}\n aria-label={ariaLabel}\n onClick={onSelect}\n render={\n <Button\n className=\"min-w-0 flex-1 justify-start\"\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n />\n }\n >\n {icon ? <span className=\"shrink-0\">{icon}</span> : null}\n <span className=\"truncate\">{label}</span>\n {count === undefined ? null : (\n <span\n aria-hidden=\"true\"\n className=\"ms-auto shrink-0 text-muted-foreground text-xs tabular-nums\"\n data-slot=\"view-switcher-item-count\"\n >\n {count}\n </span>\n )}\n </PopoverClose>\n {options ? (\n <Menu\n onOpenChange={(menuOpen, details) => {\n if (!menuOpen && details.reason === 'item-press') close()\n }}\n >\n <MenuTrigger\n aria-label={optionsLabel}\n render={<Button size=\"icon-sm\" type=\"button\" variant=\"ghost\" />}\n >\n <DotsThreeIcon aria-hidden=\"true\" className=\"size-4\" />\n </MenuTrigger>\n <MenuPopup align=\"start\" className=\"w-64\" side=\"right\">\n {options}\n </MenuPopup>\n </Menu>\n ) : null}\n </div>\n )\n}\n\nexport interface ViewSwitcherCreateProps {\n label?: string\n onClick: () => void\n}\n\nexport function ViewSwitcherCreate({\n label = 'Criar nova view',\n onClick,\n}: Readonly<ViewSwitcherCreateProps>): ReactElement {\n return (\n <PopoverClose\n data-slot=\"view-switcher-create\"\n onClick={onClick}\n render={\n <Button\n className=\"w-full justify-start\"\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n />\n }\n >\n <PlusIcon aria-hidden=\"true\" />\n {label}\n </PopoverClose>\n )\n}\n",
789
+ "target": "~/packages/ui/src/patterns/view-switcher/components/view-switcher.tsx"
790
+ },
791
+ {
792
+ "path": "patterns/view-switcher/index.ts",
793
+ "type": "registry:file",
794
+ "content": "'use client'\n\nexport type {\n ViewSwitcherCreateProps,\n ViewSwitcherItemProps,\n ViewSwitcherItemsProps,\n ViewSwitcherMenuProps,\n ViewSwitcherSearchProps,\n} from './components/view-switcher'\nexport {\n ViewSwitcherCreate,\n ViewSwitcherItem,\n ViewSwitcherItems,\n ViewSwitcherMenu,\n ViewSwitcherSearch,\n} from './components/view-switcher'\n",
795
+ "target": "~/packages/ui/src/patterns/view-switcher/index.ts"
796
+ }
797
+ ],
798
+ "dependencies": [
799
+ "@base-ui/react@1.8.0",
800
+ "@daypicker/react@10.0.2",
801
+ "@dnd-kit/abstract@0.5.0",
802
+ "@dnd-kit/dom@0.5.0",
803
+ "@dnd-kit/react@0.5.0",
804
+ "@phosphor-icons/react@2.1.10",
805
+ "@tanstack/react-table@9.2.4",
806
+ "@tanstack/react-virtual@3.14.2",
807
+ "react@19.1.1"
808
+ ],
809
+ "registryDependencies": [
810
+ "@ui/avatar",
811
+ "@ui/badge",
812
+ "@ui/button",
813
+ "@ui/calendar",
814
+ "@ui/checkbox",
815
+ "@ui/combobox",
816
+ "@ui/command",
817
+ "@ui/empty",
818
+ "@ui/group",
819
+ "@ui/icon-frame",
820
+ "@ui/input",
821
+ "@ui/menu",
822
+ "@ui/pagination",
823
+ "@ui/popover",
824
+ "@ui/property-tone",
825
+ "@ui/scroll-area",
826
+ "@ui/select",
827
+ "@ui/separator",
828
+ "@ui/skeleton",
829
+ "@ui/text",
830
+ "@ui/toolbar",
831
+ "@ui/tooltip"
832
+ ],
833
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json"
834
+ }