primevue-mirror/packages/nuxt-module/src/utils.ts

21 lines
795 B
TypeScript
Raw Normal View History

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';
export const Utils = {
object: {
2024-06-11 12:21:12 +00:00
getName(item: MetaType, options: ConstructsType) {
return isFunction(options?.name) ? options.name(item) : `${options.prefix}${item.name}`;
},
2024-06-11 12:21:12 +00:00
getPath(fn: any, options: ResolvePathOptions) {
return isFunction(fn) ? fn(options) : options.from;
},
2024-06-11 12:21:12 +00:00
createStyleAsString(css: string, options = { name: '' }) {
const { name, ...rest } = options;
return createStyleAsString(css, { 'data-primevue-style-id': name, ...rest });
}
}
};