Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rpxl/recast

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rpxl/recast - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

2

dist/index.modern.js

@@ -1,2 +0,2 @@

import e,{createContext as r,useContext as t,forwardRef as n,useState as i,useMemo as l,useEffect as o,useCallback as s}from"react";function u(){return u=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},u.apply(this,arguments)}const a={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:0},d=r(a),c=({value:r={},children:t})=>{var n;const i=u({},a.viewports,r.viewports),l=null!=(n=r.delay)?n:a.delay;/*#__PURE__*/return e.createElement(d.Provider,{value:{viewports:i,delay:l}},t)};function v(){const e=t(d);if(!e)throw new Error("useRecastContext must be used within a RecastProvider");return e}const f=(()=>{let e={};return{get:()=>e,set:(r,t)=>{e=u({},e,{[r]:u({},t)})}}})(),p=f.get,y=f.set,m=(e=[],r={})=>{const t=u({},r);for(const r of e)delete t[r];return t},b=(r,t)=>(i,l)=>{y((null==l?void 0:l.themekey)||t,l);const o=n((t,n)=>{let i=u({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(t),t));const o=Object.keys(l.modifier||{}),s=o.filter(e=>!!i[e]);/*#__PURE__*/return e.createElement(r,u({modifier:s.length?s:void 0,themekey:null==l?void 0:l.themekey,ref:n},m(o,i)))});return"production"!==process.env.NODE_ENV&&(o.displayName=i),o},w=e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,h=e=>Array.isArray(e)?e.map(e=>e.trim()).join(" "):e,k=(e,r)=>w(e)&&w(r)?Object.keys(r).reduce((e,t)=>{return e[t]&&r[t]?u({},e,{[t]:(n=e[t],i=r[t],n&&i?`${h(n)} ${h(i)}`:n?h(n)||"":i&&h(i)||"")}):e[t]?u({},e,{[t]:h(e[t])||""}):r[t]?u({},e,{[t]:h(r[t])||""}):e;var n,i},e):e,z=(e,r)=>{let t;return[n=>new Promise(i=>{t&&clearTimeout(t),t=setTimeout(()=>{i(e(n))},r)}),()=>clearTimeout(t)]},g=({themekey:e,size:r,variant:t,modifier:n})=>{const{viewports:u,delay:a}=v(),d=l(()=>Object.keys(u).sort((e,r)=>u[e]-u[r]),[u]),c=l(()=>{const e=e=>"string"!=typeof e&&w(e);return e(r)||e(t)||e(n)},[r,t,n]),{breakpoint:f}=((e,r=!1,t=0)=>{const[n,s]=i(0),[u,a]=i({breakpoint:"default"}),d=l(()=>Object.keys(e).sort((r,t)=>e[r]-e[t]),[e]);return o(()=>{function i(){const r=r=>d.reduce((t,n)=>r>=e[n]?n:t,"default"),t=r(n),i=r(window.innerWidth);t!==i&&(s(window.innerWidth),a({breakpoint:i}))}if(r){const[e,r]=z(i,t);return window.addEventListener("resize",e),i(),()=>{r(),window.removeEventListener("resize",e)}}},[r,n,e,d,t]),u})(u,c,a),y=s((e={},r)=>{if("string"!=typeof e&&"object"==typeof e&&!Array.isArray(e)&&null!==e){if(e[r])return e[r];{const t=d.slice().reverse(),n=t.findIndex(e=>e===r),i=t.slice(n+1).find(r=>e[r])||"default";return e[i]}}return e},[d]);return s(()=>{var i,l,o,s,u,a;const d=e?null==(i=p())?void 0:i[e]:{},c=y(r,f),v=y(t,f),b=(({prop:e,sizes:r,fallback:t})=>r?e?null==r?void 0:r[e]:t?null==r?void 0:r[t]:{}:{})({prop:"string"==typeof c?c:"",sizes:null==d?void 0:d.size,fallback:null==d||null==(l=d.defaults)?void 0:l.size}),w=(({theme:e,prop:r,variants:t,size:n,fallback:i})=>{var l;if(!t)return{};const o=Object.keys((null==e?void 0:e.size)||{}),s=r||i,u=n&&s?null==t||null==(l=t[s])?void 0:l[n]:{};return k(m(o,s?null==t?void 0:t[s]:{}),u)})({theme:d,size:"string"==typeof c?c:null==d||null==(o=d.defaults)?void 0:o.size,prop:"string"==typeof v?v:"",variants:null==d?void 0:d.variant,fallback:null==d||null==(s=d.defaults)?void 0:s.variant}),h=(({theme:e,prop:r,size:t,variant:n,modifiers:i})=>{if(!i)return{};const l=Array.isArray(r)?r:[r||""],o=Object.keys((null==e?void 0:e.size)||{}),s=Object.keys((null==e?void 0:e.variant)||{});return l.reduce((e,r)=>{var l,u;const a=t&&r?null==i||null==(l=i[r])?void 0:l[t]:{},d=n&&r?null==i||null==(u=i[r])?void 0:u[n]:{};return k(e,k(m([...o,...s],r?null==i?void 0:i[r]:{}),k(a,d)))},{})})({theme:d,size:"string"==typeof c?c:null==d||null==(u=d.defaults)?void 0:u.size,variant:"string"==typeof v?v:null==d||null==(a=d.defaults)?void 0:a.variant,prop:y(n,f),modifiers:null==d?void 0:d.modifier});return[null==d?void 0:d.base,b,w,h].reduce((e,r)=>e&&r?k(e,r):e,{})},[n,r,t,e,f,y])()};export{c as RecastProvider,b as createRecastComponent,p as getTheme,y as setTheme,g as useRecastClasses,v as useRecastContext};
import e,{createContext as r,useContext as t,forwardRef as n,useState as i,useMemo as l,useEffect as o,useCallback as s}from"react";function u(){return u=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},u.apply(this,arguments)}const a={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:0},d=r(a),c=({value:r={},children:t})=>{var n;const i=u({},a.viewports,r.viewports),l=null!=(n=r.delay)?n:a.delay;/*#__PURE__*/return e.createElement(d.Provider,{value:{viewports:i,delay:l}},t)};function v(){const e=t(d);if(!e)throw new Error("useRecastContext must be used within a RecastProvider");return e}const f=(()=>{let e={};return{get:()=>e,set:(r,t)=>{e=u({},e,{[r]:u({},t)})}}})(),p=f.get,y=f.set,m=(e=[],r={})=>{const t=u({},r);for(const r of e)delete t[r];return t},b=(r,t)=>(i,l)=>{y((null==l?void 0:l.themekey)||t,l);const o=n((t,n)=>{let i=u({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(t),t));const o=Object.keys(l.modifier||{}),s=o.filter(e=>!!i[e]);/*#__PURE__*/return e.createElement(r,u({modifier:s.length?s:void 0,themekey:null==l?void 0:l.themekey,ref:n},m(o,i)))});return"production"!==process.env.NODE_ENV&&(o.displayName=i),o},w=e=>Array.isArray(e)?e.map(e=>e.trim()).join(" "):e,h=(e={},r={})=>Object.keys(r).reduce((e,t)=>{return e[t]&&r[t]?u({},e,{[t]:(n=e[t],i=r[t],n&&i?`${w(n)} ${w(i)}`:n?w(n)||"":i&&w(i)||"")}):e[t]?u({},e,{[t]:w(e[t])||""}):r[t]?u({},e,{[t]:w(r[t])||""}):e;var n,i},(e=>{const r=Object.keys(e);return null!=r&&r.length?r.reduce((r,t)=>u({},r,{[t]:w(e[t])||""}),{}):e})(e)),k=(e,r)=>{let t;return[n=>new Promise(i=>{t&&clearTimeout(t),t=setTimeout(()=>{i(e(n))},r)}),()=>clearTimeout(t)]},g=({themekey:e,size:r,variant:t,modifier:n})=>{const{viewports:u,delay:a}=v(),d=l(()=>Object.keys(u).sort((e,r)=>u[e]-u[r]),[u]),c=l(()=>{const e=e=>"string"!=typeof e&&(e=>"object"==typeof e&&!Array.isArray(e)&&null!==e)(e);return e(r)||e(t)||e(n)},[r,t,n]),{breakpoint:f}=((e,r=!1,t=0)=>{const[n,s]=i(0),[u,a]=i({breakpoint:"default"}),d=l(()=>Object.keys(e).sort((r,t)=>e[r]-e[t]),[e]);return o(()=>{function i(){const r=r=>d.reduce((t,n)=>r>=e[n]?n:t,"default"),t=r(n),i=r(window.innerWidth);t!==i&&(s(window.innerWidth),a({breakpoint:i}))}if(r){const[e,r]=k(i,t);return window.addEventListener("resize",e),i(),()=>{r(),window.removeEventListener("resize",e)}}},[r,n,e,d,t]),u})(u,c,a),y=s((e={},r)=>{if("string"!=typeof e&&"object"==typeof e&&!Array.isArray(e)&&null!==e){if(e[r])return e[r];{const t=d.slice().reverse(),n=t.findIndex(e=>e===r),i=t.slice(n+1).find(r=>e[r])||"default";return e[i]}}return e},[d]);return s(()=>{var i,l,o,s,u,a;const d=e?null==(i=p())?void 0:i[e]:{},c=y(r,f),v=y(t,f),b=(({prop:e,sizes:r,fallback:t})=>r?e?null==r?void 0:r[e]:t?null==r?void 0:r[t]:{}:{})({prop:"string"==typeof c?c:"",sizes:null==d?void 0:d.size,fallback:null==d||null==(l=d.defaults)?void 0:l.size}),w=(({theme:e,prop:r,variants:t,size:n,fallback:i})=>{var l;if(!t)return{};const o=Object.keys((null==e?void 0:e.size)||{}),s=r||i,u=n&&s?null==t||null==(l=t[s])?void 0:l[n]:{};return h(m(o,s?null==t?void 0:t[s]:{}),u)})({theme:d,size:"string"==typeof c?c:null==d||null==(o=d.defaults)?void 0:o.size,prop:"string"==typeof v?v:"",variants:null==d?void 0:d.variant,fallback:null==d||null==(s=d.defaults)?void 0:s.variant}),k=(({theme:e,prop:r,size:t,variant:n,modifiers:i})=>{if(!i)return{};const l=Array.isArray(r)?r:[r||""],o=Object.keys((null==e?void 0:e.size)||{}),s=Object.keys((null==e?void 0:e.variant)||{});return l.reduce((e,r)=>{var l,u;const a=t&&r?null==i||null==(l=i[r])?void 0:l[t]:{},d=n&&r?null==i||null==(u=i[r])?void 0:u[n]:{};return h(e,h(m([...o,...s],r?null==i?void 0:i[r]:{}),h(a,d)))},{})})({theme:d,size:"string"==typeof c?c:null==d||null==(u=d.defaults)?void 0:u.size,variant:"string"==typeof v?v:null==d||null==(a=d.defaults)?void 0:a.variant,prop:y(n,f),modifiers:null==d?void 0:d.modifier});return[null==d?void 0:d.base,b,w,k].reduce((e,r)=>e&&r?h(e,r):e,{})},[n,r,t,e,f,y])()};export{c as RecastProvider,b as createRecastComponent,p as getTheme,y as setTheme,g as useRecastClasses,v as useRecastContext};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

