@camox/ui 0.6.1 → 0.7.1
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/package.json +5 -47
- package/src/components/alert-dialog.tsx +62 -35
- package/src/components/alert.tsx +18 -5
- package/src/components/avatar.tsx +8 -11
- package/src/components/badge.tsx +26 -16
- package/src/components/breadcrumb.tsx +26 -25
- package/src/components/button-group.tsx +23 -23
- package/src/components/button.tsx +26 -26
- package/src/components/command.tsx +53 -48
- package/src/components/dialog.tsx +40 -32
- package/src/components/dropdown-menu.tsx +137 -107
- package/src/components/input-group.tsx +146 -0
- package/src/components/input.tsx +4 -5
- package/src/components/kbd.tsx +1 -3
- package/src/components/label.tsx +2 -5
- package/src/components/panel.tsx +56 -25
- package/src/components/popover.tsx +55 -15
- package/src/components/select.tsx +86 -67
- package/src/components/separator.tsx +4 -11
- package/src/components/sheet.tsx +32 -37
- package/src/components/skeleton.tsx +1 -1
- package/src/components/switch.tsx +11 -7
- package/src/components/tabs.tsx +37 -16
- package/src/components/textarea.tsx +2 -4
- package/src/components/toggle.tsx +12 -14
- package/src/components/tooltip.tsx +29 -32
- package/src/styles/globals.css +1 -1
- package/src/components/accordion.tsx +0 -58
- package/src/components/checkbox.tsx +0 -27
- package/src/components/control-group.tsx +0 -58
- package/src/components/frame.tsx +0 -146
- package/src/components/input-base.tsx +0 -189
- package/src/components/resizable.tsx +0 -46
- package/src/hooks/use-mobile.ts +0 -19
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
4
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
5
|
-
import { Primitive } from "@radix-ui/react-primitive";
|
|
6
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
|
|
9
|
-
import { cn } from "../lib/utils";
|
|
10
|
-
import { Button } from "./button";
|
|
11
|
-
|
|
12
|
-
export type InputBaseContextProps = Pick<InputBaseProps, "autoFocus" | "disabled"> & {
|
|
13
|
-
controlRef: React.RefObject<HTMLElement | null>;
|
|
14
|
-
onFocusedChange: (focused: boolean) => void;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const InputBaseContext = React.createContext<InputBaseContextProps>({
|
|
18
|
-
autoFocus: false,
|
|
19
|
-
controlRef: { current: null },
|
|
20
|
-
disabled: false,
|
|
21
|
-
onFocusedChange: () => {},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function useInputBase() {
|
|
25
|
-
const context = React.useContext(InputBaseContext);
|
|
26
|
-
if (!context) {
|
|
27
|
-
throw new Error("useInputBase must be used within a <InputBase />.");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return context;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface InputBaseProps extends React.ComponentProps<typeof Primitive.div> {
|
|
34
|
-
autoFocus?: boolean;
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
error?: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function InputBase({ autoFocus, disabled, className, onClick, error, ...props }: InputBaseProps) {
|
|
40
|
-
const [focused, setFocused] = React.useState(false);
|
|
41
|
-
const controlRef = React.useRef<HTMLElement>(null);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<InputBaseContext.Provider
|
|
45
|
-
value={{
|
|
46
|
-
autoFocus,
|
|
47
|
-
controlRef,
|
|
48
|
-
disabled,
|
|
49
|
-
onFocusedChange: setFocused,
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<Primitive.div
|
|
53
|
-
data-slot="input-base"
|
|
54
|
-
// Based on MUI's <InputBase /> implementation.
|
|
55
|
-
// https://github.com/mui/material-ui/blob/master/packages/mui-material/src/InputBase/InputBase.js#L458~L460
|
|
56
|
-
onClick={composeEventHandlers(onClick, (event) => {
|
|
57
|
-
if (controlRef.current && event.currentTarget === event.target) {
|
|
58
|
-
controlRef.current.focus();
|
|
59
|
-
}
|
|
60
|
-
})}
|
|
61
|
-
className={cn(
|
|
62
|
-
"border-input selection:bg-primary selection:text-primary-foreground dark:bg-input/30 flex min-h-9 cursor-text items-center gap-2 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none md:text-sm",
|
|
63
|
-
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
64
|
-
focused && "border-ring ring-ring/50 ring-[3px]",
|
|
65
|
-
error && "ring-destructive/20 dark:ring-destructive/40 border-destructive",
|
|
66
|
-
className,
|
|
67
|
-
)}
|
|
68
|
-
{...props}
|
|
69
|
-
/>
|
|
70
|
-
</InputBaseContext.Provider>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function InputBaseFlexWrapper({ className, ...props }: React.ComponentProps<typeof Primitive.div>) {
|
|
75
|
-
return (
|
|
76
|
-
<Primitive.div
|
|
77
|
-
data-slot="input-base-flex-wrapper"
|
|
78
|
-
className={cn("flex flex-1 flex-wrap", className)}
|
|
79
|
-
{...props}
|
|
80
|
-
/>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function InputBaseControl({ ref, onFocus, onBlur, ...props }: React.ComponentProps<typeof Slot>) {
|
|
85
|
-
const { controlRef, autoFocus, disabled, onFocusedChange } = useInputBase();
|
|
86
|
-
|
|
87
|
-
const composedRefs = useComposedRefs(controlRef, ref);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Slot
|
|
91
|
-
data-slot="input-base-control"
|
|
92
|
-
ref={composedRefs}
|
|
93
|
-
autoFocus={autoFocus}
|
|
94
|
-
onFocus={composeEventHandlers(onFocus, () => onFocusedChange(true))}
|
|
95
|
-
onBlur={composeEventHandlers(onBlur, () => onFocusedChange(false))}
|
|
96
|
-
{...{ disabled }}
|
|
97
|
-
{...props}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface InputBaseAdornmentProps extends React.ComponentProps<"div"> {
|
|
103
|
-
asChild?: boolean;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function InputBaseAdornment({ className, asChild, children, ...props }: InputBaseAdornmentProps) {
|
|
107
|
-
let Comp: typeof Slot | "p" | "div";
|
|
108
|
-
if (asChild) {
|
|
109
|
-
Comp = Slot;
|
|
110
|
-
} else if (typeof children === "string") {
|
|
111
|
-
Comp = "p";
|
|
112
|
-
} else {
|
|
113
|
-
Comp = "div";
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<Comp
|
|
118
|
-
data-slot="input-base-adornment"
|
|
119
|
-
className={cn(
|
|
120
|
-
"text-muted-foreground flex items-center [&_svg:not([class*='size-'])]:size-4",
|
|
121
|
-
"[&:not(:has(button))]:pointer-events-none",
|
|
122
|
-
className,
|
|
123
|
-
)}
|
|
124
|
-
{...props}
|
|
125
|
-
>
|
|
126
|
-
{children}
|
|
127
|
-
</Comp>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function InputBaseAdornmentButton({
|
|
132
|
-
type = "button",
|
|
133
|
-
variant = "ghost",
|
|
134
|
-
size = "icon",
|
|
135
|
-
disabled: disabledProp,
|
|
136
|
-
className,
|
|
137
|
-
...props
|
|
138
|
-
}: React.ComponentProps<typeof Button>) {
|
|
139
|
-
const { disabled } = useInputBase();
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<Button
|
|
143
|
-
data-slot="input-base-adornment-button"
|
|
144
|
-
type={type}
|
|
145
|
-
variant={variant}
|
|
146
|
-
size={size}
|
|
147
|
-
disabled={disabled || disabledProp}
|
|
148
|
-
className={cn("size-6", className)}
|
|
149
|
-
{...props}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function InputBaseInput({ className, ...props }: React.ComponentProps<typeof Primitive.input>) {
|
|
155
|
-
return (
|
|
156
|
-
<Primitive.input
|
|
157
|
-
data-slot="input-base-input"
|
|
158
|
-
className={cn(
|
|
159
|
-
"placeholder:text-muted-foreground file:text-foreground w-full flex-1 bg-transparent file:border-0 file:bg-transparent file:text-sm file:font-medium focus:outline-none disabled:pointer-events-none",
|
|
160
|
-
className,
|
|
161
|
-
)}
|
|
162
|
-
{...props}
|
|
163
|
-
/>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function InputBaseTextarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
168
|
-
return (
|
|
169
|
-
<textarea
|
|
170
|
-
data-slot="input-base-textarea"
|
|
171
|
-
className={cn(
|
|
172
|
-
"placeholder:text-muted-foreground min-h-16 flex-1 bg-transparent focus:outline-none disabled:pointer-events-none",
|
|
173
|
-
className,
|
|
174
|
-
)}
|
|
175
|
-
{...props}
|
|
176
|
-
/>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export {
|
|
181
|
-
InputBase,
|
|
182
|
-
InputBaseFlexWrapper,
|
|
183
|
-
InputBaseControl,
|
|
184
|
-
InputBaseAdornment,
|
|
185
|
-
InputBaseAdornmentButton,
|
|
186
|
-
InputBaseInput,
|
|
187
|
-
InputBaseTextarea,
|
|
188
|
-
useInputBase,
|
|
189
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Panel, PanelGroup, PanelResizer } from "@window-splitter/react";
|
|
2
|
-
import { GripVerticalIcon } from "lucide-react";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "../lib/utils";
|
|
6
|
-
|
|
7
|
-
function ResizablePanelGroup({ className, ...props }: React.ComponentProps<typeof PanelGroup>) {
|
|
8
|
-
return (
|
|
9
|
-
<PanelGroup
|
|
10
|
-
data-slot="resizable-panel-group"
|
|
11
|
-
className={cn("h-full w-full data-[panel-group-direction=vertical]:flex-col", className)}
|
|
12
|
-
{...props}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function ResizablePanel({ ...props }: React.ComponentProps<typeof Panel>) {
|
|
18
|
-
return <Panel data-slot="resizable-panel" {...props} />;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function ResizableHandle({
|
|
22
|
-
withHandle,
|
|
23
|
-
className,
|
|
24
|
-
...props
|
|
25
|
-
}: React.ComponentProps<typeof PanelResizer> & {
|
|
26
|
-
withHandle?: boolean;
|
|
27
|
-
}) {
|
|
28
|
-
return (
|
|
29
|
-
<PanelResizer
|
|
30
|
-
data-slot="resizable-handle"
|
|
31
|
-
className={cn(
|
|
32
|
-
"bg-border ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
|
|
33
|
-
className,
|
|
34
|
-
)}
|
|
35
|
-
{...props}
|
|
36
|
-
>
|
|
37
|
-
{withHandle && (
|
|
38
|
-
<div className="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border">
|
|
39
|
-
<GripVerticalIcon className="size-2.5" />
|
|
40
|
-
</div>
|
|
41
|
-
)}
|
|
42
|
-
</PanelResizer>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
|
package/src/hooks/use-mobile.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
const MOBILE_BREAKPOINT = 768;
|
|
4
|
-
|
|
5
|
-
export function useIsMobile() {
|
|
6
|
-
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
|
7
|
-
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
10
|
-
const onChange = () => {
|
|
11
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
-
};
|
|
13
|
-
mql.addEventListener("change", onChange);
|
|
14
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
15
|
-
return () => mql.removeEventListener("change", onChange);
|
|
16
|
-
}, []);
|
|
17
|
-
|
|
18
|
-
return !!isMobile;
|
|
19
|
-
}
|