jclib-ui 1.0.2 → 1.0.4

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,14 @@
1
+ type Props = {
2
+ valor: number;
3
+ format?: boolean;
4
+ currency?: boolean;
5
+ };
6
+ export declare function DynamicCounter({ valor, format, currency }: Props): any;
7
+ export declare namespace DynamicCounter {
8
+ var defaultProps: {
9
+ valor: number;
10
+ format: boolean;
11
+ currency: boolean;
12
+ };
13
+ }
14
+ export {};
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { default as IconUserGear } from './iconSvg/iconUserGear';
29
29
  export { default as Panel } from './panel/panel';
30
30
  export { PanelHeader } from './panel/panelHeader';
31
31
  export { LoadingReport } from './LoadingReport/LoadingReport';
32
+ export { DynamicCounter } from './dynamicCounter/dynamicCounter';
32
33
  export { default as InputColor } from './inputColor/inputColor';
33
34
  export { default as InputPesquisa } from './inputPesquisa/inputPesquisa';
34
35
  export { default as InputQRCode } from './inputQRCode/inputQRCode';
@@ -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, isDesktop, getHash } from "jcinfo-utils";
3
+ import { isDarkMode, random, isDesktop, getHash, formatValor } from "jcinfo-utils";
4
4
  import { motion, useDragControls } from "framer-motion";
5
5
  import styled from "styled-components";
6
6
  import { Dropdown, DropdownMenu, DropdownItem, DropdownToggle, Alert, Button, InputGroup, Input as Input$1 } from "reactstrap";
@@ -8901,6 +8901,36 @@ function LoadingReportView({ url, file: fileOrigin, fileTo, setLoading }) {
8901
8901
  error && /* @__PURE__ */ jsxRuntimeExports.jsx(Alerta, { onConfirm: () => setLoading(false), children: error })
8902
8902
  ] });
8903
8903
  }
8904
+ DynamicCounter.defaultProps = {
8905
+ valor: 0,
8906
+ format: false,
8907
+ currency: false
8908
+ };
8909
+ function DynamicCounter({ valor, format, currency }) {
8910
+ const [counter, setCounter] = useState(0);
8911
+ let result = counter;
8912
+ useEffect(() => {
8913
+ const executeSalt = () => {
8914
+ const salto = Math.ceil(valor / 10) + 1;
8915
+ setCounter((prev) => {
8916
+ let newValue = prev + salto;
8917
+ if (newValue > valor) {
8918
+ newValue = valor;
8919
+ }
8920
+ if (newValue === valor) {
8921
+ clearInterval(timer2);
8922
+ }
8923
+ return newValue;
8924
+ });
8925
+ };
8926
+ const timer2 = setInterval(executeSalt, 30);
8927
+ return () => clearInterval(timer2);
8928
+ }, [valor]);
8929
+ if (format) {
8930
+ result = formatValor(counter, currency ? 2 : 0, Boolean(currency));
8931
+ }
8932
+ return result;
8933
+ }
8904
8934
  const inputPesquisa = "";
8905
8935
  function InputPesquisa({
8906
8936
  search,
@@ -22067,6 +22097,7 @@ export {
22067
22097
  Confirma,
22068
22098
  DataItem,
22069
22099
  DropDownButton,
22100
+ DynamicCounter,
22070
22101
  FormEdit,
22071
22102
  FormEnter,
22072
22103
  FormatData,