@api7/ui-components 0.4.0 → 0.6.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 +221 -30
- package/dist/animations.css +12 -0
- package/dist/components/alert/alert.d.ts +0 -2
- package/dist/components/alert/alert.js +8 -9
- package/dist/components/avatar/avatar.d.ts +4 -6
- package/dist/components/avatar/avatar.js +7 -8
- package/dist/components/badge/badge.d.ts +0 -2
- package/dist/components/badge/badge.js +15 -16
- package/dist/components/button/button.d.ts +1 -4
- package/dist/components/button/button.js +15 -16
- package/dist/components/calendar/calendar.d.ts +1 -3
- package/dist/components/calendar/calendar.js +29 -30
- package/dist/components/checkbox/checkbox.d.ts +0 -2
- package/dist/components/checkbox/checkbox.js +4 -5
- package/dist/components/combobox/combobox.d.ts +0 -2
- package/dist/components/combobox/combobox.js +25 -25
- package/dist/components/data-table/data-table.d.ts +0 -2
- package/dist/components/data-table/data-table.js +8 -9
- package/dist/components/data-table/filter-header.d.ts +1 -3
- package/dist/components/data-table/filter-header.js +5 -6
- package/dist/components/data-table/sort-header.js +3 -4
- package/dist/components/date-picker/date-picker.d.ts +0 -2
- package/dist/components/date-picker/date-picker.js +15 -16
- package/dist/components/description-list/description-list.d.ts +24 -0
- package/dist/components/description-list/description-list.js +88 -0
- package/dist/components/dialog/dialog.d.ts +0 -2
- package/dist/components/dialog/dialog.js +12 -13
- package/dist/components/drawer/drawer.d.ts +0 -2
- package/dist/components/drawer/drawer.js +13 -14
- package/dist/components/empty/empty.d.ts +0 -2
- package/dist/components/empty/empty.js +9 -10
- package/dist/components/field/field.d.ts +0 -2
- package/dist/components/field/field.js +7 -8
- package/dist/components/field/labeled-field.d.ts +33 -0
- package/dist/components/field/labeled-field.js +67 -0
- package/dist/components/form/choice-fields.d.ts +1 -3
- package/dist/components/form/choice-fields.js +1 -2
- package/dist/components/form/date-fields.d.ts +0 -2
- package/dist/components/form/date-fields.js +2 -3
- package/dist/components/form/errors.d.ts +1 -3
- package/dist/components/form/errors.js +1 -2
- package/dist/components/form/form-context.d.ts +1 -3
- package/dist/components/form/form-context.js +1 -2
- package/dist/components/form/form-item.d.ts +6 -17
- package/dist/components/form/form-item.js +9 -58
- package/dist/components/form/form.d.ts +1 -3
- package/dist/components/form/form.js +1 -2
- package/dist/components/form/lazy-field-components.js +2 -3
- package/dist/components/form/submit-button.d.ts +1 -3
- package/dist/components/form/submit-button.js +1 -2
- package/dist/components/form/text-field.d.ts +1 -3
- package/dist/components/form/text-field.js +1 -2
- package/dist/components/form/toggle-fields.d.ts +1 -3
- package/dist/components/form/toggle-fields.js +30 -46
- package/dist/components/input/input.d.ts +0 -2
- package/dist/components/input/input.js +2 -3
- package/dist/components/input-group/input-group.d.ts +0 -2
- package/dist/components/input-group/input-group.js +12 -13
- package/dist/components/menu/menu.d.ts +14 -4
- package/dist/components/menu/menu.js +43 -31
- package/dist/components/number-field/number-field.d.ts +0 -2
- package/dist/components/number-field/number-field.js +8 -9
- package/dist/components/pagination/pagination.d.ts +1 -3
- package/dist/components/pagination/pagination.js +13 -14
- package/dist/components/popover/popover.d.ts +3 -3
- package/dist/components/popover/popover.js +14 -7
- package/dist/components/progress/progress.d.ts +17 -0
- package/dist/components/progress/progress.js +35 -0
- package/dist/components/radio-group/radio-group.d.ts +0 -2
- package/dist/components/radio-group/radio-group.js +4 -5
- package/dist/components/select/select.d.ts +0 -2
- package/dist/components/select/select.js +18 -18
- package/dist/components/separator/separator.d.ts +0 -2
- package/dist/components/separator/separator.js +2 -3
- package/dist/components/sidebar/sidebar.d.ts +0 -2
- package/dist/components/sidebar/sidebar.js +11 -12
- package/dist/components/skeleton/skeleton.d.ts +0 -2
- package/dist/components/skeleton/skeleton.js +2 -3
- package/dist/components/spinner/spinner.d.ts +12 -0
- package/dist/components/spinner/spinner.js +27 -0
- package/dist/components/switch/switch.d.ts +0 -2
- package/dist/components/switch/switch.js +3 -4
- package/dist/components/table/table.d.ts +0 -2
- package/dist/components/table/table.js +8 -9
- package/dist/components/tabs/tabs.d.ts +0 -2
- package/dist/components/tabs/tabs.js +5 -6
- package/dist/components/textarea/textarea.d.ts +0 -2
- package/dist/components/textarea/textarea.js +2 -3
- package/dist/components/toast/toast.d.ts +0 -2
- package/dist/components/toast/toast.js +19 -20
- package/dist/components/tooltip/tooltip.d.ts +0 -2
- package/dist/components/tooltip/tooltip.js +5 -4
- package/dist/config/config-provider.d.ts +1 -3
- package/dist/config/config-provider.js +1 -2
- package/dist/config/messages.d.ts +5 -3
- package/dist/config/messages.js +3 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -3
- package/dist/lib/cn.js +5 -6
- package/dist/lib/control.js +4 -5
- package/dist/lib/popup.js +6 -6
- package/dist/theme.css +220 -0
- package/dist/tokens/contrast.d.ts +1 -3
- package/dist/tokens/contrast.js +1 -2
- package/dist/tokens/palette.d.ts +0 -2
- package/dist/tokens/palette.js +1 -2
- package/dist/tokens/scale.js +1 -2
- package/dist/tokens/semantic.d.ts +0 -2
- package/dist/tokens/semantic.js +0 -1
- package/dist/tokens/types.d.ts +1 -3
- package/dist/tokens/types.js +1 -2
- package/package.json +11 -9
- package/dist/styles.css +0 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMessages } from "../../config/config-provider.js";
|
|
3
3
|
import { cn } from "../../lib/cn.js";
|
|
4
|
-
import { listItemClassName, listboxClassName } from "../../lib/popup.js";
|
|
4
|
+
import { listItemClassName, listboxClassName, popupLayerClassName } from "../../lib/popup.js";
|
|
5
5
|
import { controlFocus, controlSurface } from "../../lib/control.js";
|
|
6
6
|
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
|
|
9
9
|
import { Select } from "@base-ui/react/select";
|
|
10
|
-
|
|
10
|
+
// src/components/select/select.tsx
|
|
11
11
|
const SelectClearContext = createContext(void 0);
|
|
12
12
|
/**
|
|
13
13
|
* Pass `items` (a value-to-label map, e.g. `{ http: 'HTTP' }`, or a `{ label, value }[]` list)
|
|
@@ -72,19 +72,19 @@ function SelectTrigger({ className, children, size = "default", ...props }) {
|
|
|
72
72
|
const messages = useMessages();
|
|
73
73
|
const showClear = clearState?.hasValue ?? false;
|
|
74
74
|
return /* @__PURE__ */ jsxs("div", {
|
|
75
|
-
className: cn("
|
|
75
|
+
className: cn("relative flex w-full", className),
|
|
76
76
|
"data-slot": "select-trigger-wrapper",
|
|
77
77
|
children: [/* @__PURE__ */ jsxs(Select.Trigger, {
|
|
78
78
|
ref: clearState?.triggerRef,
|
|
79
|
-
className: cn(controlSurface, controlFocus, "
|
|
79
|
+
className: cn(controlSurface, controlFocus, "peer/select-trigger flex w-full items-center justify-between", size === "sm" ? "h-6 gap-1 px-2" : "h-8 gap-2 px-3"),
|
|
80
80
|
...props,
|
|
81
81
|
"data-slot": "select-trigger",
|
|
82
82
|
children: [children, /* @__PURE__ */ jsxs("span", {
|
|
83
|
-
className: "
|
|
83
|
+
className: "flex shrink-0 items-center gap-2",
|
|
84
84
|
children: [showClear && /* @__PURE__ */ jsx("span", {
|
|
85
85
|
"aria-hidden": true,
|
|
86
|
-
className: "
|
|
87
|
-
}), /* @__PURE__ */ jsx(Select.Icon, { children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("
|
|
86
|
+
className: "size-3"
|
|
87
|
+
}), /* @__PURE__ */ jsx(Select.Icon, { children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("shrink-0 text-foreground", size === "sm" ? "size-3.5" : "size-5") }) })]
|
|
88
88
|
})]
|
|
89
89
|
}), showClear && clearState && /* @__PURE__ */ jsx("button", {
|
|
90
90
|
type: "button",
|
|
@@ -93,31 +93,32 @@ function SelectTrigger({ className, children, size = "default", ...props }) {
|
|
|
93
93
|
event.stopPropagation();
|
|
94
94
|
clearState.onClear();
|
|
95
95
|
},
|
|
96
|
-
className: cn("
|
|
96
|
+
className: cn("absolute top-1/2 -translate-y-1/2 rounded-sm text-muted-foreground outline-none hover:text-foreground", size === "sm" ? "right-6" : "right-8", "peer-data-disabled/select-trigger:hidden", "focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 aria-invalid:focus-visible:ring-destructive/40 data-invalid:focus-visible:ring-destructive/40"),
|
|
97
97
|
"data-slot": "select-clear",
|
|
98
|
-
children: /* @__PURE__ */ jsx(XIcon, { className: "
|
|
98
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3" })
|
|
99
99
|
})]
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
function SelectValue({ className, ...props }) {
|
|
103
103
|
return /* @__PURE__ */ jsx(Select.Value, {
|
|
104
|
-
className: cn("
|
|
104
|
+
className: cn("min-w-0 truncate text-left data-placeholder:text-muted-foreground", className),
|
|
105
105
|
...props,
|
|
106
106
|
"data-slot": "select-value"
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
function SelectContent({ className, side = "bottom", sideOffset = 4, align = "start", alignItemWithTrigger = false, children, ...props }) {
|
|
110
110
|
return /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, {
|
|
111
|
+
className: popupLayerClassName,
|
|
111
112
|
side,
|
|
112
113
|
sideOffset,
|
|
113
114
|
align,
|
|
114
115
|
alignItemWithTrigger,
|
|
115
116
|
children: /* @__PURE__ */ jsx(Select.Popup, {
|
|
116
|
-
className: "
|
|
117
|
+
className: "outline-none",
|
|
117
118
|
...props,
|
|
118
119
|
"data-slot": "select-popup",
|
|
119
120
|
children: /* @__PURE__ */ jsx(Select.List, {
|
|
120
|
-
className: cn(listboxClassName, "
|
|
121
|
+
className: cn(listboxClassName, "min-w-(--anchor-width)", className),
|
|
121
122
|
"data-slot": "select-content",
|
|
122
123
|
children
|
|
123
124
|
})
|
|
@@ -130,11 +131,11 @@ function SelectItem({ className, children, ...props }) {
|
|
|
130
131
|
...props,
|
|
131
132
|
"data-slot": "select-item",
|
|
132
133
|
children: [/* @__PURE__ */ jsx(Select.ItemText, {
|
|
133
|
-
className: "
|
|
134
|
+
className: "min-w-0 flex-1 truncate",
|
|
134
135
|
children
|
|
135
136
|
}), /* @__PURE__ */ jsx(Select.ItemIndicator, {
|
|
136
|
-
className: "
|
|
137
|
-
children: /* @__PURE__ */ jsx(CheckIcon, { className: "
|
|
137
|
+
className: "flex size-4 shrink-0 items-center justify-center",
|
|
138
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" })
|
|
138
139
|
})]
|
|
139
140
|
});
|
|
140
141
|
}
|
|
@@ -147,17 +148,16 @@ function SelectGroup({ className, ...props }) {
|
|
|
147
148
|
}
|
|
148
149
|
function SelectGroupLabel({ className, ...props }) {
|
|
149
150
|
return /* @__PURE__ */ jsx(Select.GroupLabel, {
|
|
150
|
-
className: cn("
|
|
151
|
+
className: cn("px-4 py-2 text-xs font-medium text-muted-foreground", className),
|
|
151
152
|
...props,
|
|
152
153
|
"data-slot": "select-group-label"
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
function SelectSeparator({ className, ...props }) {
|
|
156
157
|
return /* @__PURE__ */ jsx(Select.Separator, {
|
|
157
|
-
className: cn("
|
|
158
|
+
className: cn("my-1 h-px bg-border", className),
|
|
158
159
|
...props,
|
|
159
160
|
"data-slot": "select-separator"
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
|
-
//#endregion
|
|
163
163
|
export { Select$1 as Select, SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectSeparator, SelectTrigger, SelectValue };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Separator } from "@base-ui/react/separator";
|
|
2
|
-
//#region src/components/separator/separator.d.ts
|
|
3
2
|
export type SeparatorProps = Omit<Separator.Props, 'className'> & {
|
|
4
3
|
className?: string;
|
|
5
4
|
};
|
|
6
5
|
declare function Separator$1({ className, orientation, ...props }: SeparatorProps): import("react").JSX.Element;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { Separator$1 as Separator };
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Separator } from "@base-ui/react/separator";
|
|
5
|
-
|
|
5
|
+
// src/components/separator/separator.tsx
|
|
6
6
|
function Separator$1({ className, orientation = "horizontal", ...props }) {
|
|
7
7
|
return /* @__PURE__ */ jsx(Separator, {
|
|
8
8
|
orientation,
|
|
9
|
-
className: cn("
|
|
9
|
+
className: cn("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch", className),
|
|
10
10
|
...props,
|
|
11
11
|
"data-slot": "separator"
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { Separator$1 as Separator };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
|
-
//#region src/components/sidebar/sidebar.d.ts
|
|
3
2
|
export type SidebarProps = ComponentProps<'nav'>;
|
|
4
3
|
declare function Sidebar({ className, ...props }: SidebarProps): import("react").JSX.Element;
|
|
5
4
|
export type SidebarGroupProps = ComponentProps<'div'> & {
|
|
@@ -17,5 +16,4 @@ export type SidebarItemProps = Omit<ComponentProps<'a'>, 'className' | 'children
|
|
|
17
16
|
children?: ReactNode;
|
|
18
17
|
};
|
|
19
18
|
declare function SidebarItem({ render, className, active, disabled, disabledReason, icon, children, onClick, href, tabIndex, ...props }: SidebarItemProps): import("react").JSX.Element;
|
|
20
|
-
//#endregion
|
|
21
19
|
export { Sidebar, SidebarGroup, SidebarItem };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
|
-
import { Separator } from "../separator/separator.js";
|
|
4
3
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
|
|
4
|
+
import { Separator } from "../separator/separator.js";
|
|
5
5
|
import { cloneElement, useId } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/sidebar/sidebar.tsx
|
|
8
8
|
function Sidebar({ className, ...props }) {
|
|
9
9
|
return /* @__PURE__ */ jsx("nav", {
|
|
10
|
-
className: cn("
|
|
10
|
+
className: cn("w-[226px] bg-background p-2 pt-5", className),
|
|
11
11
|
...props,
|
|
12
12
|
"data-slot": "sidebar"
|
|
13
13
|
});
|
|
@@ -15,13 +15,13 @@ function Sidebar({ className, ...props }) {
|
|
|
15
15
|
function SidebarGroup({ label, separator = false, className, children, ...props }) {
|
|
16
16
|
return /* @__PURE__ */ jsxs(Fragment, { children: [separator && /* @__PURE__ */ jsx("div", {
|
|
17
17
|
"data-slot": "sidebar-group-separator",
|
|
18
|
-
children: /* @__PURE__ */ jsx(Separator, { className: "
|
|
18
|
+
children: /* @__PURE__ */ jsx(Separator, { className: "my-2" })
|
|
19
19
|
}), /* @__PURE__ */ jsxs("div", {
|
|
20
|
-
className: cn("
|
|
20
|
+
className: cn("mb-2", className),
|
|
21
21
|
...props,
|
|
22
22
|
"data-slot": "sidebar-group",
|
|
23
23
|
children: [label && /* @__PURE__ */ jsx("div", {
|
|
24
|
-
className: "
|
|
24
|
+
className: "px-2 py-2 pl-4 text-xs text-muted-foreground",
|
|
25
25
|
"data-slot": "sidebar-group-label",
|
|
26
26
|
children: label
|
|
27
27
|
}), children]
|
|
@@ -32,17 +32,17 @@ function SidebarItem({ render, className, active = false, disabled = false, disa
|
|
|
32
32
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
33
|
icon && /* @__PURE__ */ jsx("span", {
|
|
34
34
|
"aria-hidden": "true",
|
|
35
|
-
className: "
|
|
35
|
+
className: "size-5 shrink-0 [&>svg]:size-5",
|
|
36
36
|
"data-slot": "sidebar-item-icon",
|
|
37
37
|
children: icon
|
|
38
38
|
}),
|
|
39
39
|
/* @__PURE__ */ jsx("span", {
|
|
40
|
-
className: "
|
|
40
|
+
className: "truncate",
|
|
41
41
|
children
|
|
42
42
|
}),
|
|
43
43
|
active && /* @__PURE__ */ jsx("span", {
|
|
44
44
|
"aria-hidden": "true",
|
|
45
|
-
className: "
|
|
45
|
+
className: "absolute inset-y-0 left-0 w-1 bg-sidebar-indicator",
|
|
46
46
|
"data-slot": "sidebar-item-indicator"
|
|
47
47
|
})
|
|
48
48
|
] });
|
|
@@ -68,16 +68,15 @@ function SidebarItem({ render, className, active = false, disabled = false, disa
|
|
|
68
68
|
baseProps.onClick?.(event);
|
|
69
69
|
onClick?.(event);
|
|
70
70
|
},
|
|
71
|
-
className: cn("
|
|
71
|
+
className: cn("relative mb-1 flex items-center gap-3 overflow-hidden rounded-md px-3 py-2.5 text-sm leading-5 text-foreground whitespace-nowrap", "hover:bg-sidebar-accent", active && "bg-sidebar-accent font-medium", disabled && "opacity-50 cursor-not-allowed", baseProps.className, className),
|
|
72
72
|
"data-slot": "sidebar-item"
|
|
73
73
|
}, content);
|
|
74
74
|
if (showReason) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: element }), /* @__PURE__ */ jsx(TooltipContent, { children: disabledReason })] }), /* @__PURE__ */ jsx("span", {
|
|
75
75
|
id: reasonId,
|
|
76
|
-
className: "
|
|
76
|
+
className: "sr-only",
|
|
77
77
|
"data-slot": "sidebar-item-reason",
|
|
78
78
|
children: disabledReason
|
|
79
79
|
})] });
|
|
80
80
|
return element;
|
|
81
81
|
}
|
|
82
|
-
//#endregion
|
|
83
82
|
export { Sidebar, SidebarGroup, SidebarItem };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
|
-
//#region src/components/skeleton/skeleton.d.ts
|
|
3
2
|
export type SkeletonProps = ComponentProps<'div'>;
|
|
4
3
|
declare function Skeleton({ className, ...props }: SkeletonProps): import("react").JSX.Element;
|
|
5
|
-
//#endregion
|
|
6
4
|
export { Skeleton };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { cn } from "../../lib/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
// src/components/skeleton/skeleton.tsx
|
|
4
4
|
function Skeleton({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx("div", {
|
|
6
|
-
className: cn("
|
|
6
|
+
className: cn("animate-pulse rounded-md bg-accent-selected motion-reduce:animate-none", className),
|
|
7
7
|
...props,
|
|
8
8
|
"data-slot": "skeleton"
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { Skeleton };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const spinnerVariants: (props?: ({
|
|
4
|
+
size?: "sm" | "md" | "lg" | "xs" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
/**
|
|
7
|
+
* The spinner is an SVG that takes its colour from the text colour, so set it with a `text-*` class. An
|
|
8
|
+
* `aria-label` overrides the localized default announcement.
|
|
9
|
+
*/
|
|
10
|
+
export type SpinnerProps = Omit<ComponentProps<'svg'>, 'ref'> & VariantProps<typeof spinnerVariants>;
|
|
11
|
+
declare function Spinner({ className, size, ...props }: SpinnerProps): import("react").JSX.Element;
|
|
12
|
+
export { Spinner, spinnerVariants };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMessages } from "../../config/config-provider.js";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { LoaderCircle } from "lucide-react";
|
|
7
|
+
// src/components/spinner/spinner.tsx
|
|
8
|
+
const spinnerVariants = cva("shrink-0 animate-spin motion-reduce:animate-none", {
|
|
9
|
+
variants: { size: {
|
|
10
|
+
xs: "size-3",
|
|
11
|
+
sm: "size-4",
|
|
12
|
+
md: "size-6",
|
|
13
|
+
lg: "size-8"
|
|
14
|
+
} },
|
|
15
|
+
defaultVariants: { size: "md" }
|
|
16
|
+
});
|
|
17
|
+
function Spinner({ className, size, ...props }) {
|
|
18
|
+
const messages = useMessages();
|
|
19
|
+
return /* @__PURE__ */ jsx(LoaderCircle, {
|
|
20
|
+
role: "status",
|
|
21
|
+
"aria-label": messages.spinner.label,
|
|
22
|
+
className: cn(spinnerVariants({ size }), className),
|
|
23
|
+
...props,
|
|
24
|
+
"data-slot": "spinner"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { Spinner, spinnerVariants };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Switch } from "@base-ui/react/switch";
|
|
2
|
-
//#region src/components/switch/switch.d.ts
|
|
3
2
|
export type SwitchProps = Omit<Switch.Root.Props, 'className'> & {
|
|
4
3
|
className?: string;
|
|
5
4
|
size?: 'sm' | 'md';
|
|
6
5
|
};
|
|
7
6
|
declare function Switch$1({ className, size, ...props }: SwitchProps): import("react").JSX.Element;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { Switch$1 as Switch };
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Switch } from "@base-ui/react/switch";
|
|
5
|
-
|
|
5
|
+
// src/components/switch/switch.tsx
|
|
6
6
|
function Switch$1({ className, size = "md", ...props }) {
|
|
7
7
|
return /* @__PURE__ */ jsx(Switch.Root, {
|
|
8
8
|
"data-size": size,
|
|
9
9
|
"data-base-ui-swipe-ignore": true,
|
|
10
|
-
className: cn("
|
|
10
|
+
className: cn("group/switch peer relative inline-flex shrink-0 items-center rounded-full p-0.5 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/40 data-checked:bg-primary data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=md]:h-5 data-[size=md]:w-9 data-[size=sm]:h-4 data-[size=sm]:w-7", className),
|
|
11
11
|
...props,
|
|
12
12
|
"data-slot": "switch",
|
|
13
13
|
children: /* @__PURE__ */ jsx(Switch.Thumb, {
|
|
14
|
-
className: "
|
|
14
|
+
className: "pointer-events-none block rounded-full bg-background shadow-sm transition-transform group-data-[size=md]/switch:size-4 group-data-[size=sm]/switch:size-3 data-unchecked:translate-x-0 group-data-[size=md]/switch:data-checked:translate-x-4 group-data-[size=sm]/switch:data-checked:translate-x-3",
|
|
15
15
|
"data-slot": "switch-thumb"
|
|
16
16
|
})
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
//#endregion
|
|
20
19
|
export { Switch$1 as Switch };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
|
-
//#region src/components/table/table.d.ts
|
|
3
2
|
export type TableProps = Omit<ComponentProps<'table'>, 'className'> & {
|
|
4
3
|
className?: string;
|
|
5
4
|
containerClassName?: string;
|
|
@@ -29,5 +28,4 @@ export type TableCaptionProps = Omit<ComponentProps<'caption'>, 'className'> & {
|
|
|
29
28
|
className?: string;
|
|
30
29
|
};
|
|
31
30
|
declare function TableCaption({ className, ...props }: TableCaptionProps): import("react").JSX.Element;
|
|
32
|
-
//#endregion
|
|
33
31
|
export { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cn } from "../../lib/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
// src/components/table/table.tsx
|
|
4
4
|
function Table({ className, containerClassName, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx("div", {
|
|
6
6
|
"data-slot": "table-container",
|
|
7
|
-
className: cn("
|
|
7
|
+
className: cn("relative w-full overflow-x-auto", containerClassName),
|
|
8
8
|
children: /* @__PURE__ */ jsx("table", {
|
|
9
|
-
className: cn("
|
|
9
|
+
className: cn("w-full caption-bottom border-collapse text-sm", className),
|
|
10
10
|
...props,
|
|
11
11
|
"data-slot": "table"
|
|
12
12
|
})
|
|
@@ -21,21 +21,21 @@ function TableHeader({ className, ...props }) {
|
|
|
21
21
|
}
|
|
22
22
|
function TableBody({ className, ...props }) {
|
|
23
23
|
return /* @__PURE__ */ jsx("tbody", {
|
|
24
|
-
className: cn("
|
|
24
|
+
className: cn("[&_tr:hover]:bg-muted/50", className),
|
|
25
25
|
...props,
|
|
26
26
|
"data-slot": "table-body"
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function TableRow({ className, ...props }) {
|
|
30
30
|
return /* @__PURE__ */ jsx("tr", {
|
|
31
|
-
className: cn("
|
|
31
|
+
className: cn("group/row border-b border-border", className),
|
|
32
32
|
...props,
|
|
33
33
|
"data-slot": "table-row"
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
function TableHead({ className, ...props }) {
|
|
37
37
|
return /* @__PURE__ */ jsx("th", {
|
|
38
|
-
className: cn("
|
|
38
|
+
className: cn("h-10 px-4 py-2 text-left align-middle text-xs font-medium text-muted-foreground bg-table-header", className),
|
|
39
39
|
scope: "col",
|
|
40
40
|
...props,
|
|
41
41
|
"data-slot": "table-head"
|
|
@@ -43,17 +43,16 @@ function TableHead({ className, ...props }) {
|
|
|
43
43
|
}
|
|
44
44
|
function TableCell({ className, ...props }) {
|
|
45
45
|
return /* @__PURE__ */ jsx("td", {
|
|
46
|
-
className: cn("
|
|
46
|
+
className: cn("p-4 align-middle text-sm leading-[1.75] text-foreground", className),
|
|
47
47
|
...props,
|
|
48
48
|
"data-slot": "table-cell"
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
function TableCaption({ className, ...props }) {
|
|
52
52
|
return /* @__PURE__ */ jsx("caption", {
|
|
53
|
-
className: cn("
|
|
53
|
+
className: cn("mt-4 text-sm text-muted-foreground", className),
|
|
54
54
|
...props,
|
|
55
55
|
"data-slot": "table-caption"
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
//#endregion
|
|
59
58
|
export { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Tabs } from "@base-ui/react/tabs";
|
|
2
|
-
//#region src/components/tabs/tabs.d.ts
|
|
3
2
|
export type TabsProps = Omit<Tabs.Root.Props, 'className'> & {
|
|
4
3
|
className?: string;
|
|
5
4
|
};
|
|
@@ -16,5 +15,4 @@ export type TabsContentProps = Omit<Tabs.Panel.Props, 'className'> & {
|
|
|
16
15
|
className?: string;
|
|
17
16
|
};
|
|
18
17
|
declare function TabsContent({ className, ...props }: TabsContentProps): import("react").JSX.Element;
|
|
19
|
-
//#endregion
|
|
20
18
|
export { Tabs$1 as Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Tabs } from "@base-ui/react/tabs";
|
|
5
|
-
|
|
5
|
+
// src/components/tabs/tabs.tsx
|
|
6
6
|
function Tabs$1({ className, ...props }) {
|
|
7
7
|
return /* @__PURE__ */ jsx(Tabs.Root, {
|
|
8
|
-
className: cn("
|
|
8
|
+
className: cn("flex flex-col data-[orientation=vertical]:flex-row", className),
|
|
9
9
|
...props,
|
|
10
10
|
"data-slot": "tabs"
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
function TabsList({ className, children, ...props }) {
|
|
14
14
|
return /* @__PURE__ */ jsx(Tabs.List, {
|
|
15
|
-
className: cn("
|
|
15
|
+
className: cn("relative flex gap-8 overflow-x-auto shadow-[inset_0_-1px_0_0_var(--color-border)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:overflow-x-visible data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border)]", className),
|
|
16
16
|
...props,
|
|
17
17
|
"data-slot": "tabs-list",
|
|
18
18
|
children
|
|
@@ -20,17 +20,16 @@ function TabsList({ className, children, ...props }) {
|
|
|
20
20
|
}
|
|
21
21
|
function TabsTrigger({ className, ...props }) {
|
|
22
22
|
return /* @__PURE__ */ jsx(Tabs.Tab, {
|
|
23
|
-
className: cn("
|
|
23
|
+
className: cn("relative h-10 shrink-0 rounded-sm px-0 text-sm font-medium whitespace-nowrap text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring/40 data-active:text-primary-text data-disabled:opacity-50", "after:pointer-events-none after:absolute after:inset-x-[-10px] after:bottom-0 after:hidden after:h-0.5 after:bg-primary after:content-[\"\"] data-active:after:block data-[orientation=vertical]:after:inset-x-auto data-[orientation=vertical]:after:inset-y-[-10px] data-[orientation=vertical]:after:right-[-1px] data-[orientation=vertical]:after:bottom-auto data-[orientation=vertical]:after:h-auto data-[orientation=vertical]:after:w-0.5", className),
|
|
24
24
|
...props,
|
|
25
25
|
"data-slot": "tabs-trigger"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
function TabsContent({ className, ...props }) {
|
|
29
29
|
return /* @__PURE__ */ jsx(Tabs.Panel, {
|
|
30
|
-
className: cn("
|
|
30
|
+
className: cn("pt-4 outline-none data-[orientation=vertical]:pt-0 data-[orientation=vertical]:pl-4", className),
|
|
31
31
|
...props,
|
|
32
32
|
"data-slot": "tabs-content"
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
//#endregion
|
|
36
35
|
export { Tabs$1 as Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import { Input } from "@base-ui/react/input";
|
|
3
|
-
//#region src/components/textarea/textarea.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Base UI's Field.Control (which Input wraps) derives `id`, `name`, `disabled`,
|
|
6
5
|
* `autoFocus`, the controlled/uncontrolled `value`/`defaultValue` and the field's
|
|
@@ -23,5 +22,4 @@ export type TextareaProps = Omit<ComponentProps<'textarea'>, 'className' | 'valu
|
|
|
23
22
|
onValueChange?: Input.Props['onValueChange'];
|
|
24
23
|
};
|
|
25
24
|
declare function Textarea({ className, id, name, disabled, autoFocus, value, defaultValue, onChange, onValueChange, ...rest }: TextareaProps): import("react").JSX.Element;
|
|
26
|
-
//#endregion
|
|
27
25
|
export { Textarea };
|
|
@@ -3,7 +3,7 @@ import { cn } from "../../lib/cn.js";
|
|
|
3
3
|
import { controlFocus, controlSurface } from "../../lib/control.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Input } from "@base-ui/react/input";
|
|
6
|
-
|
|
6
|
+
// src/components/textarea/textarea.tsx
|
|
7
7
|
function Textarea({ className, id, name, disabled, autoFocus, value, defaultValue, onChange, onValueChange, ...rest }) {
|
|
8
8
|
return /* @__PURE__ */ jsx(Input, {
|
|
9
9
|
id,
|
|
@@ -18,8 +18,7 @@ function Textarea({ className, id, name, disabled, autoFocus, value, defaultValu
|
|
|
18
18
|
...rest,
|
|
19
19
|
"data-slot": "textarea"
|
|
20
20
|
}),
|
|
21
|
-
className: cn(controlSurface, controlFocus, "
|
|
21
|
+
className: cn(controlSurface, controlFocus, "min-h-16 px-3 py-2 field-sizing-content", className)
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { Textarea };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { CircleCheck } from "lucide-react";
|
|
3
|
-
//#region src/components/toast/toast.d.ts
|
|
4
3
|
export type ToastActionOptions = React.ComponentPropsWithoutRef<'button'>;
|
|
5
4
|
export interface ToastOptions {
|
|
6
5
|
description?: ReactNode;
|
|
@@ -43,5 +42,4 @@ export interface ToasterProps {
|
|
|
43
42
|
* mounted, only the first one renders and the rest take over in order when it unmounts.
|
|
44
43
|
*/
|
|
45
44
|
declare function Toaster({ limit }: ToasterProps): import("react").JSX.Element | null;
|
|
46
|
-
//#endregion
|
|
47
45
|
export { Toaster };
|
|
@@ -6,7 +6,7 @@ import { useEffect, useState, useSyncExternalStore } from "react";
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { CircleAlert, CircleCheck, Info, LoaderCircle, TriangleAlert, X } from "lucide-react";
|
|
8
8
|
import { Toast } from "@base-ui/react/toast";
|
|
9
|
-
|
|
9
|
+
// src/components/toast/toast.tsx
|
|
10
10
|
const DEFAULT_TIMEOUT = {
|
|
11
11
|
success: 3e3,
|
|
12
12
|
info: 3e3,
|
|
@@ -22,18 +22,18 @@ const TOAST_ICON = {
|
|
|
22
22
|
loading: LoaderCircle
|
|
23
23
|
};
|
|
24
24
|
const TOAST_ICON_CLASSNAME = {
|
|
25
|
-
success: "
|
|
26
|
-
info: "
|
|
27
|
-
warning: "
|
|
28
|
-
error: "
|
|
29
|
-
loading: "
|
|
25
|
+
success: "text-success",
|
|
26
|
+
info: "text-info",
|
|
27
|
+
warning: "text-warning",
|
|
28
|
+
error: "text-destructive-text",
|
|
29
|
+
loading: "text-info"
|
|
30
30
|
};
|
|
31
31
|
const TOAST_BACKGROUND_CLASSNAME = {
|
|
32
|
-
success: "
|
|
33
|
-
info: "
|
|
34
|
-
warning: "
|
|
35
|
-
error: "
|
|
36
|
-
loading: "
|
|
32
|
+
success: "bg-success-subtle",
|
|
33
|
+
info: "bg-info-subtle",
|
|
34
|
+
warning: "bg-warning-subtle",
|
|
35
|
+
error: "bg-destructive-subtle",
|
|
36
|
+
loading: "bg-info-subtle"
|
|
37
37
|
};
|
|
38
38
|
const toastManager = Toast.createToastManager();
|
|
39
39
|
function isToastPromiseMessage(value) {
|
|
@@ -88,24 +88,24 @@ function ToastItem({ toast: toastObject }) {
|
|
|
88
88
|
const Icon = TOAST_ICON[type];
|
|
89
89
|
return /* @__PURE__ */ jsxs(Toast.Root, {
|
|
90
90
|
toast: toastObject,
|
|
91
|
-
className: cn("
|
|
91
|
+
className: cn("relative flex gap-2 rounded-md p-2 pr-8 text-sm text-foreground shadow-lg dark:ring-1 dark:ring-border data-limited:hidden", TOAST_BACKGROUND_CLASSNAME[type]),
|
|
92
92
|
"data-slot": "toast",
|
|
93
93
|
children: [/* @__PURE__ */ jsxs(Toast.Content, {
|
|
94
|
-
className: "
|
|
94
|
+
className: "flex flex-1 gap-2",
|
|
95
95
|
children: [/* @__PURE__ */ jsx(Icon, {
|
|
96
96
|
"aria-hidden": "true",
|
|
97
|
-
className: cn("
|
|
97
|
+
className: cn("size-4 shrink-0", TOAST_ICON_CLASSNAME[type], type === "loading" && "animate-spin")
|
|
98
98
|
}), /* @__PURE__ */ jsxs("div", {
|
|
99
|
-
className: "
|
|
99
|
+
className: "flex flex-1 flex-col gap-0.5",
|
|
100
100
|
children: [
|
|
101
|
-
/* @__PURE__ */ jsx(Toast.Title, { className: "
|
|
101
|
+
/* @__PURE__ */ jsx(Toast.Title, { className: "font-medium" }),
|
|
102
102
|
/* @__PURE__ */ jsx(Toast.Description, {}),
|
|
103
103
|
toastObject.actionProps && /* @__PURE__ */ jsx(Toast.Action, {
|
|
104
104
|
...toastObject.actionProps,
|
|
105
105
|
className: cn(buttonVariants({
|
|
106
106
|
variant: "outline",
|
|
107
107
|
size: "sm"
|
|
108
|
-
}), "
|
|
108
|
+
}), "mt-1 self-start", toastObject.actionProps.className)
|
|
109
109
|
})
|
|
110
110
|
]
|
|
111
111
|
})]
|
|
@@ -114,7 +114,7 @@ function ToastItem({ toast: toastObject }) {
|
|
|
114
114
|
className: cn(buttonVariants({
|
|
115
115
|
variant: "ghost",
|
|
116
116
|
size: "icon"
|
|
117
|
-
}), "
|
|
117
|
+
}), "absolute top-1 right-1 size-6"),
|
|
118
118
|
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
|
|
119
119
|
})]
|
|
120
120
|
});
|
|
@@ -155,11 +155,10 @@ function Toaster({ limit = 3 }) {
|
|
|
155
155
|
toastManager,
|
|
156
156
|
limit,
|
|
157
157
|
children: /* @__PURE__ */ jsx(Toast.Portal, { children: /* @__PURE__ */ jsx(Toast.Viewport, {
|
|
158
|
-
className: "
|
|
158
|
+
className: "fixed top-4 right-4 z-[1010] flex w-90 max-w-[calc(100vw-2rem)] flex-col gap-2",
|
|
159
159
|
"data-slot": "toaster",
|
|
160
160
|
children: /* @__PURE__ */ jsx(ToastList, {})
|
|
161
161
|
}) })
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
//#endregion
|
|
165
164
|
export { DEFAULT_TIMEOUT, TOAST_BACKGROUND_CLASSNAME, TOAST_ICON, TOAST_ICON_CLASSNAME, Toaster, toast, toastManager };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Tooltip } from "@base-ui/react/tooltip";
|
|
2
|
-
//#region src/components/tooltip/tooltip.d.ts
|
|
3
2
|
type WithClassName<P> = Omit<P, 'className'> & {
|
|
4
3
|
className?: string;
|
|
5
4
|
};
|
|
@@ -14,5 +13,4 @@ export type TooltipContentProps = WithClassName<Tooltip.Popup.Props> & {
|
|
|
14
13
|
align?: Tooltip.Positioner.Props['align'];
|
|
15
14
|
};
|
|
16
15
|
declare function TooltipContent({ className, side, sideOffset, align, children, ...props }: TooltipContentProps): import("react").JSX.Element;
|
|
17
|
-
//#endregion
|
|
18
16
|
export { Tooltip$1 as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|