@trackunit/react-components 2.1.24 → 2.1.29
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/index.cjs.js +60 -54
- package/index.esm.js +60 -54
- package/package.json +6 -6
- package/src/hooks/encoding/utils/customEncoding.d.ts +14 -0
package/index.cjs.js
CHANGED
|
@@ -200,10 +200,11 @@ const Icon = ({ name, size = "medium", className, "data-testid": dataTestId, col
|
|
|
200
200
|
}, [size]);
|
|
201
201
|
const iconName = uiIcons.iconNames[name];
|
|
202
202
|
const href = react.useMemo(() => ({
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
// Symbol ids are namespaced by type so the four sprites can be inlined together.
|
|
204
|
+
solid: `${IconSpriteSolid}#solid-${iconName}`,
|
|
205
|
+
outline: `${IconSpriteOutline}#outline-${iconName}`,
|
|
206
|
+
mini: `${IconSpriteMini}#mini-${iconName}`,
|
|
207
|
+
micro: `${IconSpriteMicro}#micro-${iconName}`,
|
|
207
208
|
}), [iconName]);
|
|
208
209
|
react.useEffect(() => {
|
|
209
210
|
if (isSafari() && useTagRef.current) {
|
|
@@ -10532,6 +10533,58 @@ const b64urlDecode = (s) => {
|
|
|
10532
10533
|
}
|
|
10533
10534
|
return out;
|
|
10534
10535
|
};
|
|
10536
|
+
/**
|
|
10537
|
+
* Encode a value with the same gzip + base64url format used by useCustomEncoding.
|
|
10538
|
+
*
|
|
10539
|
+
* @param input - The value to encode.
|
|
10540
|
+
* @returns {string} The compressed URL-safe encoded value, or an empty string on failure.
|
|
10541
|
+
*/
|
|
10542
|
+
const encodeCustomValue = (input) => {
|
|
10543
|
+
try {
|
|
10544
|
+
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10545
|
+
const textInput = new TextEncoder().encode(json);
|
|
10546
|
+
const compressed = fflate.gzipSync(textInput, { mtime: 0 });
|
|
10547
|
+
return b64urlEncode(compressed);
|
|
10548
|
+
}
|
|
10549
|
+
catch (_) {
|
|
10550
|
+
return "";
|
|
10551
|
+
}
|
|
10552
|
+
};
|
|
10553
|
+
/**
|
|
10554
|
+
* Decode a value produced by encodeCustomValue.
|
|
10555
|
+
*
|
|
10556
|
+
* @param str - The compressed URL-safe encoded value.
|
|
10557
|
+
* @returns {object | Array<object> | string} The decoded object/string value, or an empty string on failure.
|
|
10558
|
+
*/
|
|
10559
|
+
const decodeCustomValue = (str) => {
|
|
10560
|
+
try {
|
|
10561
|
+
try {
|
|
10562
|
+
const bytes = b64urlDecode(str);
|
|
10563
|
+
const decompressed = fflate.gunzipSync(bytes);
|
|
10564
|
+
const json = new TextDecoder().decode(decompressed);
|
|
10565
|
+
try {
|
|
10566
|
+
return JSON.parse(json);
|
|
10567
|
+
}
|
|
10568
|
+
catch (_) {
|
|
10569
|
+
return json;
|
|
10570
|
+
}
|
|
10571
|
+
}
|
|
10572
|
+
catch (_) {
|
|
10573
|
+
// If compression decoding fails, fall back to regular decoding.
|
|
10574
|
+
}
|
|
10575
|
+
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10576
|
+
try {
|
|
10577
|
+
return JSON.parse(decoded);
|
|
10578
|
+
}
|
|
10579
|
+
catch (_) {
|
|
10580
|
+
return decoded;
|
|
10581
|
+
}
|
|
10582
|
+
}
|
|
10583
|
+
catch (_) {
|
|
10584
|
+
return "";
|
|
10585
|
+
}
|
|
10586
|
+
};
|
|
10587
|
+
|
|
10535
10588
|
/**
|
|
10536
10589
|
* React hook for safe base64 encoding/decoding with UTF-8 support and compression
|
|
10537
10590
|
*
|
|
@@ -10551,22 +10604,7 @@ const useCustomEncoding = () => {
|
|
|
10551
10604
|
* @param input - The object or string to encode
|
|
10552
10605
|
* @returns The compressed and encoded string
|
|
10553
10606
|
*/
|
|
10554
|
-
const encode = react.useCallback((input) =>
|
|
10555
|
-
try {
|
|
10556
|
-
// If it's already a string, use it directly; otherwise stringify the object
|
|
10557
|
-
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10558
|
-
const textInput = new TextEncoder().encode(json);
|
|
10559
|
-
// Use fflate for synchronous gzip compression.
|
|
10560
|
-
// mtime: 0 ensures deterministic output — without it the gzip header
|
|
10561
|
-
// includes the current timestamp, making the same input produce a
|
|
10562
|
-
// different encoded string on every call.
|
|
10563
|
-
const compressed = fflate.gzipSync(textInput, { mtime: 0 });
|
|
10564
|
-
return b64urlEncode(compressed);
|
|
10565
|
-
}
|
|
10566
|
-
catch (_) {
|
|
10567
|
-
return "";
|
|
10568
|
-
}
|
|
10569
|
-
}, []);
|
|
10607
|
+
const encode = react.useCallback((input) => encodeCustomValue(input), []);
|
|
10570
10608
|
/**
|
|
10571
10609
|
* Safely decode a compressed and encoded string back to its original form
|
|
10572
10610
|
*
|
|
@@ -10574,41 +10612,9 @@ const useCustomEncoding = () => {
|
|
|
10574
10612
|
* and returning the original object or string.
|
|
10575
10613
|
*
|
|
10576
10614
|
* @param str - The compressed and encoded string to decode
|
|
10577
|
-
* @returns The decoded object or string, or
|
|
10615
|
+
* @returns The decoded object or string, or an empty string if decoding fails
|
|
10578
10616
|
*/
|
|
10579
|
-
const decode = react.useCallback((str) =>
|
|
10580
|
-
try {
|
|
10581
|
-
// Try to decode as compressed data first
|
|
10582
|
-
try {
|
|
10583
|
-
const bytes = b64urlDecode(str);
|
|
10584
|
-
const decompressed = fflate.gunzipSync(bytes);
|
|
10585
|
-
const json = new TextDecoder().decode(decompressed);
|
|
10586
|
-
// Try to parse as JSON first (for objects)
|
|
10587
|
-
try {
|
|
10588
|
-
return JSON.parse(json);
|
|
10589
|
-
}
|
|
10590
|
-
catch (_) {
|
|
10591
|
-
// If JSON parsing fails, return the string as-is
|
|
10592
|
-
return json;
|
|
10593
|
-
}
|
|
10594
|
-
}
|
|
10595
|
-
catch (_) {
|
|
10596
|
-
// If compression decoding fails, fall back to regular decoding
|
|
10597
|
-
}
|
|
10598
|
-
// Fallback: use regular base64 decoding
|
|
10599
|
-
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10600
|
-
try {
|
|
10601
|
-
return JSON.parse(decoded);
|
|
10602
|
-
}
|
|
10603
|
-
catch (_) {
|
|
10604
|
-
// If JSON parsing fails, return the string as-is
|
|
10605
|
-
return decoded;
|
|
10606
|
-
}
|
|
10607
|
-
}
|
|
10608
|
-
catch (_) {
|
|
10609
|
-
return "";
|
|
10610
|
-
}
|
|
10611
|
-
}, []);
|
|
10617
|
+
const decode = react.useCallback((str) => decodeCustomValue(str), []);
|
|
10612
10618
|
return react.useMemo(() => ({ encode, decode }), [encode, decode]);
|
|
10613
10619
|
};
|
|
10614
10620
|
|
package/index.esm.js
CHANGED
|
@@ -198,10 +198,11 @@ const Icon = ({ name, size = "medium", className, "data-testid": dataTestId, col
|
|
|
198
198
|
}, [size]);
|
|
199
199
|
const iconName = iconNames[name];
|
|
200
200
|
const href = useMemo(() => ({
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
// Symbol ids are namespaced by type so the four sprites can be inlined together.
|
|
202
|
+
solid: `${IconSpriteSolid}#solid-${iconName}`,
|
|
203
|
+
outline: `${IconSpriteOutline}#outline-${iconName}`,
|
|
204
|
+
mini: `${IconSpriteMini}#mini-${iconName}`,
|
|
205
|
+
micro: `${IconSpriteMicro}#micro-${iconName}`,
|
|
205
206
|
}), [iconName]);
|
|
206
207
|
useEffect(() => {
|
|
207
208
|
if (isSafari() && useTagRef.current) {
|
|
@@ -10530,6 +10531,58 @@ const b64urlDecode = (s) => {
|
|
|
10530
10531
|
}
|
|
10531
10532
|
return out;
|
|
10532
10533
|
};
|
|
10534
|
+
/**
|
|
10535
|
+
* Encode a value with the same gzip + base64url format used by useCustomEncoding.
|
|
10536
|
+
*
|
|
10537
|
+
* @param input - The value to encode.
|
|
10538
|
+
* @returns {string} The compressed URL-safe encoded value, or an empty string on failure.
|
|
10539
|
+
*/
|
|
10540
|
+
const encodeCustomValue = (input) => {
|
|
10541
|
+
try {
|
|
10542
|
+
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10543
|
+
const textInput = new TextEncoder().encode(json);
|
|
10544
|
+
const compressed = gzipSync(textInput, { mtime: 0 });
|
|
10545
|
+
return b64urlEncode(compressed);
|
|
10546
|
+
}
|
|
10547
|
+
catch (_) {
|
|
10548
|
+
return "";
|
|
10549
|
+
}
|
|
10550
|
+
};
|
|
10551
|
+
/**
|
|
10552
|
+
* Decode a value produced by encodeCustomValue.
|
|
10553
|
+
*
|
|
10554
|
+
* @param str - The compressed URL-safe encoded value.
|
|
10555
|
+
* @returns {object | Array<object> | string} The decoded object/string value, or an empty string on failure.
|
|
10556
|
+
*/
|
|
10557
|
+
const decodeCustomValue = (str) => {
|
|
10558
|
+
try {
|
|
10559
|
+
try {
|
|
10560
|
+
const bytes = b64urlDecode(str);
|
|
10561
|
+
const decompressed = gunzipSync(bytes);
|
|
10562
|
+
const json = new TextDecoder().decode(decompressed);
|
|
10563
|
+
try {
|
|
10564
|
+
return JSON.parse(json);
|
|
10565
|
+
}
|
|
10566
|
+
catch (_) {
|
|
10567
|
+
return json;
|
|
10568
|
+
}
|
|
10569
|
+
}
|
|
10570
|
+
catch (_) {
|
|
10571
|
+
// If compression decoding fails, fall back to regular decoding.
|
|
10572
|
+
}
|
|
10573
|
+
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10574
|
+
try {
|
|
10575
|
+
return JSON.parse(decoded);
|
|
10576
|
+
}
|
|
10577
|
+
catch (_) {
|
|
10578
|
+
return decoded;
|
|
10579
|
+
}
|
|
10580
|
+
}
|
|
10581
|
+
catch (_) {
|
|
10582
|
+
return "";
|
|
10583
|
+
}
|
|
10584
|
+
};
|
|
10585
|
+
|
|
10533
10586
|
/**
|
|
10534
10587
|
* React hook for safe base64 encoding/decoding with UTF-8 support and compression
|
|
10535
10588
|
*
|
|
@@ -10549,22 +10602,7 @@ const useCustomEncoding = () => {
|
|
|
10549
10602
|
* @param input - The object or string to encode
|
|
10550
10603
|
* @returns The compressed and encoded string
|
|
10551
10604
|
*/
|
|
10552
|
-
const encode = useCallback((input) =>
|
|
10553
|
-
try {
|
|
10554
|
-
// If it's already a string, use it directly; otherwise stringify the object
|
|
10555
|
-
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10556
|
-
const textInput = new TextEncoder().encode(json);
|
|
10557
|
-
// Use fflate for synchronous gzip compression.
|
|
10558
|
-
// mtime: 0 ensures deterministic output — without it the gzip header
|
|
10559
|
-
// includes the current timestamp, making the same input produce a
|
|
10560
|
-
// different encoded string on every call.
|
|
10561
|
-
const compressed = gzipSync(textInput, { mtime: 0 });
|
|
10562
|
-
return b64urlEncode(compressed);
|
|
10563
|
-
}
|
|
10564
|
-
catch (_) {
|
|
10565
|
-
return "";
|
|
10566
|
-
}
|
|
10567
|
-
}, []);
|
|
10605
|
+
const encode = useCallback((input) => encodeCustomValue(input), []);
|
|
10568
10606
|
/**
|
|
10569
10607
|
* Safely decode a compressed and encoded string back to its original form
|
|
10570
10608
|
*
|
|
@@ -10572,41 +10610,9 @@ const useCustomEncoding = () => {
|
|
|
10572
10610
|
* and returning the original object or string.
|
|
10573
10611
|
*
|
|
10574
10612
|
* @param str - The compressed and encoded string to decode
|
|
10575
|
-
* @returns The decoded object or string, or
|
|
10613
|
+
* @returns The decoded object or string, or an empty string if decoding fails
|
|
10576
10614
|
*/
|
|
10577
|
-
const decode = useCallback((str) =>
|
|
10578
|
-
try {
|
|
10579
|
-
// Try to decode as compressed data first
|
|
10580
|
-
try {
|
|
10581
|
-
const bytes = b64urlDecode(str);
|
|
10582
|
-
const decompressed = gunzipSync(bytes);
|
|
10583
|
-
const json = new TextDecoder().decode(decompressed);
|
|
10584
|
-
// Try to parse as JSON first (for objects)
|
|
10585
|
-
try {
|
|
10586
|
-
return JSON.parse(json);
|
|
10587
|
-
}
|
|
10588
|
-
catch (_) {
|
|
10589
|
-
// If JSON parsing fails, return the string as-is
|
|
10590
|
-
return json;
|
|
10591
|
-
}
|
|
10592
|
-
}
|
|
10593
|
-
catch (_) {
|
|
10594
|
-
// If compression decoding fails, fall back to regular decoding
|
|
10595
|
-
}
|
|
10596
|
-
// Fallback: use regular base64 decoding
|
|
10597
|
-
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10598
|
-
try {
|
|
10599
|
-
return JSON.parse(decoded);
|
|
10600
|
-
}
|
|
10601
|
-
catch (_) {
|
|
10602
|
-
// If JSON parsing fails, return the string as-is
|
|
10603
|
-
return decoded;
|
|
10604
|
-
}
|
|
10605
|
-
}
|
|
10606
|
-
catch (_) {
|
|
10607
|
-
return "";
|
|
10608
|
-
}
|
|
10609
|
-
}, []);
|
|
10615
|
+
const decode = useCallback((str) => decodeCustomValue(str), []);
|
|
10610
10616
|
return useMemo(() => ({ encode, decode }), [encode, decode]);
|
|
10611
10617
|
};
|
|
10612
10618
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.29",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.13.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "1.13.
|
|
19
|
-
"@trackunit/shared-utils": "1.15.
|
|
20
|
-
"@trackunit/ui-icons": "1.13.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.13.33",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "1.13.33",
|
|
19
|
+
"@trackunit/shared-utils": "1.15.33",
|
|
20
|
+
"@trackunit/ui-icons": "1.13.35",
|
|
21
21
|
"es-toolkit": "^1.39.10",
|
|
22
22
|
"@tanstack/react-virtual": "3.13.12",
|
|
23
23
|
"dequal": "^2.0.3",
|
|
24
24
|
"fflate": "^0.8.2",
|
|
25
25
|
"superjson": "^2.2.6",
|
|
26
26
|
"zod": "^3.25.76",
|
|
27
|
-
"@trackunit/i18n-library-translation": "2.0.
|
|
27
|
+
"@trackunit/i18n-library-translation": "2.0.30"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^19.0.0",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a value with the same gzip + base64url format used by useCustomEncoding.
|
|
3
|
+
*
|
|
4
|
+
* @param input - The value to encode.
|
|
5
|
+
* @returns {string} The compressed URL-safe encoded value, or an empty string on failure.
|
|
6
|
+
*/
|
|
7
|
+
export declare const encodeCustomValue: (input: string | object | Array<object>) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Decode a value produced by encodeCustomValue.
|
|
10
|
+
*
|
|
11
|
+
* @param str - The compressed URL-safe encoded value.
|
|
12
|
+
* @returns {object | Array<object> | string} The decoded object/string value, or an empty string on failure.
|
|
13
|
+
*/
|
|
14
|
+
export declare const decodeCustomValue: (str: string) => object | Array<object> | string;
|