componenteshospitais 1.4.0 → 1.4.2
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 +1350 -51
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1345 -46
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/InputField.d.ts +1 -0
- package/dist/types/components/SelectField.d.ts +3 -2
- package/package.json +3 -1
- package/src/components/InputField.tsx +58 -15
- package/src/components/SelectField.tsx +34 -22
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var React = require('react');
|
|
3
|
+
var React$2 = require('react');
|
|
4
|
+
var reactDom = require('react-dom');
|
|
4
5
|
|
|
5
6
|
function styleInject(css, ref) {
|
|
6
7
|
if ( ref === void 0 ) ref = {};
|
|
@@ -39,10 +40,10 @@ styleInject(css_248z$7);
|
|
|
39
40
|
var TituloPagina = function (_a) {
|
|
40
41
|
var titulo = _a.titulo, onClick = _a.onClick, empresa = _a.empresa;
|
|
41
42
|
var empresaClass = styles$7["empresa".concat(empresa)];
|
|
42
|
-
return (React.createElement("div", { className: "".concat(empresaClass) },
|
|
43
|
-
React.createElement("div", { className: styles$7.header },
|
|
44
|
-
React.createElement("p", { className: styles$7.title }, titulo),
|
|
45
|
-
React.createElement("button", { onClick: onClick, className: styles$7.backButton }, "Voltar"))));
|
|
43
|
+
return (React$2.createElement("div", { className: "".concat(empresaClass) },
|
|
44
|
+
React$2.createElement("div", { className: styles$7.header },
|
|
45
|
+
React$2.createElement("p", { className: styles$7.title }, titulo),
|
|
46
|
+
React$2.createElement("button", { onClick: onClick, className: styles$7.backButton }, "Voltar"))));
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
var css_248z$6 = ".card-module_icone__8F-jV{height:55px;width:55px}.card-module_item__YYEzi{align-items:center;border-radius:10px;color:#fff;display:flex;font-size:18px;margin-bottom:1rem;padding:15px}.card-module_imgLateral__zCZz5{height:55px;margin-left:auto;margin-right:10px;width:55px}.card-module_empresa1__Jl5OB .card-module_item__YYEzi{background-color:var(--blue)}.card-module_empresa1__Jl5OB .card-module_item__YYEzi:hover{background-color:var(--red)}.card-module_empresa3__TCJpW .card-module_item__YYEzi{background-color:var(--green)}.card-module_empresa3__TCJpW .card-module_item__YYEzi:hover{background-color:var(--lightblue)}.card-module_empresa4__zoSLq .card-module_item__YYEzi{background-color:var(--red)}.card-module_empresa4__zoSLq .card-module_item__YYEzi:hover{background-color:var(--blue)}";
|
|
@@ -67,11 +68,11 @@ var Card = function (_a) {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
|
-
return (React.createElement("div", { className: "".concat(empresaClass), onClick: link ? handleClick : handleActionClick, style: { cursor: link || (funcao && parametro) ? 'pointer' : 'default' } },
|
|
71
|
-
React.createElement("div", { className: "".concat(styles$6.item, " empresa").concat(empresa), style: { width: largura ? "".concat(largura) : '' } },
|
|
72
|
-
img && (React.createElement("img", { src: img, alt: text, className: styles$6.icone })),
|
|
73
|
-
React.createElement("span", { className: styles$6.texto, dangerouslySetInnerHTML: { __html: text } }),
|
|
74
|
-
imgLateral && (React.createElement("img", { src: imgLateral, alt: "Right", className: styles$6.imgLateral })))));
|
|
71
|
+
return (React$2.createElement("div", { className: "".concat(empresaClass), onClick: link ? handleClick : handleActionClick, style: { cursor: link || (funcao && parametro) ? 'pointer' : 'default' } },
|
|
72
|
+
React$2.createElement("div", { className: "".concat(styles$6.item, " empresa").concat(empresa), style: { width: largura ? "".concat(largura) : '' } },
|
|
73
|
+
img && (React$2.createElement("img", { src: img, alt: text, className: styles$6.icone })),
|
|
74
|
+
React$2.createElement("span", { className: styles$6.texto, dangerouslySetInnerHTML: { __html: text } }),
|
|
75
|
+
imgLateral && (React$2.createElement("img", { src: imgLateral, alt: "Right", className: styles$6.imgLateral })))));
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
var css_248z$5 = ".cardImage-module_botaoCert__Rs0fg{align-items:center;border-color:transparent;border-radius:1rem;box-sizing:border-box;color:#fff;display:flex;flex-direction:column;justify-content:center;padding:.8rem;text-decoration:none}.cardImage-module_iconeOna__WQil5{height:150px;margin-bottom:10px}.cardImage-module_cardText__NfgFE{bottom:.5rem;font-size:18px;overflow:hidden;position:relative;text-align:center}.cardImage-module_empresa1__SnbEU{background-color:var(--blue)}.cardImage-module_empresa1__SnbEU:hover{background-color:var(--red)}.cardImage-module_empresa3__ItFp0{background-color:var(--green)}.cardImage-module_empresa3__ItFp0:hover{background-color:var(--lightblue)}.cardImage-module_empresa4__L6K5N{background-color:var(--red)}.cardImage-module_empresa4__L6K5N:hover{background-color:var(--blue)}";
|
|
@@ -80,7 +81,7 @@ styleInject(css_248z$5);
|
|
|
80
81
|
|
|
81
82
|
var CardImage = function (_a) {
|
|
82
83
|
var img = _a.img, href = _a.href, texto = _a.texto, empresa = _a.empresa, largura = _a.largura, altura = _a.altura, externo = _a.externo, funcao = _a.funcao, parametro = _a.parametro, fileInput = _a.fileInput, alturaImage = _a.alturaImage, larguraImage = _a.larguraImage, onFileSelect = _a.onFileSelect, accept = _a.accept;
|
|
83
|
-
var _b = React.useState(null), fileName = _b[0], setFileName = _b[1];
|
|
84
|
+
var _b = React$2.useState(null), fileName = _b[0], setFileName = _b[1];
|
|
84
85
|
var empresaClass = styles$5["empresa".concat(empresa)];
|
|
85
86
|
var handleActionClick = function () {
|
|
86
87
|
if (funcao && parametro) {
|
|
@@ -99,11 +100,11 @@ var CardImage = function (_a) {
|
|
|
99
100
|
setFileName(null);
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
|
-
var content = (React.createElement(React.Fragment, null,
|
|
103
|
-
React.createElement("img", { src: img, alt: img, className: styles$5.iconeOna, style: { width: larguraImage ? larguraImage : undefined, height: alturaImage ? alturaImage : undefined } }),
|
|
104
|
-
texto && (React.createElement("span", { className: styles$5.cardText, dangerouslySetInnerHTML: { __html: texto } }))));
|
|
105
|
-
return (React.createElement("div", { className: "".concat(empresaClass), style: { width: largura ? "".concat(largura) : '250px', height: altura ? "".concat(altura) : '300px', borderRadius: '1rem' } }, fileInput ? (React.createElement("label", { className: "".concat(styles$5.botaoCert), style: { position: 'relative', cursor: 'pointer', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' } },
|
|
106
|
-
React.createElement("input", { type: "file", onChange: handleFileChange, style: {
|
|
103
|
+
var content = (React$2.createElement(React$2.Fragment, null,
|
|
104
|
+
React$2.createElement("img", { src: img, alt: img, className: styles$5.iconeOna, style: { width: larguraImage ? larguraImage : undefined, height: alturaImage ? alturaImage : undefined } }),
|
|
105
|
+
texto && (React$2.createElement("span", { className: styles$5.cardText, dangerouslySetInnerHTML: { __html: texto } }))));
|
|
106
|
+
return (React$2.createElement("div", { className: "".concat(empresaClass), style: { width: largura ? "".concat(largura) : '250px', height: altura ? "".concat(altura) : '300px', borderRadius: '1rem' } }, fileInput ? (React$2.createElement("label", { className: "".concat(styles$5.botaoCert), style: { position: 'relative', cursor: 'pointer', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' } },
|
|
107
|
+
React$2.createElement("input", { type: "file", onChange: handleFileChange, style: {
|
|
107
108
|
position: 'absolute',
|
|
108
109
|
top: 0,
|
|
109
110
|
left: 0,
|
|
@@ -113,7 +114,7 @@ var CardImage = function (_a) {
|
|
|
113
114
|
cursor: 'pointer'
|
|
114
115
|
}, accept: accept }),
|
|
115
116
|
content,
|
|
116
|
-
React.createElement("span", { className: styles$5.cardText }, fileName ? fileName : 'Selecione um arquivo'))) : (href ? (React.createElement("a", { href: href, target: externo ? "_blank" : "_self", rel: externo ? "noopener noreferrer" : undefined, className: "".concat(styles$5.botaoCert), title: href, style: { width: '100%', height: '100%' } }, content)) : (React.createElement("div", { className: "".concat(styles$5.botaoCert), onClick: handleActionClick, style: { width: '100%', height: '100%' } }, content)))));
|
|
117
|
+
React$2.createElement("span", { className: styles$5.cardText }, fileName ? fileName : 'Selecione um arquivo'))) : (href ? (React$2.createElement("a", { href: href, target: externo ? "_blank" : "_self", rel: externo ? "noopener noreferrer" : undefined, className: "".concat(styles$5.botaoCert), title: href, style: { width: '100%', height: '100%' } }, content)) : (React$2.createElement("div", { className: "".concat(styles$5.botaoCert), onClick: handleActionClick, style: { width: '100%', height: '100%' } }, content)))));
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
var css_248z$4 = ".input-module_inputSubmit__21-Pj{align-self:center;border:none;border-radius:20px;color:#fff;cursor:pointer;font-size:15px;padding:10px;width:10rem}.input-module_inputPadrao__jypjY{border:1px solid #ccc;border-radius:.5rem;font-style:italic;padding:.8rem 0 .8rem 1rem;width:100%}.input-module_inputPadrao__jypjY:focus{outline:none}.input-module_empresa1__bxBov .input-module_inputSubmit__21-Pj{background-color:var(--blue)}.input-module_empresa1__bxBov .input-module_inputSubmit__21-Pj:hover{background-color:var(--red)}.input-module_empresa3__RU89A .input-module_inputSubmit__21-Pj{background-color:var(--green)}.input-module_empresa3__RU89A .input-module_inputSubmit__21-Pj:hover{background-color:var(--lightblue)}.input-module_empresa4__rWmWH .input-module_inputSubmit__21-Pj{background-color:var(--red)}.input-module_empresa4__rWmWH .input-module_inputSubmit__21-Pj:hover{background-color:var(--blue)}";
|
|
@@ -123,11 +124,1296 @@ styleInject(css_248z$4);
|
|
|
123
124
|
var Button = function (_a) {
|
|
124
125
|
var empresa = _a.empresa, _b = _a.type, type = _b === void 0 ? 'submit' : _b, onClick = _a.onClick, texto = _a.texto, largura = _a.largura;
|
|
125
126
|
var empresaClass = styles$4["empresa".concat(empresa)];
|
|
126
|
-
return (React.createElement("div", { className: "".concat(empresaClass) }, type === 'submit' ? (React.createElement("input", { type: "submit", className: styles$4.inputSubmit, style: { width: largura ? "".concat(largura) : '' } })) : (React.createElement("button", { type: "button", className: styles$4.inputSubmit, onClick: onClick, style: { width: largura ? "".concat(largura) : '' } }, texto))));
|
|
127
|
+
return (React$2.createElement("div", { className: "".concat(empresaClass) }, type === 'submit' ? (React$2.createElement("input", { type: "submit", className: styles$4.inputSubmit, style: { width: largura ? "".concat(largura) : '' } })) : (React$2.createElement("button", { type: "button", className: styles$4.inputSubmit, onClick: onClick, style: { width: largura ? "".concat(largura) : '' } }, texto))));
|
|
127
128
|
};
|
|
128
129
|
|
|
130
|
+
/******************************************************************************
|
|
131
|
+
Copyright (c) Microsoft Corporation.
|
|
132
|
+
|
|
133
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
134
|
+
purpose with or without fee is hereby granted.
|
|
135
|
+
|
|
136
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
137
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
138
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
139
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
140
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
141
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
142
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
143
|
+
***************************************************************************** */
|
|
144
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
var __assign = function() {
|
|
148
|
+
__assign = Object.assign || function __assign(t) {
|
|
149
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
150
|
+
s = arguments[i];
|
|
151
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
152
|
+
}
|
|
153
|
+
return t;
|
|
154
|
+
};
|
|
155
|
+
return __assign.apply(this, arguments);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
159
|
+
var e = new Error(message);
|
|
160
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
function createCommonjsModule(fn, module) {
|
|
164
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function _interopDefault$2(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var React$1=_interopDefault$2(React$2);function _defaults2$1(e,t){for(var n=Object.getOwnPropertyNames(t),a=0;a<n.length;a++){var i=n[a],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&e[i]===undefined&&Object.defineProperty(e,i,r);}return e}function _extends$1(){return (_extends$1=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);}return e}).apply(this,arguments)}function _inheritsLoose$1(e,t){e.prototype=Object.create(t.prototype),_defaults2$1(e.prototype.constructor=e,t);}function _objectWithoutPropertiesLoose$1(e,t){if(null==e)return {};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],0<=t.indexOf(n)||(i[n]=e[n]);return i}function _assertThisInitialized$1(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var invariant$2=function(e,t,n,a,i,r,o,s){if(!e){var l;if(t===undefined)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else {var u=[n,a,i,r,o,s],c=0;(l=new Error(t.replace(/%s/g,function(){return u[c++]}))).name="Invariant Violation";}throw l.framesToPop=1,l}},invariant_1$1=invariant$2;function setInputSelection$1(e,t,n){if("selectionStart"in e&&"selectionEnd"in e)e.selectionStart=t,e.selectionEnd=n;else {var a=e.createTextRange();a.collapse(!0),a.moveStart("character",t),a.moveEnd("character",n-t),a.select();}}function getInputSelection$1(e){var t=0,n=0;if("selectionStart"in e&&"selectionEnd"in e)t=e.selectionStart,n=e.selectionEnd;else {var a=document.selection.createRange();a.parentElement()===e&&(t=-a.moveStart("character",-e.value.length),n=-a.moveEnd("character",-e.value.length));}return {start:t,end:n,length:n-t}}var defaultFormatChars$1={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},defaultMaskChar$1="_";function parseMask$1(e,t,n){var a="",i="",r=null,o=[];if(t===undefined&&(t=defaultMaskChar$1),null==n&&(n=defaultFormatChars$1),!e||"string"!=typeof e)return {maskChar:t,formatChars:n,mask:null,prefix:null,lastEditablePosition:null,permanents:[]};var s=!1;return e.split("").forEach(function(e){s=!s&&"\\"===e||(s||!n[e]?(o.push(a.length),a.length===o.length-1&&(i+=e)):r=a.length+1,a+=e,!1);}),{maskChar:t,formatChars:n,prefix:i,mask:a,lastEditablePosition:r,permanents:o}}function isPermanentCharacter$1(e,t){return -1!==e.permanents.indexOf(t)}function isAllowedCharacter$1(e,t,n){var a=e.mask,i=e.formatChars;if(!n)return !1;if(isPermanentCharacter$1(e,t))return a[t]===n;var r=i[a[t]];return new RegExp(r).test(n)}function isEmpty$1(n,e){return e.split("").every(function(e,t){return isPermanentCharacter$1(n,t)||!isAllowedCharacter$1(n,t,e)})}function getFilledLength$1(e,t){var n=e.maskChar,a=e.prefix;if(!n){for(;t.length>a.length&&isPermanentCharacter$1(e,t.length-1);)t=t.slice(0,t.length-1);return t.length}for(var i=a.length,r=t.length;r>=a.length;r--){var o=t[r];if(!isPermanentCharacter$1(e,r)&&isAllowedCharacter$1(e,r,o)){i=r+1;break}}return i}function isFilled$1(e,t){return getFilledLength$1(e,t)===e.mask.length}function formatValue$1(e,t){var n=e.maskChar,a=e.mask,i=e.prefix;if(!n){for((t=insertString$1(e,"",t,0)).length<i.length&&(t=i);t.length<a.length&&isPermanentCharacter$1(e,t.length);)t+=a[t.length];return t}if(t)return insertString$1(e,formatValue$1(e,""),t,0);for(var r=0;r<a.length;r++)isPermanentCharacter$1(e,r)?t+=a[r]:t+=n;return t}function clearRange$1(n,e,a,t){var i=a+t,r=n.maskChar,o=n.mask,s=n.prefix,l=e.split("");if(r)return l.map(function(e,t){return t<a||i<=t?e:isPermanentCharacter$1(n,t)?o[t]:r}).join("");for(var u=i;u<l.length;u++)isPermanentCharacter$1(n,u)&&(l[u]="");return a=Math.max(s.length,a),l.splice(a,i-a),e=l.join(""),formatValue$1(n,e)}function insertString$1(r,o,e,s){var l=r.mask,u=r.maskChar,c=r.prefix,t=e.split(""),h=isFilled$1(r,o);return !u&&s>o.length&&(o+=l.slice(o.length,s)),t.every(function(e){for(;i=e,isPermanentCharacter$1(r,a=s)&&i!==l[a];){if(s>=o.length&&(o+=l[s]),t=e,n=s,u&&isPermanentCharacter$1(r,n)&&t===u)return !0;if(++s>=l.length)return !1}var t,n,a,i;return !isAllowedCharacter$1(r,s,e)&&e!==u||(s<o.length?o=u||h||s<c.length?o.slice(0,s)+e+o.slice(s+1):(o=o.slice(0,s)+e+o.slice(s),formatValue$1(r,o)):u||(o+=e),++s<l.length)}),o}function getInsertStringLength$1(a,e,t,i){var r=a.mask,o=a.maskChar,n=t.split(""),s=i;return n.every(function(e){for(;n=e,isPermanentCharacter$1(a,t=i)&&n!==r[t];)if(++i>=r.length)return !1;var t,n;return (isAllowedCharacter$1(a,i,e)||e===o)&&i++,i<r.length}),i-s}function getLeftEditablePosition$1(e,t){for(var n=t;0<=n;--n)if(!isPermanentCharacter$1(e,n))return n;return null}function getRightEditablePosition$1(e,t){for(var n=e.mask,a=t;a<n.length;++a)if(!isPermanentCharacter$1(e,a))return a;return null}function getStringValue$1(e){return e||0===e?e+"":""}function processChange$1(e,t,n,a,i){var r=e.mask,o=e.prefix,s=e.lastEditablePosition,l=t,u="",c=0,h=0,f=Math.min(i.start,n.start);if(n.end>i.start?h=(c=getInsertStringLength$1(e,a,u=l.slice(i.start,n.end),f))?i.length:0:l.length<a.length&&(h=a.length-l.length),l=a,h){if(1===h&&!i.length)f=i.start===n.start?getRightEditablePosition$1(e,n.start):getLeftEditablePosition$1(e,n.start);l=clearRange$1(e,l,f,h);}return l=insertString$1(e,l,u,f),(f+=c)>=r.length?f=r.length:f<o.length&&!c?f=o.length:f>=o.length&&f<s&&c&&(f=getRightEditablePosition$1(e,f)),u||(u=null),{value:l=formatValue$1(e,l),enteredString:u,selection:{start:f,end:f}}}function isWindowsPhoneBrowser$1(){var e=new RegExp("windows","i"),t=new RegExp("phone","i"),n=navigator.userAgent;return e.test(n)&&t.test(n)}function isFunction$1(e){return "function"==typeof e}function getRequestAnimationFrame$1(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame}function getCancelAnimationFrame$1(){return window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame}function defer$1(e){return (!!getCancelAnimationFrame$1()?getRequestAnimationFrame$1():function(){return setTimeout(e,1e3/60)})(e)}function cancelDefer$1(e){(getCancelAnimationFrame$1()||clearTimeout)(e);}var InputElement$1=function(c){function e(e){var f=c.call(this,e)||this;f.focused=!1,f.mounted=!1,f.previousSelection=null,f.selectionDeferId=null,f.saveSelectionLoopDeferId=null,f.saveSelectionLoop=function(){f.previousSelection=f.getSelection(),f.saveSelectionLoopDeferId=defer$1(f.saveSelectionLoop);},f.runSaveSelectionLoop=function(){null===f.saveSelectionLoopDeferId&&f.saveSelectionLoop();},f.stopSaveSelectionLoop=function(){null!==f.saveSelectionLoopDeferId&&(cancelDefer$1(f.saveSelectionLoopDeferId),f.saveSelectionLoopDeferId=null,f.previousSelection=null);},f.getInputDOMNode=function(){if(!f.mounted)return null;var e=reactDom.findDOMNode(_assertThisInitialized$1(_assertThisInitialized$1(f))),t="undefined"!=typeof window&&e instanceof window.Element;if(e&&!t)return null;if("INPUT"!==e.nodeName&&(e=e.querySelector("input")),!e)throw new Error("react-input-mask: inputComponent doesn't contain input node");return e},f.getInputValue=function(){var e=f.getInputDOMNode();return e?e.value:null},f.setInputValue=function(e){var t=f.getInputDOMNode();t&&(f.value=e,t.value=e);},f.setCursorToEnd=function(){var e=getFilledLength$1(f.maskOptions,f.value),t=getRightEditablePosition$1(f.maskOptions,e);null!==t&&f.setCursorPosition(t);},f.setSelection=function(e,t,n){void 0===n&&(n={});var a=f.getInputDOMNode(),i=f.isFocused();a&&i&&(n.deferred||setInputSelection$1(a,e,t),null!==f.selectionDeferId&&cancelDefer$1(f.selectionDeferId),f.selectionDeferId=defer$1(function(){f.selectionDeferId=null,setInputSelection$1(a,e,t);}),f.previousSelection={start:e,end:t,length:Math.abs(t-e)});},f.getSelection=function(){return getInputSelection$1(f.getInputDOMNode())},f.getCursorPosition=function(){return f.getSelection().start},f.setCursorPosition=function(e){f.setSelection(e,e);},f.isFocused=function(){return f.focused},f.getBeforeMaskedValueChangeConfig=function(){var e=f.maskOptions,t=e.mask,n=e.maskChar,a=e.permanents,i=e.formatChars;return {mask:t,maskChar:n,permanents:a,alwaysShowMask:!!f.props.alwaysShowMask,formatChars:i}},f.isInputAutofilled=function(e,t,n,a){var i=f.getInputDOMNode();try{if(i.matches(":-webkit-autofill"))return !0}catch(r){}return !f.focused||a.end<n.length&&t.end===e.length},f.onChange=function(e){var t=_assertThisInitialized$1(_assertThisInitialized$1(f)).beforePasteState,n=_assertThisInitialized$1(_assertThisInitialized$1(f)).previousSelection,a=f.props.beforeMaskedValueChange,i=f.getInputValue(),r=f.value,o=f.getSelection();f.isInputAutofilled(i,o,r,n)&&(r=formatValue$1(f.maskOptions,""),n={start:0,end:0,length:0}),t&&(n=t.selection,r=t.value,o={start:n.start+i.length,end:n.start+i.length,length:0},i=r.slice(0,n.start)+i+r.slice(n.end),f.beforePasteState=null);var s=processChange$1(f.maskOptions,i,o,r,n),l=s.enteredString,u=s.selection,c=s.value;if(isFunction$1(a)){var h=a({value:c,selection:u},{value:r,selection:n},l,f.getBeforeMaskedValueChangeConfig());c=h.value,u=h.selection;}f.setInputValue(c),isFunction$1(f.props.onChange)&&f.props.onChange(e),f.isWindowsPhoneBrowser?f.setSelection(u.start,u.end,{deferred:!0}):f.setSelection(u.start,u.end);},f.onFocus=function(e){var t=f.props.beforeMaskedValueChange,n=f.maskOptions,a=n.mask,i=n.prefix;if(f.focused=!0,f.mounted=!0,a){if(f.value)getFilledLength$1(f.maskOptions,f.value)<f.maskOptions.mask.length&&f.setCursorToEnd();else {var r=formatValue$1(f.maskOptions,i),o=formatValue$1(f.maskOptions,r),s=getFilledLength$1(f.maskOptions,o),l=getRightEditablePosition$1(f.maskOptions,s),u={start:l,end:l};if(isFunction$1(t)){var c=t({value:o,selection:u},{value:f.value,selection:null},null,f.getBeforeMaskedValueChangeConfig());o=c.value,u=c.selection;}var h=o!==f.getInputValue();h&&f.setInputValue(o),h&&isFunction$1(f.props.onChange)&&f.props.onChange(e),f.setSelection(u.start,u.end);}f.runSaveSelectionLoop();}isFunction$1(f.props.onFocus)&&f.props.onFocus(e);},f.onBlur=function(e){var t=f.props.beforeMaskedValueChange,n=f.maskOptions.mask;if(f.stopSaveSelectionLoop(),f.focused=!1,n&&!f.props.alwaysShowMask&&isEmpty$1(f.maskOptions,f.value)){var a="";if(isFunction$1(t))a=t({value:a,selection:null},{value:f.value,selection:f.previousSelection},null,f.getBeforeMaskedValueChangeConfig()).value;var i=a!==f.getInputValue();i&&f.setInputValue(a),i&&isFunction$1(f.props.onChange)&&f.props.onChange(e);}isFunction$1(f.props.onBlur)&&f.props.onBlur(e);},f.onMouseDown=function(e){if(!f.focused&&document.addEventListener){f.mouseDownX=e.clientX,f.mouseDownY=e.clientY,f.mouseDownTime=(new Date).getTime();var r=function r(e){if(document.removeEventListener("mouseup",r),f.focused){var t=Math.abs(e.clientX-f.mouseDownX),n=Math.abs(e.clientY-f.mouseDownY),a=Math.max(t,n),i=(new Date).getTime()-f.mouseDownTime;(a<=10&&i<=200||a<=5&&i<=300)&&f.setCursorToEnd();}};document.addEventListener("mouseup",r);}isFunction$1(f.props.onMouseDown)&&f.props.onMouseDown(e);},f.onPaste=function(e){isFunction$1(f.props.onPaste)&&f.props.onPaste(e),e.defaultPrevented||(f.beforePasteState={value:f.getInputValue(),selection:f.getSelection()},f.setInputValue(""));},f.handleRef=function(e){null==f.props.children&&isFunction$1(f.props.inputRef)&&f.props.inputRef(e);};var t=e.mask,n=e.maskChar,a=e.formatChars,i=e.alwaysShowMask,r=e.beforeMaskedValueChange,o=e.defaultValue,s=e.value;f.maskOptions=parseMask$1(t,n,a),null==o&&(o=""),null==s&&(s=o);var l=getStringValue$1(s);if(f.maskOptions.mask&&(i||l)&&(l=formatValue$1(f.maskOptions,l),isFunction$1(r))){var u=e.value;null==e.value&&(u=o),l=r({value:l,selection:null},{value:u=getStringValue$1(u),selection:null},null,f.getBeforeMaskedValueChangeConfig()).value;}return f.value=l,f}_inheritsLoose$1(e,c);var t=e.prototype;return t.componentDidMount=function(){this.mounted=!0,this.getInputDOMNode()&&(this.isWindowsPhoneBrowser=isWindowsPhoneBrowser$1(),this.maskOptions.mask&&this.getInputValue()!==this.value&&this.setInputValue(this.value));},t.componentDidUpdate=function(){var e=this.previousSelection,t=this.props,n=t.beforeMaskedValueChange,a=t.alwaysShowMask,i=t.mask,r=t.maskChar,o=t.formatChars,s=this.maskOptions,l=a||this.isFocused(),u=null!=this.props.value,c=u?getStringValue$1(this.props.value):this.value,h=e?e.start:null;if(this.maskOptions=parseMask$1(i,r,o),this.maskOptions.mask){!s.mask&&this.isFocused()&&this.runSaveSelectionLoop();var f=this.maskOptions.mask&&this.maskOptions.mask!==s.mask;if(s.mask||u||(c=this.getInputValue()),(f||this.maskOptions.mask&&(c||l))&&(c=formatValue$1(this.maskOptions,c)),f){var p=getFilledLength$1(this.maskOptions,c);(null===h||p<h)&&(h=isFilled$1(this.maskOptions,c)?p:getRightEditablePosition$1(this.maskOptions,p));}!this.maskOptions.mask||!isEmpty$1(this.maskOptions,c)||l||u&&this.props.value||(c="");var d={start:h,end:h};if(isFunction$1(n)){var m=n({value:c,selection:d},{value:this.value,selection:this.previousSelection},null,this.getBeforeMaskedValueChangeConfig());c=m.value,d=m.selection;}this.value=c;var g=this.getInputValue()!==this.value;g?(this.setInputValue(this.value),this.forceUpdate()):f&&this.forceUpdate();var v=!1;null!=d.start&&null!=d.end&&(v=!e||e.start!==d.start||e.end!==d.end),(v||g)&&this.setSelection(d.start,d.end);}else s.mask&&(this.stopSaveSelectionLoop(),this.forceUpdate());},t.componentWillUnmount=function(){this.mounted=!1,null!==this.selectionDeferId&&cancelDefer$1(this.selectionDeferId),this.stopSaveSelectionLoop();},t.render=function(){var t,e=this.props,n=(e.mask,e.alwaysShowMask,e.maskChar,e.formatChars,e.inputRef,e.beforeMaskedValueChange,e.children),a=_objectWithoutPropertiesLoose$1(e,["mask","alwaysShowMask","maskChar","formatChars","inputRef","beforeMaskedValueChange","children"]);if(n){isFunction$1(n)||invariant_1$1(!1);var i=["onChange","onPaste","onMouseDown","onFocus","onBlur","value","disabled","readOnly"],r=_extends$1({},a);i.forEach(function(e){return delete r[e]}),t=n(r),i.filter(function(e){return null!=t.props[e]&&t.props[e]!==a[e]}).length&&invariant_1$1(!1);}else t=React$1.createElement("input",_extends$1({ref:this.handleRef},a));var o={onFocus:this.onFocus,onBlur:this.onBlur};return this.maskOptions.mask&&(a.disabled||a.readOnly||(o.onChange=this.onChange,o.onPaste=this.onPaste,o.onMouseDown=this.onMouseDown),null!=a.value&&(o.value=this.value)),t=React$1.cloneElement(t,o)},e}(React$1.Component);var reactInputMask_production_min=InputElement$1;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
171
|
+
*
|
|
172
|
+
* This source code is licensed under the MIT license found in the
|
|
173
|
+
* LICENSE file in the root directory of this source tree.
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
179
|
+
*
|
|
180
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
181
|
+
* to provide information about what broke and what you were
|
|
182
|
+
* expecting.
|
|
183
|
+
*
|
|
184
|
+
* The invariant message will be stripped in production, but the invariant
|
|
185
|
+
* will remain to ensure logic does not differ in production.
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
var NODE_ENV = process.env.NODE_ENV;
|
|
189
|
+
|
|
190
|
+
var invariant$1 = function(condition, format, a, b, c, d, e, f) {
|
|
191
|
+
if (NODE_ENV !== 'production') {
|
|
192
|
+
if (format === undefined) {
|
|
193
|
+
throw new Error('invariant requires an error message argument');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!condition) {
|
|
198
|
+
var error;
|
|
199
|
+
if (format === undefined) {
|
|
200
|
+
error = new Error(
|
|
201
|
+
'Minified exception occurred; use the non-minified dev environment ' +
|
|
202
|
+
'for the full error message and additional helpful warnings.'
|
|
203
|
+
);
|
|
204
|
+
} else {
|
|
205
|
+
var args = [a, b, c, d, e, f];
|
|
206
|
+
var argIndex = 0;
|
|
207
|
+
error = new Error(
|
|
208
|
+
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
209
|
+
);
|
|
210
|
+
error.name = 'Invariant Violation';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
var invariant_1 = invariant$1;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
222
|
+
*
|
|
223
|
+
* This source code is licensed under the MIT license found in the
|
|
224
|
+
* LICENSE file in the root directory of this source tree.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
230
|
+
* This can be used to log issues in development environments in critical
|
|
231
|
+
* paths. Removing the logging code for production environments will keep the
|
|
232
|
+
* same logic and follow the same code paths.
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
var __DEV__ = process.env.NODE_ENV !== 'production';
|
|
236
|
+
|
|
237
|
+
var warning$1 = function() {};
|
|
238
|
+
|
|
239
|
+
if (__DEV__) {
|
|
240
|
+
var printWarning = function printWarning(format, args) {
|
|
241
|
+
var len = arguments.length;
|
|
242
|
+
args = new Array(len > 1 ? len - 1 : 0);
|
|
243
|
+
for (var key = 1; key < len; key++) {
|
|
244
|
+
args[key - 1] = arguments[key];
|
|
245
|
+
}
|
|
246
|
+
var argIndex = 0;
|
|
247
|
+
var message = 'Warning: ' +
|
|
248
|
+
format.replace(/%s/g, function() {
|
|
249
|
+
return args[argIndex++];
|
|
250
|
+
});
|
|
251
|
+
if (typeof console !== 'undefined') {
|
|
252
|
+
console.error(message);
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
// --- Welcome to debugging React ---
|
|
256
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
257
|
+
// to find the callsite that caused this warning to fire.
|
|
258
|
+
throw new Error(message);
|
|
259
|
+
} catch (x) {}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
warning$1 = function(condition, format, args) {
|
|
263
|
+
var len = arguments.length;
|
|
264
|
+
args = new Array(len > 2 ? len - 2 : 0);
|
|
265
|
+
for (var key = 2; key < len; key++) {
|
|
266
|
+
args[key - 2] = arguments[key];
|
|
267
|
+
}
|
|
268
|
+
if (format === undefined) {
|
|
269
|
+
throw new Error(
|
|
270
|
+
'`warning(condition, format, ...args)` requires a warning ' +
|
|
271
|
+
'message argument'
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
if (!condition) {
|
|
275
|
+
printWarning.apply(null, [format].concat(args));
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
var warning_1 = warning$1;
|
|
281
|
+
|
|
282
|
+
function _interopDefault$1 (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
283
|
+
|
|
284
|
+
var React = _interopDefault$1(React$2);
|
|
285
|
+
|
|
286
|
+
var invariant = _interopDefault$1(invariant_1);
|
|
287
|
+
var warning = _interopDefault$1(warning_1);
|
|
288
|
+
|
|
289
|
+
function _defaults2(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
|
|
290
|
+
|
|
291
|
+
function _extends() {
|
|
292
|
+
_extends = Object.assign || function (target) {
|
|
293
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
294
|
+
var source = arguments[i];
|
|
295
|
+
|
|
296
|
+
for (var key in source) {
|
|
297
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
298
|
+
target[key] = source[key];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return target;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return _extends.apply(this, arguments);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function _inheritsLoose(subClass, superClass) {
|
|
310
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
311
|
+
subClass.prototype.constructor = subClass;
|
|
312
|
+
|
|
313
|
+
_defaults2(subClass, superClass);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
317
|
+
if (source == null) return {};
|
|
318
|
+
var target = {};
|
|
319
|
+
var sourceKeys = Object.keys(source);
|
|
320
|
+
var key, i;
|
|
321
|
+
|
|
322
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
323
|
+
key = sourceKeys[i];
|
|
324
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
325
|
+
target[key] = source[key];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return target;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function _assertThisInitialized(self) {
|
|
332
|
+
if (self === void 0) {
|
|
333
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return self;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function setInputSelection(input, start, end) {
|
|
340
|
+
if ('selectionStart' in input && 'selectionEnd' in input) {
|
|
341
|
+
input.selectionStart = start;
|
|
342
|
+
input.selectionEnd = end;
|
|
343
|
+
} else {
|
|
344
|
+
var range = input.createTextRange();
|
|
345
|
+
range.collapse(true);
|
|
346
|
+
range.moveStart('character', start);
|
|
347
|
+
range.moveEnd('character', end - start);
|
|
348
|
+
range.select();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function getInputSelection(input) {
|
|
352
|
+
var start = 0;
|
|
353
|
+
var end = 0;
|
|
354
|
+
|
|
355
|
+
if ('selectionStart' in input && 'selectionEnd' in input) {
|
|
356
|
+
start = input.selectionStart;
|
|
357
|
+
end = input.selectionEnd;
|
|
358
|
+
} else {
|
|
359
|
+
var range = document.selection.createRange();
|
|
360
|
+
|
|
361
|
+
if (range.parentElement() === input) {
|
|
362
|
+
start = -range.moveStart('character', -input.value.length);
|
|
363
|
+
end = -range.moveEnd('character', -input.value.length);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
start: start,
|
|
369
|
+
end: end,
|
|
370
|
+
length: end - start
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
var defaultFormatChars = {
|
|
375
|
+
'9': '[0-9]',
|
|
376
|
+
'a': '[A-Za-z]',
|
|
377
|
+
'*': '[A-Za-z0-9]'
|
|
378
|
+
};
|
|
379
|
+
var defaultMaskChar = '_';
|
|
380
|
+
|
|
381
|
+
function parseMask (mask, maskChar, formatChars) {
|
|
382
|
+
var parsedMaskString = '';
|
|
383
|
+
var prefix = '';
|
|
384
|
+
var lastEditablePosition = null;
|
|
385
|
+
var permanents = [];
|
|
386
|
+
|
|
387
|
+
if (maskChar === undefined) {
|
|
388
|
+
maskChar = defaultMaskChar;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (formatChars == null) {
|
|
392
|
+
formatChars = defaultFormatChars;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (!mask || typeof mask !== 'string') {
|
|
396
|
+
return {
|
|
397
|
+
maskChar: maskChar,
|
|
398
|
+
formatChars: formatChars,
|
|
399
|
+
mask: null,
|
|
400
|
+
prefix: null,
|
|
401
|
+
lastEditablePosition: null,
|
|
402
|
+
permanents: []
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
var isPermanent = false;
|
|
407
|
+
mask.split('').forEach(function (character) {
|
|
408
|
+
if (!isPermanent && character === '\\') {
|
|
409
|
+
isPermanent = true;
|
|
410
|
+
} else {
|
|
411
|
+
if (isPermanent || !formatChars[character]) {
|
|
412
|
+
permanents.push(parsedMaskString.length);
|
|
413
|
+
|
|
414
|
+
if (parsedMaskString.length === permanents.length - 1) {
|
|
415
|
+
prefix += character;
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
lastEditablePosition = parsedMaskString.length + 1;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
parsedMaskString += character;
|
|
422
|
+
isPermanent = false;
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
return {
|
|
426
|
+
maskChar: maskChar,
|
|
427
|
+
formatChars: formatChars,
|
|
428
|
+
prefix: prefix,
|
|
429
|
+
mask: parsedMaskString,
|
|
430
|
+
lastEditablePosition: lastEditablePosition,
|
|
431
|
+
permanents: permanents
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/* eslint no-use-before-define: ["error", { functions: false }] */
|
|
436
|
+
function isPermanentCharacter(maskOptions, pos) {
|
|
437
|
+
return maskOptions.permanents.indexOf(pos) !== -1;
|
|
438
|
+
}
|
|
439
|
+
function isAllowedCharacter(maskOptions, pos, character) {
|
|
440
|
+
var mask = maskOptions.mask,
|
|
441
|
+
formatChars = maskOptions.formatChars;
|
|
442
|
+
|
|
443
|
+
if (!character) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (isPermanentCharacter(maskOptions, pos)) {
|
|
448
|
+
return mask[pos] === character;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
var ruleChar = mask[pos];
|
|
452
|
+
var charRule = formatChars[ruleChar];
|
|
453
|
+
return new RegExp(charRule).test(character);
|
|
454
|
+
}
|
|
455
|
+
function isEmpty(maskOptions, value) {
|
|
456
|
+
return value.split('').every(function (character, i) {
|
|
457
|
+
return isPermanentCharacter(maskOptions, i) || !isAllowedCharacter(maskOptions, i, character);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
function getFilledLength(maskOptions, value) {
|
|
461
|
+
var maskChar = maskOptions.maskChar,
|
|
462
|
+
prefix = maskOptions.prefix;
|
|
463
|
+
|
|
464
|
+
if (!maskChar) {
|
|
465
|
+
while (value.length > prefix.length && isPermanentCharacter(maskOptions, value.length - 1)) {
|
|
466
|
+
value = value.slice(0, value.length - 1);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return value.length;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
var filledLength = prefix.length;
|
|
473
|
+
|
|
474
|
+
for (var i = value.length; i >= prefix.length; i--) {
|
|
475
|
+
var character = value[i];
|
|
476
|
+
var isEnteredCharacter = !isPermanentCharacter(maskOptions, i) && isAllowedCharacter(maskOptions, i, character);
|
|
477
|
+
|
|
478
|
+
if (isEnteredCharacter) {
|
|
479
|
+
filledLength = i + 1;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return filledLength;
|
|
485
|
+
}
|
|
486
|
+
function isFilled(maskOptions, value) {
|
|
487
|
+
return getFilledLength(maskOptions, value) === maskOptions.mask.length;
|
|
488
|
+
}
|
|
489
|
+
function formatValue(maskOptions, value) {
|
|
490
|
+
var maskChar = maskOptions.maskChar,
|
|
491
|
+
mask = maskOptions.mask,
|
|
492
|
+
prefix = maskOptions.prefix;
|
|
493
|
+
|
|
494
|
+
if (!maskChar) {
|
|
495
|
+
value = insertString(maskOptions, '', value, 0);
|
|
496
|
+
|
|
497
|
+
if (value.length < prefix.length) {
|
|
498
|
+
value = prefix;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
while (value.length < mask.length && isPermanentCharacter(maskOptions, value.length)) {
|
|
502
|
+
value += mask[value.length];
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return value;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (value) {
|
|
509
|
+
var emptyValue = formatValue(maskOptions, '');
|
|
510
|
+
return insertString(maskOptions, emptyValue, value, 0);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
for (var i = 0; i < mask.length; i++) {
|
|
514
|
+
if (isPermanentCharacter(maskOptions, i)) {
|
|
515
|
+
value += mask[i];
|
|
516
|
+
} else {
|
|
517
|
+
value += maskChar;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return value;
|
|
522
|
+
}
|
|
523
|
+
function clearRange(maskOptions, value, start, len) {
|
|
524
|
+
var end = start + len;
|
|
525
|
+
var maskChar = maskOptions.maskChar,
|
|
526
|
+
mask = maskOptions.mask,
|
|
527
|
+
prefix = maskOptions.prefix;
|
|
528
|
+
var arrayValue = value.split('');
|
|
529
|
+
|
|
530
|
+
if (!maskChar) {
|
|
531
|
+
// remove any permanent chars after clear range, they will be added back by formatValue
|
|
532
|
+
for (var i = end; i < arrayValue.length; i++) {
|
|
533
|
+
if (isPermanentCharacter(maskOptions, i)) {
|
|
534
|
+
arrayValue[i] = '';
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
start = Math.max(prefix.length, start);
|
|
539
|
+
arrayValue.splice(start, end - start);
|
|
540
|
+
value = arrayValue.join('');
|
|
541
|
+
return formatValue(maskOptions, value);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return arrayValue.map(function (character, i) {
|
|
545
|
+
if (i < start || i >= end) {
|
|
546
|
+
return character;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (isPermanentCharacter(maskOptions, i)) {
|
|
550
|
+
return mask[i];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return maskChar;
|
|
554
|
+
}).join('');
|
|
555
|
+
}
|
|
556
|
+
function insertString(maskOptions, value, insertStr, insertPosition) {
|
|
557
|
+
var mask = maskOptions.mask,
|
|
558
|
+
maskChar = maskOptions.maskChar,
|
|
559
|
+
prefix = maskOptions.prefix;
|
|
560
|
+
var arrayInsertStr = insertStr.split('');
|
|
561
|
+
var isInputFilled = isFilled(maskOptions, value);
|
|
562
|
+
|
|
563
|
+
var isUsablePosition = function isUsablePosition(pos, character) {
|
|
564
|
+
return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
var isUsableCharacter = function isUsableCharacter(character, pos) {
|
|
568
|
+
return !maskChar || !isPermanentCharacter(maskOptions, pos) || character !== maskChar;
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
if (!maskChar && insertPosition > value.length) {
|
|
572
|
+
value += mask.slice(value.length, insertPosition);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
arrayInsertStr.every(function (insertCharacter) {
|
|
576
|
+
while (!isUsablePosition(insertPosition, insertCharacter)) {
|
|
577
|
+
if (insertPosition >= value.length) {
|
|
578
|
+
value += mask[insertPosition];
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (!isUsableCharacter(insertCharacter, insertPosition)) {
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
insertPosition++; // stop iteration if maximum value length reached
|
|
586
|
+
|
|
587
|
+
if (insertPosition >= mask.length) {
|
|
588
|
+
return false;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
|
|
593
|
+
|
|
594
|
+
if (!isAllowed) {
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (insertPosition < value.length) {
|
|
599
|
+
if (maskChar || isInputFilled || insertPosition < prefix.length) {
|
|
600
|
+
value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition + 1);
|
|
601
|
+
} else {
|
|
602
|
+
value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition);
|
|
603
|
+
value = formatValue(maskOptions, value);
|
|
604
|
+
}
|
|
605
|
+
} else if (!maskChar) {
|
|
606
|
+
value += insertCharacter;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
insertPosition++; // stop iteration if maximum value length reached
|
|
610
|
+
|
|
611
|
+
return insertPosition < mask.length;
|
|
612
|
+
});
|
|
613
|
+
return value;
|
|
614
|
+
}
|
|
615
|
+
function getInsertStringLength(maskOptions, value, insertStr, insertPosition) {
|
|
616
|
+
var mask = maskOptions.mask,
|
|
617
|
+
maskChar = maskOptions.maskChar;
|
|
618
|
+
var arrayInsertStr = insertStr.split('');
|
|
619
|
+
var initialInsertPosition = insertPosition;
|
|
620
|
+
|
|
621
|
+
var isUsablePosition = function isUsablePosition(pos, character) {
|
|
622
|
+
return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
arrayInsertStr.every(function (insertCharacter) {
|
|
626
|
+
while (!isUsablePosition(insertPosition, insertCharacter)) {
|
|
627
|
+
insertPosition++; // stop iteration if maximum value length reached
|
|
628
|
+
|
|
629
|
+
if (insertPosition >= mask.length) {
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
|
|
635
|
+
|
|
636
|
+
if (isAllowed) {
|
|
637
|
+
insertPosition++;
|
|
638
|
+
} // stop iteration if maximum value length reached
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
return insertPosition < mask.length;
|
|
642
|
+
});
|
|
643
|
+
return insertPosition - initialInsertPosition;
|
|
644
|
+
}
|
|
645
|
+
function getLeftEditablePosition(maskOptions, pos) {
|
|
646
|
+
for (var i = pos; i >= 0; --i) {
|
|
647
|
+
if (!isPermanentCharacter(maskOptions, i)) {
|
|
648
|
+
return i;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
function getRightEditablePosition(maskOptions, pos) {
|
|
655
|
+
var mask = maskOptions.mask;
|
|
656
|
+
|
|
657
|
+
for (var i = pos; i < mask.length; ++i) {
|
|
658
|
+
if (!isPermanentCharacter(maskOptions, i)) {
|
|
659
|
+
return i;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
function getStringValue(value) {
|
|
666
|
+
return !value && value !== 0 ? '' : value + '';
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function processChange(maskOptions, value, selection, previousValue, previousSelection) {
|
|
670
|
+
var mask = maskOptions.mask,
|
|
671
|
+
prefix = maskOptions.prefix,
|
|
672
|
+
lastEditablePosition = maskOptions.lastEditablePosition;
|
|
673
|
+
var newValue = value;
|
|
674
|
+
var enteredString = '';
|
|
675
|
+
var formattedEnteredStringLength = 0;
|
|
676
|
+
var removedLength = 0;
|
|
677
|
+
var cursorPosition = Math.min(previousSelection.start, selection.start);
|
|
678
|
+
|
|
679
|
+
if (selection.end > previousSelection.start) {
|
|
680
|
+
enteredString = newValue.slice(previousSelection.start, selection.end);
|
|
681
|
+
formattedEnteredStringLength = getInsertStringLength(maskOptions, previousValue, enteredString, cursorPosition);
|
|
682
|
+
|
|
683
|
+
if (!formattedEnteredStringLength) {
|
|
684
|
+
removedLength = 0;
|
|
685
|
+
} else {
|
|
686
|
+
removedLength = previousSelection.length;
|
|
687
|
+
}
|
|
688
|
+
} else if (newValue.length < previousValue.length) {
|
|
689
|
+
removedLength = previousValue.length - newValue.length;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
newValue = previousValue;
|
|
693
|
+
|
|
694
|
+
if (removedLength) {
|
|
695
|
+
if (removedLength === 1 && !previousSelection.length) {
|
|
696
|
+
var deleteFromRight = previousSelection.start === selection.start;
|
|
697
|
+
cursorPosition = deleteFromRight ? getRightEditablePosition(maskOptions, selection.start) : getLeftEditablePosition(maskOptions, selection.start);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
newValue = clearRange(maskOptions, newValue, cursorPosition, removedLength);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
newValue = insertString(maskOptions, newValue, enteredString, cursorPosition);
|
|
704
|
+
cursorPosition = cursorPosition + formattedEnteredStringLength;
|
|
705
|
+
|
|
706
|
+
if (cursorPosition >= mask.length) {
|
|
707
|
+
cursorPosition = mask.length;
|
|
708
|
+
} else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
|
|
709
|
+
cursorPosition = prefix.length;
|
|
710
|
+
} else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
|
|
711
|
+
cursorPosition = getRightEditablePosition(maskOptions, cursorPosition);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
newValue = formatValue(maskOptions, newValue);
|
|
715
|
+
|
|
716
|
+
if (!enteredString) {
|
|
717
|
+
enteredString = null;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return {
|
|
721
|
+
value: newValue,
|
|
722
|
+
enteredString: enteredString,
|
|
723
|
+
selection: {
|
|
724
|
+
start: cursorPosition,
|
|
725
|
+
end: cursorPosition
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function isWindowsPhoneBrowser() {
|
|
731
|
+
var windows = new RegExp('windows', 'i');
|
|
732
|
+
var phone = new RegExp('phone', 'i');
|
|
733
|
+
var ua = navigator.userAgent;
|
|
734
|
+
return windows.test(ua) && phone.test(ua);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function isFunction(value) {
|
|
738
|
+
return typeof value === 'function';
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function getRequestAnimationFrame() {
|
|
742
|
+
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function getCancelAnimationFrame() {
|
|
746
|
+
return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function defer(fn) {
|
|
750
|
+
var hasCancelAnimationFrame = !!getCancelAnimationFrame();
|
|
751
|
+
var deferFn;
|
|
752
|
+
|
|
753
|
+
if (hasCancelAnimationFrame) {
|
|
754
|
+
deferFn = getRequestAnimationFrame();
|
|
755
|
+
} else {
|
|
756
|
+
deferFn = function deferFn() {
|
|
757
|
+
return setTimeout(fn, 1000 / 60);
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return deferFn(fn);
|
|
762
|
+
}
|
|
763
|
+
function cancelDefer(deferId) {
|
|
764
|
+
var cancelFn = getCancelAnimationFrame() || clearTimeout;
|
|
765
|
+
cancelFn(deferId);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
var InputElement =
|
|
769
|
+
/*#__PURE__*/
|
|
770
|
+
function (_React$Component) {
|
|
771
|
+
_inheritsLoose(InputElement, _React$Component);
|
|
772
|
+
|
|
773
|
+
function InputElement(props) {
|
|
774
|
+
var _this;
|
|
775
|
+
|
|
776
|
+
_this = _React$Component.call(this, props) || this;
|
|
777
|
+
_this.focused = false;
|
|
778
|
+
_this.mounted = false;
|
|
779
|
+
_this.previousSelection = null;
|
|
780
|
+
_this.selectionDeferId = null;
|
|
781
|
+
_this.saveSelectionLoopDeferId = null;
|
|
782
|
+
|
|
783
|
+
_this.saveSelectionLoop = function () {
|
|
784
|
+
_this.previousSelection = _this.getSelection();
|
|
785
|
+
_this.saveSelectionLoopDeferId = defer(_this.saveSelectionLoop);
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
_this.runSaveSelectionLoop = function () {
|
|
789
|
+
if (_this.saveSelectionLoopDeferId === null) {
|
|
790
|
+
_this.saveSelectionLoop();
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
_this.stopSaveSelectionLoop = function () {
|
|
795
|
+
if (_this.saveSelectionLoopDeferId !== null) {
|
|
796
|
+
cancelDefer(_this.saveSelectionLoopDeferId);
|
|
797
|
+
_this.saveSelectionLoopDeferId = null;
|
|
798
|
+
_this.previousSelection = null;
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
_this.getInputDOMNode = function () {
|
|
803
|
+
if (!_this.mounted) {
|
|
804
|
+
return null;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
var input = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
808
|
+
var isDOMNode = typeof window !== 'undefined' && input instanceof window.Element; // workaround for react-test-renderer
|
|
809
|
+
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
810
|
+
|
|
811
|
+
if (input && !isDOMNode) {
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (input.nodeName !== 'INPUT') {
|
|
816
|
+
input = input.querySelector('input');
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
if (!input) {
|
|
820
|
+
throw new Error('react-input-mask: inputComponent doesn\'t contain input node');
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
return input;
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
_this.getInputValue = function () {
|
|
827
|
+
var input = _this.getInputDOMNode();
|
|
828
|
+
|
|
829
|
+
if (!input) {
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
return input.value;
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
_this.setInputValue = function (value) {
|
|
837
|
+
var input = _this.getInputDOMNode();
|
|
838
|
+
|
|
839
|
+
if (!input) {
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
_this.value = value;
|
|
844
|
+
input.value = value;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
_this.setCursorToEnd = function () {
|
|
848
|
+
var filledLength = getFilledLength(_this.maskOptions, _this.value);
|
|
849
|
+
var pos = getRightEditablePosition(_this.maskOptions, filledLength);
|
|
850
|
+
|
|
851
|
+
if (pos !== null) {
|
|
852
|
+
_this.setCursorPosition(pos);
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
_this.setSelection = function (start, end, options) {
|
|
857
|
+
if (options === void 0) {
|
|
858
|
+
options = {};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
var input = _this.getInputDOMNode();
|
|
862
|
+
|
|
863
|
+
var isFocused = _this.isFocused(); // don't change selection on unfocused input
|
|
864
|
+
// because Safari sets focus on selection change (#154)
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
if (!input || !isFocused) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
var _options = options,
|
|
872
|
+
deferred = _options.deferred;
|
|
873
|
+
|
|
874
|
+
if (!deferred) {
|
|
875
|
+
setInputSelection(input, start, end);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
if (_this.selectionDeferId !== null) {
|
|
879
|
+
cancelDefer(_this.selectionDeferId);
|
|
880
|
+
} // deferred selection update is required for pre-Lollipop Android browser,
|
|
881
|
+
// but for consistent behavior we do it for all browsers
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
_this.selectionDeferId = defer(function () {
|
|
885
|
+
_this.selectionDeferId = null;
|
|
886
|
+
setInputSelection(input, start, end);
|
|
887
|
+
});
|
|
888
|
+
_this.previousSelection = {
|
|
889
|
+
start: start,
|
|
890
|
+
end: end,
|
|
891
|
+
length: Math.abs(end - start)
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
_this.getSelection = function () {
|
|
896
|
+
var input = _this.getInputDOMNode();
|
|
897
|
+
|
|
898
|
+
return getInputSelection(input);
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
_this.getCursorPosition = function () {
|
|
902
|
+
return _this.getSelection().start;
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
_this.setCursorPosition = function (pos) {
|
|
906
|
+
_this.setSelection(pos, pos);
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
_this.isFocused = function () {
|
|
910
|
+
return _this.focused;
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
_this.getBeforeMaskedValueChangeConfig = function () {
|
|
914
|
+
var _this$maskOptions = _this.maskOptions,
|
|
915
|
+
mask = _this$maskOptions.mask,
|
|
916
|
+
maskChar = _this$maskOptions.maskChar,
|
|
917
|
+
permanents = _this$maskOptions.permanents,
|
|
918
|
+
formatChars = _this$maskOptions.formatChars;
|
|
919
|
+
var alwaysShowMask = _this.props.alwaysShowMask;
|
|
920
|
+
return {
|
|
921
|
+
mask: mask,
|
|
922
|
+
maskChar: maskChar,
|
|
923
|
+
permanents: permanents,
|
|
924
|
+
alwaysShowMask: !!alwaysShowMask,
|
|
925
|
+
formatChars: formatChars
|
|
926
|
+
};
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
_this.isInputAutofilled = function (value, selection, previousValue, previousSelection) {
|
|
930
|
+
var input = _this.getInputDOMNode(); // only check for positive match because it will be false negative
|
|
931
|
+
// in case of autofill simulation in tests
|
|
932
|
+
//
|
|
933
|
+
// input.matches throws an exception if selector isn't supported
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
try {
|
|
937
|
+
if (input.matches(':-webkit-autofill')) {
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
} catch (e) {} // if input isn't focused then change event must have been triggered
|
|
941
|
+
// either by autofill or event simulation in tests
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
if (!_this.focused) {
|
|
945
|
+
return true;
|
|
946
|
+
} // if cursor has moved to the end while previousSelection forbids it
|
|
947
|
+
// then it must be autofill
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
return previousSelection.end < previousValue.length && selection.end === value.length;
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
_this.onChange = function (event) {
|
|
954
|
+
var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)),
|
|
955
|
+
beforePasteState = _assertThisInitialize.beforePasteState;
|
|
956
|
+
|
|
957
|
+
var _assertThisInitialize2 = _assertThisInitialized(_assertThisInitialized(_this)),
|
|
958
|
+
previousSelection = _assertThisInitialize2.previousSelection;
|
|
959
|
+
|
|
960
|
+
var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
|
|
961
|
+
|
|
962
|
+
var value = _this.getInputValue();
|
|
963
|
+
|
|
964
|
+
var previousValue = _this.value;
|
|
965
|
+
|
|
966
|
+
var selection = _this.getSelection(); // autofill replaces entire value, ignore old one
|
|
967
|
+
// https://github.com/sanniassin/react-input-mask/issues/113
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
if (_this.isInputAutofilled(value, selection, previousValue, previousSelection)) {
|
|
971
|
+
previousValue = formatValue(_this.maskOptions, '');
|
|
972
|
+
previousSelection = {
|
|
973
|
+
start: 0,
|
|
974
|
+
end: 0,
|
|
975
|
+
length: 0
|
|
976
|
+
};
|
|
977
|
+
} // set value and selection as if we haven't
|
|
978
|
+
// cleared input in onPaste handler
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
if (beforePasteState) {
|
|
982
|
+
previousSelection = beforePasteState.selection;
|
|
983
|
+
previousValue = beforePasteState.value;
|
|
984
|
+
selection = {
|
|
985
|
+
start: previousSelection.start + value.length,
|
|
986
|
+
end: previousSelection.start + value.length,
|
|
987
|
+
length: 0
|
|
988
|
+
};
|
|
989
|
+
value = previousValue.slice(0, previousSelection.start) + value + previousValue.slice(previousSelection.end);
|
|
990
|
+
_this.beforePasteState = null;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
var changedState = processChange(_this.maskOptions, value, selection, previousValue, previousSelection);
|
|
994
|
+
var enteredString = changedState.enteredString;
|
|
995
|
+
var newSelection = changedState.selection;
|
|
996
|
+
var newValue = changedState.value;
|
|
997
|
+
|
|
998
|
+
if (isFunction(beforeMaskedValueChange)) {
|
|
999
|
+
var modifiedValue = beforeMaskedValueChange({
|
|
1000
|
+
value: newValue,
|
|
1001
|
+
selection: newSelection
|
|
1002
|
+
}, {
|
|
1003
|
+
value: previousValue,
|
|
1004
|
+
selection: previousSelection
|
|
1005
|
+
}, enteredString, _this.getBeforeMaskedValueChangeConfig());
|
|
1006
|
+
newValue = modifiedValue.value;
|
|
1007
|
+
newSelection = modifiedValue.selection;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
_this.setInputValue(newValue);
|
|
1011
|
+
|
|
1012
|
+
if (isFunction(_this.props.onChange)) {
|
|
1013
|
+
_this.props.onChange(event);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
if (_this.isWindowsPhoneBrowser) {
|
|
1017
|
+
_this.setSelection(newSelection.start, newSelection.end, {
|
|
1018
|
+
deferred: true
|
|
1019
|
+
});
|
|
1020
|
+
} else {
|
|
1021
|
+
_this.setSelection(newSelection.start, newSelection.end);
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
_this.onFocus = function (event) {
|
|
1026
|
+
var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
|
|
1027
|
+
var _this$maskOptions2 = _this.maskOptions,
|
|
1028
|
+
mask = _this$maskOptions2.mask,
|
|
1029
|
+
prefix = _this$maskOptions2.prefix;
|
|
1030
|
+
_this.focused = true; // if autoFocus is set, onFocus triggers before componentDidMount
|
|
1031
|
+
|
|
1032
|
+
_this.mounted = true;
|
|
1033
|
+
|
|
1034
|
+
if (mask) {
|
|
1035
|
+
if (!_this.value) {
|
|
1036
|
+
var emptyValue = formatValue(_this.maskOptions, prefix);
|
|
1037
|
+
var newValue = formatValue(_this.maskOptions, emptyValue);
|
|
1038
|
+
var filledLength = getFilledLength(_this.maskOptions, newValue);
|
|
1039
|
+
var cursorPosition = getRightEditablePosition(_this.maskOptions, filledLength);
|
|
1040
|
+
var newSelection = {
|
|
1041
|
+
start: cursorPosition,
|
|
1042
|
+
end: cursorPosition
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
if (isFunction(beforeMaskedValueChange)) {
|
|
1046
|
+
var modifiedValue = beforeMaskedValueChange({
|
|
1047
|
+
value: newValue,
|
|
1048
|
+
selection: newSelection
|
|
1049
|
+
}, {
|
|
1050
|
+
value: _this.value,
|
|
1051
|
+
selection: null
|
|
1052
|
+
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
1053
|
+
newValue = modifiedValue.value;
|
|
1054
|
+
newSelection = modifiedValue.selection;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
var isInputValueChanged = newValue !== _this.getInputValue();
|
|
1058
|
+
|
|
1059
|
+
if (isInputValueChanged) {
|
|
1060
|
+
_this.setInputValue(newValue);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
if (isInputValueChanged && isFunction(_this.props.onChange)) {
|
|
1064
|
+
_this.props.onChange(event);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
_this.setSelection(newSelection.start, newSelection.end);
|
|
1068
|
+
} else if (getFilledLength(_this.maskOptions, _this.value) < _this.maskOptions.mask.length) {
|
|
1069
|
+
_this.setCursorToEnd();
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
_this.runSaveSelectionLoop();
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
if (isFunction(_this.props.onFocus)) {
|
|
1076
|
+
_this.props.onFocus(event);
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
_this.onBlur = function (event) {
|
|
1081
|
+
var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
|
|
1082
|
+
var mask = _this.maskOptions.mask;
|
|
1083
|
+
|
|
1084
|
+
_this.stopSaveSelectionLoop();
|
|
1085
|
+
|
|
1086
|
+
_this.focused = false;
|
|
1087
|
+
|
|
1088
|
+
if (mask && !_this.props.alwaysShowMask && isEmpty(_this.maskOptions, _this.value)) {
|
|
1089
|
+
var newValue = '';
|
|
1090
|
+
|
|
1091
|
+
if (isFunction(beforeMaskedValueChange)) {
|
|
1092
|
+
var modifiedValue = beforeMaskedValueChange({
|
|
1093
|
+
value: newValue,
|
|
1094
|
+
selection: null
|
|
1095
|
+
}, {
|
|
1096
|
+
value: _this.value,
|
|
1097
|
+
selection: _this.previousSelection
|
|
1098
|
+
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
1099
|
+
newValue = modifiedValue.value;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
var isInputValueChanged = newValue !== _this.getInputValue();
|
|
1103
|
+
|
|
1104
|
+
if (isInputValueChanged) {
|
|
1105
|
+
_this.setInputValue(newValue);
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
if (isInputValueChanged && isFunction(_this.props.onChange)) {
|
|
1109
|
+
_this.props.onChange(event);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
if (isFunction(_this.props.onBlur)) {
|
|
1114
|
+
_this.props.onBlur(event);
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
_this.onMouseDown = function (event) {
|
|
1119
|
+
// tiny unintentional mouse movements can break cursor
|
|
1120
|
+
// position on focus, so we have to restore it in that case
|
|
1121
|
+
//
|
|
1122
|
+
// https://github.com/sanniassin/react-input-mask/issues/108
|
|
1123
|
+
if (!_this.focused && document.addEventListener) {
|
|
1124
|
+
_this.mouseDownX = event.clientX;
|
|
1125
|
+
_this.mouseDownY = event.clientY;
|
|
1126
|
+
_this.mouseDownTime = new Date().getTime();
|
|
1127
|
+
|
|
1128
|
+
var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
|
|
1129
|
+
document.removeEventListener('mouseup', mouseUpHandler);
|
|
1130
|
+
|
|
1131
|
+
if (!_this.focused) {
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
var deltaX = Math.abs(mouseUpEvent.clientX - _this.mouseDownX);
|
|
1136
|
+
var deltaY = Math.abs(mouseUpEvent.clientY - _this.mouseDownY);
|
|
1137
|
+
var axisDelta = Math.max(deltaX, deltaY);
|
|
1138
|
+
|
|
1139
|
+
var timeDelta = new Date().getTime() - _this.mouseDownTime;
|
|
1140
|
+
|
|
1141
|
+
if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
|
|
1142
|
+
_this.setCursorToEnd();
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
document.addEventListener('mouseup', mouseUpHandler);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
if (isFunction(_this.props.onMouseDown)) {
|
|
1150
|
+
_this.props.onMouseDown(event);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
_this.onPaste = function (event) {
|
|
1155
|
+
if (isFunction(_this.props.onPaste)) {
|
|
1156
|
+
_this.props.onPaste(event);
|
|
1157
|
+
} // event.clipboardData might not work in Android browser
|
|
1158
|
+
// cleaning input to get raw text inside onChange handler
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
if (!event.defaultPrevented) {
|
|
1162
|
+
_this.beforePasteState = {
|
|
1163
|
+
value: _this.getInputValue(),
|
|
1164
|
+
selection: _this.getSelection()
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
_this.setInputValue('');
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
_this.handleRef = function (ref) {
|
|
1172
|
+
if (_this.props.children == null && isFunction(_this.props.inputRef)) {
|
|
1173
|
+
_this.props.inputRef(ref);
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
var _mask = props.mask,
|
|
1178
|
+
_maskChar = props.maskChar,
|
|
1179
|
+
_formatChars = props.formatChars,
|
|
1180
|
+
_alwaysShowMask = props.alwaysShowMask,
|
|
1181
|
+
_beforeMaskedValueChange = props.beforeMaskedValueChange;
|
|
1182
|
+
var defaultValue = props.defaultValue,
|
|
1183
|
+
_value = props.value;
|
|
1184
|
+
_this.maskOptions = parseMask(_mask, _maskChar, _formatChars);
|
|
1185
|
+
|
|
1186
|
+
if (defaultValue == null) {
|
|
1187
|
+
defaultValue = '';
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
if (_value == null) {
|
|
1191
|
+
_value = defaultValue;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
var _newValue = getStringValue(_value);
|
|
1195
|
+
|
|
1196
|
+
if (_this.maskOptions.mask && (_alwaysShowMask || _newValue)) {
|
|
1197
|
+
_newValue = formatValue(_this.maskOptions, _newValue);
|
|
1198
|
+
|
|
1199
|
+
if (isFunction(_beforeMaskedValueChange)) {
|
|
1200
|
+
var oldValue = props.value;
|
|
1201
|
+
|
|
1202
|
+
if (props.value == null) {
|
|
1203
|
+
oldValue = defaultValue;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
oldValue = getStringValue(oldValue);
|
|
1207
|
+
|
|
1208
|
+
var modifiedValue = _beforeMaskedValueChange({
|
|
1209
|
+
value: _newValue,
|
|
1210
|
+
selection: null
|
|
1211
|
+
}, {
|
|
1212
|
+
value: oldValue,
|
|
1213
|
+
selection: null
|
|
1214
|
+
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
1215
|
+
|
|
1216
|
+
_newValue = modifiedValue.value;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
_this.value = _newValue;
|
|
1221
|
+
return _this;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
var _proto = InputElement.prototype;
|
|
1225
|
+
|
|
1226
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
1227
|
+
this.mounted = true; // workaround for react-test-renderer
|
|
1228
|
+
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
1229
|
+
|
|
1230
|
+
if (!this.getInputDOMNode()) {
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
this.isWindowsPhoneBrowser = isWindowsPhoneBrowser();
|
|
1235
|
+
|
|
1236
|
+
if (this.maskOptions.mask && this.getInputValue() !== this.value) {
|
|
1237
|
+
this.setInputValue(this.value);
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
1242
|
+
var previousSelection = this.previousSelection;
|
|
1243
|
+
var _this$props = this.props,
|
|
1244
|
+
beforeMaskedValueChange = _this$props.beforeMaskedValueChange,
|
|
1245
|
+
alwaysShowMask = _this$props.alwaysShowMask,
|
|
1246
|
+
mask = _this$props.mask,
|
|
1247
|
+
maskChar = _this$props.maskChar,
|
|
1248
|
+
formatChars = _this$props.formatChars;
|
|
1249
|
+
var previousMaskOptions = this.maskOptions;
|
|
1250
|
+
var showEmpty = alwaysShowMask || this.isFocused();
|
|
1251
|
+
var hasValue = this.props.value != null;
|
|
1252
|
+
var newValue = hasValue ? getStringValue(this.props.value) : this.value;
|
|
1253
|
+
var cursorPosition = previousSelection ? previousSelection.start : null;
|
|
1254
|
+
this.maskOptions = parseMask(mask, maskChar, formatChars);
|
|
1255
|
+
|
|
1256
|
+
if (!this.maskOptions.mask) {
|
|
1257
|
+
if (previousMaskOptions.mask) {
|
|
1258
|
+
this.stopSaveSelectionLoop(); // render depends on this.maskOptions and this.value,
|
|
1259
|
+
// call forceUpdate to keep it in sync
|
|
1260
|
+
|
|
1261
|
+
this.forceUpdate();
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
return;
|
|
1265
|
+
} else if (!previousMaskOptions.mask && this.isFocused()) {
|
|
1266
|
+
this.runSaveSelectionLoop();
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
var isMaskChanged = this.maskOptions.mask && this.maskOptions.mask !== previousMaskOptions.mask;
|
|
1270
|
+
|
|
1271
|
+
if (!previousMaskOptions.mask && !hasValue) {
|
|
1272
|
+
newValue = this.getInputValue();
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
if (isMaskChanged || this.maskOptions.mask && (newValue || showEmpty)) {
|
|
1276
|
+
newValue = formatValue(this.maskOptions, newValue);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
if (isMaskChanged) {
|
|
1280
|
+
var filledLength = getFilledLength(this.maskOptions, newValue);
|
|
1281
|
+
|
|
1282
|
+
if (cursorPosition === null || filledLength < cursorPosition) {
|
|
1283
|
+
if (isFilled(this.maskOptions, newValue)) {
|
|
1284
|
+
cursorPosition = filledLength;
|
|
1285
|
+
} else {
|
|
1286
|
+
cursorPosition = getRightEditablePosition(this.maskOptions, filledLength);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
if (this.maskOptions.mask && isEmpty(this.maskOptions, newValue) && !showEmpty && (!hasValue || !this.props.value)) {
|
|
1292
|
+
newValue = '';
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
var newSelection = {
|
|
1296
|
+
start: cursorPosition,
|
|
1297
|
+
end: cursorPosition
|
|
1298
|
+
};
|
|
1299
|
+
|
|
1300
|
+
if (isFunction(beforeMaskedValueChange)) {
|
|
1301
|
+
var modifiedValue = beforeMaskedValueChange({
|
|
1302
|
+
value: newValue,
|
|
1303
|
+
selection: newSelection
|
|
1304
|
+
}, {
|
|
1305
|
+
value: this.value,
|
|
1306
|
+
selection: this.previousSelection
|
|
1307
|
+
}, null, this.getBeforeMaskedValueChangeConfig());
|
|
1308
|
+
newValue = modifiedValue.value;
|
|
1309
|
+
newSelection = modifiedValue.selection;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
this.value = newValue;
|
|
1313
|
+
var isValueChanged = this.getInputValue() !== this.value; // render depends on this.maskOptions and this.value,
|
|
1314
|
+
// call forceUpdate to keep it in sync
|
|
1315
|
+
|
|
1316
|
+
if (isValueChanged) {
|
|
1317
|
+
this.setInputValue(this.value);
|
|
1318
|
+
this.forceUpdate();
|
|
1319
|
+
} else if (isMaskChanged) {
|
|
1320
|
+
this.forceUpdate();
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
var isSelectionChanged = false;
|
|
1324
|
+
|
|
1325
|
+
if (newSelection.start != null && newSelection.end != null) {
|
|
1326
|
+
isSelectionChanged = !previousSelection || previousSelection.start !== newSelection.start || previousSelection.end !== newSelection.end;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if (isSelectionChanged || isValueChanged) {
|
|
1330
|
+
this.setSelection(newSelection.start, newSelection.end);
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
1335
|
+
this.mounted = false;
|
|
1336
|
+
|
|
1337
|
+
if (this.selectionDeferId !== null) {
|
|
1338
|
+
cancelDefer(this.selectionDeferId);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
this.stopSaveSelectionLoop();
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
_proto.render = function render() {
|
|
1345
|
+
var _this$props2 = this.props,
|
|
1346
|
+
mask = _this$props2.mask;
|
|
1347
|
+
_this$props2.alwaysShowMask;
|
|
1348
|
+
var maskChar = _this$props2.maskChar,
|
|
1349
|
+
formatChars = _this$props2.formatChars,
|
|
1350
|
+
inputRef = _this$props2.inputRef;
|
|
1351
|
+
_this$props2.beforeMaskedValueChange;
|
|
1352
|
+
var children = _this$props2.children,
|
|
1353
|
+
restProps = _objectWithoutPropertiesLoose(_this$props2, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
|
|
1354
|
+
|
|
1355
|
+
var inputElement;
|
|
1356
|
+
process.env.NODE_ENV !== "production" ? warning( // parse mask to test against actual mask prop as this.maskOptions
|
|
1357
|
+
// will be updated later in componentDidUpdate
|
|
1358
|
+
!restProps.maxLength || !parseMask(mask, maskChar, formatChars).mask, 'react-input-mask: maxLength property shouldn\'t be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.') : void 0;
|
|
1359
|
+
|
|
1360
|
+
if (children) {
|
|
1361
|
+
!isFunction(children) ? process.env.NODE_ENV !== "production" ? invariant(false, 'react-input-mask: children must be a function') : invariant(false) : void 0;
|
|
1362
|
+
var controlledProps = ['onChange', 'onPaste', 'onMouseDown', 'onFocus', 'onBlur', 'value', 'disabled', 'readOnly'];
|
|
1363
|
+
|
|
1364
|
+
var childrenProps = _extends({}, restProps);
|
|
1365
|
+
|
|
1366
|
+
controlledProps.forEach(function (propId) {
|
|
1367
|
+
return delete childrenProps[propId];
|
|
1368
|
+
});
|
|
1369
|
+
inputElement = children(childrenProps);
|
|
1370
|
+
var conflictProps = controlledProps.filter(function (propId) {
|
|
1371
|
+
return inputElement.props[propId] != null && inputElement.props[propId] !== restProps[propId];
|
|
1372
|
+
});
|
|
1373
|
+
!!conflictProps.length ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: the following props should be passed to the react-input-mask's component and should not be altered in children's function: " + conflictProps.join(', ')) : invariant(false) : void 0;
|
|
1374
|
+
process.env.NODE_ENV !== "production" ? warning(!inputRef, 'react-input-mask: inputRef is ignored when children is passed, attach ref to the children instead') : void 0;
|
|
1375
|
+
} else {
|
|
1376
|
+
inputElement = React.createElement("input", _extends({
|
|
1377
|
+
ref: this.handleRef
|
|
1378
|
+
}, restProps));
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
var changedProps = {
|
|
1382
|
+
onFocus: this.onFocus,
|
|
1383
|
+
onBlur: this.onBlur
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
if (this.maskOptions.mask) {
|
|
1387
|
+
if (!restProps.disabled && !restProps.readOnly) {
|
|
1388
|
+
changedProps.onChange = this.onChange;
|
|
1389
|
+
changedProps.onPaste = this.onPaste;
|
|
1390
|
+
changedProps.onMouseDown = this.onMouseDown;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
if (restProps.value != null) {
|
|
1394
|
+
changedProps.value = this.value;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
inputElement = React.cloneElement(inputElement, changedProps);
|
|
1399
|
+
return inputElement;
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
return InputElement;
|
|
1403
|
+
}(React.Component);
|
|
1404
|
+
|
|
1405
|
+
var reactInputMask_development = InputElement;
|
|
1406
|
+
|
|
1407
|
+
var reactInputMask = createCommonjsModule(function (module) {
|
|
1408
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1409
|
+
module.exports = reactInputMask_production_min;
|
|
1410
|
+
} else {
|
|
1411
|
+
module.exports = reactInputMask_development;
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
|
|
129
1415
|
var InputField = function (_a) {
|
|
130
|
-
var type = _a.type, id = _a.id, placeholder = _a.placeholder, onChange = _a.onChange, value = _a.value, label = _a.label, largura = _a.largura, readonly = _a.readonly, disabled = _a.disabled, required = _a.required, maxLength = _a.maxLength;
|
|
1416
|
+
var type = _a.type, id = _a.id, placeholder = _a.placeholder, onChange = _a.onChange, value = _a.value, label = _a.label, largura = _a.largura, readonly = _a.readonly, disabled = _a.disabled, required = _a.required, maxLength = _a.maxLength, maskType = _a.maskType;
|
|
131
1417
|
var appliedMaxLength = maxLength !== undefined ? maxLength : 524288;
|
|
132
1418
|
var handleChange = function (e) {
|
|
133
1419
|
if (type === 'number' && e.target.value.length > appliedMaxLength) {
|
|
@@ -135,9 +1421,13 @@ var InputField = function (_a) {
|
|
|
135
1421
|
}
|
|
136
1422
|
onChange(e);
|
|
137
1423
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1424
|
+
// Definindo as máscaras baseadas no tipo
|
|
1425
|
+
var mask = maskType === 'cpf' ? '999.999.999-99' :
|
|
1426
|
+
maskType === 'phone' ? '(99) 99999-9999' :
|
|
1427
|
+
maskType === 'time' ? '99:99' : '';
|
|
1428
|
+
return (React$2.createElement(React$2.Fragment, null,
|
|
1429
|
+
label && React$2.createElement("label", { htmlFor: id }, label),
|
|
1430
|
+
maskType ? (React$2.createElement(reactInputMask, { mask: mask, value: value, onChange: handleChange, disabled: disabled }, function (inputProps) { return (React$2.createElement("input", __assign({}, inputProps, { type: type, id: id, name: id, placeholder: placeholder, className: styles$4.inputPadrao, style: { width: largura ? "".concat(largura) : '', backgroundColor: disabled ? '#e5e5e5' : '' }, readOnly: readonly, required: required }))); })) : (React$2.createElement("input", { type: type, id: id, name: id, value: value, placeholder: placeholder, onChange: handleChange, className: styles$4.inputPadrao, style: { width: largura ? "".concat(largura) : '', backgroundColor: disabled ? '#e5e5e5' : '' }, readOnly: readonly, disabled: disabled, required: required, maxLength: type === 'text' ? appliedMaxLength : undefined }))));
|
|
141
1431
|
};
|
|
142
1432
|
|
|
143
1433
|
var css_248z$3 = ".textPage-module_container__GBEF6{align-items:center;display:flex;flex-direction:column;justify-content:center;padding:20px}.textPage-module_content__CpD68{display:flex;text-align:justify}.textPage-module_imageCabecalho__J6YFH{border-radius:8px}.textPage-module_imageCabecalho__J6YFH img{border-radius:8px;height:100%;object-fit:cover;width:100%}.textPage-module_contentWithLateralImage__-f5pQ{flex-direction:row}.textPage-module_imageLateral__Dy9Kx{align-self:flex-start;height:230px;margin-right:20px;margin-top:15px;width:300px}.textPage-module_imageLateral__Dy9Kx img{border-radius:8px;height:100%;object-fit:cover;width:100%}.textPage-module_text__3pwuU{color:#5d5d5d;flex:2;line-height:1.8;text-align:justify}.textPage-module_text__3pwuU p{line-height:1.6;margin:10px 0}.textPage-module_text__3pwuU .textPage-module_coordenacao__UypV-,.textPage-module_text__3pwuU .textPage-module_direcao__x5psb{font-weight:700;margin-top:20px}";
|
|
@@ -146,14 +1436,14 @@ styleInject(css_248z$3);
|
|
|
146
1436
|
|
|
147
1437
|
var TextPage = function (_a) {
|
|
148
1438
|
var imgLateral = _a.imgLateral, imgCabecalho = _a.imgCabecalho, texto = _a.texto;
|
|
149
|
-
return (React.createElement(React.Fragment, null,
|
|
150
|
-
React.createElement("div", { className: styles$3.container },
|
|
151
|
-
imgCabecalho && (React.createElement("div", { className: styles$3.imageCabecalho },
|
|
152
|
-
React.createElement("img", { src: imgCabecalho, alt: imgCabecalho }))),
|
|
153
|
-
React.createElement("div", { className: "".concat(styles$3.content, " ").concat(imgLateral ? styles$3.contentWithLateralImage : '') },
|
|
154
|
-
imgLateral && (React.createElement("div", { className: styles$3.imageLateral },
|
|
155
|
-
React.createElement("img", { src: imgLateral, alt: imgLateral }))),
|
|
156
|
-
React.createElement("div", { className: styles$3.text, dangerouslySetInnerHTML: { __html: texto } })))));
|
|
1439
|
+
return (React$2.createElement(React$2.Fragment, null,
|
|
1440
|
+
React$2.createElement("div", { className: styles$3.container },
|
|
1441
|
+
imgCabecalho && (React$2.createElement("div", { className: styles$3.imageCabecalho },
|
|
1442
|
+
React$2.createElement("img", { src: imgCabecalho, alt: imgCabecalho }))),
|
|
1443
|
+
React$2.createElement("div", { className: "".concat(styles$3.content, " ").concat(imgLateral ? styles$3.contentWithLateralImage : '') },
|
|
1444
|
+
imgLateral && (React$2.createElement("div", { className: styles$3.imageLateral },
|
|
1445
|
+
React$2.createElement("img", { src: imgLateral, alt: imgLateral }))),
|
|
1446
|
+
React$2.createElement("div", { className: styles$3.text, dangerouslySetInnerHTML: { __html: texto } })))));
|
|
157
1447
|
};
|
|
158
1448
|
|
|
159
1449
|
var css_248z$2 = ".menuPage-module_container__grjEI{color:#000;display:flex;height:100%}.menuPage-module_sidebar__7Kg1S{background-color:#fff;border-right:1px solid var(--greyHover);height:500px;max-height:500px;overflow-y:auto;padding-bottom:15px;width:250px}.menuPage-module_sidebar__7Kg1S ul{list-style:none;margin:0;padding:0}.menuPage-module_sidebar__7Kg1S ul li{margin:10px 0}.menuPage-module_sidebar__7Kg1S ul li button{background:none;border:none;cursor:pointer;font-weight:700;padding:10px;text-align:left;text-decoration:none;width:100%}.menuPage-module_content__g2T-d{background-color:#fff;flex:1;max-height:475px;overflow-y:auto;padding:20px}@media (max-width:800px){.menuPage-module_sidebar__7Kg1S{width:160px}}.menuPage-module_empresa1__tLASf .menuPage-module_sidebar__7Kg1S ul li button{color:var(--blue)}.menuPage-module_empresa1__tLASf .menuPage-module_sidebar__7Kg1S ul li button.menuPage-module_active__Mfy4T{background-color:var(--lightGray);border-left:4px solid var(--blue)}.menuPage-module_empresa3__xkxls .menuPage-module_sidebar__7Kg1S ul li button{color:var(--green)}.menuPage-module_empresa3__xkxls .menuPage-module_sidebar__7Kg1S ul li button.menuPage-module_active__Mfy4T{background-color:var(--lightGray);border-left:4px solid var(--green)}.menuPage-module_empresa4__h8gOQ .menuPage-module_sidebar__7Kg1S ul li button{background-color:var(--red)}.menuPage-module_empresa4__h8gOQ .menuPage-module_sidebar__7Kg1S ul li button.menuPage-module_active__Mfy4T{background-color:var(--blue)}";
|
|
@@ -163,13 +1453,13 @@ styleInject(css_248z$2);
|
|
|
163
1453
|
var MenuPage = function (_a) {
|
|
164
1454
|
var menus = _a.menus, contents = _a.contents, empresa = _a.empresa;
|
|
165
1455
|
var empresaClass = styles$2["empresa".concat(empresa)];
|
|
166
|
-
var _b = React.useState(menus[0].key), selectedSection = _b[0], setSelectedSection = _b[1];
|
|
167
|
-
return (React.createElement("div", { className: "".concat(empresaClass) },
|
|
168
|
-
React.createElement("div", { className: styles$2.container },
|
|
169
|
-
React.createElement("nav", { className: styles$2.sidebar },
|
|
170
|
-
React.createElement("ul", null, menus.map(function (menu) { return (React.createElement("li", { key: menu.key },
|
|
171
|
-
React.createElement("button", { className: selectedSection === menu.key ? styles$2.active : '', onClick: function () { return setSelectedSection(menu.key); } }, menu.label))); }))),
|
|
172
|
-
React.createElement("main", { className: styles$2.content }, contents[selectedSection]))));
|
|
1456
|
+
var _b = React$2.useState(menus[0].key), selectedSection = _b[0], setSelectedSection = _b[1];
|
|
1457
|
+
return (React$2.createElement("div", { className: "".concat(empresaClass) },
|
|
1458
|
+
React$2.createElement("div", { className: styles$2.container },
|
|
1459
|
+
React$2.createElement("nav", { className: styles$2.sidebar },
|
|
1460
|
+
React$2.createElement("ul", null, menus.map(function (menu) { return (React$2.createElement("li", { key: menu.key },
|
|
1461
|
+
React$2.createElement("button", { className: selectedSection === menu.key ? styles$2.active : '', onClick: function () { return setSelectedSection(menu.key); } }, menu.label))); }))),
|
|
1462
|
+
React$2.createElement("main", { className: styles$2.content }, contents[selectedSection]))));
|
|
173
1463
|
};
|
|
174
1464
|
|
|
175
1465
|
var css_248z$1 = ".select-module_selectPadrao__poGiL{border:1px solid #ccc;border-radius:.5rem;font-style:italic;padding:.8rem 0 .8rem 1rem;width:100%}.select-module_selectPadrao__poGiL:focus{outline:none}";
|
|
@@ -177,12 +1467,21 @@ var styles$1 = {"selectPadrao":"select-module_selectPadrao__poGiL"};
|
|
|
177
1467
|
styleInject(css_248z$1);
|
|
178
1468
|
|
|
179
1469
|
var SelectField = function (_a) {
|
|
180
|
-
var id = _a.id, name = _a.name, options = _a.options, value = _a.value, onChange = _a.onChange, label = _a.label, optionDefault = _a.optionDefault, largura = _a.largura, disabled = _a.disabled;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
1470
|
+
var id = _a.id, name = _a.name, options = _a.options, value = _a.value, onChange = _a.onChange, label = _a.label, optionDefault = _a.optionDefault, largura = _a.largura, disabled = _a.disabled, multiple = _a.multiple;
|
|
1471
|
+
var handleSelectChange = function (e) {
|
|
1472
|
+
if (multiple) {
|
|
1473
|
+
var selectedOptions = Array.from(e.target.selectedOptions, function (option) { return option.value; });
|
|
1474
|
+
onChange(selectedOptions);
|
|
1475
|
+
}
|
|
1476
|
+
else {
|
|
1477
|
+
onChange(e.target.value);
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
return (React$2.createElement(React$2.Fragment, null,
|
|
1481
|
+
label && React$2.createElement("label", { htmlFor: id }, label),
|
|
1482
|
+
React$2.createElement("select", { id: id, name: name, className: styles$1.selectPadrao, value: value, onChange: handleSelectChange, style: { width: largura ? "".concat(largura) : '' }, disabled: disabled, multiple: multiple },
|
|
1483
|
+
optionDefault && !multiple && (React$2.createElement("option", { value: "" }, "Selecione...")),
|
|
1484
|
+
options.map(function (option) { return (React$2.createElement("option", { key: option.value, value: option.value }, option.description)); }))));
|
|
186
1485
|
};
|
|
187
1486
|
|
|
188
1487
|
var css_248z = ".busca-module_search__xf4qJ{align-items:center;display:flex;flex-direction:column;justify-content:center;margin:2rem 0;width:100%}.busca-module_searchContainer__jhcnm{align-items:center;display:flex;max-width:600px;position:relative;width:100%}.busca-module_searchIcon__FPl1-{height:20px;left:10px;position:absolute;width:20px}.busca-module_searchInput__GjG8B{background-color:var(--lightGray);border:none;border-radius:50px;box-sizing:border-box;color:var(--gray);height:100%;outline:none;padding:10px 15px 10px 35px;width:100%;z-index:1001}.busca-module_suggestionsWrapper__vbmxG{background:#fff;border-bottom-left-radius:20px;border-bottom-right-radius:20px;box-shadow:0 4px 6px rgba(0,0,0,.1);color:var(--blue);width:45%;z-index:1000}.busca-module_suggestions__pYBV1{border-bottom-left-radius:20px;border-bottom-right-radius:20px;max-height:500px;overflow-y:auto}.busca-module_suggestion__V-d8T{cursor:pointer;padding:10px}.busca-module_suggestion__V-d8T:hover{background-color:var(--blue);color:#fff}.busca-module_suggestion__V-d8T:not(:first-child){border-top:1px solid var(--lightGray);padding-top:8px}@media (max-width:768px){.busca-module_searchInput__GjG8B{padding:10px 15px 10px 30px}.busca-module_suggestionsWrapper__vbmxG{top:35px}}@media (max-width:500px){.busca-module_searchContainer__jhcnm{width:90%}.busca-module_searchInput__GjG8B{padding:10px;width:100%}}";
|
|
@@ -191,9 +1490,9 @@ styleInject(css_248z);
|
|
|
191
1490
|
|
|
192
1491
|
var Busca = function (_a) {
|
|
193
1492
|
var allItems = _a.allItems; _a.placeholder; var onItemClick = _a.onItemClick;
|
|
194
|
-
var _c = React.useState(''), searchValue = _c[0], setSearchValue = _c[1];
|
|
195
|
-
var _d = React.useState(allItems), filteredItems = _d[0], setFilteredItems = _d[1];
|
|
196
|
-
var _e = React.useState(false), isInputFocused = _e[0], setIsInputFocused = _e[1];
|
|
1493
|
+
var _c = React$2.useState(''), searchValue = _c[0], setSearchValue = _c[1];
|
|
1494
|
+
var _d = React$2.useState(allItems), filteredItems = _d[0], setFilteredItems = _d[1];
|
|
1495
|
+
var _e = React$2.useState(false), isInputFocused = _e[0], setIsInputFocused = _e[1];
|
|
197
1496
|
var handleSearchChange = function (event) {
|
|
198
1497
|
var value = event.target.value;
|
|
199
1498
|
setSearchValue(value);
|
|
@@ -213,11 +1512,11 @@ var Busca = function (_a) {
|
|
|
213
1512
|
var handleInputBlur = function () {
|
|
214
1513
|
setTimeout(function () { return setIsInputFocused(false); }, 100);
|
|
215
1514
|
};
|
|
216
|
-
return (React.createElement("div", { className: styles.search },
|
|
217
|
-
React.createElement("div", { className: styles.searchContainer },
|
|
218
|
-
React.createElement("input", { type: "text", className: styles.searchInput, placeholder: "Pesquisar...", value: searchValue, onChange: handleSearchChange, onFocus: handleInputFocus, onBlur: handleInputBlur })),
|
|
219
|
-
isInputFocused && filteredItems.length > 0 && (React.createElement("div", { className: styles.suggestionsWrapper },
|
|
220
|
-
React.createElement("div", { className: styles.suggestions }, filteredItems.map(function (item, index) { return (React.createElement("div", { key: index, className: styles.suggestion, onClick: function () { return onItemClick(item.path); } }, item.id)); }))))));
|
|
1515
|
+
return (React$2.createElement("div", { className: styles.search },
|
|
1516
|
+
React$2.createElement("div", { className: styles.searchContainer },
|
|
1517
|
+
React$2.createElement("input", { type: "text", className: styles.searchInput, placeholder: "Pesquisar...", value: searchValue, onChange: handleSearchChange, onFocus: handleInputFocus, onBlur: handleInputBlur })),
|
|
1518
|
+
isInputFocused && filteredItems.length > 0 && (React$2.createElement("div", { className: styles.suggestionsWrapper },
|
|
1519
|
+
React$2.createElement("div", { className: styles.suggestions }, filteredItems.map(function (item, index) { return (React$2.createElement("div", { key: index, className: styles.suggestion, onClick: function () { return onItemClick(item.path); } }, item.id)); }))))));
|
|
221
1520
|
};
|
|
222
1521
|
|
|
223
1522
|
exports.Busca = Busca;
|