@equisoft/design-elements-react 9.11.4-snapshot.20260210134257 → 9.11.4-snapshot.20260210185541

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bundle.js +1 -1
  2. package/package.json +1 -1
package/dist/bundle.js CHANGED
@@ -2598,7 +2598,7 @@
2598
2598
  text-align: ${({$textAlignment:e})=>e};
2599
2599
  width: 132px;
2600
2600
  }
2601
- `;function Aw(e,t,r,n){return null===e?"":function(e,t,r,n="CAD"){return Intl.NumberFormat(r,{style:"currency",currency:n,minimumFractionDigits:t,maximumFractionDigits:t,currencyDisplay:"narrowSymbol"}).format(e)}(e,t,r,n)}function Lw(e,t){return null===e||Number.isNaN(e)?null:Math.round(e*Math.pow(10,t))/Math.pow(10,t)}function Iw(e,t){return""===e?null:Lw(Number(e.replace(",",".")),t)}const Vw=r=>{var{id:n,className:o,readOnly:a,required:i,disabled:l,label:s,onChange:c,precision:d=2,value:u=null,validationErrorMessage:p,locale:m,currency:h="CAD",hint:f,noMargin:g,textAlignment:b="left",toggletip:v}=r,y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(r,["id","className","readOnly","required","disabled","label","onChange","precision","value","validationErrorMessage","locale","currency","hint","noMargin","textAlignment","toggletip"]);const{i18n:_,t:x}=D("money-input"),k=null!=m?m:function(e,t){if(!e.match(/^[a-z]{2}-[a-z]{2}$/i))switch(t.toUpperCase()){case"CAD":return`${e}-CA`;case"USD":return`${e}-US`}return e}(_.language,h),w=(0,t.useRef)(null),[M,S]=(0,t.useState)(Aw(u,d,k,h)),[E,C]=(0,t.useState)(Aw(u,d,k,h)),[O,$]=(0,t.useState)(!1),z=$t(y),R=(0,t.useCallback)(e=>{const t=Iw(e,d),r=Aw(t,d,k,h);S(r),E!==r&&(C(r),null==c||c(t,r))},[h,k,E,c,d]);u&&!O&&M!==Aw(u,d,k,h)&&R(u.toString()),(0,t.useEffect)(()=>{null!=w.current&&(O||M===E||R(w.current.value))},[O,M,E,R]),(0,t.useEffect)(()=>{var e;O&&(null===(e=w.current)||void 0===e||e.select())},[O]);const j=(0,t.useCallback)(()=>{$(!1)},[$]),F=(0,t.useCallback)(()=>{const e=Lw(u,d),t=null===e?"":e.toString();S(t),$(!0)},[$,d,u]),N=(0,t.useCallback)(e=>{const t=e.target.value.replace(/[^0-9.,]/g,"");e.preventDefault(),S(t);const r=Iw(t,d),n=Aw(r,d,k,h);null==c||c(r,n)},[h,k,c,d]);return(0,e.jsx)(Tw,Object.assign({$textAlignment:b,id:n,className:o,readOnly:a,required:i,disabled:l,ref:w,type:"text",inputMode:"numeric",value:M,label:s,onChange:N,onBlur:j,onFocus:F,validationErrorMessage:p||x("validationErrorMessage"),hint:f,noMargin:g,toggletip:v},z))};Vw.displayName="MoneyInput";const Hw=`[${[".",","].join("")}]`;function Uw(e,t){return e?e.replace(new RegExp(`${Hw}(?!.*${Hw})`),t):e}function Bw(e){return Uw(e,".")}function qw(e,t){if(""===e||"-"===e)return!0;const r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^-?\\d*(${r}?\\d*)?$`).test(e)}const Yw=e=>({value:e,valueAsNumber:""===e?null:Number(Bw(e))});function Ww({defaultValue:e,max:r,min:n,onBlur:o,onChange:a,precision:i,required:l,invalid:s,validationErrorMessage:c,value:d}){var u;const{t:p,i18n:m}=D("numeric-input"),h=(0,t.useMemo)(()=>function(e){try{const t=new Intl.NumberFormat(e).formatToParts(1.1).find(e=>"decimal"===e.type);return(null==t?void 0:t.value)||"."}catch(t){return console.warn(`Could not determine decimal separator for locale "${e}", defaulting to '.'.`,t),"."}}(m.language),[m.language]),f=(0,t.useCallback)(e=>Uw(e,h),[h]),g=(0,t.useCallback)(e=>{if("number"==typeof(t=e)&&Number.isFinite(t))return f(e.toString());var t;if("string"==typeof e){const t=Bw(e);if(qw(t,"."))return f(t)}return console.warn(`Invalid value passed to NumericInput: ${e}`),""},[f]),[b,v]=(0,t.useState)(g(null!==(u=null!=d?d:e)&&void 0!==u?u:"")),y=(0,t.useCallback)((e,t)=>{if(""===e&&l&&!0!==(null==t?void 0:t.skipRequired))return"required";if(""!==e){const t=Bw(e),o=Number(t);if(void 0!==r&&o>r)return"max";if(void 0!==n&&o<n)return"min"}},[r,n,l]),[_,x]=(0,t.useState)(y(b,{skipRequired:!0})),k=(0,t.useCallback)(e=>{const t=y(e);x(t)},[y]),w=(0,t.useCallback)(e=>{e.preventDefault();let t=Uw(function(e){const t=e.clipboardData.getData("text/plain").trim(),r=e.currentTarget,n=r.selectionStart||0,o=r.selectionEnd||0;return function(e,t,r,n){if(t>r||t<0||r>e.length)throw new Error("Invalid index range");return e.slice(0,t)+n+e.slice(r)}(r.value,n,o,t)}(e),h);if(qw(t,h)){if(void 0!==i){const e=mi(Bw(t),i);t=f(e)}}else t=b;qw(t,h)||(t=""),v(t),null==a||a(function(e,t){return Object.assign(Object.assign({},e),{currentTarget:Object.assign(Object.assign({},e.currentTarget),{value:t}),target:Object.assign(Object.assign(Object.assign({},e.currentTarget),e.target),{value:t})})}(e,t),Yw(t)),k(t)},[a,i,h,b,f,k]),M=(0,t.useCallback)(e=>{const t=e.target.value;if(""!==t){if(!qw(t,h))return;if(void 0!==i&&!function(e,t){var r;return!(0===t&&e.includes(".")||t>0&&(null===(r=e.split(".")[1])||void 0===r?void 0:r.length)>t)}(Bw(t),i))return}v(t),null==a||a(e,Yw(t)),void 0===s&&k(t)},[a,i,h,k,s]),S=(0,t.useCallback)(e=>{let t=function(e,t){if(e===t||e===`-${t}`)return"";const r=Bw(e);if(""===r||Number.isNaN(Number(r)))return"";let n=r;return n.endsWith(".")&&(n=n.slice(0,-1)),n.startsWith(".")?n=`0${n}`:n.startsWith("-.")&&(n=`-0${n.substring(1)}`),""===n?"":Uw(n,t)}(e.target.value,h);if(void 0!==i&&""!==t){const e=mi(Bw(t),i);t=f(e)}v(t),l&&""===t?x(y(t)):k(t),null==o||o(e,Yw(t))},[o,l,k,h,i,f,y]),E=(0,t.useCallback)(()=>{void 0===s&&k(b)},[b,s,k]);if(void 0!==d){const e=g(d);e!==b&&(v(e),void 0===s&&k(e))}const C=null!=s?s:void 0!==_,O=null!=c?c:(()=>{switch(_){case"required":return p("requiredValidationErrorMessage");case"max":return p("maxValidationErrorMessage",{max:r});case"min":return p("minValidationErrorMessage",{min:n});default:return}})();return{max:r,min:n,onBlurHandler:S,onChangeHandler:M,onPasteHandler:w,onInvalid:E,precision:i,required:l,invalid:C,validationErrorMessage:O,value:b}}const Gw=a()(Pw)`
2601
+ `;function Aw(e,t,r,n){return null===e?"":function(e,t,r,n="CAD"){return Intl.NumberFormat(r,{style:"currency",currency:n,minimumFractionDigits:t,maximumFractionDigits:t,currencyDisplay:"narrowSymbol"}).format(e)}(e,t,r,n)}function Lw(e,t){return null===e||Number.isNaN(e)?null:Math.round(e*Math.pow(10,t))/Math.pow(10,t)}function Iw(e,t){return""===e?null:Lw(Number(e.replace(",",".")),t)}const Vw=r=>{var{id:n,className:o,readOnly:a,required:i,disabled:l,label:s,onChange:c,precision:d=2,value:u=null,validationErrorMessage:p,locale:m,currency:h="CAD",hint:f,noMargin:g,textAlignment:b="left",toggletip:v}=r,y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(r,["id","className","readOnly","required","disabled","label","onChange","precision","value","validationErrorMessage","locale","currency","hint","noMargin","textAlignment","toggletip"]);const{i18n:_,t:x}=D("money-input"),k=null!=m?m:function(e,t){if(!e.match(/^[a-z]{2}-[a-z]{2}$/i))switch(t.toUpperCase()){case"CAD":return`${e}-CA`;case"USD":return`${e}-US`}return e}(_.language,h),w=(0,t.useRef)(null),[M,S]=(0,t.useState)(Aw(u,d,k,h)),[E,C]=(0,t.useState)(Aw(u,d,k,h)),[O,$]=(0,t.useState)(!1),z=$t(y),R=(0,t.useCallback)(e=>{const t=Iw(e,d),r=Aw(t,d,k,h);S(r),E!==r&&(C(r),null==c||c(t,r))},[h,k,E,c,d]);null===u||O||M===Aw(u,d,k,h)||R(u.toString()),(0,t.useEffect)(()=>{null!=w.current&&(O||M===E||R(w.current.value))},[O,M,E,R]),(0,t.useEffect)(()=>{var e;O&&(null===(e=w.current)||void 0===e||e.select())},[O]);const j=(0,t.useCallback)(()=>{$(!1)},[$]),F=(0,t.useCallback)(()=>{const e=Lw(u,d),t=null===e?"":e.toString();S(t),$(!0)},[$,d,u]),N=(0,t.useCallback)(e=>{const t=e.target.value.replace(/[^0-9.,]/g,"");e.preventDefault(),S(t);const r=Iw(t,d),n=Aw(r,d,k,h);null==c||c(r,n)},[h,k,c,d]);return(0,e.jsx)(Tw,Object.assign({$textAlignment:b,id:n,className:o,readOnly:a,required:i,disabled:l,ref:w,type:"text",inputMode:"numeric",value:M,label:s,onChange:N,onBlur:j,onFocus:F,validationErrorMessage:p||x("validationErrorMessage"),hint:f,noMargin:g,toggletip:v},z))};Vw.displayName="MoneyInput";const Hw=`[${[".",","].join("")}]`;function Uw(e,t){return e?e.replace(new RegExp(`${Hw}(?!.*${Hw})`),t):e}function Bw(e){return Uw(e,".")}function qw(e,t){if(""===e||"-"===e)return!0;const r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^-?\\d*(${r}?\\d*)?$`).test(e)}const Yw=e=>({value:e,valueAsNumber:""===e?null:Number(Bw(e))});function Ww({defaultValue:e,max:r,min:n,onBlur:o,onChange:a,precision:i,required:l,invalid:s,validationErrorMessage:c,value:d}){var u;const{t:p,i18n:m}=D("numeric-input"),h=(0,t.useMemo)(()=>function(e){try{const t=new Intl.NumberFormat(e).formatToParts(1.1).find(e=>"decimal"===e.type);return(null==t?void 0:t.value)||"."}catch(t){return console.warn(`Could not determine decimal separator for locale "${e}", defaulting to '.'.`,t),"."}}(m.language),[m.language]),f=(0,t.useCallback)(e=>Uw(e,h),[h]),g=(0,t.useCallback)(e=>{if("number"==typeof(t=e)&&Number.isFinite(t))return f(e.toString());var t;if("string"==typeof e){const t=Bw(e);if(qw(t,"."))return f(t)}return console.warn(`Invalid value passed to NumericInput: ${e}`),""},[f]),[b,v]=(0,t.useState)(g(null!==(u=null!=d?d:e)&&void 0!==u?u:"")),y=(0,t.useCallback)((e,t)=>{if(""===e&&l&&!0!==(null==t?void 0:t.skipRequired))return"required";if(""!==e){const t=Bw(e),o=Number(t);if(void 0!==r&&o>r)return"max";if(void 0!==n&&o<n)return"min"}},[r,n,l]),[_,x]=(0,t.useState)(y(b,{skipRequired:!0})),k=(0,t.useCallback)(e=>{const t=y(e);x(t)},[y]),w=(0,t.useCallback)(e=>{e.preventDefault();let t=Uw(function(e){const t=e.clipboardData.getData("text/plain").trim(),r=e.currentTarget,n=r.selectionStart||0,o=r.selectionEnd||0;return function(e,t,r,n){if(t>r||t<0||r>e.length)throw new Error("Invalid index range");return e.slice(0,t)+n+e.slice(r)}(r.value,n,o,t)}(e),h);if(qw(t,h)){if(void 0!==i){const e=mi(Bw(t),i);t=f(e)}}else t=b;qw(t,h)||(t=""),v(t),null==a||a(function(e,t){return Object.assign(Object.assign({},e),{currentTarget:Object.assign(Object.assign({},e.currentTarget),{value:t}),target:Object.assign(Object.assign(Object.assign({},e.currentTarget),e.target),{value:t})})}(e,t),Yw(t)),k(t)},[a,i,h,b,f,k]),M=(0,t.useCallback)(e=>{const t=e.target.value;if(""!==t){if(!qw(t,h))return;if(void 0!==i&&!function(e,t){var r;return!(0===t&&e.includes(".")||t>0&&(null===(r=e.split(".")[1])||void 0===r?void 0:r.length)>t)}(Bw(t),i))return}v(t),null==a||a(e,Yw(t)),void 0===s&&k(t)},[a,i,h,k,s]),S=(0,t.useCallback)(e=>{let t=function(e,t){if(e===t||e===`-${t}`)return"";const r=Bw(e);if(""===r||Number.isNaN(Number(r)))return"";let n=r;return n.endsWith(".")&&(n=n.slice(0,-1)),n.startsWith(".")?n=`0${n}`:n.startsWith("-.")&&(n=`-0${n.substring(1)}`),""===n?"":Uw(n,t)}(e.target.value,h);if(void 0!==i&&""!==t){const e=mi(Bw(t),i);t=f(e)}v(t),l&&""===t?x(y(t)):k(t),null==o||o(e,Yw(t))},[o,l,k,h,i,f,y]),E=(0,t.useCallback)(()=>{void 0===s&&k(b)},[b,s,k]);if(void 0!==d){const e=g(d);e!==b&&(v(e),void 0===s&&k(e))}const C=null!=s?s:void 0!==_,O=null!=c?c:(()=>{switch(_){case"required":return p("requiredValidationErrorMessage");case"max":return p("maxValidationErrorMessage",{max:r});case"min":return p("minValidationErrorMessage",{min:n});default:return}})();return{max:r,min:n,onBlurHandler:S,onChangeHandler:M,onPasteHandler:w,onInvalid:E,precision:i,required:l,invalid:C,validationErrorMessage:O,value:b}}const Gw=a()(Pw)`
2602
2602
  .${zw.control} {
2603
2603
  text-align: ${({$textAlign:e})=>e};
2604
2604
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equisoft/design-elements-react",
3
- "version": "9.11.4-snapshot.20260210134257",
3
+ "version": "9.11.4-snapshot.20260210185541",
4
4
  "description": "React implementation of the Equisoft design system.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/bundle.js",