@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,17 +0,0 @@
1
- import { Spinner } from '@components/ui/spinner/spinner'
2
- import { APP_CONFIG } from '@lib/config'
3
-
4
- export function Loader({ label }: Readonly<{ label: string }>) {
5
- // disable loader during e2e tests to avoid slowdown due to transitions
6
- if (APP_CONFIG.mapBoxDisableTransitions) {
7
- return null
8
- }
9
- return (
10
- <div className="flex absolute z-1 left-0 top-0 bottom-0 right-0 bg-secondary/50">
11
- <div className="flex items-center justify-center flex-1 flex-col">
12
- <Spinner classNames="w-[24px] h-[25px]" />
13
- <h3 className="pb-0 pt-3 font-medium text-xl mb-2 text-muted-foreground">{label}</h3>
14
- </div>
15
- </div>
16
- )
17
- }
@@ -1,114 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
-
3
- import { MarkValueRenderer } from './mark-value-renderer'
4
- import { useRef, useState } from 'react'
5
- import { expect, userEvent, screen, within } from 'storybook/test'
6
- import { Command, CommandEmpty, CommandInput, CommandItem, CommandList } from '@components/ui/command/command'
7
-
8
- const meta = {
9
- title: 'MarkValueRenderer',
10
- component: MarkValueRenderer,
11
- tags: ['autodocs'],
12
- parameters: {
13
- layout: 'centered',
14
- },
15
- } satisfies Meta<typeof MarkValueRenderer>
16
- export default meta
17
-
18
- type Story = StoryObj<typeof meta>
19
-
20
- export const Default: Story = {
21
- args: {
22
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor nisl velit, at posuere nisi mollis rutrum. Mauris rutrum blandit metus, non rutrum ante luctus non. Donec magna metus, congue vel sodales ut, auctor a metus.',
23
- searchValues: ['Phasellus port', 'etu', 'NotFound'],
24
- },
25
- render: (args) => (
26
- <div className="">
27
- <MarkValueRenderer {...args} />
28
- </div>
29
- ),
30
- }
31
-
32
- export const InteractiveExample: Story = {
33
- args: { text: '', searchValues: [] },
34
- render: () => {
35
- const [open, setOpen] = useState(false)
36
- const [searchValue, setSearchValue] = useState('')
37
- const allValues = [
38
- 'Black leather laptop bag',
39
- 'Laptop backpack with USB charging port',
40
- 'Stainless steel reusable water bottle',
41
- 'Glass water bottle with silicone sleeve',
42
- 'Wireless Bluetooth headphones with noise cancellation',
43
- 'Over-ear headphones with built-in microphone',
44
- 'Ergonomic keyboard with backlight',
45
- 'Compact Bluetooth keyboard for tablet and phone',
46
- 'Digital camera with interchangeable lens',
47
- 'Compact travel camera with 4K resolution',
48
- 'Men`s wristwatch with stainless steel case',
49
- 'Smartwatch with heart rate monitor and GPS',
50
- 'Classic umbrella with wooden handle',
51
- 'Automatic folding umbrella in black',
52
- 'Recycled paper notebook with leather cover',
53
- ]
54
- const [selectedValue, setSelectedValue] = useState<string>('')
55
- const commandRef = useRef<HTMLDivElement>(null)
56
-
57
- return (
58
- <div ref={commandRef}>
59
- <Command
60
- className="w-[350px] border"
61
- onFocus={() => setOpen(true)}
62
- onBlur={(e) => {
63
- if (commandRef.current && !commandRef.current.contains(e.relatedTarget as Node)) {
64
- setOpen(false)
65
- setSearchValue('')
66
- }
67
- }}
68
- >
69
- <CommandInput
70
- placeholder={selectedValue || 'Search...'}
71
- variant={open ? 'default' : 'borderless'}
72
- inputSize="md"
73
- value={searchValue}
74
- onValueChange={(val) => {
75
- setSearchValue(val)
76
- }}
77
- />
78
- {open && (
79
- <CommandList>
80
- <CommandEmpty data-testid="no-results">No results found.</CommandEmpty>
81
- {allValues.map((value) => (
82
- <CommandItem
83
- key={value}
84
- data-testid={`item-${value}`}
85
- onSelect={() => {
86
- setSelectedValue(value)
87
- setOpen(false)
88
- setSearchValue('')
89
- }}
90
- >
91
- {searchValue ? <MarkValueRenderer text={value} searchValues={[searchValue]} /> : value}
92
- </CommandItem>
93
- ))}
94
- </CommandList>
95
- )}
96
- </Command>
97
- </div>
98
- )
99
- },
100
- play: async ({ canvasElement }) => {
101
- const canvas = within(canvasElement)
102
- const commandInput = canvas.getByPlaceholderText('Search...')
103
- await userEvent.click(commandInput)
104
- await userEvent.type(commandInput, 'leather')
105
-
106
- const item = await canvas.findByTestId('item-Recycled paper notebook with leather cover')
107
- // the MarkValueRenderer wraps matches in <mark>, so find that fragment directly
108
- const highlighted = item.querySelector('mark')
109
- if (!highlighted) throw new Error('Highlighted fragment (<mark>) not found inside the item')
110
- const highlightedColor = window.getComputedStyle(highlighted).color
111
- const itemColor = window.getComputedStyle(item).color
112
- expect(highlightedColor).not.toBe(itemColor)
113
- },
114
- }
@@ -1,48 +0,0 @@
1
- import { memo } from 'react'
2
-
3
- /**
4
- * Adds a mark tag around all search hits in the text,
5
- * so that the given searchValues are highlighted in the text
6
- */
7
- const MarkValueRenderer = memo(({ text, searchValues }: { text: string; searchValues: string[] | undefined }) => {
8
- if (!searchValues || searchValues.length === 0) {
9
- return <span>{text}</span>
10
- }
11
-
12
- // escape special characters; empty strings are removed using .filter(Boolean)
13
- const escapedFilterValues = searchValues
14
- .map((value) => {
15
- return value.replaceAll(/[|\\{}()[\]^$+*?.]/g, String.raw`\$&`)
16
- })
17
- .filter(Boolean)
18
-
19
- // no words to highlight
20
- if (escapedFilterValues.length === 0) {
21
- return <span>{text}</span>
22
- }
23
-
24
- // The split method is used to divide the "text" string into parts based on the regular expression.
25
- // This results in an array ("parts") where the matching words and the non-matching segments are separated.
26
- const regex = new RegExp(`(${escapedFilterValues.join('|')})`, 'gi')
27
- const parts = text.split(regex)
28
-
29
- return (
30
- <span>
31
- {parts.map((part, index) => {
32
- // to compare the parts with the words, the parts also have to be escaped
33
- const escapedPart = part.replaceAll(/[|\\{}()[\]^$+*?.]/g, String.raw`\$&`)
34
- return escapedFilterValues.some((escapedWord) => escapedPart.toLowerCase() === escapedWord.toLowerCase()) ? (
35
- <mark key={`${part}_${index}`} className="text-primary font-semibold bg-transparent">
36
- {part}
37
- </mark>
38
- ) : (
39
- part
40
- )
41
- })}
42
- </span>
43
- )
44
- })
45
-
46
- MarkValueRenderer.displayName = 'MarkCellValueRenderer'
47
-
48
- export { MarkValueRenderer }
@@ -1,134 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
-
3
- import {
4
- Menubar,
5
- MenubarCheckboxItem,
6
- MenubarContent,
7
- MenubarItem,
8
- MenubarMenu,
9
- MenubarRadioGroup,
10
- MenubarRadioItem,
11
- MenubarSeparator,
12
- MenubarShortcut,
13
- MenubarSub,
14
- MenubarSubContent,
15
- MenubarSubTrigger,
16
- MenubarTrigger,
17
- } from './menubar'
18
-
19
- const meta = {
20
- title: 'Menubar',
21
- component: Menubar,
22
- tags: ['autodocs'],
23
- parameters: {
24
- docs: {
25
- description: {
26
- component:
27
- 'The menubar is a horizontal bar that lists the top-level menus in an application. It provides quick access to a consistent set of commands.',
28
- },
29
- },
30
- },
31
- } satisfies Meta<typeof Menubar>
32
-
33
- export default meta
34
- type Story = StoryObj<typeof meta>
35
-
36
- export const Default: Story = {
37
- parameters: {
38
- docs: {
39
- description: {
40
- story:
41
- 'A comprehensive menubar with File, Edit, View, and Profiles menus showcasing various menu item types including shortcuts, submenus, checkboxes, and radio groups.',
42
- },
43
- },
44
- },
45
- render: () => (
46
- <div className="flex items-center justify-center">
47
- <Menubar>
48
- <MenubarMenu>
49
- <MenubarTrigger>File</MenubarTrigger>
50
- <MenubarContent>
51
- <MenubarItem>
52
- New Tab <MenubarShortcut>⌘T</MenubarShortcut>
53
- </MenubarItem>
54
- <MenubarItem>
55
- New Window <MenubarShortcut>⌘N</MenubarShortcut>
56
- </MenubarItem>
57
- <MenubarItem disabled>New Incognito Window</MenubarItem>
58
- <MenubarSeparator />
59
- <MenubarSub>
60
- <MenubarSubTrigger>Share</MenubarSubTrigger>
61
- <MenubarSubContent>
62
- <MenubarItem>Email link</MenubarItem>
63
- <MenubarItem>Messages</MenubarItem>
64
- <MenubarItem>Notes</MenubarItem>
65
- </MenubarSubContent>
66
- </MenubarSub>
67
- <MenubarSeparator />
68
- <MenubarItem>
69
- Print... <MenubarShortcut>⌘P</MenubarShortcut>
70
- </MenubarItem>
71
- </MenubarContent>
72
- </MenubarMenu>
73
- <MenubarMenu>
74
- <MenubarTrigger>Edit</MenubarTrigger>
75
- <MenubarContent>
76
- <MenubarItem>
77
- Undo <MenubarShortcut>⌘Z</MenubarShortcut>
78
- </MenubarItem>
79
- <MenubarItem>
80
- Redo <MenubarShortcut>⇧⌘Z</MenubarShortcut>
81
- </MenubarItem>
82
- <MenubarSeparator />
83
- <MenubarSub>
84
- <MenubarSubTrigger>Find</MenubarSubTrigger>
85
- <MenubarSubContent>
86
- <MenubarItem>Search the web</MenubarItem>
87
- <MenubarSeparator />
88
- <MenubarItem>Find...</MenubarItem>
89
- <MenubarItem>Find Next</MenubarItem>
90
- <MenubarItem>Find Previous</MenubarItem>
91
- </MenubarSubContent>
92
- </MenubarSub>
93
- <MenubarSeparator />
94
- <MenubarItem>Cut</MenubarItem>
95
- <MenubarItem>Copy</MenubarItem>
96
- <MenubarItem>Paste</MenubarItem>
97
- </MenubarContent>
98
- </MenubarMenu>
99
- <MenubarMenu>
100
- <MenubarTrigger>View</MenubarTrigger>
101
- <MenubarContent>
102
- <MenubarCheckboxItem>Always Show Bookmarks Bar</MenubarCheckboxItem>
103
- <MenubarCheckboxItem checked>Always Show Full URLs</MenubarCheckboxItem>
104
- <MenubarSeparator />
105
- <MenubarItem inset>
106
- Reload <MenubarShortcut>⌘R</MenubarShortcut>
107
- </MenubarItem>
108
- <MenubarItem disabled inset>
109
- Force Reload <MenubarShortcut>⇧⌘R</MenubarShortcut>
110
- </MenubarItem>
111
- <MenubarSeparator />
112
- <MenubarItem inset>Toggle Fullscreen</MenubarItem>
113
- <MenubarSeparator />
114
- <MenubarItem inset>Hide Sidebar</MenubarItem>
115
- </MenubarContent>
116
- </MenubarMenu>
117
- <MenubarMenu>
118
- <MenubarTrigger>Profiles</MenubarTrigger>
119
- <MenubarContent>
120
- <MenubarRadioGroup value="benoit">
121
- <MenubarRadioItem value="andy">Andy</MenubarRadioItem>
122
- <MenubarRadioItem value="benoit">Benoit</MenubarRadioItem>
123
- <MenubarRadioItem value="Luis">Luis</MenubarRadioItem>
124
- </MenubarRadioGroup>
125
- <MenubarSeparator />
126
- <MenubarItem inset>Edit...</MenubarItem>
127
- <MenubarSeparator />
128
- <MenubarItem inset>Add Profile...</MenubarItem>
129
- </MenubarContent>
130
- </MenubarMenu>
131
- </Menubar>
132
- </div>
133
- ),
134
- }
@@ -1,208 +0,0 @@
1
- import { CheckIcon, ChevronRightIcon, DotFilledIcon } from '@radix-ui/react-icons'
2
- import * as MenubarPrimitive from '@radix-ui/react-menubar'
3
-
4
- import * as React from 'react'
5
-
6
- import { cn } from '@lib/utils'
7
-
8
- const MenubarMenu = MenubarPrimitive.Menu
9
-
10
- const MenubarGroup = MenubarPrimitive.Group
11
-
12
- const MenubarPortal = MenubarPrimitive.Portal
13
-
14
- const MenubarSub = MenubarPrimitive.Sub
15
-
16
- const MenubarRadioGroup = MenubarPrimitive.RadioGroup
17
-
18
- const Menubar = React.forwardRef<
19
- React.ElementRef<typeof MenubarPrimitive.Root>,
20
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
21
- >(({ className, ...props }, ref) => (
22
- <MenubarPrimitive.Root
23
- ref={ref}
24
- className={cn('flex h-9 items-center space-x-1 rounded-md border bg-background p-1 shadow-sm', className)}
25
- {...props}
26
- />
27
- ))
28
- Menubar.displayName = MenubarPrimitive.Root.displayName
29
-
30
- const MenubarTrigger = React.forwardRef<
31
- React.ElementRef<typeof MenubarPrimitive.Trigger>,
32
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
33
- >(({ className, ...props }, ref) => (
34
- <MenubarPrimitive.Trigger
35
- ref={ref}
36
- className={cn(
37
- 'flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
38
- className,
39
- )}
40
- {...props}
41
- />
42
- ))
43
- MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName
44
-
45
- const MenubarSubTrigger = React.forwardRef<
46
- React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
47
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
48
- inset?: boolean
49
- }
50
- >(({ className, inset, children, ...props }, ref) => (
51
- <MenubarPrimitive.SubTrigger
52
- ref={ref}
53
- className={cn(
54
- 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
55
- inset && 'pl-8',
56
- className,
57
- )}
58
- {...props}
59
- >
60
- {children}
61
- <ChevronRightIcon className="ml-auto h-4 w-4" />
62
- </MenubarPrimitive.SubTrigger>
63
- ))
64
- MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName
65
-
66
- const MenubarSubContent = React.forwardRef<
67
- React.ElementRef<typeof MenubarPrimitive.SubContent>,
68
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
69
- >(({ className, ...props }, ref) => (
70
- <MenubarPrimitive.SubContent
71
- ref={ref}
72
- className={cn(
73
- 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
74
- className,
75
- )}
76
- {...props}
77
- />
78
- ))
79
- MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName
80
-
81
- const MenubarContent = React.forwardRef<
82
- React.ElementRef<typeof MenubarPrimitive.Content>,
83
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
84
- >(({ className, align = 'start', alignOffset = -4, sideOffset = 8, ...props }, ref) => (
85
- <MenubarPrimitive.Portal>
86
- <MenubarPrimitive.Content
87
- ref={ref}
88
- align={align}
89
- alignOffset={alignOffset}
90
- sideOffset={sideOffset}
91
- className={cn(
92
- 'z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
93
- className,
94
- )}
95
- {...props}
96
- />
97
- </MenubarPrimitive.Portal>
98
- ))
99
- MenubarContent.displayName = MenubarPrimitive.Content.displayName
100
-
101
- const MenubarItem = React.forwardRef<
102
- React.ElementRef<typeof MenubarPrimitive.Item>,
103
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
104
- inset?: boolean
105
- }
106
- >(({ className, inset, ...props }, ref) => (
107
- <MenubarPrimitive.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 focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
111
- inset && 'pl-8',
112
- className,
113
- )}
114
- {...props}
115
- />
116
- ))
117
- MenubarItem.displayName = MenubarPrimitive.Item.displayName
118
-
119
- const MenubarCheckboxItem = React.forwardRef<
120
- React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
121
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
122
- >(({ className, children, checked, ...props }, ref) => (
123
- <MenubarPrimitive.CheckboxItem
124
- ref={ref}
125
- className={cn(
126
- 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
127
- className,
128
- )}
129
- checked={checked}
130
- {...props}
131
- >
132
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
133
- <MenubarPrimitive.ItemIndicator>
134
- <CheckIcon className="h-4 w-4" />
135
- </MenubarPrimitive.ItemIndicator>
136
- </span>
137
- {children}
138
- </MenubarPrimitive.CheckboxItem>
139
- ))
140
- MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName
141
-
142
- const MenubarRadioItem = React.forwardRef<
143
- React.ElementRef<typeof MenubarPrimitive.RadioItem>,
144
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
145
- >(({ className, children, ...props }, ref) => (
146
- <MenubarPrimitive.RadioItem
147
- ref={ref}
148
- className={cn(
149
- 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
150
- className,
151
- )}
152
- {...props}
153
- >
154
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
155
- <MenubarPrimitive.ItemIndicator>
156
- <DotFilledIcon className="h-4 w-4 fill-current" />
157
- </MenubarPrimitive.ItemIndicator>
158
- </span>
159
- {children}
160
- </MenubarPrimitive.RadioItem>
161
- ))
162
- MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName
163
-
164
- const MenubarLabel = React.forwardRef<
165
- React.ElementRef<typeof MenubarPrimitive.Label>,
166
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
167
- inset?: boolean
168
- }
169
- >(({ className, inset, ...props }, ref) => (
170
- <MenubarPrimitive.Label
171
- ref={ref}
172
- className={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
173
- {...props}
174
- />
175
- ))
176
- MenubarLabel.displayName = MenubarPrimitive.Label.displayName
177
-
178
- const MenubarSeparator = React.forwardRef<
179
- React.ElementRef<typeof MenubarPrimitive.Separator>,
180
- React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
181
- >(({ className, ...props }, ref) => (
182
- <MenubarPrimitive.Separator ref={ref} className={cn('-mx-1 my-1 h-px bg-muted', className)} {...props} />
183
- ))
184
- MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName
185
-
186
- const MenubarShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
187
- return <span className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)} {...props} />
188
- }
189
- MenubarShortcut.displayname = 'MenubarShortcut'
190
-
191
- export {
192
- Menubar,
193
- MenubarMenu,
194
- MenubarTrigger,
195
- MenubarContent,
196
- MenubarItem,
197
- MenubarSeparator,
198
- MenubarLabel,
199
- MenubarCheckboxItem,
200
- MenubarRadioGroup,
201
- MenubarRadioItem,
202
- MenubarPortal,
203
- MenubarSubContent,
204
- MenubarSubTrigger,
205
- MenubarGroup,
206
- MenubarSub,
207
- MenubarShortcut,
208
- }