@mobilestock-native/form 1.0.3 → 1.1.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.
Files changed (3) hide show
  1. package/index.d.ts +39 -6
  2. package/index.js +40 -43
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -129,19 +129,26 @@ interface CounterRootProps {
129
129
  value: number;
130
130
  event: CounterEventName;
131
131
  }): void;
132
+ autoFocus?: boolean;
133
+ onFocus?(): void;
134
+ onBlur?(): void;
132
135
  }
133
136
 
134
137
  declare function CounterRoot({ children, ...props }: CounterRootProps): react_jsx_runtime.JSX.Element;
135
138
 
136
139
  type InputType = 'text' | 'password' | 'tel' | 'email' | 'number' | 'url' | 'zipcode' | 'hidden';
137
- interface InputProps extends Omit<TextInputProps, 'hitSlop'> {
140
+ interface InputProps extends Omit<TextInputProps, 'hitSlop' | 'onChangeText' | 'onChange'> {
138
141
  name: string;
139
142
  label?: string;
140
- autofocus?: boolean;
141
143
  type?: InputType;
142
144
  autoSubmit?: boolean;
143
145
  full?: boolean;
146
+ showMaxContent?: boolean;
144
147
  format?(value: string): string;
148
+ onChange?(payload: {
149
+ value: unknown;
150
+ event: 'INPUT_CHANGE' | 'AUTO_SUBMIT' | 'TOGGLE_PASSWORD';
151
+ }): void;
145
152
  }
146
153
  interface InputRef {
147
154
  focus(): void;
@@ -217,6 +224,13 @@ interface FormSelectPropsBase {
217
224
  disabled: boolean;
218
225
  placeholder: string;
219
226
  defaultValue?: CustomOption;
227
+ onChange?(payload: {
228
+ value: CustomOption['value'];
229
+ event: 'SELECT_CHANGE';
230
+ }): void;
231
+ autoFocus?: boolean;
232
+ onFocus?(): void;
233
+ onBlur?(): void;
220
234
  }
221
235
  interface FormSelectProps extends Omit<FormSelectPropsBase, 'placeholder' | 'disabled'> {
222
236
  placeholder?: string;
@@ -224,22 +238,41 @@ interface FormSelectProps extends Omit<FormSelectPropsBase, 'placeholder' | 'dis
224
238
  disabled?: boolean;
225
239
  full?: boolean;
226
240
  }
227
- declare function FormSelect({ name, label, disabled, options, placeholder, full, defaultValue }: FormSelectProps): react_jsx_runtime.JSX.Element;
241
+ declare function FormSelect({ name, label, disabled, options, placeholder, full, defaultValue, onChange, autoFocus, onFocus, onBlur }: FormSelectProps): react_jsx_runtime.JSX.Element;
228
242
 
229
243
  declare function FormVertical({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
230
244
 
231
- interface FormPropsWithHandler<T extends object> extends FormProps {
232
- onSubmit(params: SubmitParams<T>): Promise<void> | void;
245
+ interface FormPropsWithHandler<T extends object> extends Omit<FormProps, 'onSubmit'> {
246
+ onSubmit?(params: SubmitParams<T>): Promise<void> | void;
247
+ onBeforeSubmit?(params: {
248
+ data: T;
249
+ }): Promise<boolean> | boolean;
250
+ onAfterSubmit?(params: {
251
+ data: T;
252
+ }): Promise<void> | void;
233
253
  schema?: ZodSchema<T>;
254
+ name?: string;
234
255
  }
235
256
  interface PropsContext {
236
257
  submitForm(): void;
237
258
  clearForm(): void;
238
259
  formRef: RefObject<FormHandles>;
239
260
  loading?: boolean;
261
+ notifyFieldChange?(name: string, value: unknown): void;
262
+ }
263
+ declare function FormComponent<T extends object>({ children, onSubmit, onBeforeSubmit, onAfterSubmit, schema, name: formName, ...props }: FormPropsWithHandler<T>): react_jsx_runtime.JSX.Element;
264
+
265
+ interface UseFormReturn<T extends object> {
266
+ readonly values: T;
267
+ getValue<K extends keyof T & string>(name: K): T[K] | undefined;
268
+ setValue<K extends keyof T & string>(name: K, value: T[K]): void;
269
+ submit(): void;
270
+ clear(): void;
271
+ setErrors(errors: Record<string, string>): void;
272
+ reset(data?: Partial<T>): void;
240
273
  }
241
274
  declare function useForm(): PropsContext;
242
- declare function FormComponent<T extends object>({ children, onSubmit, schema, ...props }: FormPropsWithHandler<T>): react_jsx_runtime.JSX.Element;
275
+ declare function useForm<T extends object>(name: string): UseFormReturn<T>;
243
276
 
244
277
  interface SubmitParams<T extends object> {
245
278
  data: T;
package/index.js CHANGED
@@ -1,49 +1,46 @@
1
- "use strict";var Fn=Object.create;var Ne=Object.defineProperty,In=Object.defineProperties,Rn=Object.getOwnPropertyDescriptor,wn=Object.getOwnPropertyDescriptors,xn=Object.getOwnPropertyNames,ke=Object.getOwnPropertySymbols,Nn=Object.getPrototypeOf,lo=Object.prototype.hasOwnProperty,No=Object.prototype.propertyIsEnumerable;var xo=(e,o,t)=>o in e?Ne(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,C=(e,o)=>{for(var t in o||(o={}))lo.call(o,t)&&xo(e,t,o[t]);if(ke)for(var t of ke(o))No.call(o,t)&&xo(e,t,o[t]);return e},E=(e,o)=>In(e,wn(o));var I=(e,o)=>{var t={};for(var n in e)lo.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&ke)for(var n of ke(e))o.indexOf(n)<0&&No.call(e,n)&&(t[n]=e[n]);return t};var Ln=(e,o)=>{for(var t in o)Ne(e,t,{get:o[t],enumerable:!0})},Lo=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of xn(o))!lo.call(e,r)&&r!==t&&Ne(e,r,{get:()=>o[r],enumerable:!(n=Rn(o,r))||n.enumerable});return e};var R=(e,o,t)=>(t=e!=null?Fn(Nn(e)):{},Lo(o||!e||!e.__esModule?Ne(t,"default",{value:e,enumerable:!0}):t,e)),An=e=>Lo(Ne({},"__esModule",{value:!0}),e);var se=(e,o,t)=>new Promise((n,r)=>{var a=l=>{try{m(t.next(l))}catch(u){r(u)}},i=l=>{try{m(t.throw(l))}catch(u){r(u)}},m=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,i);m((t=t.apply(e,o)).next())});var oi={};Ln(oi,{Form:()=>ei,useForm:()=>q});module.exports=An(oi);var zo=require("@mobilestock-native/button");var Ao=require("@unform/mobile"),te=require("react"),Vo=require("zod"),Mo=require("@mobilestock-native/container"),Oo=require("@mobilestock-native/modalalert");var Te=require("react/jsx-runtime"),Do=(0,te.createContext)({});function q(){return(0,te.useContext)(Do)}function Ho(r){var a=r,{children:e,onSubmit:o,schema:t}=a,n=I(a,["children","onSubmit","schema"]);let i=(0,te.useRef)(null),[m,l]=(0,te.useState)(!1),[u,p]=(0,te.useState)(void 0);function c(){var f;(f=i.current)==null||f.submitForm()}function h(){var f,s;(f=i.current)==null||f.setErrors({}),(s=i.current)==null||s.reset()}function d(f){let s={};for(let v of f){let S=v.path.filter(A=>typeof A=="string"||typeof A=="number").join(".");S&&(s[String(S)]=v.message)}return s}function b(f){if(f instanceof Vo.ZodError)return d(f.issues);if(typeof f=="object"&&f!==null&&"errors"in f){let s=f.errors;if(Array.isArray(s)&&s.length>0&&"message"in s[0]&&"path"in s[0])return d(s)}return null}function g(v,S){return se(this,arguments,function*(f,{reset:s}){var A,D,T,V,Q;if((A=i.current)==null||A.setErrors({}),t){let z=t.safeParse(f);if(!z.success){(D=i.current)==null||D.setErrors(d(z.error.issues));return}}try{l(!0),yield o({data:f,ref:i,reset:s})}catch(z){let be=b(z);if(be)(T=i.current)==null||T.setErrors(be);else{let x="Erro ao realizar opera\xE7\xE3o",P=500;if(typeof z=="object"&&z!==null&&"isAxiosError"in z&&z.isAxiosError){let y=z;P=((V=y.response)==null?void 0:V.status)||500;let N=(Q=y.response)==null?void 0:Q.data;N!=null&&N.message&&(x=N.message)}else z instanceof Error&&(x=z.message||x);p({message:x,status:P})}}finally{l(!1)}})}return(0,Te.jsxs)(Do.Provider,{value:{formRef:i,submitForm:c,clearForm:h,loading:m},children:[(0,Te.jsx)(Ao.Form,E(C({ref:i,onSubmit:g},n),{children:(0,Te.jsx)(Mo.Container.Vertical,{gap:"2XS",children:e})})),(0,Te.jsx)(Oo.ModalAlert,{visible:!!u,message:u==null?void 0:u.message,type:u&&u.status>=500?"FATAL_ERROR":"ERROR_NOTICE",title:"Erro ao enviar o formul\xE1rio",onClose:()=>p(void 0)})]})}var Bo=require("react/jsx-runtime");function ko(a){var i=a,{type:e="SUBMIT",disabled:o,isLoading:t,onPress:n}=i,r=I(i,["type","disabled","isLoading","onPress"]);let{submitForm:m,clearForm:l,loading:u}=q();function p(c){switch(e){case"SUBMIT":m();break;case"RESET":l();break;default:n==null||n(c)}}return(0,Bo.jsx)(zo.Button,E(C({size:"LG"},r),{onPress:p,isLoading:e==="SUBMIT"&&u||t,disabled:u||t||o}))}var so=R(require("styled-components/native")),Ko=require("@mobilestock-native/badge"),Yo=require("@mobilestock-native/container"),Zo=R(require("@mobilestock-native/tools")),Jo=require("@mobilestock-native/typography");var _o=require("@unform/core"),K=require("react"),Uo=require("react/jsx-runtime"),$o=(0,K.createContext)(void 0);function Go(e){let{fieldName:o,registerField:t,error:n,defaultValue:r}=(0,_o.useField)(e.name),[a,i]=(0,K.useState)(0),m=(0,K.useCallback)(c=>{let h=c;return e.maxCount!==void 0&&h>e.maxCount&&(h=e.maxCount),e.minCount!==void 0&&h<e.minCount&&(h=e.minCount),h},[e.maxCount,e.minCount]),l=(0,K.useCallback)(c=>{var d;let h=m(c);i(h),(d=e.onChange)==null||d.call(e,{value:h,event:"EDIT"})},[m]);(0,K.useEffect)(()=>{t({name:o,getValue:()=>a,setValue:(c,h)=>l(h),clearValue:()=>l(0)})},[o,a,t,l]),(0,K.useEffect)(()=>{l(Number(e.initialCount)||Number(r)||0)},[e.initialCount,l,r]);function u(c=1){i(h=>{var b;let d=m(h+1*c);return(b=e.onChange)==null||b.call(e,{value:d,event:"INCREMENT"}),d})}function p(c=1){i(h=>{var b;let d=m(h-1*c);return(b=e.onChange)==null||b.call(e,{value:d,event:"DECREMENT"}),d})}return(0,Uo.jsx)($o.Provider,{value:{count:a,increment:u,decrement:p,configureCount:l,multiplier:e.multiplier,maxCount:e.maxCount,minCount:e.minCount,editable:e.editable,label:e.label,labelPosition:e.labelPosition,buttonTransparent:e.buttonTransparent,groupElements:e.groupElements,error:n},children:e.children})}function Y(){let e=(0,K.useContext)($o);if(!e)throw new Error("useCounter must be used within a CounterProvider");return e}var Xo=R(require("styled-components/native")),Wo=require("@mobilestock-native/container");var qo=require("react/jsx-runtime");function fe(e){return(0,qo.jsx)(Vn,C({align:"CENTER"},e))}var Vn=(0,Xo.default)(Wo.Container.Vertical)`
1
+ "use strict";var ai=Object.create;var Xe=Object.defineProperty,li=Object.defineProperties,si=Object.getOwnPropertyDescriptor,ui=Object.getOwnPropertyDescriptors,mi=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols,ci=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable;var jt=(e,t,o)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,v=(e,t)=>{for(var o in t||(t={}))It.call(t,o)&&jt(e,o,t[o]);if(nt)for(var o of nt(t))eo.call(t,o)&&jt(e,o,t[o]);return e},R=(e,t)=>li(e,ui(t));var L=(e,t)=>{var o={};for(var a in e)It.call(e,a)&&t.indexOf(a)<0&&(o[a]=e[a]);if(e!=null&&nt)for(var a of nt(e))t.indexOf(a)<0&&eo.call(e,a)&&(o[a]=e[a]);return o};var pi=(e,t)=>{for(var o in t)Xe(e,o,{get:t[o],enumerable:!0})},to=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mi(t))!It.call(e,i)&&i!==o&&Xe(e,i,{get:()=>t[i],enumerable:!(a=si(t,i))||a.enumerable});return e};var A=(e,t,o)=>(o=e!=null?ai(ci(e)):{},to(t||!e||!e.__esModule?Xe(o,"default",{value:e,enumerable:!0}):o,e)),di=e=>to(Xe({},"__esModule",{value:!0}),e);var be=(e,t,o)=>new Promise((a,i)=>{var s=r=>{try{u(o.next(r))}catch(l){i(l)}},n=r=>{try{u(o.throw(r))}catch(l){i(l)}},u=r=>r.done?a(r.value):Promise.resolve(r.value).then(s,n);u((o=o.apply(e,t)).next())});var Mi={};pi(Mi,{Form:()=>Oi,useForm:()=>z});module.exports=di(Mi);var mo=require("@mobilestock-native/button");var Se=require("react");var io=require("@unform/mobile"),ae=require("react"),ao=require("zod"),lo=require("@mobilestock-native/container"),so=require("@mobilestock-native/modalalert");var We=new Map;function wt(e){let t=We.get(e);return t||(t={formRef:null,values:{},watchedFields:new Set,listeners:new Set},We.set(e,t)),t}function oo(e,t){let o=wt(e);o.formRef=t}function ro(e){let t=We.get(e);t&&(t.formRef=null,t.values={},t.watchedFields.clear(),t.listeners.clear(),We.delete(e))}function no(e,t,o){let a=We.get(e);!a||!a.watchedFields.has(t)||a.values[t]===o||(a.values=R(v({},a.values),{[t]:o}),a.listeners.forEach(i=>i()))}var Ne=require("react/jsx-runtime"),Nt=(0,ae.createContext)({});function uo(u){var r=u,{children:e,onSubmit:t,onBeforeSubmit:o,onAfterSubmit:a,schema:i,name:s}=r,n=L(r,["children","onSubmit","onBeforeSubmit","onAfterSubmit","schema","name"]);let l=(0,ae.useRef)(null),[c,g]=(0,ae.useState)(!1),[m,b]=(0,ae.useState)(void 0);(0,ae.useEffect)(()=>{if(s)return oo(s,l),()=>ro(s)},[s]);let E=(0,ae.useCallback)((h,d)=>{s&&no(s,h,d)},[s]);function S(){var h;(h=l.current)==null||h.submitForm()}function y(){var h,d;(h=l.current)==null||h.setErrors({}),(d=l.current)==null||d.reset()}function C(h){let d={};for(let F of h){let p=F.path.filter(I=>typeof I=="string"||typeof I=="number").join(".");p&&(d[String(p)]=F.message)}return d}function T(h){if(h instanceof ao.ZodError)return C(h.issues);if(typeof h=="object"&&h!==null&&"errors"in h){let d=h.errors;if(Array.isArray(d)&&d.length>0&&"message"in d[0]&&"path"in d[0])return C(d)}return null}function P(F,p){return be(this,arguments,function*(h,{reset:d}){var I,ee,$,q,ge;if((I=l.current)==null||I.setErrors({}),i){let U=i.safeParse(h);if(!U.success){(ee=l.current)==null||ee.setErrors(C(U.error.issues));return}}if(!(o&&(yield o({data:h}))===!1))try{g(!0),yield t==null?void 0:t({data:h,ref:l,reset:d}),yield a==null?void 0:a({data:h})}catch(U){let w=T(U);if(w)($=l.current)==null||$.setErrors(w);else{let M="Erro ao realizar opera\xE7\xE3o",O=500;if(typeof U=="object"&&U!==null&&"isAxiosError"in U&&U.isAxiosError){let X=U;O=((q=X.response)==null?void 0:q.status)||500;let te=(ge=X.response)==null?void 0:ge.data;te!=null&&te.message&&(M=te.message)}else U instanceof Error&&(M=U.message||M);b({message:M,status:O})}}finally{g(!1)}})}return(0,Ne.jsxs)(Nt.Provider,{value:{formRef:l,submitForm:S,clearForm:y,loading:c,notifyFieldChange:E},children:[(0,Ne.jsx)(io.Form,R(v({ref:l,onSubmit:P},n),{children:(0,Ne.jsx)(lo.Container.Vertical,{gap:"2XS",children:e})})),(0,Ne.jsx)(so.ModalAlert,{visible:!!m,message:m==null?void 0:m.message,type:m&&m.status>=500?"FATAL_ERROR":"ERROR_NOTICE",title:"Erro ao enviar o formul\xE1rio",onClose:()=>b(void 0)})]})}var fi={};function z(e){let t=(0,Se.useContext)(Nt),o=e?wt(e):null,a=(0,Se.useCallback)(n=>o?(o.listeners.add(n),()=>{o.listeners.delete(n)}):()=>{},[o]),i=(0,Se.useCallback)(()=>o?o.values:fi,[o]),s=(0,Se.useSyncExternalStore)(a,i);return!e||!o?t:{get values(){var n,u,r;return(r=(u=(n=o.formRef)==null?void 0:n.current)==null?void 0:u.getData())!=null?r:{}},getValue(n){var u,r;return o.watchedFields.add(n),n in s?s[n]:(r=(u=o.formRef)==null?void 0:u.current)==null?void 0:r.getFieldValue(n)},setValue(n,u){var r,l;(l=(r=o.formRef)==null?void 0:r.current)==null||l.setFieldValue(n,u)},submit(){var n,u;(u=(n=o.formRef)==null?void 0:n.current)==null||u.submitForm()},clear(){var n,u,r,l;(u=(n=o.formRef)==null?void 0:n.current)==null||u.setErrors({}),(l=(r=o.formRef)==null?void 0:r.current)==null||l.reset()},setErrors(n){var u,r;(r=(u=o.formRef)==null?void 0:u.current)==null||r.setErrors(n)},reset(n){var u,r;(r=(u=o.formRef)==null?void 0:u.current)==null||r.reset(n)}}}var po=require("react/jsx-runtime");function co(s){var n=s,{type:e="SUBMIT",disabled:t,isLoading:o,onPress:a}=n,i=L(n,["type","disabled","isLoading","onPress"]);let{submitForm:u,clearForm:r,loading:l}=z();function c(g){switch(e){case"SUBMIT":u();break;case"RESET":r();break;default:a==null||a(g)}}return(0,po.jsx)(mo.Button,R(v({size:"LG"},i),{onPress:c,isLoading:e==="SUBMIT"&&l||o,disabled:l||o||t}))}var At=A(require("styled-components/native")),Eo=require("@mobilestock-native/badge"),yo=require("@mobilestock-native/container"),So=A(require("@mobilestock-native/tools")),Po=require("@mobilestock-native/typography");var fo=require("@unform/core"),oe=require("react");var bo=require("react/jsx-runtime"),go=(0,oe.createContext)(void 0);function ho(e){let{notifyFieldChange:t}=z(),{fieldName:o,registerField:a,error:i,defaultValue:s}=(0,fo.useField)(e.name),[n,u]=(0,oe.useState)(0),r=(0,oe.useCallback)(m=>{let b=m;return e.maxCount!==void 0&&b>e.maxCount&&(b=e.maxCount),e.minCount!==void 0&&b<e.minCount&&(b=e.minCount),b},[e.maxCount,e.minCount]),l=(0,oe.useCallback)((m,b=!0)=>{var S;let E=r(m);u(E),t==null||t(o,E),b&&((S=e.onChange)==null||S.call(e,{value:E,event:"EDIT"}))},[r,t,o]);(0,oe.useEffect)(()=>{a({name:o,getValue:()=>n,setValue:(m,b)=>l(b),clearValue:()=>l(0)})},[o,n,a,l]),(0,oe.useEffect)(()=>{l(Number(e.initialCount)||Number(s)||0,!1)},[e.initialCount,l,s]);function c(m=1){u(b=>{var S;let E=r(b+1*m);return t==null||t(o,E),(S=e.onChange)==null||S.call(e,{value:E,event:"INCREMENT"}),E})}function g(m=1){u(b=>{var S;let E=r(b-1*m);return t==null||t(o,E),(S=e.onChange)==null||S.call(e,{value:E,event:"DECREMENT"}),E})}return(0,bo.jsx)(go.Provider,{value:{count:n,increment:c,decrement:g,configureCount:l,multiplier:e.multiplier,maxCount:e.maxCount,minCount:e.minCount,editable:e.editable,label:e.label,labelPosition:e.labelPosition,buttonTransparent:e.buttonTransparent,groupElements:e.groupElements,error:i,autoFocus:e.autoFocus,onFocus:e.onFocus,onBlur:e.onBlur},children:e.children})}function re(){let e=(0,oe.useContext)(go);if(!e)throw new Error("useCounter must be used within a CounterProvider");return e}var Co=A(require("styled-components/native")),To=require("@mobilestock-native/container");var vo=require("react/jsx-runtime");function Pe(e){return(0,vo.jsx)(gi,v({align:"CENTER"},e))}var gi=(0,Co.default)(To.Container.Vertical)`
2
2
  min-width: 40px;
3
3
  height: 34px;
4
4
  user-select: none;
5
- `;var Le=require("react/jsx-runtime");function Ae(e){let{groupElements:o}=Y();return(0,Le.jsx)(fe,{children:o&&e.renderInsidePill?(0,Le.jsx)(Mn,{$type:e.type,full:!0,align:"CENTER",children:(0,Le.jsx)(On,{$type:e.type,children:e.text})}):(0,Le.jsx)(Ko.Badge,{text:e.text,type:e.type,size:"XS"})})}function Qo(e,o){return Object.keys(o.colors.badge).find(t=>t.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var Mn=(0,so.default)(Yo.Container.Vertical)`
6
- background-color: ${({$type:e,theme:o})=>{let t=Qo(e,o);return o.colors.badge[t]}};
5
+ `;var Ke=require("react/jsx-runtime");function qe(e){let{groupElements:t}=re();return(0,Ke.jsx)(Pe,{children:t&&e.renderInsidePill?(0,Ke.jsx)(hi,{$type:e.type,full:!0,align:"CENTER",children:(0,Ke.jsx)(bi,{$type:e.type,children:e.text})}):(0,Ke.jsx)(Eo.Badge,{text:e.text,type:e.type,size:"XS"})})}function Fo(e,t){return Object.keys(t.colors.badge).find(o=>o.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var hi=(0,At.default)(yo.Container.Vertical)`
6
+ background-color: ${({$type:e,theme:t})=>{let o=Fo(e,t);return t.colors.badge[o]}};
7
7
  width: 100%;
8
- `,On=(0,so.default)(Jo.Typography)`
9
- color: ${({$type:e,theme:o})=>{let t=Qo(e,o);return Zo.default.defineTextColor(o.colors.badge[t])}};
10
- `;Ae.displayName="Form.FormCounter.Badge";var ne=require("react"),Z=require("@mobilestock-native/container"),it=R(require("@mobilestock-native/tools"));var Ve=R(require("styled-components/native")),jo=require("@mobilestock-native/container");var et=require("react/jsx-runtime");function Ee(t){var n=t,{children:e}=n,o=I(n,["children"]);let{groupElements:r,error:a}=Y();return(0,et.jsx)(Dn,E(C({align:"CENTER",$groupElements:r,$error:!!a},o),{children:e}))}var Dn=(0,Ve.default)(jo.Container.Horizontal)`
8
+ `,bi=(0,At.default)(Po.Typography)`
9
+ color: ${({$type:e,theme:t})=>{let o=Fo(e,t);return So.default.defineTextColor(t.colors.badge[o])}};
10
+ `;qe.displayName="Form.FormCounter.Badge";var pe=require("react"),ne=require("@mobilestock-native/container"),Ho=A(require("@mobilestock-native/tools"));var Ye=A(require("styled-components/native")),xo=require("@mobilestock-native/container");var Ro=require("react/jsx-runtime");function Ae(o){var a=o,{children:e}=a,t=L(a,["children"]);let{groupElements:i,error:s}=re();return(0,Ro.jsx)(Ci,R(v({align:"CENTER",$groupElements:i,$error:!!s},t),{children:e}))}var Ci=(0,Ye.default)(xo.Container.Horizontal)`
11
11
  border-radius: ${({theme:e})=>e.borderRadius.default};
12
12
  overflow: hidden;
13
13
  background-color: transparent;
14
14
  border: none;
15
- ${({$groupElements:e,theme:o})=>e&&Ve.css`
16
- background-color: ${o.colors.input.default};
15
+ ${({$groupElements:e,theme:t})=>e&&Ye.css`
16
+ background-color: ${t.colors.input.default};
17
17
 
18
- border: 1px solid ${o.colors.input.border};
18
+ border: 1px solid ${t.colors.input.border};
19
19
  `}
20
- ${({$error:e,theme:o})=>e&&Ve.css`
21
- background-color: ${o.colors.input.error};
22
- border: 1px solid ${o.colors.alert.urgent};
20
+ ${({$error:e,theme:t})=>e&&Ye.css`
21
+ background-color: ${t.colors.input.error};
22
+ border: 1px solid ${t.colors.alert.urgent};
23
23
  `}
24
- `;var ot=require("@mobilestock-native/typography"),tt=require("react/jsx-runtime");function re({children:e}){return(0,tt.jsx)(ot.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var rt=require("@mobilestock-native/typography"),nt=require("react/jsx-runtime");function me({children:e}){return(0,nt.jsx)(rt.Typography,{weight:"REGULAR",children:e})}var w=require("react/jsx-runtime");function at({children:e}){let{label:o,error:t,labelPosition:n}=Y(),r=[],a=[],i=(0,ne.useCallback)(l=>(0,ne.isValidElement)(l)&&l.type===ne.Fragment?i(l.props.children):l,[]),m=i(e);return ne.Children.toArray(m).forEach(l=>{(0,ne.isValidElement)(l)&&it.default.isComponentWithDisplayName(l.type)&&l.type.displayName===Ae.displayName&&!l.props.renderInsidePill?r.push(l):a.push(l)}),(0,w.jsxs)(Z.Container.Vertical,{align:"CENTER_START",children:[n==="TOP_START"&&o&&(0,w.jsxs)(Z.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,w.jsx)(me,{children:o}),t&&!r.length&&(0,w.jsx)(re,{children:t})]}),n!=="LEFT"&&(0,w.jsxs)(Z.Container.Vertical,{align:"CENTER",children:[(n!=="TOP_START"&&o||n!=="TOP_START"&&t&&!r.length)&&(0,w.jsxs)(Z.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[o&&(0,w.jsx)(me,{children:o}),t&&!r.length&&(0,w.jsx)(re,{children:t})]}),(0,w.jsxs)(Z.Container.Horizontal,{align:"CENTER_START",children:[r.length>0&&(0,w.jsx)(Z.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,w.jsxs)(Z.Container.Vertical,{children:[(0,w.jsx)(Ee,{children:a}),t&&!!r.length&&(0,w.jsx)(re,{children:t})]})]})]}),n==="LEFT"&&(0,w.jsx)(Z.Container.Vertical,{children:(0,w.jsxs)(Z.Container.Horizontal,{align:"CENTER",children:[(0,w.jsxs)(Z.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[o&&(0,w.jsx)(me,{children:o}),t&&!r.length&&(0,w.jsx)(re,{children:t})]}),r.length>0&&(0,w.jsx)(Z.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,w.jsx)(Ee,{children:a})]})})]})}var ue=require("@mobilestock-native/container");var lt=require("react"),st=require("react-native"),mt=R(require("styled-components/native")),ut=require("@mobilestock-native/button");var mo=require("react/jsx-runtime");function ie(n){var r=n,{type:e,disabled:o}=r,t=I(r,["type","disabled"]);let{loading:a}=q(),i=Y(),m=(0,lt.useMemo)(()=>e==="PLUS"&&i.maxCount!==void 0?i.count>=i.maxCount:e==="MINUS"&&i.minCount!==void 0?i.count<=i.minCount:!1,[e,i.count,i.maxCount,i.minCount]);function l(){e==="PLUS"?i.increment():i.decrement()}function u(){st.Vibration.vibrate(50),e==="PLUS"?i.increment(i.multiplier):i.decrement(i.multiplier)}return(0,mo.jsx)(fe,{children:(0,mo.jsx)(Hn,E(C({backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},t),{size:"SM",icon:e==="PLUS"?"Plus":"Minus",variant:i.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:i.groupElements,disabled:m||o||a,onPress:l,onLongPress:u,delayLongPress:500}))})}var Hn=(0,mt.default)(ut.Button)`
25
- border-radius: ${({$grouped:e,theme:o})=>e?o.borderRadius.none:o.borderRadius.default};
26
- `;var Me=require("react"),pt=require("react-native"),ct=require("styled-components/native"),dt=require("@mobilestock-native/clickable"),uo=require("@mobilestock-native/container"),po=require("@mobilestock-native/typography");var ae=require("react/jsx-runtime");function ve(){let e=(0,ct.useTheme)(),{count:o,editable:t,configureCount:n}=Y(),[r,a]=(0,Me.useState)(!1),[i,m]=(0,Me.useState)(o.toString());(0,Me.useEffect)(()=>{m(o.toString())},[o]);function l(u){n(Number(u.nativeEvent.text)||0),a(!1)}return t?(0,ae.jsx)(dt.Clickable,{onPress:()=>a(!0),children:(0,ae.jsx)(uo.Container.Horizontal,{padding:"NONE_2XS",children:(0,ae.jsx)(fe,{children:r?(0,ae.jsx)(pt.TextInput,{testID:"counter-input",value:i,keyboardType:"numeric",style:{fontWeight:"bold",fontSize:Number(e.font.size.lg)||16,textAlign:"center",width:40,height:40},autoFocus:!0,selectTextOnFocus:!0,onBlur:l,onChangeText:m,onEndEditing:l}):(0,ae.jsx)(po.Typography,{weight:"BOLD",size:"LG",children:o})})})}):(0,ae.jsx)(uo.Container.Horizontal,{padding:"NONE_2XS",children:(0,ae.jsx)(fe,{children:(0,ae.jsx)(po.Typography,{weight:"BOLD",size:"LG",children:o})})})}ve.displayName="Form.FormCounter.Display";var F=require("react/jsx-runtime");function ft(){let{label:e,labelPosition:o,error:t}=Y();return(0,F.jsxs)(ue.Container.Vertical,{align:"CENTER_START",children:[o==="TOP_START"&&e&&(0,F.jsxs)(ue.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,F.jsx)(me,{children:e}),t&&(0,F.jsx)(re,{children:t})]}),o!=="LEFT"&&(0,F.jsxs)(ue.Container.Vertical,{align:"CENTER",children:[o!=="TOP_START"&&(e||t)&&(0,F.jsxs)(ue.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,F.jsx)(me,{children:e}),t&&(0,F.jsx)(re,{children:t})]}),(0,F.jsxs)(Ee,{children:[(0,F.jsx)(ie,{type:"MINUS"}),(0,F.jsx)(ve,{}),(0,F.jsx)(ie,{type:"PLUS"})]})]}),o==="LEFT"&&(0,F.jsx)(ue.Container.Vertical,{children:(0,F.jsxs)(ue.Container.Horizontal,{align:"CENTER",children:[(e||t)&&(0,F.jsxs)(ue.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,F.jsx)(me,{children:e}),t&&(0,F.jsx)(re,{children:t})]}),(0,F.jsxs)(Ee,{children:[(0,F.jsx)(ie,{type:"MINUS"}),(0,F.jsx)(ve,{}),(0,F.jsx)(ie,{type:"PLUS"})]})]})})]})}var Be=require("react/jsx-runtime");function gt(t){var n=t,{children:e}=n,o=I(n,["children"]);return(0,Be.jsx)(Go,E(C({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},o),{children:e?(0,Be.jsx)(at,{children:e}):(0,Be.jsx)(ft,{})}))}var ht=require("react/jsx-runtime");function co(e){return(0,ht.jsx)(ie,E(C({},e),{type:"MINUS"}))}co.displayName="Form.FormCounter.Minus";var Ct=require("react/jsx-runtime");function fo(e){return(0,Ct.jsx)(ie,E(C({},e),{type:"PLUS"}))}fo.displayName="Form.FormCounter.Plus";var bt=Object.assign(gt,{Display:ve,Plus:fo,Minus:co,Badge:Ae});var Tt=require("@mobilestock-native/container");var vt=require("react/jsx-runtime");function Et(t){var n=t,{children:e}=n,o=I(n,["children"]);return(0,vt.jsx)(Tt.Container.Horizontal,E(C({gap:"SM"},o),{children:e}))}var yt=require("@unform/core"),k=require("react"),Pt=require("react-native"),ye=R(require("styled-components/native")),St=require("@mobilestock-native/button"),Co=require("@mobilestock-native/container"),go=R(require("@mobilestock-native/tools")),ho=require("@mobilestock-native/typography");var pe=require("react/jsx-runtime"),Ft=(0,k.forwardRef)(function(d,h){var b=d,{name:o,label:t,defaultValue:n,type:r="text",autoSubmit:a=!1,format:i,onChangeText:m,autoCapitalize:l,full:u,maxLength:p}=b,c=I(b,["name","label","defaultValue","type","autoSubmit","format","onChangeText","autoCapitalize","full","maxLength"]);let{loading:g,submitForm:f}=q(),s=(0,yt.useField)(o),v=(0,k.useRef)(null),[S,A]=(0,k.useState)(!0),[D,T]=(0,k.useState)(""),V=r==="password",Q=r==="tel"?15:r==="zipcode"?9:p;(0,k.useEffect)(()=>{let x=D||n||(s==null?void 0:s.defaultValue)||"";v.current.value=x,T(x),s.registerField({name:s.fieldName,ref:v.current,getValue(P){return(P==null?void 0:P.value)||""},setValue(P,y){P.value=y,T(y)},clearValue(P){P.value="",T("")}})},[s==null?void 0:s.fieldName,s==null?void 0:s.registerField]),(0,k.useImperativeHandle)(h,()=>({focus(){var x;(x=v.current)==null||x.focus()},blur(){var x;(x=v.current)==null||x.blur()}}));let z=(0,k.useCallback)(x=>{var y,N;let P=x;switch(r){case"tel":P=go.default.phoneNumberFormatter(x);break;case"email":case"url":P=x.trim();break;case"number":P=x.replace(/[^0-9.,]/g,"");break;case"zipcode":P=go.default.formatZipcode(P);break}i&&(P=i(P)),T(P),v.current.value=P,m==null||m(P),r==="tel"&&a&&P.length===15&&((y=v.current)==null||y.blur(),f()),r==="zipcode"&&a&&P.length===9&&((N=v.current)==null||N.blur(),f())},[r,i,a,m,s]),be=(0,k.useCallback)(()=>{switch(r){case"tel":return"phone-pad";case"email":return"email-address";case"url":return"url";case"number":return"numeric";default:return"default"}},[r]);return(0,pe.jsxs)(zn,{full:u,$show:r!=="hidden",children:[t&&(0,pe.jsx)(ho.Typography,{children:t}),(0,pe.jsxs)(kn,{error:!!(s!=null&&s.error),$isPassword:V,children:[(0,pe.jsx)(Bn,E(C({},c),{ref:v,value:D,autoCapitalize:r&&["email","url"].includes(r)?"none":l,keyboardType:be(),secureTextEntry:S&&V,onChangeText:z,maxLength:Q,editable:!g&&c.editable})),V&&(0,pe.jsx)(St.Button,{size:"SM",onPress:()=>A(!S),icon:S?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),!!(s!=null&&s.error)&&(0,pe.jsx)(ho.Typography,{color:"DANGER",size:"SM",children:s.error})]})}),zn=(0,ye.default)(Co.Container.Vertical)`
27
- ${({$show:e})=>!e&&ye.css`
24
+ `;var Io=require("@mobilestock-native/typography"),wo=require("react/jsx-runtime");function ce({children:e}){return(0,wo.jsx)(Io.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var No=require("@mobilestock-native/typography"),Ao=require("react/jsx-runtime");function Ce({children:e}){return(0,Ao.jsx)(No.Typography,{weight:"REGULAR",children:e})}var V=require("react/jsx-runtime");function Lo({children:e}){let{label:t,error:o,labelPosition:a}=re(),i=[],s=[],n=(0,pe.useCallback)(r=>(0,pe.isValidElement)(r)&&r.type===pe.Fragment?n(r.props.children):r,[]),u=n(e);return pe.Children.toArray(u).forEach(r=>{(0,pe.isValidElement)(r)&&Ho.default.isComponentWithDisplayName(r.type)&&r.type.displayName===qe.displayName&&!r.props.renderInsidePill?i.push(r):s.push(r)}),(0,V.jsxs)(ne.Container.Vertical,{align:"CENTER_START",children:[a==="TOP_START"&&t&&(0,V.jsxs)(ne.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,V.jsx)(Ce,{children:t}),o&&!i.length&&(0,V.jsx)(ce,{children:o})]}),a!=="LEFT"&&(0,V.jsxs)(ne.Container.Vertical,{align:"CENTER",children:[(a!=="TOP_START"&&t||a!=="TOP_START"&&o&&!i.length)&&(0,V.jsxs)(ne.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[t&&(0,V.jsx)(Ce,{children:t}),o&&!i.length&&(0,V.jsx)(ce,{children:o})]}),(0,V.jsxs)(ne.Container.Horizontal,{align:"CENTER_START",children:[i.length>0&&(0,V.jsx)(ne.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:i}),(0,V.jsxs)(ne.Container.Vertical,{children:[(0,V.jsx)(Ae,{children:s}),o&&!!i.length&&(0,V.jsx)(ce,{children:o})]})]})]}),a==="LEFT"&&(0,V.jsx)(ne.Container.Vertical,{children:(0,V.jsxs)(ne.Container.Horizontal,{align:"CENTER",children:[(0,V.jsxs)(ne.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[t&&(0,V.jsx)(Ce,{children:t}),o&&!i.length&&(0,V.jsx)(ce,{children:o})]}),i.length>0&&(0,V.jsx)(ne.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:i}),(0,V.jsx)(Ae,{children:s})]})})]})}var Te=require("@mobilestock-native/container");var Vo=require("react"),Oo=require("react-native"),Mo=A(require("styled-components/native")),Do=require("@mobilestock-native/button");var Ht=require("react/jsx-runtime");function de(a){var i=a,{type:e,disabled:t}=i,o=L(i,["type","disabled"]);let{loading:s}=z(),n=re(),u=(0,Vo.useMemo)(()=>e==="PLUS"&&n.maxCount!==void 0?n.count>=n.maxCount:e==="MINUS"&&n.minCount!==void 0?n.count<=n.minCount:!1,[e,n.count,n.maxCount,n.minCount]);function r(){e==="PLUS"?n.increment():n.decrement()}function l(){Oo.Vibration.vibrate(50),e==="PLUS"?n.increment(n.multiplier):n.decrement(n.multiplier)}return(0,Ht.jsx)(Pe,{children:(0,Ht.jsx)(Ti,R(v({backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},o),{size:"SM",icon:e==="PLUS"?"Plus":"Minus",variant:n.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:n.groupElements,disabled:u||t||s,onPress:r,onLongPress:l,delayLongPress:500}))})}var Ti=(0,Mo.default)(Do.Button)`
25
+ border-radius: ${({$grouped:e,theme:t})=>e?t.borderRadius.none:t.borderRadius.default};
26
+ `;var Ze=require("react"),zo=require("react-native"),ko=require("styled-components/native"),Bo=require("@mobilestock-native/clickable"),Lt=require("@mobilestock-native/container"),Vt=require("@mobilestock-native/typography");var fe=require("react/jsx-runtime");function He(){let e=(0,ko.useTheme)(),{count:t,editable:o,configureCount:a,autoFocus:i,onFocus:s,onBlur:n}=re(),[u,r]=(0,Ze.useState)(i&&o),[l,c]=(0,Ze.useState)(t.toString());(0,Ze.useEffect)(()=>{c(t.toString())},[t]);function g(m){a(Number(m.nativeEvent.text)||0),r(!1),n==null||n()}return o?(0,fe.jsx)(Bo.Clickable,{onPress:()=>r(!0),children:(0,fe.jsx)(Lt.Container.Horizontal,{padding:"NONE_2XS",children:(0,fe.jsx)(Pe,{children:u?(0,fe.jsx)(zo.TextInput,{testID:"counter-input",value:l,keyboardType:"numeric",style:{fontWeight:"bold",fontSize:Number(e.font.size.lg)||16,textAlign:"center",width:40,height:40},autoFocus:!0,selectTextOnFocus:!0,onFocus:()=>s==null?void 0:s(),onBlur:g,onChangeText:c,onEndEditing:g}):(0,fe.jsx)(Vt.Typography,{weight:"BOLD",size:"LG",children:t})})})}):(0,fe.jsx)(Lt.Container.Horizontal,{padding:"NONE_2XS",children:(0,fe.jsx)(Pe,{children:(0,fe.jsx)(Vt.Typography,{weight:"BOLD",size:"LG",children:t})})})}He.displayName="Form.FormCounter.Display";var H=require("react/jsx-runtime");function _o(){let{label:e,labelPosition:t,error:o}=re();return(0,H.jsxs)(Te.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,H.jsxs)(Te.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,H.jsx)(Ce,{children:e}),o&&(0,H.jsx)(ce,{children:o})]}),t!=="LEFT"&&(0,H.jsxs)(Te.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,H.jsxs)(Te.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,H.jsx)(Ce,{children:e}),o&&(0,H.jsx)(ce,{children:o})]}),(0,H.jsxs)(Ae,{children:[(0,H.jsx)(de,{type:"MINUS"}),(0,H.jsx)(He,{}),(0,H.jsx)(de,{type:"PLUS"})]})]}),t==="LEFT"&&(0,H.jsx)(Te.Container.Vertical,{children:(0,H.jsxs)(Te.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,H.jsxs)(Te.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,H.jsx)(Ce,{children:e}),o&&(0,H.jsx)(ce,{children:o})]}),(0,H.jsxs)(Ae,{children:[(0,H.jsx)(de,{type:"MINUS"}),(0,H.jsx)(He,{}),(0,H.jsx)(de,{type:"PLUS"})]})]})})]})}var it=require("react/jsx-runtime");function Go(o){var a=o,{children:e}=a,t=L(a,["children"]);return(0,it.jsx)(ho,R(v({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,it.jsx)(Lo,{children:e}):(0,it.jsx)(_o,{})}))}var Uo=require("react/jsx-runtime");function Ot(e){return(0,Uo.jsx)(de,R(v({},e),{type:"MINUS"}))}Ot.displayName="Form.FormCounter.Minus";var $o=require("react/jsx-runtime");function Mt(e){return(0,$o.jsx)(de,R(v({},e),{type:"PLUS"}))}Mt.displayName="Form.FormCounter.Plus";var Xo=Object.assign(Go,{Display:He,Plus:Mt,Minus:Ot,Badge:qe});var Wo=require("@mobilestock-native/container");var qo=require("react/jsx-runtime");function Ko(o){var a=o,{children:e}=a,t=L(a,["children"]);return(0,qo.jsx)(Wo.Container.Horizontal,R(v({gap:"SM"},t),{children:e}))}var Yo=require("@unform/core"),N=require("react"),Le=require("react-native"),Fe=A(require("styled-components/native")),Zo=require("@mobilestock-native/button"),zt=require("@mobilestock-native/container"),Dt=A(require("@mobilestock-native/tools")),at=require("@mobilestock-native/typography");var le=require("react/jsx-runtime"),Jo=(0,N.forwardRef)(function(S,E){var y=S,{name:t,type:o="text",full:a,label:i,maxLength:s,autoSubmit:n=!1,defaultValue:u,numberOfLines:r=1,showMaxContent:l=!1,autoCapitalize:c,format:g,onChange:m}=y,b=L(y,["name","type","full","label","maxLength","autoSubmit","defaultValue","numberOfLines","showMaxContent","autoCapitalize","format","onChange"]);let C=(0,Fe.useTheme)(),{loading:T,submitForm:P,notifyFieldChange:h}=z(),d=(0,Yo.useField)(t),F=(0,N.useRef)(null),p=(0,N.useRef)(null),[I,ee]=(0,N.useState)(!0),[$,q]=(0,N.useState)(""),[ge,U]=(0,N.useState)(0),w=(0,N.useRef)(""),M=t+"-input"+(0,N.useId)(),O=o==="password",X=r>1,te=Le.Platform.OS==="web"&&X,Jt=o==="tel"?15:o==="zipcode"?9:s,Qt=Number(C.font.size.sm),Zn=Math.ceil(Qt*(Number(C.font.lineHeight)||1.5)),_e=10,Ge=Zn*r+_e,Jn={width:"100%",border:"none",outline:"none",backgroundColor:"transparent",fontFamily:C.font.families[0].name,lineHeight:Number(C.font.lineHeight)||1.5,fontSize:Qt,color:String(C.colors.text.default),padding:"10px 0",display:"block",resize:"none",overflow:"hidden",boxSizing:"border-box"},Qn=(0,N.useMemo)(()=>v({flex:1,outline:"none",color:C.colors.text.default,height:X?l?Ge:Math.min(Math.max(ge?ge+_e:45,45),Ge):45},X&&{paddingTop:_e/2,paddingBottom:_e/2}),[X,l,Ge,ge,_e,C]),jn=(0,N.useMemo)(()=>{switch(o){case"tel":return"phone-pad";case"email":return"email-address";case"url":return"url";case"number":return"numeric";default:return"default"}},[o]),et=(0,N.useCallback)(()=>{if(!te||!p.current)return;let x=p.current,f=window.getComputedStyle(x),D=parseInt(f.lineHeight,10);isNaN(D)&&(D=parseInt(f.fontSize,10)*(Number(C.font.lineHeight)||1.5));let ye=parseInt(f.paddingTop,10),he=parseInt(f.paddingBottom,10),ot=D*r+ye+he+1,$e=parseFloat(getComputedStyle(document.documentElement).fontSize)*2.5;if(l)x.style.height=ot+"px";else{x.style.height="0";let rt=x.scrollHeight;x.style.height=Math.max($e,Math.min(rt,ot))+"px"}},[te,r,l,C.font.lineHeight]),ei=(0,N.useCallback)(x=>{let f=x.nativeEvent.contentSize.height;if(X&&r&&f>Ge){q(w.current),F.current.value=w.current;return}U(f)},[X,r,Ge]),tt=(0,N.useCallback)(x=>{let f=x;switch(o){case"tel":f=Dt.default.phoneNumberFormatter(x);break;case"email":case"url":f=x.trim();break;case"number":f=x.replace(/[^0-9.,]/g,"");break;case"zipcode":f=Dt.default.formatZipcode(f);break}return g&&(f=g(f)),f},[o,g]),ti=(0,N.useCallback)(x=>{var D,ye;let f=tt(x.target.value);if(r&&p.current){let he=p.current;he.value=f,he.style.height="auto";let ot=he.scrollHeight,Ue=window.getComputedStyle(he),$e=parseInt(Ue.lineHeight,10);isNaN($e)&&($e=parseInt(Ue.fontSize,10)*(Number(C.font.lineHeight)||1.5));let rt=parseInt(Ue.paddingTop,10),ni=parseInt(Ue.paddingBottom,10),ii=$e*(r+1)+rt+ni+1;if(ot>ii){he.value=$,et();return}}q(f),x.target.value=f,p.current&&(p.current.value=f),m==null||m({value:f,event:"INPUT_CHANGE"}),h==null||h(t,f),o==="tel"&&n&&f.length===15&&(m==null||m({value:f,event:"AUTO_SUBMIT"}),(D=p.current)==null||D.blur(),P()),o==="zipcode"&&n&&f.length===9&&(m==null||m({value:f,event:"AUTO_SUBMIT"}),(ye=p.current)==null||ye.blur(),P())},[tt,r,$,et,m,h,t,n,o,P,C.font.lineHeight]),oi=(0,N.useCallback)(x=>{var D,ye;let f=tt(x);X&&r&&f.split(`
27
+ `).length>r||(q(f),F.current.value=f,w.current=f,m==null||m({value:f,event:"INPUT_CHANGE"}),h==null||h(t,f),o==="tel"&&n&&f.length===15&&(m==null||m({value:f,event:"AUTO_SUBMIT"}),(D=F.current)==null||D.blur(),P()),o==="zipcode"&&n&&f.length===9&&(m==null||m({value:f,event:"AUTO_SUBMIT"}),(ye=F.current)==null||ye.blur(),P()))},[tt,n,m,h,X,r,$,t,o,P]);(0,N.useEffect)(()=>{et()},[$,et]),(0,N.useEffect)(()=>{let x=$||u||(d==null?void 0:d.defaultValue)||"";te?p.current&&(p.current.value=x):F.current.value=x,q(x),te?d.registerField({name:d.fieldName,ref:p,getValue:f=>{var D;return((D=f.current)==null?void 0:D.value)||""},setValue:(f,D)=>{f.current&&(f.current.value=D,q(D))},clearValue:f=>{f.current&&(f.current.value="",q(""))}}):d.registerField({name:d.fieldName,ref:F.current,getValue(f){return(f==null?void 0:f.value)||""},setValue(f,D){f.value=D,q(D)},clearValue(f){f.value="",q("")}})},[d==null?void 0:d.fieldName,d==null?void 0:d.registerField]),(0,N.useImperativeHandle)(E,()=>({focus(){var x,f;te?(x=p.current)==null||x.focus():(f=F.current)==null||f.focus()},blur(){var x,f;te?(x=p.current)==null||x.blur():(f=F.current)==null||f.blur()}}));function ri(){ee(x=>(m==null||m({value:!x,event:"TOGGLE_PASSWORD"}),!x))}return(0,le.jsxs)(vi,{full:a,$show:o!=="hidden",children:[i&&Le.Platform.OS==="android"&&(0,le.jsx)(at.Typography,{children:i}),i&&Le.Platform.OS==="web"&&(0,le.jsx)("label",{htmlFor:M,children:(0,le.jsx)(at.Typography,{children:i})}),(0,le.jsxs)(Ei,{$error:!!(d!=null&&d.error),$isPassword:O,children:[te?(0,le.jsx)("textarea",{ref:p,id:M,value:$,onChange:ti,maxLength:Jt,disabled:T||b.editable===!1,placeholder:b.placeholder,autoFocus:b.autoFocus,style:Jn}):(0,le.jsx)(Le.TextInput,R(v({},b),{ref:F,id:M,value:$,autoCapitalize:o&&["email","url"].includes(o)?"none":c,keyboardType:jn,secureTextEntry:I&&O,onChangeText:oi,maxLength:Jt,editable:!T&&b.editable,multiline:X,numberOfLines:r,textAlignVertical:X?"top":"center",onContentSizeChange:X?ei:void 0,scrollEnabled:!1,style:Qn})),O&&(0,le.jsx)(Zo.Button,{size:"SM",onPress:ri,icon:I?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),!!(d!=null&&d.error)&&(0,le.jsx)(at.Typography,{color:"DANGER",size:"SM",children:d.error})]})}),vi=(0,Fe.default)(zt.Container.Vertical)`
28
+ ${({$show:e})=>!e&&Fe.css`
28
29
  display: none;
29
30
  `}
30
- `,kn=(0,ye.default)(Co.Container.Horizontal)`
31
+ `,Ei=(0,Fe.default)(zt.Container.Horizontal)`
31
32
  overflow: hidden;
32
- background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
33
- border: 1px solid ${({error:e,theme:o})=>e?o.colors.alert.urgent:o.colors.input.border};
33
+ background-color: ${({$error:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
34
+ border: 1px solid ${({$error:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
34
35
  border-radius: ${({theme:e})=>e.borderRadius.default};
35
36
  padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
36
- `,Bn=(0,ye.default)(Pt.TextInput)`
37
- flex: 1;
38
- height: 45px;
39
- color: ${({theme:e})=>e.colors.text.default};
40
- `;var rr=require("@unform/core"),nr=require("react"),ir=require("react-native"),ar=R(require("styled-components/native")),Ye=require("@mobilestock-native/container");var It=require("@unform/core"),Rt=R(require("expo-document-picker")),wt=require("expo-media-library"),$=require("react"),xt=require("react-native");var B={getHashFile(e){return`${e.name}-${e.size}`}};var bo=(a=>(a.json="application/json",a.png="image/png",a.jpg="image/jpg",a.jpeg="image/jpeg",a.all="*/*",a))(bo||{});var At=require("react/jsx-runtime"),Nt=(0,$.createContext)(null);function Lt({children:e,accept:o,onChange:t,name:n}){let{fieldName:r,registerField:a,defaultValue:i}=(0,It.useField)(n),[m,l]=(0,wt.usePermissions)({granularPermissions:["photo"]}),[u,p]=(0,$.useState)(null),c=(0,$.useCallback)(g=>{let f=g.map(T=>({file:T,hash:B.getHashFile(T)})),s=(u||[]).map(T=>({file:T,hash:B.getHashFile(T)})),v=[...f,...s],S=Array.from(new Set(v.map(T=>T.hash))).map(T=>v.find(V=>V.hash===T)),A=S.filter(T=>f.some(V=>V.hash===T.hash));if(!A.length)return;let D=S.map(T=>T.file);p(D),t==null||t({value:A.map(T=>T.file),event:"ADD_FILES"})},[u,t]),h=(0,$.useCallback)(g=>{if(!g){p(null);return}let f=g.filter(s=>!!s);c(f)},[c,p]);(0,$.useEffect)(()=>{a({name:r,getValue:()=>u,setValue:(g,f)=>h(f||i),clearValue:()=>p(null)})},[r,a,u,h,i]),(0,$.useEffect)(()=>{m!=null&&m.granted||l()},[m,l]),(0,$.useEffect)(()=>{p(null)},[o]);function d(g){if(!u)return;let f=u.filter(s=>B.getHashFile(s)!==g);p(f),t==null||t({value:u.find(s=>B.getHashFile(s)===g),event:"REMOVE_FILE"})}function b(){return se(this,null,function*(){let g=yield Rt.getDocumentAsync({multiple:!0,type:o==null?void 0:o.map(s=>bo[s])});if(!g.assets)return;if(xt.Platform.OS==="android"){c(g.assets.map(s=>({uri:s.uri,name:s.name,type:s.mimeType})));return}let f=g.assets.map(s=>s.file).filter(s=>!!s);f.length&&c(f)})}return(0,At.jsx)(Nt.Provider,{value:{handleSelectFile:b,handleSaveFiles:c,handleRemoveFile:d,accept:o,files:u,name:n},children:e})}function J(){let e=(0,$.useContext)(Nt);if(e===null)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var _e={convertBytesToReadableFormat(e){return e>=1073741824?(e/1073741824).toFixed(2)+" GB":e>=1048576?(e/1048576).toFixed(2)+" MB":e>=1024?(e/1024).toFixed(2)+" KB":e+" B"},parseAcceptString(e){if(!e)return["all"];let o=["|",",",";"," ",`
41
- `," ","\r"];return typeof e=="string"?e.split(new RegExp(o.map(t=>`\\${t}`).join("|"))).map(t=>t.trim().replace(".","")).filter(t=>t.length>0):e}};var Bt=require("react-native"),_t=require("@mobilestock-native/container"),$t=require("@mobilestock-native/spacer");var Vt=require("@unform/core"),Mt=require("@mobilestock-native/typography");var Ot=require("react/jsx-runtime");function $e(){let e=J(),{error:o}=(0,Vt.useField)(e.name);return(0,Ot.jsx)(Mt.Typography,{color:"DANGER",size:"XS",children:o})}var Dt=require("@mobilestock-native/button");var Ht=require("react/jsx-runtime");function Ge(){let e=J();return(0,Ht.jsx)(Dt.Button,{text:"Selecionar arquivo",size:"XS",onPress:e.handleSelectFile})}var Ue=require("@mobilestock-native/typography");var ce=require("react/jsx-runtime");function Xe(){var o,t;let e=J();return(o=e.accept)!=null&&o.includes("all")?(0,ce.jsx)(Ue.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(Ue.Typography,{size:"XS",children:"Arquivos suportados"}),(0,ce.jsxs)(Ue.Typography,{size:"XS",children:["( ",(t=e.accept)==null?void 0:t.join(", ")," )"]})]})}var zt=require("@mobilestock-native/typography"),kt=require("react/jsx-runtime");function We({children:e}){return(0,kt.jsx)(zt.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var de=require("react/jsx-runtime");function Gt(){var o;let e=J();return(0,de.jsxs)(_t.Container.Vertical,{align:"CENTER",children:[Bt.Platform.OS==="web"?(0,de.jsx)(We,{}):null,(0,de.jsx)($t.Spacer,{size:"2XS"}),(0,de.jsx)(Ge,{}),(0,de.jsx)($e,{}),(o=e.accept)!=null&&o.includes("all")?null:(0,de.jsx)(Xe,{})]})}var Ut=R(require("chroma-js")),Xt=require("react"),Wt=require("react-native"),qt=require("styled-components/native");var Yt=require("react/jsx-runtime");function Kt(e){let o=J(),t=(0,qt.useTheme)(),[n,r]=(0,Xt.useState)(!1);function a(i){var u;i.preventDefault(),r(!1);let m=i.dataTransfer;if(!m)return;let l=[];if(m.items&&m.items.length>0)for(let p=0;p<m.items.length;p++){let c=m.items[p];if(c.kind!=="file")continue;let h=c.webkitGetAsEntry();if(h&&h.isDirectory)continue;let d=c.getAsFile();d&&l.push(d)}else if(m.files&&m.files.length>0)for(let p=0;p<m.files.length;p++){let c=m.files.item(p);c&&l.push(c)}l.length!==0&&((u=o.accept)!=null&&u.some(p=>p!=="all")&&(l=l.filter(p=>{var h;let c=p.name.split(".").pop();return(h=o.accept)==null?void 0:h.includes(c==null?void 0:c.toLowerCase())}),!l.length)||o.handleSaveFiles(l))}return Wt.Platform.OS!=="web"?e.children:(0,Yt.jsx)("div",C({onDragOver:i=>{i.preventDefault(),r(!0)},onDrop:a,onDragLeave:i=>{i.preventDefault(),r(!1)},style:C({},n?{backgroundColor:(0,Ut.default)(t.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:o.handleSelectFile},e))}var Ke=require("react"),G=R(require("react-native-reanimated")),Zt=require("@mobilestock-native/button"),Jt=require("@mobilestock-native/clickable"),Oe=require("@mobilestock-native/container"),Qt=require("@mobilestock-native/icons"),qe=require("@mobilestock-native/typography");var M=require("react/jsx-runtime");function _n(e){"worklet";switch(e){case 0:return 0;case 1:return 20;case 2:return 50;case 3:return 75;default:return 100}}function jt(){var i,m,l;let e=J(),o=(0,G.useSharedValue)(!1),t=(0,G.useSharedValue)(0),n=(0,Ke.useRef)(null);(0,Ke.useEffect)(()=>{var u;t.value=((u=e.files)==null?void 0:u.length)||0},[e.files,t]);let r=(0,G.useAnimatedStyle)(()=>({transform:[{rotate:(0,G.withSpring)(o.value?"180deg":"0deg")}]})),a=(0,G.useAnimatedStyle)(()=>{let u=_n(t.value);return{height:(0,G.withSpring)(o.value?u:0),opacity:(0,G.withSpring)(o.value?1:0)}},[n.current,t]);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(Oe.Container.Horizontal,{align:"END",children:!!((i=e.files)!=null&&i.length)&&(0,M.jsx)(Jt.Clickable,{onPress:()=>o.value=!o.value,children:(0,M.jsxs)(Oe.Container.Horizontal,{align:"CENTER",children:[(0,M.jsxs)(qe.Typography,{size:"XS",children:[(m=e.files)==null?void 0:m.length," arquivos"]}),(0,M.jsx)(G.default.View,{style:r,children:(0,M.jsx)(Qt.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,M.jsx)(G.default.ScrollView,{style:a,children:(l=e.files)==null?void 0:l.map((u,p)=>(0,M.jsxs)(Oe.Container.Horizontal,{align:"START_CENTER",children:[(0,M.jsxs)(Oe.Container.Horizontal,{gap:"SM",full:!0,children:[(0,M.jsx)(qe.Typography,{size:"XS",weight:"MEDIUM",children:u.name.slice(0,20)}),u.size&&(0,M.jsx)(qe.Typography,{size:"XS",children:_e.convertBytesToReadableFormat(u.size)})]}),(0,M.jsx)(Zt.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS",testID:"remove-file-button",onPress:()=>e.handleRemoveFile(B.getHashFile(u))})]},p))})]})}var er=require("@mobilestock-native/typography"),tr=require("react/jsx-runtime");function or({children:e}){return(0,tr.jsx)(er.Typography,{children:e})}var oe=require("react/jsx-runtime");function lr(t){var n=t,{accept:e}=n,o=I(n,["accept"]);let{error:r}=(0,rr.useField)(o.name),a=(0,nr.useMemo)(()=>_e.parseAcceptString(e),[e]);return(0,oe.jsx)(Lt,E(C({},o),{accept:a,children:(0,oe.jsxs)(Ye.Container.Vertical,{gap:"2XS",children:[(0,oe.jsx)(Ye.Container.Horizontal,{align:o.alignLabel||"START",children:(0,oe.jsx)(or,{children:o.label})}),(0,oe.jsxs)($n,{$error:!!r,$minWidth:ir.Platform.OS==="web"?"400px":"100%",padding:"MD",children:[(0,oe.jsx)(Kt,{children:o.children||(0,oe.jsx)(Gt,{})}),(0,oe.jsx)(jt,{})]})]})}))}var $n=(0,ar.default)(Ye.Container.Vertical)`
42
- border: 1px solid ${({theme:e,$error:o})=>o?e.colors.input.error:e.colors.input.border};
37
+ `;var wr=require("@unform/core"),Nr=require("react"),Ar=require("react-native"),Hr=A(require("styled-components/native")),gt=require("@mobilestock-native/container");var Qo=require("@unform/core"),jo=A(require("expo-document-picker")),er=require("expo-media-library"),Y=require("react"),tr=require("react-native");var W={getHashFile(e){return`${e.name}-${e.size}`}};var kt=(s=>(s.json="application/json",s.png="image/png",s.jpg="image/jpg",s.jpeg="image/jpeg",s.all="*/*",s))(kt||{});var nr=require("react/jsx-runtime"),or=(0,Y.createContext)(null);function rr({children:e,accept:t,onChange:o,name:a}){let{notifyFieldChange:i}=z(),{fieldName:s,registerField:n,defaultValue:u}=(0,Qo.useField)(a),[r,l]=(0,er.usePermissions)({granularPermissions:["photo"]}),[c,g]=(0,Y.useState)(null),m=(0,Y.useCallback)(y=>{let C=y.map(p=>({file:p,hash:W.getHashFile(p)})),T=(c||[]).map(p=>({file:p,hash:W.getHashFile(p)})),P=[...C,...T],h=Array.from(new Set(P.map(p=>p.hash))).map(p=>P.find(I=>I.hash===p)),d=h.filter(p=>C.some(I=>I.hash===p.hash));if(!d.length)return;let F=h.map(p=>p.file);g(F),i==null||i(s,F),o==null||o({value:d.map(p=>p.file),event:"ADD_FILES"})},[c,o,i,s]),b=(0,Y.useCallback)(y=>{if(!y){g(null);return}let C=y.filter(T=>!!T);m(C)},[m,g]);(0,Y.useEffect)(()=>{n({name:s,getValue:()=>c,setValue:(y,C)=>b(C||u),clearValue:()=>g(null)})},[s,n,c,b,u]),(0,Y.useEffect)(()=>{r!=null&&r.granted||l()},[r,l]),(0,Y.useEffect)(()=>{g(null)},[t]);function E(y){if(!c)return;let C=c.filter(T=>W.getHashFile(T)!==y);g(C),i==null||i(s,C),o==null||o({value:c.find(T=>W.getHashFile(T)===y),event:"REMOVE_FILE"})}function S(){return be(this,null,function*(){let y=yield jo.getDocumentAsync({multiple:!0,type:t==null?void 0:t.map(T=>kt[T])});if(!y.assets)return;if(tr.Platform.OS==="android"){m(y.assets.map(T=>({uri:T.uri,name:T.name,type:T.mimeType})));return}let C=y.assets.map(T=>T.file).filter(T=>!!T);C.length&&m(C)})}return(0,nr.jsx)(or.Provider,{value:{handleSelectFile:S,handleSaveFiles:m,handleRemoveFile:E,accept:t,files:c,name:a},children:e})}function ie(){let e=(0,Y.useContext)(or);if(e===null)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var lt={convertBytesToReadableFormat(e){return e>=1073741824?(e/1073741824).toFixed(2)+" GB":e>=1048576?(e/1048576).toFixed(2)+" MB":e>=1024?(e/1024).toFixed(2)+" KB":e+" B"},parseAcceptString(e){if(!e)return["all"];let t=["|",",",";"," ",`
38
+ `," ","\r"];return typeof e=="string"?e.split(new RegExp(t.map(o=>`\\${o}`).join("|"))).map(o=>o.trim().replace(".","")).filter(o=>o.length>0):e}};var pr=require("react-native"),dr=require("@mobilestock-native/container"),fr=require("@mobilestock-native/spacer");var ir=require("@unform/core"),ar=require("@mobilestock-native/typography");var lr=require("react/jsx-runtime");function st(){let e=ie(),{error:t}=(0,ir.useField)(e.name);return(0,lr.jsx)(ar.Typography,{color:"DANGER",size:"XS",children:t})}var sr=require("@mobilestock-native/button");var ur=require("react/jsx-runtime");function ut(){let e=ie();return(0,ur.jsx)(sr.Button,{text:"Selecionar arquivo",size:"XS",onPress:e.handleSelectFile})}var mt=require("@mobilestock-native/typography");var ve=require("react/jsx-runtime");function ct(){var t,o;let e=ie();return(t=e.accept)!=null&&t.includes("all")?(0,ve.jsx)(mt.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(mt.Typography,{size:"XS",children:"Arquivos suportados"}),(0,ve.jsxs)(mt.Typography,{size:"XS",children:["( ",(o=e.accept)==null?void 0:o.join(", ")," )"]})]})}var mr=require("@mobilestock-native/typography"),cr=require("react/jsx-runtime");function pt({children:e}){return(0,cr.jsx)(mr.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var Ee=require("react/jsx-runtime");function gr(){var t;let e=ie();return(0,Ee.jsxs)(dr.Container.Vertical,{align:"CENTER",children:[pr.Platform.OS==="web"?(0,Ee.jsx)(pt,{}):null,(0,Ee.jsx)(fr.Spacer,{size:"2XS"}),(0,Ee.jsx)(ut,{}),(0,Ee.jsx)(st,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,Ee.jsx)(ct,{})]})}var hr=A(require("chroma-js")),br=require("react"),Cr=require("react-native"),Tr=require("styled-components/native");var Er=require("react/jsx-runtime");function vr(e){let t=ie(),o=(0,Tr.useTheme)(),[a,i]=(0,br.useState)(!1);function s(n){var l;n.preventDefault(),i(!1);let u=n.dataTransfer;if(!u)return;let r=[];if(u.items&&u.items.length>0)for(let c=0;c<u.items.length;c++){let g=u.items[c];if(g.kind!=="file")continue;let m=g.webkitGetAsEntry();if(m&&m.isDirectory)continue;let b=g.getAsFile();b&&r.push(b)}else if(u.files&&u.files.length>0)for(let c=0;c<u.files.length;c++){let g=u.files.item(c);g&&r.push(g)}r.length!==0&&((l=t.accept)!=null&&l.some(c=>c!=="all")&&(r=r.filter(c=>{var m;let g=c.name.split(".").pop();return(m=t.accept)==null?void 0:m.includes(g==null?void 0:g.toLowerCase())}),!r.length)||t.handleSaveFiles(r))}return Cr.Platform.OS!=="web"?e.children:(0,Er.jsx)("div",v({onDragOver:n=>{n.preventDefault(),i(!0)},onDrop:s,onDragLeave:n=>{n.preventDefault(),i(!1)},style:v({},a?{backgroundColor:(0,hr.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var ft=require("react"),Z=A(require("react-native-reanimated")),yr=require("@mobilestock-native/button"),Sr=require("@mobilestock-native/clickable"),Je=require("@mobilestock-native/container"),Pr=require("@mobilestock-native/icons"),dt=require("@mobilestock-native/typography");var B=require("react/jsx-runtime");function yi(e){"worklet";switch(e){case 0:return 0;case 1:return 20;case 2:return 50;case 3:return 75;default:return 100}}function Fr(){var n,u,r;let e=ie(),t=(0,Z.useSharedValue)(!1),o=(0,Z.useSharedValue)(0),a=(0,ft.useRef)(null);(0,ft.useEffect)(()=>{var l;o.value=((l=e.files)==null?void 0:l.length)||0},[e.files,o]);let i=(0,Z.useAnimatedStyle)(()=>({transform:[{rotate:(0,Z.withSpring)(t.value?"180deg":"0deg")}]})),s=(0,Z.useAnimatedStyle)(()=>{let l=yi(o.value);return{height:(0,Z.withSpring)(t.value?l:0),opacity:(0,Z.withSpring)(t.value?1:0)}},[a.current,o]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Je.Container.Horizontal,{align:"END",children:!!((n=e.files)!=null&&n.length)&&(0,B.jsx)(Sr.Clickable,{onPress:()=>t.value=!t.value,children:(0,B.jsxs)(Je.Container.Horizontal,{align:"CENTER",children:[(0,B.jsxs)(dt.Typography,{size:"XS",children:[(u=e.files)==null?void 0:u.length," arquivos"]}),(0,B.jsx)(Z.default.View,{style:i,children:(0,B.jsx)(Pr.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,B.jsx)(Z.default.ScrollView,{style:s,children:(r=e.files)==null?void 0:r.map((l,c)=>(0,B.jsxs)(Je.Container.Horizontal,{align:"START_CENTER",children:[(0,B.jsxs)(Je.Container.Horizontal,{gap:"SM",full:!0,children:[(0,B.jsx)(dt.Typography,{size:"XS",weight:"MEDIUM",children:l.name.slice(0,20)}),l.size&&(0,B.jsx)(dt.Typography,{size:"XS",children:lt.convertBytesToReadableFormat(l.size)})]}),(0,B.jsx)(yr.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS",testID:"remove-file-button",onPress:()=>e.handleRemoveFile(W.getHashFile(l))})]},c))})]})}var xr=require("@mobilestock-native/typography"),Ir=require("react/jsx-runtime");function Rr({children:e}){return(0,Ir.jsx)(xr.Typography,{children:e})}var me=require("react/jsx-runtime");function Lr(o){var a=o,{accept:e}=a,t=L(a,["accept"]);let{error:i}=(0,wr.useField)(t.name),s=(0,Nr.useMemo)(()=>lt.parseAcceptString(e),[e]);return(0,me.jsx)(rr,R(v({},t),{accept:s,children:(0,me.jsxs)(gt.Container.Vertical,{gap:"2XS",children:[(0,me.jsx)(gt.Container.Horizontal,{align:t.alignLabel||"START",children:(0,me.jsx)(Rr,{children:t.label})}),(0,me.jsxs)(Si,{$error:!!i,$minWidth:Ar.Platform.OS==="web"?"400px":"100%",padding:"MD",children:[(0,me.jsx)(vr,{children:t.children||(0,me.jsx)(gr,{})}),(0,me.jsx)(Fr,{})]})]})}))}var Si=(0,Hr.default)(gt.Container.Vertical)`
39
+ border: 1px solid ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.border};
43
40
  border-radius: ${({theme:e})=>e.borderRadius.default};
44
- background-color: ${({theme:e,$error:o})=>o?e.colors.input.error:e.colors.input.default};
41
+ background-color: ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.default};
45
42
  min-width: ${({$minWidth:e})=>e};
46
- `;var sr=Object.assign(lr,{Title:We,HelpButton:Ge,HelpText:Xe,ErrorLabel:$e});var oo=require("react"),Ie=require("react-native"),Xr=R(require("react-native-draggable-flatlist")),Wr=require("styled-components/native"),eo=require("@mobilestock-native/container");var mr=require("@unform/core"),ur=require("expo-image-picker"),pr=require("expo-media-library"),O=require("react"),To=require("react-native"),cr=require("styled-components/native");var gr=require("react/jsx-runtime"),dr=(0,O.createContext)(null);function fr({gap:e="2XS",size:o="SM",name:t,children:n,onChange:r,multiple:a,dragAndDrop:i,buttonAddDirection:m}){let l=(0,cr.useTheme)(),{fieldName:u,registerField:p,defaultValue:c}=(0,mr.useField)(t),[h,d]=(0,pr.usePermissions)({granularPermissions:["photo"]}),[b,g]=(0,O.useState)(null),[f,s]=(0,O.useState)(!1),[v,S]=(0,O.useState)(null),A=(0,O.useMemo)(()=>parseInt(l.sizeImage[o.toLowerCase()]),[l,o]),D=(0,O.useMemo)(()=>parseInt(l.gaps[e.toLowerCase()]),[l,e]),T=(0,O.useCallback)(y=>{g(m==="RIGHT"?N=>[...N||[],...y].reverse():N=>[...N||[],...y])},[g,m]),V=(0,O.useCallback)(y=>{if(!y){g(null);return}T(y)},[T]);(0,O.useEffect)(()=>{p({name:u,getValue:()=>b,setValue:(y,N)=>V(N||c),clearValue:()=>g(null)})},[u,p,b,V,c]),(0,O.useEffect)(()=>{h!=null&&h.granted||d()},[h,d]);function Q(){return se(this,null,function*(){var N;let y=yield(0,ur.launchImageLibraryAsync)({mediaTypes:["images"],allowsEditing:a?void 0:!0,quality:1,allowsMultipleSelection:a});if(To.Platform.OS==="web"&&y.assets&&!a){s(!0),S(y.assets[0].file);return}T(((N=y.assets)==null?void 0:N.map(le=>To.Platform.OS==="web"?le.file:{uri:le.uri,name:le.fileName,type:le.mimeType}))||[])})}function z(y){if(!b)return;let N=b.filter(le=>B.getHashFile(le)!==y);g(N),r==null||r({value:b.find(le=>B.getHashFile(le)===y),event:"REMOVE_IMAGE"})}function be(y){g(y),r==null||r({value:y,event:"REORDER_IMAGES"})}function x(y){T([y]),s(!1),S(null),r==null||r({value:y,event:"CROP_SAVE"})}function P(){s(!1),S(null)}return(0,gr.jsx)(dr.Provider,{value:{showDeviceImage:Q,images:b,removeImage:z,reorderImages:be,openImageCropModal:f,imageToCrop:v,handleImageCropCancel:P,handleImageCropSave:x,sizeComponent:A,gapComponent:D,dragAndDrop:i,name:t,gap:e},children:n})}function _(){let e=(0,O.useContext)(dr);if(!e)throw new Error("usePhotoList must be used within a PhotoListProvider");return e}var hr=require("@mobilestock-native/button");var Cr=require("react/jsx-runtime");function Eo(){let e=_();return(0,Cr.jsx)(hr.Button,{icon:"Plus",variant:"OUTLINE",onPress:e.showDeviceImage,style:{height:e.sizeComponent,width:e.sizeComponent}})}var br=require("@unform/core"),Tr=require("@mobilestock-native/typography");var vr=require("react/jsx-runtime");function Er(){let e=_(),{error:o}=(0,br.useField)(e.name);return(0,vr.jsx)(Tr.Typography,{color:"DANGER",size:"XS",children:o})}var Je=require("react"),Vr=require("react-native"),Qe=R(require("styled-components/native")),Mr=require("@mobilestock-native/container"),Or=require("@mobilestock-native/image");var Ir=R(require("styled-components/native")),Rr=require("@mobilestock-native/clickable");var yr=require("styled-components/native"),Pr=require("@mobilestock-native/container");var Fr=require("react/jsx-runtime");function Sr({isActive:e}){let o=(0,yr.useTheme)(),t=_();return(0,Fr.jsx)(Pr.Container.Horizontal,{style:[{height:2,width:t.sizeComponent*.7,backgroundColor:o.colors.formPhotoList.defaultBar},e&&{backgroundColor:o.colors.formPhotoList.highlightBar}]})}var vo=require("react/jsx-runtime");function wr({drag:e,isActive:o}){return(0,vo.jsx)(Gn,{onLongPress:e,onTouchMove:e,onTouchStart:e,onPressIn:e,children:(0,vo.jsx)(Sr,{isActive:o})})}var Gn=(0,Ir.default)(Rr.Clickable)`
43
+ `;var Vr=Object.assign(Lr,{Title:pt,HelpButton:ut,HelpText:ct,ErrorLabel:st});var Et=require("react"),De=require("react-native"),Cn=A(require("react-native-draggable-flatlist")),Tn=require("styled-components/native"),vt=require("@mobilestock-native/container");var Or=require("@unform/core"),Mr=require("expo-image-picker"),Dr=require("expo-media-library"),_=require("react"),Bt=require("react-native"),zr=require("styled-components/native");var _r=require("react/jsx-runtime"),kr=(0,_.createContext)(null);function Br({gap:e="2XS",size:t="SM",name:o,children:a,onChange:i,multiple:s,dragAndDrop:n,buttonAddDirection:u}){let r=(0,zr.useTheme)(),{notifyFieldChange:l}=z(),{fieldName:c,registerField:g,defaultValue:m}=(0,Or.useField)(o),[b,E]=(0,Dr.usePermissions)({granularPermissions:["photo"]}),[S,y]=(0,_.useState)(null),[C,T]=(0,_.useState)(!1),[P,h]=(0,_.useState)(null),d=(0,_.useMemo)(()=>parseInt(r.sizeImage[t.toLowerCase()]),[r,t]),F=(0,_.useMemo)(()=>parseInt(r.gaps[e.toLowerCase()]),[r,e]),p=(0,_.useCallback)(w=>{y(u==="RIGHT"?M=>{let O=[...M||[],...w].reverse();return l==null||l(c,O),O}:M=>{let O=[...M||[],...w];return l==null||l(c,O),O})},[y,u,l,c]),I=(0,_.useCallback)(w=>{if(!w){y(null);return}p(w)},[p]);(0,_.useEffect)(()=>{g({name:c,getValue:()=>S,setValue:(w,M)=>I(M||m),clearValue:()=>y(null)})},[c,g,S,I,m]),(0,_.useEffect)(()=>{b!=null&&b.granted||E()},[b,E]);function ee(){return be(this,null,function*(){var M;let w=yield(0,Mr.launchImageLibraryAsync)({mediaTypes:["images"],allowsEditing:s?void 0:!0,quality:1,allowsMultipleSelection:s});if(Bt.Platform.OS==="web"&&w.assets&&!s){T(!0),h(w.assets[0].file);return}p(((M=w.assets)==null?void 0:M.map(O=>Bt.Platform.OS==="web"?O.file:{uri:O.uri,name:O.fileName,type:O.mimeType}))||[])})}function $(w){if(!S)return;let M=S.filter(O=>W.getHashFile(O)!==w);y(M),l==null||l(c,M),i==null||i({value:S.find(O=>W.getHashFile(O)===w),event:"REMOVE_IMAGE"})}function q(w){y(w),l==null||l(c,w),i==null||i({value:w,event:"REORDER_IMAGES"})}function ge(w){p([w]),T(!1),h(null),i==null||i({value:w,event:"CROP_SAVE"})}function U(){T(!1),h(null)}return(0,_r.jsx)(kr.Provider,{value:{showDeviceImage:ee,images:S,removeImage:$,reorderImages:q,openImageCropModal:C,imageToCrop:P,handleImageCropCancel:U,handleImageCropSave:ge,sizeComponent:d,gapComponent:F,dragAndDrop:n,name:o,gap:e},children:a})}function K(){let e=(0,_.useContext)(kr);if(!e)throw new Error("usePhotoList must be used within a PhotoListProvider");return e}var Gr=require("@mobilestock-native/button");var Ur=require("react/jsx-runtime");function _t(){let e=K();return(0,Ur.jsx)(Gr.Button,{icon:"Plus",variant:"OUTLINE",onPress:e.showDeviceImage,style:{height:e.sizeComponent,width:e.sizeComponent}})}var $r=require("@unform/core"),Xr=require("@mobilestock-native/typography");var Kr=require("react/jsx-runtime");function Wr(){let e=K(),{error:t}=(0,$r.useField)(e.name);return(0,Kr.jsx)(Xr.Typography,{color:"DANGER",size:"XS",children:t})}var bt=require("react"),an=require("react-native"),Ct=A(require("styled-components/native")),ln=require("@mobilestock-native/container"),sn=require("@mobilestock-native/image");var Qr=A(require("styled-components/native")),jr=require("@mobilestock-native/clickable");var qr=require("styled-components/native"),Yr=require("@mobilestock-native/container");var Jr=require("react/jsx-runtime");function Zr({isActive:e}){let t=(0,qr.useTheme)(),o=K();return(0,Jr.jsx)(Yr.Container.Horizontal,{style:[{height:2,width:o.sizeComponent*.7,backgroundColor:t.colors.formPhotoList.defaultBar},e&&{backgroundColor:t.colors.formPhotoList.highlightBar}]})}var Gt=require("react/jsx-runtime");function en({drag:e,isActive:t}){return(0,Gt.jsx)(Pi,{onLongPress:e,onTouchMove:e,onTouchStart:e,onPressIn:e,children:(0,Gt.jsx)(Zr,{isActive:t})})}var Pi=(0,Qr.default)(jr.Clickable)`
47
44
  flex-direction: row;
48
45
  justify-content: space-between;
49
46
  align-items: center;
@@ -51,14 +48,14 @@
51
48
  position: absolute;
52
49
  bottom: 0;
53
50
  background-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
54
- `;var Ze=R(require("styled-components/native")),xr=require("@mobilestock-native/clickable"),Nr=require("@mobilestock-native/icons"),Lr=R(require("@mobilestock-native/tools"));var yo=require("react/jsx-runtime");function Ar({photo:e}){let o=_(),t=(0,Ze.useTheme)();function n(){o.removeImage(B.getHashFile(e))}return(0,yo.jsx)(Un,{onPress:n,children:(0,yo.jsx)(Nr.Icon,{name:"X",size:"XS",color:Lr.default.defineTextColor(t.colors.formPhotoList.trashButton)})})}var Un=(0,Ze.default)(xr.Clickable)`
51
+ `;var ht=A(require("styled-components/native")),tn=require("@mobilestock-native/clickable"),on=require("@mobilestock-native/icons"),rn=A(require("@mobilestock-native/tools"));var Ut=require("react/jsx-runtime");function nn({photo:e}){let t=K(),o=(0,ht.useTheme)();function a(){t.removeImage(W.getHashFile(e))}return(0,Ut.jsx)(Fi,{onPress:a,children:(0,Ut.jsx)(on.Icon,{name:"X",size:"XS",color:rn.default.defineTextColor(o.colors.formPhotoList.trashButton)})})}var Fi=(0,ht.default)(tn.Clickable)`
55
52
  position: absolute;
56
53
  top: 0;
57
54
  right: 0;
58
55
  z-index: 1;
59
56
  border-bottom-left-radius: 4px;
60
57
  background-color: ${({theme:e})=>e.colors.formPhotoList.trashButton};
61
- `;var Pe=require("react/jsx-runtime");function Xn({item:e,drag:o,isActive:t}){let n=_(),r=(0,Je.useMemo)(()=>Vr.Platform.OS==="web"?URL.createObjectURL(e):e.uri,[e]);return(0,Pe.jsxs)(Wn,{align:"CENTER",sizeComponent:n.sizeComponent,isActive:t,children:[(0,Pe.jsx)(Ar,{photo:e}),(0,Pe.jsx)(Or.Img,{src:{uri:r},alt:"image",size:"SM"}),n.dragAndDrop&&(0,Pe.jsx)(wr,{drag:o,isActive:t})]})}var Dr=(0,Je.memo)(Xn),Wn=(0,Qe.default)(Mr.Container.Vertical)`
58
+ `;var Ve=require("react/jsx-runtime");function xi({item:e,drag:t,isActive:o}){let a=K(),i=(0,bt.useMemo)(()=>an.Platform.OS==="web"?URL.createObjectURL(e):e.uri,[e]);return(0,Ve.jsxs)(Ri,{align:"CENTER",sizeComponent:a.sizeComponent,isActive:o,children:[(0,Ve.jsx)(nn,{photo:e}),(0,Ve.jsx)(sn.Img,{src:{uri:i},alt:"image",size:"SM"}),a.dragAndDrop&&(0,Ve.jsx)(en,{drag:t,isActive:o})]})}var un=(0,bt.memo)(xi),Ri=(0,Ct.default)(ln.Container.Vertical)`
62
59
  background-color: ${({theme:e})=>e.colors.formPhotoList.defaultBar};
63
60
  border-radius: ${({theme:e})=>e.borderRadius.default};
64
61
  overflow: hidden;
@@ -68,10 +65,10 @@
68
65
  position: relative;
69
66
  border-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
70
67
 
71
- ${({theme:e,isActive:o})=>o&&Qe.css`
68
+ ${({theme:e,isActive:t})=>t&&Ct.css`
72
69
  border-color: ${e.colors.formPhotoList.highlightBar};
73
70
  `}
74
- `;var Hr=require("@mobilestock-native/typography"),kr=require("react/jsx-runtime");function zr({children:e}){return(0,kr.jsx)(Hr.Typography,{children:e})}var j=require("react"),Gr=require("react-image-crop"),Xl=require("react-image-crop/dist/ReactCrop.css"),Fe=R(require("styled-components/native")),So=require("@mobilestock-native/button"),he=require("@mobilestock-native/container");var ge=require("react"),Po=require("react-native"),Br=R(require("styled-components/native")),_r=require("ua-parser-js"),je=require("@mobilestock-native/container");var Se=require("react/jsx-runtime");function $r(t){var n=t,{children:e}=n,o=I(n,["children"]);let[r,a]=(0,ge.useState)(!1),i=(0,ge.useCallback)(()=>(0,_r.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),m=(0,ge.useCallback)(()=>{a(i())},[i]);return(0,ge.useEffect)(()=>(window.addEventListener("resize",m),a(i()),()=>{window.removeEventListener("resize",m)}),[i,m]),r?(0,Se.jsx)(Po.Modal,E(C({transparent:!0,statusBarTranslucent:!0},o),{children:(0,Se.jsx)(je.Container.Main,{children:e})})):(0,Se.jsx)(Po.Modal,E(C({transparent:!0,statusBarTranslucent:!0,animationType:"slide"},o),{children:(0,Se.jsx)(je.Container.Vertical,{align:"CENTER",full:!0,children:(0,Se.jsx)(qn,{padding:"SM",children:e})})}))}var qn=(0,Br.default)(je.Container.Vertical)`
71
+ `;var mn=require("@mobilestock-native/typography"),pn=require("react/jsx-runtime");function cn({children:e}){return(0,pn.jsx)(mn.Typography,{children:e})}var se=require("react"),hn=require("react-image-crop"),Us=require("react-image-crop/dist/ReactCrop.css"),Me=A(require("styled-components/native")),Xt=require("@mobilestock-native/button"),Re=require("@mobilestock-native/container");var xe=require("react"),$t=require("react-native"),dn=A(require("styled-components/native")),fn=require("ua-parser-js"),Tt=require("@mobilestock-native/container");var Oe=require("react/jsx-runtime");function gn(o){var a=o,{children:e}=a,t=L(a,["children"]);let[i,s]=(0,xe.useState)(!1),n=(0,xe.useCallback)(()=>(0,fn.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),u=(0,xe.useCallback)(()=>{s(n())},[n]);return(0,xe.useEffect)(()=>(window.addEventListener("resize",u),s(n()),()=>{window.removeEventListener("resize",u)}),[n,u]),i?(0,Oe.jsx)($t.Modal,R(v({transparent:!0,statusBarTranslucent:!0},t),{children:(0,Oe.jsx)(Tt.Container.Main,{children:e})})):(0,Oe.jsx)($t.Modal,R(v({transparent:!0,statusBarTranslucent:!0,animationType:"slide"},t),{children:(0,Oe.jsx)(Tt.Container.Vertical,{align:"CENTER",full:!0,children:(0,Oe.jsx)(Ii,{padding:"SM",children:e})})}))}var Ii=(0,dn.default)(Tt.Container.Vertical)`
75
72
  background-color: ${({theme:e})=>e.colors.container.default};
76
73
  border-radius: ${({theme:e})=>e.borderRadius.default};
77
74
  border: 1px solid ${({theme:e})=>e.colors.input.border};
@@ -80,27 +77,27 @@
80
77
  width: 100%;
81
78
  height: 100%;
82
79
  overflow: hidden;
83
- `;var U=require("react/jsx-runtime");function Ur(){let e=_(),[o,t]=(0,j.useState)(),[n,r]=(0,j.useState)(),[a,i]=(0,j.useState)(),m=(0,j.useRef)(null),l=(0,j.useRef)(null),u=(0,j.useMemo)(()=>e.imageToCrop?URL.createObjectURL(e.imageToCrop):void 0,[e.imageToCrop]);(0,j.useEffect)(()=>{e.imageToCrop||(t(void 0),r(void 0),i(void 0))},[e.imageToCrop,e.openImageCropModal]);function p({displayWidth:d,displayHeight:b,naturalWidth:g,naturalHeight:f}){r({displayWidth:d,displayHeight:b,naturalWidth:g,naturalHeight:f});let s=Math.min(d,b);t({unit:"px",width:s,height:s,x:d>b?(d-s)/2:0,y:b>d?(b-s)/2:0})}function c(){return se(this,null,function*(){if(!e.imageToCrop||!o||!n)return;let d=n.naturalWidth/n.displayWidth,b=n.naturalHeight/n.displayHeight,g=o.x*d,f=o.y*b,s=o.width*d,v=o.height*b,S=new OffscreenCanvas(s,v),A=S.getContext("2d"),D=new Image;D.src=URL.createObjectURL(e.imageToCrop),yield new Promise(Q=>{D.onload=()=>Q()}),A.drawImage(D,g,f,s,v,0,0,s,v);let T=yield S.convertToBlob({type:"image/png",quality:1}),V="";if(!e.imageToCrop.name)V="image-cropped.png";else{let Q=e.imageToCrop.name.split(".");Q.pop(),V=Q.join(".")+"-cropped.png"}e.handleImageCropSave(new File([T],V,{type:"image/png",lastModified:Date.now()}))})}function h(d){let b=d.currentTarget,g=l.current,f=g.clientWidth,s=g.clientHeight,v=b.naturalWidth,S=b.naturalHeight,A=Math.min(f/v,s/S),D=v*A,T=S*A;i({width:D,height:T}),p({displayWidth:D,displayHeight:T,naturalWidth:v,naturalHeight:S})}return(0,U.jsx)($r,{visible:e.openImageCropModal,children:(0,U.jsxs)(he.Container.Vertical,{full:!0,padding:"NONE_XS_XS_XS",gap:"MD",children:[(0,U.jsx)(Kn,{full:!0,align:"CENTER",children:(0,U.jsx)(Yn,{ref:l,testID:"container-crop-vertical",align:"CENTER",children:(0,U.jsx)(Zn,{crop:o,width:a==null?void 0:a.width,height:a==null?void 0:a.height,onChange:d=>t(d),children:(0,U.jsx)("img",{src:u,ref:m,testID:"image-to-crop",onLoad:h})})})}),(0,U.jsxs)(he.Container.Horizontal,{gap:"MD",children:[(0,U.jsx)(he.Container.Vertical,{full:!0,children:(0,U.jsx)(So.Button,{onPress:e.handleImageCropCancel,text:"Cancelar",testID:"button-cancel",backgroundColor:"CANCEL_DARK"})}),(0,U.jsx)(he.Container.Vertical,{full:!0,children:(0,U.jsx)(So.Button,{onPress:c,testID:"button-save",text:"Salvar"})})]})]})})}var Kn=(0,Fe.default)(he.Container.Vertical)`
80
+ `;var J=require("react/jsx-runtime");function bn(){let e=K(),[t,o]=(0,se.useState)(),[a,i]=(0,se.useState)(),[s,n]=(0,se.useState)(),u=(0,se.useRef)(null),r=(0,se.useRef)(null),l=(0,se.useMemo)(()=>e.imageToCrop?URL.createObjectURL(e.imageToCrop):void 0,[e.imageToCrop]);(0,se.useEffect)(()=>{e.imageToCrop||(o(void 0),i(void 0),n(void 0))},[e.imageToCrop,e.openImageCropModal]);function c({displayWidth:b,displayHeight:E,naturalWidth:S,naturalHeight:y}){i({displayWidth:b,displayHeight:E,naturalWidth:S,naturalHeight:y});let C=Math.min(b,E);o({unit:"px",width:C,height:C,x:b>E?(b-C)/2:0,y:E>b?(E-C)/2:0})}function g(){return be(this,null,function*(){if(!e.imageToCrop||!t||!a)return;let b=a.naturalWidth/a.displayWidth,E=a.naturalHeight/a.displayHeight,S=t.x*b,y=t.y*E,C=t.width*b,T=t.height*E,P=new OffscreenCanvas(C,T),h=P.getContext("2d"),d=new Image;d.src=URL.createObjectURL(e.imageToCrop),yield new Promise(I=>{d.onload=()=>I()}),h.drawImage(d,S,y,C,T,0,0,C,T);let F=yield P.convertToBlob({type:"image/png",quality:1}),p="";if(!e.imageToCrop.name)p="image-cropped.png";else{let I=e.imageToCrop.name.split(".");I.pop(),p=I.join(".")+"-cropped.png"}e.handleImageCropSave(new File([F],p,{type:"image/png",lastModified:Date.now()}))})}function m(b){let E=b.currentTarget,S=r.current,y=S.clientWidth,C=S.clientHeight,T=E.naturalWidth,P=E.naturalHeight,h=Math.min(y/T,C/P),d=T*h,F=P*h;n({width:d,height:F}),c({displayWidth:d,displayHeight:F,naturalWidth:T,naturalHeight:P})}return(0,J.jsx)(gn,{visible:e.openImageCropModal,children:(0,J.jsxs)(Re.Container.Vertical,{full:!0,padding:"NONE_XS_XS_XS",gap:"MD",children:[(0,J.jsx)(wi,{full:!0,align:"CENTER",children:(0,J.jsx)(Ni,{ref:r,testID:"container-crop-vertical",align:"CENTER",children:(0,J.jsx)(Ai,{crop:t,width:s==null?void 0:s.width,height:s==null?void 0:s.height,onChange:b=>o(b),children:(0,J.jsx)("img",{src:l,ref:u,testID:"image-to-crop",onLoad:m})})})}),(0,J.jsxs)(Re.Container.Horizontal,{gap:"MD",children:[(0,J.jsx)(Re.Container.Vertical,{full:!0,children:(0,J.jsx)(Xt.Button,{onPress:e.handleImageCropCancel,text:"Cancelar",testID:"button-cancel",backgroundColor:"CANCEL_DARK"})}),(0,J.jsx)(Re.Container.Vertical,{full:!0,children:(0,J.jsx)(Xt.Button,{onPress:g,testID:"button-save",text:"Salvar"})})]})]})})}var wi=(0,Me.default)(Re.Container.Vertical)`
84
81
  width: 100%;
85
- `,Yn=(0,Fe.default)(he.Container.Vertical)`
82
+ `,Ni=(0,Me.default)(Re.Container.Vertical)`
86
83
  width: 100%;
87
84
  height: 100%;
88
85
  padding-left: 16px;
89
86
  padding-right: 16px;
90
- `,Zn=(0,Fe.default)(Gr.ReactCrop)`
91
- ${({width:e,height:o})=>e&&o&&Fe.css`
87
+ `,Ai=(0,Me.default)(hn.ReactCrop)`
88
+ ${({width:e,height:t})=>e&&t&&Me.css`
92
89
  width: ${e}px;
93
- height: ${o}px;
90
+ height: ${t}px;
94
91
  display: inline-flex;
95
92
  `}
96
- `;var H=require("react/jsx-runtime");function qr({numberOfImagesVisible:e,buttonAddDirection:o,label:t,alignLabel:n}){let r=(0,Ie.useWindowDimensions)(),a=_(),i=(0,Wr.useTheme)(),m=(0,oo.useCallback)(u=>{a.reorderImages(u.data)},[a]),l=(0,oo.useMemo)(()=>e?a.sizeComponent*e+a.gapComponent*(e-1):r.width-a.sizeComponent-a.gapComponent*4,[e,r.width,a.sizeComponent,a.gapComponent]);return(0,H.jsxs)(H.Fragment,{children:[!!t&&(0,H.jsx)(eo.Container.Horizontal,{align:n||"START",testID:"label-container",children:(0,H.jsx)(zr,{children:t})}),(0,H.jsxs)(eo.Container.Horizontal,{gap:a.gap,children:[o==="LEFT"&&(0,H.jsx)(Eo,{}),a.images&&(0,H.jsx)(eo.Container.Horizontal,{children:(0,H.jsx)(Xr.default,{data:a.images,keyExtractor:B.getHashFile,horizontal:!0,onDragEnd:m,activationDistance:10,style:{maxWidth:l,paddingBottom:parseInt(i.spacing["2xs"])},ItemSeparatorComponent:()=>(0,H.jsx)(Ie.View,{style:{width:a.gapComponent}}),renderItem:u=>(0,H.jsx)(Dr,C({},u))})}),o==="RIGHT"&&(0,H.jsx)(Eo,{})]}),(0,H.jsx)(Er,{}),Ie.Platform.OS==="web"&&(0,H.jsx)(Ur,{})]})}var Fo=require("react/jsx-runtime");function Kr(a){var i=a,{label:e,alignLabel:o,buttonAddDirection:t="LEFT",numberOfImagesVisible:n=0}=i,r=I(i,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,Fo.jsx)(fr,E(C({multiple:!0,dragAndDrop:!0,buttonAddDirection:t},r),{children:(0,Fo.jsx)(qr,{label:e,alignLabel:o,buttonAddDirection:t,numberOfImagesVisible:n})}))}var bn=require("@unform/core"),Tn=require("react-native"),En=require("@mobilestock-native/container"),wo=require("@mobilestock-native/typography");var ln=require("@unform/core"),De=require("react"),ze=R(require("styled-components/native")),sn=require("@mobilestock-native/clickable"),He=require("@mobilestock-native/container"),mn=require("@mobilestock-native/icons"),un=require("@mobilestock-native/typography");var rn=require("react"),we=require("react-native"),ao=require("react-native-gesture-handler"),L=R(require("react-native-reanimated")),nn=require("styled-components/native"),no=require("@mobilestock-native/container"),io=require("@mobilestock-native/list");var on=require("react-native-gesture-handler"),Re=require("@mobilestock-native/container");var Yr=require("styled-components/native"),Zr=require("@mobilestock-native/container");var Qr=require("react/jsx-runtime");function Jr(e){let o=(0,Yr.useTheme)();return(0,Qr.jsx)(Zr.Container.Horizontal,C({style:{width:100,height:4,borderRadius:5,backgroundColor:o.colors.container.shadow}},e))}var jr=require("@mobilestock-native/typography");var en=require("react/jsx-runtime");function Io(e){return(0,en.jsx)(jr.Typography,C({size:"MD",align:"RIGHT",color:"DEFAULT_100"},e))}var ee=require("react/jsx-runtime");function tn({placeholder:e,panGesture:o}){return o?(0,ee.jsx)(on.GestureDetector,{gesture:o,children:(0,ee.jsxs)(Re.Container.Vertical,{padding:"XS",testID:"form-sheet-header-with-gesture",children:[(0,ee.jsx)(Re.Container.Horizontal,{align:"CENTER",children:(0,ee.jsx)(Jr,{})}),(0,ee.jsx)(Re.Container.Horizontal,{children:(0,ee.jsx)(Io,{children:e})})]})}):(0,ee.jsx)(Re.Container.Vertical,{padding:"XS",testID:"form-sheet-header-without-gesture",children:(0,ee.jsx)(Re.Container.Horizontal,{children:(0,ee.jsx)(Io,{children:e})})})}var X=require("react/jsx-runtime"),{height:Jn}=we.Dimensions.get("window"),Ro=Jn*.8,to=200,ro=45;function an(e){let o=(0,nn.useTheme)(),t=(0,rn.useMemo)(()=>Math.min(Ro,e.options.length*ro+ro),[e.options]),n=Math.min(to,t),r=(0,L.useSharedValue)(n),a=(0,L.useSharedValue)(n),i=ao.Gesture.Pan().onStart(()=>{a.value=r.value}).onUpdate(p=>{let c=a.value-p.translationY;r.value=Math.max(to,Math.min(c,t))}).onEnd(p=>{p.velocityY<-1e3?r.value=(0,L.withTiming)(t):r.value>Ro/2?r.value=(0,L.withTiming)(Ro):r.value=(0,L.withTiming)(to)}),m=(0,L.useAnimatedStyle)(()=>({height:r.value,bottom:0}));(0,L.useAnimatedReaction)(()=>e.visible,p=>{p&&(r.value=(0,L.withSpring)(n,{damping:20,stiffness:90,mass:.3}))},[e.visible]);function l(){"worklet";r.value=(0,L.withTiming)(0,{},()=>{(0,L.runOnJS)(e.onClose)()})}function u(p){var c;e.onSelect(p.value===((c=e.selectValue)==null?void 0:c.value)?null:p),l()}return(0,X.jsx)(we.Modal,{visible:e.visible,transparent:!0,animationType:"none",testID:"modal",children:(0,X.jsxs)(ao.GestureHandlerRootView,{children:[(0,X.jsx)(we.TouchableWithoutFeedback,{onPress:l,testID:"backdrop",children:(0,X.jsx)(no.Container.Vertical,{full:!0})}),(0,X.jsxs)(L.default.View,{style:[m,{position:"absolute",width:"100%",backgroundColor:o.colors.container.default,borderTopLeftRadius:20,borderTopRightRadius:20,borderWidth:1,borderColor:o.colors.container.shadow}],children:[(0,X.jsx)(tn,{placeholder:e.placeholder,panGesture:e.options.length*ro+ro>to?i:void 0}),(0,X.jsx)(no.Container.Main,{children:(0,X.jsx)(io.List,{data:e.options,itemKey:"value",ItemSeparatorComponent:()=>(0,X.jsx)(no.Container.Horizontal,{testID:"separator",style:{backgroundColor:o.colors.container.shadow,height:1,width:"100%"}}),renderItem:p=>{var c;return(0,X.jsx)(io.List.Item.Horizontal,{isSelected:((c=e.selectValue)==null?void 0:c.value)===p.value,padding:"SM",onPress:()=>u(p),children:(0,X.jsx)(io.List.Item.Title,{children:p.label})})}})})]})]})})}var W=require("react/jsx-runtime");function pn({options:e,placeholder:o,disabled:t,defaultValue:n,name:r}){let a=(0,ze.useTheme)(),{loading:i}=q(),{fieldName:m,registerField:l,error:u,defaultValue:p}=(0,ln.useField)(r),[c,h]=(0,De.useState)(!1),[d,b]=(0,De.useState)(p||n||null);return(0,De.useEffect)(()=>{l({name:m,getValue:()=>(d==null?void 0:d.value)||"",setValue:(g,f)=>{let s=e.find(v=>v.value===f);s&&b(s)},clearValue:()=>{b(null)}})},[m,l,d,e]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(sn.Clickable,{disabled:t||i,onPress:()=>h(!0),testID:"select-android",children:(0,W.jsxs)(Qn,{padding:"NONE_XS_NONE_MD",error:!!u,testID:"select-android-container",align:"BETWEEN_CENTER",children:[(0,W.jsx)(He.Container.Horizontal,{children:(0,W.jsx)(un.Typography,{color:d?"DEFAULT":"DEFAULT_200",children:(d==null?void 0:d.label)||o})}),(0,W.jsxs)(He.Container.Horizontal,{style:{opacity:.3},gap:"XS",align:"CENTER",children:[(0,W.jsx)(jn,{error:!!u}),(0,W.jsx)(mn.Icon,{name:"ChevronDown",size:"XS",color:u?a.colors.alert.urgent:a.colors.text.default})]})]})}),!t&&!i&&(0,W.jsx)(an,{options:e,onClose:()=>h(!1),visible:c,placeholder:o,selectValue:d,onSelect:g=>{b(g)}})]})}var Qn=(0,ze.default)(He.Container.Horizontal)`
93
+ `;var G=require("react/jsx-runtime");function vn({numberOfImagesVisible:e,buttonAddDirection:t,label:o,alignLabel:a}){let i=(0,De.useWindowDimensions)(),s=K(),n=(0,Tn.useTheme)(),u=(0,Et.useCallback)(l=>{s.reorderImages(l.data)},[s]),r=(0,Et.useMemo)(()=>e?s.sizeComponent*e+s.gapComponent*(e-1):i.width-s.sizeComponent-s.gapComponent*4,[e,i.width,s.sizeComponent,s.gapComponent]);return(0,G.jsxs)(G.Fragment,{children:[!!o&&(0,G.jsx)(vt.Container.Horizontal,{align:a||"START",testID:"label-container",children:(0,G.jsx)(cn,{children:o})}),(0,G.jsxs)(vt.Container.Horizontal,{gap:s.gap,children:[t==="LEFT"&&(0,G.jsx)(_t,{}),s.images&&(0,G.jsx)(vt.Container.Horizontal,{children:(0,G.jsx)(Cn.default,{data:s.images,keyExtractor:W.getHashFile,horizontal:!0,onDragEnd:u,activationDistance:10,style:{maxWidth:r,paddingBottom:parseInt(n.spacing["2xs"])},ItemSeparatorComponent:()=>(0,G.jsx)(De.View,{style:{width:s.gapComponent}}),renderItem:l=>(0,G.jsx)(un,v({},l))})}),t==="RIGHT"&&(0,G.jsx)(_t,{})]}),(0,G.jsx)(Wr,{}),De.Platform.OS==="web"&&(0,G.jsx)(bn,{})]})}var Wt=require("react/jsx-runtime");function En(s){var n=s,{label:e,alignLabel:t,buttonAddDirection:o="LEFT",numberOfImagesVisible:a=0}=n,i=L(n,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,Wt.jsx)(Br,R(v({multiple:!0,dragAndDrop:!0,buttonAddDirection:o},i),{children:(0,Wt.jsx)(vn,{label:e,alignLabel:t,buttonAddDirection:o,numberOfImagesVisible:a})}))}var Un=require("@unform/core"),$n=require("react-native"),Xn=require("@mobilestock-native/container"),Zt=require("@mobilestock-native/typography");var Ln=require("@unform/core"),Be=require("react"),je=A(require("styled-components/native")),Vn=require("@mobilestock-native/clickable"),Qe=require("@mobilestock-native/container"),On=require("@mobilestock-native/icons"),Mn=require("@mobilestock-native/typography");var Nn=require("react"),ke=require("react-native"),xt=require("react-native-gesture-handler"),k=A(require("react-native-reanimated")),An=require("styled-components/native"),Pt=require("@mobilestock-native/container"),Ft=require("@mobilestock-native/list");var In=require("react-native-gesture-handler"),ze=require("@mobilestock-native/container");var yn=require("styled-components/native"),Sn=require("@mobilestock-native/container");var Fn=require("react/jsx-runtime");function Pn(e){let t=(0,yn.useTheme)();return(0,Fn.jsx)(Sn.Container.Horizontal,v({style:{width:100,height:4,borderRadius:5,backgroundColor:t.colors.container.shadow}},e))}var xn=require("@mobilestock-native/typography");var Rn=require("react/jsx-runtime");function Kt(e){return(0,Rn.jsx)(xn.Typography,v({size:"MD",align:"RIGHT",color:"DEFAULT_100"},e))}var ue=require("react/jsx-runtime");function wn({placeholder:e,panGesture:t}){return t?(0,ue.jsx)(In.GestureDetector,{gesture:t,children:(0,ue.jsxs)(ze.Container.Vertical,{padding:"XS",testID:"form-sheet-header-with-gesture",children:[(0,ue.jsx)(ze.Container.Horizontal,{align:"CENTER",children:(0,ue.jsx)(Pn,{})}),(0,ue.jsx)(ze.Container.Horizontal,{children:(0,ue.jsx)(Kt,{children:e})})]})}):(0,ue.jsx)(ze.Container.Vertical,{padding:"XS",testID:"form-sheet-header-without-gesture",children:(0,ue.jsx)(ze.Container.Horizontal,{children:(0,ue.jsx)(Kt,{children:e})})})}var Q=require("react/jsx-runtime"),{height:Hi}=ke.Dimensions.get("window"),qt=Hi*.8,yt=200,St=45;function Hn(e){let t=(0,An.useTheme)(),o=(0,Nn.useMemo)(()=>Math.min(qt,e.options.length*St+St),[e.options]),a=Math.min(yt,o),i=(0,k.useSharedValue)(a),s=(0,k.useSharedValue)(a),n=xt.Gesture.Pan().onStart(()=>{s.value=i.value}).onUpdate(c=>{let g=s.value-c.translationY;i.value=Math.max(yt,Math.min(g,o))}).onEnd(c=>{c.velocityY<-1e3?i.value=(0,k.withTiming)(o):i.value>qt/2?i.value=(0,k.withTiming)(qt):i.value=(0,k.withTiming)(yt)}),u=(0,k.useAnimatedStyle)(()=>({height:i.value,bottom:0}));(0,k.useAnimatedReaction)(()=>e.visible,c=>{c&&(i.value=(0,k.withSpring)(a,{damping:20,stiffness:90,mass:.3}))},[e.visible]);function r(){"worklet";i.value=(0,k.withTiming)(0,{},()=>{(0,k.runOnJS)(e.onClose)()})}function l(c){var g;e.onSelect(c.value===((g=e.selectValue)==null?void 0:g.value)?null:c),r()}return(0,Q.jsx)(ke.Modal,{visible:e.visible,transparent:!0,animationType:"none",testID:"modal",children:(0,Q.jsxs)(xt.GestureHandlerRootView,{children:[(0,Q.jsx)(ke.TouchableWithoutFeedback,{onPress:r,testID:"backdrop",children:(0,Q.jsx)(Pt.Container.Vertical,{full:!0})}),(0,Q.jsxs)(k.default.View,{style:[u,{position:"absolute",width:"100%",backgroundColor:t.colors.container.default,borderTopLeftRadius:20,borderTopRightRadius:20,borderWidth:1,borderColor:t.colors.container.shadow}],children:[(0,Q.jsx)(wn,{placeholder:e.placeholder,panGesture:e.options.length*St+St>yt?n:void 0}),(0,Q.jsx)(Pt.Container.Main,{children:(0,Q.jsx)(Ft.List,{data:e.options,itemKey:"value",ItemSeparatorComponent:()=>(0,Q.jsx)(Pt.Container.Horizontal,{testID:"separator",style:{backgroundColor:t.colors.container.shadow,height:1,width:"100%"}}),renderItem:c=>{var g;return(0,Q.jsx)(Ft.List.Item.Horizontal,{isSelected:((g=e.selectValue)==null?void 0:g.value)===c.value,padding:"SM",onPress:()=>l(c),children:(0,Q.jsx)(Ft.List.Item.Title,{children:c.label})})}})})]})]})})}var j=require("react/jsx-runtime");function Dn({options:e,placeholder:t,disabled:o,defaultValue:a,name:i,onChange:s,autoFocus:n,onFocus:u,onBlur:r}){let l=(0,je.useTheme)(),{loading:c,notifyFieldChange:g}=z(),{fieldName:m,registerField:b,error:E,defaultValue:S}=(0,Ln.useField)(i),[y,C]=(0,Be.useState)(!1),[T,P]=(0,Be.useState)(S||a||null);(0,Be.useEffect)(()=>{n&&!o&&!c&&(C(!0),u==null||u())},[]),(0,Be.useEffect)(()=>{b({name:m,getValue:()=>(T==null?void 0:T.value)||"",setValue:(p,I)=>{let ee=e.find($=>$.value===I);ee&&P(ee)},clearValue:()=>{P(null)}})},[m,b,T,e]);function h(){C(!0),u==null||u()}function d(){C(!1),r==null||r()}function F(p){var I,ee;P(p),g==null||g(m,(I=p==null?void 0:p.value)!=null?I:""),s==null||s({value:(ee=p==null?void 0:p.value)!=null?ee:"",event:"SELECT_CHANGE"})}return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(Vn.Clickable,{disabled:o||c,onPress:h,testID:"select-android",children:(0,j.jsxs)(Li,{padding:"NONE_XS_NONE_MD",error:!!E,testID:"select-android-container",align:"BETWEEN_CENTER",children:[(0,j.jsx)(Qe.Container.Horizontal,{children:(0,j.jsx)(Mn.Typography,{color:T?"DEFAULT":"DEFAULT_200",children:(T==null?void 0:T.label)||t})}),(0,j.jsxs)(Qe.Container.Horizontal,{style:{opacity:.3},gap:"XS",align:"CENTER",children:[(0,j.jsx)(Vi,{error:!!E}),(0,j.jsx)(On.Icon,{name:"ChevronDown",size:"XS",color:E?l.colors.alert.urgent:l.colors.text.default})]})]})}),!o&&!c&&(0,j.jsx)(Hn,{options:e,onClose:d,visible:y,placeholder:t,selectValue:T,onSelect:F})]})}var Li=(0,je.default)(Qe.Container.Horizontal)`
97
94
  overflow: hidden;
98
95
  height: 47px;
99
- background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
100
- border: 1px solid ${({error:e,theme:o})=>e?o.colors.alert.urgent:o.colors.input.border};
96
+ background-color: ${({error:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
97
+ border: 1px solid ${({error:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
101
98
  border-radius: 5px;
102
- `,jn=(0,ze.default)(He.Container.Vertical)`
99
+ `,Vi=(0,je.default)(Qe.Container.Vertical)`
103
100
  width: 1px;
104
101
  height: 30px;
105
- background-color: ${({theme:e,error:o})=>o?e.colors.alert.urgent:e.colors.text.default};
106
- `;var cn=require("@unform/core"),dn=require("lodash"),xe=require("react"),fn=R(require("react-select")),gn=require("styled-components/native");var Cn=require("react/jsx-runtime");function hn({options:e,placeholder:o,disabled:t,name:n,defaultValue:r}){var d,b;let a=(0,gn.useTheme)(),{loading:i}=q(),{fieldName:m,defaultValue:l,registerField:u,error:p}=(0,cn.useField)(n),c=(0,xe.useRef)(null);(0,xe.useEffect)(()=>{u({name:m,ref:c.current,getValue:g=>{var s,v,S;return((S=(v=(s=g==null?void 0:g.state)==null?void 0:s.selectValue)==null?void 0:v[0])==null?void 0:S.value)||""}})},[m,u]);let h=(0,xe.useCallback)(g=>function(f){return(0,dn.mergeWith)(f,g)},[]);return(0,Cn.jsx)(fn.default,{options:[{label:o,options:e}],placeholder:o,defaultInputValue:(b=(d=r==null?void 0:r.label)!=null?d:l==null?void 0:l.label)!=null?b:void 0,menuPortalTarget:typeof document!="undefined"?document.body:void 0,menuPosition:"fixed",styles:{container:h({width:"100%",display:"flex",height:"3rem"}),control:h({width:"100%",backgroundColor:p?a.colors.input.error:void 0,borderColor:p?a.colors.alert.urgent:void 0}),indicatorSeparator:h({backgroundColor:p?a.colors.alert.urgent:void 0}),dropdownIndicator:h({color:p?a.colors.alert.urgent:void 0}),option:(g,f)=>E(C({},g),{backgroundColor:f.isSelected?a.colors.listItem.selected:a.colors.listItem.default}),menuPortal:g=>E(C({},g),{zIndex:99999})},defaultValue:r,ref:c,isDisabled:t||i})}var Ce=require("react/jsx-runtime");function vn({name:e,label:o,disabled:t=!1,options:n,placeholder:r="Selecione um item",full:a=!1,defaultValue:i}){let{error:m}=(0,bn.useField)(e);return(0,Ce.jsxs)(En.Container.Vertical,{full:a,children:[o&&(0,Ce.jsx)(wo.Typography,{testID:"label",children:o}),Tn.Platform.OS==="web"?(0,Ce.jsx)(hn,{disabled:t,options:n,name:e,defaultValue:i,placeholder:r}):(0,Ce.jsx)(pn,{name:e,disabled:t,options:n,defaultValue:i,placeholder:r}),m&&(0,Ce.jsx)(wo.Typography,{color:"DANGER",size:"SM",testID:"error",children:m})]})}var yn=require("@mobilestock-native/container");var Sn=require("react/jsx-runtime");function Pn(t){var n=t,{children:e}=n,o=I(n,["children"]);return(0,Sn.jsx)(yn.Container.Vertical,E(C({gap:"SM"},o),{children:e}))}var ei=Object.assign(Ho,{Input:Ft,Button:ko,Select:vn,Counter:bt,Vertical:Pn,MultipleArchive:sr,PhotoList:Kr,Horizontal:Et});0&&(module.exports={Form,useForm});
102
+ background-color: ${({theme:e,error:t})=>t?e.colors.alert.urgent:e.colors.text.default};
103
+ `;var zn=require("@unform/core"),Rt=A(require("chroma-js")),Yt=require("lodash"),Ie=require("react"),kn=A(require("react-select")),Bn=require("styled-components/native");var Gn=require("react/jsx-runtime");function _n({options:e,placeholder:t,disabled:o,name:a,defaultValue:i,onChange:s,autoFocus:n,onFocus:u,onBlur:r}){let l=(0,Bn.useTheme)(),{loading:c,notifyFieldChange:g}=z(),{fieldName:m,defaultValue:b,registerField:E,error:S}=(0,zn.useField)(a),y=(0,Ie.useRef)(null);(0,Ie.useEffect)(()=>{E({name:m,ref:y.current,getValue:P=>{var d,F,p;let h=((p=(F=(d=P==null?void 0:P.state)==null?void 0:d.selectValue)==null?void 0:F[0])==null?void 0:p.value)||"";return g==null||g(m,h),s==null||s({value:h,event:"SELECT_CHANGE"}),h}})},[m,E,g,s]);let C=(0,Ie.useCallback)(P=>function(h){return(0,Yt.mergeWith)(h,{fontFamily:l.font.families[0].name,lineHeight:l.font.lineHeight,color:l.colors.text.default},P)},[]),T=(0,Ie.useCallback)((P,h)=>{let d="transparent",F=l.colors.text.default;switch(!0){case h.isFocused:{let p=(0,Rt.default)(l.colors.listItem.hover);p.luminance()>.5?d=p.brighten(1).hex("rgb"):d=p.hex("rgb");let I=(0,Rt.default)(d);F=I.luminance(I.luminance()>.5?-2:2).hex("rgb");break}case h.isSelected:{d=l.colors.listItem.selected;let p=(0,Rt.default)(d);F=p.luminance(p.luminance()>.5?-2:2).hex("rgb");break}}return(0,Yt.mergeWith)(P,{fontFamily:l.font.families[0].name,lineHeight:l.font.lineHeight,color:F,backgroundColor:d})},[]);return(0,Gn.jsx)(kn.default,{options:[{label:t,options:e}],placeholder:t,menuPortalTarget:typeof document!="undefined"?document.body:void 0,menuPosition:"fixed",styles:{container:C({width:"100%",display:"flex",height:"3rem"}),control:C({width:"100%",backgroundColor:S?l.colors.input.error:void 0,borderColor:S?l.colors.alert.urgent:void 0}),indicatorSeparator:C({backgroundColor:S?l.colors.alert.urgent:void 0}),dropdownIndicator:C({color:S?l.colors.alert.urgent:void 0}),option:T,menuPortal:C({zIndex:99999})},openMenuOnFocus:!0,defaultValue:i||b,ref:y,isDisabled:o||c,autoFocus:n,onFocus:u,onBlur:r})}var we=require("react/jsx-runtime");function Wn({name:e,label:t,disabled:o=!1,options:a,placeholder:i="Selecione um item",full:s=!1,defaultValue:n,onChange:u,autoFocus:r,onFocus:l,onBlur:c}){let{error:g}=(0,Un.useField)(e);return(0,we.jsxs)(Xn.Container.Vertical,{full:s,children:[t&&(0,we.jsx)(Zt.Typography,{testID:"label",children:t}),$n.Platform.OS==="web"?(0,we.jsx)(_n,{disabled:o,options:a,name:e,placeholder:i,onChange:u,autoFocus:r,onFocus:l,onBlur:c}):(0,we.jsx)(Dn,{name:e,disabled:o,options:a,defaultValue:n,placeholder:i,onChange:u,autoFocus:r,onFocus:l,onBlur:c}),g&&(0,we.jsx)(Zt.Typography,{color:"DANGER",size:"SM",testID:"error",children:g})]})}var Kn=require("@mobilestock-native/container");var Yn=require("react/jsx-runtime");function qn(o){var a=o,{children:e}=a,t=L(a,["children"]);return(0,Yn.jsx)(Kn.Container.Vertical,R(v({gap:"SM"},t),{children:e}))}var Oi=Object.assign(uo,{Input:Jo,Button:co,Select:Wn,Counter:Xo,Vertical:qn,MultipleArchive:Vr,PhotoList:En,Horizontal:Ko});0&&(module.exports={Form,useForm});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobilestock-native/form",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "lodash": "^4.17.14",
@@ -20,9 +20,9 @@
20
20
  "@mobilestock-native/modalalert": "^0.0.17",
21
21
  "@mobilestock-native/tools": "^0.0.10",
22
22
  "@mobilestock-native/typography": "^0.0.9",
23
+ "@mobilestock-native/list": "^0.0.12",
23
24
  "@mobilestock-native/clickable": "^1.0.9",
24
- "@mobilestock-native/spacer": "^0.0.6",
25
- "@mobilestock-native/list": "^0.0.12"
25
+ "@mobilestock-native/spacer": "^0.0.6"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/lodash": "^4.17.14",