@mobilestock-native/form 0.0.13 → 0.1.1

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 +20 -0
  2. package/index.js +20 -10
  3. package/package.json +10 -3
package/index.d.ts CHANGED
@@ -30,6 +30,25 @@ declare function FormButton({ type, disabled, isLoading, onPress, ...props }: Fo
30
30
 
31
31
  declare function FormHorizontal({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
32
32
 
33
+ interface CustomOption {
34
+ label: string;
35
+ value: string;
36
+ }
37
+ interface FormSelectPropsBase {
38
+ name: string;
39
+ options: CustomOption[];
40
+ disabled: boolean;
41
+ placeholder: string;
42
+ defaultValue?: CustomOption;
43
+ }
44
+ interface FormSelectProps extends Omit<FormSelectPropsBase, 'placeholder' | 'disabled'> {
45
+ placeholder?: string;
46
+ label?: string;
47
+ disabled?: boolean;
48
+ full?: boolean;
49
+ }
50
+ declare function FormSelect({ name, label, disabled, options, placeholder, full, defaultValue }: FormSelectProps): react_jsx_runtime.JSX.Element;
51
+
33
52
  declare function FormVertical({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
34
53
 
35
54
  interface FormPropsWithHandler<T extends object> extends FormProps {
@@ -53,6 +72,7 @@ interface SubmitParams<T extends object> {
53
72
  declare const Form: typeof FormComponent & {
54
73
  Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<InputRef>>;
55
74
  Button: typeof FormButton;
75
+ Select: typeof FormSelect;
56
76
  Vertical: typeof FormVertical;
57
77
  Horizontal: typeof FormHorizontal;
58
78
  };
package/index.js CHANGED
@@ -1,15 +1,25 @@
1
- "use strict";var gr=Object.create;var H=Object.defineProperty,Fr=Object.defineProperties,Er=Object.getOwnPropertyDescriptor,Ir=Object.getOwnPropertyDescriptors,xr=Object.getOwnPropertyNames,G=Object.getOwnPropertySymbols,Pr=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var W=(r,e,o)=>e in r?H(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,g=(r,e)=>{for(var o in e||(e={}))U.call(e,o)&&W(r,o,e[o]);if(G)for(var o of G(e))_.call(e,o)&&W(r,o,e[o]);return r},F=(r,e)=>Fr(r,Ir(e));var E=(r,e)=>{var o={};for(var n in r)U.call(r,n)&&e.indexOf(n)<0&&(o[n]=r[n]);if(r!=null&&G)for(var n of G(r))e.indexOf(n)<0&&_.call(r,n)&&(o[n]=r[n]);return o};var Rr=(r,e)=>{for(var o in e)H(r,o,{get:e[o],enumerable:!0})},D=(r,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xr(e))!U.call(r,s)&&s!==o&&H(r,s,{get:()=>e[s],enumerable:!(n=Er(e,s))||n.enumerable});return r};var X=(r,e,o)=>(o=r!=null?gr(Pr(r)):{},D(e||!r||!r.__esModule?H(o,"default",{value:r,enumerable:!0}):o,r)),Tr=r=>D(H({},"__esModule",{value:!0}),r);var q=(r,e,o)=>new Promise((n,s)=>{var I=c=>{try{d(o.next(c))}catch(m){s(m)}},u=c=>{try{d(o.throw(c))}catch(m){s(m)}},d=c=>c.done?n(c.value):Promise.resolve(c.value).then(I,u);d((o=o.apply(r,e)).next())});var wr={};Rr(wr,{Form:()=>yr,useForm:()=>B});module.exports=Tr(wr);var tr=require("@mobilestock-native/button");var J=require("@unform/mobile"),x=require("react"),Q=require("zod"),Y=require("@mobilestock-native/container"),rr=require("@mobilestock-native/modalalert");var V=require("react/jsx-runtime"),er=(0,x.createContext)({});function B(){return(0,x.useContext)(er)}function or(s){var I=s,{children:r,onSubmit:e,schema:o}=I,n=E(I,["children","onSubmit","schema"]);let u=(0,x.useRef)(null),[d,c]=(0,x.useState)(!1),[m,S]=(0,x.useState)(void 0);function y(){var a;(a=u.current)==null||a.submitForm()}function j(){var a,t;(a=u.current)==null||a.setErrors({}),(t=u.current)==null||t.reset()}function A(a){let t={};for(let b of a){let w=b.path.filter(T=>typeof T=="string"||typeof T=="number").join(".");w&&(t[String(w)]=b.message)}return t}function k(a){if(a instanceof Q.ZodError)return A(a.issues);if(typeof a=="object"&&a!==null&&"errors"in a){let t=a.errors;if(Array.isArray(t)&&t.length>0&&"message"in t[0]&&"path"in t[0])return A(t)}return null}function N(b,w){return q(this,arguments,function*(a,{reset:t}){var T,z,h,C,M;if((T=u.current)==null||T.setErrors({}),o){let f=o.safeParse(a);if(!f.success){(z=u.current)==null||z.setErrors(A(f.error.issues));return}}try{c(!0),yield e({data:a,ref:u,reset:t})}catch(f){let $=k(f);if($)(h=u.current)==null||h.setErrors($);else{let l="Erro ao realizar opera\xE7\xE3o",i=500;if(typeof f=="object"&&f!==null&&"isAxiosError"in f&&f.isAxiosError){let P=f;i=((C=P.response)==null?void 0:C.status)||500;let v=(M=P.response)==null?void 0:M.data;v!=null&&v.message&&(l=v.message)}else f instanceof Error&&(l=f.message||l);S({message:l,status:i})}}finally{c(!1)}})}return(0,V.jsxs)(er.Provider,{value:{formRef:u,submitForm:y,clearForm:j,loading:d},children:[(0,V.jsx)(J.Form,F(g({ref:u,onSubmit:N},n),{children:(0,V.jsx)(Y.Container.Vertical,{gap:"2XS",children:r})})),(0,V.jsx)(rr.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:()=>S(void 0)})]})}var sr=require("react/jsx-runtime");function nr(I){var u=I,{type:r="SUBMIT",disabled:e,isLoading:o,onPress:n}=u,s=E(u,["type","disabled","isLoading","onPress"]);let{submitForm:d,clearForm:c,loading:m}=B();function S(y){switch(r){case"SUBMIT":d();break;case"RESET":c();break;default:n==null||n(y)}}return(0,sr.jsx)(tr.Button,F(g({size:"LG"},s),{onPress:S,isLoading:r==="SUBMIT"&&m||o,disabled:m||o||e}))}var ir=require("@mobilestock-native/container");var ur=require("react/jsx-runtime");function ar(o){var n=o,{children:r}=n,e=E(n,["children"]);return(0,ur.jsx)(ir.Container.Horizontal,F(g({gap:"SM"},e),{children:r}))}var lr=require("@unform/core"),p=require("react"),mr=require("react-native"),O=X(require("styled-components/native")),cr=require("@mobilestock-native/button"),K=require("@mobilestock-native/container"),L=X(require("@mobilestock-native/tools")),Z=require("@mobilestock-native/typography");var R=require("react/jsx-runtime"),pr=(0,p.forwardRef)(function(A,j){var k=A,{name:e,label:o,defaultValue:n,type:s="text",autoSubmit:I=!1,format:u,onChangeText:d,autoCapitalize:c,full:m,maxLength:S}=k,y=E(k,["name","label","defaultValue","type","autoSubmit","format","onChangeText","autoCapitalize","full","maxLength"]);let{loading:N,submitForm:a}=B(),t=(0,lr.useField)(e),b=(0,p.useRef)(null),[w,T]=(0,p.useState)(!0),[z,h]=(0,p.useState)(""),C=s==="password",M=s==="tel"?15:s==="zipcode"?9:S;(0,p.useEffect)(()=>{let l=z||n||(t==null?void 0:t.defaultValue)||"";b.current.value=l,h(l),t.registerField({name:t.fieldName,ref:b.current,getValue(i){return(i==null?void 0:i.value)||""},setValue(i,P){i.value=P,h(P)},clearValue(i){i.value="",h("")}})},[t==null?void 0:t.fieldName,t==null?void 0:t.registerField]),(0,p.useImperativeHandle)(j,()=>({focus(){var l;(l=b.current)==null||l.focus()},blur(){var l;(l=b.current)==null||l.blur()}}));let f=(0,p.useCallback)(l=>{var P,v;let i=l;switch(s){case"tel":i=L.default.phoneNumberFormatter(l);break;case"email":case"url":i=l.trim();break;case"number":i=l.replace(/[^0-9.,]/g,"");break;case"zipcode":i=L.default.formatZipcode(i);break}u&&(i=u(i)),h(i),b.current.value=i,d==null||d(i),s==="tel"&&I&&i.length===15&&((P=b.current)==null||P.blur(),a()),s==="zipcode"&&I&&i.length===9&&((v=b.current)==null||v.blur(),a())},[s,u,I,d,t]),$=(0,p.useCallback)(()=>{switch(s){case"tel":return"phone-pad";case"email":return"email-address";case"url":return"url";case"number":return"numeric";default:return"default"}},[s]);return(0,R.jsxs)(hr,{full:m,$show:s!=="hidden",children:[o&&(0,R.jsx)(Z.Typography,{children:o}),(0,R.jsxs)(vr,{error:!!(t!=null&&t.error),$isPassword:C,children:[(0,R.jsx)(Sr,F(g({},y),{ref:b,value:z,autoCapitalize:s&&["email","url"].includes(s)?"none":c,keyboardType:$(),secureTextEntry:w&&C,onChangeText:f,maxLength:M,editable:!N&&y.editable})),C&&(0,R.jsx)(cr.Button,{size:"SM",onPress:()=>T(!w),icon:w?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),(t==null?void 0:t.error)&&(0,R.jsx)(Z.Typography,{color:"DANGER",size:"SM",children:t.error})]})}),hr=(0,O.default)(K.Container.Vertical)`
2
- ${({$show:r})=>!r&&O.css`
1
+ "use strict";var so=Object.create;var X=Object.defineProperty,lo=Object.defineProperties,uo=Object.getOwnPropertyDescriptor,mo=Object.getOwnPropertyDescriptors,co=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,po=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var pe=(e,o,r)=>o in e?X(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,C=(e,o)=>{for(var r in o||(o={}))ie.call(o,r)&&pe(e,r,o[r]);if(Q)for(var r of Q(o))de.call(o,r)&&pe(e,r,o[r]);return e},v=(e,o)=>lo(e,mo(o));var R=(e,o)=>{var r={};for(var n in e)ie.call(e,n)&&o.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Q)for(var n of Q(e))o.indexOf(n)<0&&de.call(e,n)&&(r[n]=e[n]);return r};var fo=(e,o)=>{for(var r in o)X(e,r,{get:o[r],enumerable:!0})},fe=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of co(o))!ie.call(e,t)&&t!==r&&X(e,t,{get:()=>o[t],enumerable:!(n=uo(o,t))||n.enumerable});return e};var j=(e,o,r)=>(r=e!=null?so(po(e)):{},fe(o||!e||!e.__esModule?X(r,"default",{value:e,enumerable:!0}):r,e)),bo=e=>fe(X({},"__esModule",{value:!0}),e);var be=(e,o,r)=>new Promise((n,t)=>{var u=m=>{try{p(r.next(m))}catch(c){t(c)}},a=m=>{try{p(r.throw(m))}catch(c){t(c)}},p=m=>m.done?n(m.value):Promise.resolve(m.value).then(u,a);p((r=r.apply(e,o)).next())});var Eo={};fo(Eo,{Form:()=>Fo,useForm:()=>x});module.exports=bo(Eo);var Fe=require("@mobilestock-native/button");var ge=require("@unform/mobile"),O=require("react"),he=require("zod"),Se=require("@mobilestock-native/container"),Ce=require("@mobilestock-native/modalalert");var L=require("react/jsx-runtime"),Ie=(0,O.createContext)({});function x(){return(0,O.useContext)(Ie)}function Te(t){var u=t,{children:e,onSubmit:o,schema:r}=u,n=R(u,["children","onSubmit","schema"]);let a=(0,O.useRef)(null),[p,m]=(0,O.useState)(!1),[c,l]=(0,O.useState)(void 0);function f(){var s;(s=a.current)==null||s.submitForm()}function y(){var s,i;(s=a.current)==null||s.setErrors({}),(i=a.current)==null||i.reset()}function h(s){let i={};for(let S of s){let V=S.path.filter(k=>typeof k=="string"||typeof k=="number").join(".");V&&(i[String(V)]=S.message)}return i}function w(s){if(s instanceof he.ZodError)return h(s.issues);if(typeof s=="object"&&s!==null&&"errors"in s){let i=s.errors;if(Array.isArray(i)&&i.length>0&&"message"in i[0]&&"path"in i[0])return h(i)}return null}function I(S,V){return be(this,arguments,function*(s,{reset:i}){var k,U,A,G,J;if((k=a.current)==null||k.setErrors({}),r){let F=r.safeParse(s);if(!F.success){(U=a.current)==null||U.setErrors(h(F.error.issues));return}}try{m(!0),yield o({data:s,ref:a,reset:i})}catch(F){let q=w(F);if(q)(A=a.current)==null||A.setErrors(q);else{let b="Erro ao realizar opera\xE7\xE3o",d=500;if(typeof F=="object"&&F!==null&&"isAxiosError"in F&&F.isAxiosError){let M=F;d=((G=M.response)==null?void 0:G.status)||500;let B=(J=M.response)==null?void 0:J.data;B!=null&&B.message&&(b=B.message)}else F instanceof Error&&(b=F.message||b);l({message:b,status:d})}}finally{m(!1)}})}return(0,L.jsxs)(Ie.Provider,{value:{formRef:a,submitForm:f,clearForm:y,loading:p},children:[(0,L.jsx)(ge.Form,v(C({ref:a,onSubmit:I},n),{children:(0,L.jsx)(Se.Container.Vertical,{gap:"2XS",children:e})})),(0,L.jsx)(Ce.ModalAlert,{visible:!!c,message:c==null?void 0:c.message,type:c&&c.status>=500?"FATAL_ERROR":"ERROR_NOTICE",title:"Erro ao enviar o formul\xE1rio",onClose:()=>l(void 0)})]})}var Pe=require("react/jsx-runtime");function Ee(u){var a=u,{type:e="SUBMIT",disabled:o,isLoading:r,onPress:n}=a,t=R(a,["type","disabled","isLoading","onPress"]);let{submitForm:p,clearForm:m,loading:c}=x();function l(f){switch(e){case"SUBMIT":p();break;case"RESET":m();break;default:n==null||n(f)}}return(0,Pe.jsx)(Fe.Button,v(C({size:"LG"},t),{onPress:l,isLoading:e==="SUBMIT"&&c||r,disabled:c||r||o}))}var ve=require("@mobilestock-native/container");var we=require("react/jsx-runtime");function ye(r){var n=r,{children:e}=n,o=R(n,["children"]);return(0,we.jsx)(ve.Container.Horizontal,v(C({gap:"SM"},o),{children:e}))}var He=require("@unform/core"),T=require("react"),Re=require("react-native"),N=j(require("styled-components/native")),xe=require("@mobilestock-native/button"),le=require("@mobilestock-native/container"),ae=j(require("@mobilestock-native/tools")),se=require("@mobilestock-native/typography");var z=require("react/jsx-runtime"),Ve=(0,T.forwardRef)(function(h,y){var w=h,{name:o,label:r,defaultValue:n,type:t="text",autoSubmit:u=!1,format:a,onChangeText:p,autoCapitalize:m,full:c,maxLength:l}=w,f=R(w,["name","label","defaultValue","type","autoSubmit","format","onChangeText","autoCapitalize","full","maxLength"]);let{loading:I,submitForm:s}=x(),i=(0,He.useField)(o),S=(0,T.useRef)(null),[V,k]=(0,T.useState)(!0),[U,A]=(0,T.useState)(""),G=t==="password",J=t==="tel"?15:t==="zipcode"?9:l;(0,T.useEffect)(()=>{let b=U||n||(i==null?void 0:i.defaultValue)||"";S.current.value=b,A(b),i.registerField({name:i.fieldName,ref:S.current,getValue(d){return(d==null?void 0:d.value)||""},setValue(d,M){d.value=M,A(M)},clearValue(d){d.value="",A("")}})},[i==null?void 0:i.fieldName,i==null?void 0:i.registerField]),(0,T.useImperativeHandle)(y,()=>({focus(){var b;(b=S.current)==null||b.focus()},blur(){var b;(b=S.current)==null||b.blur()}}));let F=(0,T.useCallback)(b=>{var M,B;let d=b;switch(t){case"tel":d=ae.default.phoneNumberFormatter(b);break;case"email":case"url":d=b.trim();break;case"number":d=b.replace(/[^0-9.,]/g,"");break;case"zipcode":d=ae.default.formatZipcode(d);break}a&&(d=a(d)),A(d),S.current.value=d,p==null||p(d),t==="tel"&&u&&d.length===15&&((M=S.current)==null||M.blur(),s()),t==="zipcode"&&u&&d.length===9&&((B=S.current)==null||B.blur(),s())},[t,a,u,p,i]),q=(0,T.useCallback)(()=>{switch(t){case"tel":return"phone-pad";case"email":return"email-address";case"url":return"url";case"number":return"numeric";default:return"default"}},[t]);return(0,z.jsxs)(go,{full:c,$show:t!=="hidden",children:[r&&(0,z.jsx)(se.Typography,{children:r}),(0,z.jsxs)(ho,{error:!!(i!=null&&i.error),$isPassword:G,children:[(0,z.jsx)(So,v(C({},f),{ref:S,value:U,autoCapitalize:t&&["email","url"].includes(t)?"none":m,keyboardType:q(),secureTextEntry:V&&G,onChangeText:F,maxLength:J,editable:!I&&f.editable})),G&&(0,z.jsx)(xe.Button,{size:"SM",onPress:()=>k(!V),icon:V?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),(i==null?void 0:i.error)&&(0,z.jsx)(se.Typography,{color:"DANGER",size:"SM",children:i.error})]})}),go=(0,N.default)(le.Container.Vertical)`
2
+ ${({$show:e})=>!e&&N.css`
3
3
  display: none;
4
4
  `}
5
- `,vr=(0,O.default)(K.Container.Horizontal)`
5
+ `,ho=(0,N.default)(le.Container.Horizontal)`
6
6
  overflow: hidden;
7
- background-color: ${({error:r,theme:e})=>r?e.colors.input.error:e.colors.input.default};
8
- border: 1px solid ${({error:r,theme:e})=>r?e.colors.alert.urgent:e.colors.input.border};
9
- border-radius: ${({theme:r})=>r.borderRadius.default};
10
- padding: ${({$isPassword:r})=>r?"0 0 0 10px":"0 10px"};
11
- `,Sr=(0,O.default)(mr.TextInput)`
7
+ background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
8
+ border: 1px solid ${({error:e,theme:o})=>e?o.colors.alert.urgent:o.colors.input.border};
9
+ border-radius: ${({theme:e})=>e.borderRadius.default};
10
+ padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
11
+ `,So=(0,N.default)(Re.TextInput)`
12
12
  flex: 1;
13
13
  height: 45px;
14
- color: ${({theme:r})=>r.colors.text.default};
15
- `;var fr=require("@mobilestock-native/container");var br=require("react/jsx-runtime");function dr(o){var n=o,{children:r}=n,e=E(n,["children"]);return(0,br.jsx)(fr.Container.Vertical,F(g({gap:"SM"},e),{children:r}))}var yr=Object.assign(or,{Input:pr,Button:nr,Vertical:dr,Horizontal:ar});0&&(module.exports={Form,useForm});
14
+ color: ${({theme:e})=>e.colors.text.default};
15
+ `;var eo=require("@unform/core"),oo=require("react-native"),ro=require("@mobilestock-native/container"),ce=require("@mobilestock-native/typography");var We=require("@unform/core"),Z=require("react"),Y=j(require("styled-components/native")),$e=require("@mobilestock-native/clickable"),K=require("@mobilestock-native/container"),Ue=require("@mobilestock-native/icons"),Xe=require("@mobilestock-native/typography");var Le=require("react"),W=require("react-native"),ne=require("react-native-gesture-handler"),g=j(require("react-native-reanimated")),Ne=require("styled-components/native"),re=require("@mobilestock-native/container"),te=require("@mobilestock-native/list");var De=require("react-native-gesture-handler"),_=require("@mobilestock-native/container");var Oe=require("styled-components/native"),Me=require("@mobilestock-native/container");var ke=require("react/jsx-runtime");function ze(e){let o=(0,Oe.useTheme)();return(0,ke.jsx)(Me.Container.Horizontal,C({style:{width:100,height:4,borderRadius:5,backgroundColor:o.colors.container.shadow}},e))}var Ae=require("@mobilestock-native/typography");var Be=require("react/jsx-runtime");function ue(e){return(0,Be.jsx)(Ae.Typography,C({size:"MD",align:"RIGHT",color:"DEFAULT_100"},e))}var H=require("react/jsx-runtime");function Ge({placeholder:e,panGesture:o}){return o?(0,H.jsx)(De.GestureDetector,{gesture:o,children:(0,H.jsxs)(_.Container.Vertical,{padding:"XS",testID:"form-sheet-header-with-gesture",children:[(0,H.jsx)(_.Container.Horizontal,{align:"CENTER",children:(0,H.jsx)(ze,{})}),(0,H.jsx)(_.Container.Horizontal,{children:(0,H.jsx)(ue,{children:e})})]})}):(0,H.jsx)(_.Container.Vertical,{padding:"XS",testID:"form-sheet-header-without-gesture",children:(0,H.jsx)(_.Container.Horizontal,{children:(0,H.jsx)(ue,{children:e})})})}var E=require("react/jsx-runtime"),{height:Co}=W.Dimensions.get("window"),me=Co*.8,ee=200,oe=45;function _e(e){let o=(0,Ne.useTheme)(),r=(0,Le.useMemo)(()=>Math.min(me,e.options.length*oe+oe),[e.options]),n=Math.min(ee,r),t=(0,g.useSharedValue)(n),u=(0,g.useSharedValue)(n),a=ne.Gesture.Pan().onStart(()=>{u.value=t.value}).onUpdate(l=>{let f=u.value-l.translationY;t.value=Math.max(ee,Math.min(f,r))}).onEnd(l=>{l.velocityY<-1e3?t.value=(0,g.withTiming)(r):t.value>me/2?t.value=(0,g.withTiming)(me):t.value=(0,g.withTiming)(ee)}),p=(0,g.useAnimatedStyle)(()=>({height:t.value,bottom:0}));(0,g.useAnimatedReaction)(()=>e.visible,l=>{l&&(t.value=(0,g.withSpring)(n,{damping:20,stiffness:90,mass:.3}))},[e.visible]);function m(){"worklet";t.value=(0,g.withTiming)(0,{},()=>{(0,g.runOnJS)(e.onClose)()})}function c(l){var f;e.onSelect(l.value===((f=e.selectValue)==null?void 0:f.value)?null:l),m()}return(0,E.jsx)(W.Modal,{visible:e.visible,transparent:!0,animationType:"none",testID:"modal",children:(0,E.jsxs)(ne.GestureHandlerRootView,{children:[(0,E.jsx)(W.TouchableWithoutFeedback,{onPress:m,testID:"backdrop",children:(0,E.jsx)(re.Container.Vertical,{full:!0})}),(0,E.jsxs)(g.default.View,{style:[p,{position:"absolute",width:"100%",backgroundColor:o.colors.container.default,borderTopLeftRadius:20,borderTopRightRadius:20,borderWidth:1,borderColor:o.colors.container.shadow}],children:[(0,E.jsx)(Ge,{placeholder:e.placeholder,panGesture:e.options.length*oe+oe>ee?a:void 0}),(0,E.jsx)(re.Container.Main,{children:(0,E.jsx)(te.List,{data:e.options,itemKey:"value",ItemSeparatorComponent:()=>(0,E.jsx)(re.Container.Horizontal,{testID:"separator",style:{backgroundColor:o.colors.container.shadow,height:1,width:"100%"}}),renderItem:l=>{var f;return(0,E.jsx)(te.List.Item.Horizontal,{isSelected:((f=e.selectValue)==null?void 0:f.value)===l.value,padding:"SM",onPress:()=>c(l),children:(0,E.jsx)(te.List.Item.Title,{children:l.label})})}})})]})]})})}var P=require("react/jsx-runtime");function je({options:e,placeholder:o,disabled:r,defaultValue:n,name:t}){let u=(0,Y.useTheme)(),{loading:a}=x(),{fieldName:p,registerField:m,error:c,defaultValue:l}=(0,We.useField)(t),[f,y]=(0,Z.useState)(!1),[h,w]=(0,Z.useState)(l||n||null);return(0,Z.useEffect)(()=>{m({name:p,getValue:()=>(h==null?void 0:h.value)||"",setValue:(I,s)=>{let i=e.find(S=>S.value===s);i&&w(i)},clearValue:()=>{w(null)}})},[p,m,h,e]),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)($e.Clickable,{disabled:r||a,onPress:()=>y(!0),testID:"select-android",children:(0,P.jsxs)(Io,{padding:"NONE_XS_NONE_MD",error:!!c,testID:"select-android-container",align:"BETWEEN_CENTER",children:[(0,P.jsx)(K.Container.Horizontal,{children:(0,P.jsx)(Xe.Typography,{color:h?"DEFAULT":"DEFAULT_200",children:(h==null?void 0:h.label)||o})}),(0,P.jsxs)(K.Container.Horizontal,{style:{opacity:.3},gap:"XS",align:"CENTER",children:[(0,P.jsx)(To,{error:!!c}),(0,P.jsx)(Ue.Icon,{name:"ChevronDown",size:"XS",color:c?u.colors.alert.urgent:u.colors.text.default})]})]})}),!r&&!a&&(0,P.jsx)(_e,{options:e,onClose:()=>y(!1),visible:f,placeholder:o,selectValue:h,onSelect:I=>{w(I)}})]})}var Io=(0,Y.default)(K.Container.Horizontal)`
16
+ overflow: hidden;
17
+ height: 47px;
18
+ background-color: ${({error:e,theme:o})=>e?o.colors.input.error:o.colors.input.default};
19
+ border: 1px solid ${({error:e,theme:o})=>e?o.colors.alert.urgent:o.colors.input.border};
20
+ border-radius: 5px;
21
+ `,To=(0,Y.default)(K.Container.Vertical)`
22
+ width: 1px;
23
+ height: 30px;
24
+ background-color: ${({theme:e,error:o})=>o?e.colors.alert.urgent:e.colors.text.default};
25
+ `;var Ze=require("@unform/core"),Ke=require("lodash"),$=require("react"),Ye=j(require("react-select")),Je=require("styled-components");var Qe=require("react/jsx-runtime");function qe({options:e,placeholder:o,disabled:r,name:n,defaultValue:t}){var h,w;let u=(0,Je.useTheme)(),{loading:a}=x(),{fieldName:p,defaultValue:m,registerField:c,error:l}=(0,Ze.useField)(n),f=(0,$.useRef)(null);(0,$.useEffect)(()=>{c({name:p,ref:f.current,getValue:I=>{var i,S,V;return((V=(S=(i=I==null?void 0:I.state)==null?void 0:i.selectValue)==null?void 0:S[0])==null?void 0:V.value)||""}})},[p,c]);let y=(0,$.useCallback)(I=>function(s){return(0,Ke.mergeWith)(s,I)},[]);return(0,Qe.jsx)(Ye.default,{options:[{label:o,options:e}],placeholder:o,defaultInputValue:(w=(h=t==null?void 0:t.label)!=null?h:m==null?void 0:m.label)!=null?w:void 0,menuPortalTarget:typeof document!="undefined"?document.body:void 0,menuPosition:"fixed",styles:{container:y({width:"100%",display:"flex",height:"3rem"}),control:y({width:"100%",backgroundColor:l?u.colors.input.error:void 0,borderColor:l?u.colors.alert.urgent:void 0}),indicatorSeparator:y({backgroundColor:l?u.colors.alert.urgent:void 0}),dropdownIndicator:y({color:l?u.colors.alert.urgent:void 0}),option:(I,s)=>v(C({},I),{backgroundColor:s.isSelected?u.colors.listItem.selected:u.colors.listItem.default})},defaultValue:t,ref:f,isDisabled:r||a})}var D=require("react/jsx-runtime");function to({name:e,label:o,disabled:r=!1,options:n,placeholder:t="Selecione um item",full:u=!1,defaultValue:a}){let{error:p}=(0,eo.useField)(e);return(0,D.jsxs)(ro.Container.Vertical,{full:u,children:[o&&(0,D.jsx)(ce.Typography,{testID:"label",children:o}),oo.Platform.OS==="web"?(0,D.jsx)(qe,{disabled:r,options:n,name:e,defaultValue:a,placeholder:t}):(0,D.jsx)(je,{name:e,disabled:r,options:n,defaultValue:a,placeholder:t}),p&&(0,D.jsx)(ce.Typography,{color:"DANGER",size:"SM",testID:"error",children:p})]})}var no=require("@mobilestock-native/container");var ao=require("react/jsx-runtime");function io(r){var n=r,{children:e}=n,o=R(n,["children"]);return(0,ao.jsx)(no.Container.Vertical,v(C({gap:"SM"},o),{children:e}))}var Fo=Object.assign(Te,{Input:Ve,Button:Ee,Select:to,Vertical:io,Horizontal:ye});0&&(module.exports={Form,useForm});
package/package.json CHANGED
@@ -1,24 +1,31 @@
1
1
  {
2
2
  "name": "@mobilestock-native/form",
3
- "version": "0.0.13",
3
+ "version": "0.1.1",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
+ "lodash": "^4.17.14",
6
7
  "@unform/core": "^2.1.6",
8
+ "react-select": "5.10.1",
7
9
  "@unform/mobile": "^2.1.6",
8
10
  "@mobilestock-native/button": "^1.0.11",
9
- "@mobilestock-native/icons": "^0.0.6",
10
11
  "@mobilestock-native/container": "^0.1.0",
12
+ "@mobilestock-native/icons": "^0.0.6",
11
13
  "@mobilestock-native/modalalert": "^0.0.13",
12
14
  "@mobilestock-native/tools": "^0.0.10",
13
- "@mobilestock-native/typography": "^0.0.9"
15
+ "@mobilestock-native/typography": "^0.0.9",
16
+ "@mobilestock-native/clickable": "^1.0.6",
17
+ "@mobilestock-native/list": "^0.0.8"
14
18
  },
15
19
  "devDependencies": {
20
+ "@types/lodash": "^4.17.14",
16
21
  "axios": "^1.7.7"
17
22
  },
18
23
  "peerDependencies": {
19
24
  "react": "18.2.0",
20
25
  "react-native": "0.74.5",
21
26
  "styled-components": "^6.1.8",
27
+ "react-native-gesture-handler": "~2.16.1",
28
+ "react-native-reanimated": "^3.10.1",
22
29
  "zod": "^3.24.2"
23
30
  }
24
31
  }