UNPKG

@infinityfx/fluid

Version:

React UI library, using zero-runtime CSS-in-JS.

3 lines (2 loc) 1.48 kB
import{GLOBAL_CONTEXT as t}from"./shared.js";import{mergeRecursive as e}from"./utils.js";function s(t){let e=3735928559,s=1103547991;for(let r,n=0;n<t.length;n++)r=t.charCodeAt(n),e=Math.imul(e^r,2654435761),s=Math.imul(s^r,1597334677);return e=Math.imul(e^e>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),e=4294967296*(2097151&s)+(e>>>0),e.toString(16).slice(-8).padStart(8,"0")}function r(t,e,s={}){return{rules:Object.entries(t).reduce(((t,[n,o])=>{if(null==o)return t;if("object"==typeof o){return t+`${(e?n.split(/((?::global\()?[.#][\w\-_][\w\d\-_]*)/gi).reduce(((t,r)=>{if(/^[.#]/.test(r)){const t=r.slice(1);s[t]=`${t}__${e}`,r=`${r}__${e}`}return t+r}),""):n).replace(/:global\((.+?)\)/g,"$1")}{${r(o,e,s).rules}}`}return t+`${n.replace(/(.?)([A-Z])/g,"$1-$2").toLowerCase()}:${o};`}),""),selectors:s}}function n(n,o){const l=o instanceof Function?o(t.theme):o,i=t.components[n]||{},u=s("automatic"===t.cssOutput?JSON.stringify([i,l]):n);return t.styles[n]=r(function(...t){const s={};for(const r of t)for(const t in r){const n=e(s[t],r[t]);void 0!==n&&(s[t]=n)}return s}(i,l),u),t.styles[n].selectors}function o(e){const n=e instanceof Function?e(t.theme):e,o=s(JSON.stringify(n)),{rules:l}=r(n);o in t.styles||(t.styles.__globals={rules:(t.styles.__globals?.rules||"")+l,selectors:{}},t.styles[o]={rules:"",selectors:{}})}export{o as createGlobalStyles,n as createStyles}; //# sourceMappingURL=style.js.map