@body-ui/core
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
import{createContext as e,useContext as n,useMemo as t,forwardRef as r,createElement as o,useState as i,useEffect as s}from"react";import{style as c}from"typestyle";import{jsx as a}from"react/jsx-runtime";const u=!0,f={};function d(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function m(e,n,t){const r={};return n.forEach((n,o)=>{const i=t(n,o);if(i)if(0===o)Object.assign(r,i);else{const n=r.$nest||{};n[`@media screen and (min-width: ${e[o-1]}px)`]=i,Object.assign(r,{$nest:n})}}),r}function l(e){return 0===e?"0":e?e/16+"rem":void 0}function h(){return h=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},h.apply(this,arguments)}const p=/*#__PURE__*/e(null);function v(e){const r=n(p),{children:o,mode:i=(null==r?void 0:r.mode),palette:s=(null==r?void 0:r.palette),scheme:c="light",theme:u=(null==r?void 0:r.theme),tone:f=(null==r?void 0:r.tone)}=e,d=t(()=>({mode:i,palette:s,scheme:c,tone:f,theme:u}),[i,s,c,u,f]);return a(p.Provider,{value:d,children:o},void 0)}function g(){const e=n(p);if(!e)throw new Error("Theme: no theme");return e}function x(e){const{theme:n}=g();if(e)return(null==n?void 0:n.variants)&&(null==n?void 0:n.variants[e])}const w=["as"],y=new WeakMap;function b(e){return(...n)=>{const i=/*#__PURE__*/r((r,i)=>{const{as:s=e}=r,a=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}(r,w),{theme:u}=g(),f=t(()=>{const e=h({},a,{ref:i});for(const n of Object.keys(e))"$"===n[0]&&delete e[n];const t=n.map(e=>{if("function"==typeof e){const n=e(a,u);if(!n)return"";if(y.has(n))return y.get(n);const t=c(h({$debugName:e.name||"anon"},n));return y.set(n,t),t}if(y.has(e))return y.get(e);const n=c(e);return y.set(e,n),n});return e.className=[e.className,...t].filter(Boolean).join(" "),e},[i,a,u]);/*#__PURE__*/return o(s,f)});return i.displayName="Styled("+e||"undefined)",i}}const O=new WeakMap;function $(e,n){return 0===n?`screen and (max-width: ${e[n]-1}px)`:n===e.length?`screen and (min-width: ${e[n-1]}px)`:`screen and (min-width: ${e[n-1]}px) and (max-width: ${e[n]-1}px)`}function j(){const{theme:e}=g(),{media:n}=e,r=t(()=>function(e){let n=O.get(e);return n||(n=function(e){const n=[];if("undefined"!=typeof window)for(let t=e.length;t>-1;t-=1){const r=$(e,t);n.push({index:t,mq:window.matchMedia(r)})}return{getCurrentIndex:()=>{for(const{index:e,mq:t}of n)if(t.matches)return e;return 0},subscribe:e=>{const t=[];for(const{index:r,mq:o}of n){const n=()=>{o.matches&&e(r)};o.addEventListener?o.addEventListener("change",n):o.addListener(n),t.push(()=>{o.removeEventListener?o.removeEventListener("change",n):o.removeListener(n)})}return()=>{for(const e of t)e()}}}}(e),O.set(e,n)),n}(n),[n]),[o,c]=i(r.getCurrentIndex);return s(()=>r.subscribe(c),[r]),o}const E={};function L(e){const n=JSON.stringify(e)||"_";return E[n]||(E[n]=d(e)),E[n]}export{u as CACHE_ENABLED,v as ThemeProvider,f as cache,d as getResponsiveValue,l as rem,m as responsive,b as styled,j as useMediaIndex,L as useResponsiveValue,g as useTheme,x as useVariant}; | ||
import{createContext as e,useContext as n,useMemo as t,forwardRef as r,createElement as o,useState as i,useEffect as s}from"react";import{style as c}from"typestyle";import{jsx as u}from"react/jsx-runtime";const a=!0,f={};function d(e,n,t){const r=JSON.stringify([e,...t]);return f[r]||(f[r]=n()),f[r].$debugName=e,f[r]}function m(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function l(e,n,t){const r={};return n.forEach((n,o)=>{const i=t(n,o);if(i)if(0===o)Object.assign(r,i);else{const n=r.$nest||{};n[`@media screen and (min-width: ${e[o-1]}px)`]=i,Object.assign(r,{$nest:n})}}),r}function h(e){return 0===e?"0":e?e/16+"rem":void 0}function p(){return p=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},p.apply(this,arguments)}const v=/*#__PURE__*/e(null);function g(e){const r=n(v),{children:o,mode:i=(null==r?void 0:r.mode),palette:s=(null==r?void 0:r.palette),scheme:c="light",theme:a=(null==r?void 0:r.theme),tone:f=(null==r?void 0:r.tone)}=e,d=t(()=>({mode:i,palette:s,scheme:c,tone:f,theme:a}),[i,s,c,a,f]);return u(v.Provider,{value:d,children:o},void 0)}function x(){const e=n(v);if(!e)throw new Error("Theme: no theme");return e}function y(e){const{theme:n}=x();if(e)return(null==n?void 0:n.variants)&&(null==n?void 0:n.variants[e])}const w=["as"],b=new WeakMap;function O(e){return(...n)=>{const i=/*#__PURE__*/r((r,i)=>{const{as:s=e}=r,u=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}(r,w),{theme:a}=x(),f=t(()=>{const e=p({},u,{ref:i});for(const n of Object.keys(e))"$"===n[0]&&delete e[n];const t=n.map(e=>{if("function"==typeof e){const n=e(u,a);if(!n)return"";if(b.has(n))return b.get(n);const t=c(p({$debugName:e.name||"_"},n));return b.set(n,t),t}if(b.has(e))return b.get(e);const n=c(e);return b.set(e,n),n});return e.className=[e.className,...t].filter(Boolean).join(" "),e},[i,u,a]);/*#__PURE__*/return o(s,f)});return i.displayName="Styled("+e||"undefined)",i}}const $=new WeakMap;function j(e,n){return 0===n?`screen and (max-width: ${e[n]-1}px)`:n===e.length?`screen and (min-width: ${e[n-1]}px)`:`screen and (min-width: ${e[n-1]}px) and (max-width: ${e[n]-1}px)`}function N(){const{theme:e}=x(),{media:n}=e,r=t(()=>function(e){let n=$.get(e);return n||(n=function(e){const n=[];if("undefined"!=typeof window)for(let t=e.length;t>-1;t-=1){const r=j(e,t);n.push({index:t,mq:window.matchMedia(r)})}return{getCurrentIndex:()=>{for(const{index:e,mq:t}of n)if(t.matches)return e;return 0},subscribe:e=>{const t=[];for(const{index:r,mq:o}of n){const n=()=>{o.matches&&e(r)};o.addEventListener?o.addEventListener("change",n):o.addListener(n),t.push(()=>{o.removeEventListener?o.removeEventListener("change",n):o.removeListener(n)})}return()=>{for(const e of t)e()}}}}(e),$.set(e,n)),n}(n),[n]),[o,c]=i(r.getCurrentIndex);return s(()=>r.subscribe(c),[r]),o}const E={};function L(e){const n=JSON.stringify(e)||"_";return E[n]||(E[n]=m(e)),E[n]}export{a as CACHE_ENABLED,g as ThemeProvider,f as cache,d as cachedStyle,m as getResponsiveValue,h as rem,l as responsive,O as styled,N as useMediaIndex,L as useResponsiveValue,x as useTheme,y as useVariant}; | ||
//# sourceMappingURL=body-ui-core.js.map |
@@ -1,2 +0,2 @@ | ||
import{createContext as e,useContext as n,useMemo as r,forwardRef as t,createElement as i,useState as a,useEffect as o}from"react";import{style as u}from"typestyle";import{jsx as c}from"react/jsx-runtime";var f=!0,v={};function d(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function l(e,n,r){var t={};return n.forEach(function(n,i){var a=r(n,i);if(a)if(0===i)Object.assign(t,a);else{var o=t.$nest||{};o["@media screen and (min-width: "+e[i-1]+"px)"]=a,Object.assign(t,{$nest:o})}}),t}function s(e){return 0===e?"0":e?e/16+"rem":void 0}function m(){return m=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},m.apply(this,arguments)}function h(e,n){if(null==e)return{};var r,t,i={},a=Object.keys(e);for(t=0;t<a.length;t++)n.indexOf(r=a[t])>=0||(i[r]=e[r]);return i}function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function y(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return p(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var g=/*#__PURE__*/e(null);function b(e){var t=n(g),i=e.children,a=e.mode,o=void 0===a?null==t?void 0:t.mode:a,u=e.palette,f=void 0===u?null==t?void 0:t.palette:u,v=e.scheme,d=void 0===v?"light":v,l=e.theme,s=void 0===l?null==t?void 0:t.theme:l,m=e.tone,h=void 0===m?null==t?void 0:t.tone:m,p=r(function(){return{mode:o,palette:f,scheme:d,tone:h,theme:s}},[o,f,d,s,h]);return c(g.Provider,{value:p,children:i},void 0)}function w(){var e=n(g);if(!e)throw new Error("Theme: no theme");return e}function x(e){var n=w().theme;if(e)return(null==n?void 0:n.variants)&&(null==n?void 0:n.variants[e])}var j=["as"],O=new WeakMap;function A(e){return function(){var n=arguments,a=/*#__PURE__*/t(function(t,a){var o=t.as,c=void 0===o?e:o,f=h(t,j),v=w().theme,d=r(function(){for(var e=m({},f,{ref:a}),r=0,t=Object.keys(e);r<t.length;r++){var i=t[r];"$"===i[0]&&delete e[i]}var o=[].slice.call(n).map(function(e){if("function"==typeof e){var n=e(f,v);if(!n)return"";if(O.has(n))return O.get(n);var r=u(m({$debugName:e.name||"anon"},n));return O.set(n,r),r}if(O.has(e))return O.get(e);var t=u(e);return O.set(e,t),t});return e.className=[e.className].concat(o).filter(Boolean).join(" "),e},[a,f,v]);/*#__PURE__*/return i(c,d)});return a.displayName="Styled("+e||"undefined)",a}}var E=new WeakMap;function S(e,n){return 0===n?"screen and (max-width: "+(e[n]-1)+"px)":n===e.length?"screen and (min-width: "+e[n-1]+"px)":"screen and (min-width: "+e[n-1]+"px) and (max-width: "+(e[n]-1)+"px)"}function L(){var e=w().theme.media,n=r(function(){return function(e){var n=E.get(e);return n||(n=function(e){var n=[];if("undefined"!=typeof window)for(var r=e.length;r>-1;r-=1){var t=S(e,r);n.push({index:r,mq:window.matchMedia(t)})}return{getCurrentIndex:function(){for(var e,r=y(n);!(e=r()).done;){var t=e.value;if(t.mq.matches)return t.index}return 0},subscribe:function(e){for(var r,t=[],i=function(){var n=r.value,i=n.index,a=n.mq,o=function(){a.matches&&e(i)};a.addEventListener?a.addEventListener("change",o):a.addListener(o),t.push(function(){a.removeEventListener?a.removeEventListener("change",o):a.removeListener(o)})},a=y(n);!(r=a()).done;)i();return function(){for(var e,n=y(t);!(e=n()).done;)(0,e.value)()}}}}(e),E.set(e,n)),n}(e)},[e]),t=a(n.getCurrentIndex),i=t[0],u=t[1];return o(function(){return n.subscribe(u)},[n]),i}var I={};function N(e){var n=JSON.stringify(e)||"_";return I[n]||(I[n]=d(e)),I[n]}export{f as CACHE_ENABLED,b as ThemeProvider,v as cache,d as getResponsiveValue,s as rem,l as responsive,A as styled,L as useMediaIndex,N as useResponsiveValue,w as useTheme,x as useVariant}; | ||
import{createContext as e,useContext as n,useMemo as r,forwardRef as t,createElement as i,useState as a,useEffect as o}from"react";import{style as u}from"typestyle";import{jsx as c}from"react/jsx-runtime";var f=!0,v={};function d(e,n,r){var t=JSON.stringify([e].concat(r));return v[t]||(v[t]=n()),v[t].$debugName=e,v[t]}function l(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function s(e,n,r){var t={};return n.forEach(function(n,i){var a=r(n,i);if(a)if(0===i)Object.assign(t,a);else{var o=t.$nest||{};o["@media screen and (min-width: "+e[i-1]+"px)"]=a,Object.assign(t,{$nest:o})}}),t}function m(e){return 0===e?"0":e?e/16+"rem":void 0}function h(){return h=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},h.apply(this,arguments)}function p(e,n){if(null==e)return{};var r,t,i={},a=Object.keys(e);for(t=0;t<a.length;t++)n.indexOf(r=a[t])>=0||(i[r]=e[r]);return i}function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function g(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return y(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b=/*#__PURE__*/e(null);function w(e){var t=n(b),i=e.children,a=e.mode,o=void 0===a?null==t?void 0:t.mode:a,u=e.palette,f=void 0===u?null==t?void 0:t.palette:u,v=e.scheme,d=void 0===v?"light":v,l=e.theme,s=void 0===l?null==t?void 0:t.theme:l,m=e.tone,h=void 0===m?null==t?void 0:t.tone:m,p=r(function(){return{mode:o,palette:f,scheme:d,tone:h,theme:s}},[o,f,d,s,h]);return c(b.Provider,{value:p,children:i},void 0)}function x(){var e=n(b);if(!e)throw new Error("Theme: no theme");return e}function O(e){var n=x().theme;if(e)return(null==n?void 0:n.variants)&&(null==n?void 0:n.variants[e])}var j=["as"],A=new WeakMap;function S(e){return function(){var n=arguments,a=/*#__PURE__*/t(function(t,a){var o=t.as,c=void 0===o?e:o,f=p(t,j),v=x().theme,d=r(function(){for(var e=h({},f,{ref:a}),r=0,t=Object.keys(e);r<t.length;r++){var i=t[r];"$"===i[0]&&delete e[i]}var o=[].slice.call(n).map(function(e){if("function"==typeof e){var n=e(f,v);if(!n)return"";if(A.has(n))return A.get(n);var r=u(h({$debugName:e.name||"_"},n));return A.set(n,r),r}if(A.has(e))return A.get(e);var t=u(e);return A.set(e,t),t});return e.className=[e.className].concat(o).filter(Boolean).join(" "),e},[a,f,v]);/*#__PURE__*/return i(c,d)});return a.displayName="Styled("+e||"undefined)",a}}var E=new WeakMap;function N(e,n){return 0===n?"screen and (max-width: "+(e[n]-1)+"px)":n===e.length?"screen and (min-width: "+e[n-1]+"px)":"screen and (min-width: "+e[n-1]+"px) and (max-width: "+(e[n]-1)+"px)"}function L(){var e=x().theme.media,n=r(function(){return function(e){var n=E.get(e);return n||(n=function(e){var n=[];if("undefined"!=typeof window)for(var r=e.length;r>-1;r-=1){var t=N(e,r);n.push({index:r,mq:window.matchMedia(t)})}return{getCurrentIndex:function(){for(var e,r=g(n);!(e=r()).done;){var t=e.value;if(t.mq.matches)return t.index}return 0},subscribe:function(e){for(var r,t=[],i=function(){var n=r.value,i=n.index,a=n.mq,o=function(){a.matches&&e(i)};a.addEventListener?a.addEventListener("change",o):a.addListener(o),t.push(function(){a.removeEventListener?a.removeEventListener("change",o):a.removeListener(o)})},a=g(n);!(r=a()).done;)i();return function(){for(var e,n=g(t);!(e=n()).done;)(0,e.value)()}}}}(e),E.set(e,n)),n}(e)},[e]),t=a(n.getCurrentIndex),i=t[0],u=t[1];return o(function(){return n.subscribe(u)},[n]),i}var $={};function I(e){var n=JSON.stringify(e)||"_";return $[n]||($[n]=l(e)),$[n]}export{f as CACHE_ENABLED,w as ThemeProvider,v as cache,d as cachedStyle,l as getResponsiveValue,m as rem,s as responsive,S as styled,L as useMediaIndex,I as useResponsiveValue,x as useTheme,O as useVariant}; | ||
//# sourceMappingURL=body-ui-core.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("typestyle"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["exports","react","typestyle","react/jsx-runtime"],n):n((e||self).core={},e.react,e.typestyle,e.jsx)}(this,function(e,n,t,r){function i(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function o(){return o=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},o.apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(i[t]=e[t]);return i}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function s(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c=/*#__PURE__*/n.createContext(null);function f(){var e=n.useContext(c);if(!e)throw new Error("Theme: no theme");return e}var d=["as"],l=new WeakMap,v=new WeakMap;function m(e,n){return 0===n?"screen and (max-width: "+(e[n]-1)+"px)":n===e.length?"screen and (min-width: "+e[n-1]+"px)":"screen and (min-width: "+e[n-1]+"px) and (max-width: "+(e[n]-1)+"px)"}var h={};e.CACHE_ENABLED=!0,e.ThemeProvider=function(e){var t=n.useContext(c),i=e.children,o=e.mode,a=void 0===o?null==t?void 0:t.mode:o,u=e.palette,s=void 0===u?null==t?void 0:t.palette:u,f=e.scheme,d=void 0===f?"light":f,l=e.theme,v=void 0===l?null==t?void 0:t.theme:l,m=e.tone,h=void 0===m?null==t?void 0:t.tone:m,p=n.useMemo(function(){return{mode:a,palette:s,scheme:d,tone:h,theme:v}},[a,s,d,v,h]);return r.jsx(c.Provider,{value:p,children:i},void 0)},e.cache={},e.getResponsiveValue=i,e.rem=function(e){return 0===e?"0":e?e/16+"rem":void 0},e.responsive=function(e,n,t){var r={};return n.forEach(function(n,i){var o=t(n,i);if(o)if(0===i)Object.assign(r,o);else{var a=r.$nest||{};a["@media screen and (min-width: "+e[i-1]+"px)"]=o,Object.assign(r,{$nest:a})}}),r},e.styled=function(e){return function(){var r=arguments,i=/*#__PURE__*/n.forwardRef(function(i,u){var s=i.as,c=void 0===s?e:s,v=a(i,d),m=f().theme,h=n.useMemo(function(){for(var e=o({},v,{ref:u}),n=0,i=Object.keys(e);n<i.length;n++){var a=i[n];"$"===a[0]&&delete e[a]}var s=[].slice.call(r).map(function(e){if("function"==typeof e){var n=e(v,m);if(!n)return"";if(l.has(n))return l.get(n);var r=t.style(o({$debugName:e.name||"anon"},n));return l.set(n,r),r}if(l.has(e))return l.get(e);var i=t.style(e);return l.set(e,i),i});return e.className=[e.className].concat(s).filter(Boolean).join(" "),e},[u,v,m]);/*#__PURE__*/return n.createElement(c,h)});return i.displayName="Styled("+e||"undefined)",i}},e.useMediaIndex=function(){var e=f().theme.media,t=n.useMemo(function(){return function(e){var n=v.get(e);return n||(n=function(e){var n=[];if("undefined"!=typeof window)for(var t=e.length;t>-1;t-=1){var r=m(e,t);n.push({index:t,mq:window.matchMedia(r)})}return{getCurrentIndex:function(){for(var e,t=s(n);!(e=t()).done;){var r=e.value;if(r.mq.matches)return r.index}return 0},subscribe:function(e){for(var t,r=[],i=function(){var n=t.value,i=n.index,o=n.mq,a=function(){o.matches&&e(i)};o.addEventListener?o.addEventListener("change",a):o.addListener(a),r.push(function(){o.removeEventListener?o.removeEventListener("change",a):o.removeListener(a)})},o=s(n);!(t=o()).done;)i();return function(){for(var e,n=s(r);!(e=n()).done;)(0,e.value)()}}}}(e),v.set(e,n)),n}(e)},[e]),r=n.useState(t.getCurrentIndex),i=r[0],o=r[1];return n.useEffect(function(){return t.subscribe(o)},[t]),i},e.useResponsiveValue=function(e){var n=JSON.stringify(e)||"_";return h[n]||(h[n]=i(e)),h[n]},e.useTheme=f,e.useVariant=function(e){var n=f().theme;if(e)return(null==n?void 0:n.variants)&&(null==n?void 0:n.variants[e])}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("typestyle"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["exports","react","typestyle","react/jsx-runtime"],n):n((e||self).core={},e.react,e.typestyle,e.jsx)}(this,function(e,n,t,r){var i={};function o(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function a(){return a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},a.apply(this,arguments)}function u(e,n){if(null==e)return{};var t,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(i[t]=e[t]);return i}function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function c(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return s(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?s(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f=/*#__PURE__*/n.createContext(null);function d(){var e=n.useContext(f);if(!e)throw new Error("Theme: no theme");return e}var l=["as"],v=new WeakMap,m=new WeakMap;function h(e,n){return 0===n?"screen and (max-width: "+(e[n]-1)+"px)":n===e.length?"screen and (min-width: "+e[n-1]+"px)":"screen and (min-width: "+e[n-1]+"px) and (max-width: "+(e[n]-1)+"px)"}var p={};e.CACHE_ENABLED=!0,e.ThemeProvider=function(e){var t=n.useContext(f),i=e.children,o=e.mode,a=void 0===o?null==t?void 0:t.mode:o,u=e.palette,s=void 0===u?null==t?void 0:t.palette:u,c=e.scheme,d=void 0===c?"light":c,l=e.theme,v=void 0===l?null==t?void 0:t.theme:l,m=e.tone,h=void 0===m?null==t?void 0:t.tone:m,p=n.useMemo(function(){return{mode:a,palette:s,scheme:d,tone:h,theme:v}},[a,s,d,v,h]);return r.jsx(f.Provider,{value:p,children:i},void 0)},e.cache=i,e.cachedStyle=function(e,n,t){var r=JSON.stringify([e].concat(t));return i[r]||(i[r]=n()),i[r].$debugName=e,i[r]},e.getResponsiveValue=o,e.rem=function(e){return 0===e?"0":e?e/16+"rem":void 0},e.responsive=function(e,n,t){var r={};return n.forEach(function(n,i){var o=t(n,i);if(o)if(0===i)Object.assign(r,o);else{var a=r.$nest||{};a["@media screen and (min-width: "+e[i-1]+"px)"]=o,Object.assign(r,{$nest:a})}}),r},e.styled=function(e){return function(){var r=arguments,i=/*#__PURE__*/n.forwardRef(function(i,o){var s=i.as,c=void 0===s?e:s,f=u(i,l),m=d().theme,h=n.useMemo(function(){for(var e=a({},f,{ref:o}),n=0,i=Object.keys(e);n<i.length;n++){var u=i[n];"$"===u[0]&&delete e[u]}var s=[].slice.call(r).map(function(e){if("function"==typeof e){var n=e(f,m);if(!n)return"";if(v.has(n))return v.get(n);var r=t.style(a({$debugName:e.name||"_"},n));return v.set(n,r),r}if(v.has(e))return v.get(e);var i=t.style(e);return v.set(e,i),i});return e.className=[e.className].concat(s).filter(Boolean).join(" "),e},[o,f,m]);/*#__PURE__*/return n.createElement(c,h)});return i.displayName="Styled("+e||"undefined)",i}},e.useMediaIndex=function(){var e=d().theme.media,t=n.useMemo(function(){return function(e){var n=m.get(e);return n||(n=function(e){var n=[];if("undefined"!=typeof window)for(var t=e.length;t>-1;t-=1){var r=h(e,t);n.push({index:t,mq:window.matchMedia(r)})}return{getCurrentIndex:function(){for(var e,t=c(n);!(e=t()).done;){var r=e.value;if(r.mq.matches)return r.index}return 0},subscribe:function(e){for(var t,r=[],i=function(){var n=t.value,i=n.index,o=n.mq,a=function(){o.matches&&e(i)};o.addEventListener?o.addEventListener("change",a):o.addListener(a),r.push(function(){o.removeEventListener?o.removeEventListener("change",a):o.removeListener(a)})},o=c(n);!(t=o()).done;)i();return function(){for(var e,n=c(r);!(e=n()).done;)(0,e.value)()}}}}(e),m.set(e,n)),n}(e)},[e]),r=n.useState(t.getCurrentIndex),i=r[0],o=r[1];return n.useEffect(function(){return t.subscribe(o)},[t]),i},e.useResponsiveValue=function(e){var n=JSON.stringify(e)||"_";return p[n]||(p[n]=o(e)),p[n]},e.useTheme=d,e.useVariant=function(e){var n=d().theme;if(e)return(null==n?void 0:n.variants)&&(null==n?void 0:n.variants[e])}}); | ||
//# sourceMappingURL=body-ui-core.umd.js.map |
@@ -0,1 +1,2 @@ | ||
import { CSSObject } from '.'; | ||
/** | ||
@@ -9,2 +10,6 @@ * @internal | ||
export declare const cache: any; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function cachedStyle(name: string, fn: () => any, deps: unknown[]): CSSObject; | ||
//# sourceMappingURL=cache.d.ts.map |
{ | ||
"name": "@body-ui/core", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"sideEffects": false, | ||
@@ -49,3 +49,3 @@ "files": [ | ||
}, | ||
"gitHead": "fcd2dd34a517b76ee63dcb7be8af66e9a6e9355c" | ||
"gitHead": "20cf330edd309ec2c8e4fb36938b17a6527cadff" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
82533
235