@skybin-tech/nebula-ui 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/cjs/components/Form/Select.cjs +131 -0
- package/dist/cjs/components/Form/Select.cjs.map +1 -0
- package/dist/cjs/components/Form/index.cjs +29 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/components/Form/Select.js +131 -0
- package/dist/components/Form/Select.js.map +1 -0
- package/dist/components/Form/index.d.ts +2 -2
- package/dist/components/Form/index.d.ts.map +1 -1
- package/dist/components/Form/index.js +11 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/package.json +503 -504
package/README.md
CHANGED
|
@@ -134,10 +134,12 @@ Supports the same validation props as `TextBox` (except `minValue`, `maxValue`,
|
|
|
134
134
|
|
|
135
135
|
### Select
|
|
136
136
|
|
|
137
|
-
Dropdown select with support for an `options` array or custom `children`.
|
|
137
|
+
Dropdown select with support for an `options` array or custom `children`. Import as `FormSelect` from the main package (or `Select` from `@skybin-tech/nebula-ui/components/Form`).
|
|
138
138
|
|
|
139
139
|
```tsx
|
|
140
|
-
|
|
140
|
+
import { Form, FormSelect } from "@skybin-tech/nebula-ui";
|
|
141
|
+
|
|
142
|
+
<FormSelect
|
|
141
143
|
name="country"
|
|
142
144
|
label="Country"
|
|
143
145
|
required
|
|
@@ -148,10 +150,10 @@ Dropdown select with support for an `options` array or custom `children`.
|
|
|
148
150
|
/>
|
|
149
151
|
|
|
150
152
|
// Or with custom children
|
|
151
|
-
<
|
|
153
|
+
<FormSelect name="role" label="Role" required>
|
|
152
154
|
<SelectItem value="admin">Admin</SelectItem>
|
|
153
155
|
<SelectItem value="user">User</SelectItem>
|
|
154
|
-
</
|
|
156
|
+
</FormSelect>
|
|
155
157
|
```
|
|
156
158
|
|
|
157
159
|
---
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
const require_cn = require("../../utils/cn.cjs");
|
|
4
|
+
const require_context = require("./context.cjs");
|
|
5
|
+
const require_variants = require("./variants.cjs");
|
|
6
|
+
const require_label = require("../../primitives/label.cjs");
|
|
7
|
+
const require_select = require("../../primitives/select.cjs");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let class_variance_authority = require("class-variance-authority");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let react_hook_form = require("react-hook-form");
|
|
12
|
+
//#region src/components/Form/Select.tsx
|
|
13
|
+
var selectSizeVariants = (0, class_variance_authority.cva)("", {
|
|
14
|
+
variants: { size: {
|
|
15
|
+
sm: "h-8 text-xs",
|
|
16
|
+
md: "h-10 text-sm",
|
|
17
|
+
lg: "h-12 text-base"
|
|
18
|
+
} },
|
|
19
|
+
defaultVariants: { size: "md" }
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Select component with form integration
|
|
23
|
+
*
|
|
24
|
+
* This is a wrapper around the shadcn/ui Select primitive that adds:
|
|
25
|
+
* - Form integration with react-hook-form
|
|
26
|
+
* - Automatic validation registration
|
|
27
|
+
* - Label, helper text, and error message support
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* // Inside a Form component
|
|
32
|
+
* <Select
|
|
33
|
+
* name="country"
|
|
34
|
+
* label="Country"
|
|
35
|
+
* required
|
|
36
|
+
* options={[
|
|
37
|
+
* { label: "USA", value: "us" },
|
|
38
|
+
* { label: "Canada", value: "ca" },
|
|
39
|
+
* ]}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function Select({ name, label, helperText, showError = true, error: customError, size, variant, fullWidth = true, className, disabled, options = [], placeholder, allowClear, id: providedId, control: externalControl, children, required, validate }) {
|
|
44
|
+
const generatedId = (0, react.useId)();
|
|
45
|
+
const inputId = providedId ?? generatedId;
|
|
46
|
+
const formConfigContext = (0, react.useContext)(require_context.FormConfigContext);
|
|
47
|
+
const formConfig = formConfigContext ?? {};
|
|
48
|
+
const rhfContext = (0, react_hook_form.useFormContext)();
|
|
49
|
+
const control = externalControl ?? rhfContext?.control;
|
|
50
|
+
(0, react.useEffect)(() => {
|
|
51
|
+
if (formConfigContext?.registerFieldValidation) {
|
|
52
|
+
const rules = {};
|
|
53
|
+
if (required !== void 0) rules.required = required;
|
|
54
|
+
if (validate !== void 0) rules.validate = validate;
|
|
55
|
+
formConfigContext.registerFieldValidation({
|
|
56
|
+
name,
|
|
57
|
+
type: "string",
|
|
58
|
+
rules
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
formConfigContext.unregisterFieldValidation(name);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
formConfigContext,
|
|
66
|
+
name,
|
|
67
|
+
required,
|
|
68
|
+
validate
|
|
69
|
+
]);
|
|
70
|
+
const { field, fieldState } = (0, react_hook_form.useController)({
|
|
71
|
+
name,
|
|
72
|
+
control
|
|
73
|
+
});
|
|
74
|
+
const fieldError = fieldState.error?.message;
|
|
75
|
+
const errorMessage = customError ?? fieldError;
|
|
76
|
+
const hasError = !!errorMessage;
|
|
77
|
+
const effectiveSize = size ?? formConfig.size ?? "md";
|
|
78
|
+
const effectiveDisabled = disabled ?? formConfig.disabled;
|
|
79
|
+
const effectiveVariant = hasError ? "error" : variant;
|
|
80
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
81
|
+
className: require_cn.cn("space-y-1.5", fullWidth && "w-full"),
|
|
82
|
+
children: [
|
|
83
|
+
label && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_label.Label, {
|
|
84
|
+
htmlFor: inputId,
|
|
85
|
+
className: require_variants.labelVariants({ required: !!required }),
|
|
86
|
+
children: [label, formConfig.colon && ":"]
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_select.Select, {
|
|
89
|
+
value: field.value?.toString() ?? "",
|
|
90
|
+
onValueChange: (value) => {
|
|
91
|
+
if (value === "" && allowClear) field.onChange("");
|
|
92
|
+
else field.onChange(value);
|
|
93
|
+
},
|
|
94
|
+
disabled: effectiveDisabled,
|
|
95
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_select.SelectTrigger, {
|
|
96
|
+
id: inputId,
|
|
97
|
+
"aria-invalid": hasError,
|
|
98
|
+
"aria-describedby": hasError ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
|
|
99
|
+
className: require_cn.cn(selectSizeVariants({ size: effectiveSize }), effectiveVariant === "error" && "border-destructive focus:ring-destructive", effectiveVariant === "success" && "border-green-500 focus:ring-green-500", className),
|
|
100
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_select.SelectValue, { placeholder })
|
|
101
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_select.SelectContent, { children: [allowClear && field.value && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_select.SelectItem, {
|
|
102
|
+
value: "",
|
|
103
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
104
|
+
className: "text-muted-foreground",
|
|
105
|
+
children: "Clear selection"
|
|
106
|
+
})
|
|
107
|
+
}), children ?? options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_select.SelectItem, {
|
|
108
|
+
value: option.value.toString(),
|
|
109
|
+
disabled: option.disabled,
|
|
110
|
+
children: option.label
|
|
111
|
+
}, option.value))] })]
|
|
112
|
+
}),
|
|
113
|
+
showError && hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
114
|
+
id: `${inputId}-error`,
|
|
115
|
+
className: "text-sm text-destructive",
|
|
116
|
+
role: "alert",
|
|
117
|
+
children: errorMessage
|
|
118
|
+
}),
|
|
119
|
+
helperText && !hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
120
|
+
id: `${inputId}-helper`,
|
|
121
|
+
className: "text-sm text-muted-foreground",
|
|
122
|
+
children: helperText
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
Select.displayName = "Select";
|
|
128
|
+
//#endregion
|
|
129
|
+
exports.Select = Select;
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=Select.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.cjs","names":[],"sources":["../../../../src/components/Form/Select.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useContext, useEffect } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../utils/cn\";\nimport { labelVariants } from \"./variants\";\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\nimport {\n Select as ShadcnSelect,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../../primitives/select\";\nimport { Label } from \"../../primitives/label\";\n\nconst selectSizeVariants = cva(\n \"\",\n {\n variants: {\n size: {\n sm: \"h-8 text-xs\",\n md: \"h-10 text-sm\",\n lg: \"h-12 text-base\",\n },\n },\n defaultVariants: {\n size: \"md\",\n },\n }\n);\n\nexport interface SelectOption {\n label: string;\n value: string | number;\n disabled?: boolean;\n}\n\nexport interface SelectProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends VariantProps<typeof selectSizeVariants> {\n /** Field name - required for form integration */\n name: TName;\n /** Label text for the select */\n label?: string;\n /** Helper text displayed below the select */\n helperText?: string;\n /** Whether to show the error message */\n showError?: boolean;\n /** Custom error message (overrides form error) */\n error?: string;\n /** Whether the select should take full width */\n fullWidth?: boolean;\n /** Options for the select */\n options?: SelectOption[];\n /** Placeholder text */\n placeholder?: string;\n /** Allow clear selection */\n allowClear?: boolean;\n /** External control (for use outside Form) */\n control?: Control<TFieldValues>;\n /** Children (alternative to options prop) */\n children?: ReactNode;\n /** Disabled state */\n disabled?: boolean;\n /** Additional class name */\n className?: string;\n /** ID for the select */\n id?: string;\n /** Variant style */\n variant?: \"default\" | \"error\" | \"success\";\n \n // Validation props\n /** Field is required */\n required?: boolean | string;\n /** Custom validation function */\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\n}\n\n/**\n * Select component with form integration\n * \n * This is a wrapper around the shadcn/ui Select primitive that adds:\n * - Form integration with react-hook-form\n * - Automatic validation registration\n * - Label, helper text, and error message support\n * \n * @example\n * ```tsx\n * // Inside a Form component\n * <Select \n * name=\"country\" \n * label=\"Country\" \n * required\n * options={[\n * { label: \"USA\", value: \"us\" },\n * { label: \"Canada\", value: \"ca\" },\n * ]} \n * />\n * ```\n */\nexport function Select<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n helperText,\n showError = true,\n error: customError,\n size,\n variant,\n fullWidth = true,\n className,\n disabled,\n options = [],\n placeholder,\n allowClear,\n id: providedId,\n control: externalControl,\n children,\n // Validation props\n required,\n validate,\n}: SelectProps<TFieldValues, TName>) {\n const generatedId = useId();\n const inputId = providedId ?? generatedId;\n \n // Try to get form context\n const formConfigContext = useContext(FormConfigContext);\n const formConfig: FormConfig = formConfigContext ?? {};\n \n // Get form context from react-hook-form\n const rhfContext = useRHFFormContext<TFieldValues>();\n const control = externalControl ?? rhfContext?.control;\n\n // Register validation rules with the form\n useEffect(() => {\n if (formConfigContext?.registerFieldValidation) {\n const rules: FieldValidationRules = {};\n \n if (required !== undefined) rules.required = required;\n if (validate !== undefined) rules.validate = validate;\n\n formConfigContext.registerFieldValidation({\n name: name as string,\n type: \"string\",\n rules,\n });\n\n return () => {\n formConfigContext.unregisterFieldValidation(name as string);\n };\n }\n }, [formConfigContext, name, required, validate]);\n\n // Use controller for form integration\n const { field, fieldState } = useController<TFieldValues, TName>({\n name,\n control,\n });\n\n const fieldError = fieldState.error?.message;\n const errorMessage = customError ?? fieldError;\n const hasError = !!errorMessage;\n \n // Merge sizes - prop takes precedence over form config\n const effectiveSize = size ?? formConfig.size ?? \"md\";\n const effectiveDisabled = disabled ?? formConfig.disabled;\n \n // Determine variant based on error state\n const effectiveVariant = hasError ? \"error\" : variant;\n\n return (\n <div className={cn(\"space-y-1.5\", fullWidth && \"w-full\")}>\n {label && (\n <Label\n htmlFor={inputId}\n className={labelVariants({ required: !!required })}\n >\n {label}\n {formConfig.colon && \":\"}\n </Label>\n )}\n \n <ShadcnSelect\n value={field.value?.toString() ?? \"\"}\n onValueChange={(value) => {\n // Handle clear selection\n if (value === \"\" && allowClear) {\n field.onChange(\"\");\n } else {\n field.onChange(value);\n }\n }}\n disabled={effectiveDisabled}\n >\n <SelectTrigger\n id={inputId}\n aria-invalid={hasError}\n aria-describedby={\n hasError\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined\n }\n className={cn(\n selectSizeVariants({ size: effectiveSize }),\n effectiveVariant === \"error\" && \"border-destructive focus:ring-destructive\",\n effectiveVariant === \"success\" && \"border-green-500 focus:ring-green-500\",\n className\n )}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {allowClear && field.value && (\n <SelectItem value=\"\">\n <span className=\"text-muted-foreground\">Clear selection</span>\n </SelectItem>\n )}\n {children ?? options.map((option) => (\n <SelectItem\n key={option.value}\n value={option.value.toString()}\n disabled={option.disabled}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </ShadcnSelect>\n\n {showError && hasError && (\n <p\n id={`${inputId}-error`}\n className=\"text-sm text-destructive\"\n role=\"alert\"\n >\n {errorMessage}\n </p>\n )}\n \n {helperText && !hasError && (\n <p\n id={`${inputId}-helper`}\n className=\"text-sm text-muted-foreground\"\n >\n {helperText}\n </p>\n )}\n </div>\n );\n}\n\nSel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Z,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;IACV,MAAK;cAEJ;GACA,CAAA;GAGJ,cAAc,CAAC,YACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;cAET;GACA,CAAA;EAEF;;AAET;AAEA,OAAO,cAAc"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_context = require("./context.cjs");
|
|
4
|
+
const require_Form = require("./Form.cjs");
|
|
5
|
+
const require_TextBox = require("./TextBox.cjs");
|
|
6
|
+
const require_TextArea = require("./TextArea.cjs");
|
|
7
|
+
const require_Select = require("./Select.cjs");
|
|
8
|
+
const require_Checkbox = require("./Checkbox.cjs");
|
|
9
|
+
const require_Radio = require("./Radio.cjs");
|
|
10
|
+
const require_FormSwitch = require("./FormSwitch.cjs");
|
|
11
|
+
const require_hooks = require("./hooks.cjs");
|
|
12
|
+
exports.Checkbox = require_Checkbox.Checkbox;
|
|
13
|
+
exports.Form = require_Form.Form;
|
|
14
|
+
exports.FormCheckbox = require_Checkbox.Checkbox;
|
|
15
|
+
exports.FormConfigContext = require_context.FormConfigContext;
|
|
16
|
+
exports.FormSelect = require_Select.Select;
|
|
17
|
+
exports.FormSwitch = require_FormSwitch.FormSwitch;
|
|
18
|
+
exports.RadioGroup = require_Radio.RadioGroup;
|
|
19
|
+
exports.RadioItem = require_Radio.RadioItem;
|
|
20
|
+
exports.Select = require_Select.Select;
|
|
21
|
+
exports.TextArea = require_TextArea.TextArea;
|
|
22
|
+
exports.TextBox = require_TextBox.TextBox;
|
|
23
|
+
exports.buildZodSchemaFromRules = require_context.buildZodSchemaFromRules;
|
|
24
|
+
exports.defaultFormConfig = require_context.defaultFormConfig;
|
|
25
|
+
exports.useFieldError = require_hooks.useFieldError;
|
|
26
|
+
exports.useFieldValidationRegistry = require_context.useFieldValidationRegistry;
|
|
27
|
+
exports.useForm = require_hooks.useForm;
|
|
28
|
+
exports.useFormConfig = require_hooks.useFormConfig;
|
|
29
|
+
exports.useFormField = require_hooks.useFormField;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const require_Form = require("./components/Form/Form.cjs");
|
|
|
7
7
|
const require_TextBox = require("./components/Form/TextBox.cjs");
|
|
8
8
|
const require_TextArea = require("./components/Form/TextArea.cjs");
|
|
9
9
|
const require_select = require("./primitives/select.cjs");
|
|
10
|
+
const require_Select = require("./components/Form/Select.cjs");
|
|
10
11
|
const require_Checkbox = require("./components/Form/Checkbox.cjs");
|
|
11
12
|
const require_Radio = require("./components/Form/Radio.cjs");
|
|
12
13
|
const require_FormSwitch = require("./components/Form/FormSwitch.cjs");
|
|
@@ -96,6 +97,7 @@ exports.DropdownMenuTrigger = require_DropdownMenu.DropdownMenuTrigger;
|
|
|
96
97
|
exports.Form = require_Form.Form;
|
|
97
98
|
exports.FormCheckbox = require_Checkbox.Checkbox;
|
|
98
99
|
exports.FormConfigContext = require_context.FormConfigContext;
|
|
100
|
+
exports.FormSelect = require_Select.Select;
|
|
99
101
|
exports.FormSwitch = require_FormSwitch.FormSwitch;
|
|
100
102
|
exports.Input = require_Input.Input;
|
|
101
103
|
exports.Label = require_Label.Label;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { FormConfigContext } from "./context.js";
|
|
5
|
+
import { labelVariants } from "./variants.js";
|
|
6
|
+
import { Label } from "../../primitives/label.js";
|
|
7
|
+
import { Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../primitives/select.js";
|
|
8
|
+
import { useContext, useEffect, useId } from "react";
|
|
9
|
+
import { cva } from "class-variance-authority";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useController, useFormContext } from "react-hook-form";
|
|
12
|
+
//#region src/components/Form/Select.tsx
|
|
13
|
+
var selectSizeVariants = cva("", {
|
|
14
|
+
variants: { size: {
|
|
15
|
+
sm: "h-8 text-xs",
|
|
16
|
+
md: "h-10 text-sm",
|
|
17
|
+
lg: "h-12 text-base"
|
|
18
|
+
} },
|
|
19
|
+
defaultVariants: { size: "md" }
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Select component with form integration
|
|
23
|
+
*
|
|
24
|
+
* This is a wrapper around the shadcn/ui Select primitive that adds:
|
|
25
|
+
* - Form integration with react-hook-form
|
|
26
|
+
* - Automatic validation registration
|
|
27
|
+
* - Label, helper text, and error message support
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* // Inside a Form component
|
|
32
|
+
* <Select
|
|
33
|
+
* name="country"
|
|
34
|
+
* label="Country"
|
|
35
|
+
* required
|
|
36
|
+
* options={[
|
|
37
|
+
* { label: "USA", value: "us" },
|
|
38
|
+
* { label: "Canada", value: "ca" },
|
|
39
|
+
* ]}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function Select({ name, label, helperText, showError = true, error: customError, size, variant, fullWidth = true, className, disabled, options = [], placeholder, allowClear, id: providedId, control: externalControl, children, required, validate }) {
|
|
44
|
+
const generatedId = useId();
|
|
45
|
+
const inputId = providedId ?? generatedId;
|
|
46
|
+
const formConfigContext = useContext(FormConfigContext);
|
|
47
|
+
const formConfig = formConfigContext ?? {};
|
|
48
|
+
const rhfContext = useFormContext();
|
|
49
|
+
const control = externalControl ?? rhfContext?.control;
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (formConfigContext?.registerFieldValidation) {
|
|
52
|
+
const rules = {};
|
|
53
|
+
if (required !== void 0) rules.required = required;
|
|
54
|
+
if (validate !== void 0) rules.validate = validate;
|
|
55
|
+
formConfigContext.registerFieldValidation({
|
|
56
|
+
name,
|
|
57
|
+
type: "string",
|
|
58
|
+
rules
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
formConfigContext.unregisterFieldValidation(name);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
formConfigContext,
|
|
66
|
+
name,
|
|
67
|
+
required,
|
|
68
|
+
validate
|
|
69
|
+
]);
|
|
70
|
+
const { field, fieldState } = useController({
|
|
71
|
+
name,
|
|
72
|
+
control
|
|
73
|
+
});
|
|
74
|
+
const fieldError = fieldState.error?.message;
|
|
75
|
+
const errorMessage = customError ?? fieldError;
|
|
76
|
+
const hasError = !!errorMessage;
|
|
77
|
+
const effectiveSize = size ?? formConfig.size ?? "md";
|
|
78
|
+
const effectiveDisabled = disabled ?? formConfig.disabled;
|
|
79
|
+
const effectiveVariant = hasError ? "error" : variant;
|
|
80
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
81
|
+
className: cn("space-y-1.5", fullWidth && "w-full"),
|
|
82
|
+
children: [
|
|
83
|
+
label && /* @__PURE__ */ jsxs(Label, {
|
|
84
|
+
htmlFor: inputId,
|
|
85
|
+
className: labelVariants({ required: !!required }),
|
|
86
|
+
children: [label, formConfig.colon && ":"]
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsxs(Select$1, {
|
|
89
|
+
value: field.value?.toString() ?? "",
|
|
90
|
+
onValueChange: (value) => {
|
|
91
|
+
if (value === "" && allowClear) field.onChange("");
|
|
92
|
+
else field.onChange(value);
|
|
93
|
+
},
|
|
94
|
+
disabled: effectiveDisabled,
|
|
95
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
96
|
+
id: inputId,
|
|
97
|
+
"aria-invalid": hasError,
|
|
98
|
+
"aria-describedby": hasError ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
|
|
99
|
+
className: cn(selectSizeVariants({ size: effectiveSize }), effectiveVariant === "error" && "border-destructive focus:ring-destructive", effectiveVariant === "success" && "border-green-500 focus:ring-green-500", className),
|
|
100
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder })
|
|
101
|
+
}), /* @__PURE__ */ jsxs(SelectContent, { children: [allowClear && field.value && /* @__PURE__ */ jsx(SelectItem, {
|
|
102
|
+
value: "",
|
|
103
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
104
|
+
className: "text-muted-foreground",
|
|
105
|
+
children: "Clear selection"
|
|
106
|
+
})
|
|
107
|
+
}), children ?? options.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
108
|
+
value: option.value.toString(),
|
|
109
|
+
disabled: option.disabled,
|
|
110
|
+
children: option.label
|
|
111
|
+
}, option.value))] })]
|
|
112
|
+
}),
|
|
113
|
+
showError && hasError && /* @__PURE__ */ jsx("p", {
|
|
114
|
+
id: `${inputId}-error`,
|
|
115
|
+
className: "text-sm text-destructive",
|
|
116
|
+
role: "alert",
|
|
117
|
+
children: errorMessage
|
|
118
|
+
}),
|
|
119
|
+
helperText && !hasError && /* @__PURE__ */ jsx("p", {
|
|
120
|
+
id: `${inputId}-helper`,
|
|
121
|
+
className: "text-sm text-muted-foreground",
|
|
122
|
+
children: helperText
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
Select.displayName = "Select";
|
|
128
|
+
//#endregion
|
|
129
|
+
export { Select };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Form/Select.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useContext, useEffect } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../utils/cn\";\nimport { labelVariants } from \"./variants\";\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\nimport {\n Select as ShadcnSelect,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../../primitives/select\";\nimport { Label } from \"../../primitives/label\";\n\nconst selectSizeVariants = cva(\n \"\",\n {\n variants: {\n size: {\n sm: \"h-8 text-xs\",\n md: \"h-10 text-sm\",\n lg: \"h-12 text-base\",\n },\n },\n defaultVariants: {\n size: \"md\",\n },\n }\n);\n\nexport interface SelectOption {\n label: string;\n value: string | number;\n disabled?: boolean;\n}\n\nexport interface SelectProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends VariantProps<typeof selectSizeVariants> {\n /** Field name - required for form integration */\n name: TName;\n /** Label text for the select */\n label?: string;\n /** Helper text displayed below the select */\n helperText?: string;\n /** Whether to show the error message */\n showError?: boolean;\n /** Custom error message (overrides form error) */\n error?: string;\n /** Whether the select should take full width */\n fullWidth?: boolean;\n /** Options for the select */\n options?: SelectOption[];\n /** Placeholder text */\n placeholder?: string;\n /** Allow clear selection */\n allowClear?: boolean;\n /** External control (for use outside Form) */\n control?: Control<TFieldValues>;\n /** Children (alternative to options prop) */\n children?: ReactNode;\n /** Disabled state */\n disabled?: boolean;\n /** Additional class name */\n className?: string;\n /** ID for the select */\n id?: string;\n /** Variant style */\n variant?: \"default\" | \"error\" | \"success\";\n \n // Validation props\n /** Field is required */\n required?: boolean | string;\n /** Custom validation function */\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\n}\n\n/**\n * Select component with form integration\n * \n * This is a wrapper around the shadcn/ui Select primitive that adds:\n * - Form integration with react-hook-form\n * - Automatic validation registration\n * - Label, helper text, and error message support\n * \n * @example\n * ```tsx\n * // Inside a Form component\n * <Select \n * name=\"country\" \n * label=\"Country\" \n * required\n * options={[\n * { label: \"USA\", value: \"us\" },\n * { label: \"Canada\", value: \"ca\" },\n * ]} \n * />\n * ```\n */\nexport function Select<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n helperText,\n showError = true,\n error: customError,\n size,\n variant,\n fullWidth = true,\n className,\n disabled,\n options = [],\n placeholder,\n allowClear,\n id: providedId,\n control: externalControl,\n children,\n // Validation props\n required,\n validate,\n}: SelectProps<TFieldValues, TName>) {\n const generatedId = useId();\n const inputId = providedId ?? generatedId;\n \n // Try to get form context\n const formConfigContext = useContext(FormConfigContext);\n const formConfig: FormConfig = formConfigContext ?? {};\n \n // Get form context from react-hook-form\n const rhfContext = useRHFFormContext<TFieldValues>();\n const control = externalControl ?? rhfContext?.control;\n\n // Register validation rules with the form\n useEffect(() => {\n if (formConfigContext?.registerFieldValidation) {\n const rules: FieldValidationRules = {};\n \n if (required !== undefined) rules.required = required;\n if (validate !== undefined) rules.validate = validate;\n\n formConfigContext.registerFieldValidation({\n name: name as string,\n type: \"string\",\n rules,\n });\n\n return () => {\n formConfigContext.unregisterFieldValidation(name as string);\n };\n }\n }, [formConfigContext, name, required, validate]);\n\n // Use controller for form integration\n const { field, fieldState } = useController<TFieldValues, TName>({\n name,\n control,\n });\n\n const fieldError = fieldState.error?.message;\n const errorMessage = customError ?? fieldError;\n const hasError = !!errorMessage;\n \n // Merge sizes - prop takes precedence over form config\n const effectiveSize = size ?? formConfig.size ?? \"md\";\n const effectiveDisabled = disabled ?? formConfig.disabled;\n \n // Determine variant based on error state\n const effectiveVariant = hasError ? \"error\" : variant;\n\n return (\n <div className={cn(\"space-y-1.5\", fullWidth && \"w-full\")}>\n {label && (\n <Label\n htmlFor={inputId}\n className={labelVariants({ required: !!required })}\n >\n {label}\n {formConfig.colon && \":\"}\n </Label>\n )}\n \n <ShadcnSelect\n value={field.value?.toString() ?? \"\"}\n onValueChange={(value) => {\n // Handle clear selection\n if (value === \"\" && allowClear) {\n field.onChange(\"\");\n } else {\n field.onChange(value);\n }\n }}\n disabled={effectiveDisabled}\n >\n <SelectTrigger\n id={inputId}\n aria-invalid={hasError}\n aria-describedby={\n hasError\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined\n }\n className={cn(\n selectSizeVariants({ size: effectiveSize }),\n effectiveVariant === \"error\" && \"border-destructive focus:ring-destructive\",\n effectiveVariant === \"success\" && \"border-green-500 focus:ring-green-500\",\n className\n )}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {allowClear && field.value && (\n <SelectItem value=\"\">\n <span className=\"text-muted-foreground\">Clear selection</span>\n </SelectItem>\n )}\n {children ?? options.map((option) => (\n <SelectItem\n key={option.value}\n value={option.value.toString()}\n disabled={option.disabled}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </ShadcnSelect>\n\n {showError && hasError && (\n <p\n id={`${inputId}-error`}\n className=\"text-sm text-destructive\"\n role=\"alert\"\n >\n {errorMessage}\n </p>\n )}\n \n {helperText && !hasError && (\n <p\n id={`${inputId}-helper`}\n className=\"text-sm text-muted-foreground\"\n >\n {helperText}\n </p>\n )}\n </div>\n );\n}\n\nSelect.displayName = \"Select\";\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAM,qBAAqB,IACzB,IACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CACF;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAAgB,OAGd,EACA,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,YAAY,MACZ,WACA,UACA,UAAU,CAAC,GACX,aACA,YACA,IAAI,YACJ,SAAS,iBACT,UAEA,UACA,YACmC;CACnC,MAAM,cAAc,MAAM;CAC1B,MAAM,UAAU,cAAc;CAG9B,MAAM,oBAAoB,WAAW,iBAAiB;CACtD,MAAM,aAAyB,qBAAqB,CAAC;CAGrD,MAAM,aAAa,eAAgC;CACnD,MAAM,UAAU,mBAAmB,YAAY;CAG/C,gBAAgB;EACd,IAAI,mBAAmB,yBAAyB;GAC9C,MAAM,QAA8B,CA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AU;gBAAwB;KAAqB,CAAA;IACnD,CAAA,GAEb,YAAY,QAAQ,KAAK,WACxB,oBAAC,YAAD;KAEE,OAAO,OAAO,MAAM,SAAS;KAC7B,UAAU,OAAO;eAEhB,OAAO;IACE,GALL,OAAO,KAKF,CACb,CACY,EAAA,CAAA,CACH;;GAEb,aAAa,YACZ,oBAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;IACV,MAAK;cAEJ;GACA,CAAA;GAGJ,cAAc,CAAC,YACd,oBAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;cAET;GACA,CAAA;EAEF;;AAET;AAEA,OAAO,cAAc"}
|
|
@@ -4,8 +4,8 @@ export { TextBox } from './TextBox';
|
|
|
4
4
|
export type { TextBoxProps } from './TextBox';
|
|
5
5
|
export { TextArea } from './TextArea';
|
|
6
6
|
export type { TextAreaProps } from './TextArea';
|
|
7
|
-
export { Select } from './Select';
|
|
8
|
-
export type { SelectProps, SelectOption } from './Select';
|
|
7
|
+
export { Select, Select as FormSelect } from './Select';
|
|
8
|
+
export type { SelectProps, SelectProps as FormSelectProps, SelectOption } from './Select';
|
|
9
9
|
export { Checkbox, Checkbox as FormCheckbox } from './Checkbox';
|
|
10
10
|
export type { CheckboxProps } from './Checkbox';
|
|
11
11
|
export { RadioGroup, RadioItem } from './Radio';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD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
|
1
|
+
"use client";
|
|
2
|
+
import { FormConfigContext, buildZodSchemaFromRules, defaultFormConfig, useFieldValidationRegistry } from "./context.js";
|
|
3
|
+
import { Form } from "./Form.js";
|
|
4
|
+
import { TextBox } from "./TextBox.js";
|
|
5
|
+
import { TextArea } from "./TextArea.js";
|
|
6
|
+
import { Select } from "./Select.js";
|
|
7
|
+
import { Checkbox } from "./Checkbox.js";
|
|
8
|
+
import { RadioGroup, RadioItem } from "./Radio.js";
|
|
9
|
+
import { FormSwitch } from "./FormSwitch.js";
|
|
10
|
+
import { useFieldError, useForm, useFormConfig, useFormField } from "./hooks.js";
|
|
11
|
+
export { Checkbox, Form, Checkbox as FormCheckbox, FormConfigContext, Select as FormSelect, FormSwitch, RadioGroup, RadioItem, Select, TextArea, TextBox, buildZodSchemaFromRules, defaultFormConfig, useFieldError, useFieldValidationRegistry, useForm, useFormConfig, useFormField };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { Button, buttonVariants } from './components/Button';
|
|
2
2
|
export type { ButtonProps } from './components/Button';
|
|
3
3
|
export { Form, TextBox, TextArea, FormCheckbox, RadioGroup, RadioItem, FormSwitch, FormConfigContext, defaultFormConfig, buildZodSchemaFromRules, useFieldValidationRegistry, useFormConfig, useForm, useFormField, useFieldError, } from './components/Form';
|
|
4
|
-
export
|
|
4
|
+
export { Select as FormSelect } from './components/Form/Select';
|
|
5
|
+
export type { FormProps, TextBoxProps, TextAreaProps, CheckboxProps, RadioGroupProps, RadioItemProps, RadioOption, FormSwitchProps, FormConfig, FormContextValue, FieldValidationRules, FieldRegistration, } from './components/Form';
|
|
6
|
+
export type { SelectProps as FormSelectProps, SelectOption } from './components/Form/Select';
|
|
5
7
|
export { Checkbox } from './components/Checkbox/Checkbox';
|
|
6
8
|
export type { CheckboxProps as StandaloneCheckboxProps } from './components/Checkbox/Checkbox';
|
|
7
9
|
export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, } from './components/Card';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC5D,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGtD,OAAO,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,OAAO,EACP,YAAY,EACZ,aAAa,GACd,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC5D,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGtD,OAAO,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,OAAO,EACP,YAAY,EACZ,aAAa,GACd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE/D,YAAY,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EAAE,WAAW,IAAI,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CA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AA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC/F,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAG/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGrG,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@ import { FormConfigContext, buildZodSchemaFromRules, defaultFormConfig, useField
|
|
|
5
5
|
import { Form } from "./components/Form/Form.js";
|
|
6
6
|
import { TextBox } from "./components/Form/TextBox.js";
|
|
7
7
|
import { TextArea } from "./components/Form/TextArea.js";
|
|
8
|
-
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from "./primitives/select.js";
|
|
8
|
+
import { Select as Select$1, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from "./primitives/select.js";
|
|
9
|
+
import { Select } from "./components/Form/Select.js";
|
|
9
10
|
import { Checkbox as Checkbox$1 } from "./components/Form/Checkbox.js";
|
|
10
11
|
import { RadioGroup, RadioItem } from "./components/Form/Radio.js";
|
|
11
12
|
import { FormSwitch } from "./components/Form/FormSwitch.js";
|
|
@@ -38,4 +39,4 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./comp
|
|
|
38
39
|
import { Skeleton } from "./components/Skeleton/Skeleton.js";
|
|
39
40
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "./components/Accordion/Accordion.js";
|
|
40
41
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "./components/Pagination/Pagination.js";
|
|
41
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, Checkbox$1 as FormCheckbox, FormConfigContext, FormSwitch, Input, Label, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, RadioGroup, RadioItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TextArea, TextBox, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, Toaster, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buildZodSchemaFromRules, buttonVariants, cn, defaultFormConfig, toast, toggleVariants, useDebounce, useFieldError, useFieldValidationRegistry, useForm, useFormConfig, useFormField, useToast, useToggle };
|
|
42
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, Checkbox$1 as FormCheckbox, FormConfigContext, Select as FormSelect, FormSwitch, Input, Label, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, RadioGroup, RadioItem, ScrollArea, ScrollBar, Select$1 as Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TextArea, TextBox, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, Toaster, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buildZodSchemaFromRules, buttonVariants, cn, defaultFormConfig, toast, toggleVariants, useDebounce, useFieldError, useFieldValidationRegistry, useForm, useFormConfig, useFormField, useToast, useToggle };
|