@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.
Files changed (181) hide show
  1. package/dist/backend-core/backend.generator.js +4 -1
  2. package/dist/backend-core/backend.generator.js.map +1 -1
  3. package/dist/backend-core/generators/jest.config.generator.d.ts +2 -0
  4. package/dist/backend-core/{template/jest.config.ts → generators/jest.config.generator.js} +12 -8
  5. package/dist/backend-core/generators/jest.config.generator.js.map +1 -0
  6. package/dist/backend-core/generators/tsconfig.generator.d.ts +1 -1
  7. package/dist/backend-core/generators/tsconfig.generator.js +1 -9
  8. package/dist/backend-core/generators/tsconfig.generator.js.map +1 -1
  9. package/dist/backend-core/types.d.ts +2 -0
  10. package/dist/base/base.generator.js +12 -8
  11. package/dist/base/base.generator.js.map +1 -1
  12. package/dist/e2e/template/e2e/package.json +1 -1
  13. package/dist/e2e/template/e2e/specs/example.spec.ts +1 -1
  14. package/dist/e2e/template/e2e/specs/example.spec.ts-snapshots/Navigate-to-homepage-and-take-snapshot-1-chromium-linux.png +0 -0
  15. package/dist/frontend-core/frontend.generator.d.ts +0 -58
  16. package/dist/frontend-core/frontend.generator.js +9 -173
  17. package/dist/frontend-core/frontend.generator.js.map +1 -1
  18. package/dist/frontend-core/generators/tsconfig.generator.js +2 -0
  19. package/dist/frontend-core/generators/tsconfig.generator.js.map +1 -1
  20. package/dist/frontend-core/template/README.md +1 -1
  21. package/dist/frontend-core/template/src/components/admin/table-filter.tsx +1 -5
  22. package/dist/frontend-core/template/src/components/ui/color-mode-toggle/color-mode-toggle.tsx +10 -4
  23. package/dist/frontend-core/template/src/lib/query-client.ts +45 -4
  24. package/dist/frontend-core/template/src/pages/dashboard/dashboard.page.tsx +2 -3
  25. package/dist/frontend-core/template/src/pages/error/default-error.page.tsx +45 -12
  26. package/dist/frontend-core/template/src/pages/error/not-found-error.page.tsx +1 -1
  27. package/dist/frontend-core/template/src/styles/styles.css +13 -1
  28. package/dist/frontend-core/template/tsconfig.json +2 -0
  29. package/dist/frontend-core/types/component.d.ts +1 -1
  30. package/dist/frontend-forms/generators/discriminated-union/fields.generator.js +4 -6
  31. package/dist/frontend-forms/generators/discriminated-union/fields.generator.js.map +1 -1
  32. package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js +1 -1
  33. package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js.map +1 -1
  34. package/dist/frontend-forms/generators/enum/inputs.generator.js +1 -1
  35. package/dist/frontend-forms/generators/enum/inputs.generator.js.map +1 -1
  36. package/dist/frontend-forms/generators/model/forms.generator.js +8 -12
  37. package/dist/frontend-forms/generators/model/forms.generator.js.map +1 -1
  38. package/dist/frontend-forms/generators/model/inputs.generator.js +2 -6
  39. package/dist/frontend-forms/generators/model/inputs.generator.js.map +1 -1
  40. package/dist/frontend-forms/template/src/components/ui/field/field.tsx +1 -4
  41. package/dist/frontend-tables/generators/model-table.generator.js +1 -5
  42. package/dist/frontend-tables/generators/model-table.generator.js.map +1 -1
  43. package/package.json +4 -3
  44. package/dist/e2e/generators/package-json.generator.d.ts +0 -2
  45. package/dist/e2e/generators/package-json.generator.js +0 -29
  46. package/dist/e2e/generators/package-json.generator.js.map +0 -1
  47. package/dist/frontend-core/template/src/components/ui/accordion/accordion.stories.tsx +0 -47
  48. package/dist/frontend-core/template/src/components/ui/accordion/accordion.tsx +0 -52
  49. package/dist/frontend-core/template/src/components/ui/admin-sidebar/admin-sidebar.tsx +0 -195
  50. package/dist/frontend-core/template/src/components/ui/alert/alert.stories.tsx +0 -61
  51. package/dist/frontend-core/template/src/components/ui/alert/alert.tsx +0 -45
  52. package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.stories.tsx +0 -52
  53. package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.tsx +0 -105
  54. package/dist/frontend-core/template/src/components/ui/avatar/avatar.stories.tsx +0 -30
  55. package/dist/frontend-core/template/src/components/ui/avatar/avatar.tsx +0 -39
  56. package/dist/frontend-core/template/src/components/ui/badge/badge.stories.tsx +0 -78
  57. package/dist/frontend-core/template/src/components/ui/badge/badge.tsx +0 -48
  58. package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.stories.tsx +0 -67
  59. package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.tsx +0 -85
  60. package/dist/frontend-core/template/src/components/ui/button/button.stories.tsx +0 -150
  61. package/dist/frontend-core/template/src/components/ui/button/button.tsx +0 -68
  62. package/dist/frontend-core/template/src/components/ui/calendar/calendar.stories.tsx +0 -160
  63. package/dist/frontend-core/template/src/components/ui/calendar/calendar.tsx +0 -293
  64. package/dist/frontend-core/template/src/components/ui/card/card.stories.tsx +0 -77
  65. package/dist/frontend-core/template/src/components/ui/card/card.tsx +0 -45
  66. package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.stories.tsx +0 -29
  67. package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.tsx +0 -28
  68. package/dist/frontend-core/template/src/components/ui/carousel/carousel.stories.tsx +0 -154
  69. package/dist/frontend-core/template/src/components/ui/carousel/carousel.tsx +0 -227
  70. package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.stories.tsx +0 -106
  71. package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.tsx +0 -88
  72. package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.stories.tsx +0 -90
  73. package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.tsx +0 -54
  74. package/dist/frontend-core/template/src/components/ui/collapse/collapse.stories.tsx +0 -52
  75. package/dist/frontend-core/template/src/components/ui/collapse/collapse.tsx +0 -9
  76. package/dist/frontend-core/template/src/components/ui/combobox/combobox.stories.tsx +0 -207
  77. package/dist/frontend-core/template/src/components/ui/combobox/combobox.tsx +0 -79
  78. package/dist/frontend-core/template/src/components/ui/command/command.stories.tsx +0 -186
  79. package/dist/frontend-core/template/src/components/ui/command/command.tsx +0 -165
  80. package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.stories.tsx +0 -160
  81. package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.tsx +0 -134
  82. package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.stories.tsx +0 -198
  83. package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.tsx +0 -100
  84. package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.stories.tsx +0 -78
  85. package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.tsx +0 -179
  86. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/cell-variant-types.ts +0 -11
  87. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/checkbox-cell.tsx +0 -116
  88. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/date-cell.tsx +0 -157
  89. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/gantt-cell.tsx +0 -82
  90. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/long-text-cell.tsx +0 -180
  91. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/multi-select-cell.tsx +0 -280
  92. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/number-cell.tsx +0 -169
  93. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/react-node-cell.tsx +0 -33
  94. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/select-cell.tsx +0 -175
  95. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/short-text-cell.tsx +0 -138
  96. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timeline.tsx +0 -92
  97. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timerange-picker.tsx +0 -330
  98. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell-wrapper.tsx +0 -212
  99. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell.tsx +0 -157
  100. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-column-header.tsx +0 -340
  101. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-context-menu.tsx +0 -271
  102. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-row.tsx +0 -123
  103. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-search.tsx +0 -211
  104. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-types.ts +0 -159
  105. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-utils.ts +0 -67
  106. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-view-menu.tsx +0 -360
  107. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.stories.tsx +0 -780
  108. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.tsx +0 -217
  109. package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-callback-ref.ts +0 -22
  110. package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-data-grid.tsx +0 -1892
  111. package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-debounced-callback.ts +0 -19
  112. package/dist/frontend-core/template/src/components/ui/data-grid/styles.css +0 -3
  113. package/dist/frontend-core/template/src/components/ui/data-table/context-menu-simple.tsx +0 -141
  114. package/dist/frontend-core/template/src/components/ui/data-table/data-table.stories.tsx +0 -146
  115. package/dist/frontend-core/template/src/components/ui/data-table/data-table.tsx +0 -447
  116. package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-array-cell-renderer.tsx +0 -77
  117. package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-cell-renderer.tsx +0 -56
  118. package/dist/frontend-core/template/src/components/ui/data-table/renderers/favorite-cell-renderer.tsx +0 -68
  119. package/dist/frontend-core/template/src/components/ui/data-table/renderers/links-cell-renderer.tsx +0 -205
  120. package/dist/frontend-core/template/src/components/ui/data-table/utils/columns.ts +0 -351
  121. package/dist/frontend-core/template/src/components/ui/data-table/utils/data-table.utils.ts +0 -49
  122. package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.stories.tsx +0 -149
  123. package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.tsx +0 -30
  124. package/dist/frontend-core/template/src/components/ui/dialog/dialog.stories.tsx +0 -80
  125. package/dist/frontend-core/template/src/components/ui/dialog/dialog.tsx +0 -134
  126. package/dist/frontend-core/template/src/components/ui/drawer/drawer.stories.tsx +0 -104
  127. package/dist/frontend-core/template/src/components/ui/drawer/drawer.tsx +0 -87
  128. package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.stories.tsx +0 -168
  129. package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.tsx +0 -225
  130. package/dist/frontend-core/template/src/components/ui/input/input.stories.tsx +0 -141
  131. package/dist/frontend-core/template/src/components/ui/input/input.tsx +0 -47
  132. package/dist/frontend-core/template/src/components/ui/label/label.stories.tsx +0 -41
  133. package/dist/frontend-core/template/src/components/ui/label/label.tsx +0 -20
  134. package/dist/frontend-core/template/src/components/ui/loader/loader.stories.tsx +0 -45
  135. package/dist/frontend-core/template/src/components/ui/loader/loader.tsx +0 -17
  136. package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.stories.tsx +0 -114
  137. package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.tsx +0 -48
  138. package/dist/frontend-core/template/src/components/ui/menubar/menu.stories.tsx +0 -134
  139. package/dist/frontend-core/template/src/components/ui/menubar/menubar.tsx +0 -208
  140. package/dist/frontend-core/template/src/components/ui/modal/modal.stories.tsx +0 -297
  141. package/dist/frontend-core/template/src/components/ui/modal/modal.tsx +0 -80
  142. package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.stories.tsx +0 -213
  143. package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.tsx +0 -142
  144. package/dist/frontend-core/template/src/components/ui/pagination/pagination.stories.tsx +0 -49
  145. package/dist/frontend-core/template/src/components/ui/pagination/pagination.tsx +0 -84
  146. package/dist/frontend-core/template/src/components/ui/popover/popover.stories.tsx +0 -82
  147. package/dist/frontend-core/template/src/components/ui/popover/popover.tsx +0 -55
  148. package/dist/frontend-core/template/src/components/ui/progress/progress.stories.tsx +0 -80
  149. package/dist/frontend-core/template/src/components/ui/progress/progress.tsx +0 -17
  150. package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.stories.tsx +0 -154
  151. package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.tsx +0 -68
  152. package/dist/frontend-core/template/src/components/ui/resizable/resizable.stories.tsx +0 -73
  153. package/dist/frontend-core/template/src/components/ui/resizable/resizeable.tsx +0 -38
  154. package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.stories.tsx +0 -55
  155. package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.tsx +0 -39
  156. package/dist/frontend-core/template/src/components/ui/select/select.stories.tsx +0 -297
  157. package/dist/frontend-core/template/src/components/ui/select/select.tsx +0 -227
  158. package/dist/frontend-core/template/src/components/ui/separator/separator.tsx +0 -21
  159. package/dist/frontend-core/template/src/components/ui/separator/seperator.stories.tsx +0 -25
  160. package/dist/frontend-core/template/src/components/ui/sheet/sheet.stories.tsx +0 -45
  161. package/dist/frontend-core/template/src/components/ui/sheet/sheet.tsx +0 -107
  162. package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.stories.tsx +0 -26
  163. package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.tsx +0 -7
  164. package/dist/frontend-core/template/src/components/ui/slider/slider.stories.tsx +0 -101
  165. package/dist/frontend-core/template/src/components/ui/slider/slider.tsx +0 -98
  166. package/dist/frontend-core/template/src/components/ui/spinner/spinner.stories.tsx +0 -19
  167. package/dist/frontend-core/template/src/components/ui/spinner/spinner.tsx +0 -21
  168. package/dist/frontend-core/template/src/components/ui/switch/switch.stories.tsx +0 -33
  169. package/dist/frontend-core/template/src/components/ui/switch/switch.tsx +0 -28
  170. package/dist/frontend-core/template/src/components/ui/tabs/tabs.stories.tsx +0 -215
  171. package/dist/frontend-core/template/src/components/ui/tabs/tabs.tsx +0 -70
  172. package/dist/frontend-core/template/src/components/ui/textarea/textarea.stories.tsx +0 -138
  173. package/dist/frontend-core/template/src/components/ui/textarea/textarea.tsx +0 -40
  174. package/dist/frontend-core/template/src/components/ui/toast/toast.mdx +0 -31
  175. package/dist/frontend-core/template/src/components/ui/toast/toast.stories.tsx +0 -89
  176. package/dist/frontend-core/template/src/components/ui/toggle/toggle.stories.tsx +0 -65
  177. package/dist/frontend-core/template/src/components/ui/toggle/toggle.tsx +0 -38
  178. package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.stories.tsx +0 -85
  179. package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.tsx +0 -54
  180. package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.stories.tsx +0 -29
  181. package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.tsx +0 -29
