@activecollab/components 1.0.403 → 1.0.404

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.
Files changed (49) hide show
  1. package/dist/cjs/components/EditableCurrency/EditableCurrency.js +76 -0
  2. package/dist/cjs/components/EditableCurrency/EditableCurrency.js.map +1 -0
  3. package/dist/cjs/components/EditableCurrency/index.js +17 -0
  4. package/dist/cjs/components/EditableCurrency/index.js.map +1 -0
  5. package/dist/cjs/components/Input/InputCurrency.js.map +1 -1
  6. package/dist/cjs/components/Input/InputNumber.js +27 -131
  7. package/dist/cjs/components/Input/InputNumber.js.map +1 -1
  8. package/dist/cjs/hooks/index.js +11 -0
  9. package/dist/cjs/hooks/index.js.map +1 -1
  10. package/dist/cjs/hooks/useInputNumber.js +147 -0
  11. package/dist/cjs/hooks/useInputNumber.js.map +1 -0
  12. package/dist/cjs/utils/currencyUtils.js +18 -15
  13. package/dist/cjs/utils/currencyUtils.js.map +1 -1
  14. package/dist/cjs/utils/currencyUtils.test.js +2 -2
  15. package/dist/cjs/utils/currencyUtils.test.js.map +1 -1
  16. package/dist/esm/components/EditableCurrency/EditableCurrency.d.ts +4 -0
  17. package/dist/esm/components/EditableCurrency/EditableCurrency.d.ts.map +1 -0
  18. package/dist/esm/components/EditableCurrency/EditableCurrency.js +63 -0
  19. package/dist/esm/components/EditableCurrency/EditableCurrency.js.map +1 -0
  20. package/dist/esm/components/EditableCurrency/index.d.ts +2 -0
  21. package/dist/esm/components/EditableCurrency/index.d.ts.map +1 -0
  22. package/dist/esm/components/EditableCurrency/index.js +2 -0
  23. package/dist/esm/components/EditableCurrency/index.js.map +1 -0
  24. package/dist/esm/components/Input/InputCurrency.d.ts +1 -1
  25. package/dist/esm/components/Input/InputCurrency.d.ts.map +1 -1
  26. package/dist/esm/components/Input/InputCurrency.js.map +1 -1
  27. package/dist/esm/components/Input/InputNumber.d.ts +1 -10
  28. package/dist/esm/components/Input/InputNumber.d.ts.map +1 -1
  29. package/dist/esm/components/Input/InputNumber.js +28 -124
  30. package/dist/esm/components/Input/InputNumber.js.map +1 -1
  31. package/dist/esm/hooks/index.d.ts +1 -0
  32. package/dist/esm/hooks/index.d.ts.map +1 -1
  33. package/dist/esm/hooks/index.js +1 -0
  34. package/dist/esm/hooks/index.js.map +1 -1
  35. package/dist/esm/hooks/useInputNumber.d.ts +22 -0
  36. package/dist/esm/hooks/useInputNumber.d.ts.map +1 -0
  37. package/dist/esm/hooks/useInputNumber.js +131 -0
  38. package/dist/esm/hooks/useInputNumber.js.map +1 -0
  39. package/dist/esm/utils/currencyUtils.d.ts +8 -2
  40. package/dist/esm/utils/currencyUtils.d.ts.map +1 -1
  41. package/dist/esm/utils/currencyUtils.js +16 -14
  42. package/dist/esm/utils/currencyUtils.js.map +1 -1
  43. package/dist/esm/utils/currencyUtils.test.js +2 -2
  44. package/dist/esm/utils/currencyUtils.test.js.map +1 -1
  45. package/dist/index.js +167 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.min.js +1 -1
  48. package/dist/index.min.js.map +1 -1
  49. package/package.json +1 -1
@@ -2,12 +2,12 @@
2
2
 
3
3
  var _currencyUtils = require("./currencyUtils");
