@postxl/generators 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/backend-core/template/apps/api/src/e2e.ts +13 -4
  2. package/dist/e2e/e2e.generator.js +2 -14
  3. package/dist/e2e/e2e.generator.js.map +1 -1
  4. package/dist/e2e/generators/docker-sh.generator.d.ts +2 -0
  5. package/dist/e2e/generators/docker-sh.generator.js +25 -0
  6. package/dist/e2e/generators/docker-sh.generator.js.map +1 -0
  7. package/dist/frontend-core/frontend.generator.d.ts +0 -58
  8. package/dist/frontend-core/frontend.generator.js +6 -172
  9. package/dist/frontend-core/frontend.generator.js.map +1 -1
  10. package/dist/frontend-core/template/README.md +1 -1
  11. package/dist/frontend-core/template/src/components/admin/table-filter.tsx +1 -5
  12. package/dist/frontend-core/template/src/components/ui/color-mode-toggle/color-mode-toggle.tsx +10 -4
  13. package/dist/frontend-core/template/src/context-providers/auth-context-provider.tsx +2 -5
  14. package/dist/frontend-core/template/src/pages/dashboard/dashboard.page.tsx +2 -3
  15. package/dist/frontend-core/template/src/pages/error/default-error.page.tsx +1 -1
  16. package/dist/frontend-core/template/src/pages/error/not-found-error.page.tsx +1 -1
  17. package/dist/frontend-core/template/src/styles/styles.css +13 -1
  18. package/dist/frontend-core/template/tsconfig.json +2 -0
  19. package/dist/frontend-core/types/component.d.ts +1 -1
  20. package/dist/frontend-forms/generators/discriminated-union/fields.generator.js +4 -6
  21. package/dist/frontend-forms/generators/discriminated-union/fields.generator.js.map +1 -1
  22. package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js +1 -1
  23. package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js.map +1 -1
  24. package/dist/frontend-forms/generators/enum/inputs.generator.js +1 -1
  25. package/dist/frontend-forms/generators/enum/inputs.generator.js.map +1 -1
  26. package/dist/frontend-forms/generators/model/forms.generator.js +8 -12
  27. package/dist/frontend-forms/generators/model/forms.generator.js.map +1 -1
  28. package/dist/frontend-forms/generators/model/inputs.generator.js +2 -6
  29. package/dist/frontend-forms/generators/model/inputs.generator.js.map +1 -1
  30. package/dist/frontend-forms/template/src/components/ui/field/field.tsx +1 -4
  31. package/dist/frontend-tables/generators/model-table.generator.js +1 -5
  32. package/dist/frontend-tables/generators/model-table.generator.js.map +1 -1
  33. package/package.json +3 -2
  34. package/dist/e2e/template/scripts/docker.sh +0 -17
  35. package/dist/frontend-core/template/src/components/ui/accordion/accordion.stories.tsx +0 -47
  36. package/dist/frontend-core/template/src/components/ui/accordion/accordion.tsx +0 -52
  37. package/dist/frontend-core/template/src/components/ui/admin-sidebar/admin-sidebar.tsx +0 -195
  38. package/dist/frontend-core/template/src/components/ui/alert/alert.stories.tsx +0 -61
  39. package/dist/frontend-core/template/src/components/ui/alert/alert.tsx +0 -45
  40. package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.stories.tsx +0 -52
  41. package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.tsx +0 -105
  42. package/dist/frontend-core/template/src/components/ui/avatar/avatar.stories.tsx +0 -30
  43. package/dist/frontend-core/template/src/components/ui/avatar/avatar.tsx +0 -39
  44. package/dist/frontend-core/template/src/components/ui/badge/badge.stories.tsx +0 -78
  45. package/dist/frontend-core/template/src/components/ui/badge/badge.tsx +0 -48
  46. package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.stories.tsx +0 -67
  47. package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.tsx +0 -85
  48. package/dist/frontend-core/template/src/components/ui/button/button.stories.tsx +0 -150
  49. package/dist/frontend-core/template/src/components/ui/button/button.tsx +0 -68
  50. package/dist/frontend-core/template/src/components/ui/calendar/calendar.stories.tsx +0 -160
  51. package/dist/frontend-core/template/src/components/ui/calendar/calendar.tsx +0 -293
  52. package/dist/frontend-core/template/src/components/ui/card/card.stories.tsx +0 -77
  53. package/dist/frontend-core/template/src/components/ui/card/card.tsx +0 -45
  54. package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.stories.tsx +0 -29
  55. package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.tsx +0 -28
  56. package/dist/frontend-core/template/src/components/ui/carousel/carousel.stories.tsx +0 -154
  57. package/dist/frontend-core/template/src/components/ui/carousel/carousel.tsx +0 -227
  58. package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.stories.tsx +0 -106
  59. package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.tsx +0 -88
  60. package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.stories.tsx +0 -90
  61. package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.tsx +0 -54
  62. package/dist/frontend-core/template/src/components/ui/collapse/collapse.stories.tsx +0 -52
  63. package/dist/frontend-core/template/src/components/ui/collapse/collapse.tsx +0 -9
  64. package/dist/frontend-core/template/src/components/ui/combobox/combobox.stories.tsx +0 -207
  65. package/dist/frontend-core/template/src/components/ui/combobox/combobox.tsx +0 -79
  66. package/dist/frontend-core/template/src/components/ui/command/command.stories.tsx +0 -186
  67. package/dist/frontend-core/template/src/components/ui/command/command.tsx +0 -165
  68. package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.stories.tsx +0 -160
  69. package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.tsx +0 -134
  70. package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.stories.tsx +0 -198
  71. package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.tsx +0 -100
  72. package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.stories.tsx +0 -78
  73. package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.tsx +0 -179
  74. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/cell-variant-types.ts +0 -11
  75. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/checkbox-cell.tsx +0 -116
  76. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/date-cell.tsx +0 -157
  77. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/gantt-cell.tsx +0 -82
  78. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/long-text-cell.tsx +0 -180
  79. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/multi-select-cell.tsx +0 -280
  80. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/number-cell.tsx +0 -169
  81. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/react-node-cell.tsx +0 -33
  82. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/select-cell.tsx +0 -175
  83. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/short-text-cell.tsx +0 -138
  84. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timeline.tsx +0 -92
  85. package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timerange-picker.tsx +0 -330
  86. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell-wrapper.tsx +0 -212
  87. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell.tsx +0 -157
  88. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-column-header.tsx +0 -340
  89. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-context-menu.tsx +0 -271
  90. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-row.tsx +0 -123
  91. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-search.tsx +0 -211
  92. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-types.ts +0 -159
  93. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-utils.ts +0 -67
  94. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-view-menu.tsx +0 -360
  95. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.stories.tsx +0 -780
  96. package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.tsx +0 -217
  97. package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-callback-ref.ts +0 -22
  98. package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-data-grid.tsx +0 -1892
  99. package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-debounced-callback.ts +0 -19
  100. package/dist/frontend-core/template/src/components/ui/data-grid/styles.css +0 -3
  101. package/dist/frontend-core/template/src/components/ui/data-table/context-menu-simple.tsx +0 -141
  102. package/dist/frontend-core/template/src/components/ui/data-table/data-table.stories.tsx +0 -146
  103. package/dist/frontend-core/template/src/components/ui/data-table/data-table.tsx +0 -447
  104. package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-array-cell-renderer.tsx +0 -77
  105. package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-cell-renderer.tsx +0 -56
  106. package/dist/frontend-core/template/src/components/ui/data-table/renderers/favorite-cell-renderer.tsx +0 -68
  107. package/dist/frontend-core/template/src/components/ui/data-table/renderers/links-cell-renderer.tsx +0 -205
  108. package/dist/frontend-core/template/src/components/ui/data-table/utils/columns.ts +0 -351
  109. package/dist/frontend-core/template/src/components/ui/data-table/utils/data-table.utils.ts +0 -49
  110. package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.stories.tsx +0 -149
  111. package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.tsx +0 -30
  112. package/dist/frontend-core/template/src/components/ui/dialog/dialog.stories.tsx +0 -80
  113. package/dist/frontend-core/template/src/components/ui/dialog/dialog.tsx +0 -134
  114. package/dist/frontend-core/template/src/components/ui/drawer/drawer.stories.tsx +0 -104
  115. package/dist/frontend-core/template/src/components/ui/drawer/drawer.tsx +0 -87
  116. package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.stories.tsx +0 -168
  117. package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.tsx +0 -225
  118. package/dist/frontend-core/template/src/components/ui/input/input.stories.tsx +0 -141
  119. package/dist/frontend-core/template/src/components/ui/input/input.tsx +0 -47
  120. package/dist/frontend-core/template/src/components/ui/label/label.stories.tsx +0 -41
  121. package/dist/frontend-core/template/src/components/ui/label/label.tsx +0 -20
  122. package/dist/frontend-core/template/src/components/ui/loader/loader.stories.tsx +0 -45
  123. package/dist/frontend-core/template/src/components/ui/loader/loader.tsx +0 -17
  124. package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.stories.tsx +0 -114
  125. package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.tsx +0 -48
  126. package/dist/frontend-core/template/src/components/ui/menubar/menu.stories.tsx +0 -134
  127. package/dist/frontend-core/template/src/components/ui/menubar/menubar.tsx +0 -208
  128. package/dist/frontend-core/template/src/components/ui/modal/modal.stories.tsx +0 -297
  129. package/dist/frontend-core/template/src/components/ui/modal/modal.tsx +0 -80
  130. package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.stories.tsx +0 -213
  131. package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.tsx +0 -142
  132. package/dist/frontend-core/template/src/components/ui/pagination/pagination.stories.tsx +0 -49
  133. package/dist/frontend-core/template/src/components/ui/pagination/pagination.tsx +0 -84
  134. package/dist/frontend-core/template/src/components/ui/popover/popover.stories.tsx +0 -82
  135. package/dist/frontend-core/template/src/components/ui/popover/popover.tsx +0 -55
  136. package/dist/frontend-core/template/src/components/ui/progress/progress.stories.tsx +0 -80
  137. package/dist/frontend-core/template/src/components/ui/progress/progress.tsx +0 -17
  138. package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.stories.tsx +0 -154
  139. package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.tsx +0 -68
  140. package/dist/frontend-core/template/src/components/ui/resizable/resizable.stories.tsx +0 -73
  141. package/dist/frontend-core/template/src/components/ui/resizable/resizeable.tsx +0 -38
  142. package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.stories.tsx +0 -55
  143. package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.tsx +0 -39
  144. package/dist/frontend-core/template/src/components/ui/select/select.stories.tsx +0 -297
  145. package/dist/frontend-core/template/src/components/ui/select/select.tsx +0 -227
  146. package/dist/frontend-core/template/src/components/ui/separator/separator.tsx +0 -21
  147. package/dist/frontend-core/template/src/components/ui/separator/seperator.stories.tsx +0 -25
  148. package/dist/frontend-core/template/src/components/ui/sheet/sheet.stories.tsx +0 -45
  149. package/dist/frontend-core/template/src/components/ui/sheet/sheet.tsx +0 -107
  150. package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.stories.tsx +0 -26
  151. package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.tsx +0 -7
  152. package/dist/frontend-core/template/src/components/ui/slider/slider.stories.tsx +0 -101
  153. package/dist/frontend-core/template/src/components/ui/slider/slider.tsx +0 -98
  154. package/dist/frontend-core/template/src/components/ui/spinner/spinner.stories.tsx +0 -19
  155. package/dist/frontend-core/template/src/components/ui/spinner/spinner.tsx +0 -21
  156. package/dist/frontend-core/template/src/components/ui/switch/switch.stories.tsx +0 -33
  157. package/dist/frontend-core/template/src/components/ui/switch/switch.tsx +0 -28
  158. package/dist/frontend-core/template/src/components/ui/tabs/tabs.stories.tsx +0 -215
  159. package/dist/frontend-core/template/src/components/ui/tabs/tabs.tsx +0 -70
  160. package/dist/frontend-core/template/src/components/ui/textarea/textarea.stories.tsx +0 -138
  161. package/dist/frontend-core/template/src/components/ui/textarea/textarea.tsx +0 -40
  162. package/dist/frontend-core/template/src/components/ui/toast/toast.mdx +0 -31
  163. package/dist/frontend-core/template/src/components/ui/toast/toast.stories.tsx +0 -89
  164. package/dist/frontend-core/template/src/components/ui/toggle/toggle.stories.tsx +0 -65
  165. package/dist/frontend-core/template/src/components/ui/toggle/toggle.tsx +0 -38
  166. package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.stories.tsx +0 -85
  167. package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.tsx +0 -54
  168. package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.stories.tsx +0 -29
  169. package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.tsx +0 -29
