gl-w-frontend
Advanced tools
Comparing version 3.4.0 to 4.0.0
@@ -25,2 +25,3 @@ export * from './scripts/core/services/array/core-services-array.service'; | ||
export * from './scripts/core/services/menu/core-services-menu.interfaces'; | ||
export * from './scripts/core/services/number/core-services-number-interface'; | ||
export * from './scripts/core/services/string/core-services-string-interface'; | ||
@@ -27,0 +28,0 @@ export * from './scripts/services/export/excel/services-export-excel.interface'; |
@@ -25,2 +25,3 @@ export * from './scripts/core/services/array/core-services-array.service'; | ||
export * from './scripts/core/services/menu/core-services-menu.interfaces'; | ||
export * from './scripts/core/services/number/core-services-number-interface'; | ||
export * from './scripts/core/services/string/core-services-string-interface'; | ||
@@ -27,0 +28,0 @@ export * from './scripts/services/export/excel/services-export-excel.interface'; |
export * from './bundle'; |
export * from './bundle'; | ||
//# sourceMappingURL=index.js.map |
@@ -0,0 +0,0 @@ declare class Remove { |
@@ -0,0 +0,0 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
@@ -0,0 +0,0 @@ export interface IAttachmentData { |
export {}; | ||
//# sourceMappingURL=core-services-attachment.interface.js.map |
@@ -0,0 +0,0 @@ import { IAttachmentData, IAttachmentFileInfo } from './core-services-attachment.interface'; |
@@ -0,0 +0,0 @@ class Convert { |
@@ -0,0 +0,0 @@ export interface IFullscreenResult { |
export {}; | ||
//# sourceMappingURL=core-services-browser.interface.js.map |
@@ -0,0 +0,0 @@ import { IFullScreenAlt, IFullScreenSrc, IMenuButton } from '../menu/core-services-menu.interfaces'; |
@@ -0,0 +0,0 @@ import * as screenfull from 'screenfull'; |
@@ -0,0 +0,0 @@ export interface IComboBoxData { |
export {}; | ||
//# sourceMappingURL=core-services-combobox.interface.js.map |
@@ -0,0 +0,0 @@ import { IComboBoxData } from './core-services-combobox.interface'; |
@@ -0,0 +0,0 @@ import { ElementRemove } from '../elements/core-services-elements.service'; |
@@ -0,0 +0,0 @@ declare class Converter { |
@@ -0,0 +0,0 @@ class Converter { |
@@ -0,0 +0,0 @@ import { MomentInput, unitOfTime } from 'moment/moment'; |
export {}; | ||
//# sourceMappingURL=core-services-date.interface.js.map |
@@ -0,0 +0,0 @@ import { IDate, IDateLocal, IDayMonthYear, IDaysOfMonth, IWeeksOfMonth } from './core-services-date.interface'; |
import * as moment from 'moment'; | ||
import { extendMoment } from 'moment-range'; | ||
import { StringConverter } from '../string/core-services-string.service'; | ||
import { NumberParse } from '../number/core-services-number.service'; | ||
class Get { | ||
@@ -212,3 +212,3 @@ excelToDate(serialDate) { | ||
for (let j = start; j <= end; j++) { | ||
const day = StringConverter.numberToString(j); | ||
const day = NumberParse.toString(j); | ||
weekDays.push({ | ||
@@ -215,0 +215,0 @@ week: week.week, |
export declare type TFields = HTMLInputElement | HTMLDivElement | HTMLTextAreaElement | HTMLSpanElement | null; |
export {}; | ||
//# sourceMappingURL=core-services-elements.interface.js.map |
@@ -0,0 +0,0 @@ import { TFields } from './core-services-elements.interface'; |
@@ -0,0 +0,0 @@ import { DateValidation } from '../date/core-services-date.service'; |
@@ -0,0 +0,0 @@ export interface IImageUpdate { |
export {}; | ||
//# sourceMappingURL=core-services-image.interface.js.map |
@@ -0,0 +0,0 @@ import { IImageUpdate } from './core-services-image.interface'; |
@@ -11,6 +11,6 @@ class Resize { | ||
maxHeight = 1024; | ||
const canvas = document.createElement("canvas"); | ||
const ctx = canvas.getContext("2d"); | ||
const canvasCopy = document.createElement("canvas"); | ||
const copyContext = canvasCopy.getContext("2d"); | ||
const canvas = document.createElement('canvas'); | ||
const ctx = canvas.getContext('2d'); | ||
const canvasCopy = document.createElement('canvas'); | ||
const copyContext = canvasCopy.getContext('2d'); | ||
const img = new Image(); | ||
@@ -17,0 +17,0 @@ img.src = base64; |
@@ -0,0 +0,0 @@ export interface IInputMaskOptions { |
export {}; | ||
//# sourceMappingURL=core-services-input.interface.js.map |
@@ -0,3 +1,3 @@ | ||
import { TDecimalSeparators } from '../number/core-services-number-interface'; | ||
import { TCurrencyTypes } from './core-services-input.interface'; | ||
import { TDecimalSeparators } from '../string/core-services-string-interface'; | ||
declare class Mask { | ||
@@ -4,0 +4,0 @@ currency(field: HTMLInputElement, type?: TCurrencyTypes, currencySymbol?: string): string; |
@@ -0,0 +0,0 @@ import Inputmask from 'inputmask'; |
@@ -0,0 +0,0 @@ export interface IInternationalizationList { |
export {}; | ||
//# sourceMappingURL=core-services-internationalization.interface.js.map |
@@ -6,6 +6,2 @@ import { IInternationalizationList, TCountryLanguage, TCountryName, TCurrencyCode, TCurrentFullName } from './core-services-internationalization.interface'; | ||
export declare const InternationalCore: Core; | ||
declare class Conversion { | ||
numberToCurrency(currencyCode: TCurrencyCode, value: number): string; | ||
} | ||
export declare const InternationalConversion: Conversion; | ||
export {}; |
@@ -1445,12 +1445,2 @@ class Core { | ||
export const InternationalCore = new Core(); | ||
class Conversion { | ||
numberToCurrency(currencyCode, value) { | ||
const list = InternationalCore.retrieveList(undefined, undefined, undefined, currencyCode)[0]; | ||
return new Intl.NumberFormat(list.countryLanguage, { | ||
style: 'currency', | ||
currency: list.currencyCode | ||
}).format(value); | ||
} | ||
} | ||
export const InternationalConversion = new Conversion(); | ||
//# sourceMappingURL=core-services-internationalization.service.js.map |
@@ -0,0 +0,0 @@ export interface IMenuButton { |
export {}; | ||
//# sourceMappingURL=core-services-menu.interfaces.js.map |
import { Decimal } from 'decimal.js'; | ||
import { TCurrencyCode } from '../internationalization/core-services-internationalization.interface'; | ||
import { TCurrencySymbolTypes, TDecimalSeparators } from './core-services-number-interface'; | ||
declare class Core { | ||
numberToDecimal(value: number, errorValue?: Decimal): Decimal; | ||
toCurrency(currencyCode: TCurrencyCode, value: number, decimalPlaces?: number): string; | ||
toDecimal(value: number, errorValue?: Decimal): Decimal; | ||
toPercentage(num: number, includeSymbol?: boolean, decimalSeparator?: TDecimalSeparators, decimalPlaces?: number): string; | ||
toString(number: number): string; | ||
currencyToNumber(num: number, decimal?: TDecimalSeparators, currency?: TCurrencySymbolTypes, decimalPlaces?: number): number; | ||
decimalToString(num: number, decimalOutput?: TDecimalSeparators, decimalPlaces?: number): string; | ||
percentageToNumber(num: string, decimal?: TDecimalSeparators, decimalPlaces?: number): number; | ||
stringCurrencyToNumber(num: string, decimal: TDecimalSeparators | undefined, currency: TCurrencySymbolTypes, decimalPlaces?: number): number; | ||
formatDecimalSeparator(num: number, decimal?: TDecimalSeparators): string; | ||
} | ||
export declare const NumberParse: Core; | ||
export {}; |
import { Decimal } from 'decimal.js'; | ||
import { InternationalCore } from '../internationalization/core-services-internationalization.service'; | ||
class Core { | ||
numberToDecimal(value, errorValue = new Decimal(0).toDecimalPlaces(0)) { | ||
toCurrency(currencyCode, value, decimalPlaces = 2) { | ||
const list = InternationalCore.retrieveList(undefined, undefined, undefined, currencyCode)[0]; | ||
return new Intl.NumberFormat(list.countryLanguage, { | ||
style: 'currency', | ||
currency: list.currencyCode, | ||
maximumFractionDigits: decimalPlaces | ||
}).format(value); | ||
} | ||
toDecimal(value, errorValue = new Decimal(0).toDecimalPlaces(0)) { | ||
const invalid = value == null || Number.isNaN(value) || new Decimal(value).isNaN(); | ||
@@ -13,4 +22,115 @@ if (!invalid) { | ||
} | ||
toPercentage(num, includeSymbol = true, decimalSeparator = ',', decimalPlaces = 2) { | ||
const parsedNumber = new Decimal(num).plus(100); | ||
const parsedString = parsedNumber.toDecimalPlaces(decimalPlaces).toString().replace('.', decimalSeparator); | ||
const symbol = includeSymbol ? '%' : ''; | ||
return `${parsedString}${symbol}`; | ||
} | ||
toString(number) { | ||
const maxLength = number.toString().length; | ||
if (maxLength < 3) { | ||
if (number < 10) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else if (maxLength < 4) { | ||
if (number < 10) { | ||
return '00' + number; | ||
} | ||
else if (number < 100) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else if (maxLength < 5) { | ||
if (number < 10) { | ||
return '000' + number; | ||
} | ||
else if (number < 100) { | ||
return '00' + number; | ||
} | ||
else if (number < 1000) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else if (maxLength < 6) { | ||
if (number < 10) { | ||
return '0000' + number; | ||
} | ||
else if (number < 100) { | ||
return '000' + number; | ||
} | ||
else if (number < 1000) { | ||
return '00' + number; | ||
} | ||
else if (number < 10000) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
currencyToNumber(num, decimal = ',', currency, decimalPlaces = 2) { | ||
const parsedNumber = new Decimal(num).toDecimalPlaces(decimalPlaces).toString(); | ||
if (currency != null) { | ||
return new Decimal(parsedNumber | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace(' ', '') | ||
.replace(currency, '')).toDecimalPlaces(decimalPlaces).toNumber(); | ||
} | ||
else { | ||
return new Decimal(parsedNumber | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace('Ar$ ', '') | ||
.replace('R$ ', '') | ||
.replace('€ ', '') | ||
.replace('US$ ', '')).toDecimalPlaces(decimalPlaces).toNumber(); | ||
} | ||
} | ||
decimalToString(num, decimalOutput = '.', decimalPlaces = 2) { | ||
const value = new Decimal(num); | ||
const stringValue = value.toDecimalPlaces(decimalPlaces).toFixed(decimalPlaces); | ||
const separator = decimalOutput === ',' ? '$1.' : '$1,'; | ||
return stringValue | ||
.replace('.', decimalOutput) | ||
.replace(/(\d)(?=(\d{3})+(?!\d))/g, separator); | ||
} | ||
percentageToNumber(num, decimal = ',', decimalPlaces = 2) { | ||
const parsedNumber = num | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace(decimal, '.') | ||
.replace('% ', ''); | ||
return new Decimal(parsedNumber) | ||
.dividedBy(100) | ||
.toDecimalPlaces(decimalPlaces) | ||
.toNumber(); | ||
} | ||
stringCurrencyToNumber(num, decimal = ',', currency, decimalPlaces = 2) { | ||
return new Decimal(num | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace(' ', '') | ||
.replace(currency, '')).toDecimalPlaces(decimalPlaces).toNumber(); | ||
} | ||
formatDecimalSeparator(num, decimal = '.') { | ||
const separator = decimal === '.' ? '$1.' : '$1,'; | ||
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, separator); | ||
} | ||
} | ||
export const NumberParse = new Core(); | ||
//# sourceMappingURL=core-services-number.service.js.map |
export declare type TCurrencyNames = 'euro' | 'dolar' | 'real' | 'peso' | 'peso-ar' | 'pounds-sterling' | 'canadian-dollars' | 'yuan' | 'rupee' | 'yen'; | ||
export declare type TCurrencySymbolTypes = 'Ar$' | 'R$' | '€' | 'US$'; | ||
export declare type TDecimalSeparators = '.' | ','; |
export {}; | ||
//# sourceMappingURL=core-services-string-interface.js.map |
@@ -1,2 +0,2 @@ | ||
import { TCurrencyNames, TCurrencySymbolTypes, TDecimalSeparators } from './core-services-string-interface'; | ||
import { TCurrencyNames } from './core-services-string-interface'; | ||
declare class Clean { | ||
@@ -12,10 +12,3 @@ trim(text: string): string; | ||
declare class Converter { | ||
percentageToNumber(num: string, decimal?: TDecimalSeparators): number; | ||
numberToPercentage(num: number, includeSymbol?: boolean, separator?: TDecimalSeparators): string; | ||
currencyToNumber(num: number, decimal?: TDecimalSeparators, currency?: TCurrencySymbolTypes): number; | ||
stringCurrencyToNumber(num: string, decimal: TDecimalSeparators | undefined, currency: TCurrencySymbolTypes): number; | ||
currencyNameToSymbol(currency: TCurrencyNames): string; | ||
decimalNumberToString(num: number, decimalOutput?: TDecimalSeparators, places?: number): string; | ||
formatNumber(num: number, decimal?: TDecimalSeparators): string; | ||
numberToString(number: number): string; | ||
stringToBoolean(value: string): boolean; | ||
@@ -22,0 +15,0 @@ stringUnicode(string: string): string; |
@@ -1,2 +0,1 @@ | ||
import Decimal from 'decimal.js'; | ||
import { UrlDecode } from '../url/core-services-url.service'; | ||
@@ -59,39 +58,2 @@ class Clean { | ||
class Converter { | ||
percentageToNumber(num, decimal = ',') { | ||
return parseFloat(num | ||
.replace(/\./g, '') | ||
.replace(decimal, '.') | ||
.replace('% ', '')) / 100.0; | ||
} | ||
numberToPercentage(num, includeSymbol = true, separator = ',') { | ||
const parsedNumber = num * 100.0; | ||
const parsedString = parsedNumber.toString().replace('.', separator); | ||
const symbol = includeSymbol ? '%' : ''; | ||
return `${parsedString}${symbol}`; | ||
} | ||
currencyToNumber(num, decimal = ',', currency) { | ||
if (currency != null) { | ||
return parseFloat(num.toString() | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace(' ', '') | ||
.replace(currency, '')); | ||
} | ||
else { | ||
return parseFloat(num.toString() | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace('Ar$ ', '') | ||
.replace('R$ ', '') | ||
.replace('€ ', '') | ||
.replace('US$ ', '')); | ||
} | ||
} | ||
stringCurrencyToNumber(num, decimal = ',', currency) { | ||
return parseFloat(num | ||
.replace(/\./g, '') | ||
.replace(',', '.') | ||
.replace(' ', '') | ||
.replace(currency, '')); | ||
} | ||
currencyNameToSymbol(currency) { | ||
@@ -112,70 +74,2 @@ switch (currency) { | ||
} | ||
decimalNumberToString(num, decimalOutput = '.', places = 2) { | ||
const value = new Decimal(num); | ||
const stringValue = value.toDecimalPlaces(places).toFixed(places); | ||
const separator = decimalOutput === ',' ? '$1.' : '$1,'; | ||
return stringValue | ||
.replace('.', decimalOutput) | ||
.replace(/(\d)(?=(\d{3})+(?!\d))/g, separator); | ||
} | ||
formatNumber(num, decimal = '.') { | ||
const separator = decimal === '.' ? '$1.' : '$1,'; | ||
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, separator); | ||
} | ||
numberToString(number) { | ||
const maxLength = number.toString().length; | ||
if (maxLength < 3) { | ||
if (number < 10) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else if (maxLength < 4) { | ||
if (number < 10) { | ||
return '00' + number; | ||
} | ||
else if (number < 100) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else if (maxLength < 5) { | ||
if (number < 10) { | ||
return '000' + number; | ||
} | ||
else if (number < 100) { | ||
return '00' + number; | ||
} | ||
else if (number < 1000) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else if (maxLength < 6) { | ||
if (number < 10) { | ||
return '0000' + number; | ||
} | ||
else if (number < 100) { | ||
return '000' + number; | ||
} | ||
else if (number < 1000) { | ||
return '00' + number; | ||
} | ||
else if (number < 10000) { | ||
return '0' + number; | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
else { | ||
return number.toString(); | ||
} | ||
} | ||
stringToBoolean(value) { | ||
@@ -182,0 +76,0 @@ switch (value) { |
@@ -0,0 +0,0 @@ declare class Core { |
@@ -0,0 +0,0 @@ class Core { |
@@ -0,0 +0,0 @@ export declare type TExcelFileName = string | null; |
export {}; | ||
//# sourceMappingURL=services-export-excel.interface.js.map |
@@ -0,0 +0,0 @@ import { Subject } from 'rxjs'; |
@@ -0,0 +0,0 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
@@ -0,0 +0,0 @@ export interface IAlignments { |
export {}; | ||
//# sourceMappingURL=statics.alignment.interface.js.map |
@@ -0,0 +0,0 @@ import { IAlignments } from './statics.alignment.interface'; |
@@ -0,0 +0,0 @@ class Core { |
@@ -0,0 +0,0 @@ export interface IColors { |
export {}; | ||
//# sourceMappingURL=statics.color.interface.js.map |
@@ -0,0 +0,0 @@ import { IColors } from './statics.color.interface'; |
@@ -0,0 +0,0 @@ class Core { |
@@ -0,0 +0,0 @@ export interface IFonts { |
export {}; | ||
//# sourceMappingURL=statics.font.interface.js.map |
@@ -0,0 +0,0 @@ import { IFonts } from './statics.font.interface'; |
@@ -0,0 +0,0 @@ class Core { |
{ | ||
"name": "gl-w-frontend", | ||
"version": "3.4.0", | ||
"version": "4.0.0", | ||
"description": "Common code for using among web front-end development such as ES6+ and TypeScript", | ||
@@ -55,3 +55,3 @@ "main": "lib/bundle.js", | ||
"decimal.js": "^10.2.1", | ||
"inputmask": "^5.0.5", | ||
"inputmask": "^5.0.6", | ||
"moment": "^2.29.1", | ||
@@ -66,6 +66,6 @@ "moment-range": "^4.0.2", | ||
"@types/node": "^14.14.22", | ||
"@typescript-eslint/eslint-plugin": "^4.14.1", | ||
"@typescript-eslint/eslint-plugin-tslint": "^4.14.1", | ||
"@typescript-eslint/parser": "^4.14.1", | ||
"eslint": "^7.18.0", | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/eslint-plugin-tslint": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"eslint": "^7.28.0", | ||
"shx": "^0.3.3", | ||
@@ -72,0 +72,0 @@ "tslint": "^6.1.3", |
@@ -0,0 +0,0 @@ # gl-w-frontend # |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
259803
104
3981
Updatedinputmask@^5.0.6