@postxl/generators 1.1.1 → 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.
- package/dist/frontend-core/frontend.generator.d.ts +0 -58
- package/dist/frontend-core/frontend.generator.js +6 -172
- package/dist/frontend-core/frontend.generator.js.map +1 -1
- package/dist/frontend-core/template/README.md +1 -1
- package/dist/frontend-core/template/src/components/admin/table-filter.tsx +1 -5
- package/dist/frontend-core/template/src/components/ui/color-mode-toggle/color-mode-toggle.tsx +10 -4
- package/dist/frontend-core/template/src/pages/dashboard/dashboard.page.tsx +2 -3
- package/dist/frontend-core/template/src/pages/error/default-error.page.tsx +1 -1
- package/dist/frontend-core/template/src/pages/error/not-found-error.page.tsx +1 -1
- package/dist/frontend-core/template/src/styles/styles.css +13 -1
- package/dist/frontend-core/template/tsconfig.json +2 -0
- package/dist/frontend-core/types/component.d.ts +1 -1
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.js +4 -6
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.js.map +1 -1
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js +1 -1
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js.map +1 -1
- package/dist/frontend-forms/generators/enum/inputs.generator.js +1 -1
- package/dist/frontend-forms/generators/enum/inputs.generator.js.map +1 -1
- package/dist/frontend-forms/generators/model/forms.generator.js +8 -12
- package/dist/frontend-forms/generators/model/forms.generator.js.map +1 -1
- package/dist/frontend-forms/generators/model/inputs.generator.js +2 -6
- package/dist/frontend-forms/generators/model/inputs.generator.js.map +1 -1
- package/dist/frontend-forms/template/src/components/ui/field/field.tsx +1 -4
- package/dist/frontend-tables/generators/model-table.generator.js +1 -5
- package/dist/frontend-tables/generators/model-table.generator.js.map +1 -1
- package/package.json +3 -2
- package/dist/frontend-core/template/src/components/ui/accordion/accordion.stories.tsx +0 -47
- package/dist/frontend-core/template/src/components/ui/accordion/accordion.tsx +0 -52
- package/dist/frontend-core/template/src/components/ui/admin-sidebar/admin-sidebar.tsx +0 -195
- package/dist/frontend-core/template/src/components/ui/alert/alert.stories.tsx +0 -61
- package/dist/frontend-core/template/src/components/ui/alert/alert.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.stories.tsx +0 -52
- package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.tsx +0 -105
- package/dist/frontend-core/template/src/components/ui/avatar/avatar.stories.tsx +0 -30
- package/dist/frontend-core/template/src/components/ui/avatar/avatar.tsx +0 -39
- package/dist/frontend-core/template/src/components/ui/badge/badge.stories.tsx +0 -78
- package/dist/frontend-core/template/src/components/ui/badge/badge.tsx +0 -48
- package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.stories.tsx +0 -67
- package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.tsx +0 -85
- package/dist/frontend-core/template/src/components/ui/button/button.stories.tsx +0 -150
- package/dist/frontend-core/template/src/components/ui/button/button.tsx +0 -68
- package/dist/frontend-core/template/src/components/ui/calendar/calendar.stories.tsx +0 -160
- package/dist/frontend-core/template/src/components/ui/calendar/calendar.tsx +0 -293
- package/dist/frontend-core/template/src/components/ui/card/card.stories.tsx +0 -77
- package/dist/frontend-core/template/src/components/ui/card/card.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.stories.tsx +0 -29
- package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.tsx +0 -28
- package/dist/frontend-core/template/src/components/ui/carousel/carousel.stories.tsx +0 -154
- package/dist/frontend-core/template/src/components/ui/carousel/carousel.tsx +0 -227
- package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.stories.tsx +0 -106
- package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.tsx +0 -88
- package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.stories.tsx +0 -90
- package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.tsx +0 -54
- package/dist/frontend-core/template/src/components/ui/collapse/collapse.stories.tsx +0 -52
- package/dist/frontend-core/template/src/components/ui/collapse/collapse.tsx +0 -9
- package/dist/frontend-core/template/src/components/ui/combobox/combobox.stories.tsx +0 -207
- package/dist/frontend-core/template/src/components/ui/combobox/combobox.tsx +0 -79
- package/dist/frontend-core/template/src/components/ui/command/command.stories.tsx +0 -186
- package/dist/frontend-core/template/src/components/ui/command/command.tsx +0 -165
- package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.stories.tsx +0 -160
- package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.tsx +0 -134
- package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.stories.tsx +0 -198
- package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.tsx +0 -100
- package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.stories.tsx +0 -78
- package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.tsx +0 -179
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/cell-variant-types.ts +0 -11
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/checkbox-cell.tsx +0 -116
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/date-cell.tsx +0 -157
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/gantt-cell.tsx +0 -82
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/long-text-cell.tsx +0 -180
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/multi-select-cell.tsx +0 -280
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/number-cell.tsx +0 -169
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/react-node-cell.tsx +0 -33
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/select-cell.tsx +0 -175
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/short-text-cell.tsx +0 -138
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timeline.tsx +0 -92
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timerange-picker.tsx +0 -330
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell-wrapper.tsx +0 -212
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell.tsx +0 -157
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-column-header.tsx +0 -340
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-context-menu.tsx +0 -271
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-row.tsx +0 -123
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-search.tsx +0 -211
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-types.ts +0 -159
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-utils.ts +0 -67
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-view-menu.tsx +0 -360
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.stories.tsx +0 -780
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.tsx +0 -217
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-callback-ref.ts +0 -22
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-data-grid.tsx +0 -1892
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-debounced-callback.ts +0 -19
- package/dist/frontend-core/template/src/components/ui/data-grid/styles.css +0 -3
- package/dist/frontend-core/template/src/components/ui/data-table/context-menu-simple.tsx +0 -141
- package/dist/frontend-core/template/src/components/ui/data-table/data-table.stories.tsx +0 -146
- package/dist/frontend-core/template/src/components/ui/data-table/data-table.tsx +0 -447
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-array-cell-renderer.tsx +0 -77
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-cell-renderer.tsx +0 -56
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/favorite-cell-renderer.tsx +0 -68
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/links-cell-renderer.tsx +0 -205
- package/dist/frontend-core/template/src/components/ui/data-table/utils/columns.ts +0 -351
- package/dist/frontend-core/template/src/components/ui/data-table/utils/data-table.utils.ts +0 -49
- package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.stories.tsx +0 -149
- package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.tsx +0 -30
- package/dist/frontend-core/template/src/components/ui/dialog/dialog.stories.tsx +0 -80
- package/dist/frontend-core/template/src/components/ui/dialog/dialog.tsx +0 -134
- package/dist/frontend-core/template/src/components/ui/drawer/drawer.stories.tsx +0 -104
- package/dist/frontend-core/template/src/components/ui/drawer/drawer.tsx +0 -87
- package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.stories.tsx +0 -168
- package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.tsx +0 -225
- package/dist/frontend-core/template/src/components/ui/input/input.stories.tsx +0 -141
- package/dist/frontend-core/template/src/components/ui/input/input.tsx +0 -47
- package/dist/frontend-core/template/src/components/ui/label/label.stories.tsx +0 -41
- package/dist/frontend-core/template/src/components/ui/label/label.tsx +0 -20
- package/dist/frontend-core/template/src/components/ui/loader/loader.stories.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/loader/loader.tsx +0 -17
- package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.stories.tsx +0 -114
- package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.tsx +0 -48
- package/dist/frontend-core/template/src/components/ui/menubar/menu.stories.tsx +0 -134
- package/dist/frontend-core/template/src/components/ui/menubar/menubar.tsx +0 -208
- package/dist/frontend-core/template/src/components/ui/modal/modal.stories.tsx +0 -297
- package/dist/frontend-core/template/src/components/ui/modal/modal.tsx +0 -80
- package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.stories.tsx +0 -213
- package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.tsx +0 -142
- package/dist/frontend-core/template/src/components/ui/pagination/pagination.stories.tsx +0 -49
- package/dist/frontend-core/template/src/components/ui/pagination/pagination.tsx +0 -84
- package/dist/frontend-core/template/src/components/ui/popover/popover.stories.tsx +0 -82
- package/dist/frontend-core/template/src/components/ui/popover/popover.tsx +0 -55
- package/dist/frontend-core/template/src/components/ui/progress/progress.stories.tsx +0 -80
- package/dist/frontend-core/template/src/components/ui/progress/progress.tsx +0 -17
- package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.stories.tsx +0 -154
- package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.tsx +0 -68
- package/dist/frontend-core/template/src/components/ui/resizable/resizable.stories.tsx +0 -73
- package/dist/frontend-core/template/src/components/ui/resizable/resizeable.tsx +0 -38
- package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.stories.tsx +0 -55
- package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.tsx +0 -39
- package/dist/frontend-core/template/src/components/ui/select/select.stories.tsx +0 -297
- package/dist/frontend-core/template/src/components/ui/select/select.tsx +0 -227
- package/dist/frontend-core/template/src/components/ui/separator/separator.tsx +0 -21
- package/dist/frontend-core/template/src/components/ui/separator/seperator.stories.tsx +0 -25
- package/dist/frontend-core/template/src/components/ui/sheet/sheet.stories.tsx +0 -45
- package/dist/frontend-core/template/src/components/ui/sheet/sheet.tsx +0 -107
- package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.stories.tsx +0 -26
- package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.tsx +0 -7
- package/dist/frontend-core/template/src/components/ui/slider/slider.stories.tsx +0 -101
- package/dist/frontend-core/template/src/components/ui/slider/slider.tsx +0 -98
- package/dist/frontend-core/template/src/components/ui/spinner/spinner.stories.tsx +0 -19
- package/dist/frontend-core/template/src/components/ui/spinner/spinner.tsx +0 -21
- package/dist/frontend-core/template/src/components/ui/switch/switch.stories.tsx +0 -33
- package/dist/frontend-core/template/src/components/ui/switch/switch.tsx +0 -28
- package/dist/frontend-core/template/src/components/ui/tabs/tabs.stories.tsx +0 -215
- package/dist/frontend-core/template/src/components/ui/tabs/tabs.tsx +0 -70
- package/dist/frontend-core/template/src/components/ui/textarea/textarea.stories.tsx +0 -138
- package/dist/frontend-core/template/src/components/ui/textarea/textarea.tsx +0 -40
- package/dist/frontend-core/template/src/components/ui/toast/toast.mdx +0 -31
- package/dist/frontend-core/template/src/components/ui/toast/toast.stories.tsx +0 -89
- package/dist/frontend-core/template/src/components/ui/toggle/toggle.stories.tsx +0 -65
- package/dist/frontend-core/template/src/components/ui/toggle/toggle.tsx +0 -38
- package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.stories.tsx +0 -85
- package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.tsx +0 -54
- package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.stories.tsx +0 -29
- package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.tsx +0 -29
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { ChevronDownIcon } from '@radix-ui/react-icons'
|
|
2
|
-
import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'
|
|
3
|
-
|
|
4
|
-
import { cva } from 'class-variance-authority'
|
|
5
|
-
|
|
6
|
-
import { cn } from '@lib/utils'
|
|
7
|
-
|
|
8
|
-
function NavigationMenu({
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
viewport = true,
|
|
12
|
-
...props
|
|
13
|
-
}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
|
|
14
|
-
viewport?: boolean
|
|
15
|
-
}) {
|
|
16
|
-
return (
|
|
17
|
-
<NavigationMenuPrimitive.Root
|
|
18
|
-
data-slot="navigation-menu"
|
|
19
|
-
data-viewport={viewport}
|
|
20
|
-
className={cn('group/navigation-menu relative flex max-w-max flex-1 items-center justify-center', className)}
|
|
21
|
-
{...props}
|
|
22
|
-
>
|
|
23
|
-
{children}
|
|
24
|
-
{viewport && <NavigationMenuViewport />}
|
|
25
|
-
</NavigationMenuPrimitive.Root>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function NavigationMenuList({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.List>) {
|
|
30
|
-
return (
|
|
31
|
-
<NavigationMenuPrimitive.List
|
|
32
|
-
data-slot="navigation-menu-list"
|
|
33
|
-
className={cn('group flex flex-1 list-none items-center justify-center gap-1', className)}
|
|
34
|
-
{...props}
|
|
35
|
-
/>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function NavigationMenuItem({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) {
|
|
40
|
-
return (
|
|
41
|
-
<NavigationMenuPrimitive.Item data-slot="navigation-menu-item" className={cn('relative', className)} {...props} />
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const navigationMenuTriggerStyle = cva(
|
|
46
|
-
'group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1',
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
function NavigationMenuTrigger({
|
|
50
|
-
className,
|
|
51
|
-
children,
|
|
52
|
-
...props
|
|
53
|
-
}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
|
|
54
|
-
return (
|
|
55
|
-
<NavigationMenuPrimitive.Trigger
|
|
56
|
-
data-slot="navigation-menu-trigger"
|
|
57
|
-
className={cn(navigationMenuTriggerStyle(), 'group', className)}
|
|
58
|
-
{...props}
|
|
59
|
-
>
|
|
60
|
-
{children}{' '}
|
|
61
|
-
<ChevronDownIcon
|
|
62
|
-
className="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
|
|
63
|
-
aria-hidden="true"
|
|
64
|
-
/>
|
|
65
|
-
</NavigationMenuPrimitive.Trigger>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function NavigationMenuContent({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) {
|
|
70
|
-
return (
|
|
71
|
-
<NavigationMenuPrimitive.Content
|
|
72
|
-
data-slot="navigation-menu-content"
|
|
73
|
-
className={cn(
|
|
74
|
-
'data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto',
|
|
75
|
-
'group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none',
|
|
76
|
-
className,
|
|
77
|
-
)}
|
|
78
|
-
{...props}
|
|
79
|
-
/>
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function NavigationMenuViewport({
|
|
84
|
-
className,
|
|
85
|
-
...props
|
|
86
|
-
}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) {
|
|
87
|
-
return (
|
|
88
|
-
<div className={cn('absolute top-full left-0 isolate z-50 flex justify-center')}>
|
|
89
|
-
<NavigationMenuPrimitive.Viewport
|
|
90
|
-
data-slot="navigation-menu-viewport"
|
|
91
|
-
className={cn(
|
|
92
|
-
'origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]',
|
|
93
|
-
className,
|
|
94
|
-
)}
|
|
95
|
-
{...props}
|
|
96
|
-
/>
|
|
97
|
-
</div>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function NavigationMenuLink({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) {
|
|
102
|
-
return (
|
|
103
|
-
<NavigationMenuPrimitive.Link
|
|
104
|
-
data-slot="navigation-menu-link"
|
|
105
|
-
className={cn(
|
|
106
|
-
"data-[active=true]:focus:bg-accent data-[active=true]:hover:bg-accent data-[active=true]:bg-accent/50 data-[active=true]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-ring/50 [&_svg:not([class*='text-'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4",
|
|
107
|
-
className,
|
|
108
|
-
)}
|
|
109
|
-
{...props}
|
|
110
|
-
/>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function NavigationMenuIndicator({
|
|
115
|
-
className,
|
|
116
|
-
...props
|
|
117
|
-
}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) {
|
|
118
|
-
return (
|
|
119
|
-
<NavigationMenuPrimitive.Indicator
|
|
120
|
-
data-slot="navigation-menu-indicator"
|
|
121
|
-
className={cn(
|
|
122
|
-
'data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
|
|
123
|
-
className,
|
|
124
|
-
)}
|
|
125
|
-
{...props}
|
|
126
|
-
>
|
|
127
|
-
<div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
|
|
128
|
-
</NavigationMenuPrimitive.Indicator>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export {
|
|
133
|
-
NavigationMenu,
|
|
134
|
-
NavigationMenuList,
|
|
135
|
-
NavigationMenuItem,
|
|
136
|
-
NavigationMenuContent,
|
|
137
|
-
NavigationMenuTrigger,
|
|
138
|
-
NavigationMenuLink,
|
|
139
|
-
NavigationMenuIndicator,
|
|
140
|
-
NavigationMenuViewport,
|
|
141
|
-
navigationMenuTriggerStyle,
|
|
142
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Pagination,
|
|
3
|
-
PaginationContent,
|
|
4
|
-
PaginationEllipsis,
|
|
5
|
-
PaginationItem,
|
|
6
|
-
PaginationLink,
|
|
7
|
-
PaginationNext,
|
|
8
|
-
PaginationPrevious,
|
|
9
|
-
} from './pagination'
|
|
10
|
-
import { Meta } from '@storybook/react-vite'
|
|
11
|
-
|
|
12
|
-
const meta: Meta<typeof Pagination> = {
|
|
13
|
-
title: 'Pagination',
|
|
14
|
-
component: Pagination,
|
|
15
|
-
tags: ['autodocs'],
|
|
16
|
-
} satisfies Meta<typeof Pagination>
|
|
17
|
-
|
|
18
|
-
export default meta
|
|
19
|
-
|
|
20
|
-
export const Default = {
|
|
21
|
-
render: () => (
|
|
22
|
-
<div className="flex items-center justify-center">
|
|
23
|
-
<Pagination>
|
|
24
|
-
<PaginationContent>
|
|
25
|
-
<PaginationItem>
|
|
26
|
-
<PaginationPrevious href="#" />
|
|
27
|
-
</PaginationItem>
|
|
28
|
-
<PaginationItem>
|
|
29
|
-
<PaginationLink href="#">1</PaginationLink>
|
|
30
|
-
</PaginationItem>
|
|
31
|
-
<PaginationItem>
|
|
32
|
-
<PaginationLink href="#" isActive>
|
|
33
|
-
2
|
|
34
|
-
</PaginationLink>
|
|
35
|
-
</PaginationItem>
|
|
36
|
-
<PaginationItem>
|
|
37
|
-
<PaginationLink href="#">3</PaginationLink>
|
|
38
|
-
</PaginationItem>
|
|
39
|
-
<PaginationItem>
|
|
40
|
-
<PaginationEllipsis />
|
|
41
|
-
</PaginationItem>
|
|
42
|
-
<PaginationItem>
|
|
43
|
-
<PaginationNext href="#" />
|
|
44
|
-
</PaginationItem>
|
|
45
|
-
</PaginationContent>
|
|
46
|
-
</Pagination>
|
|
47
|
-
</div>
|
|
48
|
-
),
|
|
49
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { ChevronLeftIcon, ChevronRightIcon, DotsHorizontalIcon } from '@radix-ui/react-icons'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
|
|
5
|
-
import { ButtonProps, buttonVariants } from '@components/ui/button/button'
|
|
6
|
-
import { cn } from '@lib/utils'
|
|
7
|
-
|
|
8
|
-
const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => (
|
|
9
|
-
<nav
|
|
10
|
-
role="navigation"
|
|
11
|
-
aria-label="pagination"
|
|
12
|
-
className={cn('mx-auto flex w-full justify-center', className)}
|
|
13
|
-
{...props}
|
|
14
|
-
/>
|
|
15
|
-
)
|
|
16
|
-
Pagination.displayName = 'Pagination'
|
|
17
|
-
|
|
18
|
-
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(
|
|
19
|
-
({ className, ...props }, ref) => (
|
|
20
|
-
<ul ref={ref} className={cn('flex flex-row items-center gap-1', className)} {...props} />
|
|
21
|
-
),
|
|
22
|
-
)
|
|
23
|
-
PaginationContent.displayName = 'PaginationContent'
|
|
24
|
-
|
|
25
|
-
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(({ className, ...props }, ref) => (
|
|
26
|
-
<li ref={ref} className={cn('', className)} {...props} />
|
|
27
|
-
))
|
|
28
|
-
PaginationItem.displayName = 'PaginationItem'
|
|
29
|
-
|
|
30
|
-
type PaginationLinkProps = {
|
|
31
|
-
isActive?: boolean
|
|
32
|
-
} & Pick<ButtonProps, 'size'> &
|
|
33
|
-
React.ComponentProps<'a'>
|
|
34
|
-
|
|
35
|
-
const PaginationLink = ({ className, isActive, size = 'icon', children, ...props }: PaginationLinkProps) => (
|
|
36
|
-
<a
|
|
37
|
-
aria-current={isActive ? 'page' : undefined}
|
|
38
|
-
className={cn(
|
|
39
|
-
buttonVariants({
|
|
40
|
-
variant: isActive ? 'outline' : 'ghost',
|
|
41
|
-
size,
|
|
42
|
-
}),
|
|
43
|
-
className,
|
|
44
|
-
)}
|
|
45
|
-
{...props}
|
|
46
|
-
>
|
|
47
|
-
{children}
|
|
48
|
-
</a>
|
|
49
|
-
)
|
|
50
|
-
PaginationLink.displayName = 'PaginationLink'
|
|
51
|
-
|
|
52
|
-
const PaginationPrevious = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
|
53
|
-
<PaginationLink aria-label="Go to previous page" size="default" className={cn('gap-1 pl-2.5', className)} {...props}>
|
|
54
|
-
<ChevronLeftIcon className="h-4 w-4" />
|
|
55
|
-
<span>Previous</span>
|
|
56
|
-
</PaginationLink>
|
|
57
|
-
)
|
|
58
|
-
PaginationPrevious.displayName = 'PaginationPrevious'
|
|
59
|
-
|
|
60
|
-
const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
|
61
|
-
<PaginationLink aria-label="Go to next page" size="default" className={cn('gap-1 pr-2.5', className)} {...props}>
|
|
62
|
-
<span>Next</span>
|
|
63
|
-
<ChevronRightIcon className="h-4 w-4" />
|
|
64
|
-
</PaginationLink>
|
|
65
|
-
)
|
|
66
|
-
PaginationNext.displayName = 'PaginationNext'
|
|
67
|
-
|
|
68
|
-
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<'span'>) => (
|
|
69
|
-
<span aria-hidden className={cn('flex h-9 w-9 items-center justify-center', className)} {...props}>
|
|
70
|
-
<DotsHorizontalIcon className="h-4 w-4" />
|
|
71
|
-
<span className="sr-only">More pages</span>
|
|
72
|
-
</span>
|
|
73
|
-
)
|
|
74
|
-
PaginationEllipsis.displayName = 'PaginationEllipsis'
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
Pagination,
|
|
78
|
-
PaginationContent,
|
|
79
|
-
PaginationLink,
|
|
80
|
-
PaginationItem,
|
|
81
|
-
PaginationPrevious,
|
|
82
|
-
PaginationNext,
|
|
83
|
-
PaginationEllipsis,
|
|
84
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
import { expect, userEvent, screen, waitFor } from 'storybook/test'
|
|
3
|
-
|
|
4
|
-
import { Popover, PopoverContent, PopoverTrigger } from './popover'
|
|
5
|
-
import { Button } from '@components/ui/button/button'
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
title: 'Popover',
|
|
9
|
-
component: PopoverContent,
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
},
|
|
14
|
-
argTypes: {
|
|
15
|
-
variant: {
|
|
16
|
-
control: 'select',
|
|
17
|
-
options: ['default', 'simple'],
|
|
18
|
-
},
|
|
19
|
-
align: {
|
|
20
|
-
control: 'select',
|
|
21
|
-
options: ['start', 'center', 'end'],
|
|
22
|
-
},
|
|
23
|
-
side: {
|
|
24
|
-
control: 'select',
|
|
25
|
-
options: ['top', 'right', 'bottom', 'left'],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
} satisfies Meta<typeof PopoverContent>
|
|
29
|
-
export default meta
|
|
30
|
-
|
|
31
|
-
type Story = StoryObj<typeof meta>
|
|
32
|
-
|
|
33
|
-
export const Default: Story = {
|
|
34
|
-
render: (args) => (
|
|
35
|
-
<Popover>
|
|
36
|
-
<PopoverTrigger asChild>
|
|
37
|
-
<Button variant="outline">Open popover</Button>
|
|
38
|
-
</PopoverTrigger>
|
|
39
|
-
<PopoverContent className="w-[250px]" variant={args.variant} align={args.align} side={args.side}>
|
|
40
|
-
<div className="bg-primary/20 p-2">popover content</div>
|
|
41
|
-
</PopoverContent>
|
|
42
|
-
</Popover>
|
|
43
|
-
),
|
|
44
|
-
play: async () => {
|
|
45
|
-
await userEvent.click(screen.getByText('Open popover'))
|
|
46
|
-
const popoverContent = await screen.findByText('popover content')
|
|
47
|
-
await waitFor(() => {
|
|
48
|
-
expect(window.getComputedStyle(popoverContent).visibility).toBe('visible')
|
|
49
|
-
})
|
|
50
|
-
await userEvent.click(document.body)
|
|
51
|
-
await waitFor(() => {
|
|
52
|
-
expect(screen.queryByText('popover content')).toBeNull()
|
|
53
|
-
})
|
|
54
|
-
await userEvent.keyboard('{Escape}')
|
|
55
|
-
await waitFor(() => {
|
|
56
|
-
expect(screen.queryByText('popover content')).toBeNull()
|
|
57
|
-
})
|
|
58
|
-
},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const Variants: Story = {
|
|
62
|
-
render: () => (
|
|
63
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
64
|
-
<Popover>
|
|
65
|
-
<PopoverTrigger asChild>
|
|
66
|
-
<Button variant="outline">default</Button>
|
|
67
|
-
</PopoverTrigger>
|
|
68
|
-
<PopoverContent className="w-[250px]" variant="default">
|
|
69
|
-
<div className="bg-primary/20 p-2">popover content</div>
|
|
70
|
-
</PopoverContent>
|
|
71
|
-
</Popover>
|
|
72
|
-
<Popover>
|
|
73
|
-
<PopoverTrigger asChild>
|
|
74
|
-
<Button variant="outline">simple</Button>
|
|
75
|
-
</PopoverTrigger>
|
|
76
|
-
<PopoverContent className="w-[250px]" variant="simple">
|
|
77
|
-
<div className="bg-primary/20 p-2">popover content</div>
|
|
78
|
-
</PopoverContent>
|
|
79
|
-
</Popover>
|
|
80
|
-
</div>
|
|
81
|
-
),
|
|
82
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as PopoverPrimitive from '@radix-ui/react-popover'
|
|
2
|
-
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
-
import * as React from 'react'
|
|
5
|
-
|
|
6
|
-
import { cn } from '@lib/utils'
|
|
7
|
-
|
|
8
|
-
function Popover({ ...props }: Readonly<React.ComponentProps<typeof PopoverPrimitive.Root>>) {
|
|
9
|
-
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function PopoverTrigger({ ...props }: Readonly<React.ComponentProps<typeof PopoverPrimitive.Trigger>>) {
|
|
13
|
-
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const popoverVariants = cva(
|
|
17
|
-
'outline-hidden border z-50 origin-(--radix-popover-content-transform-origin) 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',
|
|
18
|
-
{
|
|
19
|
-
variants: {
|
|
20
|
-
variant: {
|
|
21
|
-
default: 'bg-popover text-popover-foreground w-72 rounded p-4 shadow-md',
|
|
22
|
-
simple: 'bg-background text-foreground w-auto border-(--discreet-border) shadow-lg',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
defaultVariants: {
|
|
26
|
-
variant: 'default',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
function PopoverContent({
|
|
32
|
-
className,
|
|
33
|
-
variant,
|
|
34
|
-
align = 'center',
|
|
35
|
-
sideOffset = 4,
|
|
36
|
-
...props
|
|
37
|
-
}: Readonly<React.ComponentProps<typeof PopoverPrimitive.Content> & VariantProps<typeof popoverVariants>>) {
|
|
38
|
-
return (
|
|
39
|
-
<PopoverPrimitive.Portal>
|
|
40
|
-
<PopoverPrimitive.Content
|
|
41
|
-
data-slot="popover-content"
|
|
42
|
-
align={align}
|
|
43
|
-
sideOffset={sideOffset}
|
|
44
|
-
className={cn(popoverVariants({ variant }), className)}
|
|
45
|
-
{...props}
|
|
46
|
-
/>
|
|
47
|
-
</PopoverPrimitive.Portal>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
52
|
-
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
import { expect, userEvent, screen } from 'storybook/test'
|
|
3
|
-
|
|
4
|
-
import { Progress } from './progress'
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Progress',
|
|
8
|
-
component: Progress,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'centered',
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
value: {
|
|
15
|
-
control: { type: 'range', min: 0, max: 1, step: 0.01 },
|
|
16
|
-
description: 'Current progress value (0-100)',
|
|
17
|
-
},
|
|
18
|
-
size: {
|
|
19
|
-
description: 'css value for width of the progress bar',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
args: {
|
|
23
|
-
size: '100%',
|
|
24
|
-
},
|
|
25
|
-
} satisfies Meta<typeof Progress>
|
|
26
|
-
export default meta
|
|
27
|
-
|
|
28
|
-
type Story = StoryObj<typeof meta>
|
|
29
|
-
|
|
30
|
-
export const Default: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
value: 0.5,
|
|
33
|
-
size: '100%',
|
|
34
|
-
},
|
|
35
|
-
render: (args) => (
|
|
36
|
-
<div className="w-[200px]">
|
|
37
|
-
<Progress value={args.value} size={args.size} />
|
|
38
|
-
</div>
|
|
39
|
-
),
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const testValues = [0, 0.283, 0.8731, 1]
|
|
43
|
-
|
|
44
|
-
export const ValueRatioTest: Story = {
|
|
45
|
-
args: { value: 0, size: '200px' },
|
|
46
|
-
render: () => (
|
|
47
|
-
<div>
|
|
48
|
-
{testValues.map((v, idx) => (
|
|
49
|
-
<div key={idx} data-testid={`progress-${idx}`}>
|
|
50
|
-
<Progress value={v} size="200px" />
|
|
51
|
-
</div>
|
|
52
|
-
))}
|
|
53
|
-
</div>
|
|
54
|
-
),
|
|
55
|
-
play: async () => {
|
|
56
|
-
function getFilledWidth(testId: string) {
|
|
57
|
-
const container = screen.getByTestId(testId)
|
|
58
|
-
const filled = container.querySelector('[data-testid="progress-filled"]')
|
|
59
|
-
return filled ? filled.getBoundingClientRect().width : 0
|
|
60
|
-
}
|
|
61
|
-
function getBgWidth(testId: string) {
|
|
62
|
-
const container = screen.getByTestId(testId)
|
|
63
|
-
const bg = container.querySelector('[data-testid="progress-bg"]')
|
|
64
|
-
return bg ? bg.getBoundingClientRect().width : 0
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
testValues.forEach((v, idx) => {
|
|
68
|
-
const width = getFilledWidth(`progress-${idx}`)
|
|
69
|
-
const bgWidth = getBgWidth(`progress-${idx}`)
|
|
70
|
-
if (v === 0) {
|
|
71
|
-
expect(width).toBeCloseTo(0, 1)
|
|
72
|
-
} else if (v === 1) {
|
|
73
|
-
expect(width).toBeCloseTo(bgWidth, 1)
|
|
74
|
-
} else {
|
|
75
|
-
expect(width).toBeCloseTo(bgWidth * v, 1)
|
|
76
|
-
}
|
|
77
|
-
expect(bgWidth).toBeGreaterThan(0)
|
|
78
|
-
})
|
|
79
|
-
},
|
|
80
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react'
|
|
2
|
-
|
|
3
|
-
export const Progress = ({ value, size = '100%' }: { value: number; size?: string }) => {
|
|
4
|
-
return (
|
|
5
|
-
<div
|
|
6
|
-
style={{ '--parent-width': size } as CSSProperties}
|
|
7
|
-
className="w-(--parent-width) flex justify-center relative rounded-md overflow-hidden h-2 mt-8"
|
|
8
|
-
>
|
|
9
|
-
<div className="w-full absolute top-0 left-0 h-2.5 bg-(--discreet-border)" data-testid="progress-bg" />
|
|
10
|
-
<div
|
|
11
|
-
style={{ '--child-width': `calc(${value}*100%)` } as CSSProperties}
|
|
12
|
-
className="w-(--child-width) absolute h-2.5 top-0 left-0 bg-primary"
|
|
13
|
-
data-testid="progress-filled"
|
|
14
|
-
/>
|
|
15
|
-
</div>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
import { expect, userEvent, screen } from 'storybook/test'
|
|
3
|
-
|
|
4
|
-
import { RadioGroup, RadioGroupItem } from './radio-group'
|
|
5
|
-
import { Label } from '@components/ui/label/label'
|
|
6
|
-
|
|
7
|
-
const items = [
|
|
8
|
-
{ value: 'item-1', label: 'Item 1' },
|
|
9
|
-
{ value: 'item-2', label: 'Item 2' },
|
|
10
|
-
{ value: 'item-3', label: 'Item 3' },
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
const circleVariants = ['default', 'grayThick'] as const
|
|
14
|
-
const sizes = ['default', 'sm'] as const
|
|
15
|
-
|
|
16
|
-
const meta = {
|
|
17
|
-
title: 'RadioGroup',
|
|
18
|
-
component: RadioGroupItem,
|
|
19
|
-
tags: ['autodocs'],
|
|
20
|
-
parameters: {
|
|
21
|
-
layout: 'centered',
|
|
22
|
-
},
|
|
23
|
-
argTypes: {
|
|
24
|
-
value: {
|
|
25
|
-
table: { disable: true },
|
|
26
|
-
},
|
|
27
|
-
circleVariant: {
|
|
28
|
-
control: 'select',
|
|
29
|
-
options: circleVariants,
|
|
30
|
-
},
|
|
31
|
-
size: {
|
|
32
|
-
control: 'select',
|
|
33
|
-
options: sizes,
|
|
34
|
-
},
|
|
35
|
-
defaultValue: {
|
|
36
|
-
control: 'select',
|
|
37
|
-
options: items.map((i) => i.value),
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
} satisfies Meta<typeof RadioGroupItem>
|
|
41
|
-
export default meta
|
|
42
|
-
|
|
43
|
-
type Story = StoryObj<typeof meta>
|
|
44
|
-
|
|
45
|
-
export const Default: Story = {
|
|
46
|
-
args: {
|
|
47
|
-
value: '',
|
|
48
|
-
circleVariant: 'default',
|
|
49
|
-
size: 'default',
|
|
50
|
-
defaultValue: 'item-1',
|
|
51
|
-
},
|
|
52
|
-
render: (args) => (
|
|
53
|
-
<div className="w-[200px]">
|
|
54
|
-
<RadioGroup defaultValue={String(args.defaultValue)}>
|
|
55
|
-
{items.map(({ value, label }) => (
|
|
56
|
-
<div key={value} className="flex items-center gap-2">
|
|
57
|
-
<RadioGroupItem
|
|
58
|
-
value={value}
|
|
59
|
-
id={value}
|
|
60
|
-
circleVariant={args.circleVariant}
|
|
61
|
-
size={args.size}
|
|
62
|
-
className="cursor-pointer"
|
|
63
|
-
/>
|
|
64
|
-
<Label htmlFor={value} className="cursor-pointer">
|
|
65
|
-
{label}
|
|
66
|
-
</Label>
|
|
67
|
-
</div>
|
|
68
|
-
))}
|
|
69
|
-
</RadioGroup>
|
|
70
|
-
</div>
|
|
71
|
-
),
|
|
72
|
-
play: async () => {
|
|
73
|
-
// Check that the default radio is checked
|
|
74
|
-
const radio1 = screen.getByLabelText('Item 1')
|
|
75
|
-
const radio2 = screen.getByLabelText('Item 2')
|
|
76
|
-
await expect(radio1).toBeChecked()
|
|
77
|
-
await expect(radio2).not.toBeChecked()
|
|
78
|
-
// Click the label for Item 2
|
|
79
|
-
await userEvent.click(screen.getByLabelText('Item 2'))
|
|
80
|
-
await expect(radio2).toBeChecked()
|
|
81
|
-
await expect(radio1).not.toBeChecked()
|
|
82
|
-
},
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const itemsVariants = [
|
|
86
|
-
{ value: 'item-1', label: 'Item 1' },
|
|
87
|
-
{ value: 'item-2', label: 'Item 2' },
|
|
88
|
-
]
|
|
89
|
-
|
|
90
|
-
export const CircleVariants: Story = {
|
|
91
|
-
args: {
|
|
92
|
-
value: '',
|
|
93
|
-
circleVariant: 'default',
|
|
94
|
-
size: 'default',
|
|
95
|
-
defaultValue: '',
|
|
96
|
-
},
|
|
97
|
-
render: () => (
|
|
98
|
-
<div className="flex gap-6">
|
|
99
|
-
{circleVariants.map((variant) => (
|
|
100
|
-
<div key={variant} className="flex items-center gap-2">
|
|
101
|
-
<RadioGroup defaultValue="item-2">
|
|
102
|
-
{itemsVariants.map(({ value, label }) => (
|
|
103
|
-
<div key={value} className="flex items-center gap-2">
|
|
104
|
-
<RadioGroupItem
|
|
105
|
-
value={value}
|
|
106
|
-
id={`variants-${variant}-${value}`}
|
|
107
|
-
circleVariant={variant}
|
|
108
|
-
size="default"
|
|
109
|
-
className="cursor-pointer"
|
|
110
|
-
/>
|
|
111
|
-
<Label htmlFor={`variants-${variant}-${value}`} className="cursor-pointer">
|
|
112
|
-
{variant}
|
|
113
|
-
</Label>
|
|
114
|
-
</div>
|
|
115
|
-
))}
|
|
116
|
-
</RadioGroup>
|
|
117
|
-
</div>
|
|
118
|
-
))}
|
|
119
|
-
</div>
|
|
120
|
-
),
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const Sizes: Story = {
|
|
124
|
-
args: {
|
|
125
|
-
value: '',
|
|
126
|
-
circleVariant: 'default',
|
|
127
|
-
size: 'default',
|
|
128
|
-
defaultValue: '',
|
|
129
|
-
},
|
|
130
|
-
render: () => (
|
|
131
|
-
<div className="flex flex-col gap-2">
|
|
132
|
-
{sizes.map((size) => (
|
|
133
|
-
<div key={size} className="flex items-center gap-2 justify-center">
|
|
134
|
-
<RadioGroup defaultValue="item-2" className="flex flex-row">
|
|
135
|
-
{itemsVariants.map(({ value, label }) => (
|
|
136
|
-
<div key={value} className="flex items-center gap-2">
|
|
137
|
-
<RadioGroupItem
|
|
138
|
-
value={value}
|
|
139
|
-
id={`sizes-${size}-${value}`}
|
|
140
|
-
circleVariant="default"
|
|
141
|
-
size={size}
|
|
142
|
-
className="cursor-pointer"
|
|
143
|
-
/>
|
|
144
|
-
<Label htmlFor={`sizes-${size}-${value}`} className="cursor-pointer">
|
|
145
|
-
{size}
|
|
146
|
-
</Label>
|
|
147
|
-
</div>
|
|
148
|
-
))}
|
|
149
|
-
</RadioGroup>
|
|
150
|
-
</div>
|
|
151
|
-
))}
|
|
152
|
-
</div>
|
|
153
|
-
),
|
|
154
|
-
}
|