gl-w-frontend
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -1,1 +0,1 @@ | ||
var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P((function(resolve){resolve(value)}))}return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))};class Remove{duplicateLegacy(array){const unique=array.filter((item,index)=>array.indexOf(item)===index);return unique.sort()}duplicate(array,identification,sortIdentification,asc=true){return __awaiter(this,void 0,void 0,(function*(){let uniqueArray=array.filter((identification,index)=>{const _thing=JSON.stringify(identification);return index===array.findIndex(obj=>JSON.stringify(obj)===_thing)});if(sortIdentification!=null&&sortIdentification.length>0){uniqueArray=yield ArraySort.byKey(uniqueArray,sortIdentification,asc)}return uniqueArray}))}notDuplicated(array,asc=true){return __awaiter(this,void 0,void 0,(function*(){const arrayWithoutDuplicates=[...new Set(array)];let duplicates=[...array];arrayWithoutDuplicates.forEach(item=>{const i=duplicates.indexOf(item);duplicates=duplicates.slice(0,i).concat(duplicates.slice(i+1,duplicates.length))});return yield ArraySort.get(duplicates,asc)}))}notDuplicatedByKey(data,identification,sortIdentification,asc=true){return __awaiter(this,void 0,void 0,(function*(){const array=[];for(const item of data){array.push(item[identification])}const arrayWithoutDuplicates=[...new Set(array)];let duplicates=[...array];arrayWithoutDuplicates.forEach(item=>{const i=duplicates.indexOf(item);duplicates=duplicates.slice(0,i).concat(duplicates.slice(i+1,duplicates.length))});if(sortIdentification!=null){return yield ArraySort.byKey(duplicates,sortIdentification,asc)}else{return duplicates}}))}}export const ArrayRemove=new Remove;class Sort{get(array,asc){return __awaiter(this,void 0,void 0,(function*(){return new Promise(resolve=>{const _asc=asc?1:-1;const sorted=array.sort((a,b)=>{const x=a;const y=b;return x===y?0:x>y?_asc:-1*_asc});resolve(sorted)})}))}byKey(array,key,asc){return __awaiter(this,void 0,void 0,(function*(){return new Promise(resolve=>{const _asc=asc?1:-1;const sorted=array.sort((a,b)=>{const x=a[key];const y=b[key];return x===y?0:x>y?_asc:-1*_asc});resolve(sorted)})}))}}export const ArraySort=new Sort; | ||
var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};class Remove{duplicateLegacy(array){const unique=array.filter((item,index)=>{return array.indexOf(item)===index});return unique.sort()}duplicate(array,identification,sortIdentification,asc=true){return __awaiter(this,void 0,void 0,function*(){let uniqueArray=array.filter((identification,index)=>{const _thing=JSON.stringify(identification);return index===array.findIndex(obj=>{return JSON.stringify(obj)===_thing})});if(sortIdentification!=null&&sortIdentification.length>0){uniqueArray=yield ArraySort.byKey(uniqueArray,sortIdentification,asc)}return uniqueArray})}notDuplicated(array,asc=true){return __awaiter(this,void 0,void 0,function*(){const arrayWithoutDuplicates=[...new Set(array)];let duplicates=[...array];arrayWithoutDuplicates.forEach(item=>{const i=duplicates.indexOf(item);duplicates=duplicates.slice(0,i).concat(duplicates.slice(i+1,duplicates.length))});return yield ArraySort.get(duplicates,asc)})}notDuplicatedByKey(data,identification,sortIdentification,asc=true){return __awaiter(this,void 0,void 0,function*(){const array=[];for(const item of data){array.push(item[identification])}const arrayWithoutDuplicates=[...new Set(array)];let duplicates=[...array];arrayWithoutDuplicates.forEach(item=>{const i=duplicates.indexOf(item);duplicates=duplicates.slice(0,i).concat(duplicates.slice(i+1,duplicates.length))});if(sortIdentification!=null){return yield ArraySort.byKey(duplicates,sortIdentification,asc)}else{return duplicates}})}}export const ArrayRemove=new Remove;class Sort{get(array,asc){return __awaiter(this,void 0,void 0,function*(){return new Promise(resolve=>{const _asc=asc?1:-1;const sorted=array.sort((a,b)=>{const x=a;const y=b;return x===y?0:x>y?_asc:-1*_asc});resolve(sorted)})})}byKey(array,key,asc){return __awaiter(this,void 0,void 0,function*(){return new Promise(resolve=>{const _asc=asc?1:-1;const sorted=array.sort((a,b)=>{const x=a[key];const y=b[key];return x===y?0:x>y?_asc:-1*_asc});resolve(sorted)})})}}export const ArraySort=new Sort; |
@@ -8,2 +8,3 @@ import { TCurrencyTypes } from './core-services-input.interface'; | ||
integer(field: HTMLInputElement, allowMinus?: boolean, rightAlign?: boolean, step?: number): string; | ||
customNumberPhone(mask: string, field: HTMLInputElement, rightAlign?: boolean): string; | ||
remove(field: HTMLInputElement): void; | ||
@@ -10,0 +11,0 @@ } |
@@ -63,2 +63,10 @@ import Inputmask from 'inputmask'; | ||
} | ||
customNumberPhone(mask, field, rightAlign = false) { | ||
Inputmask({ | ||
mask, | ||
rightAlign, | ||
placeholder: mask | ||
}).mask(field); | ||
return mask; | ||
} | ||
remove(field) { | ||
@@ -65,0 +73,0 @@ Inputmask.remove(field); |
@@ -1,1 +0,1 @@ | ||
import Inputmask from"inputmask";class Mask{currency(field,type="currency",currencySymbol="R$"){let options;let mask;if(type==="million-currency"){mask=`${currencySymbol} 0,00mn`;options={prefix:`${currencySymbol} `,suffix:"mn",allowMinus:true}}else{mask=`${currencySymbol} 0,00`;options={prefix:`${currencySymbol} `,numericInput:true,allowMinus:true,rightAlign:false,radixPoint:",",groupSeparator:"."}}const im=new Inputmask("currency",options);im.mask(field);return mask}percentage(field,allowMinus=true,decimalSeparator=",",rightAlign=true,step=5){const symbol="%";const mask=`0,00${symbol}`;const groupSeparator=decimalSeparator===","?".":",";Inputmask({alias:"numeric",suffix:`${symbol} `,numericInput:true,allowMinus:allowMinus,rightAlign:rightAlign,radixPoint:decimalSeparator,groupSeparator:groupSeparator,step:step,placeholder:mask}).mask(field);return mask}numeric(field,allowMinus=true,decimalSeparator=",",rightAlign=true,step=1){const mask=`0,00`;const groupSeparator=decimalSeparator===","?".":",";Inputmask({alias:"numeric",numericInput:true,allowMinus:allowMinus,rightAlign:rightAlign,radixPoint:decimalSeparator,groupSeparator:groupSeparator,step:step,placeholder:mask}).mask(field);return mask}integer(field,allowMinus=true,rightAlign=false,step=1){const mask=`0`;Inputmask({alias:"integer",numericInput:true,inputmode:"numeric",allowMinus:allowMinus,rightAlign:rightAlign,step:step,placeholder:mask}).mask(field);return mask}remove(field){Inputmask.remove(field)}}export const InputMask=new Mask; | ||
import Inputmask from"inputmask";class Mask{currency(field,type="currency",currencySymbol="R$"){let options;let mask;if(type==="million-currency"){mask=`${currencySymbol} 0,00mn`;options={prefix:`${currencySymbol} `,suffix:"mn",allowMinus:true}}else{mask=`${currencySymbol} 0,00`;options={prefix:`${currencySymbol} `,numericInput:true,allowMinus:true,rightAlign:false,radixPoint:",",groupSeparator:"."}}const im=new Inputmask("currency",options);im.mask(field);return mask}percentage(field,allowMinus=true,decimalSeparator=",",rightAlign=true,step=5){const symbol="%";const mask=`0,00${symbol}`;const groupSeparator=decimalSeparator===","?".":",";Inputmask({alias:"numeric",suffix:`${symbol} `,numericInput:true,allowMinus:allowMinus,rightAlign:rightAlign,radixPoint:decimalSeparator,groupSeparator:groupSeparator,step:step,placeholder:mask}).mask(field);return mask}numeric(field,allowMinus=true,decimalSeparator=",",rightAlign=true,step=1){const mask=`0,00`;const groupSeparator=decimalSeparator===","?".":",";Inputmask({alias:"numeric",numericInput:true,allowMinus:allowMinus,rightAlign:rightAlign,radixPoint:decimalSeparator,groupSeparator:groupSeparator,step:step,placeholder:mask}).mask(field);return mask}integer(field,allowMinus=true,rightAlign=false,step=1){const mask=`0`;Inputmask({alias:"integer",numericInput:true,inputmode:"numeric",allowMinus:allowMinus,rightAlign:rightAlign,step:step,placeholder:mask}).mask(field);return mask}customNumberPhone(mask,field,rightAlign=false){Inputmask({mask:mask,rightAlign:rightAlign,placeholder:mask}).mask(field);return mask}remove(field){Inputmask.remove(field)}}export const InputMask=new Mask; |
@@ -1,1 +0,1 @@ | ||
var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P((function(resolve){resolve(value)}))}return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))};import{Subject}from"rxjs";import*as Excel from"xlsx";import{DateGet}from"../../../core/services/date/core-services-date.service";import{DataConversor}from"../../../core/services/data/core-services-data.service";class Core{excelFileToJson(file,sheet=0){return new Promise(resolve=>__awaiter(this,void 0,void 0,(function*(){const fileArray=yield file.arrayBuffer();const reader=new FileReader;reader.onload=e=>{const data=new Uint8Array(fileArray);const workbook=Excel.read(data,{type:"array",sheets:sheet});const workbookName=workbook.SheetNames[sheet];const json=Excel.utils.sheet_to_json(workbook.Sheets[workbookName]);resolve(json)};reader.readAsArrayBuffer(file)})))}jsonToFile(userData,sheetName,fileName,properties){return new Promise(resolve=>{const currentDate=DateGet.currentDateString("YYYYMMDD_HHmmss");const _fileName=fileName==null?`Export ${currentDate}`:`${fileName}`;const fileNameWidthDate=`${_fileName} ${currentDate}.xlsx`;const ws=Excel.utils.json_to_sheet(userData);const wb=Excel.utils.book_new();Excel.utils.book_append_sheet(wb,ws,"Base");const file=Excel.write(wb,{Props:{Title:properties.Title,Author:properties.Author,Company:properties.Company,Category:properties.Category},bookType:"xlsx",type:"binary"});const type="application/octet-stream";const content=new Blob([DataConversor.binaryStringToArrayBuffer(file)],{type:type});const excelFile=new File([content],fileNameWidthDate,{lastModified:(new Date).getMilliseconds(),type:type});resolve(excelFile)})}}export const ExcelConversor=new Core;class Export{constructor(){this.status$=new Subject}exportDatabase(userData,sheetName,fileName){const single={userData:userData,fileName:fileName,sheetName:sheetName};const multiple={data:[],fileName:""};return this.exportExcel("Single",single,multiple)}exportMultipleDatabase(data,fileName=null){const single={userData:[],fileName:"",sheetName:""};const multiple={data:data,fileName:fileName};return this.exportExcel("Multiple",single,multiple)}static saveFile(content,sheetName,_fileName=null){return __awaiter(this,void 0,void 0,(function*(){const currentDate=DateGet.currentDateString("YYYYMMDD_HHmmss");const fileName=_fileName==null?`Export ${currentDate}`:`${_fileName}`;const fileNameWidthDate=`${fileName} ${currentDate}.xlsx`;const ws=Excel.utils.json_to_sheet(content);const wb=Excel.utils.book_new();Excel.utils.book_append_sheet(wb,ws,sheetName);yield Excel.writeFile(wb,fileNameWidthDate,{cellStyles:true});ExportExcel.clearSubject();return{code:200,message:"File saved successfully"}}))}static saveFileFromMultiple(data,fileName=null){return __awaiter(this,void 0,void 0,(function*(){const currentDate=DateGet.currentDateString("YYYYMMDD_HHmmss");const currentFileName=fileName==null?`Export ${currentDate}`:`${fileName}`;const fileNameWidthDate=`${currentFileName} ${currentDate}.xlsx`;const wb=Excel.utils.book_new();for(const sheet of data){const ws=Excel.utils.json_to_sheet(sheet.content);Excel.utils.book_append_sheet(wb,ws,sheet.sheetName)}yield Excel.writeFile(wb,fileNameWidthDate,{cellStyles:true});ExportExcel.clearSubject();return{code:200,message:"File saved successfully"}}))}exportExcel(type,singleData,multipleData){return __awaiter(this,void 0,void 0,(function*(){this.status$.next("Creating Excel workbook...");return new Promise(resolve=>__awaiter(this,void 0,void 0,(function*(){let result;if(type==="Single"){result=yield Export.saveFile(singleData.userData,singleData.sheetName,singleData.fileName)}else{result=yield Export.saveFileFromMultiple(multipleData.data,multipleData.fileName)}this.status$.next(result.message);if(result.code===200){resolve(result.message)}else{throw new Error(result.message)}})))}))}clearSubject(){this.status$.observers.map(x=>x.complete())}}export const ExportExcel=new Export; | ||
var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};import{Subject}from"rxjs";import*as Excel from"xlsx";import{DateGet}from"../../../core/services/date/core-services-date.service";import{DataConversor}from"../../../core/services/data/core-services-data.service";class Core{excelFileToJson(file,sheet=0){return new Promise(resolve=>__awaiter(this,void 0,void 0,function*(){const fileArray=yield file.arrayBuffer();const reader=new FileReader;reader.onload=e=>{const data=new Uint8Array(fileArray);const workbook=Excel.read(data,{type:"array",sheets:sheet});const workbookName=workbook.SheetNames[sheet];const json=Excel.utils.sheet_to_json(workbook.Sheets[workbookName]);resolve(json)};reader.readAsArrayBuffer(file)}))}jsonToFile(userData,sheetName,fileName,properties){return new Promise(resolve=>{const currentDate=DateGet.currentDateString("YYYYMMDD_HHmmss");const _fileName=fileName==null?`Export ${currentDate}`:`${fileName}`;const fileNameWidthDate=`${_fileName} ${currentDate}.xlsx`;const ws=Excel.utils.json_to_sheet(userData);const wb=Excel.utils.book_new();Excel.utils.book_append_sheet(wb,ws,"Base");const file=Excel.write(wb,{Props:{Title:properties.Title,Author:properties.Author,Company:properties.Company,Category:properties.Category},bookType:"xlsx",type:"binary"});const type="application/octet-stream";const content=new Blob([DataConversor.binaryStringToArrayBuffer(file)],{type:type});const excelFile=new File([content],fileNameWidthDate,{lastModified:(new Date).getMilliseconds(),type:type});resolve(excelFile)})}}export const ExcelConversor=new Core;class Export{constructor(){this.status$=new Subject}exportDatabase(userData,sheetName,fileName){const single={userData:userData,fileName:fileName,sheetName:sheetName};const multiple={data:[],fileName:""};return this.exportExcel("Single",single,multiple)}exportMultipleDatabase(data,fileName=null){const single={userData:[],fileName:"",sheetName:""};const multiple={data:data,fileName:fileName};return this.exportExcel("Multiple",single,multiple)}static saveFile(content,sheetName,_fileName=null){return __awaiter(this,void 0,void 0,function*(){const currentDate=DateGet.currentDateString("YYYYMMDD_HHmmss");const fileName=_fileName==null?`Export ${currentDate}`:`${_fileName}`;const fileNameWidthDate=`${fileName} ${currentDate}.xlsx`;const ws=Excel.utils.json_to_sheet(content);const wb=Excel.utils.book_new();Excel.utils.book_append_sheet(wb,ws,sheetName);yield Excel.writeFile(wb,fileNameWidthDate,{cellStyles:true});ExportExcel.clearSubject();return{code:200,message:"File saved successfully"}})}static saveFileFromMultiple(data,fileName=null){return __awaiter(this,void 0,void 0,function*(){const currentDate=DateGet.currentDateString("YYYYMMDD_HHmmss");const currentFileName=fileName==null?`Export ${currentDate}`:`${fileName}`;const fileNameWidthDate=`${currentFileName} ${currentDate}.xlsx`;const wb=Excel.utils.book_new();for(const sheet of data){const ws=Excel.utils.json_to_sheet(sheet.content);Excel.utils.book_append_sheet(wb,ws,sheet.sheetName)}yield Excel.writeFile(wb,fileNameWidthDate,{cellStyles:true});ExportExcel.clearSubject();return{code:200,message:"File saved successfully"}})}exportExcel(type,singleData,multipleData){return __awaiter(this,void 0,void 0,function*(){this.status$.next("Creating Excel workbook...");return new Promise(resolve=>__awaiter(this,void 0,void 0,function*(){let result;if(type==="Single"){result=yield Export.saveFile(singleData.userData,singleData.sheetName,singleData.fileName)}else{result=yield Export.saveFileFromMultiple(multipleData.data,multipleData.fileName)}this.status$.next(result.message);if(result.code===200){resolve(result.message)}else{throw new Error(result.message)}}))})}clearSubject(){this.status$.observers.map(x=>x.complete())}}export const ExportExcel=new Export; |
{ | ||
"name": "gl-w-frontend", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Common code for using among web front-end development such as ES6+ and TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/bundle.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
353765
3901