@majapisoftwares/ui 4.3.15 → 4.3.17
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/components/PictureCropInput/PictureCropInput.jsx +9 -9
- package/components/Table/TableFooterWithPagination.jsx +2 -2
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/getInitials.d.ts +1 -1
- package/utils/getInitials.js +18 -4
- package/utils/formatTime.d.ts +0 -16
- package/utils/formatTime.js +0 -66
package/utils/getInitials.d.ts
CHANGED
package/utils/getInitials.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gets all the initials of a name.
|
|
3
3
|
*/
|
|
4
|
-
export default function getInitials(name
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default function getInitials(name) {
|
|
5
|
+
if (!name)
|
|
6
|
+
return "";
|
|
7
|
+
// Normalize to decompose diacritics, then remove any non-letter characters.
|
|
8
|
+
const normalizeAndClean = (s) => s
|
|
9
|
+
.normalize("NFD") // decompose combined letters (e.g., é -> e + ´)
|
|
10
|
+
.replace(/\p{M}/gu, "") // remove diacritic marks
|
|
11
|
+
.replace(/[^A-Za-zÀ-ÖØ-öø-ÿ]/g, "") // strip anything that's not a letter (basic Latin + Latin-1 Supplement)
|
|
12
|
+
.trim();
|
|
13
|
+
// Split into words, clean each word, take first letter of up to two words.
|
|
14
|
+
const words = name.split(/\s+/);
|
|
15
|
+
const initials = words
|
|
16
|
+
.map((w) => normalizeAndClean(w))
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.slice(0, 2)
|
|
19
|
+
.map((w) => w.charAt(0).toUpperCase())
|
|
20
|
+
.join("");
|
|
21
|
+
return initials;
|
|
8
22
|
}
|
package/utils/formatTime.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Formats the given time in milliseconds into a human-readable string.
|
|
3
|
-
* @param time - The time in milliseconds.
|
|
4
|
-
* @param opts - Optional settings.
|
|
5
|
-
* @param opts.includeMs - Whether to include milliseconds in the output.
|
|
6
|
-
* @returns A string representing the formatted time.
|
|
7
|
-
*/
|
|
8
|
-
export default function formatTime(time: number, opts?: {
|
|
9
|
-
includeMs?: boolean;
|
|
10
|
-
}): string;
|
|
11
|
-
/**
|
|
12
|
-
* Parses a formatted time string and converts it to milliseconds.
|
|
13
|
-
* @param formattedTime - The formatted time string (e.g., "1h 30m 15s"), may be undefined/null.
|
|
14
|
-
* @returns The time in milliseconds.
|
|
15
|
-
*/
|
|
16
|
-
export declare function parseFormattedTime(formattedTime?: string | null): number;
|
package/utils/formatTime.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Formats the given time in milliseconds into a human-readable string.
|
|
3
|
-
* @param time - The time in milliseconds.
|
|
4
|
-
* @param opts - Optional settings.
|
|
5
|
-
* @param opts.includeMs - Whether to include milliseconds in the output.
|
|
6
|
-
* @returns A string representing the formatted time.
|
|
7
|
-
*/
|
|
8
|
-
export default function formatTime(time, opts) {
|
|
9
|
-
const includeMs = opts?.includeMs;
|
|
10
|
-
const totalMilliseconds = Math.max(0, Math.floor(time));
|
|
11
|
-
const totalSeconds = Math.floor(totalMilliseconds / 1000);
|
|
12
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
13
|
-
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
14
|
-
const seconds = totalSeconds % 60;
|
|
15
|
-
const ms = totalMilliseconds % 1000;
|
|
16
|
-
const parts = [];
|
|
17
|
-
if (hours > 0)
|
|
18
|
-
parts.push(`${hours}h`);
|
|
19
|
-
if (minutes > 0)
|
|
20
|
-
parts.push(`${minutes}m`);
|
|
21
|
-
if (seconds > 0)
|
|
22
|
-
parts.push(`${seconds}s`);
|
|
23
|
-
if (includeMs && ms > 0)
|
|
24
|
-
parts.push(`${ms}ms`);
|
|
25
|
-
// Maintain previous behavior: if everything is zero and ms not requested or zero, return empty string
|
|
26
|
-
if (parts.length === 0) {
|
|
27
|
-
if (includeMs && ms > 0)
|
|
28
|
-
return `${ms}ms`;
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
return parts.join(" ");
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Parses a formatted time string and converts it to milliseconds.
|
|
35
|
-
* @param formattedTime - The formatted time string (e.g., "1h 30m 15s"), may be undefined/null.
|
|
36
|
-
* @returns The time in milliseconds.
|
|
37
|
-
*/
|
|
38
|
-
export function parseFormattedTime(formattedTime) {
|
|
39
|
-
if (!formattedTime)
|
|
40
|
-
return 0;
|
|
41
|
-
let totalMilliseconds = 0;
|
|
42
|
-
const regex = /(\d+(?:\.\d+)?)(ms|h|m|s)/g;
|
|
43
|
-
let match;
|
|
44
|
-
while ((match = regex.exec(formattedTime)) !== null) {
|
|
45
|
-
const valueStr = match[1]; // capture group 1 is ensured by the regex pattern
|
|
46
|
-
const value = parseFloat(valueStr);
|
|
47
|
-
const unit = match[2];
|
|
48
|
-
if (isNaN(value))
|
|
49
|
-
continue;
|
|
50
|
-
switch (unit) {
|
|
51
|
-
case "h":
|
|
52
|
-
totalMilliseconds += value * 3600000;
|
|
53
|
-
break;
|
|
54
|
-
case "m":
|
|
55
|
-
totalMilliseconds += value * 60000;
|
|
56
|
-
break;
|
|
57
|
-
case "s":
|
|
58
|
-
totalMilliseconds += value * 1000;
|
|
59
|
-
break;
|
|
60
|
-
case "ms":
|
|
61
|
-
totalMilliseconds += value;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return totalMilliseconds;
|
|
66
|
-
}
|