@s_mart/form 7.2.7 → 8.0.0-next.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.d.mts CHANGED
@@ -2,6 +2,7 @@ import * as react_hook_form from 'react-hook-form';
2
2
  import { FieldValues, UseFormReturn, FormProviderProps, UseFormProps, ControllerProps, UseControllerProps } from 'react-hook-form';
3
3
  import { z } from 'zod';
4
4
  import * as react from 'react';
5
+ import react__default from 'react';
5
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
7
  import { TextFieldProps as TextFieldProps$1, SelectProps as SelectProps$1, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, SwitchProps as SwitchProps$1, RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1, SliderProps as SliderProps$1 } from '@mui/material';
7
8
  import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
@@ -575,7 +576,7 @@ type TimePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps
575
576
  disableIconError?: boolean;
576
577
  };
577
578
 
578
- declare const _default$4: react.MemoExoticComponent<({ rules, defaultValue, shouldUnregister, name, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element>;
579
+ declare const _default$4: react__default.MemoExoticComponent<({ rules, defaultValue, shouldUnregister, name, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element>;
579
580
 
580
581
  type AutoCompleteOption = {
581
582
  key?: string | number;
@@ -583,7 +584,7 @@ type AutoCompleteOption = {
583
584
  value: string | number | readonly string[] | undefined;
584
585
  afterLabel?: string | React.ReactNode;
585
586
  };
586
- type AutocompleteProps<T = any> = Omit<UseControllerProps, 'control'> & Omit<AutocompleteProps$1<T, any, any, any>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'options'> & {
587
+ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> & Omit<AutocompleteProps$1<ValueType, any, any, any>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'options'> & {
587
588
  /**
588
589
  * Opções do autocomplete
589
590
  * @default []
@@ -597,13 +598,6 @@ type AutocompleteProps<T = any> = Omit<UseControllerProps, 'control'> & Omit<Aut
597
598
  * @memberof AutocompleteProps
598
599
  */
599
600
  options: AutoCompleteOption[];
600
- /**
601
- * Props do textField que é renderizado dentro do autocomplete
602
- * @default {}
603
- * @type {TextFieldProps}
604
- * @memberof AutocompleteProps
605
- */
606
- textFieldProps?: TextFieldProps$1;
607
601
  label?: React.ReactNode;
608
602
  required?: boolean;
609
603
  onInputChange?: (value: string, values: FieldValues) => void;
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-runtime";function io({children:e,style:t,onSubmit:i,...n}){return Ie(to,{...n,children:Ie("form",{onSubmit:l=>{l.preventDefault(),l.stopPropagation(),i(l)},style:t,children:e})})}var Fe=io;import{useEffect as lo}from"react";import{useForm as no}from"react-hook-form";import{zodResolver as ao}from"@hookform/resolvers/zod";var so=({disableDefaultValuesUpdate:e,onSubmit:t,...i})=>{let n=no({...i,resolver:i.schema&&ao(i.schema)});return lo(()=>{e||n.reset(i.defaultValues)},[i.defaultValues,n.reset]),{...n,onSubmit:n.handleSubmit(l=>t(l,n))}},be=so;import{jsx as uo}from"react/jsx-runtime";function po({children:e,style:t,...i}){let n=be(i);return uo(Fe,{...n,style:t,children:typeof e=="function"?e(n):e})}var mo=po;import{memo as Po,useRef as ho,useState as vo}from"react";import{Controller as Co,useFormContext as To}from"react-hook-form";import{Tooltip as Io,Grid as ge,InputAdornment as So,TextField as ko}from"@mui/material";import{lineEye as Vo,lineEyeSlash as wo,lineInfoCircle as Ro}from"@s_mart/solid-icons";import*as Ve from"@s_mart/masks";import{Typography as Se}from"@mui/material";import{toRem as fo}from"@s_mart/utils";import{jsx as ke,jsxs as yo}from"react/jsx-runtime";var co=({label:e,required:t,regular:i})=>yo("span",{style:{display:"flex",alignItems:"center",gap:fo(2)},children:[ke(Se,{variant:"caption",fontWeight:i?400:700,style:{display:"flex",alignItems:"center"},children:e}),t&&ke(Se,{variant:"caption",fontWeight:900,color:"error",children:"*"})]}),h=co;import{useFormContext as xo}from"react-hook-form";import{Indicator as Fo}from"@s_mart/core";var R=(e,t)=>t.replace(/[[\]]/g,"").split(".").reduce((n,l)=>n?.[l],e);import{jsx as go}from"react/jsx-runtime";var bo=({name:e,disableIcon:t})=>{let i=xo(),n=R(i?.formState?.errors,e);return n?go(Fo,{severity:"error",icon:t?!1:void 0,children:n?.message}):null},S=bo;import{LIcon as we}from"@s_mart/core";import{jsx as q,jsxs as Re}from"react/jsx-runtime";var Eo=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,mask:c,variant:y="outlined",info:v,parse:u,format:f,onInputChange:a,disableIconError:b,...s})=>{let g=To(),x=ho(i||void 0);if(!g)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[d,F]=vo(!1),p=o=>{let r=o;return r=f?.(o)??o,c?Ve?.[c]?.format(r):r},m=o=>{let r=o;return r=u?.(o)??r,c?Ve?.[c]?.parse(r,x.current):r},L=o=>{if(!o||c!=="porcentagem"&&c!=="porcentagem0")return;o?.stopPropagation();let r=(o?.target).value;if(r){let C=String(r);if(C.length>0){let k=C.indexOf("%");k>-1&&(o.currentTarget.selectionEnd=k)}}},A=R(g.formState.errors,e);return q(Co,{control:g.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:o,onChange:r,ref:C}})=>Re(ge,{display:"flex",flexDirection:"column",children:[Re("div",{style:{display:"flex"},children:[l&&q(ge,{item:!0,children:q(h,{label:l,required:P})}),v&&q(ge,{item:!0,children:q(Io,{title:v,placement:"top",children:q("div",{style:{width:"fit-content"},children:q(we,{icon:Ro,color:"#757575"})})})})]}),q(ko,{variant:y,defaultValue:i,value:p(o||(o!=0?"":o)),onChange:k=>{let H=m(k?.target?.value);r(H),a?.(H,g.getValues()),x.current=k.target.value},error:!!A,...s,type:s.type==="password"?d?"text":"password":s.type,autoComplete:s.autoComplete||"off",InputProps:{onKeyDown:L,inputRef:C,endAdornment:s.type==="password"&&q(So,{position:"start",onClick:()=>F(!d),style:{cursor:"pointer"},children:q(we,{icon:d?Vo:wo,size:"24px",removeMargin:!0})}),...s.InputProps}},e),q(S,{name:e,disableIcon:b})]})})},Lo=Po(Eo);import{memo as Ao,useState as Bo}from"react";import{Controller as Go,useFormContext as Mo}from"react-hook-form";import{IconButton as $o,LIcon as Ee}from"@s_mart/core";import{lineTimes as Do}from"@s_mart/regular-icons";import{lineInfoCircle as _o}from"@s_mart/solid-icons";import{colorPalette as qo}from"@s_mart/tokens";import{Divider as zo,Tooltip as Oo,Grid as J,Select as No,MenuItem as Uo,useTheme as jo}from"@mui/material";import{Fragment as Wo,jsx as $,jsxs as le}from"react/jsx-runtime";var Le=Ao(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,options:c,placeholder:y,clearable:v,disableOnChangeForm:u=!1,multiple:f,info:a,footer:b,onChange:s,disableIconError:g,variant:x="outlined",...d})=>{let F=Mo(),{palette:p}=jo(),[m,L]=Bo(!1);if(!F)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let A=R(F.formState.errors,e);return $(Go,{control:F.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:o,onChange:r,ref:C}})=>le(J,{display:"flex",flexDirection:"column",children:[le("div",{style:{display:"flex"},children:[l&&$(J,{item:!0,children:$(h,{label:l,required:P})}),a&&$(J,{item:!0,children:$(Oo,{title:a,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(Ee,{icon:_o,color:"#757575"})})})})]}),le(No,{open:m,onOpen:()=>L(!0),onClose:()=>L(!1),displayEmpty:!!y,variant:x,autoComplete:"off",value:o?o||"":f?[]:"",renderValue:k=>{if(k.label)return k.label;if(y)return $("p",{style:{color:p.grey[400]},children:y})},multiple:f,onChange:k=>{!u&&r(k.target.value),s&&s(k.target.value,F.getValues())},error:!!A,size:d.size||"medium",inputRef:C,...d,endAdornment:le(Wo,{children:[d.endAdornment,!!(v&&o)&&$($o,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!u&&r(null),s&&s(null,F.getValues())},children:$(Ee,{icon:Do,color:qo.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c?.map((k,H)=>$(Uo,{value:k,children:le(J,{container:!0,direction:"column",children:[$(J,{item:!0,children:k.label}),k.afterLabel&&$(J,{item:!0,children:k.afterLabel})]})},H)),b&&[$(J,{px:2,py:1,children:$(zo,{})},"footer-divider"),$("div",{children:b({closeSelect:()=>L(!1)})},"footer-content")]]},e),$(S,{name:e,disableIcon:g})]})})});Le.displayName="Select";var Ho=Le;import{forwardRef as Yo,memo as Jo}from"react";import{Controller as Ko,useFormContext as Xo}from"react-hook-form";import{Tooltip as Qo,Divider as Ae,Grid as W,Autocomplete as Zo,TextField as er}from"@mui/material";import{LIcon as or}from"@s_mart/core";import{lineInfoCircle as rr}from"@s_mart/solid-icons";import{colorPalette as tr}from"@s_mart/tokens";import{Fragment as se,jsx as M,jsxs as K}from"react/jsx-runtime";import{createElement as Be}from"react";var Ge=Jo(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,options:c,textFieldProps:y,noOptionsText:v,footer:u,multiple:f,info:a,placeholder:b,onChange:s,onInputChange:g,disableIconError:x,...d})=>{let F=Xo();if(!F)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let p=R(F.formState.errors,e);return M(Ko,{control:F.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{onChange:m,value:L,ref:A}})=>K(W,{display:"flex",flexDirection:"column",children:[K("div",{style:{display:"flex"},children:[l&&M(W,{item:!0,children:M(h,{label:l,required:P})}),a&&M(W,{item:!0,children:M(Qo,{title:a,placement:"top",children:M("div",{style:{width:"fit-content"},children:M(or,{icon:rr,color:"#757575"})})})})]}),M(Zo,{onChange:(o,r)=>{m(r),s?.(r,F.getValues())},onInputChange:(o,r,C)=>{C==="input"&&setTimeout(()=>{g?.(r,F.getValues())},0)},slotProps:{...d.slotProps||{},paper:{...(d.slotProps||{}).paper||{},sx:{border:`1px solid ${tr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(d.slotProps||{}).paper?.sx||{}}}},value:L||(f?[]:null),options:c,multiple:f,readOnly:d.disabled,noOptionsText:K(se,{children:[v||"Nenhum resultado encontrado",u?K(se,{children:[M(W,{py:1,children:M(Ae,{})}),u]}):null]}),isOptionEqualToValue:(o,r)=>typeof o=="string"&&typeof r=="string"?o===r:typeof o=="object"&&typeof r=="object"?typeof o.value=="object"&&typeof r.value=="object"&&o.key!==void 0&&r.key!==void 0?o.key===r.key:o.value===r.value:!1,renderOption:(o,r)=>typeof r=="object"?Be("li",{...o,key:r.key||r.value},K(W,{container:!0,direction:"column",children:[M(W,{item:!0,children:r.label}),r.afterLabel&&M(W,{item:!0,children:r.afterLabel})]})):Be("li",{...o,key:r},r),ListboxComponent:Yo(function(r,C){return K(se,{children:[M("ul",{...r,ref:C}),!!u&&M("div",{...r,children:K(se,{children:[M(W,{px:2,py:1,children:M(Ae,{})}),u]})},"searchable-footer")]})}),...d,renderInput:o=>M(er,{error:!!p,placeholder:b,...o,...y,inputRef:A})},e),M(S,{name:e,disableIcon:x})]})})});Ge.displayName="Searchable";var ir=Ge;import{forwardRef as ar,memo as dr}from"react";import{Controller as sr,useFormContext as pr}from"react-hook-form";import{isObject as mr,isEmpty as ur}from"lodash-es";import{Grid as X,Autocomplete as fr,TextField as cr,Tooltip as yr,Divider as xr}from"@mui/material";import{LIcon as me,Button as Fr}from"@s_mart/core";import{colorPalette as br}from"@s_mart/tokens";import{linePlus as _e,linePen as gr,lineInfoCircle as Pr}from"@s_mart/solid-icons";import{toRem as qe}from"@s_mart/utils";import{toRem as pe}from"@s_mart/utils";import lr from"@emotion/styled";import{css as Me}from"@emotion/react";var $e=Me`
1
+ import{FormProvider as io}from"react-hook-form";import{jsx as Ie}from"react/jsx-runtime";function lo({children:e,style:t,onSubmit:i,...n}){return Ie(io,{...n,children:Ie("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 Po,useRef as vo,useState as Co}from"react";import{Controller as To,useFormContext as So}from"react-hook-form";import{Tooltip as Io,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:"*"})]}),v=yo;import{useFormContext as bo}from"react-hook-form";import{Indicator as Fo}from"@s_mart/core";var R=(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=R(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 q,jsxs as Ee}from"react/jsx-runtime";var Lo=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,mask:c,variant:y="outlined",info:C,parse:u,format:f,onInputChange:s,disableIconError:b,...a})=>{let F=So(),g=vo(i||void 0);if(!F)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[d,x]=Co(!1),p=o=>{let r=o;return r=f?.(o)??o,c?we?.[c]?.format(r):r},m=o=>{let r=o;return r=u?.(o)??r,c?we?.[c]?.parse(r,g.current):r},E=o=>{if(!o||c!=="porcentagem"&&c!=="porcentagem0")return;o?.stopPropagation();let r=(o?.target).value;if(r){let T=String(r);if(T.length>0){let I=T.indexOf("%");I>-1&&(o.currentTarget.selectionEnd=I)}}},L=R(F.formState.errors,e);return q(To,{control:F.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:o,onChange:r,ref:T}})=>Ee(he,{display:"flex",flexDirection:"column",children:[Ee("div",{style:{display:"flex"},children:[l&&q(he,{item:!0,children:q(v,{label:l,required:h})}),C&&q(he,{item:!0,children:q(Io,{title:C,placement:"top",children:q("div",{style:{width:"fit-content"},children:q(Re,{icon:Eo,color:"#757575"})})})})]}),q(Vo,{variant:y,defaultValue:i,value:p(o||(o!=0?"":o)),onChange:I=>{let H=m(I?.target?.value);r(H),s?.(H,F.getValues()),g.current=I.target.value},error:!!L,...a,type:a.type==="password"?d?"text":"password":a.type,autoComplete:a.autoComplete||"off",InputProps:{onKeyDown:E,inputRef:T,endAdornment:a.type==="password"&&q(ko,{position:"start",onClick:()=>x(!d),style:{cursor:"pointer"},children:q(Re,{icon:d?wo:Ro,size:"24px",removeMargin:!0})}),...a.InputProps}},e),q(S,{name:e,disableIcon:b})]})})},Ao=Po(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 _o}from"@s_mart/regular-icons";import{lineInfoCircle as qo}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 $,jsxs as ne}from"react/jsx-runtime";var Ae=Bo(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,options:c,placeholder:y,clearable:C,disableOnChangeForm:u=!1,multiple:f,info:s,footer:b,onChange:a,disableIconError:F,variant:g="outlined",...d})=>{let x=$o(),{palette:p}=Ho(),[m,E]=Go(!1);if(!x)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=R(x.formState.errors,e);return $(Mo,{control:x.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:o,onChange:r,ref:T}})=>ne(J,{display:"flex",flexDirection:"column",children:[ne("div",{style:{display:"flex"},children:[l&&$(J,{item:!0,children:$(v,{label:l,required:h})}),s&&$(J,{item:!0,children:$(No,{title:s,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(Le,{icon:qo,color:"#757575"})})})})]}),ne(Uo,{open:m,onOpen:()=>E(!0),onClose:()=>E(!1),displayEmpty:!!y,variant:g,autoComplete:"off",value:o?o||"":f?[]:"",renderValue:I=>{if(I.label)return I.label;if(y)return $("p",{style:{color:p.grey[400]},children:y})},multiple:f,onChange:I=>{!u&&r(I.target.value),a&&a(I.target.value,x.getValues())},error:!!L,size:d.size||"medium",inputRef:T,...d,endAdornment:ne(Yo,{children:[d.endAdornment,!!(C&&o)&&$(Do,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!u&&r(null),a&&a(null,x.getValues())},children:$(Le,{icon:_o,color:zo.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c?.map((I,H)=>$(jo,{value:I,children:ne(J,{container:!0,direction:"column",children:[$(J,{item:!0,children:I.label}),I.afterLabel&&$(J,{item:!0,children:I.afterLabel})]})},H)),b&&[$(J,{px:2,py:1,children:$(Oo,{})},"footer-divider"),$("div",{children:b({closeSelect:()=>E(!1)})},"footer-content")]]},e),$(S,{name:e,disableIcon:F})]})})});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 pe,jsx as M,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:h,options:c,textFieldProps:y,noOptionsText:C,footer:u,multiple:f,info:s,placeholder:b,onChange:a,onInputChange:F,disableIconError:g,...d})=>{let x=Qo();if(!x)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let p=R(x.formState.errors,e);return M(Xo,{control:x.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{onChange:m,value:E,ref:L}})=>K(W,{display:"flex",flexDirection:"column",children:[K("div",{style:{display:"flex"},children:[l&&M(W,{item:!0,children:M(v,{label:l,required:h})}),s&&M(W,{item:!0,children:M(Zo,{title:s,placement:"top",children:M("div",{style:{width:"fit-content"},children:M(rr,{icon:tr,color:"#757575"})})})})]}),M(er,{onChange:(o,r)=>{m(r),a?.(r,x.getValues())},onInputChange:(o,r,T)=>{T==="input"&&setTimeout(()=>{F?.(r,x.getValues())},0)},slotProps:{...d.slotProps||{},paper:{...(d.slotProps||{}).paper||{},sx:{border:`1px solid ${ir.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},value:E||(f?[]:null),options:c,multiple:f,readOnly:d.disabled,noOptionsText:K(pe,{children:[C||"Nenhum resultado encontrado",u?K(pe,{children:[M(W,{py:1,children:M(Be,{})}),u]}):null]}),isOptionEqualToValue:(o,r)=>typeof o=="string"&&typeof r=="string"?o===r:typeof o=="object"&&typeof r=="object"?typeof o.value=="object"&&typeof r.value=="object"&&o.key!==void 0&&r.key!==void 0?o.key===r.key:o.value===r.value:!1,renderOption:(o,r)=>typeof r=="object"?Ge("li",{...o,key:r.key||r.value},K(W,{container:!0,direction:"column",children:[M(W,{item:!0,children:r.label}),r.afterLabel&&M(W,{item:!0,children:r.afterLabel})]})):Ge("li",{...o,key:r},r),ListboxComponent:Jo(function(r,T){return K(pe,{children:[M("ul",{...r,ref:T}),!!u&&M("div",{...r,children:K(pe,{children:[M(W,{px:2,py:1,children:M(Be,{})}),u]})},"searchable-footer")]})}),...d,renderInput:o=>M(or,{error:!!p,placeholder:b,...o,...y,inputRef:L})},e),M(S,{name:e,disableIcon:g})]})})});Me.displayName="Searchable";var lr=Me;import{forwardRef as dr,memo as sr}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 ue,Button as Fr}from"@s_mart/core";import{colorPalette as gr}from"@s_mart/tokens";import{linePlus as qe,linePen as hr,lineInfoCircle as Pr}from"@s_mart/solid-icons";import{toRem as ze}from"@s_mart/utils";import{toRem as me}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;
5
- `,nr=e=>Me`
5
+ `,ar=e=>$e`
6
6
  .creatable,
7
7
  .editable {
8
- ${$e}
8
+ ${De}
9
9
 
10
10
  .divider {
11
11
  width: 1px;
12
- height: ${pe(20)};
12
+ height: ${me(20)};
13
13
  background-color: ${e.palette.grey[400]};
14
14
  }
15
15
 
@@ -20,9 +20,9 @@ import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-
20
20
  color: ${e.palette.grey[600]};
21
21
  border-radius: 50%;
22
22
 
23
- margin: 0 ${pe(6)};
24
- width: ${pe(28)};
25
- height: ${pe(28)};
23
+ margin: 0 ${me(6)};
24
+ width: ${me(28)};
25
+ height: ${me(28)};
26
26
 
27
27
  &:hover {
28
28
  cursor: pointer;
@@ -31,14 +31,14 @@ import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-
31
31
  }
32
32
  }
33
33
  }
34
- `,De=lr.div`
34
+ `,_e=nr.div`
35
35
  display: flex;
36
36
 
37
37
  div.endAdornments {
38
38
  position: absolute;
39
39
  right: 0;
40
40
 
41
- ${$e}
41
+ ${De}
42
42
  }
43
43
 
44
44
  .MuiAutocomplete-endAdornment {
@@ -50,37 +50,37 @@ import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-
50
50
  transform: translate(0, 0);
51
51
  }
52
52
 
53
- ${({hideAddButton:e,theme:t})=>!e&&nr(t)}
54
- `;import{Fragment as Pe,jsx as V,jsxs as N}from"react/jsx-runtime";import{createElement as ze}from"react";var Oe=dr(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,options:c,editable:y,footer:v,onEditOption:u,onCreateOption:f,textFieldProps:a,hideAddButton:b,multiple:s,info:g,onChange:x,onInputChange:d,placeholder:F,disableIconError:p,...m})=>{let L=pr();if(!L)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let A=R(L.formState.errors,e),o=b||m.disabled,r=w=>{let D=0;return a?.InputProps||(D+=2.5),o||(D+=2.56,C(w)&&(D+=2.56)),!m.disableClearable&&!m.disabled&&(D+=1.3),D+"rem"},C=w=>m.disabled?!1:y&&mr(w)&&!ur(w);console.warn=()=>{};let k=w=>{f?f(w):console.error("onCreateOption n\xE3o foi definido")},H=w=>{u?u(w):console.error("onEditOption n\xE3o foi definido")};return V(sr,{control:L.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:w,onChange:D,ref:xe}})=>{let ie=w?.label||w?.value||w;return N(X,{display:"flex",flexDirection:"column",children:[N("div",{style:{display:"flex"},children:[l&&V(X,{item:!0,children:V(h,{label:l,required:P})}),g&&V(X,{item:!0,children:V(yr,{title:g,placement:"top",children:V("div",{style:{width:"fit-content"},children:V(me,{icon:Pr,color:"#757575"})})})})]}),V(De,{hideAddButton:o,children:V(fr,{fullWidth:!0,onChange:(E,T)=>{D(T),x?.(T,L.getValues())},onInputChange:(E,T,I)=>{I==="input"&&setTimeout(()=>{d?.(T,L.getValues())},0)},slotProps:{...m.slotProps||{},paper:{...(m.slotProps||{}).paper||{},sx:{border:`1px solid ${br.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(m.slotProps||{}).paper?.sx||{}}}},options:c,value:w||(s?[]:null),multiple:s,readOnly:m.disabled,noOptionsText:o?void 0:N(Fr,{sx:{justifyContent:"flex-start",padding:`${qe(6)} ${qe(-16)}`,margin:0},fullWidth:!0,onClick:()=>k(w),variant:"text",startIcon:V(me,{icon:_e}),children:["Adicionar ",ie&&`"${ie}"`]}),isOptionEqualToValue:(E,T)=>T?typeof E=="string"&&typeof T=="string"?E===T:typeof E=="object"&&typeof T=="object"?typeof E.value=="object"&&typeof T.value=="object"&&E.key!==void 0&&T.key!==void 0?E.key===T.key:E.value===T.value:typeof E=="object"&&typeof T=="string":!1,renderOption:(E,T)=>typeof T=="object"?ze("li",{...E,key:T.key||T.value},N(X,{container:!0,direction:"column",children:[V(X,{item:!0,children:T.label}),T.afterLabel&&V(X,{item:!0,children:T.afterLabel})]})):ze("li",{...E,key:T},T),ListboxComponent:ar(function(T,I){return N(Pe,{children:[V("ul",{...T,ref:I}),!!v&&V("div",{...T,children:N(Pe,{children:[V(X,{px:2,py:1,children:V(xr,{})}),v]})},"creatable-footer")]})}),...m,sx:{"& div.MuiInputBase-root":{paddingRight:`${r(w)} !important`},...m.sx},renderInput:E=>V(cr,{placeholder:F,...E,error:!!A,InputProps:{...E.InputProps,inputRef:xe,endAdornment:N("div",{className:"endAdornments",children:[E.InputProps.endAdornment,!o&&N(Pe,{children:[C(w)?N("div",{className:"editable",children:[V("div",{className:"divider"}),V("div",{className:"button",onClick:()=>H(w),children:V(me,{icon:gr,size:"24px",removeMargin:!0})})]}):null,N("div",{className:"creatable",children:[V("div",{className:"divider"}),V("div",{className:"button",onClick:()=>k(w),children:V(me,{icon:_e,size:"24px",removeMargin:!0})})]})]})]})},...a})},e)}),V(S,{name:e,disableIcon:p})]})}})});Oe.displayName="Creatable";var hr=Oe;import{Controller as vr,useFormContext as Cr}from"react-hook-form";import{Grid as Tr,Checkbox as Ir,FormControlLabel as Sr}from"@mui/material";import{jsx as ne,jsxs as wr}from"react/jsx-runtime";var kr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:P,required:c,disableIconError:y,onChange:v,...u})=>{let f=Cr();if(!f)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ne(vr,{control:f.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:a,onChange:b}})=>wr(Tr,{display:"flex",flexDirection:"column",children:[ne(Sr,{control:ne(Ir,{checked:!!a,value:a??"",defaultValue:a,onChange:(s,g)=>{b(s,g),v?.(s,g)},...u},e),label:ne(h,{label:l,required:c,regular:!0}),labelPlacement:P||"end"}),ne(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:P,disableIconError:c,onChange:y,...v})=>{let u=Er();if(!u)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ae(Rr,{control:u.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:f,onChange:a}})=>$r(Lr,{display:"flex",flexDirection:"column",children:[ae(Br,{control:ae(Ar,{value:f??"",checked:f??!1,defaultValue:f,onChange:(b,s)=>{a(b,s),y?.(b,s)},...v},e),label:ae(h,{label:l}),labelPlacement:P||"end"}),ae(S,{name:e,disableIcon:c})]})})},Mr=Gr;import{Grid as Dr,Radio as _r,FormControlLabel as qr}from"@mui/material";import{jsx as ue}from"react/jsx-runtime";var zr=({label:e,labelPlacement:t,...i})=>ue(Dr,{display:"flex",flexDirection:"column",children:ue(qr,{control:ue(_r,{...i}),label:ue(h,{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 fe,jsxs as Jr}from"react/jsx-runtime";var Wr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,children:c,orientation:y="row",disableIconError:v,...u})=>{let f=Ur();if(!f)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return fe(Nr,{control:f.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:a,onChange:b}})=>Jr(jr,{display:"flex",flexDirection:"column",children:[l&&fe(h,{label:l,required:P}),fe(Hr,{value:a||"",name:e,...u,onChange:s=>{u?.onChange?.(s,s.target?.value),b(s)},style:{display:"flex",flexDirection:y},children:c},e),fe(S,{name:e,disableIcon:v})]})})},Yr=Wr;import{Controller as Kr,useFormContext as Xr}from"react-hook-form";import{Slider as Qr}from"@mui/material";import{jsx as Ne}from"react/jsx-runtime";var Zr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,...l})=>{let P=Xr();if(!P)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Ne(Kr,{control:P.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:c,onChange:y}})=>Ne(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 dt,date as je}from"@s_mart/rules";import{Grid as st,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 U}from"@s_mart/utils";var tt=e=>{switch(e){case"small":return U(16);default:case"medium":return U(20);case"large":return U(24)}},it=e=>{switch(e){case"small":return`${U(2)} ${U(8)}`;default:case"medium":return`${U(6)} ${U(8)}`;case"large":return`${U(10)}`}},Ue=ot(rt)`
53
+ ${({hideAddButton:e,theme:t})=>!e&&ar(t)}
54
+ `;import{Fragment as Pe,jsx as k,jsxs as N}from"react/jsx-runtime";import{createElement as Oe}from"react";var Ne=sr(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,options:c,editable:y,footer:C,onEditOption:u,onCreateOption:f,textFieldProps:s,hideAddButton:b,multiple:a,info:F,onChange:g,onInputChange:d,placeholder:x,disableIconError:p,...m})=>{let E=mr();if(!E)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=R(E.formState.errors,e),o=b||m.disabled,r=w=>{let D=0;return s?.InputProps||(D+=2.5),o||(D+=2.56,T(w)&&(D+=2.56)),!m.disableClearable&&!m.disabled&&(D+=1.3),D+"rem"},T=w=>m.disabled?!1:y&&ur(w)&&!fr(w);console.warn=()=>{};let I=w=>{f?f(w):console.error("onCreateOption n\xE3o foi definido")},H=w=>{u?u(w):console.error("onEditOption n\xE3o foi definido")};return k(pr,{control:E.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:w,onChange:D,ref:be}})=>{let ie=w?.label||w?.value||w;return N(X,{display:"flex",flexDirection:"column",children:[N("div",{style:{display:"flex"},children:[l&&k(X,{item:!0,children:k(v,{label:l,required:h})}),F&&k(X,{item:!0,children:k(xr,{title:F,placement:"top",children:k("div",{style:{width:"fit-content"},children:k(ue,{icon:Pr,color:"#757575"})})})})]}),k(_e,{hideAddButton:o,children:k(cr,{fullWidth:!0,onChange:(A,P)=>{D(P),g?.(P,E.getValues())},onInputChange:(A,P,le)=>{le==="input"&&setTimeout(()=>{d?.(P,E.getValues())},0)},slotProps:{...m.slotProps||{},paper:{...(m.slotProps||{}).paper||{},sx:{border:`1px solid ${gr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},options:c,value:w||(a?[]:null),multiple:a,readOnly:m.disabled,noOptionsText:o?void 0:N(Fr,{sx:{justifyContent:"flex-start",padding:`${ze(6)} ${ze(-16)}`,margin:0},fullWidth:!0,onClick:()=>I(w),variant:"text",startIcon:k(ue,{icon:qe}),children:["Adicionar ",ie&&`"${ie}"`]}),isOptionEqualToValue:(A,P)=>P?typeof A=="string"&&typeof P=="string"?A===P:typeof A=="object"&&typeof P=="object"?typeof A.value=="object"&&typeof P.value=="object"&&A.key!==void 0&&P.key!==void 0?A.key===P.key:A.value===P.value:typeof A=="object"&&typeof P=="string":!1,renderOption:(A,P)=>typeof P=="object"?Oe("li",{...A,key:P.key||P.value},N(X,{container:!0,direction:"column",children:[k(X,{item:!0,children:P.label}),P.afterLabel&&k(X,{item:!0,children:P.afterLabel})]})):Oe("li",{...A,key:P},P),ListboxComponent:dr(function(P,le){return N(Pe,{children:[k("ul",{...P,ref:le}),!!C&&k("div",{...P,children:N(Pe,{children:[k(X,{px:2,py:1,children:k(br,{})}),C]})},"creatable-footer")]})}),...m,sx:{"& div.MuiInputBase-root":{paddingRight:`${r(w)} !important`},...m.sx},renderInput:A=>k(yr,{placeholder:x,...A,error:!!L,InputProps:{...A.InputProps,inputRef:be,endAdornment:N("div",{className:"endAdornments",children:[A.InputProps.endAdornment,!o&&N(Pe,{children:[T(w)?N("div",{className:"editable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>H(w),children:k(ue,{icon:hr,size:"24px",removeMargin:!0})})]}):null,N("div",{className:"creatable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>I(w),children:k(ue,{icon:qe,size:"24px",removeMargin:!0})})]})]})]})},...s})},e)}),k(S,{name:e,disableIcon:p})]})}})});Ne.displayName="Creatable";var vr=Ne;import{Controller as Cr,useFormContext as Tr}from"react-hook-form";import{Grid as Sr,Checkbox as Ir,FormControlLabel as kr}from"@mui/material";import{jsx as ae,jsxs as Rr}from"react/jsx-runtime";var Vr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:h,required:c,disableIconError:y,onChange:C,...u})=>{let f=Tr();if(!f)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ae(Cr,{control:f.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:s,onChange:b}})=>Rr(Sr,{display:"flex",flexDirection:"column",children:[ae(kr,{control:ae(Ir,{checked:!!s,value:s??"",defaultValue:s,onChange:(a,F)=>{b(a,F),C?.(a,F)},...u},e),label:ae(v,{label:l,required:c,regular:!0}),labelPlacement:h||"end"}),ae(S,{name:e,disableIcon:y})]})})},wr=Vr;import{Controller as Er,useFormContext as Lr}from"react-hook-form";import{Grid as Ar,Switch as Br,FormControlLabel as Gr}from"@mui/material";import{jsx as de,jsxs as Dr}from"react/jsx-runtime";var Mr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:h,disableIconError:c,onChange:y,...C})=>{let u=Lr();if(!u)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return de(Er,{control:u.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:f,onChange:s}})=>Dr(Ar,{display:"flex",flexDirection:"column",children:[de(Gr,{control:de(Br,{value:f??"",checked:f??!1,defaultValue:f,onChange:(b,a)=>{s(b,a),y?.(b,a)},...C},e),label:de(v,{label:l}),labelPlacement:h||"end"}),de(S,{name:e,disableIcon:c})]})})},$r=Mr;import{Grid as _r,Radio as qr,FormControlLabel as zr}from"@mui/material";import{jsx as fe}from"react/jsx-runtime";var Or=({label:e,labelPlacement:t,...i})=>fe(_r,{display:"flex",flexDirection:"column",children:fe(zr,{control:fe(qr,{...i}),label:fe(v,{label:e}),labelPlacement:t||"end"})}),Nr=Or;import{Controller as Ur,useFormContext as jr}from"react-hook-form";import{Grid as Hr,RadioGroup as Wr}from"@mui/material";import{jsx as ce,jsxs as Kr}from"react/jsx-runtime";var Yr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,children:c,orientation:y="row",disableIconError:C,...u})=>{let f=jr();if(!f)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ce(Ur,{control:f.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:s,onChange:b}})=>Kr(Hr,{display:"flex",flexDirection:"column",children:[l&&ce(v,{label:l,required:h}),ce(Wr,{value:s||"",name:e,...u,onChange:a=>{u?.onChange?.(a,a.target?.value),b(a)},style:{display:"flex",flexDirection:y},children:c},e),ce(S,{name:e,disableIcon:C})]})})},Jr=Yr;import{Controller as Xr,useFormContext as Qr}from"react-hook-form";import{Slider as Zr}from"@mui/material";import{jsx as Ue}from"react/jsx-runtime";var et=({name:e,rules:t,defaultValue:i,shouldUnregister:n,...l})=>{let h=Qr();if(!h)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Ue(Xr,{control:h.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:c,onChange:y}})=>Ue(Zr,{value:c||l?.min||0,onChange:y,valueLabelDisplay:"auto",...l},e)})},ot=et;import{memo as nt}from"react";import{Controller as at,useFormContext as dt}from"react-hook-form";import{composeValidators as st,date as He}from"@s_mart/rules";import{Grid as pt,TextField as mt}from"@mui/material";import{DatePicker as ut}from"@mui/x-date-pickers/DatePicker";import{AdapterDayjs as ft}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as ct}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as yt}from"@mui/x-date-pickers/locales/ptBR";import xt from"dayjs/locale/pt-br";import rt from"@emotion/styled";import{IconButton as tt}from"@mui/material";import{toRem as U}from"@s_mart/utils";var it=e=>{switch(e){case"small":return U(16);default:case"medium":return U(20);case"large":return U(24)}},lt=e=>{switch(e){case"small":return`${U(2)} ${U(8)}`;default:case"medium":return`${U(6)} ${U(8)}`;case"large":return`${U(10)}`}},je=rt(tt)`
55
55
  margin: 0px;
56
56
 
57
- padding: ${({size:e})=>it(e)};
57
+ padding: ${({size:e})=>lt(e)};
58
58
  border-radius: 0 ${U(4)} ${U(4)} 0;
59
59
 
60
60
  svg {
61
- width: ${({size:e})=>tt(e)} !important;
61
+ width: ${({size:e})=>it(e)} !important;
62
62
  }
63
- `;import{jsx as de,jsxs as gt}from"react/jsx-runtime";import{createElement as bt}from"react";var xt=({rules:e,name:t,defaultValue:i,shouldUnregister:n,datePickerProps:l,label:P,required:c,placeholder:y,disabled:v,disableIconError:u,...f})=>{let a=at();if(!a)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=R(a.formState.errors,t),s=l?.format||"DD/MM/YYYY",g=e?dt([je(s),e]):je(s);return de(ft,{dateAdapter:ut,adapterLocale:yt,localeText:ct.components.MuiLocalizationProvider.defaultProps.localeText,children:de(nt,{control:a.control,name:t,rules:g,defaultValue:i,shouldUnregister:n,render:({field:{value:x,onChange:d,ref:F}})=>gt(st,{display:"flex",flexDirection:"column",children:[P&&de(h,{label:P,required:c}),bt(mt,{...l,key:t,value:x??null,format:s,onChange:(p,m)=>{d(p,m),l?.onChange?.(p,m)},disabled:v,slots:{textField:pt,openPickerButton:p=>de(Ue,{...p,size:f.size})},slotProps:{textField:p=>({variant:"outlined",...p,error:!!b,...f,inputProps:{...p.inputProps,placeholder:y||p.inputProps?.placeholder},InputProps:{...p.InputProps,inputRef(m){F(m),typeof p.inputRef=="function"&&p.inputRef(m)}}})}}),de(S,{name:t,disableIcon:u})]})})})},Ft=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 We}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 Pt from"@emotion/styled";import{IconButton as ht}from"@mui/material";import{toRem as j}from"@s_mart/utils";var vt=e=>{switch(e){case"small":return j(16);default:case"medium":return j(20);case"large":return j(24)}},Ct=e=>{switch(e){case"small":return`${j(2)} ${j(8)}`;default:case"medium":return`${j(6)} ${j(8)}`;case"large":return`${j(10)}`}},He=Pt(ht)`
63
+ `;import{jsx as se,jsxs as ht}from"react/jsx-runtime";import{createElement as gt}from"react";var bt=({rules:e,name:t,defaultValue:i,shouldUnregister:n,datePickerProps:l,label:h,required:c,placeholder:y,disabled:C,disableIconError:u,...f})=>{let s=dt();if(!s)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=R(s.formState.errors,t),a=l?.format||"DD/MM/YYYY",F=e?st([He(a),e]):He(a);return se(ct,{dateAdapter:ft,adapterLocale:xt,localeText:yt.components.MuiLocalizationProvider.defaultProps.localeText,children:se(at,{control:s.control,name:t,rules:F,defaultValue:i,shouldUnregister:n,render:({field:{value:g,onChange:d,ref:x}})=>ht(pt,{display:"flex",flexDirection:"column",children:[h&&se(v,{label:h,required:c}),gt(ut,{...l,key:t,value:g??null,format:a,onChange:(p,m)=>{d(p,m),l?.onChange?.(p,m)},disabled:C,slots:{textField:mt,openPickerButton:p=>se(je,{...p,size:f.size})},slotProps:{textField:p=>({variant:"outlined",...p,error:!!b,...f,inputProps:{...p.inputProps,placeholder:y||p.inputProps?.placeholder},InputProps:{...p.InputProps,inputRef:m=>{x(m),typeof p.inputRef=="function"&&p.inputRef(m)}}})}}),se(S,{name:t,disableIcon:u})]})})})},Ft=nt(bt);import{memo as St}from"react";import{Controller as It,useFormContext as kt}from"react-hook-form";import{composeValidators as Vt,time as Ye}from"@s_mart/rules";import{Grid as wt,TextField as Rt}from"@mui/material";import{TimePicker as Et}from"@mui/x-date-pickers/TimePicker";import{AdapterDayjs as Lt}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as At}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Bt}from"@mui/x-date-pickers/locales/ptBR";import Gt from"dayjs/locale/pt-br";import Pt from"@emotion/styled";import{IconButton as vt}from"@mui/material";import{toRem as j}from"@s_mart/utils";var Ct=e=>{switch(e){case"small":return j(16);default:case"medium":return j(20);case"large":return j(24)}},Tt=e=>{switch(e){case"small":return`${j(2)} ${j(8)}`;default:case"medium":return`${j(6)} ${j(8)}`;case"large":return`${j(10)}`}},We=Pt(vt)`
64
64
  margin: 0px;
65
65
 
66
- padding: ${({size:e})=>Ct(e)};
66
+ padding: ${({size:e})=>Tt(e)};
67
67
  border-radius: 0 ${j(4)} ${j(4)} 0;
68
68
 
69
69
  svg {
70
- width: ${({size:e})=>vt(e)} !important;
70
+ width: ${({size:e})=>Ct(e)} !important;
71
71
  }
72
- `;import{jsx as oe,jsxs as $t}from"react/jsx-runtime";var Gt=({rules:e,defaultValue:t,shouldUnregister:i,name:n,required:l,label:P,timePickerProps:c,placeholder:y,disabled:v,disableIconError:u,...f})=>{let a=St();if(!a)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=R(a.formState.errors,n),s=c?.format||"HH:mm",g=e?kt([We(s),e]):We(s);return oe(Lt,{dateAdapter:Et,adapterLocale:Bt,localeText:At.components.MuiLocalizationProvider.defaultProps.localeText,children:oe(It,{control:a.control,name:n,rules:g,defaultValue:t,shouldUnregister:i,render:({field:{value:x,onChange:d,ref:F}})=>$t(Vt,{display:"flex",flexDirection:"column",children:[P&&oe(h,{label:P,required:l}),oe(Rt,{ampm:!1,format:s,value:x??null,disabled:v,...c,onChange:(p,m)=>{d(p,m),c?.onChange?.(p,m)},slots:{textField:wt,openPickerButton:p=>oe(He,{...p,size:f.size})},slotProps:{textField:p=>({variant:"outlined",...p,error:!!b,...f,inputProps:{...p.inputProps,placeholder:y||p.inputProps?.placeholder},InputProps:{...p.InputProps,inputRef(m){F(m),typeof p.inputRef=="function"&&p.inputRef(m)}}})}},n),oe(S,{name:n,disableIcon:u})]})})})},Mt=Tt(Gt);import{memo as Dt}from"react";import{Controller as _t,useFormContext as qt}from"react-hook-form";import{Grid as ce,Autocomplete as zt,TextField as Ot}from"@mui/material";import{colorPalette as Nt}from"@s_mart/tokens";import{jsx as Q,jsxs as Ye}from"react/jsx-runtime";import{createElement as Ht}from"react";var Ut=({name:e,defaultValue:t,rules:i,shouldUnregister:n,label:l,required:P,noOptionsText:c,placeholder:y,onInputChange:v,onChange:u,disableIconError:f,...a})=>{let b=qt();if(!b)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let s=R(b.formState.errors,e);return console.warn=()=>{},Q(_t,{name:e,control:b.control,defaultValue:t,rules:i,shouldUnregister:n,render:({field:g})=>Ye(ce,{display:"flex",flexDirection:"column",children:[l&&Q(h,{label:l,required:P}),Q(zt,{onChange:(x,d)=>{g.onChange(d),u?.(d,b.getValues())},onInputChange:(x,d,F)=>{F==="input"&&(g.onChange(d),setTimeout(()=>{v?.(d,b.getValues())},0))},slotProps:{...a.slotProps||{},paper:{...(a.slotProps||{}).paper||{},sx:{border:`1px solid ${Nt.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(a.slotProps||{}).paper?.sx||{}}}},isOptionEqualToValue:(x,d)=>x.value===d.value,renderOption:(x,d)=>Ht("li",{...x,key:d.key||d.value,onClick:F=>{x.onClick?.(F),g.onChange(d)}},Ye(ce,{container:!0,direction:"column",children:[Q(ce,{item:!0,children:d.label}),d.afterLabel&&Q(ce,{item:!0,children:d.afterLabel})]})),value:g.value||null,readOnly:a.disabled,noOptionsText:c||"Nenhuma op\xE7\xE3o encontrada",...a,renderInput:x=>Q(Ot,{placeholder:y,...x,...a.textFieldProps,error:!!s,InputProps:{...x.InputProps,...a.textFieldProps?.InputProps,inputRef:g.ref,inputProps:{...x.inputProps,...a.textFieldProps?.InputProps?.inputProps}}})},e),Q(S,{name:e,disableIcon:f})]})})},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 he}from"react/jsx-runtime";var Kt=({title:e})=>he(Wt,{title:e,placement:"top",children:he("div",{style:{width:"fit-content"},children:he(Yt,{icon:Jt,color:"#757575"})})}),Z=Kt;import{Autocomplete as ei,Divider as Je,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 re=Xt;import{Fragment as ve,jsx as _,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:P,options:c,textFieldProps:y,noOptionsText:v,footer:u,multiple:f,info:a,placeholder:b,onChange:s,onInputChange:g,getOptionAfterLabel:x,getOptionLabel:d,getOptionKey:F,...p})=>{let m=Zt();if(!m)throw new Error("Para usar o <SearchableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=R(m.formState.errors,e),{field:A}=Qt({name:e,control:m.control,rules:t,defaultValue:i,shouldUnregister:n});return ee("div",{style:{display:"flex",flexDirection:"column"},children:[ee("div",{style:{display:"flex"},children:[l&&_(h,{label:l,required:P}),a&&_(Z,{title:a})]}),_(ei,{onChange:(o,r)=>{A.onChange(r),s?.(r)},onInputChange:(o,r,C)=>{C==="input"&&g?.(r)},value:A.value?A.value:f?[]:null,options:c,multiple:f,readOnly:p.disabled,slotProps:{...p.slotProps,paper:{...p.slotProps?.paper,sx:{border:`1px solid ${ii.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...p.slotProps?.paper?.sx}}},noOptionsText:ee(ve,{children:[v||"Nenhuma op\xE7\xE3o encontrada",typeof u<"u"?ee(ve,{children:[_("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:_(Je,{})}),u()]}):null]}),isOptionEqualToValue:(o,r)=>ri(o,r),getOptionLabel:o=>d(o),getOptionKey:o=>F(o),renderOption:typeof x=="function"?(o,r)=>{let C=x(r),k=F(r);return ai("li",{...o,key:k},ee("div",{style:{display:"flex",flexDirection:"column"},children:[_("span",{children:d(r)}),typeof C=="string"?_("span",{children:C}):C]}))}:void 0,ListboxComponent:ti(function(r,C){return ee(ve,{children:[_("ul",{...r,ref:C}),typeof u<"u"?ee("div",{...r,children:[_("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:_(Je,{})}),u()]},"searchable-footer"):null]})}),...p,renderInput:o=>_(oi,{error:!!L,placeholder:b,...o,...y,inputRef:A.ref})},e),_(S,{name:e})]})},ni=re(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 Fi,MenuItem as bi,Divider as gi}from"@mui/material";import{colorPalette as di}from"@s_mart/tokens";import{jsx as si}from"react/jsx-runtime";var Ke=({value:e,placeholder:t,getOptionLabel:i})=>e===null||e?.length===0?si("p",{style:{color:di.neutral[100]},children:t}):i(e);import{Fragment as vi,jsx as z,jsxs as te}from"react/jsx-runtime";var Pi=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,options:c,placeholder:y,clearable:v,info:u,footer:f,onChange:a,variant:b="outlined",getOptionKey:s,getOptionLabel:g,getOptionAfterLabel:x,...d})=>{let F=ui(),[p,m]=pi(!1);if(!F)throw new Error("Para usar o <SelectV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=R(F.formState.errors,e),{field:A}=mi({control:F.control,name:e,rules:t,defaultValue:i,shouldUnregister:n});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[l&&z(h,{label:l,required:P}),u&&z(Z,{title:u})]}),te(Fi,{open:p,onOpen:()=>m(!0),onClose:()=>m(!1),displayEmpty:!!y,variant:b,autoComplete:"off",value:A.value||null,renderValue:o=>z(Ke,{getOptionLabel:g,placeholder:y,value:o}),onChange:o=>{A.onChange(o.target.value),a?.(o.target.value)},error:!!L,size:d.size||"medium",inputRef:A.ref,...d,endAdornment:te(vi,{children:[d.endAdornment,!!(v&&A.value)&&z(fi,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{A.onChange(null),a?.(null)},children:z(ci,{icon:yi,color:xi.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c.map(o=>{let r=s(o),C=g(o);return z(bi,{value:o,children:te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[C,z("span",{children:x?.(o)??null})]})},r)}),f!==void 0&&te("div",{children:[z("div",{style:{padding:"8px 16px"},children:z(gi,{})},"footer-divider"),z("div",{children:f({closeSelect:()=>m(!1)})},"footer-content")]},"footer")]},e),z(S,{name:e})]})},hi=re(Pi);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 Ze}from"@mui/material";import{LIcon as Ce,Button as Gi}from"@s_mart/core";import{colorPalette as Mi}from"@s_mart/tokens";import{linePlus as eo,linePen as $i}from"@s_mart/solid-icons";import{toRem as oo}from"@s_mart/utils";import{toRem as ye}from"@s_mart/utils";import Ci from"@emotion/styled";import{css as Ti}from"@emotion/react";var Xe=Ti`
72
+ `;import{jsx as oe,jsxs as Dt}from"react/jsx-runtime";var Mt=({rules:e,defaultValue:t,shouldUnregister:i,name:n,required:l,label:h,timePickerProps:c,placeholder:y,disabled:C,disableIconError:u,...f})=>{let s=kt();if(!s)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=R(s.formState.errors,n),a=c?.format||"HH:mm",F=e?Vt([Ye(a),e]):Ye(a);return oe(At,{dateAdapter:Lt,adapterLocale:Gt,localeText:Bt.components.MuiLocalizationProvider.defaultProps.localeText,children:oe(It,{control:s.control,name:n,rules:F,defaultValue:t,shouldUnregister:i,render:({field:{value:g,onChange:d,ref:x}})=>Dt(wt,{display:"flex",flexDirection:"column",children:[h&&oe(v,{label:h,required:l}),oe(Et,{ampm:!1,format:a,value:g??null,disabled:C,...c,onChange:(p,m)=>{d(p,m),c?.onChange?.(p,m)},slots:{textField:Rt,openPickerButton:p=>oe(We,{...p,size:f.size})},slotProps:{textField:p=>({variant:"outlined",...p,error:!!b,...f,inputProps:{...p.inputProps,placeholder:y||p.inputProps?.placeholder},InputProps:{...p.InputProps,inputRef:m=>{x(m),typeof p.inputRef=="function"&&p.inputRef(m)}}})}},n),oe(S,{name:n,disableIcon:u})]})})})},$t=St(Mt);import{memo as _t}from"react";import{Controller as qt,useFormContext as zt}from"react-hook-form";import{Grid as ye,Autocomplete as Ot,TextField as Nt}from"@mui/material";import{colorPalette as Ut}from"@s_mart/tokens";import{jsx as Q,jsxs as Je}from"react/jsx-runtime";import{createElement as Wt}from"react";var jt=({name:e,defaultValue:t,rules:i,shouldUnregister:n,label:l,required:h,noOptionsText:c,placeholder:y,onInputChange:C,onChange:u,disableIconError:f,...s})=>{let b=zt();if(!b)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let a=R(b.formState.errors,e);return console.warn=()=>{},Q(qt,{name:e,control:b.control,defaultValue:t,rules:i,shouldUnregister:n,render:({field:F})=>Je(ye,{display:"flex",flexDirection:"column",children:[l&&Q(v,{label:l,required:h}),Q(Ot,{onChange:(g,d)=>{F.onChange(d),u?.(d,b.getValues())},onInputChange:(g,d,x)=>{x==="input"&&(F.onChange(d),setTimeout(()=>{C?.(d,b.getValues())},0))},slotProps:{...s.slotProps||{},paper:{...s.slotProps?.paper||{},sx:{border:`1px solid ${Ut.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(g,d)=>g.value===d.value,renderOption:(g,d)=>Wt("li",{...g,key:d.key||d.value,onClick:x=>{g.onClick?.(x),F.onChange(d)}},Je(ye,{container:!0,direction:"column",children:[Q(ye,{item:!0,children:d.label}),d.afterLabel&&Q(ye,{item:!0,children:d.afterLabel})]})),value:F.value||null,readOnly:s.disabled,noOptionsText:c||"Nenhuma op\xE7\xE3o encontrada",...s,renderInput:g=>Q(Nt,{placeholder:y,...g,error:!!a,slotProps:{input:{inputProps:g.inputProps,inputRef:F.ref}}})},e),Q(S,{name:e,disableIcon:f})]})})},Ht=_t(jt);import{useController as Zt,useFormContext as ei}from"react-hook-form";import{Tooltip as Yt}from"@mui/material";import{LIcon as Jt}from"@s_mart/core";import{lineInfoCircle as Kt}from"@s_mart/solid-icons";import{jsx as ve}from"react/jsx-runtime";var Xt=({title:e})=>ve(Yt,{title:e,placement:"top",children:ve("div",{style:{width:"fit-content"},children:ve(Jt,{icon:Kt,color:"#757575"})})}),Z=Xt;import{Autocomplete as oi,Divider as Ke,TextField as ri}from"@mui/material";import{isEqual as ti}from"lodash-es";import{forwardRef as ii}from"react";import{colorPalette as li}from"@s_mart/tokens";import{memo as Qt}from"react";var re=Qt;import{Fragment as Ce,jsx as _,jsxs as ee}from"react/jsx-runtime";import{createElement as di}from"react";var ni=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,options:c,textFieldProps:y,noOptionsText:C,footer:u,multiple:f,info:s,placeholder:b,onChange:a,onInputChange:F,getOptionAfterLabel:g,getOptionLabel:d,getOptionKey:x,...p})=>{let m=ei();if(!m)throw new Error("Para usar o <SearchableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let E=R(m.formState.errors,e),{field:L}=Zt({name:e,control:m.control,rules:t,defaultValue:i,shouldUnregister:n});return ee("div",{style:{display:"flex",flexDirection:"column"},children:[ee("div",{style:{display:"flex"},children:[l&&_(v,{label:l,required:h}),s&&_(Z,{title:s})]}),_(oi,{onChange:(o,r)=>{L.onChange(r),a?.(r)},onInputChange:(o,r,T)=>{T==="input"&&F?.(r)},value:L.value?L.value:f?[]:null,options:c,multiple:f,readOnly:p.disabled,slotProps:{...p.slotProps,paper:{...p.slotProps?.paper,sx:{border:`1px solid ${li.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},noOptionsText:ee(Ce,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof u<"u"?ee(Ce,{children:[_("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:_(Ke,{})}),u()]}):null]}),isOptionEqualToValue:(o,r)=>ti(o,r),getOptionLabel:o=>d(o),getOptionKey:o=>x(o),renderOption:typeof g=="function"?(o,r)=>{let T=g(r),I=x(r);return di("li",{...o,key:I},ee("div",{style:{display:"flex",flexDirection:"column"},children:[_("span",{children:d(r)}),typeof T=="string"?_("span",{children:T}):T]}))}:void 0,ListboxComponent:ii(function(r,T){return ee(Ce,{children:[_("ul",{...r,ref:T}),typeof u<"u"?ee("div",{...r,children:[_("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:_(Ke,{})}),u()]},"searchable-footer"):null]})}),...p,renderInput:o=>_(ri,{error:!!E,placeholder:b,...o,...y,inputRef:L.ref})},e),_(S,{name:e})]})},ai=re(ni);import{useState as mi}from"react";import{useController as ui,useFormContext as fi}from"react-hook-form";import{IconButton as ci,LIcon as yi}from"@s_mart/core";import{lineTimes as xi}from"@s_mart/regular-icons";import{colorPalette as bi}from"@s_mart/tokens";import{Select as Fi,MenuItem as gi,Divider as hi}from"@mui/material";import{colorPalette as si}from"@s_mart/tokens";import{jsx as pi}from"react/jsx-runtime";var Xe=({value:e,placeholder:t,getOptionLabel:i})=>e===null||e?.length===0?pi("p",{style:{color:si.neutral[100]},children:t}):i(e);import{Fragment as Ci,jsx as z,jsxs as te}from"react/jsx-runtime";var Pi=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,options:c,placeholder:y,clearable:C,info:u,footer:f,onChange:s,variant:b="outlined",getOptionKey:a,getOptionLabel:F,getOptionAfterLabel:g,...d})=>{let x=fi(),[p,m]=mi(!1);if(!x)throw new Error("Para usar o <SelectV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let E=R(x.formState.errors,e),{field:L}=ui({control:x.control,name:e,rules:t,defaultValue:i,shouldUnregister:n});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[l&&z(v,{label:l,required:h}),u&&z(Z,{title:u})]}),te(Fi,{open:p,onOpen:()=>m(!0),onClose:()=>m(!1),displayEmpty:!!y,variant:b,autoComplete:"off",value:L.value||null,renderValue:o=>z(Xe,{getOptionLabel:F,placeholder:y,value:o}),onChange:o=>{L.onChange(o.target.value),s?.(o.target.value)},error:!!E,size:d.size||"medium",inputRef:L.ref,...d,endAdornment:te(Ci,{children:[d.endAdornment,!!(C&&L.value)&&z(ci,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{L.onChange(null),s?.(null)},children:z(yi,{icon:xi,color:bi.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c.map(o=>{let r=a(o),T=F(o);return z(gi,{value:o,children:te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[T,z("span",{children:g?.(o)??null})]})},r)}),f!==void 0&&te("div",{children:[z("div",{style:{padding:"8px 16px"},children:z(hi,{})},"footer-divider"),z("div",{children:f({closeSelect:()=>m(!1)})},"footer-content")]},"footer")]},e),z(S,{name:e})]})},vi=re(Pi);import{forwardRef as Ii,useCallback as ki,useState as Vi}from"react";import{useController as wi,useFormContext as Ri}from"react-hook-form";import{isObject as Ei,isEmpty as Li,isEqual as Ai}from"lodash-es";import{Autocomplete as Bi,TextField as Gi,Divider as eo}from"@mui/material";import{LIcon as Te,Button as Mi}from"@s_mart/core";import{colorPalette as $i}from"@s_mart/tokens";import{linePlus as oo,linePen as Di}from"@s_mart/solid-icons";import{toRem as ro}from"@s_mart/utils";import{toRem as xe}from"@s_mart/utils";import Ti from"@emotion/styled";import{css as Si}from"@emotion/react";var Qe=Si`
73
73
  display: flex;
74
74
  align-items: center;
75
75
  justify-content: center;
76
- `,Qe=Ci.div`
76
+ `,Ze=Ti.div`
77
77
  display: flex;
78
78
 
79
79
  div.endAdornments {
80
80
  position: absolute;
81
81
  right: 0;
82
82
 
83
- ${Xe}
83
+ ${Qe}
84
84
  }
85
85
 
86
86
  .MuiAutocomplete-endAdornment {
@@ -94,11 +94,11 @@ import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-
94
94
 
95
95
  .creatable,
96
96
  .editable {
97
- ${Xe}
97
+ ${Qe}
98
98
 
99
99
  .divider {
100
100
  width: 1px;
101
- height: ${ye(20)};
101
+ height: ${xe(20)};
102
102
  background-color: ${({theme:e})=>e.palette.grey[400]};
103
103
  }
104
104
 
@@ -109,9 +109,9 @@ import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-
109
109
  color: ${({theme:e})=>e.palette.grey[600]};
110
110
  border-radius: 50%;
111
111
 
112
- margin: 0 ${ye(6)};
113
- width: ${ye(28)};
114
- height: ${ye(28)};
112
+ margin: 0 ${xe(6)};
113
+ width: ${xe(28)};
114
+ height: ${xe(28)};
115
115
 
116
116
  &:hover {
117
117
  cursor: pointer;
@@ -120,4 +120,4 @@ import{FormProvider as to}from"react-hook-form";import{jsx as Ie}from"react/jsx-
120
120
  }
121
121
  }
122
122
  }
123
- `;import{Fragment as Te,jsx as G,jsxs as O}from"react/jsx-runtime";import{createElement as qi}from"react";var Di=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:P,options:c,footer:y,showCreatableButton:v=!0,showEditableButton:u,onEditOption:f,onCreateOption:a,getOptionKey:b,getOptionLabel:s,getOptionAfterLabel:g,textFieldProps:x,multiple:d,info:F,noOptionsText:p,onChange:m,onInputChange:L,placeholder:A,...o})=>{let[r,C]=ki(""),k=wi();if(!k)throw new Error("Para usar o <CreatableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let H=R(k.formState.errors,e),w=!v||o.disabled,{field:D}=Vi({name:e,control:k.control,rules:t,defaultValue:i,shouldUnregister:n}),xe=I=>{let B=0;return x?.InputProps||(B+=2.5),w||(B+=2.56,ie(I)&&(B+=2.56)),!o.disableClearable&&!o.disabled&&(B+=1.3),B+"rem"},ie=I=>o.disabled?!1:u&&Ri(I)&&!Ei(I),E=Si(()=>{typeof a<"u"&&(a(r),C(""))},[r]),T=I=>{f?.(I)};return O("div",{style:{display:"flex",flexDirection:"column"},children:[O("div",{style:{display:"flex"},children:[l&&G(h,{label:l,required:P}),F&&G(Z,{title:F})]}),G(Qe,{children:G(Ai,{fullWidth:!0,onChange:(I,B)=>{C(""),D.onChange(B),m?.(B)},onInputChange:(I,B,Y)=>{Y==="input"&&(C(B),L?.(B))},slotProps:{...o.slotProps,paper:{...o.slotProps?.paper,sx:{border:`1px solid ${Mi.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...o.slotProps?.paper?.sx}}},value:D.value?D.value:d?[]:null,options:c,multiple:d,readOnly:o.disabled,noOptionsText:O(Te,{children:[p||"Nenhuma op\xE7\xE3o encontrada",!w&&O(Gi,{sx:{justifyContent:"flex-start",padding:`${oo(6)} ${oo(-16)}`,margin:0},fullWidth:!0,onClick:E,variant:"text",startIcon:G(Ce,{icon:eo}),children:["Adicionar ",`"${r}"`]}),typeof y<"u"&&O(Te,{children:[G("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:G(Ze,{})}),y()]})]}),isOptionEqualToValue:(I,B)=>Li(I,B),getOptionLabel:I=>s(I),getOptionKey:I=>b(I),renderOption:typeof g=="function"?(I,B)=>{let Y=g(B),ro=b(B);return qi("li",{...I,key:ro},O("div",{style:{display:"flex",flexDirection:"column"},children:[G("span",{children:s(B)}),typeof Y=="string"?G("span",{children:Y}):Y]}))}:void 0,ListboxComponent:Ii(function(B,Y){return O(Te,{children:[G("ul",{...B,ref:Y}),typeof y<"u"?O("div",{...B,children:[G("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:G(Ze,{})}),y()]},"creatable-footer"):null]})}),...o,sx:{"& div.MuiInputBase-root":{paddingRight:`${xe(D.value)} !important`},...o.sx},onBlur:I=>{o?.onBlur?.(I),C("")},renderInput:I=>G(Bi,{placeholder:A,...I,error:!!H,...x,InputProps:{...I.InputProps,...x?.InputProps,inputRef:D.ref,endAdornment:O("div",{className:"endAdornments",children:[I.InputProps.endAdornment,x?.InputProps?.endAdornment??null,ie(D.value)?O("div",{className:"editable",children:[G("div",{className:"divider"}),G("div",{className:"button",onClick:()=>T(D.value),children:G(Ce,{icon:$i,size:"24px",removeMargin:!0})})]}):null,v&&O("div",{className:"creatable",children:[G("div",{className:"divider"}),G("div",{className:"button",onClick:E,children:G(Ce,{icon:eo,size:"24px",removeMargin:!0})})]})]})}})},e)}),G(S,{name:e})]})},_i=re(Di);export{jt as Autocomplete,Vr as Checkbox,hr as Creatable,_i as CreatableV2,Ft as DatePicker,h as FieldLabel,mo as Form,Fe as FormProvider,Or as RadioButton,Yr as RadioGroup,ir as Searchable,ni as SearchableV2,Ho as Select,hi as SelectV2,et as Slider,Mr as Switch,Lo as TextField,Mt as TimePicker,be as useForm};
123
+ `;import{Fragment as Se,jsx as G,jsxs as O}from"react/jsx-runtime";import{createElement as zi}from"react";var _i=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:h,options:c,footer:y,showCreatableButton:C=!0,showEditableButton:u,onEditOption:f,onCreateOption:s,getOptionKey:b,getOptionLabel:a,getOptionAfterLabel:F,textFieldProps:g,multiple:d,info:x,noOptionsText:p,onChange:m,onInputChange:E,placeholder:L,...o})=>{let[r,T]=Vi(""),I=Ri();if(!I)throw new Error("Para usar o <CreatableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let H=R(I.formState.errors,e),w=!C||o.disabled,{field:D}=wi({name:e,control:I.control,rules:t,defaultValue:i,shouldUnregister:n}),be=V=>{let B=0;return g?.InputProps||(B+=2.5),w||(B+=2.56,ie(V)&&(B+=2.56)),!o.disableClearable&&!o.disabled&&(B+=1.3),B+"rem"},ie=V=>o.disabled?!1:u&&Ei(V)&&!Li(V),A=()=>o.disabled?!1:C,P=ki(()=>{typeof s<"u"&&(s(r),T(""))},[r]),le=V=>{f?.(V)};return O("div",{style:{display:"flex",flexDirection:"column"},children:[O("div",{style:{display:"flex"},children:[l&&G(v,{label:l,required:h}),x&&G(Z,{title:x})]}),G(Ze,{children:G(Bi,{fullWidth:!0,onChange:(V,B)=>{T(""),D.onChange(B),m?.(B)},onInputChange:(V,B,Y)=>{Y==="input"&&(T(B),E?.(B))},slotProps:{...o.slotProps,paper:{...o.slotProps?.paper,sx:{border:`1px solid ${$i.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},value:D.value?D.value:d?[]:null,options:c,multiple:d,readOnly:o.disabled,noOptionsText:O(Se,{children:[p||"Nenhuma op\xE7\xE3o encontrada",!w&&O(Mi,{sx:{justifyContent:"flex-start",padding:`${ro(6)} ${ro(-16)}`,margin:0},fullWidth:!0,onClick:P,variant:"text",startIcon:G(Te,{icon:oo}),children:["Adicionar ",`"${r}"`]}),typeof y<"u"&&O(Se,{children:[G("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:G(eo,{})}),y()]})]}),isOptionEqualToValue:(V,B)=>Ai(V,B),getOptionLabel:V=>a(V),getOptionKey:V=>b(V),renderOption:typeof F=="function"?(V,B)=>{let Y=F(B),to=b(B);return zi("li",{...V,key:to},O("div",{style:{display:"flex",flexDirection:"column"},children:[G("span",{children:a(B)}),typeof Y=="string"?G("span",{children:Y}):Y]}))}:void 0,ListboxComponent:Ii(function(B,Y){return O(Se,{children:[G("ul",{...B,ref:Y}),typeof y<"u"?O("div",{...B,children:[G("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:G(eo,{})}),y()]},"creatable-footer"):null]})}),...o,sx:{"& div.MuiInputBase-root":{paddingRight:`${be(D.value)} !important`},...o.sx},onBlur:V=>{o?.onBlur?.(V),T("")},renderInput:V=>G(Gi,{placeholder:L,...V,error:!!H,...g,InputProps:{...V.InputProps,...g?.InputProps,inputRef:D.ref,endAdornment:O("div",{className:"endAdornments",children:[V.InputProps.endAdornment,g?.InputProps?.endAdornment??null,ie(D.value)?O("div",{className:"editable",children:[G("div",{className:"divider"}),G("div",{className:"button",onClick:()=>le(D.value),children:G(Te,{icon:Di,size:"24px",removeMargin:!0})})]}):null,A()&&O("div",{className:"creatable",children:[G("div",{className:"divider"}),G("div",{className:"button",onClick:P,children:G(Te,{icon:oo,size:"24px",removeMargin:!0})})]})]})}})},e)}),G(S,{name:e})]})},qi=re(_i);export{Ht as Autocomplete,wr as Checkbox,vr as Creatable,qi as CreatableV2,Ft as DatePicker,v as FieldLabel,uo as Form,Fe as FormProvider,Nr as RadioButton,Jr as RadioGroup,lr as Searchable,ai as SearchableV2,Wo as Select,vi as SelectV2,ot as Slider,$r as Switch,Ao as TextField,$t as TimePicker,ge as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "7.2.7",
3
+ "version": "8.0.0-next.0",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -11,50 +11,51 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "@hookform/resolvers": "^3.1.0",
14
- "dayjs": "^1.11.10",
15
- "@types/react": ">=18.3.1",
16
- "@types/react-dom": ">=18.3.0",
17
- "@types/lodash-es": ">=4.17.12",
18
14
  "lodash-es": "^4.17.21",
19
15
  "tsup": "8.0.2",
20
- "typescript": ">=5.4.2",
21
- "@s_mart/core": "7.0.3",
22
- "@s_mart/masks": "5.1.2",
23
- "eslint-config-smarten": "4.1.0",
24
- "@s_mart/rules": "5.1.1",
25
- "@s_mart/solid-icons": "5.2.1",
26
- "@s_mart/regular-icons": "5.3.0",
27
- "@s_mart/tokens": "5.1.0",
28
- "@s_mart/typed": "6.0.0",
29
- "@s_mart/utils": "5.1.1"
16
+ "@s_mart/regular-icons": "5.3.1",
17
+ "@s_mart/solid-icons": "5.2.1"
30
18
  },
