@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,54 +0,0 @@
|
|
|
1
|
-
import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
|
|
2
|
-
import { CheckIcon } from '@radix-ui/react-icons'
|
|
3
|
-
|
|
4
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
-
import * as React from 'react'
|
|
6
|
-
|
|
7
|
-
import { cn } from '@lib/utils'
|
|
8
|
-
|
|
9
|
-
const checkboxVariants = cva(
|
|
10
|
-
'cursor-pointer peer border-input dark:bg-input/30 data-[state=checked]:text-primary-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
|
11
|
-
{
|
|
12
|
-
variants: {
|
|
13
|
-
variant: {
|
|
14
|
-
default: 'data-[state=checked]:bg-primary data-[state=checked]:border-primary',
|
|
15
|
-
},
|
|
16
|
-
size: {
|
|
17
|
-
default: 'size-4 [&_svg]:size-3.5',
|
|
18
|
-
sm: 'size-3.5 [&_svg]:size-3',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
defaultVariants: {
|
|
22
|
-
variant: 'default',
|
|
23
|
-
size: 'default',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
type CheckboxProps = React.ComponentProps<typeof CheckboxPrimitive.Root> &
|
|
29
|
-
VariantProps<typeof checkboxVariants> & {
|
|
30
|
-
/**
|
|
31
|
-
* E2E test_id to identify the button.
|
|
32
|
-
*/
|
|
33
|
-
__e2e_test_id__?: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function Checkbox({ className, variant, size, __e2e_test_id__, ...props }: CheckboxProps) {
|
|
37
|
-
return (
|
|
38
|
-
<CheckboxPrimitive.Root
|
|
39
|
-
data-slot="checkbox"
|
|
40
|
-
className={cn(checkboxVariants({ variant, size, className }))}
|
|
41
|
-
{...props}
|
|
42
|
-
data-test-id={__e2e_test_id__}
|
|
43
|
-
>
|
|
44
|
-
<CheckboxPrimitive.Indicator
|
|
45
|
-
data-slot="checkbox-indicator"
|
|
46
|
-
className="flex items-center justify-center text-current transition-none"
|
|
47
|
-
>
|
|
48
|
-
<CheckIcon />
|
|
49
|
-
</CheckboxPrimitive.Indicator>
|
|
50
|
-
</CheckboxPrimitive.Root>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { Checkbox, checkboxVariants }
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { CaretSortIcon } from '@radix-ui/react-icons'
|
|
2
|
-
import { Meta, StoryObj } from '@storybook/react-vite'
|
|
3
|
-
|
|
4
|
-
import { useState } from 'react'
|
|
5
|
-
|
|
6
|
-
import { Button } from '@components/ui/button/button'
|
|
7
|
-
|
|
8
|
-
import { Collapse, CollapseContent, CollapseTrigger } from './collapse'
|
|
9
|
-
|
|
10
|
-
const meta = {
|
|
11
|
-
title: 'Collapse',
|
|
12
|
-
component: Collapse,
|
|
13
|
-
tags: ['autodocs'],
|
|
14
|
-
} satisfies Meta<typeof Collapse>
|
|
15
|
-
|
|
16
|
-
export default meta
|
|
17
|
-
|
|
18
|
-
function CollapseExample() {
|
|
19
|
-
const [isOpen, setIsOpen] = useState(false)
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<div className="flex items-center justify-center border rounded p-4">
|
|
23
|
-
<Collapse open={isOpen} onOpenChange={setIsOpen} className="w-[350px] space-y-2">
|
|
24
|
-
<div className="flex items-center justify-between space-x-4 px-4">
|
|
25
|
-
<h4 className="text-sm font-semibold">You have made 3 commits</h4>
|
|
26
|
-
<CollapseTrigger asChild>
|
|
27
|
-
<Button variant="ghost" size="sm">
|
|
28
|
-
<CaretSortIcon className="h-4 w-4" />
|
|
29
|
-
<span className="sr-only">Toggle</span>
|
|
30
|
-
</Button>
|
|
31
|
-
</CollapseTrigger>
|
|
32
|
-
</div>
|
|
33
|
-
<div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm">@radix-ui/primitives</div>
|
|
34
|
-
<CollapseContent className="space-y-2">
|
|
35
|
-
<div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm">@radix-ui/colors</div>
|
|
36
|
-
<div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm">@stitches/react</div>
|
|
37
|
-
</CollapseContent>
|
|
38
|
-
</Collapse>
|
|
39
|
-
</div>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const Default: StoryObj<typeof meta> = {
|
|
44
|
-
parameters: {
|
|
45
|
-
docs: {
|
|
46
|
-
description: {
|
|
47
|
-
story: 'The Collapse component allows you to show and hide content.',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
render: () => <CollapseExample />,
|
|
52
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as CollapsePrimitive from '@radix-ui/react-collapsible'
|
|
2
|
-
|
|
3
|
-
const Collapse = CollapsePrimitive.Root
|
|
4
|
-
|
|
5
|
-
const CollapseTrigger = CollapsePrimitive.CollapsibleTrigger
|
|
6
|
-
|
|
7
|
-
const CollapseContent = CollapsePrimitive.CollapsibleContent
|
|
8
|
-
|
|
9
|
-
export { Collapse, CollapseTrigger, CollapseContent }
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import { ComboboxDemo } from './combobox'
|
|
4
|
-
import { useState } from 'react'
|
|
5
|
-
import { Button } from '@components/ui/button/button'
|
|
6
|
-
import {
|
|
7
|
-
CommandPalette,
|
|
8
|
-
CommandPaletteEmpty,
|
|
9
|
-
CommandPaletteGroup,
|
|
10
|
-
CommandPaletteInput,
|
|
11
|
-
CommandPaletteItem,
|
|
12
|
-
CommandPaletteList,
|
|
13
|
-
} from '@components/ui/command-palette/command-palette'
|
|
14
|
-
import { Popover, PopoverContent, PopoverTrigger } from '@components/ui/popover/popover'
|
|
15
|
-
import {
|
|
16
|
-
DropdownMenu,
|
|
17
|
-
DropdownMenuContent,
|
|
18
|
-
DropdownMenuGroup,
|
|
19
|
-
DropdownMenuItem,
|
|
20
|
-
DropdownMenuLabel,
|
|
21
|
-
DropdownMenuSeparator,
|
|
22
|
-
DropdownMenuShortcut,
|
|
23
|
-
DropdownMenuSub,
|
|
24
|
-
DropdownMenuSubContent,
|
|
25
|
-
DropdownMenuSubTrigger,
|
|
26
|
-
DropdownMenuTrigger,
|
|
27
|
-
} from 'components/ui/dropdown-menu/dropdown-menu'
|
|
28
|
-
import { DotsHorizontalIcon } from '@radix-ui/react-icons'
|
|
29
|
-
|
|
30
|
-
// DATA ------------------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
const labels = ['feature', 'bug', 'enhancement', 'documentation', 'design', 'question', 'maintenance']
|
|
33
|
-
|
|
34
|
-
type Status = {
|
|
35
|
-
value: string
|
|
36
|
-
label: string
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const statuses: Status[] = [
|
|
40
|
-
{
|
|
41
|
-
value: 'backlog',
|
|
42
|
-
label: 'Backlog',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
value: 'todo',
|
|
46
|
-
label: 'Todo',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
value: 'in progress',
|
|
50
|
-
label: 'In Progress',
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
value: 'done',
|
|
54
|
-
label: 'Done',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
value: 'canceled',
|
|
58
|
-
label: 'Canceled',
|
|
59
|
-
},
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
const meta = {
|
|
63
|
-
title: 'Combobox',
|
|
64
|
-
component: ComboboxDemo,
|
|
65
|
-
tags: ['autodocs'],
|
|
66
|
-
} satisfies Meta<typeof ComboboxDemo>
|
|
67
|
-
|
|
68
|
-
export default meta
|
|
69
|
-
type Story = StoryObj<typeof meta>
|
|
70
|
-
|
|
71
|
-
export const Default: Story = {
|
|
72
|
-
parameters: {
|
|
73
|
-
docs: {
|
|
74
|
-
description: {
|
|
75
|
-
story: 'A basic combobox component with search and selection functionality.',
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
render: () => (
|
|
80
|
-
<div className="flex items-center justify-center">
|
|
81
|
-
<ComboboxDemo />
|
|
82
|
-
</div>
|
|
83
|
-
),
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const PopoverComboboxExample = () => {
|
|
87
|
-
const [openPopover, setOpenPopover] = useState(false)
|
|
88
|
-
const [selectedStatus, setSelectedStatus] = useState<Status | null>(null)
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<div className="flex items-center space-x-4">
|
|
92
|
-
<p className="text-sm text-muted-foreground">Status</p>
|
|
93
|
-
<Popover open={openPopover} onOpenChange={setOpenPopover}>
|
|
94
|
-
<PopoverTrigger asChild>
|
|
95
|
-
<Button variant="outline" className="w-[150px] justify-start">
|
|
96
|
-
{selectedStatus ? <>{selectedStatus.label}</> : <>+ Set status</>}
|
|
97
|
-
</Button>
|
|
98
|
-
</PopoverTrigger>
|
|
99
|
-
<PopoverContent className="p-0" side="right" align="start">
|
|
100
|
-
<CommandPalette>
|
|
101
|
-
<CommandPaletteInput placeholder="Change status..." />
|
|
102
|
-
<CommandPaletteList>
|
|
103
|
-
<CommandPaletteEmpty>No results found.</CommandPaletteEmpty>
|
|
104
|
-
<CommandPaletteGroup>
|
|
105
|
-
{statuses.map((status) => (
|
|
106
|
-
<CommandPaletteItem
|
|
107
|
-
key={status.value}
|
|
108
|
-
value={status.value}
|
|
109
|
-
onSelect={(value) => {
|
|
110
|
-
setSelectedStatus(statuses.find((priority) => priority.value === value) || null)
|
|
111
|
-
setOpenPopover(false)
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
{status.label}
|
|
115
|
-
</CommandPaletteItem>
|
|
116
|
-
))}
|
|
117
|
-
</CommandPaletteGroup>
|
|
118
|
-
</CommandPaletteList>
|
|
119
|
-
</CommandPalette>
|
|
120
|
-
</PopoverContent>
|
|
121
|
-
</Popover>
|
|
122
|
-
</div>
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export const WithPopover: Story = {
|
|
127
|
-
parameters: {
|
|
128
|
-
docs: {
|
|
129
|
-
description: {
|
|
130
|
-
story: 'A combobox implemented using a popover with status selection functionality.',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
render: () => <PopoverComboboxExample />,
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const DropdownMenuComboboxExample = () => {
|
|
138
|
-
const [label, setLabel] = useState('feature')
|
|
139
|
-
const [openDropdown, setOpenDropdown] = useState(false)
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div className="flex items-center justify-center">
|
|
143
|
-
<div className="flex w-full flex-col items-start justify-between rounded-md border px-4 py-3 sm:flex-row sm:items-center">
|
|
144
|
-
<p className="text-sm font-medium leading-none">
|
|
145
|
-
<span className="mr-2 rounded-lg bg-primary px-2 py-1 text-xs text-primary-foreground">{label}</span>
|
|
146
|
-
<span className="text-muted-foreground">Create a new project</span>
|
|
147
|
-
</p>
|
|
148
|
-
<DropdownMenu open={openDropdown} onOpenChange={setOpenDropdown}>
|
|
149
|
-
<DropdownMenuTrigger asChild>
|
|
150
|
-
<Button variant="ghost" size="sm">
|
|
151
|
-
<DotsHorizontalIcon />
|
|
152
|
-
</Button>
|
|
153
|
-
</DropdownMenuTrigger>
|
|
154
|
-
<DropdownMenuContent align="end" className="w-[200px]">
|
|
155
|
-
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
|
156
|
-
<DropdownMenuGroup>
|
|
157
|
-
<DropdownMenuItem>Assign to...</DropdownMenuItem>
|
|
158
|
-
<DropdownMenuItem>Set due date...</DropdownMenuItem>
|
|
159
|
-
<DropdownMenuSeparator />
|
|
160
|
-
<DropdownMenuSub>
|
|
161
|
-
<DropdownMenuSubTrigger>Apply label</DropdownMenuSubTrigger>
|
|
162
|
-
<DropdownMenuSubContent className="p-0">
|
|
163
|
-
<CommandPalette>
|
|
164
|
-
<CommandPaletteInput placeholder="Filter label..." autoFocus={true} className="h-9" />
|
|
165
|
-
<CommandPaletteList>
|
|
166
|
-
<CommandPaletteEmpty>No label found.</CommandPaletteEmpty>
|
|
167
|
-
<DropdownMenuGroup>
|
|
168
|
-
{labels.map((label) => (
|
|
169
|
-
<CommandPaletteItem
|
|
170
|
-
key={label}
|
|
171
|
-
value={label}
|
|
172
|
-
onSelect={(value) => {
|
|
173
|
-
setLabel(value)
|
|
174
|
-
setOpenDropdown(false)
|
|
175
|
-
}}
|
|
176
|
-
>
|
|
177
|
-
{label}
|
|
178
|
-
</CommandPaletteItem>
|
|
179
|
-
))}
|
|
180
|
-
</DropdownMenuGroup>
|
|
181
|
-
</CommandPaletteList>
|
|
182
|
-
</CommandPalette>
|
|
183
|
-
</DropdownMenuSubContent>
|
|
184
|
-
</DropdownMenuSub>
|
|
185
|
-
<DropdownMenuSeparator />
|
|
186
|
-
<DropdownMenuItem className="text-red-600">
|
|
187
|
-
Delete
|
|
188
|
-
<DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
|
|
189
|
-
</DropdownMenuItem>
|
|
190
|
-
</DropdownMenuGroup>
|
|
191
|
-
</DropdownMenuContent>
|
|
192
|
-
</DropdownMenu>
|
|
193
|
-
</div>
|
|
194
|
-
</div>
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export const WithDropdownMenu: Story = {
|
|
199
|
-
parameters: {
|
|
200
|
-
docs: {
|
|
201
|
-
description: {
|
|
202
|
-
story: 'A combobox integrated within a dropdown menu for label selection with project management actions.',
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
render: () => <DropdownMenuComboboxExample />,
|
|
207
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { CaretSortIcon, CheckIcon } from '@radix-ui/react-icons'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
|
|
5
|
-
import { Button } from '@components/ui/button/button'
|
|
6
|
-
import {
|
|
7
|
-
CommandPalette,
|
|
8
|
-
CommandPaletteEmpty,
|
|
9
|
-
CommandPaletteGroup,
|
|
10
|
-
CommandPaletteInput,
|
|
11
|
-
CommandPaletteItem,
|
|
12
|
-
CommandPaletteList,
|
|
13
|
-
} from '@components/ui/command-palette/command-palette'
|
|
14
|
-
import { Popover, PopoverContent, PopoverTrigger } from '@components/ui/popover/popover'
|
|
15
|
-
import { cn } from '@lib/utils'
|
|
16
|
-
|
|
17
|
-
const frameworks = [
|
|
18
|
-
{
|
|
19
|
-
value: 'next.js',
|
|
20
|
-
label: 'Next.js',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
value: 'sveltekit',
|
|
24
|
-
label: 'SvelteKit',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
value: 'nuxt.js',
|
|
28
|
-
label: 'Nuxt.js',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
value: 'remix',
|
|
32
|
-
label: 'Remix',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
value: 'astro',
|
|
36
|
-
label: 'Astro',
|
|
37
|
-
},
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
export function ComboboxDemo() {
|
|
41
|
-
const [open, setOpen] = React.useState(false)
|
|
42
|
-
const [value, setValue] = React.useState('')
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
46
|
-
<PopoverTrigger asChild>
|
|
47
|
-
<Button variant="outline" aria-expanded={open} className="w-[200px] justify-between">
|
|
48
|
-
{value ? frameworks.find((framework) => framework.value === value)?.label : 'Select framework...'}
|
|
49
|
-
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
50
|
-
</Button>
|
|
51
|
-
</PopoverTrigger>
|
|
52
|
-
<PopoverContent className="w-[200px] p-0">
|
|
53
|
-
<CommandPalette>
|
|
54
|
-
<CommandPaletteInput placeholder="Search framework..." className="h-9" />
|
|
55
|
-
<CommandPaletteList>
|
|
56
|
-
<CommandPaletteEmpty>No framework found.</CommandPaletteEmpty>
|
|
57
|
-
<CommandPaletteGroup>
|
|
58
|
-
{frameworks.map((framework) => (
|
|
59
|
-
<CommandPaletteItem
|
|
60
|
-
key={framework.value}
|
|
61
|
-
value={framework.value}
|
|
62
|
-
onSelect={(currentValue) => {
|
|
63
|
-
setValue(currentValue === value ? '' : currentValue)
|
|
64
|
-
setOpen(false)
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
{framework.label}
|
|
68
|
-
<CheckIcon
|
|
69
|
-
className={cn('ml-auto h-4 w-4', value === framework.value ? 'opacity-100' : 'opacity-0')}
|
|
70
|
-
/>
|
|
71
|
-
</CommandPaletteItem>
|
|
72
|
-
))}
|
|
73
|
-
</CommandPaletteGroup>
|
|
74
|
-
</CommandPaletteList>
|
|
75
|
-
</CommandPalette>
|
|
76
|
-
</PopoverContent>
|
|
77
|
-
</Popover>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Command,
|
|
5
|
-
CommandEmpty,
|
|
6
|
-
CommandInput,
|
|
7
|
-
CommandItem,
|
|
8
|
-
CommandList,
|
|
9
|
-
CommandGroup,
|
|
10
|
-
CommandSeparator,
|
|
11
|
-
CommandShortcut,
|
|
12
|
-
CommandInputProps,
|
|
13
|
-
} from './command'
|
|
14
|
-
import { expect, userEvent, waitFor, screen } from 'storybook/test'
|
|
15
|
-
import { useState } from 'storybook/preview-api'
|
|
16
|
-
|
|
17
|
-
const CommandWithInput = ({
|
|
18
|
-
variant: inputVariant,
|
|
19
|
-
inputSize,
|
|
20
|
-
showContent = true,
|
|
21
|
-
searchValue,
|
|
22
|
-
setSearchValue,
|
|
23
|
-
placeholder,
|
|
24
|
-
...rest
|
|
25
|
-
}: CommandProps & { showContent?: boolean } & { searchValue?: string } & {
|
|
26
|
-
setSearchValue?: (val: string) => void
|
|
27
|
-
}) => (
|
|
28
|
-
<Command {...rest} className="w-[250px] border">
|
|
29
|
-
<CommandInput
|
|
30
|
-
placeholder={placeholder}
|
|
31
|
-
variant={inputVariant}
|
|
32
|
-
inputSize={inputSize}
|
|
33
|
-
value={searchValue}
|
|
34
|
-
onValueChange={(val) => {
|
|
35
|
-
setSearchValue?.(val)
|
|
36
|
-
}}
|
|
37
|
-
/>
|
|
38
|
-
{showContent && (
|
|
39
|
-
<CommandList>
|
|
40
|
-
<CommandEmpty>No results found.</CommandEmpty>
|
|
41
|
-
<CommandGroup heading="Category 1">
|
|
42
|
-
<CommandItem>
|
|
43
|
-
<span>Item</span>
|
|
44
|
-
</CommandItem>
|
|
45
|
-
<CommandItem disabled>
|
|
46
|
-
<span>Disabled item</span>
|
|
47
|
-
</CommandItem>
|
|
48
|
-
</CommandGroup>
|
|
49
|
-
<CommandSeparator />
|
|
50
|
-
<CommandGroup heading="Category 2">
|
|
51
|
-
<CommandItem>
|
|
52
|
-
<span>With shortcut</span>
|
|
53
|
-
<CommandShortcut>⌘P (only visually)</CommandShortcut>
|
|
54
|
-
</CommandItem>
|
|
55
|
-
</CommandGroup>
|
|
56
|
-
</CommandList>
|
|
57
|
-
)}
|
|
58
|
-
</Command>
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
const meta = {
|
|
62
|
-
title: 'Command',
|
|
63
|
-
component: CommandWithInput,
|
|
64
|
-
tags: ['autodocs'],
|
|
65
|
-
parameters: {
|
|
66
|
-
layout: 'centered',
|
|
67
|
-
},
|
|
68
|
-
argTypes: {
|
|
69
|
-
inputVariant: {
|
|
70
|
-
control: 'select',
|
|
71
|
-
options: ['default', 'borderless'],
|
|
72
|
-
},
|
|
73
|
-
inputSize: {
|
|
74
|
-
control: 'select',
|
|
75
|
-
options: ['md', 'sm', 'lg'],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
export default meta
|
|
80
|
-
|
|
81
|
-
interface CommandStoryArgs {
|
|
82
|
-
inputVariant?: 'default' | 'borderless'
|
|
83
|
-
inputSize?: 'md' | 'sm' | 'lg'
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
type Story = StoryObj<CommandStoryArgs>
|
|
87
|
-
|
|
88
|
-
type CommandProps = CommandInputProps &
|
|
89
|
-
React.ComponentProps<typeof Command> & {
|
|
90
|
-
inputVariant?: 'default' | 'borderless'
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const Default: Story = {
|
|
94
|
-
render: (args) => (
|
|
95
|
-
<CommandWithInput
|
|
96
|
-
variant={args.inputVariant}
|
|
97
|
-
inputSize={args.inputSize}
|
|
98
|
-
placeholder="Command with border and w-[250px]"
|
|
99
|
-
/>
|
|
100
|
-
),
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export const InputVariants: Story = {
|
|
104
|
-
render: () => (
|
|
105
|
-
<div className="flex flex-wrap gap-4">
|
|
106
|
-
<CommandWithInput variant="default" inputSize="md" placeholder="Command with border and w-[250px]" />
|
|
107
|
-
<CommandWithInput variant="borderless" inputSize="md" placeholder="Command with border and w-[250px]" />
|
|
108
|
-
</div>
|
|
109
|
-
),
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export const InputSizes: Story = {
|
|
113
|
-
render: () => (
|
|
114
|
-
<div className="flex flex-wrap gap-4 items-center">
|
|
115
|
-
<CommandWithInput
|
|
116
|
-
variant="borderless"
|
|
117
|
-
inputSize="sm"
|
|
118
|
-
showContent={false}
|
|
119
|
-
placeholder="Command with border and w-[250px]"
|
|
120
|
-
/>
|
|
121
|
-
<CommandWithInput
|
|
122
|
-
variant="borderless"
|
|
123
|
-
inputSize="md"
|
|
124
|
-
showContent={false}
|
|
125
|
-
placeholder="Command with border and w-[250px]"
|
|
126
|
-
/>
|
|
127
|
-
<CommandWithInput
|
|
128
|
-
variant="borderless"
|
|
129
|
-
inputSize="lg"
|
|
130
|
-
showContent={false}
|
|
131
|
-
placeholder="Command with border and w-[250px]"
|
|
132
|
-
/>
|
|
133
|
-
</div>
|
|
134
|
-
),
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export const InteractiveExample: Story = {
|
|
138
|
-
render: () => {
|
|
139
|
-
const [open, setOpen] = useState(false)
|
|
140
|
-
const [searchValue, setSearchValue] = useState('')
|
|
141
|
-
return (
|
|
142
|
-
<CommandWithInput
|
|
143
|
-
variant={open ? 'default' : 'borderless'}
|
|
144
|
-
inputSize="md"
|
|
145
|
-
placeholder="Type a command or search..."
|
|
146
|
-
searchValue={searchValue}
|
|
147
|
-
setSearchValue={(val) => {
|
|
148
|
-
setSearchValue(val)
|
|
149
|
-
}}
|
|
150
|
-
showContent={open}
|
|
151
|
-
onBlur={() => {
|
|
152
|
-
setOpen(false)
|
|
153
|
-
setSearchValue('')
|
|
154
|
-
}}
|
|
155
|
-
onFocus={() => setOpen(true)}
|
|
156
|
-
/>
|
|
157
|
-
)
|
|
158
|
-
},
|
|
159
|
-
play: async () => {
|
|
160
|
-
const input = screen.getByPlaceholderText('Type a command or search...')
|
|
161
|
-
|
|
162
|
-
// 1. Dropdown should be closed initially
|
|
163
|
-
await expect(screen.queryByText('Category 1')).toBeNull()
|
|
164
|
-
// 2. Focus input, dropdown opens
|
|
165
|
-
await userEvent.click(input)
|
|
166
|
-
// await expect(await screen.findByText('Category 1')).toBeVisible()
|
|
167
|
-
// 3. Type to filter items
|
|
168
|
-
await userEvent.type(input, 'Item')
|
|
169
|
-
// await expect(await screen.findByText('Item')).toBeVisible()
|
|
170
|
-
await expect(screen.queryByText('With shortcut')).toBeNull()
|
|
171
|
-
// 4. Clear input, all items visible again
|
|
172
|
-
await userEvent.clear(input)
|
|
173
|
-
// await expect(await screen.findByText('Category 1')).toBeVisible()
|
|
174
|
-
// await expect(await screen.findByText('With shortcut')).toBeVisible()
|
|
175
|
-
// 5. Blur input, dropdown closes
|
|
176
|
-
await userEvent.tab()
|
|
177
|
-
await waitFor(() => {
|
|
178
|
-
const el = screen.queryByText('Category 1')
|
|
179
|
-
expect(!el || el.getAttribute('aria-hidden') === 'true').toBe(true)
|
|
180
|
-
})
|
|
181
|
-
// 6. check that value is reset correctly
|
|
182
|
-
const inputField = screen.getByPlaceholderText('Type a command or search...')
|
|
183
|
-
await expect(inputField).toHaveValue('')
|
|
184
|
-
await expect(inputField).not.toHaveFocus()
|
|
185
|
-
},
|
|
186
|
-
}
|