2024-06-26 07:46:26 +00:00
|
|
|
import { createStyleAsString } from '@primeuix/utils/dom';
|
|
|
|
import { isFunction } from '@primeuix/utils/object';
|
2024-06-11 12:21:12 +00:00
|
|
|
import type { MetaType } from '@primevue/metadata';
|
|
|
|
import type { ConstructsType, ResolvePathOptions } from './types';
|
|
|
|
|
2023-10-24 10:09:12 +00:00
|
|
|
export const Utils = {
|
|
|
|
object: {
|
2024-06-11 12:21:12 +00:00
|
|
|
getName(item: MetaType, options: ConstructsType) {
|
2024-06-26 07:46:26 +00:00
|
|
|
return isFunction(options?.name) ? options.name(item) : `${options.prefix}${item.name}`;
|
2023-10-24 10:09:12 +00:00
|
|
|
},
|
2024-06-11 12:21:12 +00:00
|
|
|
getPath(fn: any, options: ResolvePathOptions) {
|
2024-06-26 07:46:26 +00:00
|
|
|
return isFunction(fn) ? fn(options) : options.from;
|
2023-10-24 10:09:12 +00:00
|
|
|
},
|
2024-06-11 12:21:12 +00:00
|
|
|
createStyleAsString(css: string, options = { name: '' }) {
|
2024-06-26 07:46:26 +00:00
|
|
|
const { name, ...rest } = options;
|
2023-10-24 10:09:12 +00:00
|
|
|
|
2024-06-26 07:46:26 +00:00
|
|
|
return createStyleAsString(css, { 'data-primevue-style-id': name, ...rest });
|
2023-10-24 10:09:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|