import r,{createContext as n,useContext as e,forwardRef as t,useState as i,useMemo as o,useEffect as u,useCallback as a}from"react";function l(){return l=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},l.apply(this,arguments)}function f(r,n){(null==n||n>r.length)&&(n=r.length);for(var e=0,t=new Array(n);e<n;e++)t[e]=r[e];return t}var c={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:0},s=n(c),v=function(n){var e,t=n.value,i=void 0===t?{}:t,o=n.children,u=l({},c.viewports,i.viewports),a=null!=(e=i.delay)?e:c.delay;/*#__PURE__*/return r.createElement(s.Provider,{value:{viewports:u,delay:a}},o)};function d(){var r=e(s);if(!r)throw new Error("useRecastContext must be used within a RecastProvider");return r}var y,p=(y={},{get:function(){return y},set:function(r,n){var e;y=l({},y,((e={})[r]=l({},n),e))}}),m=p.get,b=p.set,h=function(r,n){void 0===r&&(r=[]),void 0===n&&(n={});for(var e,t=l({},n),i=function(r,n){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(e)return(e=e.call(r)).next.bind(e);if(Array.isArray(r)||(e=function(r,n){if(r){if("string"==typeof r)return f(r,n);var e=Object.prototype.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?f(r,n):void 0}}(r))){e&&(r=e);var t=0;return function(){return t>=r.length?{done:!0}:{done:!1,value:r[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.")}(r);!(e=i()).done;)delete t[e.value];return t},w=function(n,e){return function(i,o){b((null==o?void 0:o.themekey)||e,o);var u=t(function(e,t){var i=l({},(function(r){if(null==r)throw new TypeError("Cannot destructure "+r)}(e),e)),u=Object.keys(o.modifier||{}),a=u.filter(function(r){return!!i[r]});/*#__PURE__*/return r.createElement(n,l({modifier:a.length?a:void 0,themekey:null==o?void 0:o.themekey,ref:t},h(u,i)))});return"production"!==process.env.NODE_ENV&&(u.displayName=i),u}},g=function(r){return"object"==typeof r&&!Array.isArray(r)&&null!==r},k=function(r){return Array.isArray(r)?r.map(function(r){return r.trim()}).join(" "):r},j=function(r,n){return g(r)&&g(n)?Object.keys(n).reduce(function(r,e){var t,i,o,u,a;return r[e]&&n[e]?l({},r,((t={})[e]=(a=n[e],(u=r[e])&&a?k(u)+" "+k(a):u?k(u)||"":a&&k(a)||""),t)):r[e]?l({},r,((i={})[e]=k(r[e])||"",i)):n[e]?l({},r,((o={})[e]=k(n[e])||"",o)):r},r):r},z=function(r,n){var e;return[function(t){return new Promise(function(i){e&&clearTimeout(e),e=setTimeout(function(){i(r(t))},n)})},function(){return clearTimeout(e)}]},A=function(r){var n=r.themekey,e=r.size,t=r.variant,l=r.modifier,f=d(),c=f.viewports,s=f.delay,v=o(function(){return Object.keys(c).sort(function(r,n){return c[r]-c[n]})},[c]),y=o(function(){var r=function(r){return"string"!=typeof r&&g(r)};return r(e)||r(t)||r(l)},[e,t,l]),p=function(r,n,e){void 0===n&&(n=!1),void 0===e&&(e=0);var t=i(0),a=t[0],l=t[1],f=i({breakpoint:"default"}),c=f[0],s=f[1],v=o(function(){return Object.keys(r).sort(function(n,e){return r[n]-r[e]})},[r]);return u(function(){function t(){var n=function(n){return v.reduce(function(e,t){return n>=r[t]?t:e},"default")},e=n(a),t=n(window.innerWidth);e!==t&&(l(window.innerWidth),s({breakpoint:t}))}if(n){var i=z(t,e),o=i[0],u=i[1];return window.addEventListener("resize",o),t(),function(){u(),window.removeEventListener("resize",o)}}},[n,a,r,v,e]),c}(c,y,s),b=p.breakpoint,w=a(function(r,n){if(void 0===r&&(r={}),"string"!=typeof r&&"object"==typeof r&&!Array.isArray(r)&&null!==r){if(r[n])return r[n];var e=v.slice().reverse(),t=e.findIndex(function(r){return r===n}),i=e.slice(t+1).find(function(n){return r[n]})||"default";return r[i]}return r},[v]),k=a(function(){var r,i,o,u,a,f,c=n?null==(r=m())?void 0:r[n]:{},s=w(e,b),v=w(t,b),d=function(r){var n=r.prop,e=r.sizes,t=r.fallback;return e?n?null==e?void 0:e[n]:t?null==e?void 0:e[t]:{}:{}}({prop:"string"==typeof s?s:"",sizes:null==c?void 0:c.size,fallback:null==c||null==(i=c.defaults)?void 0:i.size}),y=function(r){var n,e=r.theme,t=r.prop,i=r.variants,o=r.size,u=r.fallback;if(!i)return{};var a=Object.keys((null==e?void 0:e.size)||{}),l=t||u,f=o&&l?null==i||null==(n=i[l])?void 0:n[o]:{};return j(h(a,l?null==i?void 0:i[l]:{}),f)}({theme:c,size:"string"==typeof s?s:null==c||null==(o=c.defaults)?void 0:o.size,prop:"string"==typeof v?v:"",variants:null==c?void 0:c.variant,fallback:null==c||null==(u=c.defaults)?void 0:u.variant}),p=function(r){var n=r.theme,e=r.prop,t=r.size,i=r.variant,o=r.modifiers;if(!o)return{};var u=Array.isArray(e)?e:[e||""],a=Object.keys((null==n?void 0:n.size)||{}),l=Object.keys((null==n?void 0:n.variant)||{});return u.reduce(function(r,n){var e,u,f=n?null==o?void 0:o[n]:{},c=t&&n?null==o||null==(e=o[n])?void 0:e[t]:{},s=i&&n?null==o||null==(u=o[n])?void 0:u[i]:{};return j(r,j(h([].concat(a,l),f),j(c,s)))},{})}({theme:c,size:"string"==typeof s?s:null==c||null==(a=c.defaults)?void 0:a.size,variant:"string"==typeof v?v:null==c||null==(f=c.defaults)?void 0:f.variant,prop:w(l,b),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,d,y,p].reduce(function(r,n){return r&&n?j(r,n):r},{})},[l,e,t,n,b,w]);return k()};export{v as RecastProvider,w as createRecastComponent,m as getTheme,b as setTheme,A as useRecastClasses,d as useRecastContext};
import r,{createContext as n,useContext as e,forwardRef as t,useState as i,useMemo as o,useEffect as u,useCallback as l}from"react";function a(){return a=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},a.apply(this,arguments)}function f(r,n){(null==n||n>r.length)&&(n=r.length);for(var e=0,t=new Array(n);e<n;e++)t[e]=r[e];return t}var c={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:0},v=n(c),s=function(n){var e,t=n.value,i=void 0===t?{}:t,o=n.children,u=a({},c.viewports,i.viewports),l=null!=(e=i.delay)?e:c.delay;/*#__PURE__*/return r.createElement(v.Provider,{value:{viewports:u,delay:l}},o)};function d(){var r=e(v);if(!r)throw new Error("useRecastContext must be used within a RecastProvider");return r}var y,p=(y={},{get:function(){return y},set:function(r,n){var e;y=a({},y,((e={})[r]=a({},n),e))}}),m=p.get,b=p.set,h=function(r,n){void 0===r&&(r=[]),void 0===n&&(n={});for(var e,t=a({},n),i=function(r,n){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(e)return(e=e.call(r)).next.bind(e);if(Array.isArray(r)||(e=function(r,n){if(r){if("string"==typeof r)return f(r,n);var e=Object.prototype.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?f(r,n):void 0}}(r))){e&&(r=e);var t=0;return function(){return t>=r.length?{done:!0}:{done:!1,value:r[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.")}(r);!(e=i()).done;)delete t[e.value];return t},w=function(n,e){return function(i,o){b((null==o?void 0:o.themekey)||e,o);var u=t(function(e,t){var i=a({},(function(r){if(null==r)throw new TypeError("Cannot destructure "+r)}(e),e)),u=Object.keys(o.modifier||{}),l=u.filter(function(r){return!!i[r]});/*#__PURE__*/return r.createElement(n,a({modifier:l.length?l:void 0,themekey:null==o?void 0:o.themekey,ref:t},h(u,i)))});return"production"!==process.env.NODE_ENV&&(u.displayName=i),u}},g=function(r){return Array.isArray(r)?r.map(function(r){return r.trim()}).join(" "):r},k=function(r,n){var e,t;return void 0===r&&(r={}),void 0===n&&(n={}),Object.keys(n).reduce(function(r,e){var t,i,o,u,l;return r[e]&&n[e]?a({},r,((t={})[e]=(l=n[e],(u=r[e])&&l?g(u)+" "+g(l):u?g(u)||"":l&&g(l)||""),t)):r[e]?a({},r,((i={})[e]=g(r[e])||"",i)):n[e]?a({},r,((o={})[e]=g(n[e])||"",o)):r},(e=r,null!=(t=Object.keys(e))&&t.length?t.reduce(function(r,n){var t;return a({},r,((t={})[n]=g(e[n])||"",t))},{}):e))},j=function(r,n){var e;return[function(t){return new Promise(function(i){e&&clearTimeout(e),e=setTimeout(function(){i(r(t))},n)})},function(){return clearTimeout(e)}]},z=function(r){var n=r.themekey,e=r.size,t=r.variant,a=r.modifier,f=d(),c=f.viewports,v=f.delay,s=o(function(){return Object.keys(c).sort(function(r,n){return c[r]-c[n]})},[c]),y=o(function(){var r=function(r){return"string"!=typeof r&&function(r){return"object"==typeof r&&!Array.isArray(r)&&null!==r}(r)};return r(e)||r(t)||r(a)},[e,t,a]),p=function(r,n,e){void 0===n&&(n=!1),void 0===e&&(e=0);var t=i(0),l=t[0],a=t[1],f=i({breakpoint:"default"}),c=f[0],v=f[1],s=o(function(){return Object.keys(r).sort(function(n,e){return r[n]-r[e]})},[r]);return u(function(){function t(){var n=function(n){return s.reduce(function(e,t){return n>=r[t]?t:e},"default")},e=n(l),t=n(window.innerWidth);e!==t&&(a(window.innerWidth),v({breakpoint:t}))}if(n){var i=j(t,e),o=i[0],u=i[1];return window.addEventListener("resize",o),t(),function(){u(),window.removeEventListener("resize",o)}}},[n,l,r,s,e]),c}(c,y,v),b=p.breakpoint,w=l(function(r,n){if(void 0===r&&(r={}),"string"!=typeof r&&"object"==typeof r&&!Array.isArray(r)&&null!==r){if(r[n])return r[n];var e=s.slice().reverse(),t=e.findIndex(function(r){return r===n}),i=e.slice(t+1).find(function(n){return r[n]})||"default";return r[i]}return r},[s]),g=l(function(){var r,i,o,u,l,f,c=n?null==(r=m())?void 0:r[n]:{},v=w(e,b),s=w(t,b),d=function(r){var n=r.prop,e=r.sizes,t=r.fallback;return e?n?null==e?void 0:e[n]:t?null==e?void 0:e[t]:{}:{}}({prop:"string"==typeof v?v:"",sizes:null==c?void 0:c.size,fallback:null==c||null==(i=c.defaults)?void 0:i.size}),y=function(r){var n,e=r.theme,t=r.prop,i=r.variants,o=r.size,u=r.fallback;if(!i)return{};var l=Object.keys((null==e?void 0:e.size)||{}),a=t||u,f=o&&a?null==i||null==(n=i[a])?void 0:n[o]:{};return k(h(l,a?null==i?void 0:i[a]:{}),f)}({theme:c,size:"string"==typeof v?v:null==c||null==(o=c.defaults)?void 0:o.size,prop:"string"==typeof s?s:"",variants:null==c?void 0:c.variant,fallback:null==c||null==(u=c.defaults)?void 0:u.variant}),p=function(r){var n=r.theme,e=r.prop,t=r.size,i=r.variant,o=r.modifiers;if(!o)return{};var u=Array.isArray(e)?e:[e||""],l=Object.keys((null==n?void 0:n.size)||{}),a=Object.keys((null==n?void 0:n.variant)||{});return u.reduce(function(r,n){var e,u,f=n?null==o?void 0:o[n]:{},c=t&&n?null==o||null==(e=o[n])?void 0:e[t]:{},v=i&&n?null==o||null==(u=o[n])?void 0:u[i]:{};return k(r,k(h([].concat(l,a),f),k(c,v)))},{})}({theme:c,size:"string"==typeof v?v:null==c||null==(l=c.defaults)?void 0:l.size,variant:"string"==typeof s?s:null==c||null==(f=c.defaults)?void 0:f.variant,prop:w(a,b),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,d,y,p].reduce(function(r,n){return r&&n?k(r,n):r},{})},[a,e,t,n,b,w]);return g()};export{s as RecastProvider,w as createRecastComponent,m as getTheme,b as setTheme,z as useRecastClasses,d as useRecastContext};
//# sourceMappingURL=index.module.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e||self).recast={},e.react)}(this,function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(t);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var u={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:0},a=t.createContext(u);function l(){var e=t.useContext(a);if(!e)throw new Error("useRecastContext must be used within a RecastProvider");return e}var f,s=(f={},{get:function(){return f},set:function(e,t){var n;f=i({},f,((n={})[e]=i({},t),n))}}),c=s.get,d=s.set,v=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});for(var n,r=i({},t),u=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e))){n&&(e=n);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.")}(e);!(n=u()).done;)delete r[n.value];return r},p=function(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e},y=function(e){return Array.isArray(e)?e.map(function(e){return e.trim()}).join(" "):e},m=function(e,t){return p(e)&&p(t)?Object.keys(t).reduce(function(e,n){var r,o,u,a,l;return e[n]&&t[n]?i({},e,((r={})[n]=(l=t[n],(a=e[n])&&l?y(a)+" "+y(l):a?y(a)||"":l&&y(l)||""),r)):e[n]?i({},e,((o={})[n]=y(e[n])||"",o)):t[n]?i({},e,((u={})[n]=y(t[n])||"",u)):e},e):e},b=function(e,t){var n;return[function(r){return new Promise(function(i){n&&clearTimeout(n),n=setTimeout(function(){i(e(r))},t)})},function(){return clearTimeout(n)}]};e.RecastProvider=function(e){var t,n=e.value,o=void 0===n?{}:n,l=e.children,f=i({},u.viewports,o.viewports),s=null!=(t=o.delay)?t:u.delay;/*#__PURE__*/return r.default.createElement(a.Provider,{value:{viewports:f,delay:s}},l)},e.createRecastComponent=function(e,n){return function(o,u){d((null==u?void 0:u.themekey)||n,u);var a=t.forwardRef(function(t,n){var o=i({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(t),t)),a=Object.keys(u.modifier||{}),l=a.filter(function(e){return!!o[e]});/*#__PURE__*/return r.default.createElement(e,i({modifier:l.length?l:void 0,themekey:null==u?void 0:u.themekey,ref:n},v(a,o)))});return"production"!==process.env.NODE_ENV&&(a.displayName=o),a}},e.getTheme=c,e.setTheme=d,e.useRecastClasses=function(e){var n=e.themekey,r=e.size,i=e.variant,o=e.modifier,u=l(),a=u.viewports,f=u.delay,s=t.useMemo(function(){return Object.keys(a).sort(function(e,t){return a[e]-a[t]})},[a]),d=t.useMemo(function(){var e=function(e){return"string"!=typeof e&&p(e)};return e(r)||e(i)||e(o)},[r,i,o]),y=function(e,n,r){void 0===n&&(n=!1),void 0===r&&(r=0);var i=t.useState(0),o=i[0],u=i[1],a=t.useState({breakpoint:"default"}),l=a[0],f=a[1],s=t.useMemo(function(){return Object.keys(e).sort(function(t,n){return e[t]-e[n]})},[e]);return t.useEffect(function(){function t(){var t=function(t){return s.reduce(function(n,r){return t>=e[r]?r:n},"default")},n=t(o),r=t(window.innerWidth);n!==r&&(u(window.innerWidth),f({breakpoint:r}))}if(n){var i=b(t,r),a=i[0],l=i[1];return window.addEventListener("resize",a),t(),function(){l(),window.removeEventListener("resize",a)}}},[n,o,e,s,r]),l}(a,d,f),h=y.breakpoint,w=t.useCallback(function(e,t){if(void 0===e&&(e={}),"string"!=typeof e&&"object"==typeof e&&!Array.isArray(e)&&null!==e){if(e[t])return e[t];var n=s.slice().reverse(),r=n.findIndex(function(e){return e===t}),i=n.slice(r+1).find(function(t){return e[t]})||"default";return e[i]}return e},[s]),g=t.useCallback(function(){var e,t,u,a,l,f,s=n?null==(e=c())?void 0:e[n]:{},d=w(r,h),p=w(i,h),y=function(e){var t=e.prop,n=e.sizes,r=e.fallback;return n?t?null==n?void 0:n[t]:r?null==n?void 0:n[r]:{}:{}}({prop:"string"==typeof d?d:"",sizes:null==s?void 0:s.size,fallback:null==s||null==(t=s.defaults)?void 0:t.size}),b=function(e){var t,n=e.theme,r=e.prop,i=e.variants,o=e.size,u=e.fallback;if(!i)return{};var a=Object.keys((null==n?void 0:n.size)||{}),l=r||u,f=o&&l?null==i||null==(t=i[l])?void 0:t[o]:{};return m(v(a,l?null==i?void 0:i[l]:{}),f)}({theme:s,size:"string"==typeof d?d:null==s||null==(u=s.defaults)?void 0:u.size,prop:"string"==typeof p?p:"",variants:null==s?void 0:s.variant,fallback:null==s||null==(a=s.defaults)?void 0:a.variant}),g=function(e){var t=e.theme,n=e.prop,r=e.size,i=e.variant,o=e.modifiers;if(!o)return{};var u=Array.isArray(n)?n:[n||""],a=Object.keys((null==t?void 0:t.size)||{}),l=Object.keys((null==t?void 0:t.variant)||{});return u.reduce(function(e,t){var n,u,f=t?null==o?void 0:o[t]:{},s=r&&t?null==o||null==(n=o[t])?void 0:n[r]:{},c=i&&t?null==o||null==(u=o[t])?void 0:u[i]:{};return m(e,m(v([].concat(a,l),f),m(s,c)))},{})}({theme:s,size:"string"==typeof d?d:null==s||null==(l=s.defaults)?void 0:l.size,variant:"string"==typeof p?p:null==s||null==(f=s.defaults)?void 0:f.variant,prop:w(o,h),modifiers:null==s?void 0:s.modifier});return[null==s?void 0:s.base,y,b,g].reduce(function(e,t){return e&&t?m(e,t):e},{})},[o,r,i,n,h,w]);return g()},e.useRecastContext=l});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e||self).recast={},e.react)}(this,function(e,n){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/t(n);function i(){return i=Object.assign?Object.assign.bind():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},i.apply(this,arguments)}function o(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}var u={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:0},a=n.createContext(u);function l(){var e=n.useContext(a);if(!e)throw new Error("useRecastContext must be used within a RecastProvider");return e}var f,c=(f={},{get:function(){return f},set:function(e,n){var t;f=i({},f,((t={})[e]=i({},n),t))}}),s=c.get,d=c.set,v=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});for(var t,r=i({},n),u=function(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 o(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)?o(e,n):void 0}}(e))){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.")}(e);!(t=u()).done;)delete r[t.value];return r},y=function(e){return Array.isArray(e)?e.map(function(e){return e.trim()}).join(" "):e},p=function(e,n){var t,r;return void 0===e&&(e={}),void 0===n&&(n={}),Object.keys(n).reduce(function(e,t){var r,o,u,a,l;return e[t]&&n[t]?i({},e,((r={})[t]=(l=n[t],(a=e[t])&&l?y(a)+" "+y(l):a?y(a)||"":l&&y(l)||""),r)):e[t]?i({},e,((o={})[t]=y(e[t])||"",o)):n[t]?i({},e,((u={})[t]=y(n[t])||"",u)):e},(t=e,null!=(r=Object.keys(t))&&r.length?r.reduce(function(e,n){var r;return i({},e,((r={})[n]=y(t[n])||"",r))},{}):t))},m=function(e,n){var t;return[function(r){return new Promise(function(i){t&&clearTimeout(t),t=setTimeout(function(){i(e(r))},n)})},function(){return clearTimeout(t)}]};e.RecastProvider=function(e){var n,t=e.value,o=void 0===t?{}:t,l=e.children,f=i({},u.viewports,o.viewports),c=null!=(n=o.delay)?n:u.delay;/*#__PURE__*/return r.default.createElement(a.Provider,{value:{viewports:f,delay:c}},l)},e.createRecastComponent=function(e,t){return function(o,u){d((null==u?void 0:u.themekey)||t,u);var a=n.forwardRef(function(n,t){var o=i({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(n),n)),a=Object.keys(u.modifier||{}),l=a.filter(function(e){return!!o[e]});/*#__PURE__*/return r.default.createElement(e,i({modifier:l.length?l:void 0,themekey:null==u?void 0:u.themekey,ref:t},v(a,o)))});return"production"!==process.env.NODE_ENV&&(a.displayName=o),a}},e.getTheme=s,e.setTheme=d,e.useRecastClasses=function(e){var t=e.themekey,r=e.size,i=e.variant,o=e.modifier,u=l(),a=u.viewports,f=u.delay,c=n.useMemo(function(){return Object.keys(a).sort(function(e,n){return a[e]-a[n]})},[a]),d=n.useMemo(function(){var e=function(e){return"string"!=typeof e&&function(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}(e)};return e(r)||e(i)||e(o)},[r,i,o]),y=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=0);var i=n.useState(0),o=i[0],u=i[1],a=n.useState({breakpoint:"default"}),l=a[0],f=a[1],c=n.useMemo(function(){return Object.keys(e).sort(function(n,t){return e[n]-e[t]})},[e]);return n.useEffect(function(){function n(){var n=function(n){return c.reduce(function(t,r){return n>=e[r]?r:t},"default")},t=n(o),r=n(window.innerWidth);t!==r&&(u(window.innerWidth),f({breakpoint:r}))}if(t){var i=m(n,r),a=i[0],l=i[1];return window.addEventListener("resize",a),n(),function(){l(),window.removeEventListener("resize",a)}}},[t,o,e,c,r]),l}(a,d,f),b=y.breakpoint,h=n.useCallback(function(e,n){if(void 0===e&&(e={}),"string"!=typeof e&&"object"==typeof e&&!Array.isArray(e)&&null!==e){if(e[n])return e[n];var t=c.slice().reverse(),r=t.findIndex(function(e){return e===n}),i=t.slice(r+1).find(function(n){return e[n]})||"default";return e[i]}return e},[c]),g=n.useCallback(function(){var e,n,u,a,l,f,c=t?null==(e=s())?void 0:e[t]:{},d=h(r,b),y=h(i,b),m=function(e){var n=e.prop,t=e.sizes,r=e.fallback;return t?n?null==t?void 0:t[n]:r?null==t?void 0:t[r]:{}:{}}({prop:"string"==typeof d?d:"",sizes:null==c?void 0:c.size,fallback:null==c||null==(n=c.defaults)?void 0:n.size}),g=function(e){var n,t=e.theme,r=e.prop,i=e.variants,o=e.size,u=e.fallback;if(!i)return{};var a=Object.keys((null==t?void 0:t.size)||{}),l=r||u,f=o&&l?null==i||null==(n=i[l])?void 0:n[o]:{};return p(v(a,l?null==i?void 0:i[l]:{}),f)}({theme:c,size:"string"==typeof d?d:null==c||null==(u=c.defaults)?void 0:u.size,prop:"string"==typeof y?y:"",variants:null==c?void 0:c.variant,fallback:null==c||null==(a=c.defaults)?void 0:a.variant}),w=function(e){var n=e.theme,t=e.prop,r=e.size,i=e.variant,o=e.modifiers;if(!o)return{};var u=Array.isArray(t)?t:[t||""],a=Object.keys((null==n?void 0:n.size)||{}),l=Object.keys((null==n?void 0:n.variant)||{});return u.reduce(function(e,n){var t,u,f=n?null==o?void 0:o[n]:{},c=r&&n?null==o||null==(t=o[n])?void 0:t[r]:{},s=i&&n?null==o||null==(u=o[n])?void 0:u[i]:{};return p(e,p(v([].concat(a,l),f),p(c,s)))},{})}({theme:c,size:"string"==typeof d?d:null==c||null==(l=c.defaults)?void 0:l.size,variant:"string"==typeof y?y:null==c||null==(f=c.defaults)?void 0:f.variant,prop:h(o,b),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,m,g,w].reduce(function(e,n){return e&&n?p(e,n):e},{})},[o,r,i,t,b,h]);return g()},e.useRecastContext=l});
//# sourceMappingURL=index.umd.js.map
export type ClassNameRecord = Record<string, string | string[]>;
export declare const mergeClassNames: (target: ClassNameRecord, source: ClassNameRecord) => ClassNameRecord;
/**
* Merges class names from a target and source object, normalizing and concatenating them.
* If a class name exists in both the target and source, they are merged.
* If a class name exists only in the target or source, it is normalized.
*
* @param {ClassNameRecord} target - The target object containing class names.
* @param {ClassNameRecord} source - The source object containing class names.
* @returns {ClassNameRecord} The merged class names object.
*/
export declare const mergeClassNames: (target?: ClassNameRecord, source?: ClassNameRecord) => ClassNameRecord;
{
"name": "@rpxl/recast",
"license": "MIT",
"version": "0.1.3",
"version": "0.1.4",
"type": "module",

@@ -6,0 +6,0 @@ "sideEffects": false,

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc