@dyrected/admin 2.4.0 → 2.4.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.
Files changed (170) hide show
  1. package/dist/App.d.ts +1 -0
  2. package/dist/admin.css +2 -0
  3. package/dist/components/auth/auth-gate.d.ts +13 -0
  4. package/dist/components/error-boundary.d.ts +16 -0
  5. package/dist/components/forms/field-renderer.d.ts +22 -0
  6. package/dist/components/forms/fields/block-builder.d.ts +9 -0
  7. package/dist/components/forms/fields/date-picker.d.ts +8 -0
  8. package/dist/components/forms/fields/json-editor.d.ts +8 -0
  9. package/dist/components/forms/fields/media-picker.d.ts +12 -0
  10. package/dist/components/forms/fields/multi-select.d.ts +19 -0
  11. package/dist/components/forms/fields/radio-field.d.ts +8 -0
  12. package/dist/components/forms/fields/relationship-picker.d.ts +10 -0
  13. package/dist/components/forms/fields/rich-text-editor.d.ts +9 -0
  14. package/dist/components/forms/fields/select-field.d.ts +8 -0
  15. package/dist/components/forms/fields/switch-field.d.ts +6 -0
  16. package/dist/components/forms/fields/text-area-field.d.ts +8 -0
  17. package/dist/components/forms/fields/text-field.d.ts +8 -0
  18. package/dist/components/forms/form-engine.d.ts +14 -0
  19. package/dist/components/forms/form-field-renderer.d.ts +20 -0
  20. package/dist/components/forms/utils.d.ts +11 -0
  21. package/dist/components/layout/admin-shell.d.ts +5 -0
  22. package/dist/components/layout/branding-provider.d.ts +4 -0
  23. package/dist/components/live-preview/LivePreviewPane.d.ts +7 -0
  24. package/dist/components/media/focal-point-picker.d.ts +12 -0
  25. package/dist/components/media/media-card.d.ts +8 -0
  26. package/dist/components/media/media-grid.d.ts +8 -0
  27. package/dist/components/media/media-library-dialog.d.ts +11 -0
  28. package/dist/components/ui/aspect-ratio.d.ts +3 -0
  29. package/dist/components/ui/badge.d.ts +9 -0
  30. package/dist/components/ui/button.d.ts +11 -0
  31. package/dist/components/ui/calendar.d.ts +8 -0
  32. package/dist/components/ui/card.d.ts +8 -0
  33. package/dist/components/ui/checkbox.d.ts +4 -0
  34. package/dist/components/ui/command.d.ts +80 -0
  35. package/dist/components/ui/data-table.d.ts +14 -0
  36. package/dist/components/ui/dialog.d.ts +19 -0
  37. package/dist/components/ui/dropdown-menu.d.ts +27 -0
  38. package/dist/components/ui/form.d.ts +23 -0
  39. package/dist/components/ui/input.d.ts +3 -0
  40. package/dist/components/ui/label.d.ts +5 -0
  41. package/dist/components/ui/page-header.d.ts +10 -0
  42. package/dist/components/ui/pagination.d.ts +11 -0
  43. package/dist/components/ui/popover.d.ts +6 -0
  44. package/dist/components/ui/progress.d.ts +4 -0
  45. package/dist/components/ui/radio-group.d.ts +5 -0
  46. package/dist/components/ui/render-cell.d.ts +8 -0
  47. package/dist/components/ui/scroll-area.d.ts +5 -0
  48. package/dist/components/ui/select.d.ts +13 -0
  49. package/dist/components/ui/separator.d.ts +4 -0
  50. package/dist/components/ui/sheet.d.ts +25 -0
  51. package/dist/components/ui/sidebar.d.ts +65 -0
  52. package/dist/components/ui/skeleton.d.ts +2 -0
  53. package/dist/components/ui/sonner.d.ts +4 -0
  54. package/dist/components/ui/switch.d.ts +4 -0
  55. package/dist/components/ui/table.d.ts +10 -0
  56. package/dist/components/ui/tabs.d.ts +7 -0
  57. package/dist/components/ui/textarea.d.ts +3 -0
  58. package/dist/components/ui/toggle.d.ts +12 -0
  59. package/dist/components/ui/tooltip.d.ts +7 -0
  60. package/dist/hooks/use-mobile.d.ts +1 -0
  61. package/dist/hooks/use-preferences.d.ts +6 -0
  62. package/dist/index.d.ts +38 -0
  63. package/dist/index.mjs +69091 -0
  64. package/dist/lib/utils.d.ts +3 -0
  65. package/dist/main.d.ts +0 -0
  66. package/dist/pages/auth/first-user-page.d.ts +4 -0
  67. package/dist/pages/auth/login-page.d.ts +4 -0
  68. package/dist/pages/collections/edit-page.d.ts +1 -0
  69. package/dist/pages/collections/list-page.d.ts +5 -0
  70. package/dist/pages/dashboard/dashboard.d.ts +1 -0
  71. package/dist/pages/globals/editor-page.d.ts +1 -0
  72. package/dist/pages/media/media-page.d.ts +4 -0
  73. package/dist/pages/setup/setup-prompt.d.ts +6 -0
  74. package/dist/providers/dyrected-provider.d.ts +29 -0
  75. package/dist/providers/query-provider.d.ts +3 -0
  76. package/package.json +6 -3
  77. package/CHANGELOG.md +0 -153
  78. package/components.json +0 -17
  79. package/eslint.config.js +0 -22
  80. package/index.html +0 -13
  81. package/postcss.config.js +0 -6
  82. package/scripts/prefix-tailwind-precision.py +0 -98
  83. package/scripts/prefix-tailwind.py +0 -67
  84. package/src/App.css +0 -184
  85. package/src/App.tsx +0 -25
  86. package/src/assets/dyrected.svg +0 -155
  87. package/src/assets/hero.png +0 -0
  88. package/src/assets/react.svg +0 -1
  89. package/src/assets/vite.svg +0 -1
  90. package/src/components/auth/auth-gate.tsx +0 -64
  91. package/src/components/error-boundary.tsx +0 -45
  92. package/src/components/forms/field-renderer.tsx +0 -111
  93. package/src/components/forms/fields/block-builder.tsx +0 -213
  94. package/src/components/forms/fields/date-picker.tsx +0 -60
  95. package/src/components/forms/fields/json-editor.tsx +0 -62
  96. package/src/components/forms/fields/media-picker.tsx +0 -286
  97. package/src/components/forms/fields/multi-select.tsx +0 -145
  98. package/src/components/forms/fields/radio-field.tsx +0 -51
  99. package/src/components/forms/fields/relationship-picker.tsx +0 -143
  100. package/src/components/forms/fields/rich-text-editor.tsx +0 -224
  101. package/src/components/forms/fields/select-field.tsx +0 -35
  102. package/src/components/forms/fields/switch-field.tsx +0 -16
  103. package/src/components/forms/fields/text-area-field.tsx +0 -15
  104. package/src/components/forms/fields/text-field.tsx +0 -24
  105. package/src/components/forms/form-engine.tsx +0 -87
  106. package/src/components/forms/form-field-renderer.tsx +0 -269
  107. package/src/components/forms/utils.ts +0 -97
  108. package/src/components/layout/admin-shell.tsx +0 -479
  109. package/src/components/layout/branding-provider.tsx +0 -112
  110. package/src/components/live-preview/LivePreviewPane.tsx +0 -128
  111. package/src/components/media/focal-point-picker.tsx +0 -66
  112. package/src/components/media/media-card.tsx +0 -44
  113. package/src/components/media/media-grid.tsx +0 -32
  114. package/src/components/media/media-library-dialog.tsx +0 -465
  115. package/src/components/ui/aspect-ratio.tsx +0 -7
  116. package/src/components/ui/badge.tsx +0 -36
  117. package/src/components/ui/button.tsx +0 -56
  118. package/src/components/ui/calendar.tsx +0 -214
  119. package/src/components/ui/card.tsx +0 -79
  120. package/src/components/ui/checkbox.tsx +0 -28
  121. package/src/components/ui/command.tsx +0 -151
  122. package/src/components/ui/data-table.tsx +0 -219
  123. package/src/components/ui/dialog.tsx +0 -122
  124. package/src/components/ui/dropdown-menu.tsx +0 -200
  125. package/src/components/ui/form.tsx +0 -178
  126. package/src/components/ui/input.tsx +0 -24
  127. package/src/components/ui/label.tsx +0 -24
  128. package/src/components/ui/page-header.tsx +0 -30
  129. package/src/components/ui/pagination.tsx +0 -57
  130. package/src/components/ui/popover.tsx +0 -29
  131. package/src/components/ui/progress.tsx +0 -26
  132. package/src/components/ui/radio-group.tsx +0 -42
  133. package/src/components/ui/render-cell.tsx +0 -110
  134. package/src/components/ui/scroll-area.tsx +0 -46
  135. package/src/components/ui/select.tsx +0 -160
  136. package/src/components/ui/separator.tsx +0 -29
  137. package/src/components/ui/sheet.tsx +0 -140
  138. package/src/components/ui/sidebar.tsx +0 -771
  139. package/src/components/ui/skeleton.tsx +0 -15
  140. package/src/components/ui/sonner.tsx +0 -27
  141. package/src/components/ui/switch.tsx +0 -27
  142. package/src/components/ui/table.tsx +0 -117
  143. package/src/components/ui/tabs.tsx +0 -53
  144. package/src/components/ui/textarea.tsx +0 -22
  145. package/src/components/ui/toggle.tsx +0 -43
  146. package/src/components/ui/tooltip.tsx +0 -28
  147. package/src/hooks/use-mobile.tsx +0 -19
  148. package/src/hooks/use-preferences.ts +0 -56
  149. package/src/index.css +0 -111
  150. package/src/index.tsx +0 -198
  151. package/src/lib/utils.ts +0 -36
  152. package/src/main.tsx +0 -10
  153. package/src/pages/auth/first-user-page.tsx +0 -115
  154. package/src/pages/auth/login-page.tsx +0 -91
  155. package/src/pages/collections/edit-page.tsx +0 -280
  156. package/src/pages/collections/list-page.tsx +0 -343
  157. package/src/pages/dashboard/dashboard.tsx +0 -150
  158. package/src/pages/globals/editor-page.tsx +0 -122
  159. package/src/pages/media/media-page.tsx +0 -564
  160. package/src/pages/setup/setup-prompt.tsx +0 -181
  161. package/src/providers/dyrected-provider.tsx +0 -122
  162. package/src/providers/query-provider.tsx +0 -19
  163. package/src/types/jexl.d.ts +0 -11
  164. package/tailwind.config.ts +0 -103
  165. package/tsconfig.app.json +0 -28
  166. package/tsconfig.json +0 -12
  167. package/tsconfig.node.json +0 -25
  168. package/vite.config.ts +0 -39
  169. /package/{public → dist}/favicon.svg +0 -0
  170. /package/{public → dist}/icons.svg +0 -0
