@exxatdesignux/ui 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/consumer-extras/AGENTS.md +76 -0
  3. package/consumer-extras/README.md +5 -1
  4. package/consumer-extras/cursor-skills/exxat-centralized-list-dataset/SKILL.md +14 -3
  5. package/consumer-extras/cursor-skills/exxat-consumer-app/SKILL.md +37 -0
  6. package/consumer-extras/cursor-skills/exxat-ds-skill/SKILL.md +21 -6
  7. package/consumer-extras/cursor-skills/exxat-focused-workflow-page/SKILL.md +57 -0
  8. package/consumer-extras/cursor-skills/exxat-primary-nav-secondary-panel/SKILL.md +4 -2
  9. package/consumer-extras/patterns/consumer-app-pattern.md +39 -0
  10. package/consumer-extras/patterns/consumer-upgrade-checklist.md +20 -0
  11. package/consumer-extras/patterns/data-views-pattern.md +40 -3
  12. package/consumer-extras/patterns/focused-workflow-page-pattern.md +84 -0
  13. package/consumer-extras/patterns/shell-surface-elevation-pattern.md +5 -3
  14. package/package.json +2 -1
  15. package/src/components/ui/button-group.tsx +81 -0
  16. package/src/components/ui/button.tsx +4 -4
  17. package/src/globals.css +7 -1858
  18. package/src/theme.css +10 -1126
  19. package/src/tokens/README.md +15 -0
  20. package/src/tokens/base.css +337 -0
  21. package/src/tokens/high-contrast.css +1195 -0
  22. package/src/tokens/layers.css +224 -0
  23. package/src/tokens/tailwind-bridge.css +118 -0
  24. package/src/tokens/themes.css +201 -0
  25. package/template/AGENTS.md +60 -22
  26. package/template/app/(app)/dashboard/loading.tsx +3 -15
  27. package/template/app/(app)/dashboard/page.tsx +2 -14
  28. package/template/app/(app)/data-list/layout.tsx +43 -0
  29. package/template/app/(app)/data-list/page.tsx +2 -2
  30. package/template/app/(app)/examples/focused-workflow/page.tsx +5 -0
  31. package/template/app/(app)/examples/page.tsx +1 -0
  32. package/template/app/(app)/loading.tsx +1 -18
  33. package/template/app/(app)/question-bank/find/page.tsx +2 -1
  34. package/template/app/(app)/question-bank/library/page.tsx +2 -1
  35. package/template/app/(app)/question-bank/list/page.tsx +2 -1
  36. package/template/app/(app)/question-bank/new/page.tsx +15 -23
  37. package/template/app/(app)/question-bank/page.tsx +2 -1
  38. package/template/app/(app)/settings/page.tsx +4 -5
  39. package/template/app/globals.css +7 -1964
  40. package/template/components/app-route-loading.tsx +14 -0
  41. package/template/components/app-sidebar.tsx +70 -55
  42. package/template/components/data-views/index.ts +37 -9
  43. package/template/components/data-views/list-page-calendar-view.tsx +593 -0
  44. package/template/components/data-views/list-page-connected-view-body.tsx +66 -0
  45. package/template/components/data-views/list-page-folder-columns-panel.tsx +345 -0
  46. package/template/components/data-views/list-page-split-hub-chrome.tsx +8 -0
  47. package/template/components/examples/focused-workflow-showcase.tsx +183 -0
  48. package/template/components/list-hub-board-view.tsx +68 -0
  49. package/template/components/list-hub-client.tsx +186 -0
  50. package/template/components/list-hub-list-view.tsx +36 -0
  51. package/template/components/list-hub-panel-activator.tsx +8 -0
  52. package/template/components/list-hub-secondary-nav.tsx +121 -0
  53. package/template/components/list-hub-table.tsx +336 -0
  54. package/template/components/new-question-composer.tsx +6 -24
  55. package/template/components/product-switcher.tsx +3 -2
  56. package/template/components/question-bank-client.tsx +4 -1
  57. package/template/components/question-bank-folder-columns-panel.tsx +104 -0
  58. package/template/components/question-bank-table.tsx +143 -485
  59. package/template/components/secondary-panel/nav-link-rows.tsx +83 -0
  60. package/template/components/secondary-panel.tsx +4 -44
  61. package/template/components/secondary-panels/list-hub-panel.tsx +39 -0
  62. package/template/components/secondary-panels/question-bank-panel.tsx +39 -0
  63. package/template/components/secondary-panels/registry.tsx +15 -0
  64. package/template/components/settings-appearance-card.tsx +3 -2
  65. package/template/components/settings-client.tsx +59 -15
  66. package/template/components/settings-form-row.tsx +9 -4
  67. package/template/components/table-properties/drawer-button.tsx +13 -0
  68. package/template/components/table-properties/drawer.tsx +65 -4
  69. package/template/components/templates/focused-workflow-layouts.tsx +448 -0
  70. package/template/components/templates/focused-workflow-page-template.tsx +69 -0
  71. package/template/components/templates/list-page.tsx +29 -5
  72. package/template/components/templates/nested-secondary-panel-shell.tsx +2 -1
  73. package/template/components/templates/page-loading-shell.tsx +262 -0
  74. package/template/components/ui/button-group.tsx +1 -0
  75. package/template/docs/consumer-app-pattern.md +39 -0
  76. package/template/docs/data-views-pattern.md +40 -3
  77. package/template/docs/drawer-vs-dialog-pattern.md +3 -1
  78. package/template/docs/focused-workflow-page-pattern.md +84 -0
  79. package/template/docs/shell-surface-elevation-pattern.md +5 -3
  80. package/template/lib/command-menu-search-data.ts +11 -27
  81. package/template/lib/data-list-display-options.ts +16 -2
  82. package/template/lib/data-list-view-registry.ts +104 -0
  83. package/template/lib/data-list-view-surface.ts +15 -1
  84. package/template/lib/data-list-view.ts +10 -1
  85. package/template/lib/data-view-dashboard-storage.ts +38 -35
  86. package/template/lib/hub-connected-view-renderers.ts +58 -0
  87. package/template/lib/list-hub-nav.ts +121 -0
  88. package/template/lib/list-hub-supported-views.ts +10 -0
  89. package/template/lib/list-page-table-properties.ts +3 -7
  90. package/template/lib/list-status-badges.ts +4 -97
  91. package/template/lib/mock/list-hub-directory.ts +27 -0
  92. package/template/lib/mock/list-hub-kpi.ts +27 -0
  93. package/template/lib/mock/navigation.tsx +1 -0
  94. package/template/lib/page-loading-variant.ts +40 -0
  95. package/template/lib/question-bank-supported-views.ts +13 -0
  96. package/template/lib/table-state-lifecycle.ts +2 -2
  97. package/template/app/(app)/data-list/[id]/page.tsx +0 -44
  98. package/template/app/(app)/data-list/new/page.tsx +0 -34
  99. package/template/components/compliance-board-view.tsx +0 -142
  100. package/template/components/compliance-client.tsx +0 -92
  101. package/template/components/compliance-list-view.tsx +0 -54
  102. package/template/components/compliance-page-header.tsx +0 -89
  103. package/template/components/compliance-table.tsx +0 -612
  104. package/template/components/data-view-dashboard-charts-compliance.tsx +0 -963
  105. package/template/components/data-view-dashboard-charts-team.tsx +0 -971
  106. package/template/components/data-view-dashboard-charts.tsx +0 -1503
  107. package/template/components/new-placement-back-btn.tsx +0 -28
  108. package/template/components/new-placement-form.tsx +0 -1068
  109. package/template/components/placement-board-card.tsx +0 -262
  110. package/template/components/placement-detail.tsx +0 -438
  111. package/template/components/placements-board-view.tsx +0 -404
  112. package/template/components/placements-client.tsx +0 -252
  113. package/template/components/placements-list-view.tsx +0 -171
  114. package/template/components/placements-page-header.tsx +0 -166
  115. package/template/components/placements-table-cells.test.tsx +0 -22
  116. package/template/components/placements-table-cells.tsx +0 -173
  117. package/template/components/placements-table-columns.tsx +0 -640
  118. package/template/components/placements-table.tsx +0 -1642
  119. package/template/components/rotations-empty-state.tsx +0 -50
  120. package/template/components/rotations-panel-activator.tsx +0 -8
  121. package/template/components/sites-all-client.tsx +0 -154
  122. package/template/components/sites-board-view.tsx +0 -67
  123. package/template/components/sites-list-view.tsx +0 -42
  124. package/template/components/sites-table.tsx +0 -382
  125. package/template/components/team-board-view.tsx +0 -122
  126. package/template/components/team-client.tsx +0 -100
  127. package/template/components/team-list-view.tsx +0 -59
  128. package/template/components/team-page-header.tsx +0 -92
  129. package/template/components/team-table.tsx +0 -693
  130. package/template/lib/data-view-dashboard-placements-layout.ts +0 -215
  131. package/template/lib/mock/compliance-kpi.ts +0 -61
  132. package/template/lib/mock/compliance.ts +0 -146
  133. package/template/lib/mock/placements-kpi.ts +0 -134
  134. package/template/lib/mock/placements.ts +0 -183
  135. package/template/lib/mock/sites-directory.ts +0 -16
  136. package/template/lib/mock/sites-kpi.ts +0 -25
  137. package/template/lib/mock/team-kpi.ts +0 -60
  138. package/template/lib/mock/team.ts +0 -118
  139. package/template/lib/placement-board-card-layout.ts +0 -79
  140. package/template/lib/placement-lifecycle.ts +0 -5
