@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 +1 -1
- package/dist/index.js +19 -19
- package/dist/index.mjs +19 -19
- package/package.json +3 -2
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
|
|
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
|
-
`,
|
|
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
|
-
${
|
|
12
|
+
${fe}
|
|
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
|
+
`,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
|
-
${
|
|
45
|
+
${fe}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
${({hideAddButton:
|
|
49
|
-
`,
|
|
50
|
-
color: ${({theme:
|
|
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,
|
|
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"),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
|
|
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
|
-
`,
|
|
5
|
+
`,Se=e=>M`
|
|
6
6
|
.MuiAutocomplete-endAdornment {
|
|
7
7
|
position: relative;
|
|
8
8
|
right: 0;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.creatable {
|
|
12
|
-
${
|
|
12
|
+
${k}
|
|
13
13
|
|
|
14
14
|
.divider {
|
|
15
15
|
width: 1px;
|
|
16
|
-
height: ${
|
|
17
|
-
background-color: ${
|
|
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: ${
|
|
24
|
+
color: ${e.palette.grey[600]};
|
|
25
25
|
border-radius: 50%;
|
|
26
26
|
|
|
27
|
-
margin: 0 ${
|
|
28
|
-
width: ${
|
|
29
|
-
height: ${
|
|
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: ${
|
|
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
|
+
`,U=q.div`
|
|
39
39
|
display: flex;
|
|
40
40
|
|
|
41
41
|
div.endAdornments {
|
|
42
42
|
position: absolute;
|
|
43
43
|
right: 0;
|
|
44
44
|
|
|
45
|
-
${
|
|
45
|
+
${k}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
${({hideAddButton:
|
|
49
|
-
`,
|
|
50
|
-
color: ${({theme:
|
|
48
|
+
${({hideAddButton:e,theme:r})=>!e&&Se(r)}
|
|
49
|
+
`,V=q.div`
|
|
50
|
+
color: ${({theme:e})=>e.palette.text.primary};
|
|
51
51
|
|
|
52
|
-
padding: ${
|
|
53
|
-
margin: ${
|
|
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:
|
|
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 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
|
|
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": "*",
|