argous 1.2.243 → 1.2.245

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.
@@ -1,3 +1,6 @@
1
+ import { TypographyVariant } from '@material-ui/core';
2
+
3
+
1
4
  export interface PercentageDisplayProps {
2
5
  /**
3
6
  * Identificação do elemento
@@ -6,7 +9,7 @@ export interface PercentageDisplayProps {
6
9
  /**
7
10
  * Porcentagem
8
11
  */
9
- percentage?: number|string,
12
+ percentage?: (number|string),
10
13
  /**
11
14
  * Tamanho do componente
12
15
  */
@@ -34,9 +37,15 @@ export interface PercentageDisplayProps {
34
37
  /**
35
38
  * Cor de fundo da barra
36
39
  */
37
- barBackgroundColor?: string
40
+ barBackgroundColor?: string,
41
+ /**
42
+ * Variant do componente Typography MUI
43
+ */
44
+ typographyVariant?: TypographyVariant
38
45
  }
39
46
 
47
+
40
48
  declare function PercentageDisplay(props: PercentageDisplayProps): JSX.Element
41
49
 
50
+
42
51
  export default PercentageDisplay;
@@ -61,7 +61,9 @@ var useStyles = core_1.makeStyles({
61
61
  }
62
62
  },
63
63
  valueContainer: {
64
- position: 'relative',
64
+ position: 'relative'
65
+ },
66
+ typography: {
65
67
  color: function (_a) {
66
68
  var color = _a.color;
67
69
  return color;
@@ -73,7 +75,7 @@ var useStyles = core_1.makeStyles({
73
75
  }
74
76
  });
75
77
  var PercentageDisplay = function (_a) {
76
- var id = _a.id, _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.size, size = _c === void 0 ? 50 : _c, _d = _a.barWidth, barWidth = _d === void 0 ? 6 : _d, _e = _a.fontSize, fontSize = _e === void 0 ? '0.9rem' : _e, _f = _a.color, color = _f === void 0 ? '#000' : _f, _g = _a.backgroundColor, backgroundColor = _g === void 0 ? '#fff' : _g, _h = _a.barColor, barColor = _h === void 0 ? '#00995d' : _h, _j = _a.barBackgroundColor, barBackgroundColor = _j === void 0 ? '#00995d26' : _j;
78
+ var id = _a.id, _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.size, size = _c === void 0 ? 50 : _c, _d = _a.barWidth, barWidth = _d === void 0 ? 6 : _d, _e = _a.fontSize, fontSize = _e === void 0 ? '0.9rem' : _e, _f = _a.color, color = _f === void 0 ? '#000' : _f, _g = _a.typographyVariant, typographyVariant = _g === void 0 ? undefined : _g, _h = _a.backgroundColor, backgroundColor = _h === void 0 ? '#fff' : _h, _j = _a.barColor, barColor = _j === void 0 ? '#00995d' : _j, _k = _a.barBackgroundColor, barBackgroundColor = _k === void 0 ? '#00995d26' : _k;
77
79
  var progressBarWidth = size - barWidth;
78
80
  var classes = useStyles({ color: color, backgroundColor: backgroundColor, barColor: barColor, barBackgroundColor: barBackgroundColor, size: size, progressBarWidth: progressBarWidth, fontSize: fontSize });
79
81
  var percentageDisplayProgressId = id + "-percentageDisplayProgress";
@@ -84,9 +86,12 @@ var PercentageDisplay = function (_a) {
84
86
  return;
85
87
  progressBar.style.background = "conic-gradient(" + barColor + " " + porcentagem * 3.6 + "deg, " + barBackgroundColor + " " + porcentagem * 3.6 + "deg)";
86
88
  }, [barBackgroundColor, barColor, percentage, percentageDisplayProgressId]);
87
- react_1.useEffect(function () { return createProgress(); }, [percentage, createProgress]);
89
+ react_1.useEffect(function () {
90
+ createProgress();
91
+ }, [percentage, createProgress]);
88
92
  return react_1.default.createElement("div", { className: classes.container },
89
93
  react_1.default.createElement("div", { id: percentageDisplayProgressId, className: classes.circularProgress },
90
- react_1.default.createElement("div", { className: classes.valueContainer }, percentage + "%")));
94
+ react_1.default.createElement("div", { className: classes.valueContainer },
95
+ react_1.default.createElement(core_1.Typography, { variant: typographyVariant, className: classes.typography }, percentage + "%"))));
91
96
  };
