componenteshospitais 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +51 -37
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +52 -38
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/InputField.d.ts +1 -1
- package/dist/types/stories/InputField.stories.d.ts +3 -3
- package/package.json +1 -4
- package/src/components/InputField.tsx +80 -69
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var reactDom = require('react-dom');
|
|
5
4
|
|
|
6
5
|
function styleInject(css, ref) {
|
|
7
6
|
if ( ref === void 0 ) ref = {};
|
|
@@ -170,22 +169,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
170
169
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
171
170
|
};
|
|
172
171
|
|
|
173
|
-
function e$3(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function t$1(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?e$3(Object(a),!0).forEach((function(e){n$3(t,e,a[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):e$3(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e));}));}return t}function r$1(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}function n$3(e,t,n){return (t=r$1(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);}return e},a.apply(this,arguments)}function o$1(e,t){if(null==e)return {};var r,n,a=function(e,t){if(null==e)return {};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);}return a}function c$2(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i$2(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c$2(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c$2(e,t):void 0}}(e))||t){r&&(e=r);var n=0,a=function(){};return {s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return {s:function(){r=r.call(e);},n:function(){var e=r.next();return i=e.done,e},e:function(e){l=!0,o=e;},f:function(){try{i||null==r.return||r.return();}finally{if(l)throw o}}}}function l(e,t){var r,n=t.replacementChars,a=t.replacement,o=t.separate,c=n,l="",s=i$2(e);try{for(s.s();!(r=s.n()).done;){var u,p=r.value,f=!Object.prototype.hasOwnProperty.call(a,p)&&(null===(u=a[c[0]])||void 0===u?void 0:u.test(p));(o&&p===c[0]||f)&&(c=c.slice(1),l+=p);}}catch(e){s.e(e);}finally{s.f();}return l}function s(e){return e.length>0?n$3({},e,/./):{}}function u$3(e,t){var r,n=t.mask,a=t.replacement,o=t.showMask,c=0,l="",s=i$2(n);try{for(s.s();!(r=s.n()).done;){var u=r.value;if(!o&&void 0===e[c])break;Object.prototype.hasOwnProperty.call(a,u)&&void 0!==e[c]?l+=e[c++]:l+=u;}}catch(e){s.e(e);}finally{s.f();}return l}function p$1(e,t){for(var r=t.mask,n=t.replacement,a=[],o=0;o<r.length;o++){var c,i=null!==(c=e[o])&&void 0!==c?c:r[o],l=Object.prototype.hasOwnProperty.call(n,i)?"replacement":void 0!==e[o]&&e[o]!==r[o]?"input":"mask";a.push({type:l,value:i,index:o});}return a}function f$1(e,t){for(var r=t.start,n=void 0===r?0:r,a=t.end,o=t.mask,c=t.replacement,i=t.separate,l=e.slice(n,a),s=o.slice(n,a),u="",p=0;p<s.length;p++){var f=Object.prototype.hasOwnProperty.call(c,s[p]);f&&void 0!==l[p]&&l[p]!==s[p]?u+=l[p]:f&&i&&(u+=s[p]);}return u}function b(e){for(var t=e.mask,r=e.replacement,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a="string"==typeof r?s(r):r,o=["[","]","\\","/","^","$",".","|","?","*","+","(",")","{","}"],c="",i=0;i<t.length;i++){var l=Object.prototype.hasOwnProperty.call(a,t[i]),u=n?"(?!".concat(t[i],")"):"";0===i&&(c+="^"),c+=l?"".concat(u,"(").concat(a[t[i]].toString().slice(1,-1),")"):o.includes(t[i])?"\\".concat(t[i]):t[i],i===t.length-1&&(c+="$");}return c}
|
|
174
|
-
|
|
175
|
-
function t(t,n,r){return n=c$1(n),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,e$2()?Reflect.construct(n,r||[],c$1(t).constructor):n.apply(t,r))}function e$2(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(t){}return (e$2=function(){return !!t})()}function n$2(t){return n$2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n$2(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return Object.defineProperty(t,"prototype",{writable:!1}),t}function u$2(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i$1(t,e);}function c$1(t){return c$1=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c$1(t)}function i$1(t,e){return i$1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i$1(t,e)}function f(t){var n="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||!function(t){try{return -1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return "function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,r);}function r(){return function(t,n,r){if(e$2())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,n);var u=new(t.bind.apply(t,o));return r&&i$1(u,r.prototype),u}(t,arguments,c$1(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i$1(r,t)},f(t)}
|
|
176
|
-
|
|
177
|
-
var n$1=function(e){function n(r$1,a){var e;return r(this,n),(e=t(this,n,[r$1])).name="SyntheticChangeError",e.cause=a,e}return u$2(n,e),o(n)}(f(Error));
|
|
178
|
-
|
|
179
|
-
function e$1(e,n){return React.useCallback((function(t){e.current=t,"function"==typeof n?n(t):"object"===n$2(n)&&null!==n&&(n.current=t);}),[e,n])}
|
|
180
|
-
|
|
181
|
-
function e(e,t){var o=t.value,a=t.selectionStart,i=t.selectionEnd;void 0!==o&&(e.value=o),void 0!==a&&void 0!==i&&e.setSelectionRange(a,i);}
|
|
182
|
-
|
|
183
|
-
var u$1=["text","email","tel","search","url"];function i(i){var o=i.init,a=i.tracking,c=i.eventType,d=i.eventHandler,v=React.useRef({timeoutId:-1,fallbackTimeoutId:-1,cachedTimeoutId:-1,start:0,end:0}),s=React.useRef(!0),m=React.useRef(null),p=React.useRef({init:o,tracking:a,eventType:c,eventHandler:d});return p.current.init=o,p.current.tracking=a,p.current.eventType=c,p.current.eventHandler=d,React.useMemo((function(){return function(e$1,t,n){var r=n.onFocus,i=n.onBlur,o=n.onInput;return new Proxy(e$1,{set:function(n,a,c){if("current"!==a)return !1;var d=null!==c&&u$1.includes(c.type);if("production"===process.env.NODE_ENV||null===c||d||console.warn("Warn: The input element type does not match one of the types: ".concat(u$1.join(", "),".")),c!==e$1.current&&(null!==e$1.current&&(e$1.current.removeEventListener("focus",r),e$1.current.removeEventListener("blur",i),e$1.current.removeEventListener("input",o)),null!==c&&d)){var v,s=null!==(v=c._wrapperState)&&void 0!==v?v:{},m=s.controlled,p=void 0!==m&&m,h=s.initialValue,f=void 0===h?"":h,E=t({controlled:p,initialValue:c.value||f});e(c,{value:E.value}),document.activeElement===c&&r(),c.addEventListener("focus",r),c.addEventListener("blur",i),c.addEventListener("input",o);}return n[a]=c,!0}})}(m,p.current.init,{onFocus:function(){v.current.timeoutId=window.setTimeout((function e(){var t,n,r,l;s.current?(v.current.start=null!==(t=null===(n=m.current)||void 0===n?void 0:n.selectionStart)&&void 0!==t?t:0,v.current.end=null!==(r=null===(l=m.current)||void 0===l?void 0:l.selectionEnd)&&void 0!==r?r:0,v.current.timeoutId=window.setTimeout(e)):v.current.fallbackTimeoutId=window.setTimeout(e);}));},onBlur:function(){window.clearTimeout(v.current.timeoutId),window.clearTimeout(v.current.fallbackTimeoutId),v.current.timeoutId=-1,v.current.fallbackTimeoutId=-1,v.current.cachedTimeoutId=-1;},onInput:function(e$1){var t=m.current;if(null!==t)try{var u,i,o,a,c;if(v.current.cachedTimeoutId===v.current.timeoutId)throw new n$1("The input selection has not been updated.");v.current.cachedTimeoutId=v.current.timeoutId;var d=t.value,h=t.selectionStart,f=t.selectionEnd;if(null===h||null===f)throw new n$1("The selection attributes have not been initialized.");var E,w=null!==(u=null===(i=t._valueTracker)||void 0===i||null===(o=i.getValue)||void 0===o?void 0:o.call(i))&&void 0!==u?u:"";if(void 0===e$1.inputType&&(v.current.start=0,v.current.end=w.length),h>v.current.start?E="insert":h<=v.current.start&&h<v.current.end?E="deleteBackward":h===v.current.end&&d.length<w.length&&(E="deleteForward"),void 0===E||("deleteBackward"===E||"deleteForward"===E)&&d.length>w.length)throw new n$1("Input type detection error.");var T="",b="",g=v.current.start,_=v.current.end;if("insert"===E)T=d.slice(v.current.start,h);else {var I=w.length-d.length;g=h,_=h+I,b=w.slice(g,_);}var S=p.current.tracking({inputType:E,previousValue:w,value:d,addedValue:T,deletedValue:b,changeStart:g,changeEnd:_,selectionStart:h,selectionEnd:f});e(t,{value:S.value,selectionStart:S.selectionStart,selectionEnd:S.selectionEnd});var y=p.current.eventType,k=p.current.eventHandler;if("string"==typeof y&&k){var V=t.value,L=t.selectionStart,F=t.selectionEnd;s.current=!1,requestAnimationFrame((function(){e(t,{value:V,selectionStart:null!=L?L:V.length,selectionEnd:null!=F?F:V.length});var e$1=new CustomEvent(y,{bubbles:!0,cancelable:!1,composed:!0,detail:S.__detail});t.dispatchEvent(e$1),reactDom.unstable_batchedUpdates?reactDom.unstable_batchedUpdates(k,e$1):k(e$1),s.current=!0;}));}null===(a=t._valueTracker)||void 0===a||null===(c=a.setValue)||void 0===c||c.call(a,w),v.current.start=S.selectionStart,v.current.end=S.selectionEnd;}catch(n){var B,H,j,x,C,A,D,N,P,q,z,O=n,W=O.name,G=O.cause;if(e(t,{value:null!==(B=null!==(H=null==G||null===(j=G.__attributes)||void 0===j?void 0:j.value)&&void 0!==H?H:null===(x=t._valueTracker)||void 0===x||null===(C=x.getValue)||void 0===C?void 0:C.call(x))&&void 0!==B?B:"",selectionStart:null!==(A=null==G||null===(D=G.__attributes)||void 0===D?void 0:D.selectionStart)&&void 0!==A?A:v.current.start,selectionEnd:null!==(N=null==G||null===(P=G.__attributes)||void 0===P?void 0:P.selectionEnd)&&void 0!==N?N:v.current.end}),void 0!==(null==G||null===(q=G.__attributes)||void 0===q?void 0:q.selectionStart)&&(v.current.start=G.__attributes.selectionStart),void 0!==(null==G||null===(z=G.__attributes)||void 0===z?void 0:z.selectionEnd)&&(v.current.end=G.__attributes.selectionEnd),e$1.preventDefault(),e$1.stopPropagation(),"SyntheticChangeError"!==W)throw n}}})}),[])}
|
|
184
|
-
|
|
185
|
-
var c=function(e){return function(){for(var r=arguments.length,t=new Array(r),a=0;a<r;a++)t[a]=arguments[a];return new e("".concat(t.join("\n\n"),"\n"))}};function u(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},v=u.mask,d=void 0===v?"":v,h=u.replacement,m=void 0===h?{}:h,f=u.showMask,k=void 0!==f&&f,g=u.separate,y=void 0!==g&&g,w=u.track,b$1=u.modify,V=u.onMask,j="string"==typeof m?s(m):m,E=React.useRef(null);return i({init:function(e){var r=e.controlled,t=e.initialValue;"production"!==process.env.NODE_ENV&&function(e){var r=e.initialValue,t=e.mask,a=e.replacement;r.length>t.length&&console.error(c(Error)("The initialized value of the `value` or `defaultValue` property is longer than the value specified in the `mask` property. Check the correctness of the initialized value in the specified property.",'Invalid value: "'.concat(r,'".')));var n=Object.keys(a).filter((function(e){return e.length>1}));n.length>0&&console.error(c(Error)("Object keys in the `replacement` property are longer than one character. Replacement keys must be one character long. Check the correctness of the value in the specified property.","Invalid keys: ".concat(n.join(", "),".")));for(var l=t.slice(0,r.length),o=-1,i=0;i<l.length;i++){var p=Object.prototype.hasOwnProperty.call(a,l[i]);if(!(l[i]===r[i]||p&&a[l[i]].test(r[i]))){o=i;break}}-1!==o&&console.error(c(Error)("An invalid character was found in the initialized property value `value` or `defaultValue` (index: ".concat(o,"). Check the correctness of the initialized value in the specified property."),'Invalid value: "'.concat(r,'".')));}({initialValue:t,mask:d,replacement:j}),t=r||t?t:k?d:"";var a={mask:d,replacement:j,showMask:k,separate:y};return E.current={value:t,props:a,fallbackProps:a},{value:t}},tracking:function(i){var p,c=i.inputType,u=i.previousValue,v=i.addedValue,h=i.changeStart,m=i.changeEnd;if(null===E.current)throw new n$1("The state has not been initialized.");E.current.value!==u?E.current.props=E.current.fallbackProps:E.current.fallbackProps=E.current.props;var f=f$1(u,{end:h,mask:E.current.props.mask,replacement:E.current.props.replacement,separate:E.current.props.separate}),g=RegExp("[^".concat(Object.keys(E.current.props.replacement).join(""),"]"),"g"),V=E.current.props.mask.replace(g,"");f&&(f=l(f,{replacementChars:V,replacement:E.current.props.replacement,separate:E.current.props.separate}));var C=null==w?void 0:w(t$1(t$1({},"insert"===c?{inputType:c,data:v}:{inputType:c,data:null}),{},{value:u,selectionStart:h,selectionEnd:m}));if(!1===C)throw new n$1("Custom trekking stop.");if(null===C?v="":!0!==C&&void 0!==C&&(v=C),v&&(v=l(v,{replacementChars:V.slice(f.length),replacement:E.current.props.replacement,separate:!1})),"insert"===c&&""===v)throw new n$1("The character does not match the key value of the `replacement` object.");var T=f$1(u,{start:m,mask:E.current.props.mask,replacement:E.current.props.replacement,separate:E.current.props.separate});if(E.current.props.separate){var x=E.current.props.mask.slice(h,m).replace(g,""),M=x.length-v.length;M<0?T=T.slice(-M):M>0&&(T=x.slice(-M)+T);}T&&(T=l(T,{replacementChars:V.slice(f.length+v.length),replacement:E.current.props.replacement,separate:E.current.props.separate}));var O=f+v+T,z=null!==(p=null==b$1?void 0:b$1(O))&&void 0!==p?p:{},P=z.mask,I=void 0===P?d:P,R=z.replacement,S=void 0===R?j:R,_=z.showMask,A=void 0===_?k:_,N=z.separate,B=void 0===N?y:N;"string"==typeof S&&(S=s(S));var D=function(a,n){var l=n.mask,o=n.replacement,i=n.showMask,p=u$3(a,{mask:l,replacement:o,showMask:i}),s=p$1(p,{mask:l,replacement:o}),c=b({mask:l,replacement:o}),u=b({mask:l,replacement:o},!0);return {value:p,input:a,parts:s,pattern:c,isValid:RegExp(u).test(p)}}(O,{mask:I,replacement:S,showMask:A}),F=function(e){var r,t,a,n=e.inputType,l=e.value,o=e.addedValue,i=e.beforeChangeValue,p=e.parts,s=e.replacement,c=e.separate,u=p.filter((function(e){var r=e.type;return "input"===r||c&&"replacement"===r})),v=null===(r=u[i.length+o.length-1])||void 0===r?void 0:r.index,d=null===(t=u[i.length-1])||void 0===t?void 0:t.index,h=null===(a=u[i.length+o.length])||void 0===a?void 0:a.index;if("insert"===n){if(void 0!==v)return v+1;if(void 0!==h)return h;if(void 0!==d)return d+1}if("deleteForward"===n){if(void 0!==h)return h;if(void 0!==d)return d+1}if("deleteBackward"===n){if(void 0!==d)return d+1;if(void 0!==h)return h}var m=l.split("").findIndex((function(e){return Object.prototype.hasOwnProperty.call(s,e)}));return -1!==m?m:l.length}({inputType:c,value:D.value,addedValue:v,beforeChangeValue:f,parts:D.parts,replacement:S,separate:B});return E.current.value=D.value,E.current.props={mask:I,replacement:S,showMask:A,separate:B},{value:D.value,selectionStart:F,selectionEnd:F,__detail:D}},eventType:"input-mask",eventHandler:V})}
|
|
186
|
-
|
|
187
|
-
var m=["component","mask","replacement","showMask","separate","track","modify","onMask"];function n(t,n){var p=t.component,c=t.mask,k=t.replacement,f=t.showMask,i=t.separate,l=t.track,M=t.modify,u$1=t.onMask,d=o$1(t,m),h=u({mask:c,replacement:k,showMask:f,separate:i,track:l,modify:M,onMask:u$1}),v=e$1(h,n);return p?React.createElement(p,a({ref:v},d)):React.createElement("input",a({ref:v},d))}var p=React.forwardRef(n);
|
|
188
|
-
|
|
189
172
|
var DefaultContext = {
|
|
190
173
|
color: undefined,
|
|
191
174
|
size: undefined,
|
|
@@ -263,34 +246,65 @@ var InputField = function (_a) {
|
|
|
263
246
|
setIsPasswordVisible(!isPasswordVisible);
|
|
264
247
|
};
|
|
265
248
|
var appliedMaxLength = maxLength !== undefined ? maxLength : 524288;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
249
|
+
// Helper function to apply masks
|
|
250
|
+
var applyMask = function (maskType, value) {
|
|
251
|
+
switch (maskType) {
|
|
252
|
+
case 'cpf':
|
|
253
|
+
return value
|
|
254
|
+
.replace(/\D/g, '') // Remove all non-digits
|
|
255
|
+
.replace(/(\d{3})(\d)/, '$1.$2') // Add dots and hyphen
|
|
256
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
257
|
+
.replace(/(\d{3})(\d{1,2})$/, '$1-$2')
|
|
258
|
+
.slice(0, 14); // Limit length
|
|
259
|
+
case 'phone':
|
|
260
|
+
return value
|
|
261
|
+
.replace(/\D/g, '')
|
|
262
|
+
.replace(/(\d{2})(\d)/, '($1) $2') // Add parentheses and space
|
|
263
|
+
.replace(/(\d{5})(\d)/, '$1-$2') // Add hyphen
|
|
264
|
+
.slice(0, 15); // Limit length
|
|
265
|
+
case 'telefone':
|
|
266
|
+
return value
|
|
267
|
+
.replace(/\D/g, '')
|
|
268
|
+
.replace(/(\d{2})(\d)/, '($1) $2') // Add parentheses and space
|
|
269
|
+
.replace(/(\d{4})(\d)/, '$1-$2') // Add hyphen
|
|
270
|
+
.slice(0, 14); // Limit length
|
|
271
|
+
case 'cep':
|
|
272
|
+
return value
|
|
273
|
+
.replace(/\D/g, '')
|
|
274
|
+
.replace(/(\d{5})(\d)/, '$1-$2') // Add hyphen
|
|
275
|
+
.slice(0, 9); // Limit length
|
|
276
|
+
case 'date':
|
|
277
|
+
return value
|
|
278
|
+
.replace(/\D/g, '')
|
|
279
|
+
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
280
|
+
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
281
|
+
.slice(0, 10); // Limit length
|
|
282
|
+
case 'time':
|
|
283
|
+
return value
|
|
284
|
+
.replace(/\D/g, '')
|
|
285
|
+
.replace(/(\d{2})(\d)/, '$1:$2')
|
|
286
|
+
.slice(0, 5); // Limit length
|
|
287
|
+
default:
|
|
288
|
+
return value; // No mask applied
|
|
269
289
|
}
|
|
290
|
+
};
|
|
291
|
+
var handleChange = function (e) {
|
|
292
|
+
var value = e.target.value;
|
|
293
|
+
var maskedValue = applyMask(maskType, value);
|
|
270
294
|
if (onChange) {
|
|
271
|
-
|
|
295
|
+
var event_1 = __assign(__assign({}, e), { target: __assign(__assign({}, e.target), { value: maskedValue }) }); // Create a new event with the masked value
|
|
296
|
+
onChange(event_1);
|
|
272
297
|
}
|
|
273
298
|
};
|
|
274
|
-
var mask = maskType === 'cpf' ? '999.999.999-99' :
|
|
275
|
-
maskType === 'phone' ? '(99) 99999-9999' :
|
|
276
|
-
maskType === 'time' ? '99:99' :
|
|
277
|
-
maskType === 'date' ? '99/99/9999' :
|
|
278
|
-
maskType === 'cep' ? '99999-999' :
|
|
279
|
-
maskType === 'telefone' ? '(99) 9999-9999' : '';
|
|
280
299
|
return (React.createElement(React.Fragment, null,
|
|
281
300
|
label && React.createElement("label", { htmlFor: id, style: { color: corLabel ? corLabel : '' } }, label),
|
|
282
301
|
React.createElement("div", { className: styles$5.inputWrapper },
|
|
283
|
-
|
|
284
|
-
width: largura ? "".concat(largura) : '',
|
|
285
|
-
backgroundColor: (disabled ? '#e5e5e5' : (corFundo ? corFundo : '')),
|
|
286
|
-
borderRadius: (borderRadius ? "".concat(borderRadius, "px") : ''),
|
|
287
|
-
border: (border ? border : '')
|
|
288
|
-
}, readOnly: readonly, required: required, checked: checked, onKeyPress: onKeyPress, onBlur: onBlur }))); })) : (React.createElement("input", { type: type === 'password' && isPasswordVisible ? 'text' : type, id: id, name: id, value: value, placeholder: placeholder, onChange: handleChange, className: styles$5.inputPadrao, style: {
|
|
302
|
+
React.createElement("input", { type: type === 'password' && isPasswordVisible ? 'text' : type, id: id, name: id, value: value, placeholder: placeholder, onChange: handleChange, className: styles$5.inputPadrao, style: {
|
|
289
303
|
width: largura ? "".concat(largura) : '',
|
|
290
|
-
backgroundColor:
|
|
291
|
-
borderRadius:
|
|
292
|
-
border:
|
|
293
|
-
}, readOnly: readonly, disabled: disabled, required: required, checked: checked, maxLength: type === 'text' ? appliedMaxLength : undefined, onKeyPress: onKeyPress, onBlur: onBlur })
|
|
304
|
+
backgroundColor: disabled ? '#e5e5e5' : (corFundo ? corFundo : ''),
|
|
305
|
+
borderRadius: borderRadius ? "".concat(borderRadius, "px") : '',
|
|
306
|
+
border: border ? border : ''
|
|
307
|
+
}, readOnly: readonly, disabled: disabled, required: required, checked: checked, maxLength: type === 'text' ? appliedMaxLength : undefined, onKeyPress: onKeyPress, onBlur: onBlur }),
|
|
294
308
|
type === 'password' && (React.createElement("div", { className: styles$5.passwordToggleIcon, onClick: togglePasswordVisibility }, isPasswordVisible ? React.createElement(FaEyeSlash, { style: { color: colorIcon ? colorIcon : '' } }) : React.createElement(FaEye, { style: { color: colorIcon ? colorIcon : '' } }))))));
|
|
295
309
|
};
|
|
296
310
|
|