@mobilestock-native/form 1.1.0 → 1.2.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.
- package/index.d.ts +70 -3
- package/index.js +46 -26
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, RefObject } from 'react';
|
|
4
|
+
import { TypographyProps } from '@mobilestock-native/typography';
|
|
5
|
+
import { DefaultTheme } from 'styled-components';
|
|
6
|
+
import { IconName } from '@mobilestock-native/icons';
|
|
4
7
|
import { BadgeType } from '@mobilestock-native/badge';
|
|
5
8
|
import { ButtonProps } from '@mobilestock-native/button';
|
|
6
9
|
import { TextInputProps } from 'react-native';
|
|
7
10
|
import { FormHandles } from '@unform/core';
|
|
8
11
|
import { ViewBaseProps } from '@mobilestock-native/container';
|
|
9
|
-
import { DefaultTheme } from 'styled-components/native';
|
|
12
|
+
import { DefaultTheme as DefaultTheme$1 } from 'styled-components/native';
|
|
10
13
|
import { FormProps } from '@unform/mobile';
|
|
11
14
|
import { ZodSchema } from 'zod';
|
|
12
15
|
|
|
@@ -60,6 +63,65 @@ interface MultipleArchiveProps extends Omit<MultipleArchiveProviderProps, 'child
|
|
|
60
63
|
|
|
61
64
|
declare function Display$1({ accept, ...props }: MultipleArchiveProps): react_jsx_runtime.JSX.Element;
|
|
62
65
|
|
|
66
|
+
declare function Error({ children }: {
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
69
|
+
|
|
70
|
+
declare function Label({ children, ...rest }: TypographyProps): react_jsx_runtime.JSX.Element;
|
|
71
|
+
|
|
72
|
+
declare function Toggle(): react_jsx_runtime.JSX.Element;
|
|
73
|
+
|
|
74
|
+
type SwitchEventName = 'TOGGLE' | 'EDIT';
|
|
75
|
+
type LabelPosition = 'TOP_START' | 'TOP_CENTER' | 'TOP_END' | 'LEFT' | 'RIGHT';
|
|
76
|
+
|
|
77
|
+
type SwitchColor = Uppercase<keyof DefaultTheme['colors']['switch'] & string>;
|
|
78
|
+
type SwitchSize = Uppercase<keyof DefaultTheme['sizeSwitch'] & string>;
|
|
79
|
+
interface SwitchRootProps {
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
name: string;
|
|
82
|
+
label?: string;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
defaultValue?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* @default 'TOP_START'
|
|
87
|
+
* @description Position of the label relative to the switch.
|
|
88
|
+
*/
|
|
89
|
+
labelPosition?: LabelPosition;
|
|
90
|
+
/**
|
|
91
|
+
* @default 'ON'
|
|
92
|
+
* @description Color of the switch when checked, based on theme.colors.switch tokens.
|
|
93
|
+
*/
|
|
94
|
+
checkedColor?: Exclude<SwitchColor, 'OFF' | 'HANDLE'>;
|
|
95
|
+
/**
|
|
96
|
+
* @default 'OFF'
|
|
97
|
+
* @description Background color of the switch when unchecked, based on theme.colors.switch tokens.
|
|
98
|
+
*/
|
|
99
|
+
backgroundColor?: Exclude<SwitchColor, 'ON' | 'HANDLE'>;
|
|
100
|
+
/**
|
|
101
|
+
* @default 'HANDLE'
|
|
102
|
+
* @description Color of the switch handle (circle), based on theme.colors.switch tokens.
|
|
103
|
+
*/
|
|
104
|
+
handleColor?: Exclude<SwitchColor, 'ON' | 'OFF'>;
|
|
105
|
+
/**
|
|
106
|
+
* @default 'MD'
|
|
107
|
+
* @description Size of the switch toggle.
|
|
108
|
+
*/
|
|
109
|
+
size?: SwitchSize;
|
|
110
|
+
/**
|
|
111
|
+
* @description Icons to display inside the handle, reactive to the switch state.
|
|
112
|
+
*/
|
|
113
|
+
icons?: {
|
|
114
|
+
on?: IconName;
|
|
115
|
+
off?: IconName;
|
|
116
|
+
};
|
|
117
|
+
onChange?(data: {
|
|
118
|
+
value: boolean;
|
|
119
|
+
event: SwitchEventName;
|
|
120
|
+
}): void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare function SwitchRoot({ children, ...props }: SwitchRootProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
|
|
63
125
|
interface BadgeProps {
|
|
64
126
|
text: string;
|
|
65
127
|
renderInsidePill?: boolean;
|
|
@@ -178,8 +240,8 @@ type PhotoListProviderProps<TypeEventOnChangeGeneric extends TypeEventOnChange =
|
|
|
178
240
|
dragAndDrop?: boolean;
|
|
179
241
|
buttonAddDirection?: 'LEFT' | 'RIGHT';
|
|
180
242
|
name: string;
|
|
181
|
-
size?: Uppercase<keyof DefaultTheme['sizeImage'] & string>;
|
|
182
|
-
gap?: Uppercase<keyof DefaultTheme['gaps'] & string>;
|
|
243
|
+
size?: Uppercase<keyof DefaultTheme$1['sizeImage'] & string>;
|
|
244
|
+
gap?: Uppercase<keyof DefaultTheme$1['gaps'] & string>;
|
|
183
245
|
};
|
|
184
246
|
|
|
185
247
|
type EventOnChangeRemoveImage = {
|
|
@@ -289,6 +351,11 @@ declare const Form: typeof FormComponent & {
|
|
|
289
351
|
Minus: typeof Minus;
|
|
290
352
|
Badge: typeof Badge;
|
|
291
353
|
};
|
|
354
|
+
Switch: typeof SwitchRoot & {
|
|
355
|
+
Toggle: typeof Toggle;
|
|
356
|
+
Label: typeof Label;
|
|
357
|
+
Error: typeof Error;
|
|
358
|
+
};
|
|
292
359
|
Vertical: typeof FormVertical;
|
|
293
360
|
MultipleArchive: typeof Display$1 & {
|
|
294
361
|
Title: typeof Title;
|
package/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _i=Object.create;var je=Object.defineProperty,Bi=Object.defineProperties,$i=Object.getOwnPropertyDescriptor,Gi=Object.getOwnPropertyDescriptors,Ui=Object.getOwnPropertyNames,ft=Object.getOwnPropertySymbols,Xi=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable;var go=(e,t,o)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,v=(e,t)=>{for(var o in t||(t={}))_t.call(t,o)&&go(e,o,t[o]);if(ft)for(var o of ft(t))ho.call(t,o)&&go(e,o,t[o]);return e},x=(e,t)=>Bi(e,Gi(t));var O=(e,t)=>{var o={};for(var r in e)_t.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&ft)for(var r of ft(e))t.indexOf(r)<0&&ho.call(e,r)&&(o[r]=e[r]);return o};var Wi=(e,t)=>{for(var o in t)je(e,o,{get:t[o],enumerable:!0})},To=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ui(t))!_t.call(e,n)&&n!==o&&je(e,n,{get:()=>t[n],enumerable:!(r=$i(t,n))||r.enumerable});return e};var N=(e,t,o)=>(o=e!=null?_i(Xi(e)):{},To(t||!e||!e.__esModule?je(o,"default",{value:e,enumerable:!0}):o,e)),Ki=e=>To(je({},"__esModule",{value:!0}),e);var Ce=(e,t,o)=>new Promise((r,n)=>{var s=i=>{try{u(o.next(i))}catch(l){n(l)}},a=i=>{try{u(o.throw(i))}catch(l){n(l)}},u=i=>i.done?r(i.value):Promise.resolve(i.value).then(s,a);u((o=o.apply(e,t)).next())});var ya={};Wi(ya,{Form:()=>Sa,useForm:()=>M});module.exports=Ki(ya);var xo=require("@mobilestock-native/button");var xe=require("react");var Eo=require("@unform/mobile"),se=require("react"),So=require("zod"),yo=require("@mobilestock-native/container"),Po=require("@mobilestock-native/modalalert");var et=new Map;function Bt(e){let t=et.get(e);return t||(t={formRef:null,values:{},watchedFields:new Set,listeners:new Set},et.set(e,t)),t}function bo(e,t){let o=Bt(e);o.formRef=t}function Co(e){let t=et.get(e);t&&(t.formRef=null,t.values={},t.watchedFields.clear(),t.listeners.clear(),et.delete(e))}function vo(e,t,o){let r=et.get(e);!r||!r.watchedFields.has(t)||r.values[t]===o||(r.values=x(v({},r.values),{[t]:o}),r.listeners.forEach(n=>n()))}var Ve=require("react/jsx-runtime"),$t=(0,se.createContext)({});function Ro(u){var i=u,{children:e,onSubmit:t,onBeforeSubmit:o,onAfterSubmit:r,schema:n,name:s}=i,a=O(i,["children","onSubmit","onBeforeSubmit","onAfterSubmit","schema","name"]);let l=(0,se.useRef)(null),[m,d]=(0,se.useState)(!1),[c,h]=(0,se.useState)(void 0);(0,se.useEffect)(()=>{if(s)return bo(s,l),()=>Co(s)},[s]);let S=(0,se.useCallback)((T,f)=>{s&&vo(s,T,f)},[s]);function R(){var T;(T=l.current)==null||T.submitForm()}function P(){var T,f;(T=l.current)==null||T.setErrors({}),(f=l.current)==null||f.reset()}function b(T){let f={};for(let E of T){let p=E.path.filter(F=>typeof F=="string"||typeof F=="number").join(".");p&&(f[String(p)]=E.message)}return f}function C(T){if(T instanceof So.ZodError)return b(T.issues);if(typeof T=="object"&&T!==null&&"errors"in T){let f=T.errors;if(Array.isArray(f)&&f.length>0&&"message"in f[0]&&"path"in f[0])return b(f)}return null}function y(E,p){return Ce(this,arguments,function*(T,{reset:f}){var F,oe,W,Z,Te;if((F=l.current)==null||F.setErrors({}),n){let X=n.safeParse(T);if(!X.success){(oe=l.current)==null||oe.setErrors(b(X.error.issues));return}}if(!(o&&(yield o({data:T}))===!1))try{d(!0),yield t==null?void 0:t({data:T,ref:l,reset:f}),yield r==null?void 0:r({data:T})}catch(X){let I=C(X);if(I)(W=l.current)==null||W.setErrors(I);else{let D="Erro ao realizar opera\xE7\xE3o",H=500;if(typeof X=="object"&&X!==null&&"isAxiosError"in X&&X.isAxiosError){let K=X;H=((Z=K.response)==null?void 0:Z.status)||500;let re=(Te=K.response)==null?void 0:Te.data;re!=null&&re.message&&(D=re.message)}else X instanceof Error&&(D=X.message||D);h({message:D,status:H})}}finally{d(!1)}})}return(0,Ve.jsxs)($t.Provider,{value:{formRef:l,submitForm:R,clearForm:P,loading:m,notifyFieldChange:S},children:[(0,Ve.jsx)(Eo.Form,x(v({ref:l,onSubmit:y},a),{children:(0,Ve.jsx)(yo.Container.Vertical,{gap:"2XS",children:e})})),(0,Ve.jsx)(Po.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:()=>h(void 0)})]})}var qi={};function M(e){let t=(0,xe.useContext)($t),o=e?Bt(e):null,r=(0,xe.useCallback)(a=>o?(o.listeners.add(a),()=>{o.listeners.delete(a)}):()=>{},[o]),n=(0,xe.useCallback)(()=>o?o.values:qi,[o]),s=(0,xe.useSyncExternalStore)(r,n);return!e||!o?t:{get values(){var a,u,i;return(i=(u=(a=o.formRef)==null?void 0:a.current)==null?void 0:u.getData())!=null?i:{}},getValue(a){var u,i;return o.watchedFields.add(a),a in s?s[a]:(i=(u=o.formRef)==null?void 0:u.current)==null?void 0:i.getFieldValue(a)},setValue(a,u){var i,l;(l=(i=o.formRef)==null?void 0:i.current)==null||l.setFieldValue(a,u)},submit(){var a,u;(u=(a=o.formRef)==null?void 0:a.current)==null||u.submitForm()},clear(){var a,u,i,l;(u=(a=o.formRef)==null?void 0:a.current)==null||u.setErrors({}),(l=(i=o.formRef)==null?void 0:i.current)==null||l.reset()},setErrors(a){var u,i;(i=(u=o.formRef)==null?void 0:u.current)==null||i.setErrors(a)},reset(a){var u,i;(i=(u=o.formRef)==null?void 0:u.current)==null||i.reset(a)}}}var Fo=require("react/jsx-runtime");function wo(s){var a=s,{type:e="SUBMIT",disabled:t,isLoading:o,onPress:r}=a,n=O(a,["type","disabled","isLoading","onPress"]);let{submitForm:u,clearForm:i,loading:l}=M();function m(d){switch(e){case"SUBMIT":u();break;case"RESET":i();break;default:r==null||r(d)}}return(0,Fo.jsx)(xo.Button,x(v({size:"LG"},n),{onPress:m,isLoading:e==="SUBMIT"&&l||o,disabled:l||o||t}))}var Gt=N(require("styled-components/native")),Do=require("@mobilestock-native/badge"),Mo=require("@mobilestock-native/container"),zo=N(require("@mobilestock-native/tools")),ko=require("@mobilestock-native/typography");var Io=require("@unform/core"),ne=require("react");var Ao=require("react/jsx-runtime"),No=(0,ne.createContext)(void 0);function Oo(e){let{notifyFieldChange:t}=M(),{fieldName:o,registerField:r,error:n,defaultValue:s}=(0,Io.useField)(e.name),[a,u]=(0,ne.useState)(0),i=(0,ne.useCallback)(c=>{let h=c;return e.maxCount!==void 0&&h>e.maxCount&&(h=e.maxCount),e.minCount!==void 0&&h<e.minCount&&(h=e.minCount),h},[e.maxCount,e.minCount]),l=(0,ne.useCallback)((c,h=!0)=>{var R;let S=i(c);u(S),t==null||t(o,S),h&&((R=e.onChange)==null||R.call(e,{value:S,event:"EDIT"}))},[i,t,o]);(0,ne.useEffect)(()=>{r({name:o,getValue:()=>a,setValue:(c,h)=>l(h),clearValue:()=>l(0)})},[o,a,r,l]),(0,ne.useEffect)(()=>{l(Number(e.initialCount)||Number(s)||0,!1)},[e.initialCount,l,s]);function m(c=1){u(h=>{var R;let S=i(h+1*c);return t==null||t(o,S),(R=e.onChange)==null||R.call(e,{value:S,event:"INCREMENT"}),S})}function d(c=1){u(h=>{var R;let S=i(h-1*c);return t==null||t(o,S),(R=e.onChange)==null||R.call(e,{value:S,event:"DECREMENT"}),S})}return(0,Ao.jsx)(No.Provider,{value:{count:a,increment:m,decrement:d,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,autoFocus:e.autoFocus,onFocus:e.onFocus,onBlur:e.onBlur},children:e.children})}function ie(){let e=(0,ne.useContext)(No);if(!e)throw new Error("useCounter must be used within a CounterProvider");return e}var Vo=N(require("styled-components/native")),Lo=require("@mobilestock-native/container");var Ho=require("react/jsx-runtime");function we(e){return(0,Ho.jsx)(Yi,v({align:"CENTER"},e))}var Yi=(0,Vo.default)(Lo.Container.Vertical)`
|
|
2
2
|
min-width: 40px;
|
|
3
3
|
height: 34px;
|
|
4
4
|
user-select: none;
|
|
5
|
-
`;var
|
|
6
|
-
background-color: ${({$type:e,theme:t})=>{let o=
|
|
5
|
+
`;var tt=require("react/jsx-runtime");function ot(e){let{groupElements:t}=ie();return(0,tt.jsx)(we,{children:t&&e.renderInsidePill?(0,tt.jsx)(Zi,{$type:e.type,full:!0,align:"CENTER",children:(0,tt.jsx)(Ji,{$type:e.type,children:e.text})}):(0,tt.jsx)(Do.Badge,{text:e.text,type:e.type,size:"XS"})})}function _o(e,t){return Object.keys(t.colors.badge).find(o=>o.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var Zi=(0,Gt.default)(Mo.Container.Vertical)`
|
|
6
|
+
background-color: ${({$type:e,theme:t})=>{let o=_o(e,t);return t.colors.badge[o]}};
|
|
7
7
|
width: 100%;
|
|
8
|
-
`,
|
|
9
|
-
color: ${({$type:e,theme:t})=>{let o=
|
|
10
|
-
`;
|
|
8
|
+
`,Ji=(0,Gt.default)(ko.Typography)`
|
|
9
|
+
color: ${({$type:e,theme:t})=>{let o=_o(e,t);return zo.default.defineTextColor(t.colors.badge[o])}};
|
|
10
|
+
`;ot.displayName="Form.FormCounter.Badge";var fe=require("react"),ae=require("@mobilestock-native/container"),Ko=N(require("@mobilestock-native/tools"));var rt=N(require("styled-components/native")),Bo=require("@mobilestock-native/container");var $o=require("react/jsx-runtime");function Le(o){var r=o,{children:e}=r,t=O(r,["children"]);let{groupElements:n,error:s}=ie();return(0,$o.jsx)(Qi,x(v({align:"CENTER",$groupElements:n,$error:!!s},t),{children:e}))}var Qi=(0,rt.default)(Bo.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:t})=>e&&
|
|
15
|
+
${({$groupElements:e,theme:t})=>e&&rt.css`
|
|
16
16
|
background-color: ${t.colors.input.default};
|
|
17
17
|
|
|
18
18
|
border: 1px solid ${t.colors.input.border};
|
|
19
19
|
`}
|
|
20
|
-
${({$error:e,theme:t})=>e&&
|
|
20
|
+
${({$error:e,theme:t})=>e&&rt.css`
|
|
21
21
|
background-color: ${t.colors.input.error};
|
|
22
22
|
border: 1px solid ${t.colors.alert.urgent};
|
|
23
23
|
`}
|
|
24
|
-
`;var
|
|
24
|
+
`;var Go=require("@mobilestock-native/typography"),Uo=require("react/jsx-runtime");function de({children:e}){return(0,Uo.jsx)(Go.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var Xo=require("@mobilestock-native/typography"),Wo=require("react/jsx-runtime");function ve({children:e}){return(0,Wo.jsx)(Xo.Typography,{weight:"REGULAR",children:e})}var L=require("react/jsx-runtime");function qo({children:e}){let{label:t,error:o,labelPosition:r}=ie(),n=[],s=[],a=(0,fe.useCallback)(i=>(0,fe.isValidElement)(i)&&i.type===fe.Fragment?a(i.props.children):i,[]),u=a(e);return fe.Children.toArray(u).forEach(i=>{(0,fe.isValidElement)(i)&&Ko.default.isComponentWithDisplayName(i.type)&&i.type.displayName===ot.displayName&&!i.props.renderInsidePill?n.push(i):s.push(i)}),(0,L.jsxs)(ae.Container.Vertical,{align:"CENTER_START",children:[r==="TOP_START"&&t&&(0,L.jsxs)(ae.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,L.jsx)(ve,{children:t}),o&&!n.length&&(0,L.jsx)(de,{children:o})]}),r!=="LEFT"&&(0,L.jsxs)(ae.Container.Vertical,{align:"CENTER",children:[(r!=="TOP_START"&&t||r!=="TOP_START"&&o&&!n.length)&&(0,L.jsxs)(ae.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[t&&(0,L.jsx)(ve,{children:t}),o&&!n.length&&(0,L.jsx)(de,{children:o})]}),(0,L.jsxs)(ae.Container.Horizontal,{align:"CENTER_START",children:[n.length>0&&(0,L.jsx)(ae.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:n}),(0,L.jsxs)(ae.Container.Vertical,{children:[(0,L.jsx)(Le,{children:s}),o&&!!n.length&&(0,L.jsx)(de,{children:o})]})]})]}),r==="LEFT"&&(0,L.jsx)(ae.Container.Vertical,{children:(0,L.jsxs)(ae.Container.Horizontal,{align:"CENTER",children:[(0,L.jsxs)(ae.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[t&&(0,L.jsx)(ve,{children:t}),o&&!n.length&&(0,L.jsx)(de,{children:o})]}),n.length>0&&(0,L.jsx)(ae.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:n}),(0,L.jsx)(Le,{children:s})]})})]})}var Ee=require("@mobilestock-native/container");var Yo=require("react"),Zo=require("react-native"),Jo=N(require("styled-components/native")),Qo=require("@mobilestock-native/button");var Ut=require("react/jsx-runtime");function ge(r){var n=r,{type:e,disabled:t}=n,o=O(n,["type","disabled"]);let{loading:s}=M(),a=ie(),u=(0,Yo.useMemo)(()=>e==="PLUS"&&a.maxCount!==void 0?a.count>=a.maxCount:e==="MINUS"&&a.minCount!==void 0?a.count<=a.minCount:!1,[e,a.count,a.maxCount,a.minCount]);function i(){e==="PLUS"?a.increment():a.decrement()}function l(){Zo.Vibration.vibrate(50),e==="PLUS"?a.increment(a.multiplier):a.decrement(a.multiplier)}return(0,Ut.jsx)(we,{children:(0,Ut.jsx)(ji,x(v({backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},o),{size:"SM",icon:e==="PLUS"?"Plus":"Minus",variant:a.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:a.groupElements,disabled:u||t||s,onPress:i,onLongPress:l,delayLongPress:500}))})}var ji=(0,Jo.default)(Qo.Button)`
|
|
25
25
|
border-radius: ${({$grouped:e,theme:t})=>e?t.borderRadius.none:t.borderRadius.default};
|
|
26
|
-
`;var
|
|
27
|
-
`).length>
|
|
26
|
+
`;var nt=require("react"),jo=require("react-native"),er=require("styled-components/native"),tr=require("@mobilestock-native/clickable"),Xt=require("@mobilestock-native/container"),Wt=require("@mobilestock-native/typography");var he=require("react/jsx-runtime");function He(){let e=(0,er.useTheme)(),{count:t,editable:o,configureCount:r,autoFocus:n,onFocus:s,onBlur:a}=ie(),[u,i]=(0,nt.useState)(n&&o),[l,m]=(0,nt.useState)(t.toString());(0,nt.useEffect)(()=>{m(t.toString())},[t]);function d(c){r(Number(c.nativeEvent.text)||0),i(!1),a==null||a()}return o?(0,he.jsx)(tr.Clickable,{onPress:()=>i(!0),children:(0,he.jsx)(Xt.Container.Horizontal,{padding:"NONE_2XS",children:(0,he.jsx)(we,{children:u?(0,he.jsx)(jo.TextInput,{testID:"counter-input",value:l,keyboardType:"numeric",style:{fontWeight:"bold",fontSize:Number(e.font.size.lg)||16,textAlign:"center",width:40,height:40},autoFocus:!0,selectTextOnFocus:!0,onFocus:()=>s==null?void 0:s(),onBlur:d,onChangeText:m,onEndEditing:d}):(0,he.jsx)(Wt.Typography,{weight:"BOLD",size:"LG",children:t})})})}):(0,he.jsx)(Xt.Container.Horizontal,{padding:"NONE_2XS",children:(0,he.jsx)(we,{children:(0,he.jsx)(Wt.Typography,{weight:"BOLD",size:"LG",children:t})})})}He.displayName="Form.FormCounter.Display";var V=require("react/jsx-runtime");function or(){let{label:e,labelPosition:t,error:o}=ie();return(0,V.jsxs)(Ee.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,V.jsxs)(Ee.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,V.jsx)(ve,{children:e}),o&&(0,V.jsx)(de,{children:o})]}),t!=="LEFT"&&(0,V.jsxs)(Ee.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,V.jsxs)(Ee.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,V.jsx)(ve,{children:e}),o&&(0,V.jsx)(de,{children:o})]}),(0,V.jsxs)(Le,{children:[(0,V.jsx)(ge,{type:"MINUS"}),(0,V.jsx)(He,{}),(0,V.jsx)(ge,{type:"PLUS"})]})]}),t==="LEFT"&&(0,V.jsx)(Ee.Container.Vertical,{children:(0,V.jsxs)(Ee.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,V.jsxs)(Ee.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,V.jsx)(ve,{children:e}),o&&(0,V.jsx)(de,{children:o})]}),(0,V.jsxs)(Le,{children:[(0,V.jsx)(ge,{type:"MINUS"}),(0,V.jsx)(He,{}),(0,V.jsx)(ge,{type:"PLUS"})]})]})})]})}var gt=require("react/jsx-runtime");function rr(o){var r=o,{children:e}=r,t=O(r,["children"]);return(0,gt.jsx)(Oo,x(v({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,gt.jsx)(qo,{children:e}):(0,gt.jsx)(or,{})}))}var nr=require("react/jsx-runtime");function Kt(e){return(0,nr.jsx)(ge,x(v({},e),{type:"MINUS"}))}Kt.displayName="Form.FormCounter.Minus";var ir=require("react/jsx-runtime");function qt(e){return(0,ir.jsx)(ge,x(v({},e),{type:"PLUS"}))}qt.displayName="Form.FormCounter.Plus";var ar=Object.assign(rr,{Display:He,Plus:qt,Minus:Kt,Badge:ot});var lr=require("@mobilestock-native/container");var ur=require("react/jsx-runtime");function sr(o){var r=o,{children:e}=r,t=O(r,["children"]);return(0,ur.jsx)(lr.Container.Horizontal,x(v({gap:"SM"},t),{children:e}))}var mr=require("@unform/core"),A=require("react"),De=require("react-native"),Fe=N(require("styled-components/native")),cr=require("@mobilestock-native/button"),Zt=require("@mobilestock-native/container"),Yt=N(require("@mobilestock-native/tools")),ht=require("@mobilestock-native/typography");var ue=require("react/jsx-runtime"),pr=(0,A.forwardRef)(function(R,S){var P=R,{name:t,type:o="text",full:r,label:n,maxLength:s,autoSubmit:a=!1,defaultValue:u,numberOfLines:i=1,showMaxContent:l=!1,autoCapitalize:m,format:d,onChange:c}=P,h=O(P,["name","type","full","label","maxLength","autoSubmit","defaultValue","numberOfLines","showMaxContent","autoCapitalize","format","onChange"]);let b=(0,Fe.useTheme)(),{loading:C,submitForm:y,notifyFieldChange:T}=M(),f=(0,mr.useField)(t),E=(0,A.useRef)(null),p=(0,A.useRef)(null),[F,oe]=(0,A.useState)(!0),[W,Z]=(0,A.useState)(""),[Te,X]=(0,A.useState)(0),I=(0,A.useRef)(""),D=t+"-input"+(0,A.useId)(),H=o==="password",K=i>1,re=De.Platform.OS==="web"&&K,po=o==="tel"?15:o==="zipcode"?9:s,fo=Number(b.font.size.sm),Ni=Math.ceil(fo*(Number(b.font.lineHeight)||1.5)),Ye=10,Ze=Ni*i+Ye,Oi={width:"100%",border:"none",outline:"none",backgroundColor:"transparent",fontFamily:b.font.families[0].name,lineHeight:Number(b.font.lineHeight)||1.5,fontSize:fo,color:String(b.colors.text.default),padding:"10px 0",display:"block",resize:"none",overflow:"hidden",boxSizing:"border-box"},Ai=(0,A.useMemo)(()=>v({flex:1,outline:"none",color:b.colors.text.default,height:K?l?Ze:Math.min(Math.max(Te?Te+Ye:45,45),Ze):45},K&&{paddingTop:Ye/2,paddingBottom:Ye/2}),[K,l,Ze,Te,Ye,b]),Vi=(0,A.useMemo)(()=>{switch(o){case"tel":return"phone-pad";case"email":return"email-address";case"url":return"url";case"number":return"numeric";default:return"default"}},[o]),mt=(0,A.useCallback)(()=>{if(!re||!p.current)return;let w=p.current,g=window.getComputedStyle(w),k=parseInt(g.lineHeight,10);isNaN(k)&&(k=parseInt(g.fontSize,10)*(Number(b.font.lineHeight)||1.5));let Re=parseInt(g.paddingTop,10),be=parseInt(g.paddingBottom,10),pt=k*i+Re+be+1,Qe=parseFloat(getComputedStyle(document.documentElement).fontSize)*2.5;if(l)w.style.height=pt+"px";else{w.style.height="0";let dt=w.scrollHeight;w.style.height=Math.max(Qe,Math.min(dt,pt))+"px"}},[re,i,l,b.font.lineHeight]),Li=(0,A.useCallback)(w=>{let g=w.nativeEvent.contentSize.height;if(K&&i&&g>Ze){Z(I.current),E.current.value=I.current;return}X(g)},[K,i,Ze]),ct=(0,A.useCallback)(w=>{let g=w;switch(o){case"tel":g=Yt.default.phoneNumberFormatter(w);break;case"email":case"url":g=w.trim();break;case"number":g=w.replace(/[^0-9.,]/g,"");break;case"zipcode":g=Yt.default.formatZipcode(g);break}return d&&(g=d(g)),g},[o,d]),Hi=(0,A.useCallback)(w=>{var k,Re;let g=ct(w.target.value);if(i&&p.current){let be=p.current;be.value=g,be.style.height="auto";let pt=be.scrollHeight,Je=window.getComputedStyle(be),Qe=parseInt(Je.lineHeight,10);isNaN(Qe)&&(Qe=parseInt(Je.fontSize,10)*(Number(b.font.lineHeight)||1.5));let dt=parseInt(Je.paddingTop,10),zi=parseInt(Je.paddingBottom,10),ki=Qe*(i+1)+dt+zi+1;if(pt>ki){be.value=W,mt();return}}Z(g),w.target.value=g,p.current&&(p.current.value=g),c==null||c({value:g,event:"INPUT_CHANGE"}),T==null||T(t,g),o==="tel"&&a&&g.length===15&&(c==null||c({value:g,event:"AUTO_SUBMIT"}),(k=p.current)==null||k.blur(),y()),o==="zipcode"&&a&&g.length===9&&(c==null||c({value:g,event:"AUTO_SUBMIT"}),(Re=p.current)==null||Re.blur(),y())},[ct,i,W,mt,c,T,t,a,o,y,b.font.lineHeight]),Di=(0,A.useCallback)(w=>{var k,Re;let g=ct(w);K&&i&&g.split(`
|
|
27
|
+
`).length>i||(Z(g),E.current.value=g,I.current=g,c==null||c({value:g,event:"INPUT_CHANGE"}),T==null||T(t,g),o==="tel"&&a&&g.length===15&&(c==null||c({value:g,event:"AUTO_SUBMIT"}),(k=E.current)==null||k.blur(),y()),o==="zipcode"&&a&&g.length===9&&(c==null||c({value:g,event:"AUTO_SUBMIT"}),(Re=E.current)==null||Re.blur(),y()))},[ct,a,c,T,K,i,W,t,o,y]);(0,A.useEffect)(()=>{mt()},[W,mt]),(0,A.useEffect)(()=>{let w=W||u||(f==null?void 0:f.defaultValue)||"";re?p.current&&(p.current.value=w):E.current.value=w,Z(w),re?f.registerField({name:f.fieldName,ref:p,getValue:g=>{var k;return((k=g.current)==null?void 0:k.value)||""},setValue:(g,k)=>{g.current&&(g.current.value=k,Z(k))},clearValue:g=>{g.current&&(g.current.value="",Z(""))}}):f.registerField({name:f.fieldName,ref:E.current,getValue(g){return(g==null?void 0:g.value)||""},setValue(g,k){g.value=k,Z(k)},clearValue(g){g.value="",Z("")}})},[f==null?void 0:f.fieldName,f==null?void 0:f.registerField]),(0,A.useImperativeHandle)(S,()=>({focus(){var w,g;re?(w=p.current)==null||w.focus():(g=E.current)==null||g.focus()},blur(){var w,g;re?(w=p.current)==null||w.blur():(g=E.current)==null||g.blur()}}));function Mi(){oe(w=>(c==null||c({value:!w,event:"TOGGLE_PASSWORD"}),!w))}return(0,ue.jsxs)(ea,{full:r,$show:o!=="hidden",children:[n&&De.Platform.OS==="android"&&(0,ue.jsx)(ht.Typography,{children:n}),n&&De.Platform.OS==="web"&&(0,ue.jsx)("label",{htmlFor:D,children:(0,ue.jsx)(ht.Typography,{children:n})}),(0,ue.jsxs)(ta,{$error:!!(f!=null&&f.error),$isPassword:H,children:[re?(0,ue.jsx)("textarea",{ref:p,id:D,value:W,onChange:Hi,maxLength:po,disabled:C||h.editable===!1,placeholder:h.placeholder,autoFocus:h.autoFocus,style:Oi}):(0,ue.jsx)(De.TextInput,x(v({},h),{ref:E,id:D,value:W,autoCapitalize:o&&["email","url"].includes(o)?"none":m,keyboardType:Vi,secureTextEntry:F&&H,onChangeText:Di,maxLength:po,editable:!C&&h.editable,multiline:K,numberOfLines:i,textAlignVertical:K?"top":"center",onContentSizeChange:K?Li:void 0,scrollEnabled:!1,style:Ai})),H&&(0,ue.jsx)(cr.Button,{size:"SM",onPress:Mi,icon:F?"EyeOff":"EyeOutline",variant:"TRANSPARENT"})]}),!!(f!=null&&f.error)&&(0,ue.jsx)(ht.Typography,{color:"DANGER",size:"SM",children:f.error})]})}),ea=(0,Fe.default)(Zt.Container.Vertical)`
|
|
28
28
|
${({$show:e})=>!e&&Fe.css`
|
|
29
29
|
display: none;
|
|
30
30
|
`}
|
|
31
|
-
`,
|
|
31
|
+
`,ta=(0,Fe.default)(Zt.Container.Horizontal)`
|
|
32
32
|
overflow: hidden;
|
|
33
33
|
background-color: ${({$error:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
|
|
34
34
|
border: 1px solid ${({$error:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
|
|
35
35
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
36
36
|
padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
|
|
37
|
-
`;var
|
|
38
|
-
`," ","\r"];return typeof e=="string"?e.split(new RegExp(t.map(o=>`\\${o}`).join("|"))).map(o=>o.trim().replace(".","")).filter(o=>o.length>0):e}};var
|
|
37
|
+
`;var Xr=require("@unform/core"),Wr=require("react"),Kr=require("react-native"),qr=N(require("styled-components/native")),Rt=require("@mobilestock-native/container");var fr=require("@unform/core"),gr=N(require("expo-document-picker")),hr=require("expo-media-library"),J=require("react"),Tr=require("react-native");var oa=1.775,ra=.125,na=.54,ia=16,dr=300,z={getHashFile(e){return`${e.name}-${e.size}`},resolveColor(e,t,o){var r;return e&&(r=t.colors.switch[e.toLowerCase()])!=null?r:t.colors.switch[o]},toNum(e){return Math.round(e*1e4)/1e4},buildDimensions(e){let t=parseFloat(e),o=this.toNum(t*ia),r=this.toNum(o*ra),n=this.toNum(o-2*r),s=this.toNum(o*oa),a=this.toNum(s-n-2*r),u=this.toNum(n*na);return{width:s,height:o,handle:n,translate:a,offset:r,iconSize:u}},resolveSliderColor(e,t,o,r,n){return n?r?n.colors.alert.error_notice:e?this.resolveColor(t,n,"on"):this.resolveColor(o,n,"off"):n.colors.container.default}};var Jt=(s=>(s.json="application/json",s.png="image/png",s.jpg="image/jpg",s.jpeg="image/jpeg",s.all="*/*",s))(Jt||{});var vr=require("react/jsx-runtime"),br=(0,J.createContext)(null);function Cr({children:e,accept:t,onChange:o,name:r}){let{notifyFieldChange:n}=M(),{fieldName:s,registerField:a,defaultValue:u}=(0,fr.useField)(r),[i,l]=(0,hr.usePermissions)({granularPermissions:["photo"]}),[m,d]=(0,J.useState)(null),c=(0,J.useCallback)(P=>{let b=P.map(p=>({file:p,hash:z.getHashFile(p)})),C=(m||[]).map(p=>({file:p,hash:z.getHashFile(p)})),y=[...b,...C],T=Array.from(new Set(y.map(p=>p.hash))).map(p=>y.find(F=>F.hash===p)),f=T.filter(p=>b.some(F=>F.hash===p.hash));if(!f.length)return;let E=T.map(p=>p.file);d(E),n==null||n(s,E),o==null||o({value:f.map(p=>p.file),event:"ADD_FILES"})},[m,o,n,s]),h=(0,J.useCallback)(P=>{if(!P){d(null);return}let b=P.filter(C=>!!C);c(b)},[c,d]);(0,J.useEffect)(()=>{a({name:s,getValue:()=>m,setValue:(P,b)=>h(b||u),clearValue:()=>d(null)})},[s,a,m,h,u]),(0,J.useEffect)(()=>{i!=null&&i.granted||l()},[i,l]),(0,J.useEffect)(()=>{d(null)},[t]);function S(P){if(!m)return;let b=m.filter(C=>z.getHashFile(C)!==P);d(b),n==null||n(s,b),o==null||o({value:m.find(C=>z.getHashFile(C)===P),event:"REMOVE_FILE"})}function R(){return Ce(this,null,function*(){let P=yield gr.getDocumentAsync({multiple:!0,type:t==null?void 0:t.map(C=>Jt[C])});if(!P.assets)return;if(Tr.Platform.OS==="android"){c(P.assets.map(C=>({uri:C.uri,name:C.name,type:C.mimeType})));return}let b=P.assets.map(C=>C.file).filter(C=>!!C);b.length&&c(b)})}return(0,vr.jsx)(br.Provider,{value:{handleSelectFile:R,handleSaveFiles:c,handleRemoveFile:S,accept:t,files:m,name:r},children:e})}function le(){let e=(0,J.useContext)(br);if(e===null)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var Tt={convertBytesToReadableFormat(e){return e>=1073741824?(e/1073741824).toFixed(2)+" GB":e>=1048576?(e/1048576).toFixed(2)+" MB":e>=1024?(e/1024).toFixed(2)+" KB":e+" B"},parseAcceptString(e){if(!e)return["all"];let t=["|",",",";"," ",`
|
|
38
|
+
`," ","\r"];return typeof e=="string"?e.split(new RegExp(t.map(o=>`\\${o}`).join("|"))).map(o=>o.trim().replace(".","")).filter(o=>o.length>0):e}};var Fr=require("react-native"),Ir=require("@mobilestock-native/container"),Nr=require("@mobilestock-native/spacer");var Er=require("@unform/core"),Sr=require("@mobilestock-native/typography");var yr=require("react/jsx-runtime");function bt(){let e=le(),{error:t}=(0,Er.useField)(e.name);return(0,yr.jsx)(Sr.Typography,{color:"DANGER",size:"XS",children:t})}var Pr=require("@mobilestock-native/button");var Rr=require("react/jsx-runtime");function Ct(){let e=le();return(0,Rr.jsx)(Pr.Button,{text:"Selecionar arquivo",size:"XS",onPress:e.handleSelectFile})}var vt=require("@mobilestock-native/typography");var Se=require("react/jsx-runtime");function Et(){var t,o;let e=le();return(t=e.accept)!=null&&t.includes("all")?(0,Se.jsx)(vt.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(vt.Typography,{size:"XS",children:"Arquivos suportados"}),(0,Se.jsxs)(vt.Typography,{size:"XS",children:["( ",(o=e.accept)==null?void 0:o.join(", ")," )"]})]})}var xr=require("@mobilestock-native/typography"),wr=require("react/jsx-runtime");function St({children:e}){return(0,wr.jsx)(xr.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var ye=require("react/jsx-runtime");function Or(){var t;let e=le();return(0,ye.jsxs)(Ir.Container.Vertical,{align:"CENTER",children:[Fr.Platform.OS==="web"?(0,ye.jsx)(St,{}):null,(0,ye.jsx)(Nr.Spacer,{size:"2XS"}),(0,ye.jsx)(Ct,{}),(0,ye.jsx)(bt,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,ye.jsx)(Et,{})]})}var Ar=N(require("chroma-js")),Vr=require("react"),Lr=require("react-native"),Hr=require("styled-components/native");var Mr=require("react/jsx-runtime");function Dr(e){let t=le(),o=(0,Hr.useTheme)(),[r,n]=(0,Vr.useState)(!1);function s(a){var l;a.preventDefault(),n(!1);let u=a.dataTransfer;if(!u)return;let i=[];if(u.items&&u.items.length>0)for(let m=0;m<u.items.length;m++){let d=u.items[m];if(d.kind!=="file")continue;let c=d.webkitGetAsEntry();if(c&&c.isDirectory)continue;let h=d.getAsFile();h&&i.push(h)}else if(u.files&&u.files.length>0)for(let m=0;m<u.files.length;m++){let d=u.files.item(m);d&&i.push(d)}i.length!==0&&((l=t.accept)!=null&&l.some(m=>m!=="all")&&(i=i.filter(m=>{var c;let d=m.name.split(".").pop();return(c=t.accept)==null?void 0:c.includes(d==null?void 0:d.toLowerCase())}),!i.length)||t.handleSaveFiles(i))}return Lr.Platform.OS!=="web"?e.children:(0,Mr.jsx)("div",v({onDragOver:a=>{a.preventDefault(),n(!0)},onDrop:s,onDragLeave:a=>{a.preventDefault(),n(!1)},style:v({},r?{backgroundColor:(0,Ar.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var Pt=require("react"),Q=N(require("react-native-reanimated")),zr=require("@mobilestock-native/button"),kr=require("@mobilestock-native/clickable"),it=require("@mobilestock-native/container"),_r=require("@mobilestock-native/icons"),yt=require("@mobilestock-native/typography");var B=require("react/jsx-runtime");function aa(e){"worklet";switch(e){case 0:return 0;case 1:return 20;case 2:return 50;case 3:return 75;default:return 100}}function Br(){var a,u,i;let e=le(),t=(0,Q.useSharedValue)(!1),o=(0,Q.useSharedValue)(0),r=(0,Pt.useRef)(null);(0,Pt.useEffect)(()=>{var l;o.value=((l=e.files)==null?void 0:l.length)||0},[e.files,o]);let n=(0,Q.useAnimatedStyle)(()=>({transform:[{rotate:(0,Q.withSpring)(t.value?"180deg":"0deg")}]})),s=(0,Q.useAnimatedStyle)(()=>{let l=aa(o.value);return{height:(0,Q.withSpring)(t.value?l:0),opacity:(0,Q.withSpring)(t.value?1:0)}},[r.current,o]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(it.Container.Horizontal,{align:"END",children:!!((a=e.files)!=null&&a.length)&&(0,B.jsx)(kr.Clickable,{onPress:()=>t.value=!t.value,children:(0,B.jsxs)(it.Container.Horizontal,{align:"CENTER",children:[(0,B.jsxs)(yt.Typography,{size:"XS",children:[(u=e.files)==null?void 0:u.length," arquivos"]}),(0,B.jsx)(Q.default.View,{style:n,children:(0,B.jsx)(_r.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,B.jsx)(Q.default.ScrollView,{style:s,children:(i=e.files)==null?void 0:i.map((l,m)=>(0,B.jsxs)(it.Container.Horizontal,{align:"START_CENTER",children:[(0,B.jsxs)(it.Container.Horizontal,{gap:"SM",full:!0,children:[(0,B.jsx)(yt.Typography,{size:"XS",weight:"MEDIUM",children:l.name.slice(0,20)}),l.size&&(0,B.jsx)(yt.Typography,{size:"XS",children:Tt.convertBytesToReadableFormat(l.size)})]}),(0,B.jsx)(zr.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS",testID:"remove-file-button",onPress:()=>e.handleRemoveFile(z.getHashFile(l))})]},m))})]})}var $r=require("@mobilestock-native/typography"),Ur=require("react/jsx-runtime");function Gr({children:e}){return(0,Ur.jsx)($r.Typography,{children:e})}var pe=require("react/jsx-runtime");function Yr(o){var r=o,{accept:e}=r,t=O(r,["accept"]);let{error:n}=(0,Xr.useField)(t.name),s=(0,Wr.useMemo)(()=>Tt.parseAcceptString(e),[e]);return(0,pe.jsx)(Cr,x(v({},t),{accept:s,children:(0,pe.jsxs)(Rt.Container.Vertical,{gap:"2XS",children:[(0,pe.jsx)(Rt.Container.Horizontal,{align:t.alignLabel||"START",children:(0,pe.jsx)(Gr,{children:t.label})}),(0,pe.jsxs)(la,{$error:!!n,$minWidth:Kr.Platform.OS==="web"?"400px":"100%",padding:"MD",children:[(0,pe.jsx)(Dr,{children:t.children||(0,pe.jsx)(Or,{})}),(0,pe.jsx)(Br,{})]})]})}))}var la=(0,qr.default)(Rt.Container.Vertical)`
|
|
39
39
|
border: 1px solid ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.border};
|
|
40
40
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
41
41
|
background-color: ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.default};
|
|
42
42
|
min-width: ${({$minWidth:e})=>e};
|
|
43
|
-
`;var
|
|
43
|
+
`;var Zr=Object.assign(Yr,{Title:St,HelpButton:Ct,HelpText:Et,ErrorLabel:bt});var Ot=require("react"),_e=require("react-native"),Ln=N(require("react-native-draggable-flatlist")),Hn=require("styled-components/native"),Nt=require("@mobilestock-native/container");var Jr=require("@unform/core"),Qr=require("expo-image-picker"),jr=require("expo-media-library"),$=require("react"),Qt=require("react-native"),en=require("styled-components/native");var rn=require("react/jsx-runtime"),tn=(0,$.createContext)(null);function on({gap:e="2XS",size:t="SM",name:o,children:r,onChange:n,multiple:s,dragAndDrop:a,buttonAddDirection:u}){let i=(0,en.useTheme)(),{notifyFieldChange:l}=M(),{fieldName:m,registerField:d,defaultValue:c}=(0,Jr.useField)(o),[h,S]=(0,jr.usePermissions)({granularPermissions:["photo"]}),[R,P]=(0,$.useState)(null),[b,C]=(0,$.useState)(!1),[y,T]=(0,$.useState)(null),f=(0,$.useMemo)(()=>parseInt(i.sizeImage[t.toLowerCase()]),[i,t]),E=(0,$.useMemo)(()=>parseInt(i.gaps[e.toLowerCase()]),[i,e]),p=(0,$.useCallback)(I=>{P(u==="RIGHT"?D=>{let H=[...D||[],...I].reverse();return l==null||l(m,H),H}:D=>{let H=[...D||[],...I];return l==null||l(m,H),H})},[P,u,l,m]),F=(0,$.useCallback)(I=>{if(!I){P(null);return}p(I)},[p]);(0,$.useEffect)(()=>{d({name:m,getValue:()=>R,setValue:(I,D)=>F(D||c),clearValue:()=>P(null)})},[m,d,R,F,c]),(0,$.useEffect)(()=>{h!=null&&h.granted||S()},[h,S]);function oe(){return Ce(this,null,function*(){var D;let I=yield(0,Qr.launchImageLibraryAsync)({mediaTypes:["images"],allowsEditing:s?void 0:!0,quality:1,allowsMultipleSelection:s});if(Qt.Platform.OS==="web"&&I.assets&&!s){C(!0),T(I.assets[0].file);return}p(((D=I.assets)==null?void 0:D.map(H=>Qt.Platform.OS==="web"?H.file:{uri:H.uri,name:H.fileName,type:H.mimeType}))||[])})}function W(I){if(!R)return;let D=R.filter(H=>z.getHashFile(H)!==I);P(D),l==null||l(m,D),n==null||n({value:R.find(H=>z.getHashFile(H)===I),event:"REMOVE_IMAGE"})}function Z(I){P(I),l==null||l(m,I),n==null||n({value:I,event:"REORDER_IMAGES"})}function Te(I){p([I]),C(!1),T(null),n==null||n({value:I,event:"CROP_SAVE"})}function X(){C(!1),T(null)}return(0,rn.jsx)(tn.Provider,{value:{showDeviceImage:oe,images:R,removeImage:W,reorderImages:Z,openImageCropModal:b,imageToCrop:y,handleImageCropCancel:X,handleImageCropSave:Te,sizeComponent:f,gapComponent:E,dragAndDrop:a,name:o,gap:e},children:r})}function q(){let e=(0,$.useContext)(tn);if(!e)throw new Error("usePhotoList must be used within a PhotoListProvider");return e}var nn=require("@mobilestock-native/button");var an=require("react/jsx-runtime");function jt(){let e=q();return(0,an.jsx)(nn.Button,{icon:"Plus",variant:"OUTLINE",onPress:e.showDeviceImage,style:{height:e.sizeComponent,width:e.sizeComponent}})}var ln=require("@unform/core"),sn=require("@mobilestock-native/typography");var mn=require("react/jsx-runtime");function un(){let e=q(),{error:t}=(0,ln.useField)(e.name);return(0,mn.jsx)(sn.Typography,{color:"DANGER",size:"XS",children:t})}var wt=require("react"),Sn=require("react-native"),Ft=N(require("styled-components/native")),yn=require("@mobilestock-native/container"),Pn=require("@mobilestock-native/image");var gn=N(require("styled-components/native")),hn=require("@mobilestock-native/clickable");var cn=require("styled-components/native"),pn=require("@mobilestock-native/container");var fn=require("react/jsx-runtime");function dn({isActive:e}){let t=(0,cn.useTheme)(),o=q();return(0,fn.jsx)(pn.Container.Horizontal,{style:[{height:2,width:o.sizeComponent*.7,backgroundColor:t.colors.formPhotoList.defaultBar},e&&{backgroundColor:t.colors.formPhotoList.highlightBar}]})}var eo=require("react/jsx-runtime");function Tn({drag:e,isActive:t}){return(0,eo.jsx)(sa,{onLongPress:e,onTouchMove:e,onTouchStart:e,onPressIn:e,children:(0,eo.jsx)(dn,{isActive:t})})}var sa=(0,gn.default)(hn.Clickable)`
|
|
44
44
|
flex-direction: row;
|
|
45
45
|
justify-content: space-between;
|
|
46
46
|
align-items: center;
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
position: absolute;
|
|
49
49
|
bottom: 0;
|
|
50
50
|
background-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
|
|
51
|
-
`;var
|
|
51
|
+
`;var xt=N(require("styled-components/native")),bn=require("@mobilestock-native/clickable"),Cn=require("@mobilestock-native/icons"),vn=N(require("@mobilestock-native/tools"));var to=require("react/jsx-runtime");function En({photo:e}){let t=q(),o=(0,xt.useTheme)();function r(){t.removeImage(z.getHashFile(e))}return(0,to.jsx)(ua,{onPress:r,children:(0,to.jsx)(Cn.Icon,{name:"X",size:"XS",color:vn.default.defineTextColor(o.colors.formPhotoList.trashButton)})})}var ua=(0,xt.default)(bn.Clickable)`
|
|
52
52
|
position: absolute;
|
|
53
53
|
top: 0;
|
|
54
54
|
right: 0;
|
|
55
55
|
z-index: 1;
|
|
56
56
|
border-bottom-left-radius: 4px;
|
|
57
57
|
background-color: ${({theme:e})=>e.colors.formPhotoList.trashButton};
|
|
58
|
-
`;var
|
|
58
|
+
`;var Me=require("react/jsx-runtime");function ma({item:e,drag:t,isActive:o}){let r=q(),n=(0,wt.useMemo)(()=>Sn.Platform.OS==="web"?URL.createObjectURL(e):e.uri,[e]);return(0,Me.jsxs)(ca,{align:"CENTER",sizeComponent:r.sizeComponent,isActive:o,children:[(0,Me.jsx)(En,{photo:e}),(0,Me.jsx)(Pn.Img,{src:{uri:n},alt:"image",size:"SM"}),r.dragAndDrop&&(0,Me.jsx)(Tn,{drag:t,isActive:o})]})}var Rn=(0,wt.memo)(ma),ca=(0,Ft.default)(yn.Container.Vertical)`
|
|
59
59
|
background-color: ${({theme:e})=>e.colors.formPhotoList.defaultBar};
|
|
60
60
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
61
61
|
overflow: hidden;
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
position: relative;
|
|
66
66
|
border-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
|
|
67
67
|
|
|
68
|
-
${({theme:e,isActive:t})=>t&&
|
|
68
|
+
${({theme:e,isActive:t})=>t&&Ft.css`
|
|
69
69
|
border-color: ${e.colors.formPhotoList.highlightBar};
|
|
70
70
|
`}
|
|
71
|
-
`;var
|
|
71
|
+
`;var xn=require("@mobilestock-native/typography"),Fn=require("react/jsx-runtime");function wn({children:e}){return(0,Fn.jsx)(xn.Typography,{children:e})}var me=require("react"),An=require("react-image-crop"),Nu=require("react-image-crop/dist/ReactCrop.css"),ke=N(require("styled-components/native")),ro=require("@mobilestock-native/button"),Ne=require("@mobilestock-native/container");var Ie=require("react"),oo=require("react-native"),In=N(require("styled-components/native")),Nn=require("ua-parser-js"),It=require("@mobilestock-native/container");var ze=require("react/jsx-runtime");function On(o){var r=o,{children:e}=r,t=O(r,["children"]);let[n,s]=(0,Ie.useState)(!1),a=(0,Ie.useCallback)(()=>(0,Nn.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),u=(0,Ie.useCallback)(()=>{s(a())},[a]);return(0,Ie.useEffect)(()=>(window.addEventListener("resize",u),s(a()),()=>{window.removeEventListener("resize",u)}),[a,u]),n?(0,ze.jsx)(oo.Modal,x(v({transparent:!0,statusBarTranslucent:!0},t),{children:(0,ze.jsx)(It.Container.Main,{children:e})})):(0,ze.jsx)(oo.Modal,x(v({transparent:!0,statusBarTranslucent:!0,animationType:"slide"},t),{children:(0,ze.jsx)(It.Container.Vertical,{align:"CENTER",full:!0,children:(0,ze.jsx)(pa,{padding:"SM",children:e})})}))}var pa=(0,In.default)(It.Container.Vertical)`
|
|
72
72
|
background-color: ${({theme:e})=>e.colors.container.default};
|
|
73
73
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
74
74
|
border: 1px solid ${({theme:e})=>e.colors.input.border};
|
|
@@ -77,27 +77,47 @@
|
|
|
77
77
|
width: 100%;
|
|
78
78
|
height: 100%;
|
|
79
79
|
overflow: hidden;
|
|
80
|
-
`;var
|
|
80
|
+
`;var j=require("react/jsx-runtime");function Vn(){let e=q(),[t,o]=(0,me.useState)(),[r,n]=(0,me.useState)(),[s,a]=(0,me.useState)(),u=(0,me.useRef)(null),i=(0,me.useRef)(null),l=(0,me.useMemo)(()=>e.imageToCrop?URL.createObjectURL(e.imageToCrop):void 0,[e.imageToCrop]);(0,me.useEffect)(()=>{e.imageToCrop||(o(void 0),n(void 0),a(void 0))},[e.imageToCrop,e.openImageCropModal]);function m({displayWidth:h,displayHeight:S,naturalWidth:R,naturalHeight:P}){n({displayWidth:h,displayHeight:S,naturalWidth:R,naturalHeight:P});let b=Math.min(h,S);o({unit:"px",width:b,height:b,x:h>S?(h-b)/2:0,y:S>h?(S-b)/2:0})}function d(){return Ce(this,null,function*(){if(!e.imageToCrop||!t||!r)return;let h=r.naturalWidth/r.displayWidth,S=r.naturalHeight/r.displayHeight,R=t.x*h,P=t.y*S,b=t.width*h,C=t.height*S,y=new OffscreenCanvas(b,C),T=y.getContext("2d"),f=new Image;f.src=URL.createObjectURL(e.imageToCrop),yield new Promise(F=>{f.onload=()=>F()}),T.drawImage(f,R,P,b,C,0,0,b,C);let E=yield y.convertToBlob({type:"image/png",quality:1}),p="";if(!e.imageToCrop.name)p="image-cropped.png";else{let F=e.imageToCrop.name.split(".");F.pop(),p=F.join(".")+"-cropped.png"}e.handleImageCropSave(new File([E],p,{type:"image/png",lastModified:Date.now()}))})}function c(h){let S=h.currentTarget,R=i.current,P=R.clientWidth,b=R.clientHeight,C=S.naturalWidth,y=S.naturalHeight,T=Math.min(P/C,b/y),f=C*T,E=y*T;a({width:f,height:E}),m({displayWidth:f,displayHeight:E,naturalWidth:C,naturalHeight:y})}return(0,j.jsx)(On,{visible:e.openImageCropModal,children:(0,j.jsxs)(Ne.Container.Vertical,{full:!0,padding:"NONE_XS_XS_XS",gap:"MD",children:[(0,j.jsx)(da,{full:!0,align:"CENTER",children:(0,j.jsx)(fa,{ref:i,testID:"container-crop-vertical",align:"CENTER",children:(0,j.jsx)(ga,{crop:t,width:s==null?void 0:s.width,height:s==null?void 0:s.height,onChange:h=>o(h),children:(0,j.jsx)("img",{src:l,ref:u,testID:"image-to-crop",onLoad:c})})})}),(0,j.jsxs)(Ne.Container.Horizontal,{gap:"MD",children:[(0,j.jsx)(Ne.Container.Vertical,{full:!0,children:(0,j.jsx)(ro.Button,{onPress:e.handleImageCropCancel,text:"Cancelar",testID:"button-cancel",backgroundColor:"CANCEL_DARK"})}),(0,j.jsx)(Ne.Container.Vertical,{full:!0,children:(0,j.jsx)(ro.Button,{onPress:d,testID:"button-save",text:"Salvar"})})]})]})})}var da=(0,ke.default)(Ne.Container.Vertical)`
|
|
81
81
|
width: 100%;
|
|
82
|
-
`,
|
|
82
|
+
`,fa=(0,ke.default)(Ne.Container.Vertical)`
|
|
83
83
|
width: 100%;
|
|
84
84
|
height: 100%;
|
|
85
85
|
padding-left: 16px;
|
|
86
86
|
padding-right: 16px;
|
|
87
|
-
`,
|
|
88
|
-
${({width:e,height:t})=>e&&t&&
|
|
87
|
+
`,ga=(0,ke.default)(An.ReactCrop)`
|
|
88
|
+
${({width:e,height:t})=>e&&t&&ke.css`
|
|
89
89
|
width: ${e}px;
|
|
90
90
|
height: ${t}px;
|
|
91
91
|
display: inline-flex;
|
|
92
92
|
`}
|
|
93
|
-
`;var G=require("react/jsx-runtime");function
|
|
93
|
+
`;var G=require("react/jsx-runtime");function Dn({numberOfImagesVisible:e,buttonAddDirection:t,label:o,alignLabel:r}){let n=(0,_e.useWindowDimensions)(),s=q(),a=(0,Hn.useTheme)(),u=(0,Ot.useCallback)(l=>{s.reorderImages(l.data)},[s]),i=(0,Ot.useMemo)(()=>e?s.sizeComponent*e+s.gapComponent*(e-1):n.width-s.sizeComponent-s.gapComponent*4,[e,n.width,s.sizeComponent,s.gapComponent]);return(0,G.jsxs)(G.Fragment,{children:[!!o&&(0,G.jsx)(Nt.Container.Horizontal,{align:r||"START",testID:"label-container",children:(0,G.jsx)(wn,{children:o})}),(0,G.jsxs)(Nt.Container.Horizontal,{gap:s.gap,children:[t==="LEFT"&&(0,G.jsx)(jt,{}),s.images&&(0,G.jsx)(Nt.Container.Horizontal,{children:(0,G.jsx)(Ln.default,{data:s.images,keyExtractor:z.getHashFile,horizontal:!0,onDragEnd:u,activationDistance:10,style:{maxWidth:i,paddingBottom:parseInt(a.spacing["2xs"])},ItemSeparatorComponent:()=>(0,G.jsx)(_e.View,{style:{width:s.gapComponent}}),renderItem:l=>(0,G.jsx)(Rn,v({},l))})}),t==="RIGHT"&&(0,G.jsx)(jt,{})]}),(0,G.jsx)(un,{}),_e.Platform.OS==="web"&&(0,G.jsx)(Vn,{})]})}var no=require("react/jsx-runtime");function Mn(s){var a=s,{label:e,alignLabel:t,buttonAddDirection:o="LEFT",numberOfImagesVisible:r=0}=a,n=O(a,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,no.jsx)(on,x(v({multiple:!0,dragAndDrop:!0,buttonAddDirection:o},n),{children:(0,no.jsx)(Dn,{label:e,alignLabel:t,buttonAddDirection:o,numberOfImagesVisible:r})}))}var ii=require("@unform/core"),ai=require("react-native"),li=require("@mobilestock-native/container"),so=require("@mobilestock-native/typography");var Yn=require("@unform/core"),Ge=require("react"),lt=N(require("styled-components/native")),Zn=require("@mobilestock-native/clickable"),at=require("@mobilestock-native/container"),Jn=require("@mobilestock-native/icons"),Qn=require("@mobilestock-native/typography");var Wn=require("react"),$e=require("react-native"),Dt=require("react-native-gesture-handler"),_=N(require("react-native-reanimated")),Kn=require("styled-components/native"),Lt=require("@mobilestock-native/container"),Ht=require("@mobilestock-native/list");var Un=require("react-native-gesture-handler"),Be=require("@mobilestock-native/container");var zn=require("styled-components/native"),kn=require("@mobilestock-native/container");var Bn=require("react/jsx-runtime");function _n(e){let t=(0,zn.useTheme)();return(0,Bn.jsx)(kn.Container.Horizontal,v({style:{width:100,height:4,borderRadius:5,backgroundColor:t.colors.container.shadow}},e))}var $n=require("@mobilestock-native/typography");var Gn=require("react/jsx-runtime");function io(e){return(0,Gn.jsx)($n.Typography,v({size:"MD",align:"RIGHT",color:"DEFAULT_100"},e))}var ce=require("react/jsx-runtime");function Xn({placeholder:e,panGesture:t}){return t?(0,ce.jsx)(Un.GestureDetector,{gesture:t,children:(0,ce.jsxs)(Be.Container.Vertical,{padding:"XS",testID:"form-sheet-header-with-gesture",children:[(0,ce.jsx)(Be.Container.Horizontal,{align:"CENTER",children:(0,ce.jsx)(_n,{})}),(0,ce.jsx)(Be.Container.Horizontal,{children:(0,ce.jsx)(io,{children:e})})]})}):(0,ce.jsx)(Be.Container.Vertical,{padding:"XS",testID:"form-sheet-header-without-gesture",children:(0,ce.jsx)(Be.Container.Horizontal,{children:(0,ce.jsx)(io,{children:e})})})}var ee=require("react/jsx-runtime"),{height:ha}=$e.Dimensions.get("window"),ao=ha*.8,At=200,Vt=45;function qn(e){let t=(0,Kn.useTheme)(),o=(0,Wn.useMemo)(()=>Math.min(ao,e.options.length*Vt+Vt),[e.options]),r=Math.min(At,o),n=(0,_.useSharedValue)(r),s=(0,_.useSharedValue)(r),a=Dt.Gesture.Pan().onStart(()=>{s.value=n.value}).onUpdate(m=>{let d=s.value-m.translationY;n.value=Math.max(At,Math.min(d,o))}).onEnd(m=>{m.velocityY<-1e3?n.value=(0,_.withTiming)(o):n.value>ao/2?n.value=(0,_.withTiming)(ao):n.value=(0,_.withTiming)(At)}),u=(0,_.useAnimatedStyle)(()=>({height:n.value,bottom:0}));(0,_.useAnimatedReaction)(()=>e.visible,m=>{m&&(n.value=(0,_.withSpring)(r,{damping:20,stiffness:90,mass:.3}))},[e.visible]);function i(){"worklet";n.value=(0,_.withTiming)(0,{},()=>{(0,_.runOnJS)(e.onClose)()})}function l(m){var d;e.onSelect(m.value===((d=e.selectValue)==null?void 0:d.value)?null:m),i()}return(0,ee.jsx)($e.Modal,{visible:e.visible,transparent:!0,animationType:"none",testID:"modal",children:(0,ee.jsxs)(Dt.GestureHandlerRootView,{children:[(0,ee.jsx)($e.TouchableWithoutFeedback,{onPress:i,testID:"backdrop",children:(0,ee.jsx)(Lt.Container.Vertical,{full:!0})}),(0,ee.jsxs)(_.default.View,{style:[u,{position:"absolute",width:"100%",backgroundColor:t.colors.container.default,borderTopLeftRadius:20,borderTopRightRadius:20,borderWidth:1,borderColor:t.colors.container.shadow}],children:[(0,ee.jsx)(Xn,{placeholder:e.placeholder,panGesture:e.options.length*Vt+Vt>At?a:void 0}),(0,ee.jsx)(Lt.Container.Main,{children:(0,ee.jsx)(Ht.List,{data:e.options,itemKey:"value",ItemSeparatorComponent:()=>(0,ee.jsx)(Lt.Container.Horizontal,{testID:"separator",style:{backgroundColor:t.colors.container.shadow,height:1,width:"100%"}}),renderItem:m=>{var d;return(0,ee.jsx)(Ht.List.Item.Horizontal,{isSelected:((d=e.selectValue)==null?void 0:d.value)===m.value,padding:"SM",onPress:()=>l(m),children:(0,ee.jsx)(Ht.List.Item.Title,{children:m.label})})}})})]})]})})}var te=require("react/jsx-runtime");function jn({options:e,placeholder:t,disabled:o,defaultValue:r,name:n,onChange:s,autoFocus:a,onFocus:u,onBlur:i}){let l=(0,lt.useTheme)(),{loading:m,notifyFieldChange:d}=M(),{fieldName:c,registerField:h,error:S,defaultValue:R}=(0,Yn.useField)(n),[P,b]=(0,Ge.useState)(!1),[C,y]=(0,Ge.useState)(R||r||null);(0,Ge.useEffect)(()=>{a&&!o&&!m&&(b(!0),u==null||u())},[]),(0,Ge.useEffect)(()=>{h({name:c,getValue:()=>(C==null?void 0:C.value)||"",setValue:(p,F)=>{let oe=e.find(W=>W.value===F);oe&&y(oe)},clearValue:()=>{y(null)}})},[c,h,C,e]);function T(){b(!0),u==null||u()}function f(){b(!1),i==null||i()}function E(p){var F,oe;y(p),d==null||d(c,(F=p==null?void 0:p.value)!=null?F:""),s==null||s({value:(oe=p==null?void 0:p.value)!=null?oe:"",event:"SELECT_CHANGE"})}return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(Zn.Clickable,{disabled:o||m,onPress:T,testID:"select-android",children:(0,te.jsxs)(Ta,{padding:"NONE_XS_NONE_MD",error:!!S,testID:"select-android-container",align:"BETWEEN_CENTER",children:[(0,te.jsx)(at.Container.Horizontal,{children:(0,te.jsx)(Qn.Typography,{color:C?"DEFAULT":"DEFAULT_200",children:(C==null?void 0:C.label)||t})}),(0,te.jsxs)(at.Container.Horizontal,{style:{opacity:.3},gap:"XS",align:"CENTER",children:[(0,te.jsx)(ba,{error:!!S}),(0,te.jsx)(Jn.Icon,{name:"ChevronDown",size:"XS",color:S?l.colors.alert.urgent:l.colors.text.default})]})]})}),!o&&!m&&(0,te.jsx)(qn,{options:e,onClose:f,visible:P,placeholder:t,selectValue:C,onSelect:E})]})}var Ta=(0,lt.default)(at.Container.Horizontal)`
|
|
94
94
|
overflow: hidden;
|
|
95
95
|
height: 47px;
|
|
96
96
|
background-color: ${({error:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
|
|
97
97
|
border: 1px solid ${({error:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
|
|
98
98
|
border-radius: 5px;
|
|
99
|
-
`,
|
|
99
|
+
`,ba=(0,lt.default)(at.Container.Vertical)`
|
|
100
100
|
width: 1px;
|
|
101
101
|
height: 30px;
|
|
102
102
|
background-color: ${({theme:e,error:t})=>t?e.colors.alert.urgent:e.colors.text.default};
|
|
103
|
-
`;var
|
|
103
|
+
`;var ei=require("@unform/core"),Mt=N(require("chroma-js")),lo=require("lodash"),Oe=require("react"),ti=N(require("react-select")),oi=require("styled-components/native");var ni=require("react/jsx-runtime");function ri({options:e,placeholder:t,disabled:o,name:r,defaultValue:n,onChange:s,autoFocus:a,onFocus:u,onBlur:i}){let l=(0,oi.useTheme)(),{loading:m,notifyFieldChange:d}=M(),{fieldName:c,defaultValue:h,registerField:S,error:R}=(0,ei.useField)(r),P=(0,Oe.useRef)(null);(0,Oe.useEffect)(()=>{S({name:c,ref:P.current,getValue:y=>{var f,E,p;let T=((p=(E=(f=y==null?void 0:y.state)==null?void 0:f.selectValue)==null?void 0:E[0])==null?void 0:p.value)||"";return d==null||d(c,T),s==null||s({value:T,event:"SELECT_CHANGE"}),T}})},[c,S,d,s]);let b=(0,Oe.useCallback)(y=>function(T){return(0,lo.mergeWith)(T,{fontFamily:l.font.families[0].name,lineHeight:l.font.lineHeight,color:l.colors.text.default},y)},[]),C=(0,Oe.useCallback)((y,T)=>{let f="transparent",E=l.colors.text.default;switch(!0){case T.isFocused:{let p=(0,Mt.default)(l.colors.listItem.hover);p.luminance()>.5?f=p.brighten(1).hex("rgb"):f=p.hex("rgb");let F=(0,Mt.default)(f);E=F.luminance(F.luminance()>.5?-2:2).hex("rgb");break}case T.isSelected:{f=l.colors.listItem.selected;let p=(0,Mt.default)(f);E=p.luminance(p.luminance()>.5?-2:2).hex("rgb");break}}return(0,lo.mergeWith)(y,{fontFamily:l.font.families[0].name,lineHeight:l.font.lineHeight,color:E,backgroundColor:f})},[]);return(0,ni.jsx)(ti.default,{options:[{label:t,options:e}],placeholder:t,menuPortalTarget:typeof document!="undefined"?document.body:void 0,menuPosition:"fixed",styles:{container:b({width:"100%",display:"flex",height:"3rem"}),control:b({width:"100%",backgroundColor:R?l.colors.input.error:void 0,borderColor:R?l.colors.alert.urgent:void 0}),indicatorSeparator:b({backgroundColor:R?l.colors.alert.urgent:void 0}),dropdownIndicator:b({color:R?l.colors.alert.urgent:void 0}),option:C,menuPortal:b({zIndex:99999})},openMenuOnFocus:!0,defaultValue:n||h,ref:P,isDisabled:o||m,autoFocus:a,onFocus:u,onBlur:i})}var Ae=require("react/jsx-runtime");function si({name:e,label:t,disabled:o=!1,options:r,placeholder:n="Selecione um item",full:s=!1,defaultValue:a,onChange:u,autoFocus:i,onFocus:l,onBlur:m}){let{error:d}=(0,ii.useField)(e);return(0,Ae.jsxs)(li.Container.Vertical,{full:s,children:[t&&(0,Ae.jsx)(so.Typography,{testID:"label",children:t}),ai.Platform.OS==="web"?(0,Ae.jsx)(ri,{disabled:o,options:r,name:e,placeholder:n,onChange:u,autoFocus:i,onFocus:l,onBlur:m}):(0,Ae.jsx)(jn,{name:e,disabled:o,options:r,defaultValue:a,placeholder:n,onChange:u,autoFocus:i,onFocus:l,onBlur:m}),d&&(0,Ae.jsx)(so.Typography,{color:"DANGER",size:"SM",testID:"error",children:d})]})}var di=require("@mobilestock-native/typography");var ui=require("@unform/core"),Y=require("react");var pi=require("react/jsx-runtime"),mi=(0,Y.createContext)(void 0);function ci(e){let{notifyFieldChange:t,loading:o}=M(),{fieldName:r,registerField:n,error:s,defaultValue:a}=(0,ui.useField)(e.name),[u,i]=(0,Y.useState)(()=>{var E;return(E=e.defaultValue)!=null?E:!!a}),{onChange:l,defaultValue:m,label:d,labelPosition:c,checkedColor:h,backgroundColor:S,handleColor:R,size:P,icons:b}=e,C=e.disabled||o,y=(0,Y.useCallback)((E,p=!0)=>{i(E),t==null||t(r,E),p&&(l==null||l({value:E,event:"EDIT"}))},[t,r,l]);(0,Y.useEffect)(()=>{n({name:r,getValue:()=>u,setValue:(E,p)=>y(!!p),clearValue:()=>y(!1)})},[r,u,n,y]),(0,Y.useEffect)(()=>{let E=m!=null?m:!!a;y(E,!1)},[m,y,a]);let T=(0,Y.useCallback)(()=>{C||i(E=>{let p=!E;return t==null||t(r,p),l==null||l({value:p,event:"TOGGLE"}),p})},[C,r,t,l]),f=(0,Y.useMemo)(()=>({checked:u,toggle:T,configureChecked:y,error:s,label:d,labelPosition:c,disabled:C,checkedColor:h,backgroundColor:S,handleColor:R,size:P,icons:b}),[u,T,y,s,d,c,C,h,S,R,P,b]);return(0,pi.jsx)(mi.Provider,{value:f,children:e.children})}function Ue(){let e=(0,Y.useContext)(mi);if(!e)throw new Error("useSwitch must be used within a SwitchProvider");return e}var fi=require("react/jsx-runtime");function zt({children:e}){let{error:t}=Ue(),o=e!=null?e:t;return o?(0,fi.jsx)(di.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:o}):null}var gi=require("@mobilestock-native/typography");var hi=require("react/jsx-runtime");function Xe(o){var r=o,{children:e}=r,t=O(r,["children"]);return(0,hi.jsx)(gi.Typography,x(v({weight:"REGULAR"},t),{children:e}))}var mo=require("@mobilestock-native/container");var Ke=require("@mobilestock-native/container");var Ei=require("react-native"),ut=N(require("styled-components/native"));var Ti=require("react"),Pe=N(require("react-native-reanimated")),kt=N(require("styled-components/native")),bi=require("@mobilestock-native/icons"),Ci=N(require("@mobilestock-native/tools"));var uo=require("react/jsx-runtime");function vi({checked:e,translate:t,handle:o,offset:r,iconSize:n,handleColor:s,currentIcon:a}){let u=(0,kt.useTheme)(),i=z.resolveColor(s,u,"handle"),l=(0,Pe.useSharedValue)(e?t:0);(0,Ti.useEffect)(()=>{l.value=(0,Pe.withTiming)(e?t:0,{duration:dr})},[e,t,l]);let m=(0,Pe.useAnimatedStyle)(()=>({transform:[{translateX:l.value}]}));return(0,uo.jsx)(Ca,{style:v({cursor:"pointer"},m),$handle:o,$offset:r,$handleColor:i,children:a&&(0,uo.jsx)(bi.Icon,{name:a,color:Ci.default.defineTextColor(i),size:"XS",style:{width:n,height:n}})})}var Ca=(0,kt.default)(Pe.default.View)`
|
|
104
|
+
position: absolute;
|
|
105
|
+
left: ${({$offset:e})=>e}px;
|
|
106
|
+
width: ${({$handle:e})=>e}px;
|
|
107
|
+
height: ${({$handle:e})=>e}px;
|
|
108
|
+
border-radius: ${({$handle:e})=>e/2}px;
|
|
109
|
+
background-color: ${({$handleColor:e})=>e};
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
`;var st=require("react/jsx-runtime");function We(){let e=(0,ut.useTheme)(),{checked:t,toggle:o,disabled:r,checkedColor:n,backgroundColor:s,handleColor:a,size:u,icons:i,error:l}=Ue(),m=(u!=null?u:"MD").toLowerCase(),d=z.buildDimensions(e.sizeSwitch[m]),c=t?i==null?void 0:i.on:i==null?void 0:i.off,h=z.resolveSliderColor(t,n,s,!!l,e);return(0,st.jsx)(Ei.Pressable,{onPress:o,accessibilityRole:"switch",accessibilityState:{checked:t,disabled:r},children:(0,st.jsx)(va,{$disabled:r,$width:d.width,$height:d.height,children:(0,st.jsx)(Ea,{$height:d.height,$color:h,children:(0,st.jsx)(vi,{checked:t,translate:d.translate,handle:d.handle,offset:d.offset,iconSize:d.iconSize,handleColor:a,currentIcon:c})})})})}var va=ut.default.View`
|
|
113
|
+
opacity: ${({$disabled:e})=>e?.5:1};
|
|
114
|
+
width: ${({$width:e})=>e}px;
|
|
115
|
+
height: ${({$height:e})=>e}px;
|
|
116
|
+
border: 1px solid ${({theme:e})=>e.colors.input.border};
|
|
117
|
+
border-radius: ${({$height:e})=>e}px;
|
|
118
|
+
`,Ea=ut.default.View`
|
|
119
|
+
flex: 1;
|
|
120
|
+
border-radius: ${({$height:e})=>e}px;
|
|
121
|
+
background-color: ${({$color:e})=>e};
|
|
122
|
+
justify-content: center;
|
|
123
|
+
`;var U=require("react/jsx-runtime");function Si({position:e,label:t,align:o}){return e==="LEFT"?(0,U.jsxs)(Ke.Container.Horizontal,{align:"CENTER",gap:"SM",children:[t&&(0,U.jsx)(Ke.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:(0,U.jsx)(Xe,{children:t})}),(0,U.jsx)(We,{})]}):e==="RIGHT"?(0,U.jsxs)(Ke.Container.Horizontal,{align:"CENTER",gap:"SM",children:[(0,U.jsx)(We,{}),t&&(0,U.jsx)(Ke.Container.Vertical,{padding:"NONE_NONE_NONE_2XS",children:(0,U.jsx)(Xe,{children:t})})]}):(0,U.jsxs)(U.Fragment,{children:[t&&(0,U.jsx)(Ke.Container.Vertical,{align:o||"CENTER_START",padding:"NONE_NONE_2XS_NONE",children:(0,U.jsx)(Xe,{children:t})}),(0,U.jsx)(We,{})]})}var qe=require("react/jsx-runtime"),yi=(r=>(r.TOP_START="CENTER_START",r.TOP_CENTER="CENTER",r.TOP_END="CENTER_END",r))(yi||{});function Pi(){let{label:e,labelPosition:t,error:o}=Ue(),r=t!=null?t:"TOP_START",s=r.startsWith("TOP")?yi[r]:void 0;return(0,qe.jsxs)(mo.Container.Vertical,{align:s,children:[(0,qe.jsx)(Si,{position:r,label:e,align:s}),o&&(0,qe.jsx)(mo.Container.Vertical,{align:s,padding:"2XS_NONE_NONE_NONE",children:(0,qe.jsx)(zt,{children:o})})]})}var co=require("react/jsx-runtime");function Ri(o){var r=o,{children:e}=r,t=O(r,["children"]);return(0,co.jsx)(ci,x(v({labelPosition:"TOP_START",size:"MD"},t),{children:e!=null?e:(0,co.jsx)(Pi,{})}))}var xi=Object.assign(Ri,{Toggle:We,Label:Xe,Error:zt});var wi=require("@mobilestock-native/container");var Ii=require("react/jsx-runtime");function Fi(o){var r=o,{children:e}=r,t=O(r,["children"]);return(0,Ii.jsx)(wi.Container.Vertical,x(v({gap:"SM"},t),{children:e}))}var Sa=Object.assign(Ro,{Input:pr,Button:wo,Select:si,Counter:ar,Switch:xi,Vertical:Fi,MultipleArchive:Zr,PhotoList:Mn,Horizontal:sr});0&&(module.exports={Form,useForm});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestock-native/form",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"lodash": "^4.17.14",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"expo-media-library": "~18.2.0",
|
|
14
14
|
"expo-document-picker": "~14.0.7",
|
|
15
15
|
"expo-image-picker": "~17.0.8",
|
|
16
|
-
"@mobilestock-native/button": "^1.0.
|
|
17
|
-
"@mobilestock-native/badge": "^0.0.7",
|
|
16
|
+
"@mobilestock-native/button": "^1.0.17",
|
|
18
17
|
"@mobilestock-native/container": "^1.0.0",
|
|
19
|
-
"@mobilestock-native/
|
|
20
|
-
"@mobilestock-native/
|
|
18
|
+
"@mobilestock-native/badge": "^0.0.7",
|
|
19
|
+
"@mobilestock-native/icons": "^0.3.0",
|
|
20
|
+
"@mobilestock-native/modalalert": "^0.0.19",
|
|
21
21
|
"@mobilestock-native/tools": "^0.0.10",
|
|
22
22
|
"@mobilestock-native/typography": "^0.0.9",
|
|
23
|
-
"@mobilestock-native/
|
|
24
|
-
"@mobilestock-native/
|
|
23
|
+
"@mobilestock-native/clickable": "^1.0.11",
|
|
24
|
+
"@mobilestock-native/list": "^0.0.14",
|
|
25
25
|
"@mobilestock-native/spacer": "^0.0.6"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|