@s_mart/form 2.1.2 → 2.2.1

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/index.d.ts CHANGED
@@ -13,7 +13,7 @@ declare type TextFieldProps = TextFieldProps$1 & ControllerTextField & {
13
13
  mask?: Masks;
14
14
  };
15
15
 
16
- declare const TextField: ({ name, rules, defaultValue, shouldUnregister, label, required, mask, ...rest }: TextFieldProps) => JSX.Element;
16
+ declare const TextField: ({ name, rules, defaultValue, shouldUnregister, label, required, mask, variant, ...rest }: TextFieldProps) => JSX.Element;
17
17
 
18
18
  declare type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
19
19
  declare type SelectOption = {
package/dist/index.js CHANGED
@@ -1,60 +1,60 @@
1
- "use strict";var h2=Object.create;var E=Object.defineProperty;var x2=Object.getOwnPropertyDescriptor;var b2=Object.getOwnPropertyNames;var y2=Object.getPrototypeOf,F2=Object.prototype.hasOwnProperty;var w2=(C,i)=>{for(var e in i)E(C,e,{get:i[e],enumerable:!0})},j=(C,i,e,H)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of b2(i))!F2.call(C,o)&&o!==e&&E(C,o,{get:()=>i[o],enumerable:!(H=x2(i,o))||H.enumerable});return C};var C2=(C,i,e)=>(e=C!=null?h2(y2(C)):{},j(i||!C||!C.__esModule?E(e,"default",{value:C,enumerable:!0}):e,C)),P2=C=>j(E({},"__esModule",{value:!0}),C);var U2={};w2(U2,{Checkbox:()=>a2,Creatable:()=>c2,Form:()=>i2,RadioButton:()=>m2,RadioGroup:()=>u2,Searchable:()=>L2,Select:()=>V2,Slider:()=>g2,Switch:()=>p2,TextField:()=>l2});module.exports=P2(U2);var D=require("react-hook-form"),K=require("react/jsx-runtime");function k2({children:C,onSubmit:i,...e}){let H=(0,D.useForm)(e);return(0,K.jsx)(D.FormProvider,{...H,children:(0,K.jsx)("form",{onSubmit:H.handleSubmit(i),children:C})})}var i2=k2;var I=require("react-hook-form"),G=require("@mui/material");var Q=require("@mui/material"),e2=require("@s_mart/utils"),T=require("react/jsx-runtime"),s=({label:C,required:i,regular:e})=>(0,T.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:(0,e2.toRem)(2)},children:[(0,T.jsx)(Q.Typography,{variant:"caption",fontWeight:e?400:700,style:{display:"flex",alignItems:"center"},children:C}),i&&(0,T.jsx)(Q.Typography,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});var o2=require("react-hook-form"),H2=require("@s_mart/core"),r2=require("react/jsx-runtime"),Z=({name:C})=>{var e,H,o;let i=(0,o2.useFormContext)();return(H=(e=i==null?void 0:i.formState)==null?void 0:e.errors)!=null&&H[C]?(0,r2.jsx)(H2.Indicator,{severity:"error",children:(o=i.formState.errors[C])==null?void 0:o.message}):null};var n2=C2(require("@s_mart/masks")),b=require("react/jsx-runtime"),v2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,required:d,mask:n,...l})=>{let V=(0,I.useFormContext)();if(!V)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=r=>n?n2[n].format(r):r,a=r=>n?n2[n].parse(r):r,c=r=>{if(!r||n!=="porcentagem")return;r==null||r.stopPropagation();let t=(r==null?void 0:r.target).value;if(t){let x=String(t);if(x.length>0){let S=x.indexOf("%");S>-1&&(r.currentTarget.selectionEnd=S)}}};return(0,b.jsx)(I.Controller,{control:V.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:r,onChange:t}})=>(0,b.jsxs)(G.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,b.jsx)(s,{label:o,required:d}),(0,b.jsx)(G.TextField,{size:"small",variant:"outlined",autoComplete:"off",defaultValue:e,value:L(r||""),onChange:x=>t(a(x.target.value)),InputProps:{onKeyDown:c},...l}),(0,b.jsx)(Z,{name:C})]})})},l2=v2;var R=require("react-hook-form"),F=require("@mui/material");var m=require("react/jsx-runtime"),S2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,required:d,options:n,...l})=>{let V=(0,R.useFormContext)();if(!V)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,m.jsx)(R.Controller,{control:V.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:L,onChange:a}})=>(0,m.jsxs)(F.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,m.jsx)(s,{label:o,required:d}),(0,m.jsx)(F.Select,{size:"small",variant:"outlined",autoComplete:"off",value:L||"",onChange:a,...l,children:n==null?void 0:n.map((c,r)=>(0,m.jsx)(F.MenuItem,{value:c.value,children:c.label},r))}),(0,m.jsx)(Z,{name:C})]})})},V2=S2;var U=require("react-hook-form"),w=require("@mui/material");var u=require("react/jsx-runtime"),B2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,required:d,options:n,textFieldProps:l,...V})=>{let L=(0,U.useFormContext)();if(!L)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,u.jsx)(U.Controller,{control:L.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{onChange:a}})=>(0,u.jsxs)(w.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,u.jsx)(s,{label:o,required:d}),(0,u.jsx)(w.Autocomplete,{size:"small",onChange:(c,r)=>a(r),options:n,noOptionsText:"Nenhuma op\xE7\xE3o encontrada",...V,renderInput:c=>(0,u.jsx)(w.TextField,{...c,...l})}),(0,u.jsx)(Z,{name:C})]})})},L2=B2;var q=require("react-hook-form"),f=require("@mui/material"),Z2=require("@s_mart/core");var d2={description:"M35.8286 21.8493H26.1506V12.1714C26.1506 11.6338 25.613 11.0961 25.0753 11.0961H22.9247C22.3198 11.0961 21.8493 11.6338 21.8493 12.1714V21.8493H12.1714C11.5666 21.8493 11.0961 22.387 11.0961 22.9247V25.0753C11.0961 25.6802 11.5666 26.1506 12.1714 26.1506H21.8493V35.8286C21.8493 36.4334 22.3198 36.9039 22.9247 36.9039H25.0753C25.613 36.9039 26.1506 36.4334 26.1506 35.8286V26.1506H35.8286C36.3662 26.1506 36.9039 25.6802 36.9039 25.0753V22.9247C36.9039 22.387 36.3662 21.8493 35.8286 21.8493Z",viewBox:"0 0 48 48",id:"line-plus-solid"};var p=require("@s_mart/utils"),Y=C2(require("@emotion/styled")),J=require("@emotion/react"),t2=J.css`
1
+ "use strict";var we=Object.create;var k=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ae=(e,r)=>{for(var o in r)k(e,o,{get:r[o],enumerable:!0})},re=(e,r,o,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of Ge(r))!Te.call(e,t)&&t!==o&&k(e,t,{get:()=>r[t],enumerable:!(l=Ee(r,t))||l.enumerable});return e};var oe=(e,r,o)=>(o=e!=null?we(Ie(e)):{},re(r||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),ve=e=>re(k({},"__esModule",{value:!0}),e);var Oe={};Ae(Oe,{Checkbox:()=>be,Creatable:()=>Fe,Form:()=>te,RadioButton:()=>ge,RadioGroup:()=>Ce,Searchable:()=>ue,Select:()=>pe,Slider:()=>Se,Switch:()=>ye,TextField:()=>me});module.exports=ve(Oe);var U=require("react-hook-form"),Q=require("react/jsx-runtime");function De({children:e,onSubmit:r,...o}){let l=(0,U.useForm)(o);return(0,Q.jsx)(U.FormProvider,{...l,children:(0,Q.jsx)("form",{onSubmit:l.handleSubmit(r),children:e})})}var te=De;var de=require("react"),V=require("react-hook-form"),N=require("phosphor-react"),T=require("@mui/material"),se=oe(require("@s_mart/masks"));var X=require("@mui/material"),le=require("@s_mart/utils"),$=require("react/jsx-runtime"),p=({label:e,required:r,regular:o})=>(0,$.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:(0,le.toRem)(2)},children:[(0,$.jsx)(X.Typography,{variant:"caption",fontWeight:o?400:700,style:{display:"flex",alignItems:"center"},children:e}),r&&(0,$.jsx)(X.Typography,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});var ie=require("react-hook-form"),ne=require("@s_mart/core"),ae=require("react/jsx-runtime"),f=({name:e})=>{var o,l,t;let r=(0,ie.useFormContext)();return(l=(o=r==null?void 0:r.formState)==null?void 0:o.errors)!=null&&l[e]?(0,ae.jsx)(ne.Indicator,{severity:"error",children:(t=r.formState.errors[e])==null?void 0:t.message}):null};var b=require("react/jsx-runtime"),Le=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,mask:i,variant:d="outlined",...n})=>{let s=(0,V.useFormContext)();if(!s)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[c,h]=(0,de.useState)(!1),g=a=>i?se[i].format(a):a,x=a=>i?se[i].parse(a):a,M=a=>{if(!a||i!=="porcentagem")return;a==null||a.stopPropagation();let F=(a==null?void 0:a.target).value;if(F){let C=String(F);if(C.length>0){let ee=C.indexOf("%");ee>-1&&(a.currentTarget.selectionEnd=ee)}}};return(0,b.jsx)(V.Controller,{control:s.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:a,onChange:F}})=>(0,b.jsxs)(T.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,b.jsx)(p,{label:t,required:m}),(0,b.jsx)(T.TextField,{size:"small",variant:d,autoComplete:"off",defaultValue:o,value:g(a||""),onChange:C=>F(x(C.target.value)),...n,type:n.type==="password"?c?"text":"password":n.type,InputProps:{onKeyDown:M,endAdornment:n.type==="password"&&(0,b.jsx)(T.InputAdornment,{position:"end",onClick:()=>h(!c),style:{cursor:"pointer"},children:c?(0,b.jsx)(N.Eye,{size:20}):(0,b.jsx)(N.EyeSlash,{size:20})}),...n.InputProps}}),(0,b.jsx)(f,{name:e})]})})},me=Le;var z=require("react-hook-form"),A=require("@mui/material");var P=require("react/jsx-runtime"),Re=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,options:i,...d})=>{let n=(0,z.useFormContext)();if(!n)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,P.jsx)(z.Controller,{control:n.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:s,onChange:c}})=>(0,P.jsxs)(A.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,P.jsx)(p,{label:t,required:m}),(0,P.jsx)(A.Select,{size:"small",variant:"outlined",autoComplete:"off",value:s||"",onChange:c,...d,children:i==null?void 0:i.map((h,g)=>(0,P.jsx)(A.MenuItem,{value:h.value,children:h.label},g))}),(0,P.jsx)(f,{name:e})]})})},pe=Re;var O=require("react-hook-form"),v=require("@mui/material");var S=require("react/jsx-runtime"),$e=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,options:i,textFieldProps:d,...n})=>{let s=(0,O.useFormContext)();if(!s)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,S.jsx)(O.Controller,{control:s.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{onChange:c}})=>(0,S.jsxs)(v.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,S.jsx)(p,{label:t,required:m}),(0,S.jsx)(v.Autocomplete,{size:"small",onChange:(h,g)=>c(g),options:i,noOptionsText:"Nenhuma op\xE7\xE3o encontrada",...n,renderInput:h=>(0,S.jsx)(v.TextField,{...h,...d})}),(0,S.jsx)(f,{name:e})]})})},ue=$e;var W=require("react-hook-form"),he=require("phosphor-react"),w=require("@mui/material");var y=require("@s_mart/utils"),Y=oe(require("@emotion/styled")),Z=require("@emotion/react"),fe=Z.css`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,T2=C=>J.css`
5
+ `,qe=e=>Z.css`
6
6
  .MuiAutocomplete-endAdornment {
7
7
  position: relative;
8
8
  right: 0;
9
9
  }
10
10
 
11
11
  .creatable {
12
- ${t2}
12
+ ${fe}
13
13
 
14
14
  .divider {
15
15
  width: 1px;
16
- height: ${(0,p.toRem)(20)};
17
- background-color: ${C.palette.grey[400]};
16
+ height: ${(0,y.toRem)(20)};
17
+ background-color: ${e.palette.grey[400]};
18
18
  }
19
19
 
20
20
  .button {
21
21
  display: flex;
22
22
  justify-content: center;
23
23
  align-items: center;
24
- color: ${C.palette.grey[600]};
24
+ color: ${e.palette.grey[600]};
25
25
  border-radius: 50%;
26
26
 
27
- margin: 0 ${(0,p.toRem)(6)};
28
- width: ${(0,p.toRem)(28)};
29
- height: ${(0,p.toRem)(28)};
27
+ margin: 0 ${(0,y.toRem)(6)};
28
+ width: ${(0,y.toRem)(28)};
29
+ height: ${(0,y.toRem)(28)};
30
30
 
31
31
  &:hover {
32
32
  cursor: pointer;
33
- background-color: ${C.palette.grey[100]};
33
+ background-color: ${e.palette.grey[100]};
34
34
  transition: background-color 0.2s ease-in-out;
35
35
  }
36
36
  }
37
37
  }
38
- `,s2=Y.default.div`
38
+ `,ce=Y.default.div`
39
39
  display: flex;
40
40
 
41
41
  div.endAdornments {
42
42
  position: absolute;
43
43
  right: 0;
44
44
 
45
- ${t2}
45
+ ${fe}
46
46
  }
47
47
 
48
- ${({hideAddButton:C,theme:i})=>!C&&T2(i)}
49
- `,M2=Y.default.div`
50
- color: ${({theme:C})=>C.palette.text.primary};
48
+ ${({hideAddButton:e,theme:r})=>!e&&qe(r)}
49
+ `,xe=Y.default.div`
50
+ color: ${({theme:e})=>e.palette.text.primary};
51
51
 
52
- padding: ${(0,p.toRem)(6)} ${(0,p.toRem)(16)};
53
- margin: ${(0,p.toRem)(-6)} ${(0,p.toRem)(-16)};
52
+ padding: ${(0,y.toRem)(6)} ${(0,y.toRem)(16)};
53
+ margin: ${(0,y.toRem)(-6)} ${(0,y.toRem)(-16)};
54
54
 
55
55
  &:hover {
56
56
  cursor: pointer;
57
57
  transition: background-color 0.2s ease-in-out;
58
- background-color: ${({theme:C})=>C.palette.grey[100]};
58
+ background-color: ${({theme:e})=>e.palette.grey[100]};
59
59
  }
60
- `;var M=require("react/jsx-runtime"),A2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,required:d,options:n,onCreateOption:l,textFieldProps:V,hideAddButton:L,...a})=>{let c=(0,q.useFormContext)();if(!c)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let r=t=>{l?l(t):console.error("onCreateOption n\xE3o foi definido")};return(0,M.jsx)(q.Controller,{control:c.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:t,onChange:x}})=>{let S=(t==null?void 0:t.label)||(t==null?void 0:t.value)||t;return(0,M.jsxs)(f.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,M.jsx)(s,{label:o,required:d}),(0,M.jsx)(s2,{hideAddButton:L,children:(0,M.jsx)(f.Autocomplete,{size:"small",fullWidth:!0,onChange:(B,_)=>x(_),options:n,noOptionsText:(0,M.jsx)(M2,{onClick:()=>r(t),children:(0,M.jsxs)(f.Typography,{children:["Adicionar ",S&&`"${S}"`]})}),...a,renderInput:B=>{let _=L?B.InputProps:{...B.InputProps,endAdornment:(0,M.jsxs)("div",{className:"endAdornments",children:[B.InputProps.endAdornment,(0,M.jsxs)("div",{className:"creatable",children:[(0,M.jsx)("div",{className:"divider"}),(0,M.jsx)("div",{className:"button",onClick:()=>r(t),children:(0,M.jsx)(Z2.LIcon,{icon:d2,size:"24"})})]})]})};return(0,M.jsx)(f.TextField,{...B,onChange:x,InputProps:_,...V})}})}),(0,M.jsx)(Z,{name:C})]})}})},c2=A2;var $=require("react-hook-form"),P=require("@mui/material");var g=require("react/jsx-runtime"),E2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,labelPlacement:d,required:n,...l})=>{let V=(0,$.useFormContext)();if(!V)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,g.jsx)($.Controller,{control:V.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:L,onChange:a}})=>(0,g.jsxs)(P.Grid,{display:"flex",flexDirection:"column",children:[(0,g.jsx)(P.FormControlLabel,{control:(0,g.jsx)(P.Checkbox,{value:L??"",defaultValue:L,onChange:a,...l}),label:(0,g.jsx)(s,{label:o,required:n,regular:!0}),labelPlacement:d||"end"}),(0,g.jsx)(Z,{name:C})]})})},a2=E2;var O=require("react-hook-form"),k=require("@mui/material");var h=require("react/jsx-runtime"),D2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,labelPlacement:d,...n})=>{let l=(0,O.useFormContext)();if(!l)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,h.jsx)(O.Controller,{control:l.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:V,onChange:L}})=>(0,h.jsxs)(k.Grid,{display:"flex",flexDirection:"column",children:[(0,h.jsx)(k.FormControlLabel,{control:(0,h.jsx)(k.Switch,{value:V??"",defaultValue:V,onChange:L,...n}),label:(0,h.jsx)(s,{label:o}),labelPlacement:d||"end"}),(0,h.jsx)(Z,{name:C})]})})},p2=D2;var v=require("@mui/material");var A=require("react/jsx-runtime"),I2=({label:C,labelPlacement:i,...e})=>(0,A.jsx)(v.Grid,{display:"flex",flexDirection:"column",children:(0,A.jsx)(v.FormControlLabel,{control:(0,A.jsx)(v.Radio,{...e}),label:(0,A.jsx)(s,{label:C}),labelPlacement:i||"end"})}),m2=I2;var N=require("react-hook-form"),W=require("@mui/material");var y=require("react/jsx-runtime"),G2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,label:o,required:d,children:n,orientation:l="row",...V})=>{let L=(0,N.useFormContext)();if(!L)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,y.jsx)(N.Controller,{control:L.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:a,onChange:c}})=>(0,y.jsxs)(W.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,y.jsx)(s,{label:o,required:d}),(0,y.jsx)(W.RadioGroup,{value:a||"",onChange:c,name:C,...V,style:{display:"flex",flexDirection:l},children:n}),(0,y.jsx)(Z,{name:C})]})})},u2=G2;var z=require("react-hook-form"),f2=require("@mui/material"),X=require("react/jsx-runtime"),R2=({name:C,rules:i,defaultValue:e,shouldUnregister:H,...o})=>{let d=(0,z.useFormContext)();if(!d)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,X.jsx)(z.Controller,{control:d.control,name:C,rules:i,defaultValue:e,shouldUnregister:H,render:({field:{value:n,onChange:l}})=>(0,X.jsx)(f2.Slider,{value:n||(o==null?void 0:o.min)||0,onChange:l,valueLabelDisplay:"auto",...o})})},g2=R2;0&&(module.exports={Checkbox,Creatable,Form,RadioButton,RadioGroup,Searchable,Select,Slider,Switch,TextField});
60
+ `;var u=require("react/jsx-runtime"),Me=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,options:i,onCreateOption:d,textFieldProps:n,hideAddButton:s,...c})=>{let h=(0,W.useFormContext)();if(!h)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let g=x=>{d?d(x):console.error("onCreateOption n\xE3o foi definido")};return(0,u.jsx)(W.Controller,{control:h.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:x,onChange:M}})=>{let a=(x==null?void 0:x.label)||(x==null?void 0:x.value)||x;return(0,u.jsxs)(w.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,u.jsx)(p,{label:t,required:m}),(0,u.jsx)(ce,{hideAddButton:s,children:(0,u.jsx)(w.Autocomplete,{size:"small",fullWidth:!0,onChange:(F,C)=>M(C),options:i,noOptionsText:(0,u.jsx)(xe,{onClick:()=>g(x),children:(0,u.jsxs)(w.Typography,{children:["Adicionar ",a&&`"${a}"`]})}),...c,renderInput:F=>{let C=s?F.InputProps:{...F.InputProps,endAdornment:(0,u.jsxs)("div",{className:"endAdornments",children:[F.InputProps.endAdornment,(0,u.jsxs)("div",{className:"creatable",children:[(0,u.jsx)("div",{className:"divider"}),(0,u.jsx)("div",{className:"button",onClick:()=>g(x),children:(0,u.jsx)(he.Plus,{size:18,weight:"bold"})})]})]})};return(0,u.jsx)(w.TextField,{...F,onChange:M,InputProps:C,...n})}})}),(0,u.jsx)(f,{name:e})]})}})},Fe=Me;var _=require("react-hook-form"),D=require("@mui/material");var E=require("react/jsx-runtime"),ke=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,labelPlacement:m,required:i,...d})=>{let n=(0,_.useFormContext)();if(!n)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,E.jsx)(_.Controller,{control:n.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:s,onChange:c}})=>(0,E.jsxs)(D.Grid,{display:"flex",flexDirection:"column",children:[(0,E.jsx)(D.FormControlLabel,{control:(0,E.jsx)(D.Checkbox,{value:s??"",defaultValue:s,onChange:c,...d}),label:(0,E.jsx)(p,{label:t,required:i,regular:!0}),labelPlacement:m||"end"}),(0,E.jsx)(f,{name:e})]})})},be=ke;var B=require("react-hook-form"),L=require("@mui/material");var G=require("react/jsx-runtime"),Ue=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,labelPlacement:m,...i})=>{let d=(0,B.useFormContext)();if(!d)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,G.jsx)(B.Controller,{control:d.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:n,onChange:s}})=>(0,G.jsxs)(L.Grid,{display:"flex",flexDirection:"column",children:[(0,G.jsx)(L.FormControlLabel,{control:(0,G.jsx)(L.Switch,{value:n??"",defaultValue:n,onChange:s,...i}),label:(0,G.jsx)(p,{label:t}),labelPlacement:m||"end"}),(0,G.jsx)(f,{name:e})]})})},ye=Ue;var R=require("@mui/material");var q=require("react/jsx-runtime"),Ve=({label:e,labelPlacement:r,...o})=>(0,q.jsx)(R.Grid,{display:"flex",flexDirection:"column",children:(0,q.jsx)(R.FormControlLabel,{control:(0,q.jsx)(R.Radio,{...o}),label:(0,q.jsx)(p,{label:e}),labelPlacement:r||"end"})}),ge=Ve;var H=require("react-hook-form"),K=require("@mui/material");var I=require("react/jsx-runtime"),Ne=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,children:i,orientation:d="row",...n})=>{let s=(0,H.useFormContext)();if(!s)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,I.jsx)(H.Controller,{control:s.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:c,onChange:h}})=>(0,I.jsxs)(K.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,I.jsx)(p,{label:t,required:m}),(0,I.jsx)(K.RadioGroup,{value:c||"",onChange:h,name:e,...n,style:{display:"flex",flexDirection:d},children:i}),(0,I.jsx)(f,{name:e})]})})},Ce=Ne;var J=require("react-hook-form"),Pe=require("@mui/material"),j=require("react/jsx-runtime"),ze=({name:e,rules:r,defaultValue:o,shouldUnregister:l,...t})=>{let m=(0,J.useFormContext)();if(!m)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,j.jsx)(J.Controller,{control:m.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:i,onChange:d}})=>(0,j.jsx)(Pe.Slider,{value:i||(t==null?void 0:t.min)||0,onChange:d,valueLabelDisplay:"auto",...t})})},Se=ze;0&&(module.exports={Checkbox,Creatable,Form,RadioButton,RadioGroup,Searchable,Select,Slider,Switch,TextField});
package/dist/index.mjs CHANGED
@@ -1,60 +1,60 @@
1
- import{FormProvider as q,useForm as $}from"react-hook-form";import{jsx as v}from"react/jsx-runtime";function O({children:C,onSubmit:i,...o}){let r=$(o);return v(q,{...r,children:v("form",{onSubmit:r.handleSubmit(i),children:C})})}var N=O;import{Controller as Y,useFormContext as J}from"react-hook-form";import{Grid as X,TextField as j}from"@mui/material";import{Typography as S}from"@mui/material";import{toRem as W}from"@s_mart/utils";import{jsx as B,jsxs as z}from"react/jsx-runtime";var s=({label:C,required:i,regular:o})=>z("span",{style:{display:"flex",alignItems:"center",gap:W(2)},children:[B(S,{variant:"caption",fontWeight:o?400:700,style:{display:"flex",alignItems:"center"},children:C}),i&&B(S,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});import{useFormContext as _}from"react-hook-form";import{Indicator as K}from"@s_mart/core";import{jsx as Q}from"react/jsx-runtime";var M=({name:C})=>{var o,r,e;let i=_();return(r=(o=i==null?void 0:i.formState)==null?void 0:o.errors)!=null&&r[C]?Q(K,{severity:"error",children:(e=i.formState.errors[C])==null?void 0:e.message}):null};import*as T from"@s_mart/masks";import{jsx as y,jsxs as e2}from"react/jsx-runtime";var C2=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,required:d,mask:n,...l})=>{let V=J();if(!V)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=H=>n?T[n].format(H):H,c=H=>n?T[n].parse(H):H,Z=H=>{if(!H||n!=="porcentagem")return;H==null||H.stopPropagation();let t=(H==null?void 0:H.target).value;if(t){let m=String(t);if(m.length>0){let u=m.indexOf("%");u>-1&&(H.currentTarget.selectionEnd=u)}}};return y(Y,{control:V.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:H,onChange:t}})=>e2(X,{display:"flex",flexDirection:"column",children:[e&&y(s,{label:e,required:d}),y(j,{size:"small",variant:"outlined",autoComplete:"off",defaultValue:o,value:L(H||""),onChange:m=>t(c(m.target.value)),InputProps:{onKeyDown:Z},...l}),y(M,{name:C})]})})},i2=C2;import{Controller as o2,useFormContext as H2}from"react-hook-form";import{Grid as r2,Select as n2,MenuItem as l2}from"@mui/material";import{jsx as g,jsxs as d2}from"react/jsx-runtime";var V2=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,required:d,options:n,...l})=>{let V=H2();if(!V)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return g(o2,{control:V.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:L,onChange:c}})=>d2(r2,{display:"flex",flexDirection:"column",children:[e&&g(s,{label:e,required:d}),g(n2,{size:"small",variant:"outlined",autoComplete:"off",value:L||"",onChange:c,...l,children:n==null?void 0:n.map((Z,H)=>g(l2,{value:Z.value,children:Z.label},H))}),g(M,{name:C})]})})},L2=V2;import{Controller as t2,useFormContext as s2}from"react-hook-form";import{Grid as M2,Autocomplete as Z2,TextField as c2}from"@mui/material";import{jsx as h,jsxs as m2}from"react/jsx-runtime";var a2=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,required:d,options:n,textFieldProps:l,...V})=>{let L=s2();if(!L)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return h(t2,{control:L.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{onChange:c}})=>m2(M2,{display:"flex",flexDirection:"column",children:[e&&h(s,{label:e,required:d}),h(Z2,{size:"small",onChange:(Z,H)=>c(H),options:n,noOptionsText:"Nenhuma op\xE7\xE3o encontrada",...V,renderInput:Z=>h(c2,{...Z,...l})}),h(M,{name:C})]})})},p2=a2;import{Controller as f2,useFormContext as g2}from"react-hook-form";import{Grid as h2,Autocomplete as x2,TextField as b2,Typography as y2}from"@mui/material";import{LIcon as F2}from"@s_mart/core";var A={description:"M35.8286 21.8493H26.1506V12.1714C26.1506 11.6338 25.613 11.0961 25.0753 11.0961H22.9247C22.3198 11.0961 21.8493 11.6338 21.8493 12.1714V21.8493H12.1714C11.5666 21.8493 11.0961 22.387 11.0961 22.9247V25.0753C11.0961 25.6802 11.5666 26.1506 12.1714 26.1506H21.8493V35.8286C21.8493 36.4334 22.3198 36.9039 22.9247 36.9039H25.0753C25.613 36.9039 26.1506 36.4334 26.1506 35.8286V26.1506H35.8286C36.3662 26.1506 36.9039 25.6802 36.9039 25.0753V22.9247C36.9039 22.387 36.3662 21.8493 35.8286 21.8493Z",viewBox:"0 0 48 48",id:"line-plus-solid"};import{toRem as p}from"@s_mart/utils";import E from"@emotion/styled";import{css as D}from"@emotion/react";var I=D`
1
+ import{FormProvider as z,useForm as O}from"react-hook-form";import{jsx as D}from"react/jsx-runtime";function W({children:e,onSubmit:r,...t}){let l=O(t);return D(z,{...l,children:D("form",{onSubmit:l.handleSubmit(r),children:e})})}var _=W;import{useState as X}from"react";import{Controller as Y,useFormContext as Z}from"react-hook-form";import{Eye as j,EyeSlash as ee}from"phosphor-react";import{Grid as re,InputAdornment as oe,TextField as te}from"@mui/material";import*as $ from"@s_mart/masks";import{Typography as L}from"@mui/material";import{toRem as B}from"@s_mart/utils";import{jsx as R,jsxs as H}from"react/jsx-runtime";var p=({label:e,required:r,regular:t})=>H("span",{style:{display:"flex",alignItems:"center",gap:B(2)},children:[R(L,{variant:"caption",fontWeight:t?400:700,style:{display:"flex",alignItems:"center"},children:e}),r&&R(L,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});import{useFormContext as K}from"react-hook-form";import{Indicator as J}from"@s_mart/core";import{jsx as Q}from"react/jsx-runtime";var u=({name:e})=>{var t,l,o;let r=K();return(l=(t=r==null?void 0:r.formState)==null?void 0:t.errors)!=null&&l[e]?Q(J,{severity:"error",children:(o=r.formState.errors[e])==null?void 0:o.message}):null};import{jsx as C,jsxs as ne}from"react/jsx-runtime";var le=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,mask:i,variant:d="outlined",...n})=>{let s=Z();if(!s)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[f,x]=X(!1),b=a=>i?$[i].format(a):a,c=a=>i?$[i].parse(a):a,G=a=>{if(!a||i!=="porcentagem")return;a==null||a.stopPropagation();let h=(a==null?void 0:a.target).value;if(h){let y=String(h);if(y.length>0){let v=y.indexOf("%");v>-1&&(a.currentTarget.selectionEnd=v)}}};return C(Y,{control:s.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:a,onChange:h}})=>ne(re,{display:"flex",flexDirection:"column",children:[o&&C(p,{label:o,required:m}),C(te,{size:"small",variant:d,autoComplete:"off",defaultValue:t,value:b(a||""),onChange:y=>h(c(y.target.value)),...n,type:n.type==="password"?f?"text":"password":n.type,InputProps:{onKeyDown:G,endAdornment:n.type==="password"&&C(oe,{position:"end",onClick:()=>x(!f),style:{cursor:"pointer"},children:f?C(j,{size:20}):C(ee,{size:20})}),...n.InputProps}}),C(u,{name:e})]})})},ie=le;import{Controller as ae,useFormContext as se}from"react-hook-form";import{Grid as de,Select as me,MenuItem as pe}from"@mui/material";import{jsx as P,jsxs as ce}from"react/jsx-runtime";var ue=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,options:i,...d})=>{let n=se();if(!n)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return P(ae,{control:n.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:s,onChange:f}})=>ce(de,{display:"flex",flexDirection:"column",children:[o&&P(p,{label:o,required:m}),P(me,{size:"small",variant:"outlined",autoComplete:"off",value:s||"",onChange:f,...d,children:i==null?void 0:i.map((x,b)=>P(pe,{value:x.value,children:x.label},b))}),P(u,{name:e})]})})},fe=ue;import{Controller as xe,useFormContext as he}from"react-hook-form";import{Grid as Fe,Autocomplete as be,TextField as ye}from"@mui/material";import{jsx as S,jsxs as Pe}from"react/jsx-runtime";var ge=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,options:i,textFieldProps:d,...n})=>{let s=he();if(!s)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return S(xe,{control:s.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{onChange:f}})=>Pe(Fe,{display:"flex",flexDirection:"column",children:[o&&S(p,{label:o,required:m}),S(be,{size:"small",onChange:(x,b)=>f(b),options:i,noOptionsText:"Nenhuma op\xE7\xE3o encontrada",...n,renderInput:x=>S(ye,{...x,...d})}),S(u,{name:e})]})})},Ce=ge;import{Controller as we,useFormContext as Ee}from"react-hook-form";import{Plus as Ge}from"phosphor-react";import{Grid as Ie,Autocomplete as Te,TextField as Ae,Typography as ve}from"@mui/material";import{toRem as g}from"@s_mart/utils";import q from"@emotion/styled";import{css as M}from"@emotion/react";var k=M`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,u2=C=>D`
5
+ `,Se=e=>M`
6
6
  .MuiAutocomplete-endAdornment {
7
7
  position: relative;
8
8
  right: 0;
9
9
  }
