@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.
Files changed (3) hide show
  1. package/index.d.ts +57 -0
  2. package/index.js +32 -34
  3. 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 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
- min-width: 40px;
3
- height: 34px;
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 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]}};
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
- `,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)`
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&&Xe.css`
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&&Xe.css`
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 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)`
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 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`
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 t,o;return((o=(t=e==null?void 0:e.font)==null?void 0:t.size)==null?void 0:o.lg)||16}}px;
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
- width: 40px;
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
- `,jn=(0,ye.default)(wt.Container.Horizontal)`
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 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)`
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
- `,ni=(0,Nt.default)(ge.Container.Vertical)`
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 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)`
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 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`
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 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)`
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=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)`
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 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)`
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
- `,mi=(0,Le.default)(en.ReactCrop)`
92
- ${({width:e,height:t})=>e&&t&&Le.css`
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
- `,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`
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
- `,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`
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 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`
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
- `,Ci=Pe.default.label`
119
+ `,Ti=Pe.default.label`
122
120
  cursor: pointer;
123
- `,Ti=Pe.default.input`
121
+ `,Ei=Pe.default.input`
124
122
  opacity: 0;
125
123
  width: 0;
126
124
  height: 0;
127
125
  position: absolute;
128
- `,Ei=Pe.default.span`
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 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});
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.4",
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": {