@activecollab/components 1.0.402 → 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.
- package/dist/cjs/components/EditableCurrency/EditableCurrency.js +76 -0
- package/dist/cjs/components/EditableCurrency/EditableCurrency.js.map +1 -0
- package/dist/cjs/components/EditableCurrency/index.js +17 -0
- package/dist/cjs/components/EditableCurrency/index.js.map +1 -0
- package/dist/cjs/components/Icons/collection/DescriptionSmall.js +48 -0
- package/dist/cjs/components/Icons/collection/DescriptionSmall.js.map +1 -0
- package/dist/cjs/components/Icons/collection/index.js +7 -0
- package/dist/cjs/components/Icons/collection/index.js.map +1 -1
- package/dist/cjs/components/Input/InputCurrency.js.map +1 -1
- package/dist/cjs/components/Input/InputNumber.js +27 -131
- package/dist/cjs/components/Input/InputNumber.js.map +1 -1
- package/dist/cjs/hooks/index.js +11 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useInputNumber.js +147 -0
- package/dist/cjs/hooks/useInputNumber.js.map +1 -0
- package/dist/cjs/utils/currencyUtils.js +18 -15
- package/dist/cjs/utils/currencyUtils.js.map +1 -1
- package/dist/cjs/utils/currencyUtils.test.js +2 -2
- package/dist/cjs/utils/currencyUtils.test.js.map +1 -1
- package/dist/esm/components/EditableCurrency/EditableCurrency.d.ts +4 -0
- package/dist/esm/components/EditableCurrency/EditableCurrency.d.ts.map +1 -0
- package/dist/esm/components/EditableCurrency/EditableCurrency.js +63 -0
- package/dist/esm/components/EditableCurrency/EditableCurrency.js.map +1 -0
- package/dist/esm/components/EditableCurrency/index.d.ts +2 -0
- package/dist/esm/components/EditableCurrency/index.d.ts.map +1 -0
- package/dist/esm/components/EditableCurrency/index.js +2 -0
- package/dist/esm/components/EditableCurrency/index.js.map +1 -0
- package/dist/esm/components/Icons/collection/DescriptionSmall.d.ts +23 -0
- package/dist/esm/components/Icons/collection/DescriptionSmall.d.ts.map +1 -0
- package/dist/esm/components/Icons/collection/DescriptionSmall.js +41 -0
- package/dist/esm/components/Icons/collection/DescriptionSmall.js.map +1 -0
- package/dist/esm/components/Icons/collection/index.d.ts +1 -0
- package/dist/esm/components/Icons/collection/index.d.ts.map +1 -1
- package/dist/esm/components/Icons/collection/index.js +1 -0
- package/dist/esm/components/Icons/collection/index.js.map +1 -1
- package/dist/esm/components/Input/InputCurrency.d.ts +1 -1
- package/dist/esm/components/Input/InputCurrency.d.ts.map +1 -1
- package/dist/esm/components/Input/InputCurrency.js.map +1 -1
- package/dist/esm/components/Input/InputNumber.d.ts +1 -10
- package/dist/esm/components/Input/InputNumber.d.ts.map +1 -1
- package/dist/esm/components/Input/InputNumber.js +28 -124
- package/dist/esm/components/Input/InputNumber.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useInputNumber.d.ts +22 -0
- package/dist/esm/hooks/useInputNumber.d.ts.map +1 -0
- package/dist/esm/hooks/useInputNumber.js +131 -0
- package/dist/esm/hooks/useInputNumber.js.map +1 -0
- package/dist/esm/utils/currencyUtils.d.ts +8 -2
- package/dist/esm/utils/currencyUtils.d.ts.map +1 -1
- package/dist/esm/utils/currencyUtils.js +16 -14
- package/dist/esm/utils/currencyUtils.js.map +1 -1
- package/dist/esm/utils/currencyUtils.test.js +2 -2
- package/dist/esm/utils/currencyUtils.test.js.map +1 -1
- package/dist/index.js +206 -0
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export var currencyMultiplier = {
|
|
2
|
+
k: 1000,
|
|
3
|
+
m: 1000000,
|
|
4
|
+
b: 1000000000,
|
|
5
|
+
t: 1000000000000
|
|
6
|
+
};
|
|
1
7
|
export var formatCurrency = function formatCurrency(n, thousandSeparator) {
|
|
2
8
|
if (thousandSeparator === void 0) {
|
|
3
9
|
thousandSeparator = ",";
|
|
@@ -6,21 +12,17 @@ export var formatCurrency = function formatCurrency(n, thousandSeparator) {
|
|
|
6
12
|
if (isNaN(number)) {
|
|
7
13
|
return "";
|
|
8
14
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return _formattedNum.endsWith(".0") ? (number / 1000000).toFixed(0) + "M" : _formattedNum + "M";
|
|
17
|
-
} else if (number >= 1000000000 && number < 1000000000000) {
|
|
18
|
-
var _formattedNum2 = (number / 1000000000).toFixed(1);
|
|
19
|
-
return _formattedNum2.endsWith(".0") ? (number / 1000000000).toFixed(0) + "B" : _formattedNum2 + "B";
|
|
20
|
-
} else if (number >= 1000000000000 && number < 1000000000000000) {
|
|
21
|
-
var _formattedNum3 = (number / 1000000000000).toFixed(1);
|
|
22
|
-
return _formattedNum3.endsWith(".0") ? (number / 1000000000000).toFixed(0) + "T" : _formattedNum3 + "T";
|
|
15
|
+
var isNegative = number < 0;
|
|
16
|
+
var absoluteNumber = Math.abs(number);
|
|
17
|
+
var suffixes = ["", "K", "M", "B", "T"];
|
|
18
|
+
var scale = 0;
|
|
19
|
+
while (absoluteNumber >= 1000 && scale < suffixes.length - 1) {
|
|
20
|
+
absoluteNumber /= 1000;
|
|
21
|
+
scale++;
|
|
23
22
|
}
|
|
23
|
+
var formattedNum = scale === 0 ? absoluteNumber.toFixed(0) : absoluteNumber.toFixed(1);
|
|
24
|
+
var result = formattedNum.endsWith(".0") ? formattedNum.slice(0, -2) : formattedNum;
|
|
25
|
+
return isNegative ? "-" + result + suffixes[scale] : "" + result + suffixes[scale];
|
|
24
26
|
};
|
|
25
27
|
export var numberWithSeparator = function numberWithSeparator(x, thousandSeparator, format) {
|
|
26
28
|
if (format === void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currencyUtils.js","names":["formatCurrency","n","thousandSeparator","number","parseFloat","String","replaceAll","isNaN","formattedNum","toFixed","endsWith","numberWithSeparator","x","format","parts","toString","split","replace","join"],"sources":["../../../src/utils/currencyUtils.ts"],"sourcesContent":["import { Separators } from \"../
|
|
1
|
+
{"version":3,"file":"currencyUtils.js","names":["currencyMultiplier","k","m","b","t","formatCurrency","n","thousandSeparator","number","parseFloat","String","replaceAll","isNaN","isNegative","absoluteNumber","Math","abs","suffixes","scale","length","formattedNum","toFixed","result","endsWith","slice","numberWithSeparator","x","format","parts","toString","split","replace","join"],"sources":["../../../src/utils/currencyUtils.ts"],"sourcesContent":["import { Separators } from \"../hooks\";\n\nexport const currencyMultiplier = {\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 const formatCurrency = (n: string, thousandSeparator = \",\") => {\n const number = parseFloat(String(n).replaceAll(thousandSeparator, \"\"));\n\n if (isNaN(number)) {\n return \"\";\n }\n\n const isNegative = number < 0;\n let absoluteNumber = Math.abs(number);\n\n const suffixes = [\"\", \"K\", \"M\", \"B\", \"T\"];\n let scale = 0;\n\n while (absoluteNumber >= 1000 && scale < suffixes.length - 1) {\n absoluteNumber /= 1000;\n scale++;\n }\n\n const formattedNum =\n scale === 0 ? absoluteNumber.toFixed(0) : absoluteNumber.toFixed(1);\n const result = formattedNum.endsWith(\".0\")\n ? formattedNum.slice(0, -2)\n : formattedNum;\n\n return isNegative\n ? `-${result}${suffixes[scale]}`\n : `${result}${suffixes[scale]}`;\n};\n\nexport const numberWithSeparator = (\n x: number | string,\n thousandSeparator: Separators,\n format = true\n) => {\n if (!format) {\n return x;\n }\n\n const parts = x.toString().split(\".\");\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousandSeparator);\n\n return parts.join(\".\");\n};\n"],"mappings":"AAEA,OAAO,IAAMA,kBAAkB,GAAG;EAChCC,CAAC,EAAE,IAAK;EACRC,CAAC,EAAE,OAAS;EACZC,CAAC,EAAE,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IADHA,MAAM;IAANA,MAAM,GAAG,IAAI;EAAA;EAEb,IAAI,CAACA,MAAM,EAAE;IACX,OAAOD,CAAC;EACV;EAEA,IAAME,KAAK,GAAGF,CAAC,CAACG,QAAQ,EAAE,CAACC,KAAK,CAAC,GAAG,CAAC;EACrCF,KAAK,CAAC,CAAC,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,CAACG,OAAO,CAAC,uBAAuB,EAAExB,iBAAiB,CAAC;EAEvE,OAAOqB,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;AACxB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { formatCurrency, numberWithSeparator } from "./currencyUtils";
|
|
2
2
|
describe("format currency with thousandseparator set to ',' and decimalSeparator to '.'", function () {
|
|
3
|
-
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) {
|
|
3
|
+
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) {
|
|
4
4
|
expect(formatCurrency(value, ",")).toEqual(expected);
|
|
5
5
|
});
|
|
6
6
|
});
|
|
7
7
|
describe("format currency with thousandseparator set to '.' and decimalSeparator to ','", function () {
|
|
8
|
-
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) {
|
|
8
|
+
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) {
|
|
9
9
|
expect(formatCurrency(value, ".")).toEqual(expected);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currencyUtils.test.js","names":["formatCurrency","numberWithSeparator","describe","it","each","value","expected","expect","toEqual","test","result","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,SAASA,cAAc,EAAEC,mBAAmB,QAAQ,iBAAiB;AAErEC,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,
|
|
1
|
+
{"version":3,"file":"currencyUtils.test.js","names":["formatCurrency","numberWithSeparator","describe","it","each","value","expected","expect","toEqual","test","result","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,SAASA,cAA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AClE,IAAMC,MAAM,GAAGT,mBAAmB,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC;IACnDM,MAAM,CAACG,MAAM,CAAC,CAACC,IAAI,CAAC,cAAc,CAAC;EACrC,CAAC,CAAC;EAEFF,IAAI,CAAC,mBAAmB,EAAE,YAAM;IAC9B,IAAMC,MAAM,GAAGT,mBAAmB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC;IACzDM,MAAM,CAACG,MAAM,CAAC,CAACC,IAAI,CAAC,SAAS,CAAC;EAChC,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3300,6 +3300,44 @@
|
|
|
3300
3300
|
DependencyIcon.displayName = "DependencyIcon";
|
|
3301
3301
|
var DependencyIcon$1 = DependencyIcon;
|
|
3302
3302
|
|
|
3303
|
+
/**
|
|
3304
|
+
* @component DescriptionSmallIcon
|
|
3305
|
+
* @description
|
|
3306
|
+
*
|
|
3307
|
+
* The React Icon component is a visual element that displays an icon to represent a concept, object, or action.
|
|
3308
|
+
* The Icon component is
|
|
3309
|
+
* customizable, allowing for variations in size, color, and style to fit the needs of the application.
|
|
3310
|
+
*
|
|
3311
|
+
*
|
|
3312
|
+
* @example
|
|
3313
|
+
* return (
|
|
3314
|
+
* <DescriptionSmallIcon className="mr-2" />
|
|
3315
|
+
* )
|
|
3316
|
+
*
|
|
3317
|
+
* @see
|
|
3318
|
+
* https://system.activecollab.com/?path=/story/foundation-icons-icons--icons
|
|
3319
|
+
* @see
|
|
3320
|
+
* https://design.activecollab.com/docs/foundations/icons
|
|
3321
|
+
*/
|
|
3322
|
+
var DescriptionSmallIcon = /*#__PURE__*/React__default["default"].forwardRef(function (props, svgRef) {
|
|
3323
|
+
return /*#__PURE__*/React__default["default"].createElement("svg", _extends({
|
|
3324
|
+
width: 18,
|
|
3325
|
+
height: 18,
|
|
3326
|
+
viewBox: "0 0 18 18",
|
|
3327
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3328
|
+
"data-testid": "DescriptionSmallIcon",
|
|
3329
|
+
fill: "var(--color-theme-600)",
|
|
3330
|
+
focusable: false,
|
|
3331
|
+
ref: svgRef
|
|
3332
|
+
}, props), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
3333
|
+
fillRule: "evenodd",
|
|
3334
|
+
clipRule: "evenodd",
|
|
3335
|
+
d: "M15 15H3a1.5 1.5 0 01-1.5-1.5v-9A1.5 1.5 0 013 3h12a1.5 1.5 0 011.5 1.5v9A1.5 1.5 0 0115 15zM3 4.5v9h12v-9H3zm1.5 2.25h9v1.5h-9v-1.5zm0 3H12v1.5H4.5v-1.5z"
|
|
3336
|
+
}));
|
|
3337
|
+
});
|
|
3338
|
+
DescriptionSmallIcon.displayName = "DescriptionSmallIcon";
|
|
3339
|
+
var DescriptionSmallIcon$1 = DescriptionSmallIcon;
|
|
3340
|
+
|
|
3303
3341
|
/**
|
|
3304
3342
|
* @component DescriptionIcon
|
|
3305
3343
|
* @description
|
|
@@ -11008,6 +11046,172 @@
|
|
|
11008
11046
|
return height;
|
|
11009
11047
|
};
|
|
11010
11048
|
|
|
11049
|
+
var currencyMultiplier = {
|
|
11050
|
+
k: 1000,
|
|
11051
|
+
m: 1000000,
|
|
11052
|
+
b: 1000000000,
|
|
11053
|
+
t: 1000000000000
|
|
11054
|
+
};
|
|
11055
|
+
var formatCurrency = function formatCurrency(n) {
|
|
11056
|
+
var thousandSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ",";
|
|
11057
|
+
var number = parseFloat(String(n).replaceAll(thousandSeparator, ""));
|
|
11058
|
+
if (isNaN(number)) {
|
|
11059
|
+
return "";
|
|
11060
|
+
}
|
|
11061
|
+
var isNegative = number < 0;
|
|
11062
|
+
var absoluteNumber = Math.abs(number);
|
|
11063
|
+
var suffixes = ["", "K", "M", "B", "T"];
|
|
11064
|
+
var scale = 0;
|
|
11065
|
+
while (absoluteNumber >= 1000 && scale < suffixes.length - 1) {
|
|
11066
|
+
absoluteNumber /= 1000;
|
|
11067
|
+
scale++;
|
|
11068
|
+
}
|
|
11069
|
+
var formattedNum = scale === 0 ? absoluteNumber.toFixed(0) : absoluteNumber.toFixed(1);
|
|
11070
|
+
var result = formattedNum.endsWith(".0") ? formattedNum.slice(0, -2) : formattedNum;
|
|
11071
|
+
return isNegative ? "-".concat(result).concat(suffixes[scale]) : "".concat(result).concat(suffixes[scale]);
|
|
11072
|
+
};
|
|
11073
|
+
var numberWithSeparator = function numberWithSeparator(x, thousandSeparator) {
|
|
11074
|
+
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11075
|
+
if (!format) {
|
|
11076
|
+
return x;
|
|
11077
|
+
}
|
|
11078
|
+
var parts = x.toString().split(".");
|
|
11079
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
|
|
11080
|
+
return parts.join(".");
|
|
11081
|
+
};
|
|
11082
|
+
|
|
11083
|
+
var useInputNumber = function useInputNumber(_ref, ref) {
|
|
11084
|
+
var _ref$decimalSeparator = _ref.decimalSeparator,
|
|
11085
|
+
decimalSeparator = _ref$decimalSeparator === void 0 ? "." : _ref$decimalSeparator,
|
|
11086
|
+
_ref$thousandSeparato = _ref.thousandSeparator,
|
|
11087
|
+
thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
|
|
11088
|
+
disableAbbreviation = _ref.disableAbbreviation,
|
|
11089
|
+
disableMacros = _ref.disableMacros,
|
|
11090
|
+
decimalLength = _ref.decimalLength,
|
|
11091
|
+
value = _ref.value,
|
|
11092
|
+
onValueChange = _ref.onValueChange,
|
|
11093
|
+
onKeyDown = _ref.onKeyDown,
|
|
11094
|
+
onBlur = _ref.onBlur,
|
|
11095
|
+
onFocus = _ref.onFocus,
|
|
11096
|
+
step = _ref.step;
|
|
11097
|
+
var _useState = React.useState(value),
|
|
11098
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
11099
|
+
formattedValue = _useState2[0],
|
|
11100
|
+
setFormatted = _useState2[1];
|
|
11101
|
+
var _useState3 = React.useState(value),
|
|
11102
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
11103
|
+
rootValue = _useState4[0],
|
|
11104
|
+
setRootValue = _useState4[1];
|
|
11105
|
+
var _useState5 = React.useState(false),
|
|
11106
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
11107
|
+
focused = _useState6[0],
|
|
11108
|
+
setFocused = _useState6[1];
|
|
11109
|
+
var handleInputBlur = function handleInputBlur() {
|
|
11110
|
+
if (ref && ref.current) {
|
|
11111
|
+
ref.current.blur();
|
|
11112
|
+
}
|
|
11113
|
+
};
|
|
11114
|
+
var handleSelect = function handleSelect() {
|
|
11115
|
+
if (ref && ref.current) {
|
|
11116
|
+
ref.current.select();
|
|
11117
|
+
}
|
|
11118
|
+
};
|
|
11119
|
+
var handleChange = function handleChange(e) {
|
|
11120
|
+
var inputValue = e.target.value;
|
|
11121
|
+
var isValidInput = false;
|
|
11122
|
+
if (inputValue.startsWith("00")) {
|
|
11123
|
+
return;
|
|
11124
|
+
}
|
|
11125
|
+
var numericInput = disableMacros ? inputValue : inputValue.replace(/([0-9.]+)([kmbtKMBT])/, function (_, num, unit) {
|
|
11126
|
+
return (parseFloat(num) * currencyMultiplier[unit.toLowerCase()]).toString();
|
|
11127
|
+
});
|
|
11128
|
+
var regexString = "^(-?\\d{0,9}(?:[".concat(thousandSeparator, "]?\\d{0,3})*(?:\\").concat(decimalSeparator, "\\d{0,").concat(decimalLength, "})?)?$");
|
|
11129
|
+
if (thousandSeparator === ",") {
|
|
11130
|
+
isValidInput = new RegExp(regexString).test(numericInput);
|
|
11131
|
+
}
|
|
11132
|
+
if (thousandSeparator === ".") {
|
|
11133
|
+
isValidInput = new RegExp(regexString).test(numericInput);
|
|
11134
|
+
}
|
|
11135
|
+
if (!isValidInput) {
|
|
11136
|
+
return;
|
|
11137
|
+
}
|
|
11138
|
+
setFormatted(numericInput);
|
|
11139
|
+
onValueChange && onValueChange(numericInput);
|
|
11140
|
+
};
|
|
11141
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
11142
|
+
var key = e.key;
|
|
11143
|
+
var _step = parseFloat(String(step));
|
|
11144
|
+
if (key === "Escape") {
|
|
11145
|
+
handleInputBlur();
|
|
11146
|
+
}
|
|
11147
|
+
if (key === "ArrowUp") {
|
|
11148
|
+
e.preventDefault();
|
|
11149
|
+
updateValue("increment", _step);
|
|
11150
|
+
}
|
|
11151
|
+
if (key === "ArrowDown") {
|
|
11152
|
+
e.preventDefault();
|
|
11153
|
+
updateValue("decrement", _step);
|
|
11154
|
+
}
|
|
11155
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "a") {
|
|
11156
|
+
handleSelect();
|
|
11157
|
+
}
|
|
11158
|
+
if (decimalLength === 0 && e.key === decimalSeparator) {
|
|
11159
|
+
e.preventDefault();
|
|
11160
|
+
}
|
|
11161
|
+
onKeyDown && onKeyDown(e);
|
|
11162
|
+
};
|
|
11163
|
+
var handleBlur = function handleBlur(e) {
|
|
11164
|
+
if (disableAbbreviation) {
|
|
11165
|
+
setFormatted(formattedValue);
|
|
11166
|
+
} else {
|
|
11167
|
+
setFormatted(formatCurrency(formattedValue, thousandSeparator));
|
|
11168
|
+
}
|
|
11169
|
+
setRootValue(formattedValue);
|
|
11170
|
+
setFocused(false);
|
|
11171
|
+
onBlur && onBlur(e);
|
|
11172
|
+
};
|
|
11173
|
+
var handleFocus = function handleFocus(e) {
|
|
11174
|
+
setFormatted(rootValue);
|
|
11175
|
+
setFocused(true);
|
|
11176
|
+
onFocus && onFocus(e);
|
|
11177
|
+
};
|
|
11178
|
+
var updateValue = function updateValue(type, step) {
|
|
11179
|
+
var value = String(formattedValue);
|
|
11180
|
+
var decimalPart = "";
|
|
11181
|
+
var increasedValue = 0;
|
|
11182
|
+
var nonDecimalPart = value.replaceAll(thousandSeparator, "");
|
|
11183
|
+
if (!value) {
|
|
11184
|
+
return;
|
|
11185
|
+
}
|
|
11186
|
+
if (value.includes(decimalSeparator)) {
|
|
11187
|
+
nonDecimalPart = value.slice(0, value.indexOf(decimalSeparator)).replaceAll(thousandSeparator, "");
|
|
11188
|
+
}
|
|
11189
|
+
if (value.includes(decimalSeparator)) {
|
|
11190
|
+
decimalPart = value.slice(value.indexOf(decimalSeparator));
|
|
11191
|
+
}
|
|
11192
|
+
if (type === "increment") {
|
|
11193
|
+
increasedValue = parseFloat(nonDecimalPart) + step;
|
|
11194
|
+
} else {
|
|
11195
|
+
increasedValue = parseFloat(nonDecimalPart) - step;
|
|
11196
|
+
}
|
|
11197
|
+
if (value.includes(decimalSeparator)) {
|
|
11198
|
+
increasedValue = parseFloat(increasedValue.toFixed(decimalLength));
|
|
11199
|
+
}
|
|
11200
|
+
var joinedValue = numberWithSeparator(increasedValue, thousandSeparator, value.includes(thousandSeparator));
|
|
11201
|
+
setFormatted(decimalPart ? joinedValue + decimalPart : joinedValue);
|
|
11202
|
+
};
|
|
11203
|
+
return {
|
|
11204
|
+
focused: focused,
|
|
11205
|
+
formattedValue: formattedValue,
|
|
11206
|
+
rootValue: rootValue,
|
|
11207
|
+
handleChange: handleChange,
|
|
11208
|
+
handleKeyDown: handleKeyDown,
|
|
11209
|
+
handleBlur: handleBlur,
|
|
11210
|
+
handleFocus: handleFocus,
|
|
11211
|
+
onValueChange: onValueChange
|
|
11212
|
+
};
|
|
11213
|
+
};
|
|
11214
|
+
|
|
11011
11215
|
var _excluded$O = ["as", "className", "invert", "style"];
|
|
11012
11216
|
var ScrollElement = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
11013
11217
|
var _ref$as = _ref.as,
|
|
@@ -18005,6 +18209,7 @@
|
|
|
18005
18209
|
exports.DependencyIcon = DependencyIcon$1;
|
|
18006
18210
|
exports.DependencySmallIcon = DependencySmallIcon$1;
|
|
18007
18211
|
exports.DescriptionIcon = DescriptionIcon$1;
|
|
18212
|
+
exports.DescriptionSmallIcon = DescriptionSmallIcon$1;
|
|
18008
18213
|
exports.Dialog = Dialog;
|
|
18009
18214
|
exports.DiscussionAddIcon = DiscussionAddIcon$1;
|
|
18010
18215
|
exports.DiscussionIcon = DiscussionIcon$1;
|
|
@@ -18229,6 +18434,7 @@
|
|
|
18229
18434
|
exports.useForkRef = useForkRef;
|
|
18230
18435
|
exports.useHeight = useHeight;
|
|
18231
18436
|
exports.useInitScrollRef = useInitScrollRef;
|
|
18437
|
+
exports.useInputNumber = useInputNumber;
|
|
18232
18438
|
exports.useLayerContext = useLayerContext;
|
|
18233
18439
|
exports.useMenuContext = useMenuContext;
|
|
18234
18440
|
exports.useResizeObserver = useResizeObserver$1;
|