@rio-cloud/rio-uikit 1.10.0 → 1.11.0
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/.DS_Store +0 -0
- package/components/assetTree/AssetTree.js +1 -1
- package/components/assetTree/Tree.d.ts +6 -0
- package/components/assetTree/Tree.js +2 -2
- package/components/assetTree/TreeNode.d.ts +1 -0
- package/components/assetTree/TreeNode.js +3 -2
- package/components/dialog/SplitDialog.d.ts +6 -0
- package/components/dialog/SplitDialog.js +2 -2
- package/components/filepicker/FilePicker.d.ts +1 -1
- package/components/formLabel/FormLabel.js +1 -1
- package/components/map/components/Map.js +70 -68
- package/components/map/components/features/settings/builtinSettings/MapTypeSettings.d.ts +1 -1
- package/components/map/utils/rendering.d.ts +1 -1
- package/components/map/utils/rendering.js +7 -11
- package/hooks/useAverage.d.ts +18 -0
- package/hooks/useAverage.js +28 -0
- package/hooks/useCount.d.ts +22 -0
- package/hooks/useCount.js +31 -0
- package/hooks/useMax.d.ts +18 -0
- package/hooks/useMax.js +24 -0
- package/hooks/useMin.d.ts +18 -0
- package/hooks/useMin.js +24 -0
- package/hooks/useSum.d.ts +18 -0
- package/hooks/useSum.js +23 -0
- package/lib/es/components/assetTree/AssetTree.js +1 -1
- package/lib/es/components/assetTree/Tree.d.ts +6 -0
- package/lib/es/components/assetTree/Tree.js +2 -2
- package/lib/es/components/assetTree/TreeNode.d.ts +1 -0
- package/lib/es/components/assetTree/TreeNode.js +3 -2
- package/lib/es/components/dialog/SplitDialog.d.ts +6 -0
- package/lib/es/components/dialog/SplitDialog.js +2 -2
- package/lib/es/components/filepicker/FilePicker.d.ts +1 -1
- package/lib/es/components/formLabel/FormLabel.js +1 -1
- package/lib/es/components/map/components/Map.js +70 -68
- package/lib/es/components/map/components/features/settings/builtinSettings/MapTypeSettings.d.ts +1 -1
- package/lib/es/components/map/utils/rendering.d.ts +1 -1
- package/lib/es/components/map/utils/rendering.js +7 -11
- package/lib/es/hooks/useAverage.d.ts +18 -0
- package/lib/es/hooks/useAverage.js +30 -0
- package/lib/es/hooks/useCount.d.ts +22 -0
- package/lib/es/hooks/useCount.js +33 -0
- package/lib/es/hooks/useMax.d.ts +18 -0
- package/lib/es/hooks/useMax.js +26 -0
- package/lib/es/hooks/useMin.d.ts +18 -0
- package/lib/es/hooks/useMin.js +26 -0
- package/lib/es/hooks/useSum.d.ts +18 -0
- package/lib/es/hooks/useSum.js +25 -0
- package/lib/es/useAverage.d.ts +2 -0
- package/lib/es/useAverage.js +7 -0
- package/lib/es/useCount.d.ts +2 -0
- package/lib/es/useCount.js +7 -0
- package/lib/es/useMax.d.ts +2 -0
- package/lib/es/useMax.js +7 -0
- package/lib/es/useMin.d.ts +2 -0
- package/lib/es/useMin.js +7 -0
- package/lib/es/useSum.d.ts +2 -0
- package/lib/es/useSum.js +7 -0
- package/lib/es/utils/formatUtils.d.ts +16 -0
- package/lib/es/utils/formatUtils.js +55 -0
- package/lib/es/version.json +1 -1
- package/package.json +6 -6
- package/useAverage.d.ts +2 -0
- package/useAverage.js +2 -0
- package/useCount.d.ts +2 -0
- package/useCount.js +2 -0
- package/useMax.d.ts +2 -0
- package/useMax.js +2 -0
- package/useMin.d.ts +2 -0
- package/useMin.js +2 -0
- package/useSum.d.ts +2 -0
- package/useSum.js +2 -0
- package/utils/formatUtils.d.ts +16 -0
- package/utils/formatUtils.js +49 -0
- package/version.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValueByPath = exports.parseNumberFromValue = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const isNil_1 = tslib_1.__importDefault(require("lodash/fp/isNil"));
|
|
6
|
+
/**
|
|
7
|
+
* Helper to extract a number from a string that may have units or grouping delimiters. It take localization into account.
|
|
8
|
+
*
|
|
9
|
+
* @param value
|
|
10
|
+
* @param locale
|
|
11
|
+
* @returns parsed number
|
|
12
|
+
*/
|
|
13
|
+
const parseNumberFromValue = (value, locale) => {
|
|
14
|
+
if ((0, isNil_1.default)(value)) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'number') {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value !== 'string') {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
const example = 1234567.89;
|
|
24
|
+
const parts = new Intl.NumberFormat(locale).formatToParts(example);
|
|
25
|
+
const groupSymbol = parts.find(p => p.type === 'group')?.value ?? ',';
|
|
26
|
+
const decimalSymbol = parts.find(p => p.type === 'decimal')?.value ?? '.';
|
|
27
|
+
// Extract numeric part only (up to last digit or decimal), ignore units
|
|
28
|
+
const match = value.match(/[-\d.,'\u00A0\s]+/);
|
|
29
|
+
if (!match) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
let numeric = match[0].trim();
|
|
33
|
+
// Normalize: remove group symbols (thousand delimiter)
|
|
34
|
+
if (groupSymbol !== decimalSymbol) {
|
|
35
|
+
numeric = numeric.replaceAll(groupSymbol, '');
|
|
36
|
+
}
|
|
37
|
+
// Replace decimal with dot for number parsing
|
|
38
|
+
if (decimalSymbol !== '.') {
|
|
39
|
+
numeric = numeric.replace(decimalSymbol, '.');
|
|
40
|
+
}
|
|
41
|
+
const parsed = Number.parseFloat(numeric);
|
|
42
|
+
return Number.isNaN(parsed) ? Number.NaN : parsed;
|
|
43
|
+
};
|
|
44
|
+
exports.parseNumberFromValue = parseNumberFromValue;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a nested property value from an object using dot-notation.
|
|
47
|
+
*
|
|
48
|
+
* @param obj - The object to retrieve the value from.
|
|
49
|
+
* @param path - Dot-separated path to the desired property (e.g. "price.amount").
|
|
50
|
+
* @returns The value at the given path or undefined if not found.
|
|
51
|
+
*/
|
|
52
|
+
const getValueByPath = (obj, path) => {
|
|
53
|
+
return path.split('.').reduce((acc, key) => (acc && typeof acc === 'object' ? acc[key] : undefined), obj);
|
|
54
|
+
};
|
|
55
|
+
exports.getValueByPath = getValueByPath;
|
package/lib/es/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rio-cloud/rio-uikit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "The RIO UIKIT component library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"**/*.*"
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@biomejs/biome": "2.1.
|
|
54
|
-
"@testing-library/dom": "10.4.
|
|
55
|
-
"@testing-library/jest-dom": "6.6.
|
|
53
|
+
"@biomejs/biome": "2.1.4",
|
|
54
|
+
"@testing-library/dom": "10.4.1",
|
|
55
|
+
"@testing-library/jest-dom": "6.6.4",
|
|
56
56
|
"@testing-library/react": "16.3.0",
|
|
57
57
|
"@testing-library/react-hooks": "8.0.1",
|
|
58
58
|
"@testing-library/user-event": "14.6.1",
|
|
@@ -80,11 +80,11 @@
|
|
|
80
80
|
"react-dom": "18.0.0",
|
|
81
81
|
"react-intl": "6.6.8",
|
|
82
82
|
"rollup-plugin-copy": "3.5.0",
|
|
83
|
-
"sass": "^1.
|
|
83
|
+
"sass": "^1.90.0",
|
|
84
84
|
"strip-ansi": "7.1.0",
|
|
85
85
|
"svgo": "4.0.0",
|
|
86
86
|
"tiny-invariant": "1.3.3",
|
|
87
|
-
"typescript": "5.
|
|
87
|
+
"typescript": "5.9.2",
|
|
88
88
|
"vite": "6.3.5",
|
|
89
89
|
"vite-plugin-zip-pack": "1.2.4",
|
|
90
90
|
"vitest": "3.2.4",
|
package/useAverage.d.ts
ADDED
package/useAverage.js
ADDED
package/useCount.d.ts
ADDED
package/useCount.js
ADDED
package/useMax.d.ts
ADDED
package/useMax.js
ADDED
package/useMin.d.ts
ADDED
package/useMin.js
ADDED
package/useSum.d.ts
ADDED
package/useSum.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to extract a number from a string that may have units or grouping delimiters. It take localization into account.
|
|
3
|
+
*
|
|
4
|
+
* @param value
|
|
5
|
+
* @param locale
|
|
6
|
+
* @returns parsed number
|
|
7
|
+
*/
|
|
8
|
+
export declare const parseNumberFromValue: (value: unknown, locale: string) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves a nested property value from an object using dot-notation.
|
|
11
|
+
*
|
|
12
|
+
* @param obj - The object to retrieve the value from.
|
|
13
|
+
* @param path - Dot-separated path to the desired property (e.g. "price.amount").
|
|
14
|
+
* @returns The value at the given path or undefined if not found.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getValueByPath: (obj: unknown, path: string) => unknown;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import isNil from 'lodash/fp/isNil';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to extract a number from a string that may have units or grouping delimiters. It take localization into account.
|
|
4
|
+
*
|
|
5
|
+
* @param value
|
|
6
|
+
* @param locale
|
|
7
|
+
* @returns parsed number
|
|
8
|
+
*/
|
|
9
|
+
export const parseNumberFromValue = (value, locale) => {
|
|
10
|
+
if (isNil(value)) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'number') {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value !== 'string') {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
const example = 1234567.89;
|
|
20
|
+
const parts = new Intl.NumberFormat(locale).formatToParts(example);
|
|
21
|
+
const groupSymbol = parts.find(p => p.type === 'group')?.value ?? ',';
|
|
22
|
+
const decimalSymbol = parts.find(p => p.type === 'decimal')?.value ?? '.';
|
|
23
|
+
// Extract numeric part only (up to last digit or decimal), ignore units
|
|
24
|
+
const match = value.match(/[-\d.,'\u00A0\s]+/);
|
|
25
|
+
if (!match) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
let numeric = match[0].trim();
|
|
29
|
+
// Normalize: remove group symbols (thousand delimiter)
|
|
30
|
+
if (groupSymbol !== decimalSymbol) {
|
|
31
|
+
numeric = numeric.replaceAll(groupSymbol, '');
|
|
32
|
+
}
|
|
33
|
+
// Replace decimal with dot for number parsing
|
|
34
|
+
if (decimalSymbol !== '.') {
|
|
35
|
+
numeric = numeric.replace(decimalSymbol, '.');
|
|
36
|
+
}
|
|
37
|
+
const parsed = Number.parseFloat(numeric);
|
|
38
|
+
return Number.isNaN(parsed) ? Number.NaN : parsed;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves a nested property value from an object using dot-notation.
|
|
42
|
+
*
|
|
43
|
+
* @param obj - The object to retrieve the value from.
|
|
44
|
+
* @param path - Dot-separated path to the desired property (e.g. "price.amount").
|
|
45
|
+
* @returns The value at the given path or undefined if not found.
|
|
46
|
+
*/
|
|
47
|
+
export const getValueByPath = (obj, path) => {
|
|
48
|
+
return path.split('.').reduce((acc, key) => (acc && typeof acc === 'object' ? acc[key] : undefined), obj);
|
|
49
|
+
};
|
package/version.json
CHANGED