@mobilestock-native/form 0.2.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +85 -2
  2. package/index.js +72 -16
  3. package/package.json +13 -6
package/index.d.ts CHANGED
@@ -1,14 +1,58 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, RefObject } from 'react';
2
4
  import { BadgeType } from '@mobilestock-native/badge';
3
5
  import { ButtonProps } from '@mobilestock-native/button';
4
- import * as react from 'react';
5
- import { RefObject } from 'react';
6
6
  import { TextInputProps } from 'react-native';
7
7
  import { FormHandles } from '@unform/core';
8
8
  import { ViewBaseProps } from '@mobilestock-native/container';
9
+ import { DefaultTheme } from 'styled-components/native';
9
10
  import { FormProps } from '@unform/mobile';
10
11
  import { ZodSchema } from 'zod';
11
12
 
13
+ declare function ErrorLabel(): react_jsx_runtime.JSX.Element;
14
+
15
+ declare function HelpText(): react_jsx_runtime.JSX.Element;
16
+
17
+ declare function HelpButton(): react_jsx_runtime.JSX.Element;
18
+
19
+ declare function Title({ children }: {
20
+ children?: React.ReactNode;
21
+ }): react_jsx_runtime.JSX.Element;
22
+
23
+ declare enum TypeFiles {
24
+ json = "application/json",
25
+ png = "image/png",
26
+ jpg = "image/jpg",
27
+ jpeg = "image/jpeg",
28
+ all = "*/*"
29
+ }
30
+
31
+ type TypeEventOnChange$1 = EventOnChangeAddFiles | EventOnChangeRemoveFile;
32
+ type MultipleArchiveProviderProps<TypeEventOnChangeGeneric extends TypeEventOnChange$1 = TypeEventOnChange$1> = {
33
+ children: ReactNode;
34
+ accept?: (keyof typeof TypeFiles)[];
35
+ onChange?(event: TypeEventOnChangeGeneric): void;
36
+ name: string;
37
+ };
38
+
39
+ type EventOnChangeAddFiles = {
40
+ value: File[];
41
+ event: 'ADD_FILES';
42
+ };
43
+ type EventOnChangeRemoveFile = {
44
+ value: File;
45
+ event: 'REMOVE_FILE';
46
+ };
47
+ interface MultipleArchiveProps extends Omit<MultipleArchiveProviderProps, 'children' | 'accept'> {
48
+ children?: React.ReactNode;
49
+ accept?: (keyof typeof TypeFiles)[] | string;
50
+ alignLabel?: 'END' | 'CENTER' | 'START';
51
+ label?: string;
52
+ }
53
+
54
+ declare function Display$1({ accept, ...props }: MultipleArchiveProps): react_jsx_runtime.JSX.Element;
55
+
12
56
  interface BadgeProps {
13
57
  text: string;
14
58
  renderInsidePill?: boolean;
@@ -84,6 +128,38 @@ declare function FormButton({ type, disabled, isLoading, onPress, ...props }: Fo
84
128
 
85
129
  declare function FormHorizontal({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
86
130
 
131
+ type TypeEventOnChange = EventOnChangeRemoveImage | EventOnChangeReorderImages | EventOnChangeCropSave;
132
+ type PhotoListProviderProps<TypeEventOnChangeGeneric extends TypeEventOnChange = TypeEventOnChange> = {
133
+ children: ReactNode;
134
+ onChange?(event: TypeEventOnChangeGeneric): void;
135
+ multiple?: boolean;
136
+ dragAndDrop?: boolean;
137
+ buttonAddDirection?: 'LEFT' | 'RIGHT';
138
+ name: string;
139
+ size?: Uppercase<keyof DefaultTheme['sizeImage'] & string>;
140
+ gap?: Uppercase<keyof DefaultTheme['gaps'] & string>;
141
+ };
142
+
143
+ type EventOnChangeRemoveImage = {
144
+ value: File;
145
+ event: 'REMOVE_IMAGE';
146
+ };
147
+ type EventOnChangeReorderImages = {
148
+ value: File[];
149
+ event: 'REORDER_IMAGES';
150
+ };
151
+ type EventOnChangeCropSave = {
152
+ value: File;
153
+ event: 'CROP_SAVE';
154
+ };
155
+ interface PhotoInputProps extends Omit<PhotoListProviderProps, 'children'> {
156
+ label?: string;
157
+ alignLabel?: 'END' | 'CENTER' | 'START';
158
+ buttonAddDirection?: 'LEFT' | 'RIGHT';
159
+ numberOfImagesVisible?: number;
160
+ }
161
+ declare function FormPhotoList({ label, alignLabel, buttonAddDirection, numberOfImagesVisible, ...props }: PhotoInputProps): react_jsx_runtime.JSX.Element;
162
+
87
163
  interface CustomOption {
88
164
  label: string;
89
165
  value: string;
@@ -134,6 +210,13 @@ declare const Form: typeof FormComponent & {
134
210
  Badge: typeof Badge;
135
211
  };
136
212
  Vertical: typeof FormVertical;
213
+ MultipleArchive: typeof Display$1 & {
214
+ Title: typeof Title;
215
+ HelpButton: typeof HelpButton;
216
+ HelpText: typeof HelpText;
217
+ ErrorLabel: typeof ErrorLabel;
218
+ };
219
+ PhotoList: typeof FormPhotoList;
137
220
  Horizontal: typeof FormHorizontal;
138
221
  };
139
222
 
package/index.js CHANGED
@@ -1,50 +1,106 @@
1
- "use strict";var ct=Object.create;var le=Object.defineProperty,dt=Object.defineProperties,pt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertyNames,be=Object.getOwnPropertySymbols,Ct=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var ze=(e,o,t)=>o in e?le(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,p=(e,o)=>{for(var t in o||(o={}))Ne.call(o,t)&&ze(e,t,o[t]);if(be)for(var t of be(o))De.call(o,t)&&ze(e,t,o[t]);return e},T=(e,o)=>dt(e,ft(o));var R=(e,o)=>{var t={};for(var n in e)Ne.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&be)for(var n of be(e))o.indexOf(n)<0&&De.call(e,n)&&(t[n]=e[n]);return t};var bt=(e,o)=>{for(var t in o)le(e,t,{get:o[t],enumerable:!0})},Ae=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of gt(o))!Ne.call(e,r)&&r!==t&&le(e,r,{get:()=>o[r],enumerable:!(n=pt(o,r))||n.enumerable});return e};var L=(e,o,t)=>(t=e!=null?ct(Ct(e)):{},Ae(o||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e)),Et=e=>Ae(le({},"__esModule",{value:!0}),e);var Me=(e,o,t)=>new Promise((n,r)=>{var l=a=>{try{u(t.next(a))}catch(m){r(m)}},i=a=>{try{u(t.throw(a))}catch(m){r(m)}},u=a=>a.done?n(a.value):Promise.resolve(a.value).then(l,i);u((t=t.apply(e,o)).next())});var Ot={};bt(Ot,{Form:()=>Vt,useForm:()=>O});module.exports=Et(Ot);var Ke=require("@mobilestock-native/button");var ke=require("@unform/mobile"),D=require("react"),$e=require("zod"),Ue=require("@mobilestock-native/container"),Ge=require("@mobilestock-native/modalalert");var j=require("react/jsx-runtime"),Xe=(0,D.createContext)({});function O(){return(0,D.useContext)(Xe)}function We(r){var l=r,{children:e,onSubmit:o,schema:t}=l,n=R(l,["children","onSubmit","schema"]);let i=(0,D.useRef)(null),[u,a]=(0,D.useState)(!1),[m,c]=(0,D.useState)(void 0);function d(){var f;(f=i.current)==null||f.submitForm()}function g(){var f,s;(f=i.current)==null||f.setErrors({}),(s=i.current)==null||s.reset()}function C(f){let s={};for(let N of f){let z=N.path.filter(K=>typeof K=="string"||typeof K=="number").join(".");z&&(s[String(z)]=N.message)}return s}function y(f){if(f instanceof $e.ZodError)return C(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 C(s)}return null}function I(N,z){return Me(this,arguments,function*(f,{reset:s}){var K,ae,Z,Q,ge;if((K=i.current)==null||K.setErrors({}),t){let x=t.safeParse(f);if(!x.success){(ae=i.current)==null||ae.setErrors(C(x.error.issues));return}}try{a(!0),yield o({data:f,ref:i,reset:s})}catch(x){let Ce=y(x);if(Ce)(Z=i.current)==null||Z.setErrors(Ce);else{let S="Erro ao realizar opera\xE7\xE3o",b=500;if(typeof x=="object"&&x!==null&&"isAxiosError"in x&&x.isAxiosError){let U=x;b=((Q=U.response)==null?void 0:Q.status)||500;let Y=(ge=U.response)==null?void 0:ge.data;Y!=null&&Y.message&&(S=Y.message)}else x instanceof Error&&(S=x.message||S);c({message:S,status:b})}}finally{a(!1)}})}return(0,j.jsxs)(Xe.Provider,{value:{formRef:i,submitForm:d,clearForm:g,loading:u},children:[(0,j.jsx)(ke.Form,T(p({ref:i,onSubmit:I},n),{children:(0,j.jsx)(Ue.Container.Vertical,{gap:"2XS",children:e})})),(0,j.jsx)(Ge.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:()=>c(void 0)})]})}var Ye=require("react/jsx-runtime");function Ze(l){var i=l,{type:e="SUBMIT",disabled:o,isLoading:t,onPress:n}=i,r=R(i,["type","disabled","isLoading","onPress"]);let{submitForm:u,clearForm:a,loading:m}=O();function c(d){switch(e){case"SUBMIT":u();break;case"RESET":a();break;default:n==null||n(d)}}return(0,Ye.jsx)(Ke.Button,T(p({size:"LG"},r),{onPress:c,isLoading:e==="SUBMIT"&&m||t,disabled:m||t||o}))}var Re=L(require("styled-components/native")),ro=require("@mobilestock-native/badge"),no=require("@mobilestock-native/container"),io=L(require("@mobilestock-native/tools")),ao=require("@mobilestock-native/typography");var Je=require("@unform/core"),w=require("react"),je=require("react/jsx-runtime"),qe=(0,w.createContext)(void 0);function Qe(e){let{fieldName:o,registerField:t,error:n,defaultValue:r}=(0,Je.useField)(e.name),[l,i]=(0,w.useState)(0),u=(0,w.useCallback)(d=>{let g=d;return e.maxCount!==void 0&&g>e.maxCount&&(g=e.maxCount),e.minCount!==void 0&&g<e.minCount&&(g=e.minCount),g},[e.maxCount,e.minCount]),a=(0,w.useCallback)(d=>{var C;let g=u(d);i(g),(C=e.onChange)==null||C.call(e,{value:g,event:"EDIT"})},[u]);(0,w.useEffect)(()=>{t({name:o,getValue:()=>l,setValue:(d,g)=>a(g),clearValue:()=>a(0)})},[o,l,t,a]),(0,w.useEffect)(()=>{a(Number(e.initialCount)||Number(r)||0)},[e.initialCount,a,r]);function m(d=1){i(g=>{var y;let C=u(g+1*d);return(y=e.onChange)==null||y.call(e,{value:C,event:"INCREMENT"}),C})}function c(d=1){i(g=>{var y;let C=u(g-1*d);return(y=e.onChange)==null||y.call(e,{value:C,event:"DECREMENT"}),C})}return(0,je.jsx)(qe.Provider,{value:{count:l,increment:m,decrement:c,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 H(){let e=(0,w.useContext)(qe);if(!e)throw new Error("useCounter must be used within a CounterProvider");return e}var eo=L(require("styled-components/native")),oo=require("@mobilestock-native/container");var to=require("react/jsx-runtime");function J(e){return(0,to.jsx)(Tt,p({align:"CENTER"},e))}var Tt=(0,eo.default)(oo.Container.Vertical)`
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},v=(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 g(){var f,s;(f=i.current)==null||f.setErrors({}),(s=i.current)==null||s.reset()}function d(f){let s={};for(let E of f){let S=E.path.filter(A=>typeof A=="string"||typeof A=="number").join(".");S&&(s[String(S)]=E.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 h(E,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:g,loading:m},children:[(0,Te.jsx)(Ao.Form,v(C({ref:i,onSubmit:h},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,v(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 g=c;return e.maxCount!==void 0&&g>e.maxCount&&(g=e.maxCount),e.minCount!==void 0&&g<e.minCount&&(g=e.minCount),g},[e.maxCount,e.minCount]),l=(0,K.useCallback)(c=>{var d;let g=m(c);i(g),(d=e.onChange)==null||d.call(e,{value:g,event:"EDIT"})},[m]);(0,K.useEffect)(()=>{t({name:o,getValue:()=>a,setValue:(c,g)=>l(g),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(g=>{var b;let d=m(g+1*c);return(b=e.onChange)==null||b.call(e,{value:d,event:"INCREMENT"}),d})}function p(c=1){i(g=>{var b;let d=m(g-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)`
2
2
  min-width: 40px;
3
3
  height: 34px;
4
4
  user-select: none;
5
- `;var se=require("react/jsx-runtime");function ue(e){let{groupElements:o}=H();return(0,se.jsx)(J,{children:o&&e.renderInsidePill?(0,se.jsx)(ht,{$type:e.type,full:!0,align:"CENTER",children:(0,se.jsx)(St,{$type:e.type,children:e.text})}):(0,se.jsx)(ro.Badge,{text:e.text,type:e.type,size:"XS"})})}function lo(e,o){return Object.keys(o.colors.badge).find(t=>t.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var ht=(0,Re.default)(no.Container.Vertical)`
6
- background-color: ${({$type:e,theme:o})=>{let t=lo(e,o);return o.colors.badge[t]}};
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]}};
7
7
  width: 100%;
8
- `,St=(0,Re.default)(ao.Typography)`
9
- color: ${({$type:e,theme:o})=>{let t=lo(e,o);return io.default.defineTextColor(o.colors.badge[t])}};
10
- `;ue.displayName="Form.FormCounter.Badge";var M=require("react"),B=require("@mobilestock-native/container"),go=L(require("@mobilestock-native/tools"));var me=L(require("styled-components/native")),so=require("@mobilestock-native/container");var uo=require("react/jsx-runtime");function ee(t){var n=t,{children:e}=n,o=R(n,["children"]);let{groupElements:r,error:l}=H();return(0,uo.jsx)(Pt,T(p({align:"CENTER",$groupElements:r,$error:!!l},o),{children:e}))}var Pt=(0,me.default)(so.Container.Horizontal)`
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,v(C({align:"CENTER",$groupElements:r,$error:!!a},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;
14
14
  border: none;
15
- ${({$groupElements:e,theme:o})=>e&&me.css`
15
+ ${({$groupElements:e,theme:o})=>e&&Ve.css`
16
16
  background-color: ${o.colors.input.default};
17
17
 
18
18
  border: 1px solid ${o.colors.input.border};
19
19
  `}
20
- ${({$error:e,theme:o})=>e&&me.css`
20
+ ${({$error:e,theme:o})=>e&&Ve.css`
21
21
  background-color: ${o.colors.input.error};
22
22
  border: 1px solid ${o.colors.alert.urgent};
23
23
  `}
24
- `;var mo=require("@mobilestock-native/typography"),co=require("react/jsx-runtime");function A({children:e}){return(0,co.jsx)(mo.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var po=require("@mobilestock-native/typography"),fo=require("react/jsx-runtime");function G({children:e}){return(0,fo.jsx)(po.Typography,{weight:"REGULAR",children:e})}var h=require("react/jsx-runtime");function Co({children:e}){let{label:o,error:t,labelPosition:n}=H(),r=[],l=[],i=(0,M.useCallback)(a=>(0,M.isValidElement)(a)&&a.type===M.Fragment?i(a.props.children):a,[]),u=i(e);return M.Children.toArray(u).forEach(a=>{(0,M.isValidElement)(a)&&go.default.isComponentWithDisplayName(a.type)&&a.type.displayName===ue.displayName&&!a.props.renderInsidePill?r.push(a):l.push(a)}),(0,h.jsxs)(B.Container.Vertical,{align:"CENTER_START",children:[n==="TOP_START"&&o&&(0,h.jsxs)(B.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,h.jsx)(G,{children:o}),t&&!r.length&&(0,h.jsx)(A,{children:t})]}),n!=="LEFT"&&(0,h.jsxs)(B.Container.Vertical,{align:"CENTER",children:[(n!=="TOP_START"&&o||n!=="TOP_START"&&t&&!r.length)&&(0,h.jsxs)(B.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[o&&(0,h.jsx)(G,{children:o}),t&&!r.length&&(0,h.jsx)(A,{children:t})]}),(0,h.jsxs)(B.Container.Horizontal,{align:"CENTER_START",children:[r.length>0&&(0,h.jsx)(B.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,h.jsxs)(B.Container.Vertical,{children:[(0,h.jsx)(ee,{children:l}),t&&!!r.length&&(0,h.jsx)(A,{children:t})]})]})]}),n==="LEFT"&&(0,h.jsx)(B.Container.Vertical,{children:(0,h.jsxs)(B.Container.Horizontal,{align:"CENTER",children:[(0,h.jsxs)(B.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[o&&(0,h.jsx)(G,{children:o}),t&&!r.length&&(0,h.jsx)(A,{children:t})]}),r.length>0&&(0,h.jsx)(B.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,h.jsx)(ee,{children:l})]})})]})}var X=require("@mobilestock-native/container");var bo=require("react"),Eo=require("react-native"),To=L(require("styled-components/native")),ho=require("@mobilestock-native/button");var Ie=require("react/jsx-runtime");function k(n){var r=n,{type:e,disabled:o}=r,t=R(r,["type","disabled"]);let{loading:l}=O(),i=H(),u=(0,bo.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 m(){Eo.Vibration.vibrate(50),e==="PLUS"?i.increment(i.multiplier):i.decrement(i.multiplier)}return(0,Ie.jsx)(J,{children:(0,Ie.jsx)(yt,T(p({backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},t),{size:"SM",icon:e==="PLUS"?"Plus":"Minus",variant:i.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:i.groupElements,disabled:u||o||l,onPress:a,onLongPress:m,delayLongPress:500}))})}var yt=(0,To.default)(ho.Button)`
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,v(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
25
  border-radius: ${({$grouped:e,theme:o})=>e?o.borderRadius.none:o.borderRadius.default};
26
- `;var ce=require("react"),So=require("react-native"),Po=require("styled-components/native"),yo=require("@mobilestock-native/clickable"),ve=require("@mobilestock-native/container"),xe=require("@mobilestock-native/typography");var $=require("react/jsx-runtime");function oe(){let e=(0,Po.useTheme)(),{count:o,editable:t,configureCount:n}=H(),[r,l]=(0,ce.useState)(!1),[i,u]=(0,ce.useState)(o.toString());(0,ce.useEffect)(()=>{u(o.toString())},[o]);function a(m){n(Number(m.nativeEvent.text)||0),l(!1)}return t?(0,$.jsx)(yo.Clickable,{onPress:()=>l(!0),children:(0,$.jsx)(ve.Container.Horizontal,{padding:"NONE_2XS",children:(0,$.jsx)(J,{children:r?(0,$.jsx)(So.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:u,onEndEditing:a}):(0,$.jsx)(xe.Typography,{weight:"BOLD",size:"LG",children:o})})})}):(0,$.jsx)(ve.Container.Horizontal,{padding:"NONE_2XS",children:(0,$.jsx)(J,{children:(0,$.jsx)(xe.Typography,{weight:"BOLD",size:"LG",children:o})})})}oe.displayName="Form.FormCounter.Display";var E=require("react/jsx-runtime");function No(){let{label:e,labelPosition:o,error:t}=H();return(0,E.jsxs)(X.Container.Vertical,{align:"CENTER_START",children:[o==="TOP_START"&&e&&(0,E.jsxs)(X.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,E.jsx)(G,{children:e}),t&&(0,E.jsx)(A,{children:t})]}),o!=="LEFT"&&(0,E.jsxs)(X.Container.Vertical,{align:"CENTER",children:[o!=="TOP_START"&&(e||t)&&(0,E.jsxs)(X.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,E.jsx)(G,{children:e}),t&&(0,E.jsx)(A,{children:t})]}),(0,E.jsxs)(ee,{children:[(0,E.jsx)(k,{type:"MINUS"}),(0,E.jsx)(oe,{}),(0,E.jsx)(k,{type:"PLUS"})]})]}),o==="LEFT"&&(0,E.jsx)(X.Container.Vertical,{children:(0,E.jsxs)(X.Container.Horizontal,{align:"CENTER",children:[(e||t)&&(0,E.jsxs)(X.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,E.jsx)(G,{children:e}),t&&(0,E.jsx)(A,{children:t})]}),(0,E.jsxs)(ee,{children:[(0,E.jsx)(k,{type:"MINUS"}),(0,E.jsx)(oe,{}),(0,E.jsx)(k,{type:"PLUS"})]})]})})]})}var Ee=require("react/jsx-runtime");function Ro(t){var n=t,{children:e}=n,o=R(n,["children"]);return(0,Ee.jsx)(Qe,T(p({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},o),{children:e?(0,Ee.jsx)(Co,{children:e}):(0,Ee.jsx)(No,{})}))}var Io=require("react/jsx-runtime");function Fe(e){return(0,Io.jsx)(k,T(p({},e),{type:"MINUS"}))}Fe.displayName="Form.FormCounter.Minus";var vo=require("react/jsx-runtime");function Ve(e){return(0,vo.jsx)(k,T(p({},e),{type:"PLUS"}))}Ve.displayName="Form.FormCounter.Plus";var xo=Object.assign(Ro,{Display:oe,Plus:Ve,Minus:Fe,Badge:ue});var Fo=require("@mobilestock-native/container");var Oo=require("react/jsx-runtime");function Vo(t){var n=t,{children:e}=n,o=R(n,["children"]);return(0,Oo.jsx)(Fo.Container.Horizontal,T(p({gap:"SM"},o),{children:e}))}var wo=require("@unform/core"),v=require("react"),Ho=require("react-native"),te=L(require("styled-components/native")),Bo=require("@mobilestock-native/button"),He=require("@mobilestock-native/container"),Oe=L(require("@mobilestock-native/tools")),we=require("@mobilestock-native/typography");var W=require("react/jsx-runtime"),Lo=(0,v.forwardRef)(function(C,g){var y=C,{name:o,label:t,defaultValue:n,type:r="text",autoSubmit:l=!1,format:i,onChangeText:u,autoCapitalize:a,full:m,maxLength:c}=y,d=R(y,["name","label","defaultValue","type","autoSubmit","format","onChangeText","autoCapitalize","full","maxLength"]);let{loading:I,submitForm:f}=O(),s=(0,wo.useField)(o),N=(0,v.useRef)(null),[z,K]=(0,v.useState)(!0),[ae,Z]=(0,v.useState)(""),Q=r==="password",ge=r==="tel"?15:r==="zipcode"?9:c;(0,v.useEffect)(()=>{let S=ae||n||(s==null?void 0:s.defaultValue)||"";N.current.value=S,Z(S),s.registerField({name:s.fieldName,ref:N.current,getValue(b){return(b==null?void 0:b.value)||""},setValue(b,U){b.value=U,Z(U)},clearValue(b){b.value="",Z("")}})},[s==null?void 0:s.fieldName,s==null?void 0:s.registerField]),(0,v.useImperativeHandle)(g,()=>({focus(){var S;(S=N.current)==null||S.focus()},blur(){var S;(S=N.current)==null||S.blur()}}));let x=(0,v.useCallback)(S=>{var U,Y;let b=S;switch(r){case"tel":b=Oe.default.phoneNumberFormatter(S);break;case"email":case"url":b=S.trim();break;case"number":b=S.replace(/[^0-9.,]/g,"");break;case"zipcode":b=Oe.default.formatZipcode(b);break}i&&(b=i(b)),Z(b),N.current.value=b,u==null||u(b),r==="tel"&&l&&b.length===15&&((U=N.current)==null||U.blur(),f()),r==="zipcode"&&l&&b.length===9&&((Y=N.current)==null||Y.blur(),f())},[r,i,l,u,s]),Ce=(0,v.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,W.jsxs)(Nt,{full:m,$show:r!=="hidden",children:[t&&(0,W.jsx)(we.Typography,{children:t}),(0,W.jsxs)(Rt,{error:!!(s!=null&&s.error),$isPassword:Q,children:[(0,W.jsx)(It,T(p({},d),{ref:N,value:ae,autoCapitalize:r&&["email","url"].includes(r)?"none":a,keyboardType:Ce(),secureTextEntry:z&&Q,onChangeText:x,maxLength:ge,editable:!I&&d.editable})),Q&&(0,W.jsx)(Bo.Button,{size:"SM",onPress:()=>K(!z),icon:z?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),(s==null?void 0:s.error)&&(0,W.jsx)(we.Typography,{color:"DANGER",size:"SM",children:s.error})]})}),Nt=(0,te.default)(He.Container.Vertical)`
27
- ${({$show:e})=>!e&&te.css`
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,v(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,v(C({},e),{type:"MINUS"}))}co.displayName="Form.FormCounter.Minus";var Ct=require("react/jsx-runtime");function fo(e){return(0,Ct.jsx)(ie,v(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,v(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,g){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:h,submitForm:f}=q(),s=(0,yt.useField)(o),E=(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)||"";E.current.value=x,T(x),s.registerField({name:s.fieldName,ref:E.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)(g,()=>({focus(){var x;(x=E.current)==null||x.focus()},blur(){var x;(x=E.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),E.current.value=P,m==null||m(P),r==="tel"&&a&&P.length===15&&((y=E.current)==null||y.blur(),f()),r==="zipcode"&&a&&P.length===9&&((N=E.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,v(C({},c),{ref:E,value:D,autoCapitalize:r&&["email","url"].includes(r)?"none":l,keyboardType:be(),secureTextEntry:S&&V,onChangeText:z,maxLength:Q,editable:!h&&c.editable})),V&&(0,pe.jsx)(St.Button,{size:"SM",onPress:()=>A(!S),icon:S?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),(s==null?void 0: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`
28
28
  display: none;
29
29
  `}
30
- `,Rt=(0,te.default)(He.Container.Horizontal)`
30
+ `,kn=(0,ye.default)(Co.Container.Horizontal)`
31
31
  overflow: hidden;
32
32
  background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
33
33
  border: 1px solid ${({error:e,theme:o})=>e?o.colors.alert.urgent:o.colors.input.border};
34
34
  border-radius: ${({theme:e})=>e.borderRadius.default};
35
35
  padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
36
- `,It=(0,te.default)(Ho.TextInput)`
36
+ `,Bn=(0,ye.default)(Pt.TextInput)`
37
37
  flex: 1;
38
38
  height: 45px;
39
39
  color: ${({theme:e})=>e.colors.text.default};
40
- `;var nt=require("@unform/core"),it=require("react-native"),at=require("@mobilestock-native/container"),_e=require("@mobilestock-native/typography");var Ko=require("@unform/core"),de=require("react"),fe=L(require("styled-components/native")),Zo=require("@mobilestock-native/clickable"),pe=require("@mobilestock-native/container"),Yo=require("@mobilestock-native/icons"),Jo=require("@mobilestock-native/typography");var Go=require("react"),ne=require("react-native"),ye=require("react-native-gesture-handler"),P=L(require("react-native-reanimated")),Xo=require("styled-components/native"),Se=require("@mobilestock-native/container"),Pe=require("@mobilestock-native/list");var $o=require("react-native-gesture-handler"),re=require("@mobilestock-native/container");var _o=require("styled-components/native"),zo=require("@mobilestock-native/container");var Ao=require("react/jsx-runtime");function Do(e){let o=(0,_o.useTheme)();return(0,Ao.jsx)(zo.Container.Horizontal,p({style:{width:100,height:4,borderRadius:5,backgroundColor:o.colors.container.shadow}},e))}var Mo=require("@mobilestock-native/typography");var ko=require("react/jsx-runtime");function Be(e){return(0,ko.jsx)(Mo.Typography,p({size:"MD",align:"RIGHT",color:"DEFAULT_100"},e))}var _=require("react/jsx-runtime");function Uo({placeholder:e,panGesture:o}){return o?(0,_.jsx)($o.GestureDetector,{gesture:o,children:(0,_.jsxs)(re.Container.Vertical,{padding:"XS",testID:"form-sheet-header-with-gesture",children:[(0,_.jsx)(re.Container.Horizontal,{align:"CENTER",children:(0,_.jsx)(Do,{})}),(0,_.jsx)(re.Container.Horizontal,{children:(0,_.jsx)(Be,{children:e})})]})}):(0,_.jsx)(re.Container.Vertical,{padding:"XS",testID:"form-sheet-header-without-gesture",children:(0,_.jsx)(re.Container.Horizontal,{children:(0,_.jsx)(Be,{children:e})})})}var F=require("react/jsx-runtime"),{height:vt}=ne.Dimensions.get("window"),Le=vt*.8,Te=200,he=45;function Wo(e){let o=(0,Xo.useTheme)(),t=(0,Go.useMemo)(()=>Math.min(Le,e.options.length*he+he),[e.options]),n=Math.min(Te,t),r=(0,P.useSharedValue)(n),l=(0,P.useSharedValue)(n),i=ye.Gesture.Pan().onStart(()=>{l.value=r.value}).onUpdate(c=>{let d=l.value-c.translationY;r.value=Math.max(Te,Math.min(d,t))}).onEnd(c=>{c.velocityY<-1e3?r.value=(0,P.withTiming)(t):r.value>Le/2?r.value=(0,P.withTiming)(Le):r.value=(0,P.withTiming)(Te)}),u=(0,P.useAnimatedStyle)(()=>({height:r.value,bottom:0}));(0,P.useAnimatedReaction)(()=>e.visible,c=>{c&&(r.value=(0,P.withSpring)(n,{damping:20,stiffness:90,mass:.3}))},[e.visible]);function a(){"worklet";r.value=(0,P.withTiming)(0,{},()=>{(0,P.runOnJS)(e.onClose)()})}function m(c){var d;e.onSelect(c.value===((d=e.selectValue)==null?void 0:d.value)?null:c),a()}return(0,F.jsx)(ne.Modal,{visible:e.visible,transparent:!0,animationType:"none",testID:"modal",children:(0,F.jsxs)(ye.GestureHandlerRootView,{children:[(0,F.jsx)(ne.TouchableWithoutFeedback,{onPress:a,testID:"backdrop",children:(0,F.jsx)(Se.Container.Vertical,{full:!0})}),(0,F.jsxs)(P.default.View,{style:[u,{position:"absolute",width:"100%",backgroundColor:o.colors.container.default,borderTopLeftRadius:20,borderTopRightRadius:20,borderWidth:1,borderColor:o.colors.container.shadow}],children:[(0,F.jsx)(Uo,{placeholder:e.placeholder,panGesture:e.options.length*he+he>Te?i:void 0}),(0,F.jsx)(Se.Container.Main,{children:(0,F.jsx)(Pe.List,{data:e.options,itemKey:"value",ItemSeparatorComponent:()=>(0,F.jsx)(Se.Container.Horizontal,{testID:"separator",style:{backgroundColor:o.colors.container.shadow,height:1,width:"100%"}}),renderItem:c=>{var d;return(0,F.jsx)(Pe.List.Item.Horizontal,{isSelected:((d=e.selectValue)==null?void 0:d.value)===c.value,padding:"SM",onPress:()=>m(c),children:(0,F.jsx)(Pe.List.Item.Title,{children:c.label})})}})})]})]})})}var V=require("react/jsx-runtime");function qo({options:e,placeholder:o,disabled:t,defaultValue:n,name:r}){let l=(0,fe.useTheme)(),{loading:i}=O(),{fieldName:u,registerField:a,error:m,defaultValue:c}=(0,Ko.useField)(r),[d,g]=(0,de.useState)(!1),[C,y]=(0,de.useState)(c||n||null);return(0,de.useEffect)(()=>{a({name:u,getValue:()=>(C==null?void 0:C.value)||"",setValue:(I,f)=>{let s=e.find(N=>N.value===f);s&&y(s)},clearValue:()=>{y(null)}})},[u,a,C,e]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Zo.Clickable,{disabled:t||i,onPress:()=>g(!0),testID:"select-android",children:(0,V.jsxs)(xt,{padding:"NONE_XS_NONE_MD",error:!!m,testID:"select-android-container",align:"BETWEEN_CENTER",children:[(0,V.jsx)(pe.Container.Horizontal,{children:(0,V.jsx)(Jo.Typography,{color:C?"DEFAULT":"DEFAULT_200",children:(C==null?void 0:C.label)||o})}),(0,V.jsxs)(pe.Container.Horizontal,{style:{opacity:.3},gap:"XS",align:"CENTER",children:[(0,V.jsx)(Ft,{error:!!m}),(0,V.jsx)(Yo.Icon,{name:"ChevronDown",size:"XS",color:m?l.colors.alert.urgent:l.colors.text.default})]})]})}),!t&&!i&&(0,V.jsx)(Wo,{options:e,onClose:()=>g(!1),visible:d,placeholder:o,selectValue:C,onSelect:I=>{y(I)}})]})}var xt=(0,fe.default)(pe.Container.Horizontal)`
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)(h=>{let f=h.map(T=>({file:T,hash:B.getHashFile(T)})),s=(u||[]).map(T=>({file:T,hash:B.getHashFile(T)})),E=[...f,...s],S=Array.from(new Set(E.map(T=>T.hash))).map(T=>E.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]),g=(0,$.useCallback)(h=>{if(!h){p(null);return}let f=h.filter(s=>!!s);c(f)},[c,p]);(0,$.useEffect)(()=>{a({name:r,getValue:()=>u,setValue:(h,f)=>g(f||i),clearValue:()=>p(null)})},[r,a,u,g,i]),(0,$.useEffect)(()=>{m!=null&&m.granted||l()},[m,l]),(0,$.useEffect)(()=>{p(null)},[o]);function d(h){if(!u)return;let f=u.filter(s=>B.getHashFile(s)!==h);p(f),t==null||t({value:u.find(s=>B.getHashFile(s)===h),event:"REMOVE_FILE"})}function b(){return se(this,null,function*(){let h=yield Rt.getDocumentAsync({multiple:!0,type:o==null?void 0:o.map(s=>bo[s])});if(!h.assets)return;if(xt.Platform.OS==="android"){c(h.assets.map(s=>({uri:s.uri,name:s.name,type:s.mimeType})));return}let f=h.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 g=c.webkitGetAsEntry();if(g&&g.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 g;let c=p.name.split(".").pop();return(g=o.accept)==null?void 0:g.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,v(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};
43
+ border-radius: ${({theme:e})=>e.borderRadius.default};
44
+ background-color: ${({theme:e,$error:o})=>o?e.colors.input.error:e.colors.input.default};
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:a,dragAndDrop:i,buttonAddDirection:m}){let l=(0,cr.useTheme)(),{fieldName:u,registerField:p,defaultValue:c}=(0,mr.useField)(t),[g,d]=(0,pr.usePermissions)({granularPermissions:["photo"]}),[b,h]=(0,O.useState)(null),[f,s]=(0,O.useState)(!1),[E,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=>{h(m==="RIGHT"?N=>[...N||[],...y].reverse():N=>[...N||[],...y])},[h,m]),V=(0,O.useCallback)(y=>{if(!y){h(null);return}T(y)},[T]);(0,O.useEffect)(()=>{p({name:u,getValue:()=>b,setValue:(y,N)=>V(N||c),clearValue:()=>h(null)})},[u,p,b,V,c]),(0,O.useEffect)(()=>{g!=null&&g.granted||d()},[g,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);h(N),r==null||r({value:b.find(le=>B.getHashFile(le)===y),event:"REMOVE_IMAGE"})}function be(y){h(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:E,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)`
47
+ flex-direction: row;
48
+ justify-content: space-between;
49
+ align-items: center;
50
+ padding: 4px 12px;
51
+ position: absolute;
52
+ bottom: 0;
53
+ 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)`
55
+ position: absolute;
56
+ top: 0;
57
+ right: 0;
58
+ z-index: 1;
59
+ border-bottom-left-radius: 4px;
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)(wr,{drag:o,isActive:t})]})}var Dr=(0,Je.memo)(Xn),Wn=(0,Qe.default)(Mr.Container.Vertical)`
62
+ background-color: ${({theme:e})=>e.colors.formPhotoList.defaultBar};
63
+ border-radius: ${({theme:e})=>e.borderRadius.default};
64
+ overflow: hidden;
65
+ margin-bottom: 8px;
66
+ width: ${({sizeComponent:e})=>e}px;
67
+ border-width: 1px;
68
+ position: relative;
69
+ border-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
70
+
71
+ ${({theme:e,isActive:o})=>o&&Qe.css`
72
+ border-color: ${e.colors.formPhotoList.highlightBar};
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=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,v(C({transparent:!0,statusBarTranslucent:!0},o),{children:(0,Se.jsx)(je.Container.Main,{children:e})})):(0,Se.jsx)(Po.Modal,v(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)`
75
+ background-color: ${({theme:e})=>e.colors.container.default};
76
+ border-radius: ${({theme:e})=>e.borderRadius.default};
77
+ border: 1px solid ${({theme:e})=>e.colors.input.border};
78
+ max-width: 80%;
79
+ max-height: 80%;
80
+ width: 100%;
81
+ height: 100%;
82
+ 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:h,naturalHeight:f}){r({displayWidth:d,displayHeight:b,naturalWidth:h,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,h=o.x*d,f=o.y*b,s=o.width*d,E=o.height*b,S=new OffscreenCanvas(s,E),A=S.getContext("2d"),D=new Image;D.src=URL.createObjectURL(e.imageToCrop),yield new Promise(Q=>{D.onload=()=>Q()}),A.drawImage(D,h,f,s,E,0,0,s,E);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 g(d){let b=d.currentTarget,h=l.current,f=h.clientWidth,s=h.clientHeight,E=b.naturalWidth,S=b.naturalHeight,A=Math.min(f/E,s/S),D=E*A,T=S*A;i({width:D,height:T}),p({displayWidth:D,displayHeight:T,naturalWidth:E,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:g})})})}),(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)`
84
+ width: 100%;
85
+ `,Yn=(0,Fe.default)(he.Container.Vertical)`
86
+ width: 100%;
87
+ height: 100%;
88
+ padding-left: 16px;
89
+ padding-right: 16px;
90
+ `,Zn=(0,Fe.default)(Gr.ReactCrop)`
91
+ ${({width:e,height:o})=>e&&o&&Fe.css`
92
+ width: ${e}px;
93
+ height: ${o}px;
94
+ display: inline-flex;
95
+ `}
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,v(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,g]=(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:(h,f)=>{let s=e.find(E=>E.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:()=>g(!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:()=>g(!1),visible:c,placeholder:o,selectValue:d,onSelect:h=>{b(h)}})]})}var Qn=(0,ze.default)(He.Container.Horizontal)`
41
97
  overflow: hidden;
