@mobilestockweb/form 1.0.5 → 1.2.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.
- package/index.d.ts +69 -20
- package/index.js +31 -59
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import * as react from 'react';
|
|
|
3
3
|
import { ReactNode, InputHTMLAttributes, RefObject } from 'react';
|
|
4
4
|
import { BadgeType } from '@mobilestockweb/badge';
|
|
5
5
|
import { ButtonProps } from '@mobilestockweb/button';
|
|
6
|
+
import { GroupBase, Props } from 'react-select';
|
|
6
7
|
import { FormHandles, FormProps } from '@unform/core';
|
|
7
8
|
import { ViewBaseProps } from '@mobilestockweb/container';
|
|
8
9
|
import { DefaultTheme } from 'styled-components';
|
|
9
|
-
import { GroupBase, Props } from 'react-select';
|
|
10
10
|
import { ZodSchema } from 'zod';
|
|
11
11
|
|
|
12
12
|
declare function ErrorLabel(): react_jsx_runtime.JSX.Element;
|
|
@@ -128,19 +128,56 @@ interface CounterRootProps {
|
|
|
128
128
|
value: number;
|
|
129
129
|
event: CounterEventName;
|
|
130
130
|
}): void;
|
|
131
|
+
autoFocus?: boolean;
|
|
132
|
+
onFocus?(): void;
|
|
133
|
+
onBlur?(): void;
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
declare function CounterRoot({ children, ...props }: CounterRootProps): react_jsx_runtime.JSX.Element;
|
|
134
137
|
|
|
138
|
+
interface CustomOption {
|
|
139
|
+
label: string;
|
|
140
|
+
value: string;
|
|
141
|
+
}
|
|
142
|
+
interface SelectProps<Option extends CustomOption, IsMulti extends boolean, Group extends GroupBase<Option>> extends Omit<Props<Option, IsMulti, Group>, 'isDisabled' | 'onChange'> {
|
|
143
|
+
name: string;
|
|
144
|
+
disabled?: boolean;
|
|
145
|
+
label?: string;
|
|
146
|
+
onChange?(payload: {
|
|
147
|
+
value: CustomOption['value'];
|
|
148
|
+
event: 'SELECT_CHANGE';
|
|
149
|
+
}): void;
|
|
150
|
+
}
|
|
151
|
+
interface SelectRef {
|
|
152
|
+
focus(): void;
|
|
153
|
+
blur(): void;
|
|
154
|
+
}
|
|
155
|
+
interface FormSelectPropsBase extends SelectProps<CustomOption, false, GroupBase<CustomOption>> {
|
|
156
|
+
name: string;
|
|
157
|
+
options: CustomOption[];
|
|
158
|
+
disabled?: boolean;
|
|
159
|
+
placeholder?: string;
|
|
160
|
+
defaultValue?: CustomOption;
|
|
161
|
+
label?: string;
|
|
162
|
+
autoFocus?: boolean;
|
|
163
|
+
onFocus?(): void;
|
|
164
|
+
onBlur?(): void;
|
|
165
|
+
}
|
|
166
|
+
|
|
135
167
|
type InputType = 'text' | 'password' | 'tel' | 'email' | 'number' | 'url' | 'zipcode' | 'hidden';
|
|
136
|
-
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
168
|
+
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> {
|
|
137
169
|
name: string;
|
|
138
170
|
label?: string;
|
|
139
171
|
type?: InputType;
|
|
140
172
|
autoSubmit?: boolean;
|
|
141
173
|
full?: boolean;
|
|
142
|
-
|
|
174
|
+
showMaxContent?: boolean;
|
|
175
|
+
numberOfLines?: number;
|
|
143
176
|
format?(value: string): string;
|
|
177
|
+
onChange?(payload: {
|
|
178
|
+
value: unknown;
|
|
179
|
+
event: 'INPUT_CHANGE' | 'AUTO_SUBMIT' | 'TOGGLE_PASSWORD';
|
|
180
|
+
}): void;
|
|
144
181
|
}
|
|
145
182
|
interface InputRef {
|
|
146
183
|
focus(): void;
|
|
@@ -206,38 +243,50 @@ interface PhotoInputProps extends Omit<PhotoListProviderProps, 'children'> {
|
|
|
206
243
|
}
|
|
207
244
|
declare function FormPhotoList({ label, alignLabel, buttonAddDirection, numberOfImagesVisible, ...props }: PhotoInputProps): react_jsx_runtime.JSX.Element;
|
|
208
245
|
|
|
209
|
-
interface PropsFormInputRadio extends InputHTMLAttributes<HTMLInputElement> {
|
|
246
|
+
interface PropsFormInputRadio extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
210
247
|
name: string;
|
|
211
248
|
label: string;
|
|
212
249
|
value: string;
|
|
250
|
+
onChange?(payload: {
|
|
251
|
+
value: string;
|
|
252
|
+
event: 'RADIO_CHANGE';
|
|
253
|
+
}): void;
|
|
213
254
|
}
|
|
214
|
-
declare function FormRadio(props: PropsFormInputRadio): react_jsx_runtime.JSX.Element;
|
|
215
|
-
|
|
216
|
-
interface CustomOption {
|
|
217
|
-
label: string;
|
|
218
|
-
value: string;
|
|
219
|
-
}
|
|
220
|
-
interface SelectProps<Option extends CustomOption, IsMulti extends boolean, Group extends GroupBase<Option>> extends Omit<Props<Option, IsMulti, Group>, 'isDisabled'> {
|
|
221
|
-
name: string;
|
|
222
|
-
disabled?: boolean;
|
|
223
|
-
label?: string;
|
|
224
|
-
}
|
|
225
|
-
declare function FormSelect<Option extends CustomOption, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectProps<Option, IsMulti, Group>): react_jsx_runtime.JSX.Element;
|
|
255
|
+
declare function FormRadio({ name, label, value, onChange, ...props }: PropsFormInputRadio): react_jsx_runtime.JSX.Element;
|
|
226
256
|
|
|
227
257
|
declare function FormVertical({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
|
|
228
258
|
|
|
229
|
-
interface FormPropsWithHandler<T extends object> extends FormProps {
|
|
230
|
-
onSubmit(params: SubmitParams<T>): Promise<void> | void;
|
|
259
|
+
interface FormPropsWithHandler<T extends object> extends Omit<FormProps, 'onSubmit'> {
|
|
260
|
+
onSubmit?(params: SubmitParams<T>): Promise<void> | void;
|
|
261
|
+
onBeforeSubmit?(params: {
|
|
262
|
+
data: T;
|
|
263
|
+
}): Promise<boolean> | boolean;
|
|
264
|
+
onAfterSubmit?(params: {
|
|
265
|
+
data: T;
|
|
266
|
+
}): Promise<void> | void;
|
|
231
267
|
schema?: ZodSchema<T>;
|
|
268
|
+
name?: string;
|
|
232
269
|
}
|
|
233
270
|
interface PropsContext {
|
|
234
271
|
submitForm(): void;
|
|
235
272
|
clearForm(): void;
|
|
236
273
|
formRef: RefObject<FormHandles>;
|
|
237
274
|
loading?: boolean;
|
|
275
|
+
notifyFieldChange(fieldName: string, fieldValue: unknown): void;
|
|
276
|
+
}
|
|
277
|
+
declare function FormComponent<T extends object>({ children, onSubmit, onBeforeSubmit, onAfterSubmit, schema, name: formName, ...props }: FormPropsWithHandler<T>): react_jsx_runtime.JSX.Element;
|
|
278
|
+
|
|
279
|
+
interface UseFormReturn<T extends object> {
|
|
280
|
+
readonly values: T;
|
|
281
|
+
getValue<K extends keyof T & string>(name: K): T[K] | undefined;
|
|
282
|
+
setValue<K extends keyof T & string>(name: K, value: T[K]): void;
|
|
283
|
+
submit(): void;
|
|
284
|
+
clear(): void;
|
|
285
|
+
setErrors(errors: Record<string, string>): void;
|
|
286
|
+
reset(data?: Partial<T>): void;
|
|
238
287
|
}
|
|
239
288
|
declare function useForm(): PropsContext;
|
|
240
|
-
declare function
|
|
289
|
+
declare function useForm<T extends object>(name: string): UseFormReturn<T>;
|
|
241
290
|
|
|
242
291
|
interface SubmitParams<T extends object> {
|
|
243
292
|
data: T;
|
|
@@ -247,7 +296,7 @@ interface SubmitParams<T extends object> {
|
|
|
247
296
|
declare const Form: typeof FormComponent & {
|
|
248
297
|
Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<InputRef>>;
|
|
249
298
|
Radio: typeof FormRadio;
|
|
250
|
-
Select:
|
|
299
|
+
Select: react.ForwardRefExoticComponent<FormSelectPropsBase & react.RefAttributes<SelectRef>>;
|
|
251
300
|
Button: typeof FormButton;
|
|
252
301
|
Counter: typeof CounterRoot & {
|
|
253
302
|
Display: typeof Display;
|
package/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ln=Object.create;var Ae=Object.defineProperty,sn=Object.defineProperties,un=Object.getOwnPropertyDescriptor,mn=Object.getOwnPropertyDescriptors,pn=Object.getOwnPropertyNames,$e=Object.getOwnPropertySymbols,cn=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable;var At=(e,t,o)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))at.call(t,o)&&At(e,o,t[o]);if($e)for(var o of $e(t))Mt.call(t,o)&&At(e,o,t[o]);return e},S=(e,t)=>sn(e,mn(t));var P=(e,t)=>{var o={};for(var i in e)at.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&$e)for(var i of $e(e))t.indexOf(i)<0&&Mt.call(e,i)&&(o[i]=e[i]);return o};var dn=(e,t)=>{for(var o in t)Ae(e,o,{get:t[o],enumerable:!0})},Nt=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pn(t))!at.call(e,r)&&r!==o&&Ae(e,r,{get:()=>t[r],enumerable:!(i=un(t,r))||i.enumerable});return e};var L=(e,t,o)=>(o=e!=null?ln(cn(e)):{},Nt(t||!e||!e.__esModule?Ae(o,"default",{value:e,enumerable:!0}):o,e)),fn=e=>Nt(Ae({},"__esModule",{value:!0}),e);var Ue=(e,t,o)=>new Promise((i,r)=>{var m=a=>{try{l(o.next(a))}catch(s){r(s)}},n=a=>{try{l(o.throw(a))}catch(s){r(s)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(m,n);l((o=o.apply(e,t)).next())});var Dn={};dn(Dn,{Form:()=>Vn,useForm:()=>B});module.exports=fn(Dn);var Ut=require("@mobilestockweb/button");var be=require("react");var Dt=require("@unform/web"),Bt=require("notistack"),te=require("react"),kt=require("zod"),_t=require("@mobilestockweb/container");var Me=new Map;function lt(e){let t=Me.get(e);return t||(t={formRef:null,values:{},watchedFields:new Set,listeners:new Set},Me.set(e,t)),t}function Ot(e,t){let o=lt(e);o.formRef=t}function zt(e){let t=Me.get(e);t&&(t.formRef=null,t.values={},t.watchedFields.clear(),t.listeners.clear(),Me.delete(e))}function Vt(e,t,o){let i=Me.get(e);!i||!i.watchedFields.has(t)||i.values[t]===o||(i.values=S(b({},i.values),{[t]:o}),i.listeners.forEach(r=>r()))}var Ge=require("react/jsx-runtime"),st=(0,te.createContext)({});function $t(l){var a=l,{children:e,onSubmit:t,onBeforeSubmit:o,onAfterSubmit:i,schema:r,name:m}=a,n=P(a,["children","onSubmit","onBeforeSubmit","onAfterSubmit","schema","name"]);let s=(0,te.useRef)(null),[f,C]=(0,te.useState)(!1);(0,te.useEffect)(()=>{if(m)return Ot(m,s),()=>zt(m)},[m]);let p=(0,te.useCallback)((g,T)=>{m&&Vt(m,g,T)},[m]);function c(){var g;(g=s.current)==null||g.submitForm()}function u(){var g,T;(g=s.current)==null||g.setErrors({}),(T=s.current)==null||T.reset()}function d(g){let T={};for(let v of g){let y=v.path.filter(h=>typeof h=="string"||typeof h=="number").join(".");y&&(T[String(y)]=v.message)}return T}function R(g){if(g instanceof kt.ZodError)return d(g.issues);if(typeof g=="object"&&g!==null&&"errors"in g){let T=g.errors;if(Array.isArray(T)&&T.length>0&&"message"in T[0]&&"path"in T[0])return d(T)}return null}function E(v,y){return Ue(this,arguments,function*(g,{reset:T}){var h,H,A,D,N;if((h=s.current)==null||h.setErrors({}),r){let O=r.safeParse(g);if(!O.success){(H=s.current)==null||H.setErrors(d(O.error.issues));return}}if(!(o&&(yield o({data:g}))===!1))try{C(!0),yield t==null?void 0:t({data:g,ref:s,reset:T}),yield i==null?void 0:i({data:g})}catch(O){let x=R(O);if(x)(A=s.current)==null||A.setErrors(x);else{let z="Erro ao realizar opera\xE7\xE3o",_=500;if(typeof O=="object"&&O!==null&&"isAxiosError"in O&&O.isAxiosError){let Ve=O;_=((D=Ve.response)==null?void 0:D.status)||500;let Se=(N=Ve.response)==null?void 0:N.data;Se!=null&&Se.message&&(z=Se.message)}else O instanceof Error&&(z=O.message||z);(0,Bt.enqueueSnackbar)(z,{variant:_>=500?"error":"warning"})}}finally{C(!1)}})}return(0,Ge.jsx)(st.Provider,{value:{formRef:s,submitForm:c,clearForm:u,loading:f,notifyFieldChange:p},children:(0,Ge.jsx)(Dt.Form,S(b({},n),{ref:s,onSubmit:E,children:(0,Ge.jsx)(_t.Container.Vertical,{gap:"2XS",children:e})}))})}var gn={};function B(e){let t=(0,be.useContext)(st),o=e?lt(e):null,i=(0,be.useCallback)(n=>o?(o.listeners.add(n),()=>{o.listeners.delete(n)}):()=>{},[o]),r=(0,be.useCallback)(()=>o?o.values:gn,[o]),m=(0,be.useSyncExternalStore)(i,r);return!e||!o?t:{get values(){var n,l,a;return(a=(l=(n=o.formRef)==null?void 0:n.current)==null?void 0:l.getData())!=null?a:{}},getValue(n){var l,a;return o.watchedFields.add(n),n in m?m[n]:(a=(l=o.formRef)==null?void 0:l.current)==null?void 0:a.getFieldValue(n)},setValue(n,l){var a,s;(s=(a=o.formRef)==null?void 0:a.current)==null||s.setFieldValue(n,l)},submit(){var n,l;(l=(n=o.formRef)==null?void 0:n.current)==null||l.submitForm()},clear(){var n,l,a,s;(l=(n=o.formRef)==null?void 0:n.current)==null||l.setErrors({}),(s=(a=o.formRef)==null?void 0:a.current)==null||s.reset()},setErrors(n){var l,a;(a=(l=o.formRef)==null?void 0:l.current)==null||a.setErrors(n)},reset(n){var l,a;(a=(l=o.formRef)==null?void 0:l.current)==null||a.reset(n)}}}var Xt=require("react/jsx-runtime");function Gt(m){var n=m,{type:e="SUBMIT",disabled:t,isLoading:o,onClick:i}=n,r=P(n,["type","disabled","isLoading","onClick"]);let{submitForm:l,clearForm:a,loading:s}=B();function f(C){switch(C.preventDefault(),e){case"SUBMIT":l();break;case"RESET":a();break;default:i==null||i(C)}}return(0,Xt.jsx)(Ut.Button,S(b({},r),{onClick:f,isLoading:e==="SUBMIT"&&s||o,disabled:s||o||t,type:e.toLowerCase()}))}var ut=L(require("styled-components")),jt=require("@mobilestockweb/badge"),eo=require("@mobilestockweb/container"),to=L(require("@mobilestockweb/tools")),oo=require("@mobilestockweb/typography");var Wt=require("@unform/core"),Z=require("react");var Zt=require("react/jsx-runtime"),Kt=(0,Z.createContext)(void 0);function qt(e){let{notifyFieldChange:t}=B(),{fieldName:o,registerField:i,error:r,defaultValue:m}=(0,Wt.useField)(e.name),[n,l]=(0,Z.useState)(0),a=(0,Z.useCallback)(p=>{let c=p;return e.maxCount!==void 0&&c>e.maxCount&&(c=e.maxCount),e.minCount!==void 0&&c<e.minCount&&(c=e.minCount),c},[e.maxCount,e.minCount]),s=(0,Z.useCallback)((p,c=!0)=>{var d;let u=a(p);l(u),t==null||t(o,u),c&&((d=e.onChange)==null||d.call(e,{value:u,event:"EDIT"}))},[a,t,o]);(0,Z.useEffect)(()=>{i({name:o,getValue:()=>n,setValue:(p,c)=>s(c),clearValue:()=>s(0)})},[o,n,i,s]),(0,Z.useEffect)(()=>{s(Number(e.initialCount)||Number(m)||0,!1)},[e.initialCount,s,m]);function f(p=1){l(c=>{var d;let u=a(c+1*p);return t==null||t(o,u),(d=e.onChange)==null||d.call(e,{value:u,event:"INCREMENT"}),u})}function C(p=1){l(c=>{var d;let u=a(c-1*p);return t==null||t(o,u),(d=e.onChange)==null||d.call(e,{value:u,event:"DECREMENT"}),u})}return(0,Zt.jsx)(Kt.Provider,{value:{count:n,increment:f,decrement:C,configureCount:s,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:r,autoFocus:e.autoFocus,onFocus:e.onFocus,onBlur:e.onBlur},children:e.children})}function Y(){let e=(0,Z.useContext)(Kt);if(!e)throw new Error("useCounter must be used within a CounterProvider");return e}var Yt=L(require("styled-components")),Jt=require("@mobilestockweb/container");var Qt=require("react/jsx-runtime");function Ce(e){return(0,Qt.jsx)(hn,b({align:"CENTER"},e))}var hn=(0,Yt.default)(Jt.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 Ne=require("react/jsx-runtime");function Oe(e){let{groupElements:t}=Y();return(0,Ne.jsx)(Ce,{children:t&&e.renderInsidePill?(0,Ne.jsx)(bn,{$type:e.type,full:!0,align:"CENTER",children:(0,Ne.jsx)(Cn,{$type:e.type,children:e.text})}):(0,Ne.jsx)(jt.Badge,{text:e.text,type:e.type,size:"XS"})})}function ro(e,t){return Object.keys(t.colors.badge).find(o=>o.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var bn=(0,ut.default)(eo.Container.Vertical)`
|
|
6
|
+
background-color: ${({$type:e,theme:t})=>{let o=ro(e,t);return t.colors.badge[o]}};
|
|
7
7
|
width: 100%;
|
|
8
|
-
`,
|
|
9
|
-
color: ${({$type:e,theme:t})=>{let o=
|
|
10
|
-
`;
|
|
8
|
+
`,Cn=(0,ut.default)(oo.Typography)`
|
|
9
|
+
color: ${({$type:e,theme:t})=>{let o=ro(e,t);return to.default.defineTextColor(t.colors.badge[o])}};
|
|
10
|
+
`;Oe.displayName="Form.FormCounter.Badge";var ae=require("react"),J=require("@mobilestockweb/container"),mo=L(require("@mobilestockweb/tools"));var ze=L(require("styled-components")),no=require("@mobilestockweb/container");var io=require("react/jsx-runtime");function xe(o){var i=o,{children:e}=i,t=P(i,["children"]);let{groupElements:r,error:m}=Y();return(0,io.jsx)(Tn,S(b({align:"CENTER",$groupElements:r,$error:!!m},t),{children:e}))}var Tn=(0,ze.default)(no.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&&ze.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&&ze.css`
|
|
21
21
|
background-color: ${t.colors.input.error};
|
|
22
22
|
border: 1px solid ${t.colors.alert.urgent};
|
|
23
23
|
`}
|
|
24
|
-
`;var
|
|
24
|
+
`;var ao=require("@mobilestockweb/typography"),lo=require("react/jsx-runtime");function ie({children:e}){return(0,lo.jsx)(ao.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var so=require("@mobilestockweb/typography"),uo=require("react/jsx-runtime");function ue({children:e}){return(0,uo.jsx)(so.Typography,{weight:"REGULAR",children:e})}var w=require("react/jsx-runtime");function po({children:e}){let{label:t,error:o,labelPosition:i}=Y(),r=[],m=[],n=(0,ae.useCallback)(a=>(0,ae.isValidElement)(a)&&a.type===ae.Fragment?n(a.props.children):a,[]),l=n(e);return ae.Children.toArray(l).forEach(a=>{(0,ae.isValidElement)(a)&&mo.default.isComponentWithDisplayName(a.type)&&a.type.displayName===Oe.displayName&&!a.props.renderInsidePill?r.push(a):m.push(a)}),(0,w.jsxs)(J.Container.Vertical,{align:"CENTER_START",children:[i==="TOP_START"&&t&&(0,w.jsxs)(J.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,w.jsx)(ue,{children:t}),o&&!r.length&&(0,w.jsx)(ie,{children:o})]}),i!=="LEFT"&&(0,w.jsxs)(J.Container.Vertical,{align:"CENTER",children:[(i!=="TOP_START"&&t||i!=="TOP_START"&&o&&!r.length)&&(0,w.jsxs)(J.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[t&&(0,w.jsx)(ue,{children:t}),o&&!r.length&&(0,w.jsx)(ie,{children:o})]}),(0,w.jsxs)(J.Container.Horizontal,{align:"CENTER_START",children:[r.length>0&&(0,w.jsx)(J.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,w.jsxs)(J.Container.Vertical,{children:[(0,w.jsx)(xe,{children:m}),o&&!!r.length&&(0,w.jsx)(ie,{children:o})]})]})]}),i==="LEFT"&&(0,w.jsx)(J.Container.Vertical,{children:(0,w.jsxs)(J.Container.Horizontal,{align:"CENTER",children:[(0,w.jsxs)(J.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[t&&(0,w.jsx)(ue,{children:t}),o&&!r.length&&(0,w.jsx)(ie,{children:o})]}),r.length>0&&(0,w.jsx)(J.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:r}),(0,w.jsx)(xe,{children:m})]})})]})}var me=require("@mobilestockweb/container");var Xe=require("react"),co=L(require("styled-components")),fo=require("@mobilestockweb/button");var mt=require("react/jsx-runtime");function le(i){var r=i,{type:e,disabled:t}=r,o=P(r,["type","disabled"]);let{loading:m}=B(),n=Y(),l=(0,Xe.useRef)(null),a=(0,Xe.useMemo)(()=>e==="PLUS"&&n.maxCount!==void 0?n.count>=n.maxCount:e==="MINUS"&&n.minCount!==void 0?n.count<=n.minCount:!1,[e,n.count,n.maxCount,n.minCount]);function s(){e==="PLUS"?n.increment():n.decrement()}function f(){l.current=setTimeout(()=>{"vibrate"in navigator&&navigator.vibrate(500),e==="PLUS"?n.increment(n.multiplier):n.decrement(n.multiplier)},500)}function C(){l.current&&(clearTimeout(l.current),l.current=null)}return(0,mt.jsx)(Ce,{children:(0,mt.jsx)(vn,S(b({type:"button",icon:e==="PLUS"?"Plus":"Minus",backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},o),{size:"SM",variant:n.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:n.groupElements,disabled:a||t||m,onClick:s,onMouseDown:f,onMouseUp:C,onMouseLeave:C,onTouchStart:f,onTouchEnd:C}))})}var vn=(0,co.default)(fo.Button)`
|
|
25
25
|
border-radius: ${({$grouped:e,theme:t})=>e?t.borderRadius.none:t.borderRadius.default};
|
|
26
|
-
`;var
|
|
26
|
+
`;var Te=require("react"),go=L(require("styled-components")),ho=require("@mobilestockweb/clickable"),pt=require("@mobilestockweb/container"),ct=require("@mobilestockweb/typography");var se=require("react/jsx-runtime");function Fe(){let{count:e,editable:t,configureCount:o,autoFocus:i,onFocus:r,onBlur:m}=Y(),n=(0,Te.useRef)(null),[l,a]=(0,Te.useState)(i&&t),[s,f]=(0,Te.useState)(e.toString());(0,Te.useEffect)(()=>{f(e.toString())},[e]);function C(u){let d=Number(u.target.value);o(Number.isNaN(d)?0:d),a(!1),m==null||m()}function p(u){var d;u.key==="Enter"&&(u.preventDefault(),(d=n.current)==null||d.blur())}function c(u){u.target.select(),r==null||r()}return t?(0,se.jsx)(ho.Clickable,{onClick:()=>a(!0),type:"button",children:(0,se.jsx)(pt.Container.Horizontal,{padding:"NONE_2XS",children:(0,se.jsx)(Ce,{children:l?(0,se.jsx)(En,{"data-testid":"counter-input",ref:n,value:s,autoFocus:!0,onKeyDown:p,type:"text",inputMode:"numeric",onChange:u=>f(u.target.value),onFocus:c,onBlur:C}):(0,se.jsx)(ct.Typography,{weight:"BOLD",size:"LG",children:e})})})}):(0,se.jsx)(pt.Container.Horizontal,{padding:"NONE_2XS",children:(0,se.jsx)(Ce,{children:(0,se.jsx)(ct.Typography,{weight:"BOLD",size:"LG",children:e})})})}var En=go.default.input`
|
|
27
27
|
&:focus {
|
|
28
28
|
outline: none;
|
|
29
29
|
box-shadow: none;
|
|
@@ -42,87 +42,59 @@
|
|
|
42
42
|
text-align: center;
|
|
43
43
|
width: 40px;
|
|
44
44
|
height: 34px;
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
`;Fe.displayName="Form.FormCounter.Display";var I=require("react/jsx-runtime");function bo(){let{label:e,labelPosition:t,error:o}=Y();return(0,I.jsxs)(me.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,I.jsxs)(me.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,I.jsx)(ue,{children:e}),o&&(0,I.jsx)(ie,{children:o})]}),t!=="LEFT"&&(0,I.jsxs)(me.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,I.jsxs)(me.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,I.jsx)(ue,{children:e}),o&&(0,I.jsx)(ie,{children:o})]}),(0,I.jsxs)(xe,{children:[(0,I.jsx)(le,{type:"MINUS"}),(0,I.jsx)(Fe,{}),(0,I.jsx)(le,{type:"PLUS"})]})]}),t==="LEFT"&&(0,I.jsx)(me.Container.Vertical,{children:(0,I.jsxs)(me.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,I.jsxs)(me.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,I.jsx)(ue,{children:e}),o&&(0,I.jsx)(ie,{children:o})]}),(0,I.jsxs)(xe,{children:[(0,I.jsx)(le,{type:"MINUS"}),(0,I.jsx)(Fe,{}),(0,I.jsx)(le,{type:"PLUS"})]})]})})]})}var We=require("react/jsx-runtime");function Co(o){var i=o,{children:e}=i,t=P(i,["children"]);return(0,We.jsx)(qt,S(b({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,We.jsx)(po,{children:e}):(0,We.jsx)(bo,{})}))}var To=require("react/jsx-runtime");function dt(e){return(0,To.jsx)(le,S(b({},e),{type:"MINUS"}))}dt.displayName="Form.FormCounter.Minus";var vo=require("react/jsx-runtime");function ft(e){return(0,vo.jsx)(le,S(b({},e),{type:"PLUS"}))}ft.displayName="Form.FormCounter.Plus";var Eo=Object.assign(Co,{Display:Fe,Plus:ft,Minus:dt,Badge:Oe});var yo=require("@mobilestockweb/container");var xo=require("react/jsx-runtime");function So(o){var i=o,{children:e}=i,t=P(i,["children"]);return(0,xo.jsx)(yo.Container.Horizontal,S(b({gap:"SM"},t),{children:e}))}var Fo=require("@unform/core"),V=require("react"),ve=L(require("styled-components")),Ro=require("@mobilestockweb/button"),bt=require("@mobilestockweb/container"),gt=L(require("@mobilestockweb/tools")),ht=require("@mobilestockweb/typography");var oe=require("react/jsx-runtime"),Po=(0,V.forwardRef)(function(d,u){var R=d,{name:t,type:o="text",full:i,label:r,maxLength:m,autoSubmit:n=!1,defaultValue:l,numberOfLines:a=1,showMaxContent:s=!1,autoCapitalize:f,format:C,onChange:p}=R,c=P(R,["name","type","full","label","maxLength","autoSubmit","defaultValue","numberOfLines","showMaxContent","autoCapitalize","format","onChange"]);let E=(0,ve.useTheme)(),{loading:g,notifyFieldChange:T}=B(),v=(0,Fo.useField)(t),y=a>1,h=(0,V.useRef)(null),[H,A]=(0,V.useState)(!1),[D,N]=(0,V.useState)(""),O=o==="password",x=o==="tel"?15:o==="zipcode"?9:m,z=t+"-input"+(0,V.useId)(),_={width:"100%",border:"none",outline:"none",backgroundColor:"transparent",fontFamily:E.font.families[0],lineHeight:E.font.lineHeight,fontSize:E.font.size.sm,color:E.colors.text.default},Ve=S(b({},_),{height:"2.5rem"}),Se=S(b({},_),{padding:"10px 0",display:"block",resize:"none",overflow:"hidden",boxSizing:"border-box"}),on=(0,V.useMemo)(()=>o==="password"?H?"text":"password":o,[o,H]),De=(0,V.useCallback)(()=>{if(!y||!h.current)return;let M=h.current,F=window.getComputedStyle(M),q=parseInt(F.lineHeight,10);isNaN(q)&&(q=parseInt(F.fontSize,10)*E.font.lineHeight);let Be=parseInt(F.paddingTop,10),he=parseInt(F.paddingBottom,10),ke=q*a+Be+he+1,He=parseFloat(getComputedStyle(document.documentElement).fontSize)*2.5;if(s)M.style.height=ke+"px";else{M.style.height="0";let _e=M.scrollHeight;M.style.height=Math.max(He,Math.min(_e,ke))+"px"}},[y,a,s,E.font.lineHeight]),Ht=(0,V.useCallback)(M=>{var q,Be;let F=M.target.value;switch(o){case"tel":F=gt.default.phoneNumberFormatter(F);break;case"email":case"url":F=F.trim();break;case"zipcode":F=gt.default.formatZipcode(F);break}if(C&&(F=C(F)),y&&a&&h.current){let he=h.current;he.value=F,he.style.height="auto";let ke=he.scrollHeight,we=window.getComputedStyle(he),He=parseInt(we.lineHeight,10);isNaN(He)&&(He=parseInt(we.fontSize,10)*E.font.lineHeight);let _e=parseInt(we.paddingTop,10),nn=parseInt(we.paddingBottom,10),an=He*(a+1)+_e+nn+1;if(ke>an){he.value=D,De();return}}N(F),M.target.value=F,h.current.value=F,p==null||p({value:F,event:"INPUT_CHANGE"}),T==null||T(t,F),o==="tel"&&n&&F.length===15&&((q=h.current)!=null&&q.form)&&(p==null||p({value:F,event:"AUTO_SUBMIT"}),h.current.form.requestSubmit(),h.current.blur()),o==="zipcode"&&n&&F.length===9&&((Be=h.current)!=null&&Be.form)&&(p==null||p({value:F,event:"AUTO_SUBMIT"}),h.current.form.requestSubmit(),h.current.blur())},[o,C,n,p,v,T,y,a,D,De]);(0,V.useEffect)(()=>{let M=D||l||(v==null?void 0:v.defaultValue)||"";h.current.value=M,N(M),v.registerField({name:v.fieldName,ref:h,getValue:F=>{var q;return((q=F.current)==null?void 0:q.value)||""},setValue:(F,q)=>{F.current&&(F.current.value=q,N(q))},clearValue:F=>{F.current&&(F.current.value="",N(""))}})},[v==null?void 0:v.fieldName,v==null?void 0:v.registerField]),(0,V.useEffect)(()=>{De()},[D,De]),(0,V.useImperativeHandle)(u,()=>({focus(){var M;(M=h.current)==null||M.focus()},blur(){var M;(M=h.current)==null||M.blur()}}));function rn(){A(M=>(p==null||p({value:!M,event:"TOGGLE_PASSWORD"}),!M))}return(0,oe.jsxs)(yn,{full:i,$show:o!=="hidden",children:[r&&(0,oe.jsx)("label",{htmlFor:z,children:(0,oe.jsx)(ht.Typography,{children:r})}),(0,oe.jsxs)(Sn,{$error:!!(v!=null&&v.error),$isPassword:O,children:[y?(0,oe.jsx)("textarea",S(b({},c),{ref:h,id:z,value:D,onChange:Ht,maxLength:x,disabled:g||c.disabled,style:Se})):(0,oe.jsx)("input",S(b({},c),{ref:h,id:z,value:D,onChange:Ht,maxLength:x,type:on,disabled:g||c.disabled,style:Ve})),O&&(0,oe.jsx)(Ro.Button,{size:"SM",onClick:rn,icon:H?"EyeOutline":"EyeOff",variant:"TRANSPARENT",type:"button"})]}),!!(v!=null&&v.error)&&(0,oe.jsx)(ht.Typography,{color:"DANGER",size:"SM",children:v==null?void 0:v.error})]})}),yn=(0,ve.default)(bt.Container.Vertical)`
|
|
46
|
+
${({$show:e})=>!e&&ve.css`
|
|
47
|
+
display: none;
|
|
48
|
+
`}
|
|
49
|
+
`,Sn=(0,ve.default)(bt.Container.Horizontal)`
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
background-color: ${({$error:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
|
|
52
|
+
border: 1px solid ${({$error:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
|
|
51
53
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
height: 2.5rem;
|
|
56
|
-
outline: none;
|
|
57
|
-
background-color: transparent;
|
|
58
|
-
`;var wo=require("@unform/core"),Ho=require("react"),Oo=I(require("styled-components")),De=require("@mobilestockweb/container");var io=require("@unform/core"),X=require("react");var V={getHashFile(e){return`${e.name}-${e.size}`}};var so=require("react/jsx-runtime"),ao=(0,X.createContext)(null);function lo({children:e,accept:t,onChange:o,name:n}){let{fieldName:r,registerField:u,defaultValue:i}=(0,io.useField)(n),[l,a]=(0,X.useState)(null),g=(0,X.useCallback)(s=>{let m=s.map(y=>({file:y,hash:V.getHashFile(y)})),E=(l||[]).map(y=>({file:y,hash:V.getHashFile(y)})),C=[...m,...E],d=Array.from(new Set(C.map(y=>y.hash))).map(y=>C.find(S=>S.hash===y)),F=d.filter(y=>m.some(S=>S.hash===y.hash));if(!F.length)return;let L=d.map(y=>y.file);a(L),o==null||o({value:F.map(y=>y.file),event:"ADD_FILES"})},[l,o]),c=(0,X.useCallback)(s=>{if(!s){a(null);return}let m=s.filter(E=>!!E);g(m)},[g,a]);(0,X.useEffect)(()=>{u({name:r,getValue:()=>l,setValue:(s,m)=>c(m||i),clearValue:()=>a(null)})},[r,u,l,c,i]),(0,X.useEffect)(()=>{a(null)},[t]);function p(s){if(!l)return;let m=l.filter(E=>V.getHashFile(E)!==s);a(m),o==null||o({value:l.find(E=>V.getHashFile(E)===s),event:"REMOVE_FILE"})}function b(){let s=document.createElement("input");s.style.display="none",s.setAttribute("type","file"),s.setAttribute("accept","*/*"),s.setAttribute("id",String(Math.random())),s.setAttribute("multiple","multiple"),document.body.appendChild(s),s.addEventListener("change",()=>{s.files&&g(Array.from(s.files)),document.body.removeChild(s)});let m=new MouseEvent("click");s.dispatchEvent(m)}return(0,so.jsx)(ao.Provider,{value:{handleSelectFile:b,handleSaveFiles:g,handleRemoveFile:p,accept:t,files:l,name:n},children:e})}function K(){let e=(0,X.useContext)(ao);if(!e)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var Me={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=["|",",",";"," ",`
|
|
59
|
-
`," ","\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 Co=require("@mobilestockweb/container"),bo=require("@mobilestockweb/spacer");var uo=require("@unform/core"),mo=require("@mobilestockweb/typography");var po=require("react/jsx-runtime");function Ae(){let e=K(),{error:t}=(0,uo.useField)(e.name);return(0,po.jsx)(mo.Typography,{color:"DANGER",size:"XS",children:t})}var co=require("@mobilestockweb/button"),fo=require("react/jsx-runtime");function we(){return(0,fo.jsx)(co.Button,{type:"button",text:"Selecionar arquivo",size:"XS"})}var He=require("@mobilestockweb/typography");var ie=require("react/jsx-runtime");function Oe(){var t,o;let e=K();return(t=e.accept)!=null&&t.includes("all")?(0,ie.jsx)(He.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(He.Typography,{size:"XS",children:"Arquivos suportados"}),(0,ie.jsxs)(He.Typography,{size:"XS",children:["( ",(o=e.accept)==null?void 0:o.join(", ")," )"]})]})}var go=require("@mobilestockweb/typography"),ho=require("react/jsx-runtime");function ze({children:e}){return(0,ho.jsx)(go.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var ae=require("react/jsx-runtime");function Eo(){var t;let e=K();return(0,ae.jsxs)(Co.Container.Vertical,{align:"CENTER",children:[(0,ae.jsx)(ze,{}),(0,ae.jsx)(bo.Spacer,{size:"2XS"}),(0,ae.jsx)(we,{}),(0,ae.jsx)(Ae,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,ae.jsx)(Oe,{})]})}var To=I(require("chroma-js")),vo=require("react"),yo=require("styled-components");var Ro=require("react/jsx-runtime");function Fo(e){let t=K(),o=(0,yo.useTheme)(),[n,r]=(0,vo.useState)(!1);function u(i){var g;i.preventDefault(),r(!1);let l=i.dataTransfer;if(!l)return;let a=[];if(l.items&&l.items.length>0)for(let c=0;c<l.items.length;c++){let p=l.items[c];if(p.kind!=="file")continue;let b=p.webkitGetAsEntry();if(b&&b.isDirectory)continue;let s=p.getAsFile();s&&a.push(s)}else if(l.files&&l.files.length>0)for(let c=0;c<l.files.length;c++){let p=l.files.item(c);p&&a.push(p)}a.length!==0&&((g=t.accept)!=null&&g.some(c=>c!=="all")&&(a=a.filter(c=>{var b;let p=c.name.split(".").pop();return(b=t.accept)==null?void 0:b.includes(p==null?void 0:p.toLowerCase())}),!a.length)||t.handleSaveFiles(a))}return(0,Ro.jsx)("div",h({onDragOver:i=>{i.preventDefault(),r(!0)},onDrop:u,onDragLeave:i=>{i.preventDefault(),r(!1)},style:h({},n?{backgroundColor:(0,To.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var Po=require("react"),je=I(require("styled-components")),xo=require("@mobilestockweb/button"),So=require("@mobilestockweb/clickable"),le=require("@mobilestockweb/container"),Io=require("@mobilestockweb/icons"),Ve=require("@mobilestockweb/typography");var M=require("react/jsx-runtime");function Lo(){var n,r,u;let e=K(),[t,o]=(0,Po.useState)(!1);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(le.Container.Horizontal,{align:"END",children:!!((n=e.files)!=null&&n.length)&&(0,M.jsx)(So.Clickable,{type:"button","data-testid":"flip-button",onClick:()=>o(!t),children:(0,M.jsxs)(le.Container.Horizontal,{align:"CENTER",children:[(0,M.jsxs)(Ve.Typography,{size:"XS",children:[(r=e.files)==null?void 0:r.length," arquivos"]}),(0,M.jsx)(Qr,{"data-testid":"flip-icon-container","data-flip":t,$flip:t,children:(0,M.jsx)(Io.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,M.jsx)(jr,{"data-testid":"multiple-archive-list","data-open":t,$flip:t,children:(u=e.files)==null?void 0:u.map((i,l)=>(0,M.jsxs)(le.Container.Horizontal,{align:"START_CENTER",children:[(0,M.jsxs)(le.Container.Horizontal,{gap:"SM",full:!0,children:[(0,M.jsx)(Ve.Typography,{size:"XS",weight:"MEDIUM",children:i.name.slice(0,20)}),i.size&&(0,M.jsx)(Ve.Typography,{size:"XS",children:Me.convertBytesToReadableFormat(i.size)})]}),(0,M.jsx)(le.Container.Vertical,{children:(0,M.jsx)(xo.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS","data-testid":`trash-button-${l}`,onClick:()=>e.handleRemoveFile(`${i.name}-${i.size}`)})})]},l))})]})}var Qr=(0,je.default)(le.Container.Horizontal)`
|
|
54
|
+
padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
|
|
55
|
+
`;var tr=require("@unform/core"),or=require("react"),rr=L(require("styled-components")),et=require("@mobilestockweb/container");var Io=require("@unform/core"),Q=require("react");var W={getHashFile(e){return`${e.name}-${e.size}`}};var Ho=require("react/jsx-runtime"),Lo=(0,Q.createContext)(null);function wo({children:e,accept:t,onChange:o,name:i}){let{notifyFieldChange:r}=B(),{fieldName:m,registerField:n,defaultValue:l}=(0,Io.useField)(i),[a,s]=(0,Q.useState)(null),f=(0,Q.useCallback)(u=>{let d=u.map(y=>({file:y,hash:W.getHashFile(y)})),R=(a||[]).map(y=>({file:y,hash:W.getHashFile(y)})),E=[...d,...R],g=Array.from(new Set(E.map(y=>y.hash))).map(y=>E.find(h=>h.hash===y)),T=g.filter(y=>d.some(h=>h.hash===y.hash));if(!T.length)return;let v=g.map(y=>y.file);s(v),r==null||r(m,v),o==null||o({value:T.map(y=>y.file),event:"ADD_FILES"})},[a,o,r,m]),C=(0,Q.useCallback)(u=>{if(!u){s(null);return}let d=u.filter(R=>!!R);f(d)},[f,s]);(0,Q.useEffect)(()=>{n({name:m,getValue:()=>a,setValue:(u,d)=>C(d||l),clearValue:()=>s(null)})},[m,n,a,C,l]),(0,Q.useEffect)(()=>{s(null)},[t]);function p(u){if(!a)return;let d=a.filter(R=>W.getHashFile(R)!==u);s(d),r==null||r(m,d),o==null||o({value:a.find(R=>W.getHashFile(R)===u),event:"REMOVE_FILE"})}function c(){let u=document.createElement("input");u.style.display="none",u.setAttribute("type","file"),u.setAttribute("accept","*/*"),u.setAttribute("id",String(Math.random())),u.setAttribute("multiple","multiple"),document.body.appendChild(u),u.addEventListener("change",()=>{u.files&&f(Array.from(u.files)),document.body.removeChild(u)});let d=new MouseEvent("click");u.dispatchEvent(d)}return(0,Ho.jsx)(Lo.Provider,{value:{handleSelectFile:c,handleSaveFiles:f,handleRemoveFile:p,accept:t,files:a,name:i},children:e})}function re(){let e=(0,Q.useContext)(Lo);if(!e)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var Ke={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=["|",",",";"," ",`
|
|
56
|
+
`," ","\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 Bo=require("@mobilestockweb/container"),ko=require("@mobilestockweb/spacer");var Ao=require("@unform/core"),Mo=require("@mobilestockweb/typography");var No=require("react/jsx-runtime");function qe(){let e=re(),{error:t}=(0,Ao.useField)(e.name);return(0,No.jsx)(Mo.Typography,{color:"DANGER",size:"XS",children:t})}var Oo=require("@mobilestockweb/button"),zo=require("react/jsx-runtime");function Ze(){return(0,zo.jsx)(Oo.Button,{type:"button",text:"Selecionar arquivo",size:"XS"})}var Ye=require("@mobilestockweb/typography");var pe=require("react/jsx-runtime");function Je(){var t,o;let e=re();return(t=e.accept)!=null&&t.includes("all")?(0,pe.jsx)(Ye.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(Ye.Typography,{size:"XS",children:"Arquivos suportados"}),(0,pe.jsxs)(Ye.Typography,{size:"XS",children:["( ",(o=e.accept)==null?void 0:o.join(", ")," )"]})]})}var Vo=require("@mobilestockweb/typography"),Do=require("react/jsx-runtime");function Qe({children:e}){return(0,Do.jsx)(Vo.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var ce=require("react/jsx-runtime");function _o(){var t;let e=re();return(0,ce.jsxs)(Bo.Container.Vertical,{align:"CENTER",children:[(0,ce.jsx)(Qe,{}),(0,ce.jsx)(ko.Spacer,{size:"2XS"}),(0,ce.jsx)(Ze,{}),(0,ce.jsx)(qe,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,ce.jsx)(Je,{})]})}var $o=L(require("chroma-js")),Uo=require("react"),Go=require("styled-components");var Wo=require("react/jsx-runtime");function Xo(e){let t=re(),o=(0,Go.useTheme)(),[i,r]=(0,Uo.useState)(!1);function m(n){var s;n.preventDefault(),r(!1);let l=n.dataTransfer;if(!l)return;let a=[];if(l.items&&l.items.length>0)for(let f=0;f<l.items.length;f++){let C=l.items[f];if(C.kind!=="file")continue;let p=C.webkitGetAsEntry();if(p&&p.isDirectory)continue;let c=C.getAsFile();c&&a.push(c)}else if(l.files&&l.files.length>0)for(let f=0;f<l.files.length;f++){let C=l.files.item(f);C&&a.push(C)}a.length!==0&&((s=t.accept)!=null&&s.some(f=>f!=="all")&&(a=a.filter(f=>{var p;let C=f.name.split(".").pop();return(p=t.accept)==null?void 0:p.includes(C==null?void 0:C.toLowerCase())}),!a.length)||t.handleSaveFiles(a))}return(0,Wo.jsx)("div",b({onDragOver:n=>{n.preventDefault(),r(!0)},onDrop:m,onDragLeave:n=>{n.preventDefault(),r(!1)},style:b({},i?{backgroundColor:(0,$o.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var Ko=require("react"),Ct=L(require("styled-components")),qo=require("@mobilestockweb/button"),Zo=require("@mobilestockweb/clickable"),de=require("@mobilestockweb/container"),Yo=require("@mobilestockweb/icons"),je=require("@mobilestockweb/typography");var k=require("react/jsx-runtime");function Jo(){var i,r,m;let e=re(),[t,o]=(0,Ko.useState)(!1);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(de.Container.Horizontal,{align:"END",children:!!((i=e.files)!=null&&i.length)&&(0,k.jsx)(Zo.Clickable,{type:"button","data-testid":"flip-button",onClick:()=>o(!t),children:(0,k.jsxs)(de.Container.Horizontal,{align:"CENTER",children:[(0,k.jsxs)(je.Typography,{size:"XS",children:[(r=e.files)==null?void 0:r.length," arquivos"]}),(0,k.jsx)(xn,{"data-testid":"flip-icon-container","data-flip":t,$flip:t,children:(0,k.jsx)(Yo.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,k.jsx)(Fn,{"data-testid":"multiple-archive-list","data-open":t,$flip:t,children:(m=e.files)==null?void 0:m.map((n,l)=>(0,k.jsxs)(de.Container.Horizontal,{align:"START_CENTER",children:[(0,k.jsxs)(de.Container.Horizontal,{gap:"SM",full:!0,children:[(0,k.jsx)(je.Typography,{size:"XS",weight:"MEDIUM",children:n.name.slice(0,20)}),n.size&&(0,k.jsx)(je.Typography,{size:"XS",children:Ke.convertBytesToReadableFormat(n.size)})]}),(0,k.jsx)(de.Container.Vertical,{children:(0,k.jsx)(qo.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS","data-testid":`trash-button-${l}`,onClick:()=>e.handleRemoveFile(`${n.name}-${n.size}`)})})]},l))})]})}var xn=(0,Ct.default)(de.Container.Horizontal)`
|
|
60
57
|
transform: ${({$flip:e})=>e?"rotate(180deg)":"rotate(0deg)"};
|
|
61
58
|
transition: transform 0.3s ease;
|
|
62
|
-
`,
|
|
59
|
+
`,Fn=(0,Ct.default)(de.Container.Vertical)`
|
|
63
60
|
display: ${({$flip:e})=>e?"flex":"none"};
|
|
64
61
|
max-height: 200px;
|
|
65
62
|
overflow-y: auto;
|
|
66
|
-
`;var
|
|
63
|
+
`;var Qo=require("@mobilestockweb/typography"),er=require("react/jsx-runtime");function jo({children:e}){return(0,er.jsx)(Qo.Typography,{children:e})}var ne=require("react/jsx-runtime");function nr(o){var i=o,{accept:e}=i,t=P(i,["accept"]);let{error:r}=(0,tr.useField)(t.name),m=(0,or.useMemo)(()=>Ke.parseAcceptString(e),[e]);return(0,ne.jsx)(wo,S(b({},t),{accept:m,children:(0,ne.jsxs)(et.Container.Vertical,{gap:"2XS",children:[(0,ne.jsx)(et.Container.Horizontal,{align:t.alignLabel||"START",children:(0,ne.jsx)(jo,{children:t.label})}),(0,ne.jsxs)(Rn,{$error:!!r,padding:"MD",children:[(0,ne.jsx)(Xo,{children:t.children||(0,ne.jsx)(_o,{})}),(0,ne.jsx)(Jo,{})]})]})}))}var Rn=(0,rr.default)(et.Container.Vertical)`
|
|
67
64
|
border: 1px solid ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.border};
|
|
68
65
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
69
66
|
background-color: ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.default};
|
|
70
67
|
min-width: 400px;
|
|
71
|
-
`;var
|
|
68
|
+
`;var ir=Object.assign(nr,{Title:Qe,HelpButton:Ze,HelpText:Je,ErrorLabel:qe});var G=require("@dnd-kit/core"),$r=require("@dnd-kit/modifiers"),ge=require("@dnd-kit/sortable"),Ie=require("react"),Ur=require("styled-components"),rt=require("@mobilestockweb/container");var ar=require("@unform/core"),$=require("react"),lr=require("styled-components");var mr=require("react/jsx-runtime"),sr=(0,$.createContext)(null);function ur({gap:e="2XS",size:t="SM",name:o,children:i,onChange:r,multiple:m,dragAndDrop:n,buttonAddDirection:l}){let a=(0,lr.useTheme)(),{notifyFieldChange:s}=B(),{fieldName:f,registerField:C,defaultValue:p}=(0,ar.useField)(o),[c,u]=(0,$.useState)(null),[d,R]=(0,$.useState)(!1),[E,g]=(0,$.useState)(null),T=(0,$.useMemo)(()=>a.sizeImage[t.toLowerCase()],[a,t]),v=(0,$.useMemo)(()=>a.gaps[e.toLowerCase()],[a,e]),y=(0,$.useCallback)(x=>{u(l==="RIGHT"?z=>{let _=[...z||[],...x].reverse();return s==null||s(f,_),_}:z=>{let _=[...z||[],...x];return s==null||s(f,_),_})},[u,l,s,f]),h=(0,$.useCallback)(x=>{if(!x){u(null);return}y(x)},[y]);(0,$.useEffect)(()=>{C({name:f,getValue:()=>c,setValue:(x,z)=>h(z||p),clearValue:()=>u(null)})},[f,C,c,h,p]);function H(){let x=document.createElement("input");x.style.display="none",x.setAttribute("type","file"),x.setAttribute("accept","image/*"),x.setAttribute("id",String(Math.random())),m&&x.setAttribute("multiple","multiple"),document.body.appendChild(x),x.addEventListener("change",()=>{x.files&&(m?y(Array.from(x.files)):(R(!0),g(Array.from(x.files)[0])),document.body.removeChild(x))});let z=new MouseEvent("click");x.dispatchEvent(z)}function A(x){if(!c)return;let z=c.filter(_=>`${_.name}-${_.size}`!==x);u(z),s==null||s(f,z),r==null||r({value:c.find(_=>`${_.name}-${_.size}`===x),event:"REMOVE_IMAGE"})}function D(x){u(x),s==null||s(f,x),r==null||r({value:x,event:"REORDER_IMAGES"})}function N(x){y([x]),R(!1),g(null),r==null||r({value:x,event:"CROP_SAVE"})}function O(){R(!1),g(null)}return(0,mr.jsx)(sr.Provider,{value:{showDeviceImage:H,images:c,removeImage:A,reorderImages:D,openImageCropModal:d,imageToCrop:E,handleImageCropCancel:O,handleImageCropSave:N,sizeComponent:T,gapComponent:v,dragAndDrop:n,name:o,gap:e},children:i})}function X(){let e=(0,$.useContext)(sr);if(!e)throw new Error("usePhotoList must be used within a PhotoListProvider");return e}var pr=require("@mobilestockweb/button");var cr=require("react/jsx-runtime");function Tt(){let e=X();return(0,cr.jsx)(pr.Button,{type:"button",icon:"Plus",variant:"OUTLINE",onClick:e.showDeviceImage,style:{height:e.sizeComponent,width:e.sizeComponent,minWidth:e.sizeComponent,maxWidth:e.sizeComponent}})}var dr=require("@unform/core"),fr=require("@mobilestockweb/typography");var hr=require("react/jsx-runtime");function gr(){let e=X(),{error:t}=(0,dr.useField)(e.name);return(0,hr.jsx)(fr.Typography,{color:"DANGER",size:"XS",children:t})}var Lr=require("@dnd-kit/sortable"),wr=require("@dnd-kit/utilities"),ot=require("react"),Hr=require("styled-components"),Ar=require("@mobilestockweb/container");var Er=require("@dnd-kit/sortable"),yr=L(require("styled-components")),Sr=require("@mobilestockweb/container");var br=require("@dnd-kit/sortable"),Cr=L(require("styled-components")),vr=require("react/jsx-runtime");function Tr({id:e}){let{isDragging:t}=(0,br.useSortable)({id:e});return(0,vr.jsx)(Pn,{$isDragging:t})}var Pn=Cr.default.div`
|
|
72
69
|
height: 5px;
|
|
73
70
|
width: 90%;
|
|
74
71
|
background-color: ${({theme:e,$isDragging:t})=>t?e.colors.formPhotoList.highlightBar:e.colors.formPhotoList.defaultBar};
|
|
75
|
-
`;var
|
|
72
|
+
`;var vt=require("react/jsx-runtime");function xr({id:e}){let t=X(),{listeners:o,attributes:i}=(0,Er.useSortable)({id:e});return(0,vt.jsx)(In,S(b(b({$sizeComponent:t.sizeComponent,align:"CENTER"},o),i),{children:(0,vt.jsx)(Tr,{id:e})}))}var In=(0,yr.default)(Sr.Container.Horizontal)`
|
|
76
73
|
padding: 4px 12px;
|
|
77
74
|
position: absolute;
|
|
78
75
|
bottom: 0;
|
|
79
76
|
width: ${({$sizeComponent:e})=>e};
|
|
80
77
|
background-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
|
|
81
|
-
`;var
|
|
78
|
+
`;var tt=L(require("styled-components")),Fr=require("@mobilestockweb/clickable"),Rr=require("@mobilestockweb/icons"),Pr=L(require("@mobilestockweb/tools"));var Et=require("react/jsx-runtime");function Ir({id:e}){let t=X(),o=(0,tt.useTheme)();function i(){t.removeImage(e)}return(0,Et.jsx)(Ln,{onClick:i,children:(0,Et.jsx)(Rr.Icon,{name:"X",size:"XS",color:Pr.default.defineTextColor(o.colors.formPhotoList.trashButton)})})}var Ln=(0,tt.default)(Fr.Clickable)`
|
|
82
79
|
position: absolute;
|
|
83
80
|
top: 0;
|
|
84
81
|
right: 0;
|
|
85
82
|
z-index: 1;
|
|
86
83
|
border-bottom-left-radius: 4px;
|
|
87
84
|
background-color: ${e=>e.theme.colors.formPhotoList.trashButton};
|
|
88
|
-
`;var
|
|
85
|
+
`;var Re=require("react/jsx-runtime");function wn({file:e}){let t=(0,Hr.useTheme)(),o=X(),{setNodeRef:i,transform:r,transition:m,isDragging:n}=(0,Lr.useSortable)({id:W.getHashFile(e)}),l=(0,ot.useMemo)(()=>URL.createObjectURL(e),[e]);return(0,Re.jsxs)(Ar.Container.Vertical,{ref:i,align:"CENTER",style:S(b({borderColor:t.colors.formPhotoList.controlBar,borderStyle:"solid",borderWidth:1},n&&{borderColor:t.colors.formPhotoList.highlightBar}),{transform:wr.CSS.Transform.toString(r),transition:m,zIndex:n?100:0,userSelect:"none",width:o.sizeComponent,minWidth:o.sizeComponent,maxWidth:o.sizeComponent,height:o.sizeComponent,flexShrink:0,backgroundColor:"white",position:"relative",borderRadius:t.borderRadius.default,overflow:"hidden"}),children:[(0,Re.jsx)(Ir,{id:W.getHashFile(e)}),(0,Re.jsx)("img",{alt:"image",style:{width:"100%",objectFit:"cover"},src:l}),o.dragAndDrop&&(0,Re.jsx)(xr,{id:W.getHashFile(e)})]})}var Mr=(0,ot.memo)(wn);var Nr=require("@mobilestockweb/typography"),zr=require("react/jsx-runtime");function Or({children:e}){return(0,zr.jsx)(Nr.Typography,{children:e})}var j=require("react"),kr=require("react-image-crop"),Pe=L(require("styled-components")),xt=require("@mobilestockweb/button"),Ee=require("@mobilestockweb/container");var fe=require("react"),yt=L(require("react-modal")),Vr=require("styled-components"),Dr=require("ua-parser-js");var St=require("react/jsx-runtime");function Br(o){var i=o,{children:e}=i,t=P(i,["children"]);let r=(0,Vr.useTheme)(),[m,n]=(0,fe.useState)(!1),[l,a]=(0,fe.useState)(void 0),s=(0,fe.useCallback)(()=>(0,Dr.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),f=(0,fe.useCallback)(()=>{n(s()),a(window.innerHeight)},[s]);return(0,fe.useEffect)(()=>(n(s()),a(window.innerHeight),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[s,f]),m?(0,St.jsx)(yt.default,S(b({ariaHideApp:!1,style:{content:{top:0,left:0,right:0,bottom:0,padding:0,margin:0,borderRadius:0,border:"none",height:l?`${l}px`:"100vh",maxHeight:l?`${l}px`:"100vh",boxSizing:"border-box"}}},t),{children:e})):(0,St.jsx)(yt.default,S(b({ariaHideApp:!1,style:{overlay:{backgroundColor:r.colors.container.shadow},content:{top:"50%",left:"50%",right:"auto",bottom:"auto",padding:0,margin:0,transform:"translate(-50%, -50%)",borderRadius:8,border:"none",width:"min(900px, 100vw - 32px)",height:"min(700px, 100vh - 32px)",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",boxSizing:"border-box"}}},t),{children:e}))}var K=require("react/jsx-runtime");function _r(){let e=X(),t=(0,j.useRef)(null),o=(0,j.useRef)(null),[i,r]=(0,j.useState)(),[m,n]=(0,j.useState)(),[l,a]=(0,j.useState)(),s=(0,j.useMemo)(()=>e.imageToCrop?URL.createObjectURL(e.imageToCrop):void 0,[e.imageToCrop]);(0,j.useEffect)(()=>{e.imageToCrop||(r(void 0),n(void 0),a(void 0))},[e.imageToCrop,e.openImageCropModal]);function f({displayWidth:c,displayHeight:u,naturalWidth:d,naturalHeight:R}){n({displayWidth:c,displayHeight:u,naturalWidth:d,naturalHeight:R});let E=Math.min(c,u);r({unit:"px",width:E,height:E,x:c>u?(c-E)/2:0,y:u>c?(u-E)/2:0})}function C(){return Ue(this,null,function*(){if(!e.imageToCrop||!i||!m)return;let c=m.naturalWidth/m.displayWidth,u=m.naturalHeight/m.displayHeight,d=i.x*c,R=i.y*u,E=i.width*c,g=i.height*u,T=new OffscreenCanvas(E,g),v=T.getContext("2d"),y=new Image;y.src=URL.createObjectURL(e.imageToCrop),yield new Promise(A=>{y.onload=()=>A()}),v.drawImage(y,d,R,E,g,0,0,E,g);let h=yield T.convertToBlob({type:"image/png",quality:1}),H="";if(!e.imageToCrop.name)H="image-cropped.png";else{let A=e.imageToCrop.name.split(".");A.pop(),H=A.join(".")+"-cropped.png"}e.handleImageCropSave(new File([h],H,{type:"image/png",lastModified:Date.now()}))})}function p(c){let u=c.currentTarget,d=o.current,R=d.clientWidth,E=d.clientHeight,g=u.naturalWidth,T=u.naturalHeight,v=Math.min(R/g,E/T),y=g*v,h=T*v;a({width:y,height:h}),f({displayWidth:y,displayHeight:h,naturalWidth:g,naturalHeight:T})}return(0,K.jsx)(Br,{isOpen:e.openImageCropModal,children:(0,K.jsxs)(Ee.Container.Vertical,{full:!0,padding:"NONE_XS_XS_XS",style:{height:"100%",maxHeight:"100%",boxSizing:"border-box"},gap:"MD",children:[(0,K.jsx)(Ee.Container.Vertical,{full:!0,align:"CENTER",style:{minHeight:0},children:(0,K.jsx)(Hn,{ref:o,align:"CENTER",children:(0,K.jsx)(An,{crop:i,width:l==null?void 0:l.width,height:l==null?void 0:l.height,onChange:c=>r(c),children:(0,K.jsx)(Mn,{src:s,ref:t,"data-testid":"image-to-crop",onLoad:p})})})}),(0,K.jsxs)(Ee.Container.Horizontal,{gap:"MD",children:[(0,K.jsx)(Ee.Container.Vertical,{full:!0,children:(0,K.jsx)(xt.Button,{onClick:e.handleImageCropCancel,text:"Cancelar",backgroundColor:"CANCEL_DARK"})}),(0,K.jsx)(Ee.Container.Vertical,{full:!0,children:(0,K.jsx)(xt.Button,{onClick:C,text:"Salvar"})})]})]})})}var Hn=(0,Pe.default)(Ee.Container.Vertical)`
|
|
89
86
|
width: 100%;
|
|
90
87
|
height: 100%;
|
|
91
88
|
min-height: 0;
|
|
92
89
|
padding-left: 16px;
|
|
93
90
|
padding-right: 16px;
|
|
94
|
-
`,
|
|
95
|
-
${({width:e,height:t})=>e&&t&&
|
|
91
|
+
`,An=(0,Pe.default)(kr.ReactCrop)`
|
|
92
|
+
${({width:e,height:t})=>e&&t&&Pe.css`
|
|
96
93
|
width: ${e}px;
|
|
97
94
|
height: ${t}px;
|
|
98
95
|
display: inline-flex;
|
|
99
96
|
`}
|
|
100
|
-
`,
|
|
97
|
+
`,Mn=Pe.default.img``;var U=require("react/jsx-runtime");function Gr({numberOfImagesVisible:e,buttonAddDirection:t,label:o,alignLabel:i}){var d,R;let r=X(),m=(0,Ur.useTheme)(),n=(0,G.useSensors)((0,G.useSensor)(G.MouseSensor),(0,G.useSensor)(G.TouchSensor),(0,G.useSensor)(G.KeyboardSensor,{coordinateGetter:ge.sortableKeyboardCoordinates})),[l,a]=(0,Ie.useState)(null),s=(0,Ie.useId)();function f(E){var T;return((T=r.images)==null?void 0:T.findIndex(v=>W.getHashFile(v)===E))||0}let C=l?f(l):-1;function p({over:E}){if(a(null),E){let g=f(E.id);if(C!==g){let T=(0,ge.arrayMove)(r.images,C,g);r.reorderImages(T)}}}function c({active:E}){E&&a(E.id)}let u=(0,Ie.useMemo)(()=>e?`calc(${r.sizeComponent} * ${e} + (${r.gapComponent} * ${e}))`:`calc(100% - ${r.sizeComponent} - ${r.gapComponent})`,[e,r.sizeComponent,r.gapComponent]);return(0,U.jsxs)(U.Fragment,{children:[!!o&&(0,U.jsx)(rt.Container.Horizontal,{align:i||"START",children:(0,U.jsx)(Or,{children:o})}),(0,U.jsx)(G.DndContext,{id:s,sensors:n,collisionDetection:G.closestCenter,onDragCancel:()=>a(null),onDragStart:c,onDragEnd:p,modifiers:[$r.restrictToHorizontalAxis],children:(0,U.jsxs)(rt.Container.Horizontal,{align:"START_CENTER",gap:r.gap,children:[t==="LEFT"&&(0,U.jsx)(Tt,{}),(0,U.jsx)(ge.SortableContext,{items:((d=r.images)==null?void 0:d.map(E=>W.getHashFile(E)))||[],strategy:ge.horizontalListSortingStrategy,children:(0,U.jsx)(rt.Container.Horizontal,{gap:r.gap,style:{flexBasis:"max-content",overflowX:"scroll",paddingBottom:m.spacing["2xs"],maxWidth:u},children:(R=r.images)==null?void 0:R.map(E=>(0,U.jsx)(Mr,{file:E},W.getHashFile(E)))})}),t==="RIGHT"&&(0,U.jsx)(Tt,{})]})}),(0,U.jsx)(gr,{}),(0,U.jsx)(_r,{})]})}var Ft=require("react/jsx-runtime");function Xr(m){var n=m,{label:e,alignLabel:t,buttonAddDirection:o="LEFT",numberOfImagesVisible:i=0}=n,r=P(n,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,Ft.jsx)(ur,S(b({multiple:!0,dragAndDrop:!0,buttonAddDirection:o},r),{children:(0,Ft.jsx)(Gr,{label:e,alignLabel:t,buttonAddDirection:o,numberOfImagesVisible:i})}))}var Wr=require("@unform/core"),Kr=require("react"),Pt=L(require("styled-components")),Rt=require("@mobilestockweb/container"),It=require("@mobilestockweb/typography");var ye=require("react/jsx-runtime");function qr(m){var n=m,{name:e,label:t,value:o,onChange:i}=n,r=P(n,["name","label","value","onChange"]);let{loading:l,notifyFieldChange:a}=B(),{error:s,fieldName:f,registerField:C}=(0,Wr.useField)(e),p=(0,Kr.useRef)(null),c=`radio_${e}_${t}`;function u(){C({name:f,ref:p,getValue:d=>d.current.value,clearValue:d=>{d.current.checked=!1}}),a==null||a(f,o),i==null||i({value:o,event:"RADIO_CHANGE"})}return(0,ye.jsxs)(Rt.Container.Vertical,{onClick:u,gap:"XS",padding:"2XS_NONE",children:[(0,ye.jsxs)(Rt.Container.Horizontal,{align:"START_CENTER",gap:"XS",children:[(0,ye.jsx)(Nn,S(b({id:c,ref:p},r),{type:"radio",disabled:l})),(0,ye.jsx)(On,{htmlFor:c,size:"MD",children:t})]}),s&&(0,ye.jsx)(It.Typography,{color:"DANGER",size:"SM",children:s})]})}var Nn=Pt.default.input`
|
|
101
98
|
width: 1rem;
|
|
102
99
|
height: 1rem;
|
|
103
|
-
`,
|
|
104
|
-
.react-select {
|
|
105
|
-
background-color: ${({$isWrong:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
|
|
106
|
-
border: 1px solid ${({$isWrong:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
|
|
107
|
-
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
108
|
-
height: 2.7rem;
|
|
109
|
-
width: 100%;
|
|
110
|
-
}
|
|
111
|
-
.react-select__control {
|
|
112
|
-
background-color: ${({$isWrong:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
|
|
113
|
-
border: none;
|
|
114
|
-
height: 100%;
|
|
115
|
-
}
|
|
116
|
-
.react-select__placeholder {
|
|
117
|
-
padding: 0.3rem;
|
|
118
|
-
}
|
|
119
|
-
.react-select__menu {
|
|
120
|
-
color: ${({theme:e})=>e.colors.select.text};
|
|
121
|
-
background-color: ${({theme:e})=>e.colors.select.default};
|
|
122
|
-
height: auto;
|
|
123
|
-
}
|
|
124
|
-
.react-select__option--is-focused {
|
|
125
|
-
color: ${({theme:e})=>e.colors.text.contrast};
|
|
126
|
-
background-color: ${({theme:e})=>e.colors.select.focused};
|
|
127
|
-
}
|
|
128
|
-
`,cn=(0,mt.default)(pt.Typography).attrs({forwardedAs:"label"})``;var Mr=require("@mobilestockweb/container");var wr=require("react/jsx-runtime");function Ar(o){var n=o,{children:e}=n,t=P(n,["children"]);return(0,wr.jsx)(Mr.Container.Vertical,v(h({gap:"SM"},t),{children:e}))}var dn=Object.assign(Tt,{Input:no,Radio:xr,Select:Nr,Button:yt,Counter:Qt,Vertical:Ar,Horizontal:eo,MultipleArchive:Vo,PhotoList:Fr});0&&(module.exports={Form,useForm});
|
|
100
|
+
`,On=(0,Pt.default)(It.Typography).attrs({forwardedAs:"label"})``;var Zr=require("@unform/core"),nt=L(require("chroma-js")),Lt=require("lodash"),ee=require("react"),Yr=L(require("react-select")),it=L(require("styled-components")),Jr=require("@mobilestockweb/container"),wt=require("@mobilestockweb/typography");var Le=require("react/jsx-runtime"),Qr=(0,ee.forwardRef)(function({name:t,label:o,options:i,placeholder:r="Selecione um item",disabled:m,defaultValue:n,onChange:l,autoFocus:a,onFocus:s,onBlur:f},C){let p=(0,it.useTheme)(),{loading:c,notifyFieldChange:u}=B(),{fieldName:d,defaultValue:R,registerField:E,error:g}=(0,Zr.useField)(t),T=(0,ee.useRef)(null);(0,ee.useImperativeHandle)(C,()=>({focus(){var h;(h=T.current)==null||h.focus()},blur(){var h;(h=T.current)==null||h.blur()}})),(0,ee.useEffect)(()=>{E({name:d,ref:T.current,getValue:h=>{var A,D,N;let H=((N=(D=(A=h==null?void 0:h.state)==null?void 0:A.selectValue)==null?void 0:D[0])==null?void 0:N.value)||"";return u==null||u(d,H),l==null||l({value:H,event:"SELECT_CHANGE"}),H}})},[d,E,l]);let v=(0,ee.useCallback)(h=>function(H){return(0,Lt.mergeWith)(H,{fontFamily:p.font.families,lineHeight:p.font.lineHeight,color:p.colors.text.default},h)},[]),y=(0,ee.useCallback)((h,H)=>{let A="transparent",D=p.colors.text.default;switch(!0){case H.isFocused:{let N=(0,nt.default)(p.colors.listItem.hover);N.luminance()>.5?A=N.brighten(1).hex("rgb"):A=N.hex("rgb");let O=(0,nt.default)(A);D=O.luminance(O.luminance()>.5?-2:2).hex("rgb");break}case H.isSelected:{A=p.colors.listItem.selected;let N=(0,nt.default)(A);D=N.luminance(N.luminance()>.5?-2:2).hex("rgb");break}}return(0,Lt.mergeWith)(h,{fontFamily:p.font.families,lineHeight:p.font.lineHeight,color:D,backgroundColor:A})},[]);return(0,Le.jsxs)(Jr.Container.Vertical,{children:[o&&(0,Le.jsx)(zn,{htmlFor:d,size:"MD",children:o}),(0,Le.jsx)(Yr.default,{defaultValue:n||R,options:[{label:r,options:i}],placeholder:r,menuPortalTarget:document.body,menuPosition:"fixed",styles:{container:v({width:"100%",display:"flex",height:"3rem"}),control:v({width:"100%",backgroundColor:g?p.colors.input.error:void 0,borderColor:g?p.colors.alert.urgent:void 0}),indicatorSeparator:v({backgroundColor:g?p.colors.alert.urgent:void 0}),dropdownIndicator:v({color:g?p.colors.alert.urgent:p.colors.text.default}),option:y,menuPortal:v({zIndex:99999})},openMenuOnFocus:!0,ref:T,isDisabled:c||m,autoFocus:a,onFocus:s,onBlur:f}),g&&(0,Le.jsx)(wt.Typography,{color:"DANGER",size:"SM",children:g})]})}),zn=(0,it.default)(wt.Typography).attrs({forwardedAs:"label"})``;var jr=require("@mobilestockweb/container");var tn=require("react/jsx-runtime");function en(o){var i=o,{children:e}=i,t=P(i,["children"]);return(0,tn.jsx)(jr.Container.Vertical,S(b({gap:"SM"},t),{children:e}))}var Vn=Object.assign($t,{Input:Po,Radio:qr,Select:Qr,Button:Gt,Counter:Eo,Vertical:en,Horizontal:So,MultipleArchive:ir,PhotoList:Xr});0&&(module.exports={Form,useForm});
|