UNPKG

@infinityfx/fluid

Version:

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

3 lines (2 loc) 2.63 kB
const t=(t,n=2)=>Math.round(t*Math.pow(10,n))/Math.pow(10,n),n=(t,n)=>void 0===(t="string"==typeof t?parseFloat(t):t)||isNaN(t)?n:t;function e(t,n){Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(t,n),t.dispatchEvent(new Event("input",{bubbles:!0}))}function r(t,n){if(void 0===t)return n;if("object"!=typeof t||null===t||Array.isArray(t))return t;const e=Object.assign({},t);for(const t in n)e[t]=r(e[t],n[t]);return e}function o(...t){return t.filter((t=>"string"==typeof t)).join(" ")}function i(t,n){const e=Object.assign({},t);for(const r in n)r in t?e[r]+=` ${n[r]}`:e[r]=n[r];return e}function a(...t){return n=>{t.forEach((t=>{t&&(t instanceof Function?t(n):t.current=n)}))}}function u(){return document.cookie.split(";").reduce(((t,n)=>{const[e,r]=n.split("=");return e&&r&&(t[decodeURIComponent(e.trim())]=decodeURIComponent(r.trim())),t}),{})}function c(t,n,e={}){e=Object.assign({path:"/",secure:!0,sameSite:"Lax"},e);const r=Object.entries(e).map((([t,n])=>("maxAge"===t&&(t="max-Age"),t=t.charAt(0).toUpperCase()+t.slice(1),"boolean"==typeof n?n?`${t};`:"":void 0===n?"":`${t}=${n};`))).join(" ");return`${t}=${n}; ${r}`}const s="a[href], button, input, textarea, [tabindex]";function f(t,n=!0){if(!t)return n?[]:null;const e=l(Array.from(t.querySelectorAll(s)),!1);return n?e:e[0]||null}function l(t,n=!0){return t.map((t=>{if(n&&!t.matches(s)){const n=t.querySelector(s);if(!n)return null;t=n}return t.hasAttribute("disabled")||"-1"===t.getAttribute("tabindex")||t.closest('[aria-hidden="true"]')?null:t})).filter((t=>null!==t))}function p(t){let n=0;for(;t;){const e=parseInt(getComputedStyle(t).zIndex);isNaN(e)||(n=Math.max(n,e)),t=t.parentElement}return n}function d(t){return`${t.map((t=>t.toString(16).padStart(2,"0"))).join("")}`}function m(t){const n=t.toLowerCase().match(/^#?([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?$/i);return n?n.slice(1,4).map((t=>parseInt(t.padStart(2,t),16))):[0,0,0]}function h([t,n,e]){n/=100,e/=100;const r=n=>(n+t/60)%6,o=t=>Math.round(255*e*(1-n*Math.max(0,Math.min(r(t),4-r(t),1))));return[o(5),o(3),o(1)]}function b([t,n,e]){t/=255,n/=255,e/=255;const r=Math.max(t,n,e),o=r-Math.min(t,n,e);let i=0;return o&&r===t&&(i=(n-e)/o),o&&r===n&&(i=2+(e-t)/o),o&&r===e&&(i=4+(t-n)/o),[60*(i<0?i+6:i),r&&o/r*100,100*r]}export{e as changeInputValue,o as classes,i as combineClasses,a as combineRefs,u as cookies,l as filterFocusable,c as formatCookie,p as getAbsoluteZIndex,f as getFocusable,m as hexToRgb,h as hsvToRgb,r as mergeRecursive,d as rgbToHex,b as rgbToHsv,t as round,n as toNumber}; //# sourceMappingURL=utils.js.map