10
10
 
11
11
  .creatable {
12
- ${I}
12
+ ${k}
13
13
 
14
14
  .divider {
15
15
  width: 1px;
16
- height: ${p(20)};
17
- background-color: ${C.palette.grey[400]};
16
+ height: ${g(20)};
17
+ background-color: ${e.palette.grey[400]};
18
18
  }
19
19
 
20
20
  .button {
21
21
  display: flex;
22
22
  justify-content: center;
23
23
  align-items: center;
24
- color: ${C.palette.grey[600]};
24
+ color: ${e.palette.grey[600]};
25
25
  border-radius: 50%;
26
26
 
27
- margin: 0 ${p(6)};
28
- width: ${p(28)};
29
- height: ${p(28)};
27
+ margin: 0 ${g(6)};
28
+ width: ${g(28)};
29
+ height: ${g(28)};
30
30
 
31
31
  &:hover {
32
32
  cursor: pointer;
33
- background-color: ${C.palette.grey[100]};
33
+ background-color: ${e.palette.grey[100]};
34
34
  transition: background-color 0.2s ease-in-out;
35
35
  }
36
36
  }
37
37
  }
38
- `,G=E.div`
38
+ `,U=q.div`
39
39
  display: flex;
40
40
 
41
41
  div.endAdornments {
42
42
  position: absolute;
43
43
  right: 0;
44
44
 
45
- ${I}
45
+ ${k}
46
46
  }
