@teamix-evo/ui 0.2.0 → 0.3.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/README.md +184 -184
- package/manifest.json +680 -492
- package/package.json +15 -9
- package/src/components/accordion/accordion.meta.md +5 -9
- package/src/components/accordion/accordion.stories.tsx +3 -3
- package/src/components/accordion/accordion.tsx +104 -8
- package/src/components/affix/affix.meta.md +21 -12
- package/src/components/affix/affix.stories.tsx +101 -26
- package/src/components/affix/affix.tsx +79 -9
- package/src/components/alert/alert.meta.md +52 -26
- package/src/components/alert/alert.stories.tsx +66 -21
- package/src/components/alert/alert.tsx +81 -34
- package/src/components/alert-dialog/alert-dialog.meta.md +48 -16
- package/src/components/alert-dialog/alert-dialog.stories.tsx +145 -3
- package/src/components/alert-dialog/alert-dialog.tsx +60 -13
- package/src/components/anchor/anchor.meta.md +10 -14
- package/src/components/anchor/anchor.stories.tsx +3 -3
- package/src/components/anchor/anchor.tsx +2 -2
- package/src/components/app/app.meta.md +10 -14
- package/src/components/app/app.stories.tsx +6 -6
- package/src/components/aspect-ratio/aspect-ratio.meta.md +4 -8
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +3 -3
- package/src/components/auto-complete/auto-complete.meta.md +19 -20
- package/src/components/auto-complete/auto-complete.stories.tsx +44 -3
- package/src/components/auto-complete/auto-complete.tsx +119 -71
- package/src/components/avatar/avatar.meta.md +9 -22
- package/src/components/avatar/avatar.stories.tsx +21 -3
- package/src/components/avatar/avatar.tsx +24 -23
- package/src/components/badge/badge.meta.md +14 -18
- package/src/components/badge/badge.stories.tsx +2 -2
- package/src/components/badge/badge.tsx +2 -2
- package/src/components/breadcrumb/breadcrumb.meta.md +29 -20
- package/src/components/breadcrumb/breadcrumb.stories.tsx +120 -5
- package/src/components/breadcrumb/breadcrumb.tsx +22 -8
- package/src/components/button/button.meta.md +261 -29
- package/src/components/button/button.stories.tsx +549 -41
- package/src/components/button/button.tsx +335 -33
- package/src/components/calendar/calendar.meta.md +19 -14
- package/src/components/calendar/calendar.stories.tsx +5 -5
- package/src/components/calendar/calendar.tsx +73 -8
- package/src/components/card/card.meta.md +31 -34
- package/src/components/card/card.stories.tsx +34 -3
- package/src/components/card/card.tsx +146 -63
- package/src/components/carousel/carousel.meta.md +10 -14
- package/src/components/carousel/carousel.stories.tsx +1 -1
- package/src/components/cascader/cascader.meta.md +43 -22
- package/src/components/cascader/cascader.stories.tsx +13 -2
- package/src/components/cascader/cascader.tsx +427 -84
- package/src/components/checkbox/checkbox.meta.md +74 -24
- package/src/components/checkbox/checkbox.stories.tsx +160 -2
- package/src/components/checkbox/checkbox.tsx +77 -9
- package/src/components/collapsible/collapsible.meta.md +7 -6
- package/src/components/collapsible/collapsible.stories.tsx +2 -2
- package/src/components/collapsible/collapsible.tsx +93 -6
- package/src/components/color-picker/color-picker.meta.md +16 -20
- package/src/components/color-picker/color-picker.stories.tsx +86 -7
- package/src/components/color-picker/color-picker.tsx +19 -9
- package/src/components/command/command.meta.md +7 -11
- package/src/components/command/command.stories.tsx +4 -4
- package/src/components/command/command.tsx +18 -7
- package/src/components/context-menu/context-menu.meta.md +5 -25
- package/src/components/context-menu/context-menu.stories.tsx +4 -4
- package/src/components/context-menu/context-menu.tsx +21 -8
- package/src/components/data-table/data-table.meta.md +14 -18
- package/src/components/data-table/data-table.stories.tsx +1 -1
- package/src/components/data-table/data-table.tsx +2 -2
- package/src/components/date-picker/date-picker.meta.md +90 -41
- package/src/components/date-picker/date-picker.stories.tsx +55 -5
- package/src/components/date-picker/date-picker.tsx +1489 -91
- package/src/components/descriptions/descriptions.meta.md +12 -16
- package/src/components/descriptions/descriptions.stories.tsx +2 -2
- package/src/components/descriptions/descriptions.tsx +22 -14
- package/src/components/dialog/dialog.meta.md +67 -17
- package/src/components/dialog/dialog.stories.tsx +182 -20
- package/src/components/dialog/dialog.tsx +67 -15
- package/src/components/dialog/imperative.tsx +252 -0
- package/src/components/drawer/drawer.meta.md +27 -39
- package/src/components/drawer/drawer.stories.tsx +29 -12
- package/src/components/drawer/drawer.tsx +22 -114
- package/src/components/dropdown-menu/dropdown-menu.meta.md +64 -24
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +81 -3
- package/src/components/dropdown-menu/dropdown-menu.tsx +24 -10
- package/src/components/ellipsis/ellipsis.meta.md +87 -0
- package/src/components/ellipsis/ellipsis.stories.tsx +72 -0
- package/src/components/ellipsis/ellipsis.tsx +153 -0
- package/src/components/empty/empty.meta.md +10 -14
- package/src/components/empty/empty.stories.tsx +3 -3
- package/src/components/empty/empty.tsx +10 -3
- package/src/components/field/field.meta.md +46 -25
- package/src/components/field/field.stories.tsx +380 -3
- package/src/components/field/field.tsx +263 -35
- package/src/components/filter-bar/filter-bar.meta.md +92 -0
- package/src/components/filter-bar/filter-bar.stories.tsx +1083 -0
- package/src/components/filter-bar/filter-bar.tsx +568 -0
- package/src/components/flex/flex.meta.md +59 -20
- package/src/components/flex/flex.stories.tsx +65 -10
- package/src/components/flex/flex.tsx +27 -4
- package/src/components/float-button/float-button.meta.md +10 -29
- package/src/components/float-button/float-button.stories.tsx +6 -6
- package/src/components/form/form.meta.md +31 -52
- package/src/components/form/form.stories.tsx +350 -3
- package/src/components/form/form.tsx +101 -35
- package/src/components/grid/grid.meta.md +4 -24
- package/src/components/grid/grid.stories.tsx +2 -2
- package/src/components/hover-card/hover-card.meta.md +9 -10
- package/src/components/hover-card/hover-card.stories.tsx +29 -4
- package/src/components/hover-card/hover-card.tsx +51 -13
- package/src/components/icon/DEVELOPMENT.md +809 -0
- package/src/components/icon/icon.meta.md +170 -0
- package/src/components/icon/icon.stories.tsx +344 -0
- package/src/components/icon/icon.tsx +248 -0
- package/src/components/image/image.meta.md +14 -18
- package/src/components/image/image.stories.tsx +3 -3
- package/src/components/image/image.tsx +2 -0
- package/src/components/input/demo/sizes.tsx +2 -2
- package/src/components/input/input.meta.md +44 -43
- package/src/components/input/input.stories.tsx +62 -35
- package/src/components/input/input.tsx +96 -101
- package/src/components/input-group/input-group.meta.md +53 -39
- package/src/components/input-group/input-group.stories.tsx +49 -16
- package/src/components/input-group/input-group.tsx +43 -8
- package/src/components/input-number/input-number.meta.md +68 -20
- package/src/components/input-number/input-number.stories.tsx +33 -6
- package/src/components/input-number/input-number.tsx +79 -20
- package/src/components/input-otp/input-otp.meta.md +8 -20
- package/src/components/input-otp/input-otp.stories.tsx +3 -3
- package/src/components/input-otp/input-otp.tsx +1 -1
- package/src/components/item/item.meta.md +8 -26
- package/src/components/item/item.stories.tsx +3 -3
- package/src/components/item/item.tsx +7 -6
- package/src/components/kbd/kbd.meta.md +7 -19
- package/src/components/kbd/kbd.stories.tsx +4 -4
- package/src/components/kbd/kbd.tsx +8 -4
- package/src/components/label/label.meta.md +21 -18
- package/src/components/label/label.stories.tsx +64 -6
- package/src/components/label/label.tsx +91 -19
- package/src/components/masonry/masonry.meta.md +8 -12
- package/src/components/masonry/masonry.stories.tsx +4 -4
- package/src/components/mentions/mentions.meta.md +42 -21
- package/src/components/mentions/mentions.stories.tsx +120 -6
- package/src/components/mentions/mentions.tsx +10 -5
- package/src/components/menubar/menubar.meta.md +4 -8
- package/src/components/menubar/menubar.stories.tsx +55 -3
- package/src/components/menubar/menubar.tsx +9 -9
- package/src/components/native-select/native-select.meta.md +7 -11
- package/src/components/native-select/native-select.stories.tsx +4 -4
- package/src/components/native-select/native-select.tsx +1 -1
- package/src/components/navigation-menu/navigation-menu.meta.md +4 -8
- package/src/components/navigation-menu/navigation-menu.stories.tsx +106 -3
- package/src/components/navigation-menu/navigation-menu.tsx +6 -3
- package/src/components/notification/notification.meta.md +41 -8
- package/src/components/notification/notification.stories.tsx +9 -9
- package/src/components/notification/notification.tsx +34 -19
- package/src/components/page-header/DEVELOPMENT.md +842 -0
- package/src/components/page-header/page-header.meta.md +208 -0
- package/src/components/page-header/page-header.stories.tsx +421 -0
- package/src/components/page-header/page-header.tsx +281 -0
- package/src/components/pagination/pagination.meta.md +122 -50
- package/src/components/pagination/pagination.stories.tsx +227 -11
- package/src/components/pagination/pagination.tsx +355 -63
- package/src/components/popconfirm/popconfirm.meta.md +19 -23
- package/src/components/popconfirm/popconfirm.stories.tsx +2 -2
- package/src/components/popconfirm/popconfirm.tsx +1 -1
- package/src/components/popover/popover.meta.md +64 -12
- package/src/components/popover/popover.stories.tsx +83 -7
- package/src/components/popover/popover.tsx +77 -28
- package/src/components/progress/progress.meta.md +43 -26
- package/src/components/progress/progress.stories.tsx +2 -2
- package/src/components/progress/progress.tsx +19 -11
- package/src/components/radio-group/radio-group.meta.md +78 -11
- package/src/components/radio-group/radio-group.stories.tsx +38 -2
- package/src/components/radio-group/radio-group.tsx +149 -18
- package/src/components/rate/rate.meta.md +41 -19
- package/src/components/rate/rate.stories.tsx +2 -2
- package/src/components/rate/rate.tsx +37 -10
- package/src/components/resizable/resizable.meta.md +4 -12
- package/src/components/resizable/resizable.stories.tsx +5 -5
- package/src/components/resizable/resizable.tsx +1 -1
- package/src/components/result/result.meta.md +10 -14
- package/src/components/result/result.stories.tsx +2 -2
- package/src/components/result/result.tsx +21 -12
- package/src/components/scroll-area/scroll-area.meta.md +4 -8
- package/src/components/scroll-area/scroll-area.stories.tsx +5 -5
- package/src/components/segmented/segmented.meta.md +15 -17
- package/src/components/segmented/segmented.stories.tsx +3 -3
- package/src/components/segmented/segmented.tsx +15 -7
- package/src/components/select/select.meta.md +199 -67
- package/src/components/select/select.stories.tsx +238 -63
- package/src/components/select/select.tsx +718 -171
- package/src/components/separator/separator.meta.md +10 -14
- package/src/components/separator/separator.stories.tsx +2 -2
- package/src/components/separator/separator.tsx +3 -7
- package/src/components/sheet/sheet.meta.md +26 -21
- package/src/components/sheet/sheet.stories.tsx +116 -10
- package/src/components/sheet/sheet.tsx +116 -29
- package/src/components/sidebar/sidebar.meta.md +28 -38
- package/src/components/sidebar/sidebar.stories.tsx +696 -29
- package/src/components/sidebar/sidebar.tsx +615 -142
- package/src/components/skeleton/skeleton.meta.md +7 -31
- package/src/components/skeleton/skeleton.stories.tsx +3 -3
- package/src/components/skeleton/skeleton.tsx +7 -7
- package/src/components/slider/slider.meta.md +60 -13
- package/src/components/slider/slider.stories.tsx +58 -6
- package/src/components/slider/slider.tsx +154 -13
- package/src/components/sonner/sonner.meta.md +54 -8
- package/src/components/sonner/sonner.stories.tsx +79 -11
- package/src/components/sonner/sonner.tsx +137 -8
- package/src/components/spinner/spinner.meta.md +57 -21
- package/src/components/spinner/spinner.stories.tsx +66 -14
- package/src/components/spinner/spinner.tsx +111 -9
- package/src/components/statistic/statistic.meta.md +14 -30
- package/src/components/statistic/statistic.stories.tsx +1 -1
- package/src/components/statistic/statistic.tsx +4 -5
- package/src/components/steps/steps.meta.md +20 -15
- package/src/components/steps/steps.stories.tsx +37 -2
- package/src/components/steps/steps.tsx +15 -12
- package/src/components/switch/switch.meta.md +56 -15
- package/src/components/switch/switch.stories.tsx +5 -5
- package/src/components/switch/switch.tsx +59 -13
- package/src/components/table/table.meta.md +3 -7
- package/src/components/table/table.stories.tsx +1 -1
- package/src/components/table/table.tsx +4 -4
- package/src/components/tabs/tabs.meta.md +40 -32
- package/src/components/tabs/tabs.stories.tsx +104 -26
- package/src/components/tabs/tabs.tsx +125 -54
- package/src/components/tag/tag.meta.md +104 -68
- package/src/components/tag/tag.stories.tsx +183 -15
- package/src/components/tag/tag.tsx +222 -21
- package/src/components/textarea/textarea.meta.md +42 -31
- package/src/components/textarea/textarea.stories.tsx +32 -6
- package/src/components/textarea/textarea.tsx +32 -8
- package/src/components/time-picker/time-picker.meta.md +119 -50
- package/src/components/time-picker/time-picker.stories.tsx +65 -33
- package/src/components/time-picker/time-picker.tsx +889 -101
- package/src/components/timeline/timeline.meta.md +16 -17
- package/src/components/timeline/timeline.stories.tsx +24 -4
- package/src/components/timeline/timeline.tsx +32 -12
- package/src/components/toggle/toggle.meta.md +8 -12
- package/src/components/toggle/toggle.stories.tsx +4 -4
- package/src/components/toggle/toggle.tsx +4 -3
- package/src/components/toggle-group/toggle-group.meta.md +10 -14
- package/src/components/toggle-group/toggle-group.stories.tsx +3 -3
- package/src/components/toggle-group/toggle-group.tsx +2 -2
- package/src/components/tooltip/tooltip.meta.md +63 -18
- package/src/components/tooltip/tooltip.stories.tsx +42 -5
- package/src/components/tooltip/tooltip.tsx +81 -21
- package/src/components/tour/tour.meta.md +16 -20
- package/src/components/tour/tour.stories.tsx +3 -3
- package/src/components/tour/tour.tsx +3 -3
- package/src/components/transfer/transfer.meta.md +18 -22
- package/src/components/transfer/transfer.stories.tsx +2 -2
- package/src/components/transfer/transfer.tsx +28 -21
- package/src/components/tree/tree.meta.md +67 -22
- package/src/components/tree/tree.stories.tsx +1 -1
- package/src/components/tree/tree.tsx +9 -8
- package/src/components/tree-select/tree-select.meta.md +59 -23
- package/src/components/tree-select/tree-select.stories.tsx +2 -2
- package/src/components/tree-select/tree-select.tsx +42 -7
- package/src/components/typography/typography.meta.md +61 -39
- package/src/components/typography/typography.stories.tsx +14 -9
- package/src/components/typography/typography.tsx +38 -25
- package/src/components/upload/upload.meta.md +61 -25
- package/src/components/upload/upload.stories.tsx +69 -3
- package/src/components/upload/upload.tsx +170 -37
- package/src/components/watermark/watermark.meta.md +15 -19
- package/src/components/watermark/watermark.stories.tsx +98 -8
- package/src/hooks/use-breakpoint.ts +117 -0
- package/src/hooks/use-debounce-callback.ts +52 -0
- package/src/hooks/use-mobile.ts +23 -0
- package/src/stories/theme-tokens.stories.tsx +747 -0
- package/src/utils/trigger-input.ts +53 -0
- package/src/components/button-group/button-group.meta.md +0 -101
- package/src/components/button-group/button-group.stories.tsx +0 -93
- package/src/components/button-group/button-group.tsx +0 -75
- package/src/components/combobox/combobox.meta.md +0 -102
- package/src/components/combobox/combobox.stories.tsx +0 -55
- package/src/components/combobox/combobox.tsx +0 -130
- package/src/components/input/demo/addon.tsx +0 -15
- package/src/components/input/demo/with-prefix-suffix.tsx +0 -19
- package/src/components/space/space.meta.md +0 -103
- package/src/components/space/space.stories.tsx +0 -108
- package/src/components/space/space.tsx +0 -106
|
@@ -21,7 +21,7 @@ const Menubar = React.forwardRef<
|
|
|
21
21
|
<MenubarPrimitive.Root
|
|
22
22
|
ref={ref}
|
|
23
23
|
className={cn(
|
|
24
|
-
'flex h-9 items-center gap-1 rounded-md border bg-background p-1 shadow-sm',
|
|
24
|
+
'flex h-9 items-center gap-1 rounded-md border border-border bg-background p-1 shadow-sm',
|
|
25
25
|
className,
|
|
26
26
|
)}
|
|
27
27
|
{...props}
|
|
@@ -36,7 +36,7 @@ const MenubarTrigger = React.forwardRef<
|
|
|
36
36
|
<MenubarPrimitive.Trigger
|
|
37
37
|
ref={ref}
|
|
38
38
|
className={cn(
|
|
39
|
-
'flex cursor-
|
|
39
|
+
'flex cursor-pointer select-none items-center rounded-sm px-3 py-1 text-xs font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
|
|
40
40
|
className,
|
|
41
41
|
)}
|
|
42
42
|
{...props}
|
|
@@ -53,7 +53,7 @@ const MenubarSubTrigger = React.forwardRef<
|
|
|
53
53
|
<MenubarPrimitive.SubTrigger
|
|
54
54
|
ref={ref}
|
|
55
55
|
className={cn(
|
|
56
|
-
'flex cursor-
|
|
56
|
+
'flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
|
|
57
57
|
inset && 'pl-8',
|
|
58
58
|
className,
|
|
59
59
|
)}
|
|
@@ -72,7 +72,7 @@ const MenubarSubContent = React.forwardRef<
|
|
|
72
72
|
<MenubarPrimitive.SubContent
|
|
73
73
|
ref={ref}
|
|
74
74
|
className={cn(
|
|
75
|
-
'z-50 min-w-menu overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
75
|
+
'z-50 min-w-menu overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
76
76
|
className,
|
|
77
77
|
)}
|
|
78
78
|
{...props}
|
|
@@ -95,7 +95,7 @@ const MenubarContent = React.forwardRef<
|
|
|
95
95
|
alignOffset={alignOffset}
|
|
96
96
|
sideOffset={sideOffset}
|
|
97
97
|
className={cn(
|
|
98
|
-
'z-50 min-w-menu-md overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
98
|
+
'z-50 min-w-menu-md overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
99
99
|
className,
|
|
100
100
|
)}
|
|
101
101
|
{...props}
|
|
@@ -114,7 +114,7 @@ const MenubarItem = React.forwardRef<
|
|
|
114
114
|
<MenubarPrimitive.Item
|
|
115
115
|
ref={ref}
|
|
116
116
|
className={cn(
|
|
117
|
-
'relative flex cursor-
|
|
117
|
+
'relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
118
118
|
inset && 'pl-8',
|
|
119
119
|
className,
|
|
120
120
|
)}
|
|
@@ -130,7 +130,7 @@ const MenubarCheckboxItem = React.forwardRef<
|
|
|
130
130
|
<MenubarPrimitive.CheckboxItem
|
|
131
131
|
ref={ref}
|
|
132
132
|
className={cn(
|
|
133
|
-
'relative flex cursor-
|
|
133
|
+
'relative flex cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
134
134
|
className,
|
|
135
135
|
)}
|
|
136
136
|
checked={checked}
|
|
@@ -153,7 +153,7 @@ const MenubarRadioItem = React.forwardRef<
|
|
|
153
153
|
<MenubarPrimitive.RadioItem
|
|
154
154
|
ref={ref}
|
|
155
155
|
className={cn(
|
|
156
|
-
'relative flex cursor-
|
|
156
|
+
'relative flex cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
157
157
|
className,
|
|
158
158
|
)}
|
|
159
159
|
{...props}
|
|
@@ -177,7 +177,7 @@ const MenubarLabel = React.forwardRef<
|
|
|
177
177
|
<MenubarPrimitive.Label
|
|
178
178
|
ref={ref}
|
|
179
179
|
className={cn(
|
|
180
|
-
'px-2 py-1.5 text-
|
|
180
|
+
'px-2 py-1.5 text-xs font-semibold',
|
|
181
181
|
inset && 'pl-8',
|
|
182
182
|
className,
|
|
183
183
|
)}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: native-select
|
|
3
3
|
name: NativeSelect
|
|
4
4
|
type: component
|
|
5
|
-
category:
|
|
5
|
+
category: deprecated
|
|
6
6
|
since: 0.1.0
|
|
7
7
|
package: '@teamix-evo/ui'
|
|
8
8
|
displayName: 原生下拉
|
|
@@ -27,24 +27,21 @@ displayName: 原生下拉
|
|
|
27
27
|
## Props
|
|
28
28
|
|
|
29
29
|
<!-- auto:props:begin -->
|
|
30
|
-
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
| `wrapperClassName` | `string` | – | – | 容器额外 className(给外层 wrapper,而非 `<select>` 本身)。 |
|
|
34
|
-
|
|
30
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
31
|
+
| --- | --- | --- | --- | --- |
|
|
32
|
+
| `wrapperClassName` | `string` | – | – | 容器额外 className(给外层 wrapper,而非 `<select>` 本身)。 |
|
|
35
33
|
<!-- auto:props:end -->
|
|
36
34
|
|
|
37
35
|
## 依赖
|
|
38
36
|
|
|
39
37
|
<!-- auto:deps:begin -->
|
|
40
|
-
|
|
41
38
|
### 同库依赖
|
|
42
39
|
|
|
43
40
|
> `teamix-evo ui add native-select` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
44
41
|
|
|
45
|
-
| Entry | 类型 | 描述
|
|
46
|
-
|
|
|
47
|
-
| `cn`
|
|
42
|
+
| Entry | 类型 | 描述 |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
48
45
|
|
|
49
46
|
### npm 依赖
|
|
50
47
|
|
|
@@ -53,7 +50,6 @@ displayName: 原生下拉
|
|
|
53
50
|
```bash
|
|
54
51
|
pnpm add lucide-react@^0.460.0
|
|
55
52
|
```
|
|
56
|
-
|
|
57
53
|
<!-- auto:deps:end -->
|
|
58
54
|
|
|
59
55
|
## AI 生成纪律
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { NativeSelect } from './native-select';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof NativeSelect> = {
|
|
5
|
-
title: '
|
|
5
|
+
title: '废弃 · Deprecated/NativeSelect',
|
|
6
6
|
component: NativeSelect,
|
|
7
7
|
tags: ['autodocs'],
|
|
8
8
|
parameters: {
|
|
9
9
|
docs: {
|
|
10
10
|
description: {
|
|
11
11
|
component:
|
|
12
|
-
'原生下拉选择 — 原生 `<select>` 元素的样式封装,零 JS 开销,移动端弹起系统 picker,直接参与 form submit。与 Radix `Select` 互为补充:NativeSelect 面向原生 / 移动端友好,Radix Select 面向自定义项 UI / 受控复杂表单。shadcn 2025-10 新增。',
|
|
12
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\n原生下拉选择 — 原生 `<select>` 元素的样式封装,零 JS 开销,移动端弹起系统 picker,直接参与 form submit。与 Radix `Select` 互为补充:NativeSelect 面向原生 / 移动端友好,Radix Select 面向自定义项 UI / 受控复杂表单。shadcn 2025-10 新增。',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
},
|
|
@@ -74,7 +74,7 @@ export const InForm: Story = {
|
|
|
74
74
|
</NativeSelect>
|
|
75
75
|
<button
|
|
76
76
|
type="submit"
|
|
77
|
-
className="rounded-md border px-3 py-1 text-sm hover:bg-accent"
|
|
77
|
+
className="rounded-md border border-border px-3 py-1 text-sm hover:bg-accent"
|
|
78
78
|
>
|
|
79
79
|
提交
|
|
80
80
|
</button>
|
|
@@ -33,7 +33,7 @@ const NativeSelect = React.forwardRef<HTMLSelectElement, NativeSelectProps>(
|
|
|
33
33
|
ref={ref}
|
|
34
34
|
disabled={disabled}
|
|
35
35
|
className={cn(
|
|
36
|
-
'flex h-9 w-full appearance-none rounded-md border border-input bg-background py-1 pl-3 pr-8 text-
|
|
36
|
+
'flex h-9 w-full appearance-none rounded-md border border-input bg-background py-1 pl-3 pr-8 text-xs shadow-sm',
|
|
37
37
|
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
38
38
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
39
39
|
className,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: navigation-menu
|
|
3
3
|
name: NavigationMenu
|
|
4
4
|
type: component
|
|
5
|
-
category:
|
|
5
|
+
category: deprecated
|
|
6
6
|
since: 0.1.0
|
|
7
7
|
package: '@teamix-evo/ui'
|
|
8
8
|
displayName: 导航菜单
|
|
@@ -30,9 +30,7 @@ displayName: 导航菜单
|
|
|
30
30
|
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。下表是 `NavigationMenu`(Root) 的 props。
|
|
31
31
|
|
|
32
32
|
<!-- auto:props:begin -->
|
|
33
|
-
|
|
34
33
|
_(组件无 `<Name>Props` interface — props 详见 [`navigation-menu.tsx`](./navigation-menu.tsx))_
|
|
35
|
-
|
|
36
34
|
<!-- auto:props:end -->
|
|
37
35
|
|
|
38
36
|
## 依赖
|
|
@@ -40,14 +38,13 @@ _(组件无 `<Name>Props` interface — props 详见 [`navigation-menu.tsx`](./n
|
|
|
40
38
|
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
41
39
|
|
|
42
40
|
<!-- auto:deps:begin -->
|
|
43
|
-
|
|
44
41
|
### 同库依赖
|
|
45
42
|
|
|
46
43
|
> `teamix-evo ui add navigation-menu` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
47
44
|
|
|
48
|
-
| Entry | 类型 | 描述
|
|
49
|
-
|
|
|
50
|
-
| `cn`
|
|
45
|
+
| Entry | 类型 | 描述 |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
51
48
|
|
|
52
49
|
### npm 依赖
|
|
53
50
|
|
|
@@ -56,7 +53,6 @@ _(组件无 `<Name>Props` interface — props 详见 [`navigation-menu.tsx`](./n
|
|
|
56
53
|
```bash
|
|
57
54
|
pnpm add @radix-ui/react-navigation-menu@^1.2.0 class-variance-authority@^0.7.0 lucide-react@^0.460.0
|
|
58
55
|
```
|
|
59
|
-
|
|
60
56
|
<!-- auto:deps:end -->
|
|
61
57
|
|
|
62
58
|
> 完整子组件:`NavigationMenu` / `NavigationMenuList` / `NavigationMenuItem` / `NavigationMenuTrigger` / `NavigationMenuContent` / `NavigationMenuLink` / `NavigationMenuIndicator` / `NavigationMenuViewport` + `navigationMenuTriggerStyle`(给独立 Link 复用 trigger 视觉)。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import {
|
|
3
3
|
NavigationMenu,
|
|
4
4
|
NavigationMenuList,
|
|
@@ -8,16 +8,17 @@ import {
|
|
|
8
8
|
NavigationMenuLink,
|
|
9
9
|
navigationMenuTriggerStyle,
|
|
10
10
|
} from './navigation-menu';
|
|
11
|
+
import { cn } from '@/utils/cn';
|
|
11
12
|
|
|
12
13
|
const meta: Meta<typeof NavigationMenu> = {
|
|
13
|
-
title: '
|
|
14
|
+
title: '废弃 · Deprecated/NavigationMenu',
|
|
14
15
|
component: NavigationMenu,
|
|
15
16
|
tags: ['autodocs'],
|
|
16
17
|
parameters: {
|
|
17
18
|
docs: {
|
|
18
19
|
description: {
|
|
19
20
|
component:
|
|
20
|
-
'
|
|
21
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\nNavigationMenu 导航菜单 —— 在网站、营销页或应用顶部承载主导航,每项可展开富面板预览子页面。Radix `NavigationMenu` 内核 + shadcn 原子,**对齐 antd `Menu mode="horizontal"`** 的水平主导航能力,对齐 shadcn `NavigationMenu` 的 `NavigationMenuTrigger` / `NavigationMenuContent` / `NavigationMenuLink` / `navigationMenuTriggerStyle`,并补足 antd 的 `disabled` 项与简单链接形态。视觉走 OpenTrek semantic tokens,所有样式来自 `@teamix-evo/tokens`,无 mock。',
|
|
21
22
|
},
|
|
22
23
|
},
|
|
23
24
|
},
|
|
@@ -106,6 +107,108 @@ export const Default: Story = {
|
|
|
106
107
|
</a>
|
|
107
108
|
</NavigationMenuLink>
|
|
108
109
|
</NavigationMenuItem>
|
|
110
|
+
<NavigationMenuItem>
|
|
111
|
+
<NavigationMenuLink
|
|
112
|
+
asChild
|
|
113
|
+
className={cn(
|
|
114
|
+
navigationMenuTriggerStyle(),
|
|
115
|
+
'pointer-events-none opacity-50',
|
|
116
|
+
)}
|
|
117
|
+
aria-disabled
|
|
118
|
+
>
|
|
119
|
+
<span>企业版(即将上线)</span>
|
|
120
|
+
</NavigationMenuLink>
|
|
121
|
+
</NavigationMenuItem>
|
|
122
|
+
</NavigationMenuList>
|
|
123
|
+
</NavigationMenu>
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const SimpleLinks: Story = {
|
|
128
|
+
parameters: { layout: 'centered' },
|
|
129
|
+
render: () => (
|
|
130
|
+
<NavigationMenu>
|
|
131
|
+
<NavigationMenuList>
|
|
132
|
+
{['首页', '产品', '文档', '社区', '联系我们'].map((label) => (
|
|
133
|
+
<NavigationMenuItem key={label}>
|
|
134
|
+
<NavigationMenuLink
|
|
135
|
+
asChild
|
|
136
|
+
className={navigationMenuTriggerStyle()}
|
|
137
|
+
>
|
|
138
|
+
<a href={`#${label}`} onClick={(e) => e.preventDefault()}>
|
|
139
|
+
{label}
|
|
140
|
+
</a>
|
|
141
|
+
</NavigationMenuLink>
|
|
142
|
+
</NavigationMenuItem>
|
|
143
|
+
))}
|
|
144
|
+
</NavigationMenuList>
|
|
145
|
+
</NavigationMenu>
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const DisabledItem: Story = {
|
|
150
|
+
parameters: { layout: 'centered' },
|
|
151
|
+
render: () => (
|
|
152
|
+
<NavigationMenu>
|
|
153
|
+
<NavigationMenuList>
|
|
154
|
+
<NavigationMenuItem>
|
|
155
|
+
<NavigationMenuLink asChild className={navigationMenuTriggerStyle()}>
|
|
156
|
+
<a href="#docs" onClick={(e) => e.preventDefault()}>
|
|
157
|
+
文档
|
|
158
|
+
</a>
|
|
159
|
+
</NavigationMenuLink>
|
|
160
|
+
</NavigationMenuItem>
|
|
161
|
+
<NavigationMenuItem>
|
|
162
|
+
<NavigationMenuLink
|
|
163
|
+
asChild
|
|
164
|
+
aria-disabled
|
|
165
|
+
className={cn(
|
|
166
|
+
navigationMenuTriggerStyle(),
|
|
167
|
+
'pointer-events-none opacity-50',
|
|
168
|
+
)}
|
|
169
|
+
>
|
|
170
|
+
<span>API(内部预览)</span>
|
|
171
|
+
</NavigationMenuLink>
|
|
172
|
+
</NavigationMenuItem>
|
|
173
|
+
<NavigationMenuItem>
|
|
174
|
+
<NavigationMenuLink asChild className={navigationMenuTriggerStyle()}>
|
|
175
|
+
<a href="#blog" onClick={(e) => e.preventDefault()}>
|
|
176
|
+
博客
|
|
177
|
+
</a>
|
|
178
|
+
</NavigationMenuLink>
|
|
179
|
+
</NavigationMenuItem>
|
|
180
|
+
</NavigationMenuList>
|
|
181
|
+
</NavigationMenu>
|
|
182
|
+
),
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* “纵向”其实是侧边列表形态的导航。Radix `NavigationMenu` 主要面向水平、
|
|
187
|
+
* 可开富面板的主导航;需要侧边导航选 `Sidebar`。下面是将 NavigationMenu
|
|
188
|
+
* `orientation="vertical"` 下的简样实例(供对齐 antd `Menu mode="vertical"` 的过度能力)。
|
|
189
|
+
*/
|
|
190
|
+
export const Vertical: Story = {
|
|
191
|
+
parameters: { layout: 'centered' },
|
|
192
|
+
render: () => (
|
|
193
|
+
<NavigationMenu orientation="vertical" className="w-56 max-w-none flex-col items-stretch">
|
|
194
|
+
<NavigationMenuList className="w-full flex-col items-stretch gap-0">
|
|
195
|
+
{[
|
|
196
|
+
{ label: '仪表盘', href: '#dashboard' },
|
|
197
|
+
{ label: '项目', href: '#projects' },
|
|
198
|
+
{ label: '任务', href: '#tasks' },
|
|
199
|
+
{ label: '设置', href: '#settings' },
|
|
200
|
+
].map((it) => (
|
|
201
|
+
<NavigationMenuItem key={it.label} className="w-full">
|
|
202
|
+
<NavigationMenuLink
|
|
203
|
+
asChild
|
|
204
|
+
className={cn(navigationMenuTriggerStyle(), 'w-full justify-start')}
|
|
205
|
+
>
|
|
206
|
+
<a href={it.href} onClick={(e) => e.preventDefault()}>
|
|
207
|
+
{it.label}
|
|
208
|
+
</a>
|
|
209
|
+
</NavigationMenuLink>
|
|
210
|
+
</NavigationMenuItem>
|
|
211
|
+
))}
|
|
109
212
|
</NavigationMenuList>
|
|
110
213
|
</NavigationMenu>
|
|
111
214
|
),
|
|
@@ -11,7 +11,10 @@ const NavigationMenu = React.forwardRef<
|
|
|
11
11
|
>(({ className, children, ...props }, ref) => (
|
|
12
12
|
<NavigationMenuPrimitive.Root
|
|
13
13
|
ref={ref}
|
|
14
|
-
className={cn(
|
|
14
|
+
className={cn(
|
|
15
|
+
'relative z-10 flex max-w-max flex-1 items-center justify-center',
|
|
16
|
+
className,
|
|
17
|
+
)}
|
|
15
18
|
{...props}
|
|
16
19
|
>
|
|
17
20
|
{children}
|
|
@@ -38,7 +41,7 @@ NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
|
|
38
41
|
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
|
39
42
|
|
|
40
43
|
const navigationMenuTriggerStyle = cva(
|
|
41
|
-
'group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-
|
|
44
|
+
'group inline-flex h-9 w-max cursor-pointer items-center justify-center rounded-md bg-background px-4 py-2 text-xs font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50',
|
|
42
45
|
);
|
|
43
46
|
|
|
44
47
|
const NavigationMenuTrigger = React.forwardRef<
|
|
@@ -84,7 +87,7 @@ const NavigationMenuViewport = React.forwardRef<
|
|
|
84
87
|
<NavigationMenuPrimitive.Viewport
|
|
85
88
|
ref={ref}
|
|
86
89
|
className={cn(
|
|
87
|
-
'origin-top-center relative mt-1.5 h-radix-nav-viewport w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-radix-nav-viewport',
|
|
90
|
+
'origin-top-center relative mt-1.5 h-radix-nav-viewport w-full overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-radix-nav-viewport',
|
|
88
91
|
className,
|
|
89
92
|
)}
|
|
90
93
|
{...props}
|
|
@@ -10,7 +10,7 @@ displayName: 通知
|
|
|
10
10
|
|
|
11
11
|
# Notification 通知
|
|
12
12
|
|
|
13
|
-
卡片式通知 — antd 独有补足。**等价 antd `Notification`**(右上角 title + description 卡片),与 sonner 同一渲染栈。基于 sonner `toast.custom` 二次封装,业务侧**只需要挂载一次 `<Toaster />`**,后续在任意地方调 `notification.success(...)` / `notification.
|
|
13
|
+
卡片式通知 — antd 独有补足。**等价 antd `Notification`**(右上角 title + description 卡片),与 sonner 同一渲染栈。基于 sonner `toast.custom` 二次封装,业务侧**只需要挂载一次 `<Toaster />`**,后续在任意地方调 `notification.success(...)` / `notification.destructive(...)` 等触发。4 档语义色对齐 [ADR 0021](../../../../docs/adr/0021-semantic-color-api-unification.md):`primary / success / warning / destructive`。
|
|
14
14
|
|
|
15
15
|
## When to use
|
|
16
16
|
|
|
@@ -40,10 +40,10 @@ _(组件无 `<Name>Props` interface — props 详见 [`notification.tsx`](./noti
|
|
|
40
40
|
|
|
41
41
|
> `teamix-evo ui add notification` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
42
42
|
|
|
43
|
-
| Entry | 类型 | 描述
|
|
44
|
-
| -------- | --------- |
|
|
45
|
-
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge)
|
|
46
|
-
| `sonner` | component | Toast 通知 — sonner 包装,等价 antd message + notification 并集(toast() 函数式 API + Toaster
|
|
43
|
+
| Entry | 类型 | 描述 |
|
|
44
|
+
| -------- | --------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
46
|
+
| `sonner` | component | Toast 通知 — sonner 包装,等价 antd message + notification 并集(toast() 函数式 API + Toaster 容器,面性 5 状态图标 + 无边框) |
|
|
47
47
|
|
|
48
48
|
### npm 依赖
|
|
49
49
|
|
|
@@ -60,7 +60,7 @@ pnpm add sonner@^1.5.0 lucide-react@^0.460.0
|
|
|
60
60
|
- **业务侧必须挂载 `<Toaster />`** —— Notification 与 toast 共用同一容器,通常挂在 root layout
|
|
61
61
|
- **`title` 用动词或事件名**:"部署成功"/"订单已创建";**不要**写"提示"等空话
|
|
62
62
|
- **`description` 解释后果或下一步**:"用户可在 1 分钟内访问新版本"/"详情请查看订单页";**不要**重复 title
|
|
63
|
-
-
|
|
63
|
+
- **语义不要混淆**:`success` 用于成功完成,`warning` 用于风险提示但操作未失败,`destructive` 用于真正失败 — 与 `Alert` / `Toast` 的语义一致(对齐 ADR 0021,不再使用 `info` / `error` 字面)
|
|
64
64
|
- **不要在 onConfirm 里同时调 toast 和 notification** — 单次反馈选一种,避免视觉噪音
|
|
65
65
|
- **`destroy(id)` 主动关闭**:用于"自动重试成功"等场景,把之前的 error notification 替换掉
|
|
66
66
|
|
|
@@ -80,14 +80,14 @@ notification.warning({
|
|
|
80
80
|
description: '请在 3 天内续费,否则服务将暂停',
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
notification.
|
|
83
|
+
notification.destructive({
|
|
84
84
|
title: '上传失败',
|
|
85
85
|
description: '请检查网络连接后重试',
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// 自定义 + 操作按钮(action 透传 sonner)
|
|
89
89
|
const id = notification.open({
|
|
90
|
-
|
|
90
|
+
color: 'primary',
|
|
91
91
|
title: '新版本可用',
|
|
92
92
|
description: 'v2.5 已发布,刷新页面以应用更新',
|
|
93
93
|
action: { label: '刷新', onClick: () => location.reload() },
|
|
@@ -98,3 +98,36 @@ notification.destroy(id);
|
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
> 应用根组件需要挂载一次 `<Toaster />`(来自 `sonner` entry),Notification 与 toast 共用此容器。
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Notification 形态 — 旧库 API → 新映射
|
|
105
|
+
|
|
106
|
+
> 旧库 `Notification`(hybridcloud,含 open/success/error/warning 命令式) → 新库 `notification`(小写对象)。
|
|
107
|
+
> 新库基于 sonner `toast.custom` 封装,共用 `<Toaster />` 容器。
|
|
108
|
+
|
|
109
|
+
### 命名 & 结构映射
|
|
110
|
+
|
|
111
|
+
| 旧库 | 新库 | 说明 |
|
|
112
|
+
| ------------------------------------ | ----------------------------------------- | ----------------------------- |
|
|
113
|
+
| `Notification` (类) | `notification` (对象) | 大小写变更 |
|
|
114
|
+
| `Notification.success()` | `notification.success()` | 直接映射 |
|
|
115
|
+
| `Notification.error()` | `notification.destructive()` | error → destructive(ADR 0021) |
|
|
116
|
+
| `Notification.warning()` | `notification.warning()` | 直接映射 |
|
|
117
|
+
| `Notification.notice()` | `notification.open({ color: 'primary' })` | notice → primary |
|
|
118
|
+
| `options.content` | `options.description` | 字段重命名 |
|
|
119
|
+
| `options.type` | `options.color` | type → color(4 档语义色) |
|
|
120
|
+
| `Notification.close(key)` | `notification.destroy(id)` | 主动关闭 |
|
|
121
|
+
| `Notification.config({ placement })` | `<Toaster position="..." />` | 声明式配置 |
|
|
122
|
+
| `size: large/medium` | 不复刻 | 固定尺寸 |
|
|
123
|
+
| `icon` 自定义 | 不复刻 | 固定语义图标(规范化) |
|
|
124
|
+
| `type='help'` | `notification.open({ color: 'primary' })` | 合并到 primary |
|
|
125
|
+
|
|
126
|
+
### 迁移 FAQ
|
|
127
|
+
|
|
128
|
+
| 问题 | 回答 |
|
|
129
|
+
| ----------------------------- | ------------------------------------------------------------------- |
|
|
130
|
+
| error 为什么变成 destructive? | 对齐 ADR 0021 语义色规范,统一用 destructive 表示错误/危险 |
|
|
131
|
+
| Notification 和 toast 的关系? | 共用 Toaster 容器;简短提示用 toast,带标题+描述的卡片用 notification |
|
|
132
|
+
| 怎么控制位置? | `<Toaster position="top-right" />`(默认右上) |
|
|
133
|
+
| 怎么加 action 按钮? | `notification.open({ ..., action: { label, onClick } })` |
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { Toaster } from '@/components/sonner/sonner';
|
|
3
3
|
import { notification } from './notification';
|
|
4
4
|
import { Button } from '@/components/button/button';
|
|
5
5
|
|
|
6
6
|
const meta: Meta = {
|
|
7
|
-
title: '
|
|
7
|
+
title: '反馈 · Feedback/Notification',
|
|
8
8
|
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
10
10
|
docs: {
|
|
11
11
|
description: {
|
|
12
12
|
component:
|
|
13
|
-
'卡片式通知 — 右上角 title + description 卡片(部署成功 / 配额提醒)。基于 sonner toast.custom,业务侧只需挂载一次 `<Toaster />`,后续在任意地方 imperative
|
|
13
|
+
'卡片式通知 — 右上角 title + description 卡片(部署成功 / 配额提醒)。基于 sonner toast.custom,业务侧只需挂载一次 `<Toaster />`,后续在任意地方 imperative 触发。4 档语义色(primary / success / warning / destructive)对齐 ADR 0021,与 toast(message)互补。',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
@@ -27,13 +27,13 @@ export const Playground: Story = {
|
|
|
27
27
|
<Button
|
|
28
28
|
variant="outline"
|
|
29
29
|
onClick={() =>
|
|
30
|
-
notification.
|
|
30
|
+
notification.primary({
|
|
31
31
|
title: '提示',
|
|
32
|
-
description: '这是一条
|
|
32
|
+
description: '这是一条 primary 通知',
|
|
33
33
|
})
|
|
34
34
|
}
|
|
35
35
|
>
|
|
36
|
-
|
|
36
|
+
Primary
|
|
37
37
|
</Button>
|
|
38
38
|
<Button
|
|
39
39
|
onClick={() =>
|
|
@@ -59,13 +59,13 @@ export const Playground: Story = {
|
|
|
59
59
|
<Button
|
|
60
60
|
variant="destructive"
|
|
61
61
|
onClick={() =>
|
|
62
|
-
notification.
|
|
62
|
+
notification.destructive({
|
|
63
63
|
title: '上传失败',
|
|
64
64
|
description: '请检查网络连接后重试',
|
|
65
65
|
})
|
|
66
66
|
}
|
|
67
67
|
>
|
|
68
|
-
|
|
68
|
+
Destructive
|
|
69
69
|
</Button>
|
|
70
70
|
</div>
|
|
71
71
|
</div>
|
|
@@ -79,7 +79,7 @@ export const WithAction: Story = {
|
|
|
79
79
|
<Button
|
|
80
80
|
onClick={() =>
|
|
81
81
|
notification.open({
|
|
82
|
-
|
|
82
|
+
color: 'primary',
|
|
83
83
|
title: '新版本可用',
|
|
84
84
|
description: 'v2.5 已发布,刷新页面以应用更新',
|
|
85
85
|
action: {
|
|
@@ -14,40 +14,54 @@ import { cn } from '@/utils/cn';
|
|
|
14
14
|
* - `notification.open()` 是 **title + description 卡片**(对应 antd `notification`)
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export type
|
|
17
|
+
export type NotificationColor =
|
|
18
|
+
| 'primary'
|
|
19
|
+
| 'success'
|
|
20
|
+
| 'warning'
|
|
21
|
+
| 'destructive';
|
|
18
22
|
|
|
19
|
-
export interface NotificationOptions
|
|
23
|
+
export interface NotificationOptions
|
|
24
|
+
extends Omit<ExternalToast, 'description' | 'icon'> {
|
|
20
25
|
/** 标题(antd `message` 并集,但 antd 这里命名为 message,易混淆 — 我们用更准确的 `title`)。 */
|
|
21
26
|
title: React.ReactNode;
|
|
22
27
|
/** 描述(antd `description` 并集)。 */
|
|
23
28
|
description?: React.ReactNode;
|
|
24
29
|
/**
|
|
25
|
-
*
|
|
26
|
-
* `success` / `warning` / `
|
|
30
|
+
* 语义色(对齐 ADR 0021)— 决定左侧 icon 颜色;`open()` 默认 `primary`。
|
|
31
|
+
* `success` / `warning` / `destructive` 也可用对应快捷方法。
|
|
27
32
|
*/
|
|
28
|
-
|
|
33
|
+
color?: NotificationColor;
|
|
34
|
+
/**
|
|
35
|
+
* 自定义左侧 icon — 覆盖默认按 `color` 映射的 lucide icon。
|
|
36
|
+
* 传 `null` 显式隐藏 icon(只展示文字内容)。
|
|
37
|
+
* @example
|
|
38
|
+
* notification.open({ icon: <UserPlus className="size-5 text-primary" />, title: '新用户加入' })
|
|
39
|
+
*/
|
|
40
|
+
icon?: React.ReactNode | null;
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
const iconMap: Record<
|
|
32
|
-
|
|
43
|
+
const iconMap: Record<NotificationColor, React.ReactNode> = {
|
|
44
|
+
primary: <Info className="size-5 text-primary" />,
|
|
33
45
|
success: <CheckCircle2 className="size-5 text-success" />,
|
|
34
46
|
warning: <AlertCircle className="size-5 text-warning" />,
|
|
35
|
-
|
|
47
|
+
destructive: <XCircle className="size-5 text-destructive" />,
|
|
36
48
|
};
|
|
37
49
|
|
|
38
50
|
function fire(
|
|
39
|
-
|
|
40
|
-
{ title, description, ...rest }: NotificationOptions,
|
|
51
|
+
color: NotificationColor,
|
|
52
|
+
{ title, description, icon, ...rest }: NotificationOptions,
|
|
41
53
|
) {
|
|
54
|
+
// icon: undefined → 默认按 color 映射;null → 显式隐藏 icon;其他 ReactNode → 自定义
|
|
55
|
+
const iconNode = icon === undefined ? iconMap[color] : icon;
|
|
42
56
|
return toast.custom(
|
|
43
57
|
(id) => (
|
|
44
58
|
<div
|
|
45
59
|
role="alert"
|
|
46
60
|
className={cn(
|
|
47
|
-
'flex w-notification gap-3 rounded-md border bg-background p-4 text-
|
|
61
|
+
'flex w-notification gap-3 rounded-md border border-border bg-background p-4 text-xs shadow-lg',
|
|
48
62
|
)}
|
|
49
63
|
>
|
|
50
|
-
<span className="mt-0.5 shrink-0">{
|
|
64
|
+
{iconNode ? <span className="mt-0.5 shrink-0">{iconNode}</span> : null}
|
|
51
65
|
<div className="min-w-0 flex-1">
|
|
52
66
|
<div className="font-semibold leading-tight">{title}</div>
|
|
53
67
|
{description ? (
|
|
@@ -58,7 +72,7 @@ function fire(
|
|
|
58
72
|
type="button"
|
|
59
73
|
aria-label="关闭"
|
|
60
74
|
onClick={() => toast.dismiss(id)}
|
|
61
|
-
className="text-muted-foreground transition-colors hover:text-foreground"
|
|
75
|
+
className="cursor-pointer text-muted-foreground transition-colors hover:text-foreground"
|
|
62
76
|
>
|
|
63
77
|
×
|
|
64
78
|
</button>
|
|
@@ -70,13 +84,14 @@ function fire(
|
|
|
70
84
|
|
|
71
85
|
const notification = {
|
|
72
86
|
/**
|
|
73
|
-
* 通用打开 — 通过 `
|
|
87
|
+
* 通用打开 — 通过 `color` 区分状态;若只传 title,样式同 `primary`。
|
|
74
88
|
*/
|
|
75
|
-
open: (opts: NotificationOptions) => fire(opts.
|
|
76
|
-
|
|
77
|
-
success: (opts: Omit<NotificationOptions, '
|
|
78
|
-
warning: (opts: Omit<NotificationOptions, '
|
|
79
|
-
|
|
89
|
+
open: (opts: NotificationOptions) => fire(opts.color ?? 'primary', opts),
|
|
90
|
+
primary: (opts: Omit<NotificationOptions, 'color'>) => fire('primary', opts),
|
|
91
|
+
success: (opts: Omit<NotificationOptions, 'color'>) => fire('success', opts),
|
|
92
|
+
warning: (opts: Omit<NotificationOptions, 'color'>) => fire('warning', opts),
|
|
93
|
+
destructive: (opts: Omit<NotificationOptions, 'color'>) =>
|
|
94
|
+
fire('destructive', opts),
|
|
80
95
|
/** 主动关闭某条(传 `id`)/ 全部(不传)。 */
|
|
81
96
|
destroy: (id?: string | number) => toast.dismiss(id),
|
|
82
97
|
};
|