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