47
47
 
48
- ${({hideAddButton:C,theme:i})=>!C&&u2(i)}
49
- `,R=E.div`
50
- color: ${({theme:C})=>C.palette.text.primary};
48
+ ${({hideAddButton:e,theme:r})=>!e&&Se(r)}
49
+ `,V=q.div`
50
+ color: ${({theme:e})=>e.palette.text.primary};
51
51
 
52
- padding: ${p(6)} ${p(16)};
53
- margin: ${p(-6)} ${p(-16)};
52
+ padding: ${g(6)} ${g(16)};
53
+ margin: ${g(-6)} ${g(-16)};
54
54
 
55
55
  &:hover {
56
56
  cursor: pointer;
57
57
  transition: background-color 0.2s ease-in-out;
58
- background-color: ${({theme:C})=>C.palette.grey[100]};
58
+ background-color: ${({theme:e})=>e.palette.grey[100]};
59
59
  }
60
- `;import{jsx as a,jsxs as F}from"react/jsx-runtime";var w2=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,required:d,options:n,onCreateOption:l,textFieldProps:V,hideAddButton:L,...c})=>{let Z=g2();if(!Z)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let H=t=>{l?l(t):console.error("onCreateOption n\xE3o foi definido")};return a(f2,{control:Z.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:t,onChange:m}})=>{let u=(t==null?void 0:t.label)||(t==null?void 0:t.value)||t;return F(h2,{display:"flex",flexDirection:"column",children:[e&&a(s,{label:e,required:d}),a(G,{hideAddButton:L,children:a(x2,{size:"small",fullWidth:!0,onChange:(f,k)=>m(k),options:n,noOptionsText:a(R,{onClick:()=>H(t),children:F(y2,{children:["Adicionar ",u&&`"${u}"`]})}),...c,renderInput:f=>{let k=L?f.InputProps:{...f.InputProps,endAdornment:F("div",{className:"endAdornments",children:[f.InputProps.endAdornment,F("div",{className:"creatable",children:[a("div",{className:"divider"}),a("div",{className:"button",onClick:()=>H(t),children:a(F2,{icon:A,size:"24"})})]})]})};return a(b2,{...f,onChange:m,InputProps:k,...V})}})}),a(M,{name:C})]})}})},P2=w2;import{Controller as k2,useFormContext as v2}from"react-hook-form";import{Grid as S2,Checkbox as B2,FormControlLabel as T2}from"@mui/material";import{jsx as x,jsxs as D2}from"react/jsx-runtime";var A2=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,labelPlacement:d,required:n,...l})=>{let V=v2();if(!V)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return x(k2,{control:V.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:L,onChange:c}})=>D2(S2,{display:"flex",flexDirection:"column",children:[x(T2,{control:x(B2,{value:L??"",defaultValue:L,onChange:c,...l}),label:x(s,{label:e,required:n,regular:!0}),labelPlacement:d||"end"}),x(M,{name:C})]})})},E2=A2;import{Controller as I2,useFormContext as G2}from"react-hook-form";import{Grid as R2,Switch as U2,FormControlLabel as q2}from"@mui/material";import{jsx as b,jsxs as N2}from"react/jsx-runtime";var $2=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,labelPlacement:d,...n})=>{let l=G2();if(!l)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return b(I2,{control:l.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:V,onChange:L}})=>N2(R2,{display:"flex",flexDirection:"column",children:[b(q2,{control:b(U2,{value:V??"",defaultValue:V,onChange:L,...n}),label:b(s,{label:e}),labelPlacement:d||"end"}),b(M,{name:C})]})})},O2=$2;import{Grid as W2,Radio as z2,FormControlLabel as _2}from"@mui/material";import{jsx as w}from"react/jsx-runtime";var K2=({label:C,labelPlacement:i,...o})=>w(W2,{display:"flex",flexDirection:"column",children:w(_2,{control:w(z2,{...o}),label:w(s,{label:C}),labelPlacement:i||"end"})}),Q2=K2;import{Controller as Y2,useFormContext as J2}from"react-hook-form";import{Grid as X2,RadioGroup as j2}from"@mui/material";import{jsx as P,jsxs as e3}from"react/jsx-runtime";var C3=({name:C,rules:i,defaultValue:o,shouldUnregister:r,label:e,required:d,children:n,orientation:l="row",...V})=>{let L=J2();if(!L)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return P(Y2,{control:L.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:c,onChange:Z}})=>e3(X2,{display:"flex",flexDirection:"column",children:[e&&P(s,{label:e,required:d}),P(j2,{value:c||"",onChange:Z,name:C,...V,style:{display:"flex",flexDirection:l},children:n}),P(M,{name:C})]})})},i3=C3;import{Controller as o3,useFormContext as H3}from"react-hook-form";import{Slider as r3}from"@mui/material";import{jsx as U}from"react/jsx-runtime";var n3=({name:C,rules:i,defaultValue:o,shouldUnregister:r,...e})=>{let d=H3();if(!d)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return U(o3,{control:d.control,name:C,rules:i,defaultValue:o,shouldUnregister:r,render:({field:{value:n,onChange:l}})=>U(r3,{value:n||(e==null?void 0:e.min)||0,onChange:l,valueLabelDisplay:"auto",...e})})},l3=n3;export{E2 as Checkbox,P2 as Creatable,N as Form,Q2 as RadioButton,i3 as RadioGroup,p2 as Searchable,L2 as Select,l3 as Slider,O2 as Switch,i2 as TextField};
60
+ `;import{jsx as F,jsxs as I}from"react/jsx-runtime";var De=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,options:i,onCreateOption:d,textFieldProps:n,hideAddButton:s,...f})=>{let x=Ee();if(!x)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=c=>{d?d(c):console.error("onCreateOption n\xE3o foi definido")};return F(we,{control:x.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:c,onChange:G}})=>{let a=(c==null?void 0:c.label)||(c==null?void 0:c.value)||c;return I(Ie,{display:"flex",flexDirection:"column",children:[o&&F(p,{label:o,required:m}),F(U,{hideAddButton:s,children:F(Te,{size:"small",fullWidth:!0,onChange:(h,y)=>G(y),options:i,noOptionsText:F(V,{onClick:()=>b(c),children:I(ve,{children:["Adicionar ",a&&`"${a}"`]})}),...f,renderInput:h=>{let y=s?h.InputProps:{...h.InputProps,endAdornment:I("div",{className:"endAdornments",children:[h.InputProps.endAdornment,I("div",{className:"creatable",children:[F("div",{className:"divider"}),F("div",{className:"button",onClick:()=>b(c),children:F(Ge,{size:18,weight:"bold"})})]})]})};return F(Ae,{...h,onChange:G,InputProps:y,...n})}})}),F(u,{name:e})]})}})},Le=De;import{Controller as Re,useFormContext as $e}from"react-hook-form";import{Grid as qe,Checkbox as Me,FormControlLabel as ke}from"@mui/material";import{jsx as w,jsxs as Ne}from"react/jsx-runtime";var Ue=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,labelPlacement:m,required:i,...d})=>{let n=$e();if(!n)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return w(Re,{control:n.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:s,onChange:f}})=>Ne(qe,{display:"flex",flexDirection:"column",children:[w(ke,{control:w(Me,{value:s??"",defaultValue:s,onChange:f,...d}),label:w(p,{label:o,required:i,regular:!0}),labelPlacement:m||"end"}),w(u,{name:e})]})})},Ve=Ue;import{Controller as ze,useFormContext as Oe}from"react-hook-form";import{Grid as We,Switch as _e,FormControlLabel as Be}from"@mui/material";import{jsx as E,jsxs as Je}from"react/jsx-runtime";var He=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,labelPlacement:m,...i})=>{let d=Oe();if(!d)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return E(ze,{control:d.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:n,onChange:s}})=>Je(We,{display:"flex",flexDirection:"column",children:[E(Be,{control:E(_e,{value:n??"",defaultValue:n,onChange:s,...i}),label:E(p,{label:o}),labelPlacement:m||"end"}),E(u,{name:e})]})})},Ke=He;import{Grid as Qe,Radio as Xe,FormControlLabel as Ye}from"@mui/material";import{jsx as T}from"react/jsx-runtime";var Ze=({label:e,labelPlacement:r,...t})=>T(Qe,{display:"flex",flexDirection:"column",children:T(Ye,{control:T(Xe,{...t}),label:T(p,{label:e}),labelPlacement:r||"end"})}),je=Ze;import{Controller as er,useFormContext as rr}from"react-hook-form";import{Grid as or,RadioGroup as tr}from"@mui/material";import{jsx as A,jsxs as nr}from"react/jsx-runtime";var lr=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,children:i,orientation:d="row",...n})=>{let s=rr();if(!s)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return A(er,{control:s.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:f,onChange:x}})=>nr(or,{display:"flex",flexDirection:"column",children:[o&&A(p,{label:o,required:m}),A(tr,{value:f||"",onChange:x,name:e,...n,style:{display:"flex",flexDirection:d},children:i}),A(u,{name:e})]})})},ir=lr;import{Controller as ar,useFormContext as sr}from"react-hook-form";import{Slider as dr}from"@mui/material";import{jsx as N}from"react/jsx-runtime";var mr=({name:e,rules:r,defaultValue:t,shouldUnregister:l,...o})=>{let m=sr();if(!m)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return N(ar,{control:m.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:i,onChange:d}})=>N(dr,{value:i||(o==null?void 0:o.min)||0,onChange:d,valueLabelDisplay:"auto",...o})})},pr=mr;export{Ve as Checkbox,Le as Creatable,_ as Form,je as RadioButton,ir as RadioGroup,Ce as Searchable,fe as Select,pr as Slider,Ke as Switch,ie as TextField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "2.1.2",
3
+ "version": "2.2.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -34,7 +34,8 @@
34
34
  "@types/react-dom": ">=18.0.6",
35
35
  "@emotion/react": ">=11.10.4",
36
36
  "@emotion/styled": ">=11.10.4",
37
- "@s_mart/core": ">=2.1.0"
37
+ "@s_mart/core": ">=2.1.0",
38
+ "phosphor-react": ">=1.4.1"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@s_mart/eslint": "*",