@@ -1,214 +0,0 @@
1
- import * as React from "react"
2
- import {
3
- ChevronDownIcon,
4
- ChevronLeftIcon,
5
- ChevronRightIcon,
6
- } from "lucide-react"
7
- import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"
8
-
9
- import { cn } from "../../lib/utils"
10
- import { Button, buttonVariants } from "../../components/ui/button"
11
-
12
- function Calendar({
13
- className,
14
- classNames,
15
- showOutsideDays = true,
16
- captionLayout = "label",
17
- buttonVariant = "ghost",
18
- formatters,
19
- components,
20
- ...props
21
- }: React.ComponentProps<typeof DayPicker> & {
22
- buttonVariant?: React.ComponentProps<typeof Button>["variant"]
23
- }) {
24
- const defaultClassNames = getDefaultClassNames()
25
-
26
- return (
27
- <DayPicker
28
- showOutsideDays={showOutsideDays}
29
- className={cn(
30
- "dy-bg-white dy-group/calendar dy-p-4 [--cell-size:dy-2.25rem] dy-shadow-sm dy-rounded-xl dy-border dy-border-border/40",
31
- String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
32
- String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
33
- className
34
- )}
35
- captionLayout={captionLayout}
36
- formatters={{
37
- formatMonthDropdown: (date) =>
38
- date.toLocaleString("default", { month: "short" }),
39
- ...formatters,
40
- }}
41
- classNames={{
42
- root: cn("dy-w-fit", defaultClassNames.root),
43
- months: cn(
44
- "dy-relative dy-flex dy-flex-col dy-gap-4 md:dy-flex-row",
45
- defaultClassNames.months
46
- ),
47
- month: cn("dy-flex dy-w-full dy-flex-col dy-gap-4", defaultClassNames.month),
48
- nav: cn(
49
- "dy-absolute dy-inset-x-0 dy-top-0 dy-flex dy-w-full dy-items-center dy-justify-between dy-gap-1",
50
- defaultClassNames.nav
51
- ),
52
- button_previous: cn(
53
- buttonVariants({ variant: buttonVariant }),
54
- "h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",
55
- defaultClassNames.button_previous
56
- ),
57
- button_next: cn(
58
- buttonVariants({ variant: buttonVariant }),
59
- "h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",
60
- defaultClassNames.button_next
61
- ),
62
- month_caption: cn(
63
- "dy-flex dy-h-[--cell-size] dy-w-full dy-items-center dy-justify-center dy-px-[--cell-size] dy-mb-4",
64
- defaultClassNames.month_caption
65
- ),
66
- dropdowns: cn(
67
- "dy-flex dy-h-[--cell-size] dy-w-full dy-items-center dy-justify-center dy-gap-1.5 dy-text-sm dy-font-medium",
68
- defaultClassNames.dropdowns
69
- ),
70
- dropdown_root: cn(
71
- "has-focus:dy-border-ring dy-border-input dy-shadow-xs has-focus:dy-ring-ring/50 has-focus:dy-ring-[3px] dy-relative dy-rounded-md dy-border",
72
- defaultClassNames.dropdown_root
73
- ),
74
- dropdown: cn(
75
- "dy-bg-popover dy-absolute dy-inset-0 dy-opacity-0",
76
- defaultClassNames.dropdown
77
- ),
78
- caption_label: cn(
79
- "dy-select-none dy-font-semibold dy-text-lg dy-tracking-tight",
80
- captionLayout === "label"
81
- ? "dy-text-sm"
82
- : "[&>svg]:dy-text-muted-foreground dy-flex dy-h-8 dy-items-center dy-gap-1 dy-rounded-md dy-pl-2 dy-pr-1 dy-text-sm [&>svg]:dy-size-3.5",
83
- defaultClassNames.caption_label
84
- ),
85
- table: "w-full border-collapse",
86
- weekdays: cn("dy-grid dy-grid-cols-7 dy-mb-2", defaultClassNames.weekdays),
87
- weekday: cn(
88
- "dy-text-muted-foreground dy-text-center dy-select-none dy-text-[0.8rem] dy-font-medium",
89
- defaultClassNames.weekday
90
- ),
91
- week: cn("dy-grid dy-grid-cols-7 dy-w-full dy-mt-1", defaultClassNames.week),
92
- week_number_header: cn(
93
- "dy-w-[--cell-size] dy-select-none",
94
- defaultClassNames.week_number_header
95
- ),
96
- week_number: cn(
97
- "dy-text-muted-foreground dy-select-none dy-text-[0.8rem]",
98
- defaultClassNames.week_number
99
- ),
100
- day: cn(
101
- "dy-group/day dy-relative dy-flex dy-items-center dy-justify-center dy-h-[--cell-size] dy-w-full dy-select-none dy-p-0 dy-text-center",
102
- defaultClassNames.day
103
- ),
104
- range_start: cn(
105
- "dy-bg-primary dy-text-primary-foreground dy-rounded-l-md",
106
- defaultClassNames.range_start
107
- ),
108
- range_middle: cn("dy-bg-accent dy-text-accent-foreground dy-rounded-none", defaultClassNames.range_middle),
109
- range_end: cn("dy-bg-primary dy-text-primary-foreground dy-rounded-r-md", defaultClassNames.range_end),
110
- today: cn(
111
- "dy-bg-accent/50 dy-text-accent-foreground dy-font-bold dy-rounded-md",
112
- defaultClassNames.today
113
- ),
114
- outside: cn(
115
- "dy-text-muted-foreground/40 aria-selected:dy-text-muted-foreground/40 dy-opacity-50",
116
- defaultClassNames.outside
117
- ),
118
- disabled: cn(
119
- "dy-text-muted-foreground dy-opacity-50",
120
- defaultClassNames.disabled
121
- ),
122
- hidden: cn("dy-invisible", defaultClassNames.hidden),
123
- ...classNames,
124
- }}
125
- components={{
126
- Root: ({ className, rootRef, ...props }) => {
127
- return (
128
- <div
129
- data-slot="calendar"
130
- ref={rootRef}
131
- className={cn(className)}
132
- {...props}
133
- />
134
- )
135
- },
136
- Chevron: ({ className, orientation, ...props }) => {
137
- if (orientation === "left") {
138
- return (
139
- <ChevronLeftIcon className={cn("dy-size-4", className)} {...props} />
140
- )
141
- }
142
-
143
- if (orientation === "right") {
144
- return (
145
- <ChevronRightIcon
146
- className={cn("dy-size-4", className)}
147
- {...props}
148
- />
149
- )
150
- }
151
-
152
- return (
153
- <ChevronDownIcon className={cn("dy-size-4", className)} {...props} />
154
- )
155
- },
156
- DayButton: CalendarDayButton,
157
- WeekNumber: ({ children, ...props }) => {
158
- return (
159
- <td {...props}>
160
- <div className="dy-flex dy-size-[--cell-size] dy-items-center dy-justify-center dy-text-center">
161
- {children}
162
- </div>
163
- </td>
164
- )
165
- },
166
- ...components,
167
- }}
168
- {...props}
169
- />
170
- )
171
- }
172
-
173
- function CalendarDayButton({
174
- className,
175
- day,
176
- modifiers,
177
- ...props
178
- }: React.ComponentProps<typeof DayButton>) {
179
- const ref = React.useRef<HTMLButtonElement>(null)
180
- React.useEffect(() => {
181
- if (modifiers.focused) ref.current?.focus()
182
- }, [modifiers.focused])
183
-
184
- return (
185
- <Button
186
- ref={ref}
187
- variant="ghost"
188
- size="icon"
189
- data-day={day.date.toLocaleDateString()}
190
- data-selected-single={
191
- modifiers.selected &&
192
- !modifiers.range_start &&
193
- !modifiers.range_end &&
194
- !modifiers.range_middle
195
- }
196
- data-range-start={modifiers.range_start}
197
- data-range-end={modifiers.range_end}
198
- data-range-middle={modifiers.range_middle}
199
- className={cn(
200
- "dy-flex dy-items-center dy-justify-center dy-h-[--cell-size] dy-w-full dy-min-w-[--cell-size] dy-p-0 dy-font-normal dy-transition-all",
201
- "hover:dy-bg-accent hover:dy-text-accent-foreground",
202
- "data-[selected-single=true]:dy-bg-primary data-[selected-single=true]:dy-text-primary-foreground data-[selected-single=true]:dy-rounded-full data-[selected-single=true]:dy-shadow-lg",
203
- "data-[range-middle=true]:dy-bg-accent data-[range-middle=true]:dy-text-accent-foreground data-[range-middle=true]:dy-rounded-none",
204
- "data-[range-start=true]:dy-bg-primary data-[range-start=true]:dy-text-primary-foreground data-[range-start=true]:dy-rounded-l-md",
205
- "data-[range-end=true]:dy-bg-primary data-[range-end=true]:dy-text-primary-foreground data-[range-end=true]:dy-rounded-r-md",
206
- "dy-group-data-[focused=true]/day:dy-ring-2 dy-group-data-[focused=true]/day:dy-ring-ring dy-group-data-[focused=true]/day:dy-relative dy-group-data-[focused=true]/day:dy-z-10",
207
- className
208
- )}
209
- {...props}
210
- />
211
- )
212
- }
213
-
214
- export { Calendar, CalendarDayButton }
@@ -1,79 +0,0 @@
1
- import * as React from "react"
2
-
3
- import { cn } from "../../lib/utils"
4
-
5
- const Card = React.forwardRef<
6
- HTMLDivElement,
7
- React.HTMLAttributes<HTMLDivElement>
8
- >(({ className, ...props }, ref) => (
9
- <div
10
- ref={ref}
11
- className={cn(
12
- "dy-rounded-lg dy-border dy-bg-card dy-text-card-foreground dy-shadow-sm",
13
- className
14
- )}
15
- {...props}
16
- />
17
- ))
18
- Card.displayName = "Card"
19
-
20
- const CardHeader = React.forwardRef<
21
- HTMLDivElement,
22
- React.HTMLAttributes<HTMLDivElement>
23
- >(({ className, ...props }, ref) => (
24
- <div
25
- ref={ref}
26
- className={cn("dy-flex dy-flex-col dy-space-y-1.5 dy-p-6", className)}
27
- {...props}
28
- />
29
- ))
30
- CardHeader.displayName = "CardHeader"
31
-
32
- const CardTitle = React.forwardRef<
33
- HTMLDivElement,
34
- React.HTMLAttributes<HTMLDivElement>
35
- >(({ className, ...props }, ref) => (
36
- <div
37
- ref={ref}
38
- className={cn(
39
- "dy-text-2xl dy-font-semibold dy-leading-none dy-tracking-tight",
40
- className
41
- )}
42
- {...props}
43
- />
44
- ))
45
- CardTitle.displayName = "CardTitle"
46
-
47
- const CardDescription = React.forwardRef<
48
- HTMLDivElement,
49
- React.HTMLAttributes<HTMLDivElement>
50
- >(({ className, ...props }, ref) => (
51
- <div
52
- ref={ref}
53
- className={cn("dy-text-sm dy-text-muted-foreground", className)}
54
- {...props}
55
- />
56
- ))
57
- CardDescription.displayName = "CardDescription"
58
-
59
- const CardContent = React.forwardRef<
60
- HTMLDivElement,
61
- React.HTMLAttributes<HTMLDivElement>
62
- >(({ className, ...props }, ref) => (
63
- <div ref={ref} className={cn("dy-p-6 dy-pt-0", className)} {...props} />
64
- ))
65
- CardContent.displayName = "CardContent"
66
-
67
- const CardFooter = React.forwardRef<
68
- HTMLDivElement,
69
- React.HTMLAttributes<HTMLDivElement>
70
- >(({ className, ...props }, ref) => (
71
- <div
72
- ref={ref}
73
- className={cn("dy-flex dy-items-center dy-p-6 dy-pt-0", className)}
74
- {...props}
75
- />
76
- ))
77
- CardFooter.displayName = "CardFooter"
78
-
79
- export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
@@ -1,28 +0,0 @@
1
- import * as React from "react"
2
- import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
3
- import { Check } from "lucide-react"
4
-
5
- import { cn } from "../../lib/utils"
6
-
7
- const Checkbox = React.forwardRef<
8
- React.ElementRef<typeof CheckboxPrimitive.Root>,
9
- React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
10
- >(({ className, ...props }, ref) => (
11
- <CheckboxPrimitive.Root
12
- ref={ref}
13
- className={cn(
14
- "dy-grid dy-place-content-center dy-peer dy-h-4 dy-w-4 dy-shrink-0 dy-rounded-sm dy-border dy-border-primary dy-ring-offset-background focus-visible:dy-outline-none focus-visible:dy-ring-2 focus-visible:dy-ring-ring focus-visible:dy-ring-offset-2 disabled:dy-cursor-not-allowed disabled:dy-opacity-50 data-[state=checked]:dy-bg-primary data-[state=checked]:dy-text-primary-foreground",
15
- className
16
- )}
17
- {...props}
18
- >
19
- <CheckboxPrimitive.Indicator
20
- className={cn("dy-grid dy-place-content-center dy-text-current")}
21
- >
22
- <Check className="dy-h-4 dy-w-4" />
23
- </CheckboxPrimitive.Indicator>
24
- </CheckboxPrimitive.Root>
25
- ))
26
- Checkbox.displayName = CheckboxPrimitive.Root.displayName
27
-
28
- export { Checkbox }
@@ -1,151 +0,0 @@
1
- import * as React from "react"
2
- import { type DialogProps } from "@radix-ui/react-dialog"
3
- import { Command as CommandPrimitive } from "cmdk"
4
- import { Search } from "lucide-react"
5
-
6
- import { cn } from "../../lib/utils"
7
- import { Dialog, DialogContent } from "../../components/ui/dialog"
8
-
9
- const Command = React.forwardRef<
10
- React.ElementRef<typeof CommandPrimitive>,
11
- React.ComponentPropsWithoutRef<typeof CommandPrimitive>
12
- >(({ className, ...props }, ref) => (
13
- <CommandPrimitive
14
- ref={ref}
15
- className={cn(
16
- "dy-flex dy-h-full dy-w-full dy-flex-col dy-overflow-hidden dy-rounded-md dy-bg-white dy-text-popover-foreground",
17
- className
18
- )}
19
- {...props}
20
- />
21
- ))
22
- Command.displayName = CommandPrimitive.displayName
23
-
24
- const CommandDialog = ({ children, ...props }: DialogProps) => {
25
- return (
26
- <Dialog {...props}>
27
- <DialogContent className="dy-overflow-hidden dy-p-0 dy-shadow-lg">
28
- <Command className="[&_[cmdk-group-heading]]:dy-px-2 [&_[cmdk-group-heading]]:dy-font-medium [&_[cmdk-group-heading]]:dy-text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:dy-pt-0 [&_[cmdk-group]]:dy-px-2 [&_[cmdk-input-wrapper]_svg]:dy-h-5 [&_[cmdk-input-wrapper]_svg]:dy-w-5 [&_[cmdk-input]]:dy-h-12 [&_[cmdk-item]]:dy-px-2 [&_[cmdk-item]]:dy-py-3 [&_[cmdk-item]_svg]:dy-h-5 [&_[cmdk-item]_svg]:dy-w-5">
29
- {children}
30
- </Command>
31
- </DialogContent>
32
- </Dialog>
33
- )
34
- }
35
-
36
- const CommandInput = React.forwardRef<
37
- React.ElementRef<typeof CommandPrimitive.Input>,
38
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
39
- >(({ className, ...props }, ref) => (
40
- <div className="dy-flex dy-items-center dy-border-b dy-px-3" cmdk-input-wrapper="">
41
- <Search className="dy-mr-2 dy-h-4 dy-w-4 dy-shrink-0 dy-opacity-50" />
42
- <CommandPrimitive.Input
43
- ref={ref}
44
- className={cn(
45
- "dy-flex dy-h-11 dy-w-full dy-rounded-md dy-bg-transparent dy-py-3 dy-text-sm dy-outline-none placeholder:dy-text-muted-foreground disabled:dy-cursor-not-allowed disabled:dy-opacity-50",
46
- className
47
- )}
48
- {...props}
49
- />
50
- </div>
51
- ))
52
-
53
- CommandInput.displayName = CommandPrimitive.Input.displayName
54
-
55
- const CommandList = React.forwardRef<
56
- React.ElementRef<typeof CommandPrimitive.List>,
57
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
58
- >(({ className, ...props }, ref) => (
59
- <CommandPrimitive.List
60
- ref={ref}
61
- className={cn("dy-max-h-[300px] dy-overflow-y-auto dy-overflow-x-hidden", className)}
62
- {...props}
63
- />
64
- ))
65
-
66
- CommandList.displayName = CommandPrimitive.List.displayName
67
-
68
- const CommandEmpty = React.forwardRef<
69
- React.ElementRef<typeof CommandPrimitive.Empty>,
70
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
71
- >((props, ref) => (
72
- <CommandPrimitive.Empty
73
- ref={ref}
74
- className="dy-py-6 dy-text-center dy-text-sm"
75
- {...props}
76
- />
77
- ))
78
-
79
- CommandEmpty.displayName = CommandPrimitive.Empty.displayName
80
-
81
- const CommandGroup = React.forwardRef<
82
- React.ElementRef<typeof CommandPrimitive.Group>,
83
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
84
- >(({ className, ...props }, ref) => (
85
- <CommandPrimitive.Group
86
- ref={ref}
87
- className={cn(
88
- "dy-overflow-hidden dy-p-1 dy-text-foreground [&_[cmdk-group-heading]]:dy-px-2 [&_[cmdk-group-heading]]:dy-py-1.5 [&_[cmdk-group-heading]]:dy-text-xs [&_[cmdk-group-heading]]:dy-font-medium [&_[cmdk-group-heading]]:dy-text-muted-foreground",
89
- className
90
- )}
91
- {...props}
92
- />
93
- ))
94
-
95
- CommandGroup.displayName = CommandPrimitive.Group.displayName
96
-
97
- const CommandSeparator = React.forwardRef<
98
- React.ElementRef<typeof CommandPrimitive.Separator>,
99
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
100
- >(({ className, ...props }, ref) => (
101
- <CommandPrimitive.Separator
102
- ref={ref}
103
- className={cn("dy--mx-1 dy-h-px dy-bg-border", className)}
104
- {...props}
105
- />
106
- ))
107
- CommandSeparator.displayName = CommandPrimitive.Separator.displayName
108
-
109
- const CommandItem = React.forwardRef<
110
- React.ElementRef<typeof CommandPrimitive.Item>,
111
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
112
- >(({ className, ...props }, ref) => (
113
- <CommandPrimitive.Item
114
- ref={ref}
115
- className={cn(
116
- "dy-relative dy-flex dy-cursor-default dy-gap-2 dy-select-none dy-items-center dy-rounded-sm dy-px-2 dy-py-1.5 dy-text-sm dy-outline-none data-[disabled=true]:dy-pointer-events-none data-[selected='true']:dy-bg-accent data-[selected=true]:dy-text-accent-foreground data-[disabled=true]:dy-opacity-50 [&_svg]:dy-pointer-events-none [&_svg]:dy-size-4 [&_svg]:dy-shrink-0",
117
- className
118
- )}
119
- {...props}
120
- />
121
- ))
122
-
123
- CommandItem.displayName = CommandPrimitive.Item.displayName
124
-
125
- const CommandShortcut = ({
126
- className,
127
- ...props
128
- }: React.HTMLAttributes<HTMLSpanElement>) => {
129
- return (
130
- <span
131
- className={cn(
132
- "dy-ml-auto dy-text-xs dy-tracking-widest dy-text-muted-foreground",
133
- className
134
- )}
135
- {...props}
136
- />
137
- )
138
- }
139
- CommandShortcut.displayName = "CommandShortcut"
140
-
141
- export {
142
- Command,
143
- CommandDialog,
144
- CommandInput,
145
- CommandList,
146
- CommandEmpty,
147
- CommandGroup,
148
- CommandItem,
149
- CommandShortcut,
150
- CommandSeparator,
151
- }
@@ -1,219 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import {
5
- type ColumnDef,
6
- type ColumnFiltersState,
7
- type SortingState,
8
- type VisibilityState,
9
- flexRender,
10
- getCoreRowModel,
11
- getFilteredRowModel,
12
- getPaginationRowModel,
13
- getSortedRowModel,
14
- useReactTable,
15
- } from "@tanstack/react-table"
16
-
17
- import {
18
- Table,
19
- TableBody,
20
- TableCell,
21
- TableHead,
22
- TableHeader,
23
- TableRow,
24
- } from "../../components/ui/table"
25
-
26
- import { Button } from "../../components/ui/button"
27
- import { Input } from "../../components/ui/input"
28
- import {
29
- DropdownMenu,
30
- DropdownMenuCheckboxItem,
31
- DropdownMenuContent,
32
- DropdownMenuTrigger,
33
- } from "../../components/ui/dropdown-menu"
34
- import { ChevronLeft, ChevronRight, Settings2 } from "lucide-react"
35
- import { usePreferences } from "../../hooks/use-preferences"
36
-
37
- interface DataTableProps<TData, TValue> {
38
- columns: ColumnDef<TData, TValue>[]
39
- data: TData[]
40
- searchKey?: string
41
- rowSelection?: any
42
- onRowSelectionChange?: any
43
- bulkActions?: (selectedIds: string[]) => React.ReactNode
44
- persistenceKey?: string
45
- initialColumnVisibility?: VisibilityState
46
- }
47
-
48
- export function DataTable<TData, TValue>({
49
- columns,
50
- data,
51
- searchKey,
52
- rowSelection: externalRowSelection,
53
- onRowSelectionChange,
54
- bulkActions,
55
- persistenceKey,
56
- initialColumnVisibility = {},
57
- }: DataTableProps<TData, TValue>) {
58
- const [sorting, setSorting] = React.useState<SortingState>([])
59
- const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
60
- []
61
- )
62
- const [columnVisibility, setColumnVisibility] = usePreferences<VisibilityState>(
63
- persistenceKey ? `visibility_${persistenceKey}` : "temp_visibility",
64
- initialColumnVisibility
65
- )
66
- const [internalRowSelection, setInternalRowSelection] = React.useState({})
67
-
68
- const rowSelection = externalRowSelection || internalRowSelection
69
- const setRowSelection = onRowSelectionChange || setInternalRowSelection
70
-
71
- const table = useReactTable({
72
- data,
73
- columns,
74
- onSortingChange: setSorting,
75
- onColumnFiltersChange: setColumnFilters,
76
- getCoreRowModel: getCoreRowModel(),
77
- getPaginationRowModel: getPaginationRowModel(),
78
- getSortedRowModel: getSortedRowModel(),
79
- getFilteredRowModel: getFilteredRowModel(),
80
- onColumnVisibilityChange: setColumnVisibility,
81
- onRowSelectionChange: setRowSelection,
82
- state: {
83
- sorting,
84
- columnFilters,
85
- columnVisibility,
86
- rowSelection,
87
- },
88
- })
89
-
90
- return (
91
- <div className="dy-w-full dy-space-y-4">
92
- <div className="dy-flex dy-items-center dy-gap-4">
93
- {searchKey && (
94
- <Input
95
- placeholder={`Search ${searchKey}...`}
96
- value={(table.getColumn(searchKey)?.getFilterValue() as string) ?? ""}
97
- onChange={(event) =>
98
- table.getColumn(searchKey)?.setFilterValue(event.target.value)
99
- }
100
- className="dy-max-w-sm"
101
- />
102
- )}
103
- {bulkActions && table.getFilteredSelectedRowModel().rows.length > 0 && (
104
- <div className="dy-flex dy-items-center dy-gap-2 dy-animate-in dy-slide-in-from-left-2">
105
- {bulkActions(
106
- table
107
- .getFilteredSelectedRowModel()
108
- .rows.map((r) => (r.original as any).id)
109
- )}
110
- </div>
111
- )}
112
- <DropdownMenu>
113
- <DropdownMenuTrigger asChild>
114
- <Button variant="outline" size="sm" className="dy-ml-auto dy-flex dy-h-8 dy-gap-2">
115
- <Settings2 className="dy-h-4 dy-w-4" />
116
- View
117
- </Button>
118
- </DropdownMenuTrigger>
119
- <DropdownMenuContent align="end">
120
- {table
121
- .getAllColumns()
122
- .filter((column) => column.getCanHide())
123
- .map((column) => {
124
- return (
125
- <DropdownMenuCheckboxItem
126
- key={column.id}
127
- className="dy-capitalize"
128
- checked={column.getIsVisible()}
129
- onCheckedChange={(value) => column.toggleVisibility(!!value)}
130
- >
131
- {column.id}
132
- </DropdownMenuCheckboxItem>
133
- )
134
- })}
135
- </DropdownMenuContent>
136
- </DropdownMenu>
137
- </div>
138
- <div className="dy-overflow-hidden">
139
- <Table>
140
- <TableHeader>
141
- {table.getHeaderGroups().map((headerGroup) => (
142
- <TableRow key={headerGroup.id}>
143
- {headerGroup.headers.map((header) => {
144
- return (
145
- <TableHead key={header.id}>
146
- {header.isPlaceholder
147
- ? null
148
- : flexRender(
149
- header.column.columnDef.header,
150
- header.getContext()
151
- )}
152
- </TableHead>
153
- )
154
- })}
155
- </TableRow>
156
- ))}
157
- </TableHeader>
158
- <TableBody className="dy-border-t dy-border-border/40">
159
- {table.getRowModel().rows?.length ? (
160
- table.getRowModel().rows.map((row) => (
161
- <TableRow
162
- key={row.id}
163
- data-state={row.getIsSelected() && "selected"}
164
- className="dy-border-none even:dy-bg-primary/[0.03] hover:dy-bg-primary/[0.06] dy-transition-colors dy-duration-200"
165
- >
166
- {row.getVisibleCells().map((cell) => (
167
- <TableCell key={cell.id} className="dy-py-4 dy-px-4 dy-border-none first:dy-pl-4 last:dy-pr-4">
168
- {flexRender(
169
- cell.column.columnDef.cell,
170
- cell.getContext()
171
- )}
172
- </TableCell>
173
- ))}
174
- </TableRow>
175
- ))
176
- ) : (
177
- <TableRow>
178
- <TableCell
179
- colSpan={columns.length}
180
- className="dy-h-24 dy-text-center"
181
- >
182
- No results.
183
- </TableCell>
184
- </TableRow>
185
- )}
186
- </TableBody>
187
- </Table>
188
- </div>
189
- <div className="dy-flex dy-items-center dy-justify-between dy-px-2">
190
- <div className="dy-flex-1 dy-text-sm dy-text-muted-foreground">
191
- {table.getFilteredSelectedRowModel().rows.length} of{" "}
192
- {table.getFilteredRowModel().rows.length} row(s) selected.
193
- </div>
194
- <div className="dy-flex dy-items-center dy-space-x-2">
195
- <Button
196
- variant="outline"
197
- size="sm"
198
- onClick={() => table.previousPage()}
199
- disabled={!table.getCanPreviousPage()}
200
- >
201
- <ChevronLeft className="dy-h-4 dy-w-4" />
202
- </Button>
203
- <span className="dy-text-sm dy-font-medium">
204
- Page {table.getState().pagination.pageIndex + 1} of{" "}
205
- {table.getPageCount()}
206
- </span>
207
- <Button
208
- variant="outline"
209
- size="sm"
210
- onClick={() => table.nextPage()}
211
- disabled={!table.getCanNextPage()}
212
- >
213
- <ChevronRight className="dy-h-4 dy-w-4" />
214
- </Button>
215
- </div>
216
- </div>
217
- </div>
218
- )
219
- }