@postxl/generators 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend-core/backend.generator.js +4 -1
- package/dist/backend-core/backend.generator.js.map +1 -1
- package/dist/backend-core/generators/jest.config.generator.d.ts +2 -0
- package/dist/backend-core/{template/jest.config.ts → generators/jest.config.generator.js} +12 -8
- package/dist/backend-core/generators/jest.config.generator.js.map +1 -0
- package/dist/backend-core/generators/tsconfig.generator.d.ts +1 -1
- package/dist/backend-core/generators/tsconfig.generator.js +1 -9
- package/dist/backend-core/generators/tsconfig.generator.js.map +1 -1
- package/dist/backend-core/types.d.ts +2 -0
- package/dist/base/base.generator.js +12 -8
- package/dist/base/base.generator.js.map +1 -1
- package/dist/e2e/template/e2e/package.json +1 -1
- package/dist/e2e/template/e2e/specs/example.spec.ts +1 -1
- package/dist/e2e/template/e2e/specs/example.spec.ts-snapshots/Navigate-to-homepage-and-take-snapshot-1-chromium-linux.png +0 -0
- package/dist/frontend-core/frontend.generator.d.ts +0 -58
- package/dist/frontend-core/frontend.generator.js +9 -173
- package/dist/frontend-core/frontend.generator.js.map +1 -1
- package/dist/frontend-core/generators/tsconfig.generator.js +2 -0
- package/dist/frontend-core/generators/tsconfig.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/lib/query-client.ts +45 -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 +45 -12
- 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 +4 -3
- package/dist/e2e/generators/package-json.generator.d.ts +0 -2
- package/dist/e2e/generators/package-json.generator.js +0 -29
- package/dist/e2e/generators/package-json.generator.js.map +0 -1
- 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,154 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Carousel,
|
|
5
|
-
CarouselApi,
|
|
6
|
-
CarouselContent,
|
|
7
|
-
CarouselItem,
|
|
8
|
-
CarouselNext,
|
|
9
|
-
CarouselPrevious,
|
|
10
|
-
CarouselProps,
|
|
11
|
-
} from './carousel'
|
|
12
|
-
import { Card, CardContent } from '@components/ui/card/card'
|
|
13
|
-
import { useEffect, useState } from 'react'
|
|
14
|
-
|
|
15
|
-
const meta = {
|
|
16
|
-
title: 'Carousel',
|
|
17
|
-
component: Carousel,
|
|
18
|
-
tags: ['autodocs'],
|
|
19
|
-
argTypes: {
|
|
20
|
-
orientation: {
|
|
21
|
-
control: 'select',
|
|
22
|
-
options: ['horizontal', 'vertical'],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
} satisfies Meta<typeof Carousel>
|
|
26
|
-
|
|
27
|
-
export default meta
|
|
28
|
-
|
|
29
|
-
export const Default: StoryObj<typeof meta> = {
|
|
30
|
-
parameters: {
|
|
31
|
-
docs: {
|
|
32
|
-
description: {
|
|
33
|
-
story: 'The Carousel component displays a list of items that can be scrolled through.',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
args: {
|
|
38
|
-
orientation: 'horizontal',
|
|
39
|
-
},
|
|
40
|
-
render: (args) => (
|
|
41
|
-
<div className="flex items-center justify-center border rounded p-4">
|
|
42
|
-
<Carousel {...args} className="w-full max-w-xs">
|
|
43
|
-
<CarouselContent>
|
|
44
|
-
{Array.from({ length: 5 }).map((_, index) => (
|
|
45
|
-
<CarouselItem key={index} className="basis-1/3">
|
|
46
|
-
<div className="p-1">
|
|
47
|
-
<Card>
|
|
48
|
-
<CardContent className="flex aspect-square items-center justify-center p-6">
|
|
49
|
-
<span className="text-4xl font-semibold">{index + 1}</span>
|
|
50
|
-
</CardContent>
|
|
51
|
-
</Card>
|
|
52
|
-
</div>
|
|
53
|
-
</CarouselItem>
|
|
54
|
-
))}
|
|
55
|
-
</CarouselContent>
|
|
56
|
-
<CarouselPrevious />
|
|
57
|
-
<CarouselNext />
|
|
58
|
-
</Carousel>
|
|
59
|
-
</div>
|
|
60
|
-
),
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function CarouselWithApi() {
|
|
64
|
-
const [api, setApi] = useState<CarouselApi>()
|
|
65
|
-
const [current, setCurrent] = useState(0)
|
|
66
|
-
const [count, setCount] = useState(0)
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!api) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
setCount(api.scrollSnapList().length)
|
|
74
|
-
setCurrent(api.selectedScrollSnap() + 1)
|
|
75
|
-
|
|
76
|
-
api.on('select', () => {
|
|
77
|
-
setCurrent(api.selectedScrollSnap() + 1)
|
|
78
|
-
})
|
|
79
|
-
}, [api])
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<div className="mx-auto max-w-xs">
|
|
83
|
-
<Carousel setApi={setApi} className="w-full max-w-xs">
|
|
84
|
-
<CarouselContent>
|
|
85
|
-
{Array.from({ length: 5 }).map((_, index) => (
|
|
86
|
-
<CarouselItem key={index}>
|
|
87
|
-
<Card>
|
|
88
|
-
<CardContent className="flex aspect-square items-center justify-center p-6">
|
|
89
|
-
<span className="text-4xl font-semibold">{index + 1}</span>
|
|
90
|
-
</CardContent>
|
|
91
|
-
</Card>
|
|
92
|
-
</CarouselItem>
|
|
93
|
-
))}
|
|
94
|
-
</CarouselContent>
|
|
95
|
-
<CarouselPrevious />
|
|
96
|
-
<CarouselNext />
|
|
97
|
-
</Carousel>
|
|
98
|
-
<div className="py-2 text-center text-sm text-muted-foreground">
|
|
99
|
-
Slide {current} of {count}
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const WithApi: StoryObj<typeof meta> = {
|
|
106
|
-
parameters: {
|
|
107
|
-
docs: {
|
|
108
|
-
description: {
|
|
109
|
-
story:
|
|
110
|
-
'Carousel with API integration showing current slide counter. The setApi prop allows you to access carousel methods and state for custom controls and indicators.',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
render: () => (
|
|
115
|
-
<div className="flex items-center justify-center border rounded p-4">
|
|
116
|
-
<CarouselWithApi />
|
|
117
|
-
</div>
|
|
118
|
-
),
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const Vertical: StoryObj<typeof meta> = {
|
|
122
|
-
parameters: {
|
|
123
|
-
docs: {
|
|
124
|
-
description: {
|
|
125
|
-
story:
|
|
126
|
-
'Vertical orientation carousel that scrolls up and down instead of left and right. Perfect for vertical content layouts or space-constrained horizontal designs.',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
args: {
|
|
131
|
-
orientation: 'vertical',
|
|
132
|
-
},
|
|
133
|
-
render: (args) => (
|
|
134
|
-
<div className="flex items-center justify-center border rounded p-4">
|
|
135
|
-
<Carousel {...args} className="w-full max-w-xs">
|
|
136
|
-
<CarouselContent className="h-[200px]">
|
|
137
|
-
{Array.from({ length: 5 }).map((_, index) => (
|
|
138
|
-
<CarouselItem key={index}>
|
|
139
|
-
<div className="p-1">
|
|
140
|
-
<Card>
|
|
141
|
-
<CardContent className="flex aspect-square items-center justify-center p-6">
|
|
142
|
-
<span className="text-4xl font-semibold">{index + 1}</span>
|
|
143
|
-
</CardContent>
|
|
144
|
-
</Card>
|
|
145
|
-
</div>
|
|
146
|
-
</CarouselItem>
|
|
147
|
-
))}
|
|
148
|
-
</CarouselContent>
|
|
149
|
-
<CarouselPrevious />
|
|
150
|
-
<CarouselNext />
|
|
151
|
-
</Carousel>
|
|
152
|
-
</div>
|
|
153
|
-
),
|
|
154
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { ArrowLeftIcon, ArrowRightIcon } from '@radix-ui/react-icons'
|
|
2
|
-
|
|
3
|
-
import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react'
|
|
4
|
-
import * as React from 'react'
|
|
5
|
-
import { useMemo } from 'react'
|
|
6
|
-
|
|
7
|
-
import { Button } from '@components/ui/button/button'
|
|
8
|
-
import { cn } from '@lib/utils'
|
|
9
|
-
|
|
10
|
-
type CarouselApi = UseEmblaCarouselType[1]
|
|
11
|
-
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
12
|
-
type CarouselOptions = UseCarouselParameters[0]
|
|
13
|
-
type CarouselPlugin = UseCarouselParameters[1]
|
|
14
|
-
|
|
15
|
-
type CarouselProps = {
|
|
16
|
-
opts?: CarouselOptions
|
|
17
|
-
plugins?: CarouselPlugin
|
|
18
|
-
orientation?: 'horizontal' | 'vertical'
|
|
19
|
-
setApi?: (api: CarouselApi) => void
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type CarouselContextProps = {
|
|
23
|
-
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
|
24
|
-
api: ReturnType<typeof useEmblaCarousel>[1]
|
|
25
|
-
scrollPrev: () => void
|
|
26
|
-
scrollNext: () => void
|
|
27
|
-
canScrollPrev: boolean
|
|
28
|
-
canScrollNext: boolean
|
|
29
|
-
} & CarouselProps
|
|
30
|
-
|
|
31
|
-
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
32
|
-
|
|
33
|
-
function useCarousel() {
|
|
34
|
-
const context = React.useContext(CarouselContext)
|
|
35
|
-
|
|
36
|
-
if (!context) {
|
|
37
|
-
throw new Error('useCarousel must be used within a <Carousel />')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return context
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const Carousel = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement> & CarouselProps>(
|
|
44
|
-
({ orientation = 'horizontal', opts, setApi, plugins, className, children, ...props }, ref) => {
|
|
45
|
-
const [carouselRef, api] = useEmblaCarousel(
|
|
46
|
-
{
|
|
47
|
-
...opts,
|
|
48
|
-
axis: orientation === 'horizontal' ? 'x' : 'y',
|
|
49
|
-
},
|
|
50
|
-
plugins,
|
|
51
|
-
)
|
|
52
|
-
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
53
|
-
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
54
|
-
|
|
55
|
-
const onSelect = React.useCallback(() => {
|
|
56
|
-
if (!api) {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
setCanScrollPrev(api.canScrollPrev())
|
|
61
|
-
setCanScrollNext(api.canScrollNext())
|
|
62
|
-
}, [api])
|
|
63
|
-
|
|
64
|
-
const scrollPrev = React.useCallback(() => {
|
|
65
|
-
api?.scrollPrev()
|
|
66
|
-
}, [api])
|
|
67
|
-
|
|
68
|
-
const scrollNext = React.useCallback(() => {
|
|
69
|
-
api?.scrollNext()
|
|
70
|
-
}, [api])
|
|
71
|
-
|
|
72
|
-
const handleKeyDown = React.useCallback(
|
|
73
|
-
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
74
|
-
if (event.key === 'ArrowLeft') {
|
|
75
|
-
event.preventDefault()
|
|
76
|
-
scrollPrev()
|
|
77
|
-
} else if (event.key === 'ArrowRight') {
|
|
78
|
-
event.preventDefault()
|
|
79
|
-
scrollNext()
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
[scrollPrev, scrollNext],
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
React.useEffect(() => {
|
|
86
|
-
if (!api || !setApi) {
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setApi(api)
|
|
91
|
-
}, [api, setApi])
|
|
92
|
-
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
if (!api) {
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
onSelect()
|
|
99
|
-
api.on('reInit', onSelect)
|
|
100
|
-
api.on('select', onSelect)
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
api?.off('select', onSelect)
|
|
104
|
-
}
|
|
105
|
-
}, [api, onSelect])
|
|
106
|
-
|
|
107
|
-
const memoizedValue = useMemo(
|
|
108
|
-
() => ({
|
|
109
|
-
carouselRef,
|
|
110
|
-
api: api,
|
|
111
|
-
opts,
|
|
112
|
-
orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
|
|
113
|
-
scrollPrev,
|
|
114
|
-
scrollNext,
|
|
115
|
-
canScrollPrev,
|
|
116
|
-
canScrollNext,
|
|
117
|
-
}),
|
|
118
|
-
[api, canScrollNext, canScrollPrev, carouselRef, opts, orientation, scrollNext, scrollPrev],
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<CarouselContext.Provider value={memoizedValue}>
|
|
123
|
-
<div
|
|
124
|
-
ref={ref}
|
|
125
|
-
onKeyDownCapture={handleKeyDown}
|
|
126
|
-
className={cn('relative', className)}
|
|
127
|
-
aria-roledescription="carousel"
|
|
128
|
-
{...props}
|
|
129
|
-
>
|
|
130
|
-
{children}
|
|
131
|
-
</div>
|
|
132
|
-
</CarouselContext.Provider>
|
|
133
|
-
)
|
|
134
|
-
},
|
|
135
|
-
)
|
|
136
|
-
Carousel.displayName = 'Carousel'
|
|
137
|
-
|
|
138
|
-
const CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
139
|
-
({ className, ...props }, ref) => {
|
|
140
|
-
const { carouselRef, orientation } = useCarousel()
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<div ref={carouselRef} className="overflow-hidden">
|
|
144
|
-
<div
|
|
145
|
-
ref={ref}
|
|
146
|
-
className={cn('flex', orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col', className)}
|
|
147
|
-
{...props}
|
|
148
|
-
/>
|
|
149
|
-
</div>
|
|
150
|
-
)
|
|
151
|
-
},
|
|
152
|
-
)
|
|
153
|
-
CarouselContent.displayName = 'CarouselContent'
|
|
154
|
-
|
|
155
|
-
const CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
156
|
-
({ className, ...props }, ref) => {
|
|
157
|
-
const { orientation } = useCarousel()
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<div
|
|
161
|
-
ref={ref}
|
|
162
|
-
aria-roledescription="slide"
|
|
163
|
-
className={cn('min-w-0 shrink-0 grow-0 basis-full', orientation === 'horizontal' ? 'pl-4' : 'pt-4', className)}
|
|
164
|
-
{...props}
|
|
165
|
-
/>
|
|
166
|
-
)
|
|
167
|
-
},
|
|
168
|
-
)
|
|
169
|
-
CarouselItem.displayName = 'CarouselItem'
|
|
170
|
-
|
|
171
|
-
const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
|
172
|
-
({ className, variant = 'outline', size = 'icon', ...props }, ref) => {
|
|
173
|
-
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<Button
|
|
177
|
-
ref={ref}
|
|
178
|
-
variant={variant}
|
|
179
|
-
size={size}
|
|
180
|
-
className={cn(
|
|
181
|
-
'absolute h-8 w-8 rounded-full',
|
|
182
|
-
orientation === 'horizontal'
|
|
183
|
-
? '-left-12 top-1/2 -translate-y-1/2'
|
|
184
|
-
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
|
|
185
|
-
className,
|
|
186
|
-
)}
|
|
187
|
-
disabled={!canScrollPrev}
|
|
188
|
-
onClick={scrollPrev}
|
|
189
|
-
{...props}
|
|
190
|
-
>
|
|
191
|
-
<ArrowLeftIcon className="h-4 w-4" />
|
|
192
|
-
<span className="sr-only">Previous slide</span>
|
|
193
|
-
</Button>
|
|
194
|
-
)
|
|
195
|
-
},
|
|
196
|
-
)
|
|
197
|
-
CarouselPrevious.displayName = 'CarouselPrevious'
|
|
198
|
-
|
|
199
|
-
const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
|
200
|
-
({ className, variant = 'outline', size = 'icon', ...props }, ref) => {
|
|
201
|
-
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<Button
|
|
205
|
-
ref={ref}
|
|
206
|
-
variant={variant}
|
|
207
|
-
size={size}
|
|
208
|
-
className={cn(
|
|
209
|
-
'absolute h-8 w-8 rounded-full',
|
|
210
|
-
orientation === 'horizontal'
|
|
211
|
-
? '-right-12 top-1/2 -translate-y-1/2'
|
|
212
|
-
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
|
|
213
|
-
className,
|
|
214
|
-
)}
|
|
215
|
-
disabled={!canScrollNext}
|
|
216
|
-
onClick={scrollNext}
|
|
217
|
-
{...props}
|
|
218
|
-
>
|
|
219
|
-
<ArrowRightIcon className="h-4 w-4" />
|
|
220
|
-
<span className="sr-only">Next slide</span>
|
|
221
|
-
</Button>
|
|
222
|
-
)
|
|
223
|
-
},
|
|
224
|
-
)
|
|
225
|
-
CarouselNext.displayName = 'CarouselNext'
|
|
226
|
-
|
|
227
|
-
export { type CarouselApi, type CarouselProps, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext }
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import { Checkbox } from './checkbox'
|
|
4
|
-
import { expect, userEvent, screen } from 'storybook/test'
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Checkbox',
|
|
8
|
-
component: Checkbox,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'centered',
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
variant: {
|
|
15
|
-
control: 'select',
|
|
16
|
-
options: ['default', 'simple', 'iconSolo'],
|
|
17
|
-
},
|
|
18
|
-
checkboxSize: {
|
|
19
|
-
control: 'select',
|
|
20
|
-
options: ['default', 'sm', 'lg'],
|
|
21
|
-
},
|
|
22
|
-
checkIcon: {
|
|
23
|
-
control: 'select',
|
|
24
|
-
options: ['default', 'check', 'square'],
|
|
25
|
-
},
|
|
26
|
-
iconStyle: {
|
|
27
|
-
control: 'select',
|
|
28
|
-
options: ['default', 'simple', 'solo'],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
} satisfies Meta<typeof Checkbox>
|
|
32
|
-
export default meta
|
|
33
|
-
|
|
34
|
-
type Story = StoryObj<typeof meta>
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {
|
|
37
|
-
args: { variant: 'default', checkboxSize: 'default', checkIcon: 'default', iconStyle: 'default' },
|
|
38
|
-
render: (args) => <Checkbox {...args} defaultChecked={true} label="Default" id="default-cb" />,
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const Variants: Story = {
|
|
42
|
-
render: () => (
|
|
43
|
-
<div className="flex flex-wrap gap-2">
|
|
44
|
-
<Checkbox defaultChecked={true} label="Default" variant="default" id="default-variant" />
|
|
45
|
-
<Checkbox
|
|
46
|
-
defaultChecked={true}
|
|
47
|
-
label="Simple (combined with iconStyle=simple)"
|
|
48
|
-
variant="simple"
|
|
49
|
-
iconStyle="simple"
|
|
50
|
-
id="simple-variant"
|
|
51
|
-
/>
|
|
52
|
-
<Checkbox
|
|
53
|
-
defaultChecked={true}
|
|
54
|
-
label="IconSolo (combined with iconStyle=solo)"
|
|
55
|
-
variant="iconSolo"
|
|
56
|
-
iconStyle="solo"
|
|
57
|
-
id="icon-solo-variant"
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
60
|
-
),
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const IconStyles: Story = {
|
|
64
|
-
render: () => (
|
|
65
|
-
<div className="flex flex-wrap gap-2">
|
|
66
|
-
<Checkbox defaultChecked={true} label="Default" iconStyle="default" id="default-icon-style" />
|
|
67
|
-
<Checkbox defaultChecked={true} label="Simple" iconStyle="simple" id="simple-icon-style" />
|
|
68
|
-
<Checkbox defaultChecked={true} label="Solo" iconStyle="solo" />
|
|
69
|
-
</div>
|
|
70
|
-
),
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const Sizes: Story = {
|
|
74
|
-
render: () => (
|
|
75
|
-
<div className="flex flex-wrap gap-2">
|
|
76
|
-
<Checkbox defaultChecked={true} label="Small" checkboxSize="sm" />
|
|
77
|
-
<Checkbox defaultChecked={true} label="Default" checkboxSize="default" id="default-size" />
|
|
78
|
-
<Checkbox defaultChecked={true} label="Large" checkboxSize="lg" />
|
|
79
|
-
</div>
|
|
80
|
-
),
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const CheckIcons: Story = {
|
|
84
|
-
render: () => (
|
|
85
|
-
<div className="flex flex-wrap gap-2">
|
|
86
|
-
<Checkbox defaultChecked={true} label="Default" checkIcon="default" id="default-icon" />
|
|
87
|
-
<Checkbox defaultChecked={true} label="Check" checkIcon="check" />
|
|
88
|
-
<Checkbox defaultChecked={true} label="Square" checkIcon="square" />
|
|
89
|
-
</div>
|
|
90
|
-
),
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const Disabled: Story = {
|
|
94
|
-
args: {
|
|
95
|
-
label: 'Disabled',
|
|
96
|
-
disabled: true,
|
|
97
|
-
},
|
|
98
|
-
render: (args) => <Checkbox {...args} data-testid="disabled-checkbox" />,
|
|
99
|
-
play: async () => {
|
|
100
|
-
const disabledCheckbox = screen.getByTestId('disabled-checkbox')
|
|
101
|
-
|
|
102
|
-
await expect(disabledCheckbox).toHaveAttribute('disabled')
|
|
103
|
-
|
|
104
|
-
await userEvent.click(disabledCheckbox, { pointerEventsCheck: 0 })
|
|
105
|
-
},
|
|
106
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { CheckIcon, Cross1Icon } from '@radix-ui/react-icons'
|
|
2
|
-
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
-
import { SquareIcon } from 'lucide-react'
|
|
5
|
-
|
|
6
|
-
import { cn } from '@lib/utils'
|
|
7
|
-
|
|
8
|
-
type CheckboxProps = React.ComponentProps<'input'> &
|
|
9
|
-
VariantProps<typeof checkboxVariants> & {
|
|
10
|
-
label?: string
|
|
11
|
-
/**
|
|
12
|
-
* E2E test_id to identify the checkbox.
|
|
13
|
-
*/
|
|
14
|
-
__e2e_test_id__?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const checkboxVariants = cva(
|
|
18
|
-
'cursor-pointer peer appearance-none rounded border focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive shrink-0 shadow-xs transition-shadow',
|
|
19
|
-
{
|
|
20
|
-
variants: {
|
|
21
|
-
variant: {
|
|
22
|
-
default: '',
|
|
23
|
-
simple: ' border-input checked:bg-muted-foreground checked:border-muted-foreground',
|
|
24
|
-
iconSolo: 'border-transparent shadow-none',
|
|
25
|
-
},
|
|
26
|
-
checkboxSize: {
|
|
27
|
-
default: 'size-4 [&_svg]:size-3.5',
|
|
28
|
-
sm: 'size-3.5 [&_svg]:size-3',
|
|
29
|
-
lg: 'size-4.5 [&_svg]:size-4',
|
|
30
|
-
},
|
|
31
|
-
checkIcon: {
|
|
32
|
-
default: 'cross',
|
|
33
|
-
check: 'check',
|
|
34
|
-
square: 'square',
|
|
35
|
-
},
|
|
36
|
-
iconStyle: {
|
|
37
|
-
default: 'text-foreground',
|
|
38
|
-
simple: 'text-primary-foreground',
|
|
39
|
-
solo: 'text-muted-foreground shadow-none',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
defaultVariants: {
|
|
43
|
-
variant: 'default',
|
|
44
|
-
checkIcon: 'default',
|
|
45
|
-
iconStyle: 'default',
|
|
46
|
-
checkboxSize: 'default',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
function Checkbox({
|
|
52
|
-
label,
|
|
53
|
-
className,
|
|
54
|
-
variant,
|
|
55
|
-
checkIcon,
|
|
56
|
-
checkboxSize,
|
|
57
|
-
iconStyle,
|
|
58
|
-
__e2e_test_id__,
|
|
59
|
-
...props
|
|
60
|
-
}: CheckboxProps) {
|
|
61
|
-
const inputId = props.id ?? (label ? `${label}-checkbox` : undefined)
|
|
62
|
-
|
|
63
|
-
let icon = <Cross1Icon />
|
|
64
|
-
if (checkIcon === 'check') {
|
|
65
|
-
icon = <CheckIcon />
|
|
66
|
-
} else if (checkIcon === 'square') {
|
|
67
|
-
icon = <SquareIcon fill="var(--muted-foreground)" className="size-1/3" />
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div className={cn('relative flex gap-2 items-center', className)} data-test-id={__e2e_test_id__}>
|
|
72
|
-
<input {...props} type="checkbox" id={inputId} className={cn(checkboxVariants({ variant, checkboxSize }))} />
|
|
73
|
-
<span
|
|
74
|
-
className={cn(
|
|
75
|
-
checkboxVariants({ iconStyle, checkboxSize }),
|
|
76
|
-
'absolute opacity-0 peer-checked:opacity-100 top-1/2 left-0 transform -translate-y-1/2 pointer-events-none flex items-center justify-center border-transparent',
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
{icon}
|
|
80
|
-
</span>
|
|
81
|
-
<label htmlFor={inputId} className="cursor-pointer select-none">
|
|
82
|
-
{label}
|
|
83
|
-
</label>
|
|
84
|
-
</div>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export { Checkbox, checkboxVariants }
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import { Checkbox } from './shadcn-checkbox'
|
|
4
|
-
import { expect, userEvent, screen } from 'storybook/test'
|
|
5
|
-
import { Label } from '@components/ui/label/label'
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
title: 'ShadcnCheckbox',
|
|
9
|
-
component: Checkbox,
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
},
|
|
14
|
-
argTypes: {
|
|
15
|
-
variant: {
|
|
16
|
-
control: 'select',
|
|
17
|
-
options: ['default'],
|
|
18
|
-
},
|
|
19
|
-
size: {
|
|
20
|
-
control: 'select',
|
|
21
|
-
options: ['default', 'sm'],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
} satisfies Meta<typeof Checkbox>
|
|
25
|
-
export default meta
|
|
26
|
-
|
|
27
|
-
type Story = StoryObj<typeof meta>
|
|
28
|
-
|
|
29
|
-
export const Default: Story = {
|
|
30
|
-
args: { variant: 'default', size: 'default' },
|
|
31
|
-
render: (args) => (
|
|
32
|
-
<div className="flex flex-wrap gap-2">
|
|
33
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
34
|
-
<Checkbox id="default-cb" {...args} />
|
|
35
|
-
<Label htmlFor="default-cb">Default</Label>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
),
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const Variants: Story = {
|
|
42
|
-
render: () => (
|
|
43
|
-
<div className="flex flex-wrap gap-2">
|
|
44
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
45
|
-
<Checkbox id="default-variant" variant="default" defaultChecked={true} />
|
|
46
|
-
<Label htmlFor="default-variant">Default</Label>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
),
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const Sizes: Story = {
|
|
53
|
-
render: () => (
|
|
54
|
-
<div className="flex flex-wrap gap-2">
|
|
55
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
56
|
-
<Checkbox id="sm" size="sm" />
|
|
57
|
-
<Label htmlFor="sm">sm</Label>
|
|
58
|
-
</div>
|
|
59
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
60
|
-
<Checkbox id="default-size" size="default" />
|
|
61
|
-
<Label htmlFor="default-size">Default</Label>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
),
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export const Disabled: Story = {
|
|
68
|
-
args: {
|
|
69
|
-
disabled: true,
|
|
70
|
-
},
|
|
71
|
-
render: (args) => (
|
|
72
|
-
<div className="flex flex-wrap gap-2">
|
|
73
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
74
|
-
<Checkbox id="disabled" {...args} data-testid="disabled-checkbox" defaultChecked={false} />
|
|
75
|
-
<Label htmlFor="disabled">Disabled</Label>
|
|
76
|
-
</div>
|
|
77
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
78
|
-
<Checkbox id="disabled" {...args} data-testid="disabled-checkbox-active" defaultChecked={true} />
|
|
79
|
-
<Label htmlFor="disabled">Disabled active</Label>
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
),
|
|
83
|
-
play: async () => {
|
|
84
|
-
const disabledCheckbox = screen.getByTestId('disabled-checkbox')
|
|
85
|
-
|
|
86
|
-
await expect(disabledCheckbox).toHaveAttribute('disabled')
|
|
87
|
-
|
|
88
|
-
await userEvent.click(disabledCheckbox, { pointerEventsCheck: 0 })
|
|
89
|
-
},
|
|
90
|
-
}
|