@teamix-evo/ui 0.1.1 → 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 +20 -10
- package/src/components/accordion/accordion.meta.md +5 -4
- package/src/components/accordion/accordion.stories.tsx +14 -9
- package/src/components/accordion/accordion.tsx +104 -8
- package/src/components/affix/affix.meta.md +20 -2
- package/src/components/affix/affix.stories.tsx +102 -25
- package/src/components/affix/affix.tsx +79 -9
- package/src/components/alert/alert.meta.md +44 -13
- 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 +61 -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 +8 -3
- package/src/components/anchor/anchor.stories.tsx +3 -3
- package/src/components/anchor/anchor.tsx +2 -2
- package/src/components/app/app.meta.md +9 -4
- package/src/components/app/app.stories.tsx +9 -7
- package/src/components/aspect-ratio/aspect-ratio.meta.md +4 -3
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +3 -3
- package/src/components/auto-complete/auto-complete.meta.md +14 -6
- package/src/components/auto-complete/auto-complete.stories.tsx +47 -4
- package/src/components/auto-complete/auto-complete.tsx +119 -71
- package/src/components/avatar/avatar.meta.md +6 -7
- package/src/components/avatar/avatar.stories.tsx +21 -3
- package/src/components/avatar/avatar.tsx +24 -23
- package/src/components/badge/badge.meta.md +10 -9
- package/src/components/badge/badge.stories.tsx +2 -2
- package/src/components/badge/badge.tsx +9 -15
- package/src/components/breadcrumb/breadcrumb.meta.md +27 -7
- package/src/components/breadcrumb/breadcrumb.stories.tsx +127 -4
- package/src/components/breadcrumb/breadcrumb.tsx +22 -8
- package/src/components/button/button.meta.md +258 -21
- package/src/components/button/button.stories.tsx +549 -41
- package/src/components/button/button.tsx +335 -33
- package/src/components/button/demo/as-child.tsx +24 -0
- package/src/components/button/demo/basic.tsx +8 -0
- package/src/components/button/demo/block.tsx +16 -0
- package/src/components/button/demo/loading.tsx +19 -0
- package/src/components/button/demo/shapes.tsx +18 -0
- package/src/components/button/demo/sizes.tsx +19 -0
- package/src/components/button/demo/variants.tsx +19 -0
- package/src/components/button/demo/with-icon.tsx +20 -0
- package/src/components/calendar/calendar.meta.md +13 -3
- package/src/components/calendar/calendar.stories.tsx +6 -6
- package/src/components/calendar/calendar.tsx +73 -8
- package/src/components/card/card.meta.md +27 -5
- package/src/components/card/card.stories.tsx +42 -3
- package/src/components/card/card.tsx +146 -63
- package/src/components/carousel/carousel.meta.md +4 -3
- package/src/components/carousel/carousel.stories.tsx +11 -6
- package/src/components/cascader/cascader.meta.md +47 -17
- package/src/components/cascader/cascader.stories.tsx +22 -10
- package/src/components/cascader/cascader.tsx +428 -85
- package/src/components/checkbox/checkbox.meta.md +75 -7
- package/src/components/checkbox/checkbox.stories.tsx +161 -3
- package/src/components/checkbox/checkbox.tsx +77 -9
- package/src/components/collapsible/collapsible.meta.md +14 -6
- package/src/components/collapsible/collapsible.stories.tsx +10 -2
- package/src/components/collapsible/collapsible.tsx +93 -6
- package/src/components/color-picker/color-picker.meta.md +12 -7
- package/src/components/color-picker/color-picker.stories.tsx +86 -7
- package/src/components/color-picker/color-picker.tsx +20 -9
- package/src/components/command/command.meta.md +29 -13
- package/src/components/command/command.stories.tsx +4 -4
- package/src/components/command/command.tsx +19 -8
- package/src/components/context-menu/context-menu.meta.md +11 -8
- package/src/components/context-menu/context-menu.stories.tsx +11 -3
- package/src/components/context-menu/context-menu.tsx +21 -8
- package/src/components/data-table/data-table.meta.md +6 -5
- package/src/components/data-table/data-table.stories.tsx +13 -6
- package/src/components/data-table/data-table.tsx +2 -2
- package/src/components/date-picker/date-picker.meta.md +88 -19
- 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 +10 -5
- package/src/components/descriptions/descriptions.stories.tsx +3 -3
- package/src/components/descriptions/descriptions.tsx +22 -14
- package/src/components/dialog/dialog.meta.md +76 -13
- 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 +33 -34
- package/src/components/drawer/drawer.stories.tsx +29 -12
- package/src/components/drawer/drawer.tsx +22 -113
- package/src/components/dropdown-menu/dropdown-menu.meta.md +78 -10
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +88 -2
- 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 +9 -4
- package/src/components/empty/empty.stories.tsx +4 -4
- package/src/components/empty/empty.tsx +10 -3
- package/src/components/field/field.meta.md +47 -9
- package/src/components/field/field.stories.tsx +385 -5
- 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 +54 -6
- package/src/components/flex/flex.stories.tsx +107 -20
- package/src/components/flex/flex.tsx +27 -4
- package/src/components/float-button/float-button.meta.md +8 -3
- package/src/components/float-button/float-button.stories.tsx +9 -7
- package/src/components/float-button/float-button.tsx +1 -1
- package/src/components/form/form.meta.md +39 -17
- package/src/components/form/form.stories.tsx +350 -3
- package/src/components/form/form.tsx +101 -35
- package/src/components/grid/grid.meta.md +7 -2
- package/src/components/grid/grid.stories.tsx +6 -4
- package/src/components/hover-card/hover-card.meta.md +20 -9
- package/src/components/hover-card/hover-card.stories.tsx +34 -5
- 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 +9 -4
- package/src/components/image/image.stories.tsx +3 -3
- package/src/components/image/image.tsx +6 -4
- package/src/components/input/demo/basic.tsx +12 -0
- package/src/components/input/demo/clearable.tsx +21 -0
- package/src/components/input/demo/show-count.tsx +18 -0
- package/src/components/input/demo/sizes.tsx +15 -0
- package/src/components/input/input.meta.md +39 -33
- package/src/components/input/input.stories.tsx +62 -35
- package/src/components/input/input.tsx +97 -98
- package/src/components/input-group/input-group.meta.md +54 -22
- package/src/components/input-group/input-group.stories.tsx +49 -16
- package/src/components/input-group/input-group.tsx +44 -8
- package/src/components/input-number/input-number.meta.md +64 -7
- package/src/components/input-number/input-number.stories.tsx +46 -8
- package/src/components/input-number/input-number.tsx +99 -26
- package/src/components/input-otp/input-otp.meta.md +4 -3
- 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 -3
- package/src/components/item/item.stories.tsx +8 -5
- package/src/components/item/item.tsx +7 -6
- package/src/components/kbd/kbd.meta.md +13 -4
- package/src/components/kbd/kbd.stories.tsx +4 -4
- package/src/components/kbd/kbd.tsx +10 -5
- package/src/components/label/label.meta.md +18 -10
- 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 -3
- package/src/components/masonry/masonry.stories.tsx +7 -5
- package/src/components/masonry/masonry.tsx +1 -0
- package/src/components/mentions/mentions.meta.md +36 -6
- package/src/components/mentions/mentions.stories.tsx +120 -6
- package/src/components/mentions/mentions.tsx +11 -5
- package/src/components/menubar/menubar.meta.md +30 -12
- package/src/components/menubar/menubar.stories.tsx +62 -2
- package/src/components/menubar/menubar.tsx +9 -9
- package/src/components/native-select/native-select.meta.md +8 -3
- package/src/components/native-select/native-select.stories.tsx +8 -5
- package/src/components/native-select/native-select.tsx +1 -1
- package/src/components/navigation-menu/navigation-menu.meta.md +19 -9
- package/src/components/navigation-menu/navigation-menu.stories.tsx +112 -9
- package/src/components/navigation-menu/navigation-menu.tsx +8 -4
- package/src/components/notification/notification.meta.md +52 -10
- package/src/components/notification/notification.stories.tsx +11 -9
- package/src/components/notification/notification.tsx +36 -21
- 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 +140 -37
- package/src/components/pagination/pagination.stories.tsx +232 -10
- package/src/components/pagination/pagination.tsx +355 -63
- package/src/components/popconfirm/popconfirm.meta.md +9 -4
- package/src/components/popconfirm/popconfirm.stories.tsx +3 -4
- package/src/components/popconfirm/popconfirm.tsx +2 -2
- package/src/components/popover/popover.meta.md +62 -5
- package/src/components/popover/popover.stories.tsx +83 -7
- package/src/components/popover/popover.tsx +77 -28
- package/src/components/progress/progress.meta.md +38 -6
- package/src/components/progress/progress.stories.tsx +3 -3
- package/src/components/progress/progress.tsx +24 -16
- package/src/components/radio-group/radio-group.meta.md +79 -7
- package/src/components/radio-group/radio-group.stories.tsx +39 -3
- package/src/components/radio-group/radio-group.tsx +149 -18
- package/src/components/rate/rate.meta.md +35 -4
- package/src/components/rate/rate.stories.tsx +13 -5
- package/src/components/rate/rate.tsx +37 -10
- package/src/components/resizable/resizable.meta.md +7 -4
- package/src/components/resizable/resizable.stories.tsx +6 -6
- package/src/components/resizable/resizable.tsx +1 -1
- package/src/components/result/result.meta.md +7 -2
- package/src/components/result/result.stories.tsx +4 -8
- package/src/components/result/result.tsx +24 -15
- package/src/components/scroll-area/scroll-area.meta.md +4 -3
- package/src/components/scroll-area/scroll-area.stories.tsx +12 -4
- package/src/components/scroll-area/scroll-area.tsx +3 -3
- package/src/components/segmented/segmented.meta.md +7 -4
- package/src/components/segmented/segmented.stories.tsx +37 -8
- package/src/components/segmented/segmented.tsx +15 -7
- package/src/components/select/select.meta.md +197 -52
- package/src/components/select/select.stories.tsx +238 -63
- package/src/components/select/select.tsx +718 -171
- package/src/components/separator/separator.meta.md +4 -3
- package/src/components/separator/separator.stories.tsx +3 -3
- package/src/components/separator/separator.tsx +3 -7
- package/src/components/sheet/sheet.meta.md +32 -16
- package/src/components/sheet/sheet.stories.tsx +116 -10
- package/src/components/sheet/sheet.tsx +116 -29
- package/src/components/sidebar/sidebar.meta.md +37 -18
- package/src/components/sidebar/sidebar.stories.tsx +701 -29
- package/src/components/sidebar/sidebar.tsx +615 -142
- package/src/components/skeleton/skeleton.meta.md +4 -5
- package/src/components/skeleton/skeleton.stories.tsx +4 -4
- package/src/components/skeleton/skeleton.tsx +7 -7
- package/src/components/slider/slider.meta.md +57 -5
- package/src/components/slider/slider.stories.tsx +58 -6
- package/src/components/slider/slider.tsx +154 -13
- package/src/components/sonner/sonner.meta.md +58 -7
- package/src/components/sonner/sonner.stories.tsx +78 -5
- package/src/components/sonner/sonner.tsx +137 -8
- package/src/components/spinner/spinner.meta.md +62 -13
- package/src/components/spinner/spinner.stories.tsx +66 -14
- package/src/components/spinner/spinner.tsx +111 -9
- package/src/components/statistic/statistic.meta.md +7 -2
- package/src/components/statistic/statistic.stories.tsx +3 -7
- package/src/components/statistic/statistic.tsx +5 -6
- package/src/components/steps/steps.meta.md +18 -4
- package/src/components/steps/steps.stories.tsx +43 -3
- package/src/components/steps/steps.tsx +15 -12
- package/src/components/switch/switch.meta.md +51 -5
- package/src/components/switch/switch.stories.tsx +6 -6
- package/src/components/switch/switch.tsx +109 -41
- package/src/components/table/table.meta.md +17 -6
- package/src/components/table/table.stories.tsx +10 -5
- package/src/components/table/table.tsx +4 -4
- package/src/components/tabs/tabs.meta.md +38 -25
- package/src/components/tabs/tabs.stories.tsx +111 -25
- package/src/components/tabs/tabs.tsx +125 -54
- package/src/components/tag/tag.meta.md +105 -40
- package/src/components/tag/tag.stories.tsx +189 -16
- package/src/components/tag/tag.tsx +222 -21
- package/src/components/textarea/textarea.meta.md +35 -19
- package/src/components/textarea/textarea.stories.tsx +32 -6
- package/src/components/textarea/textarea.tsx +33 -9
- package/src/components/time-picker/time-picker.meta.md +124 -32
- package/src/components/time-picker/time-picker.stories.tsx +85 -15
- package/src/components/time-picker/time-picker.tsx +913 -61
- package/src/components/timeline/timeline.meta.md +14 -6
- package/src/components/timeline/timeline.stories.tsx +37 -7
- package/src/components/timeline/timeline.tsx +35 -14
- package/src/components/toggle/toggle.meta.md +5 -4
- 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 +5 -4
- 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 +55 -5
- package/src/components/tooltip/tooltip.stories.tsx +42 -5
- package/src/components/tooltip/tooltip.tsx +81 -21
- package/src/components/tour/tour.meta.md +9 -4
- package/src/components/tour/tour.stories.tsx +3 -3
- package/src/components/tour/tour.tsx +4 -4
- package/src/components/transfer/transfer.meta.md +11 -6
- package/src/components/transfer/transfer.stories.tsx +4 -8
- package/src/components/transfer/transfer.tsx +28 -21
- package/src/components/tree/tree.meta.md +63 -5
- package/src/components/tree/tree.stories.tsx +31 -12
- package/src/components/tree/tree.tsx +9 -8
- package/src/components/tree-select/tree-select.meta.md +59 -8
- package/src/components/tree-select/tree-select.stories.tsx +3 -3
- package/src/components/tree-select/tree-select.tsx +42 -7
- package/src/components/typography/typography.meta.md +61 -14
- package/src/components/typography/typography.stories.tsx +12 -11
- package/src/components/typography/typography.tsx +43 -28
- package/src/components/upload/upload.meta.md +49 -4
- package/src/components/upload/upload.stories.tsx +72 -12
- package/src/components/upload/upload.tsx +170 -37
- package/src/components/watermark/watermark.meta.md +7 -2
- package/src/components/watermark/watermark.stories.tsx +101 -9
- package/src/components/watermark/watermark.tsx +1 -0
- 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 -92
- package/src/components/button-group/button-group.stories.tsx +0 -90
- package/src/components/button-group/button-group.tsx +0 -75
- package/src/components/combobox/combobox.meta.md +0 -93
- package/src/components/combobox/combobox.stories.tsx +0 -55
- package/src/components/combobox/combobox.tsx +0 -130
- package/src/components/space/space.meta.md +0 -94
- package/src/components/space/space.stories.tsx +0 -94
- package/src/components/space/space.tsx +0 -106
|
@@ -6,95 +6,159 @@ import { cn } from '@/utils/cn';
|
|
|
6
6
|
|
|
7
7
|
const Tabs = TabsPrimitive.Root;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* TabsList 的视觉风格 + 尺寸由 cva 表达;
|
|
11
|
+
* 同时通过 `TabsListContext` 把 variant / size 透传到 TabsTrigger,
|
|
12
|
+
* 使得消费者只需在 List 上声明一次。
|
|
13
|
+
*/
|
|
14
|
+
const tabsListVariants = cva('inline-flex items-center', {
|
|
10
15
|
variants: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
variant: {
|
|
17
|
+
// 下划线风格(antd 默认):整行 baseline border + 选中项底部 primary 高亮线
|
|
18
|
+
line: 'w-full justify-start gap-4 border-b border-border bg-transparent text-muted-foreground',
|
|
19
|
+
// 胶囊风格(吸收 Segmented):圆角容器 + muted 底色 + 选中项 background 白底 shadow
|
|
20
|
+
capsule:
|
|
21
|
+
'justify-center gap-1 rounded-lg bg-muted p-1 text-muted-foreground',
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
sm: '',
|
|
25
|
+
md: '',
|
|
26
|
+
lg: '',
|
|
14
27
|
},
|
|
15
28
|
},
|
|
16
|
-
|
|
29
|
+
compoundVariants: [
|
|
30
|
+
{ variant: 'capsule', size: 'sm', class: 'h-8' },
|
|
31
|
+
{ variant: 'capsule', size: 'md', class: 'h-9' },
|
|
32
|
+
{ variant: 'capsule', size: 'lg', class: 'h-10' },
|
|
33
|
+
],
|
|
34
|
+
defaultVariants: { variant: 'line', size: 'md' },
|
|
17
35
|
});
|
|
18
36
|
|
|
19
37
|
const tabsTriggerVariants = cva(
|
|
20
|
-
'inline-flex items-center justify-center whitespace-nowrap
|
|
38
|
+
'inline-flex cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
21
39
|
{
|
|
22
40
|
variants: {
|
|
23
|
-
|
|
24
|
-
line: 'relative
|
|
25
|
-
|
|
41
|
+
variant: {
|
|
42
|
+
line: 'relative -mb-px border-b-2 border-transparent text-muted-foreground hover:text-foreground data-[state=active]:border-primary data-[state=active]:text-foreground',
|
|
43
|
+
capsule:
|
|
44
|
+
'rounded-md text-muted-foreground hover:text-foreground data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
sm: 'text-xs',
|
|
48
|
+
md: 'text-xs',
|
|
49
|
+
lg: 'text-sm',
|
|
26
50
|
},
|
|
27
51
|
},
|
|
28
|
-
|
|
52
|
+
compoundVariants: [
|
|
53
|
+
{ variant: 'line', size: 'sm', class: 'px-1 py-1.5' },
|
|
54
|
+
{ variant: 'line', size: 'md', class: 'px-1 py-2' },
|
|
55
|
+
{ variant: 'line', size: 'lg', class: 'px-1 py-2.5' },
|
|
56
|
+
{ variant: 'capsule', size: 'sm', class: 'px-2.5 py-1' },
|
|
57
|
+
{ variant: 'capsule', size: 'md', class: 'px-3 py-1' },
|
|
58
|
+
{ variant: 'capsule', size: 'lg', class: 'px-4 py-1.5' },
|
|
59
|
+
],
|
|
60
|
+
defaultVariants: { variant: 'line', size: 'md' },
|
|
29
61
|
},
|
|
30
62
|
);
|
|
31
63
|
|
|
64
|
+
type TabsVariant = NonNullable<
|
|
65
|
+
VariantProps<typeof tabsListVariants>['variant']
|
|
66
|
+
>;
|
|
67
|
+
type TabsSize = NonNullable<VariantProps<typeof tabsListVariants>['size']>;
|
|
68
|
+
|
|
69
|
+
const TabsListContext = React.createContext<{
|
|
70
|
+
variant: TabsVariant;
|
|
71
|
+
size: TabsSize;
|
|
72
|
+
}>({ variant: 'line', size: 'md' });
|
|
73
|
+
|
|
32
74
|
export interface TabsListProps
|
|
33
75
|
extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>,
|
|
34
76
|
VariantProps<typeof tabsListVariants> {
|
|
35
77
|
/**
|
|
36
|
-
* 视觉风格(antd
|
|
37
|
-
*
|
|
78
|
+
* 视觉风格(shadcn ∪ antd 并集 + 吸收 Segmented)。
|
|
79
|
+
* - `line`:下划线风格(antd 默认),适合页面级主导航 / 大区块切换。
|
|
80
|
+
* - `capsule`:胶囊风格(取代旧 `card`,吸收 Segmented),muted 底色 + 选中项白底 shadow,适合紧凑互斥单选(视图切换、时间区间)。
|
|
81
|
+
* @default "line"
|
|
38
82
|
*/
|
|
39
|
-
|
|
83
|
+
variant?: TabsVariant;
|
|
40
84
|
/**
|
|
41
|
-
*
|
|
85
|
+
* 尺寸(antd `size` 并集)。三档统一驱动 trigger 的字号与 padding。
|
|
86
|
+
* @default "md"
|
|
87
|
+
*/
|
|
88
|
+
size?: TabsSize;
|
|
89
|
+
/**
|
|
90
|
+
* 右侧附加内容(antd `tabBarExtraContent` 并集);仅 `variant="line"` 显式支持(布局灵活)。
|
|
42
91
|
* 用法:把节点放进来即可,组件用 `flex justify-between` 自动撑开。
|
|
43
92
|
*/
|
|
44
93
|
extra?: React.ReactNode;
|
|
45
94
|
}
|
|
46
95
|
|
|
47
|
-
const TabsListContext = React.createContext<{ type: 'line' | 'card' }>({
|
|
48
|
-
type: 'card',
|
|
49
|
-
});
|
|
50
|
-
|
|
51
96
|
const TabsList = React.forwardRef<
|
|
52
97
|
React.ElementRef<typeof TabsPrimitive.List>,
|
|
53
98
|
TabsListProps
|
|
54
|
-
>(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
</TabsPrimitive.List>
|
|
65
|
-
);
|
|
66
|
-
if (extra) {
|
|
67
|
-
return (
|
|
68
|
-
<div
|
|
69
|
-
className={cn(
|
|
70
|
-
'flex items-center justify-between',
|
|
71
|
-
type === 'line' && 'border-b border-border',
|
|
72
|
-
)}
|
|
99
|
+
>(
|
|
100
|
+
(
|
|
101
|
+
{ className, variant = 'line', size = 'md', extra, children, ...props },
|
|
102
|
+
ref,
|
|
103
|
+
) => {
|
|
104
|
+
const list = (
|
|
105
|
+
<TabsPrimitive.List
|
|
106
|
+
ref={ref}
|
|
107
|
+
className={cn(tabsListVariants({ variant, size }), className)}
|
|
108
|
+
{...props}
|
|
73
109
|
>
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
className,
|
|
79
|
-
),
|
|
80
|
-
})}
|
|
81
|
-
<div className="shrink-0">{extra}</div>
|
|
82
|
-
</div>
|
|
110
|
+
<TabsListContext.Provider value={{ variant, size }}>
|
|
111
|
+
{children}
|
|
112
|
+
</TabsListContext.Provider>
|
|
113
|
+
</TabsPrimitive.List>
|
|
83
114
|
);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
115
|
+
if (extra) {
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
className={cn(
|
|
119
|
+
'flex items-center justify-between',
|
|
120
|
+
variant === 'line' && 'border-b border-border',
|
|
121
|
+
)}
|
|
122
|
+
>
|
|
123
|
+
{React.cloneElement(list, {
|
|
124
|
+
className: cn(
|
|
125
|
+
tabsListVariants({ variant, size }),
|
|
126
|
+
variant === 'line' && 'border-b-0',
|
|
127
|
+
className,
|
|
128
|
+
),
|
|
129
|
+
})}
|
|
130
|
+
<div className="shrink-0">{extra}</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return list;
|
|
135
|
+
},
|
|
136
|
+
);
|
|
87
137
|
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
88
138
|
|
|
139
|
+
/**
|
|
140
|
+
* `TabsTrigger` 也接受 `variant` / `size`,但仅用于显式覆盖来自 `TabsList`
|
|
141
|
+
* 的上下文(罕用)—— 通常在 `TabsList` 上声明一次即可。
|
|
142
|
+
* 类型用 inline 形式避免 gen:meta 候选优先匹配。
|
|
143
|
+
*/
|
|
89
144
|
const TabsTrigger = React.forwardRef<
|
|
90
145
|
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
91
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
92
|
-
|
|
93
|
-
|
|
146
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> & {
|
|
147
|
+
variant?: TabsVariant;
|
|
148
|
+
size?: TabsSize;
|
|
149
|
+
}
|
|
150
|
+
>(({ className, variant, size, ...props }, ref) => {
|
|
151
|
+
const ctx = React.useContext(TabsListContext);
|
|
94
152
|
return (
|
|
95
153
|
<TabsPrimitive.Trigger
|
|
96
154
|
ref={ref}
|
|
97
|
-
className={cn(
|
|
155
|
+
className={cn(
|
|
156
|
+
tabsTriggerVariants({
|
|
157
|
+
variant: variant ?? ctx.variant,
|
|
158
|
+
size: size ?? ctx.size,
|
|
159
|
+
}),
|
|
160
|
+
className,
|
|
161
|
+
)}
|
|
98
162
|
{...props}
|
|
99
163
|
/>
|
|
100
164
|
);
|
|
@@ -116,4 +180,11 @@ const TabsContent = React.forwardRef<
|
|
|
116
180
|
));
|
|
117
181
|
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
118
182
|
|
|
119
|
-
export {
|
|
183
|
+
export {
|
|
184
|
+
Tabs,
|
|
185
|
+
TabsList,
|
|
186
|
+
TabsTrigger,
|
|
187
|
+
TabsContent,
|
|
188
|
+
tabsListVariants,
|
|
189
|
+
tabsTriggerVariants,
|
|
190
|
+
};
|
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: tag
|
|
3
3
|
name: Tag
|
|
4
|
+
displayName: 标签
|
|
4
5
|
type: component
|
|
5
|
-
category:
|
|
6
|
+
category: data-display
|
|
6
7
|
since: 0.1.0
|
|
7
|
-
package:
|
|
8
|
+
package: '@teamix-evo/ui'
|
|
8
9
|
---
|
|
9
10
|
|
|
10
|
-
# Tag
|
|
11
|
+
# Tag 标签
|
|
11
12
|
|
|
12
|
-
标签 — antd
|
|
13
|
+
标签 — antd 独有补足 + cloud-design 多彩并集。**与 Badge 区别**:Tag 偏向**用户可关闭的关键词标签**(分类 / 筛选条件 / 多彩分类),支持 `variant`(形态轴)× `color`(语义色轴,对齐 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md))× `palette`(装饰色轴,9 预设 + 任意 CSS 值)的三轴正交组合,以及 `icon` / `size` / `closable`;Badge 偏向**状态徽标**(数字 / 红点 / 状态条)。
|
|
13
14
|
|
|
14
15
|
## When to use
|
|
15
16
|
|
|
16
|
-
- 关键词 / 标签 / 分类(博客标签、用户兴趣)
|
|
17
|
-
- 当前筛选条件展示(可关闭以移除条件)
|
|
18
|
-
- 列表项的次级标签(优先级 / 类型)
|
|
17
|
+
- 关键词 / 标签 / 分类(博客标签、用户兴趣) — 多彩分类用 `palette`
|
|
18
|
+
- 当前筛选条件展示(可关闭以移除条件) — 配 `closable + onClose`
|
|
19
|
+
- 列表项的次级标签(优先级 / 类型) — 状态语义用 `color`
|
|
20
|
+
- 单选 / 多选筛选 chip — 用 `CheckableTag` / `CheckableTagGroup`
|
|
19
21
|
|
|
20
22
|
## When NOT to use
|
|
21
23
|
|
|
22
|
-
- 状态指示 → `Badge`
|
|
24
|
+
- 状态指示(运行中 / 已停止 + 数字) → `Badge`
|
|
23
25
|
- 切换按钮 → `Toggle` / `ToggleGroup`
|
|
24
26
|
- 选择类输入 → `Combobox` / `Select`
|
|
25
27
|
|
|
28
|
+
## Props
|
|
29
|
+
|
|
26
30
|
<!-- auto:props:begin -->
|
|
27
31
|
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
28
32
|
| --- | --- | --- | --- | --- |
|
|
29
|
-
| `
|
|
33
|
+
| `variant` | `'solid' \| 'outline' \| 'ghost'` | `"solid"` | – | 形态轴(对齐 [ADR 0021](../../../../docs/adr/0021-semantic-color-api-unification.md)): `solid` 实色背景 / `outline` 仅描边 / `ghost` 仅文字。 |
|
|
34
|
+
| `color` | `'default' \| 'primary' \| 'success' \| 'warning' \| 'destructive'` | `"default"` | – | 语义色 — 与组件状态绑定的调色板,5 档(填充背景类省略 `muted`,信息色用 `primary`, 不收 `info` — 见 ADR 0021)。装饰性类别区分请用 `palette`。 |
|
|
35
|
+
| `size` | `'sm' \| 'md'` | `"md"` | – | 尺寸:`sm` 高 20px(更紧凑) / `md` 高 24px(默认)。 |
|
|
36
|
+
| `palette` | `TagPalettePreset \| (string & {})` | – | – | **分类色 / 装饰色** — 与 `color`(语义色) 正交,用于纯装饰的类别区分(博客标签 / 项目分类 / ...)。 接受 9 种预设色 `'blue' \| 'cyan' \| 'green' \| 'orange' \| 'purple' \| 'red' \| 'magenta' \| 'lime' \| 'gold'` 或任意 CSS 颜色值(如 `'#FF5733'` / `'hsl(280 80% 60%)'` / `'var(--brand)'`)。 `palette` 存在时会**覆盖** `color` 的语义配色(派生 bg / border / text 三档), 但仍受 `variant` 控制形态:`solid` 12% bg + 35% border、`outline` 仅 solid 描边、`ghost` 仅文字。 装饰类别走 `palette`;状态语义走 `color`。两者同传时 `palette` 优先(因为它是显式装饰意图)。 |
|
|
37
|
+
| `icon` | `React.ReactNode` | – | – | 标签文字左侧图标插槽(antd `icon` 并集)。推荐传 `lucide-react` icon。 与 `closable` 的关闭按钮不冲突 — icon 在左,X 在右。 |
|
|
30
38
|
| `closable` | `boolean` | `false` | – | 显示关闭按钮(antd `closable` 并集)。 |
|
|
31
|
-
| `onClose` | `() => void` | – | – |
|
|
39
|
+
| `onClose` | `() => void` | – | – | 关闭回调 — `closable` 触发时调用。建议父组件维护数组并在此回调中移除当前项。 |
|
|
32
40
|
<!-- auto:props:end -->
|
|
33
41
|
|
|
42
|
+
## 依赖
|
|
43
|
+
|
|
34
44
|
<!-- auto:deps:begin -->
|
|
35
45
|
### 同库依赖
|
|
36
46
|
|
|
@@ -51,44 +61,99 @@ pnpm add class-variance-authority@^0.7.0 lucide-react@^0.460.0
|
|
|
51
61
|
|
|
52
62
|
## AI 生成纪律
|
|
53
63
|
|
|
54
|
-
- **`color`
|
|
55
|
-
- **`
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
64
|
+
- **`color`(语义) vs `palette`(装饰) 选轴明确**:状态/反馈/校验类信号 → `color`;纯类别区分(标签云 / 分类) → `palette`。**不要混用**两轴去拼颜色
|
|
65
|
+
- **`variant` 是形态不是颜色**(ADR 0021):`solid` / `outline` / `ghost`,**禁止**回写 `variant="primary"` 等旧风格
|
|
66
|
+
- **`color` 不收 `info` / `error` / `danger`**:对齐 ADR 0021;信息色用 `color="primary"`,失败用 `destructive`
|
|
67
|
+
- **`palette` 优先级高于 `color`**:同时传时 palette 覆盖配色(实现:inline style > utility class)
|
|
68
|
+
- **palette 自定义值要可访问**:任意 CSS 颜色字符串都可传,但要保证 12% 透明度背景下对比度可读;**对纯白 / 极浅色慎用 solid 形态**(转为 `outline` 或 `ghost`)
|
|
69
|
+
- **`closable` 必配 `onClose`**:父组件维护数组并在回调中移除
|
|
70
|
+
- **icon 来源固定** `lucide-react`(ESLint `icon-from-lucide` 阻塞)。**不要**内联 SVG 或引入其它 icon 库
|
|
71
|
+
- **文字 ≤ 4 个汉字 / 8 字符**:过长视觉破碎,考虑改用 Description / Field
|
|
72
|
+
- **不要嵌套交互**:Tag 内不要放 Button / Link;`closable` X 已是组件唯一交互
|
|
73
|
+
- **圆角走 token**:`--radius-tag`(4px) 由组件内 inline style 注入,**不要**覆盖为其他档位
|
|
74
|
+
- **不要把语义色硬塞进 palette**:`palette="red"` 不等于 `color="destructive"` — 前者是装饰红,后者是危险信号语义
|
|
59
75
|
|
|
60
76
|
## Examples
|
|
61
77
|
|
|
62
78
|
```tsx
|
|
63
|
-
import { Tag } from '@/components/ui/tag';
|
|
79
|
+
import { Tag, CheckableTagGroup } from '@/components/ui/tag';
|
|
80
|
+
import { Hash, Star } from 'lucide-react';
|
|
64
81
|
import * as React from 'react';
|
|
65
82
|
|
|
66
|
-
//
|
|
67
|
-
<
|
|
68
|
-
<Tag
|
|
69
|
-
<Tag color="
|
|
70
|
-
<Tag color="
|
|
71
|
-
<Tag color="
|
|
72
|
-
|
|
73
|
-
// 可关闭
|
|
74
|
-
const [tags, setTags] = React.useState(['React', 'Vue', 'Angular']);
|
|
75
|
-
<div className="flex gap-2">
|
|
76
|
-
{tags.map((t) => (
|
|
77
|
-
<Tag
|
|
78
|
-
key={t}
|
|
79
|
-
color="primary"
|
|
80
|
-
closable
|
|
81
|
-
onClose={() => setTags(tags.filter((x) => x !== t))}
|
|
82
|
-
>
|
|
83
|
-
{t}
|
|
84
|
-
</Tag>
|
|
85
|
-
))}
|
|
83
|
+
// 1. 形态 × 语义色(三种 variant × 五档 color)
|
|
84
|
+
<div className="flex flex-wrap gap-2">
|
|
85
|
+
<Tag>Default</Tag>
|
|
86
|
+
<Tag variant="outline" color="primary">Primary outline</Tag>
|
|
87
|
+
<Tag variant="ghost" color="success">Ghost success</Tag>
|
|
88
|
+
<Tag color="warning">Warning</Tag>
|
|
89
|
+
<Tag color="destructive">Destructive</Tag>
|
|
86
90
|
</div>
|
|
87
91
|
|
|
88
|
-
//
|
|
92
|
+
// 2. 多彩分类(9 预设 + 任意 CSS 值)
|
|
89
93
|
<div className="flex flex-wrap gap-2">
|
|
90
|
-
<Tag
|
|
91
|
-
<Tag
|
|
92
|
-
<Tag
|
|
94
|
+
<Tag palette="blue">React</Tag>
|
|
95
|
+
<Tag palette="green">Vue</Tag>
|
|
96
|
+
<Tag palette="orange">Svelte</Tag>
|
|
97
|
+
<Tag palette="purple">Solid</Tag>
|
|
98
|
+
<Tag palette="#ff66cc">Custom Pink</Tag>
|
|
93
99
|
</div>
|
|
100
|
+
|
|
101
|
+
// 3. icon + closable + size
|
|
102
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
103
|
+
<Tag size="sm" icon={<Hash />}>small + icon</Tag>
|
|
104
|
+
<Tag icon={<Star />} closable onClose={() => alert('closed')}>
|
|
105
|
+
favorite
|
|
106
|
+
</Tag>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
// 4. CheckableTagGroup(单/多选 chip)
|
|
110
|
+
const [picked, setPicked] = React.useState<string[]>(['react']);
|
|
111
|
+
<CheckableTagGroup
|
|
112
|
+
value={picked}
|
|
113
|
+
onChange={setPicked}
|
|
114
|
+
options={[
|
|
115
|
+
{ label: 'React', value: 'react' },
|
|
116
|
+
{ label: 'Vue', value: 'vue' },
|
|
117
|
+
{ label: 'Angular', value: 'angular' },
|
|
118
|
+
]}
|
|
119
|
+
/>
|
|
94
120
|
```
|
|
121
|
+
|
|
122
|
+
## Tag 形态 — 旧库 API → 新映射
|
|
123
|
+
|
|
124
|
+
> 本节对齐 cloud-design (Teamix 1.0 hybridcloud) Tag / Tag.Closeable / Tag.Selectable / Tag.Group → 新库 Tag + CheckableTag + CheckableTagGroup 的迁移路径。
|
|
125
|
+
|
|
126
|
+
### 组件拆合
|
|
127
|
+
|
|
128
|
+
| 旧库 | 新库 | 说明 |
|
|
129
|
+
| ---------------- | -------------------------------------- | -------------------------------- |
|
|
130
|
+
| `Tag` | `Tag` | 基础标签,直接对应 |
|
|
131
|
+
| `Tag.Closeable` | `Tag closable onClose={fn}` | 合并为 `closable` prop |
|
|
132
|
+
| `Tag.Selectable` | `CheckableTag` | 重命名 |
|
|
133
|
+
| `Tag.Group` | `div className="flex flex-wrap gap-2"` | 无需专用容器,flex gap 替代 |
|
|
134
|
+
| — | `CheckableTagGroup` | 新库独有,data-driven 多选标签组 |
|
|
135
|
+
|
|
136
|
+
### Props / 值映射
|
|
137
|
+
|
|
138
|
+
| 旧库 | 新库 | 备注 |
|
|
139
|
+
| ------------------------------- | --------------------------------- | ----------------------------- |
|
|
140
|
+
| `type="normal"` | `variant="solid" color="default"` | 默认形态 |
|
|
141
|
+
| `type="primary"` | `variant="solid" color="primary"` | 主色填充 |
|
|
142
|
+
| `color="blue"` (预设色) | `palette="blue"` | 装饰色走 palette 轴 |
|
|
143
|
+
| `color="red"` (预设色) | `palette="red"` | 同上 |
|
|
144
|
+
| `size="small"` | `size="sm"` | 高 20px |
|
|
145
|
+
| `size="medium"` | `size="md"` | 高 24px(默认) |
|
|
146
|
+
| `closable` (Tag.Closeable 专属) | `closable` (Tag prop) | 统一到 Tag |
|
|
147
|
+
| `onClose` 返回 false 阻止 | 外部受控(不渲染) | 父组件 state 管理 |
|
|
148
|
+
| `closeArea="tag"` | — | 不迁移,固定 X 按钮区域 |
|
|
149
|
+
| `animation` / `afterAppear` | — | 不迁移(CSS transition 已内置) |
|
|
150
|
+
|
|
151
|
+
### 不迁移清单(保留新库优势)
|
|
152
|
+
|
|
153
|
+
| 旧库能力 | 理由 |
|
|
154
|
+
| ----------------------------- | ------------------------------------- |
|
|
155
|
+
| `closeArea="tag"` 整体可关闭 | 新库固定 X 按钮交互,语义更清晰 |
|
|
156
|
+
| `onClose` 返回 false 阻止关闭 | 新库用外部受控模式替代 |
|
|
157
|
+
| `animation` / `afterAppear` | 过渡已由 CSS `transition-colors` 覆盖 |
|
|
158
|
+
| `Tag.Group` 容器组件 | flex gap 布局更灵活,无需专用容器 |
|
|
159
|
+
| `hoverUnchangable` | 由 `variant` 形态决定 hover 行为 |
|
|
@@ -1,27 +1,68 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { Tag } from '
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import { Hash, Star, Tag as TagIcon, Sparkles } from 'lucide-react';
|
|
4
|
+
import { CheckableTagGroup, Tag } from './tag';
|
|
4
5
|
|
|
5
6
|
const meta: Meta<typeof Tag> = {
|
|
6
|
-
title: '
|
|
7
|
+
title: '数据展示 · Data Display/Tag',
|
|
7
8
|
component: Tag,
|
|
8
9
|
tags: ['autodocs'],
|
|
9
10
|
parameters: {
|
|
10
11
|
docs: {
|
|
11
12
|
description: {
|
|
12
13
|
component:
|
|
13
|
-
'标签
|
|
14
|
+
'标签 —— 用户可关闭的关键词标签 / 多彩分类 chip(博客标签、筛选条件、项目分类、单选/多选 chip)。基于原生 `<span>` + cva 形态轴,合并 antd Tag(`closable` / `icon` / `CheckableTag.Group`)与 cloud-design WindColorfulTag(`palette` 多彩分类) 的并集能力:形态 `variant`(`solid`/`outline`/`ghost`) × 语义 `color`(对齐 ADR 0021,5 档不收 `info`/`error`) × 装饰 `palette`(9 预设 + 任意 CSS 值) × `size`(`sm`/`md`) × `icon` × `closable`。视觉走 OpenTrek semantic tokens,圆角走 `--radius-tag`,所有样式来自 `@teamix-evo/tokens`,无 mock。',
|
|
14
15
|
},
|
|
15
16
|
},
|
|
16
17
|
},
|
|
17
18
|
argTypes: {
|
|
19
|
+
variant: {
|
|
20
|
+
control: 'inline-radio',
|
|
21
|
+
options: ['solid', 'outline', 'ghost'],
|
|
22
|
+
},
|
|
18
23
|
color: {
|
|
19
24
|
control: 'select',
|
|
20
|
-
options: ['default', 'primary', 'success', 'warning', '
|
|
25
|
+
options: ['default', 'primary', 'success', 'warning', 'destructive'],
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
control: 'inline-radio',
|
|
29
|
+
options: ['sm', 'md'],
|
|
30
|
+
},
|
|
31
|
+
palette: {
|
|
32
|
+
control: 'select',
|
|
33
|
+
options: [
|
|
34
|
+
undefined,
|
|
35
|
+
'blue',
|
|
36
|
+
'cyan',
|
|
37
|
+
'green',
|
|
38
|
+
'orange',
|
|
39
|
+
'purple',
|
|
40
|
+
'red',
|
|
41
|
+
'magenta',
|
|
42
|
+
'lime',
|
|
43
|
+
'gold',
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
icon: {
|
|
47
|
+
control: 'select',
|
|
48
|
+
options: ['none', 'hash', 'star', 'tag', 'sparkles'],
|
|
49
|
+
mapping: {
|
|
50
|
+
none: undefined,
|
|
51
|
+
hash: <Hash />,
|
|
52
|
+
star: <Star />,
|
|
53
|
+
tag: <TagIcon />,
|
|
54
|
+
sparkles: <Sparkles />,
|
|
55
|
+
},
|
|
21
56
|
},
|
|
22
57
|
closable: { control: 'boolean' },
|
|
23
58
|
},
|
|
24
|
-
args: {
|
|
59
|
+
args: {
|
|
60
|
+
variant: 'solid',
|
|
61
|
+
color: 'default',
|
|
62
|
+
size: 'md',
|
|
63
|
+
closable: false,
|
|
64
|
+
children: '标签',
|
|
65
|
+
},
|
|
25
66
|
};
|
|
26
67
|
|
|
27
68
|
export default meta;
|
|
@@ -29,24 +70,129 @@ type Story = StoryObj<typeof Tag>;
|
|
|
29
70
|
|
|
30
71
|
export const Playground: Story = {};
|
|
31
72
|
|
|
32
|
-
export const
|
|
73
|
+
export const SemanticColors: Story = {
|
|
74
|
+
name: '语义色 (color × variant)',
|
|
33
75
|
parameters: { controls: { disable: true } },
|
|
34
76
|
render: () => (
|
|
35
|
-
<div className="flex flex-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
<div className="flex flex-col gap-3">
|
|
78
|
+
{(['solid', 'outline', 'ghost'] as const).map((v) => (
|
|
79
|
+
<div key={v} className="flex flex-wrap items-center gap-2">
|
|
80
|
+
<span className="w-16 text-xs text-muted-foreground">{v}</span>
|
|
81
|
+
<Tag variant={v}>Default</Tag>
|
|
82
|
+
<Tag variant={v} color="primary">
|
|
83
|
+
Primary
|
|
84
|
+
</Tag>
|
|
85
|
+
<Tag variant={v} color="success">
|
|
86
|
+
Success
|
|
87
|
+
</Tag>
|
|
88
|
+
<Tag variant={v} color="warning">
|
|
89
|
+
Warning
|
|
90
|
+
</Tag>
|
|
91
|
+
<Tag variant={v} color="destructive">
|
|
92
|
+
Destructive
|
|
93
|
+
</Tag>
|
|
94
|
+
</div>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const Palette: Story = {
|
|
101
|
+
name: '多彩分类 (palette × variant)',
|
|
102
|
+
parameters: { controls: { disable: true } },
|
|
103
|
+
render: () => {
|
|
104
|
+
const presets = [
|
|
105
|
+
'blue',
|
|
106
|
+
'cyan',
|
|
107
|
+
'green',
|
|
108
|
+
'lime',
|
|
109
|
+
'gold',
|
|
110
|
+
'orange',
|
|
111
|
+
'red',
|
|
112
|
+
'magenta',
|
|
113
|
+
'purple',
|
|
114
|
+
] as const;
|
|
115
|
+
return (
|
|
116
|
+
<div className="flex flex-col gap-3">
|
|
117
|
+
{(['solid', 'outline', 'ghost'] as const).map((v) => (
|
|
118
|
+
<div key={v} className="flex flex-wrap items-center gap-2">
|
|
119
|
+
<span className="w-16 text-xs text-muted-foreground">{v}</span>
|
|
120
|
+
{presets.map((p) => (
|
|
121
|
+
<Tag key={p} variant={v} palette={p}>
|
|
122
|
+
{p}
|
|
123
|
+
</Tag>
|
|
124
|
+
))}
|
|
125
|
+
</div>
|
|
126
|
+
))}
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const PaletteCustom: Story = {
|
|
133
|
+
name: '多彩分类 · 自定义 CSS 颜色',
|
|
134
|
+
parameters: { controls: { disable: true } },
|
|
135
|
+
render: () => (
|
|
136
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
137
|
+
{/* eslint-disable teamix-evo/no-color-literal -- demo of custom palette accepting any CSS color string (hex / hsl / named); these are literals **as user input**, not styling decisions. */}
|
|
138
|
+
<Tag palette="#ff66cc">#ff66cc</Tag>
|
|
139
|
+
<Tag palette="hsl(280 80% 60%)">hsl(280 80% 60%)</Tag>
|
|
140
|
+
<Tag palette="teal">teal</Tag>
|
|
141
|
+
<Tag palette="var(--color-primary)">var(--color-primary)</Tag>
|
|
142
|
+
<Tag variant="outline" palette="rebeccapurple">
|
|
143
|
+
rebeccapurple
|
|
144
|
+
</Tag>
|
|
145
|
+
{/* eslint-enable teamix-evo/no-color-literal */}
|
|
146
|
+
</div>
|
|
147
|
+
),
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const Sizes: Story = {
|
|
151
|
+
name: '尺寸',
|
|
152
|
+
parameters: { controls: { disable: true } },
|
|
153
|
+
render: () => (
|
|
154
|
+
<div className="flex items-center gap-2">
|
|
155
|
+
<Tag size="sm">Small</Tag>
|
|
156
|
+
<Tag size="md">Medium</Tag>
|
|
157
|
+
<Tag size="sm" color="primary">
|
|
158
|
+
sm primary
|
|
159
|
+
</Tag>
|
|
160
|
+
<Tag size="md" color="success">
|
|
161
|
+
md success
|
|
162
|
+
</Tag>
|
|
163
|
+
</div>
|
|
164
|
+
),
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const WithIcon: Story = {
|
|
168
|
+
name: 'icon 插槽',
|
|
169
|
+
parameters: { controls: { disable: true } },
|
|
170
|
+
render: () => (
|
|
171
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
172
|
+
<Tag icon={<Hash />}>topic</Tag>
|
|
173
|
+
<Tag icon={<Star />} color="warning">
|
|
174
|
+
featured
|
|
175
|
+
</Tag>
|
|
176
|
+
<Tag variant="outline" icon={<Sparkles />} palette="purple">
|
|
177
|
+
new
|
|
178
|
+
</Tag>
|
|
179
|
+
<Tag icon={<TagIcon />} closable onClose={() => undefined}>
|
|
180
|
+
with icon + closable
|
|
181
|
+
</Tag>
|
|
42
182
|
</div>
|
|
43
183
|
),
|
|
44
184
|
};
|
|
45
185
|
|
|
46
186
|
export const Closable: Story = {
|
|
187
|
+
name: 'closable + 受控移除',
|
|
47
188
|
parameters: { controls: { disable: true } },
|
|
48
189
|
render: () => {
|
|
49
|
-
const [tags, setTags] = React.useState([
|
|
190
|
+
const [tags, setTags] = React.useState([
|
|
191
|
+
'React',
|
|
192
|
+
'Vue',
|
|
193
|
+
'Angular',
|
|
194
|
+
'Svelte',
|
|
195
|
+
]);
|
|
50
196
|
return (
|
|
51
197
|
<div className="flex flex-wrap gap-2">
|
|
52
198
|
{tags.map((t) => (
|
|
@@ -65,9 +211,10 @@ export const Closable: Story = {
|
|
|
65
211
|
};
|
|
66
212
|
|
|
67
213
|
export const Filters: Story = {
|
|
214
|
+
name: '场景:筛选条件',
|
|
68
215
|
parameters: { controls: { disable: true } },
|
|
69
216
|
render: () => (
|
|
70
|
-
<div className="flex flex-wrap gap-2">
|
|
217
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
71
218
|
<span className="text-sm text-muted-foreground">已选筛选:</span>
|
|
72
219
|
<Tag closable>状态: 运行中</Tag>
|
|
73
220
|
<Tag closable>类型: 服务</Tag>
|
|
@@ -75,3 +222,29 @@ export const Filters: Story = {
|
|
|
75
222
|
</div>
|
|
76
223
|
),
|
|
77
224
|
};
|
|
225
|
+
|
|
226
|
+
export const Checkable: Story = {
|
|
227
|
+
name: 'CheckableTagGroup',
|
|
228
|
+
parameters: { controls: { disable: true } },
|
|
229
|
+
render: () => {
|
|
230
|
+
const [picked, setPicked] = React.useState<string[]>(['react']);
|
|
231
|
+
return (
|
|
232
|
+
<div className="flex flex-col gap-2">
|
|
233
|
+
<CheckableTagGroup
|
|
234
|
+
value={picked}
|
|
235
|
+
onChange={setPicked}
|
|
236
|
+
options={[
|
|
237
|
+
{ label: 'React', value: 'react' },
|
|
238
|
+
{ label: 'Vue', value: 'vue' },
|
|
239
|
+
{ label: 'Angular', value: 'angular' },
|
|
240
|
+
{ label: 'Svelte', value: 'svelte' },
|
|
241
|
+
{ label: 'Solid', value: 'solid', disabled: true },
|
|
242
|
+
]}
|
|
243
|
+
/>
|
|
244
|
+
<span className="text-xs text-muted-foreground">
|
|
245
|
+
已选: {picked.join(', ') || '(空)'}
|
|
246
|
+
</span>
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
},
|
|
250
|
+
};
|