@@ -1,165 +0,0 @@
1
- import { MagnifyingGlassIcon } from '@radix-ui/react-icons'
2
-
3
- import { cva, type VariantProps } from 'class-variance-authority'
4
- import { Command as CommandPrimitive } from 'cmdk'
5
- import React from 'react'
6
-
7
- import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@components/ui/dialog/dialog'
8
- import { cn } from '@lib/utils'
9
-
10
- function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
11
- return (
12
- <CommandPrimitive
13
- data-slot="command"
14
- className={cn(
15
- 'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
16
- className,
17
- )}
18
- {...props}
19
- />
20
- )
21
- }
22
-
23
- function CommandDialog({
24
- title = 'Command Palette',
25
- description = 'Search for a command to run...',
26
- children,
27
- className,
28
- showCloseButton = true,
29
- ...props
30
- }: React.ComponentProps<typeof Dialog> & {
31
- title?: string
32
- description?: string
33
- className?: string
34
- showCloseButton?: boolean
35
- }) {
36
- return (
37
- <Dialog {...props}>
38
- <DialogHeader className="sr-only">
39
- <DialogTitle>{title}</DialogTitle>
40
- <DialogDescription>{description}</DialogDescription>
41
- </DialogHeader>
42
- <DialogContent className={cn('overflow-hidden p-0', className)} showCloseButton={showCloseButton}>
43
- <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
44
- {children}
45
- </Command>
46
- </DialogContent>
47
- </Dialog>
48
- )
49
- }
50
-
51
- const commandInputVariants = cva('', {
52
- variants: {
53
- variant: { default: '', borderless: 'border-none' },
54
- inputSize: {
55
- sm: 'h-7.5 py-2',
56
- md: 'h-9 py-3',
57
- lg: 'h-12 py-4',
58
- },
59
- },
60
- defaultVariants: { variant: 'default', inputSize: 'md' },
61
- })
62
-
63
- export type CommandInputProps = Omit<React.ComponentProps<typeof CommandPrimitive.Input>, 'size'> &
64
- VariantProps<typeof commandInputVariants> & {
65
- wrapperClassName?: string
66
- }
67
-
68
- export const CommandInput = React.forwardRef<HTMLInputElement, CommandInputProps>(
69
- ({ className, wrapperClassName, variant, inputSize, ...props }, ref) => {
70
- return (
71
- <div
72
- data-slot="command-input-wrapper"
73
- className={cn(
74
- 'flex items-center gap-2 border-b px-3',
75
- commandInputVariants({ variant, inputSize }),
76
- wrapperClassName,
77
- )}
78
- >
79
- <MagnifyingGlassIcon className="size-4 shrink-0 opacity-50" />
80
- <CommandPrimitive.Input
81
- ref={ref}
82
- data-slot="command-input"
83
- className={cn(
84
- 'placeholder:text-muted-foreground flex w-full rounded bg-transparent text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
85
- className,
86
- )}
87
- {...props}
88
- />
89
- </div>
90
- )
91
- },
92
- )
93
- CommandInput.displayName = 'CommandInput'
94
-
95
- function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
96
- return (
97
- <CommandPrimitive.List
98
- data-slot="command-list"
99
- className={cn('max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto', className)}
100
- {...props}
101
- />
102
- )
103
- }
104
-
105
- function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
106
- return <CommandPrimitive.Empty data-slot="command-empty" className="py-6 text-center text-sm" {...props} />
107
- }
108
-
109
- function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {
110
- return (
111
- <CommandPrimitive.Group
112
- data-slot="command-group"
113
- className={cn(
114
- 'text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',
115
- className,
116
- )}
117
- {...props}
118
- />
119
- )
120
- }
121
-
122
- function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
123
- return (
124
- <CommandPrimitive.Separator
125
- data-slot="command-separator"
126
- className={cn('bg-border -mx-1 h-px', className)}
127
- {...props}
128
- />
129
- )
130
- }
131
-
132
- function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
133
- return (
134
- <CommandPrimitive.Item
135
- data-slot="command-item"
136
- className={cn(
137
- "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
138
- className,
139
- )}
140
- {...props}
141
- />
142
- )
143
- }
144
-
145
- function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>) {
146
- return (
147
- <span
148
- data-slot="command-shortcut"
149
- className={cn('text-muted-foreground ml-auto text-xs tracking-widest', className)}
150
- {...props}
151
- />
152
- )
153
- }
154
-
155
- export {
156
- Command,
157
- CommandDialog,
158
- commandInputVariants,
159
- CommandList,
160
- CommandEmpty,
161
- CommandGroup,
162
- CommandItem,
163
- CommandShortcut,
164
- CommandSeparator,
165
- }
@@ -1,160 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
-
3
- import {
4
- CommandPalette,
5
- CommandPaletteEmpty,
6
- CommandPaletteDialog,
7
- CommandPaletteGroup,
8
- CommandPaletteInput,
9
- CommandPaletteItem,
10
- CommandPaletteList,
11
- CommandPaletteSeparator,
12
- CommandPaletteShortcut,
13
- } from './command-palette'
14
- import { CalendarIcon, EnvelopeClosedIcon, FaceIcon, GearIcon, PersonIcon, RocketIcon } from '@radix-ui/react-icons'
15
- import { useEffect, useState } from 'react'
16
-
17
- const meta = {
18
- title: 'Command Palette',
19
- component: CommandPalette,
20
- tags: ['autodocs'],
21
- parameters: {
22
- docs: {
23
- description: {
24
- component:
25
- 'The Command Palette component is used to display a list of commands or actions that can be triggered by the user.',
26
- },
27
- },
28
- },
29
- } satisfies Meta<typeof CommandPalette>
30
-
31
- export default meta
32
- type Story = StoryObj<typeof meta>
33
-
34
- export const Default: Story = {
35
- parameters: {
36
- docs: {
37
- description: {
38
- story: 'A basic command palette with grouped items and keyboard shortcuts.',
39
- },
40
- },
41
- },
42
- render: () => (
43
- <div className="flex items-center justify-center">
44
- <CommandPalette className="rounded-lg border shadow-md md:min-w-[450px]">
45
- <CommandPaletteInput placeholder="Type a command or search..." />
46
- <CommandPaletteList>
47
- <CommandPaletteEmpty>No results found.</CommandPaletteEmpty>
48
- <CommandPaletteGroup heading="Suggestions">
49
- <CommandPaletteItem>
50
- <CalendarIcon className="mr-2 h-4 w-4" />
51
- <span>Calendar</span>
52
- </CommandPaletteItem>
53
- <CommandPaletteItem>
54
- <FaceIcon className="mr-2 h-4 w-4" />
55
- <span>Search Emoji</span>
56
- </CommandPaletteItem>
57
- <CommandPaletteItem disabled>
58
- <RocketIcon className="mr-2 h-4 w-4" />
59
- <span>Launch</span>
60
- </CommandPaletteItem>
61
- </CommandPaletteGroup>
62
- <CommandPaletteSeparator />
63
- <CommandPaletteGroup heading="Settings">
64
- <CommandPaletteItem>
65
- <PersonIcon className="mr-2 h-4 w-4" />
66
- <span>Profile</span>
67
- <CommandPaletteShortcut>⌘P</CommandPaletteShortcut>
68
- </CommandPaletteItem>
69
- <CommandPaletteItem>
70
- <EnvelopeClosedIcon className="mr-2 h-4 w-4" />
71
- <span>Mail</span>
72
- <CommandPaletteShortcut>⌘B</CommandPaletteShortcut>
73
- </CommandPaletteItem>
74
- <CommandPaletteItem>
75
- <GearIcon className="mr-2 h-4 w-4" />
76
- <span>Settings</span>
77
- <CommandPaletteShortcut>⌘S</CommandPaletteShortcut>
78
- </CommandPaletteItem>
79
- </CommandPaletteGroup>
80
- </CommandPaletteList>
81
- </CommandPalette>
82
- </div>
83
- ),
84
- }
85
-
86
- const CommandPaletteDialogExample = () => {
87
- const [open, setOpen] = useState(false)
88
-
89
- useEffect(() => {
90
- const down = (e: KeyboardEvent) => {
91
- if (e.key === 'j' && (e.metaKey || e.ctrlKey)) {
92
- e.preventDefault()
93
- setOpen((open) => !open)
94
- }
95
- }
96
-
97
- document.addEventListener('keydown', down)
98
- return () => document.removeEventListener('keydown', down)
99
- }, [])
100
-
101
- return (
102
- <div className="flex items-center justify-center">
103
- <p className="text-sm text-muted-foreground">
104
- Press{' '}
105
- <kbd className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100">
106
- <span className="text-xs">⌘</span>J
107
- </kbd>
108
- </p>
109
- <CommandPaletteDialog open={open} onOpenChange={setOpen}>
110
- <CommandPaletteInput placeholder="Type a command or search..." />
111
- <CommandPaletteList>
112
- <CommandPaletteEmpty>No results found.</CommandPaletteEmpty>
113
- <CommandPaletteGroup heading="Suggestions">
114
- <CommandPaletteItem>
115
- <CalendarIcon className="mr-2 h-4 w-4" />
116
- <span>Calendar</span>
117
- </CommandPaletteItem>
118
- <CommandPaletteItem>
119
- <FaceIcon className="mr-2 h-4 w-4" />
120
- <span>Search Emoji</span>
121
- </CommandPaletteItem>
122
- <CommandPaletteItem>
123
- <RocketIcon className="mr-2 h-4 w-4" />
124
- <span>Launch</span>
125
- </CommandPaletteItem>
126
- </CommandPaletteGroup>
127
- <CommandPaletteSeparator />
128
- <CommandPaletteGroup heading="Settings">
129
- <CommandPaletteItem>
130
- <PersonIcon className="mr-2 h-4 w-4" />
131
- <span>Profile</span>
132
- <CommandPaletteShortcut>⌘P</CommandPaletteShortcut>
133
- </CommandPaletteItem>
134
- <CommandPaletteItem>
135
- <EnvelopeClosedIcon className="mr-2 h-4 w-4" />
136
- <span>Mail</span>
137
- <CommandPaletteShortcut>⌘B</CommandPaletteShortcut>
138
- </CommandPaletteItem>
139
- <CommandPaletteItem>
140
- <GearIcon className="mr-2 h-4 w-4" />
141
- <span>Settings</span>
142
- <CommandPaletteShortcut>⌘S</CommandPaletteShortcut>
143
- </CommandPaletteItem>
144
- </CommandPaletteGroup>
145
- </CommandPaletteList>
146
- </CommandPaletteDialog>
147
- </div>
148
- )
149
- }
150
-
151
- export const Dialog: Story = {
152
- parameters: {
153
- docs: {
154
- description: {
155
- story: 'Command palette displayed in a dialog that can be opened with ⌘J keyboard shortcut.',
156
- },
157
- },
158
- },
159
- render: () => <CommandPaletteDialogExample />,
160
- }
@@ -1,134 +0,0 @@
1
- import { type DialogProps } from '@radix-ui/react-dialog'
2
- import { MagnifyingGlassIcon } from '@radix-ui/react-icons'
3
-
4
- import { Command as CommandPalettePrimitive } from 'cmdk'
5
- import * as React from 'react'
6
-
7
- import { Dialog, DialogContent } from '@components/ui/dialog/dialog'
8
- import { cn } from '@lib/utils'
9
-
10
- const CommandPalette = React.forwardRef<
11
- React.ElementRef<typeof CommandPalettePrimitive>,
12
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive>
13
- >(({ className, ...props }, ref) => (
14
- <CommandPalettePrimitive
15
- ref={ref}
16
- className={cn(
17
- 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
18
- className,
19
- )}
20
- {...props}
21
- />
22
- ))
23
- CommandPalette.displayName = CommandPalettePrimitive.displayName
24
-
25
- type CommandPaletteDialogProps = DialogProps
26
-
27
- const CommandPaletteDialog = ({ children, ...props }: CommandPaletteDialogProps) => {
28
- return (
29
- <Dialog {...props}>
30
- <DialogContent className="overflow-hidden p-0">
31
- <CommandPalette className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
32
- {children}
33
- </CommandPalette>
34
- </DialogContent>
35
- </Dialog>
36
- )
37
- }
38
-
39
- const CommandPaletteInput = React.forwardRef<
40
- React.ElementRef<typeof CommandPalettePrimitive.Input>,
41
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive.Input>
42
- >(({ className, ...props }, ref) => (
43
- // eslint-disable-next-line react/no-unknown-property
44
- <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
45
- <MagnifyingGlassIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
46
- <CommandPalettePrimitive.Input
47
- ref={ref}
48
- className={cn(
49
- 'flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
50
- className,
51
- )}
52
- {...props}
53
- />
54
- </div>
55
- ))
56
-
57
- CommandPaletteInput.displayName = CommandPalettePrimitive.Input.displayName
58
-
59
- const CommandPaletteList = React.forwardRef<
60
- React.ElementRef<typeof CommandPalettePrimitive.List>,
61
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive.List>
62
- >(({ className, ...props }, ref) => (
63
- <CommandPalettePrimitive.List
64
- ref={ref}
65
- className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}
66
- {...props}
67
- />
68
- ))
69
-
70
- CommandPaletteList.displayName = CommandPalettePrimitive.List.displayName
71
-
72
- const CommandPaletteEmpty = React.forwardRef<
73
- React.ElementRef<typeof CommandPalettePrimitive.Empty>,
74
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive.Empty>
75
- >((props, ref) => <CommandPalettePrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />)
76
-
77
- CommandPaletteEmpty.displayName = CommandPalettePrimitive.Empty.displayName
78
-
79
- const CommandPaletteGroup = React.forwardRef<
80
- React.ElementRef<typeof CommandPalettePrimitive.Group>,
81
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive.Group>
82
- >(({ className, ...props }, ref) => (
83
- <CommandPalettePrimitive.Group
84
- ref={ref}
85
- className={cn(
86
- 'overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground',
87
- className,
88
- )}
89
- {...props}
90
- />
91
- ))
92
-
93
- CommandPaletteGroup.displayName = CommandPalettePrimitive.Group.displayName
94
-
95
- const CommandPaletteSeparator = React.forwardRef<
96
- React.ElementRef<typeof CommandPalettePrimitive.Separator>,
97
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive.Separator>
98
- >(({ className, ...props }, ref) => (
99
- <CommandPalettePrimitive.Separator ref={ref} className={cn('-mx-1 h-px bg-border', className)} {...props} />
100
- ))
101
- CommandPaletteSeparator.displayName = CommandPalettePrimitive.Separator.displayName
102
-
103
- const CommandPaletteItem = React.forwardRef<
104
- React.ElementRef<typeof CommandPalettePrimitive.Item>,
105
- React.ComponentPropsWithoutRef<typeof CommandPalettePrimitive.Item>
106
- >(({ className, ...props }, ref) => (
107
- <CommandPalettePrimitive.Item
108
- ref={ref}
109
- className={cn(
110
- 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50',
111
- className,
112
- )}
113
- {...props}
114
- />
115
- ))
116
-
117
- CommandPaletteItem.displayName = CommandPalettePrimitive.Item.displayName
118
-
119
- const CommandPaletteShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
120
- return <span className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)} {...props} />
121
- }
122
- CommandPaletteShortcut.displayName = 'CommandPaletteShortcut'
123
-
124
- export {
125
- CommandPalette,
126
- CommandPaletteDialog,
127
- CommandPaletteInput,
128
- CommandPaletteList,
129
- CommandPaletteEmpty,
130
- CommandPaletteGroup,
131
- CommandPaletteItem,
132
- CommandPaletteShortcut,
133
- CommandPaletteSeparator,
134
- }
@@ -1,198 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { ChevronLeftIcon, ChevronRightIcon } from '@radix-ui/react-icons'
3
- import { cn } from '@lib/utils'
4
-
5
- import { Button } from '@components/ui/button/button'
6
-
7
- import { ContentFrame } from './content-frame'
8
- import { expect, userEvent, screen } from 'storybook/test'
9
- import { useState } from 'react'
10
- import { Modal } from '@components/ui/modal/modal'
11
- import { Badge } from '@components/ui/badge/badge'
12
-
13
- const meta = {
14
- title: 'ContentFrame',
15
- component: ContentFrame,
16
- tags: ['autodocs'],
17
- parameters: {
18
- layout: 'centered',
19
- },
20
- argTypes: {
21
- title: {
22
- control: 'text',
23
- },
24
- variant: {
25
- control: 'select',
26
- options: ['default', 'inverted'],
27
- },
28
- },
29
- } satisfies Meta<typeof ContentFrame>
30
- export default meta
31
-
32
- type Story = StoryObj<typeof meta>
33
-
34
- export const Default: Story = {
35
- args: {
36
- title: 'Title',
37
- variant: 'default',
38
- },
39
- render: (args) => (
40
- <div className="w-[350px]">
41
- <ContentFrame {...args}>
42
- <div className="p-2">Content inside the frame</div>
43
- </ContentFrame>
44
- </div>
45
- ),
46
- play: async () => {
47
- expect(screen.getByText('Title')).toBeVisible()
48
- expect(screen.getByText('Content inside the frame')).toBeVisible()
49
- const frame = screen.getByText('Content inside the frame').closest('div')
50
- },
51
- }
52
-
53
- export const Variants: Story = {
54
- args: { title: '' },
55
- render: () => (
56
- <div className="flex gap-2">
57
- <div className="w-[200px]">
58
- <ContentFrame title="default" variant="default">
59
- <div className="p-2">Content</div>
60
- </ContentFrame>
61
- </div>
62
- <div className="w-[200px]">
63
- <ContentFrame title="inverted" variant="inverted">
64
- <div className="p-2">Content</div>
65
- </ContentFrame>
66
- </div>
67
- </div>
68
- ),
69
- }
70
-
71
- export const WithTitleLink: Story = {
72
- args: {
73
- title: '',
74
- titleLink: (
75
- <a href="https://example.com/" target="_blank" rel="noopener noreferrer">
76
- <h2 className="text-xl overflow-hidden text-ellipsis whitespace-nowrap">Title with Link</h2>
77
- </a>
78
- ),
79
- },
80
- render: (args) => (
81
- <div className="w-[350px]">
82
- <ContentFrame {...args}>
83
- <div className="p-2">Content inside the frame</div>
84
- </ContentFrame>
85
- </div>
86
- ),
87
- play: async () => {
88
- // Check that the title link exists and is correct
89
- const link = screen.getByRole('link', { name: /title with link/i })
90
- expect(link).toHaveAttribute('href', 'https://example.com/')
91
- },
92
- }
93
-
94
- export const CollapsibleAndExpandable: Story = {
95
- args: { title: '' },
96
- render: () => {
97
- const dummyText =
98
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam rutrum laoreet erat ac sodales. Pellentesque nec nunc in ipsum tincidunt congue sit amet in augue. Sed interdum consequat arcu, ac tempor nisl eleifend sed. Mauris gravida ipsum orci, sed vestibulum nisl commodo in. Aliquam ut dolor dui. Donec fermentum viverra faucibus. In aliquet erat et quam ornare, et accumsan magna ornare. Suspendisse potenti. Etiam a elit dui. Mauris et lectus vel metus lobortis luctus. Vestibulum elementum sit amet augue vel rutrum. Aenean sem turpis, viverra hendrerit consequat eget, vulputate sed nunc. Pellentesque sollicitudin diam nunc, vel pretium massa mattis at. Curabitur fringilla convallis mollis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam rutrum laoreet erat ac sodales. Pellentesque nec nunc in ipsum tincidunt congue sit amet in augue. Sed interdum consequat arcu, ac tempor nisl eleifend sed. Mauris gravida ipsum orci, sed vestibulum nisl commodo in. Aliquam ut dolor dui. Donec fermentum viverra faucibus. In aliquet erat et quam ornare, et accumsan magna ornare. Suspendisse potenti. Etiam a elit dui. Mauris et lectus vel metus lobortis luctus. Vestibulum elementum sit amet augue vel rutrum. Aenean sem turpis, viverra hendrerit consequat eget, vulputate sed nunc. Pellentesque sollicitudin diam nunc, vel pretium massa mattis at. Curabitur fringilla convallis mollis. '
99
-
100
- const [isCollapsed, setIsCollapsed] = useState(false)
101
- const [isExpanded, setIsExpanded] = useState(false)
102
- return (
103
- <>
104
- <div className="w-[350px]">
105
- <div
106
- className={cn(
107
- 'relative h-[250px]',
108
- isCollapsed ? 'min-w-[60px] max-w-[60px]' : 'min-w-[350px] max-w-[350px]',
109
- )}
110
- >
111
- <ContentFrame
112
- title="Collapsible and Expandable"
113
- variant="inverted"
114
- collapsed={isCollapsed}
115
- onExpand={() => setIsExpanded(true)}
116
- >
117
- <div className="p-2">{dummyText}</div>
118
- </ContentFrame>
119
- <Button
120
- title={isCollapsed ? 'Show normal' : 'Collapse'}
121
- variant="neutral"
122
- size="iconSm"
123
- className="absolute top-1/2 right-0 transform -translate-y-1/2 translate-x-1/4 z-10 rounded-full bg-muted-foreground text-background"
124
- onClick={() => setIsCollapsed(!isCollapsed)}
125
- >
126
- {isCollapsed ? <ChevronRightIcon /> : <ChevronLeftIcon />}
127
- </Button>
128
- </div>
129
- </div>
130
- <Modal isOpen={isExpanded} setIsOpen={setIsExpanded} title="Collapsible and Expandable">
131
- <div className="p-2">{dummyText}</div>
132
- </Modal>
133
- </>
134
- )
135
- },
136
- play: async () => {
137
- // Collapse the frame
138
- const collapseBtn = screen.getByRole('button', { name: /collapse/i })
139
- await userEvent.click(collapseBtn)
140
- // After collapse, check that the ChevronRightIcon is rendered (collapsed state)
141
- expect(screen.getByRole('button', { name: /show normal/i })).toBeVisible()
142
- const expandModal = screen.getByText('Collapsible and Expandable')
143
- expect(expandModal).toBeVisible()
144
- },
145
- }
146
-
147
- export const WithControlsAndIndicators: Story = {
148
- args: {
149
- title: '',
150
- },
151
- render: (args) => {
152
- const [newsUnread, setNewsUnread] = useState(true)
153
- return (
154
- <div className="w-[350px]">
155
- <ContentFrame
156
- {...args}
157
- title={newsUnread ? 'Unread News' : 'No unread News'}
158
- controls={[
159
- <Button key="c1" variant="outline" size="sm" onClick={() => setNewsUnread(!newsUnread)}>
160
- {newsUnread ? 'Read all' : 'Unread all'}
161
- </Button>,
162
- ]}
163
- indicators={
164
- newsUnread
165
- ? [
166
- <Badge
167
- data-testid="pill-label"
168
- key="i1"
169
- className="self-center bg-(--ring) rounded-full h-5 text-background font-bold px-2"
170
- >
171
- 3
172
- </Badge>,
173
- ]
174
- : []
175
- }
176
- >
177
- <div className="p-2">
178
- {newsUnread ? (
179
- <>
180
- News 1<br />
181
- News 2<br />
182
- News 3
183
- </>
184
- ) : (
185
- 'No new content'
186
- )}
187
- </div>
188
- </ContentFrame>
189
- </div>
190
- )
191
- },
192
- play: async () => {
193
- // Check for control button
194
- expect(screen.getByRole('button', { name: /read all|unread all/i })).toBeVisible()
195
- // Check for indicator badge
196
- expect(screen.getByTestId('pill-label')).toBeVisible()
197
- },
198
- }