jclib-ui 1.0.99 → 1.0.100
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.
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {import('reactstrap').InputProps & import('react-number-format').NumberFormatProps} props
|
|
4
|
+
* @returns {JSX.Element}
|
|
5
|
+
*/
|
|
6
|
+
export default function InputCpfCnpj(props: import('reactstrap').InputProps & import('react-number-format').NumberFormatProps): JSX.Element;
|
package/dist/inputs/inputs.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as InputCep } from './InputCep';
|
|
2
2
|
import { default as InputFone } from './InputFone';
|
|
3
3
|
import { FormatValor, FormatQuant, FormatPercent, FormatData } from './Formats';
|
|
4
|
+
import { default as InputCpfCnpj } from './inputCpfCnpj';
|
|
4
5
|
export function InputValor({ name, onChange, onClick, allowNegative, ...rest }: {
|
|
5
6
|
[x: string]: any;
|
|
6
7
|
name: any;
|
|
@@ -45,4 +46,4 @@ export function InputFinder({ title, onFind, children, ...rest }: {
|
|
|
45
46
|
onFind: any;
|
|
46
47
|
children: any;
|
|
47
48
|
}): import("react/jsx-runtime").JSX.Element;
|
|
48
|
-
export { InputCep, InputFone, FormatValor, FormatQuant, FormatPercent, FormatData };
|
|
49
|
+
export { InputCep, InputFone, FormatValor, FormatQuant, FormatPercent, FormatData, InputCpfCnpj };
|
package/dist/jclib-ui.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "react";
|
|
2
2
|
import t__default, { createContext, useState, useCallback, useEffect, useContext, useRef, useLayoutEffect, useMemo } from "react";
|
|
3
|
-
import { isDarkMode, random, isMobile, isDesktop, getDateTimeStr, getHash, formatValor } from "jcinfo-utils";
|
|
3
|
+
import { isDarkMode, random, isMobile, isDesktop, getDateTimeStr, getHash, formatValor, validarCPF, validarCNPJ } from "jcinfo-utils";
|
|
4
4
|
import { useDragControls, motion } from "framer-motion";
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { Dropdown, DropdownMenu, DropdownItem, DropdownToggle, Button, InputGroup, Input as Input$1 } from "reactstrap";
|
|
@@ -18439,6 +18439,77 @@ function InputFone({ name, value, onChange, ...rest }) {
|
|
|
18439
18439
|
}
|
|
18440
18440
|
);
|
|
18441
18441
|
}
|
|
18442
|
+
function isInvalidCpf(value) {
|
|
18443
|
+
const cpfEscapado = "00000000000";
|
|
18444
|
+
const valorLimpo = String(value).replace(/\D/g, "");
|
|
18445
|
+
let result = false;
|
|
18446
|
+
if (!validarCPF(valorLimpo)) {
|
|
18447
|
+
result = true;
|
|
18448
|
+
}
|
|
18449
|
+
if (valorLimpo == cpfEscapado) {
|
|
18450
|
+
result = false;
|
|
18451
|
+
}
|
|
18452
|
+
if (value == "") {
|
|
18453
|
+
result = false;
|
|
18454
|
+
}
|
|
18455
|
+
return result;
|
|
18456
|
+
}
|
|
18457
|
+
function isInvalidCnpj(value) {
|
|
18458
|
+
const cpnjEscapado = "00000000000000";
|
|
18459
|
+
const valorLimpo = String(value).replace(/\D/g, "");
|
|
18460
|
+
let result = false;
|
|
18461
|
+
if (!validarCNPJ(valorLimpo)) {
|
|
18462
|
+
result = true;
|
|
18463
|
+
}
|
|
18464
|
+
if (valorLimpo == cpnjEscapado) {
|
|
18465
|
+
result = false;
|
|
18466
|
+
}
|
|
18467
|
+
if (value == "") {
|
|
18468
|
+
result = false;
|
|
18469
|
+
}
|
|
18470
|
+
return result;
|
|
18471
|
+
}
|
|
18472
|
+
function isInvalidCpfCnpj(value) {
|
|
18473
|
+
const valorLimpo = String(value).replace(/\D/g, "");
|
|
18474
|
+
let result = false;
|
|
18475
|
+
if (valorLimpo.length <= 11 && isInvalidCpf(value)) {
|
|
18476
|
+
result = true;
|
|
18477
|
+
}
|
|
18478
|
+
if (valorLimpo.length > 11 && isInvalidCnpj(value)) {
|
|
18479
|
+
result = true;
|
|
18480
|
+
}
|
|
18481
|
+
if (value == "") {
|
|
18482
|
+
result = false;
|
|
18483
|
+
}
|
|
18484
|
+
return result;
|
|
18485
|
+
}
|
|
18486
|
+
const cCpfMask = "###.###.###-#####";
|
|
18487
|
+
const cCnpjMask = "##.###.###/####-##";
|
|
18488
|
+
function InputCpfCnpj(props) {
|
|
18489
|
+
const [cpfCnpjMask, setCpfCnpjMask] = useState(getMarcara(props.value));
|
|
18490
|
+
function getMarcara(initValue) {
|
|
18491
|
+
let value = initValue;
|
|
18492
|
+
value = value.replace(/\D/g, "");
|
|
18493
|
+
if (value.length > 11) {
|
|
18494
|
+
return cCnpjMask;
|
|
18495
|
+
} else {
|
|
18496
|
+
return cCpfMask;
|
|
18497
|
+
}
|
|
18498
|
+
}
|
|
18499
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18500
|
+
Input$1,
|
|
18501
|
+
{
|
|
18502
|
+
tag: NumberFormat,
|
|
18503
|
+
mask: "",
|
|
18504
|
+
format: cpfCnpjMask,
|
|
18505
|
+
onKeyUp: (e) => {
|
|
18506
|
+
setCpfCnpjMask(getMarcara(e.target.value));
|
|
18507
|
+
},
|
|
18508
|
+
invalid: isInvalidCpfCnpj(props.value),
|
|
18509
|
+
...props
|
|
18510
|
+
}
|
|
18511
|
+
);
|
|
18512
|
+
}
|
|
18442
18513
|
function handleChangeLocal(values, name, onChange) {
|
|
18443
18514
|
const getNumberConvert = (value) => {
|
|
18444
18515
|
if (!value || value === void 0 || value === null || isNaN(value)) {
|
|
@@ -18570,26 +18641,28 @@ const InputHora = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
|
18570
18641
|
}
|
|
18571
18642
|
);
|
|
18572
18643
|
const InputCpf = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18573
|
-
|
|
18644
|
+
Input$1,
|
|
18574
18645
|
{
|
|
18646
|
+
tag: NumberFormat,
|
|
18575
18647
|
name: props.name,
|
|
18576
18648
|
format: "###.###.###-##",
|
|
18577
18649
|
mask: "_",
|
|
18578
18650
|
value: props.value,
|
|
18579
18651
|
onChange: props.onChange,
|
|
18580
|
-
|
|
18652
|
+
invalid: isInvalidCpf(props.value),
|
|
18581
18653
|
...props
|
|
18582
18654
|
}
|
|
18583
18655
|
);
|
|
18584
18656
|
const InputCnpj = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18585
|
-
|
|
18657
|
+
Input$1,
|
|
18586
18658
|
{
|
|
18659
|
+
tag: NumberFormat,
|
|
18587
18660
|
name: props.name,
|
|
18588
18661
|
format: "##.###.###/####-##",
|
|
18589
18662
|
mask: "_",
|
|
18590
18663
|
value: props.value,
|
|
18591
18664
|
onChange: props.onChange,
|
|
18592
|
-
|
|
18665
|
+
invalid: isInvalidCnpj(props.value),
|
|
18593
18666
|
...props
|
|
18594
18667
|
}
|
|
18595
18668
|
);
|
|
@@ -20553,6 +20626,7 @@ export {
|
|
|
20553
20626
|
InputCodigo,
|
|
20554
20627
|
InputColor,
|
|
20555
20628
|
InputCpf,
|
|
20629
|
+
InputCpfCnpj,
|
|
20556
20630
|
InputEstado,
|
|
20557
20631
|
InputFinder$1 as InputFinder,
|
|
20558
20632
|
InputFone,
|