@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
|
@@ -8,7 +8,7 @@ import { useCallback, useState } from "react";
|
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { CalendarIcon } from "lucide-react";
|
|
10
10
|
import { Field } from "@base-ui/react/field";
|
|
11
|
-
|
|
11
|
+
// src/components/date-picker/date-picker.tsx
|
|
12
12
|
function pad(value) {
|
|
13
13
|
return String(value).padStart(2, "0");
|
|
14
14
|
}
|
|
@@ -42,7 +42,7 @@ function withTimeString(date, timeString) {
|
|
|
42
42
|
function isSameRange(a, b) {
|
|
43
43
|
return a?.from?.getTime() === b?.from?.getTime() && a?.to?.getTime() === b?.to?.getTime();
|
|
44
44
|
}
|
|
45
|
-
const timeInputClassName = cn(controlSurface, controlFocus, "
|
|
45
|
+
const timeInputClassName = cn(controlSurface, controlFocus, "h-8 w-full px-3");
|
|
46
46
|
/** Popover trigger + single-selection Calendar, matching Input's control surface. */
|
|
47
47
|
function DatePicker(props) {
|
|
48
48
|
const { value, defaultValue, onValueChange, onOpenChange, onBlur, placeholder, disabled, showTime, formatDate, calendarProps, className } = props;
|
|
@@ -74,15 +74,15 @@ function DatePicker(props) {
|
|
|
74
74
|
render: /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
75
75
|
disabled,
|
|
76
76
|
onBlur,
|
|
77
|
-
className: cn(controlSurface, controlFocus, "
|
|
78
|
-
children: [/* @__PURE__ */ jsx(CalendarIcon, { className: "
|
|
79
|
-
className: cn("
|
|
77
|
+
className: cn(controlSurface, controlFocus, "flex h-8 items-center gap-2 px-3 text-left", className),
|
|
78
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, { className: "size-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: cn("min-w-0 flex-1 truncate", !currentValue && "text-muted-foreground"),
|
|
80
80
|
children: currentValue ? format(currentValue) : resolvedPlaceholder
|
|
81
81
|
})]
|
|
82
82
|
})
|
|
83
83
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
84
84
|
"aria-label": resolvedPlaceholder,
|
|
85
|
-
className: "
|
|
85
|
+
className: "w-auto",
|
|
86
86
|
children: /* @__PURE__ */ jsxs("div", {
|
|
87
87
|
"data-slot": "date-picker-content",
|
|
88
88
|
children: [/* @__PURE__ */ jsx(Calendar, {
|
|
@@ -98,7 +98,7 @@ function DatePicker(props) {
|
|
|
98
98
|
value: currentValue ? timeInputValue(currentValue) : "",
|
|
99
99
|
disabled: !currentValue,
|
|
100
100
|
onChange: (event) => handleTimeChange(event.target.value),
|
|
101
|
-
className: cn(timeInputClassName, "
|
|
101
|
+
className: cn(timeInputClassName, "mt-3"),
|
|
102
102
|
"data-slot": "date-picker-time"
|
|
103
103
|
})]
|
|
104
104
|
})
|
|
@@ -171,22 +171,22 @@ function DateRangePicker(props) {
|
|
|
171
171
|
render: /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
172
172
|
disabled,
|
|
173
173
|
onBlur,
|
|
174
|
-
className: cn(controlSurface, controlFocus, "
|
|
175
|
-
children: [/* @__PURE__ */ jsx(CalendarIcon, { className: "
|
|
176
|
-
className: cn("
|
|
174
|
+
className: cn(controlSurface, controlFocus, "flex h-8 items-center gap-2 px-3 text-left", className),
|
|
175
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, { className: "size-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ jsx("span", {
|
|
176
|
+
className: cn("min-w-0 flex-1 truncate", !displayText && "text-muted-foreground"),
|
|
177
177
|
children: displayText ?? resolvedPlaceholder
|
|
178
178
|
})]
|
|
179
179
|
})
|
|
180
180
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
181
181
|
"aria-label": resolvedPlaceholder,
|
|
182
|
-
className: "
|
|
182
|
+
className: "w-auto",
|
|
183
183
|
children: /* @__PURE__ */ jsxs("div", {
|
|
184
|
-
className: "
|
|
184
|
+
className: "flex gap-3",
|
|
185
185
|
"data-slot": "date-range-picker-content",
|
|
186
186
|
children: [presets && presets.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
187
187
|
role: "group",
|
|
188
188
|
"aria-label": messages.datePicker.presetsLabel,
|
|
189
|
-
className: "
|
|
189
|
+
className: "flex shrink-0 flex-col gap-1 border-r border-border pr-3",
|
|
190
190
|
"data-slot": "date-range-picker-presets",
|
|
191
191
|
children: presets.map((preset, index) => {
|
|
192
192
|
const isSelected = presetSelection?.index === index && presetSelection.label === preset.label && isSameRange(presetSelection.range, currentValue);
|
|
@@ -194,7 +194,7 @@ function DateRangePicker(props) {
|
|
|
194
194
|
type: "button",
|
|
195
195
|
"aria-pressed": isSelected,
|
|
196
196
|
onClick: () => handlePresetClick(preset, index),
|
|
197
|
-
className: cn("
|
|
197
|
+
className: cn("h-8 whitespace-nowrap rounded-sm px-3 text-left text-sm text-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/40", isSelected && "bg-accent font-medium text-primary-text"),
|
|
198
198
|
"data-slot": "date-range-picker-preset",
|
|
199
199
|
children: preset.label
|
|
200
200
|
}, index);
|
|
@@ -207,7 +207,7 @@ function DateRangePicker(props) {
|
|
|
207
207
|
selected: currentValue,
|
|
208
208
|
onSelect: handleSelect
|
|
209
209
|
}), showTime && /* @__PURE__ */ jsxs("div", {
|
|
210
|
-
className: "
|
|
210
|
+
className: "mt-3 flex gap-2",
|
|
211
211
|
children: [/* @__PURE__ */ jsx("input", {
|
|
212
212
|
type: "time",
|
|
213
213
|
step: "1",
|
|
@@ -232,5 +232,4 @@ function DateRangePicker(props) {
|
|
|
232
232
|
})]
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
//#endregion
|
|
236
235
|
export { DatePicker, DateRangePicker };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const descriptionListVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "outline" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export type DescriptionListProps = Omit<ComponentProps<'dl'>, 'className'> & VariantProps<typeof descriptionListVariants> & {
|
|
7
|
+
className?: string;
|
|
8
|
+
columns?: number;
|
|
9
|
+
};
|
|
10
|
+
export type DescriptionListItemProps = Omit<ComponentProps<'div'>, 'className'> & {
|
|
11
|
+
className?: string;
|
|
12
|
+
colSpan?: number;
|
|
13
|
+
};
|
|
14
|
+
export type DescriptionListLabelProps = Omit<ComponentProps<'dt'>, 'className'> & {
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
export type DescriptionListValueProps = Omit<ComponentProps<'dd'>, 'className'> & {
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
declare function DescriptionList({ className, variant, columns, style, ...props }: DescriptionListProps): import("react").JSX.Element;
|
|
21
|
+
declare function DescriptionListItem({ className, colSpan, style, ...props }: DescriptionListItemProps): import("react").JSX.Element;
|
|
22
|
+
declare function DescriptionListLabel({ className, ...props }: DescriptionListLabelProps): import("react").JSX.Element;
|
|
23
|
+
declare function DescriptionListValue({ className, ...props }: DescriptionListValueProps): import("react").JSX.Element;
|
|
24
|
+
export { DescriptionList, DescriptionListItem, DescriptionListLabel, DescriptionListValue, descriptionListVariants };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/cn.js";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
// src/components/description-list/description-list.tsx
|
|
7
|
+
const descriptionListVariants = cva("grid w-full grid-cols-[repeat(var(--description-list-columns,1),var(--description-list-label-width,160px)_minmax(0,1fr))] text-sm leading-5", {
|
|
8
|
+
variants: { variant: {
|
|
9
|
+
default: "",
|
|
10
|
+
outline: "border-t border-l border-border"
|
|
11
|
+
} },
|
|
12
|
+
defaultVariants: { variant: "default" }
|
|
13
|
+
});
|
|
14
|
+
const DescriptionListContext = createContext({
|
|
15
|
+
variant: "default",
|
|
16
|
+
columns: 1
|
|
17
|
+
});
|
|
18
|
+
function normalizeColumns(value) {
|
|
19
|
+
if (value === void 0 || !Number.isFinite(value)) return 1;
|
|
20
|
+
return Math.max(1, Math.floor(value));
|
|
21
|
+
}
|
|
22
|
+
function clampColSpan(value, columns) {
|
|
23
|
+
if (value === void 0 || !Number.isFinite(value) || value < 1) return 1;
|
|
24
|
+
return Math.min(columns, Math.floor(value));
|
|
25
|
+
}
|
|
26
|
+
const descriptionListLabelVariants = cva("col-start-1 min-w-0 font-normal text-muted-foreground", {
|
|
27
|
+
variants: { variant: {
|
|
28
|
+
default: "py-2 pr-4",
|
|
29
|
+
outline: "border-r border-b border-border bg-table-header px-4 py-3"
|
|
30
|
+
} },
|
|
31
|
+
defaultVariants: { variant: "default" }
|
|
32
|
+
});
|
|
33
|
+
const descriptionListValueVariants = cva("col-[2/-1] m-0 min-w-0 wrap-anywhere text-foreground", {
|
|
34
|
+
variants: { variant: {
|
|
35
|
+
default: "py-2",
|
|
36
|
+
outline: "border-r border-b border-border px-2 py-3"
|
|
37
|
+
} },
|
|
38
|
+
defaultVariants: { variant: "default" }
|
|
39
|
+
});
|
|
40
|
+
function DescriptionList({ className, variant, columns, style, ...props }) {
|
|
41
|
+
const resolved = variant ?? "default";
|
|
42
|
+
const count = normalizeColumns(columns);
|
|
43
|
+
return /* @__PURE__ */ jsx(DescriptionListContext.Provider, {
|
|
44
|
+
value: {
|
|
45
|
+
variant: resolved,
|
|
46
|
+
columns: count
|
|
47
|
+
},
|
|
48
|
+
children: /* @__PURE__ */ jsx("dl", {
|
|
49
|
+
className: cn(descriptionListVariants({ variant: resolved }), className),
|
|
50
|
+
"data-variant": resolved,
|
|
51
|
+
style: {
|
|
52
|
+
"--description-list-columns": count,
|
|
53
|
+
...style
|
|
54
|
+
},
|
|
55
|
+
...props,
|
|
56
|
+
"data-slot": "description-list"
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function DescriptionListItem({ className, colSpan, style, ...props }) {
|
|
61
|
+
const { columns } = useContext(DescriptionListContext);
|
|
62
|
+
return /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: cn("grid grid-cols-subgrid", className),
|
|
64
|
+
style: {
|
|
65
|
+
gridColumn: `span ${2 * clampColSpan(colSpan, columns)}`,
|
|
66
|
+
...style
|
|
67
|
+
},
|
|
68
|
+
...props,
|
|
69
|
+
"data-slot": "description-list-item"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function DescriptionListLabel({ className, ...props }) {
|
|
73
|
+
const { variant } = useContext(DescriptionListContext);
|
|
74
|
+
return /* @__PURE__ */ jsx("dt", {
|
|
75
|
+
className: cn(descriptionListLabelVariants({ variant }), className),
|
|
76
|
+
...props,
|
|
77
|
+
"data-slot": "description-list-label"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function DescriptionListValue({ className, ...props }) {
|
|
81
|
+
const { variant } = useContext(DescriptionListContext);
|
|
82
|
+
return /* @__PURE__ */ jsx("dd", {
|
|
83
|
+
className: cn(descriptionListValueVariants({ variant }), className),
|
|
84
|
+
...props,
|
|
85
|
+
"data-slot": "description-list-value"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export { DescriptionList, DescriptionListItem, DescriptionListLabel, DescriptionListValue, descriptionListVariants };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
-
//#region src/components/dialog/dialog.d.ts
|
|
4
3
|
type WithClassName<P> = Omit<P, 'className'> & {
|
|
5
4
|
className?: string;
|
|
6
5
|
};
|
|
@@ -26,5 +25,4 @@ export type DialogFooterProps = ComponentProps<'div'>;
|
|
|
26
25
|
declare function DialogFooter({ className, ...props }: DialogFooterProps): import("react").JSX.Element;
|
|
27
26
|
export type DialogCloseProps = WithClassName<Dialog.Close.Props>;
|
|
28
27
|
declare function DialogClose({ className, ...props }: DialogCloseProps): import("react").JSX.Element;
|
|
29
|
-
//#endregion
|
|
30
28
|
export { Dialog$1 as Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
@@ -6,7 +6,7 @@ import { createContext, useContext } from "react";
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { XIcon } from "lucide-react";
|
|
8
8
|
import { Dialog } from "@base-ui/react/dialog";
|
|
9
|
-
|
|
9
|
+
// src/components/dialog/dialog.tsx
|
|
10
10
|
const DialogModalContext = createContext(true);
|
|
11
11
|
function Dialog$1({ modal = true, ...props }) {
|
|
12
12
|
return /* @__PURE__ */ jsx(DialogModalContext.Provider, {
|
|
@@ -25,22 +25,22 @@ function DialogTrigger({ className, ...props }) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
const dialogContentSizeClassName = {
|
|
28
|
-
sm: "
|
|
29
|
-
md: "
|
|
30
|
-
lg: "
|
|
28
|
+
sm: "max-w-md",
|
|
29
|
+
md: "max-w-xl",
|
|
30
|
+
lg: "max-w-3xl"
|
|
31
31
|
};
|
|
32
32
|
function DialogContent({ className, showCloseButton = true, closeLabel, size = "md", children, ...props }) {
|
|
33
33
|
const messages = useMessages();
|
|
34
34
|
const showBackdrop = useContext(DialogModalContext) === true;
|
|
35
35
|
return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [showBackdrop && /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
36
|
-
className: "
|
|
36
|
+
className: "fixed inset-0 z-50 bg-overlay transition-opacity duration-150 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0",
|
|
37
37
|
"data-slot": "dialog-backdrop"
|
|
38
38
|
}), /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
39
|
-
className: cn("
|
|
39
|
+
className: cn("fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100vh-4rem)] w-[calc(100vw-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-md bg-background text-foreground shadow-lg dark:ring-1 dark:ring-border outline-none transition-[opacity,scale] duration-150 motion-reduce:transition-none data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0", dialogContentSizeClassName[size], className),
|
|
40
40
|
...props,
|
|
41
41
|
"data-slot": "dialog-content",
|
|
42
42
|
children: [showCloseButton && /* @__PURE__ */ jsx(Dialog.Close, {
|
|
43
|
-
className: "
|
|
43
|
+
className: "absolute top-3 right-4",
|
|
44
44
|
render: /* @__PURE__ */ jsx(Button, {
|
|
45
45
|
variant: "ghost",
|
|
46
46
|
size: "icon"
|
|
@@ -52,35 +52,35 @@ function DialogContent({ className, showCloseButton = true, closeLabel, size = "
|
|
|
52
52
|
}
|
|
53
53
|
function DialogHeader({ className, ...props }) {
|
|
54
54
|
return /* @__PURE__ */ jsx("div", {
|
|
55
|
-
className: cn("
|
|
55
|
+
className: cn("flex flex-col gap-1 border-b border-border p-4 pr-12", className),
|
|
56
56
|
...props,
|
|
57
57
|
"data-slot": "dialog-header"
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
function DialogTitle({ className, ...props }) {
|
|
61
61
|
return /* @__PURE__ */ jsx(Dialog.Title, {
|
|
62
|
-
className: cn("
|
|
62
|
+
className: cn("text-lg font-medium text-foreground", className),
|
|
63
63
|
...props,
|
|
64
64
|
"data-slot": "dialog-title"
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
function DialogDescription({ className, ...props }) {
|
|
68
68
|
return /* @__PURE__ */ jsx(Dialog.Description, {
|
|
69
|
-
className: cn("
|
|
69
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
70
70
|
...props,
|
|
71
71
|
"data-slot": "dialog-description"
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
function DialogBody({ className, ...props }) {
|
|
75
75
|
return /* @__PURE__ */ jsx("div", {
|
|
76
|
-
className: cn("
|
|
76
|
+
className: cn("max-h-[596px] overflow-y-auto p-6", className),
|
|
77
77
|
...props,
|
|
78
78
|
"data-slot": "dialog-body"
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
function DialogFooter({ className, ...props }) {
|
|
82
82
|
return /* @__PURE__ */ jsx("div", {
|
|
83
|
-
className: cn("
|
|
83
|
+
className: cn("flex items-center justify-end gap-3 border-t border-border px-6 py-4", className),
|
|
84
84
|
...props,
|
|
85
85
|
"data-slot": "dialog-footer"
|
|
86
86
|
});
|
|
@@ -92,5 +92,4 @@ function DialogClose({ className, ...props }) {
|
|
|
92
92
|
"data-slot": "dialog-close"
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
//#endregion
|
|
96
95
|
export { Dialog$1 as Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import { Drawer } from "@base-ui/react/drawer";
|
|
3
|
-
//#region src/components/drawer/drawer.d.ts
|
|
4
3
|
type WithClassName<P> = Omit<P, 'className'> & {
|
|
5
4
|
className?: string;
|
|
6
5
|
};
|
|
@@ -26,5 +25,4 @@ export type DrawerFooterProps = ComponentProps<'div'>;
|
|
|
26
25
|
declare function DrawerFooter({ className, ...props }: DrawerFooterProps): import("react").JSX.Element;
|
|
27
26
|
export type DrawerCloseProps = WithClassName<Drawer.Close.Props>;
|
|
28
27
|
declare function DrawerClose({ className, ...props }: DrawerCloseProps): import("react").JSX.Element;
|
|
29
|
-
//#endregion
|
|
30
28
|
export { Drawer$1 as Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger };
|
|
@@ -6,7 +6,7 @@ import { createContext, useContext } from "react";
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { XIcon } from "lucide-react";
|
|
8
8
|
import { Drawer } from "@base-ui/react/drawer";
|
|
9
|
-
|
|
9
|
+
// src/components/drawer/drawer.tsx
|
|
10
10
|
const DrawerModalContext = createContext(true);
|
|
11
11
|
function Drawer$1({ swipeDirection = "right", modal = true, ...props }) {
|
|
12
12
|
return /* @__PURE__ */ jsx(DrawerModalContext.Provider, {
|
|
@@ -26,26 +26,26 @@ function DrawerTrigger({ className, ...props }) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
const drawerContentSizeClassName = {
|
|
29
|
-
md: "
|
|
30
|
-
lg: "
|
|
31
|
-
full: "
|
|
29
|
+
md: "w-[588px] max-w-[100vw]",
|
|
30
|
+
lg: "w-[748px] max-w-[100vw]",
|
|
31
|
+
full: "w-[90vw] max-w-[100vw]"
|
|
32
32
|
};
|
|
33
33
|
function DrawerContent({ className, showCloseButton = true, closeLabel, size = "md", children, ...props }) {
|
|
34
34
|
const messages = useMessages();
|
|
35
35
|
const isNonModal = useContext(DrawerModalContext) !== true;
|
|
36
36
|
const showBackdrop = !isNonModal;
|
|
37
37
|
return /* @__PURE__ */ jsxs(Drawer.Portal, { children: [showBackdrop && /* @__PURE__ */ jsx(Drawer.Backdrop, {
|
|
38
|
-
className: "
|
|
38
|
+
className: "fixed inset-0 z-50 bg-overlay transition-opacity duration-150 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0",
|
|
39
39
|
"data-slot": "drawer-backdrop"
|
|
40
40
|
}), /* @__PURE__ */ jsx(Drawer.Viewport, {
|
|
41
|
-
className: cn("
|
|
41
|
+
className: cn("fixed inset-0 z-50", isNonModal && "pointer-events-none"),
|
|
42
42
|
"data-slot": "drawer-viewport",
|
|
43
43
|
children: /* @__PURE__ */ jsxs(Drawer.Popup, {
|
|
44
|
-
className: cn("
|
|
44
|
+
className: cn("fixed inset-y-0 right-0 flex h-full flex-col bg-background text-foreground shadow-lg dark:ring-1 dark:ring-border outline-none transition-transform duration-200 motion-reduce:transition-none data-ending-style:translate-x-full data-starting-style:translate-x-full", isNonModal && "pointer-events-auto", drawerContentSizeClassName[size], className),
|
|
45
45
|
...props,
|
|
46
46
|
"data-slot": "drawer-content",
|
|
47
47
|
children: [showCloseButton && /* @__PURE__ */ jsx(Drawer.Close, {
|
|
48
|
-
className: "
|
|
48
|
+
className: "absolute top-3 right-4",
|
|
49
49
|
render: /* @__PURE__ */ jsx(Button, {
|
|
50
50
|
variant: "ghost",
|
|
51
51
|
size: "icon"
|
|
@@ -58,35 +58,35 @@ function DrawerContent({ className, showCloseButton = true, closeLabel, size = "
|
|
|
58
58
|
}
|
|
59
59
|
function DrawerHeader({ className, ...props }) {
|
|
60
60
|
return /* @__PURE__ */ jsx("div", {
|
|
61
|
-
className: cn("
|
|
61
|
+
className: cn("flex flex-col gap-1 border-b border-border px-6 py-4 pr-12", className),
|
|
62
62
|
...props,
|
|
63
63
|
"data-slot": "drawer-header"
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
function DrawerTitle({ className, ...props }) {
|
|
67
67
|
return /* @__PURE__ */ jsx(Drawer.Title, {
|
|
68
|
-
className: cn("
|
|
68
|
+
className: cn("text-lg font-semibold text-foreground", className),
|
|
69
69
|
...props,
|
|
70
70
|
"data-slot": "drawer-title"
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
function DrawerDescription({ className, ...props }) {
|
|
74
74
|
return /* @__PURE__ */ jsx(Drawer.Description, {
|
|
75
|
-
className: cn("
|
|
75
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
76
76
|
...props,
|
|
77
77
|
"data-slot": "drawer-description"
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function DrawerBody({ className, ...props }) {
|
|
81
81
|
return /* @__PURE__ */ jsx("div", {
|
|
82
|
-
className: cn("
|
|
82
|
+
className: cn("flex-1 overflow-y-auto px-6 py-4", className),
|
|
83
83
|
...props,
|
|
84
84
|
"data-slot": "drawer-body"
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
function DrawerFooter({ className, ...props }) {
|
|
88
88
|
return /* @__PURE__ */ jsx("div", {
|
|
89
|
-
className: cn("
|
|
89
|
+
className: cn("flex items-center justify-end gap-4 border-t border-border px-6 py-3", className),
|
|
90
90
|
...props,
|
|
91
91
|
"data-slot": "drawer-footer"
|
|
92
92
|
});
|
|
@@ -98,5 +98,4 @@ function DrawerClose({ className, ...props }) {
|
|
|
98
98
|
"data-slot": "drawer-close"
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
//#endregion
|
|
102
101
|
export { Drawer$1 as Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
|
-
//#region src/components/empty/empty.d.ts
|
|
4
3
|
declare const emptyMediaVariants: (props?: ({
|
|
5
4
|
variant?: "default" | "icon" | null | undefined;
|
|
6
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -16,5 +15,4 @@ declare function EmptyMedia({ variant, className, ...props }: EmptyMediaProps):
|
|
|
16
15
|
declare function EmptyTitle({ className, ...props }: EmptyTitleProps): import("react").JSX.Element;
|
|
17
16
|
declare function EmptyDescription({ className, ...props }: EmptyDescriptionProps): import("react").JSX.Element;
|
|
18
17
|
declare function EmptyContent({ className, ...props }: EmptyContentProps): import("react").JSX.Element;
|
|
19
|
-
//#endregion
|
|
20
18
|
export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, emptyMediaVariants };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cn } from "../../lib/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
|
-
|
|
5
|
-
const emptyVariants = cva("
|
|
6
|
-
const emptyMediaVariants = cva("
|
|
4
|
+
// src/components/empty/empty.tsx
|
|
5
|
+
const emptyVariants = cva("flex w-full min-w-0 flex-col items-center justify-center gap-3 rounded-sm border-[3px] border-dashed border-border px-4 py-4 text-center");
|
|
6
|
+
const emptyMediaVariants = cva("flex shrink-0 items-center justify-center", {
|
|
7
7
|
variants: { variant: {
|
|
8
|
-
default: "
|
|
9
|
-
icon: "
|
|
8
|
+
default: "size-[76px] [&_img]:size-full [&_img]:object-contain [&_svg]:size-full",
|
|
9
|
+
icon: "size-10 rounded-sm bg-muted text-foreground [&_svg:not([class*=size-])]:size-5"
|
|
10
10
|
} },
|
|
11
11
|
defaultVariants: { variant: "default" }
|
|
12
12
|
});
|
|
@@ -19,7 +19,7 @@ function Empty({ className, ...props }) {
|
|
|
19
19
|
}
|
|
20
20
|
function EmptyHeader({ className, ...props }) {
|
|
21
21
|
return /* @__PURE__ */ jsx("div", {
|
|
22
|
-
className: cn("
|
|
22
|
+
className: cn("flex max-w-sm flex-col items-center gap-1", className),
|
|
23
23
|
...props,
|
|
24
24
|
"data-slot": "empty-header"
|
|
25
25
|
});
|
|
@@ -34,24 +34,23 @@ function EmptyMedia({ variant = "default", className, ...props }) {
|
|
|
34
34
|
}
|
|
35
35
|
function EmptyTitle({ className, ...props }) {
|
|
36
36
|
return /* @__PURE__ */ jsx("div", {
|
|
37
|
-
className: cn("
|
|
37
|
+
className: cn("text-base font-medium text-foreground", className),
|
|
38
38
|
...props,
|
|
39
39
|
"data-slot": "empty-title"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
function EmptyDescription({ className, ...props }) {
|
|
43
43
|
return /* @__PURE__ */ jsx("div", {
|
|
44
|
-
className: cn("
|
|
44
|
+
className: cn("text-xs text-muted-foreground", className),
|
|
45
45
|
...props,
|
|
46
46
|
"data-slot": "empty-description"
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
function EmptyContent({ className, ...props }) {
|
|
50
50
|
return /* @__PURE__ */ jsx("div", {
|
|
51
|
-
className: cn("
|
|
51
|
+
className: cn("flex max-w-sm flex-col items-center gap-2", className),
|
|
52
52
|
...props,
|
|
53
53
|
"data-slot": "empty-content"
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
//#endregion
|
|
57
56
|
export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, emptyMediaVariants };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Field } from "@base-ui/react/field";
|
|
2
2
|
import { Fieldset } from "@base-ui/react/fieldset";
|
|
3
|
-
//#region src/components/field/field.d.ts
|
|
4
3
|
type WithClassName<P> = Omit<P, 'className'> & {
|
|
5
4
|
className?: string;
|
|
6
5
|
};
|
|
@@ -16,5 +15,4 @@ declare function FieldDescription({ className, ...props }: FieldDescriptionProps
|
|
|
16
15
|
declare function FieldError({ className, ...props }: FieldErrorProps): import("react").JSX.Element;
|
|
17
16
|
declare function Fieldset$1({ className, ...props }: FieldsetProps): import("react").JSX.Element;
|
|
18
17
|
declare function FieldsetLegend({ className, ...props }: FieldsetLegendProps): import("react").JSX.Element;
|
|
19
|
-
//#endregion
|
|
20
18
|
export { Field$1 as Field, FieldDescription, FieldError, FieldLabel, Fieldset$1 as Fieldset, FieldsetLegend };
|
|
@@ -3,48 +3,47 @@ import { cn } from "../../lib/cn.js";
|
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Field } from "@base-ui/react/field";
|
|
5
5
|
import { Fieldset } from "@base-ui/react/fieldset";
|
|
6
|
-
|
|
6
|
+
// src/components/field/field.tsx
|
|
7
7
|
function Field$1({ className, ...props }) {
|
|
8
8
|
return /* @__PURE__ */ jsx(Field.Root, {
|
|
9
|
-
className: cn("
|
|
9
|
+
className: cn("flex flex-col gap-1.5", className),
|
|
10
10
|
...props,
|
|
11
11
|
"data-slot": "field"
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
function FieldLabel({ className, ...props }) {
|
|
15
15
|
return /* @__PURE__ */ jsx(Field.Label, {
|
|
16
|
-
className: cn("
|
|
16
|
+
className: cn("inline-flex items-center gap-2 text-sm leading-5 font-medium text-foreground data-disabled:text-muted-foreground", className),
|
|
17
17
|
...props,
|
|
18
18
|
"data-slot": "field-label"
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
function FieldDescription({ className, ...props }) {
|
|
22
22
|
return /* @__PURE__ */ jsx(Field.Description, {
|
|
23
|
-
className: cn("
|
|
23
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
24
24
|
...props,
|
|
25
25
|
"data-slot": "field-description"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
function FieldError({ className, ...props }) {
|
|
29
29
|
return /* @__PURE__ */ jsx(Field.Error, {
|
|
30
|
-
className: cn("
|
|
30
|
+
className: cn("text-sm text-destructive-text", className),
|
|
31
31
|
...props,
|
|
32
32
|
"data-slot": "field-error"
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
function Fieldset$1({ className, ...props }) {
|
|
36
36
|
return /* @__PURE__ */ jsx(Fieldset.Root, {
|
|
37
|
-
className: cn("
|
|
37
|
+
className: cn("m-0 flex flex-col gap-3 border-0 p-0", className),
|
|
38
38
|
...props,
|
|
39
39
|
"data-slot": "fieldset"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
function FieldsetLegend({ className, ...props }) {
|
|
43
43
|
return /* @__PURE__ */ jsx(Fieldset.Legend, {
|
|
44
|
-
className: cn("
|
|
44
|
+
className: cn("mb-1 text-sm font-medium text-foreground", className),
|
|
45
45
|
...props,
|
|
46
46
|
"data-slot": "fieldset-legend"
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
//#endregion
|
|
50
49
|
export { Field$1 as Field, FieldDescription, FieldError, FieldLabel, Fieldset$1 as Fieldset, FieldsetLegend };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export type LabeledFieldLayout = 'stacked' | 'inline-end' | 'inline-start';
|
|
3
|
+
export interface LabeledFieldProps {
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
/** Info icon next to the label that shows this content in a tooltip. */
|
|
7
|
+
labelTooltip?: ReactNode;
|
|
8
|
+
/** Appends the "Optional" marker to the label. */
|
|
9
|
+
optional?: boolean;
|
|
10
|
+
optionalLabel?: string;
|
|
11
|
+
moreInfoLabel?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
layout?: LabeledFieldLayout;
|
|
14
|
+
/**
|
|
15
|
+
* Renders a fieldset whose legend is the label, for a group of controls such as radio
|
|
16
|
+
* buttons. Only the stacked layout applies to a group.
|
|
17
|
+
*/
|
|
18
|
+
group?: boolean;
|
|
19
|
+
/** Name of the field, given to the control inside it. */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Marks the field and its control invalid and shows the errors. */
|
|
22
|
+
invalid?: boolean;
|
|
23
|
+
touched?: boolean;
|
|
24
|
+
dirty?: boolean;
|
|
25
|
+
/** Messages shown under the field while it is invalid. */
|
|
26
|
+
errors?: readonly string[];
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A form row: label, optional marker, label tooltip, control, description and errors. It
|
|
31
|
+
* takes the field state as props, so any form library or plain React state can drive it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function LabeledField({ label, description, labelTooltip, optional, optionalLabel, moreInfoLabel, className, layout, group, name, invalid, touched, dirty, errors, children }: LabeledFieldProps): import("react").JSX.Element;
|