@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 +19 -19
- package/dist/index.mjs +19 -19
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
"use strict";var
|
|
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
|
-
|
|
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
|
-
${
|
|
12
|
+
${ue}
|
|
13
13
|
|
|
14
14
|
.divider {
|
|
15
15
|
width: 1px;
|
|
16
|
-
height: ${(0,
|
|
17
|
-
background-color: ${
|
|
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: ${
|
|
24
|
+
color: ${e.palette.grey[600]};
|
|
25
25
|
border-radius: 50%;
|
|
26
26
|
|
|
27
|
-
margin: 0 ${(0,
|
|
28
|
-
width: ${(0,
|
|
29
|
-
height: ${(0,
|
|
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: ${
|
|
33
|
+
background-color: ${e.palette.grey[100]};
|
|
34
34
|
transition: background-color 0.2s ease-in-out;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
`,
|
|
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
|
-
${
|
|
45
|
+
${ue}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
${({hideAddButton:
|
|
49
|
-
`,
|
|
50
|
-
color: ${({theme:
|
|
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,
|
|
53
|
-
margin: ${(0,
|
|
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:
|
|
58
|
+
background-color: ${({theme:e})=>e.palette.grey[100]};
|
|
59
59
|
}
|
|
60
|
-
`;var
|
|
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
|
|
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
|
-
`,
|
|
5
|
+
`,Pe=e=>q`
|
|
6
6
|
.MuiAutocomplete-endAdornment {
|
|
7
7
|
position: relative;
|
|
8
8
|
right: 0;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.creatable {
|
|
12
|
-
${
|
|
12
|
+
${M}
|
|
13
13
|
|
|
14
14
|
.divider {
|
|
15
15
|
width: 1px;
|
|
16
|
-
height: ${
|
|
17
|
-
background-color: ${
|
|
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: ${
|
|
24
|
+
color: ${e.palette.grey[600]};
|
|
25
25
|
border-radius: 50%;
|
|
26
26
|
|
|
27
|
-
margin: 0 ${
|
|
28
|
-
width: ${
|
|
29
|
-
height: ${
|
|
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: ${
|
|
33
|
+
background-color: ${e.palette.grey[100]};
|
|
34
34
|
transition: background-color 0.2s ease-in-out;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
`,
|
|
38
|
+
`,k=$.div`
|
|
39
39
|
display: flex;
|
|
40
40
|
|
|
41
41
|
div.endAdornments {
|
|
42
42
|
position: absolute;
|
|
43
43
|
right: 0;
|
|
44
44
|
|
|
45
|
-
${
|
|
45
|
+
${M}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
${({hideAddButton:
|
|
49
|
-
`,
|
|
50
|
-
color: ${({theme:
|
|
48
|
+
${({hideAddButton:e,theme:r})=>!e&&Pe(r)}
|
|
49
|
+
`,U=$.div`
|
|
50
|
+
color: ${({theme:e})=>e.palette.text.primary};
|
|
51
51
|
|
|
52
|
-
padding: ${
|
|
53
|
-
margin: ${
|
|
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:
|
|
58
|
+
background-color: ${({theme:e})=>e.palette.grey[100]};
|
|
59
59
|
}
|
|
60
|
-
`;import{jsx as
|
|
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.
|
|
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": "*",
|