@@ -1,149 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
-
3
- import { DatePickerDemo } from './date-picker'
4
- import { HTMLAttributes, useState } from 'react'
5
- import { DateRange } from 'react-day-picker'
6
- import { addDays, format } from 'date-fns'
7
-
8
- import { cn } from '@lib/utils'
9
- import { Button } from '@components/ui/button/button'
10
- import { Calendar } from '@components/ui/calendar/calendar'
11
- import { Popover, PopoverContent, PopoverTrigger } from '@components/ui/popover/popover'
12
- import { CalendarIcon } from '@radix-ui/react-icons'
13
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@components/ui/select/select'
14
-
15
- const meta = {
16
- title: 'Date Picker',
17
- component: DatePickerDemo,
18
- tags: ['autodocs'],
19
- parameters: {
20
- docs: {
21
- description: {
22
- component: 'A date picker component with range and presets using the calendar, popover and select components.',
23
- },
24
- },
25
- },
26
- } satisfies Meta<typeof DatePickerDemo>
27
-
28
- export default meta
29
- type Story = StoryObj<typeof meta>
30
-
31
- export const Default: Story = {
32
- parameters: {
33
- docs: {
34
- description: {
35
- story: 'A basic date picker component for single date selection.',
36
- },
37
- },
38
- },
39
- render: () => (
40
- <div className="preview flex min-h-[350px] w-full justify-center p-10 items-center">
41
- <DatePickerDemo />
42
- </div>
43
- ),
44
- }
45
-
46
- const DateRangePickerExample = ({ className }: HTMLAttributes<HTMLDivElement>) => {
47
- const [date, setDate] = useState<DateRange | undefined>({
48
- from: new Date(2022, 0, 20),
49
- to: addDays(new Date(2022, 0, 20), 20),
50
- })
51
-
52
- return (
53
- <div className="preview flex min-h-[350px] w-full justify-center p-10 items-center">
54
- <div className={cn('grid gap-2', className)}>
55
- <Popover>
56
- <PopoverTrigger asChild>
57
- <Button
58
- id="date"
59
- variant={'outline'}
60
- className={cn('w-[300px] justify-start text-left font-normal', !date && 'text-muted-foreground')}
61
- >
62
- <CalendarIcon className="mr-2 h-4 w-4" />
63
- {date?.from ? (
64
- date.to ? (
65
- <>
66
- {format(date.from, 'LLL dd, y')} - {format(date.to, 'LLL dd, y')}
67
- </>
68
- ) : (
69
- format(date.from, 'LLL dd, y')
70
- )
71
- ) : (
72
- <span>Pick a date</span>
73
- )}
74
- </Button>
75
- </PopoverTrigger>
76
- <PopoverContent className="w-auto p-0" align="start">
77
- <Calendar
78
- initialFocus
79
- mode="range"
80
- defaultMonth={date?.from}
81
- selected={date}
82
- onSelect={setDate}
83
- numberOfMonths={2}
84
- />
85
- </PopoverContent>
86
- </Popover>
87
- </div>
88
- </div>
89
- )
90
- }
91
-
92
- export const DateRangePicker: Story = {
93
- parameters: {
94
- docs: {
95
- description: {
96
- story: 'A date picker that allows selecting a date range with a dual-month calendar view.',
97
- },
98
- },
99
- },
100
- render: () => <DateRangePickerExample />,
101
- }
102
-
103
- const DatePickerWithPresetsExample = () => {
104
- const [presetDate, setPresetDate] = useState<Date>()
105
-
106
- return (
107
- <div className="preview flex min-h-[350px] w-full justify-center p-10 items-center">
108
- <Popover>
109
- <PopoverTrigger asChild>
110
- <Button
111
- variant={'outline'}
112
- className={cn('w-[240px] justify-start text-left font-normal', !presetDate && 'text-muted-foreground')}
113
- >
114
- <CalendarIcon className="mr-2 h-4 w-4" />
115
- {presetDate ? format(presetDate, 'PPP') : <span>Pick a date</span>}
116
- </Button>
117
- </PopoverTrigger>
118
- <PopoverContent align="start" className="flex w-auto flex-col space-y-2 p-2">
119
- <Select onValueChange={(value) => setPresetDate(addDays(new Date(), parseInt(value)))}>
120
- <SelectTrigger>
121
- <SelectValue placeholder="Select" />
122
- </SelectTrigger>
123
- <SelectContent position="popper">
124
- <SelectItem value="0">Today</SelectItem>
125
- <SelectItem value="1">Tomorrow</SelectItem>
126
- <SelectItem value="3">In 3 days</SelectItem>
127
- <SelectItem value="7">In a week</SelectItem>
128
- </SelectContent>
129
- </Select>
130
- <div className="rounded-md border">
131
- <Calendar mode="single" selected={presetDate} onSelect={setPresetDate} />
132
- </div>
133
- </PopoverContent>
134
- </Popover>
135
- </div>
136
- )
137
- }
138
-
139
- export const WithPresets: Story = {
140
- parameters: {
141
- docs: {
142
- description: {
143
- story:
144
- 'A date picker with preset options (Today, Tomorrow, In 3 days, In a week) and a calendar for custom selection.',
145
- },
146
- },
147
- },
148
- render: () => <DatePickerWithPresetsExample />,
149
- }
@@ -1,30 +0,0 @@
1
- import { CalendarIcon } from '@radix-ui/react-icons'
2
-
3
- import { format } from 'date-fns'
4
- import * as React from 'react'
5
-
6
- import { Button } from '@components/ui/button/button'
7
- import { Calendar } from '@components/ui/calendar/calendar'
8
- import { Popover, PopoverContent, PopoverTrigger } from '@components/ui/popover/popover'
9
- import { cn } from '@lib/utils'
10
-
11
- export function DatePickerDemo() {
12
- const [date, setDate] = React.useState<Date>()
13
-
14
- return (
15
- <Popover>
16
- <PopoverTrigger asChild>
17
- <Button
18
- variant={'outline'}
19
- className={cn('w-[240px] justify-start text-left font-normal', !date && 'text-muted-foreground')}
20
- >
21
- <CalendarIcon className="mr-2 h-4 w-4" />
22
- {date ? format(date, 'PPP') : <span>Pick a date</span>}
23
- </Button>
24
- </PopoverTrigger>
25
- <PopoverContent className="w-auto p-0" align="start">
26
- <Calendar mode="single" selected={date} onSelect={setDate} initialFocus />
27
- </PopoverContent>
28
- </Popover>
29
- )
30
- }
@@ -1,80 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { expect, userEvent, screen, waitFor } from 'storybook/test'
3
-
4
- import {
5
- Dialog,
6
- DialogClose,
7
- DialogContent,
8
- DialogDescription,
9
- DialogFooter,
10
- DialogHeader,
11
- DialogTitle,
12
- DialogTrigger,
13
- } from './dialog'
14
- import { Button } from '@components/ui/button/button'
15
-
16
- const meta = {
17
- title: 'Dialog',
18
- component: Dialog,
19
- tags: ['autodocs'],
20
- parameters: {
21
- layout: 'centered',
22
- },
23
- argTypes: {},
24
- } satisfies Meta<typeof Dialog>
25
- export default meta
26
-
27
- type Story = StoryObj<typeof meta>
28
-
29
- export const Default: Story = {
30
- render: () => (
31
- <Dialog>
32
- <DialogTrigger asChild>
33
- <Button variant="outline">Open Dialog</Button>
34
- </DialogTrigger>
35
- <DialogContent className="max-w-[425px]" showCloseButton={true}>
36
- <DialogHeader>
37
- <DialogTitle>Dialog title</DialogTitle>
38
- <DialogDescription>Dialog description</DialogDescription>
39
- </DialogHeader>
40
- <p className="border-1 border-(--discreet-border)">
41
- some dialog content here
42
- <br />
43
- showCloseButton={'{true}'} on DialogContent for cross in top right corner
44
- </p>
45
- <DialogFooter>
46
- <DialogClose asChild>
47
- <Button variant="outline">Footer (close button)</Button>
48
- </DialogClose>
49
- <Button>Footer (e.g. submit button)</Button>
50
- </DialogFooter>
51
- </DialogContent>
52
- </Dialog>
53
- ),
54
- play: async () => {
55
- await userEvent.click(screen.getByText('Open Dialog'))
56
- await waitFor(
57
- async () => {
58
- const heading = await screen.findByRole('heading', { name: 'Dialog title' })
59
- expect(heading).toBeVisible()
60
- },
61
- { timeout: 1000 },
62
- )
63
-
64
- await userEvent.click(screen.getByText('Footer (close button)'))
65
-
66
- /* await waitFor(
67
- () => {
68
- expect(screen.queryByRole('heading', { name: 'Dialog title' })).not.toBeInTheDocument()
69
- },
70
- { timeout: 1000 },
71
- ) */
72
- await waitFor(
73
- () => {
74
- expect(screen.queryByText('Dialog title')).toBeNull()
75
- expect(screen.getByText('Open Dialog')).toBeVisible()
76
- },
77
- { timeout: 1000 },
78
- )
79
- },
80
- }
@@ -1,134 +0,0 @@
1
- import * as DialogPrimitive from '@radix-ui/react-dialog'
2
- import { Cross2Icon } from '@radix-ui/react-icons'
3
-
4
- import * as React from 'react'
5
-
6
- import { Button } from '@components/ui/button/button'
7
- import { cn } from '@lib/utils'
8
-
9
- function Dialog(props: Readonly<React.ComponentProps<typeof DialogPrimitive.Root>>) {
10
- return <DialogPrimitive.Root data-slot="dialog" {...props} />
11
- }
12
-
13
- function DialogTrigger(props: Readonly<React.ComponentProps<typeof DialogPrimitive.Trigger>>) {
14
- return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
15
- }
16
-
17
- function DialogPortal(props: Readonly<React.ComponentProps<typeof DialogPrimitive.Portal>>) {
18
- return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
19
- }
20
-
21
- function DialogClose(props: Readonly<React.ComponentProps<typeof DialogPrimitive.Close>>) {
22
- return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
23
- }
24
-
25
- function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
26
- return (
27
- <DialogPrimitive.Overlay
28
- data-slot="dialog-overlay"
29
- className={cn(
30
- 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 dark:bg-gray-500/30',
31
- className,
32
- )}
33
- {...props}
34
- />
35
- )
36
- }
37
-
38
- function DialogContent({
39
- className,
40
- children,
41
- showCloseButton = true,
42
- __e2e_test_id__,
43
- ...props
44
- }: React.ComponentProps<typeof DialogPrimitive.Content> & {
45
- showCloseButton?: boolean
46
- __e2e_test_id__?: string
47
- }) {
48
- return (
49
- <DialogPortal data-slot="dialog-portal" data-test-id={__e2e_test_id__}>
50
- <DialogOverlay />
51
- <DialogPrimitive.Content
52
- data-slot="dialog-content"
53
- className={cn(
54
- 'bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
55
- className,
56
- )}
57
- {...props}
58
- >
59
- {children}
60
- {showCloseButton && (
61
- <DialogPrimitive.Close
62
- title="Close"
63
- data-slot="dialog-close"
64
- className="flex ring-offset-background focus:ring-transparent data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-3 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer"
65
- >
66
- <Button
67
- asChild
68
- variant="outline"
69
- size="icon"
70
- className="size-6 rounded"
71
- __e2e_test_id__={__e2e_test_id__ ? `${__e2e_test_id__}-close` : undefined}
72
- >
73
- <Cross2Icon />
74
- </Button>
75
- <span className="sr-only">Close</span>
76
- </DialogPrimitive.Close>
77
- )}
78
- </DialogPrimitive.Content>
79
- </DialogPortal>
80
- )
81
- }
82
-
83
- function DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
84
- return (
85
- <div
86
- data-slot="dialog-header"
87
- className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
88
- {...props}
89
- />
90
- )
91
- }
92
-
93
- function DialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
94
- return (
95
- <div
96
- data-slot="dialog-footer"
97
- className={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
98
- {...props}
99
- />
100
- )
101
- }
102
-
103
- function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
104
- return (
105
- <DialogPrimitive.Title
106
- data-slot="dialog-title"
107
- className={cn('text-lg leading-none font-semibold', className)}
108
- {...props}
109
- />
110
- )
111
- }
112
-
113
- function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>) {
114
- return (
115
- <DialogPrimitive.Description
116
- data-slot="dialog-description"
117
- className={cn('text-muted-foreground text-sm', className)}
118
- {...props}
119
- />
120
- )
121
- }
122
-
123
- export {
124
- Dialog,
125
- DialogClose,
126
- DialogContent,
127
- DialogDescription,
128
- DialogFooter,
129
- DialogHeader,
130
- DialogOverlay,
131
- DialogPortal,
132
- DialogTitle,
133
- DialogTrigger,
134
- }
@@ -1,104 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
-
3
- import {
4
- Drawer,
5
- DrawerClose,
6
- DrawerContent,
7
- DrawerDescription,
8
- DrawerFooter,
9
- DrawerHeader,
10
- DrawerTitle,
11
- DrawerTrigger,
12
- } from './drawer'
13
- import { Button } from '@components/ui/button/button'
14
- import { MinusIcon, PlusIcon } from '@radix-ui/react-icons'
15
- import { useState } from 'react'
16
-
17
- const meta = {
18
- title: 'Drawer',
19
- component: Drawer,
20
- tags: ['autodocs'],
21
- parameters: {
22
- docs: {
23
- description: {
24
- component:
25
- 'The Drawer is a panel that slides in from the edge of the screen. It can also be combined with other components to create more complex UIs e.g. combined with a dialog it can be used to render the drawer for mobile and dialog for desktop.',
26
- },
27
- },
28
- },
29
- } satisfies Meta<typeof Drawer>
30
-
31
- export default meta
32
- type Story = StoryObj<typeof meta>
33
-
34
- const DrawerExample = () => {
35
- const [goal, setGoal] = useState(350)
36
-
37
- function onClick(adjustment: number) {
38
- setGoal(Math.max(200, Math.min(400, goal + adjustment)))
39
- }
40
-
41
- return (
42
- <div className="flex items-center justify-center">
43
- <Drawer>
44
- <DrawerTrigger asChild>
45
- <Button variant="outline">Open Drawer</Button>
46
- </DrawerTrigger>
47
- <DrawerContent>
48
- <div className="mx-auto w-full max-w-sm">
49
- <DrawerHeader>
50
- <DrawerTitle>Move Goal</DrawerTitle>
51
- <DrawerDescription>Set your daily activity goal.</DrawerDescription>
52
- </DrawerHeader>
53
- <div className="p-4 pb-0">
54
- <div className="flex items-center justify-center space-x-2">
55
- <Button
56
- variant="outline"
57
- size="icon"
58
- className="h-8 w-8 shrink-0 rounded-full"
59
- onClick={() => onClick(-10)}
60
- disabled={goal <= 200}
61
- >
62
- <MinusIcon className="h-4 w-4" />
63
- <span className="sr-only">Decrease</span>
64
- </Button>
65
- <div className="flex-1 text-center">
66
- <div className="text-7xl font-bold tracking-tighter">{goal}</div>
67
- <div className="text-[0.70rem] uppercase text-muted-foreground">Calories/day</div>
68
- </div>
69
- <Button
70
- variant="outline"
71
- size="icon"
72
- className="h-8 w-8 shrink-0 rounded-full"
73
- onClick={() => onClick(10)}
74
- disabled={goal >= 400}
75
- >
76
- <PlusIcon className="h-4 w-4" />
77
- <span className="sr-only">Increase</span>
78
- </Button>
79
- </div>
80
- </div>
81
- <DrawerFooter>
82
- <Button>Submit</Button>
83
- <DrawerClose asChild>
84
- <Button variant="outline">Cancel</Button>
85
- </DrawerClose>
86
- </DrawerFooter>
87
- </div>
88
- </DrawerContent>
89
- </Drawer>
90
- </div>
91
- )
92
- }
93
-
94
- export const Default: Story = {
95
- parameters: {
96
- docs: {
97
- description: {
98
- story:
99
- 'A basic drawer with interactive content that allows setting a daily activity goal with increment/decrement controls.',
100
- },
101
- },
102
- },
103
- render: () => <DrawerExample />,
104
- }
@@ -1,87 +0,0 @@
1
- import * as React from 'react'
2
- import { Drawer as DrawerPrimitive } from 'vaul'
3
-
4
- import { cn } from '@lib/utils'
5
-
6
- const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
7
- <DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
8
- )
9
- Drawer.displayName = 'Drawer'
10
-
11
- const DrawerTrigger = DrawerPrimitive.Trigger
12
-
13
- const DrawerPortal = DrawerPrimitive.Portal
14
-
15
- const DrawerClose = DrawerPrimitive.Close
16
-
17
- const DrawerOverlay = React.forwardRef<
18
- React.ElementRef<typeof DrawerPrimitive.Overlay>,
19
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
20
- >(({ className, ...props }, ref) => (
21
- <DrawerPrimitive.Overlay ref={ref} className={cn('fixed inset-0 z-50 bg-black/80', className)} {...props} />
22
- ))
23
- DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName
24
-
25
- const DrawerContent = React.forwardRef<
26
- React.ElementRef<typeof DrawerPrimitive.Content>,
27
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
28
- >(({ className, children, ...props }, ref) => (
29
- <DrawerPortal>
30
- <DrawerOverlay />
31
- <DrawerPrimitive.Content
32
- ref={ref}
33
- className={cn(
34
- 'fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background',
35
- className,
36
- )}
37
- {...props}
38
- >
39
- <div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
40
- {children}
41
- </DrawerPrimitive.Content>
42
- </DrawerPortal>
43
- ))
44
- DrawerContent.displayName = 'DrawerContent'
45
-
46
- const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
47
- <div className={cn('grid gap-1.5 p-4 text-center sm:text-left', className)} {...props} />
48
- )
49
- DrawerHeader.displayName = 'DrawerHeader'
50
-
51
- const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
52
- <div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />
53
- )
54
- DrawerFooter.displayName = 'DrawerFooter'
55
-
56
- const DrawerTitle = React.forwardRef<
57
- React.ElementRef<typeof DrawerPrimitive.Title>,
58
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
59
- >(({ className, ...props }, ref) => (
60
- <DrawerPrimitive.Title
61
- ref={ref}
62
- className={cn('text-lg font-semibold leading-none tracking-tight', className)}
63
- {...props}
64
- />
65
- ))
66
- DrawerTitle.displayName = DrawerPrimitive.Title.displayName
67
-
68
- const DrawerDescription = React.forwardRef<
69
- React.ElementRef<typeof DrawerPrimitive.Description>,
70
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
71
- >(({ className, ...props }, ref) => (
72
- <DrawerPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
73
- ))
74
- DrawerDescription.displayName = DrawerPrimitive.Description.displayName
75
-
76
- export {
77
- Drawer,
78
- DrawerPortal,
79
- DrawerOverlay,
80
- DrawerTrigger,
81
- DrawerClose,
82
- DrawerContent,
83
- DrawerHeader,
84
- DrawerFooter,
85
- DrawerTitle,
86
- DrawerDescription,
87
- }