raft-ui 0.0.5 → 0.0.7
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/CHANGELOG.md +5 -0
- package/dist/button-CJqMhTPQ.mjs +621 -0
- package/dist/index-CpGciYPW.d.mts +267 -0
- package/dist/index.d.mts +11 -253
- package/dist/index.mjs +32 -587
- package/{src → dist}/styles.css +0 -2
- package/dist/wip.d.mts +133 -15
- package/dist/wip.mjs +289 -16
- package/package.json +7 -10
- package/dist/styled-props-B3SNekJg.d.mts +0 -16
- package/dist/use-theme-Y_h1DKll.mjs +0 -34
- package/src/components/avatar/avatar.tsx +0 -375
- package/src/components/avatar/index.ts +0 -17
- package/src/components/badge/badge.tsx +0 -393
- package/src/components/badge/index.ts +0 -2
- package/src/components/banner/banner.tsx +0 -269
- package/src/components/banner/index.ts +0 -8
- package/src/components/bottom-sheet/bottom-sheet.tsx +0 -152
- package/src/components/bottom-sheet/index.ts +0 -22
- package/src/components/button/button.tsx +0 -497
- package/src/components/button/index.ts +0 -2
- package/src/components/checkbox/checkbox-indicator.tsx +0 -128
- package/src/components/checkbox/checkbox.tsx +0 -350
- package/src/components/checkbox/index.ts +0 -2
- package/src/components/combobox/combobox.tsx +0 -603
- package/src/components/combobox/index.ts +0 -52
- package/src/components/context-menu/context-menu.tsx +0 -380
- package/src/components/context-menu/index.ts +0 -34
- package/src/components/conversation-preview-card/conversation-preview-card.tsx +0 -336
- package/src/components/conversation-preview-card/index.ts +0 -32
- package/src/components/description-list/description-list.tsx +0 -116
- package/src/components/description-list/index.ts +0 -14
- package/src/components/dropdown-menu/dropdown-menu.tsx +0 -405
- package/src/components/dropdown-menu/index.ts +0 -38
- package/src/components/empty-state/empty-state.tsx +0 -177
- package/src/components/empty-state/index.ts +0 -16
- package/src/components/field/field.tsx +0 -125
- package/src/components/field/index.ts +0 -18
- package/src/components/inline-code/index.ts +0 -2
- package/src/components/inline-code/inline-code.tsx +0 -35
- package/src/components/input/index.ts +0 -2
- package/src/components/input/input.tsx +0 -76
- package/src/components/input-group/index.ts +0 -7
- package/src/components/input-group/input-group.tsx +0 -215
- package/src/components/kbd/index.ts +0 -2
- package/src/components/kbd/kbd.tsx +0 -43
- package/src/components/label/index.ts +0 -7
- package/src/components/label/label.tsx +0 -99
- package/src/components/lightbox/index.ts +0 -24
- package/src/components/lightbox/lightbox.tsx +0 -245
- package/src/components/list-item/index.ts +0 -20
- package/src/components/list-item/list-item.tsx +0 -263
- package/src/components/media-list-item/index.ts +0 -20
- package/src/components/media-list-item/media-list-item.tsx +0 -169
- package/src/components/notification-center/index.ts +0 -39
- package/src/components/notification-center/notification-center.tsx +0 -558
- package/src/components/panel-header/index.ts +0 -22
- package/src/components/panel-header/panel-header.tsx +0 -199
- package/src/components/popover/index.ts +0 -30
- package/src/components/popover/popover.tsx +0 -248
- package/src/components/preview-shell/index.ts +0 -2
- package/src/components/preview-shell/preview-shell.tsx +0 -51
- package/src/components/quoted-message-card/index.ts +0 -36
- package/src/components/quoted-message-card/quoted-message-card.tsx +0 -391
- package/src/components/radio-group/index.ts +0 -6
- package/src/components/radio-group/radio-group.tsx +0 -119
- package/src/components/section-header/index.ts +0 -16
- package/src/components/section-header/section-header.tsx +0 -117
- package/src/components/section-label/index.ts +0 -2
- package/src/components/section-label/section-label.tsx +0 -38
- package/src/components/segmented-control/index.ts +0 -12
- package/src/components/segmented-control/segmented-control.tsx +0 -129
- package/src/components/select/index.ts +0 -40
- package/src/components/select/select.tsx +0 -382
- package/src/components/spinner/index.ts +0 -2
- package/src/components/spinner/spinner.tsx +0 -228
- package/src/components/status/index.ts +0 -2
- package/src/components/status/status.tsx +0 -152
- package/src/components/tabs/index.ts +0 -24
- package/src/components/tabs/tabs.tsx +0 -451
- package/src/components/text/index.ts +0 -2
- package/src/components/text/text.tsx +0 -131
- package/src/components/textarea/index.ts +0 -2
- package/src/components/textarea/textarea.tsx +0 -136
- package/src/components/toggle-group/index.ts +0 -12
- package/src/components/toggle-group/toggle-group.tsx +0 -111
- package/src/components/tooltip/index.ts +0 -14
- package/src/components/tooltip/tooltip.tsx +0 -212
- package/src/index.ts +0 -426
- package/src/legacy/AttentionDot.tsx +0 -28
- package/src/legacy/AvatarListRow.tsx +0 -87
- package/src/legacy/AvatarSlot.tsx +0 -157
- package/src/legacy/Badge.tsx +0 -95
- package/src/legacy/Banner.tsx +0 -74
- package/src/legacy/BottomSheet.tsx +0 -76
- package/src/legacy/CheckMarker.tsx +0 -72
- package/src/legacy/Checkbox.tsx +0 -81
- package/src/legacy/ConversationPreviewCard.tsx +0 -169
- package/src/legacy/DismissBackdrop.tsx +0 -68
- package/src/legacy/EmptyState.tsx +0 -63
- package/src/legacy/ExperimentalBadge.tsx +0 -19
- package/src/legacy/FormField.tsx +0 -106
- package/src/legacy/KeyValueRow.tsx +0 -67
- package/src/legacy/Lightbox.tsx +0 -119
- package/src/legacy/NotificationCenter.tsx +0 -217
- package/src/legacy/PanelHeader.tsx +0 -94
- package/src/legacy/PreviewShell.tsx +0 -40
- package/src/legacy/QuotedMessageCard.tsx +0 -181
- package/src/legacy/ReorderablePanelTabs.tsx +0 -156
- package/src/legacy/SandboxedPreviewFrame.tsx +0 -59
- package/src/legacy/SearchInput.tsx +0 -23
- package/src/legacy/SectionEyebrow.tsx +0 -60
- package/src/legacy/SectionHeader.tsx +0 -68
- package/src/legacy/SegmentedControl.tsx +0 -74
- package/src/legacy/SlugInput.tsx +0 -29
- package/src/legacy/Spinner.tsx +0 -89
- package/src/legacy/StatusDot.tsx +0 -51
- package/src/legacy/SurfaceListItem.tsx +0 -32
- package/src/legacy/Textarea.tsx +0 -137
- package/src/legacy/button.tsx +0 -100
- package/src/legacy/context-menu-divider.tsx +0 -12
- package/src/legacy/menu-item.tsx +0 -66
- package/src/legacy/selection-popover.tsx +0 -212
- package/src/legacy/server-switcher-menu.tsx +0 -203
- package/src/legacy/source.css +0 -240
- package/src/lib/cn.ts +0 -1
- package/src/lib/styled-props.ts +0 -11
- package/src/lib/theme/theme-context.ts +0 -28
- package/src/lib/theme/theme-provider.tsx +0 -181
- package/src/lib/theme/use-theme.ts +0 -12
- package/src/lib/tv.ts +0 -29
- package/src/lib/without-children.ts +0 -6
- package/src/wip.ts +0 -233
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Dialog } from "@base-ui/react/dialog";
|
|
2
|
-
import { mergeProps } from "@base-ui/react/merge-props";
|
|
3
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
-
import { tv } from "../../lib/tv.ts";
|
|
5
|
-
import type { StyledProps } from "../../lib/styled-props.ts";
|
|
6
|
-
import { useThemeFamily } from "../../lib/theme/use-theme.ts";
|
|
7
|
-
|
|
8
|
-
// Mobile bottom sheet, composed from base-ui Dialog parts and slot parts
|
|
9
|
-
// (`BottomSheetTrigger`, `BottomSheetContent`, `BottomSheetHeader`,
|
|
10
|
-
// `BottomSheetFooter`, `BottomSheetTitle`, `BottomSheetDescription`,
|
|
11
|
-
// `BottomSheetClose`). Dialog owns open state, the modal scroll-lock, ESC, and
|
|
12
|
-
// native outside-press dismissal, so unlike Lightbox there's no dim layer and
|
|
13
|
-
// no manual backdrop onClick: the sheet card carries the brutal frame itself.
|
|
14
|
-
//
|
|
15
|
-
// All styled parts share one `tv()` slots config so theme styling lives in a
|
|
16
|
-
// single place, ready for the elegant family to add per-slot overrides under
|
|
17
|
-
// `theme`. Each part resolves its own slot with the active theme, so they stay
|
|
18
|
-
// independently composable. `shadow-brutal-lg` maps to the --shadow-lg token.
|
|
19
|
-
const bottomSheet = tv({
|
|
20
|
-
slots: {
|
|
21
|
-
content: [
|
|
22
|
-
"fixed inset-x-3 bottom-[max(12px,env(safe-area-inset-bottom))] z-50 mx-auto max-w-md",
|
|
23
|
-
],
|
|
24
|
-
header: ["flex flex-col gap-1 p-4"],
|
|
25
|
-
footer: ["mt-auto flex flex-col gap-2 p-4"],
|
|
26
|
-
title: ["text-base font-bold text-foreground-strong"],
|
|
27
|
-
description: ["text-sm text-foreground/60"],
|
|
28
|
-
},
|
|
29
|
-
variants: {
|
|
30
|
-
theme: {
|
|
31
|
-
brutal: { content: ["border-2 border-line-strong bg-layer-panel shadow-xl"] },
|
|
32
|
-
// Elegant styling is deferred; see the component TODO.
|
|
33
|
-
elegant: {},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export type BottomSheetProps = Dialog.Root.Props;
|
|
39
|
-
|
|
40
|
-
// Composition root: a thin pass-through over Dialog.Root that owns open state.
|
|
41
|
-
// Renders no DOM element of its own.
|
|
42
|
-
export function BottomSheet(props: BottomSheetProps) {
|
|
43
|
-
return <Dialog.Root {...props} />;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type BottomSheetTriggerProps = Dialog.Trigger.Props;
|
|
47
|
-
|
|
48
|
-
// Opens the sheet. Compose your own affordance via `render` (e.g. a Button).
|
|
49
|
-
export function BottomSheetTrigger(props: BottomSheetTriggerProps) {
|
|
50
|
-
return <Dialog.Trigger data-slot="bottom-sheet-trigger" {...props} />;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type BottomSheetPortalProps = Dialog.Portal.Props;
|
|
54
|
-
|
|
55
|
-
// Portals the sheet to the document body. BottomSheetContent wraps this for you.
|
|
56
|
-
export function BottomSheetPortal(props: BottomSheetPortalProps) {
|
|
57
|
-
return <Dialog.Portal data-slot="bottom-sheet-portal" {...props} />;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type BottomSheetContentProps = StyledProps<Dialog.Popup.Props>;
|
|
61
|
-
|
|
62
|
-
// The sheet card: portaled, anchored to the bottom safe area, centered up to
|
|
63
|
-
// `max-w-md`, carrying the brutal frame. `inset-x-3` + the safe-area bottom inset
|
|
64
|
-
// reproduce the original 12px gutter. Close affordances are composed in by the
|
|
65
|
-
// caller via `BottomSheetClose`.
|
|
66
|
-
export function BottomSheetContent({ className, ...props }: BottomSheetContentProps) {
|
|
67
|
-
const theme = useThemeFamily();
|
|
68
|
-
const { content } = bottomSheet({ theme });
|
|
69
|
-
return (
|
|
70
|
-
<BottomSheetPortal>
|
|
71
|
-
<Dialog.Popup
|
|
72
|
-
data-slot="bottom-sheet-content"
|
|
73
|
-
data-side="bottom"
|
|
74
|
-
className={content({ className })}
|
|
75
|
-
{...props}
|
|
76
|
-
/>
|
|
77
|
-
</BottomSheetPortal>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type BottomSheetCloseProps = Dialog.Close.Props;
|
|
82
|
-
|
|
83
|
-
// Closes the sheet. Compose your own affordance via `render` (e.g. a Button).
|
|
84
|
-
export function BottomSheetClose(props: BottomSheetCloseProps) {
|
|
85
|
-
return <Dialog.Close data-slot="bottom-sheet-close" {...props} />;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type BottomSheetHeaderProps = useRender.ComponentProps<"div">;
|
|
89
|
-
|
|
90
|
-
// Stacks the title + description at the top of the sheet.
|
|
91
|
-
export function BottomSheetHeader({ className, render, ...props }: BottomSheetHeaderProps) {
|
|
92
|
-
const theme = useThemeFamily();
|
|
93
|
-
const { header } = bottomSheet({ theme });
|
|
94
|
-
const defaultProps: useRender.ElementProps<"div"> = {
|
|
95
|
-
className: header({ className }),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
return useRender({
|
|
99
|
-
defaultTagName: "div",
|
|
100
|
-
render,
|
|
101
|
-
props: mergeProps<"div">(defaultProps, props),
|
|
102
|
-
state: {
|
|
103
|
-
slot: "bottom-sheet-header",
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export type BottomSheetFooterProps = useRender.ComponentProps<"div">;
|
|
109
|
-
|
|
110
|
-
// Trailing action area, pushed to the bottom of the sheet.
|
|
111
|
-
export function BottomSheetFooter({ className, render, ...props }: BottomSheetFooterProps) {
|
|
112
|
-
const theme = useThemeFamily();
|
|
113
|
-
const { footer } = bottomSheet({ theme });
|
|
114
|
-
const defaultProps: useRender.ElementProps<"div"> = {
|
|
115
|
-
className: footer({ className }),
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
return useRender({
|
|
119
|
-
defaultTagName: "div",
|
|
120
|
-
render,
|
|
121
|
-
props: mergeProps<"div">(defaultProps, props),
|
|
122
|
-
state: {
|
|
123
|
-
slot: "bottom-sheet-footer",
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export type BottomSheetTitleProps = StyledProps<Dialog.Title.Props>;
|
|
129
|
-
|
|
130
|
-
// Accessible heading for the sheet (labels the dialog for screen readers).
|
|
131
|
-
export function BottomSheetTitle({ className, ...props }: BottomSheetTitleProps) {
|
|
132
|
-
const theme = useThemeFamily();
|
|
133
|
-
const { title } = bottomSheet({ theme });
|
|
134
|
-
return (
|
|
135
|
-
<Dialog.Title data-slot="bottom-sheet-title" className={title({ className })} {...props} />
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export type BottomSheetDescriptionProps = StyledProps<Dialog.Description.Props>;
|
|
140
|
-
|
|
141
|
-
// Secondary supporting copy under the title; also the dialog's a11y description.
|
|
142
|
-
export function BottomSheetDescription({ className, ...props }: BottomSheetDescriptionProps) {
|
|
143
|
-
const theme = useThemeFamily();
|
|
144
|
-
const { description } = bottomSheet({ theme });
|
|
145
|
-
return (
|
|
146
|
-
<Dialog.Description
|
|
147
|
-
data-slot="bottom-sheet-description"
|
|
148
|
-
className={description({ className })}
|
|
149
|
-
{...props}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
BottomSheet,
|
|
3
|
-
BottomSheetTrigger,
|
|
4
|
-
BottomSheetPortal,
|
|
5
|
-
BottomSheetContent,
|
|
6
|
-
BottomSheetClose,
|
|
7
|
-
BottomSheetHeader,
|
|
8
|
-
BottomSheetFooter,
|
|
9
|
-
BottomSheetTitle,
|
|
10
|
-
BottomSheetDescription,
|
|
11
|
-
} from "./bottom-sheet.tsx";
|
|
12
|
-
export type {
|
|
13
|
-
BottomSheetProps,
|
|
14
|
-
BottomSheetTriggerProps,
|
|
15
|
-
BottomSheetPortalProps,
|
|
16
|
-
BottomSheetContentProps,
|
|
17
|
-
BottomSheetCloseProps,
|
|
18
|
-
BottomSheetHeaderProps,
|
|
19
|
-
BottomSheetFooterProps,
|
|
20
|
-
BottomSheetTitleProps,
|
|
21
|
-
BottomSheetDescriptionProps,
|
|
22
|
-
} from "./bottom-sheet.tsx";
|
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
import { Button as BaseButton } from "@base-ui/react/button";
|
|
2
|
-
import type { ReactElement } from "react";
|
|
3
|
-
import { tv, type VariantProps } from "../../lib/tv.ts";
|
|
4
|
-
import type { StyledProps } from "../../lib/styled-props.ts";
|
|
5
|
-
import { useThemeFamily } from "../../lib/theme/use-theme.ts";
|
|
6
|
-
import { Spinner } from "../spinner/index.ts";
|
|
7
|
-
|
|
8
|
-
export const buttonVariants = tv({
|
|
9
|
-
slots: {
|
|
10
|
-
root: [
|
|
11
|
-
"relative inline-flex shrink-0 items-center justify-center",
|
|
12
|
-
"font-heading leading-none whitespace-nowrap select-none",
|
|
13
|
-
"border-line rounded-none",
|
|
14
|
-
"shadow-sm transition-all duration-100",
|
|
15
|
-
"outline outline-[1px] outline-offset-2 outline-transparent",
|
|
16
|
-
"data-[loading=true]:cursor-wait",
|
|
17
|
-
"disabled:pointer-events-none disabled:opacity-40 data-[loading=true]:opacity-100",
|
|
18
|
-
"disabled:transform-none",
|
|
19
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
20
|
-
],
|
|
21
|
-
content:
|
|
22
|
-
"relative z-10 inline-flex items-center justify-center gap-[inherit] data-[loading=true]:invisible",
|
|
23
|
-
loadingIndicator: "pointer-events-none absolute inset-0 z-10 flex items-center justify-center",
|
|
24
|
-
},
|
|
25
|
-
variants: {
|
|
26
|
-
theme: {
|
|
27
|
-
brutal: {
|
|
28
|
-
root: ["border-2 font-bold focus-visible:outline-transparent"],
|
|
29
|
-
},
|
|
30
|
-
elegant: {
|
|
31
|
-
root: [
|
|
32
|
-
"overflow-clip border-0 font-sans font-medium antialiased",
|
|
33
|
-
"focus-visible:outline-[var(--button-focus-outline,transparent)]",
|
|
34
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.05),0_0_0_1px_var(--line-subtle)]",
|
|
35
|
-
"before:pointer-events-none before:absolute before:inset-0 before:z-0 before:rounded-[inherit]",
|
|
36
|
-
"active:not-aria-[haspopup]:scale-[0.985]",
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
variant: {
|
|
41
|
-
primary: {
|
|
42
|
-
root: ["border-line-strong bg-primary-400 text-primary-950", "hover:bg-primary-500"],
|
|
43
|
-
},
|
|
44
|
-
default: {
|
|
45
|
-
root: ["border-line-strong bg-layer-panel text-foreground-strong", "hover:bg-layer-panel"],
|
|
46
|
-
},
|
|
47
|
-
information: {
|
|
48
|
-
root: ["border-line-strong bg-info-base text-foreground-inverse", "hover:bg-info-base"],
|
|
49
|
-
},
|
|
50
|
-
muted: {
|
|
51
|
-
root: [
|
|
52
|
-
"border-line-strong bg-secondary-400 text-secondary-950",
|
|
53
|
-
"hover:border-line-strong hover:bg-secondary-400",
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
accent: {
|
|
57
|
-
root: ["border-line-strong bg-accent-400 text-accent-950", "hover:bg-accent-500"],
|
|
58
|
-
},
|
|
59
|
-
warning: {
|
|
60
|
-
root: [
|
|
61
|
-
"border-line-strong bg-warning-base text-foreground-inverse",
|
|
62
|
-
"hover:bg-warning-base",
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
outline: {
|
|
66
|
-
root: [
|
|
67
|
-
"border-line-strong bg-transparent text-foreground-strong",
|
|
68
|
-
"hover:bg-layer-muted",
|
|
69
|
-
"shadow-none",
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
ghost: {
|
|
73
|
-
root: [
|
|
74
|
-
"border-transparent bg-transparent text-foreground shadow-none",
|
|
75
|
-
"hover:border-line-strong hover:bg-layer-muted",
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
link: {
|
|
79
|
-
root: [
|
|
80
|
-
"border-transparent bg-transparent text-foreground-strong shadow-none underline-offset-4",
|
|
81
|
-
"hover:underline",
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
"danger-secondary": {
|
|
85
|
-
root: ["border-line-strong bg-danger-lighter text-danger-base", "hover:bg-danger-lighter"],
|
|
86
|
-
},
|
|
87
|
-
danger: {
|
|
88
|
-
root: [
|
|
89
|
-
"border-line-strong bg-danger-base text-foreground-inverse",
|
|
90
|
-
"hover:border-[oklch(0.595_0.241_26.758)] hover:bg-[oklch(0.595_0.241_26.758)]",
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
"danger-outline": {
|
|
94
|
-
root: [
|
|
95
|
-
"border-line-strong bg-transparent text-danger-base",
|
|
96
|
-
"hover:bg-layer-muted",
|
|
97
|
-
"shadow-none",
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
size: {
|
|
102
|
-
xs: {
|
|
103
|
-
root: [
|
|
104
|
-
"gap-1 px-2 py-[5px] text-[11px]",
|
|
105
|
-
"has-data-[icon=inline-start]:pl-1.5 has-data-[icon=inline-end]:pr-1.5",
|
|
106
|
-
"[&_svg:not([class*='size-'])]:size-3",
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
sm: {
|
|
110
|
-
root: [
|
|
111
|
-
"gap-1.5 px-2.5 py-[6px] text-xs",
|
|
112
|
-
"has-data-[icon=inline-start]:pl-2 has-data-[icon=inline-end]:pr-2",
|
|
113
|
-
"[&_svg:not([class*='size-'])]:size-3.5",
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
md: {
|
|
117
|
-
root: [
|
|
118
|
-
"gap-2 px-3 py-2 text-sm",
|
|
119
|
-
"has-data-[icon=inline-start]:pl-2.5 has-data-[icon=inline-end]:pr-2.5",
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
lg: {
|
|
123
|
-
root: [
|
|
124
|
-
"gap-2 px-3.5 py-2.5 text-base",
|
|
125
|
-
"has-data-[icon=inline-start]:pl-3 has-data-[icon=inline-end]:pr-3",
|
|
126
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
127
|
-
],
|
|
128
|
-
},
|
|
129
|
-
"icon-xs": { root: ["p-[5px] text-[11px]", "[&_svg:not([class*='size-'])]:size-3"] },
|
|
130
|
-
"icon-sm": { root: ["p-[6px] text-xs", "[&_svg:not([class*='size-'])]:size-3.5"] },
|
|
131
|
-
"icon-md": { root: ["p-2 text-sm", "[&_svg:not([class*='size-'])]:size-4"] },
|
|
132
|
-
"icon-lg": { root: ["p-3 text-sm", "[&_svg:not([class*='size-'])]:size-4"] },
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
defaultVariants: {
|
|
136
|
-
variant: "default",
|
|
137
|
-
size: "md",
|
|
138
|
-
},
|
|
139
|
-
compoundVariants: [
|
|
140
|
-
{
|
|
141
|
-
theme: "elegant",
|
|
142
|
-
size: ["xs", "icon-xs"],
|
|
143
|
-
class: { root: "rounded-sm" },
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
theme: "elegant",
|
|
147
|
-
size: ["sm", "icon-sm"],
|
|
148
|
-
class: { root: "rounded" },
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
theme: "elegant",
|
|
152
|
-
size: ["md", "icon-md"],
|
|
153
|
-
class: { root: "rounded-md" },
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
theme: "elegant",
|
|
157
|
-
size: ["lg", "icon-lg"],
|
|
158
|
-
class: { root: "rounded-md" },
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
theme: "brutal",
|
|
162
|
-
variant: "primary",
|
|
163
|
-
class: { root: "bg-brutal-yellow text-black hover:bg-brutal-yellow" },
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
theme: "brutal",
|
|
167
|
-
variant: "default",
|
|
168
|
-
class: { root: "bg-white text-black hover:bg-white" },
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
theme: "brutal",
|
|
172
|
-
variant: "outline",
|
|
173
|
-
class: { root: "bg-white text-black shadow-sm hover:bg-white" },
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
theme: "brutal",
|
|
177
|
-
variant: "information",
|
|
178
|
-
class: { root: "bg-brutal-cyan text-black hover:bg-brutal-cyan" },
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
theme: "brutal",
|
|
182
|
-
variant: "muted",
|
|
183
|
-
class: { root: "bg-brutal-stone text-black hover:bg-brutal-stone" },
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
theme: "brutal",
|
|
187
|
-
variant: "accent",
|
|
188
|
-
class: { root: "bg-brutal-pink text-black hover:bg-brutal-pink" },
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
theme: "brutal",
|
|
192
|
-
variant: "danger",
|
|
193
|
-
class: { root: "bg-brutal-red text-black hover:bg-brutal-red" },
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
theme: "brutal",
|
|
197
|
-
variant: "warning",
|
|
198
|
-
class: { root: "bg-warning-base text-black hover:bg-warning-base" },
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
theme: "brutal",
|
|
202
|
-
size: "xs",
|
|
203
|
-
class: { root: "h-6 px-2 py-0 text-[11px]" },
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
theme: "brutal",
|
|
207
|
-
size: "sm",
|
|
208
|
-
class: { root: "h-7 px-2.5 py-0 text-xs" },
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
theme: "brutal",
|
|
212
|
-
size: "md",
|
|
213
|
-
class: { root: "h-8 px-3 py-0 text-sm" },
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
theme: "brutal",
|
|
217
|
-
size: "lg",
|
|
218
|
-
class: { root: "h-10 px-4 py-0 text-sm" },
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
theme: "brutal",
|
|
222
|
-
size: "icon-xs",
|
|
223
|
-
class: { root: "size-6 p-0 text-[11px]" },
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
theme: "brutal",
|
|
227
|
-
size: "icon-sm",
|
|
228
|
-
class: { root: "size-7 p-0 text-xs" },
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
theme: "brutal",
|
|
232
|
-
size: "icon-md",
|
|
233
|
-
class: { root: "size-8 p-0 text-sm" },
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
theme: "brutal",
|
|
237
|
-
size: "icon-lg",
|
|
238
|
-
class: { root: "size-10 p-0 text-sm" },
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
theme: "elegant",
|
|
242
|
-
variant: "default",
|
|
243
|
-
class: {
|
|
244
|
-
root: [
|
|
245
|
-
"bg-foreground-strong text-foreground-inverse",
|
|
246
|
-
"[--button-focus-outline:var(--foreground-strong)]",
|
|
247
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.12),0_0_0_1px_var(--foreground-strong)]",
|
|
248
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_8%)_0%,oklab(0%_0_0_/_0%)_100%)]",
|
|
249
|
-
"hover:bg-[oklch(0.31_0.006_285)]",
|
|
250
|
-
],
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
theme: "elegant",
|
|
255
|
-
variant: "primary",
|
|
256
|
-
class: {
|
|
257
|
-
root: [
|
|
258
|
-
"bg-primary-400 text-primary-950",
|
|
259
|
-
"[--button-focus-outline:var(--primary-400)]",
|
|
260
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.15),0_0_0_1px_oklch(0.83_0.14_91.89_/_0.83)]",
|
|
261
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_11%)_0%,oklab(100%_0_0_/_0%)_0%,oklab(0%_0_0_/_0%)_100%)]",
|
|
262
|
-
"hover:bg-[oklch(0.86_0.15_91.89)]",
|
|
263
|
-
],
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
theme: "elegant",
|
|
268
|
-
variant: "outline",
|
|
269
|
-
class: {
|
|
270
|
-
root: [
|
|
271
|
-
"bg-layer-panel text-foreground-strong",
|
|
272
|
-
"[--button-focus-outline:var(--layer-panel)]",
|
|
273
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.05),0_0_0_1px_var(--line-subtle)]",
|
|
274
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(0%_0_0_/_0%)_30%,oklab(0%_0_0_/_1%)_100%)]",
|
|
275
|
-
"hover:bg-layer-muted",
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
theme: "elegant",
|
|
281
|
-
variant: "ghost",
|
|
282
|
-
class: {
|
|
283
|
-
root: [
|
|
284
|
-
"bg-transparent text-foreground-muted shadow-none",
|
|
285
|
-
"[--button-focus-outline:var(--line-muted)]",
|
|
286
|
-
"before:bg-transparent hover:bg-line-muted",
|
|
287
|
-
],
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
theme: "elegant",
|
|
292
|
-
variant: "danger-secondary",
|
|
293
|
-
class: {
|
|
294
|
-
root: [
|
|
295
|
-
"bg-danger-lighter text-danger-base",
|
|
296
|
-
"[--button-focus-outline:var(--state-danger-lighter)]",
|
|
297
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.18),0_0_0_1px_var(--state-danger-light)]",
|
|
298
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_9%)_0%,oklab(0%_0_0_/_1%)_100%)]",
|
|
299
|
-
"hover:bg-danger-light",
|
|
300
|
-
],
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
theme: "elegant",
|
|
305
|
-
variant: "danger",
|
|
306
|
-
class: {
|
|
307
|
-
root: [
|
|
308
|
-
"bg-danger-base text-foreground-inverse",
|
|
309
|
-
"[--button-focus-outline:var(--state-danger-base)]",
|
|
310
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.12),0_0_0_1px_var(--state-danger-base)]",
|
|
311
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_10%)_0%,oklab(0%_0_0_/_0%)_100%)]",
|
|
312
|
-
"hover:bg-[oklch(0.56_0.23_26.758)]",
|
|
313
|
-
],
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
theme: "brutal",
|
|
318
|
-
variant: "danger",
|
|
319
|
-
class: {
|
|
320
|
-
root: [
|
|
321
|
-
"border-line-strong bg-brutal-red text-black",
|
|
322
|
-
"shadow-sm",
|
|
323
|
-
"hover:border-line-strong hover:bg-brutal-red",
|
|
324
|
-
"hover:-translate-y-px hover:shadow-md",
|
|
325
|
-
"active:not-aria-[haspopup]:translate-x-px active:not-aria-[haspopup]:translate-y-px",
|
|
326
|
-
"active:shadow-xs",
|
|
327
|
-
],
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
theme: "brutal",
|
|
332
|
-
variant: "danger-secondary",
|
|
333
|
-
class: {
|
|
334
|
-
root: [
|
|
335
|
-
"border-line-strong bg-danger-lighter text-[color-mix(in_oklab,var(--state-danger-base)_72%,transparent)]",
|
|
336
|
-
"shadow-sm",
|
|
337
|
-
"hover:border-line-strong hover:bg-danger-lighter",
|
|
338
|
-
"hover:-translate-y-px hover:shadow-md",
|
|
339
|
-
"active:not-aria-[haspopup]:translate-x-px active:not-aria-[haspopup]:translate-y-px",
|
|
340
|
-
"active:shadow-xs",
|
|
341
|
-
],
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
theme: "elegant",
|
|
346
|
-
variant: "danger-outline",
|
|
347
|
-
class: {
|
|
348
|
-
root: [
|
|
349
|
-
"bg-layer-panel text-danger-base",
|
|
350
|
-
"[--button-focus-outline:var(--layer-panel)]",
|
|
351
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.05),0_0_0_1px_var(--state-danger-light)]",
|
|
352
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(0%_0_0_/_0%)_30%,oklab(0%_0_0_/_1%)_100%)]",
|
|
353
|
-
"hover:bg-danger-lighter",
|
|
354
|
-
],
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
theme: "elegant",
|
|
359
|
-
variant: "accent",
|
|
360
|
-
class: {
|
|
361
|
-
root: [
|
|
362
|
-
"bg-accent-400 text-white",
|
|
363
|
-
"[--button-focus-outline:var(--accent-400)]",
|
|
364
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.12),0_0_0_1px_var(--accent-400)]",
|
|
365
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_8%)_0%,oklab(0%_0_0_/_0%)_100%)]",
|
|
366
|
-
"hover:bg-[oklch(0.72_0.15_0.71)]",
|
|
367
|
-
],
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
theme: "elegant",
|
|
372
|
-
variant: "warning",
|
|
373
|
-
class: {
|
|
374
|
-
root: [
|
|
375
|
-
"bg-warning-base text-foreground-inverse",
|
|
376
|
-
"[--button-focus-outline:var(--state-warning-base)]",
|
|
377
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.14),0_0_0_1px_var(--state-warning-base)]",
|
|
378
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_10%)_0%,oklab(0%_0_0_/_0%)_100%)]",
|
|
379
|
-
"hover:bg-[oklch(0.65_0.19_44.441)]",
|
|
380
|
-
],
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
theme: "elegant",
|
|
385
|
-
variant: "link",
|
|
386
|
-
class: {
|
|
387
|
-
root: [
|
|
388
|
-
"bg-transparent text-foreground-muted shadow-none",
|
|
389
|
-
"[--button-focus-outline:transparent]",
|
|
390
|
-
"before:bg-transparent hover:bg-transparent hover:text-foreground-muted",
|
|
391
|
-
],
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
theme: "elegant",
|
|
396
|
-
variant: "information",
|
|
397
|
-
class: {
|
|
398
|
-
root: [
|
|
399
|
-
"bg-info-base text-foreground-inverse",
|
|
400
|
-
"[--button-focus-outline:var(--state-info-base)]",
|
|
401
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.12),0_0_0_1px_var(--state-info-base)]",
|
|
402
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_8%)_0%,oklab(0%_0_0_/_0%)_100%)]",
|
|
403
|
-
"hover:bg-[oklch(0.74_0.13_219.2)]",
|
|
404
|
-
],
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
theme: "elegant",
|
|
409
|
-
variant: "muted",
|
|
410
|
-
class: {
|
|
411
|
-
root: [
|
|
412
|
-
"bg-layer-muted text-foreground-placeholder",
|
|
413
|
-
"[--button-focus-outline:var(--layer-muted)]",
|
|
414
|
-
"shadow-[inset_0_1px_0.5px_oklch(1_0_0_/_0.05),0_0_0_1px_var(--line-subtle)]",
|
|
415
|
-
"before:bg-[linear-gradient(in_oklab_180deg,oklab(100%_0_0_/_5%)_0%,oklab(0%_0_0_/_1%)_100%)]",
|
|
416
|
-
"hover:bg-line-subtle",
|
|
417
|
-
],
|
|
418
|
-
},
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
theme: "brutal",
|
|
422
|
-
variant: ["primary", "default", "information", "muted", "accent", "warning", "outline"],
|
|
423
|
-
class: {
|
|
424
|
-
root: [
|
|
425
|
-
"hover:-translate-y-px hover:shadow-md",
|
|
426
|
-
"active:not-aria-[haspopup]:translate-x-px active:not-aria-[haspopup]:translate-y-px",
|
|
427
|
-
"active:shadow-xs",
|
|
428
|
-
],
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
],
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
export type ButtonProps = StyledProps<BaseButton.Props> &
|
|
435
|
-
Omit<VariantProps<typeof buttonVariants>, "theme"> & {
|
|
436
|
-
loading?: boolean;
|
|
437
|
-
loadingLabel?: string;
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
function defaultNativeButton(render: BaseButton.Props["render"]): boolean | undefined {
|
|
441
|
-
if (!render || typeof render !== "object" || !("type" in render)) {
|
|
442
|
-
return undefined;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const element = render as ReactElement;
|
|
446
|
-
if (typeof element.type === "string") {
|
|
447
|
-
return element.type === "button";
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
return undefined;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
export function Button({
|
|
454
|
-
variant,
|
|
455
|
-
size,
|
|
456
|
-
loading = false,
|
|
457
|
-
loadingLabel = "Loading",
|
|
458
|
-
disabled,
|
|
459
|
-
className,
|
|
460
|
-
children,
|
|
461
|
-
render,
|
|
462
|
-
nativeButton,
|
|
463
|
-
...props
|
|
464
|
-
}: ButtonProps) {
|
|
465
|
-
const theme = useThemeFamily();
|
|
466
|
-
const { root, content, loadingIndicator } = buttonVariants({
|
|
467
|
-
theme,
|
|
468
|
-
variant,
|
|
469
|
-
size,
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
return (
|
|
473
|
-
<BaseButton
|
|
474
|
-
{...props}
|
|
475
|
-
render={render}
|
|
476
|
-
nativeButton={nativeButton ?? defaultNativeButton(render)}
|
|
477
|
-
data-slot="button"
|
|
478
|
-
className={root({ className })}
|
|
479
|
-
data-loading={loading ? "true" : undefined}
|
|
480
|
-
disabled={disabled || loading}
|
|
481
|
-
aria-disabled={loading || undefined}
|
|
482
|
-
>
|
|
483
|
-
{loading ? (
|
|
484
|
-
<span data-slot="button-loading-indicator" className={loadingIndicator()}>
|
|
485
|
-
<Spinner aria-label={loadingLabel} />
|
|
486
|
-
</span>
|
|
487
|
-
) : null}
|
|
488
|
-
<span
|
|
489
|
-
data-slot="button-content"
|
|
490
|
-
data-loading={loading ? "true" : undefined}
|
|
491
|
-
className={content()}
|
|
492
|
-
>
|
|
493
|
-
{children}
|
|
494
|
-
</span>
|
|
495
|
-
</BaseButton>
|
|
496
|
-
);
|
|
497
|
-
}
|