@itera-web/react-ui-form 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Form.d.ts +1 -0
- package/es/index.js +1 -1
- package/package.json +2 -2
package/es/Form.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare const useFormField: () => {
|
|
|
33
33
|
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
34
34
|
interface FormLabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {
|
|
35
35
|
width?: number | string;
|
|
36
|
+
required?: boolean;
|
|
36
37
|
}
|
|
37
38
|
declare const FormLabel: React.ForwardRefExoticComponent<FormLabelProps & React.RefAttributes<HTMLLabelElement>>;
|
|
38
39
|
declare const FormControl: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-slot").SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import*as r from"react-hook-form";import*as t from"@itera-web/react-ui-label";import*as o from"@itera-web/utils-cn";import*as a from"@radix-ui/react-slot";var n={d:(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},l={};n.d(l,{l0:()=>b,NI:()=>
|
|
1
|
+
import*as e from"react";import*as r from"react-hook-form";import*as t from"@itera-web/react-ui-label";import*as o from"@itera-web/utils-cn";import*as a from"@radix-ui/react-slot";var n={d:(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},l={};n.d(l,{l0:()=>b,NI:()=>g,pf:()=>I,Wi:()=>y,xJ:()=>N,lX:()=>w,zG:()=>C,YV:()=>h});const i=(e=>{var r={};return n.d(r,e),r})({createContext:()=>e.createContext,createElement:()=>e.createElement,forwardRef:()=>e.forwardRef,useContext:()=>e.useContext,useId:()=>e.useId});const m=(e=>{var r={};return n.d(r,e),r})({Controller:()=>r.Controller,FormProvider:()=>r.FormProvider,useFormContext:()=>r.useFormContext});const s=(e=>{var r={};return n.d(r,e),r})({Label:()=>t.Label});const c=(e=>{var r={};return n.d(r,e),r})({cn:()=>o.cn});const d=(e=>{var r={};return n.d(r,e),r})({Slot:()=>a.Slot});var f=function(){return f=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},f.apply(this,arguments)},u=function(e,r){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(o=Object.getOwnPropertySymbols(e);a<o.length;a++)r.indexOf(o[a])<0&&Object.prototype.propertyIsEnumerable.call(e,o[a])&&(t[o[a]]=e[o[a]])}return t},p=i.createContext({layout:"vertical",labelLayout:"horizontal"}),v=i.createContext({}),x=function(){return i.useContext(p)},b=function(e){var r=e.children,t=e.layout,o=void 0===t?"vertical":t,a=e.labelLayout,n=void 0===a?"horizontal":a,l=e.form,s=e.className,d=e.style,u=e.onSubmit;return i.createElement(p.Provider,{value:{layout:o,labelLayout:n}},i.createElement(m.FormProvider,f({},l),i.createElement("form",{className:(0,c.cn)("flex gap-[36px] w-full","horizontal"===o?"flex-wrap items-end":"flex-col",s),onSubmit:u&&l.handleSubmit(u),style:d},r)))},y=function(e){var r=u(e,[]);return i.createElement(v.Provider,{value:{name:r.name}},i.createElement(m.Controller,f({},r)))},h=function(){var e=i.useContext(v),r=i.useContext(F),t=(0,m.useFormContext)(),o=t.getFieldState,a=t.formState,n=o(e.name,a);if(!e)throw new Error("useFormField should be used within <FormField>");var l=r.id;return f({id:l,name:e.name,formItemId:"".concat(l,"-form-item"),formDescriptionId:"".concat(l,"-form-item-description"),formMessageId:"".concat(l,"-form-item-message")},n)},F=i.createContext({}),N=i.forwardRef(function(e,r){var t=e.className,o=u(e,["className"]),a=i.useId(),n=x().labelLayout;return i.createElement(F.Provider,{value:{id:a}},i.createElement("div",f({className:(0,c.cn)("text-font relative","horizontal"===n?"flex items-center":"flex flex-col",t),ref:r},o)))});N.displayName="FormItem";var w=i.forwardRef(function(e,r){var t=e.className,o=e.width,a=void 0===o?80:o,n=e.required,l=void 0!==n&&n,m=e.children,d=u(e,["className","width","required","children"]),p=h(),v=p.error,b=p.formItemId,y=x().labelLayout;return i.createElement(s.Label,f({className:(0,c.cn)("text-font",v&&"text-destructive","horizontal"===y?"text-right pr-[6px]":"text-left pb-2",t),htmlFor:b,ref:r,style:{width:"number"==typeof a?"".concat(a,"px"):a}},d),l?i.createElement("div",{className:"flex items-center gap-1"},i.createElement("span",{className:"text-red-400"},"*"),m):m)});w.displayName="FormLabel";var g=i.forwardRef(function(e,r){var t=u(e,[]),o=h(),a=o.error,n=o.formItemId,l=o.formDescriptionId,m=o.formMessageId;return i.createElement(d.Slot,f({"aria-describedby":a?"".concat(l," ").concat(m):"".concat(l),"aria-invalid":!!a,id:n,ref:r},t))});g.displayName="FormControl";var I=i.forwardRef(function(e,r){var t=e.className,o=u(e,["className"]),a=h().formDescriptionId;return i.createElement("p",f({className:(0,c.cn)("text-sm text-muted-foreground",t),id:a,ref:r},o))});I.displayName="FormDescription";var C=i.forwardRef(function(e,r){var t,o=e.className,a=e.children,n=u(e,["className","children"]),l=h(),m=l.error,s=l.formMessageId,d=m?String(null!==(t=null==m?void 0:m.message)&&void 0!==t?t:""):a;return d?i.createElement("p",f({className:(0,c.cn)("absolute right-0 bottom-[-24px] h-2 text-sm font-medium text-amber-500",o),id:s,ref:r},n),d):null});C.displayName="FormMessage";var E=l.l0,O=l.NI,P=l.pf,S=l.Wi,L=l.xJ,j=l.lX,z=l.zG,R=l.YV;export{E as Form,O as FormControl,P as FormDescription,S as FormField,L as FormItem,j as FormLabel,z as FormMessage,R as useFormField};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itera-web/react-ui-form",
|
|
3
3
|
"description": "表单",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.25.0",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
7
7
|
"publishConfig": {
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@itera-web/cli": "^1.1.54"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "e4e1e67e9d8c72c1191557b2aa39d47e623e1a20"
|
|
30
30
|
}
|