argous 1.2.193 → 1.2.194

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -235,7 +235,7 @@ var FilePreparer = function (_a, ref) {
235
235
  // onChange && onChange(multiple ? files : files[0], motivo);
236
236
  // setMotivo(undefined);
237
237
  // }, [files]);
238
- react_1.useImperativeHandle(ref, function () { return ({ preparaArquivo: preparaArquivo, loading: loading, setLoading: setLoading }); }, [preparaArquivo, loading]);
238
+ react_1.useImperativeHandle(ref, function () { return ({ preparaArquivo: preparaArquivo, loading: loading, setLoading: setLoading, setFiles: setFiles }); }, [preparaArquivo, loading]);
239
239
  var _j = lab_1.useAutocomplete({
240
240
  value: files,
241
241
  inputValue: files.length ? '' : placeholder || 'Selecione um arquivo',
@@ -62,3 +62,13 @@ export declare const currencyMask: (value: string | number) => string | undefine
62
62
  export declare const toFloat: (value: string) => number | undefined;
63
63
  export declare const copyToClipboard: (text: string) => void;
64
64
  export declare const confirm: (props: BasicModalProps | string) => Promise<boolean>;
65
+ export declare const storageMeasures: {
66
+ byte: string;
67
+ kilobyte: string;
68
+ megabyte: string;
69
+ gigabyte: string;
70
+ terabyte: string;
71
+ petabyte: string;
72
+ exabyte: string;
73
+ };
74
+ export declare const bytesTranslator: (bytes?: number, decimals?: number, binary?: boolean) => object;
@@ -82,7 +82,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
82
82
  return to;
83
83
  };
84
84
  Object.defineProperty(exports, "__esModule", { value: true });
85
- exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = exports.numbersOnly = exports.formataCpf = exports.useWebSocket = exports.formataTelefone = exports.reduxDispatch = exports.useStore = exports.useModal = exports.useGraph = exports.randomColor = exports.humanFileSize = exports.sanitizaHTML = exports.formataDinheiro = exports.useUpdateEffect = exports.usePrevious = exports.getNumeroFromInitials = exports.getInitials = exports.getRandomColor = exports.printPdf = exports.downloadFromUrl = exports.downloadBase64 = exports.formataNome = exports.addExtraZero = exports.getCookie = exports.widthToCenterVertically = void 0;
85
+ exports.bytesTranslator = exports.storageMeasures = exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = exports.numbersOnly = exports.formataCpf = exports.useWebSocket = exports.formataTelefone = exports.reduxDispatch = exports.useStore = exports.useModal = exports.useGraph = exports.randomColor = exports.humanFileSize = exports.sanitizaHTML = exports.formataDinheiro = exports.useUpdateEffect = exports.usePrevious = exports.getNumeroFromInitials = exports.getInitials = exports.getRandomColor = exports.printPdf = exports.downloadFromUrl = exports.downloadBase64 = exports.formataNome = exports.addExtraZero = exports.getCookie = exports.widthToCenterVertically = void 0;
86
86
  var store_1 = require("./store");
87
87
  var api_1 = require("../api");
88
88
  var ModalProvider_1 = require("../components/ConfirmModal/ModalProvider");
@@ -94,11 +94,7 @@ var react_1 = require("react");
94
94
  var widthToCenterVertically = function (content) {
95
95
  var B = document.body;
96
96
  var H = document.documentElement;
97
- // if (typeof document.height !== 'undefined') {
98
- // height = document.height;
99
- // } else {
100
97
  var height = Math.max(B.scrollHeight, B.offsetHeight, H.clientHeight, H.scrollHeight, H.offsetHeight);
101
- // }
102
98
  return (height - content) / 2;
103
99
  };
104
100
  exports.widthToCenterVertically = widthToCenterVertically;
@@ -117,11 +113,7 @@ var getCookie = function (cName) {
117
113
  return '';
118
114
  };
119
115
  exports.getCookie = getCookie;
120
- var addExtraZero = function (vl) {
121
- return vl < 10
122
- ? "0" + (typeof vl === 'string' ? parseInt(vl) : vl)
123
- : vl;
124
- };
116
+ var addExtraZero = function (vl) { return (vl < 10) ? "0" + (typeof vl === 'string' ? parseInt(vl) : vl) : vl; };
125
117
  exports.addExtraZero = addExtraZero;
126
118
  var formataNome = function (value) {
127
119
  if (value) {
@@ -326,11 +318,6 @@ var useModal = function () {
326
318
  return createModal;
327
319
  };
328
320
  exports.useModal = useModal;
329
- // Nao funciona... talvez com redux funcione, q nem a parte de erros
330
- // export const confirm = ({ title = '', description = '' }) => {
331
- // const { createModal } = useModal()
332
- // return createModal(BasicModal)({ title, description })
333
- // }
334
321
  var useStore = function () {
335
322
  return store_1.getStore().getState().argous || {};
336
323
  };
@@ -406,3 +393,27 @@ var confirm = function (props) { return new Promise(function (resolve, reject) {
406
393
  fieldsRedux_1.setAnotherProgramField('openModal', { value: Object.assign({ resolve: resolve, reject: reject, okLabel: 'Confirmar', cancelLabel: 'Cancelar', title: 'Confirmar?' }, typeof props === 'string' ? { description: props } : props) }, 'argousSystem');
407
394
  }); };
408
395
  exports.confirm = confirm;
396
+ exports.storageMeasures = {
397
+ byte: 'B',
398
+ kilobyte: 'KB',
399
+ megabyte: 'MB',
400
+ gigabyte: 'GB',
401
+ terabyte: 'TB',
402
+ petabyte: 'PB',
403
+ exabyte: 'EB'
404
+ };
405
+ var bytesTranslator = function (bytes, decimals, binary) {
406
+ if (bytes === void 0) { bytes = 0; }
407
+ if (decimals === void 0) { decimals = 2; }
408
+ if (binary === void 0) { binary = false; }
409
+ var measures = Object.values(exports.storageMeasures);
410
+ var divisor = ((binary) ? 1024 : 1000);
411
+ decimals = ((decimals < 0) ? 0 : decimals);
412
+ var index = Math.floor(Math.log(bytes) / Math.log(divisor));
413
+ if (index < 0)
414
+ index = 0;
415
+ var size = parseFloat((bytes / Math.pow(divisor, index)).toFixed(decimals));
416
+ var type = measures[index];
417
+ return { type: type, size: size };
418
+ };
419
+ exports.bytesTranslator = bytesTranslator;
@@ -151,7 +151,7 @@ const FilePreparer = ({
151
151
  // setMotivo(undefined);
152
152
  // }, [files]);
153
153
 
154
- useImperativeHandle(ref, () => ({ preparaArquivo, loading, setLoading }), [preparaArquivo, loading]);
154
+ useImperativeHandle(ref, () => ({ preparaArquivo, loading, setLoading, setFiles }), [preparaArquivo, loading]);
155
155
 
156
156
  const {
157
157
  getInputProps,
@@ -6,22 +6,14 @@ import { ActionType, ArgousType } from '../types';
6
6
  import { useTheme } from '@material-ui/core';
7
7
  import * as colors from '@material-ui/core/colors';
8
8
  import { ChartOptions } from 'chart.js';
9
- // import { BasicModal } from '../components';
10
9
  import { BasicModalProps } from 'lib/components';
11
10
  import { isNumber } from 'lodash';
12
11
  import React, { useRef, useEffect, useContext, useState } from 'react';
13
12
 
14
13
  export const widthToCenterVertically = (content:number) => {
15
-
16
14
  const B = document.body;
17
15
  const H = document.documentElement;
18
-
19
- // if (typeof document.height !== 'undefined') {
20
- // height = document.height;
21
- // } else {
22
16
  const height = Math.max(B.scrollHeight, B.offsetHeight, H.clientHeight, H.scrollHeight, H.offsetHeight);
23
- // }
24
-
25
17
  return (height - content) / 2;
26
18
  };
27
19
 
@@ -40,11 +32,7 @@ export const getCookie = (cName: string) => {
40
32
  return '';
41
33
  };
42
34
 
43
- export const addExtraZero = (vl:number|string) => {
44
- return vl < 10
45
- ? `0${typeof vl === 'string' ? parseInt(vl) : vl}`
46
- : vl;
47
- };
35
+ export const addExtraZero = (vl: number|string) => (vl < 10) ? `0${typeof vl === 'string' ? parseInt(vl) : vl}` : vl;
48
36
 
49
37
  export const formataNome = (value:string) => {
50
38
  if (value) {
@@ -260,12 +248,6 @@ export const useModal = () => {
260
248
  return createModal;
261
249
  };
262
250
 
263
- // Nao funciona... talvez com redux funcione, q nem a parte de erros
264
- // export const confirm = ({ title = '', description = '' }) => {
265
- // const { createModal } = useModal()
266
- // return createModal(BasicModal)({ title, description })
267
- // }
268
-
269
251
  export const useStore = (): ArgousType => {
270
252
  return getStore().getState().argous || {};
271
253
  };
@@ -332,4 +314,25 @@ export const copyToClipboard = (text: string) => {
332
314
 
333
315
  export const confirm = (props: BasicModalProps | string) => new Promise<boolean>((resolve, reject) => {
334
316
  setAnotherProgramField('openModal', { value: Object.assign({ resolve, reject, okLabel: 'Confirmar', cancelLabel: 'Cancelar', title: 'Confirmar?' }, typeof props === 'string' ? { description: props } : props) }, 'argousSystem');
335
- });
317
+ });
318
+
319
+ export const storageMeasures = {
320
+ byte: 'B',
321
+ kilobyte: 'KB',
322
+ megabyte: 'MB',
323
+ gigabyte: 'GB',
324
+ terabyte: 'TB',
325
+ petabyte: 'PB',
326
+ exabyte: 'EB'
327
+ };
328
+
329
+ export const bytesTranslator = (bytes: number = 0, decimals: number = 2, binary: boolean = false): object => {
330
+ const measures = Object.values(storageMeasures);
331
+ const divisor = ((binary) ? 1024 : 1000);
332
+ decimals = ((decimals < 0) ? 0 : decimals);
333
+ let index = Math.floor(Math.log(bytes) / Math.log(divisor));
334
+ if (index < 0) index = 0;
335
+ const size = parseFloat((bytes / Math.pow(divisor, index)).toFixed(decimals));
336
+ const type = measures[index];
337
+ return { type, size };
338
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.193",
3
+ "version": "1.2.194",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",