@codefast/ui 0.3.9 → 0.3.11-canary.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/CHANGELOG.md +30 -0
- package/README.md +277 -167
- package/dist/components/accordion.cjs +97 -1
- package/dist/components/accordion.js +51 -1
- package/dist/components/alert-dialog.cjs +155 -1
- package/dist/components/alert-dialog.d.ts +2 -2
- package/dist/components/alert-dialog.js +94 -1
- package/dist/components/alert.cjs +84 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +41 -1
- package/dist/components/aspect-ratio.cjs +43 -1
- package/dist/components/aspect-ratio.js +9 -1
- package/dist/components/avatar.cjs +65 -1
- package/dist/components/avatar.js +25 -1
- package/dist/components/badge.cjs +66 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +29 -1
- package/dist/components/breadcrumb.cjs +124 -1
- package/dist/components/breadcrumb.js +72 -1
- package/dist/components/button-group.cjs +86 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +43 -1
- package/dist/components/button.cjs +92 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +55 -1
- package/dist/components/calendar.cjs +150 -1
- package/dist/components/calendar.d.ts +11 -18
- package/dist/components/calendar.js +113 -1
- package/dist/components/card.cjs +105 -1
- package/dist/components/card.js +53 -1
- package/dist/components/carousel.cjs +210 -1
- package/dist/components/carousel.d.ts +1 -1
- package/dist/components/carousel.js +151 -1
- package/dist/components/chart.cjs +250 -3
- package/dist/components/chart.d.ts +5 -4
- package/dist/components/chart.js +198 -3
- package/dist/components/checkbox-cards.cjs +69 -1
- package/dist/components/checkbox-cards.js +32 -1
- package/dist/components/checkbox-group.cjs +63 -1
- package/dist/components/checkbox-group.js +26 -1
- package/dist/components/checkbox.cjs +53 -1
- package/dist/components/checkbox.js +19 -1
- package/dist/components/collapsible.cjs +61 -1
- package/dist/components/collapsible.js +21 -1
- package/dist/components/command.cjs +167 -1
- package/dist/components/command.js +106 -1
- package/dist/components/context-menu.cjs +218 -1
- package/dist/components/context-menu.js +142 -1
- package/dist/components/dialog.cjs +164 -1
- package/dist/components/dialog.d.ts +2 -2
- package/dist/components/dialog.js +106 -1
- package/dist/components/drawer.cjs +143 -1
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.js +85 -1
- package/dist/components/dropdown-menu.cjs +221 -1
- package/dist/components/dropdown-menu.js +145 -1
- package/dist/components/empty.cjs +113 -1
- package/dist/components/empty.d.ts +1 -1
- package/dist/components/empty.js +61 -1
- package/dist/components/field.cjs +193 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/field.js +129 -1
- package/dist/components/form.cjs +151 -1
- package/dist/components/form.d.ts +3 -3
- package/dist/components/form.js +96 -1
- package/dist/components/hover-card.cjs +77 -1
- package/dist/components/hover-card.js +34 -1
- package/dist/components/input-group.cjs +155 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/input-group.js +97 -1
- package/dist/components/input-number.cjs +98 -1
- package/dist/components/input-number.js +64 -1
- package/dist/components/input-otp.cjs +101 -1
- package/dist/components/input-otp.js +49 -1
- package/dist/components/input-password.cjs +71 -1
- package/dist/components/input-password.js +37 -1
- package/dist/components/input-search.cjs +80 -1
- package/dist/components/input-search.js +46 -1
- package/dist/components/input.cjs +45 -1
- package/dist/components/input.js +11 -1
- package/dist/components/item.cjs +186 -1
- package/dist/components/item.d.ts +1 -1
- package/dist/components/item.js +119 -1
- package/dist/components/kbd.cjs +54 -1
- package/dist/components/kbd.js +17 -1
- package/dist/components/label.cjs +45 -1
- package/dist/components/label.js +11 -1
- package/dist/components/menubar.cjs +232 -1
- package/dist/components/menubar.js +153 -1
- package/dist/components/native-select.cjs +75 -1
- package/dist/components/native-select.js +35 -1
- package/dist/components/navigation-menu.cjs +146 -2
- package/dist/components/navigation-menu.js +94 -2
- package/dist/components/pagination.cjs +138 -1
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/pagination.js +86 -1
- package/dist/components/popover.cjs +86 -1
- package/dist/components/popover.js +40 -1
- package/dist/components/progress-circle.cjs +184 -1
- package/dist/components/progress-circle.d.ts +1 -1
- package/dist/components/progress-circle.js +147 -1
- package/dist/components/progress.cjs +52 -1
- package/dist/components/progress.js +18 -1
- package/dist/components/radio-cards.cjs +66 -1
- package/dist/components/radio-cards.js +29 -1
- package/dist/components/radio-group.cjs +59 -1
- package/dist/components/radio-group.js +22 -1
- package/dist/components/radio.cjs +47 -1
- package/dist/components/radio.js +13 -1
- package/dist/components/resizable.cjs +71 -1
- package/dist/components/resizable.d.ts +6 -6
- package/dist/components/resizable.js +31 -1
- package/dist/components/scroll-area.cjs +140 -1
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area.js +100 -1
- package/dist/components/select.cjs +180 -1
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.js +119 -1
- package/dist/components/separator.cjs +82 -1
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +42 -1
- package/dist/components/sheet.cjs +184 -1
- package/dist/components/sheet.d.ts +2 -2
- package/dist/components/sheet.js +123 -1
- package/dist/components/sidebar.cjs +506 -1
- package/dist/components/sidebar.d.ts +1 -1
- package/dist/components/sidebar.js +400 -1
- package/dist/components/skeleton.cjs +44 -1
- package/dist/components/skeleton.js +10 -1
- package/dist/components/slider.cjs +79 -1
- package/dist/components/slider.js +45 -1
- package/dist/components/sonner.cjs +57 -1
- package/dist/components/sonner.js +17 -1
- package/dist/components/spinner.cjs +75 -1
- package/dist/components/spinner.js +41 -1
- package/dist/components/switch.cjs +49 -1
- package/dist/components/switch.js +15 -1
- package/dist/components/table.cjs +118 -1
- package/dist/components/table.js +63 -1
- package/dist/components/tabs.cjs +75 -1
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tabs.js +32 -1
- package/dist/components/textarea.cjs +44 -1
- package/dist/components/textarea.js +10 -1
- package/dist/components/toggle-group.cjs +90 -1
- package/dist/components/toggle-group.d.ts +8 -10
- package/dist/components/toggle-group.js +53 -1
- package/dist/components/toggle.cjs +71 -1
- package/dist/components/toggle.d.ts +8 -10
- package/dist/components/toggle.js +34 -1
- package/dist/components/tooltip.cjs +90 -1
- package/dist/components/tooltip.js +44 -1
- package/dist/css/amber.css +95 -1
- package/dist/css/blue.css +95 -1
- package/dist/css/cyan.css +95 -1
- package/dist/css/emerald.css +95 -1
- package/dist/css/fuchsia.css +95 -1
- package/dist/css/gray.css +95 -1
- package/dist/css/green.css +95 -1
- package/dist/css/indigo.css +95 -1
- package/dist/css/lime.css +95 -1
- package/dist/css/neutral.css +95 -1
- package/dist/css/orange.css +95 -1
- package/dist/css/pink.css +95 -1
- package/dist/css/preset.css +118 -1
- package/dist/css/purple.css +95 -1
- package/dist/css/red.css +95 -1
- package/dist/css/rose.css +95 -1
- package/dist/css/sky.css +95 -1
- package/dist/css/slate.css +95 -1
- package/dist/css/stone.css +95 -1
- package/dist/css/style.css +3 -1
- package/dist/css/teal.css +95 -1
- package/dist/css/violet.css +95 -1
- package/dist/css/yellow.css +95 -1
- package/dist/css/zinc.css +95 -1
- package/dist/hooks/use-animated-value.cjs +74 -1
- package/dist/hooks/use-animated-value.d.ts +9 -10
- package/dist/hooks/use-animated-value.js +40 -1
- package/dist/hooks/use-copy-to-clipboard.cjs +57 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +17 -0
- package/dist/hooks/use-copy-to-clipboard.js +23 -1
- package/dist/hooks/use-is-mobile.cjs +39 -1
- package/dist/hooks/use-is-mobile.d.ts +15 -6
- package/dist/hooks/use-is-mobile.js +5 -1
- package/dist/hooks/use-media-query.cjs +56 -1
- package/dist/hooks/use-media-query.d.ts +11 -3
- package/dist/hooks/use-media-query.js +22 -1
- package/dist/hooks/use-mutation-observer.cjs +56 -1
- package/dist/hooks/use-mutation-observer.d.ts +7 -11
- package/dist/hooks/use-mutation-observer.js +22 -1
- package/dist/hooks/use-pagination.cjs +92 -1
- package/dist/hooks/use-pagination.d.ts +12 -10
- package/dist/hooks/use-pagination.js +55 -1
- package/dist/index.cjs +1081 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +69 -1
- package/dist/primitives/checkbox-group.cjs +151 -1
- package/dist/primitives/checkbox-group.d.ts +1 -1
- package/dist/primitives/checkbox-group.js +99 -1
- package/dist/primitives/input-number.cjs +439 -1
- package/dist/primitives/input-number.d.ts +1 -1
- package/dist/primitives/input-number.js +381 -1
- package/dist/primitives/input.cjs +99 -1
- package/dist/primitives/input.d.ts +1 -1
- package/dist/primitives/input.js +53 -1
- package/dist/primitives/progress-circle.cjs +198 -1
- package/dist/primitives/progress-circle.d.ts +1 -1
- package/dist/primitives/progress-circle.js +128 -1
- package/package.json +405 -62
package/dist/components/field.js
CHANGED
|
@@ -1,2 +1,130 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn, tv } from "@codefast/tailwind-variants";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { Label } from "./label.js";
|
|
6
|
+
import { Separator } from "./separator.js";
|
|
7
|
+
const fieldVariants = tv({
|
|
8
|
+
base: "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
9
|
+
defaultVariants: {
|
|
10
|
+
orientation: "vertical"
|
|
11
|
+
},
|
|
12
|
+
variants: {
|
|
13
|
+
orientation: {
|
|
14
|
+
horizontal: cn("flex-row items-center", "[&>[data-slot=field-label]]:flex-auto", "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"),
|
|
15
|
+
responsive: cn("flex-col [&>*]:w-full [&>.sr-only]:w-auto", "@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto", "@md/field-group:[&>[data-slot=field-label]]:flex-auto", "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"),
|
|
16
|
+
vertical: "flex-col [&>*]:w-full [&>.sr-only]:w-auto"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
function FieldSet({ className, ...props }) {
|
|
21
|
+
return /*#__PURE__*/ jsx("fieldset", {
|
|
22
|
+
className: cn("flex flex-col gap-6", "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", className),
|
|
23
|
+
"data-slot": "field-set",
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function FieldLegend({ className, variant = "legend", ...props }) {
|
|
28
|
+
return /*#__PURE__*/ jsx("legend", {
|
|
29
|
+
className: cn("mb-3 text-base font-medium", "data-[variant=label]:text-sm", className),
|
|
30
|
+
"data-slot": "field-legend",
|
|
31
|
+
"data-variant": variant,
|
|
32
|
+
...props
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function FieldGroup({ className, ...props }) {
|
|
36
|
+
return /*#__PURE__*/ jsx("div", {
|
|
37
|
+
className: cn("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4", className),
|
|
38
|
+
"data-slot": "field-group",
|
|
39
|
+
...props
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function Field({ className, orientation = "vertical", ...props }) {
|
|
43
|
+
return /*#__PURE__*/ jsx("div", {
|
|
44
|
+
className: fieldVariants({
|
|
45
|
+
className,
|
|
46
|
+
orientation
|
|
47
|
+
}),
|
|
48
|
+
"data-orientation": orientation,
|
|
49
|
+
"data-slot": "field",
|
|
50
|
+
role: "group",
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function FieldContent({ className, ...props }) {
|
|
55
|
+
return /*#__PURE__*/ jsx("div", {
|
|
56
|
+
className: cn("group/field-content flex flex-1 flex-col gap-1.5 leading-snug", className),
|
|
57
|
+
"data-slot": "field-content",
|
|
58
|
+
...props
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function FieldLabel({ className, ...props }) {
|
|
62
|
+
return /*#__PURE__*/ jsx(Label, {
|
|
63
|
+
className: cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4", "has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10", className),
|
|
64
|
+
"data-slot": "field-label",
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function FieldTitle({ className, ...props }) {
|
|
69
|
+
return /*#__PURE__*/ jsx("div", {
|
|
70
|
+
className: cn("flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50", className),
|
|
71
|
+
"data-slot": "field-label",
|
|
72
|
+
...props
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function FieldDescription({ className, ...props }) {
|
|
76
|
+
return /*#__PURE__*/ jsx("p", {
|
|
77
|
+
className: cn("text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance", "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
78
|
+
"data-slot": "field-description",
|
|
79
|
+
...props
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function FieldSeparator({ children, className, ...props }) {
|
|
83
|
+
const hasContent = Boolean(children);
|
|
84
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
85
|
+
className: cn("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2", className),
|
|
86
|
+
"data-content": hasContent,
|
|
87
|
+
"data-slot": "field-separator",
|
|
88
|
+
...props,
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx(Separator, {
|
|
91
|
+
className: "absolute inset-0 top-1/2"
|
|
92
|
+
}),
|
|
93
|
+
hasContent ? /*#__PURE__*/ jsx("span", {
|
|
94
|
+
className: "relative mx-auto block w-fit bg-background px-2 text-muted-foreground",
|
|
95
|
+
"data-slot": "field-separator-content",
|
|
96
|
+
children: children
|
|
97
|
+
}) : null
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function FieldError({ children, className, errors, ...props }) {
|
|
102
|
+
const fallbackContent = useMemo(()=>{
|
|
103
|
+
if (!errors?.length) return null;
|
|
104
|
+
const uniqueErrors = [
|
|
105
|
+
...new Map(errors.map((error)=>[
|
|
106
|
+
error?.message,
|
|
107
|
+
error
|
|
108
|
+
])).values()
|
|
109
|
+
];
|
|
110
|
+
if (1 === uniqueErrors.length) return uniqueErrors[0]?.message ?? null;
|
|
111
|
+
return /*#__PURE__*/ jsx("ul", {
|
|
112
|
+
className: "ml-4 flex list-disc flex-col gap-1",
|
|
113
|
+
children: uniqueErrors.map((error)=>error?.message ? /*#__PURE__*/ jsx("li", {
|
|
114
|
+
children: error.message
|
|
115
|
+
}, error.message) : null)
|
|
116
|
+
});
|
|
117
|
+
}, [
|
|
118
|
+
errors
|
|
119
|
+
]);
|
|
120
|
+
const content = children ?? fallbackContent;
|
|
121
|
+
if (null == content || false === content) return null;
|
|
122
|
+
return /*#__PURE__*/ jsx("div", {
|
|
123
|
+
className: cn("text-sm font-normal text-destructive", className),
|
|
124
|
+
"data-slot": "field-error",
|
|
125
|
+
role: "alert",
|
|
126
|
+
...props,
|
|
127
|
+
children: content
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, fieldVariants };
|
package/dist/components/form.cjs
CHANGED
|
@@ -1,2 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
FormMessage: ()=>FormMessage,
|
|
29
|
+
FormDescription: ()=>FormDescription,
|
|
30
|
+
FormControl: ()=>FormControl,
|
|
31
|
+
FormItem: ()=>FormItem,
|
|
32
|
+
createFormFieldScope: ()=>createFormFieldScope,
|
|
33
|
+
FormLabel: ()=>FormLabel,
|
|
34
|
+
Form: ()=>Form,
|
|
35
|
+
FormField: ()=>FormField
|
|
36
|
+
});
|
|
37
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
38
|
+
const tailwind_variants_namespaceObject = require("@codefast/tailwind-variants");
|
|
39
|
+
const react_context_namespaceObject = require("@radix-ui/react-context");
|
|
40
|
+
const react_slot_namespaceObject = require("@radix-ui/react-slot");
|
|
41
|
+
const external_react_namespaceObject = require("react");
|
|
42
|
+
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
43
|
+
const external_label_cjs_namespaceObject = require("./label.cjs");
|
|
44
|
+
const Form = external_react_hook_form_namespaceObject.FormProvider;
|
|
45
|
+
const FORM_FIELD_NAME = "FormField";
|
|
46
|
+
const [createFormFieldContext, createFormFieldScope] = (0, react_context_namespaceObject.createContextScope)(FORM_FIELD_NAME);
|
|
47
|
+
const [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext(FORM_FIELD_NAME);
|
|
48
|
+
function useFormItem(consumerName, scope) {
|
|
49
|
+
const { id } = useFormItemContext(consumerName, scope);
|
|
50
|
+
const { name } = useFormFieldContext(consumerName, scope);
|
|
51
|
+
const { getFieldState } = (0, external_react_hook_form_namespaceObject.useFormContext)();
|
|
52
|
+
const formState = (0, external_react_hook_form_namespaceObject.useFormState)({
|
|
53
|
+
name
|
|
54
|
+
});
|
|
55
|
+
const fieldState = getFieldState(name, formState);
|
|
56
|
+
return {
|
|
57
|
+
formDescriptionId: `form-item-description-${id}`,
|
|
58
|
+
formItemId: `form-item-${id}`,
|
|
59
|
+
formMessageId: `form-item-message-${id}`,
|
|
60
|
+
id,
|
|
61
|
+
name,
|
|
62
|
+
...fieldState
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function FormField(formFieldProps) {
|
|
66
|
+
const { __scopeFormField, ...props } = formFieldProps;
|
|
67
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FormFieldContextProvider, {
|
|
68
|
+
name: props.name,
|
|
69
|
+
scope: __scopeFormField,
|
|
70
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.Controller, {
|
|
71
|
+
...props
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const FORM_ITEM_NAME = "FormItem";
|
|
76
|
+
const [FormItemContextProvider, useFormItemContext] = createFormFieldContext(FORM_ITEM_NAME);
|
|
77
|
+
function FormItem({ __scopeFormField, className, ...props }) {
|
|
78
|
+
const id = (0, external_react_namespaceObject.useId)();
|
|
79
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FormItemContextProvider, {
|
|
80
|
+
id: id,
|
|
81
|
+
scope: __scopeFormField,
|
|
82
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
83
|
+
className: (0, tailwind_variants_namespaceObject.cn)("grid gap-2", className),
|
|
84
|
+
"data-slot": "form-item",
|
|
85
|
+
...props
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const FORM_LABEL_NAME = "FormLabel";
|
|
90
|
+
function FormLabel({ __scopeFormField, ...props }) {
|
|
91
|
+
const { error, formItemId } = useFormItem(FORM_LABEL_NAME, __scopeFormField);
|
|
92
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
|
|
93
|
+
"data-invalid": error ? true : void 0,
|
|
94
|
+
"data-slot": "form-label",
|
|
95
|
+
htmlFor: formItemId,
|
|
96
|
+
...props
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const FORM_CONTROL_NAME = "FormControl";
|
|
100
|
+
function FormControl({ __scopeFormField, ...props }) {
|
|
101
|
+
const { error, formDescriptionId, formItemId, formMessageId } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);
|
|
102
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_slot_namespaceObject.Slot, {
|
|
103
|
+
"aria-describedby": error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId,
|
|
104
|
+
"aria-invalid": Boolean(error),
|
|
105
|
+
"data-slot": "form-control",
|
|
106
|
+
id: formItemId,
|
|
107
|
+
...props
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function FormDescription({ __scopeFormField, className, ...props }) {
|
|
111
|
+
const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
112
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
113
|
+
className: (0, tailwind_variants_namespaceObject.cn)("text-xs text-muted-foreground", className),
|
|
114
|
+
"data-slot": "form-description",
|
|
115
|
+
id: formDescriptionId,
|
|
116
|
+
...props
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const FORM_MESSAGE_NAME = "FormMessage";
|
|
120
|
+
function FormMessage({ __scopeFormField, children, className, ...props }) {
|
|
121
|
+
const { error, formMessageId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
122
|
+
const body = error?.message ?? children;
|
|
123
|
+
if (!body) return null;
|
|
124
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
125
|
+
className: (0, tailwind_variants_namespaceObject.cn)("text-xs", error?.message ? "font-medium text-destructive" : "text-muted-foreground", className),
|
|
126
|
+
"data-slot": "form-message",
|
|
127
|
+
id: formMessageId,
|
|
128
|
+
...props,
|
|
129
|
+
children: body
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
exports.Form = __webpack_exports__.Form;
|
|
133
|
+
exports.FormControl = __webpack_exports__.FormControl;
|
|
134
|
+
exports.FormDescription = __webpack_exports__.FormDescription;
|
|
135
|
+
exports.FormField = __webpack_exports__.FormField;
|
|
136
|
+
exports.FormItem = __webpack_exports__.FormItem;
|
|
137
|
+
exports.FormLabel = __webpack_exports__.FormLabel;
|
|
138
|
+
exports.FormMessage = __webpack_exports__.FormMessage;
|
|
139
|
+
exports.createFormFieldScope = __webpack_exports__.createFormFieldScope;
|
|
140
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
141
|
+
"Form",
|
|
142
|
+
"FormControl",
|
|
143
|
+
"FormDescription",
|
|
144
|
+
"FormField",
|
|
145
|
+
"FormItem",
|
|
146
|
+
"FormLabel",
|
|
147
|
+
"FormMessage",
|
|
148
|
+
"createFormFieldScope"
|
|
149
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
150
|
+
Object.defineProperty(exports, '__esModule', {
|
|
151
|
+
value: true
|
|
152
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ComponentProps, JSX, ReactNode } from "react";
|
|
2
|
-
import type { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
|
|
3
|
-
import { FormProvider } from "react-hook-form";
|
|
4
1
|
import type { Scope } from "@radix-ui/react-context";
|
|
5
2
|
import type * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import type { ComponentProps, JSX, ReactNode } from "react";
|
|
4
|
+
import type { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
|
|
6
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
+
import { FormProvider } from "react-hook-form";
|
|
7
7
|
type FormProps = ComponentProps<typeof FormProvider>;
|
|
8
8
|
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
9
9
|
type ScopedProps<P> = P & {
|
package/dist/components/form.js
CHANGED
|
@@ -1,2 +1,97 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
5
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { Controller, FormProvider, useFormContext, useFormState } from "react-hook-form";
|
|
8
|
+
import { Label } from "./label.js";
|
|
9
|
+
const Form = FormProvider;
|
|
10
|
+
const FORM_FIELD_NAME = "FormField";
|
|
11
|
+
const [createFormFieldContext, createFormFieldScope] = createContextScope(FORM_FIELD_NAME);
|
|
12
|
+
const [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext(FORM_FIELD_NAME);
|
|
13
|
+
function useFormItem(consumerName, scope) {
|
|
14
|
+
const { id } = useFormItemContext(consumerName, scope);
|
|
15
|
+
const { name } = useFormFieldContext(consumerName, scope);
|
|
16
|
+
const { getFieldState } = useFormContext();
|
|
17
|
+
const formState = useFormState({
|
|
18
|
+
name
|
|
19
|
+
});
|
|
20
|
+
const fieldState = getFieldState(name, formState);
|
|
21
|
+
return {
|
|
22
|
+
formDescriptionId: `form-item-description-${id}`,
|
|
23
|
+
formItemId: `form-item-${id}`,
|
|
24
|
+
formMessageId: `form-item-message-${id}`,
|
|
25
|
+
id,
|
|
26
|
+
name,
|
|
27
|
+
...fieldState
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function FormField(formFieldProps) {
|
|
31
|
+
const { __scopeFormField, ...props } = formFieldProps;
|
|
32
|
+
return /*#__PURE__*/ jsx(FormFieldContextProvider, {
|
|
33
|
+
name: props.name,
|
|
34
|
+
scope: __scopeFormField,
|
|
35
|
+
children: /*#__PURE__*/ jsx(Controller, {
|
|
36
|
+
...props
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const FORM_ITEM_NAME = "FormItem";
|
|
41
|
+
const [FormItemContextProvider, useFormItemContext] = createFormFieldContext(FORM_ITEM_NAME);
|
|
42
|
+
function FormItem({ __scopeFormField, className, ...props }) {
|
|
43
|
+
const id = useId();
|
|
44
|
+
return /*#__PURE__*/ jsx(FormItemContextProvider, {
|
|
45
|
+
id: id,
|
|
46
|
+
scope: __scopeFormField,
|
|
47
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
48
|
+
className: cn("grid gap-2", className),
|
|
49
|
+
"data-slot": "form-item",
|
|
50
|
+
...props
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const FORM_LABEL_NAME = "FormLabel";
|
|
55
|
+
function FormLabel({ __scopeFormField, ...props }) {
|
|
56
|
+
const { error, formItemId } = useFormItem(FORM_LABEL_NAME, __scopeFormField);
|
|
57
|
+
return /*#__PURE__*/ jsx(Label, {
|
|
58
|
+
"data-invalid": error ? true : void 0,
|
|
59
|
+
"data-slot": "form-label",
|
|
60
|
+
htmlFor: formItemId,
|
|
61
|
+
...props
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const FORM_CONTROL_NAME = "FormControl";
|
|
65
|
+
function FormControl({ __scopeFormField, ...props }) {
|
|
66
|
+
const { error, formDescriptionId, formItemId, formMessageId } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);
|
|
67
|
+
return /*#__PURE__*/ jsx(Slot, {
|
|
68
|
+
"aria-describedby": error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId,
|
|
69
|
+
"aria-invalid": Boolean(error),
|
|
70
|
+
"data-slot": "form-control",
|
|
71
|
+
id: formItemId,
|
|
72
|
+
...props
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function FormDescription({ __scopeFormField, className, ...props }) {
|
|
76
|
+
const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
77
|
+
return /*#__PURE__*/ jsx("p", {
|
|
78
|
+
className: cn("text-xs text-muted-foreground", className),
|
|
79
|
+
"data-slot": "form-description",
|
|
80
|
+
id: formDescriptionId,
|
|
81
|
+
...props
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const FORM_MESSAGE_NAME = "FormMessage";
|
|
85
|
+
function FormMessage({ __scopeFormField, children, className, ...props }) {
|
|
86
|
+
const { error, formMessageId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
87
|
+
const body = error?.message ?? children;
|
|
88
|
+
if (!body) return null;
|
|
89
|
+
return /*#__PURE__*/ jsx("p", {
|
|
90
|
+
className: cn("text-xs", error?.message ? "font-medium text-destructive" : "text-muted-foreground", className),
|
|
91
|
+
"data-slot": "form-message",
|
|
92
|
+
id: formMessageId,
|
|
93
|
+
...props,
|
|
94
|
+
children: body
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, createFormFieldScope };
|
|
@@ -1,2 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
HoverCard: ()=>HoverCard,
|
|
29
|
+
HoverCardContent: ()=>HoverCardContent,
|
|
30
|
+
HoverCardTrigger: ()=>HoverCardTrigger,
|
|
31
|
+
HoverCardArrow: ()=>HoverCardArrow
|
|
32
|
+
});
|
|
33
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
34
|
+
const tailwind_variants_namespaceObject = require("@codefast/tailwind-variants");
|
|
35
|
+
const react_hover_card_namespaceObject = require("@radix-ui/react-hover-card");
|
|
36
|
+
function HoverCard({ ...props }) {
|
|
37
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Root, {
|
|
38
|
+
"data-slot": "hover-card",
|
|
39
|
+
...props
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function HoverCardTrigger({ ...props }) {
|
|
43
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Trigger, {
|
|
44
|
+
"data-slot": "hover-card-trigger",
|
|
45
|
+
...props
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function HoverCardContent({ align = "center", className, sideOffset = 4, ...props }) {
|
|
49
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Portal, {
|
|
50
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Content, {
|
|
51
|
+
align: align,
|
|
52
|
+
className: (0, tailwind_variants_namespaceObject.cn)("z-50 min-w-32 origin-(--radix-hover-card-content-transform-origin) rounded-lg border bg-popover p-4 text-popover-foreground shadow-lg ease-ui data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:data-[side=bottom]:slide-out-to-top-2 data-[state=closed]:data-[side=left]:slide-out-to-right-2 data-[state=closed]:data-[side=right]:slide-out-to-left-2 data-[state=closed]:data-[side=top]:slide-out-to-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:data-[side=bottom]:slide-in-from-top-2 data-[state=open]:data-[side=left]:slide-in-from-right-2 data-[state=open]:data-[side=right]:slide-in-from-left-2 data-[state=open]:data-[side=top]:slide-in-from-bottom-2", className),
|
|
53
|
+
"data-slot": "hover-card-content",
|
|
54
|
+
sideOffset: sideOffset,
|
|
55
|
+
...props
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function HoverCardArrow({ className, ...props }) {
|
|
60
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Arrow, {
|
|
61
|
+
className: (0, tailwind_variants_namespaceObject.cn)("fill-popover", className),
|
|
62
|
+
"data-slot": "hover-card-arrow",
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.HoverCard = __webpack_exports__.HoverCard;
|
|
67
|
+
exports.HoverCardArrow = __webpack_exports__.HoverCardArrow;
|
|
68
|
+
exports.HoverCardContent = __webpack_exports__.HoverCardContent;
|
|
69
|
+
exports.HoverCardTrigger = __webpack_exports__.HoverCardTrigger;
|
|
70
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
71
|
+
"HoverCard",
|
|
72
|
+
"HoverCardArrow",
|
|
73
|
+
"HoverCardContent",
|
|
74
|
+
"HoverCardTrigger"
|
|
75
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
76
|
+
Object.defineProperty(exports, '__esModule', {
|
|
77
|
+
value: true
|
|
78
|
+
});
|
|
@@ -1,2 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
+
import { Arrow, Content, Portal, Root, Trigger } from "@radix-ui/react-hover-card";
|
|
5
|
+
function HoverCard({ ...props }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Root, {
|
|
7
|
+
"data-slot": "hover-card",
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function HoverCardTrigger({ ...props }) {
|
|
12
|
+
return /*#__PURE__*/ jsx(Trigger, {
|
|
13
|
+
"data-slot": "hover-card-trigger",
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function HoverCardContent({ align = "center", className, sideOffset = 4, ...props }) {
|
|
18
|
+
return /*#__PURE__*/ jsx(Portal, {
|
|
19
|
+
children: /*#__PURE__*/ jsx(Content, {
|
|
20
|
+
align: align,
|
|
21
|
+
className: cn("z-50 min-w-32 origin-(--radix-hover-card-content-transform-origin) rounded-lg border bg-popover p-4 text-popover-foreground shadow-lg ease-ui data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:data-[side=bottom]:slide-out-to-top-2 data-[state=closed]:data-[side=left]:slide-out-to-right-2 data-[state=closed]:data-[side=right]:slide-out-to-left-2 data-[state=closed]:data-[side=top]:slide-out-to-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:data-[side=bottom]:slide-in-from-top-2 data-[state=open]:data-[side=left]:slide-in-from-right-2 data-[state=open]:data-[side=right]:slide-in-from-left-2 data-[state=open]:data-[side=top]:slide-in-from-bottom-2", className),
|
|
22
|
+
"data-slot": "hover-card-content",
|
|
23
|
+
sideOffset: sideOffset,
|
|
24
|
+
...props
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function HoverCardArrow({ className, ...props }) {
|
|
29
|
+
return /*#__PURE__*/ jsx(Arrow, {
|
|
30
|
+
className: cn("fill-popover", className),
|
|
31
|
+
"data-slot": "hover-card-arrow",
|
|
32
|
+
...props
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export { HoverCard, HoverCardArrow, HoverCardContent, HoverCardTrigger };
|