banhaten 0.1.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/LICENSE +21 -0
- package/README.md +361 -0
- package/banhaten.config.example.json +13 -0
- package/package.json +59 -0
- package/registry/assets/activity-feed-avatar.png +0 -0
- package/registry/assets/avatars/avatar-01.jpg +0 -0
- package/registry/assets/avatars/avatar-02.jpg +0 -0
- package/registry/assets/avatars/avatar-03.jpg +0 -0
- package/registry/assets/avatars/avatar-04.jpg +0 -0
- package/registry/assets/avatars/avatar-05.jpg +0 -0
- package/registry/assets/avatars/avatar-06.jpg +0 -0
- package/registry/assets/avatars/avatar-07.jpg +0 -0
- package/registry/assets/avatars/avatar-08.jpg +0 -0
- package/registry/assets/avatars/avatar-09.jpg +0 -0
- package/registry/assets/avatars/avatar-10.jpg +0 -0
- package/registry/assets/avatars/avatar-11.jpg +0 -0
- package/registry/assets/avatars/avatar-12.jpg +0 -0
- package/registry/assets/avatars/avatar-13.jpg +0 -0
- package/registry/assets/avatars/avatar-14.jpg +0 -0
- package/registry/assets/avatars/avatar-15.jpg +0 -0
- package/registry/assets/avatars/avatar-16.jpg +0 -0
- package/registry/assets/avatars/avatar-17.jpg +0 -0
- package/registry/assets/avatars/avatar-18.jpg +0 -0
- package/registry/assets/avatars/avatar-19.jpg +0 -0
- package/registry/assets/avatars/avatar-20.jpg +0 -0
- package/registry/assets/avatars/avatar-21.jpg +0 -0
- package/registry/assets/avatars/avatar-22.jpg +0 -0
- package/registry/assets/avatars/avatar-23.jpg +0 -0
- package/registry/assets/avatars/avatar-24.jpg +0 -0
- package/registry/assets/avatars/avatar-25.jpg +0 -0
- package/registry/assets/avatars/avatar-26.jpg +0 -0
- package/registry/assets/avatars/avatar-27.jpg +0 -0
- package/registry/assets/avatars/avatar-28.jpg +0 -0
- package/registry/assets/avatars/avatar-29.jpg +0 -0
- package/registry/assets/avatars/avatar-30.jpg +0 -0
- package/registry/assets/avatars/avatar-31.jpg +0 -0
- package/registry/assets/avatars/avatar-32.jpg +0 -0
- package/registry/assets/avatars/avatar-33.jpg +0 -0
- package/registry/assets/avatars/avatar-34.jpg +0 -0
- package/registry/assets/avatars/avatar-35.jpg +0 -0
- package/registry/assets/image-assets.json +744 -0
- package/registry/assets/images/art-01.jpg +0 -0
- package/registry/assets/images/art-02.jpg +0 -0
- package/registry/assets/images/art-03.jpg +0 -0
- package/registry/assets/images/art-04.jpg +0 -0
- package/registry/assets/images/art-05.jpg +0 -0
- package/registry/assets/images/art-06.jpg +0 -0
- package/registry/assets/images/art-07.jpg +0 -0
- package/registry/assets/images/art-08.jpg +0 -0
- package/registry/assets/images/art-09.jpg +0 -0
- package/registry/assets/images/art-10.jpg +0 -0
- package/registry/assets/images/art-11.jpg +0 -0
- package/registry/assets/images/art-12.jpg +0 -0
- package/registry/assets/images/art-13.jpg +0 -0
- package/registry/assets/images/art-14.jpg +0 -0
- package/registry/assets/images/art-15.jpg +0 -0
- package/registry/assets/images/art-16.jpg +0 -0
- package/registry/assets/images/art-17.jpg +0 -0
- package/registry/assets/images/art-18.jpg +0 -0
- package/registry/assets/images/art-19.jpg +0 -0
- package/registry/assets/images/art-20.jpg +0 -0
- package/registry/assets/images/art-21.jpg +0 -0
- package/registry/assets/images/art-22.jpg +0 -0
- package/registry/assets/images/art-23.jpg +0 -0
- package/registry/assets/images/art-24.jpg +0 -0
- package/registry/assets/images/art-25.jpg +0 -0
- package/registry/assets/images/art-26.jpg +0 -0
- package/registry/assets/images/art-27.jpg +0 -0
- package/registry/assets/images/nature-01.jpg +0 -0
- package/registry/assets/images/nature-02.jpg +0 -0
- package/registry/assets/images/nature-03.jpg +0 -0
- package/registry/assets/images/nature-04.jpg +0 -0
- package/registry/assets/images/nature-05.jpg +0 -0
- package/registry/assets/images/nature-06.jpg +0 -0
- package/registry/assets/images/nature-07.jpg +0 -0
- package/registry/assets/images/nature-08.jpg +0 -0
- package/registry/assets/images/nature-09.jpg +0 -0
- package/registry/assets/images/nature-10.jpg +0 -0
- package/registry/assets/images/nature-11.jpg +0 -0
- package/registry/assets/images/nature-12.jpg +0 -0
- package/registry/assets/images/nature-13.jpg +0 -0
- package/registry/assets/images/nature-14.jpg +0 -0
- package/registry/assets/images/nature-15.jpg +0 -0
- package/registry/assets/images/nature-16.jpg +0 -0
- package/registry/assets/images/nature-17.jpg +0 -0
- package/registry/assets/images/nature-18.jpg +0 -0
- package/registry/assets/images/nature-19.jpg +0 -0
- package/registry/assets/images/nature-20.jpg +0 -0
- package/registry/components/accordion.tsx +119 -0
- package/registry/components/alert.tsx +282 -0
- package/registry/components/attribute.tsx +452 -0
- package/registry/components/avatar.tsx +142 -0
- package/registry/components/badge.tsx +567 -0
- package/registry/components/button-group.tsx +246 -0
- package/registry/components/button.tsx +102 -0
- package/registry/components/card.tsx +613 -0
- package/registry/components/checkbox.tsx +244 -0
- package/registry/components/date-picker.tsx +1143 -0
- package/registry/components/divider.tsx +82 -0
- package/registry/components/expanded/ActivityFeed.tsx +226 -0
- package/registry/components/expanded/Banner.tsx +145 -0
- package/registry/components/expanded/BannerBoard.tsx +225 -0
- package/registry/components/expanded/Breadcrumbs.tsx +156 -0
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +211 -0
- package/registry/components/expanded/CatalogDivider.tsx +48 -0
- package/registry/components/expanded/CatalogTag.tsx +92 -0
- package/registry/components/expanded/CommandBar.tsx +406 -0
- package/registry/components/expanded/FileUpload.tsx +231 -0
- package/registry/components/expanded/IconExplorer.tsx +612 -0
- package/registry/components/expanded/OnboardingStepListItem.tsx +67 -0
- package/registry/components/expanded/PageHeader.tsx +184 -0
- package/registry/components/expanded/Slideout.tsx +514 -0
- package/registry/components/expanded/Steps.tsx +266 -0
- package/registry/components/expanded/Table.tsx +1014 -0
- package/registry/components/expanded/Tabs.tsx +86 -0
- package/registry/components/expanded/Timeline.tsx +235 -0
- package/registry/components/expanded/TimelineShowcase.tsx +158 -0
- package/registry/components/expanded/activityFeed.css +292 -0
- package/registry/components/expanded/banner.css +312 -0
- package/registry/components/expanded/breadcrumbs.css +140 -0
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -0
- package/registry/components/expanded/commandBar.css +473 -0
- package/registry/components/expanded/divider.css +75 -0
- package/registry/components/expanded/fileUpload.css +228 -0
- package/registry/components/expanded/iconExplorer.css +764 -0
- package/registry/components/expanded/iconPacks.ts +866 -0
- package/registry/components/expanded/onboardingStepListItem.css +126 -0
- package/registry/components/expanded/pageHeader.css +287 -0
- package/registry/components/expanded/slideout.css +955 -0
- package/registry/components/expanded/steps.css +329 -0
- package/registry/components/expanded/table.css +607 -0
- package/registry/components/expanded/tabs.css +197 -0
- package/registry/components/expanded/tag.css +148 -0
- package/registry/components/expanded/timeline.css +282 -0
- package/registry/components/input-content.ts +106 -0
- package/registry/components/input.tsx +866 -0
- package/registry/components/menu.tsx +758 -0
- package/registry/components/modal.tsx +799 -0
- package/registry/components/pagination.tsx +543 -0
- package/registry/components/progress-slider.tsx +216 -0
- package/registry/components/progress.tsx +367 -0
- package/registry/components/radio-card.tsx +654 -0
- package/registry/components/radio-group.tsx +570 -0
- package/registry/components/select-content.tsx +313 -0
- package/registry/components/select.tsx +871 -0
- package/registry/components/slider.tsx +380 -0
- package/registry/components/social-button.tsx +360 -0
- package/registry/components/spinner.tsx +31 -0
- package/registry/components/tag.tsx +423 -0
- package/registry/components/textarea.tsx +625 -0
- package/registry/components/toggle.tsx +272 -0
- package/registry/components/toolbar.tsx +467 -0
- package/registry/components/tooltip.tsx +427 -0
- package/registry/examples/accordion-demo.tsx +34 -0
- package/registry/examples/alert-demo.tsx +14 -0
- package/registry/examples/attribute-demo.tsx +65 -0
- package/registry/examples/avatar-demo.tsx +74 -0
- package/registry/examples/badge-demo.tsx +53 -0
- package/registry/examples/button-demo.tsx +83 -0
- package/registry/examples/button-group-demo.tsx +42 -0
- package/registry/examples/card-demo.tsx +48 -0
- package/registry/examples/checkbox-demo.tsx +67 -0
- package/registry/examples/date-picker-demo.tsx +74 -0
- package/registry/examples/divider-demo.tsx +17 -0
- package/registry/examples/expanded/activity-feed-demo.tsx +22 -0
- package/registry/examples/expanded/banner-demo.tsx +23 -0
- package/registry/examples/expanded/catalog-components-demo.tsx +5 -0
- package/registry/examples/expanded/command-bar-demo.tsx +10 -0
- package/registry/examples/expanded/icons-demo.tsx +5 -0
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -0
- package/registry/examples/expanded/page-header-demo.tsx +19 -0
- package/registry/examples/expanded/slideout-demo.tsx +15 -0
- package/registry/examples/expanded/steps-demo.tsx +18 -0
- package/registry/examples/expanded/tabs-demo.tsx +13 -0
- package/registry/examples/expanded/timeline-demo.tsx +18 -0
- package/registry/examples/input-demo.tsx +87 -0
- package/registry/examples/menu-demo.tsx +109 -0
- package/registry/examples/modal-demo.tsx +16 -0
- package/registry/examples/pagination-demo.tsx +17 -0
- package/registry/examples/progress-demo.tsx +37 -0
- package/registry/examples/progress-slider-demo.tsx +29 -0
- package/registry/examples/radio-card-demo.tsx +51 -0
- package/registry/examples/radio-group-demo.tsx +62 -0
- package/registry/examples/select-demo.tsx +73 -0
- package/registry/examples/slider-demo.tsx +31 -0
- package/registry/examples/social-button-demo.tsx +51 -0
- package/registry/examples/tag-demo.tsx +29 -0
- package/registry/examples/textarea-demo.tsx +79 -0
- package/registry/examples/toggle-demo.tsx +59 -0
- package/registry/examples/toolbar-demo.tsx +80 -0
- package/registry/examples/tooltip-demo.tsx +115 -0
- package/registry/hooks/use-direction.ts +27 -0
- package/registry/index.json +1213 -0
- package/registry/styles/globals.css +4600 -0
- package/registry/utils/cn.ts +6 -0
- package/src/cli/index.js +826 -0
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
- package/tokens/banhaten.tokens.json +5525 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
type ButtonGroupSize = "md" | "sm" | "xs"
|
|
8
|
+
type ButtonGroupMode = "default" | "iconOnly"
|
|
9
|
+
|
|
10
|
+
type ButtonGroupContextValue = {
|
|
11
|
+
size: ButtonGroupSize
|
|
12
|
+
mode: ButtonGroupMode
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const buttonGroupContext = React.createContext<ButtonGroupContextValue>({
|
|
16
|
+
size: "md",
|
|
17
|
+
mode: "default",
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const buttonGroupVariants = cva(
|
|
21
|
+
"inline-flex items-center overflow-hidden rounded-[var(--bh-button-group-radius)] bg-[var(--bh-button-group-bg)] text-[var(--bh-button-group-content)] shadow-[var(--shadow-button-group)] [--shadow-button-group:inset_0px_0px_0px_var(--bh-border-width-default)_var(--bh-button-group-border),var(--shadow-component-default)]",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
size: {
|
|
25
|
+
md: "h-[var(--bh-button-group-md-height)]",
|
|
26
|
+
sm: "h-[var(--bh-button-group-sm-height)]",
|
|
27
|
+
xs: "h-[var(--bh-button-group-xs-height)]",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
size: "md",
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const buttonGroupItemVariants = cva(
|
|
37
|
+
"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap bg-[var(--bh-button-group-item-bg)] text-[length:var(--bh-text-button-font-size)] font-[var(--bh-text-button-font-weight)] leading-[var(--bh-text-button-line-height)] tracking-[var(--bh-text-button-letter-spacing)] text-[var(--bh-button-group-content)] outline-none transition-[background-color,box-shadow,color] before:absolute before:inset-y-0 before:start-0 before:w-[var(--bh-border-width-default)] before:bg-[var(--bh-button-group-divider)] before:content-[''] first:before:hidden hover:bg-[var(--bh-button-group-item-hover-bg)] active:bg-[var(--bh-button-group-item-pressed-bg)] focus-visible:z-[var(--bh-z-raised)] focus-visible:shadow-[var(--shadow-button-group-focus)] aria-[pressed=true]:bg-[var(--bh-button-group-item-active-bg)] aria-[pressed=true]:text-[var(--bh-button-group-content-active)] data-[active=true]:bg-[var(--bh-button-group-item-active-bg)] data-[active=true]:text-[var(--bh-button-group-content-active)] disabled:pointer-events-none disabled:bg-[var(--bh-button-group-item-disabled-bg)] disabled:text-[var(--bh-button-group-content-disabled)] [&_svg]:pointer-events-none [&_svg]:size-[var(--bh-button-group-icon-size)] [&_svg]:shrink-0 rtl:[&_svg[data-rtl-flip='true']]:-scale-x-100",
|
|
38
|
+
{
|
|
39
|
+
variants: {
|
|
40
|
+
size: {
|
|
41
|
+
md: "h-[var(--bh-button-group-md-height)] gap-[var(--bh-button-group-md-gap)]",
|
|
42
|
+
sm: "h-[var(--bh-button-group-sm-height)] gap-[var(--bh-button-group-sm-gap)]",
|
|
43
|
+
xs: "h-[var(--bh-button-group-xs-height)] gap-[var(--bh-button-group-xs-gap)]",
|
|
44
|
+
},
|
|
45
|
+
mode: {
|
|
46
|
+
default: "",
|
|
47
|
+
iconOnly: "",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
compoundVariants: [
|
|
51
|
+
{
|
|
52
|
+
size: "md",
|
|
53
|
+
mode: "default",
|
|
54
|
+
class:
|
|
55
|
+
"w-[var(--bh-button-group-md-item-width)] px-[var(--bh-button-group-md-padding-x)] rtl:w-[var(--bh-button-group-md-item-rtl-width)]",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
size: "sm",
|
|
59
|
+
mode: "default",
|
|
60
|
+
class:
|
|
61
|
+
"w-[var(--bh-button-group-sm-item-width)] px-[var(--bh-button-group-sm-padding-x)] rtl:w-[var(--bh-button-group-sm-item-rtl-width)]",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
size: "xs",
|
|
65
|
+
mode: "default",
|
|
66
|
+
class:
|
|
67
|
+
"w-[var(--bh-button-group-xs-item-width)] px-[var(--bh-button-group-xs-padding-x)] rtl:w-[var(--bh-button-group-xs-item-rtl-width)]",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
size: "md",
|
|
71
|
+
mode: "iconOnly",
|
|
72
|
+
class:
|
|
73
|
+
"w-[var(--bh-button-group-md-height)] px-[var(--bh-button-group-md-icon-padding-x)]",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
size: "sm",
|
|
77
|
+
mode: "iconOnly",
|
|
78
|
+
class:
|
|
79
|
+
"w-[var(--bh-button-group-sm-height)] px-[var(--bh-button-group-sm-icon-padding-x)]",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
size: "xs",
|
|
83
|
+
mode: "iconOnly",
|
|
84
|
+
class:
|
|
85
|
+
"w-[var(--bh-button-group-xs-height)] px-[var(--bh-button-group-xs-icon-padding-x)]",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
size: "md",
|
|
90
|
+
mode: "default",
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
type ButtonGroupProps = React.ComponentProps<"div"> &
|
|
96
|
+
VariantProps<typeof buttonGroupVariants> & {
|
|
97
|
+
mode?: ButtonGroupMode
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(function ButtonGroup({
|
|
101
|
+
className,
|
|
102
|
+
size = "md",
|
|
103
|
+
mode = "default",
|
|
104
|
+
children,
|
|
105
|
+
role = "group",
|
|
106
|
+
...props
|
|
107
|
+
}, ref) {
|
|
108
|
+
const contextValue = React.useMemo(
|
|
109
|
+
() => ({
|
|
110
|
+
size: (size || "md") as ButtonGroupSize,
|
|
111
|
+
mode: mode || "default",
|
|
112
|
+
}),
|
|
113
|
+
[size, mode]
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<buttonGroupContext.Provider value={contextValue}>
|
|
118
|
+
<div
|
|
119
|
+
data-mode={contextValue.mode}
|
|
120
|
+
data-size={contextValue.size}
|
|
121
|
+
data-slot="button-group"
|
|
122
|
+
ref={ref}
|
|
123
|
+
role={role}
|
|
124
|
+
className={cn(buttonGroupVariants({ size: contextValue.size }), className)}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</div>
|
|
129
|
+
</buttonGroupContext.Provider>
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
type ButtonGroupItemProps = React.ComponentProps<"button"> &
|
|
134
|
+
VariantProps<typeof buttonGroupItemVariants> & {
|
|
135
|
+
asChild?: boolean
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const ButtonGroupItem = React.forwardRef<HTMLButtonElement, ButtonGroupItemProps>(function ButtonGroupItem({
|
|
139
|
+
className,
|
|
140
|
+
size,
|
|
141
|
+
mode,
|
|
142
|
+
asChild = false,
|
|
143
|
+
children,
|
|
144
|
+
type,
|
|
145
|
+
"aria-label": ariaLabel,
|
|
146
|
+
disabled,
|
|
147
|
+
"aria-pressed": ariaPressed,
|
|
148
|
+
onMouseDown,
|
|
149
|
+
...props
|
|
150
|
+
}, ref) {
|
|
151
|
+
const context = React.useContext(buttonGroupContext)
|
|
152
|
+
const selectedSize = (size || context.size) as ButtonGroupSize
|
|
153
|
+
const selectedMode = mode || context.mode
|
|
154
|
+
const Comp = asChild ? Slot : "button"
|
|
155
|
+
const accessibleLabel =
|
|
156
|
+
selectedMode === "iconOnly" ? ariaLabel || getTextAlternative(children) : ariaLabel
|
|
157
|
+
const handleMouseDown = React.useCallback(
|
|
158
|
+
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
159
|
+
onMouseDown?.(event)
|
|
160
|
+
|
|
161
|
+
if (!event.defaultPrevented) {
|
|
162
|
+
event.preventDefault()
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
[onMouseDown]
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<Comp
|
|
170
|
+
aria-label={accessibleLabel}
|
|
171
|
+
aria-pressed={ariaPressed}
|
|
172
|
+
data-mode={selectedMode}
|
|
173
|
+
data-size={selectedSize}
|
|
174
|
+
data-slot="button-group-item"
|
|
175
|
+
ref={ref}
|
|
176
|
+
className={cn(
|
|
177
|
+
buttonGroupItemVariants({
|
|
178
|
+
size: selectedSize,
|
|
179
|
+
mode: selectedMode,
|
|
180
|
+
className,
|
|
181
|
+
})
|
|
182
|
+
)}
|
|
183
|
+
{...(!asChild ? { type: type || "button" } : {})}
|
|
184
|
+
{...(!asChild ? { disabled } : {})}
|
|
185
|
+
onMouseDown={handleMouseDown}
|
|
186
|
+
{...props}
|
|
187
|
+
>
|
|
188
|
+
{asChild ? children : (
|
|
189
|
+
<ButtonGroupItemChildren mode={selectedMode}>{children}</ButtonGroupItemChildren>
|
|
190
|
+
)}
|
|
191
|
+
</Comp>
|
|
192
|
+
)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
function ButtonGroupItemChildren({
|
|
196
|
+
children,
|
|
197
|
+
mode,
|
|
198
|
+
}: {
|
|
199
|
+
children: React.ReactNode
|
|
200
|
+
mode: ButtonGroupMode
|
|
201
|
+
}) {
|
|
202
|
+
if (mode === "iconOnly") {
|
|
203
|
+
return children
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return React.Children.map(children, (child) => {
|
|
207
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
208
|
+
return (
|
|
209
|
+
<span
|
|
210
|
+
data-slot="button-group-item-label"
|
|
211
|
+
dir="auto"
|
|
212
|
+
className="min-w-0 px-[var(--bh-button-group-label-padding-x)]"
|
|
213
|
+
>
|
|
214
|
+
{child}
|
|
215
|
+
</span>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return child
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function getTextAlternative(children: React.ReactNode) {
|
|
224
|
+
let text = ""
|
|
225
|
+
|
|
226
|
+
React.Children.forEach(children, (child) => {
|
|
227
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
228
|
+
text += child
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (React.isValidElement<{ children?: React.ReactNode }>(child)) {
|
|
233
|
+
text += getTextAlternative(child.props.children) || ""
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
return text.trim() || undefined
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export { ButtonGroup, ButtonGroupItem, buttonGroupVariants, buttonGroupItemVariants }
|
|
241
|
+
export type {
|
|
242
|
+
ButtonGroupItemProps,
|
|
243
|
+
ButtonGroupMode,
|
|
244
|
+
ButtonGroupProps,
|
|
245
|
+
ButtonGroupSize,
|
|
246
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"group/button inline-flex min-w-0 items-center justify-center whitespace-nowrap rounded-[var(--bh-control-default)] text-[length:var(--bh-text-button-font-size)] font-[var(--bh-text-button-font-weight)] leading-[var(--bh-text-button-line-height)] tracking-[var(--bh-text-button-letter-spacing)] outline-none transition-[background-color,border-color,color,box-shadow] focus-visible:shadow-[var(--shadow-button-focus)] disabled:pointer-events-none disabled:shadow-none aria-invalid:border aria-invalid:border-destructive aria-invalid:shadow-[var(--shadow-button-danger-focus)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-[var(--bh-button-icon-size)] [&_svg[data-icon='inline-start']]:ms-[var(--bh-button-icon-offset)] [&_svg[data-icon='inline-end']]:me-[var(--bh-button-icon-offset)] rtl:[&_svg[data-rtl-flip='true']]:-scale-x-100",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground shadow-[var(--shadow-button-raised)] hover:bg-[var(--primary-hover)] active:bg-[var(--primary-pressed)] disabled:bg-[var(--bh-interactive-brand-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
14
|
+
danger:
|
|
15
|
+
"bg-destructive text-destructive-foreground shadow-[var(--shadow-button-raised)] hover:bg-[var(--destructive-hover)] active:bg-[var(--destructive-pressed)] focus-visible:shadow-[var(--shadow-button-danger-focus)] disabled:bg-[var(--bh-interactive-danger-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
16
|
+
destructive:
|
|
17
|
+
"bg-destructive text-destructive-foreground shadow-[var(--shadow-button-raised)] hover:bg-[var(--destructive-hover)] active:bg-[var(--destructive-pressed)] focus-visible:shadow-[var(--shadow-button-danger-focus)] disabled:bg-[var(--bh-interactive-danger-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
18
|
+
success:
|
|
19
|
+
"bg-success text-success-foreground shadow-[var(--shadow-button-raised)] hover:bg-[var(--success-hover)] active:bg-[var(--success-pressed)] disabled:bg-[var(--bh-interactive-brand-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
20
|
+
warning:
|
|
21
|
+
"bg-warning text-warning-foreground shadow-[var(--shadow-button-raised)] hover:bg-[var(--warning-hover)] active:bg-[var(--warning-pressed)] disabled:bg-[var(--bh-interactive-brand-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
22
|
+
secondary:
|
|
23
|
+
"bg-secondary text-secondary-foreground shadow-[var(--shadow-button-secondary)] [--bh-button-secondary-border:var(--bh-border-default)] hover:bg-[var(--secondary-hover)] active:bg-[var(--secondary-pressed)] focus-visible:[--bh-button-secondary-focus-border:var(--bh-border-brand-strong)] focus-visible:shadow-[var(--shadow-button-secondary-focus)] disabled:border disabled:border-[var(--bh-border-disabled)] disabled:bg-[var(--bh-interactive-secondary-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
24
|
+
soft:
|
|
25
|
+
"border border-transparent bg-[var(--soft)] text-foreground shadow-[var(--shadow-button-soft)] hover:bg-[var(--soft-hover)] active:bg-[var(--soft-pressed)] focus-visible:border-[var(--bh-border-brand-strong)] disabled:bg-[var(--bh-interactive-soft-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
26
|
+
outline:
|
|
27
|
+
"border border-[var(--bh-border-default)] bg-[var(--outline)] text-foreground hover:bg-[var(--outline-hover)] active:bg-[var(--outline-pressed)] focus-visible:border-[var(--bh-border-brand-strong)] disabled:border-[var(--bh-border-disabled)] disabled:bg-[var(--bh-interactive-outlined-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
28
|
+
ghost:
|
|
29
|
+
"border border-transparent bg-[var(--ghost)] text-foreground hover:bg-[var(--ghost-hover)] active:bg-[var(--ghost-pressed)] focus-visible:border-[var(--bh-border-brand-strong)] disabled:bg-[var(--bh-interactive-ghost-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
30
|
+
"ghost-primary":
|
|
31
|
+
"border border-transparent bg-[var(--ghost)] text-[var(--bh-content-brand-default)] hover:bg-[var(--ghost-hover)] active:bg-[var(--ghost-pressed)] focus-visible:border-[var(--bh-border-brand-strong)] disabled:bg-[var(--bh-interactive-ghost-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
32
|
+
white:
|
|
33
|
+
"border border-transparent bg-[var(--bh-bg-always-white)] text-[var(--bh-content-on-light)] focus-visible:border-[var(--bh-border-focus)] disabled:opacity-[var(--bh-opacity-30)]",
|
|
34
|
+
"soft-danger":
|
|
35
|
+
"border border-transparent bg-[var(--destructive-soft)] text-[var(--destructive-soft-foreground)] hover:bg-[var(--destructive-soft-hover)] active:bg-[var(--destructive-soft-pressed)] focus-visible:border-[var(--destructive)] focus-visible:shadow-[var(--shadow-button-danger-focus)] disabled:bg-[var(--bh-interactive-danger-soft-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
36
|
+
"soft-destructive":
|
|
37
|
+
"border border-transparent bg-[var(--destructive-soft)] text-[var(--destructive-soft-foreground)] hover:bg-[var(--destructive-soft-hover)] active:bg-[var(--destructive-soft-pressed)] focus-visible:border-[var(--destructive)] focus-visible:shadow-[var(--shadow-button-danger-focus)] disabled:bg-[var(--bh-interactive-danger-soft-disabled)] disabled:text-[var(--bh-content-disabled)]",
|
|
38
|
+
link: "bg-[var(--ghost)] text-[var(--bh-content-brand-default)] hover:bg-[var(--ghost-hover)] active:bg-[var(--ghost-pressed)] focus-visible:border-[var(--bh-border-brand-strong)] disabled:text-[var(--bh-content-disabled)]",
|
|
39
|
+
},
|
|
40
|
+
size: {
|
|
41
|
+
xs: "h-[var(--bh-button-xs-height)] gap-[var(--bh-button-gap-xs)] px-[var(--bh-button-xs-padding-x)] py-[var(--bh-button-sm-padding-y)] has-[>svg]:px-[var(--bh-button-xs-padding-x)]",
|
|
42
|
+
sm: "h-[var(--bh-button-sm-height)] gap-[var(--bh-button-gap)] px-[var(--bh-button-sm-padding-x)] py-[var(--bh-button-sm-padding-y)] has-[>svg]:px-[var(--bh-button-sm-padding-x)]",
|
|
43
|
+
default: "h-[var(--bh-button-md-height)] gap-[var(--bh-button-gap)] px-[var(--bh-button-md-padding-x)] py-[var(--bh-button-sm-padding-y)] has-[>svg]:px-[var(--bh-button-md-padding-x)]",
|
|
44
|
+
lg: "h-[var(--bh-button-lg-height)] gap-[var(--bh-button-gap)] px-[var(--bh-button-lg-padding-x)] py-[var(--bh-button-lg-padding-y)] has-[>svg]:px-[var(--bh-button-lg-padding-x)]",
|
|
45
|
+
xl: "h-[var(--bh-button-xl-height)] gap-[var(--bh-button-gap)] px-[var(--bh-button-lg-padding-x)] py-[var(--bh-button-xl-padding-y)] has-[>svg]:px-[var(--bh-button-lg-padding-x)]",
|
|
46
|
+
"icon-xs": "size-[var(--bh-button-xs-height)] gap-[var(--bh-space-none)] p-[var(--bh-space-none)]",
|
|
47
|
+
"icon-sm": "size-[var(--bh-button-sm-height)] gap-[var(--bh-space-none)] p-[var(--bh-space-none)]",
|
|
48
|
+
icon: "size-[var(--bh-button-md-height)] gap-[var(--bh-space-none)] p-[var(--bh-space-none)]",
|
|
49
|
+
"icon-lg": "size-[var(--bh-button-lg-height)] gap-[var(--bh-space-none)] p-[var(--bh-space-none)]",
|
|
50
|
+
"icon-xl": "size-[var(--bh-button-xl-height)] gap-[var(--bh-space-none)] p-[var(--bh-space-none)]",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
variant: "default",
|
|
55
|
+
size: "default",
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
type ButtonProps = React.ComponentProps<"button"> &
|
|
61
|
+
VariantProps<typeof buttonVariants> & {
|
|
62
|
+
asChild?: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button({
|
|
66
|
+
className,
|
|
67
|
+
variant,
|
|
68
|
+
size,
|
|
69
|
+
asChild = false,
|
|
70
|
+
children,
|
|
71
|
+
...props
|
|
72
|
+
}, ref) {
|
|
73
|
+
const Comp = asChild ? Slot : "button"
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Comp
|
|
77
|
+
data-slot="button"
|
|
78
|
+
ref={ref}
|
|
79
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
{asChild ? children : <ButtonChildren>{children}</ButtonChildren>}
|
|
83
|
+
</Comp>
|
|
84
|
+
)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
function ButtonChildren({ children }: { children: React.ReactNode }) {
|
|
88
|
+
return React.Children.map(children, (child) => {
|
|
89
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
90
|
+
return (
|
|
91
|
+
<span data-slot="button-label" dir="auto" className="min-w-0 px-[var(--bh-button-label-padding-x)]">
|
|
92
|
+
{child}
|
|
93
|
+
</span>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return child
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { Button, buttonVariants }
|
|
102
|
+
export type { ButtonProps }
|