@tc96/cli 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +213 -2
- package/cli.js +1450 -0
- package/package.json +35 -4
- package/registry/agenda-1.json +1297 -0
- package/registry/aggregate.json +4 -0
- package/registry/ai-chat-1.json +91 -0
- package/registry/app-shell-1.json +81 -0
- package/registry/app-shell-2.json +89 -0
- package/registry/app-shell-3.json +109 -0
- package/registry/app-shell-4.json +104 -0
- package/registry/card-1.json +104 -0
- package/registry/card-2.json +97 -0
- package/registry/card-3.json +104 -0
- package/registry/card-4.json +98 -0
- package/registry/card-5.json +85 -0
- package/registry/card-6.json +98 -0
- package/registry/card-7.json +104 -0
- package/registry/card-8.json +106 -0
- package/registry/card-9.json +92 -0
- package/registry/charts.json +30 -0
- package/registry/chat-assistant.json +110 -0
- package/registry/chats-panel.json +97 -0
- package/registry/checklist.json +321 -0
- package/registry/collection.json +1104 -0
- package/registry/crm-1.json +1317 -0
- package/registry/crm-2.json +1400 -0
- package/registry/dashboard-1.json +160 -0
- package/registry/dashboard-2.json +153 -0
- package/registry/dashboard-3.json +154 -0
- package/registry/dashboard-4.json +168 -0
- package/registry/dashboard-5.json +167 -0
- package/registry/dashboard-6.json +143 -0
- package/registry/dashboard-7.json +188 -0
- package/registry/documents-1.json +1322 -0
- package/registry/editable.json +36 -0
- package/registry/empty-state-1.json +40 -0
- package/registry/empty-state-2.json +39 -0
- package/registry/empty-state-3.json +61 -0
- package/registry/empty-state-4.json +39 -0
- package/registry/empty-state-5.json +47 -0
- package/registry/empty-state-6.json +40 -0
- package/registry/finance-1.json +845 -0
- package/registry/finance-2.json +973 -0
- package/registry/finance-3.json +1436 -0
- package/registry/flow-1.json +460 -0
- package/registry/flow-2.json +503 -0
- package/registry/flow-3.json +198 -0
- package/registry/flow-4.json +75 -0
- package/registry/flow-canvas.json +198 -0
- package/registry/flow-inspector.json +151 -0
- package/registry/flow-step-library.json +112 -0
- package/registry/forgot-password-1.json +73 -0
- package/registry/forgot-password-2.json +73 -0
- package/registry/inbox-1.json +1184 -0
- package/registry/inventory-1.json +828 -0
- package/registry/inventory-2.json +956 -0
- package/registry/legal-1.json +1345 -0
- package/registry/legal-2.json +1279 -0
- package/registry/legal-3.json +1273 -0
- package/registry/legal-4.json +1273 -0
- package/registry/legal-5.json +1393 -0
- package/registry/legal-6.json +1309 -0
- package/registry/legal-7.json +1315 -0
- package/registry/legal-8.json +1358 -0
- package/registry/legal-9.json +1381 -0
- package/registry/list-1.json +129 -0
- package/registry/list-2.json +117 -0
- package/registry/list-3.json +129 -0
- package/registry/list-4.json +105 -0
- package/registry/list-5.json +98 -0
- package/registry/list-6.json +92 -0
- package/registry/list.json +52 -0
- package/registry/login-1.json +89 -0
- package/registry/login-10.json +88 -0
- package/registry/login-2.json +81 -0
- package/registry/login-3.json +90 -0
- package/registry/login-4.json +81 -0
- package/registry/login-5.json +82 -0
- package/registry/login-6.json +88 -0
- package/registry/login-7.json +83 -0
- package/registry/login-8.json +81 -0
- package/registry/login-9.json +88 -0
- package/registry/magic-link-6.json +79 -0
- package/registry/marketing-1.json +833 -0
- package/registry/marketing-2.json +961 -0
- package/registry/navbar-1.json +66 -0
- package/registry/navbar-10.json +50 -0
- package/registry/navbar-11.json +48 -0
- package/registry/navbar-12.json +48 -0
- package/registry/navbar-2.json +48 -0
- package/registry/navbar-3.json +50 -0
- package/registry/navbar-4.json +39 -0
- package/registry/navbar-5.json +50 -0
- package/registry/navbar-6.json +48 -0
- package/registry/navbar-7.json +72 -0
- package/registry/navbar-8.json +50 -0
- package/registry/navbar-9.json +54 -0
- package/registry/onboarding-1.json +114 -0
- package/registry/onboarding-2.json +78 -0
- package/registry/onboarding-3.json +71 -0
- package/registry/otp-1.json +73 -0
- package/registry/projects-1.json +865 -0
- package/registry/projects-2.json +993 -0
- package/registry/projects-3.json +1346 -0
- package/registry/properties.json +530 -0
- package/registry/record-dialog.json +88 -0
- package/registry/record-group.json +194 -0
- package/registry/record-preview.json +70 -0
- package/registry/record-status-list.json +70 -0
- package/registry/reset-password-1.json +92 -0
- package/registry/reset-password-2.json +98 -0
- package/registry/reset-password-6.json +91 -0
- package/registry/revenue-1.json +834 -0
- package/registry/revenue-2.json +968 -0
- package/registry/revenue-3.json +821 -0
- package/registry/revenue-4.json +949 -0
- package/registry/rich-text-editor-1.json +172 -0
- package/registry/rich-text-editor-2.json +158 -0
- package/registry/rich-text-editor-3.json +198 -0
- package/registry/rich-text-editor-4.json +200 -0
- package/registry/rich-text-editor-5.json +237 -0
- package/registry/rich-text-editor.json +113 -0
- package/registry/settings-account-1.json +119 -0
- package/registry/settings-account-2.json +118 -0
- package/registry/settings-catalog-1.json +128 -0
- package/registry/settings-catalog-10.json +129 -0
- package/registry/settings-catalog-2.json +116 -0
- package/registry/settings-catalog-3.json +118 -0
- package/registry/settings-catalog-4.json +227 -0
- package/registry/settings-catalog-5.json +129 -0
- package/registry/settings-catalog-6.json +130 -0
- package/registry/settings-catalog-7.json +130 -0
- package/registry/settings-catalog-8.json +183 -0
- package/registry/settings-catalog-9.json +159 -0
- package/registry/settings-integration-1.json +125 -0
- package/registry/settings-integration-2.json +122 -0
- package/registry/settings-integration-3.json +118 -0
- package/registry/settings-integration-4.json +129 -0
- package/registry/settings-integration-5.json +122 -0
- package/registry/settings-integration-6.json +92 -0
- package/registry/settings-integration-7.json +122 -0
- package/registry/settings-integration-8.json +593 -0
- package/registry/settings-notification-channel-1.json +112 -0
- package/registry/settings-preference-1.json +123 -0
- package/registry/settings-preference-2.json +123 -0
- package/registry/settings-preference-3.json +116 -0
- package/registry/settings-role-permission-1.json +117 -0
- package/registry/settings-security-1.json +117 -0
- package/registry/settings-workspace-1.json +119 -0
- package/registry/settings-workspace-2.json +125 -0
- package/registry/settings.json +82 -0
- package/registry/signup-1.json +100 -0
- package/registry/signup-2.json +93 -0
- package/registry/signup-3.json +83 -0
- package/registry/signup-6.json +99 -0
- package/registry/state-surface.json +58 -0
- package/registry/stats-1.json +116 -0
- package/registry/stats-2.json +115 -0
- package/registry/stats-3.json +97 -0
- package/registry/stats-4.json +92 -0
- package/registry/stats-5.json +103 -0
- package/registry/stats-6.json +105 -0
- package/registry/stats-7.json +103 -0
- package/registry/stats.json +64 -0
- package/registry/support-1.json +853 -0
- package/registry/support-2.json +981 -0
- package/registry/support-3.json +762 -0
- package/registry/support-4.json +538 -0
- package/registry/team-1.json +829 -0
- package/registry/team-2.json +957 -0
- package/registry/timeline-1.json +97 -0
- package/registry/timeline-2.json +102 -0
- package/registry/timeline-3.json +68 -0
- package/registry/timeline-4.json +86 -0
- package/registry/ui/accordion.json +15 -0
- package/registry/ui/alert-dialog.json +14 -0
- package/registry/ui/alert.json +50 -0
- package/registry/ui/autocomplete.json +18 -0
- package/registry/ui/avatar.json +14 -0
- package/registry/ui/badge.json +51 -0
- package/registry/ui/breadcrumb.json +15 -0
- package/registry/ui/button.json +25 -0
- package/registry/ui/calendar.json +15 -0
- package/registry/ui/card.json +14 -0
- package/registry/ui/chat.json +115 -0
- package/registry/ui/checkbox-group.json +14 -0
- package/registry/ui/checkbox.json +14 -0
- package/registry/ui/collapsible.json +14 -0
- package/registry/ui/combobox.json +18 -0
- package/registry/ui/command.json +17 -0
- package/registry/ui/composer-clipboard.json +14 -0
- package/registry/ui/composer-document.json +14 -0
- package/registry/ui/composer-editor.json +16 -0
- package/registry/ui/composer-query.json +12 -0
- package/registry/ui/composer.json +17 -0
- package/registry/ui/context-menu.json +23 -0
- package/registry/ui/dialog.json +18 -0
- package/registry/ui/drawer.json +18 -0
- package/registry/ui/empty.json +14 -0
- package/registry/ui/field.json +22 -0
- package/registry/ui/fieldset.json +14 -0
- package/registry/ui/form.json +14 -0
- package/registry/ui/frame.json +12 -0
- package/registry/ui/gauge.json +31 -0
- package/registry/ui/group.json +17 -0
- package/registry/ui/icon-frame.json +31 -0
- package/registry/ui/input-group.json +17 -0
- package/registry/ui/input.json +14 -0
- package/registry/ui/kbd.json +12 -0
- package/registry/ui/label.json +14 -0
- package/registry/ui/menu.json +39 -0
- package/registry/ui/meter.json +14 -0
- package/registry/ui/number-field.json +17 -0
- package/registry/ui/otp-field.json +31 -0
- package/registry/ui/pagination.json +17 -0
- package/registry/ui/popover.json +14 -0
- package/registry/ui/preview-card.json +14 -0
- package/registry/ui/progress.json +14 -0
- package/registry/ui/property-meta.json +16 -0
- package/registry/ui/property-tone.json +12 -0
- package/registry/ui/radio-group.json +14 -0
- package/registry/ui/render-anchor.json +12 -0
- package/registry/ui/scroll-area.json +14 -0
- package/registry/ui/segmented-control.json +14 -0
- package/registry/ui/select.json +16 -0
- package/registry/ui/separator.json +14 -0
- package/registry/ui/sheet.json +18 -0
- package/registry/ui/sidebar.json +25 -0
- package/registry/ui/skeleton.json +24 -0
- package/registry/ui/slider.json +14 -0
- package/registry/ui/spinner.json +14 -0
- package/registry/ui/switch.json +14 -0
- package/registry/ui/table.json +14 -0
- package/registry/ui/tabs.json +16 -0
- package/registry/ui/text.json +31 -0
- package/registry/ui/textarea.json +14 -0
- package/registry/ui/toast.json +89 -0
- package/registry/ui/toggle-group.json +18 -0
- package/registry/ui/toggle.json +15 -0
- package/registry/ui/toolbar.json +14 -0
- package/registry/ui/tooltip.json +14 -0
- package/registry/ui/use-composer-editor.json +17 -0
- package/registry/ui/use-copy-to-clipboard.json +12 -0
- package/registry/ui/use-media-query.json +12 -0
- package/registry/view.json +1104 -0
- package/registry/widgets.json +319 -0
- package/registry/wizard.json +89 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "support-4",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/data/shared/properties/data-properties.tsx",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"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",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/data/shared/properties/data-properties.tsx"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/data/shared/properties/types.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"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",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/data/shared/properties/types.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/data/shared/table/format.ts",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "import { parseDateValue } from '@tc96/ui/helpers/date'\nimport { formatAmount } from '@tc96/ui/helpers/format'\nimport type { TableFormatProps } from './types'\n\nexport const defaultTableLocale = 'pt-BR'\nexport const defaultTableCurrency = 'BRL'\n\nexport function createTableFormatter({\n currency = defaultTableCurrency,\n locale = defaultTableLocale,\n}: TableFormatProps = {}) {\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 TableFormatter = ReturnType<typeof createTableFormatter>\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/data/shared/table/format.ts"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/data/shared/table/labels.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import type {\n TableLoadLabels,\n TableSettingsLabels,\n TableViewLabels,\n} from './types'\n\nexport const defaultTableLoadLabels: Pick<\n TableLoadLabels,\n 'errorDescription' | 'retry'\n> = {\n errorDescription: 'Verifique sua conexão e tente novamente.',\n retry: 'Tentar novamente',\n}\n\nexport const defaultTableViewLabels: TableViewLabels = {\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 defaultTableSettingsLabels: TableSettingsLabels = {\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",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/data/shared/table/labels.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/data/shared/table/table-frame.tsx",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactNode } from 'react'\n\nexport interface TableFrameProps\n extends Omit<ComponentProps<'section'>, 'title'> {\n title: string\n toolbar: ReactNode\n}\n\nexport function TableFrame({\n children,\n className,\n title,\n toolbar,\n ...props\n}: Readonly<TableFrameProps>) {\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",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/data/shared/table/table-frame.tsx"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/data/shared/table/table-load-state.tsx",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"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 { TableLoadLabels, TableLoadProps } from './types'\n\nexport function TableLoadSkeleton({\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 tableLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton,\n}: Readonly<\n TableLoadProps & { labels: TableLoadLabels; 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",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/data/shared/table/table-load-state.tsx"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/data/shared/table/table-toolbar.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"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 TableToolbarProps {\n 'aria-label': string\n left?: ReactNode\n right?: ReactNode\n}\n\nexport function TableToolbar(props: Readonly<TableToolbarProps>) {\n return <CollectionToolbar className=\"min-h-14 flex-wrap gap-y-3\" {...props} />\n}\n\nexport interface TableToolbarButtonProps {\n children: ReactNode\n disabled?: boolean\n onClick: () => void\n variant?: ButtonProps['variant']\n}\n\nexport function TableToolbarButton({\n children,\n disabled,\n onClick,\n variant = 'outline',\n}: Readonly<TableToolbarButtonProps>) {\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",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/data/shared/table/table-toolbar.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/data/shared/table/types.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "export interface TablePerson {\n id: string\n imageUrl?: string\n label: string\n}\n\nexport interface TableFormatProps {\n currency?: string\n locale?: string\n}\n\nexport interface TableLoadLabels {\n errorDescription: string\n errorTitle: string\n loading: string\n retry: string\n}\n\nexport interface TableLoadProps {\n error?: boolean\n onRetry?: () => void\n pending?: boolean\n}\n\nexport type TableSortDirection = 'asc' | 'desc'\n\nexport interface TableSort<TKey extends string> {\n direction: TableSortDirection\n key: TKey\n}\n\nexport type TableColumnVisibility<TKey extends string> = Partial<\n Record<TKey, boolean>\n>\n\nexport interface TableView {\n id: string\n label: string\n}\n\nexport interface TableViewProps {\n activeViewId?: string\n onViewChange?: (viewId: string) => void\n onViewCreate?: () => void\n views?: TableView[]\n}\n\nexport interface TableViewLabels {\n viewCreate: string\n viewSearch: string\n viewSearchPlaceholder: string\n viewSelect: string\n views: string\n viewsEmpty: string\n}\n\nexport type TableDensity =\n | 'compact'\n | 'extra-tall'\n | 'medium'\n | 'short'\n | 'tall'\n\nexport interface TableSettingsLabels {\n clearSort: string\n densities: Record<TableDensity, string>\n settingsWithFilters: (settings: string, activeFilters: number) => string\n sortOption: (column: string, direction: TableSortDirection) => string\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/data/shared/table/types.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/data/support/support-4/index.ts",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "export { Support4 } from './support-4'\nexport type {\n Support4ColumnId,\n Support4Labels,\n Support4LabelsOverride,\n Support4Props,\n Support4RowAction,\n Support4Rule,\n Support4RuleIcon,\n Support4RuleMove,\n Support4Scope,\n} from './types'\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/index.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/data/support/support-4/labels.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import { defaultTableLoadLabels } from '../../shared/table/labels'\nimport type { Support4Labels, Support4LabelsOverride } from './types'\n\nexport const defaultSupport4Labels: Support4Labels = {\n ...defaultTableLoadLabels,\n columns: {\n actions: 'Ações',\n condition: 'Quando',\n drag: 'Reordenar',\n effect: 'Então',\n enabled: 'Ativa',\n matches: 'Correspondências',\n rank: '#',\n rule: 'Regra',\n scope: 'Escopo',\n },\n dragCancel: (rule) => `Movimento da regra ${rule} cancelado.`,\n dragDrop: (rule, position, total) =>\n `Regra ${rule} solta na posição ${position} de ${total}.`,\n dragHandle: (rule) => `Arrastar para reordenar a regra ${rule}`,\n dragInstructions:\n 'Pressione espaço para pegar a regra, use as setas para mover, espaço para soltar e Esc para cancelar.',\n dragOver: (rule, position, total) =>\n `Regra ${rule} sobre a posição ${position} de ${total}.`,\n dragStart: (rule, position, total) =>\n `Regra ${rule} pega na posição ${position} de ${total}.`,\n empty: 'Nenhuma regra de roteamento.',\n enabledFor: (rule) => `Ativar a regra ${rule}`,\n errorTitle: 'Não foi possível carregar as regras',\n loading: 'Carregando regras',\n matchesIn: (matches) => `${matches} correspondências nos últimos 7 dias`,\n period: '7d',\n resetOrder: 'Restaurar ordem',\n rowActionsFor: (rule) => `Ações da regra ${rule}`,\n summary: (active, matches) =>\n `A primeira regra que casar vence · ${active} ${active === 1 ? 'ativa' : 'ativas'} · ${matches} correspondências`,\n title: 'Regras de roteamento',\n toolbar: 'Controles das regras de roteamento',\n}\n\nexport function resolveSupport4Labels(\n labels: Support4LabelsOverride | undefined,\n): Support4Labels {\n return {\n ...defaultSupport4Labels,\n ...labels,\n columns: { ...defaultSupport4Labels.columns, ...labels?.columns },\n }\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/labels.ts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "blocks/data/support/support-4/support-4-cells.tsx",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import {\n ClockIcon,\n DotsThreeIcon,\n FunnelSimpleIcon,\n LightningIcon,\n PulseIcon,\n SlidersHorizontalIcon,\n TagIcon,\n UsersIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { Menu, MenuItem, MenuPopup, MenuTrigger } from '@tc96/ui/menu'\nimport { Switch } from '@tc96/ui/switch'\nimport { cn } from '@tc96/utils'\nimport type { ComponentType } from 'react'\nimport { DataSelect } from '../../shared/properties/data-properties'\nimport type { TableFormatter } from '../../shared/table/format'\nimport type {\n Support4Labels,\n Support4RowAction,\n Support4Rule,\n Support4RuleIcon,\n} from './types'\n\nconst ruleIcons = {\n alert: WarningIcon,\n clock: ClockIcon,\n people: UsersIcon,\n sliders: SlidersHorizontalIcon,\n tag: TagIcon,\n} as const satisfies Record<\n Support4RuleIcon,\n ComponentType<{ 'aria-hidden'?: 'true' }>\n>\n\nconst tone = (rule: Support4Rule) =>\n rule.enabled ? 'text-foreground' : 'text-muted-foreground'\n\nexport function RankCell({\n position,\n rule,\n}: Readonly<{ position: number; rule: Support4Rule }>) {\n return (\n <span\n className={cn('tabular-nums', tone(rule))}\n data-disabled={rule.enabled ? undefined : ''}\n data-slot=\"support-4-rank\"\n >\n {position}\n </span>\n )\n}\n\nexport function RuleCell({ rule }: Readonly<{ rule: Support4Rule }>) {\n const Icon = ruleIcons[rule.icon]\n\n return (\n <div\n className=\"flex min-w-0 items-center gap-3\"\n data-disabled={rule.enabled ? undefined : ''}\n >\n <IconFrame shape=\"rounded\" size=\"sm\">\n <Icon aria-hidden=\"true\" />\n </IconFrame>\n <span className=\"grid min-w-0 gap-0.5\">\n <span className={cn('truncate font-medium', tone(rule))}>\n {rule.name}\n </span>\n <span className=\"truncate text-muted-foreground text-xs\">\n {rule.description}\n </span>\n </span>\n </div>\n )\n}\n\nexport function ScopeCell({\n ariaLabel,\n rule,\n}: Readonly<{ ariaLabel: string; rule: Support4Rule }>) {\n const { label, tone = 'neutral' } = rule.scope\n\n return (\n <DataSelect\n ariaLabel={ariaLabel}\n options={[{ label, tone: rule.enabled ? tone : 'neutral', value: label }]}\n value={label}\n />\n )\n}\n\nexport function ClauseCell({\n kind,\n rule,\n}: Readonly<{ kind: 'condition' | 'effect'; rule: Support4Rule }>) {\n const Icon = kind === 'condition' ? FunnelSimpleIcon : LightningIcon\n\n return (\n <span className={cn('flex min-w-0 items-center gap-1.5', tone(rule))}>\n <Icon aria-hidden=\"true\" className=\"size-4 shrink-0\" />\n <span className=\"truncate\">{rule[kind]}</span>\n </span>\n )\n}\n\nexport function MatchesCell({\n formatter,\n labels,\n rule,\n}: Readonly<{\n formatter: TableFormatter\n labels: Support4Labels\n rule: Support4Rule\n}>) {\n const matches = formatter.number(rule.matches)\n\n return (\n <span className={cn('flex items-center gap-1.5', tone(rule))}>\n <PulseIcon aria-hidden=\"true\" className=\"size-4 shrink-0\" />\n <span aria-hidden=\"true\" className=\"font-medium tabular-nums\">\n {matches}\n </span>\n <span aria-hidden=\"true\" className=\"text-muted-foreground text-xs\">\n {labels.period}\n </span>\n <span className=\"sr-only\">{labels.matchesIn(matches)}</span>\n </span>\n )\n}\n\nexport function EnabledCell({\n labels,\n onEnabledChange,\n rule,\n}: Readonly<{\n labels: Support4Labels\n onEnabledChange?: (ruleId: string, enabled: boolean) => void\n rule: Support4Rule\n}>) {\n return (\n <Switch\n aria-label={labels.enabledFor(rule.name)}\n checked={rule.enabled}\n disabled={!onEnabledChange}\n onCheckedChange={(checked) => onEnabledChange?.(rule.id, checked)}\n />\n )\n}\n\nexport function RowActionsCell({\n actions,\n labels,\n onRowAction,\n rule,\n}: Readonly<{\n actions: Support4RowAction[]\n labels: Support4Labels\n onRowAction: (actionId: string, ruleId: string) => void\n rule: Support4Rule\n}>) {\n return (\n <Menu>\n <MenuTrigger\n aria-label={labels.rowActionsFor(rule.name)}\n render={<Button size=\"icon-sm\" variant=\"ghost\" />}\n >\n <DotsThreeIcon aria-hidden=\"true\" />\n </MenuTrigger>\n <MenuPopup align=\"end\">\n {actions.map((action) => (\n <MenuItem\n key={action.id}\n onClick={() => onRowAction(action.id, rule.id)}\n variant={action.destructive ? 'destructive' : undefined}\n >\n {action.label}\n </MenuItem>\n ))}\n </MenuPopup>\n </Menu>\n )\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/support-4-cells.tsx"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "blocks/data/support/support-4/support-4-columns.tsx",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import type { DataTableColumnDef } from '@tc96/ui/patterns/data-table/data-table-features'\nimport { createDataTableRowDragColumn } from '@tc96/ui/patterns/data-table/data-table-row-drag-column'\nimport type { TableFormatter } from '../../shared/table/format'\nimport {\n ClauseCell,\n EnabledCell,\n MatchesCell,\n RankCell,\n RowActionsCell,\n RuleCell,\n ScopeCell,\n} from './support-4-cells'\nimport type {\n Support4ColumnId,\n Support4Labels,\n Support4RowAction,\n Support4Rule,\n} from './types'\n\nexport interface Support4ColumnsInput {\n formatter: TableFormatter\n labels: Support4Labels\n onEnabledChange?: (ruleId: string, enabled: boolean) => void\n onRowAction?: (actionId: string, ruleId: string) => void\n rowActions?: Support4RowAction[]\n}\n\nexport function createSupport4Columns({\n formatter,\n labels,\n onEnabledChange,\n onRowAction,\n rowActions,\n}: Readonly<Support4ColumnsInput>): DataTableColumnDef<Support4Rule>[] {\n const title = (id: Support4ColumnId) => labels.columns[id]\n\n const columns: DataTableColumnDef<Support4Rule>[] = [\n createDataTableRowDragColumn<Support4Rule>({\n getHandleLabel: (rule) => labels.dragHandle(rule.name),\n headerLabel: title('drag'),\n }),\n {\n cell: ({ row }) => (\n <RankCell position={row.index + 1} rule={row.original} />\n ),\n enableResizing: false,\n header: title('rank'),\n id: 'rank',\n meta: { label: title('rank') },\n size: 56,\n },\n {\n accessorFn: (rule) => `${rule.name} ${rule.description}`,\n cell: ({ row }) => <RuleCell rule={row.original} />,\n enableHiding: false,\n header: title('rule'),\n id: 'rule',\n meta: { label: title('rule') },\n size: 280,\n },\n {\n accessorFn: (rule) => rule.scope.label,\n cell: ({ row }) => (\n <ScopeCell ariaLabel={title('scope')} rule={row.original} />\n ),\n header: title('scope'),\n id: 'scope',\n meta: { label: title('scope') },\n size: 130,\n },\n {\n accessorFn: (rule) => rule.condition,\n cell: ({ row }) => <ClauseCell kind=\"condition\" rule={row.original} />,\n header: title('condition'),\n id: 'condition',\n meta: { label: title('condition') },\n size: 200,\n },\n {\n accessorFn: (rule) => rule.effect,\n cell: ({ row }) => <ClauseCell kind=\"effect\" rule={row.original} />,\n header: title('effect'),\n id: 'effect',\n meta: { label: title('effect') },\n size: 200,\n },\n {\n accessorFn: (rule) => rule.matches,\n cell: ({ row }) => (\n <MatchesCell\n formatter={formatter}\n labels={labels}\n rule={row.original}\n />\n ),\n header: title('matches'),\n id: 'matches',\n meta: { label: title('matches') },\n size: 150,\n },\n {\n accessorFn: (rule) => rule.enabled,\n cell: ({ row }) => (\n <EnabledCell\n labels={labels}\n onEnabledChange={onEnabledChange}\n rule={row.original}\n />\n ),\n header: title('enabled'),\n id: 'enabled',\n meta: { label: title('enabled') },\n size: 100,\n },\n ]\n\n if (onRowAction && rowActions?.length) {\n columns.push({\n cell: ({ row }) => (\n <RowActionsCell\n actions={rowActions}\n labels={labels}\n onRowAction={onRowAction}\n rule={row.original}\n />\n ),\n enableHiding: false,\n enablePinning: false,\n enableResizing: 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",
|
|
75
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/support-4-columns.tsx"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "blocks/data/support/support-4/support-4-skeleton.tsx",
|
|
79
|
+
"type": "registry:file",
|
|
80
|
+
"content": "import { Skeleton } from '@tc96/ui/skeleton'\nimport { TableLoadSkeleton } from '../../shared/table/table-load-state'\n\nconst rows = ['a', 'b', 'c', 'd', 'e', 'f']\n\nexport function Support4Skeleton({ label }: Readonly<{ label: string }>) {\n return (\n <TableLoadSkeleton\n className=\"grid gap-2 rounded-md border p-3\"\n label={label}\n >\n {rows.map((id) => (\n <div\n className=\"grid grid-cols-[1.5rem_1.5rem_2fr_1fr_1.5fr_1.5fr_1fr_2.5rem] items-center gap-4 py-1.5\"\n key={id}\n >\n <Skeleton className=\"size-4\" />\n <Skeleton className=\"h-4 w-4\" />\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-32\" />\n <Skeleton className=\"h-3 w-24\" />\n </div>\n </div>\n <Skeleton className=\"h-5 w-16 rounded-sm\" />\n <Skeleton className=\"h-4 w-28\" />\n <Skeleton className=\"h-4 w-28\" />\n <Skeleton className=\"h-4 w-14\" />\n <Skeleton className=\"h-4 w-8 rounded-full\" />\n </div>\n ))}\n </TableLoadSkeleton>\n )\n}\n",
|
|
81
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/support-4-skeleton.tsx"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"path": "blocks/data/support/support-4/support-4-toolbar.tsx",
|
|
85
|
+
"type": "registry:file",
|
|
86
|
+
"content": "import { ArrowCounterClockwiseIcon } from '@phosphor-icons/react'\nimport {\n CollectionToolbarDescription,\n CollectionToolbarHeading,\n CollectionToolbarTitle,\n} from '@tc96/ui/patterns/toolbar/components/collection-toolbar-heading'\nimport {\n TableToolbar,\n TableToolbarButton,\n} from '../../shared/table/table-toolbar'\nimport type { Support4Labels } from './types'\n\nexport interface Support4ToolbarProps {\n description: string\n labels: Support4Labels\n onResetOrder?: () => void\n orderChanged: boolean\n}\n\nexport function Support4Toolbar({\n description,\n labels,\n onResetOrder,\n orderChanged,\n}: Readonly<Support4ToolbarProps>) {\n return (\n <TableToolbar\n aria-label={labels.toolbar}\n left={\n <CollectionToolbarHeading>\n <CollectionToolbarTitle>{labels.title}</CollectionToolbarTitle>\n <CollectionToolbarDescription>\n {description}\n </CollectionToolbarDescription>\n </CollectionToolbarHeading>\n }\n right={\n onResetOrder ? (\n <TableToolbarButton disabled={!orderChanged} onClick={onResetOrder}>\n <ArrowCounterClockwiseIcon aria-hidden=\"true\" />\n {labels.resetOrder}\n </TableToolbarButton>\n ) : undefined\n }\n />\n )\n}\n",
|
|
87
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/support-4-toolbar.tsx"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"path": "blocks/data/support/support-4/support-4.tsx",
|
|
91
|
+
"type": "registry:file",
|
|
92
|
+
"content": "'use client'\n\nimport {\n DataTable,\n type DataTableProps,\n} from '@tc96/ui/patterns/data-table/data-table'\nimport { useDataTable } from '@tc96/ui/patterns/data-table/use-data-table'\nimport {\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/table/format'\nimport { TableFrame } from '../../shared/table/table-frame'\nimport { tableLoadState } from '../../shared/table/table-load-state'\nimport { TableToolbar } from '../../shared/table/table-toolbar'\nimport { resolveSupport4Labels } from './labels'\nimport { createSupport4Columns } from './support-4-columns'\nimport { Support4Skeleton } from './support-4-skeleton'\nimport { Support4Toolbar } from './support-4-toolbar'\nimport type { Support4Props, Support4Rule } from './types'\n\ntype RowDragAnnouncements = NonNullable<\n DataTableProps<Support4Rule>['rowDragAnnouncements']\n>\n\nexport function Support4({\n className,\n currency,\n error,\n labels: labelsProp,\n locale,\n onEnabledChange,\n onResetOrder,\n onRetry,\n onRowAction,\n onRuleMove,\n orderChanged = false,\n pending,\n rowActions,\n rules,\n}: Readonly<Support4Props>) {\n const labels = useMemo(() => resolveSupport4Labels(labelsProp), [labelsProp])\n const formatter = useMemo(\n () => createTableFormatter({ currency, locale }),\n [currency, locale],\n )\n const handlersRef = useRef({ onEnabledChange, onRowAction })\n useLayoutEffect(() => {\n handlersRef.current = { onEnabledChange, onRowAction }\n })\n const handleRowAction = useCallback(\n (actionId: string, ruleId: string) =>\n handlersRef.current.onRowAction?.(actionId, ruleId),\n [],\n )\n const handleEnabledChange = useCallback(\n (ruleId: string, enabled: boolean) =>\n handlersRef.current.onEnabledChange?.(ruleId, enabled),\n [],\n )\n const hasRowMenu = Boolean(onRowAction)\n const hasEnabledChange = Boolean(onEnabledChange)\n\n const columns = useMemo(\n () =>\n createSupport4Columns({\n formatter,\n labels,\n onEnabledChange: hasEnabledChange ? handleEnabledChange : undefined,\n onRowAction: hasRowMenu ? handleRowAction : undefined,\n rowActions,\n }),\n [\n formatter,\n handleEnabledChange,\n handleRowAction,\n hasEnabledChange,\n hasRowMenu,\n labels,\n rowActions,\n ],\n )\n\n const { table } = useDataTable<Support4Rule>({\n columns,\n data: rules,\n density: 'tall',\n enableSorting: false,\n getRowId: (rule) => rule.id,\n })\n\n const namesRef = useRef(new Map<string, string>())\n useLayoutEffect(() => {\n namesRef.current = new Map(rules.map((rule) => [rule.id, rule.name]))\n }, [rules])\n const announcements = useMemo<RowDragAnnouncements>(() => {\n const name = (id: string) => namesRef.current.get(id) ?? id\n return {\n end: ({ canceled, rowCount, rowId, toIndex }) =>\n canceled\n ? labels.dragCancel(name(rowId))\n : labels.dragDrop(name(rowId), toIndex + 1, rowCount),\n instructions: labels.dragInstructions,\n over: ({ overIndex, rowCount, rowId }) =>\n labels.dragOver(name(rowId), overIndex + 1, rowCount),\n start: ({ index, rowCount, rowId }) =>\n labels.dragStart(name(rowId), index + 1, rowCount),\n }\n }, [labels])\n\n const loadState = tableLoadState({\n error,\n labels,\n onRetry,\n pending,\n skeleton: <Support4Skeleton label={labels.loading} />,\n })\n\n const active = rules.filter((rule) => rule.enabled).length\n const matches = rules.reduce((total, rule) => total + rule.matches, 0)\n\n return (\n <TableFrame\n className={className}\n data-block=\"support-4\"\n title={labels.title}\n toolbar={\n loadState ? (\n <TableToolbar\n aria-label={labels.toolbar}\n left={\n <CollectionToolbarHeading>\n <CollectionToolbarTitle>{labels.title}</CollectionToolbarTitle>\n </CollectionToolbarHeading>\n }\n />\n ) : (\n <Support4Toolbar\n description={labels.summary(active, formatter.number(matches))}\n labels={labels}\n onResetOrder={onResetOrder}\n orderChanged={orderChanged}\n />\n )\n }\n >\n {loadState ?? (\n <DataTable\n aria-label={labels.title}\n emptyMessage={labels.empty}\n onRowMove={\n onRuleMove\n ? ({ fromIndex, overRowId, rowId, toIndex }) =>\n onRuleMove({\n fromIndex,\n overRuleId: overRowId,\n ruleId: rowId,\n toIndex,\n })\n : undefined\n }\n rowDragAnnouncements={announcements}\n table={table}\n />\n )}\n </TableFrame>\n )\n}\n",
|
|
93
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/support-4.tsx"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"path": "blocks/data/support/support-4/types.ts",
|
|
97
|
+
"type": "registry:file",
|
|
98
|
+
"content": "import type { DataOptionAppearance } from '../../shared/properties/types'\nimport type {\n TableFormatProps,\n TableLoadLabels,\n TableLoadProps,\n} from '../../shared/table/types'\n\nexport type Support4RuleIcon = 'alert' | 'clock' | 'people' | 'sliders' | 'tag'\n\nexport interface Support4Scope {\n label: string\n tone?: DataOptionAppearance['tone']\n}\n\nexport type Support4ColumnId =\n | 'actions'\n | 'condition'\n | 'drag'\n | 'effect'\n | 'enabled'\n | 'matches'\n | 'rank'\n | 'rule'\n | 'scope'\n\nexport interface Support4Rule {\n condition: string\n description: string\n effect: string\n enabled: boolean\n icon: Support4RuleIcon\n id: string\n matches: number\n name: string\n scope: Support4Scope\n}\n\nexport interface Support4RuleMove {\n fromIndex: number\n overRuleId: string\n ruleId: string\n toIndex: number\n}\n\nexport interface Support4RowAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport interface Support4Labels extends TableLoadLabels {\n columns: Record<Support4ColumnId, string>\n dragCancel: (rule: string) => string\n dragDrop: (rule: string, position: number, total: number) => string\n dragHandle: (rule: string) => string\n dragInstructions: string\n dragOver: (rule: string, position: number, total: number) => string\n dragStart: (rule: string, position: number, total: number) => string\n empty: string\n enabledFor: (rule: string) => string\n matchesIn: (matches: string) => string\n period: string\n resetOrder: string\n rowActionsFor: (rule: string) => string\n summary: (active: number, matches: string) => string\n title: string\n toolbar: string\n}\n\nexport type Support4LabelsOverride = Partial<\n Omit<Support4Labels, 'columns'>\n> & {\n columns?: Partial<Support4Labels['columns']>\n}\n\nexport interface Support4Props extends TableFormatProps, TableLoadProps {\n className?: string\n labels?: Support4LabelsOverride\n onEnabledChange?: (ruleId: string, enabled: boolean) => void\n onResetOrder?: () => void\n onRowAction?: (actionId: string, ruleId: string) => void\n onRuleMove?: (move: Support4RuleMove) => void\n orderChanged?: boolean\n rowActions?: Support4RowAction[]\n rules: Support4Rule[]\n}\n",
|
|
99
|
+
"target": "~/packages/ui/src/blocks/data/support/support-4/types.ts"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"path": "helpers/calendar-date.ts",
|
|
103
|
+
"type": "registry:file",
|
|
104
|
+
"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",
|
|
105
|
+
"target": "~/packages/ui/src/helpers/calendar-date.ts"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"path": "helpers/date.ts",
|
|
109
|
+
"type": "registry:file",
|
|
110
|
+
"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",
|
|
111
|
+
"target": "~/packages/ui/src/helpers/date.ts"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"path": "helpers/format.ts",
|
|
115
|
+
"type": "registry:file",
|
|
116
|
+
"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",
|
|
117
|
+
"target": "~/packages/ui/src/helpers/format.ts"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"path": "helpers/initials.ts",
|
|
121
|
+
"type": "registry:file",
|
|
122
|
+
"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",
|
|
123
|
+
"target": "~/packages/ui/src/helpers/initials.ts"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"path": "helpers/zoned-date-time.ts",
|
|
127
|
+
"type": "registry:file",
|
|
128
|
+
"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",
|
|
129
|
+
"target": "~/packages/ui/src/helpers/zoned-date-time.ts"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"path": "patterns/action-bar/components/action-bar.tsx",
|
|
133
|
+
"type": "registry:file",
|
|
134
|
+
"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",
|
|
135
|
+
"target": "~/packages/ui/src/patterns/action-bar/components/action-bar.tsx"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"path": "patterns/action-bar/index.ts",
|
|
139
|
+
"type": "registry:file",
|
|
140
|
+
"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",
|
|
141
|
+
"target": "~/packages/ui/src/patterns/action-bar/index.ts"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"path": "patterns/collection/shared/components/editable-input-cell.tsx",
|
|
145
|
+
"type": "registry:file",
|
|
146
|
+
"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",
|
|
147
|
+
"target": "~/packages/ui/src/patterns/collection/shared/components/editable-input-cell.tsx"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"path": "patterns/collection/shared/components/row-drag-handle.tsx",
|
|
151
|
+
"type": "registry:file",
|
|
152
|
+
"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",
|
|
153
|
+
"target": "~/packages/ui/src/patterns/collection/shared/components/row-drag-handle.tsx"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"path": "patterns/collection/shared/components/row-reorder-provider.tsx",
|
|
157
|
+
"type": "registry:file",
|
|
158
|
+
"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",
|
|
159
|
+
"target": "~/packages/ui/src/patterns/collection/shared/components/row-reorder-provider.tsx"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"path": "patterns/collection/shared/components/selection-actions.tsx",
|
|
163
|
+
"type": "registry:file",
|
|
164
|
+
"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",
|
|
165
|
+
"target": "~/packages/ui/src/patterns/collection/shared/components/selection-actions.tsx"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"path": "patterns/collection/shared/hooks/use-collapsed-groups.ts",
|
|
169
|
+
"type": "registry:file",
|
|
170
|
+
"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",
|
|
171
|
+
"target": "~/packages/ui/src/patterns/collection/shared/hooks/use-collapsed-groups.ts"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"path": "patterns/collection/shared/hooks/use-controllable-table-state.ts",
|
|
175
|
+
"type": "registry:file",
|
|
176
|
+
"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",
|
|
177
|
+
"target": "~/packages/ui/src/patterns/collection/shared/hooks/use-controllable-table-state.ts"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"path": "patterns/collection/shared/hooks/use-end-reached.ts",
|
|
181
|
+
"type": "registry:file",
|
|
182
|
+
"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",
|
|
183
|
+
"target": "~/packages/ui/src/patterns/collection/shared/hooks/use-end-reached.ts"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"path": "patterns/collection/shared/hooks/use-latest-callback.ts",
|
|
187
|
+
"type": "registry:file",
|
|
188
|
+
"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",
|
|
189
|
+
"target": "~/packages/ui/src/patterns/collection/shared/hooks/use-latest-callback.ts"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"path": "patterns/collection/shared/hooks/use-row-reorder.ts",
|
|
193
|
+
"type": "registry:file",
|
|
194
|
+
"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",
|
|
195
|
+
"target": "~/packages/ui/src/patterns/collection/shared/hooks/use-row-reorder.ts"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"path": "patterns/collection/shared/hooks/use-scrollbar-insets.ts",
|
|
199
|
+
"type": "registry:file",
|
|
200
|
+
"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",
|
|
201
|
+
"target": "~/packages/ui/src/patterns/collection/shared/hooks/use-scrollbar-insets.ts"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"path": "patterns/collection/shared/lib/editable-cell.ts",
|
|
205
|
+
"type": "registry:file",
|
|
206
|
+
"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",
|
|
207
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/editable-cell.ts"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"path": "patterns/collection/shared/lib/end-reached.ts",
|
|
211
|
+
"type": "registry:file",
|
|
212
|
+
"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",
|
|
213
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/end-reached.ts"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"path": "patterns/collection/shared/lib/format-value.ts",
|
|
217
|
+
"type": "registry:file",
|
|
218
|
+
"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",
|
|
219
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/format-value.ts"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"path": "patterns/collection/shared/lib/group-runs.ts",
|
|
223
|
+
"type": "registry:file",
|
|
224
|
+
"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",
|
|
225
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/group-runs.ts"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"path": "patterns/collection/shared/lib/interactive-descendants.ts",
|
|
229
|
+
"type": "registry:file",
|
|
230
|
+
"content": "export const interactiveControls =\n 'a[href],button,input,select,textarea,summary,label,[role=button],[role=checkbox],[role=combobox],[role=link],[role=menuitem],[role=option],[role=radio],[role=slider],[role=spinbutton],[role=switch],[role=tab],[role=textbox],[contenteditable]:not([contenteditable=false])'\n\nexport const interactiveDescendants =\n '[&_:is(a[href],button,input,select,textarea,summary,label,[role=button],[role=checkbox],[role=combobox],[role=link],[role=menuitem],[role=option],[role=radio],[role=slider],[role=spinbutton],[role=switch],[role=tab],[role=textbox],[tabindex]:not([tabindex=\"-1\"]),[contenteditable]:not([contenteditable=false]))]:pointer-events-auto'\n",
|
|
231
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/interactive-descendants.ts"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"path": "patterns/collection/shared/lib/row-reorder.ts",
|
|
235
|
+
"type": "registry:file",
|
|
236
|
+
"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",
|
|
237
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/row-reorder.ts"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"path": "patterns/collection/shared/lib/skeleton-keys.ts",
|
|
241
|
+
"type": "registry:file",
|
|
242
|
+
"content": "export function skeletonKeys(prefix: string, count: number): string[] {\n return Array.from({ length: count }).map(\n (_, position) => `${prefix}-${position + 1}`,\n )\n}\n",
|
|
243
|
+
"target": "~/packages/ui/src/patterns/collection/shared/lib/skeleton-keys.ts"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"path": "patterns/collection/types/collection.ts",
|
|
247
|
+
"type": "registry:file",
|
|
248
|
+
"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",
|
|
249
|
+
"target": "~/packages/ui/src/patterns/collection/types/collection.ts"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"path": "patterns/data-table/data-table-aggregation-cell.tsx",
|
|
253
|
+
"type": "registry:file",
|
|
254
|
+
"content": "'use client'\n\nimport { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem } from '@tc96/ui/menu'\nimport { cn } from '@tc96/utils'\nimport type { ReactElement, ReactNode } from 'react'\nimport type {\n DataTableAggregation,\n DataTableAggregationLabels,\n} from './data-table-aggregation'\nimport { DataTableAggregationTrigger } from './data-table-aggregation-trigger'\n\nconst NONE = '__none__'\n\nconst isAggregation = (\n value: unknown,\n options: readonly DataTableAggregation[],\n): value is DataTableAggregation =>\n options.includes(value as DataTableAggregation)\n\nexport function DataTableAggregationCell({\n align = 'start',\n labels,\n onValueChange,\n options,\n result,\n value,\n}: Readonly<{\n align?: 'center' | 'end' | 'start'\n labels: DataTableAggregationLabels\n onValueChange: (value: DataTableAggregation | null) => void\n options: readonly DataTableAggregation[]\n result: ReactNode\n value: DataTableAggregation | null\n}>): ReactElement {\n return (\n <div\n className={cn(\n 'flex',\n align === 'end' && 'justify-end',\n align === 'center' && 'justify-center',\n )}\n data-aggregation={value ?? undefined}\n data-slot=\"data-table-aggregation\"\n >\n <Menu>\n <DataTableAggregationTrigger\n labels={labels}\n result={result}\n value={value}\n />\n <MenuPopup align={align}>\n <MenuRadioGroup\n onValueChange={(next) =>\n onValueChange(isAggregation(next, options) ? next : null)\n }\n value={value ?? NONE}\n >\n <MenuRadioItem value={NONE}>{labels.none}</MenuRadioItem>\n {options.map((option) => (\n <MenuRadioItem key={option} value={option}>\n {labels[option]}\n </MenuRadioItem>\n ))}\n </MenuRadioGroup>\n </MenuPopup>\n </Menu>\n </div>\n )\n}\n",
|
|
255
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-aggregation-cell.tsx"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"path": "patterns/data-table/data-table-aggregation-trigger.tsx",
|
|
259
|
+
"type": "registry:file",
|
|
260
|
+
"content": "'use client'\n\nimport { CaretDownIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { MenuTrigger } from '@tc96/ui/menu'\nimport { cva } from 'class-variance-authority'\nimport type { ReactElement, ReactNode } from 'react'\nimport type {\n DataTableAggregation,\n DataTableAggregationLabels,\n} from './data-table-aggregation'\n\nconst triggerVariants = cva('group/aggregation -mx-2 font-normal', {\n variants: {\n empty: {\n false: '',\n true: 'opacity-0 focus-visible:opacity-100 data-popup-open:opacity-100 group-focus-within/footer:opacity-100 group-hover/footer:opacity-100 pointer-coarse:opacity-100',\n },\n },\n})\n\nexport function DataTableAggregationTrigger({\n labels,\n result,\n value,\n}: Readonly<{\n labels: DataTableAggregationLabels\n result: ReactNode\n value: DataTableAggregation | null\n}>): ReactElement {\n const empty = value === null\n\n return (\n <MenuTrigger\n render={\n <Button\n className={triggerVariants({ empty })}\n size=\"xs\"\n variant=\"ghost\"\n />\n }\n >\n <span className=\"text-muted-foreground group-hover/aggregation:text-accent-foreground/72 group-data-pressed/aggregation:text-accent-foreground/72\">\n {empty ? labels.trigger : labels[value]}\n </span>\n {empty ? null : (\n <>\n {' '}\n <span className=\"font-medium tabular-nums\">{result}</span>\n </>\n )}\n <CaretDownIcon aria-hidden=\"true\" />\n </MenuTrigger>\n )\n}\n",
|
|
261
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-aggregation-trigger.tsx"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"path": "patterns/data-table/data-table-aggregation.ts",
|
|
265
|
+
"type": "registry:file",
|
|
266
|
+
"content": "import type { ReactNode } from 'react'\nimport type { EditableCellMeta } from '../collection/shared/lib/editable-cell'\nimport type { DataTableAlign } from './data-table-types'\n\nexport type DataTableAggregation = 'count' | 'sum'\n\nexport type DataTableAggregations = Readonly<\n Record<string, DataTableAggregation | null>\n>\n\nexport interface DataTableAggregationLabels {\n count: string\n none: string\n sum: string\n trigger: string\n}\n\nexport interface DataTableColumnMeta<TData> extends EditableCellMeta {\n aggregations?: readonly DataTableAggregation[]\n align?: DataTableAlign\n editable?: boolean\n variant?: 'text' | 'number'\n formatAggregation?: (\n value: number,\n aggregation: DataTableAggregation,\n ) => ReactNode\n getAggregationValue?: (row: TData) => number | null | undefined\n label?: string\n}\n\nexport const defaultAggregationLabels: DataTableAggregationLabels = {\n count: 'Contagem',\n none: 'Nenhum',\n sum: 'Soma',\n trigger: 'Calcular',\n}\n\nexport function aggregate<TRow>(\n rows: readonly TRow[],\n aggregation: DataTableAggregation,\n readValue: (row: TRow) => unknown,\n): number {\n if (aggregation === 'count') return rows.length\n return rows.reduce((total, row) => {\n const value = readValue(row)\n return typeof value === 'number' && Number.isFinite(value)\n ? total + value\n : total\n }, 0)\n}\n",
|
|
267
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-aggregation.ts"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"path": "patterns/data-table/data-table-align.ts",
|
|
271
|
+
"type": "registry:file",
|
|
272
|
+
"content": "import type { DataTableAlign } from './data-table-types'\n\nconst ALIGN_CLASS: Record<DataTableAlign, string> = {\n center: 'text-center [&>.flex]:justify-center',\n end: 'text-end [&>.flex]:justify-end',\n start: 'text-start',\n}\n\nexport function columnAlignClass(column: {\n columnDef: { meta?: unknown }\n}): string | undefined {\n const align = (\n column.columnDef.meta as { align?: DataTableAlign } | undefined\n )?.align\n return align ? ALIGN_CLASS[align] : undefined\n}\n",
|
|
273
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-align.ts"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"path": "patterns/data-table/data-table-body.tsx",
|
|
277
|
+
"type": "registry:file",
|
|
278
|
+
"content": "'use client'\n\nimport type { Row, RowData } from '@tanstack/react-table'\nimport { TableBody } from '@tc96/ui/table'\nimport { type ReactNode, useMemo } from 'react'\nimport { RowReorderProvider } from '../collection/shared/components/row-reorder-provider'\nimport { useLatestCallback } from '../collection/shared/hooks/use-latest-callback'\nimport {\n collectGroupRows,\n countGroupRows,\n splitGroupSections,\n} from '../collection/shared/lib/group-runs'\nimport type { DataTableFeatures, DataTableTable } from './data-table-features'\nimport {\n type DataTableGroupCellContext,\n DataTableGroupRow,\n} from './data-table-group-row'\nimport { DataTableRow } from './data-table-row'\nimport type {\n DataTableRowDragAnnouncements,\n DataTableRowMove,\n} from './data-table-types'\n\ntype TableRowOf<TData extends RowData> = Row<DataTableFeatures, TData>\n\nexport interface DataTableBodyProps<TData extends RowData> {\n collapsedGroupIds: readonly string[]\n getGroupToggleLabel?: (group: string, collapsed: boolean) => string\n getRowGroup?: (row: TData) => string | null\n getRowCanOpen?: (row: TableRowOf<TData>) => boolean\n getRowOpenLabel?: (row: TableRowOf<TData>) => string\n loadingMore: ReactNode\n meta: DataTableTable<TData>['options']['meta']\n onRowOpen?: (row: TableRowOf<TData>) => void\n onRowMove?: (move: DataTableRowMove) => void\n onToggleGroup: (group: string, collapsed: boolean) => void\n renderGroupCell?: (context: DataTableGroupCellContext<TData>) => ReactNode\n reorderActive: boolean\n rowDragAnnouncements?: DataTableRowDragAnnouncements\n rows: readonly TableRowOf<TData>[]\n table: DataTableTable<TData>\n visibleColumns: ReturnType<DataTableTable<TData>['getVisibleLeafColumns']>\n}\n\nconst defaultRowOpenLabel = 'Abrir registro'\nconst NON_LABEL_COLUMN_IDS: readonly string[] = ['select', 'actions', 'drag']\nconst NO_ROW_GROUPS: ReadonlyMap<string, string | null> = new Map()\n\nexport function DataTableBody<TData extends RowData>({\n collapsedGroupIds,\n getGroupToggleLabel,\n getRowCanOpen,\n getRowGroup,\n getRowOpenLabel,\n loadingMore,\n meta,\n onRowOpen,\n onRowMove,\n onToggleGroup,\n renderGroupCell,\n reorderActive,\n rowDragAnnouncements,\n rows,\n table,\n visibleColumns,\n}: DataTableBodyProps<TData>) {\n const groupByRowId = useMemo(\n () =>\n getRowGroup\n ? new Map(rows.map((row) => [row.id, getRowGroup(row.original)]))\n : NO_ROW_GROUPS,\n [getRowGroup, rows],\n )\n const indexByRowId = useMemo(\n () => new Map(rows.map((row, index) => [row.id, index])),\n [rows],\n )\n const rowIds = useMemo(() => rows.map((row) => row.id), [rows])\n const getCollectionIndexes = useLatestCallback((): number[] => {\n const positions = new Map<string, number>(\n table\n .getPrePaginatedRowModel()\n .rows.map((row, position) => [row.id, position]),\n )\n return rows.map((row, index) => positions.get(row.id) ?? index)\n })\n\n const renderRow = (row: TableRowOf<TData>) => {\n const opens = onRowOpen && (getRowCanOpen?.(row) ?? true)\n return (\n <DataTableRow\n canSelect={row.getCanSelect()}\n expanded={row.getIsExpanded()}\n key={row.id}\n meta={meta}\n onRowOpen={opens ? onRowOpen : undefined}\n openLabel={\n opens ? (getRowOpenLabel?.(row) ?? defaultRowOpenLabel) : undefined\n }\n reorderable={reorderActive}\n row={row}\n selected={row.getIsSelected()}\n visibleColumns={visibleColumns}\n />\n )\n }\n\n if (!getRowGroup) {\n return (\n <RowReorderProvider\n active={reorderActive}\n announcements={rowDragAnnouncements}\n getCollectionIndexes={getCollectionIndexes}\n indexByRowId={indexByRowId}\n onRowMove={onRowMove}\n rowIds={rowIds}\n >\n <TableBody>\n {rows.map(renderRow)}\n {loadingMore}\n </TableBody>\n </RowReorderProvider>\n )\n }\n\n const collapsed = new Set(collapsedGroupIds)\n const counts = countGroupRows(rows, groupByRowId)\n const rowsByGroup = renderGroupCell\n ? collectGroupRows(rows, groupByRowId)\n : undefined\n const labelColumnId = visibleColumns.find(\n (column) => !NON_LABEL_COLUMN_IDS.includes(column.id),\n )?.id\n const sections = splitGroupSections(rows, groupByRowId)\n\n return sections.map((section, index) => {\n const { group } = section\n const isCollapsed = group !== null && collapsed.has(group)\n const isLast = index === sections.length - 1\n return (\n <TableBody key={`${group ?? ''}:${section.rows[0]?.id ?? index}`}>\n {group === null ? null : (\n <DataTableGroupRow\n collapsed={isCollapsed}\n columns={visibleColumns}\n count={counts.get(group) ?? 0}\n getGroupToggleLabel={getGroupToggleLabel}\n group={group}\n labelColumnId={labelColumnId}\n onToggle={onToggleGroup}\n renderGroupCell={renderGroupCell}\n rows={rowsByGroup?.get(group) ?? section.rows}\n />\n )}\n {isCollapsed ? null : section.rows.map(renderRow)}\n {isLast ? loadingMore : null}\n </TableBody>\n )\n })\n}\n",
|
|
279
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-body.tsx"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"path": "patterns/data-table/data-table-cell.tsx",
|
|
283
|
+
"type": "registry:file",
|
|
284
|
+
"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 type { DataTableColumnMeta } from './data-table-aggregation'\nimport type { DataTableFeatures } from './data-table-features'\nimport type { DataTableTableMeta } from './data-table-types'\n\nconst ALIGN_CLASS = {\n center: 'text-center',\n end: 'text-end',\n start: 'text-start',\n} as const\n\nexport function DataTableCell<TData extends RowData>({\n context,\n}: {\n context: CellContext<DataTableFeatures, TData, unknown>\n}) {\n const { column, getValue, row, table } = context\n const meta = (column.columnDef.meta ?? {}) as DataTableColumnMeta<TData>\n const onValueChange = (table.options.meta as DataTableTableMeta | undefined)\n ?.onDataTableCellValueChange\n const value = toStringValue(getValue())\n\n if (!(meta.editable && onValueChange)) return value || null\n\n return (\n <EditableInputCell\n alignClassName={ALIGN_CLASS[meta.align ?? 'start']}\n cellSelector='[data-slot=\"table-cell\"]'\n columnId={column.id}\n meta={meta}\n numeric={meta.variant === 'number'}\n onValueChange={onValueChange}\n row={row}\n slot=\"data-table-input-cell\"\n triggerAttribute=\"data-table-input-trigger\"\n value={value}\n />\n )\n}\n",
|
|
285
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-cell.tsx"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"path": "patterns/data-table/data-table-columns-submenu.tsx",
|
|
289
|
+
"type": "registry:file",
|
|
290
|
+
"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 { DataTableColumnMeta } from './data-table-aggregation'\nimport type { DataTableTable } from './data-table-features'\n\nexport interface DataTableColumnsSubmenuProps<TData extends RowData> {\n label?: string\n table: DataTableTable<TData>\n}\n\nexport function DataTableColumnsSubmenu<TData extends RowData>({\n label = 'Colunas',\n table,\n}: DataTableColumnsSubmenuProps<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 ??\n {}) as DataTableColumnMeta<TData>\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",
|
|
291
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-columns-submenu.tsx"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"path": "patterns/data-table/data-table-expand-toggle.tsx",
|
|
295
|
+
"type": "registry:file",
|
|
296
|
+
"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 { DataTableFeatures } from './data-table-features'\n\nconst DEFAULT_INDENT_PX = 20\n\nexport interface DataTableExpandToggleProps<TData extends RowData> {\n children?: ReactNode\n getLabel: (row: Row<DataTableFeatures, TData>, expanded: boolean) => string\n indent?: number\n row: Row<DataTableFeatures, TData>\n}\n\nexport function DataTableExpandToggle<TData extends RowData>({\n children,\n getLabel,\n indent = DEFAULT_INDENT_PX,\n row,\n}: DataTableExpandToggleProps<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-table-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-table-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",
|
|
297
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-expand-toggle.tsx"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"path": "patterns/data-table/data-table-features.ts",
|
|
301
|
+
"type": "registry:file",
|
|
302
|
+
"content": "import {\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 RowData,\n rowExpandingFeature,\n rowPaginationFeature,\n rowSelectionFeature,\n rowSortingFeature,\n sortFns,\n type Table,\n tableFeatures,\n} from '@tanstack/react-table'\n\n/** Features, row models and sort and filter registries the DataTable relies on. */\nexport const dataTableFeatures = tableFeatures({\n columnFilteringFeature,\n globalFilteringFeature,\n columnVisibilityFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnSizingFeature,\n columnResizingFeature,\n rowSelectionFeature,\n rowSortingFeature,\n rowExpandingFeature,\n rowPaginationFeature,\n filteredRowModel: createFilteredRowModel(),\n sortedRowModel: createSortedRowModel(),\n expandedRowModel: createExpandedRowModel(),\n paginatedRowModel: createPaginatedRowModel(),\n filterFns,\n sortFns,\n})\n\nexport type DataTableFeatures = typeof dataTableFeatures\n\n/** Table instance consumed by `<DataTable />`. */\nexport type DataTableTable<TData extends RowData> = Table<\n DataTableFeatures,\n TData\n>\n\nexport type DataTableColumnDef<TData extends RowData> = ColumnDef<\n DataTableFeatures,\n TData,\n unknown\n>\n",
|
|
303
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-features.ts"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"path": "patterns/data-table/data-table-group-row.tsx",
|
|
307
|
+
"type": "registry:file",
|
|
308
|
+
"content": "'use client'\n\nimport { CaretDownIcon, CaretRightIcon } from '@phosphor-icons/react'\nimport type { Column, Row, RowData } from '@tanstack/react-table'\nimport { Badge } from '@tc96/ui/badge'\nimport { Button } from '@tc96/ui/button'\nimport { TableRow } from '@tc96/ui/table'\nimport { cn } from '@tc96/utils'\nimport { memo, type ReactNode } from 'react'\nimport type { DataTableColumnMeta } from './data-table-aggregation'\nimport type { DataTableFeatures } from './data-table-features'\n\nexport interface DataTableGroupCellContext<TData extends RowData> {\n collapsed: boolean\n column: Column<DataTableFeatures, TData, unknown>\n count: number\n group: string\n rows: readonly Row<DataTableFeatures, TData>[]\n}\n\nexport interface DataTableGroupRowProps<TData extends RowData> {\n collapsed: boolean\n columns: readonly Column<DataTableFeatures, TData, unknown>[]\n count: number\n getGroupToggleLabel?: (group: string, collapsed: boolean) => string\n group: string\n labelColumnId?: string\n onToggle: (group: string, collapsed: boolean) => void\n renderGroupCell?: (context: DataTableGroupCellContext<TData>) => ReactNode\n rows: readonly Row<DataTableFeatures, TData>[]\n}\n\nconst defaultGroupToggleLabel = (group: string, collapsed: boolean) =>\n collapsed ? `Expandir ${group}` : `Recolher ${group}`\n\nconst groupCellClassName =\n 'h-10 whitespace-nowrap bg-muted/40 px-2.5 align-middle font-medium'\n\nconst ALIGN_CLASS = {\n center: 'text-center',\n end: 'text-end',\n start: 'text-start',\n} as const\n\nfunction DataTableGroupLabel({\n collapsed,\n count,\n getGroupToggleLabel = defaultGroupToggleLabel,\n group,\n onToggle,\n}: Pick<\n DataTableGroupRowProps<RowData>,\n 'collapsed' | 'count' | 'getGroupToggleLabel' | 'group' | 'onToggle'\n>) {\n return (\n <div className=\"flex min-w-0 items-center gap-1\">\n <Button\n aria-expanded={!collapsed}\n aria-label={getGroupToggleLabel(group, collapsed)}\n data-slot=\"data-table-group-toggle\"\n onClick={() => onToggle(group, !collapsed)}\n size=\"icon-sm\"\n type=\"button\"\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-table-group-label\">\n {group}\n </span>\n <Badge\n className=\"tabular-nums\"\n data-slot=\"data-table-group-count\"\n variant=\"secondary\"\n >\n {count}\n </Badge>\n </div>\n )\n}\n\nfunction DataTableGroupRowView<TData extends RowData>({\n collapsed,\n columns,\n count,\n getGroupToggleLabel,\n group,\n labelColumnId,\n onToggle,\n renderGroupCell,\n rows,\n}: DataTableGroupRowProps<TData>) {\n const label = (\n <DataTableGroupLabel\n collapsed={collapsed}\n count={count}\n getGroupToggleLabel={getGroupToggleLabel}\n group={group}\n onToggle={onToggle}\n />\n )\n\n if (!renderGroupCell) {\n return (\n <TableRow\n data-collapsed={collapsed ? 'true' : undefined}\n data-slot=\"data-table-group-row\"\n >\n <th\n className={cn(groupCellClassName, 'text-start')}\n colSpan={columns.length}\n scope=\"rowgroup\"\n >\n {label}\n </th>\n </TableRow>\n )\n }\n\n const labelIndex = Math.max(\n columns.findIndex((column) => column.id === labelColumnId),\n 0,\n )\n\n return (\n <TableRow\n data-collapsed={collapsed ? 'true' : undefined}\n data-slot=\"data-table-group-row\"\n >\n {columns.map((column, index) => {\n const align =\n ALIGN_CLASS[\n (column.columnDef.meta as DataTableColumnMeta<TData> | undefined)\n ?.align ?? 'start'\n ]\n if (index === labelIndex) {\n return (\n <th\n className={cn(groupCellClassName, 'text-start')}\n data-column-id={column.id}\n key={column.id}\n scope=\"rowgroup\"\n >\n {label}\n </th>\n )\n }\n return (\n <td\n className={cn(groupCellClassName, align)}\n data-column-id={column.id}\n data-slot=\"data-table-group-cell\"\n key={column.id}\n >\n {index < labelIndex\n ? null\n : renderGroupCell({ collapsed, column, count, group, rows })}\n </td>\n )\n })}\n </TableRow>\n )\n}\n\nexport const DataTableGroupRow = memo(\n DataTableGroupRowView,\n) as typeof DataTableGroupRowView\n",
|
|
309
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-group-row.tsx"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"path": "patterns/data-table/data-table-resize-handle.tsx",
|
|
313
|
+
"type": "registry:file",
|
|
314
|
+
"content": "'use client'\n\nimport type { Header, RowData } from '@tanstack/react-table'\nimport { cn } from '@tc96/utils'\nimport type { KeyboardEvent, ReactElement } from 'react'\nimport type { DataTableFeatures, DataTableTable } from './data-table-features'\n\nconst RESIZE_STEP_PX = 8\nconst DEFAULT_MIN_COLUMN_SIZE = 20\nconst DEFAULT_MAX_COLUMN_SIZE = Number.MAX_SAFE_INTEGER\n\nexport interface DataTableResizeHandleProps<TData extends RowData> {\n header: Header<DataTableFeatures, TData, unknown>\n table: DataTableTable<TData>\n}\n\nexport function DataTableResizeHandle<TData extends RowData>({\n header,\n table,\n}: DataTableResizeHandleProps<TData>): ReactElement {\n const { column } = header\n const min = column.columnDef.minSize ?? DEFAULT_MIN_COLUMN_SIZE\n const max = column.columnDef.maxSize ?? DEFAULT_MAX_COLUMN_SIZE\n const size = column.getSize()\n const label =\n typeof column.columnDef.header === 'string'\n ? column.columnDef.header\n : column.id\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const delta =\n event.key === 'ArrowLeft'\n ? -RESIZE_STEP_PX\n : event.key === 'ArrowRight'\n ? RESIZE_STEP_PX\n : 0\n if (!delta) return\n event.preventDefault()\n table.setColumnSizing((current) => ({\n ...current,\n [column.id]: Math.min(max, Math.max(min, size + delta)),\n }))\n }\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: the grab area is an ::after box, which a void <hr> cannot render\n <div\n aria-label={`Redimensionar coluna ${label}`}\n aria-orientation=\"vertical\"\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={size}\n className={cn(\n 'absolute inset-y-0 end-0 z-10 w-0.5 cursor-ew-resize touch-none select-none outline-none after:absolute after:inset-y-0 after:end-0 after:w-3 hover:bg-primary focus-visible:bg-primary',\n column.getIsResizing() ? 'bg-primary' : 'bg-border',\n )}\n onDoubleClick={() => column.resetSize()}\n onKeyDown={handleKeyDown}\n onMouseDown={header.getResizeHandler()}\n onTouchStart={header.getResizeHandler()}\n role=\"separator\"\n tabIndex={0}\n />\n )\n}\n",
|
|
315
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-resize-handle.tsx"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"path": "patterns/data-table/data-table-row-drag-column.tsx",
|
|
319
|
+
"type": "registry:file",
|
|
320
|
+
"content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { RowDragHandle } from '../collection/shared/components/row-drag-handle'\nimport type { DataTableColumnDef } from './data-table-features'\n\nconst ROW_DRAG_TYPE = 'data-table-row'\n\nexport interface CreateDataTableRowDragColumnOptions<TData extends RowData> {\n getHandleLabel: (row: TData) => string\n headerLabel?: string\n size?: number\n}\n\nexport function createDataTableRowDragColumn<TData extends RowData>({\n getHandleLabel,\n headerLabel,\n size = 40,\n}: CreateDataTableRowDragColumnOptions<TData>): DataTableColumnDef<TData> {\n return {\n id: 'drag',\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=\"tr\"\n slot=\"data-table-row-drag-handle\"\n />\n ),\n }\n}\n",
|
|
321
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-row-drag-column.tsx"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"path": "patterns/data-table/data-table-row.tsx",
|
|
325
|
+
"type": "registry:file",
|
|
326
|
+
"content": "'use client'\n\nimport { flexRender, type Row, type RowData } from '@tanstack/react-table'\nimport { TableCell, TableRow } from '@tc96/ui/table'\nimport { cn } from '@tc96/utils'\nimport { memo } from 'react'\nimport { interactiveDescendants } from '../collection/shared/lib/interactive-descendants'\nimport { columnAlignClass } from './data-table-align'\nimport type { DataTableFeatures, DataTableTable } from './data-table-features'\n\nexport interface DataTableRowProps<TData extends RowData> {\n canSelect: boolean\n expanded: boolean\n meta: DataTableTable<TData>['options']['meta']\n onRowOpen?: (row: Row<DataTableFeatures, TData>) => void\n openLabel?: string\n reorderable: boolean\n row: Row<DataTableFeatures, TData>\n selected: boolean\n visibleColumns: ReturnType<DataTableTable<TData>['getVisibleLeafColumns']>\n}\n\nfunction DataTableRowView<TData extends RowData>({\n onRowOpen,\n openLabel,\n reorderable,\n row,\n selected,\n}: DataTableRowProps<TData>) {\n return (\n <TableRow\n className={\n onRowOpen || reorderable\n ? cn(\n onRowOpen && 'isolate',\n reorderable && 'data-dnd-dragging:bg-background',\n )\n : undefined\n }\n data-interactive={onRowOpen ? '' : undefined}\n data-state={selected ? 'selected' : undefined}\n >\n {row.getVisibleCells().map((cell, position) => (\n <TableCell\n className={\n cn(\n onRowOpen && ['pointer-events-none', interactiveDescendants],\n columnAlignClass(cell.column),\n ) || undefined\n }\n key={cell.id}\n >\n {onRowOpen && position === 0 ? (\n <button\n aria-label={openLabel}\n className=\"absolute inset-0 -z-10 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\"\n data-slot=\"data-table-row-trigger\"\n onClick={() => onRowOpen(row)}\n type=\"button\"\n />\n ) : null}\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </TableCell>\n ))}\n </TableRow>\n )\n}\n\nexport const DataTableRow = memo(DataTableRowView) as typeof DataTableRowView\n",
|
|
327
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-row.tsx"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"path": "patterns/data-table/data-table-select-column.tsx",
|
|
331
|
+
"type": "registry:file",
|
|
332
|
+
"content": "'use client'\n\nimport type { RowData } from '@tanstack/react-table'\nimport { Checkbox } from '@tc96/ui/checkbox'\nimport type { DataTableColumnDef } from './data-table-features'\n\nexport interface CreateDataTableSelectColumnOptions<TData extends RowData> {\n selectAllLabel?: string\n getRowLabel?: (row: TData) => string\n size?: number\n}\n\nexport function createDataTableSelectColumn<TData extends RowData>(\n options: CreateDataTableSelectColumnOptions<TData> = {},\n): DataTableColumnDef<TData> {\n return {\n id: 'select',\n size: options.size ?? 40,\n enableSorting: false,\n enableHiding: false,\n enablePinning: false,\n enableResizing: false,\n header: ({ table }) => (\n <Checkbox\n aria-label={options.selectAllLabel ?? 'Selecionar todos os registros'}\n checked={table.getIsAllPageRowsSelected()}\n indeterminate={\n table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected()\n }\n onCheckedChange={(checked) =>\n table.toggleAllPageRowsSelected(Boolean(checked))\n }\n />\n ),\n cell: ({ row }) => (\n <Checkbox\n aria-label={\n options.getRowLabel?.(row.original) ?? 'Selecionar registro'\n }\n checked={row.getIsSelected()}\n disabled={!row.getCanSelect()}\n onCheckedChange={(checked) => row.toggleSelected(Boolean(checked))}\n />\n ),\n }\n}\n",
|
|
333
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-select-column.tsx"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"path": "patterns/data-table/data-table-skeleton-rows.tsx",
|
|
337
|
+
"type": "registry:file",
|
|
338
|
+
"content": "'use client'\n\nimport { Skeleton } from '@tc96/ui/skeleton'\nimport { TableCell, TableRow } from '@tc96/ui/table'\nimport { cn } from '@tc96/utils'\nimport { skeletonKeys } from '../collection/shared/lib/skeleton-keys'\n\nexport interface DataTableRowSkeletonAnatomy {\n cell?: 'control' | 'text'\n lines?: 1 | 2\n}\n\nexport interface DataTableSkeletonRowsProps {\n anatomy: DataTableRowSkeletonAnatomy\n columnCount: number\n label: string\n linesColumnIndex: number\n loadingMore?: boolean\n rowCount: number\n scope: string\n}\n\nexport function DataTableSkeletonRows({\n anatomy,\n columnCount,\n label,\n linesColumnIndex,\n loadingMore = false,\n rowCount,\n scope,\n}: DataTableSkeletonRowsProps) {\n return skeletonKeys(scope, rowCount).map((rowKey) => (\n <TableRow\n data-cell={anatomy.cell ?? 'text'}\n data-lines={anatomy.lines ?? 1}\n data-loading-more={loadingMore ? 'true' : undefined}\n key={rowKey}\n >\n {skeletonKeys(rowKey, columnCount).map((cellKey, index) => (\n <TableCell key={cellKey}>\n {index === 0 ? (\n <output aria-busy=\"true\" className=\"sr-only\">\n {label}\n </output>\n ) : null}\n {index === linesColumnIndex && anatomy.lines === 2 ? (\n <div className=\"flex min-w-4 flex-col\">\n <Skeleton className=\"my-0.5 h-4 w-full\" />\n <Skeleton className=\"h-3 w-1/2\" />\n </div>\n ) : (\n <Skeleton\n className={cn(\n 'min-w-4 w-full',\n anatomy.cell === 'control' ? 'h-6' : 'my-0.5 h-4',\n )}\n />\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n}\n",
|
|
339
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-skeleton-rows.tsx"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"path": "patterns/data-table/data-table-types.ts",
|
|
343
|
+
"type": "registry:file",
|
|
344
|
+
"content": "import type {\n EditableCellRow,\n EditableCellValueChange,\n} from '../collection/shared/lib/editable-cell'\nimport type {\n RowDragAnnouncements,\n RowMove,\n} from '../collection/shared/lib/row-reorder'\n\nimport type { CollectionDensity } from '../collection/types/collection'\n\nexport type { CollectionDensity }\n\nexport type DataTableAlign = 'start' | 'center' | 'end'\n\nexport type DataTableCellRow = EditableCellRow\n\nexport type DataTableCellValueChange = EditableCellValueChange\n\nexport type DataTableRowMove = RowMove\n\nexport type DataTableRowDragAnnouncements = RowDragAnnouncements\n\nexport interface DataTableTableMeta {\n dataGridDensity?: CollectionDensity\n onDataGridDensityChange?: (density: CollectionDensity) => void\n onDataTableCellValueChange?: (change: DataTableCellValueChange) => void\n}\n",
|
|
345
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table-types.ts"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"path": "patterns/data-table/data-table.tsx",
|
|
349
|
+
"type": "registry:file",
|
|
350
|
+
"content": "'use client'\n\nimport { flexRender, type Row, type RowData } from '@tanstack/react-table'\nimport { ScrollArea } from '@tc96/ui/scroll-area'\nimport {\n Table,\n TableBody,\n TableCell,\n TableFooter,\n TableHead,\n TableHeader,\n TableRow,\n} from '@tc96/ui/table'\nimport { cn } from '@tc96/utils'\nimport {\n type ComponentProps,\n type ReactElement,\n type ReactNode,\n useRef,\n useState,\n} from 'react'\nimport {\n SelectionActions,\n type SelectionActionsProp,\n} from '../collection/shared/components/selection-actions'\nimport { useCollapsedGroups } from '../collection/shared/hooks/use-collapsed-groups'\nimport { useEndReached } from '../collection/shared/hooks/use-end-reached'\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 {\n aggregate,\n type DataTableAggregation,\n type DataTableAggregationLabels,\n type DataTableAggregations,\n type DataTableColumnMeta,\n defaultAggregationLabels,\n} from './data-table-aggregation'\nimport { DataTableAggregationCell } from './data-table-aggregation-cell'\nimport { columnAlignClass } from './data-table-align'\nimport { DataTableBody } from './data-table-body'\nimport type { DataTableFeatures, DataTableTable } from './data-table-features'\nimport type { DataTableGroupCellContext } from './data-table-group-row'\nimport { DataTableResizeHandle } from './data-table-resize-handle'\nimport {\n type DataTableRowSkeletonAnatomy,\n DataTableSkeletonRows,\n} from './data-table-skeleton-rows'\nimport type {\n CollectionDensity,\n DataTableRowDragAnnouncements,\n DataTableRowMove,\n DataTableTableMeta,\n} from './data-table-types'\nimport { useHorizontalOverflow } from './use-horizontal-overflow'\n\nexport type { DataTableRowSkeletonAnatomy } from './data-table-skeleton-rows'\n\nexport type DataTableSelectionActionsProp<TData extends RowData> =\n SelectionActionsProp<TData>\n\nexport interface DataTableProps<TData extends RowData>\n extends Omit<ComponentProps<'table'>, 'children'> {\n table: DataTableTable<TData>\n loading?: boolean\n loadingAnatomy?: DataTableRowSkeletonAnatomy\n loadingCount?: number\n loadingLabel?: string\n emptyMessage?: string\n /** Moldura do DataGrid, para as duas views lerem como a mesma superfície. */\n bordered?: boolean\n aggregations?: DataTableAggregations\n defaultAggregations?: DataTableAggregations\n onAggregationsChange?: (aggregations: DataTableAggregations) => void\n aggregationLabels?: Partial<DataTableAggregationLabels>\n onRowOpen?: (row: Row<DataTableFeatures, TData>) => void\n getRowOpenLabel?: (row: Row<DataTableFeatures, TData>) => string\n getRowCanOpen?: (row: Row<DataTableFeatures, TData>) => boolean\n density?: CollectionDensity\n selectionActions?: DataTableSelectionActionsProp<TData>\n getRowGroup?: (row: TData) => string | null\n collapsedGroupIds?: readonly string[]\n defaultCollapsedGroupIds?: readonly string[]\n onCollapsedGroupIdsChange?: (groupIds: readonly string[]) => void\n renderGroupCell?: (context: DataTableGroupCellContext<TData>) => ReactNode\n getGroupToggleLabel?: (group: string, collapsed: boolean) => string\n onRowMove?: (move: DataTableRowMove) => void\n rowDragAnnouncements?: DataTableRowDragAnnouncements\n onEndReached?: () => void\n endReachedThreshold?: number\n loadingMore?: boolean\n loadingMoreRowCount?: number\n}\n\nconst NO_GROUPS: readonly string[] = []\nconst FALLBACK_ROW_HEIGHT_PX = 40\n\nconst DENSITY_CLASS: Record<CollectionDensity, string | undefined> = {\n compact: '[&_tbody_td]:py-1.5',\n 'extra-tall': '[&_tbody_td]:py-7',\n medium: '[&_tbody_td]:py-3.5',\n short: undefined,\n tall: '[&_tbody_td]:py-5',\n}\n\nconst columnMetaOf = <TData,>(column: {\n columnDef: { meta?: unknown }\n}): DataTableColumnMeta<TData> =>\n (column.columnDef.meta ?? {}) as DataTableColumnMeta<TData>\n\nexport function DataTable<TData extends RowData>({\n table,\n loading = false,\n loadingAnatomy = {},\n loadingCount = 5,\n loadingLabel = 'Carregando linha',\n emptyMessage = 'Nenhum registro para exibir.',\n bordered = true,\n aggregations: controlledAggregations,\n defaultAggregations = {},\n onAggregationsChange,\n aggregationLabels,\n onRowOpen,\n getRowOpenLabel,\n getRowCanOpen,\n density: densityProp,\n selectionActions,\n getRowGroup,\n collapsedGroupIds: controlledCollapsedGroupIds,\n defaultCollapsedGroupIds = NO_GROUPS,\n onCollapsedGroupIdsChange,\n renderGroupCell,\n getGroupToggleLabel,\n onRowMove,\n rowDragAnnouncements,\n onEndReached,\n endReachedThreshold = DEFAULT_END_REACHED_THRESHOLD,\n loadingMore = false,\n loadingMoreRowCount = 3,\n className,\n style,\n ...props\n}: DataTableProps<TData>): ReactElement {\n const [uncontrolledAggregations, setUncontrolledAggregations] =\n useState<DataTableAggregations>(defaultAggregations)\n const aggregations = controlledAggregations ?? uncontrolledAggregations\n const labels = { ...defaultAggregationLabels, ...aggregationLabels }\n const changeAggregation = (\n columnId: string,\n aggregation: DataTableAggregation | null,\n ) => {\n const next = { ...aggregations, [columnId]: aggregation }\n if (controlledAggregations === undefined) setUncontrolledAggregations(next)\n onAggregationsChange?.(next)\n }\n const rows = table.getRowModel().rows\n const visibleColumns = table.getVisibleLeafColumns()\n const columnCount = visibleColumns.length\n const linesColumnIndex = Math.max(\n visibleColumns.findIndex((column) => column.accessorFn),\n 0,\n )\n const resizable = Boolean(table.options.enableColumnResizing)\n const fillColumnId = visibleColumns.at(-1)?.id\n const meta = table.options.meta\n const aggregatedRows: Row<DataTableFeatures, TData>[] =\n table.getPrePaginatedRowModel().rows\n const showAggregations = !loading && aggregatedRows.length > 0\n const hasFooter = table\n .getAllLeafColumns()\n .some(\n (column) =>\n column.columnDef.footer ||\n (showAggregations && columnMetaOf<TData>(column).aggregations?.length),\n )\n const density =\n densityProp ?? (meta as DataTableTableMeta | undefined)?.dataGridDensity\n const { collapsedGroupIds, setGroupCollapsed } = useCollapsedGroups({\n controlled: controlledCollapsedGroupIds,\n defaultValue: defaultCollapsedGroupIds,\n onChange: onCollapsedGroupIdsChange,\n })\n const onToggleGroup = useLatestCallback(setGroupCollapsed)\n const reorderActive = isRowReorderActive({\n enabled: Boolean(onRowMove),\n grouped: Boolean(getRowGroup),\n loading: loading,\n sorted: table.store.state.sorting.length > 0,\n virtualized: false,\n })\n const loadingMoreCount =\n loadingMore && !loading && rows.length > 0 ? loadingMoreRowCount : 0\n const [scrollContainerRef, overflow] = useHorizontalOverflow<HTMLDivElement>()\n useEndReached({\n enabled: Boolean(onEndReached) && !loading,\n loadingMore: loadingMoreCount > 0,\n measure: (viewport) => ({\n bottomInset:\n viewport\n .querySelector('[data-slot=\"table-footer\"]')\n ?.getBoundingClientRect().height ?? 0,\n rowHeight:\n viewport.querySelector('tbody tr')?.getBoundingClientRect().height ||\n FALLBACK_ROW_HEIGHT_PX,\n }),\n onEndReached,\n rowCount: table.options.data.length,\n scrollRef: scrollContainerRef,\n threshold: endReachedThreshold,\n })\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n useScrollbarInsets(\n scrollAreaRef,\n '[data-slot=\"table-header\"]',\n '[data-slot=\"table-footer\"]',\n hasFooter,\n )\n\n return (\n <div\n className=\"group/data-table relative flex min-h-0 min-w-0 flex-1 flex-col\"\n data-overflow-end={overflow.end || undefined}\n data-overflow-start={overflow.start || undefined}\n data-slot=\"data-table\"\n >\n <ScrollArea\n className={cn(\n 'relative flex size-auto min-h-0 flex-1 flex-col',\n bordered && 'rounded-md border bg-background',\n )}\n clampContentMinWidth={false}\n ref={scrollAreaRef}\n verticalScrollbarProps={{ style: scrollbarInsetStyle }}\n viewportProps={{\n className: 'h-auto min-h-0 flex-1',\n 'data-slot': 'data-table-viewport',\n ref: scrollContainerRef,\n }}\n >\n <Table\n aria-busy={loading || loadingMoreCount > 0 || undefined}\n data-density={density}\n render={\n <div\n className=\"overflow-x-visible!\"\n data-bordered={bordered ? '' : undefined}\n />\n }\n className={cn(\n resizable &&\n 'table-fixed [&_td]:overflow-hidden [&_td]:text-ellipsis [&_th]:overflow-hidden',\n density && DENSITY_CLASS[density],\n className,\n )}\n style={\n resizable ? { minWidth: table.getTotalSize(), ...style } : style\n }\n {...props}\n >\n {resizable ? (\n <colgroup>\n {visibleColumns.map((column) => (\n <col\n key={column.id}\n style={\n column.id === fillColumnId\n ? undefined\n : { width: column.getSize() }\n }\n />\n ))}\n </colgroup>\n ) : null}\n <TableHeader className=\"sticky top-0 z-10 not-in-data-[variant=card]:bg-[color-mix(in_srgb,var(--card),var(--color-black)_2%)] dark:not-in-data-[variant=card]:bg-[color-mix(in_srgb,var(--card),var(--color-white)_2%)]\">\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <TableHead\n className={\n cn(\n resizable && 'relative',\n columnAlignClass(header.column),\n ) || undefined\n }\n key={header.id}\n >\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n {resizable &&\n !header.isPlaceholder &&\n header.subHeaders.length === 0 &&\n header.column.id !== fillColumnId &&\n header.column.getCanResize() ? (\n <DataTableResizeHandle header={header} table={table} />\n ) : null}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n {loading ? (\n <TableBody>\n <DataTableSkeletonRows\n label={loadingLabel}\n anatomy={loadingAnatomy}\n columnCount={columnCount}\n linesColumnIndex={linesColumnIndex}\n rowCount={loadingCount}\n scope=\"loading\"\n />\n </TableBody>\n ) : rows.length ? (\n <DataTableBody\n collapsedGroupIds={collapsedGroupIds}\n getGroupToggleLabel={getGroupToggleLabel}\n getRowCanOpen={getRowCanOpen}\n getRowGroup={getRowGroup}\n getRowOpenLabel={getRowOpenLabel}\n loadingMore={\n loadingMoreCount > 0 ? (\n <DataTableSkeletonRows\n label={loadingLabel}\n anatomy={loadingAnatomy}\n columnCount={columnCount}\n linesColumnIndex={linesColumnIndex}\n loadingMore\n rowCount={loadingMoreCount}\n scope=\"loading-more\"\n />\n ) : null\n }\n meta={meta}\n onRowOpen={onRowOpen}\n onRowMove={onRowMove}\n onToggleGroup={onToggleGroup}\n renderGroupCell={renderGroupCell}\n reorderActive={reorderActive}\n rowDragAnnouncements={rowDragAnnouncements}\n rows={rows}\n table={table}\n visibleColumns={visibleColumns}\n />\n ) : (\n <TableBody>\n <TableRow>\n <TableCell className=\"h-24 text-center\" colSpan={columnCount}>\n {emptyMessage}\n </TableCell>\n </TableRow>\n </TableBody>\n )}\n {hasFooter ? (\n <TableFooter className=\"sticky bottom-0 z-10\">\n {table.getFooterGroups().map((footerGroup) => (\n <TableRow className=\"group/footer\" key={footerGroup.id}>\n {footerGroup.headers.map((header) => {\n const { column } = header\n const meta = columnMetaOf<TData>(column)\n const options = meta.aggregations ?? []\n const selected = aggregations[column.id] ?? null\n const aggregation =\n selected && options.includes(selected) ? selected : null\n const result =\n aggregation === null\n ? 0\n : aggregate(aggregatedRows, aggregation, (row) =>\n meta.getAggregationValue\n ? meta.getAggregationValue(row.original)\n : row.getValue(column.id),\n )\n\n const content =\n header.isPlaceholder ? null : options.length === 0 ? (\n flexRender(column.columnDef.footer, header.getContext())\n ) : showAggregations ? (\n <DataTableAggregationCell\n align={meta.align}\n labels={labels}\n onValueChange={(next) =>\n changeAggregation(column.id, next)\n }\n options={options}\n result={\n aggregation === null\n ? null\n : (meta.formatAggregation?.(\n result,\n aggregation,\n ) ?? String(result))\n }\n value={aggregation}\n />\n ) : null\n\n return <TableCell key={header.id}>{content}</TableCell>\n })}\n </TableRow>\n ))}\n </TableFooter>\n ) : null}\n </Table>\n </ScrollArea>\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-px start-px w-10 rounded-s-md bg-linear-to-r from-background to-transparent opacity-0 transition-opacity group-data-overflow-start/data-table:opacity-100 rtl:bg-linear-to-l\"\n data-slot=\"data-table-overflow-start\"\n />\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-px end-px w-10 rounded-e-md bg-linear-to-l from-background to-transparent opacity-0 transition-opacity group-data-overflow-end/data-table:opacity-100 rtl:bg-linear-to-r\"\n data-slot=\"data-table-overflow-end\"\n />\n <SelectionActions\n selectionActions={selectionActions}\n slot=\"data-table-selection-actions\"\n table={table}\n />\n </div>\n )\n}\n",
|
|
351
|
+
"target": "~/packages/ui/src/patterns/data-table/data-table.tsx"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"path": "patterns/data-table/index.ts",
|
|
355
|
+
"type": "registry:file",
|
|
356
|
+
"content": "export type {\n DataTableProps,\n DataTableRowSkeletonAnatomy,\n DataTableSelectionActionsProp,\n} from './data-table'\nexport { DataTable } from './data-table'\nexport type {\n DataTableAggregation,\n DataTableAggregationLabels,\n DataTableAggregations,\n DataTableColumnMeta,\n} from './data-table-aggregation'\nexport { DataTableCell } from './data-table-cell'\nexport type { DataTableColumnsSubmenuProps } from './data-table-columns-submenu'\nexport { DataTableColumnsSubmenu } from './data-table-columns-submenu'\nexport type { DataTableExpandToggleProps } from './data-table-expand-toggle'\nexport { DataTableExpandToggle } from './data-table-expand-toggle'\nexport type {\n DataTableColumnDef,\n DataTableFeatures,\n DataTableTable,\n} from './data-table-features'\nexport { dataTableFeatures } from './data-table-features'\nexport type { DataTableGroupCellContext } from './data-table-group-row'\nexport type { CreateDataTableRowDragColumnOptions } from './data-table-row-drag-column'\nexport { createDataTableRowDragColumn } from './data-table-row-drag-column'\nexport type { CreateDataTableSelectColumnOptions } from './data-table-select-column'\nexport { createDataTableSelectColumn } from './data-table-select-column'\nexport type {\n DataTableAlign,\n DataTableCellRow,\n DataTableCellValueChange,\n DataTableRowDragAnnouncements,\n DataTableRowMove,\n DataTableTableMeta,\n} from './data-table-types'\nexport type {\n UseDataTableOptions,\n UseDataTableReturn,\n} from './use-data-table'\nexport { useDataTable } from './use-data-table'\n",
|
|
357
|
+
"target": "~/packages/ui/src/patterns/data-table/index.ts"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"path": "patterns/data-table/use-data-table.ts",
|
|
361
|
+
"type": "registry:file",
|
|
362
|
+
"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 { DataTableCell } from './data-table-cell'\nimport {\n type DataTableColumnDef,\n type DataTableFeatures,\n dataTableFeatures,\n} from './data-table-features'\nimport type {\n CollectionDensity,\n DataTableCellValueChange,\n DataTableTableMeta,\n} from './data-table-types'\n\nexport interface UseDataTableOptions<TData extends RowData> {\n /** Row data. */\n data: TData[]\n /** Column definitions. Declare `footer` or `meta.aggregations` on a column to render the table footer. */\n columns: DataTableColumnDef<TData>[]\n /** Stable row identity. Strongly recommended so selection survives reordering. */\n getRowId?: (row: TData, index: number) => string\n enableRowSelection?: boolean\n enableSorting?: boolean\n /** Header edges resize columns; the last visible column takes the remaining width. */\n enableColumnResizing?: boolean\n enableColumnFilters?: boolean\n /** Enables client-side pagination. */\n enablePagination?: boolean\n enableExpanding?: boolean\n getSubRows?: (row: TData, index: number) => TData[] | undefined\n /** Rows per page when pagination is enabled. Defaults to 10. */\n pageSize?: number\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 expanded?: ExpandedState\n onExpandedChange?: (expanded: ExpandedState) => void\n density?: CollectionDensity\n onDensityChange?: (density: CollectionDensity) => void\n onCellValueChange?: (change: DataTableCellValueChange) => void\n /** Escape hatch for any TanStack Table option not surfaced above. */\n tableOptions?: Partial<TableOptions<DataTableFeatures, TData>>\n}\n\nexport interface UseDataTableReturn<TData extends RowData> {\n table: ReactTable<DataTableFeatures, TData>\n}\n\n/**\n * Wraps TanStack Table with the features the DataTable expects. Every table\n * state has a value and `on*Change` pair; without the value the hook keeps it,\n * seeded from `tableOptions.initialState`. Returns the table instance to hand\n * to `<DataTable table={table} />`.\n */\nexport function useDataTable<TData extends RowData>({\n data,\n columns,\n getRowId,\n enableRowSelection = false,\n enableSorting = false,\n enableColumnResizing = false,\n enableColumnFilters,\n enablePagination = false,\n enableExpanding = false,\n getSubRows,\n pageSize = 10,\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 expanded: controlledExpanded,\n onExpandedChange,\n density: densityProp,\n onDensityChange,\n onCellValueChange,\n tableOptions,\n}: UseDataTableOptions<TData>): UseDataTableReturn<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, setExpanded] = useControllableTableState<ExpandedState>(\n controlledExpanded,\n () => initialState?.expanded ?? {},\n onExpandedChange,\n )\n const [density, setDensity] = useControllableTableState<\n CollectionDensity | undefined\n >(\n onDensityChange ? densityProp : undefined,\n () => densityProp,\n (next) => {\n if (next) onDensityChange?.(next)\n },\n )\n\n const editable = Boolean(onCellValueChange)\n const handleCellValueChange = useLatestCallback(\n (change: DataTableCellValueChange) => onCellValueChange?.(change),\n )\n const consumerMeta = tableOptions?.meta\n const tracksDensity = Boolean(densityProp ?? onDensityChange)\n const meta = useMemo(() => {\n if (!(tracksDensity || editable)) return consumerMeta\n const tableMeta: DataTableTableMeta = {\n ...consumerMeta,\n ...(tracksDensity\n ? {\n dataGridDensity: density ?? 'short',\n onDataGridDensityChange: setDensity,\n }\n : {}),\n ...(editable\n ? { onDataTableCellValueChange: handleCellValueChange }\n : {}),\n }\n return tableMeta\n }, [\n consumerMeta,\n density,\n editable,\n handleCellValueChange,\n setDensity,\n tracksDensity,\n ])\n const defaultColumn = useMemo<Partial<DataTableColumnDef<TData>> | undefined>(\n () =>\n editable\n ? {\n cell: (context) => createElement(DataTableCell<TData>, { context }),\n }\n : undefined,\n [editable],\n )\n\n const table = useTable<DataTableFeatures, TData>({\n features: dataTableFeatures,\n data,\n columns,\n ...(defaultColumn ? { defaultColumn } : {}),\n getRowId,\n state: {\n sorting,\n globalFilter,\n columnFilters,\n columnVisibility,\n columnOrder,\n columnPinning,\n columnSizing,\n rowSelection,\n expanded,\n pagination,\n },\n enableRowSelection,\n enableSorting,\n enableColumnResizing,\n ...(enableColumnFilters === undefined ? {} : { enableColumnFilters }),\n enableExpanding,\n ...(enableExpanding\n ? { autoResetExpanded: false, getSubRows, paginateExpandedRows: false }\n : {}),\n columnResizeMode: 'onChange',\n globalFilterFn: 'includesString',\n // Paginação é sempre registrada; desligada, a tabela entrega todas as linhas.\n manualPagination: !enablePagination,\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: setExpanded,\n onPaginationChange: setPagination,\n ...tableOptions,\n ...(meta === undefined ? {} : { meta }),\n })\n\n return { table }\n}\n",
|
|
363
|
+
"target": "~/packages/ui/src/patterns/data-table/use-data-table.ts"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"path": "patterns/data-table/use-horizontal-overflow.ts",
|
|
367
|
+
"type": "registry:file",
|
|
368
|
+
"content": "'use client'\n\nimport { type RefObject, useEffect, useRef, useState } from 'react'\n\nexport interface HorizontalOverflow {\n end: boolean\n start: boolean\n}\n\nexport function useHorizontalOverflow<TElement extends HTMLElement>(): [\n RefObject<TElement | null>,\n HorizontalOverflow,\n] {\n const ref = useRef<TElement>(null)\n const [overflow, setOverflow] = useState<HorizontalOverflow>({\n end: false,\n start: false,\n })\n\n useEffect(() => {\n const element = ref.current\n if (!element) return\n\n const measure = () => {\n const offset = Math.abs(element.scrollLeft)\n const maxOffset = element.scrollWidth - element.clientWidth\n const next = { end: offset < maxOffset - 1, start: offset > 1 }\n setOverflow((current) =>\n current.end === next.end && current.start === next.start\n ? current\n : next,\n )\n }\n\n measure()\n element.addEventListener('scroll', measure, { passive: true })\n const observer =\n typeof ResizeObserver === 'undefined'\n ? undefined\n : new ResizeObserver(measure)\n observer?.observe(element)\n if (element.firstElementChild) observer?.observe(element.firstElementChild)\n\n return () => {\n element.removeEventListener('scroll', measure)\n observer?.disconnect()\n }\n }, [])\n\n return [ref, overflow]\n}\n",
|
|
369
|
+
"target": "~/packages/ui/src/patterns/data-table/use-horizontal-overflow.ts"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"path": "patterns/properties/core.ts",
|
|
373
|
+
"type": "registry:file",
|
|
374
|
+
"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",
|
|
375
|
+
"target": "~/packages/ui/src/patterns/properties/core.ts"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"path": "patterns/properties/display/date-range/date-range-format.ts",
|
|
379
|
+
"type": "registry:file",
|
|
380
|
+
"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",
|
|
381
|
+
"target": "~/packages/ui/src/patterns/properties/display/date-range/date-range-format.ts"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"path": "patterns/properties/display/date/date-property.tsx",
|
|
385
|
+
"type": "registry:file",
|
|
386
|
+
"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",
|
|
387
|
+
"target": "~/packages/ui/src/patterns/properties/display/date/date-property.tsx"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"path": "patterns/properties/display/date/date-value.ts",
|
|
391
|
+
"type": "registry:file",
|
|
392
|
+
"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",
|
|
393
|
+
"target": "~/packages/ui/src/patterns/properties/display/date/date-value.ts"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"path": "patterns/properties/display/person/person-option-content.tsx",
|
|
397
|
+
"type": "registry:file",
|
|
398
|
+
"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",
|
|
399
|
+
"target": "~/packages/ui/src/patterns/properties/display/person/person-option-content.tsx"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"path": "patterns/properties/display/person/person-property.tsx",
|
|
403
|
+
"type": "registry:file",
|
|
404
|
+
"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",
|
|
405
|
+
"target": "~/packages/ui/src/patterns/properties/display/person/person-property.tsx"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"path": "patterns/properties/display/schedule/schedule-value.ts",
|
|
409
|
+
"type": "registry:file",
|
|
410
|
+
"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",
|
|
411
|
+
"target": "~/packages/ui/src/patterns/properties/display/schedule/schedule-value.ts"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"path": "patterns/properties/display/select/select-property.tsx",
|
|
415
|
+
"type": "registry:file",
|
|
416
|
+
"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",
|
|
417
|
+
"target": "~/packages/ui/src/patterns/properties/display/select/select-property.tsx"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"path": "patterns/properties/shared/lib/property-change.ts",
|
|
421
|
+
"type": "registry:file",
|
|
422
|
+
"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",
|
|
423
|
+
"target": "~/packages/ui/src/patterns/properties/shared/lib/property-change.ts"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"path": "patterns/properties/shared/lib/property-options.ts",
|
|
427
|
+
"type": "registry:file",
|
|
428
|
+
"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",
|
|
429
|
+
"target": "~/packages/ui/src/patterns/properties/shared/lib/property-options.ts"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"path": "patterns/properties/shared/property-calendar-popover.tsx",
|
|
433
|
+
"type": "registry:file",
|
|
434
|
+
"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",
|
|
435
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-calendar-popover.tsx"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"path": "patterns/properties/shared/property-catalog.ts",
|
|
439
|
+
"type": "registry:file",
|
|
440
|
+
"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",
|
|
441
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-catalog.ts"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"path": "patterns/properties/shared/property-display-meta.ts",
|
|
445
|
+
"type": "registry:file",
|
|
446
|
+
"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",
|
|
447
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-display-meta.ts"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"path": "patterns/properties/shared/property-labels.ts",
|
|
451
|
+
"type": "registry:file",
|
|
452
|
+
"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",
|
|
453
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-labels.ts"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"path": "patterns/properties/shared/property-select-shell.tsx",
|
|
457
|
+
"type": "registry:file",
|
|
458
|
+
"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",
|
|
459
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-select-shell.tsx"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"path": "patterns/properties/shared/property-surface.tsx",
|
|
463
|
+
"type": "registry:file",
|
|
464
|
+
"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",
|
|
465
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-surface.tsx"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"path": "patterns/properties/shared/property-tooltip.tsx",
|
|
469
|
+
"type": "registry:file",
|
|
470
|
+
"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",
|
|
471
|
+
"target": "~/packages/ui/src/patterns/properties/shared/property-tooltip.tsx"
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
475
|
+
"type": "registry:file",
|
|
476
|
+
"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",
|
|
477
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
481
|
+
"type": "registry:file",
|
|
482
|
+
"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",
|
|
483
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"path": "patterns/toolbar/components/collection-toolbar-heading.tsx",
|
|
487
|
+
"type": "registry:file",
|
|
488
|
+
"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",
|
|
489
|
+
"target": "~/packages/ui/src/patterns/toolbar/components/collection-toolbar-heading.tsx"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"path": "patterns/toolbar/components/collection-toolbar.tsx",
|
|
493
|
+
"type": "registry:file",
|
|
494
|
+
"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",
|
|
495
|
+
"target": "~/packages/ui/src/patterns/toolbar/components/collection-toolbar.tsx"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
"path": "patterns/toolbar/index.ts",
|
|
499
|
+
"type": "registry:file",
|
|
500
|
+
"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",
|
|
501
|
+
"target": "~/packages/ui/src/patterns/toolbar/index.ts"
|
|
502
|
+
}
|
|
503
|
+
],
|
|
504
|
+
"dependencies": [
|
|
505
|
+
"@base-ui/react@1.8.0",
|
|
506
|
+
"@daypicker/react@10.0.2",
|
|
507
|
+
"@dnd-kit/abstract@0.5.0",
|
|
508
|
+
"@dnd-kit/dom@0.5.0",
|
|
509
|
+
"@dnd-kit/react@0.5.0",
|
|
510
|
+
"@phosphor-icons/react@2.1.10",
|
|
511
|
+
"@tanstack/react-table@9.2.4",
|
|
512
|
+
"class-variance-authority@0.7.1",
|
|
513
|
+
"react@19.1.1"
|
|
514
|
+
],
|
|
515
|
+
"registryDependencies": [
|
|
516
|
+
"@ui/avatar",
|
|
517
|
+
"@ui/badge",
|
|
518
|
+
"@ui/button",
|
|
519
|
+
"@ui/calendar",
|
|
520
|
+
"@ui/checkbox",
|
|
521
|
+
"@ui/combobox",
|
|
522
|
+
"@ui/empty",
|
|
523
|
+
"@ui/icon-frame",
|
|
524
|
+
"@ui/input",
|
|
525
|
+
"@ui/menu",
|
|
526
|
+
"@ui/popover",
|
|
527
|
+
"@ui/property-tone",
|
|
528
|
+
"@ui/scroll-area",
|
|
529
|
+
"@ui/select",
|
|
530
|
+
"@ui/skeleton",
|
|
531
|
+
"@ui/switch",
|
|
532
|
+
"@ui/table",
|
|
533
|
+
"@ui/text",
|
|
534
|
+
"@ui/toolbar",
|
|
535
|
+
"@ui/tooltip"
|
|
536
|
+
],
|
|
537
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
538
|
+
}
|