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