@mighty-justice/utils
Advanced tools
Comparing version 1.4.2 to 1.4.3
import React from 'react'; | ||
import { Argument as IClassName } from 'classnames'; | ||
export interface IDisabledContainerProps { | ||
className?: any; | ||
className?: IClassName; | ||
} | ||
@@ -5,0 +6,0 @@ export interface IGuardedContainerProps { |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { IAddress } from './interfaces'; | ||
@@ -17,3 +18,3 @@ export declare function canReplaceSymbols(template: string, chars: string[]): boolean; | ||
}): any; | ||
export declare function getOrDefault(value?: any): any; | ||
export declare function getOrDefault(value?: unknown): unknown; | ||
export declare function formatSocialSecurityNumber(value?: null | string): string; | ||
@@ -26,3 +27,3 @@ export declare function formatEmployerIdNumber(value?: null | string): string; | ||
export declare function formatCommaSeparatedNumber(value?: null | number | string): string; | ||
export declare function formatDelimitedList(list?: null | string[], delimiter?: string): any; | ||
export declare function formatDelimitedList(list?: null | string[], delimiter?: string): unknown; | ||
export declare function mapBooleanToText(bool?: boolean | null, { mapUndefinedToNo }?: { | ||
@@ -29,0 +30,0 @@ mapUndefinedToNo: boolean; |
@@ -24,5 +24,5 @@ 'use strict'; | ||
var DATE_FORMATS = { | ||
date: 'MM/DD/YY', | ||
date_at_time: 'MM/DD/YY @ h:mmA', | ||
date_value: 'YYYY-MM-DD' | ||
date: 'LL/dd/yy', | ||
date_at_time: 'LL/dd/yy @ h:mma', | ||
date_value: 'yyyy-LL-dd' | ||
}; | ||
@@ -53,5 +53,15 @@ var CENT_DECIMAL = /*#__PURE__*/new Decimal('100'); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -75,24 +85,20 @@ if (!o) return; | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -182,3 +188,3 @@ | ||
return dateFns.format(value, dateFormat); | ||
return dateFns.format(dateFns.parseISO(value), dateFormat); | ||
} | ||
@@ -563,4 +569,9 @@ function formatDateTime(value) { | ||
} | ||
function _convertibleToDecimalObject(value) { | ||
return lodash.isString(value) && value !== '' || lodash.isNumber(value) || Decimal.isDecimal(value); | ||
} | ||
function getPercentValue(value) { | ||
if (typeof value === 'undefined' || value === null || value === '') { | ||
if (!_convertibleToDecimalObject(value)) { | ||
return ''; | ||
@@ -572,3 +583,3 @@ } | ||
function getPercentDisplay(value) { | ||
if (typeof value === 'undefined' || value === null || value === '') { | ||
if (!_convertibleToDecimalObject(value)) { | ||
return ''; | ||
@@ -575,0 +586,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("decimal.js")),t=require("tslib"),n=require("react"),o=e(n),i=require("mobx"),a=require("mobx-react"),u=e(require("classnames")),s=require("iso8601-duration"),p=require("date-fns"),f=e(require("numeral")),c=e(require("html-react-parser")),l=e(require("fast-memoize")),m=require("lodash"),d=e(require("moment")),v={date:"MM/DD/YY",date_at_time:"MM/DD/YY @ h:mmA",date_value:"YYYY-MM-DD"},x=new r("100"),b=/[^A-Za-z]/g,g=/[A-Za-z0-9\u00C0-\u00FF+]+[^\s-]*/g,y=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;function h(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function C(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function D(e,r){return e.split("#").length-1===r.length}function _(e,r){var t=r.reverse();return e.split("").map((function(e){return"#"===e?t.pop():e})).join("")}function S(e){return!!m.isString(e)&&!!e.replace(/ /g,"").length}function N(e){return S(e)||m.isNumber(e)}function j(e,r){if(!S(e))return"--";var t=e.match(/\d/g)||[];if((e.match(/[^0-9\-(). ]/g)||[]).length)return e;for(var n,o=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return C(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?C(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(r);!(n=o()).done;){var i=n.value;if(D(i,t))return _(i,t)}return e}function A(e,r){return void 0===r&&(r=v.date),S(e)?p.format(e,r):"--"}function T(e){var r=void 0===e,t=null===e,n=m.isString(e)&&!S(e);return r||t||n?"--":m.isString(e)?e.trim():e}function M(e){return e.replace(/\n/g,"<br/>")}function O(e){if(e)return e.displayName||e.name||"Component"}function w(e){return e.search(y)>-1}function q(e){var r=e.split(".").pop()||"",t=m.startCase(r).match(g)||[],n=t.length>1;return t.map((function(e,r){return r>0&&n&&w(e)?e.toLowerCase():e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})).join(" ")}var E=l(q);function P(e){if(!e)return"--, --, -- --";var r=m.mapValues(e,(function(e){return e||"--"})),t=r.city,n=r.state,o=r.zip_code;return[r.address1,e.address2].join(" ").trim()+", "+t+", "+n+" "+o}function Y(){return A((new Date).toISOString(),v.date_value)}function I(e){return new Date(e).getTime()>new Date((new Date).toDateString()).getTime()}function L(e){return!e||e.length==="####-##-##".length&&d(e).isValid()}exports.CENT_DECIMAL=x,exports.DATE_FORMATS=v,exports.EMPTY_FIELD="--",exports.RE_ALPHA=b,exports.RE_SMALL_WORDS=y,exports.RE_WORDS=g,exports.canReplaceSymbols=D,exports.createDisabledContainer=function(e){var r=function(r){function t(){return r.apply(this,arguments)||this}return h(t,r),t.prototype.render=function(){var r=u(this.props.className,"disabled");return o.createElement(e,Object.assign({},this.props,{className:r,"data-for":"permission-required","data-tip":!0,"data-tip-disable":!1,onClick:null,onSelect:null}))},t}(n.Component);return r.displayName="DisabledContainer("+O(e)+")",t.__decorate([a.observer],r)},exports.createGuardedContainer=function(e){var r=e.isGuarded,u=e.enabledComponent,s=e.disabledComponent,p=function(e){function t(r){var t;return(t=e.call(this,r)||this).GuardedComponent=t.userHasPermission?u:s,t}var n;return h(t,e),t.prototype.render=function(){return o.createElement(this.GuardedComponent,Object.assign({},this.props))},(n=[{key:"userHasPermission",get:function(){return!r}}])&&function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,n),t}(n.Component);return p.displayName="GuardedContainer("+O(u)+")",t.__decorate([i.computed],p.prototype,"userHasPermission",null),t.__decorate([a.observer],p)},exports.dateToday=Y,exports.formatAddress=P,exports.formatAddressMultiline=function(e){return c(P(e).replace(", ","<br/>"))},exports.formatCommaSeparatedNumber=function(e){return N(e)?f(e).format("0,0"):"--"},exports.formatDate=A,exports.formatDateTime=function(e){return A(e,v.date_at_time)},exports.formatDelimitedList=function(e,r){return void 0===r&&(r=", "),e?T(e.join(r)):"--"},exports.formatDollars=function(e){return N(e)?f(e).format("$0,0"):"--"},exports.formatDuration=function(e){if(!S(e))return"--";var r=Object.entries(s.parse(e));return(r=r.filter((function(e){return e[1]>0}))).map((function(e){var r=e[0],t=e[1];return[1===t?r.slice(0,-1):r,t]})).map((function(e){return e[1]+" "+e[0]})).join(", ")},exports.formatEmployerIdNumber=function(e){return j(e,["##-#######"])},exports.formatFullName=function(e,r){return((e||"")+" "+(r||"")).trim()},exports.formatMoney=function(e){return N(e)?f(e).format("$0,0.00"):"--"},exports.formatMoneyInput=function(e){return N(e)?f(e).value():e},exports.formatNumberTemplates=j,exports.formatParagraphs=function(e){return S(e)?e.split(/\r?\n/).map((function(e,r){return o.createElement("p",{key:r},e)})):"--"},exports.formatPercentage=function(e,r){if(void 0===r&&(r=2),!N(e))return"--";var t="0."+m.times(r,(function(){return"0"})).join("")+"%";return f(e).format(t)},exports.formatPhoneNumber=function(e){return j(e,["###-####","(###) ###-####","+# (###) ###-####","+## (###) ###-####"])},exports.formatSocialSecurityNumber=function(e){return j(e,["####","###-##-####"])},exports.formatWebsite=function(e,r){return S(e)?o.createElement("a",{href:e,rel:"noopener noreferrer",target:"_blank"},r||e):"--"},exports.getDisplayName=O,exports.getInitials=function(e){if(!S(e))return"";var r=e.split(",")[0]||"",t=m.startCase(r),n=t===m.upperCase(t);return(t.match(g)||[]).map((function(e){var r=e===m.upperCase(e);return w(e)?"":r&&!n?e:e.charAt(0).toUpperCase()})).join("").substring(0,3)},exports.getNameOrDefault=function(e,r){var t=void 0===r?{}:r,n=t.field,o=void 0===n?"name":n,i=t.defaultValue,a=void 0===i?"--":i;if(e){if(m.has(e,"first_name"))return(m.result(e,"first_name","")+" "+m.result(e,"last_name","")).trim();if(m.has(e,o))return m.get(e,o)}return a},exports.getOrDefault=T,exports.getPercentDisplay=function(e){return null==e||""===e?"":new r(e).times(x).toString()},exports.getPercentValue=function(e){return null==e||""===e?"":new r(e).div(x).toString()},exports.getType=function(e){return e&&e.split(".")[1]||e},exports.hasStringContent=S,exports.hasStringOrNumberContent=N,exports.inferCentury=function(e){if(2!==e.length)return e;var r=""+Y().substr(0,2)+e,t=""+d().subtract(100,"years").format("YYYY").substr(0,2)+e;return I(r+"-01-01")?t:r},exports.insertIf=function(e,r){return e?[r]:[]},exports.isFutureDate=I,exports.isValidDate=L,exports.isValidPastDate=function(e){return!e||L(e)&&d(e).isBefore(d())},exports.mapBooleanToText=function(e,r){var t=(void 0===r?{mapUndefinedToNo:!1}:r).mapUndefinedToNo;return m.isBoolean(e)?e?"Yes":"No":t&&void 0===e?"No":"--"},exports.parseAndPreserveNewlines=function(e){return S(e)?c(M(m.escape(e))):"--"},exports.pluralize=function(e,r,t){return 1===t?e:""+e+r},exports.preserveNewLines=M,exports.replaceSymbolsWithChars=_,exports.splitCommaList=function(e){return S(e)?-1===e.indexOf(",")?[e.trim()]:e.split(",").map((function(e){return e.trim()})).filter((function(e){return""!==e})):[]},exports.splitName=function(e){if(!S(e))return["",""];var r=e.trim().split(" ");return[r[0],r.slice(1).join(" ").trim()]},exports.stringToHTML=function(e){return c(e)},exports.stripNonAlpha=function(e){return S(e)?e.replace(b,""):""},exports.toKey=function(e){var r=m.sortBy(m.map(e,(function(e,r){return[r,e]}))),t=m.reject(r,(function(e){return null==e[1]}));return t.length<1?"":"?"+t.map((function(e){var r=e[1];return encodeURIComponent(e[0])+"="+encodeURIComponent(r)})).join("&")},exports.varToLabel=E; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("decimal.js")),t=require("tslib"),n=require("react"),o=e(n),i=require("mobx"),a=require("mobx-react"),u=e(require("classnames")),s=require("iso8601-duration"),p=require("date-fns"),f=e(require("numeral")),c=e(require("html-react-parser")),l=e(require("fast-memoize")),m=require("lodash"),d=e(require("moment")),v={date:"LL/dd/yy",date_at_time:"LL/dd/yy @ h:mma",date_value:"yyyy-LL-dd"},x=new r("100"),b=/[^A-Za-z]/g,y=/[A-Za-z0-9\u00C0-\u00FF+]+[^\s-]*/g,g=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;function h(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function C(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _(e,r){return e.split("#").length-1===r.length}function S(e,r){var t=r.reverse();return e.split("").map((function(e){return"#"===e?t.pop():e})).join("")}function D(e){return!!m.isString(e)&&!!e.replace(/ /g,"").length}function N(e){return D(e)||m.isNumber(e)}function j(e,r){if(!D(e))return"--";var t=e.match(/\d/g)||[];if((e.match(/[^0-9\-(). ]/g)||[]).length)return e;for(var n,o=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return C(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?C(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(n=o()).done;){var i=n.value;if(_(i,t))return S(i,t)}return e}function A(e,r){return void 0===r&&(r=v.date),D(e)?p.format(p.parseISO(e),r):"--"}function O(e){var r=void 0===e,t=null===e,n=m.isString(e)&&!D(e);return r||t||n?"--":m.isString(e)?e.trim():e}function L(e){return e.replace(/\n/g,"<br/>")}function T(e){if(e)return e.displayName||e.name||"Component"}function w(e){return e.search(g)>-1}function P(e){var r=e.split(".").pop()||"",t=m.startCase(r).match(y)||[],n=t.length>1;return t.map((function(e,r){return r>0&&n&&w(e)?e.toLowerCase():e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})).join(" ")}var q=l(P);function E(e){if(!e)return"--, --, -- --";var r=m.mapValues(e,(function(e){return e||"--"})),t=r.city,n=r.state,o=r.zip_code;return[r.address1,e.address2].join(" ").trim()+", "+t+", "+n+" "+o}function I(){return A((new Date).toISOString(),v.date_value)}function M(e){return new Date(e).getTime()>new Date((new Date).toDateString()).getTime()}function R(e){return m.isString(e)&&""!==e||m.isNumber(e)||r.isDecimal(e)}function U(e){return!e||e.length==="####-##-##".length&&d(e).isValid()}exports.CENT_DECIMAL=x,exports.DATE_FORMATS=v,exports.EMPTY_FIELD="--",exports.RE_ALPHA=b,exports.RE_SMALL_WORDS=g,exports.RE_WORDS=y,exports.canReplaceSymbols=_,exports.createDisabledContainer=function(e){var r=function(r){function t(){return r.apply(this,arguments)||this}return h(t,r),t.prototype.render=function(){var r=u(this.props.className,"disabled");return o.createElement(e,Object.assign({},this.props,{className:r,"data-for":"permission-required","data-tip":!0,"data-tip-disable":!1,onClick:null,onSelect:null}))},t}(n.Component);return r.displayName="DisabledContainer("+T(e)+")",t.__decorate([a.observer],r)},exports.createGuardedContainer=function(e){var r=e.isGuarded,u=e.enabledComponent,s=e.disabledComponent,p=function(e){function t(r){var t;return(t=e.call(this,r)||this).GuardedComponent=t.userHasPermission?u:s,t}var n;return h(t,e),t.prototype.render=function(){return o.createElement(this.GuardedComponent,Object.assign({},this.props))},(n=[{key:"userHasPermission",get:function(){return!r}}])&&function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,n),t}(n.Component);return p.displayName="GuardedContainer("+T(u)+")",t.__decorate([i.computed],p.prototype,"userHasPermission",null),t.__decorate([a.observer],p)},exports.dateToday=I,exports.formatAddress=E,exports.formatAddressMultiline=function(e){return c(E(e).replace(", ","<br/>"))},exports.formatCommaSeparatedNumber=function(e){return N(e)?f(e).format("0,0"):"--"},exports.formatDate=A,exports.formatDateTime=function(e){return A(e,v.date_at_time)},exports.formatDelimitedList=function(e,r){return void 0===r&&(r=", "),e?O(e.join(r)):"--"},exports.formatDollars=function(e){return N(e)?f(e).format("$0,0"):"--"},exports.formatDuration=function(e){if(!D(e))return"--";var r=Object.entries(s.parse(e));return(r=r.filter((function(e){return e[1]>0}))).map((function(e){var r=e[0],t=e[1];return[1===t?r.slice(0,-1):r,t]})).map((function(e){return e[1]+" "+e[0]})).join(", ")},exports.formatEmployerIdNumber=function(e){return j(e,["##-#######"])},exports.formatFullName=function(e,r){return((e||"")+" "+(r||"")).trim()},exports.formatMoney=function(e){return N(e)?f(e).format("$0,0.00"):"--"},exports.formatMoneyInput=function(e){return N(e)?f(e).value():e},exports.formatNumberTemplates=j,exports.formatParagraphs=function(e){return D(e)?e.split(/\r?\n/).map((function(e,r){return o.createElement("p",{key:r},e)})):"--"},exports.formatPercentage=function(e,r){if(void 0===r&&(r=2),!N(e))return"--";var t="0."+m.times(r,(function(){return"0"})).join("")+"%";return f(e).format(t)},exports.formatPhoneNumber=function(e){return j(e,["###-####","(###) ###-####","+# (###) ###-####","+## (###) ###-####"])},exports.formatSocialSecurityNumber=function(e){return j(e,["####","###-##-####"])},exports.formatWebsite=function(e,r){return D(e)?o.createElement("a",{href:e,rel:"noopener noreferrer",target:"_blank"},r||e):"--"},exports.getDisplayName=T,exports.getInitials=function(e){if(!D(e))return"";var r=e.split(",")[0]||"",t=m.startCase(r),n=t===m.upperCase(t);return(t.match(y)||[]).map((function(e){var r=e===m.upperCase(e);return w(e)?"":r&&!n?e:e.charAt(0).toUpperCase()})).join("").substring(0,3)},exports.getNameOrDefault=function(e,r){var t=void 0===r?{}:r,n=t.field,o=void 0===n?"name":n,i=t.defaultValue,a=void 0===i?"--":i;if(e){if(m.has(e,"first_name"))return(m.result(e,"first_name","")+" "+m.result(e,"last_name","")).trim();if(m.has(e,o))return m.get(e,o)}return a},exports.getOrDefault=O,exports.getPercentDisplay=function(e){return R(e)?new r(e).times(x).toString():""},exports.getPercentValue=function(e){return R(e)?new r(e).div(x).toString():""},exports.getType=function(e){return e&&e.split(".")[1]||e},exports.hasStringContent=D,exports.hasStringOrNumberContent=N,exports.inferCentury=function(e){if(2!==e.length)return e;var r=""+I().substr(0,2)+e,t=""+d().subtract(100,"years").format("YYYY").substr(0,2)+e;return M(r+"-01-01")?t:r},exports.insertIf=function(e,r){return e?[r]:[]},exports.isFutureDate=M,exports.isValidDate=U,exports.isValidPastDate=function(e){return!e||U(e)&&d(e).isBefore(d())},exports.mapBooleanToText=function(e,r){var t=(void 0===r?{mapUndefinedToNo:!1}:r).mapUndefinedToNo;return m.isBoolean(e)?e?"Yes":"No":t&&void 0===e?"No":"--"},exports.parseAndPreserveNewlines=function(e){return D(e)?c(L(m.escape(e))):"--"},exports.pluralize=function(e,r,t){return 1===t?e:""+e+r},exports.preserveNewLines=L,exports.replaceSymbolsWithChars=S,exports.splitCommaList=function(e){return D(e)?-1===e.indexOf(",")?[e.trim()]:e.split(",").map((function(e){return e.trim()})).filter((function(e){return""!==e})):[]},exports.splitName=function(e){if(!D(e))return["",""];var r=e.trim().split(" ");return[r[0],r.slice(1).join(" ").trim()]},exports.stringToHTML=function(e){return c(e)},exports.stripNonAlpha=function(e){return D(e)?e.replace(b,""):""},exports.toKey=function(e){var r=m.sortBy(m.map(e,(function(e,r){return[r,e]}))),t=m.reject(r,(function(e){return null==e[1]}));return t.length<1?"":"?"+t.map((function(e){var r=e[1];return encodeURIComponent(e[0])+"="+encodeURIComponent(r)})).join("&")},exports.varToLabel=q; | ||
//# sourceMappingURL=utils.cjs.production.min.js.map |
@@ -1,3 +0,3 @@ | ||
export declare function insertIf(condition: boolean, element: any): any[]; | ||
export declare function getPercentValue(value?: null | string): string; | ||
export declare function getPercentDisplay(value?: null | string): string; | ||
export declare function insertIf<T>(condition: boolean, element: T): T[]; | ||
export declare function getPercentValue(value?: unknown): string; | ||
export declare function getPercentDisplay(value?: unknown): string; |
@@ -8,3 +8,3 @@ import Decimal from 'decimal.js'; | ||
import { parse } from 'iso8601-duration'; | ||
import { format } from 'date-fns'; | ||
import { format, parseISO } from 'date-fns'; | ||
import numeral from 'numeral'; | ||
@@ -18,5 +18,5 @@ import parser from 'html-react-parser'; | ||
var DATE_FORMATS = { | ||
date: 'MM/DD/YY', | ||
date_at_time: 'MM/DD/YY @ h:mmA', | ||
date_value: 'YYYY-MM-DD' | ||
date: 'LL/dd/yy', | ||
date_at_time: 'LL/dd/yy @ h:mma', | ||
date_value: 'yyyy-LL-dd' | ||
}; | ||
@@ -47,5 +47,15 @@ var CENT_DECIMAL = /*#__PURE__*/new Decimal('100'); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -69,24 +79,20 @@ if (!o) return; | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -176,3 +182,3 @@ | ||
return format(value, dateFormat); | ||
return format(parseISO(value), dateFormat); | ||
} | ||
@@ -557,4 +563,9 @@ function formatDateTime(value) { | ||
} | ||
function _convertibleToDecimalObject(value) { | ||
return isString(value) && value !== '' || isNumber(value) || Decimal.isDecimal(value); | ||
} | ||
function getPercentValue(value) { | ||
if (typeof value === 'undefined' || value === null || value === '') { | ||
if (!_convertibleToDecimalObject(value)) { | ||
return ''; | ||
@@ -566,3 +577,3 @@ } | ||
function getPercentDisplay(value) { | ||
if (typeof value === 'undefined' || value === null || value === '') { | ||
if (!_convertibleToDecimalObject(value)) { | ||
return ''; | ||
@@ -569,0 +580,0 @@ } |
{ | ||
"name": "@mighty-justice/utils", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Standardization of small utilities across Mighty", | ||
@@ -15,4 +15,4 @@ "main": "dist/index.js", | ||
"deploy": "np", | ||
"format": "tsdx lint --fix", | ||
"lint": "tsdx lint", | ||
"format": "tsdx lint --fix src test", | ||
"lint": "tsdx lint src test", | ||
"prepublishOnly": "tsdx build", | ||
@@ -70,13 +70,13 @@ "preversion": "npm run lint", | ||
"@types/classnames": "^2.2.10", | ||
"@types/enzyme": "^3.10.5", | ||
"@types/enzyme": "^3.10.9", | ||
"@types/enzyme-adapter-react-16": "^1.0.6", | ||
"@types/jest": "^26.0.13", | ||
"@types/lodash": "^4.14.161", | ||
"@types/numeral": "^0.0.28", | ||
"@types/react": "16.9.49", | ||
"babel-jest": "^26.3.0", | ||
"coveralls": "^3.1.0", | ||
"@types/jest": "^27.0.1", | ||
"@types/lodash": "^4.14.173", | ||
"@types/numeral": "^2.0.2", | ||
"@types/react": "17.0.22", | ||
"babel-jest": "^27.2.1", | ||
"coveralls": "^3.1.1", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.4", | ||
"lodash": "4.17.20", | ||
"lodash": "4.17.21", | ||
"mobx": "^5.13.0", | ||
@@ -86,14 +86,13 @@ "mobx-react": "^6.1.3", | ||
"numeral": "^2.0.6", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react": "^16", | ||
"react-dom": "^16", | ||
"source-map-explorer": "^2.5.0", | ||
"tsdx": "^0.13.3", | ||
"typescript": "^3.0.0" | ||
"tsdx": "^0.14.1" | ||
}, | ||
"dependencies": { | ||
"classnames": "^2.2.6", | ||
"date-fns": "^1.30.1", | ||
"decimal.js": "^10.1.1", | ||
"date-fns": "^2.24.0", | ||
"decimal.js": "^10.3.1", | ||
"fast-memoize": "^2.5.2", | ||
"html-react-parser": "0.10.0", | ||
"html-react-parser": "1.3.0", | ||
"iso8601-duration": "^1.1.7", | ||
@@ -100,0 +99,0 @@ "moment": "^2.24.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
134311
20
1180
0
+ Added@babel/runtime@7.26.7(transitive)
+ Addeddate-fns@2.30.0(transitive)
+ Addeddom-serializer@1.4.1(transitive)
+ Addeddomhandler@4.2.2(transitive)
+ Addeddomutils@2.8.0(transitive)
+ Addedhtml-dom-parser@1.0.2(transitive)
+ Addedhtml-react-parser@1.3.0(transitive)
+ Addedhtmlparser2@6.1.0(transitive)
+ Addedreact-property@2.0.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedstyle-to-js@1.1.0(transitive)
- Removed@types/domhandler@2.4.1(transitive)
- Removeddate-fns@1.30.1(transitive)
- Removeddom-serializer@0.2.2(transitive)
- Removeddomelementtype@1.3.1(transitive)
- Removeddomhandler@2.4.2(transitive)
- Removeddomutils@1.7.0(transitive)
- Removedentities@1.1.2(transitive)
- Removedhtml-dom-parser@0.2.3(transitive)
- Removedhtml-react-parser@0.10.0(transitive)
- Removedhtmlparser2@3.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedreact-property@1.0.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updateddate-fns@^2.24.0
Updateddecimal.js@^10.3.1
Updatedhtml-react-parser@1.3.0