@mighty-justice/utils
Advanced tools
Comparing version 1.3.9 to 1.4.0
@@ -0,0 +0,0 @@ import Decimal from 'decimal.js'; |
@@ -10,3 +10,3 @@ import React from 'react'; | ||
} | ||
export declare function createDisabledContainer(WrappedComponent: React.ComponentType<any>): React.ReactNode; | ||
export declare function createGuardedContainer({ isGuarded, enabledComponent, disabledComponent }: IGuardedContainerProps): React.ComponentClass; | ||
export declare function createDisabledContainer(WrappedComponent: React.ComponentClass<any>): React.ComponentClass; | ||
export declare function createGuardedContainer({ isGuarded, enabledComponent, disabledComponent, }: IGuardedContainerProps): React.ComponentClass; |
export declare function dateToday(): string; | ||
export declare function isFutureDate(date: string): boolean; | ||
export declare function inferCentury(year: string): string; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { IAddress } from './interfaces'; | ||
@@ -15,4 +14,4 @@ export declare function canReplaceSymbols(template: string, chars: string[]): boolean; | ||
export declare function getNameOrDefault(obj?: unknown, { field, defaultValue }?: { | ||
field?: string | undefined; | ||
defaultValue?: string | undefined; | ||
field?: string; | ||
defaultValue?: string; | ||
}): any; | ||
@@ -31,11 +30,11 @@ export declare function getOrDefault(value?: any): any; | ||
}): "--" | "Yes" | "No"; | ||
export declare function formatMoneyInput(value?: null | number | string): number | null | undefined; | ||
export declare function formatMoneyInput(value?: null | number | string): number; | ||
export declare function formatDuration(iso8601?: null | string): string; | ||
export declare function formatWebsite(website?: string | null, text?: string): (string | JSX.Element); | ||
export declare function formatWebsite(website?: string | null, text?: string): string | JSX.Element; | ||
export declare function stripNonAlpha(str?: string | null): string; | ||
export declare function pluralize(baseWord: string, pluralSuffix: string, count: number): string; | ||
export declare function getType(fullType?: null | string): string | null | undefined; | ||
export declare function getType(fullType?: null | string): string; | ||
export declare function preserveNewLines(body: string): string; | ||
export declare function parseAndPreserveNewlines(body?: string): any; | ||
export declare function getDisplayName(component: any): (string | undefined); | ||
export declare function getDisplayName(component: any): string | undefined; | ||
export declare const varToLabel: (str: string) => string; | ||
@@ -42,0 +41,0 @@ export declare function getInitials(value?: string | null): string; |
declare module 'html-react-parser'; |
@@ -0,0 +0,0 @@ export * from './constants'; |
@@ -0,0 +0,0 @@ export interface IAddress { |
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; |
import Decimal from 'decimal.js'; | ||
import { __decorate } from 'tslib'; | ||
import React, { Component } from 'react'; | ||
@@ -7,7 +8,8 @@ import { computed } from 'mobx'; | ||
import { parse } from 'iso8601-duration'; | ||
import { format, subYears, isValid, isBefore } from 'date-fns'; | ||
import { format } from 'date-fns'; | ||
import numeral from 'numeral'; | ||
import parser from 'html-react-parser'; | ||
import memoize from 'fast-memoize'; | ||
import { isString, isNumber, has, result, get, times, isBoolean, escape, startCase, upperCase, sortBy, map, reject, mapValues } from 'lodash'; | ||
import { isString, isNumber, has, result, get, times, isBoolean, escape, startCase, upperCase, sortBy, map, reject, mapValues } from 'lodash-es'; | ||
import moment from 'moment'; | ||
@@ -18,16 +20,9 @@ var EMPTY_FIELD = '--'; | ||
date_at_time: 'MM/DD/YY @ h:mmA', | ||
// ex. 07/14/16 @ 2:24PM | ||
date_value: 'YYYY-MM-DD' | ||
}; | ||
var CENT_DECIMAL = new Decimal('100'); | ||
var CENT_DECIMAL = /*#__PURE__*/new Decimal('100'); | ||
var RE_ALPHA = /[^A-Za-z]/g; | ||
var RE_WORDS = /[A-Za-z0-9\u00C0-\u00FF\+]+[^\s-]*/g; | ||
var RE_WORDS = /[A-Za-z0-9\u00C0-\u00FF+]+[^\s-]*/g; | ||
var RE_SMALL_WORDS = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
@@ -49,144 +44,48 @@ for (var i = 0; i < props.length; i++) { | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return _setPrototypeOf(o, p); | ||
return arr2; | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
return self; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (typeof call === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
function _toArray(arr) { | ||
return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
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++] | ||
}; | ||
}; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { | ||
var desc = {}; | ||
Object.keys(descriptor).forEach(function (key) { | ||
desc[key] = descriptor[key]; | ||
}); | ||
desc.enumerable = !!desc.enumerable; | ||
desc.configurable = !!desc.configurable; | ||
if ('value' in desc || desc.initializer) { | ||
desc.writable = 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."); | ||
} | ||
desc = decorators.slice().reverse().reduce(function (desc, decorator) { | ||
return decorator(target, property, desc) || desc; | ||
}, desc); | ||
if (context && desc.initializer !== void 0) { | ||
desc.value = desc.initializer ? desc.initializer.call(context) : void 0; | ||
desc.initializer = undefined; | ||
} | ||
if (desc.initializer === void 0) { | ||
Object.defineProperty(target, property, desc); | ||
desc = null; | ||
} | ||
return desc; | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
} | ||
@@ -219,5 +118,4 @@ | ||
var _name$trim$split = name.trim().split(' '), | ||
_name$trim$split2 = _toArray(_name$trim$split), | ||
firstName = _name$trim$split2[0], | ||
lastName = _name$trim$split2.slice(1); | ||
firstName = _name$trim$split[0], | ||
lastName = _name$trim$split.slice(1); | ||
@@ -242,3 +140,3 @@ return [firstName, lastName.join(' ').trim()]; | ||
function formatFullName(firstName, lastName) { | ||
return "".concat(firstName || '', " ").concat(lastName || '').trim(); | ||
return ((firstName || '') + " " + (lastName || '')).trim(); | ||
} | ||
@@ -257,27 +155,8 @@ function formatNumberTemplates(value, templates) { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (var _iterator = _createForOfIteratorHelperLoose(templates), _step; !(_step = _iterator()).done;) { | ||
var template = _step.value; | ||
try { | ||
for (var _iterator = templates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var template = _step.value; | ||
if (canReplaceSymbols(template, valueNumbers)) { | ||
return replaceSymbolsWithChars(template, valueNumbers); | ||
} | ||
if (canReplaceSymbols(template, valueNumbers)) { | ||
return replaceSymbolsWithChars(template, valueNumbers); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
@@ -290,4 +169,6 @@ | ||
} | ||
function formatDate(value) { | ||
var dateFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DATE_FORMATS.date; | ||
function formatDate(value, dateFormat) { | ||
if (dateFormat === void 0) { | ||
dateFormat = DATE_FORMATS.date; | ||
} | ||
@@ -303,4 +184,4 @@ if (!hasStringContent(value)) { | ||
} | ||
function getNameOrDefault(obj) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
function getNameOrDefault(obj, _temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$field = _ref.field, | ||
@@ -313,3 +194,3 @@ field = _ref$field === void 0 ? 'name' : _ref$field, | ||
if (has(obj, 'first_name')) { | ||
return "".concat(result(obj, 'first_name', ''), " ").concat(result(obj, 'last_name', '')).trim(); | ||
return (result(obj, 'first_name', '') + " " + result(obj, 'last_name', '')).trim(); | ||
} | ||
@@ -345,4 +226,6 @@ | ||
} | ||
function formatPercentage(value) { | ||
var decimalPoints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; | ||
function formatPercentage(value, decimalPoints) { | ||
if (decimalPoints === void 0) { | ||
decimalPoints = 2; | ||
} | ||
@@ -356,3 +239,3 @@ if (!hasStringOrNumberContent(value)) { | ||
}).join(''), | ||
formattingString = "0.".concat(zeros, "%"); | ||
formattingString = "0." + zeros + "%"; | ||
return numeral(value).format(formattingString); | ||
@@ -392,4 +275,6 @@ } | ||
} | ||
function formatDelimitedList(list) { | ||
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ', '; | ||
function formatDelimitedList(list, delimiter) { | ||
if (delimiter === void 0) { | ||
delimiter = ', '; | ||
} | ||
@@ -402,6 +287,6 @@ if (!list) { | ||
} | ||
function mapBooleanToText(bool) { | ||
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { | ||
function mapBooleanToText(bool, _temp2) { | ||
var _ref2 = _temp2 === void 0 ? { | ||
mapUndefinedToNo: false | ||
}, | ||
} : _temp2, | ||
mapUndefinedToNo = _ref2.mapUndefinedToNo; | ||
@@ -436,25 +321,17 @@ | ||
unitCounts = unitCounts.filter(function (_ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 2), | ||
_unit = _ref4[0], | ||
count = _ref4[1]; | ||
var count = _ref3[1]; | ||
return count > 0; | ||
}); // De-pluralize keys for entries of 1 | ||
var unitCountsHuman = unitCounts.map(function (_ref5) { | ||
var _ref6 = _slicedToArray(_ref5, 2), | ||
unit = _ref6[0], | ||
count = _ref6[1]; | ||
var unitCountsHuman = unitCounts.map(function (_ref4) { | ||
var unit = _ref4[0], | ||
count = _ref4[1]; | ||
return [// tslint:disable-next-line no-magic-numbers | ||
count === 1 ? unit.slice(0, -1) : unit, // de-pluralize single count units | ||
count]; | ||
count === 1 ? unit.slice(0, -1) : unit, count]; | ||
}); // Join into string | ||
return unitCountsHuman.map(function (_ref7) { | ||
var _ref8 = _slicedToArray(_ref7, 2), | ||
unit = _ref8[0], | ||
count = _ref8[1]; | ||
return "".concat(count, " ").concat(unit); | ||
return unitCountsHuman.map(function (_ref5) { | ||
var unit = _ref5[0], | ||
count = _ref5[1]; | ||
return count + " " + unit; | ||
}).join(', '); | ||
@@ -481,3 +358,3 @@ } | ||
function pluralize(baseWord, pluralSuffix, count) { | ||
return count === 1 ? baseWord : "".concat(baseWord).concat(pluralSuffix); | ||
return count === 1 ? baseWord : "" + baseWord + pluralSuffix; | ||
} | ||
@@ -526,3 +403,3 @@ function getType(fullType) { | ||
var varToLabel = memoize(_varToLabel); | ||
var varToLabel = /*#__PURE__*/memoize(_varToLabel); | ||
function getInitials(value) { | ||
@@ -556,7 +433,4 @@ if (!hasStringContent(value)) { | ||
})), | ||
dictFiltered = reject(dictSorted, function (_ref9) { | ||
var _ref10 = _slicedToArray(_ref9, 2), | ||
_key = _ref10[0], | ||
value = _ref10[1]; | ||
dictFiltered = reject(dictSorted, function (_ref6) { | ||
var value = _ref6[1]; | ||
return value === null || value === undefined; | ||
@@ -569,10 +443,8 @@ }); | ||
var dictString = dictFiltered.map(function (_ref11) { | ||
var _ref12 = _slicedToArray(_ref11, 2), | ||
key = _ref12[0], | ||
value = _ref12[1]; | ||
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)); | ||
var dictString = dictFiltered.map(function (_ref7) { | ||
var key = _ref7[0], | ||
value = _ref7[1]; | ||
return encodeURIComponent(key) + "=" + encodeURIComponent(value); | ||
}).join('&'); | ||
return "?".concat(dictString); | ||
return "?" + dictString; | ||
} | ||
@@ -593,3 +465,3 @@ function formatAddress(address) { | ||
joinedAddress = [address1, address2].join(' ').trim(); | ||
return "".concat(joinedAddress, ", ").concat(city, ", ").concat(state, " ").concat(zip_code); | ||
return joinedAddress + ", " + city + ", " + state + " " + zip_code; | ||
} | ||
@@ -601,33 +473,28 @@ function formatAddressMultiline(address) { | ||
function createDisabledContainer(WrappedComponent) { | ||
var _class, _class2, _temp; | ||
var DisabledContainer = /*#__PURE__*/function (_Component) { | ||
_inheritsLoose(DisabledContainer, _Component); | ||
var DisabledContainer = observer(_class = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(DisabledContainer, _Component); | ||
function DisabledContainer() { | ||
_classCallCheck(this, DisabledContainer); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(DisabledContainer).apply(this, arguments)); | ||
return _Component.apply(this, arguments) || this; | ||
} | ||
_createClass(DisabledContainer, [{ | ||
key: "render", | ||
value: function render() { | ||
var classNames = cx(this.props.className, 'disabled'); | ||
return React.createElement(WrappedComponent, _extends({}, this.props, { | ||
className: classNames, | ||
"data-for": "permission-required", | ||
"data-tip": true, | ||
"data-tip-disable": false, | ||
onClick: null, | ||
onSelect: null | ||
})); | ||
} | ||
}]); | ||
var _proto = DisabledContainer.prototype; | ||
_proto.render = function render() { | ||
var classNames = cx(this.props.className, 'disabled'); | ||
return React.createElement(WrappedComponent, Object.assign({}, this.props, { | ||
className: classNames, | ||
"data-for": "permission-required", | ||
"data-tip": true, | ||
"data-tip-disable": false, | ||
onClick: null, | ||
onSelect: null | ||
})); | ||
}; | ||
return DisabledContainer; | ||
}(Component), _class2.displayName = "DisabledContainer(".concat(getDisplayName(WrappedComponent), ")"), _temp)) || _class; | ||
}(Component); | ||
DisabledContainer.displayName = "DisabledContainer(" + getDisplayName(WrappedComponent) + ")"; | ||
DisabledContainer = __decorate([observer], DisabledContainer); | ||
return DisabledContainer; | ||
@@ -637,4 +504,2 @@ } // tslint:disable-next-line max-line-length | ||
function createGuardedContainer(_ref) { | ||
var _class3, _class4, _class5, _temp2; | ||
var isGuarded = _ref.isGuarded, | ||
@@ -644,6 +509,4 @@ enabledComponent = _ref.enabledComponent, | ||
var GuardedContainer = observer(_class3 = (_class4 = (_temp2 = _class5 = | ||
/*#__PURE__*/ | ||
function (_Component2) { | ||
_inherits(GuardedContainer, _Component2); | ||
var GuardedContainer = /*#__PURE__*/function (_Component2) { | ||
_inheritsLoose(GuardedContainer, _Component2); | ||
@@ -653,6 +516,3 @@ function GuardedContainer(props) { | ||
_classCallCheck(this, GuardedContainer); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(GuardedContainer).call(this, props)); | ||
_this.GuardedComponent = void 0; | ||
_this = _Component2.call(this, props) || this; | ||
_this.GuardedComponent = _this.userHasPermission ? enabledComponent : disabledComponent; | ||
@@ -662,8 +522,9 @@ return _this; | ||
var _proto2 = GuardedContainer.prototype; | ||
_proto2.render = function render() { | ||
return React.createElement(this.GuardedComponent, Object.assign({}, this.props)); | ||
}; | ||
_createClass(GuardedContainer, [{ | ||
key: "render", | ||
value: function render() { | ||
return React.createElement(this.GuardedComponent, this.props); | ||
} | ||
}, { | ||
key: "userHasPermission", | ||
@@ -676,4 +537,9 @@ get: function get() { | ||
return GuardedContainer; | ||
}(Component), _class5.displayName = "GuardedContainer(".concat(getDisplayName(enabledComponent), ")"), _temp2), (_applyDecoratedDescriptor(_class4.prototype, "userHasPermission", [computed], Object.getOwnPropertyDescriptor(_class4.prototype, "userHasPermission"), _class4.prototype)), _class4)) || _class3; | ||
}(Component); | ||
GuardedContainer.displayName = "GuardedContainer(" + getDisplayName(enabledComponent) + ")"; | ||
__decorate([computed], GuardedContainer.prototype, "userHasPermission", null); | ||
GuardedContainer = __decorate([observer], GuardedContainer); | ||
return GuardedContainer; | ||
@@ -694,7 +560,7 @@ } | ||
var thisCentury = dateToday().substr(0, 2), | ||
lastCentury = format(subYears(new Date(), 100), 'YYYY').substr(0, 2), | ||
thisCenturyGuess = "".concat(thisCentury).concat(year), | ||
lastCenturyGuess = "".concat(lastCentury).concat(year); | ||
lastCentury = moment().subtract(100, 'years').format('YYYY').substr(0, 2), | ||
thisCenturyGuess = "" + thisCentury + year, | ||
lastCenturyGuess = "" + lastCentury + year; | ||
if (isFutureDate("".concat(thisCenturyGuess, "-01-01"))) { | ||
if (isFutureDate(thisCenturyGuess + "-01-01")) { | ||
return lastCenturyGuess; | ||
@@ -725,8 +591,8 @@ } | ||
function isValidDate(value) { | ||
return !value || value.length === '####-##-##'.length // ISO date | ||
&& isValid(new Date(value)) // Real day | ||
return !value || value.length === '####-##-##'.length && // ISO date | ||
moment(value).isValid() // Real day | ||
; | ||
} | ||
function isValidPastDate(value) { | ||
return !value || isValidDate(value) && isBefore(value, new Date()) // In the past | ||
return !value || isValidDate(value) && moment(value).isBefore(moment()) // In the past | ||
; | ||
@@ -736,1 +602,2 @@ } | ||
export { CENT_DECIMAL, DATE_FORMATS, EMPTY_FIELD, RE_ALPHA, RE_SMALL_WORDS, RE_WORDS, canReplaceSymbols, createDisabledContainer, createGuardedContainer, dateToday, formatAddress, formatAddressMultiline, formatCommaSeparatedNumber, formatDate, formatDateTime, formatDelimitedList, formatDollars, formatDuration, formatEmployerIdNumber, formatFullName, formatMoney, formatMoneyInput, formatNumberTemplates, formatParagraphs, formatPercentage, formatPhoneNumber, formatSocialSecurityNumber, formatWebsite, getDisplayName, getInitials, getNameOrDefault, getOrDefault, getPercentDisplay, getPercentValue, getType, hasStringContent, hasStringOrNumberContent, inferCentury, insertIf, isFutureDate, isValidDate, isValidPastDate, mapBooleanToText, parseAndPreserveNewlines, pluralize, preserveNewLines, replaceSymbolsWithChars, splitCommaList, splitName, stripNonAlpha, toKey, varToLabel }; | ||
//# sourceMappingURL=utils.esm.js.map |
export declare function isValidDate(value: string): boolean; | ||
export declare function isValidPastDate(value: string): boolean; |
113
package.json
{ | ||
"name": "@mighty-justice/utils", | ||
"version": "1.3.9", | ||
"version": "1.4.0", | ||
"description": "Standardization of small utilities across Mighty", | ||
"main": "dist/utils.cjs.js", | ||
"module": "dist/utils.esm.js", | ||
"browser": "dist/utils.umd.js", | ||
"types": "dist/index.d.ts", | ||
"main": "dist/index.js", | ||
"module": "dist/tester.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"publishConfig": { | ||
@@ -13,14 +12,11 @@ "access": "public" | ||
"scripts": { | ||
"build": "npm run build:clean && npm run build:types && npm run build:js", | ||
"build:clean": "rm -r dist/* || true", | ||
"build:js": "rollup -c", | ||
"build:types": "yarn tsc --emitDeclarationOnly", | ||
"build": "tsdx build", | ||
"deploy": "np", | ||
"dev": "rollup -c -w", | ||
"lint": "tslint --project .", | ||
"format": "tsdx lint --fix", | ||
"lint": "tsdx lint", | ||
"prepublishOnly": "tsdx build", | ||
"preversion": "npm run lint", | ||
"test": "jest", | ||
"test:watch": "npm run test/*.js -- -w", | ||
"version": "npm run build && git add dist", | ||
"view-source-map": "source-map-explorer --html dist/index.js dist/index.map > source.html && open source.html" | ||
"start": "tsdx watch", | ||
"test": "tsdx test", | ||
"version": "npm run build && git add dist" | ||
}, | ||
@@ -43,20 +39,18 @@ "repository": { | ||
"homepage": "https://mighty-justice.github.io/utils/", | ||
"prettier": { | ||
"printWidth": 120, | ||
"proseWrap": "always", | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
}, | ||
"jest": { | ||
"testPathIgnorePatterns": [ | ||
"/_book/", | ||
"/node_modules/" | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.tsx", | ||
"src/**/*.ts" | ||
], | ||
"transform": { | ||
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest" | ||
}, | ||
"moduleFileExtensions": [ | ||
"js", | ||
"jsx", | ||
"ts", | ||
"tsx" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"./test/setup.ts" | ||
], | ||
"testURL": "http://localhost/" | ||
] | ||
}, | ||
@@ -73,30 +67,16 @@ "files": [ | ||
}, | ||
"resolutions": { | ||
"babel-core": "7.0.0-bridge.0" | ||
}, | ||
"resolutions": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.3.4", | ||
"@babel/plugin-proposal-class-properties": "^7.3.4", | ||
"@babel/plugin-proposal-decorators": "^7.3.0", | ||
"@babel/plugin-proposal-export-default-from": "^7.2.0", | ||
"@babel/plugin-proposal-optional-chaining": "^7.2.0", | ||
"@babel/polyfill": "^7.2.5", | ||
"@babel/preset-env": "^7.3.4", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@mighty-justice/tslint-config": "^0.3.0", | ||
"@types/classnames": "^2.2.7", | ||
"@types/enzyme": "^3.9.0", | ||
"@types/enzyme-adapter-react-16": "^1.0.5", | ||
"@types/jest": "^25.1.0", | ||
"@types/lodash": "^4.14.122", | ||
"@types/numeral": "^0.0.26", | ||
"@types/react": "16.9.19", | ||
"babelrc-rollup": "^3.0.0", | ||
"coveralls": "^3.0.3", | ||
"enzyme": "^3.9.0", | ||
"enzyme-adapter-react-16": "^1.10.0", | ||
"jest": "^24.1.0", | ||
"jest-environment-jsdom": "^25.1.0", | ||
"lodash": "4.17.15", | ||
"@types/classnames": "^2.2.10", | ||
"@types/enzyme": "^3.10.5", | ||
"@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", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.4", | ||
"lodash": "4.17.20", | ||
"mobx": "^5.13.0", | ||
@@ -106,14 +86,6 @@ "mobx-react": "^6.1.3", | ||
"numeral": "^2.0.6", | ||
"react": "16.12.0", | ||
"react-dom": "^16.8.3", | ||
"regenerator-runtime": "^0.13.1", | ||
"rollup": "^1.4.1", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-json": "^4.0.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-peer-deps-external": "^2.2.0", | ||
"source-map-explorer": "^2.0.1", | ||
"tslint": "^5.13.1", | ||
"typescript": "^3.3.3333" | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"tsdx": "^0.13.3", | ||
"typescript": "^3.0.0" | ||
}, | ||
@@ -124,7 +96,8 @@ "dependencies": { | ||
"decimal.js": "^10.1.1", | ||
"fast-memoize": "^2.5.1", | ||
"html-react-parser": "^0.13.0", | ||
"fast-memoize": "^2.5.2", | ||
"html-react-parser": "0.10.0", | ||
"iso8601-duration": "^1.1.7", | ||
"moment": "^2.24.0", | ||
"numeral": "^2.0.6" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
20
19
1
131597
12
1155
2
+ Addedmoment@^2.24.0
+ Addedhtml-dom-parser@0.2.3(transitive)
+ Addedhtml-react-parser@0.10.0(transitive)
+ Addedmoment@2.30.1(transitive)
- Removed@types/domhandler@2.4.53.1.0(transitive)
- Removed@types/domutils@1.7.8(transitive)
- Removed@types/htmlparser2@3.10.1(transitive)
- Removed@types/node@22.12.0(transitive)
- Removeddomhandler@5.0.3(transitive)
- Removedhtml-dom-parser@0.3.0(transitive)
- Removedhtml-react-parser@0.13.0(transitive)
- Removedundici-types@6.20.0(transitive)
Updatedfast-memoize@^2.5.2
Updatedhtml-react-parser@0.10.0