@@ -1,963 +0,0 @@
1
- "use client"
2
-
3
- /**
4
- * Compliance **Data** view dashboard — filtered compliance rows with the same canvas as Placements/Team.
5
- */
6
-
7
- import * as React from "react"
8
- import {
9
- closestCorners,
10
- DndContext,
11
- type DragEndEvent,
12
- KeyboardSensor,
13
- PointerSensor,
14
- useSensor,
15
- useSensors,
16
- } from "@dnd-kit/core"
17
- import {
18
- arrayMove,
19
- rectSortingStrategy,
20
- SortableContext,
21
- sortableKeyboardCoordinates,
22
- useSortable,
23
- } from "@dnd-kit/sortable"
24
- import { CSS } from "@dnd-kit/utilities"
25
- import { Bar, BarChart, CartesianGrid, Cell, Pie, PieChart, XAxis, YAxis } from "recharts"
26
- import { ChartCard, ChartDataTable, ChartFigure, type ChartLeoInsight } from "@/components/charts-overview"
27
- import { useChartVariant } from "@/contexts/chart-variant-context"
28
- import { KeyMetrics, type MetricInsight, type MetricItem } from "@/components/key-metrics"
29
- import { Button } from "@/components/ui/button"
30
- import {
31
- DropdownMenu,
32
- DropdownMenuContent,
33
- DropdownMenuItem,
34
- DropdownMenuTrigger,
35
- } from "@/components/ui/dropdown-menu"
36
- import { ViewSegmentedControl } from "@/components/ui/view-segmented-control"
37
- import { Tip } from "@/components/ui/tip"
38
- import { DragHandleGripIcon } from "@/components/ui/drag-handle-grip"
39
- import {
40
- ChartContainer,
41
- ChartTooltip,
42
- chartTooltipKeyboardSyncProps,
43
- ChartTooltipContent,
44
- type ChartConfig,
45
- } from "@/components/ui/chart"
46
- import {
47
- KEY_METRICS_KPI_COUNT_DEFAULT,
48
- KEY_METRICS_KPI_COUNT_MAX,
49
- KEY_METRICS_KPI_COUNT_MIN,
50
- mergeDashboardLayoutGeneric,
51
- } from "@/lib/dashboard-layout-merge"
52
- import { cn } from "@/lib/utils"
53
- import type { ComplianceItem } from "@/lib/mock/compliance"
54
- import {
55
- KEY_METRICS_CARD_ID,
56
- applyVisibleReorder,
57
- type ChartType,
58
- type DashboardLayout,
59
- } from "@/lib/data-view-dashboard-placements-layout"
60
- import {
61
- CHART_KBD_ACTIVE_BAR,
62
- CHART_KBD_ACTIVE_PIE_SHAPE,
63
- } from "@/lib/chart-keyboard-selection"
64
- import {
65
- loadDataViewLayout,
66
- saveDataViewLayout,
67
- } from "@/lib/data-view-dashboard-storage"
68
-
69
- const STATUS_CFG: ChartConfig = {
70
- value: { label: "Items", color: "var(--primary)" },
71
- }
72
-
73
- const CAT_CFG: ChartConfig = {
74
- value: { label: "Items", color: "var(--primary)" },
75
- }
76
-
77
- const CHART_MARGIN = { top: 8, right: 8, left: 0, bottom: 0 } as const
78
- const CHART_MARGIN_HORIZONTAL = { top: 8, right: 8, left: 4, bottom: 0 } as const
79
-
80
- interface ComplianceDashboardCardDef {
81
- id: string
82
- title: string
83
- description: string
84
- defaultSpan: 1 | 2
85
- defaultChartType: ChartType
86
- chartTypes: { type: ChartType; label: string; icon: string }[]
87
- }
88
-
89
- export const ALL_COMPLIANCE_DASHBOARD_CARDS: ComplianceDashboardCardDef[] = [
90
- {
91
- id: KEY_METRICS_CARD_ID,
92
- title: "Key metrics",
93
- description: "Summary KPIs for filtered obligations",
94
- defaultSpan: 2,
95
- defaultChartType: "bar",
96
- chartTypes: [],
97
- },
98
- {
99
- id: "compliance-by-status",
100
- title: "Items by status",
101
- description: "Filtered compliance obligations",
102
- defaultSpan: 1,
103
- defaultChartType: "bar",
104
- chartTypes: [
105
- { type: "bar", label: "Bar", icon: "fa-light fa-chart-bar" },
106
- { type: "horizontal-bar", label: "Horizontal Bar", icon: "fa-light fa-chart-bar fa-rotate-90" },
107
- { type: "pie", label: "Donut", icon: "fa-light fa-chart-pie" },
108
- ],
109
- },
110
- {
111
- id: "compliance-by-category",
112
- title: "Items by category",
113
- description: "Top categories in this view",
114
- defaultSpan: 1,
115
- defaultChartType: "horizontal-bar",
116
- chartTypes: [
117
- { type: "horizontal-bar", label: "Horizontal Bar", icon: "fa-light fa-chart-bar fa-rotate-90" },
118
- { type: "bar", label: "Bar", icon: "fa-light fa-chart-bar" },
119
- { type: "pie", label: "Donut", icon: "fa-light fa-chart-pie" },
120
- ],
121
- },
122
- ]
123
-
124
- export const DEFAULT_COMPLIANCE_VISIBLE_CARDS = ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => c.id)
125
- export const DEFAULT_COMPLIANCE_SPANS: Record<string, 1 | 2> = Object.fromEntries(
126
- ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => [c.id, c.defaultSpan]),
127
- )
128
- export const DEFAULT_COMPLIANCE_CHART_TYPES: Record<string, ChartType> = Object.fromEntries(
129
- ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => [c.id, c.defaultChartType]),
130
- )
131
-
132
- const COMPLIANCE_CHART_LEO_INSIGHTS: Partial<Record<string, ChartLeoInsight>> = {
133
- "compliance-by-status": {
134
- headline: "Overdue and at-risk items stand out in this mix",
135
- explanation:
136
- "When overdue or expiring-soon slices are visible, renewal timing may be out of sync with the cohort. Tightening reminders or batch renewals often reduces last-minute spikes.",
137
- },
138
- "compliance-by-category": {
139
- headline: "Workload clusters in a few categories",
140
- explanation:
141
- "Heavy bars in one or two categories usually signal template or training gaps—not random noise. Leo can help outline how to spread load or simplify the noisiest obligation types.",
142
- },
143
- }
144
-
145
- export function loadComplianceDashboardLayout(): DashboardLayout | null {
146
- const v = loadDataViewLayout("compliance")
147
- if (!v) return null
148
- return {
149
- visible: v.visible,
150
- order: v.order,
151
- spans: v.spans,
152
- chartTypes: v.chartTypes as Record<string, ChartType> | undefined,
153
- keyMetricsKpiCount: v.keyMetricsKpiCount,
154
- }
155
- }
156
-
157
- export function mergeComplianceDashboardLayout(saved: DashboardLayout | null): DashboardLayout {
158
- const defaults = {
159
- visible: [...DEFAULT_COMPLIANCE_VISIBLE_CARDS],
160
- order: ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => c.id),
161
- spans: { ...DEFAULT_COMPLIANCE_SPANS },
162
- chartTypes: { ...DEFAULT_COMPLIANCE_CHART_TYPES } as Record<string, string>,
163
- keyMetricsKpiCount: KEY_METRICS_KPI_COUNT_DEFAULT,
164
- }
165
- const ids = ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => c.id)
166
- const m = mergeDashboardLayoutGeneric(saved, defaults, ids)
167
- return {
168
- visible: m.visible,
169
- order: m.order,
170
- spans: m.spans as Record<string, 1 | 2>,
171
- chartTypes: m.chartTypes as Record<string, ChartType>,
172
- keyMetricsKpiCount: m.keyMetricsKpiCount,
173
- }
174
- }
175
-
176
- export function saveComplianceDashboardLayout(layout: DashboardLayout) {
177
- saveDataViewLayout("compliance", {
178
- visible: layout.visible,
179
- order: layout.order,
180
- spans: layout.spans,
181
- chartTypes: layout.chartTypes as Record<string, string> | undefined,
182
- keyMetricsKpiCount: layout.keyMetricsKpiCount,
183
- })
184
- }
185
-
186
- function EmptyChart({ message = "No items in this view." }: { message?: string }) {
187
- return (
188
- <div className="flex h-[200px] items-center justify-center text-sm text-muted-foreground" role="status">
189
- {message}
190
- </div>
191
- )
192
- }
193
-
194
- const PIE_FILLS = [
195
- "var(--color-chart-1)",
196
- "var(--color-chart-2)",
197
- "var(--color-chart-3)",
198
- "var(--color-chart-4)",
199
- "var(--color-chart-5)",
200
- ]
201
-
202
- function ComplianceByStatusChart({ rows, chartType }: { rows: ComplianceItem[]; chartType: ChartType }) {
203
- const byStatus = React.useMemo(() => {
204
- const c = { compliant: 0, due_soon: 0, overdue: 0, pending: 0 }
205
- for (const r of rows) c[r.status]++
206
- return [
207
- { name: "Compliant", value: c.compliant },
208
- { name: "Due soon", value: c.due_soon },
209
- { name: "Overdue", value: c.overdue },
210
- { name: "Pending", value: c.pending },
211
- ]
212
- }, [rows])
213
-
214
- if (rows.length === 0) return <EmptyChart />
215
-
216
- const statusSummary = `Compliance status: ${byStatus.map(d => `${d.name} ${d.value}`).join(", ")}. Total ${rows.length} items.`
217
-
218
- if (chartType === "pie") {
219
- return (
220
- <ChartFigure label="Items by status" summary={statusSummary} dataLength={byStatus.length}>
221
- {(activeIndex) => (
222
- <>
223
- <ChartContainer config={STATUS_CFG} className="mx-auto aspect-square max-h-[220px] w-full">
224
- <PieChart>
225
- <ChartTooltip key={chartTooltipKeyboardSyncProps(activeIndex).key} {...chartTooltipKeyboardSyncProps(activeIndex).props} content={<ChartTooltipContent />} />
226
- <Pie
227
- data={byStatus}
228
- dataKey="value"
229
- nameKey="name"
230
- innerRadius={48}
231
- outerRadius={80}
232
- strokeWidth={2}
233
- stroke="var(--card)"
234
- activeIndex={activeIndex ?? undefined}
235
- activeShape={CHART_KBD_ACTIVE_PIE_SHAPE}
236
- >
237
- {byStatus.map((_, i) => (
238
- <Cell key={i} fill={PIE_FILLS[i % PIE_FILLS.length]} />
239
- ))}
240
- </Pie>
241
- </PieChart>
242
- </ChartContainer>
243
- <ChartDataTable
244
- caption="Items by status"
245
- headers={["Status", "Count"]}
246
- rows={byStatus.map(d => [d.name, d.value])}
247
- />
248
- </>
249
- )}
250
- </ChartFigure>
251
- )
252
- }
253
-
254
- if (chartType === "horizontal-bar") {
255
- return (
256
- <ChartFigure label="Items by status" summary={statusSummary} dataLength={byStatus.length}>
257
- {(activeIndex) => (
258
- <>
259
- <ChartContainer config={STATUS_CFG} className="h-[220px] w-full">
260
- <BarChart data={byStatus} layout="vertical" margin={CHART_MARGIN}>
261
- <CartesianGrid horizontal={false} strokeDasharray="3 3" className="stroke-border" />
262
- <XAxis type="number" allowDecimals={false} tick={{ fontSize: 11 }} tickLine={false} axisLine={false} />
263
- <YAxis type="category" dataKey="name" width={88} tick={{ fontSize: 11 }} tickLine={false} axisLine={false} />
264
- <ChartTooltip key={chartTooltipKeyboardSyncProps(activeIndex).key} {...chartTooltipKeyboardSyncProps(activeIndex).props} content={<ChartTooltipContent />} />
265
- <Bar
266
- dataKey="value"
267
- fill="var(--color-chart-2)"
268
- radius={[0, 4, 4, 0]}
269
- maxBarSize={22}
270
- activeBar={CHART_KBD_ACTIVE_BAR}
271
- activeIndex={activeIndex ?? undefined}
272
- >
273
- {byStatus.map((_, i) => (
274
- <Cell key={i} fill="var(--color-chart-2)" />
275
- ))}
276
- </Bar>
277
- </BarChart>
278
- </ChartContainer>
279
- <ChartDataTable
280
- caption="Items by status"
281
- headers={["Status", "Count"]}
282
- rows={byStatus.map(d => [d.name, d.value])}
283
- />
284
- </>
285
- )}
286
- </ChartFigure>
287
- )
288
- }
289
-
290
- return (
291
- <ChartFigure label="Items by status" summary={statusSummary} dataLength={byStatus.length}>
292
- {(activeIndex) => (
293
- <>
294
- <ChartContainer config={STATUS_CFG} className="h-[220px] w-full">
295
- <BarChart data={byStatus} margin={CHART_MARGIN}>
296
- <CartesianGrid vertical={false} strokeDasharray="3 3" className="stroke-border" />
297
- <XAxis dataKey="name" tick={{ fontSize: 11 }} tickLine={false} axisLine={false} />
298
- <YAxis allowDecimals={false} width={32} tick={{ fontSize: 12 }} tickLine={false} axisLine={false} />
299
- <ChartTooltip key={chartTooltipKeyboardSyncProps(activeIndex).key} {...chartTooltipKeyboardSyncProps(activeIndex).props} content={<ChartTooltipContent />} />
300
- <Bar
301
- dataKey="value"
302
- fill="var(--color-chart-2)"
303
- radius={[4, 4, 0, 0]}
304
- maxBarSize={40}
305
- activeBar={CHART_KBD_ACTIVE_BAR}
306
- activeIndex={activeIndex ?? undefined}
307
- >
308
- {byStatus.map((_, i) => (
309
- <Cell key={i} fill="var(--color-chart-2)" />
310
- ))}
311
- </Bar>
312
- </BarChart>
313
- </ChartContainer>
314
- <ChartDataTable
315
- caption="Items by status"
316
- headers={["Status", "Count"]}
317
- rows={byStatus.map(d => [d.name, d.value])}
318
- />
319
- </>
320
- )}
321
- </ChartFigure>
322
- )
323
- }
324
-
325
- function ComplianceByCategoryChart({ rows, chartType }: { rows: ComplianceItem[]; chartType: ChartType }) {
326
- const byCategory = React.useMemo(() => {
327
- const map = new Map<string, number>()
328
- for (const r of rows) map.set(r.category, (map.get(r.category) ?? 0) + 1)
329
- return [...map.entries()]
330
- .map(([name, value]) => ({ name: name.length > 24 ? `${name.slice(0, 22)}…` : name, value }))
331
- .sort((a, b) => b.value - a.value)
332
- }, [rows])
333
-
334
- if (rows.length === 0) return <EmptyChart />
335
-
336
- const categorySummary = `${byCategory.length} categories. Total ${rows.length} items.`
337
-
338
- if (chartType === "pie") {
339
- return (
340
- <ChartFigure label="Items by category" summary={categorySummary} dataLength={byCategory.length}>
341
- {(activeIndex) => (
342
- <>
343
- <ChartContainer config={CAT_CFG} className="mx-auto aspect-square max-h-[220px] w-full">
344
- <PieChart>
345
- <ChartTooltip key={chartTooltipKeyboardSyncProps(activeIndex).key} {...chartTooltipKeyboardSyncProps(activeIndex).props} content={<ChartTooltipContent />} />
346
- <Pie
347
- data={byCategory}
348
- dataKey="value"
349
- nameKey="name"
350
- innerRadius={48}
351
- outerRadius={80}
352
- strokeWidth={2}
353
- stroke="var(--card)"
354
- activeIndex={activeIndex ?? undefined}
355
- activeShape={CHART_KBD_ACTIVE_PIE_SHAPE}
356
- >
357
- {byCategory.map((_, i) => (
358
- <Cell key={i} fill={PIE_FILLS[i % PIE_FILLS.length]} />
359
- ))}
360
- </Pie>
361
- </PieChart>
362
- </ChartContainer>
363
- <ChartDataTable
364
- caption="Items by category"
365
- headers={["Category", "Count"]}
366
- rows={byCategory.map(d => [d.name, d.value])}
367
- />
368
- </>
369
- )}
370
- </ChartFigure>
371
- )
372
- }
373
-
374
- if (chartType === "bar") {
375
- return (
376
- <ChartFigure label="Items by category" summary={categorySummary} dataLength={byCategory.length}>
377
- {(activeIndex) => (
378
- <>
379
- <ChartContainer config={CAT_CFG} className="h-[220px] w-full">
380
- <BarChart data={byCategory} margin={CHART_MARGIN}>
381
- <CartesianGrid vertical={false} strokeDasharray="3 3" className="stroke-border" />
382
- <XAxis dataKey="name" tick={{ fontSize: 11 }} tickLine={false} axisLine={false} />
383
- <YAxis allowDecimals={false} width={32} tick={{ fontSize: 12 }} tickLine={false} axisLine={false} />
384
- <ChartTooltip key={chartTooltipKeyboardSyncProps(activeIndex).key} {...chartTooltipKeyboardSyncProps(activeIndex).props} content={<ChartTooltipContent />} />
385
- <Bar
386
- dataKey="value"
387
- fill="var(--color-chart-4)"
388
- radius={[4, 4, 0, 0]}
389
- maxBarSize={40}
390
- activeBar={CHART_KBD_ACTIVE_BAR}
391
- activeIndex={activeIndex ?? undefined}
392
- >
393
- {byCategory.map((_, i) => (
394
- <Cell key={i} fill="var(--color-chart-4)" />
395
- ))}
396
- </Bar>
397
- </BarChart>
398
- </ChartContainer>
399
- <ChartDataTable
400
- caption="Items by category"
401
- headers={["Category", "Count"]}
402
- rows={byCategory.map(d => [d.name, d.value])}
403
- />
404
- </>
405
- )}
406
- </ChartFigure>
407
- )
408
- }
409
-
410
- return (
411
- <ChartFigure label="Items by category" summary={categorySummary} dataLength={byCategory.length}>
412
- {(activeIndex) => (
413
- <>
414
- <ChartContainer config={CAT_CFG} className="h-[220px] w-full">
415
- <BarChart data={byCategory} layout="vertical" margin={CHART_MARGIN_HORIZONTAL}>
416
- <CartesianGrid horizontal={false} strokeDasharray="3 3" className="stroke-border" />
417
- <XAxis type="number" allowDecimals={false} tick={{ fontSize: 12 }} tickLine={false} axisLine={false} />
418
- <YAxis type="category" dataKey="name" width={100} tick={{ fontSize: 11 }} tickLine={false} axisLine={false} />
419
- <ChartTooltip key={chartTooltipKeyboardSyncProps(activeIndex).key} {...chartTooltipKeyboardSyncProps(activeIndex).props} content={<ChartTooltipContent />} />
420
- <Bar
421
- dataKey="value"
422
- fill="var(--color-chart-4)"
423
- radius={[0, 4, 4, 0]}
424
- maxBarSize={22}
425
- activeBar={CHART_KBD_ACTIVE_BAR}
426
- activeIndex={activeIndex ?? undefined}
427
- >
428
- {byCategory.map((_, i) => (
429
- <Cell key={i} fill="var(--color-chart-4)" />
430
- ))}
431
- </Bar>
432
- </BarChart>
433
- </ChartContainer>
434
- <ChartDataTable
435
- caption="Items by category"
436
- headers={["Category", "Count"]}
437
- rows={byCategory.map(d => [d.name, d.value])}
438
- />
439
- </>
440
- )}
441
- </ChartFigure>
442
- )
443
- }
444
-
445
- const COMPLIANCE_CHART_RENDERERS: Record<string, React.FC<{ rows: ComplianceItem[]; chartType: ChartType }>> = {
446
- "compliance-by-status": ComplianceByStatusChart,
447
- "compliance-by-category": ComplianceByCategoryChart,
448
- }
449
-
450
- function SortableComplianceDashboardCard({
451
- card,
452
- rows,
453
- span,
454
- chartType,
455
- cardIndex,
456
- totalCards,
457
- onSpanChange,
458
- onChartTypeChange,
459
- onRemove,
460
- onMoveStep,
461
- keyMetrics,
462
- keyMetricsKpiCount,
463
- onKeyMetricsKpiCountChange,
464
- }: {
465
- card: ComplianceDashboardCardDef
466
- rows: ComplianceItem[]
467
- span: 1 | 2
468
- chartType: ChartType
469
- cardIndex: number
470
- totalCards: number
471
- onSpanChange: (id: string, span: 1 | 2) => void
472
- onChartTypeChange: (id: string, t: ChartType) => void
473
- onRemove: (id: string) => void
474
- onMoveStep: (direction: -1 | 1) => void
475
- keyMetrics?: { metrics: MetricItem[]; insight: MetricInsight } | null
476
- keyMetricsKpiCount: number
477
- onKeyMetricsKpiCountChange?: (n: number) => void
478
- }) {
479
- const {
480
- attributes,
481
- listeners,
482
- setNodeRef,
483
- setActivatorNodeRef,
484
- transform,
485
- transition,
486
- isDragging,
487
- } = useSortable({ id: card.id })
488
- const { chartVariant } = useChartVariant()
489
-
490
- const style: React.CSSProperties = {
491
- ...(transform ? { transform: CSS.Transform.toString(transform) } : {}),
492
- transition,
493
- }
494
-
495
- const isKeyMetrics = card.id === KEY_METRICS_CARD_ID
496
- const Renderer = isKeyMetrics ? null : COMPLIANCE_CHART_RENDERERS[card.id]
497
- if (!isKeyMetrics && !Renderer) return null
498
- if (isKeyMetrics && !keyMetrics) return null
499
-
500
- const canMoveEarlier = cardIndex > 0
501
- const canMoveLater = cardIndex < totalCards - 1
502
- const chartLeoInsight = COMPLIANCE_CHART_LEO_INSIGHTS[card.id]
503
-
504
- return (
505
- <div
506
- ref={setNodeRef}
507
- style={style}
508
- className={cn(
509
- "group flex min-h-0 w-full min-w-0 flex-col self-start rounded-xl border-2 border-dashed border-border bg-transparent p-2",
510
- span === 2 ? "lg:col-span-2" : undefined,
511
- isDragging && "z-20 opacity-95 ring-2 ring-ring",
512
- )}
513
- >
514
- <div className="mb-2 flex w-full min-w-0 flex-wrap items-center gap-2" role="toolbar" aria-label={`${card.title} layout controls`}>
515
- <div className="flex min-w-0 flex-1 flex-wrap items-center gap-2">
516
- <Tip label="Drag to reorder" side="top">
517
- <button
518
- type="button"
519
- ref={setActivatorNodeRef}
520
- className="inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
521
- aria-label={`Drag to reorder ${card.title}`}
522
- {...attributes}
523
- {...listeners}
524
- >
525
- <DragHandleGripIcon className="text-[15px]" />
526
- </button>
527
- </Tip>
528
- {card.chartTypes.length > 0 ? (
529
- <ViewSegmentedControl
530
- aria-label={`Chart type for ${card.title}`}
531
- iconOnly
532
- value={chartType}
533
- onValueChange={v => onChartTypeChange(card.id, v as ChartType)}
534
- options={card.chartTypes.map(opt => ({
535
- value: opt.type,
536
- label: opt.label,
537
- icon: opt.icon,
538
- }))}
539
- />
540
- ) : null}
541
- {isKeyMetrics && onKeyMetricsKpiCountChange ? (
542
- <ViewSegmentedControl
543
- aria-label="Number of KPIs to show"
544
- iconOnly={false}
545
- value={String(keyMetricsKpiCount)}
546
- onValueChange={v => onKeyMetricsKpiCountChange(Number(v))}
547
- options={Array.from(
548
- { length: KEY_METRICS_KPI_COUNT_MAX - KEY_METRICS_KPI_COUNT_MIN + 1 },
549
- (_, i) => {
550
- const n = KEY_METRICS_KPI_COUNT_MIN + i
551
- return { value: String(n), label: String(n) }
552
- },
553
- )}
554
- />
555
- ) : null}
556
- <ViewSegmentedControl
557
- aria-label={`Width for ${card.title}`}
558
- iconOnly
559
- value={String(span) as "1" | "2"}
560
- onValueChange={v => onSpanChange(card.id, Number(v) as 1 | 2)}
561
- options={[
562
- { value: "1", label: "Half width", icon: "fa-light fa-table-columns" },
563
- { value: "2", label: "Full width (all columns)", icon: "fa-light fa-maximize" },
564
- ]}
565
- />
566
- </div>
567
- <div className="ml-auto flex shrink-0 items-center gap-1">
568
- <div
569
- className="pointer-events-none flex items-center gap-0.5 opacity-0 transition-opacity duration-150 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"
570
- role="group"
571
- aria-label={`Reorder ${card.title}`}
572
- >
573
- <div className="flex items-center gap-0.5 lg:hidden">
574
- <Tip label="Move up" side="top">
575
- <Button
576
- type="button"
577
- variant="ghost"
578
- size="icon-sm"
579
- className="size-7 shrink-0"
580
- disabled={!canMoveEarlier}
581
- aria-label={`Move ${card.title} up`}
582
- onClick={() => onMoveStep(-1)}
583
- >
584
- <i className="fa-light fa-chevron-up text-xs" aria-hidden="true" />
585
- </Button>
586
- </Tip>
587
- <Tip label="Move down" side="top">
588
- <Button
589
- type="button"
590
- variant="ghost"
591
- size="icon-sm"
592
- className="size-7 shrink-0"
593
- disabled={!canMoveLater}
594
- aria-label={`Move ${card.title} down`}
595
- onClick={() => onMoveStep(1)}
596
- >
597
- <i className="fa-light fa-chevron-down text-xs" aria-hidden="true" />
598
- </Button>
599
- </Tip>
600
- </div>
601
- <div className="hidden items-center gap-0.5 lg:flex">
602
- <Tip label="Move left" side="top">
603
- <Button
604
- type="button"
605
- variant="ghost"
606
- size="icon-sm"
607
- className="size-7 shrink-0"
608
- disabled={!canMoveEarlier}
609
- aria-label={`Move ${card.title} left`}
610
- onClick={() => onMoveStep(-1)}
611
- >
612
- <i className="fa-light fa-chevron-left text-xs" aria-hidden="true" />
613
- </Button>
614
- </Tip>
615
- <Tip label="Move right" side="top">
616
- <Button
617
- type="button"
618
- variant="ghost"
619
- size="icon-sm"
620
- className="size-7 shrink-0"
621
- disabled={!canMoveLater}
622
- aria-label={`Move ${card.title} right`}
623
- onClick={() => onMoveStep(1)}
624
- >
625
- <i className="fa-light fa-chevron-right text-xs" aria-hidden="true" />
626
- </Button>
627
- </Tip>
628
- </div>
629
- </div>
630
- <Tip label={`Remove ${card.title}`} side="top">
631
- <Button
632
- type="button"
633
- variant="ghost"
634
- size="icon-sm"
635
- className="size-8 shrink-0 text-muted-foreground hover:text-destructive"
636
- aria-label={`Remove ${card.title} from dashboard`}
637
- onClick={() => onRemove(card.id)}
638
- >
639
- <i className="fa-light fa-trash text-[13px]" aria-hidden="true" />
640
- </Button>
641
- </Tip>
642
- </div>
643
- </div>
644
- {isKeyMetrics && keyMetrics ? (
645
- <KeyMetrics
646
- variant="card"
647
- title={card.title}
648
- description={card.description}
649
- metrics={keyMetrics.metrics.slice(0, keyMetricsKpiCount)}
650
- insight={keyMetrics.insight}
651
- metricsSingleRow
652
- metricsHalfWidthLayout={span === 1}
653
- className="w-full min-w-0"
654
- />
655
- ) : (
656
- <ChartCard
657
- variant={chartVariant}
658
- title={card.title}
659
- description={card.description}
660
- className="!h-auto min-h-0 shrink-0"
661
- leoInsight={chartLeoInsight}
662
- >
663
- {Renderer ? <Renderer rows={rows} chartType={chartType} /> : null}
664
- </ChartCard>
665
- )}
666
- </div>
667
- )
668
- }
669
-
670
- export interface ComplianceDashboardChartsSectionProps {
671
- rows: ComplianceItem[]
672
- keyMetrics: { metrics: MetricItem[]; insight: MetricInsight }
673
- visibleCards: string[]
674
- cardOrder: string[]
675
- cardSpans?: Record<string, 1 | 2>
676
- cardChartTypes?: Record<string, ChartType>
677
- keyMetricsKpiCount?: number
678
- layoutEditMode?: boolean
679
- onVisibleChange?: (visible: string[]) => void
680
- onOrderChange?: (order: string[]) => void
681
- onSpanChange?: (id: string, span: 1 | 2) => void
682
- onChartTypeChange?: (id: string, chartType: ChartType) => void
683
- onKeyMetricsKpiCountChange?: (count: number) => void
684
- onResetLayout?: () => void
685
- onLayoutEditDone?: () => void
686
- onLayoutEditCancel?: () => void
687
- }
688
-
689
- export function ComplianceDashboardChartsSection({
690
- rows,
691
- keyMetrics,
692
- visibleCards,
693
- cardOrder,
694
- cardSpans = DEFAULT_COMPLIANCE_SPANS,
695
- cardChartTypes = DEFAULT_COMPLIANCE_CHART_TYPES,
696
- keyMetricsKpiCount = KEY_METRICS_KPI_COUNT_DEFAULT,
697
- layoutEditMode = false,
698
- onVisibleChange,
699
- onOrderChange,
700
- onSpanChange,
701
- onChartTypeChange,
702
- onKeyMetricsKpiCountChange,
703
- onResetLayout,
704
- onLayoutEditDone,
705
- onLayoutEditCancel,
706
- }: ComplianceDashboardChartsSectionProps) {
707
- const { chartVariant } = useChartVariant()
708
- const defs = React.useMemo(() => new Map(ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => [c.id, c])), [])
709
-
710
- const orderedCards = React.useMemo(() => {
711
- return cardOrder
712
- .filter(id => visibleCards.includes(id) && defs.has(id))
713
- .map(id => defs.get(id)!)
714
- }, [visibleCards, cardOrder, defs])
715
-
716
- const hiddenCardDefs = React.useMemo(
717
- () => ALL_COMPLIANCE_DASHBOARD_CARDS.filter(c => !visibleCards.includes(c.id)),
718
- [visibleCards],
719
- )
720
-
721
- const sortableIds = React.useMemo(() => orderedCards.map(c => c.id), [orderedCards])
722
-
723
- const sensors = useSensors(
724
- useSensor(PointerSensor, { activationConstraint: { distance: 8 } }),
725
- useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
726
- )
727
-
728
- const handleDragEnd = React.useCallback(
729
- (event: DragEndEvent) => {
730
- if (!onOrderChange) return
731
- const { active, over } = event
732
- if (!over || active.id === over.id) return
733
- const oldIndex = sortableIds.indexOf(String(active.id))
734
- const newIndex = sortableIds.indexOf(String(over.id))
735
- if (oldIndex < 0 || newIndex < 0) return
736
- const nextVisibleOrder = arrayMove(sortableIds, oldIndex, newIndex)
737
- const visibleSet = new Set(visibleCards)
738
- onOrderChange(applyVisibleReorder(cardOrder, visibleSet, nextVisibleOrder))
739
- },
740
- [cardOrder, onOrderChange, sortableIds, visibleCards],
741
- )
742
-
743
- const moveStep = React.useCallback(
744
- (id: string, direction: -1 | 1) => {
745
- if (!onOrderChange) return
746
- const idx = sortableIds.indexOf(id)
747
- if (idx < 0) return
748
- const newIdx = idx + direction
749
- if (newIdx < 0 || newIdx >= sortableIds.length) return
750
- const nextVisibleOrder = arrayMove(sortableIds, idx, newIdx)
751
- const visibleSet = new Set(visibleCards)
752
- onOrderChange(applyVisibleReorder(cardOrder, visibleSet, nextVisibleOrder))
753
- },
754
- [cardOrder, onOrderChange, sortableIds, visibleCards],
755
- )
756
-
757
- const addCard = React.useCallback(
758
- (id: string) => {
759
- if (!onVisibleChange) return
760
- if (visibleCards.includes(id)) return
761
- onVisibleChange([...visibleCards, id])
762
- },
763
- [onVisibleChange, visibleCards],
764
- )
765
-
766
- const removeCard = React.useCallback(
767
- (id: string) => {
768
- if (!onVisibleChange) return
769
- onVisibleChange(visibleCards.filter(v => v !== id))
770
- },
771
- [onVisibleChange, visibleCards],
772
- )
773
-
774
- if (orderedCards.length === 0) {
775
- return (
776
- <div className="flex flex-col items-center justify-center gap-3 px-4 py-12 text-center lg:px-6">
777
- <i className="fa-light fa-chart-column text-2xl text-muted-foreground/40" aria-hidden="true" />
778
- <p className="text-sm text-muted-foreground">
779
- No widgets on the dashboard.
780
- {layoutEditMode && hiddenCardDefs.length > 0 ? " Add a widget below." : " Turn on Edit layout and add widgets back."}
781
- </p>
782
- {layoutEditMode && hiddenCardDefs.length > 0 && onVisibleChange ? (
783
- <DropdownMenu>
784
- <DropdownMenuTrigger asChild>
785
- <Button type="button" variant="outline" size="sm" className="size-9 p-0" aria-label="Add widget">
786
- <i className="fa-light fa-plus text-sm" aria-hidden="true" />
787
- </Button>
788
- </DropdownMenuTrigger>
789
- <DropdownMenuContent align="center">
790
- {hiddenCardDefs.map(c => (
791
- <DropdownMenuItem key={c.id} onSelect={() => addCard(c.id)}>
792
- {c.title}
793
- </DropdownMenuItem>
794
- ))}
795
- </DropdownMenuContent>
796
- </DropdownMenu>
797
- ) : null}
798
- </div>
799
- )
800
- }
801
-
802
- const grid = (
803
- <div
804
- className={cn(
805
- "grid grid-cols-1 gap-4 lg:grid-cols-2",
806
- layoutEditMode && "lg:items-start lg:content-start lg:auto-rows-min",
807
- )}
808
- >
809
- {orderedCards.map((card, cardIndex) => {
810
- const isKeyMetricsCard = card.id === KEY_METRICS_CARD_ID
811
- const Renderer = isKeyMetricsCard ? null : COMPLIANCE_CHART_RENDERERS[card.id]
812
- if (!isKeyMetricsCard && !Renderer) return null
813
- const span = cardSpans[card.id] ?? card.defaultSpan
814
- const requestedType = cardChartTypes[card.id] ?? card.defaultChartType
815
- const allowedTypes = card.chartTypes.map(o => o.type)
816
- const chartType =
817
- allowedTypes.length === 0
818
- ? card.defaultChartType
819
- : allowedTypes.includes(requestedType)
820
- ? requestedType
821
- : card.defaultChartType
822
-
823
- if (
824
- layoutEditMode &&
825
- onOrderChange &&
826
- onSpanChange &&
827
- onChartTypeChange &&
828
- onVisibleChange
829
- ) {
830
- return (
831
- <SortableComplianceDashboardCard
832
- key={card.id}
833
- card={card}
834
- rows={rows}
835
- span={span}
836
- chartType={chartType}
837
- cardIndex={cardIndex}
838
- totalCards={orderedCards.length}
839
- onSpanChange={onSpanChange}
840
- onChartTypeChange={onChartTypeChange}
841
- onRemove={removeCard}
842
- onMoveStep={dir => moveStep(card.id, dir)}
843
- keyMetrics={isKeyMetricsCard ? keyMetrics : null}
844
- keyMetricsKpiCount={keyMetricsKpiCount}
845
- onKeyMetricsKpiCountChange={
846
- isKeyMetricsCard ? onKeyMetricsKpiCountChange : undefined
847
- }
848
- />
849
- )
850
- }
851
-
852
- return (
853
- <div
854
- key={card.id}
855
- className={cn(span === 2 ? "lg:col-span-2" : undefined)}
856
- >
857
- {isKeyMetricsCard ? (
858
- <KeyMetrics
859
- variant="card"
860
- title={card.title}
861
- description={card.description}
862
- metrics={keyMetrics.metrics.slice(0, keyMetricsKpiCount)}
863
- insight={keyMetrics.insight}
864
- metricsSingleRow
865
- metricsHalfWidthLayout={span === 1}
866
- className="w-full min-w-0"
867
- />
868
- ) : (
869
- <ChartCard
870
- variant={chartVariant}
871
- title={card.title}
872
- description={card.description}
873
- leoInsight={COMPLIANCE_CHART_LEO_INSIGHTS[card.id]}
874
- >
875
- {Renderer ? <Renderer rows={rows} chartType={chartType} /> : null}
876
- </ChartCard>
877
- )}
878
- </div>
879
- )
880
- })}
881
- </div>
882
- )
883
-
884
- const editToolbar =
885
- layoutEditMode && onVisibleChange && onResetLayout ? (
886
- <div
887
- className="mb-3 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border bg-transparent px-3 py-2"
888
- role="region"
889
- aria-label="Dashboard layout options"
890
- >
891
- <p className="text-xs text-muted-foreground">Drag cards to reorder. Changes save automatically.</p>
892
- <div className="flex flex-wrap items-center justify-end gap-2">
893
- <Button
894
- type="button"
895
- size="sm"
896
- variant="ghost"
897
- className="h-8 text-xs"
898
- onClick={() => onVisibleChange(ALL_COMPLIANCE_DASHBOARD_CARDS.map(c => c.id))}
899
- >
900
- Show all
901
- </Button>
902
- <Button type="button" size="sm" variant="ghost" className="h-8 text-xs" onClick={() => onVisibleChange([])}>
903
- Hide all
904
- </Button>
905
- <Tip side="bottom" label="Reset visibility, order, widths, and chart types">
906
- <Button type="button" size="sm" variant="ghost" className="h-8 px-2 text-xs" onClick={onResetLayout}>
907
- <i className="fa-light fa-rotate-left mr-1 text-xs" aria-hidden="true" />
908
- Reset
909
- </Button>
910
- </Tip>
911
- {hiddenCardDefs.length > 0 ? (
912
- <DropdownMenu>
913
- <DropdownMenuTrigger asChild>
914
- <Button type="button" variant="outline" size="sm" className="size-8 p-0" aria-label="Add widget">
915
- <i className="fa-light fa-plus text-[13px]" aria-hidden="true" />
916
- </Button>
917
- </DropdownMenuTrigger>
918
- <DropdownMenuContent align="end">
919
- {hiddenCardDefs.map(c => (
920
- <DropdownMenuItem key={c.id} onSelect={() => addCard(c.id)}>
921
- {c.title}
922
- </DropdownMenuItem>
923
- ))}
924
- </DropdownMenuContent>
925
- </DropdownMenu>
926
- ) : null}
927
- {onLayoutEditCancel ? (
928
- <Button type="button" size="sm" variant="outline" className="h-8 text-xs" onClick={onLayoutEditCancel}>
929
- Cancel
930
- </Button>
931
- ) : null}
932
- {onLayoutEditDone ? (
933
- <Button type="button" size="sm" className="h-8 text-xs" onClick={onLayoutEditDone}>
934
- Done
935
- </Button>
936
- ) : null}
937
- </div>
938
- </div>
939
- ) : null
940
-
941
- const gridBody =
942
- layoutEditMode && onOrderChange ? (
943
- <DndContext sensors={sensors} collisionDetection={closestCorners} onDragEnd={handleDragEnd}>
944
- <SortableContext items={sortableIds} strategy={rectSortingStrategy}>
945
- {grid}
946
- </SortableContext>
947
- </DndContext>
948
- ) : (
949
- grid
950
- )
951
-
952
- return (
953
- <div
954
- className={cn(
955
- "flex flex-col gap-4 px-4 pb-2 lg:px-6",
956
- layoutEditMode && "rounded-xl border border-dashed border-border/80 bg-transparent py-3",
957
- )}
958
- >
959
- {editToolbar}
960
- {gridBody}
961
- </div>
962
- )
963
- }