@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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -2
  3. package/dist/accordion/accordion.d.ts +41 -0
  4. package/dist/accordion/accordion.js +89 -0
  5. package/dist/avatar/avatar.d.ts +20 -0
  6. package/dist/avatar/avatar.js +38 -0
  7. package/dist/badge/badge.d.ts +16 -0
  8. package/dist/badge/badge.js +85 -0
  9. package/dist/breadcrumbs/breadcrumbs.d.ts +19 -0
  10. package/dist/breadcrumbs/breadcrumbs.js +44 -0
  11. package/dist/button/button.d.ts +16 -0
  12. package/dist/button/button.js +49 -0
  13. package/dist/button/icon-button.d.ts +17 -0
  14. package/dist/button/icon-button.js +33 -0
  15. package/dist/card/card.d.ts +16 -0
  16. package/dist/card/card.js +56 -0
  17. package/dist/checkbox/checkbox.d.ts +15 -0
  18. package/dist/checkbox/checkbox.js +47 -0
  19. package/dist/combobox/combobox.d.ts +37 -0
  20. package/dist/combobox/combobox.js +155 -0
  21. package/dist/command/command-palette.d.ts +50 -0
  22. package/dist/command/command-palette.js +170 -0
  23. package/dist/command/kbd.d.ts +6 -0
  24. package/dist/command/kbd.js +16 -0
  25. package/dist/data/data-table.d.ts +105 -0
  26. package/dist/data/data-table.js +269 -0
  27. package/dist/data/export-button.d.ts +19 -0
  28. package/dist/data/export-button.js +34 -0
  29. package/dist/data/filter-bar.d.ts +54 -0
  30. package/dist/data/filter-bar.js +187 -0
  31. package/dist/data/pagination.d.ts +13 -0
  32. package/dist/data/pagination.js +84 -0
  33. package/dist/data/selection-bar.d.ts +21 -0
  34. package/dist/data/selection-bar.js +31 -0
  35. package/dist/date/date-input.d.ts +41 -0
  36. package/dist/date/date-input.js +71 -0
  37. package/dist/dialog/confirm-dialog.d.ts +24 -0
  38. package/dist/dialog/confirm-dialog.js +77 -0
  39. package/dist/dialog/dialog.d.ts +46 -0
  40. package/dist/dialog/dialog.js +102 -0
  41. package/dist/dialog/form-panel.d.ts +28 -0
  42. package/dist/dialog/form-panel.js +51 -0
  43. package/dist/feedback/alert.d.ts +29 -0
  44. package/dist/feedback/alert.js +70 -0
  45. package/dist/feedback/progress.d.ts +25 -0
  46. package/dist/feedback/progress.js +54 -0
  47. package/dist/feedback/toaster.d.ts +7 -0
  48. package/dist/feedback/toaster.js +35 -0
  49. package/dist/field/field.d.ts +40 -0
  50. package/dist/field/field.js +83 -0
  51. package/dist/field/text-field.d.ts +9 -0
  52. package/dist/field/text-field.js +16 -0
  53. package/dist/file-input/file-input.d.ts +26 -0
  54. package/dist/file-input/file-input.js +149 -0
  55. package/dist/fonts.css +3 -0
  56. package/dist/index.d.ts +43 -0
  57. package/dist/index.js +43 -0
  58. package/dist/input/input.d.ts +13 -0
  59. package/dist/input/input.js +25 -0
  60. package/dist/layout/app-shell.d.ts +100 -0
  61. package/dist/layout/app-shell.js +433 -0
  62. package/dist/layout/page.d.ts +20 -0
  63. package/dist/layout/page.js +53 -0
  64. package/dist/layout/record.d.ts +39 -0
  65. package/dist/layout/record.js +79 -0
  66. package/dist/lib/cn.d.ts +3 -0
  67. package/dist/lib/cn.js +18 -0
  68. package/dist/lib/control.js +14 -0
  69. package/dist/lib/popup.js +20 -0
  70. package/dist/menu/menu.d.ts +45 -0
  71. package/dist/menu/menu.js +85 -0
  72. package/dist/popover/popover.d.ts +22 -0
  73. package/dist/popover/popover.js +39 -0
  74. package/dist/radio/radio.d.ts +12 -0
  75. package/dist/radio/radio.js +25 -0
  76. package/dist/select/select.d.ts +23 -0
  77. package/dist/select/select.js +66 -0
  78. package/dist/separator/separator.d.ts +6 -0
  79. package/dist/separator/separator.js +14 -0
  80. package/dist/stat/stat.d.ts +28 -0
  81. package/dist/stat/stat.js +55 -0
  82. package/dist/state/states.d.ts +36 -0
  83. package/dist/state/states.js +108 -0
  84. package/dist/styles.css +42 -0
  85. package/dist/switch/switch.d.ts +9 -0
  86. package/dist/switch/switch.js +18 -0
  87. package/dist/table/table.d.ts +28 -0
  88. package/dist/table/table.js +72 -0
  89. package/dist/tabs/tabs.d.ts +26 -0
  90. package/dist/tabs/tabs.js +45 -0
  91. package/dist/tooltip/tooltip.d.ts +17 -0
  92. package/dist/tooltip/tooltip.js +27 -0
  93. package/package.json +57 -4
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from "react";
2
+ export interface SelectionBarProps {
3
+ /** How many rows are selected. The bar is hidden at 0. */
4
+ count: number;
5
+ /** The bulk actions, as small buttons, e.g. `<Button size="sm">Mark as paid</Button>`. */
6
+ children?: ReactNode;
7
+ /** Clears the selection. */
8
+ onClear: () => void;
9
+ /** Names the region for screen readers, e.g. "Selected payouts". Defaults to "Selected rows". */
10
+ label?: string;
11
+ /** Defaults to "Clear selection". */
12
+ clearLabel?: string;
13
+ /** Formats the count; defaults to the browser locale's grouping. */
14
+ formatCount?: (count: number) => string;
15
+ className?: string;
16
+ }
17
+ /**
18
+ * Shown above a `DataTable` while rows are selected: how many, the bulk actions and Clear
19
+ * selection. The count is announced when it changes.
20
+ */
21
+ export declare function SelectionBar({ count, children, onClear, label, clearLabel, formatCount, className }: SelectionBarProps): import("react").JSX.Element | null;
@@ -0,0 +1,31 @@
1
+ import { Button } from "../button/button.js";
2
+ import { cn } from "../lib/cn.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/data/selection-bar.tsx
5
+ /**
6
+ * Shown above a `DataTable` while rows are selected: how many, the bulk actions and Clear
7
+ * selection. The count is announced when it changes.
8
+ */
9
+ function SelectionBar({ count, children, onClear, label = "Selected rows", clearLabel = "Clear selection", formatCount = (value) => value.toLocaleString(), className }) {
10
+ if (count <= 0) return null;
11
+ return /* @__PURE__ */ jsxs("div", {
12
+ role: "region",
13
+ "aria-label": label,
14
+ className: cn("flex flex-wrap items-center gap-3 border-b border-border bg-surface-muted px-3 py-2 lg:px-5", className),
15
+ children: [
16
+ /* @__PURE__ */ jsxs("span", {
17
+ className: "text-sm font-medium tabular-nums",
18
+ "aria-live": "polite",
19
+ children: [formatCount(count), " selected"]
20
+ }),
21
+ children,
22
+ /* @__PURE__ */ jsx(Button, {
23
+ size: "sm",
24
+ variant: "ghost",
25
+ onClick: onClear,
26
+ children: clearLabel
27
+ })
28
+ ]
29
+ });
30
+ }
31
+ export { SelectionBar };
@@ -0,0 +1,41 @@
1
+ import { InputProps } from "../input/input.js";
2
+ /** Dates are plain ISO calendar dates (`YYYY-MM-DD`); an empty input is `null`. */
3
+ export type IsoDate = string;
4
+ export interface DateInputProps extends Omit<InputProps, 'type' | 'value' | 'defaultValue' | 'onValueChange' | 'min' | 'max'> {
5
+ value?: IsoDate | null;
6
+ defaultValue?: IsoDate | null;
7
+ onValueChange?: (value: IsoDate | null) => void;
8
+ /** Earliest allowed date, `YYYY-MM-DD`. */
9
+ min?: IsoDate;
10
+ /** Latest allowed date, `YYYY-MM-DD`. */
11
+ max?: IsoDate;
12
+ }
13
+ /**
14
+ * A calendar date picker using the browser's native control, so it works with the keyboard,
15
+ * screen readers and phone date wheels. Values are ISO dates, never `Date` objects.
16
+ */
17
+ export declare const DateInput: import("react").ForwardRefExoticComponent<Omit<DateInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
18
+ export interface DateRange {
19
+ from: IsoDate | null;
20
+ to: IsoDate | null;
21
+ }
22
+ export interface DateRangeInputProps {
23
+ value: DateRange;
24
+ onValueChange: (value: DateRange) => void;
25
+ /** Names the pair for screen readers, e.g. "Booking dates". */
26
+ 'aria-label': string;
27
+ /** Labels for each end. Default "From" and "To". */
28
+ labels?: {
29
+ from: string;
30
+ to: string;
31
+ };
32
+ min?: IsoDate;
33
+ max?: IsoDate;
34
+ disabled?: boolean;
35
+ className?: string;
36
+ }
37
+ /**
38
+ * Two date inputs for a range. The end cannot be before the start. Both ends are optional, so
39
+ * "from 1 March" with no end is a valid filter.
40
+ */
41
+ export declare function DateRangeInput({ value, onValueChange, 'aria-label': ariaLabel, labels, min, max, disabled, className }: DateRangeInputProps): import("react").JSX.Element;
@@ -0,0 +1,71 @@
1
+ import { Input } from "../input/input.js";
2
+ import { cn } from "../lib/cn.js";
3
+ import { forwardRef } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/date/date-input.tsx
6
+ const dateFrame = "w-auto min-w-36 tabular-nums [&::-webkit-calendar-picker-indicator]:opacity-60 [&::-webkit-calendar-picker-indicator]:hover:opacity-100";
7
+ /**
8
+ * A calendar date picker using the browser's native control, so it works with the keyboard,
9
+ * screen readers and phone date wheels. Values are ISO dates, never `Date` objects.
10
+ */
11
+ const DateInput = forwardRef(function DateInput({ value, defaultValue, onValueChange, className, ...props }, ref) {
12
+ return /* @__PURE__ */ jsx(Input, {
13
+ ref,
14
+ type: "date",
15
+ value: value === void 0 ? void 0 : value ?? "",
16
+ defaultValue: defaultValue === void 0 ? void 0 : defaultValue ?? "",
17
+ onValueChange: (next) => {
18
+ onValueChange?.(next || null);
19
+ },
20
+ className: cn(dateFrame, className),
21
+ ...props
22
+ });
23
+ });
24
+ /**
25
+ * Two date inputs for a range. The end cannot be before the start. Both ends are optional, so
26
+ * "from 1 March" with no end is a valid filter.
27
+ */
28
+ function DateRangeInput({ value, onValueChange, "aria-label": ariaLabel, labels = {
29
+ from: "From",
30
+ to: "To"
31
+ }, min, max, disabled, className }) {
32
+ return /* @__PURE__ */ jsxs("div", {
33
+ role: "group",
34
+ "aria-label": ariaLabel,
35
+ className: cn("inline-flex flex-wrap items-center gap-2", className),
36
+ children: [
37
+ /* @__PURE__ */ jsx(DateInput, {
38
+ "aria-label": labels.from,
39
+ value: value.from,
40
+ min,
41
+ max: value.to ?? max,
42
+ disabled,
43
+ onValueChange: (from) => {
44
+ onValueChange({
45
+ from,
46
+ to: from && value.to && value.to < from ? null : value.to
47
+ });
48
+ }
49
+ }),
50
+ /* @__PURE__ */ jsx("span", {
51
+ className: "text-sm text-fg-muted",
52
+ "aria-hidden": true,
53
+ children: "–"
54
+ }),
55
+ /* @__PURE__ */ jsx(DateInput, {
56
+ "aria-label": labels.to,
57
+ value: value.to,
58
+ min: value.from ?? min,
59
+ max,
60
+ disabled,
61
+ onValueChange: (to) => {
62
+ onValueChange({
63
+ ...value,
64
+ to
65
+ });
66
+ }
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ export { DateInput, DateRangeInput };
@@ -0,0 +1,24 @@
1
+ import { ReactElement, ReactNode } from "react";
2
+ export interface ConfirmDialogProps {
3
+ /** Element that opens the dialog, e.g. `<Button variant="ghost">Delete</Button>`. */
4
+ trigger?: ReactElement;
5
+ /** Control the dialog yourself (e.g. opened from a row menu) instead of using `trigger`. */
6
+ open?: boolean;
7
+ onOpenChange?: (open: boolean) => void;
8
+ /** A question naming the thing, e.g. "Delete contract GG-2026-0101?" */
9
+ title: ReactNode;
10
+ /** What happens and whether it can be undone. */
11
+ description?: ReactNode;
12
+ /** The action as a verb, e.g. "Delete contract". Never "OK" or "Yes". */
13
+ confirmLabel: string;
14
+ cancelLabel?: string;
15
+ /** `danger` for destructive actions. */
16
+ tone?: 'danger' | 'primary';
17
+ /**
18
+ * Runs the action. If it returns a promise the dialog stays open and busy until it settles;
19
+ * a rejection keeps it open and shows the error's message.
20
+ */
21
+ onConfirm: () => unknown;
22
+ }
23
+ /** Asks before a consequential action. Focus starts on Cancel. */
24
+ export declare function ConfirmDialog({ trigger, open: openProp, onOpenChange, title, description, confirmLabel, cancelLabel, tone, onConfirm }: ConfirmDialogProps): import("react").JSX.Element;
@@ -0,0 +1,77 @@
1
+ import { Button } from "../button/button.js";
2
+ import { cn } from "../lib/cn.js";
3
+ import { overlayBackdrop } from "./dialog.js";
4
+ import { useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { AlertDialog } from "@base-ui/react/alert-dialog";
7
+ // src/dialog/confirm-dialog.tsx
8
+ /** Asks before a consequential action. Focus starts on Cancel. */
9
+ function ConfirmDialog({ trigger, open: openProp, onOpenChange, title, description, confirmLabel, cancelLabel = "Cancel", tone = "danger", onConfirm }) {
10
+ const [openState, setOpenState] = useState(false);
11
+ const [pending, setPending] = useState(false);
12
+ const [error, setError] = useState(null);
13
+ const open = openProp ?? openState;
14
+ const setOpen = (next) => {
15
+ if (!next && pending) return;
16
+ if (next) setError(null);
17
+ setOpenState(next);
18
+ onOpenChange?.(next);
19
+ };
20
+ const confirm = async () => {
21
+ setError(null);
22
+ setPending(true);
23
+ try {
24
+ await onConfirm();
25
+ setPending(false);
26
+ setOpenState(false);
27
+ onOpenChange?.(false);
28
+ } catch (reason) {
29
+ setPending(false);
30
+ setError(reason instanceof Error && reason.message ? reason.message : "Something went wrong.");
31
+ }
32
+ };
33
+ return /* @__PURE__ */ jsxs(AlertDialog.Root, {
34
+ open,
35
+ onOpenChange: (next) => {
36
+ setOpen(next);
37
+ },
38
+ children: [trigger && /* @__PURE__ */ jsx(AlertDialog.Trigger, { render: trigger }), /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [/* @__PURE__ */ jsx(AlertDialog.Backdrop, { className: overlayBackdrop }), /* @__PURE__ */ jsxs(AlertDialog.Popup, {
39
+ className: cn("fixed z-(--z-modal) flex flex-col gap-4 border-border bg-surface-raised p-5 pb-[max(1.25rem,env(safe-area-inset-bottom))] text-fg shadow-lg outline-none sm:pb-5", "inset-x-0 bottom-0 rounded-t-xl border-t transition-[translate,scale,opacity] duration-normal ease-standard", "data-starting-style:translate-y-full data-ending-style:translate-y-full", "sm:inset-x-auto sm:bottom-auto sm:top-1/2 sm:left-1/2 sm:w-[calc(100vw-2rem)] sm:max-w-md", "sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl sm:border", "sm:data-starting-style:-translate-y-1/2 sm:data-starting-style:scale-95 sm:data-starting-style:opacity-0", "sm:data-ending-style:-translate-y-1/2 sm:data-ending-style:scale-95 sm:data-ending-style:opacity-0"),
40
+ children: [
41
+ /* @__PURE__ */ jsxs("div", {
42
+ className: "flex flex-col gap-1",
43
+ children: [/* @__PURE__ */ jsx(AlertDialog.Title, {
44
+ className: "text-lg font-semibold",
45
+ children: title
46
+ }), description && /* @__PURE__ */ jsx(AlertDialog.Description, {
47
+ className: "text-sm text-fg-muted",
48
+ children: description
49
+ })]
50
+ }),
51
+ error && /* @__PURE__ */ jsx("p", {
52
+ role: "alert",
53
+ className: "rounded-md bg-danger-soft px-3 py-2 text-sm font-medium text-on-danger-soft",
54
+ children: error
55
+ }),
56
+ /* @__PURE__ */ jsxs("div", {
57
+ className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
58
+ children: [/* @__PURE__ */ jsx(AlertDialog.Close, {
59
+ disabled: pending,
60
+ render: /* @__PURE__ */ jsx(Button, {
61
+ variant: "secondary",
62
+ children: cancelLabel
63
+ })
64
+ }), /* @__PURE__ */ jsx(Button, {
65
+ variant: tone === "danger" ? "danger" : "primary",
66
+ disabled: pending,
67
+ focusableWhenDisabled: true,
68
+ "aria-busy": pending || void 0,
69
+ onClick: () => void confirm(),
70
+ children: pending ? `${confirmLabel}…` : confirmLabel
71
+ })]
72
+ })
73
+ ]
74
+ })] })]
75
+ });
76
+ }
77
+ export { ConfirmDialog };
@@ -0,0 +1,46 @@
1
+ import { VariantProps } from "class-variance-authority";
2
+ import { ReactNode } from "react";
3
+ import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
4
+ declare const popup: (props?: ({
5
+ placement?: "center" | "right" | null | undefined;
6
+ size?: "sm" | "md" | "lg" | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ export declare const Dialog: <Payload>(props: Dialog$1.Root.Props<Payload>) => React.JSX.Element;
9
+ export type DialogProps = Dialog$1.Root.Props;
10
+ /** Opens the dialog. Use `render={<Button />}` to show it as a kit button. */
11
+ export declare const DialogTrigger: Dialog$1.Trigger;
12
+ export interface DialogContentProps extends Omit<Dialog$1.Popup.Props, 'className'>, VariantProps<typeof popup> {
13
+ className?: string;
14
+ /** Show a close button in the top corner. Defaults to true. */
15
+ showClose?: boolean;
16
+ }
17
+ /**
18
+ * The dialog box. `placement="right"` makes it a side panel (record details, filters, quick edit).
19
+ * Compose with DialogHeader, DialogBody and DialogFooter; DialogTitle is required for a name.
20
+ */
21
+ export declare const DialogContent: import("react").ForwardRefExoticComponent<Omit<DialogContentProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
+ export declare function DialogHeader({ className, children }: {
23
+ className?: string;
24
+ children: ReactNode;
25
+ }): import("react").JSX.Element;
26
+ export type DialogTitleProps = Omit<Dialog$1.Title.Props, 'className'> & {
27
+ className?: string;
28
+ };
29
+ export declare const DialogTitle: import("react").ForwardRefExoticComponent<Omit<DialogTitleProps, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
30
+ export type DialogDescriptionProps = Omit<Dialog$1.Description.Props, 'className'> & {
31
+ className?: string;
32
+ };
33
+ export declare const DialogDescription: import("react").ForwardRefExoticComponent<Omit<DialogDescriptionProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
34
+ /** Scrollable middle section. */
35
+ export declare function DialogBody({ className, children }: {
36
+ className?: string;
37
+ children: ReactNode;
38
+ }): import("react").JSX.Element;
39
+ /** Actions row: secondary actions first, the main action last (rightmost). */
40
+ export declare function DialogFooter({ className, children }: {
41
+ className?: string;
42
+ children: ReactNode;
43
+ }): import("react").JSX.Element;
44
+ /** Closes the dialog. Use `render={<Button variant="secondary" />}`. */
45
+ export declare const DialogClose: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogCloseProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
46
+ export {};
@@ -0,0 +1,102 @@
1
+ import { IconButton } from "../button/icon-button.js";
2
+ import { cn } from "../lib/cn.js";
3
+ import { cva } from "class-variance-authority";
4
+ import { forwardRef } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { X } from "lucide-react";
7
+ import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
8
+ // src/dialog/dialog.tsx
9
+ const overlayBackdrop = [
10
+ "fixed inset-0 z-(--z-overlay) min-h-dvh bg-overlay",
11
+ "transition-opacity duration-normal ease-standard",
12
+ "data-starting-style:opacity-0 data-ending-style:opacity-0"
13
+ ].join(" ");
14
+ const popup = cva(["fixed z-(--z-modal) flex flex-col border-border bg-surface-raised text-fg shadow-lg outline-none", "transition-[translate,scale,opacity] ease-standard"], {
15
+ variants: {
16
+ placement: {
17
+ center: [
18
+ "inset-x-0 bottom-0 max-h-[calc(100dvh-2rem)] rounded-t-xl border-t duration-normal",
19
+ "data-starting-style:translate-y-full data-ending-style:translate-y-full",
20
+ "sm:inset-x-auto sm:bottom-auto sm:top-1/2 sm:left-1/2 sm:w-[calc(100vw-2rem)]",
21
+ "sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl sm:border",
22
+ "sm:data-starting-style:-translate-y-1/2 sm:data-starting-style:scale-95 sm:data-starting-style:opacity-0",
23
+ "sm:data-ending-style:-translate-y-1/2 sm:data-ending-style:scale-95 sm:data-ending-style:opacity-0"
24
+ ],
25
+ right: [
26
+ "inset-0 duration-slow",
27
+ "data-starting-style:translate-x-full data-ending-style:translate-x-full",
28
+ "sm:inset-y-2 sm:right-2 sm:left-auto sm:w-[calc(100vw-1rem)] sm:rounded-xl sm:border"
29
+ ]
30
+ },
31
+ size: {
32
+ sm: "sm:max-w-sm",
33
+ md: "sm:max-w-lg",
34
+ lg: "sm:max-w-2xl"
35
+ }
36
+ },
37
+ defaultVariants: {
38
+ placement: "center",
39
+ size: "md"
40
+ }
41
+ });
42
+ const Dialog = Dialog$1.Root;
43
+ /** Opens the dialog. Use `render={<Button />}` to show it as a kit button. */
44
+ const DialogTrigger = Dialog$1.Trigger;
45
+ /**
46
+ * The dialog box. `placement="right"` makes it a side panel (record details, filters, quick edit).
47
+ * Compose with DialogHeader, DialogBody and DialogFooter; DialogTitle is required for a name.
48
+ */
49
+ const DialogContent = forwardRef(function DialogContent({ className, placement, size, showClose = true, children, ...props }, ref) {
50
+ return /* @__PURE__ */ jsxs(Dialog$1.Portal, { children: [/* @__PURE__ */ jsx(Dialog$1.Backdrop, { className: overlayBackdrop }), /* @__PURE__ */ jsxs(Dialog$1.Popup, {
51
+ ref,
52
+ className: cn(popup({
53
+ placement,
54
+ size
55
+ }), className),
56
+ ...props,
57
+ children: [children, showClose && /* @__PURE__ */ jsx(Dialog$1.Close, { render: /* @__PURE__ */ jsx(IconButton, {
58
+ label: "Close",
59
+ size: "sm",
60
+ tooltip: false,
61
+ className: "absolute top-3.5 right-3.5",
62
+ children: /* @__PURE__ */ jsx(X, {})
63
+ }) })]
64
+ })] });
65
+ });
66
+ function DialogHeader({ className, children }) {
67
+ return /* @__PURE__ */ jsx("div", {
68
+ className: cn("flex flex-col gap-1 px-5 pt-5 pr-12", className),
69
+ children
70
+ });
71
+ }
72
+ const DialogTitle = forwardRef(function DialogTitle({ className, ...props }, ref) {
73
+ return /* @__PURE__ */ jsx(Dialog$1.Title, {
74
+ ref,
75
+ className: cn("text-lg font-semibold", className),
76
+ ...props
77
+ });
78
+ });
79
+ const DialogDescription = forwardRef(function DialogDescription({ className, ...props }, ref) {
80
+ return /* @__PURE__ */ jsx(Dialog$1.Description, {
81
+ ref,
82
+ className: cn("text-sm text-fg-muted", className),
83
+ ...props
84
+ });
85
+ });
86
+ /** Scrollable middle section. */
87
+ function DialogBody({ className, children }) {
88
+ return /* @__PURE__ */ jsx("div", {
89
+ className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-4", className),
90
+ children
91
+ });
92
+ }
93
+ /** Actions row: secondary actions first, the main action last (rightmost). */
94
+ function DialogFooter({ className, children }) {
95
+ return /* @__PURE__ */ jsx("div", {
96
+ className: cn("flex flex-col-reverse gap-2 border-t border-border px-5 pt-3 sm:flex-row sm:justify-end", "pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:pb-3", className),
97
+ children
98
+ });
99
+ }
100
+ /** Closes the dialog. Use `render={<Button variant="secondary" />}`. */
101
+ const DialogClose = Dialog$1.Close;
102
+ export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, overlayBackdrop };
@@ -0,0 +1,28 @@
1
+ import { DialogContentProps } from "./dialog.js";
2
+ import { ReactNode } from "react";
3
+ export interface FormPanelProps {
4
+ title: ReactNode;
5
+ description?: ReactNode;
6
+ /** Called on Cancel, Escape, the close button or a click outside, unless saving. */
7
+ onClose: () => void;
8
+ /** Called when the form is submitted (the browser's own validation runs first). */
9
+ onSubmit: () => unknown;
10
+ /** While saving, the panel cannot close and the buttons are disabled. */
11
+ pending: boolean;
12
+ /** The last failed save as a message for the user, shown above the fields. */
13
+ error?: ReactNode;
14
+ submitDisabled?: boolean;
15
+ /** Defaults to "Save". */
16
+ submitLabel?: string;
17
+ /** Defaults to "Saving…". */
18
+ pendingLabel?: string;
19
+ /** Defaults to "Cancel". */
20
+ cancelLabel?: string;
21
+ size?: DialogContentProps['size'];
22
+ children: ReactNode;
23
+ }
24
+ /**
25
+ * A create or edit form in a side panel: title, fields, the last error, Cancel and Save. Render it
26
+ * while the panel should be open; the values stay as entered when a save fails.
27
+ */
28
+ export declare function FormPanel({ title, description, onClose, onSubmit, pending, error, submitDisabled, submitLabel, pendingLabel, cancelLabel, size, children }: FormPanelProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { Button } from "../button/button.js";
2
+ import { Alert } from "../feedback/alert.js";
3
+ import { Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./dialog.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/dialog/form-panel.tsx
6
+ /**
7
+ * A create or edit form in a side panel: title, fields, the last error, Cancel and Save. Render it
8
+ * while the panel should be open; the values stay as entered when a save fails.
9
+ */
10
+ function FormPanel({ title, description, onClose, onSubmit, pending, error, submitDisabled, submitLabel = "Save", pendingLabel = "Saving…", cancelLabel = "Cancel", size, children }) {
11
+ return /* @__PURE__ */ jsx(Dialog, {
12
+ open: true,
13
+ onOpenChange: (open) => {
14
+ if (!open && !pending) onClose();
15
+ },
16
+ children: /* @__PURE__ */ jsx(DialogContent, {
17
+ placement: "right",
18
+ size,
19
+ children: /* @__PURE__ */ jsxs("form", {
20
+ className: "flex min-h-0 flex-1 flex-col",
21
+ onSubmit: (event) => {
22
+ event.preventDefault();
23
+ onSubmit();
24
+ },
25
+ children: [
26
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), description && /* @__PURE__ */ jsx(DialogDescription, { children: description })] }),
27
+ /* @__PURE__ */ jsxs(DialogBody, {
28
+ className: "flex flex-col gap-4",
29
+ children: [error ? /* @__PURE__ */ jsx(Alert, {
30
+ tone: "danger",
31
+ children: error
32
+ }) : null, children]
33
+ }),
34
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
35
+ type: "button",
36
+ variant: "secondary",
37
+ disabled: pending,
38
+ onClick: onClose,
39
+ children: cancelLabel
40
+ }), /* @__PURE__ */ jsx(Button, {
41
+ type: "submit",
42
+ disabled: pending || submitDisabled,
43
+ "aria-busy": pending || void 0,
44
+ children: pending ? pendingLabel : submitLabel
45
+ })] })
46
+ ]
47
+ })
48
+ })
49
+ });
50
+ }
51
+ export { FormPanel };
@@ -0,0 +1,29 @@
1
+ import { HTMLAttributes, ReactNode } from "react";
2
+ declare const icons: {
3
+ readonly neutral: import("lucide-react").LucideIcon;
4
+ readonly info: import("lucide-react").LucideIcon;
5
+ readonly success: import("lucide-react").LucideIcon;
6
+ readonly warning: import("lucide-react").LucideIcon;
7
+ readonly danger: import("lucide-react").LucideIcon;
8
+ };
9
+ export type AlertTone = keyof typeof icons;
10
+ export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
11
+ tone?: AlertTone;
12
+ /** A short summary in bold. The children add detail. */
13
+ title?: ReactNode;
14
+ /** A button or link for the next step, e.g. "Review payouts". */
15
+ action?: ReactNode;
16
+ /** Shows a close button. Omit for messages the user must not dismiss. */
17
+ onDismiss?: () => void;
18
+ /**
19
+ * Announce the message when it appears. Defaults to true for `danger`; use it for messages that
20
+ * appear after an action, not for notes present when the page loads.
21
+ */
22
+ live?: boolean;
23
+ }
24
+ /**
25
+ * An inline message about the page or a region: a warning, a result or a note. For a failed load
26
+ * use `ErrorState`; for a passing confirmation after an action, use the app's toast.
27
+ */
28
+ export declare const Alert: import("react").ForwardRefExoticComponent<AlertProps & import("react").RefAttributes<HTMLDivElement>>;
29
+ export {};
@@ -0,0 +1,70 @@
1
+ import { cn } from "../lib/cn.js";
2
+ import { inlineIconButton } from "../lib/popup.js";
3
+ import { cva } from "class-variance-authority";
4
+ import { forwardRef } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { AlertTriangle, CircleCheck, Info, OctagonAlert, X } from "lucide-react";
7
+ // src/feedback/alert.tsx
8
+ const alert = cva("flex items-start gap-3 rounded-lg border px-4 py-3 text-sm", {
9
+ variants: { tone: {
10
+ neutral: "border-border bg-surface-muted text-fg",
11
+ info: "border-transparent bg-info-soft text-on-info-soft",
12
+ success: "border-transparent bg-success-soft text-on-success-soft",
13
+ warning: "border-transparent bg-warning-soft text-on-warning-soft",
14
+ danger: "border-transparent bg-danger-soft text-on-danger-soft"
15
+ } },
16
+ defaultVariants: { tone: "info" }
17
+ });
18
+ const icons = {
19
+ neutral: Info,
20
+ info: Info,
21
+ success: CircleCheck,
22
+ warning: AlertTriangle,
23
+ danger: OctagonAlert
24
+ };
25
+ /**
26
+ * An inline message about the page or a region: a warning, a result or a note. For a failed load
27
+ * use `ErrorState`; for a passing confirmation after an action, use the app's toast.
28
+ */
29
+ const Alert = forwardRef(function Alert({ tone = "info", title, action, onDismiss, live, className, children, ...props }, ref) {
30
+ const Icon = icons[tone];
31
+ return /* @__PURE__ */ jsxs("div", {
32
+ ref,
33
+ role: live ?? tone === "danger" ? tone === "danger" ? "alert" : "status" : void 0,
34
+ className: cn(alert({ tone }), className),
35
+ ...props,
36
+ children: [
37
+ /* @__PURE__ */ jsx(Icon, {
38
+ className: "mt-0.5 size-4 shrink-0",
39
+ "aria-hidden": true
40
+ }),
41
+ /* @__PURE__ */ jsxs("div", {
42
+ className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-4 gap-y-2",
43
+ children: [/* @__PURE__ */ jsxs("div", {
44
+ className: "min-w-[min(100%,14rem)] flex-1 space-y-0.5",
45
+ children: [title && /* @__PURE__ */ jsx("p", {
46
+ className: "font-semibold",
47
+ children: title
48
+ }), children && /* @__PURE__ */ jsx("div", {
49
+ className: "[&_a]:font-medium [&_a]:underline",
50
+ children
51
+ })]
52
+ }), action && /* @__PURE__ */ jsx("div", {
53
+ className: "flex shrink-0 flex-wrap items-center gap-2",
54
+ children: action
55
+ })]
56
+ }),
57
+ onDismiss && /* @__PURE__ */ jsx("button", {
58
+ type: "button",
59
+ "aria-label": "Dismiss",
60
+ onClick: onDismiss,
61
+ className: cn(inlineIconButton, "-my-0.5 -mr-1 text-current hover:text-current"),
62
+ children: /* @__PURE__ */ jsx(X, {
63
+ className: "size-4",
64
+ "aria-hidden": true
65
+ })
66
+ })
67
+ ]
68
+ });
69
+ });
70
+ export { Alert };
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from "react";
2
+ import { Progress } from "@base-ui/react/progress";
3
+ export interface ProgressBarProps extends Omit<Progress.Root.Props, 'className' | 'children'> {
4
+ /** What is progressing, e.g. "Import progress". Shown above the bar unless `hideLabel`. */
5
+ label: ReactNode;
6
+ /** Keep the label for screen readers only. */
7
+ hideLabel?: boolean;
8
+ /** Show the formatted value (e.g. "40%") beside the label. */
9
+ showValue?: boolean;
10
+ tone?: 'brand' | 'success' | 'warning' | 'danger';
11
+ className?: string;
12
+ }
13
+ /**
14
+ * A horizontal bar for a task's progress. Pass `value={null}` while the amount is unknown.
15
+ * For a share of a target (not a running task), the same bar works: say so in the label.
16
+ */
17
+ export declare function ProgressBar({ label, hideLabel, showValue, tone, value, className, ...props }: ProgressBarProps): import("react").JSX.Element;
18
+ export interface SpinnerProps {
19
+ /** Announced to screen readers, e.g. "Saving farmer". Omit when nearby text already says it. */
20
+ label?: string;
21
+ size?: 'sm' | 'md' | 'lg';
22
+ className?: string;
23
+ }
24
+ /** A small busy indicator for a button or a region that is waiting. Prefer Skeleton for loads. */
25
+ export declare function Spinner({ label, size, className }: SpinnerProps): import("react").JSX.Element;