@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.
Files changed (74) hide show
  1. package/.DS_Store +0 -0
  2. package/components/assetTree/AssetTree.js +1 -1
  3. package/components/assetTree/Tree.d.ts +6 -0
  4. package/components/assetTree/Tree.js +2 -2
  5. package/components/assetTree/TreeNode.d.ts +1 -0
  6. package/components/assetTree/TreeNode.js +3 -2
  7. package/components/dialog/SplitDialog.d.ts +6 -0
  8. package/components/dialog/SplitDialog.js +2 -2
  9. package/components/filepicker/FilePicker.d.ts +1 -1
  10. package/components/formLabel/FormLabel.js +1 -1
  11. package/components/map/components/Map.js +70 -68
  12. package/components/map/components/features/settings/builtinSettings/MapTypeSettings.d.ts +1 -1
  13. package/components/map/utils/rendering.d.ts +1 -1
  14. package/components/map/utils/rendering.js +7 -11
  15. package/hooks/useAverage.d.ts +18 -0
  16. package/hooks/useAverage.js +28 -0
  17. package/hooks/useCount.d.ts +22 -0
  18. package/hooks/useCount.js +31 -0
  19. package/hooks/useMax.d.ts +18 -0
  20. package/hooks/useMax.js +24 -0
  21. package/hooks/useMin.d.ts +18 -0
  22. package/hooks/useMin.js +24 -0
  23. package/hooks/useSum.d.ts +18 -0
  24. package/hooks/useSum.js +23 -0
  25. package/lib/es/components/assetTree/AssetTree.js +1 -1
  26. package/lib/es/components/assetTree/Tree.d.ts +6 -0
  27. package/lib/es/components/assetTree/Tree.js +2 -2
  28. package/lib/es/components/assetTree/TreeNode.d.ts +1 -0
  29. package/lib/es/components/assetTree/TreeNode.js +3 -2
  30. package/lib/es/components/dialog/SplitDialog.d.ts +6 -0
  31. package/lib/es/components/dialog/SplitDialog.js +2 -2
  32. package/lib/es/components/filepicker/FilePicker.d.ts +1 -1
  33. package/lib/es/components/formLabel/FormLabel.js +1 -1
  34. package/lib/es/components/map/components/Map.js +70 -68
  35. package/lib/es/components/map/components/features/settings/builtinSettings/MapTypeSettings.d.ts +1 -1
  36. package/lib/es/components/map/utils/rendering.d.ts +1 -1
  37. package/lib/es/components/map/utils/rendering.js +7 -11
  38. package/lib/es/hooks/useAverage.d.ts +18 -0
  39. package/lib/es/hooks/useAverage.js +30 -0
  40. package/lib/es/hooks/useCount.d.ts +22 -0
  41. package/lib/es/hooks/useCount.js +33 -0
  42. package/lib/es/hooks/useMax.d.ts +18 -0
  43. package/lib/es/hooks/useMax.js +26 -0
  44. package/lib/es/hooks/useMin.d.ts +18 -0
  45. package/lib/es/hooks/useMin.js +26 -0
  46. package/lib/es/hooks/useSum.d.ts +18 -0
  47. package/lib/es/hooks/useSum.js +25 -0
  48. package/lib/es/useAverage.d.ts +2 -0
  49. package/lib/es/useAverage.js +7 -0
  50. package/lib/es/useCount.d.ts +2 -0
  51. package/lib/es/useCount.js +7 -0
  52. package/lib/es/useMax.d.ts +2 -0
  53. package/lib/es/useMax.js +7 -0
  54. package/lib/es/useMin.d.ts +2 -0
  55. package/lib/es/useMin.js +7 -0
  56. package/lib/es/useSum.d.ts +2 -0
  57. package/lib/es/useSum.js +7 -0
  58. package/lib/es/utils/formatUtils.d.ts +16 -0
  59. package/lib/es/utils/formatUtils.js +55 -0
  60. package/lib/es/version.json +1 -1
  61. package/package.json +6 -6
  62. package/useAverage.d.ts +2 -0
  63. package/useAverage.js +2 -0
  64. package/useCount.d.ts +2 -0
  65. package/useCount.js +2 -0
  66. package/useMax.d.ts +2 -0
  67. package/useMax.js +2 -0
  68. package/useMin.d.ts +2 -0
  69. package/useMin.js +2 -0
  70. package/useSum.d.ts +2 -0
  71. package/useSum.js +2 -0
  72. package/utils/formatUtils.d.ts +16 -0
  73. package/utils/formatUtils.js +49 -0
  74. 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;
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.10.0"
2
+ "version": "1.11.0"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rio-cloud/rio-uikit",
3
- "version": "1.10.0",
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.2",
54
- "@testing-library/dom": "10.4.0",
55
- "@testing-library/jest-dom": "6.6.3",
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.89.2",
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.8.3",
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",
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useAverage';
2
+ export * from './hooks/useAverage';
package/useAverage.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useAverage';
2
+ export * from './hooks/useAverage';
package/useCount.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useCount';
2
+ export * from './hooks/useCount';
package/useCount.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useCount';
2
+ export * from './hooks/useCount';
package/useMax.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useMax';
2
+ export * from './hooks/useMax';
package/useMax.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useMax';
2
+ export * from './hooks/useMax';
package/useMin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useMin';
2
+ export * from './hooks/useMin';
package/useMin.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useMin';
2
+ export * from './hooks/useMin';
package/useSum.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useSum';
2
+ export * from './hooks/useSum';
package/useSum.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './hooks/useSum';
2
+ export * from './hooks/useSum';
@@ -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
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.10.0"
2
+ "version": "1.11.0"
3
3
  }