ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
2 lines (1 loc) • 2.25 kB
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),T=require("./Cache.js"),c=require("../type.js"),A="data-token-hash",d="data-css-hash",m="data-cache-path",u="__cssinjs_instance__";function i(){const e=Math.random().toString(12).slice(2);if(typeof document<"u"&&document.head&&document.body){const o=document.body.querySelectorAll(`style[${d}]`)||[],{firstChild:n}=document.head;Array.from(o).forEach(t=>{t[u]=t[u]||e,t[u]===e&&document.head.insertBefore(t,n)});const r={};Array.from(document.querySelectorAll(`style[${d}]`)).forEach(t=>{var l;const s=t.getAttribute(d);r[s]?t[u]===e&&((l=t.parentNode)==null||l.removeChild(t)):r[s]=!0})}return new T.default(e)}const f=Symbol("StyleContextKey"),P=()=>{var n,r,t;const e=a.getCurrentInstance();let o;if(e&&e.appContext){const s=(t=(r=(n=e.appContext)==null?void 0:n.config)==null?void 0:r.globalProperties)==null?void 0:t.__ANTDV_CSSINJS_CACHE__;s?o=s:(o=i(),e.appContext.config.globalProperties&&(e.appContext.config.globalProperties.__ANTDV_CSSINJS_CACHE__=o))}else o=i();return o},C={cache:i(),defaultCache:!0,hashPriority:"low"},h=()=>{const e=P();return a.inject(f,a.shallowRef({...C,cache:e}))},_=e=>{const o=h(),n=a.shallowRef({...C,cache:i()});return a.watch([()=>a.unref(e),o],()=>{const r={...o.value},t=a.unref(e);Object.keys(t).forEach(l=>{const S=t[l];t[l]!==void 0&&(r[l]=S)});const{cache:s}=t;r.cache=r.cache||i(),r.defaultCache=!s&&o.value.defaultCache,n.value=r},{immediate:!0}),a.provide(f,n),n},y=()=>({autoClear:c.booleanType(),mock:c.stringType(),cache:c.objectType(),defaultCache:c.booleanType(),hashPriority:c.stringType(),container:c.someType(),ssrInline:c.booleanType(),transformers:c.arrayType(),linters:c.arrayType()}),p=c.withInstall(a.defineComponent({name:"AStyleProvider",inheritAttrs:!1,props:y(),setup(e,{slots:o}){return _(e),()=>{var n;return(n=o.default)==null?void 0:n.call(o)}}})),g={useStyleInject:h,useStyleProvider:_,StyleProvider:p};exports.ATTR_CACHE_PATH=m;exports.ATTR_MARK=d;exports.ATTR_TOKEN=A;exports.CSS_IN_JS_INSTANCE=u;exports.StyleProvider=p;exports.createCache=i;exports.default=g;exports.styleProviderProps=y;exports.useStyleInject=h;exports.useStyleProvider=_;
;