@postxl/generators 1.1.1 → 1.2.1
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/backend-core/backend.generator.js +4 -1
- package/dist/backend-core/backend.generator.js.map +1 -1
- package/dist/backend-core/generators/jest.config.generator.d.ts +2 -0
- package/dist/backend-core/{template/jest.config.ts → generators/jest.config.generator.js} +12 -8
- package/dist/backend-core/generators/jest.config.generator.js.map +1 -0
- package/dist/backend-core/generators/tsconfig.generator.d.ts +1 -1
- package/dist/backend-core/generators/tsconfig.generator.js +1 -9
- package/dist/backend-core/generators/tsconfig.generator.js.map +1 -1
- package/dist/backend-core/types.d.ts +2 -0
- package/dist/base/base.generator.js +12 -8
- package/dist/base/base.generator.js.map +1 -1
- package/dist/e2e/template/e2e/package.json +1 -1
- package/dist/e2e/template/e2e/specs/example.spec.ts +1 -1
- package/dist/e2e/template/e2e/specs/example.spec.ts-snapshots/Navigate-to-homepage-and-take-snapshot-1-chromium-linux.png +0 -0
- package/dist/frontend-core/frontend.generator.d.ts +0 -58
- package/dist/frontend-core/frontend.generator.js +9 -173
- package/dist/frontend-core/frontend.generator.js.map +1 -1
- package/dist/frontend-core/generators/tsconfig.generator.js +2 -0
- package/dist/frontend-core/generators/tsconfig.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/lib/query-client.ts +45 -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 +45 -12
- 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 +4 -3
- package/dist/e2e/generators/package-json.generator.d.ts +0 -2
- package/dist/e2e/generators/package-json.generator.js +0 -29
- package/dist/e2e/generators/package-json.generator.js.map +0 -1
- 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,100 +0,0 @@
|
|
|
1
|
-
import { EnterFullScreenIcon } from '@radix-ui/react-icons'
|
|
2
|
-
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
-
import { type PropsWithChildren, type ReactNode } from 'react'
|
|
5
|
-
|
|
6
|
-
import { Button } from '@components/ui/button/button'
|
|
7
|
-
import { Loader } from '@components/ui/loader/loader'
|
|
8
|
-
import { cn } from '@lib/utils'
|
|
9
|
-
|
|
10
|
-
const gridContentFrameVariants = cva('flex flex-col border-1 border-(--discreet-border) h-full w-full', {
|
|
11
|
-
variants: {
|
|
12
|
-
variant: {
|
|
13
|
-
default: '',
|
|
14
|
-
inverted: 'bg-sidebar-border border-background border-e-transparent border-t-0',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
defaultVariants: {
|
|
18
|
-
variant: 'default',
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const gridContentFrameHeaderVariants = cva('flex items-center overflow-hidden p-3 min-h-10 border-b-1', {
|
|
23
|
-
variants: {
|
|
24
|
-
variant: {
|
|
25
|
-
default: 'border-(--discreet-border)',
|
|
26
|
-
inverted: 'border-t-0 border-t-sidebar-border border-b-background',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
defaultVariants: {
|
|
30
|
-
variant: 'default',
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
type Props = PropsWithChildren<{
|
|
35
|
-
title: string
|
|
36
|
-
controls?: ReactNode[]
|
|
37
|
-
indicators?: ReactNode[]
|
|
38
|
-
onExpand?: () => void
|
|
39
|
-
collapsed?: boolean
|
|
40
|
-
titleLink?: ReactNode
|
|
41
|
-
isLoading?: boolean
|
|
42
|
-
}> &
|
|
43
|
-
VariantProps<typeof gridContentFrameVariants>
|
|
44
|
-
|
|
45
|
-
export const ContentFrame = ({
|
|
46
|
-
title = '',
|
|
47
|
-
controls = [],
|
|
48
|
-
indicators = [],
|
|
49
|
-
children,
|
|
50
|
-
onExpand,
|
|
51
|
-
variant,
|
|
52
|
-
collapsed,
|
|
53
|
-
titleLink,
|
|
54
|
-
isLoading = false,
|
|
55
|
-
}: Props) => {
|
|
56
|
-
return (
|
|
57
|
-
<div className={cn(gridContentFrameVariants({ variant }))}>
|
|
58
|
-
{collapsed ? (
|
|
59
|
-
<div className="flex gap-2.5 min-w-0 items-center [writing-mode:vertical-lr]">
|
|
60
|
-
<h2 className="text-xl flex self-center ms-4">{title}</h2>
|
|
61
|
-
{indicators.length > 0 && <div className="flex gap-2 whitespace-nowrap">{indicators}</div>}
|
|
62
|
-
</div>
|
|
63
|
-
) : (
|
|
64
|
-
<>
|
|
65
|
-
{/* header */}
|
|
66
|
-
<div className={cn(gridContentFrameHeaderVariants({ variant }))}>
|
|
67
|
-
{/* Title + Indicators */}
|
|
68
|
-
<div className="flex flex-grow gap-2 overflow-hidden">
|
|
69
|
-
<h2 className="text-xl overflow-hidden text-ellipsis whitespace-nowrap">{titleLink ?? title}</h2>
|
|
70
|
-
{indicators.length > 0 && <div className="flex gap-2 whitespace-nowrap">{indicators}</div>}
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
{/* Controls */}
|
|
74
|
-
{controls.length > 0 && <div className="flex gap-2 whitespace-nowrap">{controls}</div>}
|
|
75
|
-
|
|
76
|
-
{/* Expand button */}
|
|
77
|
-
{onExpand && (
|
|
78
|
-
<Button
|
|
79
|
-
title="Expand"
|
|
80
|
-
onClick={onExpand}
|
|
81
|
-
variant="outline"
|
|
82
|
-
size="icon"
|
|
83
|
-
className="size-6 ml-2"
|
|
84
|
-
__e2e_test_id__={`${title.toLowerCase().replaceAll(' ', '-')}-modal-button`}
|
|
85
|
-
>
|
|
86
|
-
<EnterFullScreenIcon />
|
|
87
|
-
</Button>
|
|
88
|
-
)}
|
|
89
|
-
</div>
|
|
90
|
-
|
|
91
|
-
{/* content */}
|
|
92
|
-
<div className="h-full min-h-0 overflow-auto relative">
|
|
93
|
-
{children}
|
|
94
|
-
{isLoading && <Loader label="Loading..." />}
|
|
95
|
-
</div>
|
|
96
|
-
</>
|
|
97
|
-
)}
|
|
98
|
-
</div>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ContextMenu,
|
|
5
|
-
ContextMenuCheckboxItem,
|
|
6
|
-
ContextMenuContent,
|
|
7
|
-
ContextMenuItem,
|
|
8
|
-
ContextMenuLabel,
|
|
9
|
-
ContextMenuRadioGroup,
|
|
10
|
-
ContextMenuRadioItem,
|
|
11
|
-
ContextMenuSeparator,
|
|
12
|
-
ContextMenuShortcut,
|
|
13
|
-
ContextMenuSub,
|
|
14
|
-
ContextMenuSubContent,
|
|
15
|
-
ContextMenuSubTrigger,
|
|
16
|
-
ContextMenuTrigger,
|
|
17
|
-
} from './context-menu'
|
|
18
|
-
import type { StoryObj } from '@storybook/react-vite'
|
|
19
|
-
|
|
20
|
-
const meta: Meta<typeof ContextMenu> = {
|
|
21
|
-
title: 'Context Menu',
|
|
22
|
-
component: ContextMenu,
|
|
23
|
-
tags: ['autodocs'],
|
|
24
|
-
} satisfies Meta<typeof ContextMenu>
|
|
25
|
-
|
|
26
|
-
export default meta
|
|
27
|
-
|
|
28
|
-
export const Default: StoryObj<typeof meta> = {
|
|
29
|
-
render: () => (
|
|
30
|
-
<div className="flex items-center justify-center">
|
|
31
|
-
<ContextMenu>
|
|
32
|
-
<ContextMenuTrigger className="flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm">
|
|
33
|
-
Right click here
|
|
34
|
-
</ContextMenuTrigger>
|
|
35
|
-
<ContextMenuContent className="w-64">
|
|
36
|
-
<ContextMenuItem inset>
|
|
37
|
-
Back
|
|
38
|
-
<ContextMenuShortcut>⌘[</ContextMenuShortcut>
|
|
39
|
-
</ContextMenuItem>
|
|
40
|
-
<ContextMenuItem inset disabled>
|
|
41
|
-
Forward
|
|
42
|
-
<ContextMenuShortcut>⌘]</ContextMenuShortcut>
|
|
43
|
-
</ContextMenuItem>
|
|
44
|
-
<ContextMenuItem inset>
|
|
45
|
-
Reload
|
|
46
|
-
<ContextMenuShortcut>⌘R</ContextMenuShortcut>
|
|
47
|
-
</ContextMenuItem>
|
|
48
|
-
<ContextMenuSub>
|
|
49
|
-
<ContextMenuSubTrigger inset>More Tools</ContextMenuSubTrigger>
|
|
50
|
-
<ContextMenuSubContent className="w-48">
|
|
51
|
-
<ContextMenuItem>
|
|
52
|
-
Save Page As...
|
|
53
|
-
<ContextMenuShortcut>⇧⌘S</ContextMenuShortcut>
|
|
54
|
-
</ContextMenuItem>
|
|
55
|
-
<ContextMenuItem>Create Shortcut...</ContextMenuItem>
|
|
56
|
-
<ContextMenuItem>Name Window...</ContextMenuItem>
|
|
57
|
-
<ContextMenuSeparator />
|
|
58
|
-
<ContextMenuItem>Developer Tools</ContextMenuItem>
|
|
59
|
-
</ContextMenuSubContent>
|
|
60
|
-
</ContextMenuSub>
|
|
61
|
-
<ContextMenuSeparator />
|
|
62
|
-
<ContextMenuCheckboxItem checked>
|
|
63
|
-
Show Bookmarks Bar
|
|
64
|
-
<ContextMenuShortcut>⌘⇧B</ContextMenuShortcut>
|
|
65
|
-
</ContextMenuCheckboxItem>
|
|
66
|
-
<ContextMenuCheckboxItem>Show Full URLs</ContextMenuCheckboxItem>
|
|
67
|
-
<ContextMenuSeparator />
|
|
68
|
-
<ContextMenuRadioGroup value="pedro">
|
|
69
|
-
<ContextMenuLabel inset>People</ContextMenuLabel>
|
|
70
|
-
<ContextMenuSeparator />
|
|
71
|
-
<ContextMenuRadioItem value="pedro">Pedro Duarte</ContextMenuRadioItem>
|
|
72
|
-
<ContextMenuRadioItem value="colm">Colm Tuite</ContextMenuRadioItem>
|
|
73
|
-
</ContextMenuRadioGroup>
|
|
74
|
-
</ContextMenuContent>
|
|
75
|
-
</ContextMenu>
|
|
76
|
-
</div>
|
|
77
|
-
),
|
|
78
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu'
|
|
2
|
-
import { CheckIcon, ChevronRightIcon, DotFilledIcon } from '@radix-ui/react-icons'
|
|
3
|
-
|
|
4
|
-
import * as React from 'react'
|
|
5
|
-
|
|
6
|
-
import { cn } from '@lib/utils'
|
|
7
|
-
|
|
8
|
-
const ContextMenu = ContextMenuPrimitive.Root
|
|
9
|
-
|
|
10
|
-
const ContextMenuTrigger = ContextMenuPrimitive.Trigger
|
|
11
|
-
|
|
12
|
-
const ContextMenuGroup = ContextMenuPrimitive.Group
|
|
13
|
-
|
|
14
|
-
const ContextMenuPortal = ContextMenuPrimitive.Portal
|
|
15
|
-
|
|
16
|
-
const ContextMenuSub = ContextMenuPrimitive.Sub
|
|
17
|
-
|
|
18
|
-
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
|
|
19
|
-
|
|
20
|
-
const ContextMenuSubTrigger = React.forwardRef<
|
|
21
|
-
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
22
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
23
|
-
inset?: boolean
|
|
24
|
-
}
|
|
25
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
26
|
-
<ContextMenuPrimitive.SubTrigger
|
|
27
|
-
ref={ref}
|
|
28
|
-
className={cn(
|
|
29
|
-
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
|
|
30
|
-
inset && 'pl-8',
|
|
31
|
-
className,
|
|
32
|
-
)}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
|
37
|
-
</ContextMenuPrimitive.SubTrigger>
|
|
38
|
-
))
|
|
39
|
-
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
|
|
40
|
-
|
|
41
|
-
const ContextMenuSubContent = React.forwardRef<
|
|
42
|
-
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
43
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
|
44
|
-
>(({ className, ...props }, ref) => (
|
|
45
|
-
<ContextMenuPrimitive.SubContent
|
|
46
|
-
ref={ref}
|
|
47
|
-
className={cn(
|
|
48
|
-
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
|
49
|
-
className,
|
|
50
|
-
)}
|
|
51
|
-
{...props}
|
|
52
|
-
/>
|
|
53
|
-
))
|
|
54
|
-
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
|
|
55
|
-
|
|
56
|
-
const ContextMenuContent = React.forwardRef<
|
|
57
|
-
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
58
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
|
59
|
-
>(({ className, ...props }, ref) => (
|
|
60
|
-
<ContextMenuPrimitive.Portal>
|
|
61
|
-
<ContextMenuPrimitive.Content
|
|
62
|
-
ref={ref}
|
|
63
|
-
className={cn(
|
|
64
|
-
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
|
65
|
-
className,
|
|
66
|
-
)}
|
|
67
|
-
{...props}
|
|
68
|
-
/>
|
|
69
|
-
</ContextMenuPrimitive.Portal>
|
|
70
|
-
))
|
|
71
|
-
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
|
|
72
|
-
|
|
73
|
-
const ContextMenuItem = React.forwardRef<
|
|
74
|
-
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
75
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
|
76
|
-
inset?: boolean
|
|
77
|
-
}
|
|
78
|
-
>(({ className, inset, ...props }, ref) => (
|
|
79
|
-
<ContextMenuPrimitive.Item
|
|
80
|
-
ref={ref}
|
|
81
|
-
className={cn(
|
|
82
|
-
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
83
|
-
inset && 'pl-8',
|
|
84
|
-
className,
|
|
85
|
-
)}
|
|
86
|
-
{...props}
|
|
87
|
-
/>
|
|
88
|
-
))
|
|
89
|
-
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
|
|
90
|
-
|
|
91
|
-
const ContextMenuCheckboxItem = React.forwardRef<
|
|
92
|
-
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
93
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
94
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
95
|
-
<ContextMenuPrimitive.CheckboxItem
|
|
96
|
-
ref={ref}
|
|
97
|
-
className={cn(
|
|
98
|
-
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
99
|
-
className,
|
|
100
|
-
)}
|
|
101
|
-
checked={checked}
|
|
102
|
-
{...props}
|
|
103
|
-
>
|
|
104
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
105
|
-
<ContextMenuPrimitive.ItemIndicator>
|
|
106
|
-
<CheckIcon className="h-4 w-4" />
|
|
107
|
-
</ContextMenuPrimitive.ItemIndicator>
|
|
108
|
-
</span>
|
|
109
|
-
{children}
|
|
110
|
-
</ContextMenuPrimitive.CheckboxItem>
|
|
111
|
-
))
|
|
112
|
-
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName
|
|
113
|
-
|
|
114
|
-
const ContextMenuRadioItem = React.forwardRef<
|
|
115
|
-
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
116
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
117
|
-
>(({ className, children, ...props }, ref) => (
|
|
118
|
-
<ContextMenuPrimitive.RadioItem
|
|
119
|
-
ref={ref}
|
|
120
|
-
className={cn(
|
|
121
|
-
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
122
|
-
className,
|
|
123
|
-
)}
|
|
124
|
-
{...props}
|
|
125
|
-
>
|
|
126
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
127
|
-
<ContextMenuPrimitive.ItemIndicator>
|
|
128
|
-
<DotFilledIcon className="h-4 w-4 fill-current" />
|
|
129
|
-
</ContextMenuPrimitive.ItemIndicator>
|
|
130
|
-
</span>
|
|
131
|
-
{children}
|
|
132
|
-
</ContextMenuPrimitive.RadioItem>
|
|
133
|
-
))
|
|
134
|
-
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName
|
|
135
|
-
|
|
136
|
-
const ContextMenuLabel = React.forwardRef<
|
|
137
|
-
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
138
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
|
139
|
-
inset?: boolean
|
|
140
|
-
}
|
|
141
|
-
>(({ className, inset, ...props }, ref) => (
|
|
142
|
-
<ContextMenuPrimitive.Label
|
|
143
|
-
ref={ref}
|
|
144
|
-
className={cn('px-2 py-1.5 text-sm font-semibold text-foreground', inset && 'pl-8', className)}
|
|
145
|
-
{...props}
|
|
146
|
-
/>
|
|
147
|
-
))
|
|
148
|
-
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
|
|
149
|
-
|
|
150
|
-
const ContextMenuSeparator = React.forwardRef<
|
|
151
|
-
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
152
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
153
|
-
>(({ className, ...props }, ref) => (
|
|
154
|
-
<ContextMenuPrimitive.Separator ref={ref} className={cn('-mx-1 my-1 h-px bg-border', className)} {...props} />
|
|
155
|
-
))
|
|
156
|
-
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
|
|
157
|
-
|
|
158
|
-
const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
159
|
-
return <span className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)} {...props} />
|
|
160
|
-
}
|
|
161
|
-
ContextMenuShortcut.displayName = 'ContextMenuShortcut'
|
|
162
|
-
|
|
163
|
-
export {
|
|
164
|
-
ContextMenu,
|
|
165
|
-
ContextMenuTrigger,
|
|
166
|
-
ContextMenuContent,
|
|
167
|
-
ContextMenuItem,
|
|
168
|
-
ContextMenuCheckboxItem,
|
|
169
|
-
ContextMenuRadioItem,
|
|
170
|
-
ContextMenuLabel,
|
|
171
|
-
ContextMenuSeparator,
|
|
172
|
-
ContextMenuShortcut,
|
|
173
|
-
ContextMenuGroup,
|
|
174
|
-
ContextMenuPortal,
|
|
175
|
-
ContextMenuSub,
|
|
176
|
-
ContextMenuSubContent,
|
|
177
|
-
ContextMenuSubTrigger,
|
|
178
|
-
ContextMenuRadioGroup,
|
|
179
|
-
}
|
package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/cell-variant-types.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Cell, Table } from '@tanstack/react-table'
|
|
2
|
-
|
|
3
|
-
export type CellVariantProps<TData, TCell> = {
|
|
4
|
-
cell: Cell<TData, TCell>
|
|
5
|
-
table: Table<TData>
|
|
6
|
-
rowIndex: number
|
|
7
|
-
columnId: string
|
|
8
|
-
isEditing: boolean
|
|
9
|
-
isFocused: boolean
|
|
10
|
-
isSelected: boolean
|
|
11
|
-
}
|
package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/checkbox-cell.tsx
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
import { Checkbox } from '@components/ui/checkbox/checkbox'
|
|
4
|
-
import { DataGridCellWrapper } from '@components/ui/data-grid/data-grid-cell-wrapper'
|
|
5
|
-
|
|
6
|
-
import { CellVariantProps } from './cell-variant-types'
|
|
7
|
-
|
|
8
|
-
export function CheckboxCell<TData>({
|
|
9
|
-
cell,
|
|
10
|
-
table,
|
|
11
|
-
rowIndex,
|
|
12
|
-
columnId,
|
|
13
|
-
isFocused,
|
|
14
|
-
isSelected,
|
|
15
|
-
}: Readonly<CellVariantProps<TData, boolean>>) {
|
|
16
|
-
const initialValue = cell.getValue()
|
|
17
|
-
const [value, setValue] = React.useState(Boolean(initialValue))
|
|
18
|
-
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
19
|
-
const meta = table.options.meta
|
|
20
|
-
const colMeta = cell.column.columnDef.meta
|
|
21
|
-
// Normalize editable to a resolver function and memoize to avoid typeof checks per cell
|
|
22
|
-
const editableResolver = React.useMemo(() => {
|
|
23
|
-
const v = colMeta?.editable
|
|
24
|
-
if (v === undefined) {
|
|
25
|
-
return () => true
|
|
26
|
-
}
|
|
27
|
-
return typeof v === 'function' ? (v as (row: TData) => boolean) : () => Boolean(v)
|
|
28
|
-
}, [colMeta?.editable])
|
|
29
|
-
const isEditable = editableResolver(cell.row.original)
|
|
30
|
-
|
|
31
|
-
const onCheckedChange = React.useCallback(
|
|
32
|
-
(checked: boolean) => {
|
|
33
|
-
setValue(checked)
|
|
34
|
-
meta?.onDataUpdate?.({ rowIndex, columnId, value: checked })
|
|
35
|
-
},
|
|
36
|
-
[meta, rowIndex, columnId],
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const onWrapperKeyDown = React.useCallback(
|
|
40
|
-
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
41
|
-
if (!isEditable) {
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
if (isFocused && (event.key === '' || event.key === 'Enter')) {
|
|
45
|
-
event.preventDefault()
|
|
46
|
-
event.stopPropagation()
|
|
47
|
-
onCheckedChange(!value)
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
[isFocused, value, onCheckedChange, isEditable],
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
React.useEffect(() => {
|
|
54
|
-
setValue(Boolean(initialValue))
|
|
55
|
-
}, [initialValue])
|
|
56
|
-
|
|
57
|
-
React.useEffect(() => {
|
|
58
|
-
if (isFocused && !meta?.searchOpen && !meta?.isScrolling && containerRef.current) {
|
|
59
|
-
containerRef.current.focus()
|
|
60
|
-
}
|
|
61
|
-
}, [isFocused, meta?.searchOpen, meta?.isScrolling])
|
|
62
|
-
|
|
63
|
-
const onWrapperClick = React.useCallback(
|
|
64
|
-
(event: React.MouseEvent) => {
|
|
65
|
-
if (!isEditable) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
if (isFocused) {
|
|
69
|
-
event.preventDefault()
|
|
70
|
-
event.stopPropagation()
|
|
71
|
-
onCheckedChange(!value)
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
[isFocused, value, onCheckedChange, isEditable],
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
const onCheckboxClick = React.useCallback((event: React.MouseEvent<HTMLInputElement>) => {
|
|
78
|
-
event.stopPropagation()
|
|
79
|
-
}, [])
|
|
80
|
-
|
|
81
|
-
const onCheckboxMouseDown = React.useCallback((event: React.MouseEvent<HTMLInputElement>) => {
|
|
82
|
-
event.stopPropagation()
|
|
83
|
-
}, [])
|
|
84
|
-
|
|
85
|
-
const onCheckboxDoubleClick = React.useCallback((event: React.MouseEvent<HTMLInputElement>) => {
|
|
86
|
-
event.stopPropagation()
|
|
87
|
-
}, [])
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<DataGridCellWrapper
|
|
91
|
-
ref={containerRef}
|
|
92
|
-
cell={cell}
|
|
93
|
-
table={table}
|
|
94
|
-
rowIndex={rowIndex}
|
|
95
|
-
columnId={columnId}
|
|
96
|
-
isEditing={false}
|
|
97
|
-
isFocused={isFocused}
|
|
98
|
-
isSelected={isSelected}
|
|
99
|
-
onClick={onWrapperClick}
|
|
100
|
-
onKeyDown={onWrapperKeyDown}
|
|
101
|
-
className="flex size-full justify-center"
|
|
102
|
-
>
|
|
103
|
-
<Checkbox
|
|
104
|
-
variant="simple"
|
|
105
|
-
iconStyle="simple"
|
|
106
|
-
checkIcon="check"
|
|
107
|
-
checked={value}
|
|
108
|
-
onChange={(event) => onCheckedChange(event.target.checked)}
|
|
109
|
-
onClick={onCheckboxClick}
|
|
110
|
-
onMouseDown={onCheckboxMouseDown}
|
|
111
|
-
onDoubleClick={onCheckboxDoubleClick}
|
|
112
|
-
className="border-secondary-foreground"
|
|
113
|
-
/>
|
|
114
|
-
</DataGridCellWrapper>
|
|
115
|
-
)
|
|
116
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
import { Calendar } from '@components/ui/calendar/calendar'
|
|
4
|
-
import { DataGridCellWrapper } from '@components/ui/data-grid/data-grid-cell-wrapper'
|
|
5
|
-
import { Popover, PopoverAnchor, PopoverContent } from '@components/ui/popover/popover'
|
|
6
|
-
import { cn } from '@lib/utils'
|
|
7
|
-
|
|
8
|
-
import { CellVariantProps } from './cell-variant-types'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Parse a date value (Date object or ISO string YYYY-MM-DD) as a local date, not UTC.
|
|
12
|
-
* new Date('2025-12-01') interprets as UTC, causing timezone shifts.
|
|
13
|
-
*/
|
|
14
|
-
function parseToLocalDate(value: string | Date | null | undefined): Date | undefined {
|
|
15
|
-
if (!value) {
|
|
16
|
-
return undefined
|
|
17
|
-
}
|
|
18
|
-
if (value instanceof Date) {
|
|
19
|
-
return value
|
|
20
|
-
}
|
|
21
|
-
if (typeof value !== 'string') {
|
|
22
|
-
return undefined
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Parse ISO date string in local timezone by explicitly setting year, month, day
|
|
26
|
-
const regex = /^(\d{4})-(\d{2})-(\d{2})$/
|
|
27
|
-
const match = regex.exec(value)
|
|
28
|
-
if (!match) {
|
|
29
|
-
return undefined
|
|
30
|
-
}
|
|
31
|
-
const year = Number.parseInt(match[1], 10)
|
|
32
|
-
const month = Number.parseInt(match[2], 10) - 1 // months are 0-indexed
|
|
33
|
-
const day = Number.parseInt(match[3], 10)
|
|
34
|
-
|
|
35
|
-
return new Date(year, month, day)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function formatDateToISOString(date: Date): string {
|
|
39
|
-
const year = date.getFullYear()
|
|
40
|
-
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
41
|
-
const day = String(date.getDate()).padStart(2, '0')
|
|
42
|
-
return `${year}-${month}-${day}`
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function DateCell<TData>({
|
|
46
|
-
cell,
|
|
47
|
-
table,
|
|
48
|
-
rowIndex,
|
|
49
|
-
columnId,
|
|
50
|
-
isFocused,
|
|
51
|
-
isEditing,
|
|
52
|
-
isSelected,
|
|
53
|
-
}: Readonly<CellVariantProps<TData, string>>) {
|
|
54
|
-
const initialValue = cell.getValue() as string | Date | null | undefined
|
|
55
|
-
const [value, setValue] = React.useState<Date | undefined>(parseToLocalDate(initialValue))
|
|
56
|
-
const [open, setOpen] = React.useState(false)
|
|
57
|
-
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
58
|
-
const meta = table.options.meta
|
|
59
|
-
|
|
60
|
-
const prevInitialValueRef = React.useRef(initialValue)
|
|
61
|
-
if (initialValue !== prevInitialValueRef.current) {
|
|
62
|
-
prevInitialValueRef.current = initialValue
|
|
63
|
-
setValue(parseToLocalDate(initialValue))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const onDateSelect = React.useCallback(
|
|
67
|
-
(date: Date | undefined) => {
|
|
68
|
-
if (!date) {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
setValue(date)
|
|
73
|
-
meta?.onDataUpdate?.({ rowIndex, columnId, value: formatDateToISOString(date) })
|
|
74
|
-
setOpen(false)
|
|
75
|
-
meta?.onCellEditingStop?.()
|
|
76
|
-
},
|
|
77
|
-
[meta, rowIndex, columnId],
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
const onOpenChange = React.useCallback(
|
|
81
|
-
(isOpen: boolean) => {
|
|
82
|
-
setOpen(isOpen)
|
|
83
|
-
if (!isOpen && isEditing) {
|
|
84
|
-
meta?.onCellEditingStop?.()
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
[isEditing, meta],
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
const onWrapperKeyDown = React.useCallback(
|
|
91
|
-
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
92
|
-
if (isEditing) {
|
|
93
|
-
if (event.key === 'Escape') {
|
|
94
|
-
event.preventDefault()
|
|
95
|
-
setValue(parseToLocalDate(initialValue))
|
|
96
|
-
setOpen(false)
|
|
97
|
-
} else if (event.key === 'Tab') {
|
|
98
|
-
event.preventDefault()
|
|
99
|
-
setOpen(false)
|
|
100
|
-
meta?.onCellEditingStop?.({
|
|
101
|
-
direction: event.shiftKey ? 'left' : 'right',
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
[isEditing, initialValue, meta],
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
React.useEffect(() => {
|
|
110
|
-
setOpen(isEditing)
|
|
111
|
-
}, [isEditing])
|
|
112
|
-
|
|
113
|
-
React.useEffect(() => {
|
|
114
|
-
if (isFocused && !isEditing && !meta?.searchOpen && !meta?.isScrolling && containerRef.current) {
|
|
115
|
-
containerRef.current.focus()
|
|
116
|
-
}
|
|
117
|
-
}, [isFocused, isEditing, meta?.searchOpen, meta?.isScrolling])
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<DataGridCellWrapper
|
|
121
|
-
ref={containerRef}
|
|
122
|
-
cell={cell}
|
|
123
|
-
table={table}
|
|
124
|
-
rowIndex={rowIndex}
|
|
125
|
-
columnId={columnId}
|
|
126
|
-
isEditing={isEditing}
|
|
127
|
-
isFocused={isFocused}
|
|
128
|
-
isSelected={isSelected}
|
|
129
|
-
onKeyDown={onWrapperKeyDown}
|
|
130
|
-
>
|
|
131
|
-
<Popover open={open} onOpenChange={onOpenChange}>
|
|
132
|
-
<PopoverAnchor asChild>
|
|
133
|
-
<span
|
|
134
|
-
data-slot="grid-cell-content"
|
|
135
|
-
className={cn('tabular-nums', (cell.column.columnDef.meta as any)?.align ?? 'text-right')}
|
|
136
|
-
>
|
|
137
|
-
{value?.toLocaleDateString() ?? ''}
|
|
138
|
-
</span>
|
|
139
|
-
</PopoverAnchor>
|
|
140
|
-
{isEditing && (
|
|
141
|
-
<PopoverContent data-grid-cell-editor="" align="start" sideOffset={10} className="w-auto p-0">
|
|
142
|
-
<Calendar
|
|
143
|
-
showYearNavigation={true}
|
|
144
|
-
autoFocus
|
|
145
|
-
captionLayout="dropdown"
|
|
146
|
-
mode="single"
|
|
147
|
-
className="rounded-md border border-border shadow-sm"
|
|
148
|
-
defaultMonth={value}
|
|
149
|
-
selected={value}
|
|
150
|
-
onSelect={onDateSelect}
|
|
151
|
-
/>
|
|
152
|
-
</PopoverContent>
|
|
153
|
-
)}
|
|
154
|
-
</Popover>
|
|
155
|
-
</DataGridCellWrapper>
|
|
156
|
-
)
|
|
157
|
-
}
|