panelui-web 0.8.0 → 0.9.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.
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ButtonGroup — related actions joined into one control.
|
|
3
|
+
*
|
|
4
|
+
* ```tsx
|
|
5
|
+
* <ButtonGroup aria-label="History">
|
|
6
|
+
* <Button variant="outline">Undo</Button>
|
|
7
|
+
* <Button variant="outline">Redo</Button>
|
|
8
|
+
* </ButtonGroup>
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* ## Joining
|
|
12
|
+
*
|
|
13
|
+
* The group does not draw anything of its own. It squares the corners where
|
|
14
|
+
* two children meet and drops the border one of them would otherwise double,
|
|
15
|
+
* so outline buttons read as one strip with dividers. It does that with child
|
|
16
|
+
* selectors rather than props, so any `Button`, `Input`, `Menu.Trigger` or
|
|
17
|
+
* `Select.Trigger` placed directly inside joins without being told to.
|
|
18
|
+
*
|
|
19
|
+
* Filled buttons have no border to share, so put a `ButtonGroup.Separator`
|
|
20
|
+
* between them; without one, two primary buttons become one long button.
|
|
21
|
+
*
|
|
22
|
+
* ## Groups of groups
|
|
23
|
+
*
|
|
24
|
+
* A group whose children are groups spaces them apart instead of joining
|
|
25
|
+
* them, which is how a toolbar is built: one group per kind of action.
|
|
26
|
+
*/
|
|
27
|
+
import type { ComponentProps } from 'react';
|
|
28
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
29
|
+
export declare const buttonGroupVariants: import("tailwind-variants").TVReturnType<{
|
|
30
|
+
orientation: {
|
|
31
|
+
horizontal: {
|
|
32
|
+
root: string[];
|
|
33
|
+
separator: string;
|
|
34
|
+
};
|
|
35
|
+
vertical: {
|
|
36
|
+
root: string[];
|
|
37
|
+
separator: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/** Matches the heights of `Button` and `Input` at the same size. */
|
|
41
|
+
size: {
|
|
42
|
+
sm: {
|
|
43
|
+
text: string;
|
|
44
|
+
};
|
|
45
|
+
md: {
|
|
46
|
+
text: string;
|
|
47
|
+
};
|
|
48
|
+
lg: {
|
|
49
|
+
text: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}, {
|
|
53
|
+
root: string[];
|
|
54
|
+
separator: string;
|
|
55
|
+
text: string[];
|
|
56
|
+
}, undefined, {
|
|
57
|
+
orientation: {
|
|
58
|
+
horizontal: {
|
|
59
|
+
root: string[];
|
|
60
|
+
separator: string;
|
|
61
|
+
};
|
|
62
|
+
vertical: {
|
|
63
|
+
root: string[];
|
|
64
|
+
separator: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/** Matches the heights of `Button` and `Input` at the same size. */
|
|
68
|
+
size: {
|
|
69
|
+
sm: {
|
|
70
|
+
text: string;
|
|
71
|
+
};
|
|
72
|
+
md: {
|
|
73
|
+
text: string;
|
|
74
|
+
};
|
|
75
|
+
lg: {
|
|
76
|
+
text: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}, {
|
|
80
|
+
root: string[];
|
|
81
|
+
separator: string;
|
|
82
|
+
text: string[];
|
|
83
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
84
|
+
orientation: {
|
|
85
|
+
horizontal: {
|
|
86
|
+
root: string[];
|
|
87
|
+
separator: string;
|
|
88
|
+
};
|
|
89
|
+
vertical: {
|
|
90
|
+
root: string[];
|
|
91
|
+
separator: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/** Matches the heights of `Button` and `Input` at the same size. */
|
|
95
|
+
size: {
|
|
96
|
+
sm: {
|
|
97
|
+
text: string;
|
|
98
|
+
};
|
|
99
|
+
md: {
|
|
100
|
+
text: string;
|
|
101
|
+
};
|
|
102
|
+
lg: {
|
|
103
|
+
text: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}, {
|
|
107
|
+
root: string[];
|
|
108
|
+
separator: string;
|
|
109
|
+
text: string[];
|
|
110
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
111
|
+
export type ButtonGroupOrientation = NonNullable<VariantProps<typeof buttonGroupVariants>['orientation']>;
|
|
112
|
+
export type ButtonGroupTextSize = NonNullable<VariantProps<typeof buttonGroupVariants>['size']>;
|
|
113
|
+
export interface ButtonGroupProps extends ComponentProps<'div'> {
|
|
114
|
+
/** Lay the children out in a row or a column. Default `horizontal`. */
|
|
115
|
+
orientation?: ButtonGroupOrientation;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The group. It is a `role="group"`, so give it an `aria-label` that names
|
|
119
|
+
* what its actions have in common.
|
|
120
|
+
*/
|
|
121
|
+
declare function ButtonGroupRoot({ orientation, className, ...props }: ButtonGroupProps): import("react").JSX.Element;
|
|
122
|
+
declare namespace ButtonGroupRoot {
|
|
123
|
+
var displayName: string;
|
|
124
|
+
}
|
|
125
|
+
export interface ButtonGroupSeparatorProps extends ComponentProps<'span'> {
|
|
126
|
+
/**
|
|
127
|
+
* Which way the line runs. It follows the group: a row of buttons is divided
|
|
128
|
+
* by upright lines, a column by flat ones. Default `vertical`, for a row.
|
|
129
|
+
*/
|
|
130
|
+
orientation?: 'vertical' | 'horizontal';
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A line between two children that have no border to share, such as filled
|
|
134
|
+
* buttons. It is decorative and hidden from assistive technology.
|
|
135
|
+
*/
|
|
136
|
+
declare function ButtonGroupSeparator({ orientation, className, ...props }: ButtonGroupSeparatorProps): import("react").JSX.Element;
|
|
137
|
+
declare namespace ButtonGroupSeparator {
|
|
138
|
+
var displayName: string;
|
|
139
|
+
}
|
|
140
|
+
export interface ButtonGroupTextProps extends ComponentProps<'div'> {
|
|
141
|
+
/** The height, matching the buttons and fields beside it. Default `md`. */
|
|
142
|
+
size?: ButtonGroupTextSize;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A cell that is read rather than pressed: a prefix such as `https://`, a unit,
|
|
146
|
+
* or the value a pair of buttons changes.
|
|
147
|
+
*/
|
|
148
|
+
declare function ButtonGroupText({ size, className, ...props }: ButtonGroupTextProps): import("react").JSX.Element;
|
|
149
|
+
declare namespace ButtonGroupText {
|
|
150
|
+
var displayName: string;
|
|
151
|
+
}
|
|
152
|
+
export declare const ButtonGroup: typeof ButtonGroupRoot & {
|
|
153
|
+
Separator: typeof ButtonGroupSeparator;
|
|
154
|
+
Text: typeof ButtonGroupText;
|
|
155
|
+
};
|
|
156
|
+
export { ButtonGroupSeparator, ButtonGroupText };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { tv } from 'tailwind-variants';
|
|
3
|
+
export const buttonGroupVariants = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
root: [
|
|
6
|
+
'flex w-fit items-stretch',
|
|
7
|
+
// A focused child draws its ring over its neighbours, not under them.
|
|
8
|
+
'*:focus-visible:relative *:focus-visible:z-10',
|
|
9
|
+
// Groups inside a group are spaced, not joined.
|
|
10
|
+
'has-[>[data-slot=button-group]]:gap-2',
|
|
11
|
+
// A field takes the room the buttons leave.
|
|
12
|
+
'[&>[data-slot=input]]:min-w-0 [&>[data-slot=input]]:flex-1',
|
|
13
|
+
],
|
|
14
|
+
separator: 'shrink-0 self-stretch bg-border',
|
|
15
|
+
text: [
|
|
16
|
+
'flex shrink-0 items-center gap-2 whitespace-nowrap border bg-muted font-medium text-muted-foreground shadow-xs dark:bg-input/30',
|
|
17
|
+
'[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4',
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
variants: {
|
|
21
|
+
orientation: {
|
|
22
|
+
horizontal: {
|
|
23
|
+
root: [
|
|
24
|
+
'[&>*:not(:first-child)]:rounded-l-none [&>*:not(:last-child)]:rounded-r-none',
|
|
25
|
+
'[&>*:not(:first-child)]:border-l-0',
|
|
26
|
+
],
|
|
27
|
+
separator: 'w-px',
|
|
28
|
+
},
|
|
29
|
+
vertical: {
|
|
30
|
+
root: [
|
|
31
|
+
'flex-col',
|
|
32
|
+
'[&>*:not(:first-child)]:rounded-t-none [&>*:not(:last-child)]:rounded-b-none',
|
|
33
|
+
'[&>*:not(:first-child)]:border-t-0',
|
|
34
|
+
],
|
|
35
|
+
separator: 'h-px',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
/** Matches the heights of `Button` and `Input` at the same size. */
|
|
39
|
+
size: {
|
|
40
|
+
sm: { text: 'h-8 rounded-md px-2.5 text-[0.8125rem]' },
|
|
41
|
+
md: { text: 'h-9 rounded-lg px-3 text-sm' },
|
|
42
|
+
lg: { text: 'h-11 rounded-xl px-3.5 text-[0.9375rem]' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: { orientation: 'horizontal', size: 'md' },
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* The group. It is a `role="group"`, so give it an `aria-label` that names
|
|
49
|
+
* what its actions have in common.
|
|
50
|
+
*/
|
|
51
|
+
function ButtonGroupRoot({ orientation = 'horizontal', className, ...props }) {
|
|
52
|
+
return (_jsx("div", { role: "group", "data-slot": "button-group", "data-orientation": orientation, className: buttonGroupVariants({ orientation }).root({ className }), ...props }));
|
|
53
|
+
}
|
|
54
|
+
ButtonGroupRoot.displayName = 'ButtonGroup';
|
|
55
|
+
/**
|
|
56
|
+
* A line between two children that have no border to share, such as filled
|
|
57
|
+
* buttons. It is decorative and hidden from assistive technology.
|
|
58
|
+
*/
|
|
59
|
+
function ButtonGroupSeparator({ orientation = 'vertical', className, ...props }) {
|
|
60
|
+
const slots = buttonGroupVariants({
|
|
61
|
+
orientation: orientation === 'vertical' ? 'horizontal' : 'vertical',
|
|
62
|
+
});
|
|
63
|
+
return (_jsx("span", { "aria-hidden": "true", "data-slot": "button-group-separator", "data-orientation": orientation, className: slots.separator({ className }), ...props }));
|
|
64
|
+
}
|
|
65
|
+
ButtonGroupSeparator.displayName = 'ButtonGroup.Separator';
|
|
66
|
+
/**
|
|
67
|
+
* A cell that is read rather than pressed: a prefix such as `https://`, a unit,
|
|
68
|
+
* or the value a pair of buttons changes.
|
|
69
|
+
*/
|
|
70
|
+
function ButtonGroupText({ size, className, ...props }) {
|
|
71
|
+
return (_jsx("div", { "data-slot": "button-group-text", className: buttonGroupVariants({ size }).text({ className }), ...props }));
|
|
72
|
+
}
|
|
73
|
+
ButtonGroupText.displayName = 'ButtonGroup.Text';
|
|
74
|
+
export const ButtonGroup = Object.assign(ButtonGroupRoot, {
|
|
75
|
+
Separator: ButtonGroupSeparator,
|
|
76
|
+
Text: ButtonGroupText,
|
|
77
|
+
});
|
|
78
|
+
export { ButtonGroupSeparator, ButtonGroupText };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { Stat, StatContent, StatLabel, StatDescription, StatValue, StatUnit, Sta
|
|
|
16
16
|
export { CommandDock, CommandDockTrigger, CommandDockPanel, CommandDockInput, CommandDockResults, CommandDockRow, CommandDockRowTitle, CommandDockRowMeta, CommandDockStatus, type CommandDockProps, type CommandDockTriggerProps, type CommandDockPanelProps, type CommandDockInputProps, type CommandDockResultsProps, type CommandDockRowProps, type CommandDockRowTitleProps, type CommandDockRowMetaProps, type CommandDockStatusProps, } from './components/command-dock/index.js';
|
|
17
17
|
export { NotFound, NotFoundCode, NotFoundTitle, NotFoundDescription, NotFoundActions, type NotFoundProps, type NotFoundCodeProps, type NotFoundTitleProps, type NotFoundDescriptionProps, type NotFoundActionsProps, type NotFoundEffect, type NotFoundColor, } from './components/not-found/index.js';
|
|
18
18
|
export { Button, buttonVariants, type ButtonProps, type ButtonVariant, type ButtonSize } from './components/button/index.js';
|
|
19
|
+
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, type ButtonGroupProps, type ButtonGroupOrientation, type ButtonGroupSeparatorProps, type ButtonGroupTextProps, type ButtonGroupTextSize, } from './components/button-group/index.js';
|
|
19
20
|
export { Input, InputGroup, InputAddon, type InputProps, type InputGroupProps, type InputAddonProps, type InputSize } from './components/input/index.js';
|
|
20
21
|
export { Textarea, type TextareaProps } from './components/textarea/index.js';
|
|
21
22
|
export { Switch, type SwitchProps, type SwitchSize, type SwitchColor } from './components/switch/index.js';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { Stat, StatContent, StatLabel, StatDescription, StatValue, StatUnit, Sta
|
|
|
16
16
|
export { CommandDock, CommandDockTrigger, CommandDockPanel, CommandDockInput, CommandDockResults, CommandDockRow, CommandDockRowTitle, CommandDockRowMeta, CommandDockStatus, } from './components/command-dock/index.js';
|
|
17
17
|
export { NotFound, NotFoundCode, NotFoundTitle, NotFoundDescription, NotFoundActions, } from './components/not-found/index.js';
|
|
18
18
|
export { Button, buttonVariants } from './components/button/index.js';
|
|
19
|
+
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, } from './components/button-group/index.js';
|
|
19
20
|
export { Input, InputGroup, InputAddon } from './components/input/index.js';
|
|
20
21
|
export { Textarea } from './components/textarea/index.js';
|
|
21
22
|
export { Switch } from './components/switch/index.js';
|