@mobilestockweb/form 1.3.4 → 1.4.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 +57 -0
- package/index.js +32 -34
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -153,6 +153,58 @@ declare namespace Display {
|
|
|
153
153
|
|
|
154
154
|
type CounterEventName = 'INCREMENT' | 'DECREMENT' | 'EDIT';
|
|
155
155
|
|
|
156
|
+
declare const sizeMap: {
|
|
157
|
+
'2XS': {
|
|
158
|
+
slot: "1rem";
|
|
159
|
+
typography: "SM";
|
|
160
|
+
badge: "XS";
|
|
161
|
+
button: "2XS";
|
|
162
|
+
};
|
|
163
|
+
XS: {
|
|
164
|
+
slot: "1.375rem";
|
|
165
|
+
typography: "MD";
|
|
166
|
+
badge: "XS";
|
|
167
|
+
button: "XS";
|
|
168
|
+
};
|
|
169
|
+
SM: {
|
|
170
|
+
slot: "1.75rem";
|
|
171
|
+
typography: "LG";
|
|
172
|
+
badge: "XS";
|
|
173
|
+
button: "SM";
|
|
174
|
+
};
|
|
175
|
+
MD: {
|
|
176
|
+
slot: "2.125rem";
|
|
177
|
+
typography: "XL";
|
|
178
|
+
badge: "SM";
|
|
179
|
+
button: "MD";
|
|
180
|
+
};
|
|
181
|
+
LG: {
|
|
182
|
+
slot: "2.5rem";
|
|
183
|
+
typography: "2XL";
|
|
184
|
+
badge: "SM";
|
|
185
|
+
button: "LG";
|
|
186
|
+
};
|
|
187
|
+
XL: {
|
|
188
|
+
slot: "2.875rem";
|
|
189
|
+
typography: "3XL";
|
|
190
|
+
badge: "MD";
|
|
191
|
+
button: "XL";
|
|
192
|
+
};
|
|
193
|
+
'2XL': {
|
|
194
|
+
slot: "3.25rem";
|
|
195
|
+
typography: "3XL";
|
|
196
|
+
badge: "LG";
|
|
197
|
+
button: "2XL";
|
|
198
|
+
};
|
|
199
|
+
'3XL': {
|
|
200
|
+
slot: "3.625rem";
|
|
201
|
+
typography: "3XL";
|
|
202
|
+
badge: "LG";
|
|
203
|
+
button: "3XL";
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
type FormCounterSize = keyof typeof sizeMap;
|
|
207
|
+
|
|
156
208
|
interface CounterRootProps {
|
|
157
209
|
children?: React.ReactNode;
|
|
158
210
|
initialCount?: number;
|
|
@@ -185,6 +237,11 @@ interface CounterRootProps {
|
|
|
185
237
|
* @description If true, the counter elements (buttons and display) will be grouped together.
|
|
186
238
|
*/
|
|
187
239
|
groupElements?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* @default 'SM'
|
|
242
|
+
* @description Size of the counter — affects the buttons (+/-), the display and the badge.
|
|
243
|
+
*/
|
|
244
|
+
size?: FormCounterSize;
|
|
188
245
|
onChange?(data: {
|
|
189
246
|
value: number;
|
|
190
247
|
event: CounterEventName;
|
package/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
min-width:
|
|
3
|
-
height:
|
|
1
|
+
"use strict";var Vn=Object.create;var _e=Object.defineProperty,kn=Object.defineProperties,Bn=Object.getOwnPropertyDescriptor,$n=Object.getOwnPropertyDescriptors,_n=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols,Xn=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Kt=(e,t,o)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))Ct.call(t,o)&&Kt(e,o,t[o]);if(Qe)for(var o of Qe(t))qt.call(t,o)&&Kt(e,o,t[o]);return e},S=(e,t)=>kn(e,$n(t));var P=(e,t)=>{var o={};for(var r in e)Ct.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&Qe)for(var r of Qe(e))t.indexOf(r)<0&&qt.call(e,r)&&(o[r]=e[r]);return o};var Gn=(e,t)=>{for(var o in t)_e(e,o,{get:t[o],enumerable:!0})},Zt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _n(t))!Ct.call(e,n)&&n!==o&&_e(e,n,{get:()=>t[n],enumerable:!(r=Bn(t,n))||r.enumerable});return e};var L=(e,t,o)=>(o=e!=null?Vn(Xn(e)):{},Zt(t||!e||!e.__esModule?_e(o,"default",{value:e,enumerable:!0}):o,e)),Un=e=>Zt(_e({},"__esModule",{value:!0}),e);var je=(e,t,o)=>new Promise((r,n)=>{var u=a=>{try{s(o.next(a))}catch(l){n(l)}},i=a=>{try{s(o.throw(a))}catch(l){n(l)}},s=a=>a.done?r(a.value):Promise.resolve(a.value).then(u,i);s((o=o.apply(e,t)).next())});var yi={};Gn(yi,{Form:()=>Si,useForm:()=>H});module.exports=Un(yi);var no=require("@mobilestockweb/button");var Ee=require("react");var jt=require("@unform/web"),eo=require("notistack"),re=require("react"),to=require("zod"),oo=require("@mobilestockweb/container");var Xe=new Map;function Tt(e){let t=Xe.get(e);return t||(t={formRef:null,values:{},watchedFields:new Set,listeners:new Set},Xe.set(e,t)),t}function Yt(e,t){let o=Tt(e);o.formRef=t}function Jt(e){let t=Xe.get(e);t&&(t.formRef=null,t.values={},t.watchedFields.clear(),t.listeners.clear(),Xe.delete(e))}function Qt(e,t,o){let r=Xe.get(e);!r||!r.watchedFields.has(t)||r.values[t]===o||(r.values=S(E({},r.values),{[t]:o}),r.listeners.forEach(n=>n()))}var et=require("react/jsx-runtime"),Et=(0,re.createContext)({});function ro(s){var a=s,{children:e,onSubmit:t,onBeforeSubmit:o,onAfterSubmit:r,schema:n,name:u}=a,i=P(a,["children","onSubmit","onBeforeSubmit","onAfterSubmit","schema","name"]);let l=(0,re.useRef)(null),[f,h]=(0,re.useState)(!1);(0,re.useEffect)(()=>u?(Yt(u,l),()=>Jt(u)):()=>{},[u]);let c=(0,re.useCallback)((g,T)=>{u&&Qt(u,g,T)},[u]);function p(){var g;(g=l.current)==null||g.submitForm()}function m(){var g,T;(g=l.current)==null||g.setErrors({}),(T=l.current)==null||T.reset()}function b(g){let T={};for(let v of g){let y=v.path.filter(d=>typeof d=="string"||typeof d=="number").join(".");y&&(T[String(y)]=v.message)}return T}function R(g){if(g instanceof to.ZodError)return b(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 b(T)}return null}function C(v,y){return je(this,arguments,function*(g,{reset:T}){var d,w,z,k,O;if((d=l.current)==null||d.setErrors({}),n){let A=n.safeParse(g);if(!A.success){(w=l.current)==null||w.setErrors(b(A.error.issues));return}}if(!(o&&(yield o({data:g}))===!1))try{h(!0),yield t==null?void 0:t({data:g,ref:l,reset:T}),yield r==null?void 0:r({data:g})}catch(A){let x=R(A);if(x)(z=l.current)==null||z.setErrors(x);else{let D="Erro ao realizar opera\xE7\xE3o",_=500;if(typeof A=="object"&&A!==null&&"isAxiosError"in A&&A.isAxiosError){let Ke=A;_=((k=Ke.response)==null?void 0:k.status)||500;let we=(O=Ke.response)==null?void 0:O.data;we!=null&&we.message&&(D=we.message)}else A instanceof Error&&(D=A.message||D);(0,eo.enqueueSnackbar)(D,{variant:_>=500?"error":"warning"})}}finally{h(!1)}})}return(0,et.jsx)(Et.Provider,{value:{formRef:l,submitForm:p,clearForm:m,loading:f,notifyFieldChange:c},children:(0,et.jsx)(jt.Form,S(E({},i),{ref:l,onSubmit:C,children:(0,et.jsx)(oo.Container.Vertical,{gap:"2XS",children:e})}))})}var Wn={};function H(e){let t=(0,Ee.useContext)(Et),o=e?Tt(e):null,r=(0,Ee.useCallback)(i=>o?(o.listeners.add(i),()=>{o.listeners.delete(i)}):()=>{},[o]),n=(0,Ee.useCallback)(()=>o?o.values:Wn,[o]),u=(0,Ee.useSyncExternalStore)(r,n);return!e||!o?t:{get values(){var i,s,a;return(a=(s=(i=o.formRef)==null?void 0:i.current)==null?void 0:s.getData())!=null?a:{}},getValue(i){var s,a;return o.watchedFields.add(i),i in u?u[i]:(a=(s=o.formRef)==null?void 0:s.current)==null?void 0:a.getFieldValue(i)},setValue(i,s){var a,l;(l=(a=o.formRef)==null?void 0:a.current)==null||l.setFieldValue(i,s)},submit(){var i,s;(s=(i=o.formRef)==null?void 0:i.current)==null||s.submitForm()},clear(){var i,s,a,l;(s=(i=o.formRef)==null?void 0:i.current)==null||s.setErrors({}),(l=(a=o.formRef)==null?void 0:a.current)==null||l.reset()},setErrors(i){var s,a;(a=(s=o.formRef)==null?void 0:s.current)==null||a.setErrors(i)},reset(i){var s,a;(a=(s=o.formRef)==null?void 0:s.current)==null||a.reset(i)}}}var ao=require("react/jsx-runtime");function io(u){var i=u,{type:e="SUBMIT",disabled:t,isLoading:o,onClick:r}=i,n=P(i,["type","disabled","isLoading","onClick"]);let{submitForm:s,clearForm:a,loading:l}=H();function f(h){switch(h.preventDefault(),e){case"SUBMIT":s();break;case"RESET":a();break;default:r==null||r(h)}}return(0,ao.jsx)(no.Button,S(E({},n),{onClick:f,isLoading:e==="SUBMIT"&&l||o,disabled:l||o||t,type:e.toLowerCase()}))}var vt=L(require("styled-components")),go=require("@mobilestockweb/badge"),ho=require("@mobilestockweb/container"),bo=L(require("@mobilestockweb/tools")),Co=require("@mobilestockweb/typography");var so=require("@unform/core"),J=require("react");var mo=require("react/jsx-runtime"),lo=(0,J.createContext)(void 0);function uo(e){let{notifyFieldChange:t}=H(),{fieldName:o,registerField:r,error:n,defaultValue:u}=(0,so.useField)(e.name),[i,s]=(0,J.useState)(0),a=(0,J.useCallback)(c=>{let p=c;return e.maxCount!==void 0&&p>e.maxCount&&(p=e.maxCount),e.minCount!==void 0&&p<e.minCount&&(p=e.minCount),p},[e.maxCount,e.minCount]),l=(0,J.useCallback)((c,p=!0)=>{var b;let m=a(c);s(m),t==null||t(o,m),p&&((b=e.onChange)==null||b.call(e,{value:m,event:"EDIT"}))},[a,t,o]);(0,J.useEffect)(()=>{r({name:o,getValue:()=>i,setValue:(c,p)=>l(p),clearValue:()=>l(0)})},[o,i,r,l]),(0,J.useEffect)(()=>{l(Number(e.initialCount)||Number(u)||0,!1)},[e.initialCount,l,u]);function f(c=1){s(p=>{var b;let m=a(p+1*c);return t==null||t(o,m),(b=e.onChange)==null||b.call(e,{value:m,event:"INCREMENT"}),m})}function h(c=1){s(p=>{var b;let m=a(p-1*c);return t==null||t(o,m),(b=e.onChange)==null||b.call(e,{value:m,event:"DECREMENT"}),m})}return(0,mo.jsx)(lo.Provider,{value:{count:i,increment:f,decrement:h,configureCount:l,multiplier:e.multiplier,maxCount:e.maxCount,minCount:e.minCount,editable:e.editable,label:e.label,labelPosition:e.labelPosition,buttonTransparent:e.buttonTransparent,groupElements:e.groupElements,size:e.size,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 se={"2XS":{slot:"1rem",typography:"SM",badge:"XS",button:"2XS"},XS:{slot:"1.375rem",typography:"MD",badge:"XS",button:"XS"},SM:{slot:"1.75rem",typography:"LG",badge:"XS",button:"SM"},MD:{slot:"2.125rem",typography:"XL",badge:"SM",button:"MD"},LG:{slot:"2.5rem",typography:"2XL",badge:"SM",button:"LG"},XL:{slot:"2.875rem",typography:"3XL",badge:"MD",button:"XL"},"2XL":{slot:"3.25rem",typography:"3XL",badge:"LG",button:"2XL"},"3XL":{slot:"3.625rem",typography:"3XL",badge:"LG",button:"3XL"}};var co=L(require("styled-components")),po=require("@mobilestockweb/container");var fo=require("react/jsx-runtime");function ve(o){var r=o,{size:e="SM"}=r,t=P(r,["size"]);return(0,fo.jsx)(Kn,E({align:"CENTER",$size:e},t))}var Kn=(0,co.default)(po.Container.Vertical)`
|
|
2
|
+
min-width: 10px;
|
|
3
|
+
min-height: 20px;
|
|
4
4
|
user-select: none;
|
|
5
|
-
`;var
|
|
6
|
-
background-color: ${({$type:e,theme:t})=>{let o=
|
|
5
|
+
`;var Ge=require("react/jsx-runtime");function Ue(e){let{groupElements:t,size:o="SM"}=Q();return(0,Ge.jsx)(ve,{size:o,children:t&&e.renderInsidePill?(0,Ge.jsx)(qn,{$type:e.type,full:!0,align:"CENTER",children:(0,Ge.jsx)(Zn,{$type:e.type,children:e.text})}):(0,Ge.jsx)(go.Badge,{text:e.text,type:e.type,size:se[o].badge})})}function To(e,t){return Object.keys(t.colors.badge).find(o=>o.toLowerCase()===(e==null?void 0:e.toLowerCase()))||"default"}var qn=(0,vt.default)(ho.Container.Vertical)`
|
|
6
|
+
background-color: ${({$type:e,theme:t})=>{let o=To(e,t);return t.colors.badge[o]}};
|
|
7
7
|
width: 100%;
|
|
8
|
-
`,
|
|
9
|
-
color: ${({$type:e,theme:t})=>{let o=
|
|
10
|
-
`;
|
|
8
|
+
`,Zn=(0,vt.default)(Co.Typography)`
|
|
9
|
+
color: ${({$type:e,theme:t})=>{let o=To(e,t);return bo.default.defineTextColor(t.colors.badge[o])}};
|
|
10
|
+
`;Ue.displayName="Form.FormCounter.Badge";var ue=require("react"),j=require("@mobilestockweb/container"),Fo=L(require("@mobilestockweb/tools"));var We=L(require("styled-components")),Eo=require("@mobilestockweb/container");var vo=require("react/jsx-runtime");function Le(o){var r=o,{children:e}=r,t=P(r,["children"]);let{groupElements:n,error:u}=Q();return(0,vo.jsx)(Yn,S(E({align:"CENTER",$groupElements:n,$error:!!u},t),{children:e}))}var Yn=(0,We.default)(Eo.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&&We.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&&We.css`
|
|
21
21
|
background-color: ${t.colors.input.error};
|
|
22
22
|
border: 1px solid ${t.colors.alert.urgent};
|
|
23
23
|
`}
|
|
24
|
-
`;var
|
|
24
|
+
`;var So=require("@mobilestockweb/typography"),yo=require("react/jsx-runtime");function le({children:e}){return(0,yo.jsx)(So.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:e})}var Ro=require("@mobilestockweb/typography"),xo=require("react/jsx-runtime");function pe({children:e}){return(0,xo.jsx)(Ro.Typography,{weight:"REGULAR",children:e})}var I=require("react/jsx-runtime");function Po({children:e}){let{label:t,error:o,labelPosition:r}=Q(),n=[],u=[],i=(0,ue.useCallback)(a=>(0,ue.isValidElement)(a)&&a.type===ue.Fragment?i(a.props.children):a,[]),s=i(e);return ue.Children.toArray(s).forEach(a=>{(0,ue.isValidElement)(a)&&Fo.default.isComponentWithDisplayName(a.type)&&a.type.displayName===Ue.displayName&&!a.props.renderInsidePill?n.push(a):u.push(a)}),(0,I.jsxs)(j.Container.Vertical,{align:"CENTER_START",children:[r==="TOP_START"&&t&&(0,I.jsxs)(j.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,I.jsx)(pe,{children:t}),o&&!n.length&&(0,I.jsx)(le,{children:o})]}),r!=="LEFT"&&(0,I.jsxs)(j.Container.Vertical,{align:"CENTER",children:[(r!=="TOP_START"&&t||r!=="TOP_START"&&o&&!n.length)&&(0,I.jsxs)(j.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[t&&(0,I.jsx)(pe,{children:t}),o&&!n.length&&(0,I.jsx)(le,{children:o})]}),(0,I.jsxs)(j.Container.Horizontal,{align:"CENTER_START",children:[n.length>0&&(0,I.jsx)(j.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:n}),(0,I.jsxs)(j.Container.Vertical,{children:[(0,I.jsx)(Le,{children:u}),o&&!!n.length&&(0,I.jsx)(le,{children:o})]})]})]}),r==="LEFT"&&(0,I.jsx)(j.Container.Vertical,{children:(0,I.jsxs)(j.Container.Horizontal,{align:"CENTER",children:[(0,I.jsxs)(j.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[t&&(0,I.jsx)(pe,{children:t}),o&&!n.length&&(0,I.jsx)(le,{children:o})]}),n.length>0&&(0,I.jsx)(j.Container.Horizontal,{padding:"NONE_2XS_NONE_NONE",children:n}),(0,I.jsx)(Le,{children:u})]})})]})}var de=require("@mobilestockweb/container");var tt=require("react"),wo=L(require("styled-components")),Lo=require("@mobilestockweb/button");var St=require("react/jsx-runtime");function me(r){var n=r,{type:e,disabled:t}=n,o=P(n,["type","disabled"]);var p;let{loading:u}=H(),i=Q(),s=(0,tt.useRef)(null),a=(0,tt.useMemo)(()=>e==="PLUS"&&i.maxCount!==void 0?i.count>=i.maxCount:e==="MINUS"&&i.minCount!==void 0?i.count<=i.minCount:!1,[e,i.count,i.maxCount,i.minCount]);function l(){e==="PLUS"?i.increment():i.decrement()}function f(){s.current=setTimeout(()=>{"vibrate"in navigator&&navigator.vibrate(500),e==="PLUS"?i.increment(i.multiplier):i.decrement(i.multiplier)},500)}function h(){s.current&&(clearTimeout(s.current),s.current=null)}let c=(p=i.size)!=null?p:"SM";return(0,St.jsx)(ve,{size:c,children:(0,St.jsx)(Jn,S(E({type:"button",icon:e==="PLUS"?"Plus":"Minus",backgroundColor:e==="PLUS"?"DEFAULT_DARK":"CANCEL_DARK"},o),{size:se[c].button,variant:i.buttonTransparent?"TRANSPARENT":"DEFAULT",$grouped:i.groupElements,disabled:a||t||u,onClick:l,onMouseDown:f,onMouseUp:h,onMouseLeave:h,onTouchStart:f,onTouchEnd:h}))})}var Jn=(0,wo.default)(Lo.Button)`
|
|
25
25
|
border-radius: ${({$grouped:e,theme:t})=>e?t.borderRadius.none:t.borderRadius.default};
|
|
26
|
-
`;var
|
|
26
|
+
`;var Se=require("react"),No=L(require("styled-components")),Io=require("@mobilestockweb/clickable"),yt=require("@mobilestockweb/container"),Rt=require("@mobilestockweb/typography");var ce=require("react/jsx-runtime");function Ne(){let{count:e,editable:t,configureCount:o,autoFocus:r,onFocus:n,onBlur:u,size:i="SM"}=Q(),s=(0,Se.useRef)(null),[a,l]=(0,Se.useState)(r&&t),[f,h]=(0,Se.useState)(e.toString()),{typography:c}=se[i];(0,Se.useEffect)(()=>{h(e.toString())},[e]);function p(R){let C=Number(R.target.value);o(Number.isNaN(C)?0:C),l(!1),u==null||u()}function m(R){var C;R.key==="Enter"&&(R.preventDefault(),(C=s.current)==null||C.blur())}function b(R){R.target.select(),n==null||n()}return t?(0,ce.jsx)(Io.Clickable,{onClick:()=>l(!0),type:"button",children:(0,ce.jsx)(yt.Container.Horizontal,{padding:"NONE_2XS",children:(0,ce.jsx)(ve,{size:i,width:se[i].slot,children:a?(0,ce.jsx)(Qn,{"data-testid":"counter-input",ref:s,value:f,autoFocus:!0,onKeyDown:m,type:"text",inputMode:"numeric",$size:i,onChange:R=>h(R.target.value),onFocus:b,onBlur:p}):(0,ce.jsx)(Rt.Typography,{weight:"BOLD",size:c,children:e})})})}):(0,ce.jsx)(yt.Container.Horizontal,{padding:"NONE_2XS",children:(0,ce.jsx)(ve,{size:i,width:se[i].slot,children:(0,ce.jsx)(Rt.Typography,{weight:"BOLD",size:c,children:e})})})}var Qn=No.default.input`
|
|
27
27
|
&:focus {
|
|
28
28
|
outline: none;
|
|
29
29
|
box-shadow: none;
|
|
@@ -38,66 +38,64 @@
|
|
|
38
38
|
appearance: textfield;
|
|
39
39
|
-moz-appearance: textfield;
|
|
40
40
|
font-weight: bold;
|
|
41
|
-
font-size: ${({theme:e})=>{var
|
|
41
|
+
font-size: ${({theme:e,$size:t})=>{var o,r;return((r=(o=e==null?void 0:e.font)==null?void 0:o.size)==null?void 0:r[se[t].typography.toLowerCase()])||"16px"}};
|
|
42
42
|
text-align: center;
|
|
43
|
-
|
|
44
|
-
height: 34px;
|
|
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)`
|
|
43
|
+
`;Ne.displayName="Form.FormCounter.Display";var N=require("react/jsx-runtime");function zo(){let{label:e,labelPosition:t,error:o}=Q();return(0,N.jsxs)(de.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,N.jsxs)(de.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,N.jsx)(pe,{children:e}),o&&(0,N.jsx)(le,{children:o})]}),t!=="LEFT"&&(0,N.jsxs)(de.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,N.jsxs)(de.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,N.jsx)(pe,{children:e}),o&&(0,N.jsx)(le,{children:o})]}),(0,N.jsxs)(Le,{children:[(0,N.jsx)(me,{type:"MINUS"}),(0,N.jsx)(Ne,{}),(0,N.jsx)(me,{type:"PLUS"})]})]}),t==="LEFT"&&(0,N.jsx)(de.Container.Vertical,{children:(0,N.jsxs)(de.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,N.jsxs)(de.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,N.jsx)(pe,{children:e}),o&&(0,N.jsx)(le,{children:o})]}),(0,N.jsxs)(Le,{children:[(0,N.jsx)(me,{type:"MINUS"}),(0,N.jsx)(Ne,{}),(0,N.jsx)(me,{type:"PLUS"})]})]})})]})}var ot=require("react/jsx-runtime");function Mo(o){var r=o,{children:e}=r,t=P(r,["children"]);return(0,ot.jsx)(uo,S(E({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,ot.jsx)(Po,{children:e}):(0,ot.jsx)(zo,{})}))}var Ho=require("react/jsx-runtime");function xt(e){return(0,Ho.jsx)(me,S(E({},e),{type:"MINUS"}))}xt.displayName="Form.FormCounter.Minus";var Oo=require("react/jsx-runtime");function Ft(e){return(0,Oo.jsx)(me,S(E({},e),{type:"PLUS"}))}Ft.displayName="Form.FormCounter.Plus";var Ao=Object.assign(Mo,{Display:Ne,Plus:Ft,Minus:xt,Badge:Ue});var Do=require("@mobilestockweb/container");var ko=require("react/jsx-runtime");function Vo(o){var r=o,{children:e}=r,t=P(r,["children"]);return(0,ko.jsx)(Do.Container.Horizontal,S(E({gap:"SM"},t),{children:e}))}var Bo=require("@unform/core"),V=require("react"),ye=L(require("styled-components")),$o=require("@mobilestockweb/button"),Lt=require("@mobilestockweb/container"),Pt=L(require("@mobilestockweb/tools")),wt=require("@mobilestockweb/typography");var ne=require("react/jsx-runtime"),_o=(0,V.forwardRef)(function(b,m){var R=b,{name:t,type:o="text",full:r,label:n,maxLength:u,autoSubmit:i=!1,defaultValue:s,numberOfLines:a=1,showMaxContent:l=!1,autoCapitalize:f,format:h,onChange:c}=R,p=P(R,["name","type","full","label","maxLength","autoSubmit","defaultValue","numberOfLines","showMaxContent","autoCapitalize","format","onChange"]);let C=(0,ye.useTheme)(),{loading:g,notifyFieldChange:T}=H(),v=(0,Bo.useField)(t),y=a>1,d=(0,V.useRef)(null),[w,z]=(0,V.useState)(!1),[k,O]=(0,V.useState)(""),A=o==="password",x=o==="tel"?15:o==="zipcode"?9:u,D=t+"-input"+(0,V.useId)(),_={width:"100%",border:"none",outline:"none",backgroundColor:"transparent",fontFamily:C.font.families[0],lineHeight:C.font.lineHeight,fontSize:C.font.size.sm,color:C.colors.text.default},Ke=S(E({},_),{height:"2.5rem"}),we=S(E({},_),{padding:"10px 0",display:"block",resize:"none",overflow:"hidden",boxSizing:"border-box"}),Hn=(0,V.useMemo)(()=>o==="password"?w?"text":"password":o,[o,w]),qe=(0,V.useCallback)(()=>{if(!y||!d.current)return;let M=d.current,F=window.getComputedStyle(M),Y=parseInt(F.lineHeight,10);isNaN(Y)&&(Y=parseInt(F.fontSize,10)*C.font.lineHeight);let Ze=parseInt(F.paddingTop,10),Te=parseInt(F.paddingBottom,10),Ye=Y*a+Ze+Te+1,$e=parseFloat(getComputedStyle(document.documentElement).fontSize)*2.5;if(l)M.style.height=Ye+"px";else{M.style.height="0";let Je=M.scrollHeight;M.style.height=Math.max($e,Math.min(Je,Ye))+"px"}},[y,a,l,C.font.lineHeight]),Wt=(0,V.useCallback)(M=>{var Y,Ze;let F=M.target.value;switch(o){case"tel":F=Pt.default.phoneNumberFormatter(F);break;case"email":case"url":F=F.trim();break;case"zipcode":F=Pt.default.formatZipcode(F);break}if(h&&(F=h(F)),y&&a&&d.current){let Te=d.current;Te.value=F,Te.style.height="auto";let Ye=Te.scrollHeight,Be=window.getComputedStyle(Te),$e=parseInt(Be.lineHeight,10);isNaN($e)&&($e=parseInt(Be.fontSize,10)*C.font.lineHeight);let Je=parseInt(Be.paddingTop,10),An=parseInt(Be.paddingBottom,10),Dn=$e*(a+1)+Je+An+1;if(Ye>Dn){Te.value=k,qe();return}}O(F),M.target.value=F,d.current.value=F,c==null||c({value:F,event:"INPUT_CHANGE"}),T==null||T(t,F),o==="tel"&&i&&F.length===15&&((Y=d.current)!=null&&Y.form)&&(c==null||c({value:F,event:"AUTO_SUBMIT"}),d.current.form.requestSubmit(),d.current.blur()),o==="zipcode"&&i&&F.length===9&&((Ze=d.current)!=null&&Ze.form)&&(c==null||c({value:F,event:"AUTO_SUBMIT"}),d.current.form.requestSubmit(),d.current.blur())},[o,h,i,c,v,T,y,a,k,qe]);(0,V.useEffect)(()=>{let M=k||s||(v==null?void 0:v.defaultValue)||"";d.current.value=M,O(M),v.registerField({name:v.fieldName,ref:d,getValue:F=>{var Y;return((Y=F.current)==null?void 0:Y.value)||""},setValue:(F,Y)=>{F.current&&(F.current.value=Y,O(Y))},clearValue:F=>{F.current&&(F.current.value="",O(""))}})},[v==null?void 0:v.fieldName,v==null?void 0:v.registerField]),(0,V.useEffect)(()=>{qe()},[k,qe]),(0,V.useImperativeHandle)(m,()=>({focus(){var M;(M=d.current)==null||M.focus()},blur(){var M;(M=d.current)==null||M.blur()}}));function On(){z(M=>(c==null||c({value:!M,event:"TOGGLE_PASSWORD"}),!M))}return(0,ne.jsxs)(jn,{full:r,$show:o!=="hidden",children:[n&&(0,ne.jsx)("label",{htmlFor:D,children:(0,ne.jsx)(wt.Typography,{children:n})}),(0,ne.jsxs)(ei,{$error:!!(v!=null&&v.error),$isPassword:A,children:[y?(0,ne.jsx)("textarea",S(E({},p),{ref:d,id:D,value:k,onChange:Wt,maxLength:x,disabled:g||p.disabled,style:we})):(0,ne.jsx)("input",S(E({},p),{ref:d,id:D,value:k,onChange:Wt,maxLength:x,type:Hn,disabled:g||p.disabled,style:Ke})),A&&(0,ne.jsx)($o.Button,{size:"SM",onClick:On,icon:w?"EyeOutline":"EyeOff",variant:"TRANSPARENT",type:"button"})]}),!!(v!=null&&v.error)&&(0,ne.jsx)(wt.Typography,{color:"DANGER",size:"SM",children:v==null?void 0:v.error})]})}),jn=(0,ye.default)(Lt.Container.Vertical)`
|
|
46
44
|
${({$show:e})=>!e&&ye.css`
|
|
47
45
|
display: none;
|
|
48
46
|
`}
|
|
49
|
-
`,
|
|
47
|
+
`,ei=(0,ye.default)(Lt.Container.Horizontal)`
|
|
50
48
|
overflow: hidden;
|
|
51
49
|
background-color: ${({$error:e,theme:t})=>e?t.colors.input.error:t.colors.input.default};
|
|
52
50
|
border: 1px solid ${({$error:e,theme:t})=>e?t.colors.alert.urgent:t.colors.input.border};
|
|
53
51
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
54
52
|
padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
|
|
55
|
-
`;var
|
|
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
|
|
53
|
+
`;var hr=require("@unform/core"),br=require("react"),Cr=L(require("styled-components")),mt=require("@mobilestockweb/container");var Xo=require("@unform/core"),ee=require("react");var ti=1.775,oi=.125,ri=.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*oi,r=t-2*o,n=t*ti,u=n-r-2*o,i=r*ri;return{width:this.toRem(n),height:this.toRem(t),handle:this.toRem(r),translate:this.toRem(u),offset:this.toRem(o),iconSize:this.toRem(i)}},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 Wo=require("react/jsx-runtime"),Go=(0,ee.createContext)(null);function Uo({children:e,accept:t,onChange:o,name:r}){let{notifyFieldChange:n}=H(),{fieldName:u,registerField:i,defaultValue:s}=(0,Xo.useField)(r),[a,l]=(0,ee.useState)(null),f=(0,ee.useCallback)(m=>{let b=m.map(y=>({file:y,hash:B.getHashFile(y)})),R=(a||[]).map(y=>({file:y,hash:B.getHashFile(y)})),C=[...b,...R],g=Array.from(new Set(C.map(y=>y.hash))).map(y=>C.find(d=>d.hash===y)),T=g.filter(y=>b.some(d=>d.hash===y.hash));if(!T.length)return;let v=g.map(y=>y.file);l(v),n==null||n(u,v),o==null||o({value:T.map(y=>y.file),event:"ADD_FILES"})},[a,o,n,u]),h=(0,ee.useCallback)(m=>{if(!m){l(null);return}let b=m.filter(R=>!!R);f(b)},[f,l]);(0,ee.useEffect)(()=>{i({name:u,getValue:()=>a,setValue:(m,b)=>h(b||s),clearValue:()=>l(null)})},[u,i,a,h,s]),(0,ee.useEffect)(()=>{l(null)},[t]);function c(m){if(!a)return;let b=a.filter(R=>B.getHashFile(R)!==m);l(b),n==null||n(u,b),o==null||o({value:a.find(R=>B.getHashFile(R)===m),event:"REMOVE_FILE"})}function p(){let m=document.createElement("input");m.style.display="none",m.setAttribute("type","file"),m.setAttribute("accept","*/*"),m.setAttribute("id",String(Math.random())),m.setAttribute("multiple","multiple"),document.body.appendChild(m),m.addEventListener("change",()=>{m.files&&f(Array.from(m.files)),document.body.removeChild(m)});let b=new MouseEvent("click");m.dispatchEvent(b)}return(0,Wo.jsx)(Go.Provider,{value:{handleSelectFile:p,handleSaveFiles:f,handleRemoveFile:c,accept:t,files:a,name:r},children:e})}function ie(){let e=(0,ee.useContext)(Go);if(!e)throw new Error("useMultipleArchive must be used within a MultipleArchiveProvider");return e}var rt={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=["|",",",";"," ",`
|
|
54
|
+
`," ","\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 er=require("@mobilestockweb/container"),tr=require("@mobilestockweb/spacer");var Ko=require("@unform/core"),qo=require("@mobilestockweb/typography");var Zo=require("react/jsx-runtime");function nt(){let e=ie(),{error:t}=(0,Ko.useField)(e.name);return(0,Zo.jsx)(qo.Typography,{color:"DANGER",size:"XS",children:t})}var Yo=require("@mobilestockweb/button"),Jo=require("react/jsx-runtime");function it(){return(0,Jo.jsx)(Yo.Button,{type:"button",text:"Selecionar arquivo",size:"XS"})}var at=require("@mobilestockweb/typography");var fe=require("react/jsx-runtime");function st(){var t,o;let e=ie();return(t=e.accept)!=null&&t.includes("all")?(0,fe.jsx)(at.Typography,{size:"XS",children:"Todos os tipos de arquivos s\xE3o suportados"}):(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(at.Typography,{size:"XS",children:"Arquivos suportados"}),(0,fe.jsxs)(at.Typography,{size:"XS",children:["( ",(o=e.accept)==null?void 0:o.join(", ")," )"]})]})}var Qo=require("@mobilestockweb/typography"),jo=require("react/jsx-runtime");function lt({children:e}){return(0,jo.jsx)(Qo.Typography,{size:"LG",weight:"REGULAR",children:e||"Arraste o arquivo para c\xE1"})}var ge=require("react/jsx-runtime");function or(){var t;let e=ie();return(0,ge.jsxs)(er.Container.Vertical,{align:"CENTER",children:[(0,ge.jsx)(lt,{}),(0,ge.jsx)(tr.Spacer,{size:"2XS"}),(0,ge.jsx)(it,{}),(0,ge.jsx)(nt,{}),(t=e.accept)!=null&&t.includes("all")?null:(0,ge.jsx)(st,{})]})}var rr=L(require("chroma-js")),nr=require("react"),ir=require("styled-components");var sr=require("react/jsx-runtime");function ar(e){let t=ie(),o=(0,ir.useTheme)(),[r,n]=(0,nr.useState)(!1);function u(i){var l;i.preventDefault(),n(!1);let s=i.dataTransfer;if(!s)return;let a=[];if(s.items&&s.items.length>0)for(let f=0;f<s.items.length;f++){let h=s.items[f];if(h.kind!=="file")continue;let c=h.webkitGetAsEntry();if(c&&c.isDirectory)continue;let p=h.getAsFile();p&&a.push(p)}else if(s.files&&s.files.length>0)for(let f=0;f<s.files.length;f++){let h=s.files.item(f);h&&a.push(h)}a.length!==0&&((l=t.accept)!=null&&l.some(f=>f!=="all")&&(a=a.filter(f=>{var c;let h=f.name.split(".").pop();return(c=t.accept)==null?void 0:c.includes(h==null?void 0:h.toLowerCase())}),!a.length)||t.handleSaveFiles(a))}return(0,sr.jsx)("div",E({onDragOver:i=>{i.preventDefault(),n(!0)},onDrop:u,onDragLeave:i=>{i.preventDefault(),n(!1)},style:E({},r?{backgroundColor:(0,rr.default)(o.colors.formMultipleArchive.droppableArea).alpha(.5).css()}:void 0),onClick:t.handleSelectFile},e))}var lr=require("react"),Nt=L(require("styled-components")),ur=require("@mobilestockweb/button"),mr=require("@mobilestockweb/clickable"),he=require("@mobilestockweb/container"),cr=require("@mobilestockweb/icons"),ut=require("@mobilestockweb/typography");var $=require("react/jsx-runtime");function pr(){var r,n,u;let e=ie(),[t,o]=(0,lr.useState)(!1);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(he.Container.Horizontal,{align:"END",children:!!((r=e.files)!=null&&r.length)&&(0,$.jsx)(mr.Clickable,{type:"button","data-testid":"flip-button",onClick:()=>o(!t),children:(0,$.jsxs)(he.Container.Horizontal,{align:"CENTER",children:[(0,$.jsxs)(ut.Typography,{size:"XS",children:[(n=e.files)==null?void 0:n.length," arquivos"]}),(0,$.jsx)(ni,{"data-testid":"flip-icon-container","data-flip":t,$flip:t,children:(0,$.jsx)(cr.Icon,{name:"ChevronDown",size:"XS"})})]})})}),(0,$.jsx)(ii,{"data-testid":"multiple-archive-list","data-open":t,$flip:t,children:(u=e.files)==null?void 0:u.map((i,s)=>(0,$.jsxs)(he.Container.Horizontal,{align:"START_CENTER",children:[(0,$.jsxs)(he.Container.Horizontal,{gap:"SM",full:!0,children:[(0,$.jsx)(ut.Typography,{size:"XS",weight:"MEDIUM",children:i.name.slice(0,20)}),i.size&&(0,$.jsx)(ut.Typography,{size:"XS",children:rt.convertBytesToReadableFormat(i.size)})]}),(0,$.jsx)(he.Container.Vertical,{children:(0,$.jsx)(ur.Button,{variant:"TRANSPARENT",icon:"Trash",backgroundColor:"CANCEL_DARK",size:"XS","data-testid":`trash-button-${s}`,onClick:()=>e.handleRemoveFile(`${i.name}-${i.size}`)})})]},s))})]})}var ni=(0,Nt.default)(he.Container.Horizontal)`
|
|
57
55
|
transform: ${({$flip:e})=>e?"rotate(180deg)":"rotate(0deg)"};
|
|
58
56
|
transition: transform 0.3s ease;
|
|
59
|
-
`,
|
|
57
|
+
`,ii=(0,Nt.default)(he.Container.Vertical)`
|
|
60
58
|
display: ${({$flip:e})=>e?"flex":"none"};
|
|
61
59
|
max-height: 200px;
|
|
62
60
|
overflow-y: auto;
|
|
63
|
-
`;var
|
|
61
|
+
`;var dr=require("@mobilestockweb/typography"),gr=require("react/jsx-runtime");function fr({children:e}){return(0,gr.jsx)(dr.Typography,{children:e})}var ae=require("react/jsx-runtime");function Tr(o){var r=o,{accept:e}=r,t=P(r,["accept"]);let{error:n}=(0,hr.useField)(t.name),u=(0,br.useMemo)(()=>rt.parseAcceptString(e),[e]);return(0,ae.jsx)(Uo,S(E({},t),{accept:u,children:(0,ae.jsxs)(mt.Container.Vertical,{gap:"2XS",children:[(0,ae.jsx)(mt.Container.Horizontal,{align:t.alignLabel||"START",children:(0,ae.jsx)(fr,{children:t.label})}),(0,ae.jsxs)(ai,{$error:!!n,padding:"MD",children:[(0,ae.jsx)(ar,{children:t.children||(0,ae.jsx)(or,{})}),(0,ae.jsx)(pr,{})]})]})}))}var ai=(0,Cr.default)(mt.Container.Vertical)`
|
|
64
62
|
border: 1px solid ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.border};
|
|
65
63
|
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
66
64
|
background-color: ${({theme:e,$error:t})=>t?e.colors.input.error:e.colors.input.default};
|
|
67
65
|
min-width: 400px;
|
|
68
|
-
`;var
|
|
66
|
+
`;var Er=Object.assign(Tr,{Title:lt,HelpButton:it,HelpText:st,ErrorLabel:nt});var U=require("@dnd-kit/core"),rn=require("@dnd-kit/modifiers"),Ce=require("@dnd-kit/sortable"),Me=require("react"),nn=require("styled-components"),dt=require("@mobilestockweb/container");var vr=require("@unform/core"),X=require("react"),Sr=require("styled-components");var xr=require("react/jsx-runtime"),yr=(0,X.createContext)(null);function Rr({gap:e="2XS",size:t="SM",name:o,children:r,onChange:n,multiple:u,dragAndDrop:i,buttonAddDirection:s}){let a=(0,Sr.useTheme)(),{notifyFieldChange:l}=H(),{fieldName:f,registerField:h,defaultValue:c}=(0,vr.useField)(o),[p,m]=(0,X.useState)(null),[b,R]=(0,X.useState)(!1),[C,g]=(0,X.useState)(null),T=(0,X.useMemo)(()=>a.sizeImage[t.toLowerCase()],[a,t]),v=(0,X.useMemo)(()=>a.gaps[e.toLowerCase()],[a,e]),y=(0,X.useCallback)(x=>{m(s==="RIGHT"?D=>{let _=[...D||[],...x].reverse();return l==null||l(f,_),_}:D=>{let _=[...D||[],...x];return l==null||l(f,_),_})},[m,s,l,f]),d=(0,X.useCallback)(x=>{if(!x){m(null);return}y(x)},[y]);(0,X.useEffect)(()=>{h({name:f,getValue:()=>p,setValue:(x,D)=>d(D||c),clearValue:()=>m(null)})},[f,h,p,d,c]);function w(){let x=document.createElement("input");x.style.display="none",x.setAttribute("type","file"),x.setAttribute("accept","image/*"),x.setAttribute("id",String(Math.random())),u&&x.setAttribute("multiple","multiple"),document.body.appendChild(x),x.addEventListener("change",()=>{x.files&&(u?y(Array.from(x.files)):(R(!0),g(Array.from(x.files)[0])),document.body.removeChild(x))});let D=new MouseEvent("click");x.dispatchEvent(D)}function z(x){if(!p)return;let D=p.filter(_=>`${_.name}-${_.size}`!==x);m(D),l==null||l(f,D),n==null||n({value:p.find(_=>`${_.name}-${_.size}`===x),event:"REMOVE_IMAGE"})}function k(x){m(x),l==null||l(f,x),n==null||n({value:x,event:"REORDER_IMAGES"})}function O(x){y([x]),R(!1),g(null),n==null||n({value:x,event:"CROP_SAVE"})}function A(){R(!1),g(null)}return(0,xr.jsx)(yr.Provider,{value:{showDeviceImage:w,images:p,removeImage:z,reorderImages:k,openImageCropModal:b,imageToCrop:C,handleImageCropCancel:A,handleImageCropSave:O,sizeComponent:T,gapComponent:v,dragAndDrop:i,name:o,gap:e},children:r})}function K(){let e=(0,X.useContext)(yr);if(!e)throw new Error("usePhotoList must be used within a PhotoListProvider");return e}var Fr=require("@mobilestockweb/button");var Pr=require("react/jsx-runtime");function It(){let e=K();return(0,Pr.jsx)(Fr.Button,{type:"button",icon:"Plus",variant:"OUTLINE",onClick:e.showDeviceImage,style:{height:e.sizeComponent,width:e.sizeComponent,minWidth:e.sizeComponent,maxWidth:e.sizeComponent}})}var wr=require("@unform/core"),Lr=require("@mobilestockweb/typography");var Ir=require("react/jsx-runtime");function Nr(){let e=K(),{error:t}=(0,wr.useField)(e.name);return(0,Ir.jsx)(Lr.Typography,{color:"DANGER",size:"XS",children:t})}var Gr=require("@dnd-kit/sortable"),Ur=require("@dnd-kit/utilities"),pt=require("react"),Wr=require("styled-components"),Kr=require("@mobilestockweb/container");var Ar=require("@dnd-kit/sortable"),Dr=L(require("styled-components")),Vr=require("@mobilestockweb/container");var zr=require("@dnd-kit/sortable"),Mr=L(require("styled-components")),Or=require("react/jsx-runtime");function Hr({id:e}){let{isDragging:t}=(0,zr.useSortable)({id:e});return(0,Or.jsx)(si,{$isDragging:t})}var si=Mr.default.div`
|
|
69
67
|
height: 5px;
|
|
70
68
|
width: 90%;
|
|
71
69
|
background-color: ${({theme:e,$isDragging:t})=>t?e.colors.formPhotoList.highlightBar:e.colors.formPhotoList.defaultBar};
|
|
72
|
-
`;var
|
|
70
|
+
`;var zt=require("react/jsx-runtime");function kr({id:e}){let t=K(),{listeners:o,attributes:r}=(0,Ar.useSortable)({id:e});return(0,zt.jsx)(li,S(E(E({$sizeComponent:t.sizeComponent,align:"CENTER"},o),r),{children:(0,zt.jsx)(Hr,{id:e})}))}var li=(0,Dr.default)(Vr.Container.Horizontal)`
|
|
73
71
|
padding: 4px 12px;
|
|
74
72
|
position: absolute;
|
|
75
73
|
bottom: 0;
|
|
76
74
|
width: ${({$sizeComponent:e})=>e};
|
|
77
75
|
background-color: ${({theme:e})=>e.colors.formPhotoList.controlBar};
|
|
78
|
-
`;var ct=
|
|
76
|
+
`;var ct=L(require("styled-components")),Br=require("@mobilestockweb/clickable"),$r=require("@mobilestockweb/icons"),_r=L(require("@mobilestockweb/tools"));var Mt=require("react/jsx-runtime");function Xr({id:e}){let t=K(),o=(0,ct.useTheme)();function r(){t.removeImage(e)}return(0,Mt.jsx)(ui,{onClick:r,children:(0,Mt.jsx)($r.Icon,{name:"X",size:"XS",color:_r.default.defineTextColor(o.colors.formPhotoList.trashButton)})})}var ui=(0,ct.default)(Br.Clickable)`
|
|
79
77
|
position: absolute;
|
|
80
78
|
top: 0;
|
|
81
79
|
right: 0;
|
|
82
80
|
z-index: 1;
|
|
83
81
|
border-bottom-left-radius: 4px;
|
|
84
82
|
background-color: ${e=>e.theme.colors.formPhotoList.trashButton};
|
|
85
|
-
`;var Ie=require("react/jsx-runtime");function
|
|
83
|
+
`;var Ie=require("react/jsx-runtime");function mi({file:e}){let t=(0,Wr.useTheme)(),o=K(),{setNodeRef:r,transform:n,transition:u,isDragging:i}=(0,Gr.useSortable)({id:B.getHashFile(e)}),s=(0,pt.useMemo)(()=>URL.createObjectURL(e),[e]);return(0,Ie.jsxs)(Kr.Container.Vertical,{ref:r,align:"CENTER",style:S(E({borderColor:t.colors.formPhotoList.controlBar,borderStyle:"solid",borderWidth:1},i&&{borderColor:t.colors.formPhotoList.highlightBar}),{transform:Ur.CSS.Transform.toString(n),transition:u,zIndex:i?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)(Xr,{id:B.getHashFile(e)}),(0,Ie.jsx)("img",{alt:"image",style:{width:"100%",objectFit:"cover"},src:s}),o.dragAndDrop&&(0,Ie.jsx)(kr,{id:B.getHashFile(e)})]})}var qr=(0,pt.memo)(mi);var Zr=require("@mobilestockweb/typography"),Jr=require("react/jsx-runtime");function Yr({children:e}){return(0,Jr.jsx)(Zr.Typography,{children:e})}var te=require("react"),tn=require("react-image-crop"),ze=L(require("styled-components")),At=require("@mobilestockweb/button"),Re=require("@mobilestockweb/container");var be=require("react"),Ht=L(require("react-modal")),Qr=require("styled-components"),jr=require("ua-parser-js");var Ot=require("react/jsx-runtime");function en(o){var r=o,{children:e}=r,t=P(r,["children"]);let n=(0,Qr.useTheme)(),[u,i]=(0,be.useState)(!1),[s,a]=(0,be.useState)(void 0),l=(0,be.useCallback)(()=>(0,jr.UAParser)(window.navigator.userAgent).device.type==="mobile"||window.innerWidth<=768,[]),f=(0,be.useCallback)(()=>{i(l()),a(window.innerHeight)},[l]);return(0,be.useEffect)(()=>(i(l()),a(window.innerHeight),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[l,f]),u?(0,Ot.jsx)(Ht.default,S(E({ariaHideApp:!1,style:{content:{top:0,left:0,right:0,bottom:0,padding:0,margin:0,borderRadius:0,border:"none",height:s?`${s}px`:"100vh",maxHeight:s?`${s}px`:"100vh",boxSizing:"border-box"}}},t),{children:e})):(0,Ot.jsx)(Ht.default,S(E({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 on(){let e=K(),t=(0,te.useRef)(null),o=(0,te.useRef)(null),[r,n]=(0,te.useState)(),[u,i]=(0,te.useState)(),[s,a]=(0,te.useState)(),l=(0,te.useMemo)(()=>e.imageToCrop?URL.createObjectURL(e.imageToCrop):void 0,[e.imageToCrop]);(0,te.useEffect)(()=>{e.imageToCrop||(n(void 0),i(void 0),a(void 0))},[e.imageToCrop,e.openImageCropModal]);function f({displayWidth:p,displayHeight:m,naturalWidth:b,naturalHeight:R}){i({displayWidth:p,displayHeight:m,naturalWidth:b,naturalHeight:R});let C=Math.min(p,m);n({unit:"px",width:C,height:C,x:p>m?(p-C)/2:0,y:m>p?(m-C)/2:0})}function h(){return je(this,null,function*(){if(!e.imageToCrop||!r||!u)return;let p=u.naturalWidth/u.displayWidth,m=u.naturalHeight/u.displayHeight,b=r.x*p,R=r.y*m,C=r.width*p,g=r.height*m,T=new OffscreenCanvas(C,g),v=T.getContext("2d"),y=new Image;y.src=URL.createObjectURL(e.imageToCrop),yield new Promise(z=>{y.onload=()=>z()}),v.drawImage(y,b,R,C,g,0,0,C,g);let d=yield T.convertToBlob({type:"image/png",quality:1}),w="";if(!e.imageToCrop.name)w="image-cropped.png";else{let z=e.imageToCrop.name.split(".");z.pop(),w=z.join(".")+"-cropped.png"}e.handleImageCropSave(new File([d],w,{type:"image/png",lastModified:Date.now()}))})}function c(p){let m=p.currentTarget,b=o.current,R=b.clientWidth,C=b.clientHeight,g=m.naturalWidth,T=m.naturalHeight,v=Math.min(R/g,C/T),y=g*v,d=T*v;a({width:y,height:d}),f({displayWidth:y,displayHeight:d,naturalWidth:g,naturalHeight:T})}return(0,Z.jsx)(en,{isOpen:e.openImageCropModal,children:(0,Z.jsxs)(Re.Container.Vertical,{full:!0,padding:"NONE_XS_XS_XS",style:{height:"100%",maxHeight:"100%",boxSizing:"border-box"},gap:"MD",children:[(0,Z.jsx)(Re.Container.Vertical,{full:!0,align:"CENTER",style:{minHeight:0},children:(0,Z.jsx)(ci,{ref:o,align:"CENTER",children:(0,Z.jsx)(pi,{crop:r,width:s==null?void 0:s.width,height:s==null?void 0:s.height,onChange:p=>n(p),children:(0,Z.jsx)(di,{src:l,ref:t,"data-testid":"image-to-crop",onLoad:c})})})}),(0,Z.jsxs)(Re.Container.Horizontal,{gap:"MD",children:[(0,Z.jsx)(Re.Container.Vertical,{full:!0,children:(0,Z.jsx)(At.Button,{onClick:e.handleImageCropCancel,text:"Cancelar",backgroundColor:"CANCEL_DARK"})}),(0,Z.jsx)(Re.Container.Vertical,{full:!0,children:(0,Z.jsx)(At.Button,{onClick:h,text:"Salvar"})})]})]})})}var ci=(0,ze.default)(Re.Container.Vertical)`
|
|
86
84
|
width: 100%;
|
|
87
85
|
height: 100%;
|
|
88
86
|
min-height: 0;
|
|
89
87
|
padding-left: 16px;
|
|
90
88
|
padding-right: 16px;
|
|
91
|
-
`,
|
|
92
|
-
${({width:e,height:t})=>e&&t&&
|
|
89
|
+
`,pi=(0,ze.default)(tn.ReactCrop)`
|
|
90
|
+
${({width:e,height:t})=>e&&t&&ze.css`
|
|
93
91
|
width: ${e}px;
|
|
94
92
|
height: ${t}px;
|
|
95
93
|
display: inline-flex;
|
|
96
94
|
`}
|
|
97
|
-
`,
|
|
95
|
+
`,di=ze.default.img``;var G=require("react/jsx-runtime");function an({numberOfImagesVisible:e,buttonAddDirection:t,label:o,alignLabel:r}){var b,R;let n=K(),u=(0,nn.useTheme)(),i=(0,U.useSensors)((0,U.useSensor)(U.MouseSensor),(0,U.useSensor)(U.TouchSensor),(0,U.useSensor)(U.KeyboardSensor,{coordinateGetter:Ce.sortableKeyboardCoordinates})),[s,a]=(0,Me.useState)(null),l=(0,Me.useId)();function f(C){var T;return((T=n.images)==null?void 0:T.findIndex(v=>B.getHashFile(v)===C))||0}let h=s?f(s):-1;function c({over:C}){if(a(null),C){let g=f(C.id);if(h!==g){let T=(0,Ce.arrayMove)(n.images,h,g);n.reorderImages(T)}}}function p({active:C}){C&&a(C.id)}let m=(0,Me.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)(dt.Container.Horizontal,{align:r||"START",children:(0,G.jsx)(Yr,{children:o})}),(0,G.jsx)(U.DndContext,{id:l,sensors:i,collisionDetection:U.closestCenter,onDragCancel:()=>a(null),onDragStart:p,onDragEnd:c,modifiers:[rn.restrictToHorizontalAxis],children:(0,G.jsxs)(dt.Container.Horizontal,{align:"START_CENTER",gap:n.gap,children:[t==="LEFT"&&(0,G.jsx)(It,{}),(0,G.jsx)(Ce.SortableContext,{items:((b=n.images)==null?void 0:b.map(C=>B.getHashFile(C)))||[],strategy:Ce.horizontalListSortingStrategy,children:(0,G.jsx)(dt.Container.Horizontal,{gap:n.gap,style:{flexBasis:"max-content",overflowX:"scroll",paddingBottom:u.spacing["2xs"],maxWidth:m},children:(R=n.images)==null?void 0:R.map(C=>(0,G.jsx)(qr,{file:C},B.getHashFile(C)))})}),t==="RIGHT"&&(0,G.jsx)(It,{})]})}),(0,G.jsx)(Nr,{}),(0,G.jsx)(on,{})]})}var Dt=require("react/jsx-runtime");function sn(u){var i=u,{label:e,alignLabel:t,buttonAddDirection:o="LEFT",numberOfImagesVisible:r=0}=i,n=P(i,["label","alignLabel","buttonAddDirection","numberOfImagesVisible"]);return(0,Dt.jsx)(Rr,S(E({multiple:!0,dragAndDrop:!0,buttonAddDirection:o},n),{children:(0,Dt.jsx)(an,{label:e,alignLabel:t,buttonAddDirection:o,numberOfImagesVisible:r})}))}var ln=require("@unform/core"),un=require("react"),kt=L(require("styled-components")),Vt=require("@mobilestockweb/container"),Bt=require("@mobilestockweb/typography");var xe=require("react/jsx-runtime");function mn(u){var i=u,{name:e,label:t,value:o,onChange:r}=i,n=P(i,["name","label","value","onChange"]);let{loading:s,notifyFieldChange:a}=H(),{error:l,fieldName:f,registerField:h}=(0,ln.useField)(e),c=(0,un.useRef)(null),p=`radio_${e}_${t}`;function m(){h({name:f,ref:c,getValue:b=>b.current.value,clearValue:b=>{b.current.checked=!1}}),a==null||a(f,o),r==null||r({value:o,event:"RADIO_CHANGE"})}return(0,xe.jsxs)(Vt.Container.Vertical,{onClick:m,gap:"XS",padding:"2XS_NONE",children:[(0,xe.jsxs)(Vt.Container.Horizontal,{align:"START_CENTER",gap:"XS",children:[(0,xe.jsx)(fi,S(E({id:p,ref:c},n),{type:"radio",disabled:s})),(0,xe.jsx)(gi,{htmlFor:p,size:"MD",children:t})]}),l&&(0,xe.jsx)(Bt.Typography,{color:"DANGER",size:"SM",children:l})]})}var fi=kt.default.input`
|
|
98
96
|
width: 1rem;
|
|
99
97
|
height: 1rem;
|
|
100
|
-
`,
|
|
98
|
+
`,gi=(0,kt.default)(Bt.Typography).attrs({forwardedAs:"label"})``;var cn=require("@unform/core"),ft=L(require("chroma-js")),$t=require("lodash"),oe=require("react"),pn=L(require("react-select")),gt=L(require("styled-components")),dn=require("@mobilestockweb/container"),_t=require("@mobilestockweb/typography");var He=require("react/jsx-runtime"),fn=(0,oe.forwardRef)(function({name:t,label:o,options:r,placeholder:n="Selecione um item",disabled:u,defaultValue:i,onChange:s,autoFocus:a,onFocus:l,onBlur:f},h){let c=(0,gt.useTheme)(),{loading:p,notifyFieldChange:m}=H(),{fieldName:b,defaultValue:R,registerField:C,error:g}=(0,cn.useField)(t),T=(0,oe.useRef)(null);(0,oe.useImperativeHandle)(h,()=>({focus(){var d;(d=T.current)==null||d.focus()},blur(){var d;(d=T.current)==null||d.blur()}})),(0,oe.useEffect)(()=>{C({name:b,ref:T.current,getValue:d=>{var z,k,O;let w=((O=(k=(z=d==null?void 0:d.state)==null?void 0:z.selectValue)==null?void 0:k[0])==null?void 0:O.value)||"";return m==null||m(b,w),s==null||s({value:w,event:"SELECT_CHANGE"}),w}})},[b,C,s]);let v=(0,oe.useCallback)(d=>function(w){return(0,$t.mergeWith)(w,{fontFamily:c.font.families,lineHeight:c.font.lineHeight,color:c.colors.text.default},d)},[]),y=(0,oe.useCallback)((d,w)=>{let z="transparent",k=c.colors.text.default;switch(!0){case w.isFocused:{let O=(0,ft.default)(c.colors.listItem.hover);O.luminance()>.5?z=O.brighten(1).hex("rgb"):z=O.hex("rgb");let A=(0,ft.default)(z);k=A.luminance(A.luminance()>.5?-2:2).hex("rgb");break}case w.isSelected:{z=c.colors.listItem.selected;let O=(0,ft.default)(z);k=O.luminance(O.luminance()>.5?-2:2).hex("rgb");break}}return(0,$t.mergeWith)(d,{fontFamily:c.font.families,lineHeight:c.font.lineHeight,color:k,backgroundColor:z})},[]);return(0,He.jsxs)(dn.Container.Vertical,{children:[o&&(0,He.jsx)(hi,{htmlFor:b,size:"MD",children:o}),(0,He.jsx)(pn.default,{defaultValue:i||R,options:[{label:n,options:r}],placeholder:n,menuPortalTarget:document.body,menuPosition:"fixed",styles:{container:v({width:"100%",display:"flex",height:"3rem"}),control:v({width:"100%",backgroundColor:g?c.colors.input.error:void 0,borderColor:g?c.colors.alert.urgent:void 0}),indicatorSeparator:v({backgroundColor:g?c.colors.alert.urgent:void 0}),dropdownIndicator:v({color:g?c.colors.alert.urgent:c.colors.text.default}),option:y,menuPortal:v({zIndex:99999})},openMenuOnFocus:!0,ref:T,isDisabled:p||u,autoFocus:a,onFocus:l,onBlur:f}),g&&(0,He.jsx)(_t.Typography,{color:"DANGER",size:"SM",children:g})]})}),hi=(0,gt.default)(_t.Typography).attrs({forwardedAs:"label"})``;var Tn=require("@mobilestockweb/typography");var gn=require("@unform/core"),q=require("react");var Cn=require("react/jsx-runtime"),hn=(0,q.createContext)(void 0);function bn(e){let{notifyFieldChange:t,loading:o}=H(),{fieldName:r,registerField:n,error:u,defaultValue:i}=(0,gn.useField)(e.name),[s,a]=(0,q.useState)(()=>{var d;return(d=e.defaultValue)!=null?d:!!i}),{onChange:l,defaultValue:f,label:h,labelPosition:c,checkedColor:p,backgroundColor:m,handleColor:b,size:R,icons:C}=e,g=e.disabled||o,T=(0,q.useCallback)((d,w=!0)=>{a(d),t==null||t(r,d),w&&(l==null||l({value:d,event:"EDIT"}))},[t,r,l]);(0,q.useEffect)(()=>{n({name:r,getValue:()=>s,setValue:(d,w)=>T(!!w),clearValue:()=>T(!1)})},[r,s,n,T]),(0,q.useEffect)(()=>{let d=f!=null?f:!!i;T(d,!1)},[f,T,i]);let v=(0,q.useCallback)(()=>{g||a(d=>{let w=!d;return t==null||t(r,w),l==null||l({value:w,event:"TOGGLE"}),w})},[g,r,t,l]),y=(0,q.useMemo)(()=>({checked:s,toggle:v,configureChecked:T,error:u,label:h,labelPosition:c,disabled:g,checkedColor:p,backgroundColor:m,handleColor:b,size:R,icons:C}),[s,v,T,u,h,c,g,p,m,b,R,C]);return(0,Cn.jsx)(hn.Provider,{value:y,children:e.children})}function Oe(){let e=(0,q.useContext)(hn);if(!e)throw new Error("useSwitch must be used within a SwitchProvider");return e}var En=require("react/jsx-runtime");function ht({children:e}){let{error:t}=Oe(),o=e!=null?e:t;return o?(0,En.jsx)(Tn.Typography,{color:"DANGER_600",size:"SM",weight:"MEDIUM",children:o}):null}var vn=require("@mobilestockweb/typography");var Sn=require("react/jsx-runtime");function Ae(o){var r=o,{children:e}=r,t=P(r,["children"]);return(0,Sn.jsx)(vn.Typography,S(E({weight:"REGULAR"},t),{children:e}))}var Gt=require("@mobilestockweb/container");var Ve=require("@mobilestockweb/container");var Pe=L(require("styled-components"));var bt=L(require("styled-components")),yn=require("@mobilestockweb/icons"),Rn=L(require("@mobilestockweb/tools"));var Xt=require("react/jsx-runtime");function xn({checked:e,handleColor:t,dimensions:o,currentIcon:r}){let n=(0,bt.useTheme)(),u=B.resolveColor(t,n,"handle");return(0,Xt.jsx)(bi,{$checked:e,$handleColor:u,$dimensions:o,children:r&&(0,Xt.jsx)(yn.Icon,{name:r,color:Rn.default.defineTextColor(u),size:"XS",style:{width:o.iconSize,height:o.iconSize}})})}var bi=bt.default.span`
|
|
101
99
|
position: absolute;
|
|
102
100
|
display: flex;
|
|
103
101
|
align-items: center;
|
|
@@ -110,7 +108,7 @@
|
|
|
110
108
|
transition: 0.4s;
|
|
111
109
|
border-radius: 50%;
|
|
112
110
|
transform: ${({$checked:e,$dimensions:t})=>e?`translateX(${t.translate})`:"translateX(0)"};
|
|
113
|
-
`;var
|
|
111
|
+
`;var Fe=require("react/jsx-runtime");function De(){let e=(0,Pe.useTheme)(),{checked:t,toggle:o,disabled:r,checkedColor:n,backgroundColor:u,handleColor:i,size:s,icons:a,error:l}=Oe(),f=(s!=null?s:"MD").toLowerCase(),h=B.buildDimensions(e.sizeSwitch[f]),c=t?a==null?void 0:a.on:a==null?void 0:a.off,p=B.resolveSliderColor(t,n,u,!!l,e);return(0,Fe.jsx)(Ci,{$disabled:r,$dimensions:h,children:(0,Fe.jsxs)(Ti,{children:[(0,Fe.jsx)(Ei,{type:"checkbox",checked:t,onChange:o,disabled:r}),(0,Fe.jsx)(vi,{$color:p,$dimensions:h,children:(0,Fe.jsx)(xn,{checked:t,handleColor:i,dimensions:h,currentIcon:c})})]})})}var Ci=Pe.default.div`
|
|
114
112
|
opacity: ${({$disabled:e})=>e?.5:1};
|
|
115
113
|
position: relative;
|
|
116
114
|
display: inline-block;
|
|
@@ -118,14 +116,14 @@
|
|
|
118
116
|
height: ${({$dimensions:e})=>e.height};
|
|
119
117
|
border: 1px solid ${({theme:e})=>e.colors.input.border};
|
|
120
118
|
border-radius: ${({$dimensions:e})=>e.height};
|
|
121
|
-
`,
|
|
119
|
+
`,Ti=Pe.default.label`
|
|
122
120
|
cursor: pointer;
|
|
123
|
-
`,
|
|
121
|
+
`,Ei=Pe.default.input`
|
|
124
122
|
opacity: 0;
|
|
125
123
|
width: 0;
|
|
126
124
|
height: 0;
|
|
127
125
|
position: absolute;
|
|
128
|
-
`,
|
|
126
|
+
`,vi=Pe.default.span`
|
|
129
127
|
position: absolute;
|
|
130
128
|
cursor: pointer;
|
|
131
129
|
top: 0;
|
|
@@ -135,4 +133,4 @@
|
|
|
135
133
|
background-color: ${({$color:e})=>e};
|
|
136
134
|
border-radius: ${({$dimensions:e})=>e.height};
|
|
137
135
|
transition: 0.4s;
|
|
138
|
-
`;var W=require("react/jsx-runtime");function
|
|
136
|
+
`;var W=require("react/jsx-runtime");function Fn({position:e,label:t,align:o}){return e==="LEFT"?(0,W.jsxs)(Ve.Container.Horizontal,{align:"CENTER",gap:"SM",children:[t&&(0,W.jsx)(Ve.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:(0,W.jsx)(Ae,{children:t})}),(0,W.jsx)(De,{})]}):e==="RIGHT"?(0,W.jsxs)(Ve.Container.Horizontal,{align:"CENTER",gap:"SM",children:[(0,W.jsx)(De,{}),t&&(0,W.jsx)(Ve.Container.Vertical,{padding:"NONE_NONE_NONE_2XS",children:(0,W.jsx)(Ae,{children:t})})]}):(0,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsx)(Ve.Container.Vertical,{align:o||"CENTER_START",padding:"NONE_NONE_2XS_NONE",children:(0,W.jsx)(Ae,{children:t})}),(0,W.jsx)(De,{})]})}var ke=require("react/jsx-runtime"),Pn=(r=>(r.TOP_START="CENTER_START",r.TOP_CENTER="CENTER",r.TOP_END="CENTER_END",r))(Pn||{});function wn(){let{label:e,labelPosition:t,error:o}=Oe(),r=t!=null?t:"TOP_START",u=r.startsWith("TOP")?Pn[r]:void 0;return(0,ke.jsxs)(Gt.Container.Vertical,{align:u,children:[(0,ke.jsx)(Fn,{position:r,label:e,align:u}),o&&(0,ke.jsx)(Gt.Container.Vertical,{align:u,padding:"2XS_NONE_NONE_NONE",children:(0,ke.jsx)(ht,{children:o})})]})}var Ut=require("react/jsx-runtime");function Ln(o){var r=o,{children:e}=r,t=P(r,["children"]);return(0,Ut.jsx)(bn,S(E({labelPosition:"TOP_START",size:"MD"},t),{children:e!=null?e:(0,Ut.jsx)(wn,{})}))}var Nn=Object.assign(Ln,{Toggle:De,Label:Ae,Error:ht});var In=require("@mobilestockweb/container");var Mn=require("react/jsx-runtime");function zn(o){var r=o,{children:e}=r,t=P(r,["children"]);return(0,Mn.jsx)(In.Container.Vertical,S(E({gap:"SM"},t),{children:e}))}var Si=Object.assign(ro,{Input:_o,Radio:mn,Select:fn,Button:io,Counter:Ao,Vertical:zn,Horizontal:Vo,MultipleArchive:Er,PhotoList:sn,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.4.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"notistack": "^3.0.1",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@mobilestockweb/tools": "^0.0.16",
|
|
21
21
|
"@mobilestockweb/typography": "^0.1.0",
|
|
22
22
|
"@mobilestockweb/clickable": "^1.0.13",
|
|
23
|
+
"@mobilestockweb/data-table": "^2.0.6",
|
|
23
24
|
"@mobilestockweb/spacer": "^1.0.6",
|
|
24
25
|
"@mobilestockweb/container": "^1.1.0",
|
|
25
|
-
"@mobilestockweb/data-table": "^2.0.6",
|
|
26
26
|
"@mobilestockweb/icons": "^0.5.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|