UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 1.17 kB
import{DomHandler as e}from"primevue/utils";import{ref as t,readonly as i,getCurrentInstance as a,onMounted as d,nextTick as o,watch as l}from"vue";function n(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];a()?d(e):t?e():o(e)}var u=0;function v(a){var d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t(!1),v=t(a),m=t(null),r=e.isClient()?window.document:void 0,c=d.document,s=void 0===c?r:c,p=d.immediate,f=void 0===p||p,y=d.manual,h=void 0!==y&&y,C=d.name,x=void 0===C?"style_".concat(++u):C,g=d.id,E=void 0===g?void 0:g,w=d.media,b=void 0===w?void 0:w,q=function(){},A=function(){s&&(m.value=s.querySelector('style[data-primevue-style-id="'.concat(x,'"]'))||s.getElementById(E)||s.createElement("style"),m.value.isConnected||(m.value.type="text/css",E&&(m.value.id=E),b&&(m.value.media=b),s.head.appendChild(m.value),x&&m.value.setAttribute("data-primevue-style-id",x)),o.value||(q=l(v,(function(e){m.value.textContent=e}),{immediate:!0}),o.value=!0))};return f&&!h&&n(A),{id:E,name:x,css:v,unload:function(){s&&o.value&&(q(),e.isExist(m.value)&&s.head.removeChild(m.value),o.value=!1)},load:A,isLoaded:i(o)}}export{v as useStyle};