tera-system-ui 0.1.4 → 0.1.5
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/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +16 -0
- package/package.json +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { cn, observeVisibility } from './utils';
|
|
1
|
+
export { cn, observeVisibility, styleToString } from './utils';
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { cn, observeVisibility } from './utils';
|
|
1
|
+
export { cn, observeVisibility, styleToString } from './utils';
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { type ClassValue } from "clsx";
|
|
|
2
2
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
3
|
export declare function consoleLog(...params: any[]): void;
|
|
4
4
|
export declare function observeVisibility(element: HTMLElement, callback: (isVisible: boolean, entry?: any) => void): () => void;
|
|
5
|
+
export declare function styleToString(style: Record<string, any>): string;
|
package/dist/utils/utils.js
CHANGED
|
@@ -22,3 +22,19 @@ export function observeVisibility(element, callback) {
|
|
|
22
22
|
// Return a function to stop observing
|
|
23
23
|
return () => observer.disconnect();
|
|
24
24
|
}
|
|
25
|
+
export function styleToString(style) {
|
|
26
|
+
return Object.keys(style).reduce((acc, key) => {
|
|
27
|
+
if (style[key] === undefined || style[key] === null)
|
|
28
|
+
return acc;
|
|
29
|
+
// Convert camelCase to kebab-case
|
|
30
|
+
const cssKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
31
|
+
// Handle numbers by adding 'px' for certain properties
|
|
32
|
+
const cssValue = typeof style[key] === 'number' &&
|
|
33
|
+
!cssKey.includes('opacity') &&
|
|
34
|
+
!cssKey.includes('z-index') &&
|
|
35
|
+
!cssKey.includes('order')
|
|
36
|
+
? `${style[key]}px`
|
|
37
|
+
: style[key];
|
|
38
|
+
return `${acc}${cssKey}:${cssValue};`;
|
|
39
|
+
}, '');
|
|
40
|
+
}
|