@mobilestock-native/form 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +13 -13
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -224,7 +224,7 @@ interface FormSelectProps extends Omit<FormSelectPropsBase, 'placeholder' | 'dis
|
|
|
224
224
|
disabled?: boolean;
|
|
225
225
|
full?: boolean;
|
|
226
226
|
}
|
|
227
|
-
declare function FormSelect({ name, label, disabled, options, placeholder, full, defaultValue }: FormSelectProps): react_jsx_runtime.JSX.Element;
|
|
227
|
+
declare function FormSelect({ name, label, disabled, options, placeholder, full, defaultValue, ...rest }: FormSelectProps): react_jsx_runtime.JSX.Element;
|
|
228
228
|
|
|
229
229
|
declare function FormVertical({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
|
|
230
230
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Fn=Object.create;var Ne=Object.defineProperty,In=Object.defineProperties,Rn=Object.getOwnPropertyDescriptor,
|
|
1
|
+
"use strict";var Fn=Object.create;var Ne=Object.defineProperty,In=Object.defineProperties,Rn=Object.getOwnPropertyDescriptor,xn=Object.getOwnPropertyDescriptors,wn=Object.getOwnPropertyNames,ke=Object.getOwnPropertySymbols,Nn=Object.getPrototypeOf,lo=Object.prototype.hasOwnProperty,No=Object.prototype.propertyIsEnumerable;var wo=(e,o,t)=>o in e?Ne(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,g=(e,o)=>{for(var t in o||(o={}))lo.call(o,t)&&wo(e,t,o[t]);if(ke)for(var t of ke(o))No.call(o,t)&&wo(e,t,o[t]);return e},v=(e,o)=>In(e,xn(o));var P=(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 wn(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 l=a=>{try{m(t.next(a))}catch(u){r(u)}},i=a=>{try{m(t.throw(a))}catch(u){r(u)}},m=a=>a.done?n(a.value):Promise.resolve(a.value).then(l,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 l=r,{children:e,onSubmit:o,schema:t}=l,n=P(l,["children","onSubmit","schema"]);let i=(0,te.useRef)(null),[m,a]=(0,te.useState)(!1),[u,p]=(0,te.useState)(void 0);function d(){var c;(c=i.current)==null||c.submitForm()}function h(){var c,s;(c=i.current)==null||c.setErrors({}),(s=i.current)==null||s.reset()}function f(c){let s={};for(let E of c){let F=E.path.filter(w=>typeof w=="string"||typeof w=="number").join(".");F&&(s[String(F)]=E.message)}return s}function b(c){if(c instanceof Vo.ZodError)return f(c.issues);if(typeof c=="object"&&c!==null&&"errors"in c){let s=c.errors;if(Array.isArray(s)&&s.length>0&&"message"in s[0]&&"path"in s[0])return f(s)}return null}function C(E,F){return se(this,arguments,function*(c,{reset:s}){var w,D,T,V,Q;if((w=i.current)==null||w.setErrors({}),t){let z=t.safeParse(c);if(!z.success){(D=i.current)==null||D.setErrors(f(z.error.issues));return}}try{a(!0),yield o({data:c,ref:i,reset:s})}catch(z){let be=b(z);if(be)(T=i.current)==null||T.setErrors(be);else{let N="Erro ao realizar opera\xE7\xE3o",S=500;if(typeof z=="object"&&z!==null&&"isAxiosError"in z&&z.isAxiosError){let y=z;S=((V=y.response)==null?void 0:V.status)||500;let L=(Q=y.response)==null?void 0:Q.data;L!=null&&L.message&&(N=L.message)}else z instanceof Error&&(N=z.message||N);p({message:N,status:S})}}finally{a(!1)}})}return(0,Te.jsxs)(Do.Provider,{value:{formRef:i,submitForm:d,clearForm:h,loading:m},children:[(0,Te.jsx)(Ao.Form,v(g({ref:i,onSubmit:C},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(l){var i=l,{type:e="SUBMIT",disabled:o,isLoading:t,onPress:n}=i,r=P(i,["type","disabled","isLoading","onPress"]);let{submitForm:m,clearForm:a,loading:u}=q();function p(d){switch(e){case"SUBMIT":m();break;case"RESET":a();break;default:n==null||n(d)}}return(0,Bo.jsx)(zo.Button,v(g({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),[l,i]=(0,K.useState)(0),m=(0,K.useCallback)(d=>{let h=d;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]),a=(0,K.useCallback)(d=>{var f;let h=m(d);i(h),(f=e.onChange)==null||f.call(e,{value:h,event:"EDIT"})},[m]);(0,K.useEffect)(()=>{t({name:o,getValue:()=>l,setValue:(d,h)=>a(h),clearValue:()=>a(0)})},[o,l,t,a]),(0,K.useEffect)(()=>{a(Number(e.initialCount)||Number(r)||0)},[e.initialCount,a,r]);function u(d=1){i(h=>{var b;let f=m(h+1*d);return(b=e.onChange)==null||b.call(e,{value:f,event:"INCREMENT"}),f})}function p(d=1){i(h=>{var b;let f=m(h-1*d);return(b=e.onChange)==null||b.call(e,{value:f,event:"DECREMENT"}),f})}return(0,Uo.jsx)($o.Provider,{value:{count:l,increment:u,decrement:p,configureCount:a,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,g({align:"CENTER"},e))}var Vn=(0,Xo.default)(Wo.Container.Vertical)`
|
|
2
2
|
min-width: 40px;
|
|
3
3
|
height: 34px;
|
|
4
4
|
user-select: none;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
width: 100%;
|
|
8
8
|
`,On=(0,so.default)(Jo.Typography)`
|
|
9
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=
|
|
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=P(n,["children"]);let{groupElements:r,error:l}=Y();return(0,et.jsx)(Dn,v(g({align:"CENTER",$groupElements:r,$error:!!l},o),{children:e}))}var Dn=(0,Ve.default)(jo.Container.Horizontal)`
|
|
11
11
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
background-color: transparent;
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
background-color: ${o.colors.input.error};
|
|
22
22
|
border: 1px solid ${o.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
|
|
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 x=require("react/jsx-runtime");function at({children:e}){let{label:o,error:t,labelPosition:n}=Y(),r=[],l=[],i=(0,ne.useCallback)(a=>(0,ne.isValidElement)(a)&&a.type===ne.Fragment?i(a.props.children):a,[]),m=i(e);return ne.Children.toArray(m).forEach(a=>{(0,ne.isValidElement)(a)&&it.default.isComponentWithDisplayName(a.type)&&a.type.displayName===Ae.displayName&&!a.props.renderInsidePill?r.push(a):l.push(a)}),(0,x.jsxs)(Z.Container.Vertical,{align:"CENTER_START",children:[n==="TOP_START"&&o&&(0,x.jsxs)(Z.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,x.jsx)(me,{children:o}),t&&!r.length&&(0,x.jsx)(re,{children:t})]}),n!=="LEFT"&&(0,x.jsxs)(Z.Container.Vertical,{align:"CENTER",children:[(n!=="TOP_START"&&o||n!=="TOP_START"&&t&&!r.length)&&(0,x.jsxs)(Z.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[o&&(0,x.jsx)(me,{children:o}),t&&!r.length&&(0,x.jsx)(re,{children:t})]}),(0,x.jsxs)(Z.Container.Horizontal,{align:"CENTER_START",children:[r.length>0&&(0,x.jsx)(Z.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,x.jsxs)(Z.Container.Vertical,{children:[(0,x.jsx)(Ee,{children:l}),t&&!!r.length&&(0,x.jsx)(re,{children:t})]})]})]}),n==="LEFT"&&(0,x.jsx)(Z.Container.Vertical,{children:(0,x.jsxs)(Z.Container.Horizontal,{align:"CENTER",children:[(0,x.jsxs)(Z.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[o&&(0,x.jsx)(me,{children:o}),t&&!r.length&&(0,x.jsx)(re,{children:t})]}),r.length>0&&(0,x.jsx)(Z.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,x.jsx)(Ee,{children:l})]})})]})}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=P(r,["type","disabled"]);let{loading:l}=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 a(){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,v(g({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||l,onPress:a,onLongPress:u,delayLongPress:500}))})}var Hn=(0,mt.default)(ut.Button)`
|
|
25
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,
|
|
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,l]=(0,Me.useState)(!1),[i,m]=(0,Me.useState)(o.toString());(0,Me.useEffect)(()=>{m(o.toString())},[o]);function a(u){n(Number(u.nativeEvent.text)||0),l(!1)}return t?(0,ae.jsx)(dt.Clickable,{onPress:()=>l(!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:a,onChangeText:m,onEndEditing:a}):(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 I=require("react/jsx-runtime");function ft(){let{label:e,labelPosition:o,error:t}=Y();return(0,I.jsxs)(ue.Container.Vertical,{align:"CENTER_START",children:[o==="TOP_START"&&e&&(0,I.jsxs)(ue.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,I.jsx)(me,{children:e}),t&&(0,I.jsx)(re,{children:t})]}),o!=="LEFT"&&(0,I.jsxs)(ue.Container.Vertical,{align:"CENTER",children:[o!=="TOP_START"&&(e||t)&&(0,I.jsxs)(ue.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,I.jsx)(me,{children:e}),t&&(0,I.jsx)(re,{children:t})]}),(0,I.jsxs)(Ee,{children:[(0,I.jsx)(ie,{type:"MINUS"}),(0,I.jsx)(ve,{}),(0,I.jsx)(ie,{type:"PLUS"})]})]}),o==="LEFT"&&(0,I.jsx)(ue.Container.Vertical,{children:(0,I.jsxs)(ue.Container.Horizontal,{align:"CENTER",children:[(e||t)&&(0,I.jsxs)(ue.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,I.jsx)(me,{children:e}),t&&(0,I.jsx)(re,{children:t})]}),(0,I.jsxs)(Ee,{children:[(0,I.jsx)(ie,{type:"MINUS"}),(0,I.jsx)(ve,{}),(0,I.jsx)(ie,{type:"PLUS"})]})]})})]})}var Be=require("react/jsx-runtime");function gt(t){var n=t,{children:e}=n,o=P(n,["children"]);return(0,Be.jsx)(Go,v(g({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,v(g({},e),{type:"MINUS"}))}co.displayName="Form.FormCounter.Minus";var Ct=require("react/jsx-runtime");function fo(e){return(0,Ct.jsx)(ie,v(g({},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=P(n,["children"]);return(0,vt.jsx)(Tt.Container.Horizontal,v(g({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(f,h){var b=f,{name:o,label:t,defaultValue:n,type:r="text",autoSubmit:l=!1,format:i,onChangeText:m,autoCapitalize:a,full:u,maxLength:p}=b,d=P(b,["name","label","defaultValue","type","autoSubmit","format","onChangeText","autoCapitalize","full","maxLength"]);let{loading:C,submitForm:c}=q(),s=(0,yt.useField)(o),E=(0,k.useRef)(null),[F,w]=(0,k.useState)(!0),[D,T]=(0,k.useState)(""),V=r==="password",Q=r==="tel"?15:r==="zipcode"?9:p;(0,k.useEffect)(()=>{let N=D||n||(s==null?void 0:s.defaultValue)||"";E.current.value=N,T(N),s.registerField({name:s.fieldName,ref:E.current,getValue(S){return(S==null?void 0:S.value)||""},setValue(S,y){S.value=y,T(y)},clearValue(S){S.value="",T("")}})},[s==null?void 0:s.fieldName,s==null?void 0:s.registerField]),(0,k.useImperativeHandle)(h,()=>({focus(){var N;(N=E.current)==null||N.focus()},blur(){var N;(N=E.current)==null||N.blur()}}));let z=(0,k.useCallback)(N=>{var y,L;let S=N;switch(r){case"tel":S=go.default.phoneNumberFormatter(N);break;case"email":case"url":S=N.trim();break;case"number":S=N.replace(/[^0-9.,]/g,"");break;case"zipcode":S=go.default.formatZipcode(S);break}i&&(S=i(S)),T(S),E.current.value=S,m==null||m(S),r==="tel"&&l&&S.length===15&&((y=E.current)==null||y.blur(),c()),r==="zipcode"&&l&&S.length===9&&((L=E.current)==null||L.blur(),c())},[r,i,l,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,v(g({},d),{ref:E,value:D,autoCapitalize:r&&["email","url"].includes(r)?"none":a,keyboardType:be(),secureTextEntry:F&&V,onChangeText:z,maxLength:Q,editable:!C&&d.editable})),V&&(0,pe.jsx)(St.Button,{size:"SM",onPress:()=>w(!F),icon:F?"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
27
|
${({$show:e})=>!e&&ye.css`
|
|
28
28
|
display: none;
|
|
29
29
|
`}
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
flex: 1;
|
|
38
38
|
height: 45px;
|
|
39
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")),
|
|
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
|
|
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")),xt=require("expo-media-library"),$=require("react"),wt=require("react-native");var B={getHashFile(e){return`${e.name}-${e.size}`}};var bo=(l=>(l.json="application/json",l.png="image/png",l.jpg="image/jpg",l.jpeg="image/jpeg",l.all="*/*",l))(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:l,defaultValue:i}=(0,It.useField)(n),[m,a]=(0,xt.usePermissions)({granularPermissions:["photo"]}),[u,p]=(0,$.useState)(null),d=(0,$.useCallback)(C=>{let c=C.map(T=>({file:T,hash:B.getHashFile(T)})),s=(u||[]).map(T=>({file:T,hash:B.getHashFile(T)})),E=[...c,...s],F=Array.from(new Set(E.map(T=>T.hash))).map(T=>E.find(V=>V.hash===T)),w=F.filter(T=>c.some(V=>V.hash===T.hash));if(!w.length)return;let D=F.map(T=>T.file);p(D),t==null||t({value:w.map(T=>T.file),event:"ADD_FILES"})},[u,t]),h=(0,$.useCallback)(C=>{if(!C){p(null);return}let c=C.filter(s=>!!s);d(c)},[d,p]);(0,$.useEffect)(()=>{l({name:r,getValue:()=>u,setValue:(C,c)=>h(c||i),clearValue:()=>p(null)})},[r,l,u,h,i]),(0,$.useEffect)(()=>{m!=null&&m.granted||a()},[m,a]),(0,$.useEffect)(()=>{p(null)},[o]);function f(C){if(!u)return;let c=u.filter(s=>B.getHashFile(s)!==C);p(c),t==null||t({value:u.find(s=>B.getHashFile(s)===C),event:"REMOVE_FILE"})}function b(){return se(this,null,function*(){let C=yield Rt.getDocumentAsync({multiple:!0,type:o==null?void 0:o.map(s=>bo[s])});if(!C.assets)return;if(wt.Platform.OS==="android"){d(C.assets.map(s=>({uri:s.uri,name:s.name,type:s.mimeType})));return}let c=C.assets.map(s=>s.file).filter(s=>!!s);c.length&&d(c)})}return(0,At.jsx)(Nt.Provider,{value:{handleSelectFile:b,handleSaveFiles:d,handleRemoveFile:f,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 l(i){var u;i.preventDefault(),r(!1);let m=i.dataTransfer;if(!m)return;let a=[];if(m.items&&m.items.length>0)for(let p=0;p<m.items.length;p++){let d=m.items[p];if(d.kind!=="file")continue;let h=d.webkitGetAsEntry();if(h&&h.isDirectory)continue;let f=d.getAsFile();f&&a.push(f)}else if(m.files&&m.files.length>0)for(let p=0;p<m.files.length;p++){let d=m.files.item(p);d&&a.push(d)}a.length!==0&&((u=o.accept)!=null&&u.some(p=>p!=="all")&&(a=a.filter(p=>{var h;let d=p.name.split(".").pop();return(h=o.accept)==null?void 0:h.includes(d==null?void 0:d.toLowerCase())}),!a.length)||o.handleSaveFiles(a))}return Wt.Platform.OS!=="web"?e.children:(0,Yt.jsx)("div",g({onDragOver:i=>{i.preventDefault(),r(!0)},onDrop:l,onDragLeave:i=>{i.preventDefault(),r(!1)},style:g({},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,a;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")}]})),l=(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:l,children:(a=e.files)==null?void 0:a.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=P(n,["accept"]);let{error:r}=(0,rr.useField)(o.name),l=(0,nr.useMemo)(()=>_e.parseAcceptString(e),[e]);return(0,oe.jsx)(Lt,v(g({},o),{accept:l,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
42
|
border: 1px solid ${({theme:e,$error:o})=>o?e.colors.input.error:e.colors.input.border};
|
|
43
43
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
44
44
|
background-color: ${({theme:e,$error:o})=>o?e.colors.input.error:e.colors.input.default};
|
|
45
45
|
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:
|
|
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:l,dragAndDrop:i,buttonAddDirection:m}){let a=(0,cr.useTheme)(),{fieldName:u,registerField:p,defaultValue:d}=(0,mr.useField)(t),[h,f]=(0,pr.usePermissions)({granularPermissions:["photo"]}),[b,C]=(0,O.useState)(null),[c,s]=(0,O.useState)(!1),[E,F]=(0,O.useState)(null),w=(0,O.useMemo)(()=>parseInt(a.sizeImage[o.toLowerCase()]),[a,o]),D=(0,O.useMemo)(()=>parseInt(a.gaps[e.toLowerCase()]),[a,e]),T=(0,O.useCallback)(y=>{C(m==="RIGHT"?L=>[...L||[],...y].reverse():L=>[...L||[],...y])},[C,m]),V=(0,O.useCallback)(y=>{if(!y){C(null);return}T(y)},[T]);(0,O.useEffect)(()=>{p({name:u,getValue:()=>b,setValue:(y,L)=>V(L||d),clearValue:()=>C(null)})},[u,p,b,V,d]),(0,O.useEffect)(()=>{h!=null&&h.granted||f()},[h,f]);function Q(){return se(this,null,function*(){var L;let y=yield(0,ur.launchImageLibraryAsync)({mediaTypes:["images"],allowsEditing:l?void 0:!0,quality:1,allowsMultipleSelection:l});if(To.Platform.OS==="web"&&y.assets&&!l){s(!0),F(y.assets[0].file);return}T(((L=y.assets)==null?void 0:L.map(le=>To.Platform.OS==="web"?le.file:{uri:le.uri,name:le.fileName,type:le.mimeType}))||[])})}function z(y){if(!b)return;let L=b.filter(le=>B.getHashFile(le)!==y);C(L),r==null||r({value:b.find(le=>B.getHashFile(le)===y),event:"REMOVE_IMAGE"})}function be(y){C(y),r==null||r({value:y,event:"REORDER_IMAGES"})}function N(y){T([y]),s(!1),F(null),r==null||r({value:y,event:"CROP_SAVE"})}function S(){s(!1),F(null)}return(0,gr.jsx)(dr.Provider,{value:{showDeviceImage:Q,images:b,removeImage:z,reorderImages:be,openImageCropModal:c,imageToCrop:E,handleImageCropCancel:S,handleImageCropSave:N,sizeComponent:w,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 xr({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)`
|
|
47
47
|
flex-direction: row;
|
|
48
48
|
justify-content: space-between;
|
|
49
49
|
align-items: center;
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
position: absolute;
|
|
52
52
|
bottom: 0;
|
|
53
53
|
background-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
|
|
54
|
-
`;var Ze=R(require("styled-components/native")),
|
|
54
|
+
`;var Ze=R(require("styled-components/native")),wr=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)(wr.Clickable)`
|
|
55
55
|
position: absolute;
|
|
56
56
|
top: 0;
|
|
57
57
|
right: 0;
|
|
58
58
|
z-index: 1;
|
|
59
59
|
border-bottom-left-radius: 4px;
|
|
60
60
|
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)(
|
|
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)(xr,{drag:o,isActive:t})]})}var Dr=(0,Je.memo)(Xn),Wn=(0,Qe.default)(Mr.Container.Vertical)`
|
|
62
62
|
background-color: ${({theme:e})=>e.colors.formPhotoList.defaultBar};
|
|
63
63
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
64
64
|
overflow: hidden;
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
${({theme:e,isActive:o})=>o&&Qe.css`
|
|
72
72
|
border-color: ${e.colors.formPhotoList.highlightBar};
|
|
73
73
|
`}
|
|
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=
|
|
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=P(n,["children"]);let[r,l]=(0,ge.useState)(!1),i=(0,ge.useCallback)(()=>(0,_r.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),m=(0,ge.useCallback)(()=>{l(i())},[i]);return(0,ge.useEffect)(()=>(window.addEventListener("resize",m),l(i()),()=>{window.removeEventListener("resize",m)}),[i,m]),r?(0,Se.jsx)(Po.Modal,v(g({transparent:!0,statusBarTranslucent:!0},o),{children:(0,Se.jsx)(je.Container.Main,{children:e})})):(0,Se.jsx)(Po.Modal,v(g({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)`
|
|
75
75
|
background-color: ${({theme:e})=>e.colors.container.default};
|
|
76
76
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
77
77
|
border: 1px solid ${({theme:e})=>e.colors.input.border};
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
width: 100%;
|
|
81
81
|
height: 100%;
|
|
82
82
|
overflow: hidden;
|
|
83
|
-
`;var U=require("react/jsx-runtime");function Ur(){let e=_(),[o,t]=(0,j.useState)(),[n,r]=(0,j.useState)(),[
|
|
83
|
+
`;var U=require("react/jsx-runtime");function Ur(){let e=_(),[o,t]=(0,j.useState)(),[n,r]=(0,j.useState)(),[l,i]=(0,j.useState)(),m=(0,j.useRef)(null),a=(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:f,displayHeight:b,naturalWidth:C,naturalHeight:c}){r({displayWidth:f,displayHeight:b,naturalWidth:C,naturalHeight:c});let s=Math.min(f,b);t({unit:"px",width:s,height:s,x:f>b?(f-s)/2:0,y:b>f?(b-s)/2:0})}function d(){return se(this,null,function*(){if(!e.imageToCrop||!o||!n)return;let f=n.naturalWidth/n.displayWidth,b=n.naturalHeight/n.displayHeight,C=o.x*f,c=o.y*b,s=o.width*f,E=o.height*b,F=new OffscreenCanvas(s,E),w=F.getContext("2d"),D=new Image;D.src=URL.createObjectURL(e.imageToCrop),yield new Promise(Q=>{D.onload=()=>Q()}),w.drawImage(D,C,c,s,E,0,0,s,E);let T=yield F.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(f){let b=f.currentTarget,C=a.current,c=C.clientWidth,s=C.clientHeight,E=b.naturalWidth,F=b.naturalHeight,w=Math.min(c/E,s/F),D=E*w,T=F*w;i({width:D,height:T}),p({displayWidth:D,displayHeight:T,naturalWidth:E,naturalHeight:F})}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:a,testID:"container-crop-vertical",align:"CENTER",children:(0,U.jsx)(Zn,{crop:o,width:l==null?void 0:l.width,height:l==null?void 0:l.height,onChange:f=>t(f),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:d,testID:"button-save",text:"Salvar"})})]})]})})}var Kn=(0,Fe.default)(he.Container.Vertical)`
|
|
84
84
|
width: 100%;
|
|
85
85
|
`,Yn=(0,Fe.default)(he.Container.Vertical)`
|
|
86
86
|
width: 100%;
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
height: ${o}px;
|
|
94
94
|
display: inline-flex;
|
|
95
95
|
`}
|
|
96
|
-
`;var H=require("react/jsx-runtime");function qr({numberOfImagesVisible:e,buttonAddDirection:o,label:t,alignLabel:n}){let r=(0,Ie.useWindowDimensions)(),
|
|
96
|
+
`;var H=require("react/jsx-runtime");function qr({numberOfImagesVisible:e,buttonAddDirection:o,label:t,alignLabel:n}){let r=(0,Ie.useWindowDimensions)(),l=_(),i=(0,Wr.useTheme)(),m=(0,oo.useCallback)(u=>{l.reorderImages(u.data)},[l]),a=(0,oo.useMemo)(()=>e?l.sizeComponent*e+l.gapComponent*(e-1):r.width-l.sizeComponent-l.gapComponent*4,[e,r.width,l.sizeComponent,l.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:l.gap,children:[o==="LEFT"&&(0,H.jsx)(Eo,{}),l.images&&(0,H.jsx)(eo.Container.Horizontal,{children:(0,H.jsx)(Xr.default,{data:l.images,keyExtractor:B.getHashFile,horizontal:!0,onDragEnd:m,activationDistance:10,style:{maxWidth:a,paddingBottom:parseInt(i.spacing["2xs"])},ItemSeparatorComponent:()=>(0,H.jsx)(Ie.View,{style:{width:l.gapComponent}}),renderItem:u=>(0,H.jsx)(Dr,g({},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(l){var i=l,{label:e,alignLabel:o,buttonAddDirection:t="LEFT",numberOfImagesVisible:n=0}=i,r=P(i,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,Fo.jsx)(fr,v(g({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"),xo=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"),xe=require("react-native"),ao=require("react-native-gesture-handler"),A=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,g({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,g({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}=xe.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,A.useSharedValue)(n),l=(0,A.useSharedValue)(n),i=ao.Gesture.Pan().onStart(()=>{l.value=r.value}).onUpdate(p=>{let d=l.value-p.translationY;r.value=Math.max(to,Math.min(d,t))}).onEnd(p=>{p.velocityY<-1e3?r.value=(0,A.withTiming)(t):r.value>Ro/2?r.value=(0,A.withTiming)(Ro):r.value=(0,A.withTiming)(to)}),m=(0,A.useAnimatedStyle)(()=>({height:r.value,bottom:0}));(0,A.useAnimatedReaction)(()=>e.visible,p=>{p&&(r.value=(0,A.withSpring)(n,{damping:20,stiffness:90,mass:.3}))},[e.visible]);function a(){"worklet";r.value=(0,A.withTiming)(0,{},()=>{(0,A.runOnJS)(e.onClose)()})}function u(p){var d;e.onSelect(p.value===((d=e.selectValue)==null?void 0:d.value)?null:p),a()}return(0,X.jsx)(xe.Modal,{visible:e.visible,transparent:!0,animationType:"none",testID:"modal",children:(0,X.jsxs)(ao.GestureHandlerRootView,{children:[(0,X.jsx)(xe.TouchableWithoutFeedback,{onPress:a,testID:"backdrop",children:(0,X.jsx)(no.Container.Vertical,{full:!0})}),(0,X.jsxs)(A.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 d;return(0,X.jsx)(io.List.Item.Horizontal,{isSelected:((d=e.selectValue)==null?void 0:d.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 l=(0,ze.useTheme)(),{loading:i}=q(),{fieldName:m,registerField:a,error:u,defaultValue:p}=(0,ln.useField)(r),[d,h]=(0,De.useState)(!1),[f,b]=(0,De.useState)(p||n||null);return(0,De.useEffect)(()=>{a({name:m,getValue:()=>(f==null?void 0:f.value)||"",setValue:(C,c)=>{let s=e.find(E=>E.value===c);s&&b(s)},clearValue:()=>{b(null)}})},[m,a,f,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:f?"DEFAULT":"DEFAULT_200",children:(f==null?void 0:f.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?l.colors.alert.urgent:l.colors.text.default})]})]})}),!t&&!i&&(0,W.jsx)(an,{options:e,onClose:()=>h(!1),visible:d,placeholder:o,selectValue:f,onSelect:C=>{b(C)}})]})}var Qn=(0,ze.default)(He.Container.Horizontal)`
|
|
97
97
|
overflow: hidden;
|
|
98
98
|
height: 47px;
|
|
99
99
|
background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
|
|
@@ -103,4 +103,4 @@
|
|
|
103
103
|
width: 1px;
|
|
104
104
|
height: 30px;
|
|
105
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"),
|
|
106
|
+
`;var cn=require("@unform/core"),dn=require("lodash"),we=require("react"),fn=R(require("react-select")),gn=require("styled-components/native");var Cn=require("react/jsx-runtime");function hn(i){var m=i,{options:e,placeholder:o,disabled:t,name:n,defaultValue:r}=m,l=P(m,["options","placeholder","disabled","name","defaultValue"]);let a=(0,gn.useTheme)(),{loading:u}=q(),{fieldName:p,defaultValue:d,registerField:h,error:f}=(0,cn.useField)(n),b=(0,we.useRef)(null);(0,we.useEffect)(()=>{h({name:p,ref:b.current,getValue:c=>{var E,F,w;return((w=(F=(E=c==null?void 0:c.state)==null?void 0:E.selectValue)==null?void 0:F[0])==null?void 0:w.value)||""}})},[p,h]);let C=(0,we.useCallback)(c=>function(s){return(0,dn.mergeWith)(s,{fontFamily:a.font.families[0].name,lineHeight:a.font.lineHeight,color:a.colors.text.default},c)},[]);return(0,Cn.jsx)(fn.default,g({options:[{label:o,options:e}],placeholder:o,menuPortalTarget:typeof document!="undefined"?document.body:void 0,menuPosition:"fixed",styles:{container:C({width:"100%",display:"flex",height:"3rem"}),control:C({width:"100%",backgroundColor:f?a.colors.input.error:void 0,borderColor:f?a.colors.alert.urgent:void 0}),indicatorSeparator:C({backgroundColor:f?a.colors.alert.urgent:void 0}),dropdownIndicator:C({color:f?a.colors.alert.urgent:void 0}),option:(c,s)=>v(g({},c),{fontFamily:a.font.families[0].name,lineHeight:a.font.lineHeight,color:a.colors.text.default,backgroundColor:s.isSelected?a.colors.listItem.selected:a.colors.listItem.default}),menuPortal:C({zIndex:99999})},defaultValue:r||d,ref:b,isDisabled:t||u},l))}var Ce=require("react/jsx-runtime");function vn(a){var u=a,{name:e,label:o,disabled:t=!1,options:n,placeholder:r="Selecione um item",full:l=!1,defaultValue:i}=u,m=P(u,["name","label","disabled","options","placeholder","full","defaultValue"]);let{error:p}=(0,bn.useField)(e);return(0,Ce.jsxs)(En.Container.Vertical,{full:l,children:[o&&(0,Ce.jsx)(xo.Typography,{testID:"label",children:o}),Tn.Platform.OS==="web"?(0,Ce.jsx)(hn,g({disabled:t,options:n,name:e,placeholder:r,defaultValue:i},m)):(0,Ce.jsx)(pn,{name:e,disabled:t,options:n,defaultValue:i,placeholder:r}),p&&(0,Ce.jsx)(xo.Typography,{color:"DANGER",size:"SM",testID:"error",children:p})]})}var yn=require("@mobilestock-native/container");var Sn=require("react/jsx-runtime");function Pn(t){var n=t,{children:e}=n,o=P(n,["children"]);return(0,Sn.jsx)(yn.Container.Vertical,v(g({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});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestock-native/form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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",
|