@postxl/generators 1.1.1 → 1.2.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/dist/frontend-core/frontend.generator.d.ts +0 -58
- package/dist/frontend-core/frontend.generator.js +6 -172
- package/dist/frontend-core/frontend.generator.js.map +1 -1
- package/dist/frontend-core/template/README.md +1 -1
- package/dist/frontend-core/template/src/components/admin/table-filter.tsx +1 -5
- package/dist/frontend-core/template/src/components/ui/color-mode-toggle/color-mode-toggle.tsx +10 -4
- package/dist/frontend-core/template/src/pages/dashboard/dashboard.page.tsx +2 -3
- package/dist/frontend-core/template/src/pages/error/default-error.page.tsx +1 -1
- package/dist/frontend-core/template/src/pages/error/not-found-error.page.tsx +1 -1
- package/dist/frontend-core/template/src/styles/styles.css +13 -1
- package/dist/frontend-core/template/tsconfig.json +2 -0
- package/dist/frontend-core/types/component.d.ts +1 -1
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.js +4 -6
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.js.map +1 -1
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js +1 -1
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js.map +1 -1
- package/dist/frontend-forms/generators/enum/inputs.generator.js +1 -1
- package/dist/frontend-forms/generators/enum/inputs.generator.js.map +1 -1
- package/dist/frontend-forms/generators/model/forms.generator.js +8 -12
- package/dist/frontend-forms/generators/model/forms.generator.js.map +1 -1
- package/dist/frontend-forms/generators/model/inputs.generator.js +2 -6
- package/dist/frontend-forms/generators/model/inputs.generator.js.map +1 -1
- package/dist/frontend-forms/template/src/components/ui/field/field.tsx +1 -4
- package/dist/frontend-tables/generators/model-table.generator.js +1 -5
- package/dist/frontend-tables/generators/model-table.generator.js.map +1 -1
- package/package.json +3 -2
- package/dist/frontend-core/template/src/components/ui/accordion/accordion.stories.tsx +0 -47
- package/dist/frontend-core/template/src/components/ui/accordion/accordion.tsx +0 -52
- package/dist/frontend-core/template/src/components/ui/admin-sidebar/admin-sidebar.tsx +0 -195
- package/dist/frontend-core/template/src/components/ui/alert/alert.stories.tsx +0 -61
- package/dist/frontend-core/template/src/components/ui/alert/alert.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.stories.tsx +0 -52
- package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.tsx +0 -105
- package/dist/frontend-core/template/src/components/ui/avatar/avatar.stories.tsx +0 -30
- package/dist/frontend-core/template/src/components/ui/avatar/avatar.tsx +0 -39
- package/dist/frontend-core/template/src/components/ui/badge/badge.stories.tsx +0 -78
- package/dist/frontend-core/template/src/components/ui/badge/badge.tsx +0 -48
- package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.stories.tsx +0 -67
- package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.tsx +0 -85
- package/dist/frontend-core/template/src/components/ui/button/button.stories.tsx +0 -150
- package/dist/frontend-core/template/src/components/ui/button/button.tsx +0 -68
- package/dist/frontend-core/template/src/components/ui/calendar/calendar.stories.tsx +0 -160
- package/dist/frontend-core/template/src/components/ui/calendar/calendar.tsx +0 -293
- package/dist/frontend-core/template/src/components/ui/card/card.stories.tsx +0 -77
- package/dist/frontend-core/template/src/components/ui/card/card.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.stories.tsx +0 -29
- package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.tsx +0 -28
- package/dist/frontend-core/template/src/components/ui/carousel/carousel.stories.tsx +0 -154
- package/dist/frontend-core/template/src/components/ui/carousel/carousel.tsx +0 -227
- package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.stories.tsx +0 -106
- package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.tsx +0 -88
- package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.stories.tsx +0 -90
- package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.tsx +0 -54
- package/dist/frontend-core/template/src/components/ui/collapse/collapse.stories.tsx +0 -52
- package/dist/frontend-core/template/src/components/ui/collapse/collapse.tsx +0 -9
- package/dist/frontend-core/template/src/components/ui/combobox/combobox.stories.tsx +0 -207
- package/dist/frontend-core/template/src/components/ui/combobox/combobox.tsx +0 -79
- package/dist/frontend-core/template/src/components/ui/command/command.stories.tsx +0 -186
- package/dist/frontend-core/template/src/components/ui/command/command.tsx +0 -165
- package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.stories.tsx +0 -160
- package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.tsx +0 -134
- package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.stories.tsx +0 -198
- package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.tsx +0 -100
- package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.stories.tsx +0 -78
- package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.tsx +0 -179
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/cell-variant-types.ts +0 -11
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/checkbox-cell.tsx +0 -116
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/date-cell.tsx +0 -157
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/gantt-cell.tsx +0 -82
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/long-text-cell.tsx +0 -180
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/multi-select-cell.tsx +0 -280
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/number-cell.tsx +0 -169
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/react-node-cell.tsx +0 -33
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/select-cell.tsx +0 -175
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/short-text-cell.tsx +0 -138
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timeline.tsx +0 -92
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timerange-picker.tsx +0 -330
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell-wrapper.tsx +0 -212
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell.tsx +0 -157
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-column-header.tsx +0 -340
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-context-menu.tsx +0 -271
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-row.tsx +0 -123
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-search.tsx +0 -211
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-types.ts +0 -159
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-utils.ts +0 -67
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-view-menu.tsx +0 -360
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.stories.tsx +0 -780
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.tsx +0 -217
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-callback-ref.ts +0 -22
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-data-grid.tsx +0 -1892
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-debounced-callback.ts +0 -19
- package/dist/frontend-core/template/src/components/ui/data-grid/styles.css +0 -3
- package/dist/frontend-core/template/src/components/ui/data-table/context-menu-simple.tsx +0 -141
- package/dist/frontend-core/template/src/components/ui/data-table/data-table.stories.tsx +0 -146
- package/dist/frontend-core/template/src/components/ui/data-table/data-table.tsx +0 -447
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-array-cell-renderer.tsx +0 -77
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-cell-renderer.tsx +0 -56
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/favorite-cell-renderer.tsx +0 -68
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/links-cell-renderer.tsx +0 -205
- package/dist/frontend-core/template/src/components/ui/data-table/utils/columns.ts +0 -351
- package/dist/frontend-core/template/src/components/ui/data-table/utils/data-table.utils.ts +0 -49
- package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.stories.tsx +0 -149
- package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.tsx +0 -30
- package/dist/frontend-core/template/src/components/ui/dialog/dialog.stories.tsx +0 -80
- package/dist/frontend-core/template/src/components/ui/dialog/dialog.tsx +0 -134
- package/dist/frontend-core/template/src/components/ui/drawer/drawer.stories.tsx +0 -104
- package/dist/frontend-core/template/src/components/ui/drawer/drawer.tsx +0 -87
- package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.stories.tsx +0 -168
- package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.tsx +0 -225
- package/dist/frontend-core/template/src/components/ui/input/input.stories.tsx +0 -141
- package/dist/frontend-core/template/src/components/ui/input/input.tsx +0 -47
- package/dist/frontend-core/template/src/components/ui/label/label.stories.tsx +0 -41
- package/dist/frontend-core/template/src/components/ui/label/label.tsx +0 -20
- package/dist/frontend-core/template/src/components/ui/loader/loader.stories.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/loader/loader.tsx +0 -17
- package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.stories.tsx +0 -114
- package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.tsx +0 -48
- package/dist/frontend-core/template/src/components/ui/menubar/menu.stories.tsx +0 -134
- package/dist/frontend-core/template/src/components/ui/menubar/menubar.tsx +0 -208
- package/dist/frontend-core/template/src/components/ui/modal/modal.stories.tsx +0 -297
- package/dist/frontend-core/template/src/components/ui/modal/modal.tsx +0 -80
- package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.stories.tsx +0 -213
- package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.tsx +0 -142
- package/dist/frontend-core/template/src/components/ui/pagination/pagination.stories.tsx +0 -49
- package/dist/frontend-core/template/src/components/ui/pagination/pagination.tsx +0 -84
- package/dist/frontend-core/template/src/components/ui/popover/popover.stories.tsx +0 -82
- package/dist/frontend-core/template/src/components/ui/popover/popover.tsx +0 -55
- package/dist/frontend-core/template/src/components/ui/progress/progress.stories.tsx +0 -80
- package/dist/frontend-core/template/src/components/ui/progress/progress.tsx +0 -17
- package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.stories.tsx +0 -154
- package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.tsx +0 -68
- package/dist/frontend-core/template/src/components/ui/resizable/resizable.stories.tsx +0 -73
- package/dist/frontend-core/template/src/components/ui/resizable/resizeable.tsx +0 -38
- package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.stories.tsx +0 -55
- package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.tsx +0 -39
- package/dist/frontend-core/template/src/components/ui/select/select.stories.tsx +0 -297
- package/dist/frontend-core/template/src/components/ui/select/select.tsx +0 -227
- package/dist/frontend-core/template/src/components/ui/separator/separator.tsx +0 -21
- package/dist/frontend-core/template/src/components/ui/separator/seperator.stories.tsx +0 -25
- package/dist/frontend-core/template/src/components/ui/sheet/sheet.stories.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/sheet/sheet.tsx +0 -107
- package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.stories.tsx +0 -26
- package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.tsx +0 -7
- package/dist/frontend-core/template/src/components/ui/slider/slider.stories.tsx +0 -101
- package/dist/frontend-core/template/src/components/ui/slider/slider.tsx +0 -98
- package/dist/frontend-core/template/src/components/ui/spinner/spinner.stories.tsx +0 -19
- package/dist/frontend-core/template/src/components/ui/spinner/spinner.tsx +0 -21
- package/dist/frontend-core/template/src/components/ui/switch/switch.stories.tsx +0 -33
- package/dist/frontend-core/template/src/components/ui/switch/switch.tsx +0 -28
- package/dist/frontend-core/template/src/components/ui/tabs/tabs.stories.tsx +0 -215
- package/dist/frontend-core/template/src/components/ui/tabs/tabs.tsx +0 -70
- package/dist/frontend-core/template/src/components/ui/textarea/textarea.stories.tsx +0 -138
- package/dist/frontend-core/template/src/components/ui/textarea/textarea.tsx +0 -40
- package/dist/frontend-core/template/src/components/ui/toast/toast.mdx +0 -31
- package/dist/frontend-core/template/src/components/ui/toast/toast.stories.tsx +0 -89
- package/dist/frontend-core/template/src/components/ui/toggle/toggle.stories.tsx +0 -65
- package/dist/frontend-core/template/src/components/ui/toggle/toggle.tsx +0 -38
- package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.stories.tsx +0 -85
- package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.tsx +0 -54
- package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.stories.tsx +0 -29
- package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.tsx +0 -29
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { PlusIcon } from '@radix-ui/react-icons'
|
|
2
|
-
import { flexRender } from '@tanstack/react-table'
|
|
3
|
-
|
|
4
|
-
import * as React from 'react'
|
|
5
|
-
|
|
6
|
-
import { DataGridColumnHeader } from '@components/ui/data-grid/data-grid-column-header'
|
|
7
|
-
import { DataGridContextMenu } from '@components/ui/data-grid/data-grid-context-menu'
|
|
8
|
-
import { DataGridRow } from '@components/ui/data-grid/data-grid-row'
|
|
9
|
-
import { DataGridSearch } from '@components/ui/data-grid/data-grid-search'
|
|
10
|
-
import { getCommonPinningStyles } from '@components/ui/data-grid/data-grid-utils'
|
|
11
|
-
import type { useDataGrid } from '@components/ui/data-grid/hooks/use-data-grid'
|
|
12
|
-
import { cn } from '@lib/utils'
|
|
13
|
-
|
|
14
|
-
type DataGridProps<TData> = {
|
|
15
|
-
height?: number
|
|
16
|
-
} & ReturnType<typeof useDataGrid<TData>> &
|
|
17
|
-
React.ComponentProps<'div'>
|
|
18
|
-
|
|
19
|
-
export function DataGrid<TData>({
|
|
20
|
-
dataGridRef,
|
|
21
|
-
headerRef,
|
|
22
|
-
rowMapRef,
|
|
23
|
-
footerRef,
|
|
24
|
-
table,
|
|
25
|
-
rowVirtualizer,
|
|
26
|
-
height,
|
|
27
|
-
searchState,
|
|
28
|
-
columnSizeVars,
|
|
29
|
-
onRowAdd,
|
|
30
|
-
className,
|
|
31
|
-
...props
|
|
32
|
-
}: DataGridProps<TData>) {
|
|
33
|
-
const rows = table.getRowModel().rows
|
|
34
|
-
const columns = table.getAllColumns()
|
|
35
|
-
|
|
36
|
-
const meta = table.options.meta
|
|
37
|
-
const rowHeight = meta?.rowHeight ?? 'short'
|
|
38
|
-
const focusedCell = meta?.focusedCell ?? null
|
|
39
|
-
|
|
40
|
-
const onGridContextMenu = React.useCallback((event: React.MouseEvent<HTMLDivElement>) => {
|
|
41
|
-
event.preventDefault()
|
|
42
|
-
}, [])
|
|
43
|
-
|
|
44
|
-
const onAddRowKeyDown = React.useCallback(
|
|
45
|
-
async (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
46
|
-
if (!onRowAdd) {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (event.key === 'Enter' || event.key === '') {
|
|
51
|
-
event.preventDefault()
|
|
52
|
-
await onRowAdd()
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
[onRowAdd],
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
// calculate header/footer heights using simple measurements (no observers)
|
|
59
|
-
// previous fallbacks were header ~58 and footer ~13
|
|
60
|
-
const headerHeight = headerRef?.current?.clientHeight ?? 58
|
|
61
|
-
const footerHeight = onRowAdd ? (footerRef?.current?.clientHeight ?? 12) + 1 : 0
|
|
62
|
-
|
|
63
|
-
// if the grid has a horizontal scrollbar, measure its height so it doesn't overlap content
|
|
64
|
-
let scrollbarHeight = 0
|
|
65
|
-
if (dataGridRef?.current) {
|
|
66
|
-
const el = dataGridRef.current
|
|
67
|
-
if (el.scrollWidth > el.clientWidth) {
|
|
68
|
-
// offsetHeight - clientHeight approximates the scrollbar thickness (includes borders)
|
|
69
|
-
scrollbarHeight = Math.max(0, el.offsetHeight - el.clientHeight)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<div data-slot="grid-wrapper" className={cn('relative flex w-full flex-col', className)} {...props}>
|
|
75
|
-
{searchState && <DataGridSearch {...searchState} />}
|
|
76
|
-
<DataGridContextMenu table={table} />
|
|
77
|
-
<div
|
|
78
|
-
role="grid"
|
|
79
|
-
aria-label="Data grid"
|
|
80
|
-
aria-rowcount={rows.length + (onRowAdd ? 1 : 0)}
|
|
81
|
-
aria-colcount={columns.length}
|
|
82
|
-
data-slot="grid"
|
|
83
|
-
tabIndex={0}
|
|
84
|
-
ref={dataGridRef}
|
|
85
|
-
className="relative grid select-none overflow-auto rounded-md border border-border focus:outline-none"
|
|
86
|
-
style={{
|
|
87
|
-
...columnSizeVars,
|
|
88
|
-
// dynamically include measured header/footer heights (falling back to previous magic numbers)
|
|
89
|
-
// include horizontal scrollbar height when present, and add a small buffer of 3px
|
|
90
|
-
height: `${Math.min(
|
|
91
|
-
rowVirtualizer.getTotalSize() + headerHeight + footerHeight + scrollbarHeight + 3,
|
|
92
|
-
height ?? Infinity,
|
|
93
|
-
)}px`,
|
|
94
|
-
}}
|
|
95
|
-
onContextMenu={onGridContextMenu}
|
|
96
|
-
>
|
|
97
|
-
<div
|
|
98
|
-
role="rowgroup"
|
|
99
|
-
data-slot="grid-header"
|
|
100
|
-
ref={headerRef}
|
|
101
|
-
className="sticky top-0 z-10 grid border-b bg-background"
|
|
102
|
-
>
|
|
103
|
-
{table.getHeaderGroups().map((headerGroup, rowIndex) => (
|
|
104
|
-
<div
|
|
105
|
-
key={headerGroup.id}
|
|
106
|
-
role="row"
|
|
107
|
-
aria-rowindex={rowIndex + 1}
|
|
108
|
-
data-slot="grid-header-row"
|
|
109
|
-
tabIndex={-1}
|
|
110
|
-
className="flex w-full"
|
|
111
|
-
>
|
|
112
|
-
{headerGroup.headers.map((header, colIndex) => {
|
|
113
|
-
const sorting = table.getState().sorting
|
|
114
|
-
const currentSort = sorting.find((sort) => sort.id === header.column.id)
|
|
115
|
-
const isSortable = header.column.getCanSort()
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<div
|
|
119
|
-
key={header.id}
|
|
120
|
-
role="columnheader"
|
|
121
|
-
aria-colindex={colIndex + 1}
|
|
122
|
-
aria-sort={
|
|
123
|
-
currentSort?.desc === false
|
|
124
|
-
? 'ascending'
|
|
125
|
-
: currentSort?.desc === true
|
|
126
|
-
? 'descending'
|
|
127
|
-
: isSortable
|
|
128
|
-
? 'none'
|
|
129
|
-
: undefined
|
|
130
|
-
}
|
|
131
|
-
data-slot="grid-header-cell"
|
|
132
|
-
tabIndex={-1}
|
|
133
|
-
className={cn('relative', {
|
|
134
|
-
'border-r': header.column.id !== 'select',
|
|
135
|
-
})}
|
|
136
|
-
style={{
|
|
137
|
-
...getCommonPinningStyles({ column: header.column }),
|
|
138
|
-
width: `calc(var(--header-${header.id}-size) * 1px)`,
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
{header.isPlaceholder ? null : typeof header.column.columnDef.header === 'function' ? (
|
|
142
|
-
<div className="size-full px-3 py-1.5 bg-secondary/80 hover:bg-secondary/40">
|
|
143
|
-
{flexRender(header.column.columnDef.header, header.getContext())}
|
|
144
|
-
</div>
|
|
145
|
-
) : (
|
|
146
|
-
<DataGridColumnHeader header={header} table={table} />
|
|
147
|
-
)}
|
|
148
|
-
</div>
|
|
149
|
-
)
|
|
150
|
-
})}
|
|
151
|
-
</div>
|
|
152
|
-
))}
|
|
153
|
-
</div>
|
|
154
|
-
<div
|
|
155
|
-
role="rowgroup"
|
|
156
|
-
data-slot="grid-body"
|
|
157
|
-
className="relative grid"
|
|
158
|
-
style={{
|
|
159
|
-
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
160
|
-
}}
|
|
161
|
-
>
|
|
162
|
-
{rowVirtualizer.getVirtualIndexes().map((virtualRowIndex) => {
|
|
163
|
-
const row = rows[virtualRowIndex]
|
|
164
|
-
if (!row) {
|
|
165
|
-
return null
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<DataGridRow
|
|
170
|
-
key={row.id}
|
|
171
|
-
row={row}
|
|
172
|
-
rowMapRef={rowMapRef}
|
|
173
|
-
virtualRowIndex={virtualRowIndex}
|
|
174
|
-
rowVirtualizer={rowVirtualizer}
|
|
175
|
-
rowHeight={rowHeight}
|
|
176
|
-
focusedCell={focusedCell}
|
|
177
|
-
/>
|
|
178
|
-
)
|
|
179
|
-
})}
|
|
180
|
-
</div>
|
|
181
|
-
{onRowAdd && (
|
|
182
|
-
<div
|
|
183
|
-
role="rowgroup"
|
|
184
|
-
data-slot="grid-footer"
|
|
185
|
-
ref={footerRef}
|
|
186
|
-
className="sticky bottom-0 z-10 grid border-t bg-background"
|
|
187
|
-
>
|
|
188
|
-
<div
|
|
189
|
-
role="row"
|
|
190
|
-
aria-rowindex={rows.length + 2}
|
|
191
|
-
data-slot="grid-add-row"
|
|
192
|
-
tabIndex={-1}
|
|
193
|
-
className="flex w-full"
|
|
194
|
-
>
|
|
195
|
-
<div
|
|
196
|
-
role="gridcell"
|
|
197
|
-
tabIndex={0}
|
|
198
|
-
className="relative flex h-9 grow items-center bg-secondary/30 transition-colors hover:bg-secondary/50 focus:bg-secondary/50 focus:outline-none"
|
|
199
|
-
style={{
|
|
200
|
-
width: table.getTotalSize(),
|
|
201
|
-
minWidth: table.getTotalSize(),
|
|
202
|
-
}}
|
|
203
|
-
onClick={onRowAdd}
|
|
204
|
-
onKeyDown={onAddRowKeyDown}
|
|
205
|
-
>
|
|
206
|
-
<div className="sticky left-0 flex items-center gap-2 px-3 text-muted-foreground">
|
|
207
|
-
<PlusIcon className="size-3.5" />
|
|
208
|
-
<span className="text-sm">Add row</span>
|
|
209
|
-
</div>
|
|
210
|
-
</div>
|
|
211
|
-
</div>
|
|
212
|
-
</div>
|
|
213
|
-
)}
|
|
214
|
-
</div>
|
|
215
|
-
</div>
|
|
216
|
-
)
|
|
217
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://github.com/radix-ui/primitives/blob/main/packages/react/use-callback-ref/src/useCallbackRef.tsx
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
9
|
-
* prop or avoid re-executing effects when passed as a dependency
|
|
10
|
-
*/
|
|
11
|
-
function useCallbackRef<T extends (...args: never[]) => unknown>(callback: T | undefined): T {
|
|
12
|
-
const callbackRef = React.useRef(callback)
|
|
13
|
-
|
|
14
|
-
React.useEffect(() => {
|
|
15
|
-
callbackRef.current = callback
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
// https://github.com/facebook/react/issues/19240
|
|
19
|
-
return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, [])
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { useCallbackRef }
|