31
19
  "peerDependencies": {
32
20
  "@emotion/react": "^11.11.4",
33
- "@emotion/styled": ">=11.11.5",
34
- "@mui/material": ">=5.15.12",
21
+ "@emotion/styled": "^11.13.0",
22
+ "@mui/material": "^6.1.3",
35
23
  "@mui/x-date-pickers": ">=6.3.0",
24
+ "@types/lodash-es": ">=4.17.12",
25
+ "@types/node": ">=20.0.0",
36
26
  "@types/react": ">=18.3.1",
37
27
  "@types/react-dom": ">=18.3.0",
38
- "@types/lodash-es": ">=4.17.12",
39
28
  "dayjs": "^1.11.10",
40
29
  "react": ">=18.3.1",
41
30
  "react-dom": ">=18.3.1",
42
31
  "react-hook-form": "^7.51.0",
43
32
  "typescript": ">=5.4.2",
44
33
  "zod": ">=3.21.4",
45
- "@s_mart/core": "7.0.3",
46
- "@s_mart/masks": "5.1.2",
34
+ "@s_mart/core": "8.0.0-next.0",
47
35
  "@s_mart/rules": "5.1.1",
48
36
  "@s_mart/tokens": "5.1.0",
37
+ "@s_mart/masks": "5.1.2",
49
38
  "@s_mart/typed": "6.0.0",
50
39
  "@s_mart/utils": "5.1.1"
51
40
  },
52
41
  "devDependencies": {
53
- "eslint": "^8.47.0"
42
+ "@emotion/styled": "^11.13.0",
43
+ "@mui/material": "^6.1.3",
44
+ "@types/node": ">=20.0.0",
45
+ "@types/lodash-es": ">=4.17.12",
46
+ "@types/react": ">=18.3.1",
47
+ "@types/react-dom": ">=18.3.0",
48
+ "dayjs": "^1.11.10",
49
+ "typescript": ">=5.4.2",
50
+ "@s_mart/core": "8.0.0-next.0",
51
+ "@s_mart/masks": "5.1.2",
52
+ "@s_mart/rules": "5.1.1",
53
+ "@s_mart/tokens": "5.1.0",
54
+ "@s_mart/typed": "6.0.0",
55
+ "@s_mart/utils": "5.1.1"
54
56
  },
55
57
  "scripts": {
56
58
  "build": "tsup src/index.tsx --minify --format esm --dts --external react",
57
- "dev": "tsup src/index.tsx --format esm --watch --dts --external react",
58
- "lint": "eslint src/**/*.ts* --fix"
59
+ "dev": "tsup src/index.tsx --format esm --watch --dts --external react"
59
60
  }
60
61
  }