42
98
  height: 47px;
43
99
  background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
44
100
  border: 1px solid ${({error:e,theme:o})=>e?o.colors.alert.urgent:o.colors.input.border};
45
101
  border-radius: 5px;
46
- `,Ft=(0,fe.default)(pe.Container.Vertical)`
102
+ `,jn=(0,ze.default)(He.Container.Vertical)`
47
103
  width: 1px;
48
104
  height: 30px;
49
105
  background-color: ${({theme:e,error:o})=>o?e.colors.alert.urgent:e.colors.text.default};
50
- `;var Qo=require("@unform/core"),jo=require("lodash"),ie=require("react"),et=L(require("react-select")),ot=require("styled-components");var rt=require("react/jsx-runtime");function tt({options:e,placeholder:o,disabled:t,name:n,defaultValue:r}){var C,y;let l=(0,ot.useTheme)(),{loading:i}=O(),{fieldName:u,defaultValue:a,registerField:m,error:c}=(0,Qo.useField)(n),d=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{m({name:u,ref:d.current,getValue:I=>{var s,N,z;return((z=(N=(s=I==null?void 0:I.state)==null?void 0:s.selectValue)==null?void 0:N[0])==null?void 0:z.value)||""}})},[u,m]);let g=(0,ie.useCallback)(I=>function(f){return(0,jo.mergeWith)(f,I)},[]);return(0,rt.jsx)(et.default,{options:[{label:o,options:e}],placeholder:o,defaultInputValue:(y=(C=r==null?void 0:r.label)!=null?C:a==null?void 0:a.label)!=null?y:void 0,menuPortalTarget:typeof document!="undefined"?document.body:void 0,menuPosition:"fixed",styles:{container:g({width:"100%",display:"flex",height:"3rem"}),control:g({width:"100%",backgroundColor:c?l.colors.input.error:void 0,borderColor:c?l.colors.alert.urgent:void 0}),indicatorSeparator:g({backgroundColor:c?l.colors.alert.urgent:void 0}),dropdownIndicator:g({color:c?l.colors.alert.urgent:void 0}),option:(I,f)=>T(p({},I),{backgroundColor:f.isSelected?l.colors.listItem.selected:l.colors.listItem.default})},defaultValue:r,ref:d,isDisabled:t||i})}var q=require("react/jsx-runtime");function lt({name:e,label:o,disabled:t=!1,options:n,placeholder:r="Selecione um item",full:l=!1,defaultValue:i}){let{error:u}=(0,nt.useField)(e);return(0,q.jsxs)(at.Container.Vertical,{full:l,children:[o&&(0,q.jsx)(_e.Typography,{testID:"label",children:o}),it.Platform.OS==="web"?(0,q.jsx)(tt,{disabled:t,options:n,name:e,defaultValue:i,placeholder:r}):(0,q.jsx)(qo,{name:e,disabled:t,options:n,defaultValue:i,placeholder:r}),u&&(0,q.jsx)(_e.Typography,{color:"DANGER",size:"SM",testID:"error",children:u})]})}var st=require("@mobilestock-native/container");var mt=require("react/jsx-runtime");function ut(t){var n=t,{children:e}=n,o=R(n,["children"]);return(0,mt.jsx)(st.Container.Vertical,T(p({gap:"SM"},o),{children:e}))}var Vt=Object.assign(We,{Input:Lo,Button:Ze,Select:lt,Counter:xo,Vertical:ut,Horizontal:Vo});0&&(module.exports={Form,useForm});
106
+ `;var cn=require("@unform/core"),dn=require("lodash"),xe=require("react"),fn=R(require("react-select")),gn=require("styled-components");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:h=>{var s,E,S;return((S=(E=(s=h==null?void 0:h.state)==null?void 0:s.selectValue)==null?void 0:E[0])==null?void 0:S.value)||""}})},[m,u]);let g=(0,xe.useCallback)(h=>function(f){return(0,dn.mergeWith)(f,h)},[]);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:g({width:"100%",display:"flex",height:"3rem"}),control:g({width:"100%",backgroundColor:p?a.colors.input.error:void 0,borderColor:p?a.colors.alert.urgent:void 0}),indicatorSeparator:g({backgroundColor:p?a.colors.alert.urgent:void 0}),dropdownIndicator:g({color:p?a.colors.alert.urgent:void 0}),option:(h,f)=>v(C({},h),{backgroundColor:f.isSelected?a.colors.listItem.selected:a.colors.listItem.default})},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,v(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});
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "@mobilestock-native/form",
3
- "version": "0.2.1",
3
+ "version": "1.0.0",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "lodash": "^4.17.14",
7
7
  "@unform/core": "^2.1.6",
