@ggem-farming/ui 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +15 -2
- package/dist/accordion/accordion.d.ts +41 -0
- package/dist/accordion/accordion.js +89 -0
- package/dist/avatar/avatar.d.ts +20 -0
- package/dist/avatar/avatar.js +38 -0
- package/dist/badge/badge.d.ts +16 -0
- package/dist/badge/badge.js +85 -0
- package/dist/breadcrumbs/breadcrumbs.d.ts +19 -0
- package/dist/breadcrumbs/breadcrumbs.js +44 -0
- package/dist/button/button.d.ts +16 -0
- package/dist/button/button.js +49 -0
- package/dist/button/icon-button.d.ts +17 -0
- package/dist/button/icon-button.js +33 -0
- package/dist/card/card.d.ts +16 -0
- package/dist/card/card.js +56 -0
- package/dist/checkbox/checkbox.d.ts +15 -0
- package/dist/checkbox/checkbox.js +47 -0
- package/dist/combobox/combobox.d.ts +37 -0
- package/dist/combobox/combobox.js +155 -0
- package/dist/command/command-palette.d.ts +50 -0
- package/dist/command/command-palette.js +170 -0
- package/dist/command/kbd.d.ts +6 -0
- package/dist/command/kbd.js +16 -0
- package/dist/data/data-table.d.ts +105 -0
- package/dist/data/data-table.js +269 -0
- package/dist/data/export-button.d.ts +19 -0
- package/dist/data/export-button.js +34 -0
- package/dist/data/filter-bar.d.ts +54 -0
- package/dist/data/filter-bar.js +187 -0
- package/dist/data/pagination.d.ts +13 -0
- package/dist/data/pagination.js +84 -0
- package/dist/data/selection-bar.d.ts +21 -0
- package/dist/data/selection-bar.js +31 -0
- package/dist/date/date-input.d.ts +41 -0
- package/dist/date/date-input.js +71 -0
- package/dist/dialog/confirm-dialog.d.ts +24 -0
- package/dist/dialog/confirm-dialog.js +77 -0
- package/dist/dialog/dialog.d.ts +46 -0
- package/dist/dialog/dialog.js +102 -0
- package/dist/dialog/form-panel.d.ts +28 -0
- package/dist/dialog/form-panel.js +51 -0
- package/dist/feedback/alert.d.ts +29 -0
- package/dist/feedback/alert.js +70 -0
- package/dist/feedback/progress.d.ts +25 -0
- package/dist/feedback/progress.js +54 -0
- package/dist/feedback/toaster.d.ts +7 -0
- package/dist/feedback/toaster.js +35 -0
- package/dist/field/field.d.ts +40 -0
- package/dist/field/field.js +83 -0
- package/dist/field/text-field.d.ts +9 -0
- package/dist/field/text-field.js +16 -0
- package/dist/file-input/file-input.d.ts +26 -0
- package/dist/file-input/file-input.js +149 -0
- package/dist/fonts.css +3 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +43 -0
- package/dist/input/input.d.ts +13 -0
- package/dist/input/input.js +25 -0
- package/dist/layout/app-shell.d.ts +100 -0
- package/dist/layout/app-shell.js +433 -0
- package/dist/layout/page.d.ts +20 -0
- package/dist/layout/page.js +53 -0
- package/dist/layout/record.d.ts +39 -0
- package/dist/layout/record.js +79 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +18 -0
- package/dist/lib/control.js +14 -0
- package/dist/lib/popup.js +20 -0
- package/dist/menu/menu.d.ts +45 -0
- package/dist/menu/menu.js +85 -0
- package/dist/popover/popover.d.ts +22 -0
- package/dist/popover/popover.js +39 -0
- package/dist/radio/radio.d.ts +12 -0
- package/dist/radio/radio.js +25 -0
- package/dist/select/select.d.ts +23 -0
- package/dist/select/select.js +66 -0
- package/dist/separator/separator.d.ts +6 -0
- package/dist/separator/separator.js +14 -0
- package/dist/stat/stat.d.ts +28 -0
- package/dist/stat/stat.js +55 -0
- package/dist/state/states.d.ts +36 -0
- package/dist/state/states.js +108 -0
- package/dist/styles.css +42 -0
- package/dist/switch/switch.d.ts +9 -0
- package/dist/switch/switch.js +18 -0
- package/dist/table/table.d.ts +28 -0
- package/dist/table/table.js +72 -0
- package/dist/tabs/tabs.d.ts +26 -0
- package/dist/tabs/tabs.js +45 -0
- package/dist/tooltip/tooltip.d.ts +17 -0
- package/dist/tooltip/tooltip.js +27 -0
- package/package.json +57 -4
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { LoaderCircle } from "lucide-react";
|
|
4
|
+
import { Progress } from "@base-ui/react/progress";
|
|
5
|
+
// src/feedback/progress.tsx
|
|
6
|
+
const indicatorTone = {
|
|
7
|
+
brand: "bg-brand",
|
|
8
|
+
success: "bg-success",
|
|
9
|
+
warning: "bg-warning",
|
|
10
|
+
danger: "bg-danger"
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A horizontal bar for a task's progress. Pass `value={null}` while the amount is unknown.
|
|
14
|
+
* For a share of a target (not a running task), the same bar works: say so in the label.
|
|
15
|
+
*/
|
|
16
|
+
function ProgressBar({ label, hideLabel = false, showValue = false, tone = "brand", value, className, ...props }) {
|
|
17
|
+
return /* @__PURE__ */ jsxs(Progress.Root, {
|
|
18
|
+
value,
|
|
19
|
+
className: cn("grid gap-1.5", className),
|
|
20
|
+
...props,
|
|
21
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: cn("flex items-center justify-between gap-3 text-sm", hideLabel && "sr-only"),
|
|
23
|
+
children: [/* @__PURE__ */ jsx(Progress.Label, {
|
|
24
|
+
className: "font-medium",
|
|
25
|
+
children: label
|
|
26
|
+
}), showValue && value !== null && /* @__PURE__ */ jsx(Progress.Value, { className: "text-fg-muted tabular-nums" })]
|
|
27
|
+
}), /* @__PURE__ */ jsx(Progress.Track, {
|
|
28
|
+
className: "h-1.5 overflow-hidden rounded-full bg-surface-hover",
|
|
29
|
+
children: /* @__PURE__ */ jsx(Progress.Indicator, { className: cn("block h-full rounded-full transition-[width] duration-normal ease-standard", indicatorTone[tone], "data-indeterminate:w-1/3 data-indeterminate:animate-[ggem-progress_1.2s_ease-in-out_infinite]", "motion-reduce:data-indeterminate:w-full motion-reduce:data-indeterminate:animate-none") })
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const spinnerSize = {
|
|
34
|
+
sm: "size-4",
|
|
35
|
+
md: "size-5",
|
|
36
|
+
lg: "size-8"
|
|
37
|
+
};
|
|
38
|
+
/** A small busy indicator for a button or a region that is waiting. Prefer Skeleton for loads. */
|
|
39
|
+
function Spinner({ label, size = "md", className }) {
|
|
40
|
+
const icon = /* @__PURE__ */ jsx(LoaderCircle, {
|
|
41
|
+
className: cn("shrink-0 animate-spin text-fg-muted motion-reduce:animate-none", spinnerSize[size], className),
|
|
42
|
+
"aria-hidden": true
|
|
43
|
+
});
|
|
44
|
+
if (!label) return icon;
|
|
45
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
46
|
+
role: "status",
|
|
47
|
+
className: "inline-flex",
|
|
48
|
+
children: [icon, /* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: "sr-only",
|
|
50
|
+
children: label
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export { ProgressBar, Spinner };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ToasterProps as ToasterProps$1 } from "sonner";
|
|
2
|
+
export type ToasterProps = Pick<ToasterProps$1, 'position' | 'visibleToasts' | 'duration'>;
|
|
3
|
+
/**
|
|
4
|
+
* Toast notifications (sonner) in the kit's look. Mount once at the app root, then call
|
|
5
|
+
* `toast.success(…)`, `toast.error(…)` etc. from `sonner`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Toaster({ position, visibleToasts, duration }: ToasterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Toaster as Toaster$1 } from "sonner";
|
|
3
|
+
// src/feedback/toaster.tsx
|
|
4
|
+
const classNames = {
|
|
5
|
+
toast: [
|
|
6
|
+
"group flex w-[var(--width)] items-start gap-3 rounded-lg border border-border bg-surface-raised p-4",
|
|
7
|
+
"text-sm text-fg shadow-lg",
|
|
8
|
+
"data-[type=error]:border-danger/40 data-[type=success]:border-success/40"
|
|
9
|
+
].join(" "),
|
|
10
|
+
title: "font-medium",
|
|
11
|
+
description: "mt-0.5 text-fg-muted",
|
|
12
|
+
icon: "mt-0.5 [&_svg]:size-4 group-data-[type=error]:text-danger group-data-[type=success]:text-success group-data-[type=warning]:text-warning group-data-[type=info]:text-info",
|
|
13
|
+
actionButton: "ml-auto shrink-0 rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-on-primary",
|
|
14
|
+
cancelButton: "shrink-0 rounded-md border border-border px-2.5 py-1 text-xs font-medium",
|
|
15
|
+
closeButton: "absolute -top-2 -left-2 grid size-5 place-items-center rounded-full border border-border bg-surface text-fg-muted hover:text-fg"
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Toast notifications (sonner) in the kit's look. Mount once at the app root, then call
|
|
19
|
+
* `toast.success(…)`, `toast.error(…)` etc. from `sonner`.
|
|
20
|
+
*/
|
|
21
|
+
function Toaster({ position = "top-right", visibleToasts = 4, duration }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(Toaster$1, {
|
|
23
|
+
position,
|
|
24
|
+
offset: 16,
|
|
25
|
+
gap: 8,
|
|
26
|
+
visibleToasts,
|
|
27
|
+
duration,
|
|
28
|
+
closeButton: true,
|
|
29
|
+
toastOptions: {
|
|
30
|
+
unstyled: true,
|
|
31
|
+
classNames
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export { Toaster };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Field as Field$1 } from "@base-ui/react/field";
|
|
2
|
+
import { Fieldset as Fieldset$1 } from "@base-ui/react/fieldset";
|
|
3
|
+
import { Form as Form$1 } from "@base-ui/react/form";
|
|
4
|
+
type WithClassName<P> = Omit<P, 'className'> & {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export type FormProps = WithClassName<Form$1.Props>;
|
|
8
|
+
/** A form that shows each field's errors, including `errors` returned by the server by name. */
|
|
9
|
+
export declare const Form: import("react").ForwardRefExoticComponent<Omit<FormProps, "ref"> & import("react").RefAttributes<HTMLFormElement>>;
|
|
10
|
+
export type FieldProps = WithClassName<Field$1.Root.Props>;
|
|
11
|
+
/**
|
|
12
|
+
* Groups a label, one control, a description and an error. Give it `name` to submit the control's
|
|
13
|
+
* value with a `Form`, and `invalid` to mark it invalid from outside (e.g. a form library).
|
|
14
|
+
*/
|
|
15
|
+
export declare const Field: import("react").ForwardRefExoticComponent<Omit<FieldProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export type FieldLabelProps = WithClassName<Field$1.Label.Props>;
|
|
17
|
+
/** The field's visible label. Wrap a Checkbox, Radio or Switch in it to label that control. */
|
|
18
|
+
export declare const FieldLabel: import("react").ForwardRefExoticComponent<Omit<FieldLabelProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
|
|
19
|
+
export type FieldDescriptionProps = WithClassName<Field$1.Description.Props>;
|
|
20
|
+
export declare const FieldDescription: import("react").ForwardRefExoticComponent<Omit<FieldDescriptionProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
21
|
+
export type FieldErrorProps = WithClassName<Field$1.Error.Props>;
|
|
22
|
+
/**
|
|
23
|
+
* Shows the field's error when it is invalid. Pick one approach per field:
|
|
24
|
+
* - your own wording per check: `<FieldError match="valueMissing">Enter a name</FieldError>`;
|
|
25
|
+
* - errors you manage (server or form library): `<Field invalid={Boolean(error)}>` with
|
|
26
|
+
* `<FieldError match={Boolean(error)}>{error}</FieldError>`;
|
|
27
|
+
* - one catch-all `<FieldError />`, which shows the browser's message or the `Form` `errors` entry.
|
|
28
|
+
* A catch-all next to a specific `match` repeats the message, so don't combine them.
|
|
29
|
+
* Unlike Base UI, `match={false}` hides the error (Base UI treats `false` like no `match`).
|
|
30
|
+
*/
|
|
31
|
+
export declare const FieldError: import("react").ForwardRefExoticComponent<Omit<FieldErrorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export type FieldItemProps = WithClassName<Field$1.Item.Props>;
|
|
33
|
+
/** One option (checkbox or radio) with its own label and description inside a group. */
|
|
34
|
+
export declare const FieldItem: import("react").ForwardRefExoticComponent<Omit<FieldItemProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
+
export type FieldsetProps = WithClassName<Fieldset$1.Root.Props>;
|
|
36
|
+
/** Labels a group of controls, e.g. `<Fieldset render={<RadioGroup />}>`. */
|
|
37
|
+
export declare const Fieldset: import("react").ForwardRefExoticComponent<Omit<FieldsetProps, "ref"> & import("react").RefAttributes<HTMLFieldSetElement>>;
|
|
38
|
+
export type FieldsetLegendProps = WithClassName<Fieldset$1.Legend.Props>;
|
|
39
|
+
export declare const FieldsetLegend: import("react").ForwardRefExoticComponent<Omit<FieldsetLegendProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Field as Field$1 } from "@base-ui/react/field";
|
|
5
|
+
import { Fieldset as Fieldset$1 } from "@base-ui/react/fieldset";
|
|
6
|
+
import { Form as Form$1 } from "@base-ui/react/form";
|
|
7
|
+
// src/field/field.tsx
|
|
8
|
+
/** A form that shows each field's errors, including `errors` returned by the server by name. */
|
|
9
|
+
const Form = forwardRef(function Form({ className, ...props }, ref) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Form$1, {
|
|
11
|
+
ref,
|
|
12
|
+
className: cn("flex flex-col gap-5", className),
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Groups a label, one control, a description and an error. Give it `name` to submit the control's
|
|
18
|
+
* value with a `Form`, and `invalid` to mark it invalid from outside (e.g. a form library).
|
|
19
|
+
*/
|
|
20
|
+
const Field = forwardRef(function Field({ className, ...props }, ref) {
|
|
21
|
+
return /* @__PURE__ */ jsx(Field$1.Root, {
|
|
22
|
+
ref,
|
|
23
|
+
className: cn("flex flex-col gap-1.5", className),
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
const fieldLabelClass = "text-sm font-medium text-fg data-disabled:cursor-not-allowed data-disabled:opacity-50";
|
|
28
|
+
/** The field's visible label. Wrap a Checkbox, Radio or Switch in it to label that control. */
|
|
29
|
+
const FieldLabel = forwardRef(function FieldLabel({ className, ...props }, ref) {
|
|
30
|
+
return /* @__PURE__ */ jsx(Field$1.Label, {
|
|
31
|
+
ref,
|
|
32
|
+
className: cn(fieldLabelClass, className),
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const FieldDescription = forwardRef(function FieldDescription({ className, ...props }, ref) {
|
|
37
|
+
return /* @__PURE__ */ jsx(Field$1.Description, {
|
|
38
|
+
ref,
|
|
39
|
+
className: cn("text-sm text-fg-muted", className),
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Shows the field's error when it is invalid. Pick one approach per field:
|
|
45
|
+
* - your own wording per check: `<FieldError match="valueMissing">Enter a name</FieldError>`;
|
|
46
|
+
* - errors you manage (server or form library): `<Field invalid={Boolean(error)}>` with
|
|
47
|
+
* `<FieldError match={Boolean(error)}>{error}</FieldError>`;
|
|
48
|
+
* - one catch-all `<FieldError />`, which shows the browser's message or the `Form` `errors` entry.
|
|
49
|
+
* A catch-all next to a specific `match` repeats the message, so don't combine them.
|
|
50
|
+
* Unlike Base UI, `match={false}` hides the error (Base UI treats `false` like no `match`).
|
|
51
|
+
*/
|
|
52
|
+
const FieldError = forwardRef(function FieldError({ className, ...props }, ref) {
|
|
53
|
+
if (props.match === false) return null;
|
|
54
|
+
return /* @__PURE__ */ jsx(Field$1.Error, {
|
|
55
|
+
ref,
|
|
56
|
+
className: cn("text-sm font-medium text-on-danger-soft", className),
|
|
57
|
+
...props
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
/** One option (checkbox or radio) with its own label and description inside a group. */
|
|
61
|
+
const FieldItem = forwardRef(function FieldItem({ className, ...props }, ref) {
|
|
62
|
+
return /* @__PURE__ */ jsx(Field$1.Item, {
|
|
63
|
+
ref,
|
|
64
|
+
className: cn("flex items-start gap-2.5 pointer-coarse:min-h-11", className),
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
/** Labels a group of controls, e.g. `<Fieldset render={<RadioGroup />}>`. */
|
|
69
|
+
const Fieldset = forwardRef(function Fieldset({ className, ...props }, ref) {
|
|
70
|
+
return /* @__PURE__ */ jsx(Fieldset$1.Root, {
|
|
71
|
+
ref,
|
|
72
|
+
className: cn("flex flex-col gap-2.5", className),
|
|
73
|
+
...props
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
const FieldsetLegend = forwardRef(function FieldsetLegend({ className, ...props }, ref) {
|
|
77
|
+
return /* @__PURE__ */ jsx(Fieldset$1.Legend, {
|
|
78
|
+
ref,
|
|
79
|
+
className: cn("text-sm font-medium text-fg", className),
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
export { Field, FieldDescription, FieldError, FieldItem, FieldLabel, Fieldset, FieldsetLegend, Form, fieldLabelClass };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InputProps } from "../input/input.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export interface TextFieldProps extends InputProps {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
/** A hint under the input. */
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/** A labelled text input with an optional hint: the common case of Field + FieldLabel + Input. */
|
|
9
|
+
export declare function TextField({ label, description, className, ...props }: TextFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Input } from "../input/input.js";
|
|
2
|
+
import { Field, FieldDescription, FieldLabel } from "./field.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/field/text-field.tsx
|
|
5
|
+
/** A labelled text input with an optional hint: the common case of Field + FieldLabel + Input. */
|
|
6
|
+
function TextField({ label, description, className, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
8
|
+
className,
|
|
9
|
+
children: [
|
|
10
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: label }),
|
|
11
|
+
/* @__PURE__ */ jsx(Input, { ...props }),
|
|
12
|
+
description && /* @__PURE__ */ jsx(FieldDescription, { children: description })
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export { TextField };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export interface FileInputProps {
|
|
3
|
+
/** Visible label, e.g. "Payout file". */
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
/** File types, as for `<input accept>`, e.g. ".csv,.xlsx" or "image/*". */
|
|
6
|
+
accept?: string;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
/** Largest allowed file in bytes. Larger files are rejected with a message. */
|
|
9
|
+
maxSize?: number;
|
|
10
|
+
/** Help under the label, e.g. "CSV or Excel, up to 5 MB". */
|
|
11
|
+
hint?: ReactNode;
|
|
12
|
+
/** The chosen files (controlled). */
|
|
13
|
+
value?: File[];
|
|
14
|
+
onFilesChange?: (files: File[]) => void;
|
|
15
|
+
/** An error from validation or the server. */
|
|
16
|
+
error?: ReactNode;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
name?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function formatFileSize(bytes: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Choose files by clicking, keyboard (it is a native file input) or dropping them on the zone.
|
|
24
|
+
* Files are checked against `accept` and `maxSize` before `onFilesChange` runs.
|
|
25
|
+
*/
|
|
26
|
+
export declare function FileInput({ label, accept, multiple, maxSize, hint, value, onFilesChange, error, disabled, name, className }: FileInputProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { inlineIconButton } from "../lib/popup.js";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { FileUp, X } from "lucide-react";
|
|
6
|
+
// src/file-input/file-input.tsx
|
|
7
|
+
function formatFileSize(bytes) {
|
|
8
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
9
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(0)} KB`;
|
|
10
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
11
|
+
}
|
|
12
|
+
const matchesAccept = (file, accept) => !accept || accept.split(",").some((rule) => {
|
|
13
|
+
const type = rule.trim().toLowerCase();
|
|
14
|
+
if (!type) return false;
|
|
15
|
+
if (type.startsWith(".")) return file.name.toLowerCase().endsWith(type);
|
|
16
|
+
if (type.endsWith("/*")) return file.type.startsWith(type.slice(0, -1));
|
|
17
|
+
return file.type === type;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Choose files by clicking, keyboard (it is a native file input) or dropping them on the zone.
|
|
21
|
+
* Files are checked against `accept` and `maxSize` before `onFilesChange` runs.
|
|
22
|
+
*/
|
|
23
|
+
function FileInput({ label, accept, multiple = false, maxSize, hint, value, onFilesChange, error, disabled = false, name, className }) {
|
|
24
|
+
const id = useId();
|
|
25
|
+
const [ownFiles, setOwnFiles] = useState([]);
|
|
26
|
+
const [rejection, setRejection] = useState(null);
|
|
27
|
+
const [dragging, setDragging] = useState(false);
|
|
28
|
+
const files = value ?? ownFiles;
|
|
29
|
+
const choose = (list) => {
|
|
30
|
+
const chosen = Array.from(list);
|
|
31
|
+
const wrongType = chosen.filter((file) => !matchesAccept(file, accept));
|
|
32
|
+
const tooBig = maxSize ? chosen.filter((file) => file.size > maxSize) : [];
|
|
33
|
+
const ok = chosen.filter((file) => !wrongType.includes(file) && !tooBig.includes(file));
|
|
34
|
+
const [firstWrong] = wrongType;
|
|
35
|
+
const [firstBig] = tooBig;
|
|
36
|
+
setRejection(firstWrong ? `${firstWrong.name} is not an accepted file type.` : firstBig && maxSize ? `${firstBig.name} is larger than ${formatFileSize(maxSize)}.` : null);
|
|
37
|
+
if (!ok.length) return;
|
|
38
|
+
const next = multiple ? [...files, ...ok] : ok.slice(0, 1);
|
|
39
|
+
if (value === void 0) setOwnFiles(next);
|
|
40
|
+
onFilesChange?.(next);
|
|
41
|
+
};
|
|
42
|
+
const remove = (file) => {
|
|
43
|
+
const next = files.filter((f) => f !== file);
|
|
44
|
+
if (value === void 0) setOwnFiles(next);
|
|
45
|
+
onFilesChange?.(next);
|
|
46
|
+
};
|
|
47
|
+
const onDrop = (event) => {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
setDragging(false);
|
|
50
|
+
if (!disabled) choose(event.dataTransfer.files);
|
|
51
|
+
};
|
|
52
|
+
const message = error ?? rejection;
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: cn("grid gap-1.5", className),
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx("label", {
|
|
57
|
+
htmlFor: id,
|
|
58
|
+
className: "text-sm font-medium",
|
|
59
|
+
children: label
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ jsx("input", {
|
|
62
|
+
id,
|
|
63
|
+
type: "file",
|
|
64
|
+
name,
|
|
65
|
+
accept,
|
|
66
|
+
multiple,
|
|
67
|
+
disabled,
|
|
68
|
+
"aria-describedby": `${id}-hint`,
|
|
69
|
+
"aria-invalid": message ? true : void 0,
|
|
70
|
+
className: "peer sr-only",
|
|
71
|
+
onChange: (event) => {
|
|
72
|
+
if (event.target.files) choose(event.target.files);
|
|
73
|
+
event.target.value = "";
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx("div", {
|
|
77
|
+
role: "presentation",
|
|
78
|
+
onDragOver: (event) => {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
if (!disabled) setDragging(true);
|
|
81
|
+
},
|
|
82
|
+
onDragLeave: () => {
|
|
83
|
+
setDragging(false);
|
|
84
|
+
},
|
|
85
|
+
onDrop,
|
|
86
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
87
|
+
htmlFor: id,
|
|
88
|
+
"data-dragging": dragging || void 0,
|
|
89
|
+
className: cn("flex cursor-pointer flex-col items-center gap-1 rounded-lg border border-dashed border-input bg-surface px-4 py-6 text-center text-sm", "hover:bg-surface-muted data-dragging:border-brand data-dragging:bg-brand-soft", "peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-focus", "peer-disabled:cursor-not-allowed peer-disabled:opacity-50", message && "border-danger"),
|
|
90
|
+
children: [/* @__PURE__ */ jsx(FileUp, {
|
|
91
|
+
className: "size-5 text-fg-muted",
|
|
92
|
+
"aria-hidden": true
|
|
93
|
+
}), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsxs("span", {
|
|
94
|
+
className: "font-medium text-fg",
|
|
95
|
+
children: ["Choose ", multiple ? "files" : "a file"]
|
|
96
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
97
|
+
className: "text-fg-muted",
|
|
98
|
+
children: [
|
|
99
|
+
" or drop ",
|
|
100
|
+
multiple ? "them" : "it",
|
|
101
|
+
" here"
|
|
102
|
+
]
|
|
103
|
+
})] })]
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsx("p", {
|
|
107
|
+
id: `${id}-hint`,
|
|
108
|
+
className: "text-sm text-fg-muted",
|
|
109
|
+
children: hint
|
|
110
|
+
}),
|
|
111
|
+
message && /* @__PURE__ */ jsx("p", {
|
|
112
|
+
role: "alert",
|
|
113
|
+
className: "text-sm text-danger",
|
|
114
|
+
children: message
|
|
115
|
+
}),
|
|
116
|
+
files.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
117
|
+
"aria-label": "Chosen files",
|
|
118
|
+
className: "divide-y divide-border rounded-md border border-border",
|
|
119
|
+
children: files.map((file, i) => /* @__PURE__ */ jsxs("li", {
|
|
120
|
+
className: "flex items-center gap-2 px-3 py-2 text-sm",
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ jsx("span", {
|
|
123
|
+
className: "min-w-0 flex-1 truncate",
|
|
124
|
+
children: file.name
|
|
125
|
+
}),
|
|
126
|
+
/* @__PURE__ */ jsx("span", {
|
|
127
|
+
className: "text-fg-muted tabular-nums",
|
|
128
|
+
children: formatFileSize(file.size)
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ jsx("button", {
|
|
131
|
+
type: "button",
|
|
132
|
+
"aria-label": `Remove ${file.name}`,
|
|
133
|
+
disabled,
|
|
134
|
+
onClick: () => {
|
|
135
|
+
remove(file);
|
|
136
|
+
},
|
|
137
|
+
className: inlineIconButton,
|
|
138
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
139
|
+
className: "size-3.5",
|
|
140
|
+
"aria-hidden": true
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
}, `${file.name}-${i}`))
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export { FileInput, formatFileSize };
|
package/dist/fonts.css
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { cn } from "./lib/cn.js";
|
|
2
|
+
import { Button, ButtonProps, buttonVariants } from "./button/button.js";
|
|
3
|
+
import { IconButton, IconButtonProps } from "./button/icon-button.js";
|
|
4
|
+
import { Field, FieldDescription, FieldDescriptionProps, FieldError, FieldErrorProps, FieldItem, FieldItemProps, FieldLabel, FieldLabelProps, FieldProps, Fieldset, FieldsetLegend, FieldsetLegendProps, FieldsetProps, Form, FormProps } from "./field/field.js";
|
|
5
|
+
import { TextField, TextFieldProps } from "./field/text-field.js";
|
|
6
|
+
import { Input, InputProps, Textarea, TextareaProps } from "./input/input.js";
|
|
7
|
+
import { Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps } from "./checkbox/checkbox.js";
|
|
8
|
+
import { Radio, RadioGroup, RadioGroupProps, RadioProps } from "./radio/radio.js";
|
|
9
|
+
import { Switch, SwitchProps } from "./switch/switch.js";
|
|
10
|
+
import { Select, SelectOption, SelectProps } from "./select/select.js";
|
|
11
|
+
import { Combobox, ComboboxOption, ComboboxProps, MultiCombobox, MultiComboboxProps } from "./combobox/combobox.js";
|
|
12
|
+
import { DateInput, DateInputProps, DateRange, DateRangeInput, DateRangeInputProps, IsoDate } from "./date/date-input.js";
|
|
13
|
+
import { FileInput, FileInputProps, formatFileSize } from "./file-input/file-input.js";
|
|
14
|
+
import { Dialog, DialogBody, DialogClose, DialogContent, DialogContentProps, DialogDescription, DialogDescriptionProps, DialogFooter, DialogHeader, DialogProps, DialogTitle, DialogTitleProps, DialogTrigger } from "./dialog/dialog.js";
|
|
15
|
+
import { ConfirmDialog, ConfirmDialogProps } from "./dialog/confirm-dialog.js";
|
|
16
|
+
import { FormPanel, FormPanelProps } from "./dialog/form-panel.js";
|
|
17
|
+
import { Popover, PopoverClose, PopoverContent, PopoverContentProps, PopoverDescription, PopoverDescriptionProps, PopoverProps, PopoverTitle, PopoverTitleProps, PopoverTrigger } from "./popover/popover.js";
|
|
18
|
+
import { Menu, MenuCheckboxItem, MenuCheckboxItemProps, MenuContent, MenuContentProps, MenuGroup, MenuGroupLabel, MenuGroupLabelProps, MenuItem, MenuItemProps, MenuLinkItem, MenuLinkItemProps, MenuProps, MenuRadioGroup, MenuRadioItem, MenuRadioItemProps, MenuSeparator, MenuTrigger } from "./menu/menu.js";
|
|
19
|
+
import { Tooltip, TooltipProps, TooltipProvider, TooltipProviderProps } from "./tooltip/tooltip.js";
|
|
20
|
+
import { Badge, BadgeProps } from "./badge/badge.js";
|
|
21
|
+
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CardTitleProps } from "./card/card.js";
|
|
22
|
+
import { Stat, StatGroup, StatProps } from "./stat/stat.js";
|
|
23
|
+
import { Tab, TabProps, Tabs, TabsList, TabsListProps, TabsPanel, TabsPanelProps, TabsProps } from "./tabs/tabs.js";
|
|
24
|
+
import { Avatar, AvatarProps, initials } from "./avatar/avatar.js";
|
|
25
|
+
import { Separator, SeparatorProps } from "./separator/separator.js";
|
|
26
|
+
import { EmptyState, EmptyStateProps, ErrorState, ErrorStateProps, Skeleton } from "./state/states.js";
|
|
27
|
+
import { AppShell, AppShellProps, PageBar, PageBarProps, Sidebar, SidebarFooter, SidebarHeader, SidebarLink, SidebarLinkProps, SidebarNav, SidebarNavProps, SidebarSection, SidebarSectionProps, SidebarSubmenu, SidebarSubmenuProps, useSidebarCollapsed } from "./layout/app-shell.js";
|
|
28
|
+
import { Page, PageHeader, PageHeaderProps, PageProps } from "./layout/page.js";
|
|
29
|
+
import { DetailItem, DetailList, DetailListProps, RecordHeader, RecordHeaderProps, RecordLayout, RecordLayoutProps } from "./layout/record.js";
|
|
30
|
+
import { DataTable, DataTableColumn, DataTableFeatures, DataTableProps, DataTableRow, PaginationState, RowSelectionState, SortingState, VisibilityState, createDataTableColumnHelper, dataTableFeatures } from "./data/data-table.js";
|
|
31
|
+
import { Pagination, PaginationProps } from "./data/pagination.js";
|
|
32
|
+
import { ColumnsMenu, ColumnsMenuProps, FilterBar, FilterBarProps, FilterChip, FilterChipProps, SearchInput, SearchInputProps } from "./data/filter-bar.js";
|
|
33
|
+
import { ExportButton, ExportButtonProps } from "./data/export-button.js";
|
|
34
|
+
import { SelectionBar, SelectionBarProps } from "./data/selection-bar.js";
|
|
35
|
+
import { Alert, AlertProps, AlertTone } from "./feedback/alert.js";
|
|
36
|
+
import { ProgressBar, ProgressBarProps, Spinner, SpinnerProps } from "./feedback/progress.js";
|
|
37
|
+
import { Toaster, ToasterProps } from "./feedback/toaster.js";
|
|
38
|
+
import { Table, TableBody, TableCaption, TableCell, TableCellProps, TableFooter, TableHead, TableHeadProps, TableHeader, TableProps, TableRow } from "./table/table.js";
|
|
39
|
+
import { Accordion, AccordionItem, AccordionItemProps, AccordionPanel, AccordionPanelProps, AccordionProps, AccordionTrigger, AccordionTriggerProps, Collapsible, CollapsiblePanel, CollapsiblePanelProps, CollapsibleProps, CollapsibleTrigger, CollapsibleTriggerProps } from "./accordion/accordion.js";
|
|
40
|
+
import { BreadcrumbItem, BreadcrumbItemProps, Breadcrumbs, BreadcrumbsProps } from "./breadcrumbs/breadcrumbs.js";
|
|
41
|
+
import { CommandGroup, CommandItem, CommandPalette, CommandPaletteProps, useCommandShortcut } from "./command/command-palette.js";
|
|
42
|
+
import { Kbd } from "./command/kbd.js";
|
|
43
|
+
export { Accordion, AccordionItem, type AccordionItemProps, AccordionPanel, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Avatar, type AvatarProps, Badge, type BadgeProps, BreadcrumbItem, type BreadcrumbItemProps, Breadcrumbs, type BreadcrumbsProps, Button, type ButtonProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CardTitleProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, Collapsible, CollapsiblePanel, type CollapsiblePanelProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, ColumnsMenu, type ColumnsMenuProps, Combobox, type ComboboxOption, type ComboboxProps, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, DataTable, type DataTableColumn, type DataTableFeatures, type DataTableProps, type DataTableRow, DateInput, type DateInputProps, type DateRange, DateRangeInput, type DateRangeInputProps, type DetailItem, DetailList, type DetailListProps, Dialog, DialogBody, DialogClose, DialogContent, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, DialogHeader, type DialogProps, DialogTitle, type DialogTitleProps, DialogTrigger, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, ExportButton, type ExportButtonProps, Field, FieldDescription, type FieldDescriptionProps, FieldError, type FieldErrorProps, FieldItem, type FieldItemProps, FieldLabel, type FieldLabelProps, type FieldProps, Fieldset, FieldsetLegend, type FieldsetLegendProps, type FieldsetProps, FileInput, type FileInputProps, FilterBar, type FilterBarProps, FilterChip, type FilterChipProps, Form, FormPanel, type FormPanelProps, type FormProps, IconButton, type IconButtonProps, Input, type InputProps, type IsoDate, Kbd, Menu, MenuCheckboxItem, type MenuCheckboxItemProps, MenuContent, type MenuContentProps, MenuGroup, MenuGroupLabel, type MenuGroupLabelProps, MenuItem, type MenuItemProps, MenuLinkItem, type MenuLinkItemProps, type MenuProps, MenuRadioGroup, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, MenuTrigger, MultiCombobox, type MultiComboboxProps, Page, PageBar, type PageBarProps, PageHeader, type PageHeaderProps, type PageProps, Pagination, type PaginationProps, type PaginationState, Popover, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, type PopoverDescriptionProps, type PopoverProps, PopoverTitle, type PopoverTitleProps, PopoverTrigger, ProgressBar, type ProgressBarProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, RecordHeader, type RecordHeaderProps, RecordLayout, type RecordLayoutProps, type RowSelectionState, SearchInput, type SearchInputProps, Select, type SelectOption, type SelectProps, SelectionBar, type SelectionBarProps, Separator, type SeparatorProps, Sidebar, SidebarFooter, SidebarHeader, SidebarLink, type SidebarLinkProps, SidebarNav, type SidebarNavProps, SidebarSection, type SidebarSectionProps, SidebarSubmenu, type SidebarSubmenuProps, Skeleton, type SortingState, Spinner, type SpinnerProps, Stat, StatGroup, type StatProps, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCaption, TableCell, type TableCellProps, TableFooter, TableHead, type TableHeadProps, TableHeader, type TableProps, TableRow, Tabs, TabsList, type TabsListProps, TabsPanel, type TabsPanelProps, type TabsProps, TextField, type TextFieldProps, Textarea, type TextareaProps, Toaster, type ToasterProps, Tooltip, type TooltipProps, TooltipProvider, type TooltipProviderProps, type VisibilityState, buttonVariants, cn, createDataTableColumnHelper, dataTableFeatures, formatFileSize, initials, useCommandShortcut, useSidebarCollapsed };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { cn } from "./lib/cn.js";
|
|
2
|
+
import { Button, buttonVariants } from "./button/button.js";
|
|
3
|
+
import { IconButton } from "./button/icon-button.js";
|
|
4
|
+
import { Field, FieldDescription, FieldError, FieldItem, FieldLabel, Fieldset, FieldsetLegend, Form } from "./field/field.js";
|
|
5
|
+
import { TextField } from "./field/text-field.js";
|
|
6
|
+
import { Input, Textarea } from "./input/input.js";
|
|
7
|
+
import { Checkbox, CheckboxGroup } from "./checkbox/checkbox.js";
|
|
8
|
+
import { Radio, RadioGroup } from "./radio/radio.js";
|
|
9
|
+
import { Switch } from "./switch/switch.js";
|
|
10
|
+
import { Select } from "./select/select.js";
|
|
11
|
+
import { Combobox, MultiCombobox } from "./combobox/combobox.js";
|
|
12
|
+
import { DateInput, DateRangeInput } from "./date/date-input.js";
|
|
13
|
+
import { FileInput, formatFileSize } from "./file-input/file-input.js";
|
|
14
|
+
import { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./dialog/dialog.js";
|
|
15
|
+
import { ConfirmDialog } from "./dialog/confirm-dialog.js";
|
|
16
|
+
import { FormPanel } from "./dialog/form-panel.js";
|
|
17
|
+
import { Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger } from "./popover/popover.js";
|
|
18
|
+
import { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger } from "./menu/menu.js";
|
|
19
|
+
import { Tooltip, TooltipProvider } from "./tooltip/tooltip.js";
|
|
20
|
+
import { Badge } from "./badge/badge.js";
|
|
21
|
+
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./card/card.js";
|
|
22
|
+
import { Stat, StatGroup } from "./stat/stat.js";
|
|
23
|
+
import { Tab, Tabs, TabsList, TabsPanel } from "./tabs/tabs.js";
|
|
24
|
+
import { Avatar, initials } from "./avatar/avatar.js";
|
|
25
|
+
import { Separator } from "./separator/separator.js";
|
|
26
|
+
import { EmptyState, ErrorState, Skeleton } from "./state/states.js";
|
|
27
|
+
import { AppShell, PageBar, Sidebar, SidebarFooter, SidebarHeader, SidebarLink, SidebarNav, SidebarSection, SidebarSubmenu, useSidebarCollapsed } from "./layout/app-shell.js";
|
|
28
|
+
import { Page, PageHeader } from "./layout/page.js";
|
|
29
|
+
import { DetailList, RecordHeader, RecordLayout } from "./layout/record.js";
|
|
30
|
+
import { DataTable, createDataTableColumnHelper, dataTableFeatures } from "./data/data-table.js";
|
|
31
|
+
import { Pagination } from "./data/pagination.js";
|
|
32
|
+
import { ColumnsMenu, FilterBar, FilterChip, SearchInput } from "./data/filter-bar.js";
|
|
33
|
+
import { ExportButton } from "./data/export-button.js";
|
|
34
|
+
import { SelectionBar } from "./data/selection-bar.js";
|
|
35
|
+
import { Alert } from "./feedback/alert.js";
|
|
36
|
+
import { ProgressBar, Spinner } from "./feedback/progress.js";
|
|
37
|
+
import { Toaster } from "./feedback/toaster.js";
|
|
38
|
+
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from "./table/table.js";
|
|
39
|
+
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Collapsible, CollapsiblePanel, CollapsibleTrigger } from "./accordion/accordion.js";
|
|
40
|
+
import { BreadcrumbItem, Breadcrumbs } from "./breadcrumbs/breadcrumbs.js";
|
|
41
|
+
import { CommandPalette, useCommandShortcut } from "./command/command-palette.js";
|
|
42
|
+
import { Kbd } from "./command/kbd.js";
|
|
43
|
+
export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AppShell, Avatar, Badge, BreadcrumbItem, Breadcrumbs, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, Collapsible, CollapsiblePanel, CollapsibleTrigger, ColumnsMenu, Combobox, CommandPalette, ConfirmDialog, DataTable, DateInput, DateRangeInput, DetailList, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EmptyState, ErrorState, ExportButton, Field, FieldDescription, FieldError, FieldItem, FieldLabel, Fieldset, FieldsetLegend, FileInput, FilterBar, FilterChip, Form, FormPanel, IconButton, Input, Kbd, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger, MultiCombobox, Page, PageBar, PageHeader, Pagination, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, ProgressBar, Radio, RadioGroup, RecordHeader, RecordLayout, SearchInput, Select, SelectionBar, Separator, Sidebar, SidebarFooter, SidebarHeader, SidebarLink, SidebarNav, SidebarSection, SidebarSubmenu, Skeleton, Spinner, Stat, StatGroup, Switch, Tab, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsList, TabsPanel, TextField, Textarea, Toaster, Tooltip, TooltipProvider, buttonVariants, cn, createDataTableColumnHelper, dataTableFeatures, formatFileSize, initials, useCommandShortcut, useSidebarCollapsed };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Field } from "@base-ui/react/field";
|
|
2
|
+
import { Input as Input$1 } from "@base-ui/react/input";
|
|
3
|
+
export interface InputProps extends Omit<Input$1.Props, 'className'> {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/** A text input. Inside a `Field` it is labelled, described and validated by that field. */
|
|
7
|
+
export declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
export interface TextareaProps extends Omit<Field.Control.Props, 'className' | 'render' | 'type'> {
|
|
9
|
+
className?: string;
|
|
10
|
+
rows?: number;
|
|
11
|
+
}
|
|
12
|
+
/** A multi-line text input. Grows with `rows` (default 3) and can be resized vertically. */
|
|
13
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { controlFocus, controlFrame, controlHeight } from "../lib/control.js";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Field } from "@base-ui/react/field";
|
|
6
|
+
import { Input as Input$1 } from "@base-ui/react/input";
|
|
7
|
+
// src/input/input.tsx
|
|
8
|
+
/** A text input. Inside a `Field` it is labelled, described and validated by that field. */
|
|
9
|
+
const Input = forwardRef(function Input({ className, ...props }, ref) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Input$1, {
|
|
11
|
+
ref,
|
|
12
|
+
className: cn(controlFrame, controlFocus, controlHeight, "px-2.5 placeholder:text-fg-muted", "file:mr-2 file:border-0 file:bg-transparent file:font-medium", className),
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
/** A multi-line text input. Grows with `rows` (default 3) and can be resized vertically. */
|
|
17
|
+
const Textarea = forwardRef(function Textarea({ className, rows = 3, ...props }, ref) {
|
|
18
|
+
return /* @__PURE__ */ jsx(Field.Control, {
|
|
19
|
+
ref,
|
|
20
|
+
render: /* @__PURE__ */ jsx("textarea", { rows }),
|
|
21
|
+
className: cn(controlFrame, controlFocus, "min-h-16 resize-y px-2.5 py-1.5 placeholder:text-fg-muted", className),
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
export { Input, Textarea };
|