@s_mart/form 8.0.2 → 8.0.3
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.mts +5 -1
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -717,9 +717,13 @@ type SelectV2Props<T extends FieldValues | string | number> = Omit<SelectProps$1
|
|
|
717
717
|
* Componente renderizado embaixo da option da listagem
|
|
718
718
|
*/
|
|
719
719
|
getOptionAfterLabel?: (option: T) => string | React.ReactNode;
|
|
720
|
+
/**
|
|
721
|
+
* Ícone renderizado ao lado da label
|
|
722
|
+
*/
|
|
723
|
+
getOptionIcon?: (option: T) => React.ReactNode;
|
|
720
724
|
};
|
|
721
725
|
|
|
722
|
-
declare const _default$1: <T extends string | number | FieldValues>({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, info, footer, onChange: onChangeProp, variant, getOptionKey, getOptionLabel, getOptionAfterLabel, ...rest }: SelectV2Props<T>) => react_jsx_runtime.JSX.Element;
|
|
726
|
+
declare const _default$1: <T extends string | number | FieldValues>({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, info, footer, onChange: onChangeProp, variant, getOptionKey, getOptionLabel, getOptionAfterLabel, getOptionIcon, ...rest }: SelectV2Props<T>) => react_jsx_runtime.JSX.Element;
|
|
723
727
|
|
|
724
728
|
type CreatableV2Props<T extends FieldValues | string | number, Multiple extends boolean | undefined, _ValueType = unknown> = Omit<AutocompleteProps$1<T, Multiple, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & Omit<ControllerProps, 'render' | 'control'> & {
|
|
725
729
|
options: T[];
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{FormProvider as io}from"react-hook-form";import{jsx as
|
|
1
|
+
import{FormProvider as io}from"react-hook-form";import{jsx as Se}from"react/jsx-runtime";function lo({children:e,style:t,onSubmit:i,...n}){return Se(io,{...n,children:Se("form",{onSubmit:l=>{l.preventDefault(),l.stopPropagation(),i(l)},style:t,children:e})})}var Fe=lo;import{useEffect as no}from"react";import{useForm as ao}from"react-hook-form";import{zodResolver as so}from"@hookform/resolvers/zod";var po=({disableDefaultValuesUpdate:e,onSubmit:t,...i})=>{let n=ao({...i,resolver:i.schema&&so(i.schema)});return no(()=>{e||n.reset(i.defaultValues)},[i.defaultValues,n.reset]),{...n,onSubmit:n.handleSubmit(l=>t(l,n))}},ge=po;import{jsx as fo}from"react/jsx-runtime";function mo({children:e,style:t,...i}){let n=ge(i);return fo(Fe,{...n,style:t,children:typeof e=="function"?e(n):e})}var uo=mo;import{memo as vo,useRef as Po,useState as Co}from"react";import{Controller as To,useFormContext as Io}from"react-hook-form";import{Tooltip as So,Grid as he,InputAdornment as ko,TextField as Vo}from"@mui/material";import{lineEye as wo,lineEyeSlash as Ro,lineInfoCircle as Eo}from"@s_mart/solid-icons";import*as we from"@s_mart/masks";import{Typography as ke}from"@mui/material";import{toRem as co}from"@s_mart/utils";import{jsx as Ve,jsxs as xo}from"react/jsx-runtime";var yo=({label:e,required:t,regular:i})=>xo("span",{style:{display:"flex",alignItems:"center",gap:co(2)},children:[Ve(ke,{variant:"caption",fontWeight:i?400:700,style:{display:"flex",alignItems:"center"},children:e}),t&&Ve(ke,{variant:"caption",fontWeight:900,color:"error",children:"*"})]}),P=yo;import{useFormContext as bo}from"react-hook-form";import{Indicator as Fo}from"@s_mart/core";var E=(e,t)=>t.replace(/[[\]]/g,"").split(".").reduce((n,l)=>n?.[l],e);import{jsx as ho}from"react/jsx-runtime";var go=({name:e,disableIcon:t})=>{let i=bo(),n=E(i?.formState?.errors,e);return n?ho(Fo,{severity:"error",icon:t?!1:void 0,children:n?.message}):null},S=go;import{LIcon as Re}from"@s_mart/core";import{jsx as z,jsxs as Ee}from"react/jsx-runtime";var Lo=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,mask:c,variant:y="outlined",info:C,parse:m,format:u,onInputChange:d,disableIconError:x,...a})=>{let h=Io(),F=Po(i||void 0);if(!h)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[p,b]=Co(!1),s=r=>{let o=r;return o=u?.(r)??r,c?we?.[c]?.format(o):o},f=r=>{let o=r;return o=m?.(r)??o,c?we?.[c]?.parse(o,F.current):o},w=r=>{if(!r||c!=="porcentagem"&&c!=="porcentagem0")return;r?.stopPropagation();let o=(r?.target).value;if(o){let T=String(o);if(T.length>0){let I=T.indexOf("%");I>-1&&(r.currentTarget.selectionEnd=I)}}},$=E(h.formState.errors,e);return z(To,{control:h.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:r,onChange:o,ref:T}})=>Ee(he,{display:"flex",flexDirection:"column",children:[Ee("div",{style:{display:"flex"},children:[l&&z(he,{item:!0,children:z(P,{label:l,required:g})}),C&&z(he,{item:!0,children:z(So,{title:C,placement:"top",children:z("div",{style:{width:"fit-content"},children:z(Re,{icon:Eo,color:"#757575"})})})})]}),z(Vo,{variant:y,defaultValue:i,value:s(r||(r!=0?"":r)),onChange:I=>{let _=f(I?.target?.value);o(_),d?.(_,h.getValues()),F.current=I.target.value},error:!!$,...a,type:a.type==="password"?p?"text":"password":a.type,autoComplete:a.autoComplete||"off",InputProps:{onKeyDown:w,inputRef:T,endAdornment:a.type==="password"&&z(ko,{position:"start",onClick:()=>b(!p),style:{cursor:"pointer"},children:z(Re,{icon:p?wo:Ro,size:"24px",removeMargin:!0})}),...a.InputProps}},e),z(S,{name:e,disableIcon:x})]})})},Ao=vo(Lo);import{memo as Bo,useState as Go}from"react";import{Controller as Mo,useFormContext as $o}from"react-hook-form";import{IconButton as Do,LIcon as Le}from"@s_mart/core";import{lineTimes as qo}from"@s_mart/regular-icons";import{lineInfoCircle as _o}from"@s_mart/solid-icons";import{colorPalette as zo}from"@s_mart/tokens";import{Divider as Oo,Tooltip as No,Grid as J,Select as Uo,MenuItem as jo,useTheme as Ho}from"@mui/material";import{Fragment as Yo,jsx as M,jsxs as ne}from"react/jsx-runtime";var Ae=Bo(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,placeholder:y,clearable:C,disableOnChangeForm:m=!1,multiple:u,info:d,footer:x,onChange:a,disableIconError:h,variant:F="outlined",...p})=>{let b=$o(),{palette:s}=Ho(),[f,w]=Go(!1);if(!b)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let $=E(b.formState.errors,e);return M(Mo,{control:b.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:r,onChange:o,ref:T}})=>ne(J,{display:"flex",flexDirection:"column",children:[ne("div",{style:{display:"flex"},children:[l&&M(J,{item:!0,children:M(P,{label:l,required:g})}),d&&M(J,{item:!0,children:M(No,{title:d,placement:"top",children:M("div",{style:{width:"fit-content"},children:M(Le,{icon:_o,color:"#757575"})})})})]}),ne(Uo,{open:f,onOpen:()=>w(!0),onClose:()=>w(!1),displayEmpty:!!y,variant:F,autoComplete:"off",value:r?r||"":u?[]:"",renderValue:I=>{if(I.label)return I.label;if(y)return M("p",{style:{color:s.grey[400]},children:y})},multiple:u,onChange:I=>{!m&&o(I.target.value),a&&a(I.target.value,b.getValues())},error:!!$,size:p.size||"medium",inputRef:T,...p,endAdornment:ne(Yo,{children:[p.endAdornment,!!(C&&r)&&M(Do,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!m&&o(null),a&&a(null,b.getValues())},children:M(Le,{icon:qo,color:zo.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c?.map((I,_)=>M(jo,{value:I,children:ne(J,{container:!0,direction:"column",children:[M(J,{item:!0,children:I.label}),I.afterLabel&&M(J,{item:!0,children:I.afterLabel})]})},_)),x&&[M(J,{px:2,py:1,children:M(Oo,{})},"footer-divider"),M("div",{children:x({closeSelect:()=>w(!1)})},"footer-content")]]},e),M(S,{name:e,disableIcon:h})]})})});Ae.displayName="Select";var Wo=Ae;import{forwardRef as Jo,memo as Ko}from"react";import{Controller as Xo,useFormContext as Qo}from"react-hook-form";import{Tooltip as Zo,Divider as Be,Grid as W,Autocomplete as er,TextField as or}from"@mui/material";import{LIcon as rr}from"@s_mart/core";import{lineInfoCircle as tr}from"@s_mart/solid-icons";import{colorPalette as ir}from"@s_mart/tokens";import{Fragment as de,jsx as G,jsxs as K}from"react/jsx-runtime";import{createElement as Ge}from"react";var Me=Ko(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,textFieldProps:y,noOptionsText:C,footer:m,multiple:u,info:d,placeholder:x,onChange:a,onInputChange:h,disableIconError:F,...p})=>{let b=Qo();if(!b)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let s=E(b.formState.errors,e);return G(Xo,{control:b.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{onChange:f,value:w,ref:$}})=>K(W,{display:"flex",flexDirection:"column",children:[K("div",{style:{display:"flex"},children:[l&&G(W,{item:!0,children:G(P,{label:l,required:g})}),d&&G(W,{item:!0,children:G(Zo,{title:d,placement:"top",children:G("div",{style:{width:"fit-content"},children:G(rr,{icon:tr,color:"#757575"})})})})]}),G(er,{onChange:(r,o)=>{f(o),a?.(o,b.getValues())},onInputChange:(r,o,T)=>{T==="input"&&setTimeout(()=>{h?.(o,b.getValues())},0)},slotProps:{...p.slotProps||{},paper:{...(p.slotProps||{}).paper||{},sx:{border:`1px solid ${ir.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},value:w||(u?[]:null),options:c,multiple:u,readOnly:p.disabled,noOptionsText:K(de,{children:[C||"Nenhum resultado encontrado",m?K(de,{children:[G(W,{py:1,children:G(Be,{})}),m]}):null]}),isOptionEqualToValue:(r,o)=>typeof r=="string"&&typeof o=="string"?r===o:typeof r=="object"&&typeof o=="object"?typeof r.value=="object"&&typeof o.value=="object"&&r.key!==void 0&&o.key!==void 0?r.key===o.key:r.value===o.value:!1,renderOption:(r,o)=>typeof o=="object"?Ge("li",{...r,key:o.key||o.value},K(W,{container:!0,direction:"column",children:[G(W,{item:!0,children:o.label}),o.afterLabel&&G(W,{item:!0,children:o.afterLabel})]})):Ge("li",{...r,key:o},o),ListboxComponent:Jo(function(o,T){return K(de,{children:[G("ul",{...o,ref:T}),!!m&&G("div",{...o,children:K(de,{children:[G(W,{px:2,py:1,children:G(Be,{})}),m]})},"searchable-footer")]})}),...p,renderInput:r=>G(or,{error:!!s,placeholder:x,...r,...y,inputRef:$})},e),G(S,{name:e,disableIcon:F})]})})});Me.displayName="Searchable";var lr=Me;import{forwardRef as sr,memo as dr}from"react";import{Controller as pr,useFormContext as mr}from"react-hook-form";import{isObject as ur,isEmpty as fr}from"lodash-es";import{Grid as X,Autocomplete as cr,TextField as yr,Tooltip as xr,Divider as br}from"@mui/material";import{LIcon as me,Button as Fr}from"@s_mart/core";import{colorPalette as gr}from"@s_mart/tokens";import{linePlus as _e,linePen as hr,lineInfoCircle as vr}from"@s_mart/solid-icons";import{toRem as ze}from"@s_mart/utils";import{toRem as pe}from"@s_mart/utils";import nr from"@emotion/styled";import{css as $e}from"@emotion/react";var De=$e`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
@@ -51,25 +51,25 @@ import{FormProvider as io}from"react-hook-form";import{jsx as Ie}from"react/jsx-
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
${({hideAddButton:e,theme:t})=>!e&&ar(t)}
|
|
54
|
-
`;import{Fragment as
|
|
54
|
+
`;import{Fragment as ve,jsx as k,jsxs as U}from"react/jsx-runtime";import{createElement as Oe}from"react";var Ne=dr(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,editable:y,footer:C,onEditOption:m,onCreateOption:u,textFieldProps:d,hideAddButton:x,multiple:a,info:h,onChange:F,onInputChange:p,placeholder:b,disableIconError:s,...f})=>{let w=mr();if(!w)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let $=E(w.formState.errors,e),r=x||f.disabled,o=R=>{let D=0;return d?.InputProps||(D+=2.5),r||(D+=2.56,T(R)&&(D+=2.56)),!f.disableClearable&&!f.disabled&&(D+=1.3),D+"rem"},T=R=>f.disabled?!1:y&&ur(R)&&!fr(R);console.warn=()=>{};let I=R=>{u?u(R):console.error("onCreateOption n\xE3o foi definido")},_=R=>{m?m(R):console.error("onEditOption n\xE3o foi definido")};return k(pr,{control:w.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:R,onChange:D,ref:be}})=>{let ie=R?.label||R?.value||R;return U(X,{display:"flex",flexDirection:"column",children:[U("div",{style:{display:"flex"},children:[l&&k(X,{item:!0,children:k(P,{label:l,required:g})}),h&&k(X,{item:!0,children:k(xr,{title:h,placement:"top",children:k("div",{style:{width:"fit-content"},children:k(me,{icon:vr,color:"#757575"})})})})]}),k(qe,{hideAddButton:r,children:k(cr,{fullWidth:!0,onChange:(L,v)=>{D(v),F?.(v,w.getValues())},onInputChange:(L,v,le)=>{le==="input"&&setTimeout(()=>{p?.(v,w.getValues())},0)},slotProps:{...f.slotProps||{},paper:{...(f.slotProps||{}).paper||{},sx:{border:`1px solid ${gr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},options:c,value:R||(a?[]:null),multiple:a,readOnly:f.disabled,noOptionsText:r?void 0:U(Fr,{sx:{justifyContent:"flex-start",padding:`${ze(6)} ${ze(-16)}`,margin:0},fullWidth:!0,onClick:()=>I(R),variant:"text",startIcon:k(me,{icon:_e}),children:["Adicionar ",ie&&`"${ie}"`]}),isOptionEqualToValue:(L,v)=>v?typeof L=="string"&&typeof v=="string"?L===v:typeof L=="object"&&typeof v=="object"?typeof L.value=="object"&&typeof v.value=="object"&&L.key!==void 0&&v.key!==void 0?L.key===v.key:L.value===v.value:typeof L=="object"&&typeof v=="string":!1,renderOption:(L,v)=>typeof v=="object"?Oe("li",{...L,key:v.key||v.value},U(X,{container:!0,direction:"column",children:[k(X,{item:!0,children:v.label}),v.afterLabel&&k(X,{item:!0,children:v.afterLabel})]})):Oe("li",{...L,key:v},v),ListboxComponent:sr(function(v,le){return U(ve,{children:[k("ul",{...v,ref:le}),!!C&&k("div",{...v,children:U(ve,{children:[k(X,{px:2,py:1,children:k(br,{})}),C]})},"creatable-footer")]})}),...f,sx:{"& div.MuiInputBase-root":{paddingRight:`${o(R)} !important`},...f.sx},renderInput:L=>k(yr,{placeholder:b,...L,error:!!$,InputProps:{...L.InputProps,inputRef:be,endAdornment:U("div",{className:"endAdornments",children:[L.InputProps.endAdornment,!r&&U(ve,{children:[T(R)?U("div",{className:"editable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>_(R),children:k(me,{icon:hr,size:"24px",removeMargin:!0})})]}):null,U("div",{className:"creatable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>I(R),children:k(me,{icon:_e,size:"24px",removeMargin:!0})})]})]})]})},...d})},e)}),k(S,{name:e,disableIcon:s})]})}})});Ne.displayName="Creatable";var Pr=Ne;import{useController as Cr,useFormContext as Tr}from"react-hook-form";import{Checkbox as Ir,FormControlLabel as Sr}from"@mui/material";import{jsx as ue,jsxs as wr}from"react/jsx-runtime";var kr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:g,required:c,disableIconError:y,onChange:C,...m})=>{let u=Tr();if(!u)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let{field:d}=Cr({control:u.control,name:e,rules:t,defaultValue:i,shouldUnregister:n});return wr("span",{children:[ue(Sr,{control:ue(Ir,{checked:!!d.value,value:d.value??"",defaultValue:d.value,onChange:(x,a)=>{d.onChange(x,a),C?.(x,a)},...m},e),label:ue(P,{label:l,required:c,regular:!0}),labelPlacement:g||"end"}),ue(S,{name:e,disableIcon:y})]})},Vr=kr;import{Controller as Rr,useFormContext as Er}from"react-hook-form";import{Grid as Lr,Switch as Ar,FormControlLabel as Br}from"@mui/material";import{jsx as ae,jsxs as $r}from"react/jsx-runtime";var Gr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:g,disableIconError:c,onChange:y,...C})=>{let m=Er();if(!m)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ae(Rr,{control:m.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:u,onChange:d}})=>$r(Lr,{display:"flex",flexDirection:"column",children:[ae(Br,{control:ae(Ar,{value:u??"",checked:u??!1,defaultValue:u,onChange:(x,a)=>{d(x,a),y?.(x,a)},...C},e),label:ae(P,{label:l}),labelPlacement:g||"end"}),ae(S,{name:e,disableIcon:c})]})})},Mr=Gr;import{Grid as Dr,Radio as qr,FormControlLabel as _r}from"@mui/material";import{jsx as fe}from"react/jsx-runtime";var zr=({label:e,labelPlacement:t,...i})=>fe(Dr,{display:"flex",flexDirection:"column",children:fe(_r,{control:fe(qr,{...i}),label:fe(P,{label:e}),labelPlacement:t||"end"})}),Or=zr;import{Controller as Nr,useFormContext as Ur}from"react-hook-form";import{Grid as jr,RadioGroup as Hr}from"@mui/material";import{jsx as ce,jsxs as Jr}from"react/jsx-runtime";var Wr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,children:c,orientation:y="row",disableIconError:C,...m})=>{let u=Ur();if(!u)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ce(Nr,{control:u.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:d,onChange:x}})=>Jr(jr,{display:"flex",flexDirection:"column",children:[l&&ce(P,{label:l,required:g}),ce(Hr,{value:d||"",name:e,...m,onChange:a=>{m?.onChange?.(a,a.target?.value),x(a)},style:{display:"flex",flexDirection:y},children:c},e),ce(S,{name:e,disableIcon:C})]})})},Yr=Wr;import{Controller as Kr,useFormContext as Xr}from"react-hook-form";import{Slider as Qr}from"@mui/material";import{jsx as Ue}from"react/jsx-runtime";var Zr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,...l})=>{let g=Xr();if(!g)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Ue(Kr,{control:g.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:c,onChange:y}})=>Ue(Qr,{value:c||l?.min||0,onChange:y,valueLabelDisplay:"auto",...l},e)})},et=Zr;import{memo as lt}from"react";import{Controller as nt,useFormContext as at}from"react-hook-form";import{composeValidators as st,date as He}from"@s_mart/rules";import{Grid as dt,TextField as pt}from"@mui/material";import{DatePicker as mt}from"@mui/x-date-pickers/DatePicker";import{AdapterDayjs as ut}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as ft}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as ct}from"@mui/x-date-pickers/locales/ptBR";import yt from"dayjs/locale/pt-br";import ot from"@emotion/styled";import{IconButton as rt}from"@mui/material";import{toRem as j}from"@s_mart/utils";var tt=e=>{switch(e){case"small":return j(16);default:case"medium":return j(20);case"large":return j(24)}},it=e=>{switch(e){case"small":return`${j(2)} ${j(8)}`;default:case"medium":return`${j(6)} ${j(8)}`;case"large":return`${j(10)}`}},je=ot(rt)`
|
|
55
55
|
margin: 0px;
|
|
56
56
|
|
|
57
57
|
padding: ${({size:e})=>it(e)};
|
|
58
|
-
border-radius: 0 ${
|
|
58
|
+
border-radius: 0 ${j(4)} ${j(4)} 0;
|
|
59
59
|
|
|
60
60
|
svg {
|
|
61
61
|
width: ${({size:e})=>tt(e)} !important;
|
|
62
62
|
}
|
|
63
|
-
`;import{jsx as se,jsxs as gt}from"react/jsx-runtime";import{createElement as Ft}from"react";var xt=({rules:e,name:t,defaultValue:i,shouldUnregister:n,datePickerProps:l,label:g,required:c,placeholder:y,disabled:C,disableIconError:u
|
|
63
|
+
`;import{jsx as se,jsxs as gt}from"react/jsx-runtime";import{createElement as Ft}from"react";var xt=({rules:e,name:t,defaultValue:i,shouldUnregister:n,datePickerProps:l,label:g,required:c,placeholder:y,disabled:C,disableIconError:m,...u})=>{let d=at();if(!d)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let x=E(d.formState.errors,t),a=l?.format||"DD/MM/YYYY",h=e?st([He(a),e]):He(a);return se(ft,{dateAdapter:ut,adapterLocale:yt,localeText:ct.components.MuiLocalizationProvider.defaultProps.localeText,children:se(nt,{control:d.control,name:t,rules:h,defaultValue:i,shouldUnregister:n,render:({field:{value:F,onChange:p,ref:b}})=>gt(dt,{display:"flex",flexDirection:"column",children:[g&&se(P,{label:g,required:c}),Ft(mt,{...l,key:t,value:F??null,format:a,onChange:(s,f)=>{p(s,f),l?.onChange?.(s,f)},disabled:C,slots:{textField:pt,openPickerButton:s=>se(je,{...s,size:u.size})},slotProps:{textField:s=>({variant:"outlined",...s,error:!!x,...u,inputProps:{...s.inputProps,placeholder:y||s.inputProps?.placeholder},InputProps:{...s.InputProps,inputRef:f=>{b(f),typeof s.inputRef=="function"&&s.inputRef(f)}}})}}),se(S,{name:t,disableIcon:m})]})})})},bt=lt(xt);import{memo as Tt}from"react";import{Controller as It,useFormContext as St}from"react-hook-form";import{composeValidators as kt,time as Ye}from"@s_mart/rules";import{Grid as Vt,TextField as wt}from"@mui/material";import{TimePicker as Rt}from"@mui/x-date-pickers/TimePicker";import{AdapterDayjs as Et}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Lt}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as At}from"@mui/x-date-pickers/locales/ptBR";import Bt from"dayjs/locale/pt-br";import ht from"@emotion/styled";import{IconButton as vt}from"@mui/material";import{toRem as H}from"@s_mart/utils";var Pt=e=>{switch(e){case"small":return H(16);default:case"medium":return H(20);case"large":return H(24)}},Ct=e=>{switch(e){case"small":return`${H(2)} ${H(8)}`;default:case"medium":return`${H(6)} ${H(8)}`;case"large":return`${H(10)}`}},We=ht(vt)`
|
|
64
64
|
margin: 0px;
|
|
65
65
|
|
|
66
66
|
padding: ${({size:e})=>Ct(e)};
|
|
67
|
-
border-radius: 0 ${
|
|
67
|
+
border-radius: 0 ${H(4)} ${H(4)} 0;
|
|
68
68
|
|
|
69
69
|
svg {
|
|
70
|
-
width: ${({size:e})=>
|
|
70
|
+
width: ${({size:e})=>Pt(e)} !important;
|
|
71
71
|
}
|
|
72
|
-
`;import{jsx as
|
|
72
|
+
`;import{jsx as re,jsxs as $t}from"react/jsx-runtime";var Gt=({rules:e,defaultValue:t,shouldUnregister:i,name:n,required:l,label:g,timePickerProps:c,placeholder:y,disabled:C,disableIconError:m,...u})=>{let d=St();if(!d)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let x=E(d.formState.errors,n),a=c?.format||"HH:mm",h=e?kt([Ye(a),e]):Ye(a);return re(Lt,{dateAdapter:Et,adapterLocale:Bt,localeText:At.components.MuiLocalizationProvider.defaultProps.localeText,children:re(It,{control:d.control,name:n,rules:h,defaultValue:t,shouldUnregister:i,render:({field:{value:F,onChange:p,ref:b}})=>$t(Vt,{display:"flex",flexDirection:"column",children:[g&&re(P,{label:g,required:l}),re(Rt,{ampm:!1,format:a,value:F??null,disabled:C,...c,onChange:(s,f)=>{p(s,f),c?.onChange?.(s,f)},slots:{textField:wt,openPickerButton:s=>re(We,{...s,size:u.size})},slotProps:{textField:s=>({variant:"outlined",...s,error:!!x,...u,inputProps:{...s.inputProps,placeholder:y||s.inputProps?.placeholder},InputProps:{...s.InputProps,inputRef:f=>{b(f),typeof s.inputRef=="function"&&s.inputRef(f)}}})}},n),re(S,{name:n,disableIcon:m})]})})})},Mt=Tt(Gt);import{memo as Dt}from"react";import{Controller as qt,useFormContext as _t}from"react-hook-form";import{Grid as ye,Autocomplete as zt,TextField as Ot}from"@mui/material";import{colorPalette as Nt}from"@s_mart/tokens";import{jsx as Q,jsxs as Je}from"react/jsx-runtime";import{createElement as Ht}from"react";var Ut=({name:e,defaultValue:t,rules:i,shouldUnregister:n,label:l,required:g,noOptionsText:c,placeholder:y,onInputChange:C,onChange:m,disableIconError:u,...d})=>{let x=_t();if(!x)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let a=E(x.formState.errors,e);return console.warn=()=>{},Q(qt,{name:e,control:x.control,defaultValue:t,rules:i,shouldUnregister:n,render:({field:h})=>Je(ye,{display:"flex",flexDirection:"column",children:[l&&Q(P,{label:l,required:g}),Q(zt,{onChange:(F,p)=>{h.onChange(p),m?.(p,x.getValues())},onInputChange:(F,p,b)=>{b==="input"&&(h.onChange(p),setTimeout(()=>{C?.(p,x.getValues())},0))},slotProps:{...d.slotProps||{},paper:{...d.slotProps?.paper||{},sx:{border:`1px solid ${Nt.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(F,p)=>F.value===p.value,renderOption:(F,p)=>Ht("li",{...F,key:p.key||p.value,onClick:b=>{F.onClick?.(b),h.onChange(p)}},Je(ye,{container:!0,direction:"column",children:[Q(ye,{item:!0,children:p.label}),p.afterLabel&&Q(ye,{item:!0,children:p.afterLabel})]})),value:h.value||null,readOnly:d.disabled,noOptionsText:c||"Nenhuma op\xE7\xE3o encontrada",...d,renderInput:F=>Q(Ot,{placeholder:y,...F,error:!!a,slotProps:{input:{inputProps:F.inputProps,inputRef:h.ref}}})},e),Q(S,{name:e,disableIcon:u})]})})},jt=Dt(Ut);import{useController as Qt,useFormContext as Zt}from"react-hook-form";import{Tooltip as Wt}from"@mui/material";import{LIcon as Yt}from"@s_mart/core";import{lineInfoCircle as Jt}from"@s_mart/solid-icons";import{jsx as Pe}from"react/jsx-runtime";var Kt=({title:e})=>Pe(Wt,{title:e,placement:"top",children:Pe("div",{style:{width:"fit-content"},children:Pe(Yt,{icon:Jt,color:"#757575"})})}),Z=Kt;import{Autocomplete as ei,Divider as Ke,TextField as oi}from"@mui/material";import{isEqual as ri}from"lodash-es";import{forwardRef as ti}from"react";import{colorPalette as ii}from"@s_mart/tokens";import{memo as Xt}from"react";var te=Xt;import{Fragment as Ce,jsx as q,jsxs as ee}from"react/jsx-runtime";import{createElement as ai}from"react";var li=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,textFieldProps:y,noOptionsText:C,footer:m,multiple:u,info:d,placeholder:x,onChange:a,onInputChange:h,getOptionAfterLabel:F,getOptionLabel:p,getOptionKey:b,...s})=>{let f=Zt();if(!f)throw new Error("Para usar o <SearchableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let w=E(f.formState.errors,e),{field:$}=Qt({name:e,control:f.control,rules:t,defaultValue:i,shouldUnregister:n});return ee("div",{style:{display:"flex",flexDirection:"column"},children:[ee("div",{style:{display:"flex"},children:[l&&q(P,{label:l,required:g}),d&&q(Z,{title:d})]}),q(ei,{onChange:(r,o)=>{$.onChange(o),a?.(o)},onInputChange:(r,o,T)=>{T==="input"&&h?.(o)},value:$.value?$.value:u?[]:null,options:c,multiple:u,readOnly:s.disabled,slotProps:{...s.slotProps,paper:{...s.slotProps?.paper,sx:{border:`1px solid ${ii.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},noOptionsText:ee(Ce,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?ee(Ce,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Ke,{})}),m()]}):null]}),isOptionEqualToValue:(r,o)=>ri(r,o),getOptionLabel:r=>p(r),getOptionKey:r=>b(r),renderOption:typeof F=="function"?(r,o)=>{let T=F(o),I=b(o);return ai("li",{...r,key:I},ee("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:p(o)}),typeof T=="string"?q("span",{children:T}):T]}))}:void 0,ListboxComponent:ti(function(o,T){return ee(Ce,{children:[q("ul",{...o,ref:T}),typeof m<"u"?ee("div",{...o,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Ke,{})}),m()]},"searchable-footer"):null]})}),...s,renderInput:r=>q(oi,{error:!!w,placeholder:x,...r,...y,inputRef:$.ref})},e),q(S,{name:e})]})},ni=te(li);import{useState as pi}from"react";import{useController as mi,useFormContext as ui}from"react-hook-form";import{IconButton as fi,LIcon as ci}from"@s_mart/core";import{lineTimes as yi}from"@s_mart/regular-icons";import{colorPalette as xi}from"@s_mart/tokens";import{Select as bi,MenuItem as Fi,Divider as gi}from"@mui/material";import{colorPalette as si}from"@s_mart/tokens";import{jsx as di}from"react/jsx-runtime";var Xe=({value:e,placeholder:t,getOptionLabel:i})=>e===null||e?.length===0?di("p",{style:{color:si.neutral[100]},children:t}):i(e);import{Fragment as Pi,jsx as O,jsxs as oe}from"react/jsx-runtime";var hi=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,placeholder:y,clearable:C,info:m,footer:u,onChange:d,variant:x="outlined",getOptionKey:a,getOptionLabel:h,getOptionAfterLabel:F,getOptionIcon:p,...b})=>{let s=ui(),[f,w]=pi(!1);if(!s)throw new Error("Para usar o <SelectV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let $=E(s.formState.errors,e),{field:r}=mi({control:s.control,name:e,rules:t,defaultValue:i,shouldUnregister:n});return oe("div",{style:{display:"flex",flexDirection:"column"},children:[oe("div",{style:{display:"flex"},children:[l&&O(P,{label:l,required:g}),m&&O(Z,{title:m})]}),oe(bi,{open:f,onOpen:()=>w(!0),onClose:()=>w(!1),displayEmpty:!!y,variant:x,autoComplete:"off",value:r.value||null,renderValue:o=>O(Xe,{getOptionLabel:h,placeholder:y,value:o}),onChange:o=>{r.onChange(o.target.value),d?.(o.target.value)},error:!!$,size:b.size||"medium",inputRef:r.ref,...b,endAdornment:oe(Pi,{children:[b.endAdornment,!!(C&&r.value)&&O(fi,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{r.onChange(null),d?.(null)},children:O(ci,{icon:yi,color:xi.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c.map(o=>{let T=a(o),I=h(o),_=p?.(o);return O(Fi,{value:o,children:oe("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[_!==void 0?oe("div",{style:{display:"flex",alignItems:"center"},children:[_,I]}):I,O("span",{children:F?.(o)??null})]})},T)}),u!==void 0&&oe("div",{children:[O("div",{style:{padding:"8px 16px"},children:O(gi,{})},"footer-divider"),O("div",{children:u({closeSelect:()=>w(!1)})},"footer-content")]},"footer")]},e),O(S,{name:e})]})},vi=te(hi);import{forwardRef as Ii,useCallback as Si,useState as ki}from"react";import{useController as Vi,useFormContext as wi}from"react-hook-form";import{isObject as Ri,isEmpty as Ei,isEqual as Li}from"lodash-es";import{Autocomplete as Ai,TextField as Bi,Divider as eo}from"@mui/material";import{LIcon as Te,Button as Gi}from"@s_mart/core";import{colorPalette as Mi}from"@s_mart/tokens";import{linePlus as oo,linePen as $i}from"@s_mart/solid-icons";import{toRem as ro}from"@s_mart/utils";import{toRem as xe}from"@s_mart/utils";import Ci from"@emotion/styled";import{css as Ti}from"@emotion/react";var Qe=Ti`
|
|
73
73
|
display: flex;
|
|
74
74
|
align-items: center;
|
|
75
75
|
justify-content: center;
|
|
@@ -120,4 +120,4 @@ import{FormProvider as io}from"react-hook-form";import{jsx as Ie}from"react/jsx-
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
`;import{Fragment as
|
|
123
|
+
`;import{Fragment as Ie,jsx as B,jsxs as N}from"react/jsx-runtime";import{createElement as _i}from"react";var Di=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,footer:y,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:d,getOptionKey:x,getOptionLabel:a,getOptionAfterLabel:h,textFieldProps:F,multiple:p,info:b,noOptionsText:s,onChange:f,onInputChange:w,placeholder:$,...r})=>{let[o,T]=ki(""),I=wi();if(!I)throw new Error("Para usar o <CreatableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let _=E(I.formState.errors,e),R=!C||r.disabled,{field:D}=Vi({name:e,control:I.control,rules:t,defaultValue:i,shouldUnregister:n}),be=V=>{let A=0;return F?.InputProps||(A+=2.5),R||(A+=2.56,ie(V)&&(A+=2.56)),!r.disableClearable&&!r.disabled&&(A+=1.3),A+"rem"},ie=V=>r.disabled?!1:m&&Ri(V)&&!Ei(V),L=()=>r.disabled?!1:C,v=Si(()=>{typeof d<"u"&&(d(o),T(""))},[o]),le=V=>{u?.(V)};return N("div",{style:{display:"flex",flexDirection:"column"},children:[N("div",{style:{display:"flex"},children:[l&&B(P,{label:l,required:g}),b&&B(Z,{title:b})]}),B(Ze,{children:B(Ai,{fullWidth:!0,onChange:(V,A)=>{T(""),D.onChange(A),f?.(A)},onInputChange:(V,A,Y)=>{Y==="input"&&(T(A),w?.(A))},slotProps:{...r.slotProps,paper:{...r.slotProps?.paper,sx:{border:`1px solid ${Mi.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},value:D.value?D.value:p?[]:null,options:c,multiple:p,readOnly:r.disabled,noOptionsText:N(Ie,{children:[s||"Nenhuma op\xE7\xE3o encontrada",!R&&N(Gi,{sx:{justifyContent:"flex-start",padding:`${ro(6)} ${ro(-16)}`,margin:0},fullWidth:!0,onClick:v,variant:"text",startIcon:B(Te,{icon:oo}),children:["Adicionar ",`"${o}"`]}),typeof y<"u"&&N(Ie,{children:[B("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:B(eo,{})}),y()]})]}),isOptionEqualToValue:(V,A)=>Li(V,A),getOptionLabel:V=>a(V),getOptionKey:V=>x(V),renderOption:typeof h=="function"?(V,A)=>{let Y=h(A),to=x(A);return _i("li",{...V,key:to},N("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[B("span",{children:a(A)}),typeof Y=="string"?B("span",{children:Y}):Y]}))}:void 0,ListboxComponent:Ii(function(A,Y){return N(Ie,{children:[B("ul",{...A,ref:Y}),typeof y<"u"?N("div",{...A,children:[B("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:B(eo,{})}),y()]},"creatable-footer"):null]})}),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${be(D.value)} !important`},...r.sx},onBlur:V=>{r?.onBlur?.(V),T("")},renderInput:V=>B(Bi,{placeholder:$,...V,error:!!_,...F,InputProps:{...V.InputProps,...F?.InputProps,inputRef:D.ref,endAdornment:N("div",{className:"endAdornments",children:[V.InputProps.endAdornment,F?.InputProps?.endAdornment??null,ie(D.value)?N("div",{className:"editable",children:[B("div",{className:"divider"}),B("div",{className:"button",onClick:()=>le(D.value),children:B(Te,{icon:$i,size:"24px",removeMargin:!0})})]}):null,L()&&N("div",{className:"creatable",children:[B("div",{className:"divider"}),B("div",{className:"button",onClick:v,children:B(Te,{icon:oo,size:"24px",removeMargin:!0})})]})]})}})},e)}),B(S,{name:e})]})},qi=te(Di);export{jt as Autocomplete,Vr as Checkbox,Pr as Creatable,qi as CreatableV2,bt as DatePicker,P as FieldLabel,uo as Form,Fe as FormProvider,Or as RadioButton,Yr as RadioGroup,lr as Searchable,ni as SearchableV2,Wo as Select,vi as SelectV2,et as Slider,Mr as Switch,Ao as TextField,Mt as TimePicker,ge as useForm};
|