8
8
  "react-select": "5.10.1",
9
9
  "@unform/mobile": "^2.1.6",
10
+ "react-native-draggable-flatlist": "^4.0.3",
11
+ "ua-parser-js": "^2.0.6",
12
+ "react-image-crop": "^11.0.10",
13
+ "expo-media-library": "~18.2.0",
14
+ "expo-document-picker": "~14.0.7",
15
+ "expo-image-picker": "~17.0.8",
16
+ "@mobilestock-native/button": "^1.0.13",
17
+ "@mobilestock-native/icons": "^0.0.8",
10
18
  "@mobilestock-native/badge": "^0.0.6",
19
+ "@mobilestock-native/modalalert": "^0.0.15",
11
20
  "@mobilestock-native/container": "^0.1.0",
12
- "@mobilestock-native/icons": "^0.0.7",
13
- "@mobilestock-native/modalalert": "^0.0.14",
14
21
  "@mobilestock-native/tools": "^0.0.10",
15
- "@mobilestock-native/button": "^1.0.12",
16
22
  "@mobilestock-native/typography": "^0.0.9",
17
- "@mobilestock-native/clickable": "^1.0.7",
18
- "@mobilestock-native/list": "^0.0.9"
23
+ "@mobilestock-native/clickable": "^1.0.8",
24
+ "@mobilestock-native/list": "^0.0.10"
19
25
  },
20
26
  "devDependencies": {
21
27
  "@types/lodash": "^4.17.14",
@@ -27,6 +33,7 @@
27
33
  "styled-components": "^6.1.8",
28
34
  "react-native-gesture-handler": "~2.16.1",
29
35
  "react-native-reanimated": "^3.10.1",
36
+ "chroma-js": "^3.1.2",
30
37
  "zod": "^3.24.2"
31
38
  }
32
39
  }