@mobilestockweb/form 1.1.0 → 1.3.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 +136 -29
- package/index.js +69 -34
- package/package.json +8 -7
package/index.d.ts
CHANGED
|
@@ -1,14 +1,75 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TypographyProps } from '@mobilestockweb/typography';
|
|
3
|
+
import { DefaultTheme } from 'styled-components';
|
|
4
|
+
import { IconName } from '@mobilestockweb/icons';
|
|
2
5
|
import * as react from 'react';
|
|
3
6
|
import { ReactNode, InputHTMLAttributes, RefObject } from 'react';
|
|
4
7
|
import { BadgeType } from '@mobilestockweb/badge';
|
|
5
8
|
import { ButtonProps } from '@mobilestockweb/button';
|
|
9
|
+
import { GroupBase, Props } from 'react-select';
|
|
6
10
|
import { FormHandles, FormProps } from '@unform/core';
|
|
7
11
|
import { ViewBaseProps } from '@mobilestockweb/container';
|
|
8
|
-
import { DefaultTheme } from 'styled-components';
|
|
9
|
-
import { GroupBase, Props } from 'react-select';
|
|
10
12
|
import { ZodSchema } from 'zod';
|
|
11
13
|
|
|
14
|
+
declare function Error({ children }: {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
17
|
+
|
|
18
|
+
declare function Label({ children, ...rest }: TypographyProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
declare function Toggle(): react_jsx_runtime.JSX.Element;
|
|
21
|
+
|
|
22
|
+
type SwitchEventName = 'TOGGLE' | 'EDIT';
|
|
23
|
+
type LabelPosition = 'TOP_START' | 'TOP_CENTER' | 'TOP_END' | 'LEFT' | 'RIGHT';
|
|
24
|
+
|
|
25
|
+
type SwitchColor = Uppercase<keyof DefaultTheme['colors']['switch'] & string>;
|
|
26
|
+
type SwitchSize = Uppercase<keyof DefaultTheme['sizeSwitch'] & string>;
|
|
27
|
+
interface SwitchRootProps {
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
name: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
defaultValue?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @default 'TOP_START'
|
|
35
|
+
* @description Position of the label relative to the switch.
|
|
36
|
+
*/
|
|
37
|
+
labelPosition?: LabelPosition;
|
|
38
|
+
/**
|
|
39
|
+
* @default 'ON'
|
|
40
|
+
* @description Color of the switch when checked, based on theme.colors.switch tokens.
|
|
41
|
+
*/
|
|
42
|
+
checkedColor?: Exclude<SwitchColor, 'OFF' | 'HANDLE'>;
|
|
43
|
+
/**
|
|
44
|
+
* @default 'OFF'
|
|
45
|
+
* @description Background color of the switch when unchecked, based on theme.colors.switch tokens.
|
|
46
|
+
*/
|
|
47
|
+
backgroundColor?: Exclude<SwitchColor, 'ON' | 'HANDLE'>;
|
|
48
|
+
/**
|
|
49
|
+
* @default 'HANDLE'
|
|
50
|
+
* @description Color of the switch handle (circle), based on theme.colors.switch tokens.
|
|
51
|
+
*/
|
|
52
|
+
handleColor?: Exclude<SwitchColor, 'ON' | 'OFF'>;
|
|
53
|
+
/**
|
|
54
|
+
* @default 'MD'
|
|
55
|
+
* @description Size of the switch toggle.
|
|
56
|
+
*/
|
|
57
|
+
size?: SwitchSize;
|
|
58
|
+
/**
|
|
59
|
+
* @description Icons to display inside the handle, reactive to the switch state.
|
|
60
|
+
*/
|
|
61
|
+
icons?: {
|
|
62
|
+
on?: IconName;
|
|
63
|
+
off?: IconName;
|
|
64
|
+
};
|
|
65
|
+
onChange?(data: {
|
|
66
|
+
value: boolean;
|
|
67
|
+
event: SwitchEventName;
|
|
68
|
+
}): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare function SwitchRoot({ children, ...props }: SwitchRootProps): react_jsx_runtime.JSX.Element;
|
|
72
|
+
|
|
12
73
|
declare function ErrorLabel(): react_jsx_runtime.JSX.Element;
|
|
13
74
|
|
|
14
75
|
declare function HelpText(): react_jsx_runtime.JSX.Element;
|
|
@@ -128,19 +189,56 @@ interface CounterRootProps {
|
|
|
128
189
|
value: number;
|
|
129
190
|
event: CounterEventName;
|
|
130
191
|
}): void;
|
|
192
|
+
autoFocus?: boolean;
|
|
193
|
+
onFocus?(): void;
|
|
194
|
+
onBlur?(): void;
|
|
131
195
|
}
|
|
132
196
|
|
|
133
197
|
declare function CounterRoot({ children, ...props }: CounterRootProps): react_jsx_runtime.JSX.Element;
|
|
134
198
|
|
|
199
|
+
interface CustomOption {
|
|
200
|
+
label: string;
|
|
201
|
+
value: string;
|
|
202
|
+
}
|
|
203
|
+
interface SelectProps<Option extends CustomOption, IsMulti extends boolean, Group extends GroupBase<Option>> extends Omit<Props<Option, IsMulti, Group>, 'isDisabled' | 'onChange'> {
|
|
204
|
+
name: string;
|
|
205
|
+
disabled?: boolean;
|
|
206
|
+
label?: string;
|
|
207
|
+
onChange?(payload: {
|
|
208
|
+
value: CustomOption['value'];
|
|
209
|
+
event: 'SELECT_CHANGE';
|
|
210
|
+
}): void;
|
|
211
|
+
}
|
|
212
|
+
interface SelectRef {
|
|
213
|
+
focus(): void;
|
|
214
|
+
blur(): void;
|
|
215
|
+
}
|
|
216
|
+
interface FormSelectPropsBase extends SelectProps<CustomOption, false, GroupBase<CustomOption>> {
|
|
217
|
+
name: string;
|
|
218
|
+
options: CustomOption[];
|
|
219
|
+
disabled?: boolean;
|
|
220
|
+
placeholder?: string;
|
|
221
|
+
defaultValue?: CustomOption;
|
|
222
|
+
label?: string;
|
|
223
|
+
autoFocus?: boolean;
|
|
224
|
+
onFocus?(): void;
|
|
225
|
+
onBlur?(): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
135
228
|
type InputType = 'text' | 'password' | 'tel' | 'email' | 'number' | 'url' | 'zipcode' | 'hidden';
|
|
136
|
-
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
229
|
+
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> {
|
|
137
230
|
name: string;
|
|
138
231
|
label?: string;
|
|
139
232
|
type?: InputType;
|
|
140
233
|
autoSubmit?: boolean;
|
|
141
234
|
full?: boolean;
|
|
142
|
-
|
|
235
|
+
showMaxContent?: boolean;
|
|
236
|
+
numberOfLines?: number;
|
|
143
237
|
format?(value: string): string;
|
|
238
|
+
onChange?(payload: {
|
|
239
|
+
value: unknown;
|
|
240
|
+
event: 'INPUT_CHANGE' | 'AUTO_SUBMIT' | 'TOGGLE_PASSWORD';
|
|
241
|
+
}): void;
|
|
144
242
|
}
|
|
145
243
|
interface InputRef {
|
|
146
244
|
focus(): void;
|
|
@@ -206,46 +304,50 @@ interface PhotoInputProps extends Omit<PhotoListProviderProps, 'children'> {
|
|
|
206
304
|
}
|
|
207
305
|
declare function FormPhotoList({ label, alignLabel, buttonAddDirection, numberOfImagesVisible, ...props }: PhotoInputProps): react_jsx_runtime.JSX.Element;
|
|
208
306
|
|
|
209
|
-
interface PropsFormInputRadio extends InputHTMLAttributes<HTMLInputElement> {
|
|
307
|
+
interface PropsFormInputRadio extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
210
308
|
name: string;
|
|
211
309
|
label: string;
|
|
212
310
|
value: string;
|
|
311
|
+
onChange?(payload: {
|
|
312
|
+
value: string;
|
|
313
|
+
event: 'RADIO_CHANGE';
|
|
314
|
+
}): void;
|
|
213
315
|
}
|
|
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' | 'isMulti'> {
|
|
221
|
-
name: string;
|
|
222
|
-
disabled?: boolean;
|
|
223
|
-
label?: string;
|
|
224
|
-
}
|
|
225
|
-
interface FormSelectPropsBase extends SelectProps<CustomOption, false, GroupBase<CustomOption>> {
|
|
226
|
-
name: string;
|
|
227
|
-
options: CustomOption[];
|
|
228
|
-
disabled?: boolean;
|
|
229
|
-
placeholder?: string;
|
|
230
|
-
defaultValue?: CustomOption;
|
|
231
|
-
label?: string;
|
|
232
|
-
}
|
|
233
|
-
declare function FormSelect({ name, label, options, placeholder, disabled, defaultValue: defaultValueSelect, ...rest }: FormSelectPropsBase): react_jsx_runtime.JSX.Element;
|
|
316
|
+
declare function FormRadio({ name, label, value, onChange, ...props }: PropsFormInputRadio): react_jsx_runtime.JSX.Element;
|
|
234
317
|
|
|
235
318
|
declare function FormVertical({ children, ...props }: ViewBaseProps): react_jsx_runtime.JSX.Element;
|
|
236
319
|
|
|
237
|
-
interface FormPropsWithHandler<T extends object> extends FormProps {
|
|
238
|
-
onSubmit(params: SubmitParams<T>): Promise<void> | void;
|
|
320
|
+
interface FormPropsWithHandler<T extends object> extends Omit<FormProps, 'onSubmit'> {
|
|
321
|
+
onSubmit?(params: SubmitParams<T>): Promise<void> | void;
|
|
322
|
+
onBeforeSubmit?(params: {
|
|
323
|
+
data: T;
|
|
324
|
+
}): Promise<boolean> | boolean;
|
|
325
|
+
onAfterSubmit?(params: {
|
|
326
|
+
data: T;
|
|
327
|
+
}): Promise<void> | void;
|
|
239
328
|
schema?: ZodSchema<T>;
|
|
329
|
+
name?: string;
|
|
240
330
|
}
|
|
241
331
|
interface PropsContext {
|
|
242
332
|
submitForm(): void;
|
|
243
333
|
clearForm(): void;
|
|
244
334
|
formRef: RefObject<FormHandles>;
|
|
245
335
|
loading?: boolean;
|
|
336
|
+
notifyFieldChange(fieldName: string, fieldValue: unknown): void;
|
|
337
|
+
}
|
|
338
|
+
declare function FormComponent<T extends object>({ children, onSubmit, onBeforeSubmit, onAfterSubmit, schema, name: formName, ...props }: FormPropsWithHandler<T>): react_jsx_runtime.JSX.Element;
|
|
339
|
+
|
|
340
|
+
interface UseFormReturn<T extends object> {
|
|
341
|
+
readonly values: T;
|
|
342
|
+
getValue<K extends keyof T & string>(name: K): T[K] | undefined;
|
|
343
|
+
setValue<K extends keyof T & string>(name: K, value: T[K]): void;
|
|
344
|
+
submit(): void;
|
|
345
|
+
clear(): void;
|
|
346
|
+
setErrors(errors: Record<string, string>): void;
|
|
347
|
+
reset(data?: Partial<T>): void;
|
|
246
348
|
}
|
|
247
349
|
declare function useForm(): PropsContext;
|
|
248
|
-
declare function
|
|
350
|
+
declare function useForm<T extends object>(name: string): UseFormReturn<T>;
|
|
249
351
|
|
|
250
352
|
interface SubmitParams<T extends object> {
|
|
251
353
|
data: T;
|
|
@@ -255,7 +357,7 @@ interface SubmitParams<T extends object> {
|
|
|
255
357
|
declare const Form: typeof FormComponent & {
|
|
256
358
|
Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<InputRef>>;
|
|
257
359
|
Radio: typeof FormRadio;
|
|
258
|
-
Select:
|
|
360
|
+
Select: react.ForwardRefExoticComponent<FormSelectPropsBase & react.RefAttributes<SelectRef>>;
|
|
259
361
|
Button: typeof FormButton;
|
|
260
362
|
Counter: typeof CounterRoot & {
|
|
261
363
|
Display: typeof Display;
|
|
@@ -272,6 +374,11 @@ declare const Form: typeof FormComponent & {
|
|
|
272
374
|
ErrorLabel: typeof ErrorLabel;
|
|
273
375
|
};
|
|
274
376
|
PhotoList: typeof FormPhotoList;
|
|
377
|
+
Switch: typeof SwitchRoot & {
|
|
378
|
+
Toggle: typeof Toggle;
|
|
379
|
+
Label: typeof Label;
|
|
380
|
+
Error: typeof Error;
|
|
381
|
+
};
|
|
275
382
|
};
|
|
276
383
|
|
|
277
384
|
export { Form, type SubmitParams, useForm };
|
package/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var zn=Object.create;var _e=Object.defineProperty,Vn=Object.defineProperties,kn=Object.getOwnPropertyDescriptor,Bn=Object.getOwnPropertyDescriptors,_n=Object.getOwnPropertyNames,Je=Object.getOwnPropertySymbols,$n=Object.getPrototypeOf,bt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var Wt=(e,t,o)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))bt.call(t,o)&&Wt(e,o,t[o]);if(Je)for(var o of Je(t))Kt.call(t,o)&&Wt(e,o,t[o]);return e},y=(e,t)=>Vn(e,Bn(t));var w=(e,t)=>{var o={};for(var r in e)bt.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&Je)for(var r of Je(e))t.indexOf(r)<0&&Kt.call(e,r)&&(o[r]=e[r]);return o};var Un=(e,t)=>{for(var o in t)_e(e,o,{get:t[o],enumerable:!0})},qt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _n(t))!bt.call(e,n)&&n!==o&&_e(e,n,{get:()=>t[n],enumerable:!(r=kn(t,n))||r.enumerable});return e};var N=(e,t,o)=>(o=e!=null?zn($n(e)):{},qt(t||!e||!e.__esModule?_e(o,"default",{value:e,enumerable:!0}):o,e)),Gn=e=>qt(_e({},"__esModule",{value:!0}),e);var Qe=(e,t,o)=>new Promise((r,n)=>{var u=i=>{try{l(o.next(i))}catch(s){n(s)}},a=i=>{try{l(o.throw(i))}catch(s){n(s)}},l=i=>i.done?r(i.value):Promise.resolve(i.value).then(u,a);l((o=o.apply(e,t)).next())});var yi={};Un(yi,{Form:()=>vi,useForm:()=>A});module.exports=Gn(yi);var ro=require("@mobilestockweb/button");var Te=require("react");var Qt=require("@unform/web"),jt=require("notistack"),re=require("react"),eo=require("zod"),to=require("@mobilestockweb/container");var $e=new Map;function Ct(e){let t=$e.get(e);return t||(t={formRef:null,values:{},watchedFields:new Set,listeners:new Set},$e.set(e,t)),t}function Zt(e,t){let o=Ct(e);o.formRef=t}function Yt(e){let t=$e.get(e);t&&(t.formRef=null,t.values={},t.watchedFields.clear(),t.listeners.clear(),$e.delete(e))}function Jt(e,t,o){let r=$e.get(e);!r||!r.watchedFields.has(t)||r.values[t]===o||(r.values=y(T({},r.values),{[t]:o}),r.listeners.forEach(n=>n()))}var je=require("react/jsx-runtime"),Tt=(0,re.createContext)({});function oo(l){var i=l,{children:e,onSubmit:t,onBeforeSubmit:o,onAfterSubmit:r,schema:n,name:u}=i,a=w(i,["children","onSubmit","onBeforeSubmit","onAfterSubmit","schema","name"]);let s=(0,re.useRef)(null),[f,b]=(0,re.useState)(!1);(0,re.useEffect)(()=>u?(Zt(u,s),()=>Yt(u)):()=>{},[u]);let m=(0,re.useCallback)((h,C)=>{u&&Jt(u,h,C)},[u]);function d(){var h;(h=s.current)==null||h.submitForm()}function c(){var h,C;(h=s.current)==null||h.setErrors({}),(C=s.current)==null||C.reset()}function g(h){let C={};for(let E of h){let S=E.path.filter(p=>typeof p=="string"||typeof p=="number").join(".");S&&(C[String(S)]=E.message)}return C}function P(h){if(h instanceof eo.ZodError)return g(h.issues);if(typeof h=="object"&&h!==null&&"errors"in h){let C=h.errors;if(Array.isArray(C)&&C.length>0&&"message"in C[0]&&"path"in C[0])return g(C)}return null}function v(E,S){return Qe(this,arguments,function*(h,{reset:C}){var p,F,H,k,M;if((p=s.current)==null||p.setErrors({}),n){let D=n.safeParse(h);if(!D.success){(F=s.current)==null||F.setErrors(g(D.error.issues));return}}if(!(o&&(yield o({data:h}))===!1))try{b(!0),yield t==null?void 0:t({data:h,ref:s,reset:C}),yield r==null?void 0:r({data:h})}catch(D){let R=P(D);if(R)(H=s.current)==null||H.setErrors(R);else{let z="Erro ao realizar opera\xE7\xE3o",$=500;if(typeof D=="object"&&D!==null&&"isAxiosError"in D&&D.isAxiosError){let We=D;$=((k=We.response)==null?void 0:k.status)||500;let Fe=(M=We.response)==null?void 0:M.data;Fe!=null&&Fe.message&&(z=Fe.message)}else D instanceof Error&&(z=D.message||z);(0,jt.enqueueSnackbar)(z,{variant:$>=500?"error":"warning"})}}finally{b(!1)}})}return(0,je.jsx)(Tt.Provider,{value:{formRef:s,submitForm:d,clearForm:c,loading:f,notifyFieldChange:m},children:(0,je.jsx)(Qt.Form,y(T({},a),{ref:s,onSubmit:v,children:(0,je.jsx)(to.Container.Vertical,{gap:"2XS",children:e})}))})}var Xn={};function A(e){let t=(0,Te.useContext)(Tt),o=e?Ct(e):null,r=(0,Te.useCallback)(a=>o?(o.listeners.add(a),()=>{o.listeners.delete(a)}):()=>{},[o]),n=(0,Te.useCallback)(()=>o?o.values:Xn,[o]),u=(0,Te.useSyncExternalStore)(r,n);return!e||!o?t:{get values(){var a,l,i;return(i=(l=(a=o.formRef)==null?void 0:a.current)==null?void 0:l.getData())!=null?i:{}},getValue(a){var l,i;return o.watchedFields.add(a),a in u?u[a]:(i=(l=o.formRef)==null?void 0:l.current)==null?void 0:i.getFieldValue(a)},setValue(a,l){var i,s;(s=(i=o.formRef)==null?void 0:i.current)==null||s.setFieldValue(a,l)},submit(){var a,l;(l=(a=o.formRef)==null?void 0:a.current)==null||l.submitForm()},clear(){var a,l,i,s;(l=(a=o.formRef)==null?void 0:a.current)==null||l.setErrors({}),(s=(i=o.formRef)==null?void 0:i.current)==null||s.reset()},setErrors(a){var l,i;(i=(l=o.formRef)==null?void 0:l.current)==null||i.setErrors(a)},reset(a){var l,i;(i=(l=o.formRef)==null?void 0:l.current)==null||i.reset(a)}}}var io=require("react/jsx-runtime");function no(u){var a=u,{type:e="SUBMIT",disabled:t,isLoading:o,onClick:r}=a,n=w(a,["type","disabled","isLoading","onClick"]);let{submitForm:l,clearForm:i,loading:s}=A();function f(b){switch(b.preventDefault(),e){case"SUBMIT":l();break;case"RESET":i();break;default:r==null||r(b)}}return(0,io.jsx)(ro.Button,y(T({},n),{onClick:f,isLoading:e==="SUBMIT"&&s||o,disabled:s||o||t,type:e.toLowerCase()}))}var Et=N(require("styled-components")),fo=require("@mobilestockweb/badge"),go=require("@mobilestockweb/container"),ho=N(require("@mobilestockweb/tools")),bo=require("@mobilestockweb/typography");var ao=require("@unform/core"),J=require("react");var uo=require("react/jsx-runtime"),lo=(0,J.createContext)(void 0);function so(e){let{notifyFieldChange:t}=A(),{fieldName:o,registerField:r,error:n,defaultValue:u}=(0,ao.useField)(e.name),[a,l]=(0,J.useState)(0),i=(0,J.useCallback)(m=>{let d=m;return e.maxCount!==void 0&&d>e.maxCount&&(d=e.maxCount),e.minCount!==void 0&&d<e.minCount&&(d=e.minCount),d},[e.maxCount,e.minCount]),s=(0,J.useCallback)((m,d=!0)=>{var g;let c=i(m);l(c),t==null||t(o,c),d&&((g=e.onChange)==null||g.call(e,{value:c,event:"EDIT"}))},[i,t,o]);(0,J.useEffect)(()=>{r({name:o,getValue:()=>a,setValue:(m,d)=>s(d),clearValue:()=>s(0)})},[o,a,r,s]),(0,J.useEffect)(()=>{s(Number(e.initialCount)||Number(u)||0,!1)},[e.initialCount,s,u]);function f(m=1){l(d=>{var g;let c=i(d+1*m);return t==null||t(o,c),(g=e.onChange)==null||g.call(e,{value:c,event:"INCREMENT"}),c})}function b(m=1){l(d=>{var g;let c=i(d-1*m);return t==null||t(o,c),(g=e.onChange)==null||g.call(e,{value:c,event:"DECREMENT"}),c})}return(0,uo.jsx)(lo.Provider,{value:{count:a,increment:f,decrement:b,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:n,autoFocus:e.autoFocus,onFocus:e.onFocus,onBlur:e.onBlur},children:e.children})}function Q(){let e=(0,J.useContext)(lo);if(!e)throw new Error("useCounter must be used within a CounterProvider");return e}var co=N(require("styled-components")),mo=require("@mobilestockweb/container");var po=require("react/jsx-runtime");function Ee(e){return(0,po.jsx)(Wn,T({align:"CENTER"},e))}var Wn=(0,co.default)(mo.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 Ue=require("react/jsx-runtime");function Ge(e){let{groupElements:t}=Q();return(0,Ue.jsx)(Ee,{children:t&&e.renderInsidePill?(0,Ue.jsx)(Kn,{$type:e.type,full:!0,align:"CENTER",children:(0,Ue.jsx)(qn,{$type:e.type,children:e.text})}):(0,Ue.jsx)(fo.Badge,{text:e.text,type:e.type,size:"XS"})})}function Co(e,t){return Object.keys(t.colors.badge).find(o=>o.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var Kn=(0,Et.default)(go.Container.Vertical)`
|
|
6
|
+
background-color: ${({$type:e,theme:t})=>{let o=Co(e,t);return t.colors.badge[o]}};
|
|
7
7
|
width: 100%;
|
|
8
|
-
`,
|
|
9
|
-
color: ${({$type:e,theme:t})=>{let o=
|
|
10
|
-
`;
|
|
8
|
+
`,qn=(0,Et.default)(bo.Typography)`
|
|
9
|
+
color: ${({$type:e,theme:t})=>{let o=Co(e,t);return ho.default.defineTextColor(t.colors.badge[o])}};
|
|
10
|
+
`;Ge.displayName="Form.FormCounter.Badge";var se=require("react"),j=require("@mobilestockweb/container"),xo=N(require("@mobilestockweb/tools"));var Xe=N(require("styled-components")),To=require("@mobilestockweb/container");var Eo=require("react/jsx-runtime");function we(o){var r=o,{children:e}=r,t=w(r,["children"]);let{groupElements:n,error:u}=Q();return(0,Eo.jsx)(Zn,y(T({align:"CENTER",$groupElements:n,$error:!!u},t),{children:e}))}var Zn=(0,Xe.default)(To.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&&Xe.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&&Xe.css`
|
|
21
21
|
background-color: ${t.colors.input.error};
|
|
22
22
|
border: 1px solid ${t.colors.alert.urgent};
|
|
23
23
|
`}
|
|
24
|
-
`;var
|
|
24
|
+
`;var vo=require("@mobilestockweb/typography"),yo=require("react/jsx-runtime");function le({children:e}){return(0,yo.jsx)(vo.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var So=require("@mobilestockweb/typography"),Ro=require("react/jsx-runtime");function me({children:e}){return(0,Ro.jsx)(So.Typography,{weight:"REGULAR",children:e})}var L=require("react/jsx-runtime");function Po({children:e}){let{label:t,error:o,labelPosition:r}=Q(),n=[],u=[],a=(0,se.useCallback)(i=>(0,se.isValidElement)(i)&&i.type===se.Fragment?a(i.props.children):i,[]),l=a(e);return se.Children.toArray(l).forEach(i=>{(0,se.isValidElement)(i)&&xo.default.isComponentWithDisplayName(i.type)&&i.type.displayName===Ge.displayName&&!i.props.renderInsidePill?n.push(i):u.push(i)}),(0,L.jsxs)(j.Container.Vertical,{align:"CENTER_START",children:[r==="TOP_START"&&t&&(0,L.jsxs)(j.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,L.jsx)(me,{children:t}),o&&!n.length&&(0,L.jsx)(le,{children:o})]}),r!=="LEFT"&&(0,L.jsxs)(j.Container.Vertical,{align:"CENTER",children:[(r!=="TOP_START"&&t||r!=="TOP_START"&&o&&!n.length)&&(0,L.jsxs)(j.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[t&&(0,L.jsx)(me,{children:t}),o&&!n.length&&(0,L.jsx)(le,{children:o})]}),(0,L.jsxs)(j.Container.Horizontal,{align:"CENTER_START",children:[n.length>0&&(0,L.jsx)(j.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:n}),(0,L.jsxs)(j.Container.Vertical,{children:[(0,L.jsx)(we,{children:u}),o&&!!n.length&&(0,L.jsx)(le,{children:o})]})]})]}),r==="LEFT"&&(0,L.jsx)(j.Container.Vertical,{children:(0,L.jsxs)(j.Container.Horizontal,{align:"CENTER",children:[(0,L.jsxs)(j.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[t&&(0,L.jsx)(me,{children:t}),o&&!n.length&&(0,L.jsx)(le,{children:o})]}),n.length>0&&(0,L.jsx)(j.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:n}),(0,L.jsx)(we,{children:u})]})})]})}var pe=require("@mobilestockweb/container");var et=require("react"),Fo=N(require("styled-components")),wo=require("@mobilestockweb/button");var vt=require("react/jsx-runtime");function ue(r){var n=r,{type:e,disabled:t}=n,o=w(n,["type","disabled"]);let{loading:u}=A(),a=Q(),l=(0,et.useRef)(null),i=(0,et.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 s(){e==="PLUS"?a.increment():a.decrement()}function f(){l.current=setTimeout(()=>{"vibrate"in navigator&&navigator.vibrate(500),e==="PLUS"?a.increment(a.multiplier):a.decrement(a.multiplier)},500)}function b(){l.current&&(clearTimeout(l.current),l.current=null)}return(0,vt.jsx)(Ee,{children:(0,vt.jsx)(Yn,y(T({type:"button",icon:e==="PLUS"?"Plus":"Minus",backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},o),{size:"SM",variant:a.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:a.groupElements,disabled:i||t||u,onClick:s,onMouseDown:f,onMouseUp:b,onMouseLeave:b,onTouchStart:f,onTouchEnd:b}))})}var Yn=(0,Fo.default)(wo.Button)`
|
|
25
25
|
border-radius: ${({$grouped:e,theme:t})=>e?t.borderRadius.none:t.borderRadius.default};
|
|
26
|
-
`;var
|
|
26
|
+
`;var ve=require("react"),No=N(require("styled-components")),Io=require("@mobilestockweb/clickable"),yt=require("@mobilestockweb/container"),St=require("@mobilestockweb/typography");var ce=require("react/jsx-runtime");function Ne(){let{count:e,editable:t,configureCount:o,autoFocus:r,onFocus:n,onBlur:u}=Q(),a=(0,ve.useRef)(null),[l,i]=(0,ve.useState)(r&&t),[s,f]=(0,ve.useState)(e.toString());(0,ve.useEffect)(()=>{f(e.toString())},[e]);function b(c){let g=Number(c.target.value);o(Number.isNaN(g)?0:g),i(!1),u==null||u()}function m(c){var g;c.key==="Enter"&&(c.preventDefault(),(g=a.current)==null||g.blur())}function d(c){c.target.select(),n==null||n()}return t?(0,ce.jsx)(Io.Clickable,{onClick:()=>i(!0),type:"button",children:(0,ce.jsx)(yt.Container.Horizontal,{padding:"NONE_2XS",children:(0,ce.jsx)(Ee,{children:l?(0,ce.jsx)(Jn,{"data-testid":"counter-input",ref:a,value:s,autoFocus:!0,onKeyDown:m,type:"text",inputMode:"numeric",onChange:c=>f(c.target.value),onFocus:d,onBlur:b}):(0,ce.jsx)(St.Typography,{weight:"BOLD",size:"LG",children:e})})})}):(0,ce.jsx)(yt.Container.Horizontal,{padding:"NONE_2XS",children:(0,ce.jsx)(Ee,{children:(0,ce.jsx)(St.Typography,{weight:"BOLD",size:"LG",children:e})})})}var Jn=No.default.input`
|
|
27
27
|
&:focus {
|
|
28
28
|
outline: none;
|
|
29
29
|
box-shadow: none;
|
|
@@ -42,62 +42,97 @@
|
|
|
42
42
|
text-align: center;
|
|
43
43
|
width: 40px;
|
|
44
44
|
height: 34px;
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
`;Ne.displayName="Form.FormCounter.Display";var I=require("react/jsx-runtime");function Lo(){let{label:e,labelPosition:t,error:o}=Q();return(0,I.jsxs)(pe.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,I.jsxs)(pe.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,I.jsx)(me,{children:e}),o&&(0,I.jsx)(le,{children:o})]}),t!=="LEFT"&&(0,I.jsxs)(pe.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,I.jsxs)(pe.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,I.jsx)(me,{children:e}),o&&(0,I.jsx)(le,{children:o})]}),(0,I.jsxs)(we,{children:[(0,I.jsx)(ue,{type:"MINUS"}),(0,I.jsx)(Ne,{}),(0,I.jsx)(ue,{type:"PLUS"})]})]}),t==="LEFT"&&(0,I.jsx)(pe.Container.Vertical,{children:(0,I.jsxs)(pe.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,I.jsxs)(pe.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,I.jsx)(me,{children:e}),o&&(0,I.jsx)(le,{children:o})]}),(0,I.jsxs)(we,{children:[(0,I.jsx)(ue,{type:"MINUS"}),(0,I.jsx)(Ne,{}),(0,I.jsx)(ue,{type:"PLUS"})]})]})})]})}var tt=require("react/jsx-runtime");function Ho(o){var r=o,{children:e}=r,t=w(r,["children"]);return(0,tt.jsx)(so,y(T({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,tt.jsx)(Po,{children:e}):(0,tt.jsx)(Lo,{})}))}var Oo=require("react/jsx-runtime");function Rt(e){return(0,Oo.jsx)(ue,y(T({},e),{type:"MINUS"}))}Rt.displayName="Form.FormCounter.Minus";var Ao=require("react/jsx-runtime");function xt(e){return(0,Ao.jsx)(ue,y(T({},e),{type:"PLUS"}))}xt.displayName="Form.FormCounter.Plus";var Mo=Object.assign(Ho,{Display:Ne,Plus:xt,Minus:Rt,Badge:Ge});var Do=require("@mobilestockweb/container");var Vo=require("react/jsx-runtime");function zo(o){var r=o,{children:e}=r,t=w(r,["children"]);return(0,Vo.jsx)(Do.Container.Horizontal,y(T({gap:"SM"},t),{children:e}))}var ko=require("@unform/core"),V=require("react"),ye=N(require("styled-components")),Bo=require("@mobilestockweb/button"),wt=require("@mobilestockweb/container"),Pt=N(require("@mobilestockweb/tools")),Ft=require("@mobilestockweb/typography");var ne=require("react/jsx-runtime"),_o=(0,V.forwardRef)(function(g,c){var P=g,{name:t,type:o="text",full:r,label:n,maxLength:u,autoSubmit:a=!1,defaultValue:l,numberOfLines:i=1,showMaxContent:s=!1,autoCapitalize:f,format:b,onChange:m}=P,d=w(P,["name","type","full","label","maxLength","autoSubmit","defaultValue","numberOfLines","showMaxContent","autoCapitalize","format","onChange"]);let v=(0,ye.useTheme)(),{loading:h,notifyFieldChange:C}=A(),E=(0,ko.useField)(t),S=i>1,p=(0,V.useRef)(null),[F,H]=(0,V.useState)(!1),[k,M]=(0,V.useState)(""),D=o==="password",R=o==="tel"?15:o==="zipcode"?9:u,z=t+"-input"+(0,V.useId)(),$={width:"100%",border:"none",outline:"none",backgroundColor:"transparent",fontFamily:v.font.families[0],lineHeight:v.font.lineHeight,fontSize:v.font.size.sm,color:v.colors.text.default},We=y(T({},$),{height:"2.5rem"}),Fe=y(T({},$),{padding:"10px 0",display:"block",resize:"none",overflow:"hidden",boxSizing:"border-box"}),On=(0,V.useMemo)(()=>o==="password"?F?"text":"password":o,[o,F]),Ke=(0,V.useCallback)(()=>{if(!S||!p.current)return;let O=p.current,x=window.getComputedStyle(O),Y=parseInt(x.lineHeight,10);isNaN(Y)&&(Y=parseInt(x.fontSize,10)*v.font.lineHeight);let qe=parseInt(x.paddingTop,10),Ce=parseInt(x.paddingBottom,10),Ze=Y*i+qe+Ce+1,Be=parseFloat(getComputedStyle(document.documentElement).fontSize)*2.5;if(s)O.style.height=Ze+"px";else{O.style.height="0";let Ye=O.scrollHeight;O.style.height=Math.max(Be,Math.min(Ye,Ze))+"px"}},[S,i,s,v.font.lineHeight]),Xt=(0,V.useCallback)(O=>{var Y,qe;let x=O.target.value;switch(o){case"tel":x=Pt.default.phoneNumberFormatter(x);break;case"email":case"url":x=x.trim();break;case"zipcode":x=Pt.default.formatZipcode(x);break}if(b&&(x=b(x)),S&&i&&p.current){let Ce=p.current;Ce.value=x,Ce.style.height="auto";let Ze=Ce.scrollHeight,ke=window.getComputedStyle(Ce),Be=parseInt(ke.lineHeight,10);isNaN(Be)&&(Be=parseInt(ke.fontSize,10)*v.font.lineHeight);let Ye=parseInt(ke.paddingTop,10),Mn=parseInt(ke.paddingBottom,10),Dn=Be*(i+1)+Ye+Mn+1;if(Ze>Dn){Ce.value=k,Ke();return}}M(x),O.target.value=x,p.current.value=x,m==null||m({value:x,event:"INPUT_CHANGE"}),C==null||C(t,x),o==="tel"&&a&&x.length===15&&((Y=p.current)!=null&&Y.form)&&(m==null||m({value:x,event:"AUTO_SUBMIT"}),p.current.form.requestSubmit(),p.current.blur()),o==="zipcode"&&a&&x.length===9&&((qe=p.current)!=null&&qe.form)&&(m==null||m({value:x,event:"AUTO_SUBMIT"}),p.current.form.requestSubmit(),p.current.blur())},[o,b,a,m,E,C,S,i,k,Ke]);(0,V.useEffect)(()=>{let O=k||l||(E==null?void 0:E.defaultValue)||"";p.current.value=O,M(O),E.registerField({name:E.fieldName,ref:p,getValue:x=>{var Y;return((Y=x.current)==null?void 0:Y.value)||""},setValue:(x,Y)=>{x.current&&(x.current.value=Y,M(Y))},clearValue:x=>{x.current&&(x.current.value="",M(""))}})},[E==null?void 0:E.fieldName,E==null?void 0:E.registerField]),(0,V.useEffect)(()=>{Ke()},[k,Ke]),(0,V.useImperativeHandle)(c,()=>({focus(){var O;(O=p.current)==null||O.focus()},blur(){var O;(O=p.current)==null||O.blur()}}));function An(){H(O=>(m==null||m({value:!O,event:"TOGGLE_PASSWORD"}),!O))}return(0,ne.jsxs)(Qn,{full:r,$show:o!=="hidden",children:[n&&(0,ne.jsx)("label",{htmlFor:z,children:(0,ne.jsx)(Ft.Typography,{children:n})}),(0,ne.jsxs)(jn,{$error:!!(E!=null&&E.error),$isPassword:D,children:[S?(0,ne.jsx)("textarea",y(T({},d),{ref:p,id:z,value:k,onChange:Xt,maxLength:R,disabled:h||d.disabled,style:Fe})):(0,ne.jsx)("input",y(T({},d),{ref:p,id:z,value:k,onChange:Xt,maxLength:R,type:On,disabled:h||d.disabled,style:We})),D&&(0,ne.jsx)(Bo.Button,{size:"SM",onClick:An,icon:F?"EyeOutline":"EyeOff",variant:"TRANSPARENT",type:"button"})]}),!!(E!=null&&E.error)&&(0,ne.jsx)(Ft.Typography,{color:"DANGER",size:"SM",children:E==null?void 0:E.error})]})}),Qn=(0,ye.default)(wt.Container.Vertical)`
|
|
46
|
+
${({$show:e})=>!e&&ye.css`
|
|
47
|
+
display: none;
|
|
48
|
+
`}
|
|
49
|
+
`,jn=(0,ye.default)(wt.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=L(require("styled-components")),Be=require("@mobilestockweb/container");var io=require("@unform/core"),X=require("react");var z={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:m,defaultValue:i}=(0,io.useField)(n),[l,a]=(0,X.useState)(null),c=(0,X.useCallback)(s=>{let u=s.map(T=>({file:T,hash:z.getHashFile(T)})),b=(l||[]).map(T=>({file:T,hash:z.getHashFile(T)})),g=[...u,...b],p=Array.from(new Set(g.map(T=>T.hash))).map(T=>g.find(F=>F.hash===T)),S=p.filter(T=>u.some(F=>F.hash===T.hash));if(!S.length)return;let R=p.map(T=>T.file);a(R),o==null||o({value:S.map(T=>T.file),event:"ADD_FILES"})},[l,o]),f=(0,X.useCallback)(s=>{if(!s){a(null);return}let u=s.filter(b=>!!b);c(u)},[c,a]);(0,X.useEffect)(()=>{m({name:r,getValue:()=>l,setValue:(s,u)=>f(u||i),clearValue:()=>a(null)})},[r,m,l,f,i]),(0,X.useEffect)(()=>{a(null)},[t]);function d(s){if(!l)return;let u=l.filter(b=>z.getHashFile(b)!==s);a(u),o==null||o({value:l.find(b=>z.getHashFile(b)===s),event:"REMOVE_FILE"})}function E(){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&&c(Array.from(s.files)),document.body.removeChild(s)});let u=new MouseEvent("click");s.dispatchEvent(u)}return(0,so.jsx)(ao.Provider,{value:{handleSelectFile:E,handleSaveFiles:c,handleRemoveFile:d,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 we(){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 He(){return(0,fo.jsx)(co.Button,{type:"button",text:"Selecionar arquivo",size:"XS"})}var Oe=require("@mobilestockweb/typography");var ie=require("react/jsx-runtime");function Ve(){var t,o;let e=K();return(t=e.accept)!=null&&t.includes("all")?(0,ie.jsx)(Oe.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(Oe.Typography,{size:"XS",children:"Arquivos suportados"}),(0,ie.jsxs)(Oe.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)(He,{}),(0,ae.jsx)(we,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,ae.jsx)(Ve,{})]})}var To=L(require("chroma-js")),yo=require("react"),vo=require("styled-components");var Fo=require("react/jsx-runtime");function So(e){let t=K(),o=(0,vo.useTheme)(),[n,r]=(0,yo.useState)(!1);function m(i){var c;i.preventDefault(),r(!1);let l=i.dataTransfer;if(!l)return;let a=[];if(l.items&&l.items.length>0)for(let f=0;f<l.items.length;f++){let d=l.items[f];if(d.kind!=="file")continue;let E=d.webkitGetAsEntry();if(E&&E.isDirectory)continue;let s=d.getAsFile();s&&a.push(s)}else if(l.files&&l.files.length>0)for(let f=0;f<l.files.length;f++){let d=l.files.item(f);d&&a.push(d)}a.length!==0&&((c=t.accept)!=null&&c.some(f=>f!=="all")&&(a=a.filter(f=>{var E;let d=f.name.split(".").pop();return(E=t.accept)==null?void 0:E.includes(d==null?void 0:d.toLowerCase())}),!a.length)||t.handleSaveFiles(a))}return(0,Fo.jsx)("div",C({onDragOver:i=>{i.preventDefault(),r(!0)},onDrop:m,onDragLeave:i=>{i.preventDefault(),r(!1)},style:C({},n?{backgroundColor:(0,To.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var Po=require("react"),et=L(require("styled-components")),Ro=require("@mobilestockweb/button"),xo=require("@mobilestockweb/clickable"),le=require("@mobilestockweb/container"),Io=require("@mobilestockweb/icons"),De=require("@mobilestockweb/typography");var A=require("react/jsx-runtime");function Lo(){var n,r,m;let e=K(),[t,o]=(0,Po.useState)(!1);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(le.Container.Horizontal,{align:"END",children:!!((n=e.files)!=null&&n.length)&&(0,A.jsx)(xo.Clickable,{type:"button","data-testid":"flip-button",onClick:()=>o(!t),children:(0,A.jsxs)(le.Container.Horizontal,{align:"CENTER",children:[(0,A.jsxs)(De.Typography,{size:"XS",children:[(r=e.files)==null?void 0:r.length," arquivos"]}),(0,A.jsx)(jr,{"data-testid":"flip-icon-container","data-flip":t,$flip:t,children:(0,A.jsx)(Io.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,A.jsx)(en,{"data-testid":"multiple-archive-list","data-open":t,$flip:t,children:(m=e.files)==null?void 0:m.map((i,l)=>(0,A.jsxs)(le.Container.Horizontal,{align:"START_CENTER",children:[(0,A.jsxs)(le.Container.Horizontal,{gap:"SM",full:!0,children:[(0,A.jsx)(De.Typography,{size:"XS",weight:"MEDIUM",children:i.name.slice(0,20)}),i.size&&(0,A.jsx)(De.Typography,{size:"XS",children:Me.convertBytesToReadableFormat(i.size)})]}),(0,A.jsx)(le.Container.Vertical,{children:(0,A.jsx)(Ro.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS","data-testid":`trash-button-${l}`,onClick:()=>e.handleRemoveFile(`${i.name}-${i.size}`)})})]},l))})]})}var jr=(0,et.default)(le.Container.Horizontal)`
|
|
54
|
+
padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
|
|
55
|
+
`;var gr=require("@unform/core"),hr=require("react"),br=N(require("styled-components")),ut=require("@mobilestockweb/container");var $o=require("@unform/core"),ee=require("react");var ei=1.775,ti=.125,oi=.54,B={getHashFile(e){return`${e.name}-${e.size}`},toRem(e){return`${Math.round(e*1e4)/1e4}rem`},buildDimensions(e){let t=parseFloat(e),o=t*ti,r=t-2*o,n=t*ei,u=n-r-2*o,a=r*oi;return{width:this.toRem(n),height:this.toRem(t),handle:this.toRem(r),translate:this.toRem(u),offset:this.toRem(o),iconSize:this.toRem(a)}},resolveColor(e,t,o){var r;return e&&(r=t.colors.switch[e.toLowerCase()])!=null?r:t.colors.switch[o]},resolveSliderColor(e,t,o,r,n){return n?r?n.colors.alert.error:e?this.resolveColor(t,n,"on"):this.resolveColor(o,n,"off"):n.colors.container.default}};var Xo=require("react/jsx-runtime"),Uo=(0,ee.createContext)(null);function Go({children:e,accept:t,onChange:o,name:r}){let{notifyFieldChange:n}=A(),{fieldName:u,registerField:a,defaultValue:l}=(0,$o.useField)(r),[i,s]=(0,ee.useState)(null),f=(0,ee.useCallback)(c=>{let g=c.map(S=>({file:S,hash:B.getHashFile(S)})),P=(i||[]).map(S=>({file:S,hash:B.getHashFile(S)})),v=[...g,...P],h=Array.from(new Set(v.map(S=>S.hash))).map(S=>v.find(p=>p.hash===S)),C=h.filter(S=>g.some(p=>p.hash===S.hash));if(!C.length)return;let E=h.map(S=>S.file);s(E),n==null||n(u,E),o==null||o({value:C.map(S=>S.file),event:"ADD_FILES"})},[i,o,n,u]),b=(0,ee.useCallback)(c=>{if(!c){s(null);return}let g=c.filter(P=>!!P);f(g)},[f,s]);(0,ee.useEffect)(()=>{a({name:u,getValue:()=>i,setValue:(c,g)=>b(g||l),clearValue:()=>s(null)})},[u,a,i,b,l]),(0,ee.useEffect)(()=>{s(null)},[t]);function m(c){if(!i)return;let g=i.filter(P=>B.getHashFile(P)!==c);s(g),n==null||n(u,g),o==null||o({value:i.find(P=>B.getHashFile(P)===c),event:"REMOVE_FILE"})}function d(){let c=document.createElement("input");c.style.display="none",c.setAttribute("type","file"),c.setAttribute("accept","*/*"),c.setAttribute("id",String(Math.random())),c.setAttribute("multiple","multiple"),document.body.appendChild(c),c.addEventListener("change",()=>{c.files&&f(Array.from(c.files)),document.body.removeChild(c)});let g=new MouseEvent("click");c.dispatchEvent(g)}return(0,Xo.jsx)(Uo.Provider,{value:{handleSelectFile:d,handleSaveFiles:f,handleRemoveFile:m,accept:t,files:i,name:r},children:e})}function ie(){let e=(0,ee.useContext)(Uo);if(!e)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var ot={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 jo=require("@mobilestockweb/container"),er=require("@mobilestockweb/spacer");var Wo=require("@unform/core"),Ko=require("@mobilestockweb/typography");var qo=require("react/jsx-runtime");function rt(){let e=ie(),{error:t}=(0,Wo.useField)(e.name);return(0,qo.jsx)(Ko.Typography,{color:"DANGER",size:"XS",children:t})}var Zo=require("@mobilestockweb/button"),Yo=require("react/jsx-runtime");function nt(){return(0,Yo.jsx)(Zo.Button,{type:"button",text:"Selecionar arquivo",size:"XS"})}var it=require("@mobilestockweb/typography");var de=require("react/jsx-runtime");function at(){var t,o;let e=ie();return(t=e.accept)!=null&&t.includes("all")?(0,de.jsx)(it.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(it.Typography,{size:"XS",children:"Arquivos suportados"}),(0,de.jsxs)(it.Typography,{size:"XS",children:["( ",(o=e.accept)==null?void 0:o.join(", ")," )"]})]})}var Jo=require("@mobilestockweb/typography"),Qo=require("react/jsx-runtime");function lt({children:e}){return(0,Qo.jsx)(Jo.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var fe=require("react/jsx-runtime");function tr(){var t;let e=ie();return(0,fe.jsxs)(jo.Container.Vertical,{align:"CENTER",children:[(0,fe.jsx)(lt,{}),(0,fe.jsx)(er.Spacer,{size:"2XS"}),(0,fe.jsx)(nt,{}),(0,fe.jsx)(rt,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,fe.jsx)(at,{})]})}var or=N(require("chroma-js")),rr=require("react"),nr=require("styled-components");var ar=require("react/jsx-runtime");function ir(e){let t=ie(),o=(0,nr.useTheme)(),[r,n]=(0,rr.useState)(!1);function u(a){var s;a.preventDefault(),n(!1);let l=a.dataTransfer;if(!l)return;let i=[];if(l.items&&l.items.length>0)for(let f=0;f<l.items.length;f++){let b=l.items[f];if(b.kind!=="file")continue;let m=b.webkitGetAsEntry();if(m&&m.isDirectory)continue;let d=b.getAsFile();d&&i.push(d)}else if(l.files&&l.files.length>0)for(let f=0;f<l.files.length;f++){let b=l.files.item(f);b&&i.push(b)}i.length!==0&&((s=t.accept)!=null&&s.some(f=>f!=="all")&&(i=i.filter(f=>{var m;let b=f.name.split(".").pop();return(m=t.accept)==null?void 0:m.includes(b==null?void 0:b.toLowerCase())}),!i.length)||t.handleSaveFiles(i))}return(0,ar.jsx)("div",T({onDragOver:a=>{a.preventDefault(),n(!0)},onDrop:u,onDragLeave:a=>{a.preventDefault(),n(!1)},style:T({},r?{backgroundColor:(0,or.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var lr=require("react"),Nt=N(require("styled-components")),sr=require("@mobilestockweb/button"),ur=require("@mobilestockweb/clickable"),ge=require("@mobilestockweb/container"),cr=require("@mobilestockweb/icons"),st=require("@mobilestockweb/typography");var _=require("react/jsx-runtime");function mr(){var r,n,u;let e=ie(),[t,o]=(0,lr.useState)(!1);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ge.Container.Horizontal,{align:"END",children:!!((r=e.files)!=null&&r.length)&&(0,_.jsx)(ur.Clickable,{type:"button","data-testid":"flip-button",onClick:()=>o(!t),children:(0,_.jsxs)(ge.Container.Horizontal,{align:"CENTER",children:[(0,_.jsxs)(st.Typography,{size:"XS",children:[(n=e.files)==null?void 0:n.length," arquivos"]}),(0,_.jsx)(ri,{"data-testid":"flip-icon-container","data-flip":t,$flip:t,children:(0,_.jsx)(cr.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,_.jsx)(ni,{"data-testid":"multiple-archive-list","data-open":t,$flip:t,children:(u=e.files)==null?void 0:u.map((a,l)=>(0,_.jsxs)(ge.Container.Horizontal,{align:"START_CENTER",children:[(0,_.jsxs)(ge.Container.Horizontal,{gap:"SM",full:!0,children:[(0,_.jsx)(st.Typography,{size:"XS",weight:"MEDIUM",children:a.name.slice(0,20)}),a.size&&(0,_.jsx)(st.Typography,{size:"XS",children:ot.convertBytesToReadableFormat(a.size)})]}),(0,_.jsx)(ge.Container.Vertical,{children:(0,_.jsx)(sr.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS","data-testid":`trash-button-${l}`,onClick:()=>e.handleRemoveFile(`${a.name}-${a.size}`)})})]},l))})]})}var ri=(0,Nt.default)(ge.Container.Horizontal)`
|
|
60
57
|
transform: ${({$flip:e})=>e?"rotate(180deg)":"rotate(0deg)"};
|
|
61
58
|
transition: transform 0.3s ease;
|
|
62
|
-
`,
|
|
59
|
+
`,ni=(0,Nt.default)(ge.Container.Vertical)`
|
|
63
60
|
display: ${({$flip:e})=>e?"flex":"none"};
|
|
64
61
|
max-height: 200px;
|
|
65
62
|
overflow-y: auto;
|
|
66
|
-
`;var
|
|
63
|
+
`;var pr=require("@mobilestockweb/typography"),fr=require("react/jsx-runtime");function dr({children:e}){return(0,fr.jsx)(pr.Typography,{children:e})}var ae=require("react/jsx-runtime");function Cr(o){var r=o,{accept:e}=r,t=w(r,["accept"]);let{error:n}=(0,gr.useField)(t.name),u=(0,hr.useMemo)(()=>ot.parseAcceptString(e),[e]);return(0,ae.jsx)(Go,y(T({},t),{accept:u,children:(0,ae.jsxs)(ut.Container.Vertical,{gap:"2XS",children:[(0,ae.jsx)(ut.Container.Horizontal,{align:t.alignLabel||"START",children:(0,ae.jsx)(dr,{children:t.label})}),(0,ae.jsxs)(ii,{$error:!!n,padding:"MD",children:[(0,ae.jsx)(ir,{children:t.children||(0,ae.jsx)(tr,{})}),(0,ae.jsx)(mr,{})]})]})}))}var ii=(0,br.default)(ut.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 Tr=Object.assign(Cr,{Title:lt,HelpButton:nt,HelpText:at,ErrorLabel:rt});var X=require("@dnd-kit/core"),on=require("@dnd-kit/modifiers"),be=require("@dnd-kit/sortable"),He=require("react"),rn=require("styled-components"),pt=require("@mobilestockweb/container");var Er=require("@unform/core"),U=require("react"),vr=require("styled-components");var Rr=require("react/jsx-runtime"),yr=(0,U.createContext)(null);function Sr({gap:e="2XS",size:t="SM",name:o,children:r,onChange:n,multiple:u,dragAndDrop:a,buttonAddDirection:l}){let i=(0,vr.useTheme)(),{notifyFieldChange:s}=A(),{fieldName:f,registerField:b,defaultValue:m}=(0,Er.useField)(o),[d,c]=(0,U.useState)(null),[g,P]=(0,U.useState)(!1),[v,h]=(0,U.useState)(null),C=(0,U.useMemo)(()=>i.sizeImage[t.toLowerCase()],[i,t]),E=(0,U.useMemo)(()=>i.gaps[e.toLowerCase()],[i,e]),S=(0,U.useCallback)(R=>{c(l==="RIGHT"?z=>{let $=[...z||[],...R].reverse();return s==null||s(f,$),$}:z=>{let $=[...z||[],...R];return s==null||s(f,$),$})},[c,l,s,f]),p=(0,U.useCallback)(R=>{if(!R){c(null);return}S(R)},[S]);(0,U.useEffect)(()=>{b({name:f,getValue:()=>d,setValue:(R,z)=>p(z||m),clearValue:()=>c(null)})},[f,b,d,p,m]);function F(){let R=document.createElement("input");R.style.display="none",R.setAttribute("type","file"),R.setAttribute("accept","image/*"),R.setAttribute("id",String(Math.random())),u&&R.setAttribute("multiple","multiple"),document.body.appendChild(R),R.addEventListener("change",()=>{R.files&&(u?S(Array.from(R.files)):(P(!0),h(Array.from(R.files)[0])),document.body.removeChild(R))});let z=new MouseEvent("click");R.dispatchEvent(z)}function H(R){if(!d)return;let z=d.filter($=>`${$.name}-${$.size}`!==R);c(z),s==null||s(f,z),n==null||n({value:d.find($=>`${$.name}-${$.size}`===R),event:"REMOVE_IMAGE"})}function k(R){c(R),s==null||s(f,R),n==null||n({value:R,event:"REORDER_IMAGES"})}function M(R){S([R]),P(!1),h(null),n==null||n({value:R,event:"CROP_SAVE"})}function D(){P(!1),h(null)}return(0,Rr.jsx)(yr.Provider,{value:{showDeviceImage:F,images:d,removeImage:H,reorderImages:k,openImageCropModal:g,imageToCrop:v,handleImageCropCancel:D,handleImageCropSave:M,sizeComponent:C,gapComponent:E,dragAndDrop:a,name:o,gap:e},children:r})}function K(){let e=(0,U.useContext)(yr);if(!e)throw new Error("usePhotoList must be used within a PhotoListProvider");return e}var xr=require("@mobilestockweb/button");var Pr=require("react/jsx-runtime");function It(){let e=K();return(0,Pr.jsx)(xr.Button,{type:"button",icon:"Plus",variant:"OUTLINE",onClick:e.showDeviceImage,style:{height:e.sizeComponent,width:e.sizeComponent,minWidth:e.sizeComponent,maxWidth:e.sizeComponent}})}var Fr=require("@unform/core"),wr=require("@mobilestockweb/typography");var Ir=require("react/jsx-runtime");function Nr(){let e=K(),{error:t}=(0,Fr.useField)(e.name);return(0,Ir.jsx)(wr.Typography,{color:"DANGER",size:"XS",children:t})}var Ur=require("@dnd-kit/sortable"),Gr=require("@dnd-kit/utilities"),mt=require("react"),Xr=require("styled-components"),Wr=require("@mobilestockweb/container");var Mr=require("@dnd-kit/sortable"),Dr=N(require("styled-components")),zr=require("@mobilestockweb/container");var Lr=require("@dnd-kit/sortable"),Hr=N(require("styled-components")),Ar=require("react/jsx-runtime");function Or({id:e}){let{isDragging:t}=(0,Lr.useSortable)({id:e});return(0,Ar.jsx)(ai,{$isDragging:t})}var ai=Hr.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 Lt=require("react/jsx-runtime");function Vr({id:e}){let t=K(),{listeners:o,attributes:r}=(0,Mr.useSortable)({id:e});return(0,Lt.jsx)(li,y(T(T({$sizeComponent:t.sizeComponent,align:"CENTER"},o),r),{children:(0,Lt.jsx)(Or,{id:e})}))}var li=(0,Dr.default)(zr.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 ct=N(require("styled-components")),kr=require("@mobilestockweb/clickable"),Br=require("@mobilestockweb/icons"),_r=N(require("@mobilestockweb/tools"));var Ht=require("react/jsx-runtime");function $r({id:e}){let t=K(),o=(0,ct.useTheme)();function r(){t.removeImage(e)}return(0,Ht.jsx)(si,{onClick:r,children:(0,Ht.jsx)(Br.Icon,{name:"X",size:"XS",color:_r.default.defineTextColor(o.colors.formPhotoList.trashButton)})})}var si=(0,ct.default)(kr.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 Ie=require("react/jsx-runtime");function ui({file:e}){let t=(0,Xr.useTheme)(),o=K(),{setNodeRef:r,transform:n,transition:u,isDragging:a}=(0,Ur.useSortable)({id:B.getHashFile(e)}),l=(0,mt.useMemo)(()=>URL.createObjectURL(e),[e]);return(0,Ie.jsxs)(Wr.Container.Vertical,{ref:r,align:"CENTER",style:y(T({borderColor:t.colors.formPhotoList.controlBar,borderStyle:"solid",borderWidth:1},a&&{borderColor:t.colors.formPhotoList.highlightBar}),{transform:Gr.CSS.Transform.toString(n),transition:u,zIndex:a?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,Ie.jsx)($r,{id:B.getHashFile(e)}),(0,Ie.jsx)("img",{alt:"image",style:{width:"100%",objectFit:"cover"},src:l}),o.dragAndDrop&&(0,Ie.jsx)(Vr,{id:B.getHashFile(e)})]})}var Kr=(0,mt.memo)(ui);var qr=require("@mobilestockweb/typography"),Yr=require("react/jsx-runtime");function Zr({children:e}){return(0,Yr.jsx)(qr.Typography,{children:e})}var te=require("react"),en=require("react-image-crop"),Le=N(require("styled-components")),Mt=require("@mobilestockweb/button"),Se=require("@mobilestockweb/container");var he=require("react"),Ot=N(require("react-modal")),Jr=require("styled-components"),Qr=require("ua-parser-js");var At=require("react/jsx-runtime");function jr(o){var r=o,{children:e}=r,t=w(r,["children"]);let n=(0,Jr.useTheme)(),[u,a]=(0,he.useState)(!1),[l,i]=(0,he.useState)(void 0),s=(0,he.useCallback)(()=>(0,Qr.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),f=(0,he.useCallback)(()=>{a(s()),i(window.innerHeight)},[s]);return(0,he.useEffect)(()=>(a(s()),i(window.innerHeight),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[s,f]),u?(0,At.jsx)(Ot.default,y(T({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,At.jsx)(Ot.default,y(T({ariaHideApp:!1,style:{overlay:{backgroundColor:n.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 Z=require("react/jsx-runtime");function tn(){let e=K(),t=(0,te.useRef)(null),o=(0,te.useRef)(null),[r,n]=(0,te.useState)(),[u,a]=(0,te.useState)(),[l,i]=(0,te.useState)(),s=(0,te.useMemo)(()=>e.imageToCrop?URL.createObjectURL(e.imageToCrop):void 0,[e.imageToCrop]);(0,te.useEffect)(()=>{e.imageToCrop||(n(void 0),a(void 0),i(void 0))},[e.imageToCrop,e.openImageCropModal]);function f({displayWidth:d,displayHeight:c,naturalWidth:g,naturalHeight:P}){a({displayWidth:d,displayHeight:c,naturalWidth:g,naturalHeight:P});let v=Math.min(d,c);n({unit:"px",width:v,height:v,x:d>c?(d-v)/2:0,y:c>d?(c-v)/2:0})}function b(){return Qe(this,null,function*(){if(!e.imageToCrop||!r||!u)return;let d=u.naturalWidth/u.displayWidth,c=u.naturalHeight/u.displayHeight,g=r.x*d,P=r.y*c,v=r.width*d,h=r.height*c,C=new OffscreenCanvas(v,h),E=C.getContext("2d"),S=new Image;S.src=URL.createObjectURL(e.imageToCrop),yield new Promise(H=>{S.onload=()=>H()}),E.drawImage(S,g,P,v,h,0,0,v,h);let p=yield C.convertToBlob({type:"image/png",quality:1}),F="";if(!e.imageToCrop.name)F="image-cropped.png";else{let H=e.imageToCrop.name.split(".");H.pop(),F=H.join(".")+"-cropped.png"}e.handleImageCropSave(new File([p],F,{type:"image/png",lastModified:Date.now()}))})}function m(d){let c=d.currentTarget,g=o.current,P=g.clientWidth,v=g.clientHeight,h=c.naturalWidth,C=c.naturalHeight,E=Math.min(P/h,v/C),S=h*E,p=C*E;i({width:S,height:p}),f({displayWidth:S,displayHeight:p,naturalWidth:h,naturalHeight:C})}return(0,Z.jsx)(jr,{isOpen:e.openImageCropModal,children:(0,Z.jsxs)(Se.Container.Vertical,{full:!0,padding:"NONE_XS_XS_XS",style:{height:"100%",maxHeight:"100%",boxSizing:"border-box"},gap:"MD",children:[(0,Z.jsx)(Se.Container.Vertical,{full:!0,align:"CENTER",style:{minHeight:0},children:(0,Z.jsx)(ci,{ref:o,align:"CENTER",children:(0,Z.jsx)(mi,{crop:r,width:l==null?void 0:l.width,height:l==null?void 0:l.height,onChange:d=>n(d),children:(0,Z.jsx)(pi,{src:s,ref:t,"data-testid":"image-to-crop",onLoad:m})})})}),(0,Z.jsxs)(Se.Container.Horizontal,{gap:"MD",children:[(0,Z.jsx)(Se.Container.Vertical,{full:!0,children:(0,Z.jsx)(Mt.Button,{onClick:e.handleImageCropCancel,text:"Cancelar",backgroundColor:"CANCEL_DARK"})}),(0,Z.jsx)(Se.Container.Vertical,{full:!0,children:(0,Z.jsx)(Mt.Button,{onClick:b,text:"Salvar"})})]})]})})}var ci=(0,Le.default)(Se.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
|
+
`,mi=(0,Le.default)(en.ReactCrop)`
|
|
92
|
+
${({width:e,height:t})=>e&&t&&Le.css`
|
|
96
93
|
width: ${e}px;
|
|
97
94
|
height: ${t}px;
|
|
98
95
|
display: inline-flex;
|
|
99
96
|
`}
|
|
100
|
-
`,
|
|
97
|
+
`,pi=Le.default.img``;var G=require("react/jsx-runtime");function nn({numberOfImagesVisible:e,buttonAddDirection:t,label:o,alignLabel:r}){var g,P;let n=K(),u=(0,rn.useTheme)(),a=(0,X.useSensors)((0,X.useSensor)(X.MouseSensor),(0,X.useSensor)(X.TouchSensor),(0,X.useSensor)(X.KeyboardSensor,{coordinateGetter:be.sortableKeyboardCoordinates})),[l,i]=(0,He.useState)(null),s=(0,He.useId)();function f(v){var C;return((C=n.images)==null?void 0:C.findIndex(E=>B.getHashFile(E)===v))||0}let b=l?f(l):-1;function m({over:v}){if(i(null),v){let h=f(v.id);if(b!==h){let C=(0,be.arrayMove)(n.images,b,h);n.reorderImages(C)}}}function d({active:v}){v&&i(v.id)}let c=(0,He.useMemo)(()=>e?`calc(${n.sizeComponent} * ${e} + (${n.gapComponent} * ${e}))`:`calc(100% - ${n.sizeComponent} - ${n.gapComponent})`,[e,n.sizeComponent,n.gapComponent]);return(0,G.jsxs)(G.Fragment,{children:[!!o&&(0,G.jsx)(pt.Container.Horizontal,{align:r||"START",children:(0,G.jsx)(Zr,{children:o})}),(0,G.jsx)(X.DndContext,{id:s,sensors:a,collisionDetection:X.closestCenter,onDragCancel:()=>i(null),onDragStart:d,onDragEnd:m,modifiers:[on.restrictToHorizontalAxis],children:(0,G.jsxs)(pt.Container.Horizontal,{align:"START_CENTER",gap:n.gap,children:[t==="LEFT"&&(0,G.jsx)(It,{}),(0,G.jsx)(be.SortableContext,{items:((g=n.images)==null?void 0:g.map(v=>B.getHashFile(v)))||[],strategy:be.horizontalListSortingStrategy,children:(0,G.jsx)(pt.Container.Horizontal,{gap:n.gap,style:{flexBasis:"max-content",overflowX:"scroll",paddingBottom:u.spacing["2xs"],maxWidth:c},children:(P=n.images)==null?void 0:P.map(v=>(0,G.jsx)(Kr,{file:v},B.getHashFile(v)))})}),t==="RIGHT"&&(0,G.jsx)(It,{})]})}),(0,G.jsx)(Nr,{}),(0,G.jsx)(tn,{})]})}var Dt=require("react/jsx-runtime");function an(u){var a=u,{label:e,alignLabel:t,buttonAddDirection:o="LEFT",numberOfImagesVisible:r=0}=a,n=w(a,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,Dt.jsx)(Sr,y(T({multiple:!0,dragAndDrop:!0,buttonAddDirection:o},n),{children:(0,Dt.jsx)(nn,{label:e,alignLabel:t,buttonAddDirection:o,numberOfImagesVisible:r})}))}var ln=require("@unform/core"),sn=require("react"),Vt=N(require("styled-components")),zt=require("@mobilestockweb/container"),kt=require("@mobilestockweb/typography");var Re=require("react/jsx-runtime");function un(u){var a=u,{name:e,label:t,value:o,onChange:r}=a,n=w(a,["name","label","value","onChange"]);let{loading:l,notifyFieldChange:i}=A(),{error:s,fieldName:f,registerField:b}=(0,ln.useField)(e),m=(0,sn.useRef)(null),d=`radio_${e}_${t}`;function c(){b({name:f,ref:m,getValue:g=>g.current.value,clearValue:g=>{g.current.checked=!1}}),i==null||i(f,o),r==null||r({value:o,event:"RADIO_CHANGE"})}return(0,Re.jsxs)(zt.Container.Vertical,{onClick:c,gap:"XS",padding:"2XS_NONE",children:[(0,Re.jsxs)(zt.Container.Horizontal,{align:"START_CENTER",gap:"XS",children:[(0,Re.jsx)(di,y(T({id:d,ref:m},n),{type:"radio",disabled:l})),(0,Re.jsx)(fi,{htmlFor:d,size:"MD",children:t})]}),s&&(0,Re.jsx)(kt.Typography,{color:"DANGER",size:"SM",children:s})]})}var di=Vt.default.input`
|
|
101
98
|
width: 1rem;
|
|
102
99
|
height: 1rem;
|
|
103
|
-
`,
|
|
100
|
+
`,fi=(0,Vt.default)(kt.Typography).attrs({forwardedAs:"label"})``;var cn=require("@unform/core"),dt=N(require("chroma-js")),Bt=require("lodash"),oe=require("react"),mn=N(require("react-select")),ft=N(require("styled-components")),pn=require("@mobilestockweb/container"),_t=require("@mobilestockweb/typography");var Oe=require("react/jsx-runtime"),dn=(0,oe.forwardRef)(function({name:t,label:o,options:r,placeholder:n="Selecione um item",disabled:u,defaultValue:a,onChange:l,autoFocus:i,onFocus:s,onBlur:f},b){let m=(0,ft.useTheme)(),{loading:d,notifyFieldChange:c}=A(),{fieldName:g,defaultValue:P,registerField:v,error:h}=(0,cn.useField)(t),C=(0,oe.useRef)(null);(0,oe.useImperativeHandle)(b,()=>({focus(){var p;(p=C.current)==null||p.focus()},blur(){var p;(p=C.current)==null||p.blur()}})),(0,oe.useEffect)(()=>{v({name:g,ref:C.current,getValue:p=>{var H,k,M;let F=((M=(k=(H=p==null?void 0:p.state)==null?void 0:H.selectValue)==null?void 0:k[0])==null?void 0:M.value)||"";return c==null||c(g,F),l==null||l({value:F,event:"SELECT_CHANGE"}),F}})},[g,v,l]);let E=(0,oe.useCallback)(p=>function(F){return(0,Bt.mergeWith)(F,{fontFamily:m.font.families,lineHeight:m.font.lineHeight,color:m.colors.text.default},p)},[]),S=(0,oe.useCallback)((p,F)=>{let H="transparent",k=m.colors.text.default;switch(!0){case F.isFocused:{let M=(0,dt.default)(m.colors.listItem.hover);M.luminance()>.5?H=M.brighten(1).hex("rgb"):H=M.hex("rgb");let D=(0,dt.default)(H);k=D.luminance(D.luminance()>.5?-2:2).hex("rgb");break}case F.isSelected:{H=m.colors.listItem.selected;let M=(0,dt.default)(H);k=M.luminance(M.luminance()>.5?-2:2).hex("rgb");break}}return(0,Bt.mergeWith)(p,{fontFamily:m.font.families,lineHeight:m.font.lineHeight,color:k,backgroundColor:H})},[]);return(0,Oe.jsxs)(pn.Container.Vertical,{children:[o&&(0,Oe.jsx)(gi,{htmlFor:g,size:"MD",children:o}),(0,Oe.jsx)(mn.default,{defaultValue:a||P,options:[{label:n,options:r}],placeholder:n,menuPortalTarget:document.body,menuPosition:"fixed",styles:{container:E({width:"100%",display:"flex",height:"3rem"}),control:E({width:"100%",backgroundColor:h?m.colors.input.error:void 0,borderColor:h?m.colors.alert.urgent:void 0}),indicatorSeparator:E({backgroundColor:h?m.colors.alert.urgent:void 0}),dropdownIndicator:E({color:h?m.colors.alert.urgent:m.colors.text.default}),option:S,menuPortal:E({zIndex:99999})},openMenuOnFocus:!0,ref:C,isDisabled:d||u,autoFocus:i,onFocus:s,onBlur:f}),h&&(0,Oe.jsx)(_t.Typography,{color:"DANGER",size:"SM",children:h})]})}),gi=(0,ft.default)(_t.Typography).attrs({forwardedAs:"label"})``;var Cn=require("@mobilestockweb/typography");var fn=require("@unform/core"),q=require("react");var bn=require("react/jsx-runtime"),gn=(0,q.createContext)(void 0);function hn(e){let{notifyFieldChange:t,loading:o}=A(),{fieldName:r,registerField:n,error:u,defaultValue:a}=(0,fn.useField)(e.name),[l,i]=(0,q.useState)(()=>{var p;return(p=e.defaultValue)!=null?p:!!a}),{onChange:s,defaultValue:f,label:b,labelPosition:m,checkedColor:d,backgroundColor:c,handleColor:g,size:P,icons:v}=e,h=e.disabled||o,C=(0,q.useCallback)((p,F=!0)=>{i(p),t==null||t(r,p),F&&(s==null||s({value:p,event:"EDIT"}))},[t,r,s]);(0,q.useEffect)(()=>{n({name:r,getValue:()=>l,setValue:(p,F)=>C(!!F),clearValue:()=>C(!1)})},[r,l,n,C]),(0,q.useEffect)(()=>{let p=f!=null?f:!!a;C(p,!1)},[f,C,a]);let E=(0,q.useCallback)(()=>{h||i(p=>{let F=!p;return t==null||t(r,F),s==null||s({value:F,event:"TOGGLE"}),F})},[h,r,t,s]),S=(0,q.useMemo)(()=>({checked:l,toggle:E,configureChecked:C,error:u,label:b,labelPosition:m,disabled:h,checkedColor:d,backgroundColor:c,handleColor:g,size:P,icons:v}),[l,E,C,u,b,m,h,d,c,g,P,v]);return(0,bn.jsx)(gn.Provider,{value:S,children:e.children})}function Ae(){let e=(0,q.useContext)(gn);if(!e)throw new Error("useSwitch must be used within a SwitchProvider");return e}var Tn=require("react/jsx-runtime");function gt({children:e}){let{error:t}=Ae(),o=e!=null?e:t;return o?(0,Tn.jsx)(Cn.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:o}):null}var En=require("@mobilestockweb/typography");var vn=require("react/jsx-runtime");function Me(o){var r=o,{children:e}=r,t=w(r,["children"]);return(0,vn.jsx)(En.Typography,y(T({weight:"REGULAR"},t),{children:e}))}var Ut=require("@mobilestockweb/container");var ze=require("@mobilestockweb/container");var Pe=N(require("styled-components"));var ht=N(require("styled-components")),yn=require("@mobilestockweb/icons"),Sn=N(require("@mobilestockweb/tools"));var $t=require("react/jsx-runtime");function Rn({checked:e,handleColor:t,dimensions:o,currentIcon:r}){let n=(0,ht.useTheme)(),u=B.resolveColor(t,n,"handle");return(0,$t.jsx)(hi,{$checked:e,$handleColor:u,$dimensions:o,children:r&&(0,$t.jsx)(yn.Icon,{name:r,color:Sn.default.defineTextColor(u),size:"XS",style:{width:o.iconSize,height:o.iconSize}})})}var hi=ht.default.span`
|
|
101
|
+
position: absolute;
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
height: ${({$dimensions:e})=>e.handle};
|
|
106
|
+
width: ${({$dimensions:e})=>e.handle};
|
|
107
|
+
left: ${({$dimensions:e})=>e.offset};
|
|
108
|
+
bottom: ${({$dimensions:e})=>e.offset};
|
|
109
|
+
background-color: ${({$handleColor:e})=>e};
|
|
110
|
+
transition: 0.4s;
|
|
111
|
+
border-radius: 50%;
|
|
112
|
+
transform: ${({$checked:e,$dimensions:t})=>e?`translateX(${t.translate})`:"translateX(0)"};
|
|
113
|
+
`;var xe=require("react/jsx-runtime");function De(){let e=(0,Pe.useTheme)(),{checked:t,toggle:o,disabled:r,checkedColor:n,backgroundColor:u,handleColor:a,size:l,icons:i,error:s}=Ae(),f=(l!=null?l:"MD").toLowerCase(),b=B.buildDimensions(e.sizeSwitch[f]),m=t?i==null?void 0:i.on:i==null?void 0:i.off,d=B.resolveSliderColor(t,n,u,!!s,e);return(0,xe.jsx)(bi,{$disabled:r,$dimensions:b,children:(0,xe.jsxs)(Ci,{children:[(0,xe.jsx)(Ti,{type:"checkbox",checked:t,onChange:o,disabled:r}),(0,xe.jsx)(Ei,{$color:d,$dimensions:b,children:(0,xe.jsx)(Rn,{checked:t,handleColor:a,dimensions:b,currentIcon:m})})]})})}var bi=Pe.default.div`
|
|
114
|
+
opacity: ${({$disabled:e})=>e?.5:1};
|
|
115
|
+
position: relative;
|
|
116
|
+
display: inline-block;
|
|
117
|
+
width: ${({$dimensions:e})=>e.width};
|
|
118
|
+
height: ${({$dimensions:e})=>e.height};
|
|
119
|
+
border: 1px solid ${({theme:e})=>e.colors.input.border};
|
|
120
|
+
border-radius: ${({$dimensions:e})=>e.height};
|
|
121
|
+
`,Ci=Pe.default.label`
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
`,Ti=Pe.default.input`
|
|
124
|
+
opacity: 0;
|
|
125
|
+
width: 0;
|
|
126
|
+
height: 0;
|
|
127
|
+
position: absolute;
|
|
128
|
+
`,Ei=Pe.default.span`
|
|
129
|
+
position: absolute;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
top: 0;
|
|
132
|
+
left: 0;
|
|
133
|
+
right: 0;
|
|
134
|
+
bottom: 0;
|
|
135
|
+
background-color: ${({$color:e})=>e};
|
|
136
|
+
border-radius: ${({$dimensions:e})=>e.height};
|
|
137
|
+
transition: 0.4s;
|
|
138
|
+
`;var W=require("react/jsx-runtime");function xn({position:e,label:t,align:o}){return e==="LEFT"?(0,W.jsxs)(ze.Container.Horizontal,{align:"CENTER",gap:"SM",children:[t&&(0,W.jsx)(ze.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:(0,W.jsx)(Me,{children:t})}),(0,W.jsx)(De,{})]}):e==="RIGHT"?(0,W.jsxs)(ze.Container.Horizontal,{align:"CENTER",gap:"SM",children:[(0,W.jsx)(De,{}),t&&(0,W.jsx)(ze.Container.Vertical,{padding:"NONE_NONE_NONE_2XS",children:(0,W.jsx)(Me,{children:t})})]}):(0,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsx)(ze.Container.Vertical,{align:o||"CENTER_START",padding:"NONE_NONE_2XS_NONE",children:(0,W.jsx)(Me,{children:t})}),(0,W.jsx)(De,{})]})}var Ve=require("react/jsx-runtime"),Pn=(r=>(r.TOP_START="CENTER_START",r.TOP_CENTER="CENTER",r.TOP_END="CENTER_END",r))(Pn||{});function Fn(){let{label:e,labelPosition:t,error:o}=Ae(),r=t!=null?t:"TOP_START",u=r.startsWith("TOP")?Pn[r]:void 0;return(0,Ve.jsxs)(Ut.Container.Vertical,{align:u,children:[(0,Ve.jsx)(xn,{position:r,label:e,align:u}),o&&(0,Ve.jsx)(Ut.Container.Vertical,{align:u,padding:"2XS_NONE_NONE_NONE",children:(0,Ve.jsx)(gt,{children:o})})]})}var Gt=require("react/jsx-runtime");function wn(o){var r=o,{children:e}=r,t=w(r,["children"]);return(0,Gt.jsx)(hn,y(T({labelPosition:"TOP_START",size:"MD"},t),{children:e!=null?e:(0,Gt.jsx)(Fn,{})}))}var Nn=Object.assign(wn,{Toggle:De,Label:Me,Error:gt});var In=require("@mobilestockweb/container");var Hn=require("react/jsx-runtime");function Ln(o){var r=o,{children:e}=r,t=w(r,["children"]);return(0,Hn.jsx)(In.Container.Vertical,y(T({gap:"SM"},t),{children:e}))}var vi=Object.assign(oo,{Input:_o,Radio:un,Select:dn,Button:no,Counter:Mo,Vertical:Ln,Horizontal:zo,MultipleArchive:Tr,PhotoList:an,Switch:Nn});0&&(module.exports={Form,useForm});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestockweb/form",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"notistack": "^3.0.1",
|
|
@@ -14,15 +14,16 @@
|
|
|
14
14
|
"ua-parser-js": "^2.0.6",
|
|
15
15
|
"react-image-crop": "^11.0.10",
|
|
16
16
|
"react-modal": "^3.16.3",
|
|
17
|
-
"@mobilestockweb/button": "^1.0.
|
|
17
|
+
"@mobilestockweb/button": "^1.0.14",
|
|
18
18
|
"@mobilestockweb/badge": "^0.0.6",
|
|
19
|
-
"@mobilestockweb/snackbar": "^0.0.
|
|
20
|
-
"@mobilestockweb/tools": "^0.0.16",
|
|
19
|
+
"@mobilestockweb/snackbar": "^0.0.19",
|
|
21
20
|
"@mobilestockweb/typography": "^0.0.6",
|
|
22
|
-
"@mobilestockweb/
|
|
23
|
-
"@mobilestockweb/data-table": "^2.0.
|
|
21
|
+
"@mobilestockweb/tools": "^0.0.16",
|
|
22
|
+
"@mobilestockweb/data-table": "^2.0.2",
|
|
24
23
|
"@mobilestockweb/spacer": "^1.0.6",
|
|
25
|
-
"@mobilestockweb/
|
|
24
|
+
"@mobilestockweb/clickable": "^1.0.9",
|
|
25
|
+
"@mobilestockweb/container": "^1.0.0",
|
|
26
|
+
"@mobilestockweb/icons": "^0.2.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"axios": "^1.7.7",
|