aefis-core-ui 2.3.0-rc14 → 2.3.0-rc16
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/index.modern.js +11 -1033
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -55,7 +55,7 @@ import IconButton$2 from '@mui/material/IconButton';
|
|
|
55
55
|
import Edit$1 from '@mui/icons-material/Edit';
|
|
56
56
|
import AutorenewIcon from '@mui/icons-material/Autorenew';
|
|
57
57
|
import { VerticalTimeline, VerticalTimelineElement } from 'react-vertical-timeline-component';
|
|
58
|
-
import
|
|
58
|
+
import Moment from 'react-moment';
|
|
59
59
|
import AddIcon from '@mui/icons-material/Add';
|
|
60
60
|
import { useInView } from 'react-intersection-observer';
|
|
61
61
|
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
|
@@ -81,7 +81,7 @@ import TextField$2 from '@mui/material/TextField';
|
|
|
81
81
|
import get$1 from 'lodash/get';
|
|
82
82
|
import isPlainObject from 'lodash/isPlainObject';
|
|
83
83
|
import ToggleButton$1 from '@mui/material/ToggleButton';
|
|
84
|
-
import { parse as parse$1, format
|
|
84
|
+
import { parse as parse$1, format, setDate, setMonth } from 'date-fns';
|
|
85
85
|
import { MobileDatePicker as MobileDatePicker$1 } from '@mui/x-date-pickers/MobileDatePicker';
|
|
86
86
|
import { LocalizationProvider as LocalizationProvider$1 } from '@mui/x-date-pickers/LocalizationProvider';
|
|
87
87
|
import 'filepond-plugin-get-file/dist/filepond-plugin-get-file.css';
|
|
@@ -92,6 +92,7 @@ import { registerPlugin, FilePond } from 'react-filepond';
|
|
|
92
92
|
import FilePondPluginGetFile from 'filepond-plugin-get-file';
|
|
93
93
|
import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size';
|
|
94
94
|
import MaskedInput from 'react-text-mask';
|
|
95
|
+
import { NumericFormat, useNumericFormat } from 'react-number-format';
|
|
95
96
|
import StylesProvider from '@mui/styles/StylesProvider';
|
|
96
97
|
|
|
97
98
|
function _extends() {
|
|
@@ -2335,10 +2336,11 @@ const Chip = ({
|
|
|
2335
2336
|
})
|
|
2336
2337
|
})
|
|
2337
2338
|
};
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
const
|
|
2339
|
+
|
|
2340
|
+
// TODO: create FormChip (or similar) and use contextful version there. Pure
|
|
2341
|
+
// and Contextful component should be seperated
|
|
2342
|
+
const formControl = useFormControl();
|
|
2343
|
+
const _canDelete = canDelete && !(formControl != null && formControl.disabled);
|
|
2342
2344
|
const Chip = () => {
|
|
2343
2345
|
return /*#__PURE__*/jsx(Chip$1, _extends({
|
|
2344
2346
|
role: role || "presentation",
|
|
@@ -2346,7 +2348,7 @@ const Chip = ({
|
|
|
2346
2348
|
}, chipProps, _canDelete && {
|
|
2347
2349
|
onDelete
|
|
2348
2350
|
}, {
|
|
2349
|
-
disabled: disabled
|
|
2351
|
+
disabled: formControl == null ? void 0 : formControl.disabled
|
|
2350
2352
|
}));
|
|
2351
2353
|
};
|
|
2352
2354
|
|
|
@@ -10137,33 +10139,6 @@ Drawer.propTypes = {
|
|
|
10137
10139
|
titleComponent: PropTypes.oneOf(["h1", "h2", "h3", "div"])
|
|
10138
10140
|
};
|
|
10139
10141
|
|
|
10140
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
10141
|
-
|
|
10142
|
-
function getDefaultExportFromCjs (x) {
|
|
10143
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
10144
|
-
}
|
|
10145
|
-
|
|
10146
|
-
function createCommonjsModule(fn) {
|
|
10147
|
-
var module = { exports: {} };
|
|
10148
|
-
return fn(module, module.exports), module.exports;
|
|
10149
|
-
}
|
|
10150
|
-
|
|
10151
|
-
var dist = createCommonjsModule(function (module, exports) {
|
|
10152
|
-
!function(e,t){module.exports=t(require$$0,React);}(commonjsGlobal,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){e.exports=n(3)();},function(t,n){t.exports=e;},function(e,n){e.exports=t;},function(e,t,n){var r=n(4);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n};},function(e,t,n){e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";},function(e,t,n){var r,o,i,a,l;
|
|
10153
|
-
/*! Moment Duration Format v2.2.2
|
|
10154
|
-
* https://github.com/jsmreese/moment-duration-format
|
|
10155
|
-
* Date: 2018-02-16
|
|
10156
|
-
*
|
|
10157
|
-
* Duration format plugin function for the Moment.js library
|
|
10158
|
-
* http://momentjs.com/
|
|
10159
|
-
*
|
|
10160
|
-
* Copyright 2018 John Madhavan-Reese
|
|
10161
|
-
* Released under the MIT license
|
|
10162
|
-
*/a=this,l=function(e){var t=!1,n=!1,r=!1,o=!1,i="escape years months weeks days hours minutes seconds milliseconds general".split(" "),a=[{type:"seconds",targets:[{type:"minutes",value:60},{type:"hours",value:3600},{type:"days",value:86400},{type:"weeks",value:604800},{type:"months",value:2678400},{type:"years",value:31536e3}]},{type:"minutes",targets:[{type:"hours",value:60},{type:"days",value:1440},{type:"weeks",value:10080},{type:"months",value:44640},{type:"years",value:525600}]},{type:"hours",targets:[{type:"days",value:24},{type:"weeks",value:168},{type:"months",value:744},{type:"years",value:8760}]},{type:"days",targets:[{type:"weeks",value:7},{type:"months",value:31},{type:"years",value:365}]},{type:"months",targets:[{type:"years",value:12}]}];function l(e,t){return !(t.length>e.length)&&-1!==e.indexOf(t)}function u(e){for(var t="";e;)t+="0",e-=1;return t}function s(e,t){var n=e+"+"+v(V(t).sort(),(function(e){return e+":"+t[e]})).join(",");return s.cache[n]||(s.cache[n]=Intl.NumberFormat(e,t)),s.cache[n]}function c(e,t,i){var a,l,f,m=t.useToLocaleString,p=t.useGrouping,g=p&&t.grouping.slice(),y=t.maximumSignificantDigits,h=t.minimumIntegerDigits||1,d=t.fractionDigits||0,v=t.groupingSeparator,b=t.decimalSeparator;if(m&&i){var w,S={minimumIntegerDigits:h,useGrouping:p};return d&&(S.maximumFractionDigits=d,S.minimumFractionDigits=d),y&&e>0&&(S.maximumSignificantDigits=y),r?(o||((w=x({},t)).useGrouping=!1,w.decimalSeparator=".",e=parseFloat(c(e,w),10)),s(i,S).format(e)):(n||((w=x({},t)).useGrouping=!1,w.decimalSeparator=".",e=parseFloat(c(e,w),10)),e.toLocaleString(i,S))}var T=(y?e.toPrecision(y+1):e.toFixed(d+1)).split("e");f=T[1]||"",l=(T=T[0].split("."))[1]||"";var O=(a=T[0]||"").length,_=l.length,V=O+_,D=a+l;(y&&V===y+1||!y&&_===d+1)&&((D=function(e){for(var t=e.split("").reverse(),n=0,r=!0;r&&n<t.length;)n?"9"===t[n]?t[n]="0":(t[n]=(parseInt(t[n],10)+1).toString(),r=!1):(parseInt(t[n],10)<5&&(r=!1),t[n]="0"),n+=1;return r&&t.push("1"),t.reverse().join("")}(D)).length===V+1&&(O+=1),_&&(D=D.slice(0,-1)),a=D.slice(0,O),l=D.slice(O)),y&&(l=l.replace(/0*$/,""));var j=parseInt(f,10);j>0?l.length<=j?(a+=l+=u(j-l.length),l=""):(a+=l.slice(0,j),l=l.slice(j)):j<0&&(l=u(Math.abs(j)-a.length)+a+l,a="0"),y||((l=l.slice(0,d)).length<d&&(l+=u(d-l.length)),a.length<h&&(a=u(h-a.length)+a));var M,P="";if(p)for(T=a;T.length;)g.length&&(M=g.shift()),P&&(P=v+P),P=T.slice(-M)+P,T=T.slice(0,-M);else P=a;return l&&(P=P+b+l),P}function f(e,t){return e.label.length>t.label.length?-1:e.label.length<t.label.length?1:0}function m(e,t){var n=[];return d(V(t),(function(r){if("_durationLabels"===r.slice(0,15)){var o=r.slice(15).toLowerCase();d(V(t[r]),(function(i){i.slice(0,1)===e&&n.push({type:o,key:i,label:t[r][i]});}));}})),n}s.cache={};var p={durationLabelsStandard:{S:"millisecond",SS:"milliseconds",s:"second",ss:"seconds",m:"minute",mm:"minutes",h:"hour",hh:"hours",d:"day",dd:"days",w:"week",ww:"weeks",M:"month",MM:"months",y:"year",yy:"years"},durationLabelsShort:{S:"msec",SS:"msecs",s:"sec",ss:"secs",m:"min",mm:"mins",h:"hr",hh:"hrs",d:"dy",dd:"dys",w:"wk",ww:"wks",M:"mo",MM:"mos",y:"yr",yy:"yrs"},durationTimeTemplates:{HMS:"h:mm:ss",HM:"h:mm",MS:"m:ss"},durationLabelTypes:[{type:"standard",string:"__"},{type:"short",string:"_"}],durationPluralKey:function(e,t,n){return 1===t&&null===n?e:e+e}};function g(e){return "[object Array]"===Object.prototype.toString.call(e)}function y(e){return "[object Object]"===Object.prototype.toString.call(e)}function h(e,t){var n,r=0,o=e&&e.length||0;for("function"!=typeof t&&(n=t,t=function(e){return e===n});r<o;){if(t(e[r]))return e[r];r+=1;}}function d(e,t){var n=0,r=e.length;if(e&&r)for(;n<r;){if(!1===t(e[n],n))return;n+=1;}}function v(e,t){var n=0,r=e.length,o=[];if(!e||!r)return o;for(;n<r;)o[n]=t(e[n],n),n+=1;return o}function b(e,t){return v(e,(function(e){return e[t]}))}function w(e){var t=[];return d(e,(function(e){e&&t.push(e);})),t}function S(e){var t=[];return d(e,(function(e){h(t,e)||t.push(e);})),t}function T(e,t){var n=[];return d(e,(function(e){d(t,(function(t){e===t&&n.push(e);}));})),S(n)}function O(e,t){var n=[];return d(e,(function(r,o){if(!t(r))return n=e.slice(o),!1})),n}function _(e,t){return O(e.slice().reverse(),t).reverse()}function x(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function V(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}function D(e,t){var n=0,r=e.length;if(!e||!r)return !1;for(;n<r;){if(!0===t(e[n],n))return !0;n+=1;}return !1}function j(e){var t=[];return d(e,(function(e){t=t.concat(e);})),t}function M(e){return "3.6"===e(3.55,"en",{useGrouping:!1,minimumIntegerDigits:1,minimumFractionDigits:1,maximumFractionDigits:1})}function P(e){var t=!0;return !!((t=(t=(t=t&&"1"===e(1,"en",{minimumIntegerDigits:1}))&&"01"===e(1,"en",{minimumIntegerDigits:2}))&&"001"===e(1,"en",{minimumIntegerDigits:3}))&&(t=(t=(t=(t=t&&"100"===e(99.99,"en",{maximumFractionDigits:0,minimumFractionDigits:0}))&&"100.0"===e(99.99,"en",{maximumFractionDigits:1,minimumFractionDigits:1}))&&"99.99"===e(99.99,"en",{maximumFractionDigits:2,minimumFractionDigits:2}))&&"99.990"===e(99.99,"en",{maximumFractionDigits:3,minimumFractionDigits:3}))&&(t=(t=(t=(t=(t=t&&"100"===e(99.99,"en",{maximumSignificantDigits:1}))&&"100"===e(99.99,"en",{maximumSignificantDigits:2}))&&"100"===e(99.99,"en",{maximumSignificantDigits:3}))&&"99.99"===e(99.99,"en",{maximumSignificantDigits:4}))&&"99.99"===e(99.99,"en",{maximumSignificantDigits:5}))&&(t=(t=t&&"1,000"===e(1e3,"en",{useGrouping:!0}))&&"1000"===e(1e3,"en",{useGrouping:!1})))}function k(){var e,t=[].slice.call(arguments),n={};if(d(t,(function(t,r){if(!r){if(!g(t))throw "Expected array as the first argument to durationsFormat.";e=t;}"string"!=typeof t&&"function"!=typeof t?"number"!=typeof t?y(t)&&x(n,t):n.precision=t:n.template=t;})),!e||!e.length)return [];n.returnMomentTypes=!0;var r=v(e,(function(e){return e.format(n)})),o=T(i,S(b(j(r),"type"))),a=n.largest;return a&&(o=o.slice(0,a)),n.returnMomentTypes=!1,n.outputTypes=o,v(e,(function(e){return e.format(n)}))}function E(){var n=[].slice.call(arguments),o=x({},this.format.defaults),u=this.asMilliseconds(),s=this.asMonths();"function"==typeof this.isValid&&!1===this.isValid()&&(u=0,s=0);var j=u<0,M=e.duration(Math.abs(u),"milliseconds"),P=e.duration(Math.abs(s),"months");d(n,(function(e){"string"!=typeof e&&"function"!=typeof e?"number"!=typeof e?y(e)&&x(o,e):o.precision=e:o.template=e;}));var k={years:"y",months:"M",weeks:"w",days:"d",hours:"h",minutes:"m",seconds:"s",milliseconds:"S"},E={escape:/\[(.+?)\]/,years:/\*?[Yy]+/,months:/\*?M+/,weeks:/\*?[Ww]+/,days:/\*?[Dd]+/,hours:/\*?[Hh]+/,minutes:/\*?m+/,seconds:/\*?s+/,milliseconds:/\*?S+/,general:/.+?/};o.types=i;var L=function(e){return h(i,(function(t){return E[t].test(e)}))},F=new RegExp(v(i,(function(e){return E[e].source})).join("|"),"g");o.duration=this;var I="function"==typeof o.template?o.template.apply(o):o.template,N=o.outputTypes,C=o.returnMomentTypes,R=o.largest,G=[];N||(g(o.stopTrim)&&(o.stopTrim=o.stopTrim.join("")),o.stopTrim&&d(o.stopTrim.match(F),(function(e){var t=L(e);"escape"!==t&&"general"!==t&&G.push(t);})));var U=e.localeData();U||(U={}),d(V(p),(function(e){"function"!=typeof p[e]?U["_"+e]||(U["_"+e]=p[e]):U[e]||(U[e]=p[e]);})),d(V(U._durationTimeTemplates),(function(e){I=I.replace("_"+e+"_",U._durationTimeTemplates[e]);}));var q=o.userLocale||e.locale(),z=o.useLeftUnits,H=o.usePlural,W=o.precision,$=o.forceLength,A=o.useGrouping,B=o.trunc,K=o.useSignificantDigits&&W>0,Y=K?o.precision:0,J=Y,Q=o.minValue,X=!1,Z=o.maxValue,ee=!1,te=o.useToLocaleString,ne=o.groupingSeparator,re=o.decimalSeparator,oe=o.grouping;te=te&&(t||r);var ie=o.trim;g(ie)&&(ie=ie.join(" ")),null===ie&&(R||Z||K)&&(ie="all"),null!==ie&&!0!==ie&&"left"!==ie&&"right"!==ie||(ie="large"),!1===ie&&(ie="");var ae=function(e){return e.test(ie)},le=/large/,ue=/small/,se=/both/,ce=/mid/,fe=/^all|[^sm]all/,me=/final/,pe=R>0||D([le,se,fe],ae),ge=D([ue,se,fe],ae),ye=D([ce,fe],ae),he=D([me,fe],ae),de=v(I.match(F),(function(e,t){var n=L(e);return "*"===e.slice(0,1)&&(e=e.slice(1),"escape"!==n&&"general"!==n&&G.push(n)),{index:t,length:e.length,text:"",token:"escape"===n?e.replace(E.escape,"$1"):e,type:"escape"===n||"general"===n?null:n}})),ve={index:0,length:0,token:"",text:"",type:null},be=[];z&&de.reverse(),d(de,(function(e){if(e.type)return (ve.type||ve.text)&&be.push(ve),void(ve=e);z?ve.text=e.token+ve.text:ve.text+=e.token;})),(ve.type||ve.text)&&be.push(ve),z&&be.reverse();var we=T(i,S(w(b(be,"type"))));if(!we.length)return b(be,"text").join("");we=v(we,(function(e,t){var n,r=t+1===we.length,i=!t;n="years"===e||"months"===e?P.as(e):M.as(e);var a=Math.floor(n),l=n-a,u=h(be,(function(t){return e===t.type}));return i&&Z&&n>Z&&(ee=!0),r&&Q&&Math.abs(o.duration.as(e))<Q&&(X=!0),i&&null===$&&u.length>1&&($=!0),M.subtract(a,e),P.subtract(a,e),{rawValue:n,wholeValue:a,decimalValue:r?l:0,isSmallest:r,isLargest:i,type:e,tokenLength:u.length}}));var Se=B?Math.floor:Math.round,Te=function(e,t){var n=Math.pow(10,t);return Se(e*n)/n},Oe=!1,_e=!1,xe=function(e,t){var n={useGrouping:A,groupingSeparator:ne,decimalSeparator:re,grouping:oe,useToLocaleString:te};return K&&(Y<=0?(e.rawValue=0,e.wholeValue=0,e.decimalValue=0):(n.maximumSignificantDigits=Y,e.significantDigits=Y)),ee&&!_e&&(e.isLargest?(e.wholeValue=Z,e.decimalValue=0):(e.wholeValue=0,e.decimalValue=0)),X&&!_e&&(e.isSmallest?(e.wholeValue=Q,e.decimalValue=0):(e.wholeValue=0,e.decimalValue=0)),e.isSmallest||e.significantDigits&&e.significantDigits-e.wholeValue.toString().length<=0?W<0?e.value=Te(e.wholeValue,W):0===W?e.value=Se(e.wholeValue+e.decimalValue):K?(e.value=B?Te(e.rawValue,Y-e.wholeValue.toString().length):e.rawValue,e.wholeValue&&(Y-=e.wholeValue.toString().length)):(n.fractionDigits=W,e.value=B?e.wholeValue+Te(e.decimalValue,W):e.wholeValue+e.decimalValue):K&&e.wholeValue?(e.value=Math.round(Te(e.wholeValue,e.significantDigits-e.wholeValue.toString().length)),Y-=e.wholeValue.toString().length):e.value=e.wholeValue,e.tokenLength>1&&($||Oe)&&(n.minimumIntegerDigits=e.tokenLength,_e&&n.maximumSignificantDigits<e.tokenLength&&delete n.maximumSignificantDigits),!Oe&&(e.value>0||""===ie||h(G,e.type)||h(N,e.type))&&(Oe=!0),e.formattedValue=c(e.value,n,q),n.useGrouping=!1,n.decimalSeparator=".",e.formattedValueEn=c(e.value,n,"en"),2===e.tokenLength&&"milliseconds"===e.type&&(e.formattedValueMS=c(e.value,{minimumIntegerDigits:3,useGrouping:!1},"en").slice(0,2)),e};if((we=w(we=v(we,xe))).length>1){var Ve=function(e){return h(we,(function(t){return t.type===e}))},De=function(e){var t=Ve(e.type);t&&d(e.targets,(function(e){var n=Ve(e.type);n&&parseInt(t.formattedValueEn,10)===e.value&&(t.rawValue=0,t.wholeValue=0,t.decimalValue=0,n.rawValue+=1,n.wholeValue+=1,n.decimalValue=0,n.formattedValueEn=n.wholeValue.toString(),_e=!0);}));};d(a,De);}return _e&&(Oe=!1,Y=J,we=w(we=v(we,xe))),!N||ee&&!o.trim?(pe&&(we=O(we,(function(e){return !e.isSmallest&&!e.wholeValue&&!h(G,e.type)}))),R&&we.length&&(we=we.slice(0,R)),ge&&we.length>1&&(we=_(we,(function(e){return !e.wholeValue&&!h(G,e.type)&&!e.isLargest}))),ye&&(we=w(we=v(we,(function(e,t){return t>0&&t<we.length-1&&!e.wholeValue?null:e})))),!he||1!==we.length||we[0].wholeValue||!B&&we[0].isSmallest&&we[0].rawValue<Q||(we=[])):we=w(we=v(we,(function(e){return h(N,(function(t){return e.type===t}))?e:null}))),C?we:(d(be,(function(e){var t=k[e.type],n=h(we,(function(t){return t.type===e.type}));if(t&&n){var r=n.formattedValueEn.split(".");r[0]=parseInt(r[0],10),r[1]?r[1]=parseFloat("0."+r[1],10):r[1]=null;var o=U.durationPluralKey(t,r[0],r[1]),i=m(t,U),a=!1,u={};d(U._durationLabelTypes,(function(t){var n=h(i,(function(e){return e.type===t.type&&e.key===o}));n&&(u[n.type]=n.label,l(e.text,t.string)&&(e.text=e.text.replace(t.string,n.label),a=!0));})),H&&!a&&(i.sort(f),d(i,(function(t){return u[t.type]===t.label?!l(e.text,t.label)&&void 0:l(e.text,t.label)?(e.text=e.text.replace(t.label,u[t.type]),!1):void 0})));}})),(be=v(be,(function(e){if(!e.type)return e.text;var t=h(we,(function(t){return t.type===e.type}));if(!t)return "";var n="";return z&&(n+=e.text),(j&&ee||!j&&X)&&(n+="< ",ee=!1,X=!1),(j&&X||!j&&ee)&&(n+="> ",ee=!1,X=!1),j&&(t.value>0||""===ie||h(G,t.type)||h(N,t.type))&&(n+="-",j=!1),"milliseconds"===e.type&&t.formattedValueMS?n+=t.formattedValueMS:n+=t.formattedValue,z||(n+=e.text),n}))).join("").replace(/(,| |:|\.)*$/,"").replace(/^(,| |:|\.)*/,""))}function L(){var e=this.duration,t=function(t){return e._data[t]},n=h(this.types,t),r=function(e,t){for(var n=e.length;n-=1;)if(t(e[n]))return e[n]}(this.types,t);switch(n){case"milliseconds":return "S __";case"seconds":case"minutes":return "*_MS_";case"hours":return "_HMS_";case"days":if(n===r)return "d __";case"weeks":return n===r?"w __":(null===this.trim&&(this.trim="both"),"w __, d __, h __");case"months":if(n===r)return "M __";case"years":return n===r?"y __":(null===this.trim&&(this.trim="both"),"y __, M __, d __");default:return null===this.trim&&(this.trim="both"),"y __, d __, h __, m __, s __"}}function F(e){if(!e)throw "Moment Duration Format init cannot find moment instance.";e.duration.format=k,e.duration.fn.format=E,e.duration.fn.format.defaults={trim:null,stopTrim:null,largest:null,maxValue:null,minValue:null,precision:0,trunc:!1,forceLength:null,userLocale:null,usePlural:!0,useLeftUnits:!1,useGrouping:!0,useSignificantDigits:!1,template:L,useToLocaleString:!0,groupingSeparator:",",decimalSeparator:".",grouping:[3]},e.updateLocale("en",p);}var I=function(e,t,n){return e.toLocaleString(t,n)};t=function(){try{(0).toLocaleString("i");}catch(e){return "RangeError"===e.name}return !1}()&&P(I),n=t&&M(I);var N=function(e,t,n){if("undefined"!=typeof window&&window&&window.Intl&&window.Intl.NumberFormat)return window.Intl.NumberFormat(t,n).format(e)};return r=P(N),o=r&&M(N),F(e),F},o=[n(1)],void 0===(i="function"==typeof(r=l)?r.apply(t,o):r)||(e.exports=i),a&&(a.momentDurationFormatSetup=a.moment?l(a.moment):l);},function(e,t,n){n.r(t),n.d(t,"default",(function(){return _}));var r=n(2),o=n.n(r),i=n(0),a=n.n(i),l=n(1),u=n.n(l);n(5);function s(e){return (s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r);}return n}function f(e,t){if(null==e)return {};var n,r,o=function(e,t){if(null==e)return {};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);}return o}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r);}}function p(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),e}function g(e,t){return (g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return !1}}();return function(){var n,r=v(e);if(t){var o=v(this).constructor;n=Reflect.construct(r,arguments,o);}else n=r.apply(this,arguments);return h(this,n)}}function h(e,t){return !t||"object"!==s(t)&&"function"!=typeof t?d(e):t}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){return (v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=[a.a.string,a.a.number,a.a.array,a.a.object],S=[a.a.string,a.a.array],T=[a.a.object,a.a.bool],O=[a.a.string,a.a.bool],_=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&g(e,t);}(n,e);var t=y(n);function n(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),b(d(r=t.call(this,e)),"setTimer",(function(){var e=r.props.interval;r.clearTimer(),n.pooledTimer||0===e||(r.timer=setInterval((function(){r.update(r.props);}),e));})),b(d(r),"getTitle",(function(){var e=r.props.titleFormat,t=n.getDatetime(r.props),o=e||n.globalFormat;return t.format(o)})),b(d(r),"clearTimer",(function(){!n.pooledTimer&&r.timer&&(clearInterval(r.timer),r.timer=null),n.pooledTimer&&!r.timer&&n.removePooledElement(d(r));})),n.globalMoment||(n.globalMoment=u.a),r.state={content:""},r.timer=null,r}return p(n,null,[{key:"startPooledTimer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4;n.clearPooledTimer(),n.pooledTimer=setInterval((function(){n.pooledElements.forEach((function(e){0!==e.props.interval&&e.update();}));}),e);}},{key:"clearPooledTimer",value:function(){n.pooledTimer&&(clearInterval(n.pooledTimer),n.pooledTimer=null,n.pooledElements=[]);}},{key:"pushPooledElement",value:function(e){e instanceof n?-1===n.pooledElements.indexOf(e)&&n.pooledElements.push(e):console.error("Element not an instance of Moment.");}},{key:"removePooledElement",value:function(e){var t=n.pooledElements.indexOf(e);-1!==t&&n.pooledElements.splice(t,1);}},{key:"getDatetime",value:function(e){var t=e.utc,r=e.unix,o=e.date,i=e.locale,a=e.parse,l=e.tz,u=e.local;o=o||e.children,a=a||n.globalParse,u=u||n.globalLocal,l=l||n.globalTimezone,i=n.globalLocale?n.globalLocale:i||n.globalMoment.locale();var s=null;return s=t?n.globalMoment.utc(o,a,i):r?n.globalMoment(1e3*o,a,i):n.globalMoment(o,a,i),l?s=s.tz(l):u&&(s=s.local()),s}},{key:"getContent",value:function(e){var t=e.fromNow,r=e.fromNowDuring,o=e.from,i=e.add,a=e.subtract,l=e.toNow,s=e.to,c=e.ago,f=e.calendar,m=e.diff,p=e.duration,g=e.durationFromNow,y=e.unit,h=e.decimal,d=e.trim,v=e.format;v=v||n.globalFormat;var b=n.getDatetime(e);i&&b.add(i),a&&b.subtract(a);var w=Boolean(r)&&-b.diff(u()())<r,S="";return S=!v||w||g||p?o?b.from(o,c):t||w?b.fromNow(c):s?b.to(s,c):l?b.toNow(c):f?b.calendar(null,f):m?b.diff(m,y,h):p?b.diff(p):g?u()().diff(b):b.toString():b.format(v),(p||g)&&(S=(S=u.a.duration(S)).format(v,{trim:d})),S=(n.globalFilter||e.filter)(S)}}]),p(n,[{key:"componentDidMount",value:function(){this.setTimer(),n.pooledTimer&&n.pushPooledElement(this);}},{key:"componentDidUpdate",value:function(e){var t=this.props.interval;e.interval!==t&&this.setTimer();}},{key:"componentWillUnmount",value:function(){this.clearTimer();}},{key:"update",value:function(e){var t=e||this.props,r=t.onChange,o=n.getContent(t);this.setState({content:o},(function(){r(o);}));}},{key:"render",value:function(){var e,t,r,i,a=this.props,l=a.withTitle,u=a.element,s=f(a,["withTitle","element"]),m=this.state.content,p=(e=s,t=n.propTypes,r=Object.keys(t),i=Object.assign({},e),Object.keys(i).filter((function(e){return -1!==r.indexOf(e)})).forEach((function(e){return delete i[e]})),i);return l&&(p.title=this.getTitle()),o.a.createElement(u||n.globalElement,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){b(e,t,n[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));}));}return e}({dateTime:n.getDatetime(this.props)},p),m)}}],[{key:"getDerivedStateFromProps",value:function(e){return {content:n.getContent(e)}}}]),n}(o.a.Component);b(_,"propTypes",{element:a.a.any,date:a.a.oneOfType(w),parse:a.a.oneOfType(S),format:a.a.string,add:a.a.object,subtract:a.a.object,ago:a.a.bool,fromNow:a.a.bool,fromNowDuring:a.a.number,from:a.a.oneOfType(w),toNow:a.a.bool,to:a.a.oneOfType(w),calendar:a.a.oneOfType(T),unix:a.a.bool,utc:a.a.bool,local:a.a.bool,tz:a.a.string,withTitle:a.a.bool,titleFormat:a.a.string,locale:a.a.string,interval:a.a.number,diff:a.a.oneOfType(w),duration:a.a.oneOfType(w),durationFromNow:a.a.bool,trim:a.a.oneOfType(O),unit:a.a.string,decimal:a.a.bool,filter:a.a.func,onChange:a.a.func}),b(_,"defaultProps",{element:null,fromNow:!1,toNow:!1,calendar:!1,ago:!1,unix:!1,utc:!1,local:!1,unit:null,withTitle:!1,trim:!1,decimal:!1,titleFormat:"",interval:6e4,filter:function(e){return e},onChange:function(){}}),b(_,"globalMoment",null),b(_,"globalLocale",null),b(_,"globalLocal",null),b(_,"globalFormat",null),b(_,"globalParse",null),b(_,"globalFilter",null),b(_,"globalElement","time"),b(_,"globalTimezone",null),b(_,"pooledElements",[]),b(_,"pooledTimer",null);}])}));
|
|
10163
|
-
});
|
|
10164
|
-
|
|
10165
|
-
var Moment = /*@__PURE__*/getDefaultExportFromCjs(dist);
|
|
10166
|
-
|
|
10167
10142
|
// Copyright (c) 2022 HelioCampus Inc., all rights reserved.
|
|
10168
10143
|
const useStyles$h = makeStyles(() => ({
|
|
10169
10144
|
rootContainer: {
|
|
@@ -17463,7 +17438,7 @@ const DateSelect = props => {
|
|
|
17463
17438
|
if (!newDateType) return;
|
|
17464
17439
|
let newDate = null;
|
|
17465
17440
|
if (typeof selectedDate !== "undefined" && selectedDate != null) {
|
|
17466
|
-
newDate = format
|
|
17441
|
+
newDate = format(selectedDate, serverSideDateFormat);
|
|
17467
17442
|
}
|
|
17468
17443
|
setFieldValue(prev => _extends({}, prev, {
|
|
17469
17444
|
dateType: newDateType
|
|
@@ -17485,7 +17460,7 @@ const DateSelect = props => {
|
|
|
17485
17460
|
selectedDate: newDate
|
|
17486
17461
|
}));
|
|
17487
17462
|
onChange({
|
|
17488
|
-
date: format
|
|
17463
|
+
date: format(newDate, serverSideDateFormat),
|
|
17489
17464
|
type: dateType.type
|
|
17490
17465
|
});
|
|
17491
17466
|
} else {
|
|
@@ -19099,1003 +19074,6 @@ const PhoneWidgetReadOnly = props => {
|
|
|
19099
19074
|
const HOCs$5 = [...commonWidgetHOCs, withReadyOnly(PhoneWidgetReadOnly)];
|
|
19100
19075
|
var PhoneWidget$1 = compose(HOCs$5)(PhoneWidget);
|
|
19101
19076
|
|
|
19102
|
-
/**
|
|
19103
|
-
* react-number-format - 5.1.3
|
|
19104
|
-
* Author : Sudhanshu Yadav
|
|
19105
|
-
* Copyright (c) 2016, 2023 to Sudhanshu Yadav, released under the MIT license.
|
|
19106
|
-
* https://github.com/s-yadav/react-number-format
|
|
19107
|
-
*/
|
|
19108
|
-
|
|
19109
|
-
/******************************************************************************
|
|
19110
|
-
Copyright (c) Microsoft Corporation.
|
|
19111
|
-
|
|
19112
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
19113
|
-
purpose with or without fee is hereby granted.
|
|
19114
|
-
|
|
19115
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
19116
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19117
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19118
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19119
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19120
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19121
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19122
|
-
***************************************************************************** */
|
|
19123
|
-
|
|
19124
|
-
function __rest(s, e) {
|
|
19125
|
-
var t = {};
|
|
19126
|
-
for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19127
|
-
{ t[p] = s[p]; } }
|
|
19128
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19129
|
-
{ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19130
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19131
|
-
{ t[p[i]] = s[p[i]]; }
|
|
19132
|
-
} }
|
|
19133
|
-
return t;
|
|
19134
|
-
}
|
|
19135
|
-
|
|
19136
|
-
var SourceType;
|
|
19137
|
-
(function (SourceType) {
|
|
19138
|
-
SourceType["event"] = "event";
|
|
19139
|
-
SourceType["props"] = "prop";
|
|
19140
|
-
})(SourceType || (SourceType = {}));
|
|
19141
|
-
|
|
19142
|
-
// basic noop function
|
|
19143
|
-
function noop() { }
|
|
19144
|
-
function charIsNumber(char) {
|
|
19145
|
-
return !!(char || '').match(/\d/);
|
|
19146
|
-
}
|
|
19147
|
-
function isNil(val) {
|
|
19148
|
-
return val === null || val === undefined;
|
|
19149
|
-
}
|
|
19150
|
-
function isNanValue(val) {
|
|
19151
|
-
return typeof val === 'number' && isNaN(val);
|
|
19152
|
-
}
|
|
19153
|
-
function escapeRegExp(str) {
|
|
19154
|
-
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
|
19155
|
-
}
|
|
19156
|
-
function getThousandsGroupRegex(thousandsGroupStyle) {
|
|
19157
|
-
switch (thousandsGroupStyle) {
|
|
19158
|
-
case 'lakh':
|
|
19159
|
-
return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
|
|
19160
|
-
case 'wan':
|
|
19161
|
-
return /(\d)(?=(\d{4})+(?!\d))/g;
|
|
19162
|
-
case 'thousand':
|
|
19163
|
-
default:
|
|
19164
|
-
return /(\d)(?=(\d{3})+(?!\d))/g;
|
|
19165
|
-
}
|
|
19166
|
-
}
|
|
19167
|
-
function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
|
|
19168
|
-
var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
|
|
19169
|
-
var index = str.search(/[1-9]/);
|
|
19170
|
-
index = index === -1 ? str.length : index;
|
|
19171
|
-
return (str.substring(0, index) +
|
|
19172
|
-
str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator));
|
|
19173
|
-
}
|
|
19174
|
-
function usePersistentCallback(cb) {
|
|
19175
|
-
var callbackRef = useRef(cb);
|
|
19176
|
-
// keep the callback ref upto date
|
|
19177
|
-
callbackRef.current = cb;
|
|
19178
|
-
/**
|
|
19179
|
-
* initialize a persistent callback which never changes
|
|
19180
|
-
* through out the component lifecycle
|
|
19181
|
-
*/
|
|
19182
|
-
var persistentCbRef = useRef(function () {
|
|
19183
|
-
var args = [], len = arguments.length;
|
|
19184
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
19185
|
-
|
|
19186
|
-
return callbackRef.current.apply(callbackRef, args);
|
|
19187
|
-
});
|
|
19188
|
-
return persistentCbRef.current;
|
|
19189
|
-
}
|
|
19190
|
-
//spilt a float number into different parts beforeDecimal, afterDecimal, and negation
|
|
19191
|
-
function splitDecimal(numStr, allowNegative) {
|
|
19192
|
-
if ( allowNegative === void 0 ) allowNegative = true;
|
|
19193
|
-
|
|
19194
|
-
var hasNegation = numStr[0] === '-';
|
|
19195
|
-
var addNegation = hasNegation && allowNegative;
|
|
19196
|
-
numStr = numStr.replace('-', '');
|
|
19197
|
-
var parts = numStr.split('.');
|
|
19198
|
-
var beforeDecimal = parts[0];
|
|
19199
|
-
var afterDecimal = parts[1] || '';
|
|
19200
|
-
return {
|
|
19201
|
-
beforeDecimal: beforeDecimal,
|
|
19202
|
-
afterDecimal: afterDecimal,
|
|
19203
|
-
hasNegation: hasNegation,
|
|
19204
|
-
addNegation: addNegation,
|
|
19205
|
-
};
|
|
19206
|
-
}
|
|
19207
|
-
function fixLeadingZero(numStr) {
|
|
19208
|
-
if (!numStr)
|
|
19209
|
-
{ return numStr; }
|
|
19210
|
-
var isNegative = numStr[0] === '-';
|
|
19211
|
-
if (isNegative)
|
|
19212
|
-
{ numStr = numStr.substring(1, numStr.length); }
|
|
19213
|
-
var parts = numStr.split('.');
|
|
19214
|
-
var beforeDecimal = parts[0].replace(/^0+/, '') || '0';
|
|
19215
|
-
var afterDecimal = parts[1] || '';
|
|
19216
|
-
return ("" + (isNegative ? '-' : '') + beforeDecimal + (afterDecimal ? ("." + afterDecimal) : ''));
|
|
19217
|
-
}
|
|
19218
|
-
/**
|
|
19219
|
-
* limit decimal numbers to given scale
|
|
19220
|
-
* Not used .fixedTo because that will break with big numbers
|
|
19221
|
-
*/
|
|
19222
|
-
function limitToScale(numStr, scale, fixedDecimalScale) {
|
|
19223
|
-
var str = '';
|
|
19224
|
-
var filler = fixedDecimalScale ? '0' : '';
|
|
19225
|
-
for (var i = 0; i <= scale - 1; i++) {
|
|
19226
|
-
str += numStr[i] || filler;
|
|
19227
|
-
}
|
|
19228
|
-
return str;
|
|
19229
|
-
}
|
|
19230
|
-
function repeat(str, count) {
|
|
19231
|
-
return Array(count + 1).join(str);
|
|
19232
|
-
}
|
|
19233
|
-
function toNumericString(num) {
|
|
19234
|
-
var _num = num + ''; // typecast number to string
|
|
19235
|
-
// store the sign and remove it from the number.
|
|
19236
|
-
var sign = _num[0] === '-' ? '-' : '';
|
|
19237
|
-
if (sign)
|
|
19238
|
-
{ _num = _num.substring(1); }
|
|
19239
|
-
// split the number into cofficient and exponent
|
|
19240
|
-
var ref = _num.split(/[eE]/g);
|
|
19241
|
-
var coefficient = ref[0];
|
|
19242
|
-
var exponent = ref[1];
|
|
19243
|
-
// covert exponent to number;
|
|
19244
|
-
exponent = Number(exponent);
|
|
19245
|
-
// if there is no exponent part or its 0, return the coffiecient with sign
|
|
19246
|
-
if (!exponent)
|
|
19247
|
-
{ return sign + coefficient; }
|
|
19248
|
-
coefficient = coefficient.replace('.', '');
|
|
19249
|
-
/**
|
|
19250
|
-
* for scientific notation the current decimal index will be after first number (index 0)
|
|
19251
|
-
* So effective decimal index will always be 1 + exponent value
|
|
19252
|
-
*/
|
|
19253
|
-
var decimalIndex = 1 + exponent;
|
|
19254
|
-
var coffiecientLn = coefficient.length;
|
|
19255
|
-
if (decimalIndex < 0) {
|
|
19256
|
-
// if decimal index is less then 0 add preceding 0s
|
|
19257
|
-
// add 1 as join will have
|
|
19258
|
-
coefficient = '0.' + repeat('0', Math.abs(decimalIndex)) + coefficient;
|
|
19259
|
-
}
|
|
19260
|
-
else if (decimalIndex >= coffiecientLn) {
|
|
19261
|
-
// if decimal index is less then 0 add leading 0s
|
|
19262
|
-
coefficient = coefficient + repeat('0', decimalIndex - coffiecientLn);
|
|
19263
|
-
}
|
|
19264
|
-
else {
|
|
19265
|
-
// else add decimal point at proper index
|
|
19266
|
-
coefficient =
|
|
19267
|
-
(coefficient.substring(0, decimalIndex) || '0') + '.' + coefficient.substring(decimalIndex);
|
|
19268
|
-
}
|
|
19269
|
-
return sign + coefficient;
|
|
19270
|
-
}
|
|
19271
|
-
/**
|
|
19272
|
-
* This method is required to round prop value to given scale.
|
|
19273
|
-
* Not used .round or .fixedTo because that will break with big numbers
|
|
19274
|
-
*/
|
|
19275
|
-
function roundToPrecision(numStr, scale, fixedDecimalScale) {
|
|
19276
|
-
//if number is empty don't do anything return empty string
|
|
19277
|
-
if (['', '-'].indexOf(numStr) !== -1)
|
|
19278
|
-
{ return numStr; }
|
|
19279
|
-
var shouldHaveDecimalSeparator = (numStr.indexOf('.') !== -1 || fixedDecimalScale) && scale;
|
|
19280
|
-
var ref = splitDecimal(numStr);
|
|
19281
|
-
var beforeDecimal = ref.beforeDecimal;
|
|
19282
|
-
var afterDecimal = ref.afterDecimal;
|
|
19283
|
-
var hasNegation = ref.hasNegation;
|
|
19284
|
-
var floatValue = parseFloat(("0." + (afterDecimal || '0')));
|
|
19285
|
-
var floatValueStr = afterDecimal.length <= scale ? ("0." + afterDecimal) : floatValue.toFixed(scale);
|
|
19286
|
-
var roundedDecimalParts = floatValueStr.split('.');
|
|
19287
|
-
var intPart = beforeDecimal
|
|
19288
|
-
.split('')
|
|
19289
|
-
.reverse()
|
|
19290
|
-
.reduce(function (roundedStr, current, idx) {
|
|
19291
|
-
if (roundedStr.length > idx) {
|
|
19292
|
-
return ((Number(roundedStr[0]) + Number(current)).toString() +
|
|
19293
|
-
roundedStr.substring(1, roundedStr.length));
|
|
19294
|
-
}
|
|
19295
|
-
return current + roundedStr;
|
|
19296
|
-
}, roundedDecimalParts[0]);
|
|
19297
|
-
var decimalPart = limitToScale(roundedDecimalParts[1] || '', scale, fixedDecimalScale);
|
|
19298
|
-
var negation = hasNegation ? '-' : '';
|
|
19299
|
-
var decimalSeparator = shouldHaveDecimalSeparator ? '.' : '';
|
|
19300
|
-
return ("" + negation + intPart + decimalSeparator + decimalPart);
|
|
19301
|
-
}
|
|
19302
|
-
/** set the caret positon in an input field **/
|
|
19303
|
-
function setCaretPosition(el, caretPos) {
|
|
19304
|
-
el.value = el.value;
|
|
19305
|
-
// ^ this is used to not only get 'focus', but
|
|
19306
|
-
// to make sure we don't have it everything -selected-
|
|
19307
|
-
// (it causes an issue in chrome, and having it doesn't hurt any other browser)
|
|
19308
|
-
if (el !== null) {
|
|
19309
|
-
/* @ts-ignore */
|
|
19310
|
-
if (el.createTextRange) {
|
|
19311
|
-
/* @ts-ignore */
|
|
19312
|
-
var range = el.createTextRange();
|
|
19313
|
-
range.move('character', caretPos);
|
|
19314
|
-
range.select();
|
|
19315
|
-
return true;
|
|
19316
|
-
}
|
|
19317
|
-
// (el.selectionStart === 0 added for Firefox bug)
|
|
19318
|
-
if (el.selectionStart || el.selectionStart === 0) {
|
|
19319
|
-
el.focus();
|
|
19320
|
-
el.setSelectionRange(caretPos, caretPos);
|
|
19321
|
-
return true;
|
|
19322
|
-
}
|
|
19323
|
-
// fail city, fortunately this never happens (as far as I've tested) :)
|
|
19324
|
-
el.focus();
|
|
19325
|
-
return false;
|
|
19326
|
-
}
|
|
19327
|
-
}
|
|
19328
|
-
function findChangeRange(prevValue, newValue) {
|
|
19329
|
-
var i = 0, j = 0;
|
|
19330
|
-
var prevLength = prevValue.length;
|
|
19331
|
-
var newLength = newValue.length;
|
|
19332
|
-
while (prevValue[i] === newValue[i] && i < prevLength)
|
|
19333
|
-
{ i++; }
|
|
19334
|
-
//check what has been changed from last
|
|
19335
|
-
while (prevValue[prevLength - 1 - j] === newValue[newLength - 1 - j] &&
|
|
19336
|
-
newLength - j > i &&
|
|
19337
|
-
prevLength - j > i) {
|
|
19338
|
-
j++;
|
|
19339
|
-
}
|
|
19340
|
-
return {
|
|
19341
|
-
from: { start: i, end: prevLength - j },
|
|
19342
|
-
to: { start: i, end: newLength - j },
|
|
19343
|
-
};
|
|
19344
|
-
}
|
|
19345
|
-
/*
|
|
19346
|
-
Returns a number whose value is limited to the given range
|
|
19347
|
-
*/
|
|
19348
|
-
function clamp(num, min, max) {
|
|
19349
|
-
return Math.min(Math.max(num, min), max);
|
|
19350
|
-
}
|
|
19351
|
-
function geInputCaretPosition(el) {
|
|
19352
|
-
/*Max of selectionStart and selectionEnd is taken for the patch of pixel and other mobile device caret bug*/
|
|
19353
|
-
return Math.max(el.selectionStart, el.selectionEnd);
|
|
19354
|
-
}
|
|
19355
|
-
function addInputMode() {
|
|
19356
|
-
return (typeof navigator !== 'undefined' &&
|
|
19357
|
-
!(navigator.platform && /iPhone|iPod/.test(navigator.platform)));
|
|
19358
|
-
}
|
|
19359
|
-
function getDefaultChangeMeta(value) {
|
|
19360
|
-
return {
|
|
19361
|
-
from: {
|
|
19362
|
-
start: 0,
|
|
19363
|
-
end: 0,
|
|
19364
|
-
},
|
|
19365
|
-
to: {
|
|
19366
|
-
start: 0,
|
|
19367
|
-
end: value.length,
|
|
19368
|
-
},
|
|
19369
|
-
lastValue: '',
|
|
19370
|
-
};
|
|
19371
|
-
}
|
|
19372
|
-
function getCaretPosition(newFormattedValue, lastFormattedValue, curValue, curCaretPos, boundary, isValidInputCharacter) {
|
|
19373
|
-
/**
|
|
19374
|
-
* if something got inserted on empty value, add the formatted character before the current value,
|
|
19375
|
-
* This is to avoid the case where typed character is present on format characters
|
|
19376
|
-
*/
|
|
19377
|
-
var firstAllowedPosition = boundary.findIndex(function (b) { return b; });
|
|
19378
|
-
var prefixFormat = newFormattedValue.slice(0, firstAllowedPosition);
|
|
19379
|
-
if (!lastFormattedValue && !curValue.startsWith(prefixFormat)) {
|
|
19380
|
-
curValue = prefixFormat + curValue;
|
|
19381
|
-
curCaretPos = curCaretPos + prefixFormat.length;
|
|
19382
|
-
}
|
|
19383
|
-
var curValLn = curValue.length;
|
|
19384
|
-
var formattedValueLn = newFormattedValue.length;
|
|
19385
|
-
// create index map
|
|
19386
|
-
var addedIndexMap = {};
|
|
19387
|
-
var indexMap = new Array(curValLn);
|
|
19388
|
-
for (var i = 0; i < curValLn; i++) {
|
|
19389
|
-
indexMap[i] = -1;
|
|
19390
|
-
for (var j = 0, jLn = formattedValueLn; j < jLn; j++) {
|
|
19391
|
-
if (curValue[i] === newFormattedValue[j] && addedIndexMap[j] !== true) {
|
|
19392
|
-
indexMap[i] = j;
|
|
19393
|
-
addedIndexMap[j] = true;
|
|
19394
|
-
break;
|
|
19395
|
-
}
|
|
19396
|
-
}
|
|
19397
|
-
}
|
|
19398
|
-
/**
|
|
19399
|
-
* For current caret position find closest characters (left and right side)
|
|
19400
|
-
* which are properly mapped to formatted value.
|
|
19401
|
-
* The idea is that the new caret position will exist always in the boundary of
|
|
19402
|
-
* that mapped index
|
|
19403
|
-
*/
|
|
19404
|
-
var pos = curCaretPos;
|
|
19405
|
-
while (pos < curValLn && (indexMap[pos] === -1 || !isValidInputCharacter(curValue[pos]))) {
|
|
19406
|
-
pos++;
|
|
19407
|
-
}
|
|
19408
|
-
// if the caret position is on last keep the endIndex as last for formatted value
|
|
19409
|
-
var endIndex = pos === curValLn || indexMap[pos] === -1 ? formattedValueLn : indexMap[pos];
|
|
19410
|
-
pos = curCaretPos - 1;
|
|
19411
|
-
while (pos > 0 && indexMap[pos] === -1)
|
|
19412
|
-
{ pos--; }
|
|
19413
|
-
var startIndex = pos === -1 || indexMap[pos] === -1 ? 0 : indexMap[pos] + 1;
|
|
19414
|
-
/**
|
|
19415
|
-
* case where a char is added on suffix and removed from middle, example 2sq345 becoming $2,345 sq
|
|
19416
|
-
* there is still a mapping but the order of start index and end index is changed
|
|
19417
|
-
*/
|
|
19418
|
-
if (startIndex > endIndex)
|
|
19419
|
-
{ return endIndex; }
|
|
19420
|
-
/**
|
|
19421
|
-
* given the current caret position if it closer to startIndex
|
|
19422
|
-
* keep the new caret position on start index or keep it closer to endIndex
|
|
19423
|
-
*/
|
|
19424
|
-
return curCaretPos - startIndex < endIndex - curCaretPos ? startIndex : endIndex;
|
|
19425
|
-
}
|
|
19426
|
-
/* This keeps the caret within typing area so people can't type in between prefix or suffix or format characters */
|
|
19427
|
-
function getCaretPosInBoundary(value, caretPos, boundary, direction) {
|
|
19428
|
-
var valLn = value.length;
|
|
19429
|
-
// clamp caret position to [0, value.length]
|
|
19430
|
-
caretPos = clamp(caretPos, 0, valLn);
|
|
19431
|
-
if (direction === 'left') {
|
|
19432
|
-
while (caretPos >= 0 && !boundary[caretPos])
|
|
19433
|
-
{ caretPos--; }
|
|
19434
|
-
// if we don't find any suitable caret position on left, set it on first allowed position
|
|
19435
|
-
if (caretPos === -1)
|
|
19436
|
-
{ caretPos = boundary.indexOf(true); }
|
|
19437
|
-
}
|
|
19438
|
-
else {
|
|
19439
|
-
while (caretPos <= valLn && !boundary[caretPos])
|
|
19440
|
-
{ caretPos++; }
|
|
19441
|
-
// if we don't find any suitable caret position on right, set it on last allowed position
|
|
19442
|
-
if (caretPos > valLn)
|
|
19443
|
-
{ caretPos = boundary.lastIndexOf(true); }
|
|
19444
|
-
}
|
|
19445
|
-
// if we still don't find caret position, set it at the end of value
|
|
19446
|
-
if (caretPos === -1)
|
|
19447
|
-
{ caretPos = valLn; }
|
|
19448
|
-
return caretPos;
|
|
19449
|
-
}
|
|
19450
|
-
function caretUnknownFormatBoundary(formattedValue) {
|
|
19451
|
-
var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
|
|
19452
|
-
for (var i = 0, ln = boundaryAry.length; i < ln; i++) {
|
|
19453
|
-
// consider caret to be in boundary if it is before or after numeric value
|
|
19454
|
-
boundaryAry[i] = Boolean(charIsNumber(formattedValue[i]) || charIsNumber(formattedValue[i - 1]));
|
|
19455
|
-
}
|
|
19456
|
-
return boundaryAry;
|
|
19457
|
-
}
|
|
19458
|
-
function useInternalValues(value, defaultValue, valueIsNumericString, format, removeFormatting, onValueChange) {
|
|
19459
|
-
if ( onValueChange === void 0 ) onValueChange = noop;
|
|
19460
|
-
|
|
19461
|
-
var propValues = useRef();
|
|
19462
|
-
var getValues = usePersistentCallback(function (value) {
|
|
19463
|
-
var formattedValue, numAsString;
|
|
19464
|
-
if (isNil(value) || isNanValue(value)) {
|
|
19465
|
-
numAsString = '';
|
|
19466
|
-
formattedValue = '';
|
|
19467
|
-
}
|
|
19468
|
-
else if (typeof value === 'number' || valueIsNumericString) {
|
|
19469
|
-
numAsString = typeof value === 'number' ? toNumericString(value) : value;
|
|
19470
|
-
formattedValue = format(numAsString);
|
|
19471
|
-
}
|
|
19472
|
-
else {
|
|
19473
|
-
numAsString = removeFormatting(value, undefined);
|
|
19474
|
-
formattedValue = value;
|
|
19475
|
-
}
|
|
19476
|
-
return { formattedValue: formattedValue, numAsString: numAsString };
|
|
19477
|
-
});
|
|
19478
|
-
var ref = useState(function () {
|
|
19479
|
-
return getValues(defaultValue);
|
|
19480
|
-
});
|
|
19481
|
-
var values = ref[0];
|
|
19482
|
-
var setValues = ref[1];
|
|
19483
|
-
var _onValueChange = function (values, sourceInfo) {
|
|
19484
|
-
setValues({
|
|
19485
|
-
formattedValue: values.formattedValue,
|
|
19486
|
-
numAsString: values.value,
|
|
19487
|
-
});
|
|
19488
|
-
onValueChange(values, sourceInfo);
|
|
19489
|
-
};
|
|
19490
|
-
useMemo(function () {
|
|
19491
|
-
//if element is moved to uncontrolled mode, don't reset the value
|
|
19492
|
-
if (!isNil(value)) {
|
|
19493
|
-
propValues.current = getValues(value);
|
|
19494
|
-
setValues(propValues.current);
|
|
19495
|
-
}
|
|
19496
|
-
else {
|
|
19497
|
-
propValues.current = undefined;
|
|
19498
|
-
}
|
|
19499
|
-
}, [value, getValues]);
|
|
19500
|
-
return [values, _onValueChange];
|
|
19501
|
-
}
|
|
19502
|
-
|
|
19503
|
-
function defaultRemoveFormatting(value) {
|
|
19504
|
-
return value.replace(/[^0-9]/g, '');
|
|
19505
|
-
}
|
|
19506
|
-
function defaultFormat(value) {
|
|
19507
|
-
return value;
|
|
19508
|
-
}
|
|
19509
|
-
function NumberFormatBase(props) {
|
|
19510
|
-
var type = props.type; if ( type === void 0 ) type = 'text';
|
|
19511
|
-
var displayType = props.displayType; if ( displayType === void 0 ) displayType = 'input';
|
|
19512
|
-
var customInput = props.customInput;
|
|
19513
|
-
var renderText = props.renderText;
|
|
19514
|
-
var getInputRef = props.getInputRef;
|
|
19515
|
-
var format = props.format; if ( format === void 0 ) format = defaultFormat;
|
|
19516
|
-
var removeFormatting = props.removeFormatting; if ( removeFormatting === void 0 ) removeFormatting = defaultRemoveFormatting;
|
|
19517
|
-
var defaultValue = props.defaultValue;
|
|
19518
|
-
var valueIsNumericString = props.valueIsNumericString;
|
|
19519
|
-
var onValueChange = props.onValueChange;
|
|
19520
|
-
var isAllowed = props.isAllowed;
|
|
19521
|
-
var onChange = props.onChange; if ( onChange === void 0 ) onChange = noop;
|
|
19522
|
-
var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
|
|
19523
|
-
var onMouseUp = props.onMouseUp; if ( onMouseUp === void 0 ) onMouseUp = noop;
|
|
19524
|
-
var onFocus = props.onFocus; if ( onFocus === void 0 ) onFocus = noop;
|
|
19525
|
-
var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
|
|
19526
|
-
var propValue = props.value;
|
|
19527
|
-
var getCaretBoundary = props.getCaretBoundary; if ( getCaretBoundary === void 0 ) getCaretBoundary = caretUnknownFormatBoundary;
|
|
19528
|
-
var isValidInputCharacter = props.isValidInputCharacter; if ( isValidInputCharacter === void 0 ) isValidInputCharacter = charIsNumber;
|
|
19529
|
-
var otherProps = __rest(props, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter"]);
|
|
19530
|
-
var ref = useInternalValues(propValue, defaultValue, Boolean(valueIsNumericString), format, removeFormatting, onValueChange);
|
|
19531
|
-
var ref_0 = ref[0];
|
|
19532
|
-
var formattedValue = ref_0.formattedValue;
|
|
19533
|
-
var numAsString = ref_0.numAsString;
|
|
19534
|
-
var onFormattedValueChange = ref[1];
|
|
19535
|
-
var lastUpdatedValue = useRef();
|
|
19536
|
-
var _onValueChange = function (values, source) {
|
|
19537
|
-
lastUpdatedValue.current = values.formattedValue;
|
|
19538
|
-
onFormattedValueChange(values, source);
|
|
19539
|
-
};
|
|
19540
|
-
// check if there is any change in the value due to props change
|
|
19541
|
-
useEffect(function () {
|
|
19542
|
-
var newFormattedValue = format(numAsString);
|
|
19543
|
-
// if the formatted value is not synced to parent, or if the formatted value is different
|
|
19544
|
-
if (lastUpdatedValue.current === undefined || newFormattedValue !== lastUpdatedValue.current) {
|
|
19545
|
-
var input = focusedElm.current;
|
|
19546
|
-
// formatting can remove some of the number chars, so we need to fine number string again
|
|
19547
|
-
var _numAsString = removeFormatting(newFormattedValue, undefined);
|
|
19548
|
-
updateValue({
|
|
19549
|
-
formattedValue: newFormattedValue,
|
|
19550
|
-
numAsString: _numAsString,
|
|
19551
|
-
input: input,
|
|
19552
|
-
setCaretPosition: true,
|
|
19553
|
-
source: SourceType.props,
|
|
19554
|
-
event: undefined,
|
|
19555
|
-
});
|
|
19556
|
-
}
|
|
19557
|
-
});
|
|
19558
|
-
var ref$1 = useState(false);
|
|
19559
|
-
var mounted = ref$1[0];
|
|
19560
|
-
var setMounted = ref$1[1];
|
|
19561
|
-
var focusedElm = useRef(null);
|
|
19562
|
-
var timeout = useRef({
|
|
19563
|
-
setCaretTimeout: null,
|
|
19564
|
-
focusTimeout: null,
|
|
19565
|
-
});
|
|
19566
|
-
useEffect(function () {
|
|
19567
|
-
setMounted(true);
|
|
19568
|
-
return function () {
|
|
19569
|
-
clearTimeout(timeout.current.setCaretTimeout);
|
|
19570
|
-
clearTimeout(timeout.current.focusTimeout);
|
|
19571
|
-
};
|
|
19572
|
-
}, []);
|
|
19573
|
-
var _format = format;
|
|
19574
|
-
var getValueObject = function (formattedValue, numAsString) {
|
|
19575
|
-
var floatValue = parseFloat(numAsString);
|
|
19576
|
-
return {
|
|
19577
|
-
formattedValue: formattedValue,
|
|
19578
|
-
value: numAsString,
|
|
19579
|
-
floatValue: isNaN(floatValue) ? undefined : floatValue,
|
|
19580
|
-
};
|
|
19581
|
-
};
|
|
19582
|
-
var setPatchedCaretPosition = function (el, caretPos, currentValue) {
|
|
19583
|
-
/* setting caret position within timeout of 0ms is required for mobile chrome,
|
|
19584
|
-
otherwise browser resets the caret position after we set it
|
|
19585
|
-
We are also setting it without timeout so that in normal browser we don't see the flickering */
|
|
19586
|
-
setCaretPosition(el, caretPos);
|
|
19587
|
-
timeout.current.setCaretTimeout = setTimeout(function () {
|
|
19588
|
-
if (el.value === currentValue)
|
|
19589
|
-
{ setCaretPosition(el, caretPos); }
|
|
19590
|
-
}, 0);
|
|
19591
|
-
};
|
|
19592
|
-
/* This keeps the caret within typing area so people can't type in between prefix or suffix */
|
|
19593
|
-
var correctCaretPosition = function (value, caretPos, direction) {
|
|
19594
|
-
return getCaretPosInBoundary(value, caretPos, getCaretBoundary(value), direction);
|
|
19595
|
-
};
|
|
19596
|
-
var getNewCaretPosition = function (inputValue, newFormattedValue, caretPos) {
|
|
19597
|
-
var caretBoundary = getCaretBoundary(newFormattedValue);
|
|
19598
|
-
var updatedCaretPos = getCaretPosition(newFormattedValue, formattedValue, inputValue, caretPos, caretBoundary, isValidInputCharacter);
|
|
19599
|
-
//correct caret position if its outside of editable area
|
|
19600
|
-
updatedCaretPos = getCaretPosInBoundary(newFormattedValue, updatedCaretPos, caretBoundary);
|
|
19601
|
-
return updatedCaretPos;
|
|
19602
|
-
};
|
|
19603
|
-
var updateValue = function (params) {
|
|
19604
|
-
var newFormattedValue = params.formattedValue; if ( newFormattedValue === void 0 ) newFormattedValue = '';
|
|
19605
|
-
var input = params.input;
|
|
19606
|
-
var setCaretPosition = params.setCaretPosition; if ( setCaretPosition === void 0 ) setCaretPosition = true;
|
|
19607
|
-
var source = params.source;
|
|
19608
|
-
var event = params.event;
|
|
19609
|
-
var numAsString = params.numAsString;
|
|
19610
|
-
var caretPos = params.caretPos;
|
|
19611
|
-
if (input) {
|
|
19612
|
-
//calculate caret position if not defined
|
|
19613
|
-
if (caretPos === undefined && setCaretPosition) {
|
|
19614
|
-
var inputValue = params.inputValue || input.value;
|
|
19615
|
-
var currentCaretPosition = geInputCaretPosition(input);
|
|
19616
|
-
/**
|
|
19617
|
-
* set the value imperatively, this is required for IE fix
|
|
19618
|
-
* This is also required as if new caret position is beyond the previous value.
|
|
19619
|
-
* Caret position will not be set correctly
|
|
19620
|
-
*/
|
|
19621
|
-
input.value = newFormattedValue;
|
|
19622
|
-
//get the caret position
|
|
19623
|
-
caretPos = getNewCaretPosition(inputValue, newFormattedValue, currentCaretPosition);
|
|
19624
|
-
}
|
|
19625
|
-
/**
|
|
19626
|
-
* set the value imperatively, as we set the caret position as well imperatively.
|
|
19627
|
-
* This is to keep value and caret position in sync
|
|
19628
|
-
*/
|
|
19629
|
-
input.value = newFormattedValue;
|
|
19630
|
-
//set caret position, and value imperatively when element is provided
|
|
19631
|
-
if (setCaretPosition && caretPos !== undefined) {
|
|
19632
|
-
//set caret position
|
|
19633
|
-
setPatchedCaretPosition(input, caretPos, newFormattedValue);
|
|
19634
|
-
}
|
|
19635
|
-
}
|
|
19636
|
-
if (newFormattedValue !== formattedValue) {
|
|
19637
|
-
// trigger onValueChange synchronously, so parent is updated along with the number format. Fix for #277, #287
|
|
19638
|
-
_onValueChange(getValueObject(newFormattedValue, numAsString), { event: event, source: source });
|
|
19639
|
-
}
|
|
19640
|
-
};
|
|
19641
|
-
var formatInputValue = function (inputValue, event, source) {
|
|
19642
|
-
var changeRange = findChangeRange(formattedValue, inputValue);
|
|
19643
|
-
var changeMeta = Object.assign(Object.assign({}, changeRange), { lastValue: formattedValue });
|
|
19644
|
-
var _numAsString = removeFormatting(inputValue, changeMeta);
|
|
19645
|
-
var _formattedValue = _format(_numAsString);
|
|
19646
|
-
// formatting can remove some of the number chars, so we need to fine number string again
|
|
19647
|
-
_numAsString = removeFormatting(_formattedValue, undefined);
|
|
19648
|
-
if (isAllowed && !isAllowed(getValueObject(_formattedValue, _numAsString))) {
|
|
19649
|
-
//reset the caret position
|
|
19650
|
-
var input = event.target;
|
|
19651
|
-
var currentCaretPosition = geInputCaretPosition(input);
|
|
19652
|
-
var caretPos = getNewCaretPosition(inputValue, formattedValue, currentCaretPosition);
|
|
19653
|
-
setPatchedCaretPosition(input, caretPos, formattedValue);
|
|
19654
|
-
return false;
|
|
19655
|
-
}
|
|
19656
|
-
updateValue({
|
|
19657
|
-
formattedValue: _formattedValue,
|
|
19658
|
-
numAsString: _numAsString,
|
|
19659
|
-
inputValue: inputValue,
|
|
19660
|
-
event: event,
|
|
19661
|
-
source: source,
|
|
19662
|
-
setCaretPosition: true,
|
|
19663
|
-
input: event.target,
|
|
19664
|
-
});
|
|
19665
|
-
return true;
|
|
19666
|
-
};
|
|
19667
|
-
var _onChange = function (e) {
|
|
19668
|
-
var el = e.target;
|
|
19669
|
-
var inputValue = el.value;
|
|
19670
|
-
var changed = formatInputValue(inputValue, e, SourceType.event);
|
|
19671
|
-
if (changed)
|
|
19672
|
-
{ onChange(e); }
|
|
19673
|
-
};
|
|
19674
|
-
var _onKeyDown = function (e) {
|
|
19675
|
-
var el = e.target;
|
|
19676
|
-
var key = e.key;
|
|
19677
|
-
var selectionStart = el.selectionStart;
|
|
19678
|
-
var selectionEnd = el.selectionEnd;
|
|
19679
|
-
var value = el.value; if ( value === void 0 ) value = '';
|
|
19680
|
-
var expectedCaretPosition;
|
|
19681
|
-
//Handle backspace and delete against non numerical/decimal characters or arrow keys
|
|
19682
|
-
if (key === 'ArrowLeft' || key === 'Backspace') {
|
|
19683
|
-
expectedCaretPosition = Math.max(selectionStart - 1, 0);
|
|
19684
|
-
}
|
|
19685
|
-
else if (key === 'ArrowRight') {
|
|
19686
|
-
expectedCaretPosition = Math.min(selectionStart + 1, value.length);
|
|
19687
|
-
}
|
|
19688
|
-
else if (key === 'Delete') {
|
|
19689
|
-
expectedCaretPosition = selectionStart;
|
|
19690
|
-
}
|
|
19691
|
-
//if expectedCaretPosition is not set it means we don't want to Handle keyDown
|
|
19692
|
-
// also if multiple characters are selected don't handle
|
|
19693
|
-
if (expectedCaretPosition === undefined || selectionStart !== selectionEnd) {
|
|
19694
|
-
onKeyDown(e);
|
|
19695
|
-
return;
|
|
19696
|
-
}
|
|
19697
|
-
var newCaretPosition = expectedCaretPosition;
|
|
19698
|
-
if (key === 'ArrowLeft' || key === 'ArrowRight') {
|
|
19699
|
-
var direction = key === 'ArrowLeft' ? 'left' : 'right';
|
|
19700
|
-
newCaretPosition = correctCaretPosition(value, expectedCaretPosition, direction);
|
|
19701
|
-
}
|
|
19702
|
-
else if (key === 'Delete' && !isValidInputCharacter(value[expectedCaretPosition])) {
|
|
19703
|
-
// in case of delete go to closest caret boundary on the right side
|
|
19704
|
-
newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'right');
|
|
19705
|
-
}
|
|
19706
|
-
else if (key === 'Backspace' && !isValidInputCharacter(value[expectedCaretPosition])) {
|
|
19707
|
-
// in case of backspace go to closest caret boundary on the left side
|
|
19708
|
-
newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'left');
|
|
19709
|
-
}
|
|
19710
|
-
if (newCaretPosition !== expectedCaretPosition) {
|
|
19711
|
-
setPatchedCaretPosition(el, newCaretPosition, value);
|
|
19712
|
-
}
|
|
19713
|
-
/* NOTE: this is just required for unit test as we need to get the newCaretPosition,
|
|
19714
|
-
Remove this when you find different solution */
|
|
19715
|
-
/* @ts-ignore */
|
|
19716
|
-
if (e.isUnitTestRun) {
|
|
19717
|
-
setPatchedCaretPosition(el, newCaretPosition, value);
|
|
19718
|
-
}
|
|
19719
|
-
onKeyDown(e);
|
|
19720
|
-
};
|
|
19721
|
-
/** required to handle the caret position when click anywhere within the input **/
|
|
19722
|
-
var _onMouseUp = function (e) {
|
|
19723
|
-
var el = e.target;
|
|
19724
|
-
/**
|
|
19725
|
-
* NOTE: we have to give default value for value as in case when custom input is provided
|
|
19726
|
-
* value can come as undefined when nothing is provided on value prop.
|
|
19727
|
-
*/
|
|
19728
|
-
var selectionStart = el.selectionStart;
|
|
19729
|
-
var selectionEnd = el.selectionEnd;
|
|
19730
|
-
var value = el.value; if ( value === void 0 ) value = '';
|
|
19731
|
-
if (selectionStart === selectionEnd) {
|
|
19732
|
-
var caretPosition = correctCaretPosition(value, selectionStart);
|
|
19733
|
-
if (caretPosition !== selectionStart) {
|
|
19734
|
-
setPatchedCaretPosition(el, caretPosition, value);
|
|
19735
|
-
}
|
|
19736
|
-
}
|
|
19737
|
-
onMouseUp(e);
|
|
19738
|
-
};
|
|
19739
|
-
var _onFocus = function (e) {
|
|
19740
|
-
// Workaround Chrome and Safari bug https://bugs.chromium.org/p/chromium/issues/detail?id=779328
|
|
19741
|
-
// (onFocus event target selectionStart is always 0 before setTimeout)
|
|
19742
|
-
if (e.persist)
|
|
19743
|
-
{ e.persist(); }
|
|
19744
|
-
var el = e.target;
|
|
19745
|
-
focusedElm.current = el;
|
|
19746
|
-
timeout.current.focusTimeout = setTimeout(function () {
|
|
19747
|
-
var selectionStart = el.selectionStart;
|
|
19748
|
-
var selectionEnd = el.selectionEnd;
|
|
19749
|
-
var value = el.value; if ( value === void 0 ) value = '';
|
|
19750
|
-
var caretPosition = correctCaretPosition(value, selectionStart);
|
|
19751
|
-
//setPatchedCaretPosition only when everything is not selected on focus (while tabbing into the field)
|
|
19752
|
-
if (caretPosition !== selectionStart &&
|
|
19753
|
-
!(selectionStart === 0 && selectionEnd === value.length)) {
|
|
19754
|
-
setPatchedCaretPosition(el, caretPosition, value);
|
|
19755
|
-
}
|
|
19756
|
-
onFocus(e);
|
|
19757
|
-
}, 0);
|
|
19758
|
-
};
|
|
19759
|
-
var _onBlur = function (e) {
|
|
19760
|
-
focusedElm.current = null;
|
|
19761
|
-
clearTimeout(timeout.current.focusTimeout);
|
|
19762
|
-
clearTimeout(timeout.current.setCaretTimeout);
|
|
19763
|
-
onBlur(e);
|
|
19764
|
-
};
|
|
19765
|
-
// add input mode on element based on format prop and device once the component is mounted
|
|
19766
|
-
var inputMode = mounted && addInputMode() ? 'numeric' : undefined;
|
|
19767
|
-
var inputProps = Object.assign({ inputMode: inputMode }, otherProps, {
|
|
19768
|
-
type: type,
|
|
19769
|
-
value: formattedValue,
|
|
19770
|
-
onChange: _onChange,
|
|
19771
|
-
onKeyDown: _onKeyDown,
|
|
19772
|
-
onMouseUp: _onMouseUp,
|
|
19773
|
-
onFocus: _onFocus,
|
|
19774
|
-
onBlur: _onBlur,
|
|
19775
|
-
});
|
|
19776
|
-
if (displayType === 'text') {
|
|
19777
|
-
return renderText ? (React.createElement(React.Fragment, null, renderText(formattedValue, otherProps) || null)) : (React.createElement("span", Object.assign({}, otherProps, { ref: getInputRef }), formattedValue));
|
|
19778
|
-
}
|
|
19779
|
-
else if (customInput) {
|
|
19780
|
-
var CustomInput = customInput;
|
|
19781
|
-
/* @ts-ignore */
|
|
19782
|
-
return React.createElement(CustomInput, Object.assign({}, inputProps, { ref: getInputRef }));
|
|
19783
|
-
}
|
|
19784
|
-
return React.createElement("input", Object.assign({}, inputProps, { ref: getInputRef }));
|
|
19785
|
-
}
|
|
19786
|
-
|
|
19787
|
-
function format(numStr, props) {
|
|
19788
|
-
var decimalScale = props.decimalScale;
|
|
19789
|
-
var fixedDecimalScale = props.fixedDecimalScale;
|
|
19790
|
-
var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
|
|
19791
|
-
var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
|
|
19792
|
-
var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
|
|
19793
|
-
var thousandsGroupStyle = props.thousandsGroupStyle; if ( thousandsGroupStyle === void 0 ) thousandsGroupStyle = 'thousand';
|
|
19794
|
-
// don't apply formatting on empty string or '-'
|
|
19795
|
-
if (numStr === '' || numStr === '-') {
|
|
19796
|
-
return numStr;
|
|
19797
|
-
}
|
|
19798
|
-
var ref = getSeparators(props);
|
|
19799
|
-
var thousandSeparator = ref.thousandSeparator;
|
|
19800
|
-
var decimalSeparator = ref.decimalSeparator;
|
|
19801
|
-
/**
|
|
19802
|
-
* Keep the decimal separator
|
|
19803
|
-
* when decimalScale is not defined or non zero and the numStr has decimal in it
|
|
19804
|
-
* Or if decimalScale is > 0 and fixeDecimalScale is true (even if numStr has no decimal)
|
|
19805
|
-
*/
|
|
19806
|
-
var hasDecimalSeparator = (decimalScale !== 0 && numStr.indexOf('.') !== -1) || (decimalScale && fixedDecimalScale);
|
|
19807
|
-
var ref$1 = splitDecimal(numStr, allowNegative);
|
|
19808
|
-
var beforeDecimal = ref$1.beforeDecimal;
|
|
19809
|
-
var afterDecimal = ref$1.afterDecimal;
|
|
19810
|
-
var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
|
|
19811
|
-
//apply decimal precision if its defined
|
|
19812
|
-
if (decimalScale !== undefined) {
|
|
19813
|
-
afterDecimal = limitToScale(afterDecimal, decimalScale, !!fixedDecimalScale);
|
|
19814
|
-
}
|
|
19815
|
-
if (thousandSeparator) {
|
|
19816
|
-
beforeDecimal = applyThousandSeparator(beforeDecimal, thousandSeparator, thousandsGroupStyle);
|
|
19817
|
-
}
|
|
19818
|
-
//add prefix and suffix when there is a number present
|
|
19819
|
-
if (prefix)
|
|
19820
|
-
{ beforeDecimal = prefix + beforeDecimal; }
|
|
19821
|
-
if (suffix)
|
|
19822
|
-
{ afterDecimal = afterDecimal + suffix; }
|
|
19823
|
-
//restore negation sign
|
|
19824
|
-
if (addNegation)
|
|
19825
|
-
{ beforeDecimal = '-' + beforeDecimal; }
|
|
19826
|
-
numStr = beforeDecimal + ((hasDecimalSeparator && decimalSeparator) || '') + afterDecimal;
|
|
19827
|
-
return numStr;
|
|
19828
|
-
}
|
|
19829
|
-
function getSeparators(props) {
|
|
19830
|
-
var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
|
|
19831
|
-
var thousandSeparator = props.thousandSeparator;
|
|
19832
|
-
var allowedDecimalSeparators = props.allowedDecimalSeparators;
|
|
19833
|
-
if (thousandSeparator === true) {
|
|
19834
|
-
thousandSeparator = ',';
|
|
19835
|
-
}
|
|
19836
|
-
if (!allowedDecimalSeparators) {
|
|
19837
|
-
allowedDecimalSeparators = [decimalSeparator, '.'];
|
|
19838
|
-
}
|
|
19839
|
-
return {
|
|
19840
|
-
decimalSeparator: decimalSeparator,
|
|
19841
|
-
thousandSeparator: thousandSeparator,
|
|
19842
|
-
allowedDecimalSeparators: allowedDecimalSeparators,
|
|
19843
|
-
};
|
|
19844
|
-
}
|
|
19845
|
-
function handleNegation(value, allowNegative) {
|
|
19846
|
-
if ( value === void 0 ) value = '';
|
|
19847
|
-
|
|
19848
|
-
var negationRegex = new RegExp('(-)');
|
|
19849
|
-
var doubleNegationRegex = new RegExp('(-)(.)*(-)');
|
|
19850
|
-
// Check number has '-' value
|
|
19851
|
-
var hasNegation = negationRegex.test(value);
|
|
19852
|
-
// Check number has 2 or more '-' values
|
|
19853
|
-
var removeNegation = doubleNegationRegex.test(value);
|
|
19854
|
-
//remove negation
|
|
19855
|
-
value = value.replace(/-/g, '');
|
|
19856
|
-
if (hasNegation && !removeNegation && allowNegative) {
|
|
19857
|
-
value = '-' + value;
|
|
19858
|
-
}
|
|
19859
|
-
return value;
|
|
19860
|
-
}
|
|
19861
|
-
function getNumberRegex(decimalSeparator, global) {
|
|
19862
|
-
return new RegExp(("(^-)|[0-9]|" + (escapeRegExp(decimalSeparator))), global ? 'g' : undefined);
|
|
19863
|
-
}
|
|
19864
|
-
function removeFormatting(value, changeMeta, props) {
|
|
19865
|
-
if ( changeMeta === void 0 ) changeMeta = getDefaultChangeMeta(value);
|
|
19866
|
-
|
|
19867
|
-
var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
|
|
19868
|
-
var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
|
|
19869
|
-
var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
|
|
19870
|
-
var decimalScale = props.decimalScale;
|
|
19871
|
-
var from = changeMeta.from;
|
|
19872
|
-
var to = changeMeta.to;
|
|
19873
|
-
var start = to.start;
|
|
19874
|
-
var end = to.end;
|
|
19875
|
-
var ref = getSeparators(props);
|
|
19876
|
-
var allowedDecimalSeparators = ref.allowedDecimalSeparators;
|
|
19877
|
-
var decimalSeparator = ref.decimalSeparator;
|
|
19878
|
-
var isBeforeDecimalSeparator = value[end] === decimalSeparator;
|
|
19879
|
-
/** Check for any allowed decimal separator is added in the numeric format and replace it with decimal separator */
|
|
19880
|
-
if (end - start === 1 && allowedDecimalSeparators.indexOf(value[start]) !== -1) {
|
|
19881
|
-
var separator = decimalScale === 0 ? '' : decimalSeparator;
|
|
19882
|
-
value = value.substring(0, start) + separator + value.substring(start + 1, value.length);
|
|
19883
|
-
}
|
|
19884
|
-
var hasNegation = false;
|
|
19885
|
-
/**
|
|
19886
|
-
* if prefix starts with - the number hast to have two - at the start
|
|
19887
|
-
* if suffix starts with - and the value length is same as suffix length, then the - sign is from the suffix
|
|
19888
|
-
* In other cases, if the value starts with - then it is a negation
|
|
19889
|
-
*/
|
|
19890
|
-
if (prefix.startsWith('-'))
|
|
19891
|
-
{ hasNegation = value.startsWith('--'); }
|
|
19892
|
-
else if (suffix.startsWith('-') && value.length === suffix.length)
|
|
19893
|
-
{ hasNegation = false; }
|
|
19894
|
-
else if (value[0] === '-')
|
|
19895
|
-
{ hasNegation = true; }
|
|
19896
|
-
// remove negation from start to simplify prefix logic as negation comes before prefix
|
|
19897
|
-
if (hasNegation) {
|
|
19898
|
-
value = value.substring(1);
|
|
19899
|
-
// account for the removal of the negation for start and end index
|
|
19900
|
-
start -= 1;
|
|
19901
|
-
end -= 1;
|
|
19902
|
-
}
|
|
19903
|
-
/**
|
|
19904
|
-
* remove prefix
|
|
19905
|
-
* Remove whole prefix part if its present on the value
|
|
19906
|
-
* If the prefix is partially deleted (in which case change start index will be less the prefix length)
|
|
19907
|
-
* Remove only partial part of prefix.
|
|
19908
|
-
*/
|
|
19909
|
-
var startIndex = 0;
|
|
19910
|
-
if (value.startsWith(prefix))
|
|
19911
|
-
{ startIndex += prefix.length; }
|
|
19912
|
-
else if (start < prefix.length)
|
|
19913
|
-
{ startIndex = start; }
|
|
19914
|
-
value = value.substring(startIndex);
|
|
19915
|
-
// account for deleted prefix for end index
|
|
19916
|
-
end -= startIndex;
|
|
19917
|
-
/**
|
|
19918
|
-
* Remove suffix
|
|
19919
|
-
* Remove whole suffix part if its present on the value
|
|
19920
|
-
* If the suffix is partially deleted (in which case change end index will be greater than the suffixStartIndex)
|
|
19921
|
-
* remove the partial part of suffix
|
|
19922
|
-
*/
|
|
19923
|
-
var endIndex = value.length;
|
|
19924
|
-
var suffixStartIndex = value.length - suffix.length;
|
|
19925
|
-
if (value.endsWith(suffix))
|
|
19926
|
-
{ endIndex = suffixStartIndex; }
|
|
19927
|
-
else if (end > value.length - suffix.length)
|
|
19928
|
-
{ endIndex = end; }
|
|
19929
|
-
value = value.substring(0, endIndex);
|
|
19930
|
-
// add the negation back and handle for double negation
|
|
19931
|
-
value = handleNegation(hasNegation ? ("-" + value) : value, allowNegative);
|
|
19932
|
-
// remove non numeric characters
|
|
19933
|
-
value = (value.match(getNumberRegex(decimalSeparator, true)) || []).join('');
|
|
19934
|
-
// replace the decimalSeparator with ., and only keep the first separator, ignore following ones
|
|
19935
|
-
var firstIndex = value.indexOf(decimalSeparator);
|
|
19936
|
-
value = value.replace(new RegExp(escapeRegExp(decimalSeparator), 'g'), function (match, index) {
|
|
19937
|
-
return index === firstIndex ? '.' : '';
|
|
19938
|
-
});
|
|
19939
|
-
//check if beforeDecimal got deleted and there is nothing after decimal,
|
|
19940
|
-
//clear all numbers in such case while keeping the - sign
|
|
19941
|
-
var ref$1 = splitDecimal(value, allowNegative);
|
|
19942
|
-
var beforeDecimal = ref$1.beforeDecimal;
|
|
19943
|
-
var afterDecimal = ref$1.afterDecimal;
|
|
19944
|
-
var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
|
|
19945
|
-
//clear only if something got deleted before decimal (cursor is before decimal)
|
|
19946
|
-
if (to.end - to.start < from.end - from.start &&
|
|
19947
|
-
beforeDecimal === '' &&
|
|
19948
|
-
isBeforeDecimalSeparator &&
|
|
19949
|
-
!parseFloat(afterDecimal)) {
|
|
19950
|
-
value = addNegation ? '-' : '';
|
|
19951
|
-
}
|
|
19952
|
-
return value;
|
|
19953
|
-
}
|
|
19954
|
-
function getCaretBoundary(formattedValue, props) {
|
|
19955
|
-
var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
|
|
19956
|
-
var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
|
|
19957
|
-
var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
|
|
19958
|
-
var hasNegation = formattedValue[0] === '-';
|
|
19959
|
-
// fill for prefix and negation
|
|
19960
|
-
boundaryAry.fill(false, 0, prefix.length + (hasNegation ? 1 : 0));
|
|
19961
|
-
// fill for suffix
|
|
19962
|
-
var valLn = formattedValue.length;
|
|
19963
|
-
boundaryAry.fill(false, valLn - suffix.length + 1, valLn + 1);
|
|
19964
|
-
return boundaryAry;
|
|
19965
|
-
}
|
|
19966
|
-
function validateProps(props) {
|
|
19967
|
-
var ref = getSeparators(props);
|
|
19968
|
-
var thousandSeparator = ref.thousandSeparator;
|
|
19969
|
-
var decimalSeparator = ref.decimalSeparator;
|
|
19970
|
-
if (thousandSeparator === decimalSeparator) {
|
|
19971
|
-
throw new Error(("\n Decimal separator can't be same as thousand separator.\n thousandSeparator: " + thousandSeparator + " (thousandSeparator = {true} is same as thousandSeparator = \",\")\n decimalSeparator: " + decimalSeparator + " (default value for decimalSeparator is .)\n "));
|
|
19972
|
-
}
|
|
19973
|
-
}
|
|
19974
|
-
function useNumericFormat(props) {
|
|
19975
|
-
var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
|
|
19976
|
-
var allowLeadingZeros = props.allowLeadingZeros;
|
|
19977
|
-
var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
|
|
19978
|
-
var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
|
|
19979
|
-
var thousandSeparator = props.thousandSeparator;
|
|
19980
|
-
var decimalScale = props.decimalScale;
|
|
19981
|
-
var fixedDecimalScale = props.fixedDecimalScale;
|
|
19982
|
-
var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
|
|
19983
|
-
var defaultValue = props.defaultValue;
|
|
19984
|
-
var value = props.value;
|
|
19985
|
-
var valueIsNumericString = props.valueIsNumericString;
|
|
19986
|
-
var onValueChange = props.onValueChange;
|
|
19987
|
-
var restProps = __rest(props, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]);
|
|
19988
|
-
// validate props
|
|
19989
|
-
validateProps(props);
|
|
19990
|
-
var _format = function (numStr) { return format(numStr, props); };
|
|
19991
|
-
var _removeFormatting = function (inputValue, changeMeta) { return removeFormatting(inputValue, changeMeta, props); };
|
|
19992
|
-
var _valueIsNumericString = valueIsNumericString;
|
|
19993
|
-
if (!isNil(value)) {
|
|
19994
|
-
_valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof value === 'number';
|
|
19995
|
-
}
|
|
19996
|
-
else if (!isNil(defaultValue)) {
|
|
19997
|
-
_valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof defaultValue === 'number';
|
|
19998
|
-
}
|
|
19999
|
-
var roundIncomingValueToPrecision = function (value) {
|
|
20000
|
-
if (isNil(value) || isNanValue(value))
|
|
20001
|
-
{ return value; }
|
|
20002
|
-
if (typeof value === 'number') {
|
|
20003
|
-
value = toNumericString(value);
|
|
20004
|
-
}
|
|
20005
|
-
/**
|
|
20006
|
-
* only round numeric or float string values coming through props,
|
|
20007
|
-
* we don't need to do it for onChange events, as we want to prevent typing there
|
|
20008
|
-
*/
|
|
20009
|
-
if (_valueIsNumericString && typeof decimalScale === 'number') {
|
|
20010
|
-
return roundToPrecision(value, decimalScale, Boolean(fixedDecimalScale));
|
|
20011
|
-
}
|
|
20012
|
-
return value;
|
|
20013
|
-
};
|
|
20014
|
-
var ref = useInternalValues(roundIncomingValueToPrecision(value), roundIncomingValueToPrecision(defaultValue), Boolean(_valueIsNumericString), _format, _removeFormatting, onValueChange);
|
|
20015
|
-
var ref_0 = ref[0];
|
|
20016
|
-
var numAsString = ref_0.numAsString;
|
|
20017
|
-
var formattedValue = ref_0.formattedValue;
|
|
20018
|
-
var _onValueChange = ref[1];
|
|
20019
|
-
var _onKeyDown = function (e) {
|
|
20020
|
-
var el = e.target;
|
|
20021
|
-
var key = e.key;
|
|
20022
|
-
var selectionStart = el.selectionStart;
|
|
20023
|
-
var selectionEnd = el.selectionEnd;
|
|
20024
|
-
var value = el.value; if ( value === void 0 ) value = '';
|
|
20025
|
-
// if multiple characters are selected and user hits backspace, no need to handle anything manually
|
|
20026
|
-
if (selectionStart !== selectionEnd) {
|
|
20027
|
-
onKeyDown(e);
|
|
20028
|
-
return;
|
|
20029
|
-
}
|
|
20030
|
-
// if user hits backspace, while the cursor is before prefix, and the input has negation, remove the negation
|
|
20031
|
-
if (key === 'Backspace' && value[0] === '-' && selectionStart === prefix.length + 1) {
|
|
20032
|
-
// bring the cursor to after negation
|
|
20033
|
-
setCaretPosition(el, 1);
|
|
20034
|
-
}
|
|
20035
|
-
// don't allow user to delete decimal separator when decimalScale and fixedDecimalScale is set
|
|
20036
|
-
var ref = getSeparators(props);
|
|
20037
|
-
var decimalSeparator = ref.decimalSeparator;
|
|
20038
|
-
var allowedDecimalSeparators = ref.allowedDecimalSeparators;
|
|
20039
|
-
if (key === 'Backspace' &&
|
|
20040
|
-
value[selectionStart - 1] === decimalSeparator &&
|
|
20041
|
-
decimalScale &&
|
|
20042
|
-
fixedDecimalScale) {
|
|
20043
|
-
setCaretPosition(el, selectionStart - 1);
|
|
20044
|
-
e.preventDefault();
|
|
20045
|
-
}
|
|
20046
|
-
// if user presses the allowed decimal separator before the separator, move the cursor after the separator
|
|
20047
|
-
if ((allowedDecimalSeparators === null || allowedDecimalSeparators === void 0 ? void 0 : allowedDecimalSeparators.includes(key)) && value[selectionStart] === decimalSeparator) {
|
|
20048
|
-
setCaretPosition(el, selectionStart + 1);
|
|
20049
|
-
}
|
|
20050
|
-
var _thousandSeparator = thousandSeparator === true ? ',' : thousandSeparator;
|
|
20051
|
-
// move cursor when delete or backspace is pressed before/after thousand separator
|
|
20052
|
-
if (key === 'Backspace' && value[selectionStart - 1] === _thousandSeparator) {
|
|
20053
|
-
setCaretPosition(el, selectionStart - 1);
|
|
20054
|
-
}
|
|
20055
|
-
if (key === 'Delete' && value[selectionStart] === _thousandSeparator) {
|
|
20056
|
-
setCaretPosition(el, selectionStart + 1);
|
|
20057
|
-
}
|
|
20058
|
-
onKeyDown(e);
|
|
20059
|
-
};
|
|
20060
|
-
var _onBlur = function (e) {
|
|
20061
|
-
var _value = numAsString;
|
|
20062
|
-
// if there no no numeric value, clear the input
|
|
20063
|
-
if (!_value.match(/\d/g)) {
|
|
20064
|
-
_value = '';
|
|
20065
|
-
}
|
|
20066
|
-
// clear leading 0s
|
|
20067
|
-
if (!allowLeadingZeros) {
|
|
20068
|
-
_value = fixLeadingZero(_value);
|
|
20069
|
-
}
|
|
20070
|
-
// apply fixedDecimalScale on blur event
|
|
20071
|
-
if (fixedDecimalScale && decimalScale) {
|
|
20072
|
-
_value = roundToPrecision(_value, decimalScale, fixedDecimalScale);
|
|
20073
|
-
}
|
|
20074
|
-
if (_value !== numAsString) {
|
|
20075
|
-
var formattedValue = format(_value, props);
|
|
20076
|
-
_onValueChange({
|
|
20077
|
-
formattedValue: formattedValue,
|
|
20078
|
-
value: _value,
|
|
20079
|
-
floatValue: parseFloat(_value),
|
|
20080
|
-
}, {
|
|
20081
|
-
event: e,
|
|
20082
|
-
source: SourceType.event,
|
|
20083
|
-
});
|
|
20084
|
-
}
|
|
20085
|
-
onBlur(e);
|
|
20086
|
-
};
|
|
20087
|
-
var isValidInputCharacter = function (inputChar) {
|
|
20088
|
-
if (inputChar === decimalSeparator)
|
|
20089
|
-
{ return true; }
|
|
20090
|
-
return charIsNumber(inputChar);
|
|
20091
|
-
};
|
|
20092
|
-
return Object.assign(Object.assign({}, restProps), { value: formattedValue, valueIsNumericString: false, isValidInputCharacter: isValidInputCharacter, onValueChange: _onValueChange, format: _format, removeFormatting: _removeFormatting, getCaretBoundary: function (formattedValue) { return getCaretBoundary(formattedValue, props); }, onKeyDown: _onKeyDown, onBlur: _onBlur });
|
|
20093
|
-
}
|
|
20094
|
-
function NumericFormat(props) {
|
|
20095
|
-
var numericFormatProps = useNumericFormat(props);
|
|
20096
|
-
return React.createElement(NumberFormatBase, Object.assign({}, numericFormatProps));
|
|
20097
|
-
}
|
|
20098
|
-
|
|
20099
19077
|
const TextWidgetBase = ({
|
|
20100
19078
|
id,
|
|
20101
19079
|
onChange,
|