@s_mart/form 4.4.2 → 5.0.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.ts +4 -1
- package/dist/index.mjs +22 -22
- package/package.json +28 -24
package/dist/index.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ type TextFieldProps = TextFieldProps$1 & ControllerTextField & {
|
|
|
110
110
|
|
|
111
111
|
declare const _default$6: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, mask, variant, info, parse, inputMode, format, onInputChange, disableIconError, ...rest }: TextFieldProps) => react_jsx_runtime.JSX.Element>;
|
|
112
112
|
|
|
113
|
-
declare const _default$5: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, disableOnChangeForm, multiple, info, footer, onChange: onChangeProp, disableIconError, ...rest }: SelectProps) => react_jsx_runtime.JSX.Element>;
|
|
113
|
+
declare const _default$5: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, disableOnChangeForm, multiple, info, footer, onChange: onChangeProp, disableIconError, variant, ...rest }: SelectProps) => react_jsx_runtime.JSX.Element>;
|
|
114
114
|
|
|
115
115
|
type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
|
|
116
116
|
type SelectOption = {
|
|
@@ -240,6 +240,7 @@ type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, tr
|
|
|
240
240
|
* <TextField disableIconError />
|
|
241
241
|
*/
|
|
242
242
|
disableIconError?: boolean;
|
|
243
|
+
placeholder?: string;
|
|
243
244
|
};
|
|
244
245
|
|
|
245
246
|
declare const _default$4: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, textFieldProps, noOptionsText, footer, multiple, info, placeholder, onChange: onChangeProp, onInputChange, disableIconError, ...rest }: SearchableProps) => react_jsx_runtime.JSX.Element>;
|
|
@@ -340,6 +341,7 @@ type CreatableProps = Omit<AutocompleteProps$1<CreatableOption, true, true, true
|
|
|
340
341
|
* <TextField disableIconError />
|
|
341
342
|
*/
|
|
342
343
|
disableIconError?: boolean;
|
|
344
|
+
placeholder?: string;
|
|
343
345
|
};
|
|
344
346
|
|
|
345
347
|
declare const _default$3: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, editable, footer, onEditOption, onCreateOption, textFieldProps, hideAddButton, multiple, info, onChange: onChangeProp, onInputChange, placeholder, disableIconError, ...rest }: CreatableProps) => react_jsx_runtime.JSX.Element>;
|
|
@@ -584,6 +586,7 @@ type AutocompleteProps<T = any> = Omit<UseControllerProps, 'control'> & Omit<Aut
|
|
|
584
586
|
* <TextField disableIconError />
|
|
585
587
|
*/
|
|
586
588
|
disableIconError?: boolean;
|
|
589
|
+
placeholder?: string;
|
|
587
590
|
};
|
|
588
591
|
|
|
589
592
|
declare const _default: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, disableIconError, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
var o0=Object.create;var A1=Object.defineProperty;var n0=Object.getOwnPropertyDescriptor;var h0=Object.getOwnPropertyNames;var s0=Object.getPrototypeOf,t0=Object.prototype.hasOwnProperty;var F1=(l,c)=>()=>(c||l((c={exports:{}}).exports,c),c.exports);var v0=(l,c,v,d)=>{if(c&&typeof c=="object"||typeof c=="function")for(let h of h0(c))!t0.call(l,h)&&h!==v&&A1(l,h,{get:()=>c[h],enumerable:!(d=n0(c,h))||d.enumerable});return l};var P1=(l,c,v)=>(v=l!=null?o0(s0(l)):{},v0(c||!l||!l.__esModule?A1(v,"default",{value:l,enumerable:!0}):v,l));var K1=F1((z1,b1)=>{(function(l,c){typeof z1=="object"&&typeof b1<"u"?b1.exports=c():typeof define=="function"&&define.amd?define(c):(l=typeof globalThis<"u"?globalThis:l||self).dayjs=c()})(z1,function(){"use strict";var l=1e3,c=6e4,v=36e5,d="millisecond",h="second",y="minute",H="hour",g="day",x="week",u="month",z="quarter",m="year",L="date",f="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,C=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,Z={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(o){var i=["th","st","nd","rd"],e=o%100;return"["+o+(i[(e-20)%10]||i[e]||i[0])+"]"}},F=function(o,i,e){var s=String(o);return!s||s.length>=i?o:""+Array(i+1-s.length).join(e)+o},V={s:F,z:function(o){var i=-o.utcOffset(),e=Math.abs(i),s=Math.floor(e/60),a=e%60;return(i<=0?"+":"-")+F(s,2,"0")+":"+F(a,2,"0")},m:function o(i,e){if(i.date()<e.date())return-o(e,i);var s=12*(e.year()-i.year())+(e.month()-i.month()),a=i.clone().add(s,u),r=e-a<0,q=i.clone().add(s+(r?-1:1),u);return+(-(s+(e-a)/(r?a-q:q-a))||0)},a:function(o){return o<0?Math.ceil(o)||0:Math.floor(o)},p:function(o){return{M:u,y:m,w:x,d:g,D:L,h:H,m:y,s:h,ms:d,Q:z}[o]||String(o||"").toLowerCase().replace(/s$/,"")},u:function(o){return o===void 0}},M="en",w={};w[M]=Z;var U=function(o){return o instanceof E},p=function o(i,e,s){var a;if(!i)return M;if(typeof i=="string"){var r=i.toLowerCase();w[r]&&(a=r),e&&(w[r]=e,a=r);var q=i.split("-");if(!a&&q.length>1)return o(q[0])}else{var k=i.name;w[k]=i,a=k}return!s&&a&&(M=a),a||!s&&M},n=function(o,i){if(U(o))return o.clone();var e=typeof i=="object"?i:{};return e.date=o,e.args=arguments,new E(e)},t=V;t.l=p,t.i=U,t.w=function(o,i){return n(o,{locale:i.$L,utc:i.$u,x:i.$x,$offset:i.$offset})};var E=function(){function o(e){this.$L=p(e.locale,null,!0),this.parse(e)}var i=o.prototype;return i.parse=function(e){this.$d=function(s){var a=s.date,r=s.utc;if(a===null)return new Date(NaN);if(t.u(a))return new Date;if(a instanceof Date)return new Date(a);if(typeof a=="string"&&!/Z$/i.test(a)){var q=a.match(b);if(q){var k=q[2]-1||0,S=(q[7]||"0").substring(0,3);return r?new Date(Date.UTC(q[1],k,q[3]||1,q[4]||0,q[5]||0,q[6]||0,S)):new Date(q[1],k,q[3]||1,q[4]||0,q[5]||0,q[6]||0,S)}}return new Date(a)}(e),this.$x=e.x||{},this.init()},i.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},i.$utils=function(){return t},i.isValid=function(){return this.$d.toString()!==f},i.isSame=function(e,s){var a=n(e);return this.startOf(s)<=a&&a<=this.endOf(s)},i.isAfter=function(e,s){return n(e)<this.startOf(s)},i.isBefore=function(e,s){return this.endOf(s)<n(e)},i.$g=function(e,s,a){return t.u(e)?this[s]:this.set(a,e)},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this.$d.getTime()},i.startOf=function(e,s){var a=this,r=!!t.u(s)||s,q=t.p(e),k=function(l1,G){var N=t.w(a.$u?Date.UTC(a.$y,G,l1):new Date(a.$y,G,l1),a);return r?N:N.endOf(g)},S=function(l1,G){return t.w(a.toDate()[l1].apply(a.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(G)),a)},D=this.$W,I=this.$M,O=this.$D,r1="set"+(this.$u?"UTC":"");switch(q){case m:return r?k(1,0):k(31,11);case u:return r?k(1,I):k(0,I+1);case x:var X=this.$locale().weekStart||0,n1=(D<X?D+7:D)-X;return k(r?O-n1:O+(6-n1),I);case g:case L:return S(r1+"Hours",0);case H:return S(r1+"Minutes",1);case y:return S(r1+"Seconds",2);case h:return S(r1+"Milliseconds",3);default:return this.clone()}},i.endOf=function(e){return this.startOf(e,!1)},i.$set=function(e,s){var a,r=t.p(e),q="set"+(this.$u?"UTC":""),k=(a={},a[g]=q+"Date",a[L]=q+"Date",a[u]=q+"Month",a[m]=q+"FullYear",a[H]=q+"Hours",a[y]=q+"Minutes",a[h]=q+"Seconds",a[d]=q+"Milliseconds",a)[r],S=r===g?this.$D+(s-this.$W):s;if(r===u||r===m){var D=this.clone().set(L,1);D.$d[k](S),D.init(),this.$d=D.set(L,Math.min(this.$D,D.daysInMonth())).$d}else k&&this.$d[k](S);return this.init(),this},i.set=function(e,s){return this.clone().$set(e,s)},i.get=function(e){return this[t.p(e)]()},i.add=function(e,s){var a,r=this;e=Number(e);var q=t.p(s),k=function(I){var O=n(r);return t.w(O.date(O.date()+Math.round(I*e)),r)};if(q===u)return this.set(u,this.$M+e);if(q===m)return this.set(m,this.$y+e);if(q===g)return k(1);if(q===x)return k(7);var S=(a={},a[y]=c,a[H]=v,a[h]=l,a)[q]||1,D=this.$d.getTime()+e*S;return t.w(D,this)},i.subtract=function(e,s){return this.add(-1*e,s)},i.format=function(e){var s=this,a=this.$locale();if(!this.isValid())return a.invalidDate||f;var r=e||"YYYY-MM-DDTHH:mm:ssZ",q=t.z(this),k=this.$H,S=this.$m,D=this.$M,I=a.weekdays,O=a.months,r1=a.meridiem,X=function(G,N,h1,m1){return G&&(G[N]||G(s,r))||h1[N].slice(0,m1)},n1=function(G){return t.s(k%12||12,G,"0")},l1=r1||function(G,N,h1){var m1=G<12?"AM":"PM";return h1?m1.toLowerCase():m1};return r.replace(C,function(G,N){return N||function(h1){switch(h1){case"YY":return String(s.$y).slice(-2);case"YYYY":return t.s(s.$y,4,"0");case"M":return D+1;case"MM":return t.s(D+1,2,"0");case"MMM":return X(a.monthsShort,D,O,3);case"MMMM":return X(O,D);case"D":return s.$D;case"DD":return t.s(s.$D,2,"0");case"d":return String(s.$W);case"dd":return X(a.weekdaysMin,s.$W,I,2);case"ddd":return X(a.weekdaysShort,s.$W,I,3);case"dddd":return I[s.$W];case"H":return String(k);case"HH":return t.s(k,2,"0");case"h":return n1(1);case"hh":return n1(2);case"a":return l1(k,S,!0);case"A":return l1(k,S,!1);case"m":return String(S);case"mm":return t.s(S,2,"0");case"s":return String(s.$s);case"ss":return t.s(s.$s,2,"0");case"SSS":return t.s(s.$ms,3,"0");case"Z":return q}return null}(G)||q.replace(":","")})},i.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},i.diff=function(e,s,a){var r,q=this,k=t.p(s),S=n(e),D=(S.utcOffset()-this.utcOffset())*c,I=this-S,O=function(){return t.m(q,S)};switch(k){case m:r=O()/12;break;case u:r=O();break;case z:r=O()/3;break;case x:r=(I-D)/6048e5;break;case g:r=(I-D)/864e5;break;case H:r=I/v;break;case y:r=I/c;break;case h:r=I/l;break;default:r=I}return a?r:t.a(r)},i.daysInMonth=function(){return this.endOf(u).$D},i.$locale=function(){return w[this.$L]},i.locale=function(e,s){if(!e)return this.$L;var a=this.clone(),r=p(e,s,!0);return r&&(a.$L=r),a},i.clone=function(){return t.w(this.$d,this)},i.toDate=function(){return new Date(this.valueOf())},i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toISOString=function(){return this.$d.toISOString()},i.toString=function(){return this.$d.toUTCString()},o}(),K=E.prototype;return n.prototype=K,[["$ms",d],["$s",h],["$m",y],["$H",H],["$W",g],["$M",u],["$y",m],["$D",L]].forEach(function(o){K[o[1]]=function(i){return this.$g(i,o[0],o[1])}}),n.extend=function(o,i){return o.$i||(o(i,E,n),o.$i=!0),n},n.locale=p,n.isDayjs=U,n.unix=function(o){return n(1e3*o)},n.en=w[M],n.Ls=w,n.p={},n})});var k1=F1((C1,x1)=>{(function(l,c){typeof C1=="object"&&typeof x1<"u"?x1.exports=c(K1()):typeof define=="function"&&define.amd?define(["dayjs"],c):(l=typeof globalThis<"u"?globalThis:l||self).dayjs_locale_pt_br=c(l.dayjs)})(C1,function(l){"use strict";function c(h){return h&&typeof h=="object"&&"default"in h?h:{default:h}}var v=c(l),d={name:"pt-br",weekdays:"domingo_segunda-feira_ter\xE7a-feira_quarta-feira_quinta-feira_sexta-feira_s\xE1bado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_s\xE1b".split("_"),weekdaysMin:"Do_2\xAA_3\xAA_4\xAA_5\xAA_6\xAA_S\xE1".split("_"),months:"janeiro_fevereiro_mar\xE7o_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(h){return h+"\xBA"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [\xE0s] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [\xE0s] HH:mm"},relativeTime:{future:"em %s",past:"h\xE1 %s",s:"poucos segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um m\xEAs",MM:"%d meses",y:"um ano",yy:"%d anos"}};return v.default.locale(d,null,!0),d})});import{FormProvider as d0}from"react-hook-form";import{jsx as S1}from"react/jsx-runtime";function m0({children:l,style:c,onSubmit:v,...d}){return S1(d0,{...d,children:S1("form",{onSubmit:h=>{h.preventDefault(),h.stopPropagation(),v(h)},style:c,children:l})})}var f1=m0;import{useEffect as q0}from"react";import{useForm as p0}from"react-hook-form";import{zodResolver as u0}from"@hookform/resolvers/zod";var Z0=({disableDefaultValuesUpdate:l,onSubmit:c,...v})=>{let d=p0({...v,resolver:v.schema&&u0(v.schema)});return q0(()=>{l||d.reset(v.defaultValues)},[v.defaultValues,d.reset]),{...d,onSubmit:d.handleSubmit(h=>c(h,d))}},V1=Z0;import{jsx as f0}from"react/jsx-runtime";function M0({children:l,style:c,...v}){let d=V1(v);return f0(f1,{...d,style:c,children:typeof l=="function"?l(d):l})}var H0=M0;import{memo as C0,useState as x0}from"react";import{Controller as k0,useFormContext as A0}from"react-hook-form";import{Grid as L1,InputAdornment as F0,TextField as P0}from"@mui/material";var w1={description:"M39 23.1a17 17 0 0 0-15-10c-6.5.1-12.4 4-15.2 10V25a17 17 0 0 0 15 10A17 17 0 0 0 39 25c.5-.7.5-1.3.2-1.8Zm-15 9a8 8 0 0 1-7.6-8.5c.2-4.2 3.5-7.8 7.6-7.8a8 8 0 0 1 7.6 8.4c-.1 4.3-3.5 7.9-7.6 7.9Zm0-13.5-1.3.1c.7 1.1.6 2.6-.3 3.7-1 .9-2.3.9-3.4.1-.4 2.2.3 4.7 2.1 6a4.9 4.9 0 0 0 6-.2c1.6-1.4 2.4-4 1.6-6.1a4.9 4.9 0 0 0-4.7-3.6Z",id:"line-eye-solid"},T1={description:"M24 31.7c-4 0-7.4-3.1-7.7-7.1l-5.6-4.4c-.8 1-1.4 2-2 3a1.7 1.7 0 0 0 0 1.6 17.2 17.2 0 0 0 19.5 9l-2.8-2.2-1.4.1ZM40.9 35l-6-4.6c1.8-1.5 3.3-3.4 4.4-5.5a1.7 1.7 0 0 0 0-1.6c-3-5.7-8.7-9.5-15.3-9.5-2.8 0-5.5.7-8 2l-6.8-5.3a.9.9 0 0 0-1.2.2L7 12a.9.9 0 0 0 .1 1.2l31.7 24.5a.9.9 0 0 0 1.2-.2l1-1.3a.9.9 0 0 0-.1-1.2Zm-10-7.7-2-1.6a5 5 0 0 0-6.3-6.6 2.5 2.5 0 0 1 .4 2l-3.9-3a7.7 7.7 0 0 1 10.4.5 7.7 7.7 0 0 1 1.5 8.7Z",id:"line-eye-slash-solid"};var Q={description:"M24 8a16 16 0 0 0 0 32 16 16 0 0 0 0-32Zm0 7.1c1.5 0 2.7 1.2 2.7 2.7 0 1.6-1.2 2.7-2.7 2.7a2.6 2.6 0 0 1-2.7-2.7c0-1.5 1.2-2.7 2.7-2.7Zm3.6 16.4c0 .4-.4.8-.8.8h-5.6a.7.7 0 0 1-.8-.8v-1.6c0-.4.3-.7.8-.7h.7V25h-.7a.7.7 0 0 1-.8-.7v-1.6c0-.4.3-.8.8-.8h4c.5 0 .9.4.9.8v6.5h.7c.4 0 .8.3.8.7v1.6Z",id:"line-info-circle-solid"};var D1={description:"m25.5 17 5.5 5.5-12 12-4.9.5a1 1 0 0 1-1-1.1l.5-5L25.5 17Zm8.9-.8-2.6-2.6a2 2 0 0 0-2.9 0L26.5 16l5.5 5.5 2.4-2.4a2 2 0 0 0 0-3Z",id:"line-pen-solid"};var g1={description:"M35.8 21.8h-9.6v-9.6c0-.6-.6-1.1-1.1-1.1h-2.2a1 1 0 0 0-1 1v9.7h-9.7c-.6 0-1.1.6-1.1 1.1v2.2c0 .6.5 1 1 1h9.7v9.7c0 .6.5 1.1 1.1 1.1h2.2c.5 0 1-.5 1-1v-9.7h9.7c.6 0 1.1-.5 1.1-1.1v-2.2c0-.5-.5-1-1-1Z",id:"line-plus-solid"};import*as I1 from"@s_mart/masks";import{Typography as $1}from"@mui/material";import{toRem as V0}from"@s_mart/utils";import{jsx as B1,jsxs as L0}from"react/jsx-runtime";var g0=({label:l,required:c,regular:v})=>L0("span",{style:{display:"flex",alignItems:"center",gap:V0(2)},children:[B1($1,{variant:"caption",fontWeight:v?400:700,style:{display:"flex",alignItems:"center"},children:l}),c&&B1($1,{variant:"caption",fontWeight:900,color:"error",children:"*"})]}),P=g0;import{useFormContext as y0}from"react-hook-form";import{Indicator as z0}from"@s_mart/core";var _=(l,c)=>c.replace(/[[\]]/g,"").split(".").reduce((d,h)=>d?.[h],l);import{jsx as b0}from"react/jsx-runtime";var T=({name:l,disableIcon:c})=>{let v=y0(),d=_(v?.formState?.errors,l);return d?b0(z0,{severity:"error",icon:c?!1:void 0,children:d?.message}):null};import{LIcon as _1,Tooltip as S0}from"@s_mart/core";import{jsx as R,jsxs as E1}from"react/jsx-runtime";var w0=({name:l,rules:c,defaultValue:v,shouldUnregister:d,label:h,required:y,mask:H,variant:g="outlined",info:x,parse:u,inputMode:z,format:m,onInputChange:L,disableIconError:f,...b})=>{let C=A0();if(!C)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[Z,F]=x0(!1),V=p=>{let n=p;return m&&(n=m(p)),H?I1?.[H]?.format(n):n},M=p=>{let n=p;return u&&(n=u(p)),H?I1?.[H]?.parse(n):n},w=p=>{if(!p||H!=="porcentagem"&&H!=="porcentagem0")return;p?.stopPropagation();let n=(p?.target).value;if(n){let t=String(n);if(t.length>0){let E=t.indexOf("%");E>-1&&(p.currentTarget.selectionEnd=E)}}},U=_(C.formState.errors,l);return R(k0,{control:C.control,name:l,rules:c,defaultValue:v,shouldUnregister:d,render:({field:{value:p,onChange:n,ref:t}})=>E1(L1,{display:"flex",flexDirection:"column",children:[E1("div",{style:{display:"flex"},children:[h&&R(L1,{item:!0,children:R(P,{label:h,required:y})}),x&&R(L1,{item:!0,children:R(S0,{title:x,placement:"top",children:R("div",{style:{width:"fit-content"},children:R(_1,{icon:Q,color:"#757575"})})})})]}),R(P0,{variant:g,defaultValue:v,value:V(p||(p!=0?"":p)),onChange:E=>{let K=M(E?.target?.value);n(K),L?.(K,C.getValues())},error:!!U,...b,type:b.type==="password"?Z?"text":"password":b.type,autoComplete:b.autoComplete||"off",inputProps:{inputMode:z,...b.inputProps},InputProps:{onKeyDown:w,inputRef:t,endAdornment:b.type==="password"&&R(F0,{position:"start",onClick:()=>F(!Z),style:{cursor:"pointer"},children:R(_1,{icon:Z?w1:T1,size:"24px",removeMargin:!0})}),...b.InputProps}},l),R(T,{name:l,disableIcon:f})]})})},T0=C0(w0);import{memo as D0,useState as $0}from"react";import{Controller as B0,useFormContext as I0}from"react-hook-form";import{Divider as _0,IconButton as E0,LIcon as U1,Tooltip as G0}from"@s_mart/core";var G1={description:"m27.4 24.4 7-7q.6-.7 0-1.5l-1.6-1.6a1 1 0 0 0-1.5 0l-7 7-7-7a1 1 0 0 0-1.4 0l-1.6 1.6a1 1 0 0 0 0 1.5l7 7-7 7a1 1 0 0 0 0 1.4l1.6 1.6q.7.6 1.5 0l7-7 7 7q.6.6 1.4 0l1.6-1.6q.6-.7 0-1.5l-7-7Z",id:"line-times-regular"};import{colorPalette as U0}from"@s_mart/tokens";import{Grid as a1,Select as O0,MenuItem as R0,useTheme as Y0}from"@mui/material";import{Fragment as N0,jsx as B,jsxs as s1}from"react/jsx-runtime";var j0=({name:l,rules:c,defaultValue:v,shouldUnregister:d,label:h,required:y,options:H,placeholder:g,clearable:x,disableOnChangeForm:u=!1,multiple:z,info:m,footer:L,onChange:f,disableIconError:b,...C})=>{let Z=I0(),{palette:F}=Y0(),[V,M]=$0(!1);if(!Z)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let w=_(Z.formState.errors,l);return console.warn=()=>{},B(B0,{control:Z.control,name:l,rules:c,defaultValue:v,shouldUnregister:d,render:({field:{value:U,onChange:p,ref:n}})=>s1(a1,{display:"flex",flexDirection:"column",children:[s1("div",{style:{display:"flex"},children:[h&&B(a1,{item:!0,children:B(P,{label:h,required:y})}),m&&B(a1,{item:!0,children:B(G0,{title:m,placement:"top",children:B("div",{style:{width:"fit-content"},children:B(U1,{icon:Q,color:"#757575"})})})})]}),s1(O0,{open:V,onOpen:()=>M(!0),onClose:()=>M(!1),displayEmpty:!!g,variant:"outlined",autoComplete:"off",value:U?U||"":z?[]:"",renderValue:t=>{if(t.label)return t.label;if(g)return B("p",{style:{color:F.grey[400]},children:g})},multiple:z,onChange:t=>{!u&&p(t.target.value),f&&f(t.target.value,Z.getValues())},error:!!w,size:C.size||"medium",inputRef:n,...C,endAdornment:s1(N0,{children:[C.endAdornment,!!(x&&U)&&B(E0,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!u&&p(null),f&&f(null,Z.getValues())},children:B(U1,{icon:G1,color:U0.neutral[100],size:"25px",removeMargin:!0})})]}),children:[H?.map((t,E)=>B(R0,{value:t,children:s1(a1,{container:!0,direction:"column",children:[B(a1,{item:!0,children:t.label}),t.afterLabel&&B(a1,{item:!0,children:t.afterLabel})]})},E)),L&&[B(a1,{px:2,py:1,children:B(_0,{})},"footer-divider"),B("div",{children:L({closeSelect:()=>M(!1)})},"footer-content")]]},l),B(T,{name:l,disableIcon:b})]})})},W0=D0(j0);import{forwardRef as Q0,memo as J0}from"react";import{Controller as K0,useFormContext as X0}from"react-hook-form";import{Grid as J,Autocomplete as l2,TextField as a2}from"@mui/material";import{Divider as O1,LIcon as e2,Tooltip as i2}from"@s_mart/core";import{colorPalette as c2}from"@s_mart/tokens";import{Fragment as q1,jsx as $,jsxs as e1}from"react/jsx-runtime";import{createElement as R1}from"react";var r2=({name:l,rules:c,defaultValue:v,shouldUnregister:d,label:h,required:y,options:H,textFieldProps:g,noOptionsText:x,footer:u,multiple:z,info:m,placeholder:L,onChange:f,onInputChange:b,disableIconError:C,...Z})=>{let F=X0();if(!F)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let V=_(F.formState.errors,l);return console.warn=()=>{},$(K0,{control:F.control,name:l,rules:c,defaultValue:v,shouldUnregister:d,render:({field:{onChange:M,value:w,ref:U}})=>e1(J,{display:"flex",flexDirection:"column",children:[e1("div",{style:{display:"flex"},children:[h&&$(J,{item:!0,children:$(P,{label:h,required:y})}),m&&$(J,{item:!0,children:$(i2,{title:m,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(e2,{icon:Q,color:"#757575"})})})})]}),$(l2,{onChange:(p,n)=>{M(n),f?.(n,F.getValues())},onInputChange:(p,n,t)=>{t==="input"&&setTimeout(()=>{b?.(n,F.getValues())},0)},slotProps:{...Z.slotProps||{},paper:{...(Z.slotProps||{}).paper||{},sx:{border:`1px solid ${c2.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(Z.slotProps||{}).paper?.sx||{}}}},value:w||(z?[]:null),options:H,multiple:z,readOnly:Z.disabled,noOptionsText:e1(q1,{children:[x||"Nenhum resultado encontrado",u?e1(q1,{children:[$(J,{py:1,children:$(O1,{})}),u]}):null]}),isOptionEqualToValue:(p,n)=>typeof p=="string"&&typeof n=="string"?p===n:typeof p=="object"&&typeof n=="object"?typeof p.value=="object"&&typeof n.value=="object"&&p.key!==void 0&&n.key!==void 0?p.key===n.key:p.value===n.value:!1,renderOption:(p,n)=>typeof n=="object"?R1("li",{...p,key:n.key||n.value},e1(J,{container:!0,direction:"column",children:[$(J,{item:!0,children:n.label}),n.afterLabel&&$(J,{item:!0,children:n.afterLabel})]})):R1("li",{...p,key:n},n),ListboxComponent:Q0(function(n,t){return e1(q1,{children:[$("ul",{...n,ref:t}),!!u&&$("div",{...n,children:e1(q1,{children:[$(J,{px:2,py:1,children:$(O1,{})}),u]})},"searchable-footer")]})}),...Z,renderInput:p=>$(a2,{error:!!V,placeholder:L,...p,...g,inputRef:U})},l),$(T,{name:l,disableIcon:C})]})})},o2=J0(r2);import{forwardRef as s2,memo as t2}from"react";import{Controller as v2,useFormContext as d2}from"react-hook-form";import{isObject as m2,isEmpty as q2}from"lodash-es";import{Grid as i1,Autocomplete as p2,TextField as u2}from"@mui/material";import{LIcon as u1,Tooltip as Z2,Button as M2,Divider as H2}from"@s_mart/core";import{colorPalette as f2}from"@s_mart/tokens";import{toRem as N1}from"@s_mart/utils";import{toRem as p1}from"@s_mart/utils";import n2 from"@emotion/styled";import{css as Y1}from"@emotion/react";var j1=Y1`
|
|
1
|
+
import{FormProvider as Ve}from"react-hook-form";import{jsx as de}from"react/jsx-runtime";function Re({children:e,style:r,onSubmit:i,...t}){return de(Ve,{...t,children:de("form",{onSubmit:n=>{n.preventDefault(),n.stopPropagation(),i(n)},style:r,children:e})})}var ie=Re;import{useEffect as Ee}from"react";import{useForm as Be}from"react-hook-form";import{zodResolver as Ae}from"@hookform/resolvers/zod";var De=({disableDefaultValuesUpdate:e,onSubmit:r,...i})=>{let t=Be({...i,resolver:i.schema&&Ae(i.schema)});return Ee(()=>{e||t.reset(i.defaultValues)},[i.defaultValues,t.reset]),{...t,onSubmit:t.handleSubmit(n=>r(n,t))}},le=De;import{jsx as ze}from"react/jsx-runtime";function $e({children:e,style:r,...i}){let t=le(i);return ze(ie,{...t,style:r,children:typeof e=="function"?e(t):e})}var Me=$e;import{memo as He,useState as We}from"react";import{Controller as Ye,useFormContext as Je}from"react-hook-form";import{Grid as ne,InputAdornment as Ke,TextField as Xe}from"@mui/material";import{lineEye as Qe,lineEyeSlash as Ze,lineInfoCircle as eo}from"@s_mart/solid-icons";import*as ue from"@s_mart/masks";import{Typography as pe}from"@mui/material";import{toRem as qe}from"@s_mart/utils";import{jsx as me,jsxs as Oe}from"react/jsx-runtime";var _e=({label:e,required:r,regular:i})=>Oe("span",{style:{display:"flex",alignItems:"center",gap:qe(2)},children:[me(pe,{variant:"caption",fontWeight:i?400:700,style:{display:"flex",alignItems:"center"},children:e}),r&&me(pe,{variant:"caption",fontWeight:900,color:"error",children:"*"})]}),v=_e;import{useFormContext as Ue}from"react-hook-form";import{Indicator as je}from"@s_mart/core";var V=(e,r)=>r.replace(/[[\]]/g,"").split(".").reduce((t,n)=>t?.[n],e);import{jsx as Ne}from"react/jsx-runtime";var T=({name:e,disableIcon:r})=>{let i=Ue(),t=V(i?.formState?.errors,e);return t?Ne(je,{severity:"error",icon:r?!1:void 0,children:t?.message}):null};import{LIcon as fe,Tooltip as oo}from"@s_mart/core";import{jsx as B,jsxs as ce}from"react/jsx-runtime";var ro=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,mask:m,variant:g="outlined",info:I,parse:c,inputMode:u,format:a,onInputChange:F,disableIconError:d,...x})=>{let P=Je();if(!P)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[s,C]=We(!1),p=l=>{let o=l;return a&&(o=a(l)),m?ue?.[m]?.format(o):o},f=l=>{let o=l;return c&&(o=c(l)),m?ue?.[m]?.parse(o):o},R=l=>{if(!l||m!=="porcentagem"&&m!=="porcentagem0")return;l?.stopPropagation();let o=(l?.target).value;if(o){let E=String(o);if(E.length>0){let w=E.indexOf("%");w>-1&&(l.currentTarget.selectionEnd=w)}}},z=V(P.formState.errors,e);return B(Ye,{control:P.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:l,onChange:o,ref:E}})=>ce(ne,{display:"flex",flexDirection:"column",children:[ce("div",{style:{display:"flex"},children:[n&&B(ne,{item:!0,children:B(v,{label:n,required:b})}),I&&B(ne,{item:!0,children:B(oo,{title:I,placement:"top",children:B("div",{style:{width:"fit-content"},children:B(fe,{icon:eo,color:"#757575"})})})})]}),B(Xe,{variant:g,defaultValue:i,value:p(l||(l!=0?"":l)),onChange:w=>{let N=f(w?.target?.value);o(N),F?.(N,P.getValues())},error:!!z,...x,type:x.type==="password"?s?"text":"password":x.type,autoComplete:x.autoComplete||"off",inputProps:{inputMode:u,...x.inputProps},InputProps:{onKeyDown:R,inputRef:E,endAdornment:x.type==="password"&&B(Ke,{position:"start",onClick:()=>C(!s),style:{cursor:"pointer"},children:B(fe,{icon:s?Qe:Ze,size:"24px",removeMargin:!0})}),...x.InputProps}},e),B(T,{name:e,disableIcon:d})]})})},to=He(ro);import{memo as io,useState as lo}from"react";import{Controller as no,useFormContext as ao}from"react-hook-form";import{Divider as so,IconButton as po,LIcon as xe,Tooltip as mo}from"@s_mart/core";import{lineTimes as uo}from"@s_mart/regular-icons";import{lineInfoCircle as fo}from"@s_mart/solid-icons";import{colorPalette as co}from"@s_mart/tokens";import{Grid as _,Select as xo,MenuItem as yo,useTheme as Fo}from"@mui/material";import{Fragment as ho,jsx as L,jsxs as W}from"react/jsx-runtime";var Po=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,options:m,placeholder:g,clearable:I,disableOnChangeForm:c=!1,multiple:u,info:a,footer:F,onChange:d,disableIconError:x,variant:P="outlined",...s})=>{let C=ao(),{palette:p}=Fo(),[f,R]=lo(!1);if(!C)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let z=V(C.formState.errors,e);return console.warn=()=>{},L(no,{control:C.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:l,onChange:o,ref:E}})=>W(_,{display:"flex",flexDirection:"column",children:[W("div",{style:{display:"flex"},children:[n&&L(_,{item:!0,children:L(v,{label:n,required:b})}),a&&L(_,{item:!0,children:L(mo,{title:a,placement:"top",children:L("div",{style:{width:"fit-content"},children:L(xe,{icon:fo,color:"#757575"})})})})]}),W(xo,{open:f,onOpen:()=>R(!0),onClose:()=>R(!1),displayEmpty:!!g,variant:P,autoComplete:"off",value:l?l||"":u?[]:"",renderValue:w=>{if(w.label)return w.label;if(g)return L("p",{style:{color:p.grey[400]},children:g})},multiple:u,onChange:w=>{!c&&o(w.target.value),d&&d(w.target.value,C.getValues())},error:!!z,size:s.size||"medium",inputRef:E,...s,endAdornment:W(ho,{children:[s.endAdornment,!!(I&&l)&&L(po,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!c&&o(null),d&&d(null,C.getValues())},children:L(xe,{icon:uo,color:co.neutral[100],size:"25px",removeMargin:!0})})]}),children:[m?.map((w,N)=>L(yo,{value:w,children:W(_,{container:!0,direction:"column",children:[L(_,{item:!0,children:w.label}),w.afterLabel&&L(_,{item:!0,children:w.afterLabel})]})},N)),F&&[L(_,{px:2,py:1,children:L(so,{})},"footer-divider"),L("div",{children:F({closeSelect:()=>R(!1)})},"footer-content")]]},e),L(T,{name:e,disableIcon:x})]})})},bo=io(Po);import{forwardRef as go,memo as Co}from"react";import{Controller as vo,useFormContext as Io}from"react-hook-form";import{Grid as M,Autocomplete as To,TextField as ko}from"@mui/material";import{Divider as ye,LIcon as wo,Tooltip as So}from"@s_mart/core";import{lineInfoCircle as Go}from"@s_mart/solid-icons";import{colorPalette as Lo}from"@s_mart/tokens";import{Fragment as X,jsx as G,jsxs as O}from"react/jsx-runtime";import{createElement as Fe}from"react";var Vo=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,options:m,textFieldProps:g,noOptionsText:I,footer:c,multiple:u,info:a,placeholder:F,onChange:d,onInputChange:x,disableIconError:P,...s})=>{let C=Io();if(!C)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let p=V(C.formState.errors,e);return console.warn=()=>{},G(vo,{control:C.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{onChange:f,value:R,ref:z}})=>O(M,{display:"flex",flexDirection:"column",children:[O("div",{style:{display:"flex"},children:[n&&G(M,{item:!0,children:G(v,{label:n,required:b})}),a&&G(M,{item:!0,children:G(So,{title:a,placement:"top",children:G("div",{style:{width:"fit-content"},children:G(wo,{icon:Go,color:"#757575"})})})})]}),G(To,{onChange:(l,o)=>{f(o),d?.(o,C.getValues())},onInputChange:(l,o,E)=>{E==="input"&&setTimeout(()=>{x?.(o,C.getValues())},0)},slotProps:{...s.slotProps||{},paper:{...(s.slotProps||{}).paper||{},sx:{border:`1px solid ${Lo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(s.slotProps||{}).paper?.sx||{}}}},value:R||(u?[]:null),options:m,multiple:u,readOnly:s.disabled,noOptionsText:O(X,{children:[I||"Nenhum resultado encontrado",c?O(X,{children:[G(M,{py:1,children:G(ye,{})}),c]}):null]}),isOptionEqualToValue:(l,o)=>typeof l=="string"&&typeof o=="string"?l===o:typeof l=="object"&&typeof o=="object"?typeof l.value=="object"&&typeof o.value=="object"&&l.key!==void 0&&o.key!==void 0?l.key===o.key:l.value===o.value:!1,renderOption:(l,o)=>typeof o=="object"?Fe("li",{...l,key:o.key||o.value},O(M,{container:!0,direction:"column",children:[G(M,{item:!0,children:o.label}),o.afterLabel&&G(M,{item:!0,children:o.afterLabel})]})):Fe("li",{...l,key:o},o),ListboxComponent:go(function(o,E){return O(X,{children:[G("ul",{...o,ref:E}),!!c&&G("div",{...o,children:O(X,{children:[G(M,{px:2,py:1,children:G(ye,{})}),c]})},"searchable-footer")]})}),...s,renderInput:l=>G(ko,{error:!!p,placeholder:F,...l,...g,inputRef:z})},e),G(T,{name:e,disableIcon:P})]})})},Ro=Co(Vo);import{forwardRef as Ao,memo as Do}from"react";import{Controller as $o,useFormContext as Mo}from"react-hook-form";import{isObject as zo,isEmpty as qo}from"lodash-es";import{Grid as U,Autocomplete as _o,TextField as Oo}from"@mui/material";import{LIcon as Z,Tooltip as Uo,Button as jo,Divider as No}from"@s_mart/core";import{colorPalette as Ho}from"@s_mart/tokens";import{linePlus as ge,linePen as Wo,lineInfoCircle as Yo}from"@s_mart/solid-icons";import{toRem as Ce}from"@s_mart/utils";import{toRem as Q}from"@s_mart/utils";import Eo from"@emotion/styled";import{css as Pe}from"@emotion/react";var be=Pe`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,
|
|
5
|
+
`,Bo=e=>Pe`
|
|
6
6
|
.creatable,
|
|
7
7
|
.editable {
|
|
8
|
-
${
|
|
8
|
+
${be}
|
|
9
9
|
|
|
10
10
|
.divider {
|
|
11
11
|
width: 1px;
|
|
12
|
-
height: ${
|
|
13
|
-
background-color: ${
|
|
12
|
+
height: ${Q(20)};
|
|
13
|
+
background-color: ${e.palette.grey[400]};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.button {
|
|
17
17
|
display: flex;
|
|
18
18
|
justify-content: center;
|
|
19
19
|
align-items: center;
|
|
20
|
-
color: ${
|
|
20
|
+
color: ${e.palette.grey[600]};
|
|
21
21
|
border-radius: 50%;
|
|
22
22
|
|
|
23
|
-
margin: 0 ${
|
|
24
|
-
width: ${
|
|
25
|
-
height: ${
|
|
23
|
+
margin: 0 ${Q(6)};
|
|
24
|
+
width: ${Q(28)};
|
|
25
|
+
height: ${Q(28)};
|
|
26
26
|
|
|
27
27
|
&:hover {
|
|
28
28
|
cursor: pointer;
|
|
29
|
-
background-color: ${
|
|
29
|
+
background-color: ${e.palette.grey[100]};
|
|
30
30
|
transition: background-color 0.2s ease-in-out;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
`,
|
|
34
|
+
`,he=Eo.div`
|
|
35
35
|
display: flex;
|
|
36
36
|
|
|
37
37
|
div.endAdornments {
|
|
38
38
|
position: absolute;
|
|
39
39
|
right: 0;
|
|
40
40
|
|
|
41
|
-
${
|
|
41
|
+
${be}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.MuiAutocomplete-endAdornment {
|
|
@@ -46,23 +46,23 @@ var o0=Object.create;var A1=Object.defineProperty;var n0=Object.getOwnPropertyDe
|
|
|
46
46
|
right: 0;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
${({hideAddButton:
|
|
50
|
-
`;import{Fragment as
|
|
49
|
+
${({hideAddButton:e,theme:r})=>!e&&Bo(r)}
|
|
50
|
+
`;import{Fragment as ae,jsx as h,jsxs as A}from"react/jsx-runtime";import{createElement as ve}from"react";var Jo=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,options:m,editable:g,footer:I,onEditOption:c,onCreateOption:u,textFieldProps:a,hideAddButton:F,multiple:d,info:x,onChange:P,onInputChange:s,placeholder:C,disableIconError:p,...f})=>{let R=Mo();if(!R)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let z=V(R.formState.errors,e),l=F||f.disabled,o=k=>{let q=0;return a?.InputProps||(q+=2.5),l||(q+=2.56,E(k)&&(q+=2.56)),!f.disableClearable&&!f.disabled&&(q+=1.3),q+"rem"},E=k=>f.disabled?!1:g&&zo(k)&&!qo(k);console.warn=()=>{};let w=k=>{u?u(k):console.error("onCreateOption n\xE3o foi definido")},N=k=>{c?c(k):console.error("onEditOption n\xE3o foi definido")};return h($o,{control:R.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:k,onChange:q,ref:Le}})=>{let se=k?.label||k?.value||k;return A(U,{display:"flex",flexDirection:"column",children:[A("div",{style:{display:"flex"},children:[n&&h(U,{item:!0,children:h(v,{label:n,required:b})}),x&&h(U,{item:!0,children:h(Uo,{title:x,placement:"top",children:h("div",{style:{width:"fit-content"},children:h(Z,{icon:Yo,color:"#757575"})})})})]}),h(he,{hideAddButton:l,children:h(_o,{fullWidth:!0,onChange:(S,y)=>{q(y),P?.(y,R.getValues())},onInputChange:(S,y,te)=>{te==="input"&&setTimeout(()=>{s?.(y,R.getValues())},0)},slotProps:{...f.slotProps||{},paper:{...(f.slotProps||{}).paper||{},sx:{border:`1px solid ${Ho.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(f.slotProps||{}).paper?.sx||{}}}},options:m,value:k||(d?[]:null),multiple:d,readOnly:f.disabled,noOptionsText:l?void 0:A(jo,{sx:{justifyContent:"flex-start",padding:`${Ce(6)} ${Ce(-16)}`,margin:0},fullWidth:!0,onClick:()=>w(k),variant:"text",startIcon:h(Z,{icon:ge}),children:["Adicionar ",se&&`"${se}"`]}),isOptionEqualToValue:(S,y)=>y?typeof S=="string"&&typeof y=="string"?S===y:typeof S=="object"&&typeof y=="object"?typeof S.value=="object"&&typeof y.value=="object"&&S.key!==void 0&&y.key!==void 0?S.key===y.key:S.value===y.value:typeof S=="object"&&typeof y=="string":!1,renderOption:(S,y)=>typeof y=="object"?ve("li",{...S,key:y.key||y.value},A(U,{container:!0,direction:"column",children:[h(U,{item:!0,children:y.label}),y.afterLabel&&h(U,{item:!0,children:y.afterLabel})]})):ve("li",{...S,key:y},y),ListboxComponent:Ao(function(y,te){return A(ae,{children:[h("ul",{...y,ref:te}),!!I&&h("div",{...y,children:A(ae,{children:[h(U,{px:2,py:1,children:h(No,{})}),I]})},"creatable-footer")]})}),...f,sx:{"& div.MuiInputBase-root":{paddingRight:`${o(k)} !important`},...f.sx},renderInput:S=>h(Oo,{placeholder:C,...S,error:!!z,InputProps:{...S.InputProps,inputRef:Le,endAdornment:A("div",{className:"endAdornments",children:[S.InputProps.endAdornment,!l&&A(ae,{children:[E(k)?A("div",{className:"editable",children:[h("div",{className:"divider"}),h("div",{className:"button",onClick:()=>N(k),children:h(Z,{icon:Wo,size:"24px",removeMargin:!0})})]}):null,A("div",{className:"creatable",children:[h("div",{className:"divider"}),h("div",{className:"button",onClick:()=>w(k),children:h(Z,{icon:ge,size:"24px",removeMargin:!0})})]})]})]})},...a})},e)}),h(T,{name:e,disableIcon:p})]})}})},Ko=Do(Jo);import{Controller as Xo,useFormContext as Qo}from"react-hook-form";import{Grid as Zo,Checkbox as er,FormControlLabel as or}from"@mui/material";import{jsx as Y,jsxs as ir}from"react/jsx-runtime";var rr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,labelPlacement:b,required:m,disableIconError:g,onChange:I,...c})=>{let u=Qo();if(!u)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Y(Xo,{control:u.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:a,onChange:F}})=>ir(Zo,{display:"flex",flexDirection:"column",children:[Y(or,{control:Y(er,{checked:!!a,value:a??"",defaultValue:a,onChange:(d,x)=>{F(d,x),I?.(d,x)},...c},e),label:Y(v,{label:n,required:m,regular:!0}),labelPlacement:b||"end"}),Y(T,{name:e,disableIcon:g})]})})},tr=rr;import{Controller as lr,useFormContext as nr}from"react-hook-form";import{Grid as ar,Switch as sr,FormControlLabel as dr}from"@mui/material";import{jsx as J,jsxs as ur}from"react/jsx-runtime";var pr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,labelPlacement:b,disableIconError:m,onChange:g,...I})=>{let c=nr();if(!c)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return J(lr,{control:c.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:u,onChange:a}})=>ur(ar,{display:"flex",flexDirection:"column",children:[J(dr,{control:J(sr,{value:u??"",checked:u??!1,defaultValue:u,onChange:(F,d)=>{a(F,d),g?.(F,d)},...I},e),label:J(v,{label:n}),labelPlacement:b||"end"}),J(T,{name:e,disableIcon:m})]})})},mr=pr;import{Grid as fr,Radio as cr,FormControlLabel as xr}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var yr=({label:e,labelPlacement:r,...i})=>ee(fr,{display:"flex",flexDirection:"column",children:ee(xr,{control:ee(cr,{...i}),label:ee(v,{label:e}),labelPlacement:r||"end"})}),Fr=yr;import{Controller as Pr,useFormContext as br}from"react-hook-form";import{Grid as hr,RadioGroup as gr}from"@mui/material";import{jsx as oe,jsxs as Ir}from"react/jsx-runtime";var Cr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,children:m,orientation:g="row",disableIconError:I,...c})=>{let u=br();if(!u)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return oe(Pr,{control:u.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:a,onChange:F}})=>Ir(hr,{display:"flex",flexDirection:"column",children:[n&&oe(v,{label:n,required:b}),oe(gr,{value:a||"",name:e,...c,onChange:d=>{c?.onChange?.(d,d.target?.value),F(d)},style:{display:"flex",flexDirection:g},children:m},e),oe(T,{name:e,disableIcon:I})]})})},vr=Cr;import{Controller as Tr,useFormContext as kr}from"react-hook-form";import{Slider as wr}from"@mui/material";import{jsx as Ie}from"react/jsx-runtime";var Sr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,...n})=>{let b=kr();if(!b)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Ie(Tr,{control:b.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:m,onChange:g}})=>Ie(wr,{value:m||n?.min||0,onChange:g,valueLabelDisplay:"auto",...n},e)})},Gr=Sr;import{memo as Br}from"react";import{Controller as Ar,useFormContext as Dr}from"react-hook-form";import{Grid as $r}from"@s_mart/core";import{composeValidators as Mr,date as ke}from"@s_mart/rules";import{TextField as zr}from"@mui/material";import{DatePicker as qr}from"@mui/x-date-pickers/DatePicker";import{AdapterDayjs as _r}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Or}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Ur}from"@mui/x-date-pickers/locales/ptBR";import jr from"dayjs/locale/pt-br";import Lr from"@emotion/styled";import{IconButton as Vr}from"@mui/material";import{toRem as D}from"@s_mart/utils";var Rr=e=>{switch(e){case"small":return D(16);default:case"medium":return D(20);case"large":return D(24)}},Er=e=>{switch(e){case"small":return`${D(2)} ${D(8)}`;default:case"medium":return`${D(6)} ${D(8)}`;case"large":return`${D(10)}`}},Te=Lr(Vr)`
|
|
51
51
|
margin: 0px;
|
|
52
52
|
|
|
53
|
-
padding: ${({size:
|
|
54
|
-
border-radius: 0 ${
|
|
53
|
+
padding: ${({size:e})=>Er(e)};
|
|
54
|
+
border-radius: 0 ${D(4)} ${D(4)} 0;
|
|
55
55
|
|
|
56
56
|
svg {
|
|
57
|
-
width: ${({size:
|
|
57
|
+
width: ${({size:e})=>Rr(e)} !important;
|
|
58
58
|
}
|
|
59
|
-
`;import{jsx as
|
|
59
|
+
`;import{jsx as K,jsxs as Yr}from"react/jsx-runtime";import{createElement as Wr}from"react";var Nr=({rules:e,name:r,defaultValue:i,shouldUnregister:t,datePickerProps:n,label:b,required:m,placeholder:g,disabled:I,disableIconError:c,...u})=>{let a=Dr();if(!a)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let F=V(a.formState.errors,r),d=n?.format||"DD/MM/YYYY",x=e?Mr([ke(d),e]):ke(d);return K(Or,{dateAdapter:_r,adapterLocale:jr,localeText:Ur.components.MuiLocalizationProvider.defaultProps.localeText,children:K(Ar,{control:a.control,name:r,rules:x,defaultValue:i,shouldUnregister:t,render:({field:{value:P,onChange:s,ref:C}})=>Yr($r,{display:"flex",flexDirection:"column",children:[b&&K(v,{label:b,required:m}),Wr(qr,{...n,key:r,value:P??null,format:d,onChange:(p,f)=>{s(p,f),n?.onChange?.(p,f)},disabled:I,slots:{textField:zr,openPickerButton:p=>K(Te,{...p,size:u.size})},slotProps:{textField:p=>({variant:"outlined",...p,error:!!F,...u,inputProps:{...p.inputProps,placeholder:g||p.inputProps?.placeholder},InputProps:{...p.InputProps,inputRef(f){C(f),typeof p.inputRef=="function"&&p.inputRef(f)}}})}}),K(T,{name:r,disableIcon:c})]})})})},Hr=Br(Nr);import{memo as Zr}from"react";import{Controller as et,useFormContext as ot}from"react-hook-form";import{Grid as rt}from"@s_mart/core";import{composeValidators as tt,time as Se}from"@s_mart/rules";import{TextField as it}from"@mui/material";import{TimePicker as lt}from"@mui/x-date-pickers/TimePicker";import{AdapterDayjs as nt}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as at}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as st}from"@mui/x-date-pickers/locales/ptBR";import dt from"dayjs/locale/pt-br";import Jr from"@emotion/styled";import{IconButton as Kr}from"@mui/material";import{toRem as $}from"@s_mart/utils";var Xr=e=>{switch(e){case"small":return $(16);default:case"medium":return $(20);case"large":return $(24)}},Qr=e=>{switch(e){case"small":return`${$(2)} ${$(8)}`;default:case"medium":return`${$(6)} ${$(8)}`;case"large":return`${$(10)}`}},we=Jr(Kr)`
|
|
60
60
|
margin: 0px;
|
|
61
61
|
|
|
62
|
-
padding: ${({size:
|
|
63
|
-
border-radius: 0 ${
|
|
62
|
+
padding: ${({size:e})=>Qr(e)};
|
|
63
|
+
border-radius: 0 ${$(4)} ${$(4)} 0;
|
|
64
64
|
|
|
65
65
|
svg {
|
|
66
|
-
width: ${({size:
|
|
66
|
+
width: ${({size:e})=>Xr(e)} !important;
|
|
67
67
|
}
|
|
68
|
-
`;import{jsx as
|
|
68
|
+
`;import{jsx as H,jsxs as ut}from"react/jsx-runtime";var pt=({rules:e,defaultValue:r,shouldUnregister:i,name:t,required:n,label:b,timePickerProps:m,placeholder:g,disabled:I,disableIconError:c,...u})=>{let a=ot();if(!a)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let F=V(a.formState.errors,t),d=m?.format||"HH:mm",x=e?tt([Se(d),e]):Se(d);return H(at,{dateAdapter:nt,adapterLocale:dt,localeText:st.components.MuiLocalizationProvider.defaultProps.localeText,children:H(et,{control:a.control,name:t,rules:x,defaultValue:r,shouldUnregister:i,render:({field:{value:P,onChange:s,ref:C}})=>ut(rt,{display:"flex",flexDirection:"column",children:[b&&H(v,{label:b,required:n}),H(lt,{ampm:!1,format:d,value:P??null,disabled:I,...m,onChange:(p,f)=>{s(p,f),m?.onChange?.(p,f)},slots:{textField:it,openPickerButton:p=>H(we,{...p,size:u.size})},slotProps:{textField:p=>({variant:"outlined",...p,error:!!F,...u,inputProps:{...p.inputProps,placeholder:g||p.inputProps?.placeholder},InputProps:{...p.InputProps,inputRef(f){C(f),typeof p.inputRef=="function"&&p.inputRef(f)}}})}},t),H(T,{name:t,disableIcon:c})]})})})},mt=Zr(pt);import{memo as ft}from"react";import{Controller as ct,useFormContext as xt}from"react-hook-form";import{Autocomplete as yt,TextField as Ft}from"@mui/material";import{Grid as re}from"@s_mart/core";import{colorPalette as Pt}from"@s_mart/tokens";import{jsx as j,jsxs as Ge}from"react/jsx-runtime";import{createElement as gt}from"react";var bt=({name:e,defaultValue:r,rules:i,shouldUnregister:t,label:n,required:b,noOptionsText:m,placeholder:g,onInputChange:I,onChange:c,disableIconError:u,...a})=>{let F=xt();if(!F)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let d=V(F.formState.errors,e);return console.warn=()=>{},j(ct,{name:e,control:F.control,defaultValue:r,rules:i,shouldUnregister:t,render:({field:x})=>Ge(re,{display:"flex",flexDirection:"column",children:[n&&j(v,{label:n,required:b}),j(yt,{onChange:(P,s)=>{x.onChange(s),c?.(s,F.getValues())},onInputChange:(P,s,C)=>{C==="input"&&(x.onChange(s),setTimeout(()=>{I?.(s,F.getValues())},0))},slotProps:{...a.slotProps||{},paper:{...(a.slotProps||{}).paper||{},sx:{border:`1px solid ${Pt.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)=>gt("li",{...P,key:s.key||s.value,onClick:C=>{P.onClick?.(C),x.onChange(s)}},Ge(re,{container:!0,direction:"column",children:[j(re,{item:!0,children:s.label}),s.afterLabel&&j(re,{item:!0,children:s.afterLabel})]})),value:x.value||null,readOnly:a.disabled,noOptionsText:m||"Nenhuma op\xE7\xE3o encontrada",...a,renderInput:P=>j(Ft,{placeholder:g,...P,...a.textFieldProps,error:!!d,InputProps:{...P.InputProps,...a.textFieldProps?.InputProps,inputRef:x.ref,inputProps:{...P.inputProps,...a.textFieldProps?.InputProps?.inputProps}}})},e),j(T,{name:e,disableIcon:u})]})})},ht=ft(bt);export{ht as Autocomplete,tr as Checkbox,Ko as Creatable,Hr as DatePicker,v as FieldLabel,Me as Form,ie as FormProvider,Fr as RadioButton,vr as RadioGroup,Ro as Searchable,bo as Select,Gr as Slider,mr as Switch,to as TextField,mt as TimePicker,le as useForm};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/form",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -9,48 +9,52 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**"
|
|
11
11
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsup src/index.tsx --minify --format esm --dts --external react",
|
|
14
|
-
"dev": "tsup src/index.tsx --format esm --watch --dts --external react",
|
|
15
|
-
"lint": "eslint src/**/*.ts* --fix"
|
|
16
|
-
},
|
|
17
12
|
"dependencies": {
|
|
18
13
|
"@hookform/resolvers": "^3.1.0",
|
|
19
|
-
"
|
|
20
|
-
"@s_mart/masks": "*",
|
|
21
|
-
"@s_mart/rules": "*",
|
|
22
|
-
"@s_mart/tokens": "*",
|
|
23
|
-
"@s_mart/typed": "*",
|
|
24
|
-
"@s_mart/utils": "*",
|
|
14
|
+
"dayjs": "^1.11.10",
|
|
25
15
|
"@types/react": "^18.2.21",
|
|
26
16
|
"@types/react-dom": "^18.2.7",
|
|
17
|
+
"@types/lodash-es": ">=4.17.12",
|
|
27
18
|
"lodash-es": "^4.17.21",
|
|
28
19
|
"tsup": "^6.7.0",
|
|
29
|
-
"typescript": "^5.2.2"
|
|
20
|
+
"typescript": "^5.2.2",
|
|
21
|
+
"@s_mart/core": "5.0.0",
|
|
22
|
+
"@s_mart/masks": "5.0.0",
|
|
23
|
+
"eslint-config-smarten": "4.0.1",
|
|
24
|
+
"@s_mart/rules": "5.0.0",
|
|
25
|
+
"@s_mart/solid-icons": "5.0.0",
|
|
26
|
+
"@s_mart/regular-icons": "5.0.0",
|
|
27
|
+
"@s_mart/tokens": "5.0.0",
|
|
28
|
+
"@s_mart/typed": "5.0.0",
|
|
29
|
+
"@s_mart/utils": "5.0.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@emotion/react": ">=11.10.8",
|
|
33
33
|
"@emotion/styled": ">=11.10.8",
|
|
34
34
|
"@mui/material": ">=5.14.6",
|
|
35
35
|
"@mui/x-date-pickers": ">=6.3.0",
|
|
36
|
-
"@s_mart/core": "*",
|
|
37
|
-
"@s_mart/masks": "*",
|
|
38
|
-
"@s_mart/rules": "*",
|
|
39
|
-
"@s_mart/tokens": "*",
|
|
40
|
-
"@s_mart/typed": "*",
|
|
41
|
-
"@s_mart/utils": "*",
|
|
42
36
|
"@types/react": ">=18.2.5",
|
|
43
37
|
"@types/react-dom": ">=18.2.7",
|
|
38
|
+
"@types/lodash-es": ">=4.17.12",
|
|
39
|
+
"dayjs": "^1.11.10",
|
|
44
40
|
"react": ">=18.2.0",
|
|
45
41
|
"react-dom": ">=18.2.0",
|
|
46
42
|
"react-hook-form": ">=7.36.1",
|
|
47
43
|
"typescript": ">=5.2.2",
|
|
48
|
-
"zod": ">=3.21.4"
|
|
44
|
+
"zod": ">=3.21.4",
|
|
45
|
+
"@s_mart/core": "5.0.0",
|
|
46
|
+
"@s_mart/masks": "5.0.0",
|
|
47
|
+
"@s_mart/rules": "5.0.0",
|
|
48
|
+
"@s_mart/tokens": "5.0.0",
|
|
49
|
+
"@s_mart/typed": "5.0.0",
|
|
50
|
+
"@s_mart/utils": "5.0.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
53
|
+
"eslint": "^8.47.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"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"
|
|
55
59
|
}
|
|
56
60
|
}
|