@s_mart/form 2.1.2 → 2.2.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/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 Se=Object.create;var k=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var Te=(e,r)=>{for(var o in r)k(e,o,{get:r[o],enumerable:!0})},ee=(e,r,o,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of Ee(r))!Ie.call(e,t)&&t!==o&&k(e,t,{get:()=>r[t],enumerable:!(l=we(r,t))||l.enumerable});return e};var re=(e,r,o)=>(o=e!=null?Se(Ge(e)):{},ee(r||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),Ae=e=>ee(k({},"__esModule",{value:!0}),e);var ze={};Te(ze,{Checkbox:()=>Fe,Creatable:()=>he,Form:()=>oe,RadioButton:()=>ye,RadioGroup:()=>ge,Searchable:()=>pe,Select:()=>me,Slider:()=>Pe,Switch:()=>be,TextField:()=>de});module.exports=Ae(ze);var U=require("react-hook-form"),Q=require("react/jsx-runtime");function ve({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 oe=ve;var se=require("react"),V=require("react-hook-form"),N=require("phosphor-react"),A=require("@mui/material"),ae=re(require("@s_mart/masks"));var X=require("@mui/material"),te=require("@s_mart/utils"),q=require("react/jsx-runtime"),p=({label:e,required:r,regular:o})=>(0,q.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:(0,te.toRem)(2)},children:[(0,q.jsx)(X.Typography,{variant:"caption",fontWeight:o?400:700,style:{display:"flex",alignItems:"center"},children:e}),r&&(0,q.jsx)(X.Typography,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});var le=require("react-hook-form"),ie=require("@s_mart/core"),ne=require("react/jsx-runtime"),f=({name:e})=>{var o,l,t;let r=(0,le.useFormContext)();return(l=(o=r==null?void 0:r.formState)==null?void 0:o.errors)!=null&&l[e]?(0,ne.jsx)(ie.Indicator,{severity:"error",children:(t=r.formState.errors[e])==null?void 0:t.message}):null};var b=require("react/jsx-runtime"),De=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,mask:i,...n})=>{let d=(0,V.useFormContext)();if(!d)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[a,h]=(0,se.useState)(!1),x=s=>i?ae[i].format(s):s,g=s=>i?ae[i].parse(s):s,c=s=>{if(!s||i!=="porcentagem")return;s==null||s.stopPropagation();let G=(s==null?void 0:s.target).value;if(G){let F=String(G);if(F.length>0){let T=F.indexOf("%");T>-1&&(s.currentTarget.selectionEnd=T)}}};return(0,b.jsx)(V.Controller,{control:d.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:s,onChange:G}})=>(0,b.jsxs)(A.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,b.jsx)(p,{label:t,required:m}),(0,b.jsx)(A.TextField,{size:"small",variant:"outlined",autoComplete:"off",defaultValue:o,value:x(s||""),onChange:F=>G(g(F.target.value)),...n,type:n.type==="password"?a?"text":"password":n.type,InputProps:{onKeyDown:c,endAdornment:n.type==="password"&&(0,b.jsx)(A.InputAdornment,{position:"end",onClick:()=>h(!a),style:{cursor:"pointer"},children:a?(0,b.jsx)(N.Eye,{size:20}):(0,b.jsx)(N.EyeSlash,{size:20})}),...n.InputProps}}),(0,b.jsx)(f,{name:e})]})})},de=De;var z=require("react-hook-form"),v=require("@mui/material");var C=require("react/jsx-runtime"),Le=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,options:i,...n})=>{let d=(0,z.useFormContext)();if(!d)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,C.jsx)(z.Controller,{control:d.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:a,onChange:h}})=>(0,C.jsxs)(v.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,C.jsx)(p,{label:t,required:m}),(0,C.jsx)(v.Select,{size:"small",variant:"outlined",autoComplete:"off",value:a||"",onChange:h,...n,children:i==null?void 0:i.map((x,g)=>(0,C.jsx)(v.MenuItem,{value:x.value,children:x.label},g))}),(0,C.jsx)(f,{name:e})]})})},me=Le;var O=require("react-hook-form"),D=require("@mui/material");var P=require("react/jsx-runtime"),Re=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,options:i,textFieldProps:n,...d})=>{let a=(0,O.useFormContext)();if(!a)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,P.jsx)(O.Controller,{control:a.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{onChange:h}})=>(0,P.jsxs)(D.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,P.jsx)(p,{label:t,required:m}),(0,P.jsx)(D.Autocomplete,{size:"small",onChange:(x,g)=>h(g),options:i,noOptionsText:"Nenhuma op\xE7\xE3o encontrada",...d,renderInput:x=>(0,P.jsx)(D.TextField,{...x,...n})}),(0,P.jsx)(f,{name:e})]})})},pe=Re;var W=require("react-hook-form"),xe=require("phosphor-react"),S=require("@mui/material");var y=require("@s_mart/utils"),Y=re(require("@emotion/styled")),Z=require("@emotion/react"),ue=Z.css`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,T2=C=>J.css`
5
+ `,$e=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
+ ${ue}
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
+ `,fe=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
+ ${ue}
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&&$e(r)}
49
+ `,ce=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"),qe=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,options:i,onCreateOption:n,textFieldProps:d,hideAddButton:a,...h})=>{let x=(0,W.useFormContext)();if(!x)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let g=c=>{n?n(c):console.error("onCreateOption n\xE3o foi definido")};return(0,u.jsx)(W.Controller,{control:x.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:c,onChange:s}})=>{let G=(c==null?void 0:c.label)||(c==null?void 0:c.value)||c;return(0,u.jsxs)(S.Grid,{display:"flex",flexDirection:"column",children:[t&&(0,u.jsx)(p,{label:t,required:m}),(0,u.jsx)(fe,{hideAddButton:a,children:(0,u.jsx)(S.Autocomplete,{size:"small",fullWidth:!0,onChange:(F,T)=>s(T),options:i,noOptionsText:(0,u.jsx)(ce,{onClick:()=>g(c),children:(0,u.jsxs)(S.Typography,{children:["Adicionar ",G&&`"${G}"`]})}),...h,renderInput:F=>{let T=a?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(c),children:(0,u.jsx)(xe.Plus,{size:18,weight:"bold"})})]})]})};return(0,u.jsx)(S.TextField,{...F,onChange:s,InputProps:T,...d})}})}),(0,u.jsx)(f,{name:e})]})}})},he=qe;var _=require("react-hook-form"),L=require("@mui/material");var w=require("react/jsx-runtime"),Me=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,labelPlacement:m,required:i,...n})=>{let d=(0,_.useFormContext)();if(!d)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,w.jsx)(_.Controller,{control:d.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:a,onChange:h}})=>(0,w.jsxs)(L.Grid,{display:"flex",flexDirection:"column",children:[(0,w.jsx)(L.FormControlLabel,{control:(0,w.jsx)(L.Checkbox,{value:a??"",defaultValue:a,onChange:h,...n}),label:(0,w.jsx)(p,{label:t,required:i,regular:!0}),labelPlacement:m||"end"}),(0,w.jsx)(f,{name:e})]})})},Fe=Me;var B=require("react-hook-form"),R=require("@mui/material");var E=require("react/jsx-runtime"),ke=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,labelPlacement:m,...i})=>{let n=(0,B.useFormContext)();if(!n)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,E.jsx)(B.Controller,{control:n.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:d,onChange:a}})=>(0,E.jsxs)(R.Grid,{display:"flex",flexDirection:"column",children:[(0,E.jsx)(R.FormControlLabel,{control:(0,E.jsx)(R.Switch,{value:d??"",defaultValue:d,onChange:a,...i}),label:(0,E.jsx)(p,{label:t}),labelPlacement:m||"end"}),(0,E.jsx)(f,{name:e})]})})},be=ke;var $=require("@mui/material");var M=require("react/jsx-runtime"),Ue=({label:e,labelPlacement:r,...o})=>(0,M.jsx)($.Grid,{display:"flex",flexDirection:"column",children:(0,M.jsx)($.FormControlLabel,{control:(0,M.jsx)($.Radio,{...o}),label:(0,M.jsx)(p,{label:e}),labelPlacement:r||"end"})}),ye=Ue;var H=require("react-hook-form"),K=require("@mui/material");var I=require("react/jsx-runtime"),Ve=({name:e,rules:r,defaultValue:o,shouldUnregister:l,label:t,required:m,children:i,orientation:n="row",...d})=>{let a=(0,H.useFormContext)();if(!a)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,I.jsx)(H.Controller,{control:a.control,name:e,rules:r,defaultValue:o,shouldUnregister:l,render:({field:{value:h,onChange:x}})=>(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:h||"",onChange:x,name:e,...d,style:{display:"flex",flexDirection:n},children:i}),(0,I.jsx)(f,{name:e})]})})},ge=Ve;var J=require("react-hook-form"),Ce=require("@mui/material"),j=require("react/jsx-runtime"),Ne=({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:n}})=>(0,j.jsx)(Ce.Slider,{value:i||(t==null?void 0:t.min)||0,onChange:n,valueLabelDisplay:"auto",...t})})},Pe=Ne;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 N,useForm as z}from"react-hook-form";import{jsx as v}from"react/jsx-runtime";function O({children:e,onSubmit:r,...t}){let l=z(t);return v(N,{...l,children:v("form",{onSubmit:l.handleSubmit(r),children:e})})}var W=O;import{useState as Q}from"react";import{Controller as X,useFormContext as Y}from"react-hook-form";import{Eye as Z,EyeSlash as j}from"phosphor-react";import{Grid as ee,InputAdornment as re,TextField as oe}from"@mui/material";import*as R from"@s_mart/masks";import{Typography as D}from"@mui/material";import{toRem as _}from"@s_mart/utils";import{jsx as L,jsxs as B}from"react/jsx-runtime";var p=({label:e,required:r,regular:t})=>B("span",{style:{display:"flex",alignItems:"center",gap:_(2)},children:[L(D,{variant:"caption",fontWeight:t?400:700,style:{display:"flex",alignItems:"center"},children:e}),r&&L(D,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});import{useFormContext as H}from"react-hook-form";import{Indicator as K}from"@s_mart/core";import{jsx as J}from"react/jsx-runtime";var u=({name:e})=>{var t,l,o;let r=H();return(l=(t=r==null?void 0:r.formState)==null?void 0:t.errors)!=null&&l[e]?J(K,{severity:"error",children:(o=r.formState.errors[e])==null?void 0:o.message}):null};import{jsx as C,jsxs as ie}from"react/jsx-runtime";var te=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,mask:i,...n})=>{let d=Y();if(!d)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[a,x]=Q(!1),c=s=>i?R[i].format(s):s,b=s=>i?R[i].parse(s):s,f=s=>{if(!s||i!=="porcentagem")return;s==null||s.stopPropagation();let g=(s==null?void 0:s.target).value;if(g){let h=String(g);if(h.length>0){let P=h.indexOf("%");P>-1&&(s.currentTarget.selectionEnd=P)}}};return C(X,{control:d.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:s,onChange:g}})=>ie(ee,{display:"flex",flexDirection:"column",children:[o&&C(p,{label:o,required:m}),C(oe,{size:"small",variant:"outlined",autoComplete:"off",defaultValue:t,value:c(s||""),onChange:h=>g(b(h.target.value)),...n,type:n.type==="password"?a?"text":"password":n.type,InputProps:{onKeyDown:f,endAdornment:n.type==="password"&&C(re,{position:"end",onClick:()=>x(!a),style:{cursor:"pointer"},children:a?C(Z,{size:20}):C(j,{size:20})}),...n.InputProps}}),C(u,{name:e})]})})},le=te;import{Controller as ne,useFormContext as ae}from"react-hook-form";import{Grid as se,Select as de,MenuItem as me}from"@mui/material";import{jsx as S,jsxs as fe}from"react/jsx-runtime";var pe=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,options:i,...n})=>{let d=ae();if(!d)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return S(ne,{control:d.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:a,onChange:x}})=>fe(se,{display:"flex",flexDirection:"column",children:[o&&S(p,{label:o,required:m}),S(de,{size:"small",variant:"outlined",autoComplete:"off",value:a||"",onChange:x,...n,children:i==null?void 0:i.map((c,b)=>S(me,{value:c.value,children:c.label},b))}),S(u,{name:e})]})})},ue=pe;import{Controller as ce,useFormContext as xe}from"react-hook-form";import{Grid as he,Autocomplete as Fe,TextField as be}from"@mui/material";import{jsx as w,jsxs as Ce}from"react/jsx-runtime";var ye=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,options:i,textFieldProps:n,...d})=>{let a=xe();if(!a)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return w(ce,{control:a.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{onChange:x}})=>Ce(he,{display:"flex",flexDirection:"column",children:[o&&w(p,{label:o,required:m}),w(Fe,{size:"small",onChange:(c,b)=>x(b),options:i,noOptionsText:"Nenhuma op\xE7\xE3o encontrada",...d,renderInput:c=>w(be,{...c,...n})}),w(u,{name:e})]})})},ge=ye;import{Controller as Se,useFormContext as we}from"react-hook-form";import{Plus as Ee}from"phosphor-react";import{Grid as Ge,Autocomplete as Ie,TextField as Te,Typography as Ae}from"@mui/material";import{toRem as y}from"@s_mart/utils";import $ from"@emotion/styled";import{css as q}from"@emotion/react";var M=q`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,u2=C=>D`
5
+ `,Pe=e=>q`
6
6
  .MuiAutocomplete-endAdornment {
7
7
  position: relative;
8
8
  right: 0;
9
9
  }
10
10
 
11
11
  .creatable {
12
- ${I}
12
+ ${M}
13
13
 
14
14
  .divider {
15
15
  width: 1px;
16
- height: ${p(20)};
17
- background-color: ${C.palette.grey[400]};
16
+ height: ${y(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 ${y(6)};
28
+ width: ${y(28)};
29
+ height: ${y(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
+ `,k=$.div`
39
39
  display: flex;
40
40
 
41
41
  div.endAdornments {
42
42
  position: absolute;
43
43
  right: 0;
44
44
 
45
- ${I}
45
+ ${M}
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&&Pe(r)}
49
+ `,U=$.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: ${y(6)} ${y(16)};
53
+ margin: ${y(-6)} ${y(-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 ve=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,options:i,onCreateOption:n,textFieldProps:d,hideAddButton:a,...x})=>{let c=we();if(!c)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=f=>{n?n(f):console.error("onCreateOption n\xE3o foi definido")};return F(Se,{control:c.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:f,onChange:s}})=>{let g=(f==null?void 0:f.label)||(f==null?void 0:f.value)||f;return I(Ge,{display:"flex",flexDirection:"column",children:[o&&F(p,{label:o,required:m}),F(k,{hideAddButton:a,children:F(Ie,{size:"small",fullWidth:!0,onChange:(h,P)=>s(P),options:i,noOptionsText:F(U,{onClick:()=>b(f),children:I(Ae,{children:["Adicionar ",g&&`"${g}"`]})}),...x,renderInput:h=>{let P=a?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(f),children:F(Ee,{size:18,weight:"bold"})})]})]})};return F(Te,{...h,onChange:s,InputProps:P,...d})}})}),F(u,{name:e})]})}})},De=ve;import{Controller as Le,useFormContext as Re}from"react-hook-form";import{Grid as $e,Checkbox as qe,FormControlLabel as Me}from"@mui/material";import{jsx as E,jsxs as Ve}from"react/jsx-runtime";var ke=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,labelPlacement:m,required:i,...n})=>{let d=Re();if(!d)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return E(Le,{control:d.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:a,onChange:x}})=>Ve($e,{display:"flex",flexDirection:"column",children:[E(Me,{control:E(qe,{value:a??"",defaultValue:a,onChange:x,...n}),label:E(p,{label:o,required:i,regular:!0}),labelPlacement:m||"end"}),E(u,{name:e})]})})},Ue=ke;import{Controller as Ne,useFormContext as ze}from"react-hook-form";import{Grid as Oe,Switch as We,FormControlLabel as _e}from"@mui/material";import{jsx as G,jsxs as Ke}from"react/jsx-runtime";var Be=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,labelPlacement:m,...i})=>{let n=ze();if(!n)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return G(Ne,{control:n.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:d,onChange:a}})=>Ke(Oe,{display:"flex",flexDirection:"column",children:[G(_e,{control:G(We,{value:d??"",defaultValue:d,onChange:a,...i}),label:G(p,{label:o}),labelPlacement:m||"end"}),G(u,{name:e})]})})},He=Be;import{Grid as Je,Radio as Qe,FormControlLabel as Xe}from"@mui/material";import{jsx as T}from"react/jsx-runtime";var Ye=({label:e,labelPlacement:r,...t})=>T(Je,{display:"flex",flexDirection:"column",children:T(Xe,{control:T(Qe,{...t}),label:T(p,{label:e}),labelPlacement:r||"end"})}),Ze=Ye;import{Controller as je,useFormContext as er}from"react-hook-form";import{Grid as rr,RadioGroup as or}from"@mui/material";import{jsx as A,jsxs as ir}from"react/jsx-runtime";var tr=({name:e,rules:r,defaultValue:t,shouldUnregister:l,label:o,required:m,children:i,orientation:n="row",...d})=>{let a=er();if(!a)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return A(je,{control:a.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:x,onChange:c}})=>ir(rr,{display:"flex",flexDirection:"column",children:[o&&A(p,{label:o,required:m}),A(or,{value:x||"",onChange:c,name:e,...d,style:{display:"flex",flexDirection:n},children:i}),A(u,{name:e})]})})},lr=tr;import{Controller as nr,useFormContext as ar}from"react-hook-form";import{Slider as sr}from"@mui/material";import{jsx as V}from"react/jsx-runtime";var dr=({name:e,rules:r,defaultValue:t,shouldUnregister:l,...o})=>{let m=ar();if(!m)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return V(nr,{control:m.control,name:e,rules:r,defaultValue:t,shouldUnregister:l,render:({field:{value:i,onChange:n}})=>V(sr,{value:i||(o==null?void 0:o.min)||0,onChange:n,valueLabelDisplay:"auto",...o})})},mr=dr;export{Ue as Checkbox,De as Creatable,W as Form,Ze as RadioButton,lr as RadioGroup,ge as Searchable,ue as Select,mr as Slider,He as Switch,le 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.0",
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": "*",