92
97
  exports.default = PercentageDisplay;
@@ -50,7 +50,7 @@ var react_1 = __importStar(require("react"));
50
50
  var react_maskedinput_1 = __importDefault(require("react-maskedinput"));
51
51
  var cepMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '11111-111' }, props)); } };
52
52
  var cpfMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '111.111.111-11' }, props)); } };
53
- var cnpjMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '11.111.111/1111-11' }, props)); } };
53
+ var cnpjMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '##.###.###/####-##' }, props)); } };
54
54
  var telephoneMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '(11) 111111111' }, props)); } };
55
55
  var UtilTextField = function (_a) {
56
56
  var type = _a.type, onChange = _a.onChange, props = __rest(_a, ["type", "onChange"]);
@@ -72,7 +72,7 @@ var UtilTextField = function (_a) {
72
72
  standardObject.label = 'CPF';
73
73
  break;
74
74
  case 'cnpj':
75
- standardObject.valueHandler = function (value) { return utils_1.numbersOnly(value); };
75
+ standardObject.valueHandler = function (value) { return utils_1.numbersLettersOnly(value); };
76
76
  standardObject.InputProps = __assign({}, cnpjMaskedInput);
77
77
  standardObject.label = 'CNPJ';
78
78
  break;
@@ -56,8 +56,6 @@ export declare const useStore: () => ArgousType;
56
56
  export declare const reduxDispatch: (action: ActionType) => void;
57
57
  export declare const formataTelefone: (value: string) => string;
58
58
  export declare const useWebSocket: () => {};
59
- export declare const formataCpf: (value: string) => string;
60
- export declare const numbersOnly: (value: string, type: string) => string;
61
59
  export declare const currencyMask: (value: string | number) => string;
62
60
  export declare const toFloat: (value: string) => number | undefined;
63
61
  export declare const copyToClipboard: (text: string) => void;
@@ -72,10 +70,8 @@ export declare const storageMeasures: {
72
70
  exabyte: string;
73
71
  };
74
72
  export declare const bytesTranslator: (bytes?: number, decimals?: number, binary?: boolean) => object;
75
- export declare const formatCpfCnpj: (value: (string | number)) => string;
76
73
  export declare function dataUrlToBlob(dataUrl: string): Blob | undefined;
77
74
  export declare function allCharactersSame(s: string): boolean;
78
- export declare function cpfTest(cpf: (string | number)): boolean;
79
75
  interface PrintScreenParameters {
80
76
  /**
81
77
  * Event
@@ -122,50 +118,7 @@ declare global {
122
118
  }
123
119
  }
124
120
  export declare function stopPrntScr(e: KeyboardEvent): boolean;
125
- export declare const documentType: {
126
- cpf: {
127
- length: number;
128
- symbols: {
129
- length: number;
130
- };
131
- lengthWithSymbols: number;
132
- };
133
- cnpj: {
134
- length: number;
135
- symbols: {
136
- length: number;
137
- };
138
- lengthWithSymbols: number;
139
- };
140
- rg: {
141
- length: number;
142
- symbols: {
143
- length: number;
144
- };
145
- lengthWithSymbols: number;
146
- };
147
- cnes: {
148
- length: number;
149
- };
150
- crm: {
151
- length: number;
152
- };
153
- unimedCard: {
154
- length: number;
155
- };
156
- cep: {
157
- length: number;
158
- symbols: {
159
- length: number;
160
- };
161
- lengthWithSymbols: number;
162
- };
163
- telephone: {
164
- length: number;
165
- symbols: {
166
- length: number;
167
- };
168
- lengthWithSymbols: number;
169
- };
170
- };
121
+ export declare const numbersOnly: (value: string, type: string) => string;
122
+ export declare const lettersOnly: (valor: string) => string;
123
+ export declare const numbersLettersOnly: (valor: string) => string;
171
124
  export {};
@@ -85,7 +85,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
85
85
  return (mod && mod.__esModule) ? mod : { "default": mod };
86
86
  };
87
87
  Object.defineProperty(exports, "__esModule", { value: true });
88
- exports.documentType = exports.stopPrntScr = exports.printUrl = exports.geraLog = exports.printScreen = exports.cpfTest = exports.allCharactersSame = exports.dataUrlToBlob = exports.formatCpfCnpj = 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;
88
+ exports.numbersLettersOnly = exports.lettersOnly = exports.numbersOnly = exports.stopPrntScr = exports.printUrl = exports.geraLog = exports.printScreen = exports.allCharactersSame = exports.dataUrlToBlob = exports.bytesTranslator = exports.storageMeasures = exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = 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;
89
89
  var api_1 = require("./api");
90
90
  var store_1 = require("./store");
91
91
  var api_2 = require("../api");
@@ -354,10 +354,6 @@ var useWebSocket = function () {
354
354
  return value;
355
355
  };
356
356
  exports.useWebSocket = useWebSocket;
357
- var formataCpf = function (value) { return value === null || value === void 0 ? void 0 : value.replace(/[^\d]/, '').replace(/^(.{3})(.{3})(.{3})(.{2})$/, '$1.$2.$3-$4'); };
358
- exports.formataCpf = formataCpf;
359
- var numbersOnly = function (value, type) { return value ? value.replace(type === 'float' ? /[^0-9/.,]/g : /[^0-9]/g, '') : ''; };
360
- exports.numbersOnly = numbersOnly;
361
357
  var currencyMask = function (value) {
362
358
  if (value === 0)
363
359
  return value.toString() + ",00";
@@ -422,26 +418,6 @@ var bytesTranslator = function (bytes, decimals, binary) {
422
418
  return { type: type, size: size };
423
419
  };
424
420
  exports.bytesTranslator = bytesTranslator;
425
- var formatCpfCnpj = function (value) {
426
- if (!value)
427
- return '';
428
- if (lodash_1.isNumber(value))
429
- value = value.toString();
430
- value = value.replace(/[^\d]/g, '');
431
- var valueLen = value.length;
432
- if (valueLen > 3 && valueLen < 7)
433
- value = value.substring(0, 3) + "." + value.substring(3);
434
- else if (valueLen > 6 && valueLen < 10)
435
- value = value.substring(0, 3) + "." + value.substring(3, 6) + "." + value.substring(6);
436
- else if (valueLen > 8 && valueLen < 12)
437
- value = value.substring(0, 3) + "." + value.substring(3, 6) + "." + value.substring(6, 9) + "-" + value.substring(9);
438
- else if (valueLen > 11 && valueLen < 13)
439
- value = value.substring(0, 2) + "." + value.substring(2, 5) + "." + value.substring(5, 8) + "/" + value.substring(8);
440
- else if (valueLen > 12)
441
- value = value.substring(0, 2) + "." + value.substring(2, 5) + "." + value.substring(5, 8) + "/" + value.substring(8, 12) + "-" + value.substring(12, 14);
442
- return value;
443
- };
444
- exports.formatCpfCnpj = formatCpfCnpj;
445
421
  function dataUrlToBlob(dataUrl) {
446
422
  if (!dataUrl)
447
423
  return;
@@ -464,31 +440,6 @@ function allCharactersSame(s) {
464
440
  return true;
465
441
  }
466
442
  exports.allCharactersSame = allCharactersSame;
467
- function cpfTest(cpf) {
468
- if (typeof cpf === 'number')
469
- cpf = cpf.toString();
470
- if (!cpf || allCharactersSame(cpf))
471
- return false;
472
- var sum = 0;
473
- var rest;
474
- for (var index = 1; index <= 9; index++)
475
- sum += (parseInt(cpf.substring(index - 1, index)) * (11 - index));
476
- rest = ((sum * 10) % 11);
477
- if ((rest === 10) || (rest === 11))
478
- rest = 0;
479
- if (rest !== parseInt(cpf.substring(9, 10)))
480
- return false;
481
- sum = 0;
482
- for (var index = 1; index <= 10; index++)
483
- sum += (parseInt(cpf.substring(index - 1, index)) * (12 - index));
484
- rest = ((sum * 10) % 11);
485
- if ((rest === 10) || (rest === 11))
486
- rest = 0;
487
- if (rest !== parseInt(cpf.substring(10, 11)))
488
- return false;
489
- return true;
490
- }
491
- exports.cpfTest = cpfTest;
492
443
  var printScreen = function (_a) {
493
444
  var event = _a.event, _b = _a.id, id = _b === void 0 ? 'root' : _b, _c = _a.download, download = _c === void 0 ? false : _c;
494
445
  return __awaiter(void 0, void 0, void 0, function () {
@@ -583,49 +534,85 @@ function stopPrntScr(e) {
583
534
  return false;
584
535
  }
585
536
  exports.stopPrntScr = stopPrntScr;
586
- exports.documentType = {
587
- cpf: {
588
- length: 11,
589
- symbols: {
590
- length: 3
591
- },
592
- lengthWithSymbols: 14
593
- },
594
- cnpj: {
595
- length: 14,
596
- symbols: {
597
- length: 4
598
- },
599
- lengthWithSymbols: 18
600
- },
601
- rg: {
602
- length: 10,
603
- symbols: {
604
- length: 0
605
- },
606
- lengthWithSymbols: 10
607
- },
608
- cnes: {
609
- length: 7
610
- },
611
- crm: {
612
- length: 6
613
- },
614
- unimedCard: {
615
- length: 17
616
- },
617
- cep: {
618
- length: 8,
619
- symbols: {
620
- length: 1
621
- },
622
- lengthWithSymbols: 9
623
- },
624
- telephone: {
625
- length: 11,
626
- symbols: {
627
- length: 2
628
- },
629
- lengthWithSymbols: 13
630
- }
631
- };
537
+ var numbersOnly = function (value, type) { return value ? value.replace(type === 'float' ? /[^0-9/.,]/g : /[^0-9]/g, '') : ''; };
538
+ exports.numbersOnly = numbersOnly;
539
+ var lettersOnly = function (valor) { return valor ? valor.replace(/\W/g, '') : ''; };
540
+ exports.lettersOnly = lettersOnly;
541
+ var numbersLettersOnly = function (valor) { return valor ? valor.replace(/[^a-zA-Z0-9]+/g, '') : ''; };
542
+ exports.numbersLettersOnly = numbersLettersOnly;
543
+ // REMOVER
544
+ // export const documentType = {
545
+ // cpf: {
546
+ // length: 11,
547
+ // symbols: {
548
+ // length: 3
549
+ // },
550
+ // lengthWithSymbols: 14
551
+ // },
552
+ // cnpj: {
553
+ // length: 14,
554
+ // symbols: {
555
+ // length: 4
556
+ // },
557
+ // lengthWithSymbols: 18
558
+ // },
559
+ // rg: {
560
+ // length: 10,
561
+ // symbols: {
562
+ // length: 0
563
+ // },
564
+ // lengthWithSymbols: 10
565
+ // },
566
+ // cnes: {
567
+ // length: 7
568
+ // },
569
+ // crm: {
570
+ // length: 6
571
+ // },
572
+ // unimedCard: {
573
+ // length: 17
574
+ // },
575
+ // cep: {
576
+ // length: 8,
577
+ // symbols: {
578
+ // length: 1
579
+ // },
580
+ // lengthWithSymbols: 9
581
+ // },
582
+ // telephone: {
583
+ // length: 11,
584
+ // symbols: {
585
+ // length: 2
586
+ // },
587
+ // lengthWithSymbols: 13
588
+ // }
589
+ // };
590
+ // export const formatCpfCnpj = (value: (string|number)) => {
591
+ // if (!value) return '';
592
+ // if (isNumber(value)) value = value.toString();
593
+ // value = value.replace(/[^\d]/g, '');
594
+ // const valueLen = value.length;
595
+ // if (valueLen > 3 && valueLen < 7) value = `${value.substring(0, 3)}.${value.substring(3)}`;
596
+ // else if (valueLen > 6 && valueLen < 10) value = `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6)}`;
597
+ // else if (valueLen > 8 && valueLen < 12) value = `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6, 9)}-${value.substring(9)}`;
598
+ // else if (valueLen > 11 && valueLen < 13) value = `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8)}`;
599
+ // else if (valueLen > 12) value = `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8, 12)}-${value.substring(12, 14)}`;
600
+ // return value;
601
+ // };
602
+ // export const formataCpf = (value: string) => value?.replace(/[^\d]/, '').replace(/^(.{3})(.{3})(.{3})(.{2})$/, '$1.$2.$3-$4');
603
+ // export function cpfTest(cpf: (string|number)) {
604
+ // if (typeof cpf === 'number') cpf = cpf.toString();
605
+ // if (!cpf || allCharactersSame(cpf)) return false;
606
+ // let sum = 0;
607
+ // let rest: number;
608
+ // for (let index = 1; index <= 9; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (11 - index));
609
+ // rest = ((sum * 10) % 11);
610
+ // if ((rest === 10) || (rest === 11)) rest = 0;
611
+ // if (rest !== parseInt(cpf.substring(9, 10))) return false;
612
+ // sum = 0;
613
+ // for (let index = 1; index <= 10; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (12 - index));
614
+ // rest = ((sum * 10) % 11);
615
+ // if ((rest === 10) || (rest === 11)) rest = 0;
616
+ // if (rest !== parseInt(cpf.substring(10, 11))) return false;
617
+ // return true;
618
+ // }
@@ -1,3 +1,6 @@
1
+ import { TypographyVariant } from '@material-ui/core';
2
+
3
+
1
4
  export interface PercentageDisplayProps {
2
5
  /**
3
6
  * Identificação do elemento
@@ -6,7 +9,7 @@ export interface PercentageDisplayProps {
6
9
  /**
7
10
  * Porcentagem
8
11
  */
9
- percentage?: number|string,
12
+ percentage?: (number|string),
10
13
  /**
11
14
  * Tamanho do componente
12
15
  */
@@ -34,9 +37,15 @@ export interface PercentageDisplayProps {
34
37
  /**
35
38
  * Cor de fundo da barra
36
39
  */
37
- barBackgroundColor?: string
40
+ barBackgroundColor?: string,
41
+ /**
42
+ * Variant do componente Typography MUI
43
+ */
44
+ typographyVariant?: TypographyVariant
38
45
  }
39
46
 
47
+
40
48
  declare function PercentageDisplay(props: PercentageDisplayProps): JSX.Element
41
49
 
50
+
42
51
  export default PercentageDisplay;
@@ -1,6 +1,7 @@
1
- import { makeStyles } from '@material-ui/core';
1
+ import { makeStyles, Typography } from '@material-ui/core';
2
2
  import React, { useCallback, useEffect } from 'react';
3
3
 
4
+
4
5
  const useStyles = makeStyles({
5
6
  container: {
6
7
  display: 'grid',
@@ -23,12 +24,15 @@ const useStyles = makeStyles({
23
24
  }
24
25
  },
25
26
  valueContainer: {
26
- position: 'relative',
27
+ position: 'relative'
28
+ },
29
+ typography: {
27
30
  color: ({ color }) => color,
28
31
  fontSize: ({ fontSize }) => fontSize
29
32
  }
30
33
  });
31
34
 
35
+
32
36
  const PercentageDisplay = ({
33
37
  id,
34
38
  percentage = 0,
@@ -36,6 +40,7 @@ const PercentageDisplay = ({
36
40
  barWidth = 6,
37
41
  fontSize = '0.9rem',
38
42
  color = '#000',
43
+ typographyVariant = undefined,
39
44
  backgroundColor = '#fff',
40
45
  barColor = '#00995d',
41
46
  barBackgroundColor = '#00995d26'
@@ -51,15 +56,22 @@ const PercentageDisplay = ({
51
56
  if (!progressBar) return;
52
57
  progressBar.style.background = `conic-gradient(${barColor} ${porcentagem * 3.6}deg, ${barBackgroundColor} ${porcentagem * 3.6}deg)`;
53
58
  }, [barBackgroundColor, barColor, percentage, percentageDisplayProgressId]);
54
- useEffect(() => createProgress(), [percentage, createProgress]);
59
+
60
+ useEffect(() => {
61
+ createProgress();
62
+ }, [percentage, createProgress]);
63
+
55
64
 
56
65
  return <div className={classes.container}>
57
66
  <div id={percentageDisplayProgressId} className={classes.circularProgress}>
58
67
  <div className={classes.valueContainer}>
59
- {`${percentage}%`}
68
+ <Typography variant={typographyVariant} className={classes.typography}>
69
+ {`${percentage}%`}
70
+ </Typography>
60
71
  </div>
61
72
  </div>
62
73
  </div>;
63
74
  };
64
75
 
76
+
65
77
  export default PercentageDisplay;
@@ -1,4 +1,4 @@
1
- import { numbersOnly } from '../../utils';
1
+ import { numbersLettersOnly, numbersOnly } from '../../utils';
2
2
  import { TextField } from '@material-ui/core';
3
3
  import React, { useMemo } from 'react';
4
4
  import MaskedInput from 'react-maskedinput';
@@ -6,7 +6,7 @@ import MaskedInput from 'react-maskedinput';
6
6
 
7
7
  const cepMaskedInput = { inputComponent: (props) => <MaskedInput mask='11111-111' {...props} /> };
8
8
  const cpfMaskedInput = { inputComponent: (props) => <MaskedInput mask='111.111.111-11' {...props} /> };
9
- const cnpjMaskedInput = { inputComponent: (props) => <MaskedInput mask='11.111.111/1111-11' {...props} /> };
9
+ const cnpjMaskedInput = { inputComponent: (props) => <MaskedInput mask='##.###.###/####-##' {...props} /> };
10
10
  const telephoneMaskedInput = { inputComponent: (props) => <MaskedInput mask='(11) 111111111' {...props} /> };
11
11
 
12
12
 
@@ -32,7 +32,7 @@ const UtilTextField = ({ type, onChange, ...props }) => {
32
32
  standardObject.label = 'CPF';
33
33
  break;
34
34
  case 'cnpj':
35
- standardObject.valueHandler = (value) => numbersOnly(value);
35
+ standardObject.valueHandler = (value) => numbersLettersOnly(value);
36
36
  standardObject.InputProps = { ...cnpjMaskedInput };
37
37
  standardObject.label = 'CNPJ';
38
38
  break;
@@ -280,9 +280,7 @@ export const useWebSocket = () => {
280
280
  return value;
281
281
  };
282
282
 
283
- export const formataCpf = (value: string) => value?.replace(/[^\d]/, '').replace(/^(.{3})(.{3})(.{3})(.{2})$/, '$1.$2.$3-$4');
284
283
 
285
- export const numbersOnly = (value: string, type: string) => value ? value.replace(type === 'float' ? /[^0-9/.,]/g : /[^0-9]/g, '') : '';
286
284
 
287
285
  export const currencyMask = (value: string | number) => {
288
286
  if (value === 0) return `${value.toString()},00`;
@@ -340,18 +338,7 @@ export const bytesTranslator = (bytes: number = 0, decimals: number = 2, binary:
340
338
  return { type, size };
341
339
  };
342
340
 
343
- export const formatCpfCnpj = (value: (string|number)) => {
344
- if (!value) return '';
345
- if (isNumber(value)) value = value.toString();
346
- value = value.replace(/[^\d]/g, '');
347
- const valueLen = value.length;
348
- if (valueLen > 3 && valueLen < 7) value = `${value.substring(0, 3)}.${value.substring(3)}`;
349
- else if (valueLen > 6 && valueLen < 10) value = `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6)}`;
350
- else if (valueLen > 8 && valueLen < 12) value = `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6, 9)}-${value.substring(9)}`;
351
- else if (valueLen > 11 && valueLen < 13) value = `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8)}`;
352
- else if (valueLen > 12) value = `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8, 12)}-${value.substring(12, 14)}`;
353
- return value;
354
- };
341
+
355
342
 
356
343
  export function dataUrlToBlob(dataUrl: string) {
357
344
  if (!dataUrl) return;
@@ -373,29 +360,6 @@ export function allCharactersSame(s: string) {
373
360
  return true;
374
361
  }
375
362
 
376
- export function cpfTest(cpf: (string|number)) {
377
-
378
- if (typeof cpf === 'number') cpf = cpf.toString();
379
- if (!cpf || allCharactersSame(cpf)) return false;
380
-
381
- let sum = 0;
382
- let rest: number;
383
-
384
- for (let index = 1; index <= 9; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (11 - index));
385
- rest = ((sum * 10) % 11);
386
-
387
- if ((rest === 10) || (rest === 11)) rest = 0;
388
- if (rest !== parseInt(cpf.substring(9, 10))) return false;
389
-
390
- sum = 0;
391
- for (let index = 1; index <= 10; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (12 - index));
392
- rest = ((sum * 10) % 11);
393
-
394
- if ((rest === 10) || (rest === 11)) rest = 0;
395
- if (rest !== parseInt(cpf.substring(10, 11))) return false;
396
-
397
- return true;
398
- }
399
363
 
400
364
  interface PrintScreenParameters {
401
365
  /**
@@ -506,49 +470,98 @@ export function stopPrntScr(e: KeyboardEvent) {
506
470
  return false;
507
471
  }
508
472
 
509
- export const documentType = {
510
- cpf: {
511
- length: 11,
512
- symbols: {
513
- length: 3
514
- },
515
- lengthWithSymbols: 14
516
- },
517
- cnpj: {
518
- length: 14,
519
- symbols: {
520
- length: 4
521
- },
522
- lengthWithSymbols: 18
523
- },
524
- rg: {
525
- length: 10,
526
- symbols: {
527
- length: 0
528
- },
529
- lengthWithSymbols: 10
530
- },
531
- cnes: {
532
- length: 7
533
- },
534
- crm: {
535
- length: 6
536
- },
537
- unimedCard: {
538
- length: 17
539
- },
540
- cep: {
541
- length: 8,
542
- symbols: {
543
- length: 1
544
- },
545
- lengthWithSymbols: 9
546
- },
547
- telephone: {
548
- length: 11,
549
- symbols: {
550
- length: 2
551
- },
552
- lengthWithSymbols: 13
553
- }
554
- };
473
+
474
+
475
+ export const numbersOnly = (value: string, type: string) => value ? value.replace(type === 'float' ? /[^0-9/.,]/g : /[^0-9]/g, '') : '';
476
+
477
+ export const lettersOnly = (valor: string) => valor ? valor.replace(/\W/g, '') : '';
478
+
479
+ export const numbersLettersOnly = (valor: string) => valor ? valor.replace(/[^a-zA-Z0-9]+/g, '') : '';
480
+
481
+ // REMOVER
482
+ // export const documentType = {
483
+ // cpf: {
484
+ // length: 11,
485
+ // symbols: {
486
+ // length: 3
487
+ // },
488
+ // lengthWithSymbols: 14
489
+ // },
490
+ // cnpj: {
491
+ // length: 14,
492
+ // symbols: {
493
+ // length: 4
494
+ // },
495
+ // lengthWithSymbols: 18
496
+ // },
497
+ // rg: {
498
+ // length: 10,
499
+ // symbols: {
500
+ // length: 0
501
+ // },
502
+ // lengthWithSymbols: 10
503
+ // },
504
+ // cnes: {
505
+ // length: 7
506
+ // },
507
+ // crm: {
508
+ // length: 6
509
+ // },
510
+ // unimedCard: {
511
+ // length: 17
512
+ // },
513
+ // cep: {
514
+ // length: 8,
515
+ // symbols: {
516
+ // length: 1
517
+ // },
518
+ // lengthWithSymbols: 9
519
+ // },
520
+ // telephone: {
521
+ // length: 11,
522
+ // symbols: {
523
+ // length: 2
524
+ // },
525
+ // lengthWithSymbols: 13
526
+ // }
527
+ // };
528
+
529
+
530
+ // export const formatCpfCnpj = (value: (string|number)) => {
531
+ // if (!value) return '';
532
+ // if (isNumber(value)) value = value.toString();
533
+ // value = value.replace(/[^\d]/g, '');
534
+ // const valueLen = value.length;
535
+ // if (valueLen > 3 && valueLen < 7) value = `${value.substring(0, 3)}.${value.substring(3)}`;
536
+ // else if (valueLen > 6 && valueLen < 10) value = `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6)}`;
537
+ // else if (valueLen > 8 && valueLen < 12) value = `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6, 9)}-${value.substring(9)}`;
538
+ // else if (valueLen > 11 && valueLen < 13) value = `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8)}`;
539
+ // else if (valueLen > 12) value = `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8, 12)}-${value.substring(12, 14)}`;
540
+ // return value;
541
+ // };
542
+
543
+ // export const formataCpf = (value: string) => value?.replace(/[^\d]/, '').replace(/^(.{3})(.{3})(.{3})(.{2})$/, '$1.$2.$3-$4');
544
+
545
+ // export function cpfTest(cpf: (string|number)) {
546
+
547
+ // if (typeof cpf === 'number') cpf = cpf.toString();
548
+ // if (!cpf || allCharactersSame(cpf)) return false;
549
+
550
+ // let sum = 0;
551
+ // let rest: number;
552
+
553
+ // for (let index = 1; index <= 9; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (11 - index));
554
+ // rest = ((sum * 10) % 11);
555
+
556
+ // if ((rest === 10) || (rest === 11)) rest = 0;
557
+ // if (rest !== parseInt(cpf.substring(9, 10))) return false;
558
+
559
+ // sum = 0;
560
+ // for (let index = 1; index <= 10; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (12 - index));
561
+ // rest = ((sum * 10) % 11);
562
+
563
+ // if ((rest === 10) || (rest === 11)) rest = 0;
564
+ // if (rest !== parseInt(cpf.substring(10, 11))) return false;
565
+
566
+ // return true;
567
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.243",
3
+ "version": "1.2.245",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",