4
4
  describe("format currency with thousandseparator set to ',' and decimalSeparator to '.'", function () {
5
- it.each([["", ""], ["10", "10"], ["1000", "1K"], ["1000.00", "1K"], ["1200.50", "1.2K"], ["1,200.00", "1.2K"], ["2,240.00", "2.2K"], ["22,240.00", "22.2K"], ["50,000,000.00", "50M"]])("should format currency", function (value, expected) {
5
+ it.each([["", ""], ["10", "10"], ["1000", "1K"], ["1000.00", "1K"], ["1200.50", "1.2K"], ["1,200.00", "1.2K"], ["2,240.00", "2.2K"], ["22,240.00", "22.2K"], ["50,000,000.00", "50M"], ["-50,000.00", "-50K"], ["-1,200", "-1.2K"], ["-90,000,000.00", "-90M"]])("should format currency", function (value, expected) {
6
6
  expect((0, _currencyUtils.formatCurrency)(value, ",")).toEqual(expected);
7
7
  });
8
8
  });
9
9
  describe("format currency with thousandseparator set to '.' and decimalSeparator to ','", function () {
10
- it.each([["", ""], ["10", "10"], ["1000", "1K"], ["1000,00", "1K"], ["1200,50", "1.2K"], ["1.200,00", "1.2K"], ["2.240,00", "2.2K"], ["22.240,00", "22.2K"], ["50.000.000,00", "50M"]])("should format currency", function (value, expected) {
10
+ it.each([["", ""], ["10", "10"], ["1000", "1K"], ["1000,00", "1K"], ["1200,50", "1.2K"], ["1.200,00", "1.2K"], ["2.240,00", "2.2K"], ["22.240,00", "22.2K"], ["50.000.000,00", "50M"], ["-50.000,00", "-50K"], ["-1.200", "-1.2K"], ["-90.000.000,00", "-90M"]])("should format currency", function (value, expected) {
11
11
  expect((0, _currencyUtils.formatCurrency)(value, ".")).toEqual(expected);
12
12
  });
13
13
  });
@@ -1 +1 @@
1
- {"version":3,"file":"currencyUtils.test.js","names":["describe","it","each","value","expected","expect","formatCurrency","toEqual","test","result","numberWithSeparator","toBe"],"sources":["../../../src/utils/currencyUtils.test.ts"],"sourcesContent":["import { formatCurrency, numberWithSeparator } from \"./currencyUtils\";\n\ndescribe(\"format currency with thousandseparator set to ',' and decimalSeparator to '.'\", () => {\n it.each([\n [\"\", \"\"],\n [\"10\", \"10\"],\n [\"1000\", \"1K\"],\n [\"1000.00\", \"1K\"],\n [\"1200.50\", \"1.2K\"],\n [\"1,200.00\", \"1.2K\"],\n [\"2,240.00\", \"2.2K\"],\n [\"22,240.00\", \"22.2K\"],\n [\"50,000,000.00\", \"50M\"],\n ])(\"should format currency\", (value, expected) => {\n expect(formatCurrency(value, \",\")).toEqual(expected);\n });\n});\n\ndescribe(\"format currency with thousandseparator set to '.' and decimalSeparator to ','\", () => {\n it.each([\n [\"\", \"\"],\n [\"10\", \"10\"],\n [\"1000\", \"1K\"],\n [\"1000,00\", \"1K\"],\n [\"1200,50\", \"1.2K\"],\n [\"1.200,00\", \"1.2K\"],\n [\"2.240,00\", \"2.2K\"],\n [\"22.240,00\", \"22.2K\"],\n [\"50.000.000,00\", \"50M\"],\n ])(\"should format currency\", (value, expected) => {\n expect(formatCurrency(value, \".\")).toEqual(expected);\n });\n});\n\ndescribe(\"numberWithSeparator\", () => {\n test(\"should format number with thousand separator\", () => {\n const result = numberWithSeparator(1000, \",\");\n expect(result).toBe(\"1,000\");\n });\n\n test(\"should format string number with thousand separator\", () => {\n const result = numberWithSeparator(\"1000\", \",\");\n expect(result).toBe(\"1,000\");\n });\n\n test(\"should format decimal number with thousand separator and keep decimal part\", () => {\n const result = numberWithSeparator(12345.67, \",\");\n expect(result).toBe(\"12,345.67\");\n });\n\n test(\"should not format when format is set to false\", () => {\n const result = numberWithSeparator(1000, \",\", false);\n expect(result).toBe(1000);\n });\n\n test(\"should handle zero with thousand separator\", () => {\n const result = numberWithSeparator(0, \",\");\n expect(result).toBe(\"0\");\n });\n\n test(\"should handle negative number with thousand separator\", () => {\n const result = numberWithSeparator(-123456789, \",\");\n expect(result).toBe(\"-123,456,789\");\n });\n\n test(\"should not format\", () => {\n const result = numberWithSeparator(123456789, \",\", false);\n expect(result).toBe(123456789);\n });\n});\n"],"mappings":";;AAAA;AAEAA,QAAQ,CAAC,+EAA+E,EAAE,YAAM;EAC9FC,EAAE,CAACC,IAAI,CAAC,CACN,CAAC,EAAE,EAAE,EAAE,CAAC,EACR,CAAC,IAAI,EAAE,IAAI,CAAC,EACZ,CAAC,MAAM,EAAE,IAAI,CAAC,EACd,CAAC,SAAS,EAAE,IAAI,CAAC,EACjB,CAAC,SAAS,EAAE,MAAM,CAAC,EACnB,CAAC,UAAU,EAAE,MAAM,CAAC,EACpB,CAAC,UAAU,EAAE,MAAM,CAAC,EACpB,CAAC,WAAW,EAAE,OAAO,CAAC,EACtB,CAAC,eAAe,EAAE,KAAK,CAAC,CACzB,CAAC,CAAC,wBAAwB,EAAE,UAACC,KAAK,EAAEC,QAAQ,EAAK;IAChDC,MAAM,CAAC,IAAAC,6BAAc,EAACH,KAAK,EAAE,GAAG,CAAC,CAAC,CAACI,OAAO,CAACH,QA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C,WAAW,CAAC;EAClC,CAAC,CAAC;EAEFH,IAAI,CAAC,+CAA+C,EAAE,YAAM;IAC1D,IAAMC,MAAM,GAAG,IAAAC,kCAAmB,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;IACpDL,MAAM,CAACI,MAAM,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;EAC3B,CAAC,CAAC;EAEFH,IAAI,CAAC,4CAA4C,EAAE,YAAM;IACvD,IAAMC,MAAM,GAAG,IAAAC,kCAAmB,EAAC,CAAC,EAAE,GAAG,CAAC;IAC1CL,MAAM,CAACI,MAAM,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC;EAC1B,CAAC,CAAC;EAEFH,IAAI,CAAC,uDAAuD,EAAE,YAAM;IAClE,IAAMC,MAAM,GAAG,IAAAC,kCAAmB,EAAC,CAAC,SAAS,EAAE,GAAG,CAAC;IACnDL,MAAM,CAACI,MAAM,CAAC,CAACE,IAAI,CAAC,cAAc,CAAC;EACrC,CAAC,CAAC;EAEFH,IAAI,CAAC,mBAAmB,EAAE,YAAM;IAC9B,IAAMC,MAAM,GAAG,IAAAC,kCAAmB,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC;IACzDL,MAAM,CAACI,MAAM,CAAC,CAACE,IAAI,CAAC,SAAS,CAAC;EAChC,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"currencyUtils.test.js","names":["describe","it","each","value","expected","expect","formatCurrency","toEqual","test","result","numberWithSeparator","toBe"],"sources":["../../../src/utils/currencyUtils.test.ts"],"sourcesContent":["import { formatCurrency, numberWithSeparator } from \"./currencyUtils\";\n\ndescribe(\"format currency with thousandseparator set to ',' and decimalSeparator to '.'\", () => {\n it.each([\n [\"\", \"\"],\n [\"10\", \"10\"],\n [\"1000\", \"1K\"],\n [\"1000.00\", \"1K\"],\n [\"1200.50\", \"1.2K\"],\n [\"1,200.00\", \"1.2K\"],\n [\"2,240.00\", \"2.2K\"],\n [\"22,240.00\", \"22.2K\"],\n [\"50,000,000.00\", \"50M\"],\n [\"-50,000.00\", \"-50K\"],\n [\"-1,200\", \"-1.2K\"],\n [\"-90,000,000.00\", \"-90M\"],\n ])(\"should format currency\", (value, expected) => {\n expect(formatCurrency(value, \",\")).toEqual(expected);\n });\n});\n\ndescribe(\"format currency with thousandseparator set to '.' and decimalSeparator to ','\", () => {\n it.each([\n [\"\", \"\"],\n [\"10\", \"10\"],\n [\"1000\", \"1K\"],\n [\"1000,00\", \"1K\"],\n [\"1200,50\", \"1.2K\"],\n [\"1.200,00\", \"1.2K\"],\n [\"2.240,00\", \"2.2K\"],\n [\"22.240,00\", \"22.2K\"],\n [\"50.000.000,00\", \"50M\"],\n [\"-50.000,00\", \"-50K\"],\n [\"-1.200\", \"-1.2K\"],\n [\"-90.000.000,00\", \"-90M\"],\n ])(\"should format currency\", (value, expected) => {\n expect(formatCurrency(value, \".\")).toEqual(expected);\n });\n});\n\ndescribe(\"numberWithSeparator\", () => {\n test(\"should format number with thousand separator\", () => {\n const result = numberWithSeparator(1000, \",\");\n expect(result).toBe(\"1,000\");\n });\n\n test(\"should format string number with thousand separator\", () => {\n const result = numberWithSeparator(\"1000\", \",\");\n expect(result).toBe(\"1,000\");\n });\n\n test(\"should format decimal number with thousand separator and keep decimal part\", () => {\n const result = numberWithSeparator(12345.67, \",\");\n expect(result).toBe(\"12,345.67\");\n });\n\n test(\"should not format when format is set to false\", () => {\n const result = numberWithSeparator(1000, \",\", false);\n expect(result).toBe(1000);\n });\n\n test(\"should handle zero with thousand separator\", () => {\n const result = numberWithSeparator(0, \",\");\n expect(result).toBe(\"0\");\n });\n\n test(\"should handle negative number with thousand separator\", () => {\n const result = numberWithSeparator(-123456789, \",\");\n expect(result).toBe(\"-123,456,789\");\n });\n\n test(\"should not format\", () => {\n const result = numberWithSeparator(123456789, \",\", false);\n expect(result).toBe(123456789);\n });\n});\n"],"mappings":";;AAAA;AAEAA,QAAQ,CAAC,+EAA+E,EAAE,YAAM;E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AC,kCAAmB,EAAC,CAAC,SAAS,EAAE,GAAG,CAAC;IACnDL,MAAM,CAACI,MAAM,CAAC,CAACE,IAAI,CAAC,cAAc,CAAC;EACrC,CAAC,CAAC;EAEFH,IAAI,CAAC,mBAAmB,EAAE,YAAM;IAC9B,IAAMC,MAAM,GAAG,IAAAC,kCAAmB,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC;IACzDL,MAAM,CAACI,MAAM,CAAC,CAACE,IAAI,CAAC,SAAS,CAAC;EAChC,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { InputNumberProps } from "../../hooks";
3
+ export declare const EditableCurrency: React.ForwardRefExoticComponent<Omit<InputNumberProps, "size"> & React.RefAttributes<HTMLInputElement>>;
4
+ //# sourceMappingURL=EditableCurrency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditableCurrency.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableCurrency/EditableCurrency.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAMlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,gBAAgB,yGA+D5B,CAAC"}
@@ -0,0 +1,63 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ var _excluded = ["decimalLength", "decimalSeparator", "disableAbbreviation", "disabled", "disableMacros", "onValueChange", "step", "thousandSeparator", "value", "className"];
4
+ import React, { forwardRef, useRef } from "react";
5
+ import { useInputNumber } from "../../hooks";
6
+ import { EditableContent } from "../EditableContent";
7
+ import { Tooltip } from "../Tooltip";
8
+ import { useForkRef } from "../../utils";
9
+ export var EditableCurrency = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
+ var _ref$decimalLength = _ref.decimalLength,
11
+ decimalLength = _ref$decimalLength === void 0 ? 2 : _ref$decimalLength,
12
+ _ref$decimalSeparator = _ref.decimalSeparator,
13
+ decimalSeparator = _ref$decimalSeparator === void 0 ? "." : _ref$decimalSeparator,
14
+ _ref$disableAbbreviat = _ref.disableAbbreviation,
15
+ disableAbbreviation = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
16
+ disabled = _ref.disabled,
17
+ _ref$disableMacros = _ref.disableMacros,
18
+ disableMacros = _ref$disableMacros === void 0 ? false : _ref$disableMacros,
19
+ onValueChange = _ref.onValueChange,
20
+ _ref$step = _ref.step,
21
+ step = _ref$step === void 0 ? 1 : _ref$step,
22
+ _ref$thousandSeparato = _ref.thousandSeparator,
23
+ thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
24
+ value = _ref.value,
25
+ className = _ref.className,
26
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
27
+ var inputRef = useRef(null);
28
+ var handleRef = useForkRef(ref, inputRef);
29
+ var _useInputNumber = useInputNumber({
30
+ decimalLength: decimalLength,
31
+ decimalSeparator: decimalSeparator,
32
+ disableAbbreviation: disableAbbreviation,
33
+ disableMacros: disableMacros,
34
+ onValueChange: onValueChange,
35
+ step: step,
36
+ thousandSeparator: thousandSeparator,
37
+ value: value
38
+ }, inputRef),
39
+ focused = _useInputNumber.focused,
40
+ rootValue = _useInputNumber.rootValue,
41
+ formattedValue = _useInputNumber.formattedValue,
42
+ handleBlur = _useInputNumber.handleBlur,
43
+ handleChange = _useInputNumber.handleChange,
44
+ handleFocus = _useInputNumber.handleFocus,
45
+ handleKeyDown = _useInputNumber.handleKeyDown;
46
+ return /*#__PURE__*/React.createElement(Tooltip, {
47
+ title: rootValue,
48
+ disable: focused
49
+ }, /*#__PURE__*/React.createElement(EditableContent, {
50
+ disabled: disabled,
51
+ ref: handleRef,
52
+ className: className,
53
+ inputProps: _extends({
54
+ value: formattedValue,
55
+ onBlur: handleBlur,
56
+ onChange: handleChange,
57
+ onFocus: handleFocus,
58
+ onKeyDown: handleKeyDown
59
+ }, rest)
60
+ }));
61
+ });
62
+ EditableCurrency.displayName = "EditableCurrency";
63
+ //# sourceMappingURL=EditableCurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditableCurrency.js","names":["React","forwardRef","useRef","useInputNumber","EditableContent","Tooltip","useForkRef","EditableCurrency","ref","decimalLength","decimalSeparator","disableAbbreviation","disabled","disableMacros","onValueChange","step","thousandSeparator","value","className","rest","inputRef","handleRef","focused","rootValue","formattedValue","handleBlur","handleChange","handleFocus","handleKeyDown","onBlur","onChange","onFocus","onKeyDown","displayName"],"sources":["../../../../src/components/EditableCurrency/EditableCurrency.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from \"react\";\nimport { useInputNumber } from \"../../hooks\";\nimport { EditableContent } from \"../EditableContent\";\nimport { Tooltip } from \"../Tooltip\";\nimport { useForkRef } from \"../../utils\";\n\nimport type { InputNumberProps } from \"../../hooks\";\n\nexport const EditableCurrency = forwardRef<\n HTMLInputElement,\n Omit<InputNumberProps, \"size\">\n>(\n (\n {\n decimalLength = 2,\n decimalSeparator = \".\",\n disableAbbreviation = false,\n disabled,\n disableMacros = false,\n onValueChange,\n step = 1,\n thousandSeparator = \",\",\n value,\n className,\n ...rest\n },\n ref\n ) => {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const handleRef = useForkRef(ref, inputRef);\n\n const {\n focused,\n rootValue,\n formattedValue,\n handleBlur,\n handleChange,\n handleFocus,\n handleKeyDown,\n } = useInputNumber(\n {\n decimalLength,\n decimalSeparator,\n disableAbbreviation,\n disableMacros,\n onValueChange,\n step,\n thousandSeparator,\n value,\n },\n inputRef\n );\n\n return (\n <Tooltip title={rootValue as string} disable={focused}>\n <EditableContent\n disabled={disabled}\n ref={handleRef}\n className={className}\n inputProps={{\n value: formattedValue,\n onBlur: handleBlur,\n onChange: handleChange,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n ...rest,\n }}\n />\n </Tooltip>\n );\n }\n);\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AAZA,YAAY;IACZC,WAAW,mBAAXA,WAAW;IACXC,aAAa,mBAAbA,aAAa;EAef,oBACE,oBAAC,OAAO;IAAC,KAAK,EAAEL,SAAoB;IAAC,OAAO,EAAED;EAAQ,gBACpD,oBAAC,eAAe;IACd,QAAQ,EAAEV,QAAS;IACnB,GAAG,EAAES,SAAU;IACf,SAAS,EAAEH,SAAU;IACrB,UAAU;MACRD,KAAK,EAAEO,cAAc;MACrBK,MAAM,EAAEJ,UAAU;MAClBK,QAAQ,EAAEJ,YAAY;MACtBK,OAAO,EAAEJ,WAAW;MACpBK,SAAS,EAAEJ;IAAa,GACrBT,IAAI;EACP,EACF,CACM;AAEd,CAAC,CACF;AAEDZ,gBAAgB,CAAC0B,WAAW,GAAG,kBAAkB"}
@@ -0,0 +1,2 @@
1
+ export * from "./EditableCurrency";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableCurrency/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./EditableCurrency";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/EditableCurrency/index.ts"],"sourcesContent":["export * from \"./EditableCurrency\";\n"],"mappings":"AAAA,cAAc,oBAAoB"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { InputNumberProps } from "./InputNumber";
2
+ import type { InputNumberProps } from "../../hooks";
3
3
  export declare type InputCurrencyProps = InputNumberProps;
4
4
  export declare const InputCurrency: React.ForwardRefExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>;
5
5
  //# sourceMappingURL=InputCurrency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputCurrency.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/InputCurrency.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,oBAAY,kBAAkB,GAAG,gBAAgB,CAAC;AAElD,eAAO,MAAM,aAAa,2FAIzB,CAAC"}
1
+ {"version":3,"file":"InputCurrency.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/InputCurrency.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,oBAAY,kBAAkB,GAAG,gBAAgB,CAAC;AAElD,eAAO,MAAM,aAAa,2FAIzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputCurrency.js","names":["React","forwardRef","InputNumber","InputCurrency","ref","rest","displayName"],"sources":["../../../../src/components/Input/InputCurrency.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { InputNumber } from \"./InputNumber\";\nimport type { InputNumberProps } from \"./InputNumber\";\n\nexport type InputCurrencyProps = InputNumberProps;\n\nexport const InputCurrency = forwardRef<HTMLInputElement, InputCurrencyProps>(\n ({ ...rest }, ref) => {\n return <InputNumber ref={ref} {...rest} />;\n }\n);\n\nInputCurrency.displayName = \"InputCurrency\";\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,WAAW,QAAQ,eAAe;AAK3C,OAAO,IAAMC,aAAa,gBAAGF,UAAU,CACrC,gBAAcG,GAAG,EAAK;EAAA,IAAhBC,IAAI;EACR,oBAAO,oBAAC,WAAW;IAAC,GAAG,EAAED;EAAI,GAAKC,IAAI,EAAI;AAC5C,CAAC,CACF;AAEDF,aAAa,CAACG,WAAW,GAAG,eAAe"}
1
+ {"version":3,"file":"InputCurrency.js","names":["React","forwardRef","InputNumber","InputCurrency","ref","rest","displayName"],"sources":["../../../../src/components/Input/InputCurrency.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { InputNumber } from \"./InputNumber\";\nimport type { InputNumberProps } from \"../../hooks\";\n\nexport type InputCurrencyProps = InputNumberProps;\n\nexport const InputCurrency = forwardRef<HTMLInputElement, InputCurrencyProps>(\n ({ ...rest }, ref) => {\n return <InputNumber ref={ref} {...rest} />;\n }\n);\n\nInputCurrency.displayName = \"InputCurrency\";\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,WAAW,QAAQ,eAAe;AAK3C,OAAO,IAAMC,aAAa,gBAAGF,UAAU,CACrC,gBAAcG,GAAG,EAAK;EAAA,IAAhBC,IAAI;EACR,oBAAO,oBAAC,WAAW;IAAC,GAAG,EAAED;EAAI,GAAKC,IAAI,EAAI;AAC5C,CAAC,CACF;AAEDF,aAAa,CAACG,WAAW,GAAG,eAAe"}
@@ -1,13 +1,4 @@
1
1
  import React from "react";
2
- import type { InputProps } from "./Input";
3
- export declare type Separators = "." | ",";
4
- export interface InputNumberProps extends InputProps {
5
- decimalSeparator?: Separators;
6
- thousandSeparator?: Separators;
7
- disableAbbreviation?: boolean;
8
- disableMacros?: boolean;
9
- decimalLength?: number;
10
- onValueChange?: (value: string) => void;
11
- }
2
+ import { InputNumberProps } from "../../hooks";
12
3
  export declare const InputNumber: React.ForwardRefExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>;
13
4
  //# sourceMappingURL=InputNumber.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputNumber.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/InputNumber.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAS1C,oBAAY,UAAU,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnC,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,WAAW,2FA4LvB,CAAC"}
1
+ {"version":3,"file":"InputNumber.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/InputNumber.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAkB,MAAM,aAAa,CAAC;AAI/D,eAAO,MAAM,WAAW,2FA2DvB,CAAC"}
@@ -1,141 +1,45 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- var _excluded = ["disableMacros", "disableAbbreviation", "decimalLength", "thousandSeparator", "decimalSeparator", "value", "onBlur", "onKeyDown", "onFocus", "onValueChange", "disabled", "invalid", "step"];
4
- import React, { forwardRef, useRef, useState } from "react";
5
- import { Input } from "./Input";
6
- import { formatCurrency, numberWithSeparator } from "../../utils/currencyUtils";
3
+ var _excluded = ["decimalLength", "decimalSeparator", "disableAbbreviation", "disabled", "disableMacros", "invalid", "onValueChange", "step", "thousandSeparator", "value"];
4
+ import React, { forwardRef, useRef } from "react";
5
+ import { useInputNumber } from "../../hooks";
7
6
  import { useForkRef } from "../../utils";
8
- var multiplier = {
9
- k: 1000,
10
- m: 1000000,
11
- b: 1000000000,
12
- t: 1000000000000
13
- };
7
+ import { Input } from "./Input";
14
8
  export var InputNumber = /*#__PURE__*/forwardRef(function (_ref, ref) {
15
- var _ref$disableMacros = _ref.disableMacros,
16
- disableMacros = _ref$disableMacros === void 0 ? false : _ref$disableMacros,
17
- _ref$disableAbbreviat = _ref.disableAbbreviation,
18
- disableAbbreviation = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
19
- _ref$decimalLength = _ref.decimalLength,
9
+ var _ref$decimalLength = _ref.decimalLength,
20
10
  decimalLength = _ref$decimalLength === void 0 ? 2 : _ref$decimalLength,
21
- _ref$thousandSeparato = _ref.thousandSeparator,
22
- thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
23
11
  _ref$decimalSeparator = _ref.decimalSeparator,
24
12
  decimalSeparator = _ref$decimalSeparator === void 0 ? "." : _ref$decimalSeparator,
25
- value = _ref.value,
26
- onBlur = _ref.onBlur,
27
- onKeyDown = _ref.onKeyDown,
28
- onFocus = _ref.onFocus,
29
- onValueChange = _ref.onValueChange,
13
+ _ref$disableAbbreviat = _ref.disableAbbreviation,
14
+ disableAbbreviation = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
30
15
  disabled = _ref.disabled,
16
+ _ref$disableMacros = _ref.disableMacros,
17
+ disableMacros = _ref$disableMacros === void 0 ? false : _ref$disableMacros,
31
18
  invalid = _ref.invalid,
19
+ onValueChange = _ref.onValueChange,
32
20
  _ref$step = _ref.step,
33
21
  step = _ref$step === void 0 ? 1 : _ref$step,
22
+ _ref$thousandSeparato = _ref.thousandSeparator,
23
+ thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
24
+ value = _ref.value,
34
25
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
35
- var _useState = useState(value),
36
- formattedValue = _useState[0],
37
- setFormatted = _useState[1];
38
- var _useState2 = useState(value),
39
- rootValue = _useState2[0],
40
- setRootValue = _useState2[1];
41
26
  var inputRef = useRef(null);
42
27
  var handleRef = useForkRef(ref, inputRef);
43
- var handleInputBlur = function handleInputBlur() {
44
- if (inputRef && inputRef.current) {
45
- inputRef.current.blur();
46
- }
47
- };
48
- var handleSelect = function handleSelect() {
49
- if (inputRef && inputRef.current) {
50
- inputRef.current.select();
51
- }
52
- };
53
- var handleChange = function handleChange(e) {
54
- var inputValue = e.target.value;
55
- var isValidInput = false;
56
- if (inputValue.startsWith("00")) {
57
- return;
58
- }
59
- var numericInput = disableMacros ? inputValue : inputValue.replace(/([0-9.]+)([kmbtKMBT])/, function (_, num, unit) {
60
- return (parseFloat(num) * multiplier[unit.toLowerCase()]).toString();
61
- });
62
- var regexString = "^(\\d{0,9}(?:[" + thousandSeparator + "]?\\d{0,3})*(?:\\" + decimalSeparator + "\\d{0," + decimalLength + "})?)?$";
63
- if (thousandSeparator === ",") {
64
- isValidInput = new RegExp(regexString).test(numericInput);
65
- }
66
- if (thousandSeparator === ".") {
67
- isValidInput = new RegExp(regexString).test(numericInput);
68
- }
69
- if (!isValidInput) {
70
- return;
71
- }
72
- setFormatted(numericInput);
73
- onValueChange && onValueChange(numericInput);
74
- };
75
- var handleKeyDown = function handleKeyDown(e) {
76
- var allowedChars = /[0-9km.,b]/i;
77
- var key = e.key;
78
- var _step = parseFloat(String(step));
79
- if (key === "Escape") {
80
- handleInputBlur();
81
- }
82
- if (key === "ArrowUp") {
83
- e.preventDefault();
84
- updateValue("increment", _step);
85
- }
86
- if (key === "ArrowDown") {
87
- e.preventDefault();
88
- updateValue("decrement", _step);
89
- }
90
- if ((e.metaKey || e.ctrlKey) && e.key === "a") {
91
- handleSelect();
92
- }
93
- if (!allowedChars.test(key)) {
94
- e.preventDefault();
95
- }
96
- if (decimalLength === 0 && e.key === decimalSeparator) {
97
- e.preventDefault();
98
- }
99
- onKeyDown && onKeyDown(e);
100
- };
101
- var handleBlur = function handleBlur(e) {
102
- if (disableAbbreviation) {
103
- setFormatted(formattedValue);
104
- } else {
105
- setFormatted(formatCurrency(formattedValue, thousandSeparator));
106
- }
107
- setRootValue(formattedValue);
108
- onBlur && onBlur(e);
109
- };
110
- var handleFocus = function handleFocus(e) {
111
- setFormatted(rootValue);
112
- onFocus && onFocus(e);
113
- };
114
- var updateValue = function updateValue(type, step) {
115
- var value = String(formattedValue);
116
- var decimalPart = "";
117
- var increasedValue = 0;
118
- var nonDecimalPart = value.replaceAll(thousandSeparator, "");
119
- if (!value) {
120
- return;
121
- }
122
- if (value.includes(decimalSeparator)) {
123
- nonDecimalPart = value.slice(0, value.indexOf(decimalSeparator)).replaceAll(thousandSeparator, "");
124
- }
125
- if (value.includes(decimalSeparator)) {
126
- decimalPart = value.slice(value.indexOf(decimalSeparator));
127
- }
128
- if (type === "increment") {
129
- increasedValue = parseFloat(nonDecimalPart) + step;
130
- } else {
131
- increasedValue = parseFloat(nonDecimalPart) - step;
132
- }
133
- if (value.includes(decimalSeparator)) {
134
- increasedValue = parseFloat(increasedValue.toFixed(decimalLength));
135
- }
136
- var joinedValue = numberWithSeparator(increasedValue, thousandSeparator, value.includes(thousandSeparator));
137
- setFormatted(decimalPart ? joinedValue + decimalPart : joinedValue);
138
- };
28
+ var _useInputNumber = useInputNumber({
29
+ decimalLength: decimalLength,
30
+ decimalSeparator: decimalSeparator,
31
+ disableAbbreviation: disableAbbreviation,
32
+ disableMacros: disableMacros,
33
+ onValueChange: onValueChange,
34
+ step: step,
35
+ thousandSeparator: thousandSeparator,
36
+ value: value
37
+ }, inputRef),
38
+ formattedValue = _useInputNumber.formattedValue,
39
+ handleBlur = _useInputNumber.handleBlur,
40
+ handleChange = _useInputNumber.handleChange,
41
+ handleFocus = _useInputNumber.handleFocus,
42
+ handleKeyDown = _useInputNumber.handleKeyDown;
139
43
  return /*#__PURE__*/React.createElement(Input, _extends({
140
44
  ref: handleRef,
141
45
  placeholder: "5" + thousandSeparator + "000" + decimalSeparator + "00",
@@ -1 +1 @@
1
- {"version":3,"file":"InputNumber.js","names":["React","forwardRef","useRef","useState","Input","formatCurrency","numberWithSeparator","useForkRef","multiplier","k","m","b","t","InputNumber","ref","disableMacros","disableAbbreviation","decimalLength","thousandSeparator","decimalSeparator","value","onBlur","onKeyDown","onFocus","onValueChange","disabled","invalid","step","rest","formattedValue","setFormatted","rootValue","setRootValue","inputRef","handleRef","handleInputBlur","current","blur","handleSelect","select","handleChange","e","inputValue","target","isValidInput","startsWith","numericInput","replace","_","num","unit","parseFloat","toLowerCase","toString","regexString","RegExp","test","handleKeyDown","allowedChars","key","_step","String","preventDefault","updateValue","metaKey","ctrlKey","handleBlur","handleFocus","type","decimalPart","increasedValue","nonDecimalPart","replaceAll","includes","slice","indexOf","toFixed","joinedValue","displayName"],"sources":["../../../../src/components/Input/InputNumber.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n forwardRef,\n FocusEventHandler,\n KeyboardEventHandler,\n useRef,\n useState,\n} from \"react\";\nimport { Input } from \"./Input\";\nimport { formatCurrency, numberWithSeparator } from \"../../utils/currencyUtils\";\nimport { useForkRef } from \"../../utils\";\n\nimport type { InputProps } from \"./Input\";\n\nconst multiplier = {\n k: 1_000,\n m: 1_000_000,\n b: 1_000_000_000,\n t: 1_000_000_000_000,\n};\n\nexport type Separators = \".\" | \",\";\n\nexport interface InputNumberProps extends InputProps {\n decimalSeparator?: Separators;\n thousandSeparator?: Separators;\n disableAbbreviation?: boolean;\n disableMacros?: boolean;\n decimalLength?: number;\n onValueChange?: (value: string) => void;\n}\n\nexport const InputNumber = forwardRef<HTMLInputElement, InputNumberProps>(\n (\n {\n disableMacros = false,\n disableAbbreviation = false,\n decimalLength = 2,\n thousandSeparator = \",\",\n decimalSeparator = \".\",\n value,\n onBlur,\n onKeyDown,\n onFocus,\n onValueChange,\n disabled,\n invalid,\n step = 1,\n ...rest\n },\n ref\n ) => {\n const [formattedValue, setFormatted] = useState(value);\n const [rootValue, setRootValue] = useState(value);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, inputRef);\n\n const handleInputBlur = () => {\n if (inputRef && inputRef.current) {\n inputRef.current.blur();\n }\n };\n\n const handleSelect = () => {\n if (inputRef && inputRef.current) {\n inputRef.current.select();\n }\n };\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const inputValue = e.target.value;\n let isValidInput = false;\n\n if (inputValue.startsWith(\"00\")) {\n return;\n }\n\n const numericInput = disableMacros\n ? inputValue\n : inputValue.replace(/([0-9.]+)([kmbtKMBT])/, (_, num, unit) => {\n return (\n parseFloat(num) * multiplier[unit.toLowerCase()]\n ).toString();\n });\n\n const regexString = `^(\\\\d{0,9}(?:[${thousandSeparator}]?\\\\d{0,3})*(?:\\\\${decimalSeparator}\\\\d{0,${decimalLength}})?)?$`;\n\n if (thousandSeparator === \",\") {\n isValidInput = new RegExp(regexString).test(numericInput);\n }\n\n if (thousandSeparator === \".\") {\n isValidInput = new RegExp(regexString).test(numericInput);\n }\n\n if (!isValidInput) {\n return;\n }\n\n setFormatted(numericInput);\n\n onValueChange && onValueChange(numericInput);\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (e) => {\n const allowedChars = /[0-9km.,b]/i;\n const key = e.key;\n const _step = parseFloat(String(step));\n\n if (key === \"Escape\") {\n handleInputBlur();\n }\n\n if (key === \"ArrowUp\") {\n e.preventDefault();\n\n updateValue(\"increment\", _step);\n }\n\n if (key === \"ArrowDown\") {\n e.preventDefault();\n\n updateValue(\"decrement\", _step);\n }\n\n if ((e.metaKey || e.ctrlKey) && e.key === \"a\") {\n handleSelect();\n }\n\n if (!allowedChars.test(key)) {\n e.preventDefault();\n }\n\n if (decimalLength === 0 && e.key === decimalSeparator) {\n e.preventDefault();\n }\n\n onKeyDown && onKeyDown(e);\n };\n\n const handleBlur: FocusEventHandler<HTMLInputElement> = (e) => {\n if (disableAbbreviation) {\n setFormatted(formattedValue);\n } else {\n setFormatted(\n formatCurrency(formattedValue as string, thousandSeparator)\n );\n }\n\n setRootValue(formattedValue);\n\n onBlur && onBlur(e);\n };\n\n const handleFocus: FocusEventHandler<HTMLInputElement> = (e) => {\n setFormatted(rootValue);\n\n onFocus && onFocus(e);\n };\n\n const updateValue = (type: \"increment\" | \"decrement\", step: number) => {\n const value = String(formattedValue);\n\n let decimalPart = \"\";\n let increasedValue = 0;\n let nonDecimalPart = value.replaceAll(thousandSeparator, \"\");\n\n if (!value) {\n return;\n }\n\n if (value.includes(decimalSeparator)) {\n nonDecimalPart = value\n .slice(0, value.indexOf(decimalSeparator))\n .replaceAll(thousandSeparator, \"\");\n }\n\n if (value.includes(decimalSeparator)) {\n decimalPart = value.slice(value.indexOf(decimalSeparator));\n }\n\n if (type === \"increment\") {\n increasedValue = parseFloat(nonDecimalPart) + step;\n } else {\n increasedValue = parseFloat(nonDecimalPart) - step;\n }\n\n if (value.includes(decimalSeparator)) {\n increasedValue = parseFloat(increasedValue.toFixed(decimalLength));\n }\n\n const joinedValue = numberWithSeparator(\n increasedValue,\n thousandSeparator,\n value.includes(thousandSeparator)\n );\n\n setFormatted(decimalPart ? joinedValue + decimalPart : joinedValue);\n };\n\n return (\n <Input\n ref={handleRef}\n placeholder={`5${thousandSeparator}000${decimalSeparator}00`}\n value={formattedValue}\n type=\"text\"\n disabled={disabled}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n aria-placeholder={`5${thousandSeparator}000${decimalSeparator}00`}\n aria-disabled={disabled}\n aria-invalid={invalid}\n {...rest}\n />\n );\n }\n);\n\nInputNumber.displayName = \"InputNumber\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAEVC,UAAU,EAGVC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,KAAK,QAAQ,SAAS;AAC/B,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,2BAA2B;AAC/E,SAASC,UAAU,QAAQ,aAAa;AAIxC,IAAMC,UAAU,GAAG;EACjBC,CAAC,EAAE,IAAK;EACRC,CAAC,EAAE,OAAS;EACZC,CAAC,EAAE,UAAa;EAChBC,CAAC,EAAE;AACL,CAAC;AAaD,OAAO,IAAMC,WAAW,gBAAGZ,UAAU,CACnC,gBAiBEa,GAAG,EACA;EAAA,8BAhBDC,aAAa;IAAbA,aAAa,mCAAG,KAAK;IAAA,6BACrBC,mBAAmB;IAAnBA,mBAAmB,sCAAG,KAAK;IAAA,0BAC3BC,aAA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AeM,QAAS;IACxB,gBAAcC;EAAQ,GAClBE,IAAI,EACR;AAEN,CAAC,CACF;AAEDf,WAAW,CAACiE,WAAW,GAAG,aAAa"}
1
+ {"version":3,"file":"InputNumber.js","names":["React","forwardRef","useRef","useInputNumber","useForkRef","Input","InputNumber","ref","decimalLength","decimalSeparator","disableAbbreviation","disabled","disableMacros","invalid","onValueChange","step","thousandSeparator","value","rest","inputRef","handleRef","formattedValue","handleBlur","handleChange","handleFocus","handleKeyDown","displayName"],"sources":["../../../../src/components/Input/InputNumber.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from \"react\";\nimport { InputNumberProps, useInputNumber } from \"../../hooks\";\nimport { useForkRef } from \"../../utils\";\nimport { Input } from \"./Input\";\n\nexport const InputNumber = forwardRef<HTMLInputElement, InputNumberProps>(\n (\n {\n decimalLength = 2,\n decimalSeparator = \".\",\n disableAbbreviation = false,\n disabled,\n disableMacros = false,\n invalid,\n onValueChange,\n step = 1,\n thousandSeparator = \",\",\n value,\n ...rest\n },\n ref\n ) => {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const handleRef = useForkRef(ref, inputRef);\n\n const {\n formattedValue,\n handleBlur,\n handleChange,\n handleFocus,\n handleKeyDown,\n } = useInputNumber(\n {\n decimalLength,\n decimalSeparator,\n disableAbbreviation,\n disableMacros,\n onValueChange,\n step,\n thousandSeparator,\n value,\n },\n inputRef\n );\n\n return (\n <Input\n ref={handleRef}\n placeholder={`5${thousandSeparator}000${decimalSeparator}00`}\n value={formattedValue}\n type=\"text\"\n disabled={disabled}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n aria-placeholder={`5${thousandSeparator}000${decimalSeparator}00`}\n aria-disabled={disabled}\n aria-invalid={invalid}\n {...rest}\n />\n );\n }\n);\n\nInputNumber.displayName = \"InputNumber\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,MAAM,QAAQ,OAAO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e;IACtB,IAAI,EAAC,MAAM;IACX,QAAQ,EAAEV,QAAS;IACnB,OAAO,EAAEE,OAAQ;IACjB,QAAQ,EAAEU,YAAa;IACvB,OAAO,EAAEC,WAAY;IACrB,MAAM,EAAEF,UAAW;IACnB,SAAS,EAAEG,aAAc;IACzB,0BAAsBT,iBAAiB,WAAMP,gBAAgB,OAAK;IAClE,iBAAeE,QAAS;IACxB,gBAAcE;EAAQ,GAClBK,IAAI,EACR;AAEN,CAAC,CACF;AAEDZ,WAAW,CAACoB,WAAW,GAAG,aAAa"}
@@ -1,3 +1,4 @@
1
1
  export * from "./useInitScrollRef";
2
2
  export * from "./useHeight";
3
+ export * from "./useInputNumber";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./useInitScrollRef";
2
2
  export * from "./useHeight";
3
+ export * from "./useInputNumber";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from \"./useInitScrollRef\";\nexport * from \"./useHeight\";\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,aAAa"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from \"./useInitScrollRef\";\nexport * from \"./useHeight\";\nexport * from \"./useInputNumber\";\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,kBAAkB"}
@@ -0,0 +1,22 @@
1
+ import { ChangeEventHandler, KeyboardEventHandler, FocusEventHandler, MutableRefObject } from "react";
2
+ import type { InputProps } from "../components";
3
+ export declare type Separators = "." | ",";
4
+ export interface InputNumberProps extends InputProps {
5
+ decimalLength?: number;
6
+ decimalSeparator?: Separators;
7
+ disableAbbreviation?: boolean;
8
+ disableMacros?: boolean;
9
+ thousandSeparator?: Separators;
10
+ onValueChange?: (value: string) => void;
11
+ }
12
+ export declare const useInputNumber: ({ decimalSeparator, thousandSeparator, disableAbbreviation, disableMacros, decimalLength, value, onValueChange, onKeyDown, onBlur, onFocus, step, }: InputNumberProps, ref: MutableRefObject<HTMLInputElement | null>) => {
13
+ readonly focused: boolean;
14
+ readonly formattedValue: string | number | readonly string[] | undefined;
15
+ readonly rootValue: string | number | readonly string[] | undefined;
16
+ readonly handleChange: ChangeEventHandler<HTMLInputElement>;
17
+ readonly handleKeyDown: KeyboardEventHandler<HTMLInputElement>;
18
+ readonly handleBlur: FocusEventHandler<HTMLInputElement>;
19
+ readonly handleFocus: FocusEventHandler<HTMLInputElement>;
20
+ readonly onValueChange: ((value: string) => void) | undefined;
21
+ };
22
+ //# sourceMappingURL=useInputNumber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInputNumber.d.ts","sourceRoot":"","sources":["../../../src/hooks/useInputNumber.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAMf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,oBAAY,UAAU,GAAG,GAAG,GAAG,GAAG,CAAC;AAInC,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,cAAc,wJAatB,gBAAgB,OACd,iBAAiB,gBAAgB,GAAG,IAAI,CAAC;;;;;;;;qCAjBtB,MAAM,KAAK,IAAI;CA2KxC,CAAC"}
@@ -0,0 +1,131 @@
1
+ import { useState } from "react";
2
+ import { currencyMultiplier, formatCurrency, numberWithSeparator } from "../utils/currencyUtils";
3
+ export var useInputNumber = function useInputNumber(_ref, ref) {
4
+ var _ref$decimalSeparator = _ref.decimalSeparator,
5
+ decimalSeparator = _ref$decimalSeparator === void 0 ? "." : _ref$decimalSeparator,
6
+ _ref$thousandSeparato = _ref.thousandSeparator,
7
+ thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
8
+ disableAbbreviation = _ref.disableAbbreviation,
9
+ disableMacros = _ref.disableMacros,
10
+ decimalLength = _ref.decimalLength,
11
+ value = _ref.value,
12
+ onValueChange = _ref.onValueChange,
13
+ onKeyDown = _ref.onKeyDown,
14
+ onBlur = _ref.onBlur,
15
+ onFocus = _ref.onFocus,
16
+ step = _ref.step;
17
+ var _useState = useState(value),
18
+ formattedValue = _useState[0],
19
+ setFormatted = _useState[1];
20
+ var _useState2 = useState(value),
21
+ rootValue = _useState2[0],
22
+ setRootValue = _useState2[1];
23
+ var _useState3 = useState(false),
24
+ focused = _useState3[0],
25
+ setFocused = _useState3[1];
26
+ var handleInputBlur = function handleInputBlur() {
27
+ if (ref && ref.current) {
28
+ ref.current.blur();
29
+ }
30
+ };
31
+ var handleSelect = function handleSelect() {
32
+ if (ref && ref.current) {
33
+ ref.current.select();
34
+ }
35
+ };
36
+ var handleChange = function handleChange(e) {
37
+ var inputValue = e.target.value;
38
+ var isValidInput = false;
39
+ if (inputValue.startsWith("00")) {
40
+ return;
41
+ }
42
+ var numericInput = disableMacros ? inputValue : inputValue.replace(/([0-9.]+)([kmbtKMBT])/, function (_, num, unit) {
43
+ return (parseFloat(num) * currencyMultiplier[unit.toLowerCase()]).toString();
44
+ });
45
+ var regexString = "^(-?\\d{0,9}(?:[" + thousandSeparator + "]?\\d{0,3})*(?:\\" + decimalSeparator + "\\d{0," + decimalLength + "})?)?$";
46
+ if (thousandSeparator === ",") {
47
+ isValidInput = new RegExp(regexString).test(numericInput);
48
+ }
49
+ if (thousandSeparator === ".") {
50
+ isValidInput = new RegExp(regexString).test(numericInput);
51
+ }
52
+ if (!isValidInput) {
53
+ return;
54
+ }
55
+ setFormatted(numericInput);
56
+ onValueChange && onValueChange(numericInput);
57
+ };
58
+ var handleKeyDown = function handleKeyDown(e) {
59
+ var key = e.key;
60
+ var _step = parseFloat(String(step));
61
+ if (key === "Escape") {
62
+ handleInputBlur();
63
+ }
64
+ if (key === "ArrowUp") {
65
+ e.preventDefault();
66
+ updateValue("increment", _step);
67
+ }
68
+ if (key === "ArrowDown") {
69
+ e.preventDefault();
70
+ updateValue("decrement", _step);
71
+ }
72
+ if ((e.metaKey || e.ctrlKey) && e.key === "a") {
73
+ handleSelect();
74
+ }
75
+ if (decimalLength === 0 && e.key === decimalSeparator) {
76
+ e.preventDefault();
77
+ }
78
+ onKeyDown && onKeyDown(e);
79
+ };
80
+ var handleBlur = function handleBlur(e) {
81
+ if (disableAbbreviation) {
82
+ setFormatted(formattedValue);
83
+ } else {
84
+ setFormatted(formatCurrency(formattedValue, thousandSeparator));
85
+ }
86
+ setRootValue(formattedValue);
87
+ setFocused(false);
88
+ onBlur && onBlur(e);
89
+ };
90
+ var handleFocus = function handleFocus(e) {
91
+ setFormatted(rootValue);
92
+ setFocused(true);
93
+ onFocus && onFocus(e);
94
+ };
95
+ var updateValue = function updateValue(type, step) {
96
+ var value = String(formattedValue);
97
+ var decimalPart = "";
98
+ var increasedValue = 0;
99
+ var nonDecimalPart = value.replaceAll(thousandSeparator, "");
100
+ if (!value) {
101
+ return;
102
+ }
103
+ if (value.includes(decimalSeparator)) {
104
+ nonDecimalPart = value.slice(0, value.indexOf(decimalSeparator)).replaceAll(thousandSeparator, "");
105
+ }
106
+ if (value.includes(decimalSeparator)) {
107
+ decimalPart = value.slice(value.indexOf(decimalSeparator));
108
+ }
109
+ if (type === "increment") {
110
+ increasedValue = parseFloat(nonDecimalPart) + step;
111
+ } else {
112
+ increasedValue = parseFloat(nonDecimalPart) - step;
113
+ }
114
+ if (value.includes(decimalSeparator)) {
115
+ increasedValue = parseFloat(increasedValue.toFixed(decimalLength));
116
+ }
117
+ var joinedValue = numberWithSeparator(increasedValue, thousandSeparator, value.includes(thousandSeparator));
118
+ setFormatted(decimalPart ? joinedValue + decimalPart : joinedValue);
119
+ };
120
+ return {
121
+ focused: focused,
122
+ formattedValue: formattedValue,
123
+ rootValue: rootValue,
124
+ handleChange: handleChange,
125
+ handleKeyDown: handleKeyDown,
126
+ handleBlur: handleBlur,
127
+ handleFocus: handleFocus,
128
+ onValueChange: onValueChange
129
+ };
130
+ };
131
+ //# sourceMappingURL=useInputNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInputNumber.js","names":["useState","currencyMultiplier","formatCurrency","numberWithSeparator","useInputNumber","ref","decimalSeparator","thousandSeparator","disableAbbreviation","disableMacros","decimalLength","value","onValueChange","onKeyDown","onBlur","onFocus","step","formattedValue","setFormatted","rootValue","setRootValue","focused","setFocused","handleInputBlur","current","blur","handleSelect","select","handleChange","e","inputValue","target","isValidInput","startsWith","numericInput","replace","_","num","unit","parseFloat","toLowerCase","toString","regexString","RegExp","test","handleKeyDown","key","_step","String","preventDefault","updateValue","metaKey","ctrlKey","handleBlur","handleFocus","type","decimalPart","increasedValue","nonDecimalPart","replaceAll","includes","slice","indexOf","toFixed","joinedValue"],"sources":["../../../src/hooks/useInputNumber.tsx"],"sourcesContent":["import {\n useState,\n ChangeEventHandler,\n KeyboardEventHandler,\n FocusEventHandler,\n MutableRefObject,\n} from \"react\";\nimport {\n currencyMultiplier,\n formatCurrency,\n numberWithSeparator,\n} from \"../utils/currencyUtils\";\nimport type { InputProps } from \"../components\";\n\nexport type Separators = \".\" | \",\";\n\n// https://www.youtube.com/watch?v=2AilA-M6N5U\n// @TODO: Pitati foo za testove.\nexport interface InputNumberProps extends InputProps {\n decimalLength?: number;\n decimalSeparator?: Separators;\n disableAbbreviation?: boolean;\n disableMacros?: boolean;\n thousandSeparator?: Separators;\n onValueChange?: (value: string) => void;\n}\n\nexport const useInputNumber = (\n {\n decimalSeparator = \".\",\n thousandSeparator = \",\",\n disableAbbreviation,\n disableMacros,\n decimalLength,\n value,\n onValueChange,\n onKeyDown,\n onBlur,\n onFocus,\n step,\n }: InputNumberProps,\n ref: MutableRefObject<HTMLInputElement | null>\n) => {\n const [formattedValue, setFormatted] = useState(value);\n const [rootValue, setRootValue] = useState(value);\n const [focused, setFocused] = useState<boolean>(false);\n\n const handleInputBlur = () => {\n if (ref && ref.current) {\n ref.current.blur();\n }\n };\n\n const handleSelect = () => {\n if (ref && ref.current) {\n ref.current.select();\n }\n };\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const inputValue = e.target.value;\n let isValidInput = false;\n\n if (inputValue.startsWith(\"00\")) {\n return;\n }\n\n const numericInput = disableMacros\n ? inputValue\n : inputValue.replace(/([0-9.]+)([kmbtKMBT])/, (_, num, unit) => {\n return (\n parseFloat(num) * currencyMultiplier[unit.toLowerCase()]\n ).toString();\n });\n\n const regexString = `^(-?\\\\d{0,9}(?:[${thousandSeparator}]?\\\\d{0,3})*(?:\\\\${decimalSeparator}\\\\d{0,${decimalLength}})?)?$`;\n\n if (thousandSeparator === \",\") {\n isValidInput = new RegExp(regexString).test(numericInput);\n }\n\n if (thousandSeparator === \".\") {\n isValidInput = new RegExp(regexString).test(numericInput);\n }\n\n if (!isValidInput) {\n return;\n }\n\n setFormatted(numericInput);\n\n onValueChange && onValueChange(numericInput);\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (e) => {\n const key = e.key;\n const _step = parseFloat(String(step));\n\n if (key === \"Escape\") {\n handleInputBlur();\n }\n\n if (key === \"ArrowUp\") {\n e.preventDefault();\n\n updateValue(\"increment\", _step);\n }\n\n if (key === \"ArrowDown\") {\n e.preventDefault();\n\n updateValue(\"decrement\", _step);\n }\n\n if ((e.metaKey || e.ctrlKey) && e.key === \"a\") {\n handleSelect();\n }\n\n if (decimalLength === 0 && e.key === decimalSeparator) {\n e.preventDefault();\n }\n\n onKeyDown && onKeyDown(e);\n };\n\n const handleBlur: FocusEventHandler<HTMLInputElement> = (e) => {\n if (disableAbbreviation) {\n setFormatted(formattedValue);\n } else {\n setFormatted(formatCurrency(formattedValue as string, thousandSeparator));\n }\n\n setRootValue(formattedValue);\n setFocused(false);\n\n onBlur && onBlur(e);\n };\n\n const handleFocus: FocusEventHandler<HTMLInputElement> = (e) => {\n setFormatted(rootValue);\n setFocused(true);\n\n onFocus && onFocus(e);\n };\n\n const updateValue = (type: \"increment\" | \"decrement\", step: number) => {\n const value = String(formattedValue);\n\n let decimalPart = \"\";\n let increasedValue = 0;\n let nonDecimalPart = value.replaceAll(thousandSeparator, \"\");\n\n if (!value) {\n return;\n }\n\n if (value.includes(decimalSeparator)) {\n nonDecimalPart = value\n .slice(0, value.indexOf(decimalSeparator))\n .replaceAll(thousandSeparator, \"\");\n }\n\n if (value.includes(decimalSeparator)) {\n decimalPart = value.slice(value.indexOf(decimalSeparator));\n }\n\n if (type === \"increment\") {\n increasedValue = parseFloat(nonDecimalPart) + step;\n } else {\n increasedValue = parseFloat(nonDecimalPart) - step;\n }\n\n if (value.includes(decimalSeparator)) {\n increasedValue = parseFloat(increasedValue.toFixed(decimalLength));\n }\n\n const joinedValue = numberWithSeparator(\n increasedValue,\n thousandSeparator,\n value.includes(thousandSeparator)\n );\n\n setFormatted(decimalPart ? joinedValue + decimalPart : joinedValue);\n };\n\n return {\n focused,\n formattedValue,\n rootValue,\n handleChange,\n handleKeyDown,\n handleBlur,\n handleFocus,\n onValueChange,\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tD,gBAAgB,CAAC,EAAE;MACpCoD,cAAc,GAAG/C,KAAK,CACnBkD,KAAK,CAAC,CAAC,EAAElD,KAAK,CAACmD,OAAO,CAACxD,gBAAgB,CAAC,CAAC,CACzCqD,UAAU,CAACpD,iBAAiB,EAAE,EAAE,CAAC;IACtC;IAEA,IAAII,KAAK,CAACiD,QAAQ,CAACtD,gBAAgB,CAAC,EAAE;MACpCkD,WAAW,GAAG7C,KAAK,CAACkD,KAAK,CAAClD,KAAK,CAACmD,OAAO,CAACxD,gBAAgB,CAAC,CAAC;IAC5D;IAEA,IAAIiD,IAAI,KAAK,WAAW,EAAE;MACxBE,cAAc,GAAGlB,UAAU,CAACmB,cAAc,CAAC,GAAG1C,IAAI;IACpD,CAAC,MAAM;MACLyC,cAAc,GAAGlB,UAAU,CAACmB,cAAc,CAAC,GAAG1C,IAAI;IACpD;IAEA,IAAIL,KAAK,CAACiD,QAAQ,CAACtD,gBAAgB,CAAC,EAAE;MACpCmD,cAAc,GAAGlB,UAAU,CAACkB,cAAc,CAACM,OAAO,CAACrD,aAAa,CAAC,CAAC;IACpE;IAEA,IAAMsD,WAAW,GAAG7D,mBAAmB,CACrCsD,cAAc,EACdlD,iBAAiB,EACjBI,KAAK,CAACiD,QAAQ,CAACrD,iBAAiB,CAAC,CAClC;IAEDW,YAAY,CAACsC,WAAW,GAAGQ,WAAW,GAAGR,WAAW,GAAGQ,WAAW,CAAC;EACrE,CAAC;EAED,OAAO;IACL3C,OAAO,EAAPA,OAAO;IACPJ,cAAc,EAAdA,cAAc;IACdE,SAAS,EAATA,SAAS;IACTS,YAAY,EAAZA,YAAY;IACZiB,aAAa,EAAbA,aAAa;IACbQ,UAAU,EAAVA,UAAU;IACVC,WAAW,EAAXA,WAAW;IACX1C,aAAa,EAAbA;EACF,CAAC;AACH,CAAC"}
@@ -1,4 +1,10 @@
1
- import { Separators } from "../components/Input/InputNumber";
2
- export declare const formatCurrency: (n: string, thousandSeparator?: string) => string | undefined;
1
+ import { Separators } from "../hooks";
2
+ export declare const currencyMultiplier: {
3
+ k: number;
4
+ m: number;
5
+ b: number;
6
+ t: number;
7
+ };
8
+ export declare const formatCurrency: (n: string, thousandSeparator?: string) => string;
3
9
  export declare const numberWithSeparator: (x: number | string, thousandSeparator: Separators, format?: boolean) => string | number;
4
10
  //# sourceMappingURL=currencyUtils.d.ts.map