@dirstack/ui 1.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 +67 -0
- package/dist/components/animated-number.d.ts +18 -0
- package/dist/components/animated-number.d.ts.map +1 -0
- package/dist/components/animated-number.js +29 -0
- package/dist/components/animated-number.js.map +1 -0
- package/dist/components/avatar.d.ts +8 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +27 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +58 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +51 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +63 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +66 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/callout.d.ts +41 -0
- package/dist/components/callout.d.ts.map +1 -0
- package/dist/components/callout.js +49 -0
- package/dist/components/callout.js.map +1 -0
- package/dist/components/card.d.ts +61 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +67 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/chart.d.ts +32 -0
- package/dist/components/chart.d.ts.map +1 -0
- package/dist/components/chart.js +121 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/copy-button.d.ts +22 -0
- package/dist/components/copy-button.d.ts.map +1 -0
- package/dist/components/copy-button.js +50 -0
- package/dist/components/copy-button.js.map +1 -0
- package/dist/components/copy-input.d.ts +13 -0
- package/dist/components/copy-input.d.ts.map +1 -0
- package/dist/components/copy-input.js +28 -0
- package/dist/components/copy-input.js.map +1 -0
- package/dist/components/detail-row.d.ts +93 -0
- package/dist/components/detail-row.d.ts.map +1 -0
- package/dist/components/detail-row.js +69 -0
- package/dist/components/detail-row.js.map +1 -0
- package/dist/components/dialog.d.ts +173 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +139 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/empty-state.d.ts +96 -0
- package/dist/components/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state.js +69 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/entity-avatar.d.ts +77 -0
- package/dist/components/entity-avatar.d.ts.map +1 -0
- package/dist/components/entity-avatar.js +48 -0
- package/dist/components/entity-avatar.js.map +1 -0
- package/dist/components/form-row.d.ts +35 -0
- package/dist/components/form-row.d.ts.map +1 -0
- package/dist/components/form-row.js +46 -0
- package/dist/components/form-row.js.map +1 -0
- package/dist/components/form-section.d.ts +24 -0
- package/dist/components/form-section.d.ts.map +1 -0
- package/dist/components/form-section.js +39 -0
- package/dist/components/form-section.js.map +1 -0
- package/dist/components/form.d.ts +28 -0
- package/dist/components/form.d.ts.map +1 -0
- package/dist/components/form.js +88 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/heading.d.ts +44 -0
- package/dist/components/heading.d.ts.map +1 -0
- package/dist/components/heading.js +45 -0
- package/dist/components/heading.js.map +1 -0
- package/dist/components/input.d.ts +55 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +33 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/kbd.d.ts +28 -0
- package/dist/components/kbd.d.ts.map +1 -0
- package/dist/components/kbd.js +31 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +21 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/label.js +21 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/menu.d.ts +22 -0
- package/dist/components/menu.d.ts.map +1 -0
- package/dist/components/menu.js +73 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/nav-button.d.ts +34 -0
- package/dist/components/nav-button.d.ts.map +1 -0
- package/dist/components/nav-button.js +70 -0
- package/dist/components/nav-button.js.map +1 -0
- package/dist/components/nav.d.ts +44 -0
- package/dist/components/nav.d.ts.map +1 -0
- package/dist/components/nav.js +53 -0
- package/dist/components/nav.js.map +1 -0
- package/dist/components/number-input.d.ts +18 -0
- package/dist/components/number-input.d.ts.map +1 -0
- package/dist/components/number-input.js +25 -0
- package/dist/components/number-input.js.map +1 -0
- package/dist/components/page.d.ts +24 -0
- package/dist/components/page.d.ts.map +1 -0
- package/dist/components/page.js +24 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/pagination.d.ts +17 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/pagination.js +63 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +8 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +24 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/search-input.d.ts +14 -0
- package/dist/components/search-input.d.ts.map +1 -0
- package/dist/components/search-input.js +36 -0
- package/dist/components/search-input.js.map +1 -0
- package/dist/components/section-header.d.ts +107 -0
- package/dist/components/section-header.d.ts.map +1 -0
- package/dist/components/section-header.js +147 -0
- package/dist/components/section-header.js.map +1 -0
- package/dist/components/select.d.ts +17 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +94 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/skeleton.d.ts +5 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +13 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/stack.d.ts +54 -0
- package/dist/components/stack.d.ts.map +1 -0
- package/dist/components/stack.js +46 -0
- package/dist/components/stack.js.map +1 -0
- package/dist/components/stat-strip.d.ts +38 -0
- package/dist/components/stat-strip.d.ts.map +1 -0
- package/dist/components/stat-strip.js +57 -0
- package/dist/components/stat-strip.js.map +1 -0
- package/dist/components/steps.d.ts +19 -0
- package/dist/components/steps.d.ts.map +1 -0
- package/dist/components/steps.js +29 -0
- package/dist/components/steps.js.map +1 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +17 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.d.ts +62 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +64 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +9 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +18 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toaster.d.ts +6 -0
- package/dist/components/toaster.d.ts.map +1 -0
- package/dist/components/toaster.js +37 -0
- package/dist/components/toaster.js.map +1 -0
- package/dist/components/tooltip.d.ts +15 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +41 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/lib/animation.d.ts +12 -0
- package/dist/lib/animation.d.ts.map +1 -0
- package/dist/lib/animation.js +14 -0
- package/dist/lib/animation.js.map +1 -0
- package/dist/lib/classes.d.ts +29 -0
- package/dist/lib/classes.d.ts.map +1 -0
- package/dist/lib/classes.js +39 -0
- package/dist/lib/classes.js.map +1 -0
- package/dist/lib/icons.d.ts +21 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/dist/lib/icons.js +43 -0
- package/dist/lib/icons.js.map +1 -0
- package/dist/lib/interactive.d.ts +41 -0
- package/dist/lib/interactive.d.ts.map +1 -0
- package/dist/lib/interactive.js +30 -0
- package/dist/lib/interactive.js.map +1 -0
- package/dist/lib/slot.d.ts +12 -0
- package/dist/lib/slot.d.ts.map +1 -0
- package/dist/lib/slot.js +19 -0
- package/dist/lib/slot.js.map +1 -0
- package/dist/lib/variants.d.ts +3 -0
- package/dist/lib/variants.js +3 -0
- package/dist/styles.css +169 -0
- package/package.json +112 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ControllerProps, ControllerRenderProps, FieldPath, FieldValues } from "react-hook-form";
|
|
3
|
+
//#region src/components/form-row.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `stack` puts the label above a full-width control, for dialogs and the checkout form;
|
|
6
|
+
* `rows` puts the label and its description beside the control, for a `divide-y`
|
|
7
|
+
* settings-style body.
|
|
8
|
+
*/
|
|
9
|
+
export type FormRowLayout = "rows" | "stack";
|
|
10
|
+
type FormRowProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues> = Omit<ControllerProps<TFieldValues, TName, TTransformedValues>, "render"> & {
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
isRequired?: boolean;
|
|
14
|
+
layout?: FormRowLayout;
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Extra classes for the label itself, e.g. `text-xs` in a dense fieldset or
|
|
18
|
+
* `sr-only` where the surrounding row already names the control.
|
|
19
|
+
*/
|
|
20
|
+
labelClassName?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Extra classes for the value column in `rows` layout, e.g. `sm:items-end`
|
|
23
|
+
* to keep a switch at its intrinsic width instead of stretching.
|
|
24
|
+
*/
|
|
25
|
+
valueClassName?: string;
|
|
26
|
+
children: (field: ControllerRenderProps<TFieldValues, TName>) => ReactNode;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* One labelled form field in whichever frame the surrounding form asked for. Both layouts
|
|
30
|
+
* keep the `FormItem` / `FormLabel` / `FormControl` / `FormMessage` wiring, so validation,
|
|
31
|
+
* `htmlFor`, and the `aria-describedby` links behave the same either way.
|
|
32
|
+
*/
|
|
33
|
+
export declare function FormRow<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues>({ label, description, isRequired, layout, className, labelClassName, valueClassName, children, ...props }: FormRowProps<TFieldValues, TName, TTransformedValues>): import("react").JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
//# sourceMappingURL=form-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-row.d.ts","names":[],"sources":["../../src/components/form-row.tsx"],"mappings":";;;;;;;;YAsBY;KAEP,aACH,qBAAqB,cAAc,aACnC,cAAc,UAAU,gBAAgB,UAAU,eAClD,qBAAqB,gBACnB,KAAK,gBAAgB,cAAc,OAAO;EAC5C,OAAO;EACP,cAAc;EACd;EACA,SAAS;EACT;;;;;EAKA;;;;;EAKA;EACA,WAAW,OAAO,sBAAsB,cAAc,WAAW;;;;;;;wBAQnD,QACd,qBAAqB,cAAc,aACnC,cAAc,UAAU,gBAAgB,UAAU,eAClD,qBAAqB,gBAErB,OACA,aACA,YACA,QACA,WACA,gBACA,gBACA,aACG,SACF,aAAa,cAAc,OAAO,sCAAmB,IAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DetailRow } from "./detail-row.js";
|
|
2
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "./form.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/form-row.tsx
|
|
5
|
+
/**
|
|
6
|
+
* One labelled form field in whichever frame the surrounding form asked for. Both layouts
|
|
7
|
+
* keep the `FormItem` / `FormLabel` / `FormControl` / `FormMessage` wiring, so validation,
|
|
8
|
+
* `htmlFor`, and the `aria-describedby` links behave the same either way.
|
|
9
|
+
*/
|
|
10
|
+
function FormRow({ label, description, isRequired, layout = "stack", className, labelClassName, valueClassName, children, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
12
|
+
...props,
|
|
13
|
+
render: ({ field }) => {
|
|
14
|
+
if (layout === "rows") return /* @__PURE__ */ jsxs(DetailRow, {
|
|
15
|
+
density: "form",
|
|
16
|
+
render: /* @__PURE__ */ jsx(FormItem, {}),
|
|
17
|
+
label: /* @__PURE__ */ jsx(FormLabel, {
|
|
18
|
+
isRequired,
|
|
19
|
+
className: labelClassName,
|
|
20
|
+
children: label
|
|
21
|
+
}),
|
|
22
|
+
description: description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
23
|
+
className,
|
|
24
|
+
valueClassName,
|
|
25
|
+
children: [/* @__PURE__ */ jsx(FormControl, { children: children(field) }), /* @__PURE__ */ jsx(FormMessage, {})]
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxs(FormItem, {
|
|
28
|
+
className,
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(FormLabel, {
|
|
31
|
+
isRequired,
|
|
32
|
+
className: labelClassName,
|
|
33
|
+
children: label
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ jsx(FormControl, { children: children(field) }),
|
|
36
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
37
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { FormRow };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=form-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-row.js","names":[],"sources":["../../src/components/form-row.tsx"],"sourcesContent":["import type { ReactNode } from \"react\"\nimport type {\n ControllerProps,\n ControllerRenderProps,\n FieldPath,\n FieldValues,\n} from \"react-hook-form\"\nimport { DetailRow } from \"~/components/detail-row\"\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from \"~/components/form\"\n\n/**\n * `stack` puts the label above a full-width control, for dialogs and the checkout form;\n * `rows` puts the label and its description beside the control, for a `divide-y`\n * settings-style body.\n */\nexport type FormRowLayout = \"rows\" | \"stack\"\n\ntype FormRowProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n> = Omit<ControllerProps<TFieldValues, TName, TTransformedValues>, \"render\"> & {\n label: ReactNode\n description?: ReactNode\n isRequired?: boolean\n layout?: FormRowLayout\n className?: string\n /**\n * Extra classes for the label itself, e.g. `text-xs` in a dense fieldset or\n * `sr-only` where the surrounding row already names the control.\n */\n labelClassName?: string\n /**\n * Extra classes for the value column in `rows` layout, e.g. `sm:items-end`\n * to keep a switch at its intrinsic width instead of stretching.\n */\n valueClassName?: string\n children: (field: ControllerRenderProps<TFieldValues, TName>) => ReactNode\n}\n\n/**\n * One labelled form field in whichever frame the surrounding form asked for. Both layouts\n * keep the `FormItem` / `FormLabel` / `FormControl` / `FormMessage` wiring, so validation,\n * `htmlFor`, and the `aria-describedby` links behave the same either way.\n */\nexport function FormRow<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n>({\n label,\n description,\n isRequired,\n layout = \"stack\",\n className,\n labelClassName,\n valueClassName,\n children,\n ...props\n}: FormRowProps<TFieldValues, TName, TTransformedValues>) {\n return (\n <FormField\n {...props}\n render={({ field }) => {\n if (layout === \"rows\") {\n return (\n <DetailRow\n density=\"form\"\n render={<FormItem />}\n label={\n <FormLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FormLabel>\n }\n description={description && <FormDescription>{description}</FormDescription>}\n className={className}\n valueClassName={valueClassName}\n >\n <FormControl>{children(field)}</FormControl>\n\n <FormMessage />\n </DetailRow>\n )\n }\n\n return (\n <FormItem className={className}>\n <FormLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FormLabel>\n\n <FormControl>{children(field)}</FormControl>\n\n {description && <FormDescription>{description}</FormDescription>}\n\n <FormMessage />\n </FormItem>\n )\n }}\n />\n )\n}\n"],"mappings":";;;;;;;;;AAoDA,SAAgB,QAId,EACA,OACA,aACA,YACA,SAAS,SACT,WACA,gBACA,gBACA,UACA,GAAG,SACqD;CACxD,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,SAAS,EAAE,YAAY;GACrB,IAAI,WAAW,QACb,OACE,qBAAC,WAAD;IACE,SAAQ;IACR,QAAQ,oBAAC,UAAD,CAAW,CAAA;IACnB,OACE,oBAAC,WAAD;KAAuB;KAAY,WAAW;KAC3C,UAAA;IACQ,CAAA;IAEb,aAAa,eAAe,oBAAC,iBAAD,EAAA,UAAkB,YAA6B,CAAA;IAChE;IACK;IAVlB,UAAA,CAYE,oBAAC,aAAD,EAAA,UAAc,SAAS,KAAK,EAAe,CAAA,GAE3C,oBAAC,aAAD,CAAc,CAAA,CACL;;GAIf,OACE,qBAAC,UAAD;IAAqB;IAArB,UAAA;KACE,oBAAC,WAAD;MAAuB;MAAY,WAAW;MAC3C,UAAA;KACQ,CAAA;KAEX,oBAAC,aAAD,EAAA,UAAc,SAAS,KAAK,EAAe,CAAA;KAE1C,eAAe,oBAAC,iBAAD,EAAA,UAAkB,YAA6B,CAAA;KAE/D,oBAAC,aAAD,CAAc,CAAA;IACN;;EAEd;CACD,CAAA;AAEL"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/components/form-section.d.ts
|
|
4
|
+
type FormSectionProps = Omit<useRender.ComponentProps<"section">, "title"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Optional heading. Leave it out inside the settings dialog, whose header owns the title.
|
|
8
|
+
*/
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Right-aligned actions after the rows, e.g. a save button. Rendered as the last row.
|
|
14
|
+
*/
|
|
15
|
+
footer?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A block of settings: one padded container whose children (optional heading, the rows,
|
|
19
|
+
* optional footer) stack with hairlines between them. Renders as a `<form>` via `render`
|
|
20
|
+
* when the rows are fields, so the form is the only wrapper.
|
|
21
|
+
*/
|
|
22
|
+
export declare function FormSection({ id, title, description, actions, footer, className, children, render, ...props }: FormSectionProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
23
|
+
//#endregion
|
|
24
|
+
//# sourceMappingURL=form-section.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-section.d.ts","names":[],"sources":["../../src/components/form-section.tsx"],"mappings":";;;KAKK,mBAAmB,KAAK,UAAU;EACrC;;;;EAIA,QAAQ;EACR,cAAc;EACd,UAAU;;;;EAIV,SAAS;;;;;;;wBAQK,cACd,IACA,OACA,aACA,SACA,QACA,WACA,UACA,WACG,SACF,mCAAgB,+CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cn } from "../lib/variants.js";
|
|
2
|
+
import { SectionHeader } from "./section-header.js";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
+
//#region src/components/form-section.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A block of settings: one padded container whose children (optional heading, the rows,
|
|
8
|
+
* optional footer) stack with hairlines between them. Renders as a `<form>` via `render`
|
|
9
|
+
* when the rows are fields, so the form is the only wrapper.
|
|
10
|
+
*/
|
|
11
|
+
function FormSection({ id, title, description, actions, footer, className, children, render, ...props }) {
|
|
12
|
+
return useRender({
|
|
13
|
+
render,
|
|
14
|
+
defaultTagName: "section",
|
|
15
|
+
props: {
|
|
16
|
+
id,
|
|
17
|
+
className: cn("flex flex-col divide-y px-5 md:px-6", className),
|
|
18
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
(title || actions) && /* @__PURE__ */ jsx(SectionHeader, {
|
|
20
|
+
size: "panel",
|
|
21
|
+
className: "py-4",
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
actions
|
|
25
|
+
}),
|
|
26
|
+
children,
|
|
27
|
+
footer && /* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: "flex justify-end py-5",
|
|
29
|
+
children: footer
|
|
30
|
+
})
|
|
31
|
+
] }),
|
|
32
|
+
...props
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FormSection };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=form-section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-section.js","names":[],"sources":["../../src/components/form-section.tsx"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\"\nimport type { ReactNode } from \"react\"\nimport { SectionHeader } from \"~/components/section-header\"\nimport { cn } from \"~/lib/variants\"\n\ntype FormSectionProps = Omit<useRender.ComponentProps<\"section\">, \"title\"> & {\n id?: string\n /**\n * Optional heading. Leave it out inside the settings dialog, whose header owns the title.\n */\n title?: ReactNode\n description?: ReactNode\n actions?: ReactNode\n /**\n * Right-aligned actions after the rows, e.g. a save button. Rendered as the last row.\n */\n footer?: ReactNode\n}\n\n/**\n * A block of settings: one padded container whose children (optional heading, the rows,\n * optional footer) stack with hairlines between them. Renders as a `<form>` via `render`\n * when the rows are fields, so the form is the only wrapper.\n */\nexport function FormSection({\n id,\n title,\n description,\n actions,\n footer,\n className,\n children,\n render,\n ...props\n}: FormSectionProps) {\n return useRender({\n render,\n defaultTagName: \"section\",\n props: {\n id,\n className: cn(\"flex flex-col divide-y px-5 md:px-6\", className),\n children: (\n <>\n {(title || actions) && (\n <SectionHeader\n size=\"panel\"\n className=\"py-4\"\n title={title}\n description={description}\n actions={actions}\n />\n )}\n\n {children}\n\n {footer && <div className=\"flex justify-end py-5\">{footer}</div>}\n </>\n ),\n ...props,\n },\n })\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,YAAY,EAC1B,IACA,OACA,aACA,SACA,QACA,WACA,UACA,QACA,GAAG,SACgB;CACnB,OAAO,UAAU;EACf;EACA,gBAAgB;EAChB,OAAO;GACL;GACA,WAAW,GAAG,uCAAuC,SAAS;GAC9D,UACE,qBAAA,UAAA,EAAA,UAAA;KACI,SAAS,YACT,oBAAC,eAAD;KACE,MAAK;KACL,WAAU;KACH;KACM;KACJ;IACV,CAAA;IAGF;IAEA,UAAU,oBAAC,OAAD;KAAK,WAAU;KAAyB,UAAA;IAAY,CAAA;GAC/D,EAAA,CAAA;GAEJ,GAAG;EACL;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Stack } from "./stack.js";
|
|
2
|
+
import { Label } from "./label.js";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
import { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
|
|
6
|
+
//#region src/components/form.d.ts
|
|
7
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getErrors, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
8
|
+
declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues>({ ...props }: ControllerProps<TFieldValues, TName, TTransformedValues>): import("react").JSX.Element;
|
|
9
|
+
declare function useFormField(): {
|
|
10
|
+
invalid: boolean;
|
|
11
|
+
isDirty: boolean;
|
|
12
|
+
isTouched: boolean;
|
|
13
|
+
isValidating: boolean;
|
|
14
|
+
error?: import("react-hook-form").FieldError | undefined;
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
formItemId: string;
|
|
18
|
+
formDescriptionId: string;
|
|
19
|
+
formMessageId: string;
|
|
20
|
+
};
|
|
21
|
+
declare function FormItem({ direction, ...props }: ComponentProps<typeof Stack>): import("react").JSX.Element;
|
|
22
|
+
declare function FormLabel({ ...props }: ComponentProps<typeof Label>): import("react").JSX.Element;
|
|
23
|
+
declare function FormControl({ children, render, ...props }: useRender.ComponentProps<"div">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
24
|
+
declare function FormDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
25
|
+
declare function FormMessage({ className, children, ...props }: ComponentProps<"p">): import("react").JSX.Element | null;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
|
|
28
|
+
//# sourceMappingURL=form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.d.ts","names":[],"sources":["../../src/components/form.tsx"],"mappings":";;;;;;cAiBM,OAAI,qBAAA,aAAA,gBAAA,qBAAA,gBAAA,UAAA,OAAA,WAAA,WAAA,eAAA,UAAA,aAAA,UAAA,WAAA,SAAA,WAAA,YAAA,OAAA,oBAAA,cAAA,YAAA,SAAA,UAAA,UAAA,uCAAA,kBAAA,cAAA,UAAA,wBAAA,MAAA,IAAA;iBAWD,UACP,qBAAqB,cAAc,aACnC,cAAc,UAAU,gBAAgB,UAAU,eAClD,qBAAqB,mBAChB,SAAS,gBAAgB,cAAc,OAAO,sCAAmB,IAAA;iBAQ/D;;;;;;;;;;;;iBAgCA,WAAW,cAAyB,SAAS,sBAAsB,yBAAM,IAAA;iBAUzE,eAAe,SAAS,sBAAsB,yBAAM,IAAA;iBAMpD,cAAc,UAAU,WAAW,SAAS,UAAU,wCAAqB,+CAAA;iBAgB3E,kBAAkB,cAAc,SAAS,sCAAmB,IAAA;iBAM5D,cAAc,WAAW,aAAa,SAAS,sCAAmB,IAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/variants.js";
|
|
3
|
+
import { Stack } from "./stack.js";
|
|
4
|
+
import { descriptionClasses } from "../lib/classes.js";
|
|
5
|
+
import { Label } from "./label.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
8
|
+
import { createContext, useContext, useId } from "react";
|
|
9
|
+
import { Controller, FormProvider, useFormContext } from "react-hook-form";
|
|
10
|
+
//#region src/components/form.tsx
|
|
11
|
+
const Form = FormProvider;
|
|
12
|
+
const FormFieldContext = createContext(null);
|
|
13
|
+
function FormField({ ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
15
|
+
value: { name: props.name },
|
|
16
|
+
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function useFormField() {
|
|
20
|
+
const fieldContext = useContext(FormFieldContext);
|
|
21
|
+
const itemContext = useContext(FormItemContext);
|
|
22
|
+
const { getFieldState, formState } = useFormContext();
|
|
23
|
+
if (!fieldContext) throw new Error("useFormField should be used within <FormField>");
|
|
24
|
+
if (!itemContext) throw new Error("useFormField should be used within <FormItem>");
|
|
25
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
26
|
+
const { id } = itemContext;
|
|
27
|
+
return {
|
|
28
|
+
id,
|
|
29
|
+
name: fieldContext.name,
|
|
30
|
+
formItemId: `${id}-form-item`,
|
|
31
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
32
|
+
formMessageId: `${id}-form-item-message`,
|
|
33
|
+
...fieldState
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const FormItemContext = createContext(null);
|
|
37
|
+
function FormItem({ direction = "column", ...props }) {
|
|
38
|
+
const id = useId();
|
|
39
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
40
|
+
value: { id },
|
|
41
|
+
children: /* @__PURE__ */ jsx(Stack, {
|
|
42
|
+
direction,
|
|
43
|
+
...props
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function FormLabel({ ...props }) {
|
|
48
|
+
const { formItemId } = useFormField();
|
|
49
|
+
return /* @__PURE__ */ jsx(Label, {
|
|
50
|
+
htmlFor: formItemId,
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function FormControl({ children, render, ...props }) {
|
|
55
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
56
|
+
return useRender({
|
|
57
|
+
render: render ?? children,
|
|
58
|
+
props: {
|
|
59
|
+
id: formItemId,
|
|
60
|
+
"aria-describedby": !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`,
|
|
61
|
+
"aria-invalid": !!error,
|
|
62
|
+
...props
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function FormDescription({ className, ...props }) {
|
|
67
|
+
const { formDescriptionId } = useFormField();
|
|
68
|
+
return /* @__PURE__ */ jsx("p", {
|
|
69
|
+
id: formDescriptionId,
|
|
70
|
+
className: cn(descriptionClasses, className),
|
|
71
|
+
...props
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function FormMessage({ className, children, ...props }) {
|
|
75
|
+
const { error, formMessageId } = useFormField();
|
|
76
|
+
const body = error ? String(error?.message) : children;
|
|
77
|
+
if (!body) return null;
|
|
78
|
+
return /* @__PURE__ */ jsx("p", {
|
|
79
|
+
id: formMessageId,
|
|
80
|
+
className: cn("text-control font-medium text-danger", className),
|
|
81
|
+
...props,
|
|
82
|
+
children: body
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","names":[],"sources":["../../src/components/form.tsx"],"sourcesContent":["\"use client\"\n\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { type ComponentProps, createContext, useContext, useId } from \"react\"\nimport {\n Controller,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n FormProvider,\n useFormContext,\n} from \"react-hook-form\"\nimport { Label } from \"~/components/label\"\nimport { Stack } from \"~/components/stack\"\nimport { descriptionClasses } from \"~/lib/classes\"\nimport { cn } from \"~/lib/variants\"\n\nconst Form = FormProvider\n\ninterface FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> {\n name: TName\n}\n\nconst FormFieldContext = createContext<FormFieldContextValue | null>(null)\n\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n>({ ...props }: ControllerProps<TFieldValues, TName, TTransformedValues>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nfunction useFormField() {\n const fieldContext = useContext(FormFieldContext)\n const itemContext = useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n if (!itemContext) {\n throw new Error(\"useFormField should be used within <FormItem>\")\n }\n\n const fieldState = getFieldState(fieldContext.name, formState)\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ninterface FormItemContextValue {\n id: string\n}\n\nconst FormItemContext = createContext<FormItemContextValue | null>(null)\n\nfunction FormItem({ direction = \"column\", ...props }: ComponentProps<typeof Stack>) {\n const id = useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <Stack direction={direction} {...props} />\n </FormItemContext.Provider>\n )\n}\n\nfunction FormLabel({ ...props }: ComponentProps<typeof Label>) {\n const { formItemId } = useFormField()\n\n return <Label htmlFor={formItemId} {...props} />\n}\n\nfunction FormControl({ children, render, ...props }: useRender.ComponentProps<\"div\">) {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n // Renders *as* its single child (the form field), merging id/aria onto it —\n // the Base UI equivalent of Radix's `<Slot>`.\n return useRender({\n render: render ?? (children as useRender.RenderProp),\n props: {\n id: formItemId,\n \"aria-describedby\": !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`,\n \"aria-invalid\": !!error,\n ...props,\n },\n })\n}\n\nfunction FormDescription({ className, ...props }: ComponentProps<\"p\">) {\n const { formDescriptionId } = useFormField()\n\n return <p id={formDescriptionId} className={cn(descriptionClasses, className)} {...props} />\n}\n\nfunction FormMessage({ className, children, ...props }: ComponentProps<\"p\">) {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message) : children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n id={formMessageId}\n className={cn(\"text-control font-medium text-danger\", className)}\n {...props}\n >\n {body}\n </p>\n )\n}\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n}\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,OAAO;AASb,MAAM,mBAAmB,cAA4C,IAAI;AAEzE,SAAS,UAIP,EAAE,GAAG,SAAmE;CACxE,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,EAAE,MAAM,MAAM,KAAK;EACnD,UAAA,oBAAC,YAAD,EAAY,GAAI,MAAQ,CAAA;CACC,CAAA;AAE/B;AAEA,SAAS,eAAe;CACtB,MAAM,eAAe,WAAW,gBAAgB;CAChD,MAAM,cAAc,WAAW,eAAe;CAC9C,MAAM,EAAE,eAAe,cAAc,eAAe;CAEpD,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,gDAAgD;CAGlE,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,+CAA+C;CAGjE,MAAM,aAAa,cAAc,aAAa,MAAM,SAAS;CAC7D,MAAM,EAAE,OAAO;CAEf,OAAO;EACL;EACA,MAAM,aAAa;EACnB,YAAY,GAAG,GAAG;EAClB,mBAAmB,GAAG,GAAG;EACzB,eAAe,GAAG,GAAG;EACrB,GAAG;CACL;AACF;AAMA,MAAM,kBAAkB,cAA2C,IAAI;AAEvE,SAAS,SAAS,EAAE,YAAY,UAAU,GAAG,SAAuC;CAClF,MAAM,KAAK,MAAM;CAEjB,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO,EAAE,GAAG;EACpC,UAAA,oBAAC,OAAD;GAAkB;GAAW,GAAI;EAAQ,CAAA;CACjB,CAAA;AAE9B;AAEA,SAAS,UAAU,EAAE,GAAG,SAAuC;CAC7D,MAAM,EAAE,eAAe,aAAa;CAEpC,OAAO,oBAAC,OAAD;EAAO,SAAS;EAAY,GAAI;CAAQ,CAAA;AACjD;AAEA,SAAS,YAAY,EAAE,UAAU,QAAQ,GAAG,SAA0C;CACpF,MAAM,EAAE,OAAO,YAAY,mBAAmB,kBAAkB,aAAa;CAI7E,OAAO,UAAU;EACf,QAAQ,UAAW;EACnB,OAAO;GACL,IAAI;GACJ,oBAAoB,CAAC,QAAQ,oBAAoB,GAAG,kBAAkB,GAAG;GACzE,gBAAgB,CAAC,CAAC;GAClB,GAAG;EACL;CACF,CAAC;AACH;AAEA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAA8B;CACrE,MAAM,EAAE,sBAAsB,aAAa;CAE3C,OAAO,oBAAC,KAAD;EAAG,IAAI;EAAmB,WAAW,GAAG,oBAAoB,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC7F;AAEA,SAAS,YAAY,EAAE,WAAW,UAAU,GAAG,SAA8B;CAC3E,MAAM,EAAE,OAAO,kBAAkB,aAAa;CAC9C,MAAM,OAAO,QAAQ,OAAO,OAAO,OAAO,IAAI;CAE9C,IAAI,CAAC,MACH,OAAO;CAGT,OACE,oBAAC,KAAD;EACE,IAAI;EACJ,WAAW,GAAG,wCAAwC,SAAS;EAC/D,GAAI;EAEH,UAAA;CACA,CAAA;AAEP"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { ElementType, JSX } from "react";
|
|
4
|
+
//#region src/components/heading.d.ts
|
|
5
|
+
declare const headingVariants: import("tailwind-variants").TVReturnType<{
|
|
6
|
+
size: {
|
|
7
|
+
h1: "text-3xl text-pretty font-semibold md:text-4xl";
|
|
8
|
+
h2: "text-2xl font-semibold md:text-3xl";
|
|
9
|
+
h3: "text-2xl";
|
|
10
|
+
h4: "text-xl";
|
|
11
|
+
h5: "text-base font-medium tracking-micro";
|
|
12
|
+
h6: "text-sm font-medium";
|
|
13
|
+
};
|
|
14
|
+
}, undefined, "font-display font-medium", {
|
|
15
|
+
size: {
|
|
16
|
+
h1: "text-3xl text-pretty font-semibold md:text-4xl";
|
|
17
|
+
h2: "text-2xl font-semibold md:text-3xl";
|
|
18
|
+
h3: "text-2xl";
|
|
19
|
+
h4: "text-xl";
|
|
20
|
+
h5: "text-base font-medium tracking-micro";
|
|
21
|
+
h6: "text-sm font-medium";
|
|
22
|
+
};
|
|
23
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
24
|
+
size: {
|
|
25
|
+
h1: "text-3xl text-pretty font-semibold md:text-4xl";
|
|
26
|
+
h2: "text-2xl font-semibold md:text-3xl";
|
|
27
|
+
h3: "text-2xl";
|
|
28
|
+
h4: "text-xl";
|
|
29
|
+
h5: "text-base font-medium tracking-micro";
|
|
30
|
+
h6: "text-sm font-medium";
|
|
31
|
+
};
|
|
32
|
+
}, undefined>>;
|
|
33
|
+
export type HeadingProps = Omit<useRender.ComponentProps<"h2">, "size"> & VariantProps<typeof headingVariants> & {
|
|
34
|
+
/**
|
|
35
|
+
* Render as a different element type (h1–h6, span, ...).
|
|
36
|
+
*/
|
|
37
|
+
as?: ElementType;
|
|
38
|
+
};
|
|
39
|
+
declare function Heading({ className, as, render, size, ...props }: HeadingProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
40
|
+
declare function H5(props: HeadingProps): JSX.Element;
|
|
41
|
+
declare function H6(props: HeadingProps): JSX.Element;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { H5, H6, Heading };
|
|
44
|
+
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.d.ts","names":[],"sources":["../../src/components/heading.tsx"],"mappings":";;;;cAIM,6CAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAmBT,eAAe,KAAK,UAAU,gCACxC,oBAAoB;;;;EAIlB,KAAK;;iBAGA,UAAU,WAAW,IAAI,QAAQ,SAAS,SAAS,+BAAY,+CAAA;iBAQ/D,GAAG,OAAO,eAAY,IAAA;iBAItB,GAAG,OAAO,eAAY,IAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { cn, variants } from "../lib/variants.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
//#region src/components/heading.tsx
|
|
5
|
+
const headingVariants = variants({
|
|
6
|
+
base: "font-display font-medium",
|
|
7
|
+
variants: { size: {
|
|
8
|
+
h1: "text-3xl text-pretty font-semibold md:text-4xl",
|
|
9
|
+
h2: "text-2xl font-semibold md:text-3xl",
|
|
10
|
+
h3: "text-2xl",
|
|
11
|
+
h4: "text-xl",
|
|
12
|
+
h5: "text-base font-medium tracking-micro",
|
|
13
|
+
h6: "text-sm font-medium"
|
|
14
|
+
} },
|
|
15
|
+
defaultVariants: { size: "h3" }
|
|
16
|
+
});
|
|
17
|
+
function Heading({ className, as, render, size, ...props }) {
|
|
18
|
+
return useRender({
|
|
19
|
+
render,
|
|
20
|
+
defaultTagName: as ?? size ?? "h2",
|
|
21
|
+
props: {
|
|
22
|
+
className: cn(headingVariants({
|
|
23
|
+
size,
|
|
24
|
+
className
|
|
25
|
+
})),
|
|
26
|
+
...props
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function H5(props) {
|
|
31
|
+
return /* @__PURE__ */ jsx(Heading, {
|
|
32
|
+
size: "h5",
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function H6(props) {
|
|
37
|
+
return /* @__PURE__ */ jsx(Heading, {
|
|
38
|
+
size: "h6",
|
|
39
|
+
...props
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { H5, H6, Heading };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.js","names":[],"sources":["../../src/components/heading.tsx"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\"\nimport type { ElementType, JSX } from \"react\"\nimport { variants, cn, type VariantProps } from \"~/lib/variants\"\n\nconst headingVariants = variants({\n base: \"font-display font-medium\",\n\n variants: {\n size: {\n h1: \"text-3xl text-pretty font-semibold md:text-4xl\",\n h2: \"text-2xl font-semibold md:text-3xl\",\n h3: \"text-2xl\",\n h4: \"text-xl\",\n h5: \"text-base font-medium tracking-micro\",\n h6: \"text-sm font-medium\",\n },\n },\n\n defaultVariants: {\n size: \"h3\",\n },\n})\n\nexport type HeadingProps = Omit<useRender.ComponentProps<\"h2\">, \"size\"> &\n VariantProps<typeof headingVariants> & {\n /**\n * Render as a different element type (h1–h6, span, ...).\n */\n as?: ElementType\n }\n\nfunction Heading({ className, as, render, size, ...props }: HeadingProps) {\n return useRender({\n render,\n defaultTagName: (as ?? size ?? \"h2\") as keyof JSX.IntrinsicElements,\n props: { className: cn(headingVariants({ size, className })), ...props },\n })\n}\n\nfunction H5(props: HeadingProps) {\n return <Heading size=\"h5\" {...props} />\n}\n\nfunction H6(props: HeadingProps) {\n return <Heading size=\"h6\" {...props} />\n}\n\nexport { H5, H6, Heading }\n"],"mappings":";;;;AAIA,MAAM,kBAAkB,SAAS;CAC/B,MAAM;CAEN,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CAEA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC;AAUD,SAAS,QAAQ,EAAE,WAAW,IAAI,QAAQ,MAAM,GAAG,SAAuB;CACxE,OAAO,UAAU;EACf;EACA,gBAAiB,MAAM,QAAQ;EAC/B,OAAO;GAAE,WAAW,GAAG,gBAAgB;IAAE;IAAM;GAAU,CAAC,CAAC;GAAG,GAAG;EAAM;CACzE,CAAC;AACH;AAEA,SAAS,GAAG,OAAqB;CAC/B,OAAO,oBAAC,SAAD;EAAS,MAAK;EAAK,GAAI;CAAQ,CAAA;AACxC;AAEA,SAAS,GAAG,OAAqB;CAC/B,OAAO,oBAAC,SAAD;EAAS,MAAK;EAAK,GAAI;CAAQ,CAAA;AACxC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/components/input.d.ts
|
|
4
|
+
declare const inputVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
size: {
|
|
6
|
+
sm: "px-2 py-1 font-normal rounded-md";
|
|
7
|
+
md: "px-3 py-2 rounded-md";
|
|
8
|
+
lg: "px-4 py-2.5 rounded-lg sm:text-sm";
|
|
9
|
+
};
|
|
10
|
+
}, undefined, "appearance-none min-h-0 w-full self-stretch bg-card text-foreground text-control break-words disabled:text-secondary-foreground/50", {
|
|
11
|
+
hover: {
|
|
12
|
+
true: "not-disabled:cursor-pointer hover:not-disabled:outline-[3px] hover:not-disabled:outline-border/50";
|
|
13
|
+
};
|
|
14
|
+
focus: {
|
|
15
|
+
true: "focus-visible:outline-[3px] focus-visible:outline-border/50";
|
|
16
|
+
};
|
|
17
|
+
bordered: {
|
|
18
|
+
true: "border-border";
|
|
19
|
+
};
|
|
20
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
21
|
+
hover: {
|
|
22
|
+
true: "not-disabled:cursor-pointer hover:not-disabled:outline-[3px] hover:not-disabled:outline-border/50";
|
|
23
|
+
};
|
|
24
|
+
focus: {
|
|
25
|
+
true: "focus-visible:outline-[3px] focus-visible:outline-border/50";
|
|
26
|
+
};
|
|
27
|
+
bordered: {
|
|
28
|
+
true: "border-border";
|
|
29
|
+
};
|
|
30
|
+
}, undefined, "border border-transparent outline-transparent", {
|
|
31
|
+
hover: {
|
|
32
|
+
true: "not-disabled:cursor-pointer hover:not-disabled:outline-[3px] hover:not-disabled:outline-border/50";
|
|
33
|
+
};
|
|
34
|
+
focus: {
|
|
35
|
+
true: "focus-visible:outline-[3px] focus-visible:outline-border/50";
|
|
36
|
+
};
|
|
37
|
+
bordered: {
|
|
38
|
+
true: "border-border";
|
|
39
|
+
};
|
|
40
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
41
|
+
hover: {
|
|
42
|
+
true: "not-disabled:cursor-pointer hover:not-disabled:outline-[3px] hover:not-disabled:outline-border/50";
|
|
43
|
+
};
|
|
44
|
+
focus: {
|
|
45
|
+
true: "focus-visible:outline-[3px] focus-visible:outline-border/50";
|
|
46
|
+
};
|
|
47
|
+
bordered: {
|
|
48
|
+
true: "border-border";
|
|
49
|
+
};
|
|
50
|
+
}, undefined>>>;
|
|
51
|
+
type InputProps = Omit<ComponentProps<"input">, "size"> & VariantProps<typeof inputVariants>;
|
|
52
|
+
declare function Input({ className, hover, focus, size, ...props }: InputProps): import("react").JSX.Element;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { Input, inputVariants };
|
|
55
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","names":[],"sources":["../../src/components/input.tsx"],"mappings":";;;cAIM,2CAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoBd,aAAa,KAAK,mCAAmC,oBAAoB;iBAErE,QAAQ,WAAW,OAAO,OAAO,SAAS,SAAS,6BAAU,IAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cn, variants } from "../lib/variants.js";
|
|
2
|
+
import { interactiveVariants } from "../lib/interactive.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/input.tsx
|
|
5
|
+
const inputVariants = variants({
|
|
6
|
+
extend: interactiveVariants,
|
|
7
|
+
base: "appearance-none min-h-0 w-full self-stretch bg-card text-foreground text-control break-words disabled:text-secondary-foreground/50",
|
|
8
|
+
variants: { size: {
|
|
9
|
+
sm: "px-2 py-1 font-normal rounded-md",
|
|
10
|
+
md: "px-3 py-2 rounded-md",
|
|
11
|
+
lg: "px-4 py-2.5 rounded-lg sm:text-sm"
|
|
12
|
+
} },
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
hover: false,
|
|
15
|
+
focus: true,
|
|
16
|
+
bordered: true,
|
|
17
|
+
size: "md"
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
function Input({ className, hover, focus, size, ...props }) {
|
|
21
|
+
return /* @__PURE__ */ jsx("input", {
|
|
22
|
+
className: cn(inputVariants({
|
|
23
|
+
hover,
|
|
24
|
+
focus,
|
|
25
|
+
size
|
|
26
|
+
}), className),
|
|
27
|
+
...props
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Input, inputVariants };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../src/components/input.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { interactiveVariants } from \"~/lib/interactive\"\nimport { variants, cn, type VariantProps } from \"~/lib/variants\"\n\nconst inputVariants = variants({\n extend: interactiveVariants,\n base: \"appearance-none min-h-0 w-full self-stretch bg-card text-foreground text-control break-words disabled:text-secondary-foreground/50\",\n\n variants: {\n size: {\n sm: \"px-2 py-1 font-normal rounded-md\",\n md: \"px-3 py-2 rounded-md\",\n lg: \"px-4 py-2.5 rounded-lg sm:text-sm\",\n },\n },\n\n defaultVariants: {\n hover: false,\n focus: true,\n bordered: true,\n size: \"md\",\n },\n})\n\ntype InputProps = Omit<ComponentProps<\"input\">, \"size\"> & VariantProps<typeof inputVariants>\n\nfunction Input({ className, hover, focus, size, ...props }: InputProps) {\n return <input className={cn(inputVariants({ hover, focus, size }), className)} {...props} />\n}\n\nexport { Input, inputVariants }\n"],"mappings":";;;;AAIA,MAAM,gBAAgB,SAAS;CAC7B,QAAQ;CACR,MAAM;CAEN,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CAEA,iBAAiB;EACf,OAAO;EACP,OAAO;EACP,UAAU;EACV,MAAM;CACR;AACF,CAAC;AAID,SAAS,MAAM,EAAE,WAAW,OAAO,OAAO,MAAM,GAAG,SAAqB;CACtE,OAAO,oBAAC,SAAD;EAAO,WAAW,GAAG,cAAc;GAAE;GAAO;GAAO;EAAK,CAAC,GAAG,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC7F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/components/kbd.d.ts
|
|
4
|
+
declare const kbdVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
variant: {
|
|
6
|
+
soft: "border-transparent bg-accent";
|
|
7
|
+
secondary: "bg-background";
|
|
8
|
+
};
|
|
9
|
+
}, undefined, "inline-flex gap-[0.1em] -my-0.5 px-[0.4em] py-[0.088em] whitespace-nowrap tabular-nums rounded-sm border text-xs/tight font-medium text-muted-foreground", {
|
|
10
|
+
variant: {
|
|
11
|
+
soft: "border-transparent bg-accent";
|
|
12
|
+
secondary: "bg-background";
|
|
13
|
+
};
|
|
14
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
15
|
+
variant: {
|
|
16
|
+
soft: "border-transparent bg-accent";
|
|
17
|
+
secondary: "bg-background";
|
|
18
|
+
};
|
|
19
|
+
}, undefined>>;
|
|
20
|
+
type KbdProps = ComponentProps<"kbd"> & VariantProps<typeof kbdVariants> & {
|
|
21
|
+
meta?: boolean;
|
|
22
|
+
shift?: boolean;
|
|
23
|
+
alt?: boolean;
|
|
24
|
+
ctrl?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare function Kbd({ children, className, variant, meta, shift, alt, ctrl, ...props }: KbdProps): import("react").JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
//# sourceMappingURL=kbd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kbd.d.ts","names":[],"sources":["../../src/components/kbd.tsx"],"mappings":";;;cAGM,yCAAW;;;;;;;;;;;;;;;;KAeZ,WAAW,wBACd,oBAAoB;EAClB;EACA;EACA;EACA;;wBAGY,MAAM,UAAU,WAAW,SAAS,MAAM,OAAO,KAAK,SAAS,SAAS,2BAAQ,IAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cn, variants } from "../lib/variants.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/kbd.tsx
|
|
4
|
+
const kbdVariants = variants({
|
|
5
|
+
base: "inline-flex gap-[0.1em] -my-0.5 px-[0.4em] py-[0.088em] whitespace-nowrap tabular-nums rounded-sm border text-xs/tight font-medium text-muted-foreground",
|
|
6
|
+
variants: { variant: {
|
|
7
|
+
soft: "border-transparent bg-accent",
|
|
8
|
+
secondary: "bg-background"
|
|
9
|
+
} },
|
|
10
|
+
defaultVariants: { variant: "secondary" }
|
|
11
|
+
});
|
|
12
|
+
function Kbd({ children, className, variant, meta, shift, alt, ctrl, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsxs("kbd", {
|
|
14
|
+
className: cn(kbdVariants({
|
|
15
|
+
variant,
|
|
16
|
+
className
|
|
17
|
+
})),
|
|
18
|
+
...props,
|
|
19
|
+
children: [
|
|
20
|
+
shift && /* @__PURE__ */ jsx("span", { children: "⇧" }),
|
|
21
|
+
meta && /* @__PURE__ */ jsx("span", { children: "⌘" }),
|
|
22
|
+
alt && /* @__PURE__ */ jsx("span", { children: "⌥" }),
|
|
23
|
+
ctrl && /* @__PURE__ */ jsx("span", { children: "⌃" }),
|
|
24
|
+
children && /* @__PURE__ */ jsx("span", { children })
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Kbd };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=kbd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kbd.js","names":[],"sources":["../../src/components/kbd.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { variants, cn, type VariantProps } from \"~/lib/variants\"\n\nconst kbdVariants = variants({\n base: \"inline-flex gap-[0.1em] -my-0.5 px-[0.4em] py-[0.088em] whitespace-nowrap tabular-nums rounded-sm border text-xs/tight font-medium text-muted-foreground\",\n\n variants: {\n variant: {\n soft: \"border-transparent bg-accent\",\n secondary: \"bg-background\",\n },\n },\n\n defaultVariants: {\n variant: \"secondary\",\n },\n})\n\ntype KbdProps = ComponentProps<\"kbd\"> &\n VariantProps<typeof kbdVariants> & {\n meta?: boolean\n shift?: boolean\n alt?: boolean\n ctrl?: boolean\n }\n\nexport function Kbd({ children, className, variant, meta, shift, alt, ctrl, ...props }: KbdProps) {\n return (\n <kbd className={cn(kbdVariants({ variant, className }))} {...props}>\n {shift && <span>⇧</span>}\n {meta && <span>⌘</span>}\n {alt && <span>⌥</span>}\n {ctrl && <span>⌃</span>}\n {children && <span>{children}</span>}\n </kbd>\n )\n}\n"],"mappings":";;;AAGA,MAAM,cAAc,SAAS;CAC3B,MAAM;CAEN,UAAU,EACR,SAAS;EACP,MAAM;EACN,WAAW;CACb,EACF;CAEA,iBAAiB,EACf,SAAS,YACX;AACF,CAAC;AAUD,SAAgB,IAAI,EAAE,UAAU,WAAW,SAAS,MAAM,OAAO,KAAK,MAAM,GAAG,SAAmB;CAChG,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY;GAAE;GAAS;EAAU,CAAC,CAAC;EAAG,GAAI;EAA7D,UAAA;GACG,SAAS,oBAAC,QAAD,EAAA,UAAM,IAAO,CAAA;GACtB,QAAQ,oBAAC,QAAD,EAAA,UAAM,IAAO,CAAA;GACrB,OAAO,oBAAC,QAAD,EAAA,UAAM,IAAO,CAAA;GACpB,QAAQ,oBAAC,QAAD,EAAA,UAAM,IAAO,CAAA;GACrB,YAAY,oBAAC,QAAD,EAAO,SAAe,CAAA;EAChC;;AAET"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/components/label.d.ts
|
|
4
|
+
declare const labelVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
isRequired: {
|
|
6
|
+
true: "after:ml-0.5 after:text-danger after:content-['*']";
|
|
7
|
+
};
|
|
8
|
+
}, undefined, "self-start text-sm font-medium text-foreground [&[for]]:cursor-pointer", {
|
|
9
|
+
isRequired: {
|
|
10
|
+
true: "after:ml-0.5 after:text-danger after:content-['*']";
|
|
11
|
+
};
|
|
12
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
13
|
+
isRequired: {
|
|
14
|
+
true: "after:ml-0.5 after:text-danger after:content-['*']";
|
|
15
|
+
};
|
|
16
|
+
}, undefined>>;
|
|
17
|
+
type LabelProps = ComponentProps<"label"> & VariantProps<typeof labelVariants>;
|
|
18
|
+
declare function Label({ className, isRequired, ...props }: LabelProps): import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Label };
|
|
21
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","names":[],"sources":["../../src/components/label.tsx"],"mappings":";;;cAKM,2CAAa;;;;;;;;;;;;;KAUd,aAAa,0BAA0B,oBAAoB;iBAEvD,QAAQ,WAAW,eAAe,SAAS,6BAAU,IAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn, variants } from "../lib/variants.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/label.tsx
|
|
5
|
+
const labelVariants = variants({
|
|
6
|
+
base: "self-start text-sm font-medium text-foreground [&[for]]:cursor-pointer",
|
|
7
|
+
variants: { isRequired: { true: "after:ml-0.5 after:text-danger after:content-['*']" } }
|
|
8
|
+
});
|
|
9
|
+
function Label({ className, isRequired, ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsx("label", {
|
|
11
|
+
className: cn(labelVariants({
|
|
12
|
+
isRequired,
|
|
13
|
+
className
|
|
14
|
+
})),
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Label };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","names":[],"sources":["../../src/components/label.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ComponentProps } from \"react\"\nimport { cn, variants, type VariantProps } from \"~/lib/variants\"\n\nconst labelVariants = variants({\n base: \"self-start text-sm font-medium text-foreground [&[for]]:cursor-pointer\",\n\n variants: {\n isRequired: {\n true: \"after:ml-0.5 after:text-danger after:content-['*']\",\n },\n },\n})\n\ntype LabelProps = ComponentProps<\"label\"> & VariantProps<typeof labelVariants>\n\nfunction Label({ className, isRequired, ...props }: LabelProps) {\n // oxlint-disable-next-line jsx-a11y/label-has-associated-control -- htmlFor is supplied by callers (e.g. FormLabel)\n return <label className={cn(labelVariants({ isRequired, className }))} {...props} />\n}\n\nexport { Label }\n"],"mappings":";;;;AAKA,MAAM,gBAAgB,SAAS;CAC7B,MAAM;CAEN,UAAU,EACR,YAAY,EACV,MAAM,qDACR,EACF;AACF,CAAC;AAID,SAAS,MAAM,EAAE,WAAW,YAAY,GAAG,SAAqB;CAE9D,OAAO,oBAAC,SAAD;EAAO,WAAW,GAAG,cAAc;GAAE;GAAY;EAAU,CAAC,CAAC;EAAG,GAAI;CAAQ,CAAA;AACrF"}
|