@me1a/ui 2.1.3 → 2.1.5
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/dist/atoms.cjs.js +1 -1
- package/dist/atoms.d.mts +15 -15
- package/dist/atoms.d.ts +15 -15
- package/dist/atoms.esm.js +1 -1
- package/dist/{chunk-QQTIOIYW.esm.js → chunk-3HTFCAYW.esm.js} +2 -2
- package/dist/chunk-3HTFCAYW.esm.js.map +1 -0
- package/dist/{chunk-BAU346R2.esm.js → chunk-3IRQJ7EB.esm.js} +2 -2
- package/dist/chunk-3IRQJ7EB.esm.js.map +1 -0
- package/dist/chunk-6EETNYKI.esm.js +2 -0
- package/dist/chunk-6EETNYKI.esm.js.map +1 -0
- package/dist/{chunk-X5ID4673.esm.js → chunk-7NN2L46N.esm.js} +2 -2
- package/dist/{chunk-X5ID4673.esm.js.map → chunk-7NN2L46N.esm.js.map} +1 -1
- package/dist/{chunk-KHHRPIQY.cjs.js → chunk-BR7Z6MCL.cjs.js} +2 -2
- package/dist/chunk-BR7Z6MCL.cjs.js.map +1 -0
- package/dist/{chunk-PQK6GFRJ.cjs.js → chunk-C4ZAMI2P.cjs.js} +2 -2
- package/dist/chunk-C4ZAMI2P.cjs.js.map +1 -0
- package/dist/{chunk-THOA7DOT.esm.js → chunk-EBPUGBUT.esm.js} +2 -2
- package/dist/chunk-EBPUGBUT.esm.js.map +1 -0
- package/dist/{chunk-LMRZM37Z.cjs.js → chunk-F2K3NFCW.cjs.js} +2 -2
- package/dist/chunk-F2K3NFCW.cjs.js.map +1 -0
- package/dist/{chunk-Y5ZYAMOS.cjs.js → chunk-LDE4UXZ4.cjs.js} +2 -2
- package/dist/chunk-LDE4UXZ4.cjs.js.map +1 -0
- package/dist/{chunk-HTRP5Z25.esm.js → chunk-LEUTYD7G.esm.js} +2 -2
- package/dist/chunk-LEUTYD7G.esm.js.map +1 -0
- package/dist/chunk-TKRGIWLE.cjs.js +2 -0
- package/dist/chunk-TKRGIWLE.cjs.js.map +1 -0
- package/dist/{chunk-Z3J4HE4P.cjs.js → chunk-UAZIJGWR.cjs.js} +2 -2
- package/dist/{chunk-Z3J4HE4P.cjs.js.map → chunk-UAZIJGWR.cjs.js.map} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.esm.js +1 -1
- package/dist/{input-TJ_d3ROF.d.mts → input-Ruz0ZoY6.d.mts} +1 -1
- package/dist/{input-TJ_d3ROF.d.ts → input-Ruz0ZoY6.d.ts} +1 -1
- package/dist/molecules.cjs.js +1 -1
- package/dist/molecules.d.mts +3 -199
- package/dist/molecules.d.ts +3 -199
- package/dist/molecules.esm.js +1 -1
- package/dist/organisms.cjs.js +1 -1
- package/dist/organisms.d.mts +3 -3
- package/dist/organisms.d.ts +3 -3
- package/dist/organisms.esm.js +1 -1
- package/dist/rhf.cjs.js +2 -0
- package/dist/rhf.cjs.js.map +1 -0
- package/dist/rhf.d.mts +199 -0
- package/dist/rhf.d.ts +199 -0
- package/dist/rhf.esm.js +2 -0
- package/dist/rhf.esm.js.map +1 -0
- package/dist/{tooltip-Vd-UgSJF.d.mts → tooltip-B4jzaurK.d.mts} +2 -2
- package/dist/{tooltip-Vd-UgSJF.d.ts → tooltip-B4jzaurK.d.ts} +2 -2
- package/package.json +10 -5
- package/dist/chunk-63AGWKIA.esm.js +0 -2
- package/dist/chunk-63AGWKIA.esm.js.map +0 -1
- package/dist/chunk-AZF4HOYC.cjs.js +0 -2
- package/dist/chunk-AZF4HOYC.cjs.js.map +0 -1
- package/dist/chunk-BAU346R2.esm.js.map +0 -1
- package/dist/chunk-HTRP5Z25.esm.js.map +0 -1
- package/dist/chunk-KHHRPIQY.cjs.js.map +0 -1
- package/dist/chunk-LMRZM37Z.cjs.js.map +0 -1
- package/dist/chunk-PQK6GFRJ.cjs.js.map +0 -1
- package/dist/chunk-QQTIOIYW.esm.js.map +0 -1
- package/dist/chunk-THOA7DOT.esm.js.map +0 -1
- package/dist/chunk-Y5ZYAMOS.cjs.js.map +0 -1
package/dist/rhf.cjs.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkUAZIJGWR_cjs_js=require('./chunk-UAZIJGWR.cjs.js'),chunkBR7Z6MCL_cjs_js=require('./chunk-BR7Z6MCL.cjs.js'),chunkSL2ZUI4G_cjs_js=require('./chunk-SL2ZUI4G.cjs.js'),reactHookForm=require('react-hook-form'),l=require('react'),reactSlot=require('@radix-ui/react-slot'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var l__namespace=/*#__PURE__*/_interopNamespace(l);var z=reactHookForm.FormProvider,D=l__namespace.createContext({}),g=({...e})=>jsxRuntime.jsx(D.Provider,{value:{name:e.name},children:jsxRuntime.jsx(reactHookForm.Controller,{...e})}),C=()=>{let e=l__namespace.useContext(D),r=l__namespace.useContext(S),{getFieldState:o,formState:m}=reactHookForm.useFormContext(),a=o(e.name,m);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:t}=r;return {id:t,name:e.name,formItemId:`${t}-form-item`,formDescriptionId:`${t}-form-item-description`,formMessageId:`${t}-form-item-message`,...a}},S=l__namespace.createContext({}),f=l__namespace.forwardRef(({className:e,...r},o)=>{let m=l__namespace.useId();return jsxRuntime.jsx(S.Provider,{value:{id:m},children:jsxRuntime.jsx("div",{ref:o,className:chunkSL2ZUI4G_cjs_js.a("space-y-2",e),...r})})});f.displayName="FormItem";var x=l__namespace.forwardRef(({className:e,...r},o)=>{let{error:m,formItemId:a}=C();return jsxRuntime.jsx(chunkUAZIJGWR_cjs_js.a,{ref:o,className:chunkSL2ZUI4G_cjs_js.a(m&&"text-destructive",e),htmlFor:a,...r})});x.displayName="FormLabel";var b=l__namespace.forwardRef(({...e},r)=>{let{error:o,formItemId:m,formDescriptionId:a,formMessageId:t}=C();return jsxRuntime.jsx(reactSlot.Slot,{ref:r,id:m,"aria-describedby":o?`${a} ${t}`:`${a}`,"aria-invalid":!!o,...e})});b.displayName="FormControl";var T=l__namespace.forwardRef(({className:e,...r},o)=>{let{formDescriptionId:m}=C();return jsxRuntime.jsx("p",{ref:o,id:m,className:chunkSL2ZUI4G_cjs_js.a("text-sm text-muted-foreground",e),...r})});T.displayName="FormDescription";var v=l__namespace.forwardRef(({className:e,children:r,...o},m)=>{let{error:a,formMessageId:t}=C(),i=a?String(a?.message??""):r;return i?jsxRuntime.jsx("p",{ref:m,id:t,className:chunkSL2ZUI4G_cjs_js.a("text-sm font-medium text-destructive",e),...o,children:i}):null});v.displayName="FormMessage";function ae({name:e,label:r,description:o,className:m,type:a="text",warningText:t,required:i,disabled:y,readOnly:P,placeholder:h,"aria-label":V,"aria-describedby":I,onBlur:N,...L}){let{control:M}=reactHookForm.useFormContext();return jsxRuntime.jsx(g,{name:e,control:M,render:({field:s,fieldState:{error:n}})=>jsxRuntime.jsxs(f,{children:[r&&jsxRuntime.jsxs(x,{children:[r,i&&jsxRuntime.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsxRuntime.jsx(b,{children:jsxRuntime.jsx(chunkBR7Z6MCL_cjs_js.a,{...s,type:a,value:a==="number"&&s.value===0?"":s.value,onChange:F=>{a==="number"?s.onChange(Number(F.target.value)):s.onChange(F.target.value);},onBlur:F=>{a!=="number"&&typeof s.value=="string"&&s.onChange(s.value.trim()),s.onBlur(),N?.(F);},className:chunkSL2ZUI4G_cjs_js.a(n&&"border-destructive focus-visible:ring-destructive",m),disabled:y,readOnly:P,required:i,placeholder:h,"aria-label":V,"aria-describedby":I,"aria-invalid":!!n,"aria-required":i,...L})}),o&&jsxRuntime.jsx(T,{children:o}),n&&jsxRuntime.jsx(v,{children:n.message}),!n&&t&&jsxRuntime.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:t})]})})}var H=l__namespace.forwardRef(({className:e,autoResize:r=false,...o},m)=>{let a=l__namespace.useRef(null);return l__namespace.useEffect(()=>{if(!r||!a.current)return;let t=a.current,i=()=>{t.style.height="auto",t.style.height=`${t.scrollHeight}px`;};return t.addEventListener("input",i),i(),()=>t.removeEventListener("input",i)},[r]),jsxRuntime.jsx("textarea",{className:chunkSL2ZUI4G_cjs_js.a("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:m,...o})});H.displayName="Textarea";function pe({name:e,label:r,description:o,className:m,warningText:a,required:t,disabled:i,readOnly:y,placeholder:P,autoResize:h,"aria-label":V,"aria-describedby":I,onBlur:N,...L}){let{control:M}=reactHookForm.useFormContext();return jsxRuntime.jsx(g,{name:e,control:M,render:({field:s,fieldState:{error:n}})=>jsxRuntime.jsxs(f,{children:[r&&jsxRuntime.jsxs(x,{children:[r,t&&jsxRuntime.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsxRuntime.jsx(b,{children:jsxRuntime.jsx(H,{...s,value:s.value,onChange:F=>{s.onChange(F.target.value);},onBlur:F=>{typeof s.value=="string"&&s.onChange(s.value.trim()),s.onBlur(),N?.(F);},className:chunkSL2ZUI4G_cjs_js.a(n&&"border-destructive focus-visible:ring-destructive",m),disabled:i,readOnly:y,required:t,placeholder:P,"aria-label":V,"aria-describedby":I,"aria-invalid":!!n,"aria-required":t,autoResize:h,...L})}),o&&jsxRuntime.jsx(T,{children:o}),n&&jsxRuntime.jsx(v,{children:n.message}),!n&&a&&jsxRuntime.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:a})]})})}exports.Form=z;exports.FormControl=b;exports.FormDescription=T;exports.FormField=g;exports.FormItem=f;exports.FormLabel=x;exports.FormMessage=v;exports.RHFTextField=ae;exports.RHFTextarea=pe;exports.useFormField=C;//# sourceMappingURL=rhf.cjs.js.map
|
|
2
|
+
//# sourceMappingURL=rhf.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/rhf/form/form.tsx","../src/components/rhf/rhf-text-field/rhf-text-field.tsx","../src/components/atoms/textarea/textarea.tsx","../src/components/rhf/rhf-textarea/rhf-textarea.tsx"],"names":["Form","FormProvider","FormFieldContext","l","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body","RHFTextField","name","label","description","type","warningText","required","disabled","readOnly","placeholder","ariaLabel","ariaDescribedby","onBlur","other","control","field","jsxs","Input","e","Textarea","R","autoResize","internalRef","textarea","resizeTextarea","RHFTextarea"],"mappings":"6qBAiBA,IAAMA,CAAOC,CAAAA,0BAAAA,CASPC,EAAyBC,YAAqC,CAAA,aAAA,CAAA,EAA2B,CAEzFC,CAAAA,CAAAA,CAAY,CAGhB,CACA,GAAGC,CACL,CAAA,GAEIC,cAACJ,CAAAA,CAAAA,CAAiB,SAAjB,CAA0B,KAAA,CAAO,CAAE,IAAMG,CAAAA,CAAAA,CAAM,IAAK,CACnD,CAAA,QAAA,CAAAC,cAACC,CAAAA,wBAAAA,CAAA,CAAY,GAAGF,EAAO,CACzB,CAAA,CAAA,CAIEG,EAAe,IAAM,CACzB,IAAMC,CAAqB,CAAAN,YAAA,CAAA,UAAA,CAAWD,CAAgB,CAAA,CAChDQ,CAAoB,CAAAP,YAAA,CAAA,UAAA,CAAWQ,CAAe,CAC9C,CAAA,CAAE,cAAAC,CAAe,CAAA,SAAA,CAAAC,CAAU,CAAIC,CAAAA,4BAAAA,EAE/BC,CAAAA,CAAAA,CAAaH,CAAcH,CAAAA,CAAAA,CAAa,KAAM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AAA,CAAAA,CAAA,CAAiB,QAAAO,CAAAA,CAAAA,CAAY,EAC7Cd,CAAShB,EAAAA,cAAAA,CAACwB,EAAA,CAAa,QAAA,CAAAR,CAAM,CAAA,OAAA,CAAQ,CACrC,CAAA,CAACA,GAASgB,CACThC,EAAAA,cAAAA,CAAC,GAAE,CAAA,CAAA,SAAA,CAAU,8CAA+C,CAAA,IAAA,CAAK,QAC9D,QAAAgC,CAAAA,CAAAA,CACH,CAEJ,CAAA,CAAA,CAAA,CAEJ,CAEJ","file":"rhf.cjs.js","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport {\n Controller,\n FormProvider,\n useFormContext,\n type ControllerProps,\n type FieldPath,\n type FieldValues\n} from \"react-hook-form\"\n\nimport { cn } from \"@/utils/cn\"\nimport { Label } from \"@/components/atoms/label\"\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\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\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-2\", className)} {...props} />\n </FormItemContext.Provider>\n )\n }\n)\nFormItem.displayName = \"FormItem\"\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n ref={ref}\n className={cn(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n})\nFormLabel.displayName = \"FormLabel\"\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n})\nFormControl.displayName = \"FormControl\"\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = \"FormDescription\"\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\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 ref={ref}\n id={formMessageId}\n className={cn(\"text-sm font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n )\n})\nFormMessage.displayName = \"FormMessage\"\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField\n}\n","import * as React from \"react\"\nimport { useFormContext, type FieldValues, type FieldPath } from \"react-hook-form\"\nimport { Input } from \"@/components/atoms/input\"\nimport { cn } from \"@/utils/cn\"\nimport {\n FormControl,\n FormItem,\n FormMessage,\n FormLabel,\n FormDescription,\n FormField\n} from \"@/components/rhf/form\"\nimport { type RHFTextFieldProps } from \"./rhf-text-field.types\"\n\n// ----------------------------------------------------------------------\n\n/**\n * A text field component that integrates with React Hook Form.\n * Provides form validation, error handling, and accessibility features.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextfield--docs\n *\n * * @example\n * ```tsx\n * <Form>\n * <RHFTextField name=\"name\" label=\"Name\" />\n * <RHFTextField name=\"email\" label=\"Email\" />\n * </Form>\n * ```\n */\nexport function RHFTextField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n description,\n className,\n type = \"text\",\n warningText,\n required,\n disabled,\n readOnly,\n placeholder,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedby,\n onBlur,\n ...other\n}: RHFTextFieldProps<TFieldValues, TName>) {\n const { control } = useFormContext<TFieldValues>()\n\n return (\n <FormField\n name={name}\n control={control}\n render={({ field, fieldState: { error } }) => (\n <FormItem>\n {label && (\n <FormLabel>\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </FormLabel>\n )}\n <FormControl>\n <Input\n {...field}\n type={type}\n value={type === \"number\" && field.value === 0 ? \"\" : field.value}\n onChange={(e) => {\n if (type === \"number\") {\n field.onChange(Number(e.target.value))\n } else {\n field.onChange(e.target.value)\n }\n }}\n onBlur={(e) => {\n // trim if a string\n if (type !== \"number\" && typeof field.value === \"string\") {\n field.onChange(field.value.trim())\n }\n field.onBlur() // pass to react-hook-form\n onBlur?.(e) // pass to wrapper\n }}\n className={cn(\n error && \"border-destructive focus-visible:ring-destructive\",\n className\n )}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={!!error}\n aria-required={required}\n {...other}\n />\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {error && <FormMessage>{error.message}</FormMessage>}\n {!error && warningText && (\n <p className=\"text-sm text-yellow-600 dark:text-yellow-500\" role=\"alert\">\n {warningText}\n </p>\n )}\n </FormItem>\n )}\n />\n )\n}\n","import * as React from \"react\"\nimport { cn } from \"@/utils/index\"\nimport { TextareaProps } from \"./textarea.types\"\n\n/**\n * Textarea component for creating accessible text areas.\n * Built on top of shadcn/ui's Textarea component.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-textarea--docs\n *\n * @example\n * ```tsx\n * <Textarea placeholder=\"Enter text\" />\n * ```\n */\nconst Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, autoResize = false, ...props }, ref) => {\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n\n React.useEffect(() => {\n if (!autoResize || !internalRef.current) return\n\n const textarea = internalRef.current\n const resizeTextarea = () => {\n textarea.style.height = \"auto\"\n textarea.style.height = `${textarea.scrollHeight}px`\n }\n\n textarea.addEventListener(\"input\", resizeTextarea)\n resizeTextarea() // Initial resize\n\n return () => textarea.removeEventListener(\"input\", resizeTextarea)\n }, [autoResize])\n\n return (\n <textarea\n className={cn(\n \"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n }\n)\n\nTextarea.displayName = \"Textarea\"\n\nexport { Textarea }\n","import * as React from \"react\"\nimport { useFormContext, type FieldValues, type FieldPath } from \"react-hook-form\"\nimport { Textarea } from \"@/components/atoms/textarea\"\nimport { cn } from \"@/utils/cn\"\nimport {\n FormControl,\n FormItem,\n FormMessage,\n FormLabel,\n FormDescription,\n FormField\n} from \"@/components/rhf/form\"\nimport { type RHFTextareaProps } from \"./rhf-textarea.types\"\n\n// ----------------------------------------------------------------------\n\n/**\n * A textarea component that integrates with React Hook Form.\n * Provides form validation, error handling, and accessibility features.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextarea--docs\n *\n * @example\n * ```tsx\n * <Form>\n * <RHFTextarea name=\"description\" label=\"Description\" />\n * </Form>\n * ```\n */\nexport function RHFTextarea<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n description,\n className,\n warningText,\n required,\n disabled,\n readOnly,\n placeholder,\n autoResize,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedby,\n onBlur,\n ...other\n}: RHFTextareaProps<TFieldValues, TName>) {\n const { control } = useFormContext<TFieldValues>()\n\n return (\n <FormField\n name={name}\n control={control}\n render={({ field, fieldState: { error } }) => (\n <FormItem>\n {label && (\n <FormLabel>\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </FormLabel>\n )}\n <FormControl>\n <Textarea\n {...field}\n value={field.value}\n onChange={(e) => {\n field.onChange(e.target.value)\n }}\n onBlur={(e) => {\n // trim if a string\n if (typeof field.value === \"string\") {\n field.onChange(field.value.trim())\n }\n field.onBlur() // pass to react-hook-form\n onBlur?.(e) // pass to wrapper\n }}\n className={cn(\n error && \"border-destructive focus-visible:ring-destructive\",\n className\n )}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={!!error}\n aria-required={required}\n autoResize={autoResize}\n {...other}\n />\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {error && <FormMessage>{error.message}</FormMessage>}\n {!error && warningText && (\n <p className=\"text-sm text-yellow-600 dark:text-yellow-500\" role=\"alert\">\n {warningText}\n </p>\n )}\n </FormItem>\n )}\n />\n )\n}\n"]}
|
package/dist/rhf.d.mts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react_hook_form from 'react-hook-form';
|
|
3
|
+
import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { TextareaHTMLAttributes } from 'react';
|
|
6
|
+
import { I as Input } from './input-Ruz0ZoY6.mjs';
|
|
7
|
+
import * as _radix_ui_react_slot from '@radix-ui/react-slot';
|
|
8
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
9
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
10
|
+
|
|
11
|
+
interface RHFTextFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof Input>, "name"> {
|
|
12
|
+
/** The name of the field in the form */
|
|
13
|
+
name: TName;
|
|
14
|
+
/** Optional label for the field */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Optional description text below the field */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Optional warning text to display */
|
|
19
|
+
warningText?: string;
|
|
20
|
+
/** Whether the field is required */
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/** Whether the field is disabled */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Whether the field is read-only */
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
/** The type of input (text, number, email, etc.) */
|
|
27
|
+
type?: React.HTMLInputTypeAttribute;
|
|
28
|
+
/** Optional placeholder text */
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
/** Optional aria-label for accessibility */
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
/** Optional aria-describedby for accessibility */
|
|
33
|
+
"aria-describedby"?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A text field component that integrates with React Hook Form.
|
|
38
|
+
* Provides form validation, error handling, and accessibility features.
|
|
39
|
+
*
|
|
40
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextfield--docs
|
|
41
|
+
*
|
|
42
|
+
* * @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <Form>
|
|
45
|
+
* <RHFTextField name="name" label="Name" />
|
|
46
|
+
* <RHFTextField name="email" label="Email" />
|
|
47
|
+
* </Form>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function RHFTextField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, type, warningText, required, disabled, readOnly, placeholder, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, onBlur, ...other }: RHFTextFieldProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
51
|
+
|
|
52
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
53
|
+
/**
|
|
54
|
+
* Whether the textarea should automatically resize
|
|
55
|
+
*/
|
|
56
|
+
autoResize?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Textarea component for creating accessible text areas.
|
|
61
|
+
* Built on top of shadcn/ui's Textarea component.
|
|
62
|
+
*
|
|
63
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-textarea--docs
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Textarea placeholder="Enter text" />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
71
|
+
|
|
72
|
+
interface RHFTextareaProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof Textarea>, "name"> {
|
|
73
|
+
/** The name of the field in the form */
|
|
74
|
+
name: TName;
|
|
75
|
+
/** Optional label for the field */
|
|
76
|
+
label?: string;
|
|
77
|
+
/** Optional description text below the field */
|
|
78
|
+
description?: string;
|
|
79
|
+
/** Optional warning text to display */
|
|
80
|
+
warningText?: string;
|
|
81
|
+
/** Whether the field is required */
|
|
82
|
+
required?: boolean;
|
|
83
|
+
/** Whether the field is disabled */
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
/** Whether the field is read-only */
|
|
86
|
+
readOnly?: boolean;
|
|
87
|
+
/** Optional placeholder text */
|
|
88
|
+
placeholder?: string;
|
|
89
|
+
/** Optional aria-label for accessibility */
|
|
90
|
+
"aria-label"?: string;
|
|
91
|
+
/** Optional aria-describedby for accessibility */
|
|
92
|
+
"aria-describedby"?: string;
|
|
93
|
+
/** Whether the textarea should automatically resize */
|
|
94
|
+
autoResize?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A textarea component that integrates with React Hook Form.
|
|
99
|
+
* Provides form validation, error handling, and accessibility features.
|
|
100
|
+
*
|
|
101
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextarea--docs
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* <Form>
|
|
106
|
+
* <RHFTextarea name="description" label="Description" />
|
|
107
|
+
* </Form>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare function RHFTextarea<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, warningText, required, disabled, readOnly, placeholder, autoResize, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, onBlur, ...other }: RHFTextareaProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
113
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
114
|
+
declare const useFormField: () => {
|
|
115
|
+
invalid: boolean;
|
|
116
|
+
isDirty: boolean;
|
|
117
|
+
isTouched: boolean;
|
|
118
|
+
isValidating: boolean;
|
|
119
|
+
error?: react_hook_form.FieldError;
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
formItemId: string;
|
|
123
|
+
formDescriptionId: string;
|
|
124
|
+
formMessageId: string;
|
|
125
|
+
};
|
|
126
|
+
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
127
|
+
declare const FormLabel: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
128
|
+
declare const FormControl: React.ForwardRefExoticComponent<Omit<_radix_ui_react_slot.SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
129
|
+
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
130
|
+
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Props interface for the Form component.
|
|
134
|
+
* Extends react-hook-form's FormProvider props.
|
|
135
|
+
*/
|
|
136
|
+
interface FormProps<TFieldValues extends FieldValues = FieldValues> {
|
|
137
|
+
/**
|
|
138
|
+
* The form context value
|
|
139
|
+
*/
|
|
140
|
+
context: React.Context<TFieldValues>;
|
|
141
|
+
/**
|
|
142
|
+
* The form children
|
|
143
|
+
*/
|
|
144
|
+
children: React.ReactNode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Props interface for the FormField component.
|
|
148
|
+
* Extends react-hook-form's Controller props.
|
|
149
|
+
*/
|
|
150
|
+
interface FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends ControllerProps<TFieldValues, TName> {
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Props interface for the FormItem component.
|
|
154
|
+
* Extends HTML div attributes.
|
|
155
|
+
*/
|
|
156
|
+
interface FormItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Props interface for the FormLabel component.
|
|
160
|
+
* Extends Radix UI Label props.
|
|
161
|
+
*/
|
|
162
|
+
interface FormLabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Props interface for the FormControl component.
|
|
166
|
+
* Extends Radix UI Slot props.
|
|
167
|
+
*/
|
|
168
|
+
interface FormControlProps extends React.ComponentPropsWithoutRef<typeof Slot> {
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Props interface for the FormDescription component.
|
|
172
|
+
* Extends HTML paragraph attributes.
|
|
173
|
+
*/
|
|
174
|
+
interface FormDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Props interface for the FormMessage component.
|
|
178
|
+
* Extends HTML paragraph attributes.
|
|
179
|
+
*/
|
|
180
|
+
interface FormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
181
|
+
/**
|
|
182
|
+
* The message content
|
|
183
|
+
*/
|
|
184
|
+
children?: React.ReactNode;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Context value type for form field context
|
|
188
|
+
*/
|
|
189
|
+
type FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
190
|
+
name: TName;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Context value type for form item context
|
|
194
|
+
*/
|
|
195
|
+
type FormItemContextValue = {
|
|
196
|
+
id: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { Form, FormControl, type FormControlProps, FormDescription, type FormDescriptionProps, FormField, type FormFieldContextValue, type FormFieldProps, FormItem, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, RHFTextField, RHFTextarea, useFormField };
|
package/dist/rhf.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react_hook_form from 'react-hook-form';
|
|
3
|
+
import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { TextareaHTMLAttributes } from 'react';
|
|
6
|
+
import { I as Input } from './input-Ruz0ZoY6.js';
|
|
7
|
+
import * as _radix_ui_react_slot from '@radix-ui/react-slot';
|
|
8
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
9
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
10
|
+
|
|
11
|
+
interface RHFTextFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof Input>, "name"> {
|
|
12
|
+
/** The name of the field in the form */
|
|
13
|
+
name: TName;
|
|
14
|
+
/** Optional label for the field */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Optional description text below the field */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Optional warning text to display */
|
|
19
|
+
warningText?: string;
|
|
20
|
+
/** Whether the field is required */
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/** Whether the field is disabled */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Whether the field is read-only */
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
/** The type of input (text, number, email, etc.) */
|
|
27
|
+
type?: React.HTMLInputTypeAttribute;
|
|
28
|
+
/** Optional placeholder text */
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
/** Optional aria-label for accessibility */
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
/** Optional aria-describedby for accessibility */
|
|
33
|
+
"aria-describedby"?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A text field component that integrates with React Hook Form.
|
|
38
|
+
* Provides form validation, error handling, and accessibility features.
|
|
39
|
+
*
|
|
40
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextfield--docs
|
|
41
|
+
*
|
|
42
|
+
* * @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <Form>
|
|
45
|
+
* <RHFTextField name="name" label="Name" />
|
|
46
|
+
* <RHFTextField name="email" label="Email" />
|
|
47
|
+
* </Form>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function RHFTextField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, type, warningText, required, disabled, readOnly, placeholder, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, onBlur, ...other }: RHFTextFieldProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
51
|
+
|
|
52
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
53
|
+
/**
|
|
54
|
+
* Whether the textarea should automatically resize
|
|
55
|
+
*/
|
|
56
|
+
autoResize?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Textarea component for creating accessible text areas.
|
|
61
|
+
* Built on top of shadcn/ui's Textarea component.
|
|
62
|
+
*
|
|
63
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-textarea--docs
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Textarea placeholder="Enter text" />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
71
|
+
|
|
72
|
+
interface RHFTextareaProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof Textarea>, "name"> {
|
|
73
|
+
/** The name of the field in the form */
|
|
74
|
+
name: TName;
|
|
75
|
+
/** Optional label for the field */
|
|
76
|
+
label?: string;
|
|
77
|
+
/** Optional description text below the field */
|
|
78
|
+
description?: string;
|
|
79
|
+
/** Optional warning text to display */
|
|
80
|
+
warningText?: string;
|
|
81
|
+
/** Whether the field is required */
|
|
82
|
+
required?: boolean;
|
|
83
|
+
/** Whether the field is disabled */
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
/** Whether the field is read-only */
|
|
86
|
+
readOnly?: boolean;
|
|
87
|
+
/** Optional placeholder text */
|
|
88
|
+
placeholder?: string;
|
|
89
|
+
/** Optional aria-label for accessibility */
|
|
90
|
+
"aria-label"?: string;
|
|
91
|
+
/** Optional aria-describedby for accessibility */
|
|
92
|
+
"aria-describedby"?: string;
|
|
93
|
+
/** Whether the textarea should automatically resize */
|
|
94
|
+
autoResize?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A textarea component that integrates with React Hook Form.
|
|
99
|
+
* Provides form validation, error handling, and accessibility features.
|
|
100
|
+
*
|
|
101
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextarea--docs
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* <Form>
|
|
106
|
+
* <RHFTextarea name="description" label="Description" />
|
|
107
|
+
* </Form>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare function RHFTextarea<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, warningText, required, disabled, readOnly, placeholder, autoResize, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, onBlur, ...other }: RHFTextareaProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
113
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
114
|
+
declare const useFormField: () => {
|
|
115
|
+
invalid: boolean;
|
|
116
|
+
isDirty: boolean;
|
|
117
|
+
isTouched: boolean;
|
|
118
|
+
isValidating: boolean;
|
|
119
|
+
error?: react_hook_form.FieldError;
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
formItemId: string;
|
|
123
|
+
formDescriptionId: string;
|
|
124
|
+
formMessageId: string;
|
|
125
|
+
};
|
|
126
|
+
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
127
|
+
declare const FormLabel: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
128
|
+
declare const FormControl: React.ForwardRefExoticComponent<Omit<_radix_ui_react_slot.SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
129
|
+
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
130
|
+
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Props interface for the Form component.
|
|
134
|
+
* Extends react-hook-form's FormProvider props.
|
|
135
|
+
*/
|
|
136
|
+
interface FormProps<TFieldValues extends FieldValues = FieldValues> {
|
|
137
|
+
/**
|
|
138
|
+
* The form context value
|
|
139
|
+
*/
|
|
140
|
+
context: React.Context<TFieldValues>;
|
|
141
|
+
/**
|
|
142
|
+
* The form children
|
|
143
|
+
*/
|
|
144
|
+
children: React.ReactNode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Props interface for the FormField component.
|
|
148
|
+
* Extends react-hook-form's Controller props.
|
|
149
|
+
*/
|
|
150
|
+
interface FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends ControllerProps<TFieldValues, TName> {
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Props interface for the FormItem component.
|
|
154
|
+
* Extends HTML div attributes.
|
|
155
|
+
*/
|
|
156
|
+
interface FormItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Props interface for the FormLabel component.
|
|
160
|
+
* Extends Radix UI Label props.
|
|
161
|
+
*/
|
|
162
|
+
interface FormLabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Props interface for the FormControl component.
|
|
166
|
+
* Extends Radix UI Slot props.
|
|
167
|
+
*/
|
|
168
|
+
interface FormControlProps extends React.ComponentPropsWithoutRef<typeof Slot> {
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Props interface for the FormDescription component.
|
|
172
|
+
* Extends HTML paragraph attributes.
|
|
173
|
+
*/
|
|
174
|
+
interface FormDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Props interface for the FormMessage component.
|
|
178
|
+
* Extends HTML paragraph attributes.
|
|
179
|
+
*/
|
|
180
|
+
interface FormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
181
|
+
/**
|
|
182
|
+
* The message content
|
|
183
|
+
*/
|
|
184
|
+
children?: React.ReactNode;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Context value type for form field context
|
|
188
|
+
*/
|
|
189
|
+
type FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
190
|
+
name: TName;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Context value type for form item context
|
|
194
|
+
*/
|
|
195
|
+
type FormItemContextValue = {
|
|
196
|
+
id: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { Form, FormControl, type FormControlProps, FormDescription, type FormDescriptionProps, FormField, type FormFieldContextValue, type FormFieldProps, FormItem, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, RHFTextField, RHFTextarea, useFormField };
|
package/dist/rhf.esm.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-7NN2L46N.esm.js';import {a as a$2}from'./chunk-EBPUGBUT.esm.js';import {a}from'./chunk-C26U3FL4.esm.js';import {useFormContext,FormProvider,Controller}from'react-hook-form';import*as l from'react';import {Slot}from'@radix-ui/react-slot';import {jsx,jsxs}from'react/jsx-runtime';var z=FormProvider,D=l.createContext({}),g=({...e})=>jsx(D.Provider,{value:{name:e.name},children:jsx(Controller,{...e})}),C=()=>{let e=l.useContext(D),r=l.useContext(S),{getFieldState:o,formState:m}=useFormContext(),a=o(e.name,m);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:t}=r;return {id:t,name:e.name,formItemId:`${t}-form-item`,formDescriptionId:`${t}-form-item-description`,formMessageId:`${t}-form-item-message`,...a}},S=l.createContext({}),f=l.forwardRef(({className:e,...r},o)=>{let m=l.useId();return jsx(S.Provider,{value:{id:m},children:jsx("div",{ref:o,className:a("space-y-2",e),...r})})});f.displayName="FormItem";var x=l.forwardRef(({className:e,...r},o)=>{let{error:m,formItemId:a$2}=C();return jsx(a$1,{ref:o,className:a(m&&"text-destructive",e),htmlFor:a$2,...r})});x.displayName="FormLabel";var b=l.forwardRef(({...e},r)=>{let{error:o,formItemId:m,formDescriptionId:a,formMessageId:t}=C();return jsx(Slot,{ref:r,id:m,"aria-describedby":o?`${a} ${t}`:`${a}`,"aria-invalid":!!o,...e})});b.displayName="FormControl";var T=l.forwardRef(({className:e,...r},o)=>{let{formDescriptionId:m}=C();return jsx("p",{ref:o,id:m,className:a("text-sm text-muted-foreground",e),...r})});T.displayName="FormDescription";var v=l.forwardRef(({className:e,children:r,...o},m)=>{let{error:a$1,formMessageId:t}=C(),i=a$1?String(a$1?.message??""):r;return i?jsx("p",{ref:m,id:t,className:a("text-sm font-medium text-destructive",e),...o,children:i}):null});v.displayName="FormMessage";function ae({name:e,label:r,description:o,className:m,type:a$1="text",warningText:t,required:i,disabled:y,readOnly:P,placeholder:h,"aria-label":V,"aria-describedby":I,onBlur:N,...L}){let{control:M}=useFormContext();return jsx(g,{name:e,control:M,render:({field:s,fieldState:{error:n}})=>jsxs(f,{children:[r&&jsxs(x,{children:[r,i&&jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsx(b,{children:jsx(a$2,{...s,type:a$1,value:a$1==="number"&&s.value===0?"":s.value,onChange:F=>{a$1==="number"?s.onChange(Number(F.target.value)):s.onChange(F.target.value);},onBlur:F=>{a$1!=="number"&&typeof s.value=="string"&&s.onChange(s.value.trim()),s.onBlur(),N?.(F);},className:a(n&&"border-destructive focus-visible:ring-destructive",m),disabled:y,readOnly:P,required:i,placeholder:h,"aria-label":V,"aria-describedby":I,"aria-invalid":!!n,"aria-required":i,...L})}),o&&jsx(T,{children:o}),n&&jsx(v,{children:n.message}),!n&&t&&jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:t})]})})}var H=l.forwardRef(({className:e,autoResize:r=false,...o},m)=>{let a$1=l.useRef(null);return l.useEffect(()=>{if(!r||!a$1.current)return;let t=a$1.current,i=()=>{t.style.height="auto",t.style.height=`${t.scrollHeight}px`;};return t.addEventListener("input",i),i(),()=>t.removeEventListener("input",i)},[r]),jsx("textarea",{className:a("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:m,...o})});H.displayName="Textarea";function pe({name:e,label:r,description:o,className:m,warningText:a$1,required:t,disabled:i,readOnly:y,placeholder:P,autoResize:h,"aria-label":V,"aria-describedby":I,onBlur:N,...L}){let{control:M}=useFormContext();return jsx(g,{name:e,control:M,render:({field:s,fieldState:{error:n}})=>jsxs(f,{children:[r&&jsxs(x,{children:[r,t&&jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsx(b,{children:jsx(H,{...s,value:s.value,onChange:F=>{s.onChange(F.target.value);},onBlur:F=>{typeof s.value=="string"&&s.onChange(s.value.trim()),s.onBlur(),N?.(F);},className:a(n&&"border-destructive focus-visible:ring-destructive",m),disabled:i,readOnly:y,required:t,placeholder:P,"aria-label":V,"aria-describedby":I,"aria-invalid":!!n,"aria-required":t,autoResize:h,...L})}),o&&jsx(T,{children:o}),n&&jsx(v,{children:n.message}),!n&&a$1&&jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:a$1})]})})}export{z as Form,b as FormControl,T as FormDescription,g as FormField,f as FormItem,x as FormLabel,v as FormMessage,ae as RHFTextField,pe as RHFTextarea,C as useFormField};//# sourceMappingURL=rhf.esm.js.map
|
|
2
|
+
//# sourceMappingURL=rhf.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/rhf/form/form.tsx","../src/components/rhf/rhf-text-field/rhf-text-field.tsx","../src/components/atoms/textarea/textarea.tsx","../src/components/rhf/rhf-textarea/rhf-textarea.tsx"],"names":["Form","FormProvider","FormFieldContext","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body","RHFTextField","name","label","description","type","warningText","required","disabled","readOnly","placeholder","ariaLabel","ariaDescribedby","onBlur","other","control","field","jsxs","Input","e","Textarea","R","autoResize","internalRef","textarea","resizeTextarea","RHFTextarea"],"mappings":"oTAiBA,IAAMA,CAAOC,CAAAA,YAAAA,CASPC,EAAyB,CAAqC,CAAA,aAAA,CAAA,EAA2B,CAEzFC,CAAAA,CAAAA,CAAY,CAGhB,CACA,GAAGC,CACL,CAAA,GAEIC,GAACH,CAAAA,CAAAA,CAAiB,SAAjB,CAA0B,KAAA,CAAO,CAAE,IAAME,CAAAA,CAAAA,CAAM,IAAK,CACnD,CAAA,QAAA,CAAAC,GAACC,CAAAA,UAAAA,CAAA,CAAY,GAAGF,EAAO,CACzB,CAAA,CAAA,CAIEG,EAAe,IAAM,CACzB,IAAMC,CAAqB,CAAA,CAAA,CAAA,UAAA,CAAWN,CAAgB,CAAA,CAChDO,CAAoB,CAAA,CAAA,CAAA,UAAA,CAAWC,CAAe,CAC9C,CAAA,CAAE,cAAAC,CAAe,CAAA,SAAA,CAAAC,CAAU,CAAIC,CAAAA,cAAAA,EAE/BC,CAAAA,CAAAA,CAAaH,CAAcH,CAAAA,CAAAA,CAAa,KAA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AAAO,CAAAA,CAAAA,CAAY,EAC7Cd,CAAShB,EAAAA,GAAAA,CAACwB,EAAA,CAAa,QAAA,CAAAR,CAAM,CAAA,OAAA,CAAQ,CACrC,CAAA,CAACA,GAASgB,GACThC,EAAAA,GAAAA,CAAC,GAAE,CAAA,CAAA,SAAA,CAAU,8CAA+C,CAAA,IAAA,CAAK,QAC9D,QAAAgC,CAAAA,GAAAA,CACH,CAEJ,CAAA,CAAA,CAAA,CAEJ,CAEJ","file":"rhf.esm.js","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport {\n Controller,\n FormProvider,\n useFormContext,\n type ControllerProps,\n type FieldPath,\n type FieldValues\n} from \"react-hook-form\"\n\nimport { cn } from \"@/utils/cn\"\nimport { Label } from \"@/components/atoms/label\"\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\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\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-2\", className)} {...props} />\n </FormItemContext.Provider>\n )\n }\n)\nFormItem.displayName = \"FormItem\"\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n ref={ref}\n className={cn(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n})\nFormLabel.displayName = \"FormLabel\"\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n})\nFormControl.displayName = \"FormControl\"\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = \"FormDescription\"\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\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 ref={ref}\n id={formMessageId}\n className={cn(\"text-sm font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n )\n})\nFormMessage.displayName = \"FormMessage\"\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField\n}\n","import * as React from \"react\"\nimport { useFormContext, type FieldValues, type FieldPath } from \"react-hook-form\"\nimport { Input } from \"@/components/atoms/input\"\nimport { cn } from \"@/utils/cn\"\nimport {\n FormControl,\n FormItem,\n FormMessage,\n FormLabel,\n FormDescription,\n FormField\n} from \"@/components/rhf/form\"\nimport { type RHFTextFieldProps } from \"./rhf-text-field.types\"\n\n// ----------------------------------------------------------------------\n\n/**\n * A text field component that integrates with React Hook Form.\n * Provides form validation, error handling, and accessibility features.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextfield--docs\n *\n * * @example\n * ```tsx\n * <Form>\n * <RHFTextField name=\"name\" label=\"Name\" />\n * <RHFTextField name=\"email\" label=\"Email\" />\n * </Form>\n * ```\n */\nexport function RHFTextField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n description,\n className,\n type = \"text\",\n warningText,\n required,\n disabled,\n readOnly,\n placeholder,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedby,\n onBlur,\n ...other\n}: RHFTextFieldProps<TFieldValues, TName>) {\n const { control } = useFormContext<TFieldValues>()\n\n return (\n <FormField\n name={name}\n control={control}\n render={({ field, fieldState: { error } }) => (\n <FormItem>\n {label && (\n <FormLabel>\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </FormLabel>\n )}\n <FormControl>\n <Input\n {...field}\n type={type}\n value={type === \"number\" && field.value === 0 ? \"\" : field.value}\n onChange={(e) => {\n if (type === \"number\") {\n field.onChange(Number(e.target.value))\n } else {\n field.onChange(e.target.value)\n }\n }}\n onBlur={(e) => {\n // trim if a string\n if (type !== \"number\" && typeof field.value === \"string\") {\n field.onChange(field.value.trim())\n }\n field.onBlur() // pass to react-hook-form\n onBlur?.(e) // pass to wrapper\n }}\n className={cn(\n error && \"border-destructive focus-visible:ring-destructive\",\n className\n )}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={!!error}\n aria-required={required}\n {...other}\n />\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {error && <FormMessage>{error.message}</FormMessage>}\n {!error && warningText && (\n <p className=\"text-sm text-yellow-600 dark:text-yellow-500\" role=\"alert\">\n {warningText}\n </p>\n )}\n </FormItem>\n )}\n />\n )\n}\n","import * as React from \"react\"\nimport { cn } from \"@/utils/index\"\nimport { TextareaProps } from \"./textarea.types\"\n\n/**\n * Textarea component for creating accessible text areas.\n * Built on top of shadcn/ui's Textarea component.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-textarea--docs\n *\n * @example\n * ```tsx\n * <Textarea placeholder=\"Enter text\" />\n * ```\n */\nconst Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, autoResize = false, ...props }, ref) => {\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n\n React.useEffect(() => {\n if (!autoResize || !internalRef.current) return\n\n const textarea = internalRef.current\n const resizeTextarea = () => {\n textarea.style.height = \"auto\"\n textarea.style.height = `${textarea.scrollHeight}px`\n }\n\n textarea.addEventListener(\"input\", resizeTextarea)\n resizeTextarea() // Initial resize\n\n return () => textarea.removeEventListener(\"input\", resizeTextarea)\n }, [autoResize])\n\n return (\n <textarea\n className={cn(\n \"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n }\n)\n\nTextarea.displayName = \"Textarea\"\n\nexport { Textarea }\n","import * as React from \"react\"\nimport { useFormContext, type FieldValues, type FieldPath } from \"react-hook-form\"\nimport { Textarea } from \"@/components/atoms/textarea\"\nimport { cn } from \"@/utils/cn\"\nimport {\n FormControl,\n FormItem,\n FormMessage,\n FormLabel,\n FormDescription,\n FormField\n} from \"@/components/rhf/form\"\nimport { type RHFTextareaProps } from \"./rhf-textarea.types\"\n\n// ----------------------------------------------------------------------\n\n/**\n * A textarea component that integrates with React Hook Form.\n * Provides form validation, error handling, and accessibility features.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhftextarea--docs\n *\n * @example\n * ```tsx\n * <Form>\n * <RHFTextarea name=\"description\" label=\"Description\" />\n * </Form>\n * ```\n */\nexport function RHFTextarea<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n description,\n className,\n warningText,\n required,\n disabled,\n readOnly,\n placeholder,\n autoResize,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedby,\n onBlur,\n ...other\n}: RHFTextareaProps<TFieldValues, TName>) {\n const { control } = useFormContext<TFieldValues>()\n\n return (\n <FormField\n name={name}\n control={control}\n render={({ field, fieldState: { error } }) => (\n <FormItem>\n {label && (\n <FormLabel>\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </FormLabel>\n )}\n <FormControl>\n <Textarea\n {...field}\n value={field.value}\n onChange={(e) => {\n field.onChange(e.target.value)\n }}\n onBlur={(e) => {\n // trim if a string\n if (typeof field.value === \"string\") {\n field.onChange(field.value.trim())\n }\n field.onBlur() // pass to react-hook-form\n onBlur?.(e) // pass to wrapper\n }}\n className={cn(\n error && \"border-destructive focus-visible:ring-destructive\",\n className\n )}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={!!error}\n aria-required={required}\n autoResize={autoResize}\n {...other}\n />\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {error && <FormMessage>{error.message}</FormMessage>}\n {!error && warningText && (\n <p className=\"text-sm text-yellow-600 dark:text-yellow-500\" role=\"alert\">\n {warningText}\n </p>\n )}\n </FormItem>\n )}\n />\n )\n}\n"]}
|
|
@@ -50,7 +50,7 @@ declare const buttonVariants: (props?: ({
|
|
|
50
50
|
* Built on top of Radix UI's Slot primitive for maximum flexibility.
|
|
51
51
|
* Implements proper accessibility features and follows WCAG 2.1 Level AA guidelines.
|
|
52
52
|
*
|
|
53
|
-
* @url https://
|
|
53
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-button--docs
|
|
54
54
|
*
|
|
55
55
|
* @component
|
|
56
56
|
* @example
|
|
@@ -84,7 +84,7 @@ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAtt
|
|
|
84
84
|
* TooltipProvider component for creating accessible tooltips.
|
|
85
85
|
* Built on top of Radix UI's Tooltip primitive.
|
|
86
86
|
*
|
|
87
|
-
* @url https://
|
|
87
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-tooltip--docs
|
|
88
88
|
*
|
|
89
89
|
* @example
|
|
90
90
|
* ```tsx
|
|
@@ -50,7 +50,7 @@ declare const buttonVariants: (props?: ({
|
|
|
50
50
|
* Built on top of Radix UI's Slot primitive for maximum flexibility.
|
|
51
51
|
* Implements proper accessibility features and follows WCAG 2.1 Level AA guidelines.
|
|
52
52
|
*
|
|
53
|
-
* @url https://
|
|
53
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-button--docs
|
|
54
54
|
*
|
|
55
55
|
* @component
|
|
56
56
|
* @example
|
|
@@ -84,7 +84,7 @@ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAtt
|
|
|
84
84
|
* TooltipProvider component for creating accessible tooltips.
|
|
85
85
|
* Built on top of Radix UI's Tooltip primitive.
|
|
86
86
|
*
|
|
87
|
-
* @url https://
|
|
87
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-tooltip--docs
|
|
88
88
|
*
|
|
89
89
|
* @example
|
|
90
90
|
* ```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@me1a/ui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"import": "./dist/molecules.esm.js",
|
|
22
22
|
"require": "./dist/molecules.cjs.js"
|
|
23
23
|
},
|
|
24
|
+
"./rhf": {
|
|
25
|
+
"types": "./dist/rhf.d.ts",
|
|
26
|
+
"import": "./dist/rhf.esm.js",
|
|
27
|
+
"require": "./dist/rhf.cjs.js"
|
|
28
|
+
},
|
|
24
29
|
"./organisms": {
|
|
25
30
|
"types": "./dist/organisms.d.ts",
|
|
26
31
|
"import": "./dist/organisms.esm.js",
|
|
@@ -131,14 +136,14 @@
|
|
|
131
136
|
},
|
|
132
137
|
"repository": {
|
|
133
138
|
"type": "git",
|
|
134
|
-
"url": "git+https://github.com/
|
|
139
|
+
"url": "git+https://github.com/sergii-melnykov/ui.git"
|
|
135
140
|
},
|
|
136
141
|
"author": "",
|
|
137
142
|
"license": "ISC",
|
|
138
143
|
"bugs": {
|
|
139
|
-
"url": "https://github.com/
|
|
144
|
+
"url": "https://github.com/sergii-melnykov/ui/issues"
|
|
140
145
|
},
|
|
141
|
-
"homepage": "https://github.com/
|
|
146
|
+
"homepage": "https://github.com/sergii-melnykov/ui#readme",
|
|
142
147
|
"description": "A modern UI library for Next.js applications",
|
|
143
|
-
"storybook": "https://
|
|
148
|
+
"storybook": "https://sergii-melnykov.github.io/ui"
|
|
144
149
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-X5ID4673.esm.js';import {a as a$2}from'./chunk-THOA7DOT.esm.js';import {a}from'./chunk-C26U3FL4.esm.js';import*as l from'react';import {jsx,jsxs}from'react/jsx-runtime';import*as i from'@radix-ui/react-navigation-menu';import {ChevronDown}from'lucide-react';import {cva}from'class-variance-authority';import {useFormContext,FormProvider,Controller}from'react-hook-form';import {Slot}from'@radix-ui/react-slot';var Y=l.forwardRef(({className:e,...t},a$1)=>jsx("div",{ref:a$1,className:a("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Y.displayName="Card";var Z=l.forwardRef(({className:e,...t},a$1)=>jsx("div",{ref:a$1,className:a("flex flex-col space-y-1.5 p-6",e),...t}));Z.displayName="CardHeader";var _=l.forwardRef(({className:e,...t},a$1)=>jsx("h3",{ref:a$1,className:a("text-2xl font-semibold leading-none tracking-tight",e),...t}));_.displayName="CardTitle";var ee=l.forwardRef(({className:e,...t},a$1)=>jsx("p",{ref:a$1,className:a("text-sm text-muted-foreground",e),...t}));ee.displayName="CardDescription";var te=l.forwardRef(({className:e,...t},a$1)=>jsx("div",{ref:a$1,className:a("p-6 pt-0",e),...t}));te.displayName="CardContent";var ae=l.forwardRef(({className:e,...t},a$1)=>jsx("div",{ref:a$1,className:a("flex items-center p-6 pt-0",e),...t}));ae.displayName="CardFooter";var B=cva("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",{variants:{variant:{default:"text-foreground",ghost:"hover:bg-transparent hover:underline",link:"text-primary underline-offset-4 hover:underline",mobile:"w-full justify-between border-b border-border py-4 text-base font-medium"}},defaultVariants:{variant:"default"}});var O=l.forwardRef(({className:e,children:t,...a$1},n)=>jsxs(i.Root,{ref:n,className:a("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...a$1,children:[t,jsx(S,{})]}));O.displayName=i.Root.displayName;var W=l.forwardRef(({className:e,...t},a$1)=>jsx(i.List,{ref:a$1,className:a("group flex flex-1 list-none items-center justify-center space-x-1",e),...t}));W.displayName=i.List.displayName;var ie=i.Item,j=l.forwardRef(({className:e,children:t,variant:a$1,...n},r)=>jsxs(i.Trigger,{ref:r,className:a(B({variant:a$1}),e),...n,children:[t," ",jsx(ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));j.displayName=i.Trigger.displayName;var q=l.forwardRef(({className:e,...t},a$1)=>jsx(i.Content,{ref:a$1,className:a("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto",e),...t}));q.displayName=i.Content.displayName;var ne=i.Link,S=l.forwardRef(({className:e,...t},a$1)=>jsx("div",{className:a("absolute left-0 top-full flex justify-center"),children:jsx(i.Viewport,{className:a("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",e),ref:a$1,...t})}));S.displayName=i.Viewport.displayName;var G=l.forwardRef(({className:e,...t},a$1)=>jsx(i.Indicator,{ref:a$1,className:a("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",e),...t,children:jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));G.displayName=i.Indicator.displayName;var ue=FormProvider,K=l.createContext({}),h=({...e})=>jsx(K.Provider,{value:{name:e.name},children:jsx(Controller,{...e})}),C=()=>{let e=l.useContext(K),t=l.useContext(Q),{getFieldState:a,formState:n}=useFormContext(),r=a(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return {id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...r}},Q=l.createContext({}),x=l.forwardRef(({className:e,...t},a$1)=>{let n=l.useId();return jsx(Q.Provider,{value:{id:n},children:jsx("div",{ref:a$1,className:a("space-y-2",e),...t})})});x.displayName="FormItem";var R=l.forwardRef(({className:e,...t},a$2)=>{let{error:n,formItemId:r}=C();return jsx(a$1,{ref:a$2,className:a(n&&"text-destructive",e),htmlFor:r,...t})});R.displayName="FormLabel";var P=l.forwardRef(({...e},t)=>{let{error:a,formItemId:n,formDescriptionId:r,formMessageId:s}=C();return jsx(Slot,{ref:t,id:n,"aria-describedby":a?`${r} ${s}`:`${r}`,"aria-invalid":!!a,...e})});P.displayName="FormControl";var b=l.forwardRef(({className:e,...t},a$1)=>{let{formDescriptionId:n}=C();return jsx("p",{ref:a$1,id:n,className:a("text-sm text-muted-foreground",e),...t})});b.displayName="FormDescription";var y=l.forwardRef(({className:e,children:t,...a$1},n)=>{let{error:r,formMessageId:s}=C(),d=r?String(r?.message??""):t;return d?jsx("p",{ref:n,id:s,className:a("text-sm font-medium text-destructive",e),...a$1,children:d}):null});y.displayName="FormMessage";function ze({name:e,label:t,description:a$1,className:n,type:r="text",warningText:s,required:d,disabled:L,readOnly:w,placeholder:V,"aria-label":I,"aria-describedby":H,onBlur:E,...D}){let{control:A}=useFormContext();return jsx(h,{name:e,control:A,render:({field:m,fieldState:{error:u}})=>jsxs(x,{children:[t&&jsxs(R,{children:[t,d&&jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsx(P,{children:jsx(a$2,{...m,type:r,value:r==="number"&&m.value===0?"":m.value,onChange:p=>{r==="number"?m.onChange(Number(p.target.value)):m.onChange(p.target.value);},onBlur:p=>{r!=="number"&&typeof m.value=="string"&&m.onChange(m.value.trim()),m.onBlur(),E?.(p);},className:a(u&&"border-destructive focus-visible:ring-destructive",n),disabled:L,readOnly:w,required:d,placeholder:V,"aria-label":I,"aria-describedby":H,"aria-invalid":!!u,"aria-required":d,...D})}),a$1&&jsx(b,{children:a$1}),u&&jsx(y,{children:u.message}),!u&&s&&jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:s})]})})}var k=l.forwardRef(({className:e,autoResize:t=false,...a$1},n)=>{let r=l.useRef(null);return l.useEffect(()=>{if(!t||!r.current)return;let s=r.current,d=()=>{s.style.height="auto",s.style.height=`${s.scrollHeight}px`;};return s.addEventListener("input",d),d(),()=>s.removeEventListener("input",d)},[t]),jsx("textarea",{className:a("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...a$1})});k.displayName="Textarea";function Ue({name:e,label:t,description:a$1,className:n,warningText:r,required:s,disabled:d,readOnly:L,placeholder:w,autoResize:V,"aria-label":I,"aria-describedby":H,onBlur:E,...D}){let{control:A}=useFormContext();return jsx(h,{name:e,control:A,render:({field:m,fieldState:{error:u}})=>jsxs(x,{children:[t&&jsxs(R,{children:[t,s&&jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsx(P,{children:jsx(k,{...m,value:m.value,onChange:p=>{m.onChange(p.target.value);},onBlur:p=>{typeof m.value=="string"&&m.onChange(m.value.trim()),m.onBlur(),E?.(p);},className:a(u&&"border-destructive focus-visible:ring-destructive",n),disabled:d,readOnly:L,required:s,placeholder:w,"aria-label":I,"aria-describedby":H,"aria-invalid":!!u,"aria-required":s,autoResize:V,...D})}),a$1&&jsx(b,{children:a$1}),u&&jsx(y,{children:u.message}),!u&&r&&jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:r})]})})}export{Y as a,Z as b,_ as c,ee as d,te as e,ae as f,O as g,W as h,ie as i,j,q as k,ne as l,S as m,G as n,ue as o,h as p,C as q,x as r,R as s,P as t,b as u,y as v,ze as w,Ue as x};//# sourceMappingURL=chunk-63AGWKIA.esm.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-63AGWKIA.esm.js.map
|