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

react-svm

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-svm - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

3

dist/hooks/useSVMClasses.d.ts

@@ -7,3 +7,4 @@ type Props = {

};
export declare const useSVMClasses: <K extends Record<string, string | string[]>>({ themekey, size, variant, modifier, }: Props) => Record<keyof K, string> | undefined;
type State<K> = Record<keyof K, string> | undefined;
export declare const useSVMClasses: <K extends Record<string, string | string[]>>({ themekey, size, variant, modifier, }: Props) => State<K>;
export {};

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

import e,{createContext as r,useContext as t,forwardRef as n,useState as i,useMemo as l,useCallback as o,useEffect as s}from"react";import u from"lodash.omit";import a from"lodash.mergewith";import d from"lodash.debounce";function v(){return v=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},v.apply(this,arguments)}const c={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:50},f=r(c),p=({value:r={},children:t})=>{var n;const i=v({},c.viewports,r.viewports),l=null!=(n=r.delay)?n:c.delay;/*#__PURE__*/return e.createElement(f.Provider,{value:{viewports:i,delay:l}},t)};function m(){const e=t(f);if(!e)throw new Error("useSVMContext must be used within a SVMProvider");return e}const y=(()=>{let e={};return{get:()=>e,set:(r,t)=>{e=v({},e,{[r]:v({},t)})}}})(),h=y.get,w=y.set,b=(r,t)=>(i,l)=>{w((null==l?void 0:l.themekey)||t,l);const o=n((t,n)=>{let i=v({},(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,v({modifier:s.length?s:void 0,themekey:null==l?void 0:l.themekey,ref:n},u(i,o)))});return"production"!==process.env.NODE_ENV&&(o.displayName=i),o},z=e=>Array.isArray(e)?e.map(e=>e.trim()).join(" "):e,k=(e,r)=>e&&null!=e&&e.length&&r?null==e?void 0:e.concat(` ${z(r)}`):r?z(r):void 0,g=e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,j=({themekey:e,size:r,variant:t,modifier:n})=>{const{viewports:v,delay:c}=m(),[f,p]=i(0),[y,w]=i("default"),b=l(()=>Object.keys(v).sort((e,r)=>v[e]-v[r]),[v]),z=l(()=>{const e=e=>"string"!=typeof e&&g(e);return e(r)||e(t)||e(n)},[r,t,n]),j=o(()=>{var i,l,o,s,d,v;const c=e?null==(i=h())?void 0:i[e]:{},f=(e,r)=>{if("string"!=typeof e&&g(e)){if(e[r])return e[r];{const t=b.slice().reverse(),n=t.findIndex(e=>e===r),i=t.slice(n+1).find(r=>e[r])||"default";return e[i]}}return e},p=(({prop:e,sizes:r,fallback:t})=>r?e?null==r?void 0:r[e]:t?null==r?void 0:r[t]:{}:{})({prop:f(r,y),sizes:null==c?void 0:c.size,fallback:null==c||null==(l=c.defaults)?void 0:l.size}),m=(({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,d=n&&s?null==t||null==(l=t[s])?void 0:l[n]:{};return a(u(s?null==t?void 0:t[s]:{},o),d,k)})({theme:c,size:f(r,y)||(null==c||null==(o=c.defaults)?void 0:o.size),prop:f(t,y),variants:null==c?void 0:c.variant,fallback:null==c||null==(s=c.defaults)?void 0:s.variant}),w=(({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,d;const v=t&&r?null==i||null==(l=i[r])?void 0:l[t]:{},c=n&&r?null==i||null==(d=i[r])?void 0:d[n]:{};return a(e,a(u(r?null==i?void 0:i[r]:{},o,s),v,c,k),k)},{})})({theme:c,size:f(r,y)||(null==c||null==(d=c.defaults)?void 0:d.size),variant:f(t,y)||(null==c||null==(v=c.defaults)?void 0:v.variant),prop:f(n,y),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,p,m,w].reduce((e,r)=>a(e,r,k),{})},[n,r,t,e,y,b]),[O,E]=i(j());s(()=>{E(j())},[y,j]);const A=o(()=>{const e=e=>b.reduce((r,t)=>e>=v[t]?t:r,"default"),r=e(f),t=e(window.innerWidth);r!==t&&(p(window.innerWidth),w(t))},[v,b,f,p,w]);return s(()=>{if(z){const e=d(A,c);return window.addEventListener("resize",e),A(),()=>window.removeEventListener("resize",e)}}),O};export{p as SVMProvider,b as createSVMComponent,h as getTheme,w as setTheme,j as useSVMClasses,m as useSVMContext};
import e,{createContext as r,useContext as t,forwardRef as n,useState as i,useMemo as l,useCallback as o,useEffect as s}from"react";import u from"lodash.omit";import a from"lodash.mergewith";import d from"lodash.debounce";function v(){return v=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},v.apply(this,arguments)}const c={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:50},f=r(c),p=({value:r={},children:t})=>{var n;const i=v({},c.viewports,r.viewports),l=null!=(n=r.delay)?n:c.delay;/*#__PURE__*/return e.createElement(f.Provider,{value:{viewports:i,delay:l}},t)};function m(){const e=t(f);if(!e)throw new Error("useSVMContext must be used within a SVMProvider");return e}const y=(()=>{let e={};return{get:()=>e,set:(r,t)=>{e=v({},e,{[r]:v({},t)})}}})(),h=y.get,w=y.set,b=(r,t)=>(i,l)=>{w((null==l?void 0:l.themekey)||t,l);const o=n((t,n)=>{let i=v({},(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,v({modifier:s.length?s:void 0,themekey:null==l?void 0:l.themekey,ref:n},u(i,o)))});return"production"!==process.env.NODE_ENV&&(o.displayName=i),o},z=e=>Array.isArray(e)?e.map(e=>e.trim()).join(" "):e,k=(e,r)=>e&&null!=e&&e.length&&r?null==e?void 0:e.concat(` ${z(r)}`):r?z(r):void 0,g=e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,j=({themekey:e,size:r,variant:t,modifier:n})=>{const{viewports:v,delay:c}=m(),[f,p]=i(0),[y,w]=i("default"),b=l(()=>Object.keys(v).sort((e,r)=>v[e]-v[r]),[v]),z=l(()=>{const e=e=>"string"!=typeof e&&g(e);return e(r)||e(t)||e(n)},[r,t,n]),j=o(()=>{var i,l,o,s,d,v;const c=e?null==(i=h())?void 0:i[e]:{},f=(e,r)=>{if("string"!=typeof e&&g(e)){if(e[r])return e[r];{const t=b.slice().reverse(),n=t.findIndex(e=>e===r),i=t.slice(n+1).find(r=>e[r])||"default";return e[i]}}return e},p=(({prop:e,sizes:r,fallback:t})=>r?e?null==r?void 0:r[e]:t?null==r?void 0:r[t]:{}:{})({prop:f(r,y),sizes:null==c?void 0:c.size,fallback:null==c||null==(l=c.defaults)?void 0:l.size}),m=(({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,d=n&&s?null==t||null==(l=t[s])?void 0:l[n]:{};return a(u(s?null==t?void 0:t[s]:{},o),d,k)})({theme:c,size:f(r,y)||(null==c||null==(o=c.defaults)?void 0:o.size),prop:f(t,y),variants:null==c?void 0:c.variant,fallback:null==c||null==(s=c.defaults)?void 0:s.variant}),w=(({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,d;const v=t&&r?null==i||null==(l=i[r])?void 0:l[t]:{},c=n&&r?null==i||null==(d=i[r])?void 0:d[n]:{};return a(e,a(u(r?null==i?void 0:i[r]:{},o,s),v,c,k),k)},{})})({theme:c,size:f(r,y)||(null==c||null==(d=c.defaults)?void 0:d.size),variant:f(t,y)||(null==c||null==(v=c.defaults)?void 0:v.variant),prop:f(n,y),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,p,m,w].reduce((e,r)=>a(e,r,k),{})},[n,r,t,e,y,b]);s(()=>{A(()=>j())},[y,j]);const O=o(()=>{const e=e=>b.reduce((r,t)=>e>=v[t]?t:r,"default"),r=e(f),t=e(window.innerWidth);r!==t&&(p(window.innerWidth),w(t))},[v,b,f,p,w]);s(()=>{if(z){const e=d(O,c);return window.addEventListener("resize",e),O(),()=>window.removeEventListener("resize",e)}});const[E,A]=i(()=>j());return E};export{p as SVMProvider,b as createSVMComponent,h as getTheme,w as setTheme,j as useSVMClasses,m as useSVMContext};
//# sourceMappingURL=index.modern.js.map

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

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

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("lodash.omit"),require("lodash.mergewith"),require("lodash.debounce")):"function"==typeof define&&define.amd?define(["exports","react","lodash.omit","lodash.mergewith","lodash.debounce"],n):n((e||self).reactSvm={},e.react,e.omit,e.mergewith,e.debounce)}(this,function(e,n,t,r,i){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/u(n),l=/*#__PURE__*/u(t),a=/*#__PURE__*/u(r),f=/*#__PURE__*/u(i);function d(){return d=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},d.apply(this,arguments)}var s={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:50},c=n.createContext(s);function v(){var e=n.useContext(c);if(!e)throw new Error("useSVMContext must be used within a SVMProvider");return e}var p,m=(p={},{get:function(){return p},set:function(e,n){var t;p=d({},p,((t={})[e]=d({},n),t))}}),h=m.get,y=m.set,b=function(e){return Array.isArray(e)?e.map(function(e){return e.trim()}).join(" "):e},w=function(e,n){return e&&null!=e&&e.length&&n?null==e?void 0:e.concat(" "+b(n)):n?b(n):void 0},g=function(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e};e.SVMProvider=function(e){var n,t=e.value,r=void 0===t?{}:t,i=e.children,u=d({},s.viewports,r.viewports),l=null!=(n=r.delay)?n:s.delay;/*#__PURE__*/return o.default.createElement(c.Provider,{value:{viewports:u,delay:l}},i)},e.createSVMComponent=function(e,t){return function(r,i){y((null==i?void 0:i.themekey)||t,i);var u=n.forwardRef(function(n,t){var r=d({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(n),n)),u=Object.keys(i.modifier||{}),a=u.filter(function(e){return!!r[e]});/*#__PURE__*/return o.default.createElement(e,d({modifier:a.length?a:void 0,themekey:null==i?void 0:i.themekey,ref:t},l.default(r,u)))});return"production"!==process.env.NODE_ENV&&(u.displayName=r),u}},e.getTheme=h,e.setTheme=y,e.useSVMClasses=function(e){var t=e.themekey,r=e.size,i=e.variant,u=e.modifier,o=v(),d=o.viewports,s=o.delay,c=n.useState(0),p=c[0],m=c[1],y=n.useState("default"),b=y[0],k=y[1],z=n.useMemo(function(){return Object.keys(d).sort(function(e,n){return d[e]-d[n]})},[d]),j=n.useMemo(function(){var e=function(e){return"string"!=typeof e&&g(e)};return e(r)||e(i)||e(u)},[r,i,u]),E=n.useCallback(function(){var e,n,o,f,d,s,c=t?null==(e=h())?void 0:e[t]:{},v=function(e,n){if("string"!=typeof e&&g(e)){if(e[n])return e[n];var t=z.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},p=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:v(r,b),sizes:null==c?void 0:c.size,fallback:null==c||null==(n=c.defaults)?void 0:n.size}),m=function(e){var n,t=e.theme,r=e.prop,i=e.variants,u=e.size,o=e.fallback;if(!i)return{};var f=Object.keys((null==t?void 0:t.size)||{}),d=r||o,s=u&&d?null==i||null==(n=i[d])?void 0:n[u]:{};return a.default(l.default(d?null==i?void 0:i[d]:{},f),s,w)}({theme:c,size:v(r,b)||(null==c||null==(o=c.defaults)?void 0:o.size),prop:v(i,b),variants:null==c?void 0:c.variant,fallback:null==c||null==(f=c.defaults)?void 0:f.variant}),y=function(e){var n=e.theme,t=e.prop,r=e.size,i=e.variant,u=e.modifiers;if(!u)return{};var o=Array.isArray(t)?t:[t||""],f=Object.keys((null==n?void 0:n.size)||{}),d=Object.keys((null==n?void 0:n.variant)||{});return o.reduce(function(e,n){var t,o,s=r&&n?null==u||null==(t=u[n])?void 0:t[r]:{},c=i&&n?null==u||null==(o=u[n])?void 0:o[i]:{};return a.default(e,a.default(l.default(n?null==u?void 0:u[n]:{},f,d),s,c,w),w)},{})}({theme:c,size:v(r,b)||(null==c||null==(d=c.defaults)?void 0:d.size),variant:v(i,b)||(null==c||null==(s=c.defaults)?void 0:s.variant),prop:v(u,b),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,p,m,y].reduce(function(e,n){return a.default(e,n,w)},{})},[u,r,i,t,b,z]),O=n.useState(E()),S=O[0],x=O[1];n.useEffect(function(){x(E())},[b,E]);var C=n.useCallback(function(){var e=function(e){return z.reduce(function(n,t){return e>=d[t]?t:n},"default")},n=e(p),t=e(window.innerWidth);n!==t&&(m(window.innerWidth),k(t))},[d,z,p,m,k]);return n.useEffect(function(){if(j){var e=f.default(C,s);return window.addEventListener("resize",e),C(),function(){return window.removeEventListener("resize",e)}}}),S},e.useSVMContext=v});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("lodash.omit"),require("lodash.mergewith"),require("lodash.debounce")):"function"==typeof define&&define.amd?define(["exports","react","lodash.omit","lodash.mergewith","lodash.debounce"],n):n((e||self).reactSvm={},e.react,e.omit,e.mergewith,e.debounce)}(this,function(e,n,t,r,i){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/u(n),l=/*#__PURE__*/u(t),a=/*#__PURE__*/u(r),f=/*#__PURE__*/u(i);function d(){return d=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},d.apply(this,arguments)}var s={viewports:{sm:640,md:768,lg:1024,xl:1280},delay:50},c=n.createContext(s);function v(){var e=n.useContext(c);if(!e)throw new Error("useSVMContext must be used within a SVMProvider");return e}var p,m=(p={},{get:function(){return p},set:function(e,n){var t;p=d({},p,((t={})[e]=d({},n),t))}}),h=m.get,y=m.set,b=function(e){return Array.isArray(e)?e.map(function(e){return e.trim()}).join(" "):e},w=function(e,n){return e&&null!=e&&e.length&&n?null==e?void 0:e.concat(" "+b(n)):n?b(n):void 0},g=function(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e};e.SVMProvider=function(e){var n,t=e.value,r=void 0===t?{}:t,i=e.children,u=d({},s.viewports,r.viewports),l=null!=(n=r.delay)?n:s.delay;/*#__PURE__*/return o.default.createElement(c.Provider,{value:{viewports:u,delay:l}},i)},e.createSVMComponent=function(e,t){return function(r,i){y((null==i?void 0:i.themekey)||t,i);var u=n.forwardRef(function(n,t){var r=d({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(n),n)),u=Object.keys(i.modifier||{}),a=u.filter(function(e){return!!r[e]});/*#__PURE__*/return o.default.createElement(e,d({modifier:a.length?a:void 0,themekey:null==i?void 0:i.themekey,ref:t},l.default(r,u)))});return"production"!==process.env.NODE_ENV&&(u.displayName=r),u}},e.getTheme=h,e.setTheme=y,e.useSVMClasses=function(e){var t=e.themekey,r=e.size,i=e.variant,u=e.modifier,o=v(),d=o.viewports,s=o.delay,c=n.useState(0),p=c[0],m=c[1],y=n.useState("default"),b=y[0],k=y[1],z=n.useMemo(function(){return Object.keys(d).sort(function(e,n){return d[e]-d[n]})},[d]),j=n.useMemo(function(){var e=function(e){return"string"!=typeof e&&g(e)};return e(r)||e(i)||e(u)},[r,i,u]),E=n.useCallback(function(){var e,n,o,f,d,s,c=t?null==(e=h())?void 0:e[t]:{},v=function(e,n){if("string"!=typeof e&&g(e)){if(e[n])return e[n];var t=z.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},p=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:v(r,b),sizes:null==c?void 0:c.size,fallback:null==c||null==(n=c.defaults)?void 0:n.size}),m=function(e){var n,t=e.theme,r=e.prop,i=e.variants,u=e.size,o=e.fallback;if(!i)return{};var f=Object.keys((null==t?void 0:t.size)||{}),d=r||o,s=u&&d?null==i||null==(n=i[d])?void 0:n[u]:{};return a.default(l.default(d?null==i?void 0:i[d]:{},f),s,w)}({theme:c,size:v(r,b)||(null==c||null==(o=c.defaults)?void 0:o.size),prop:v(i,b),variants:null==c?void 0:c.variant,fallback:null==c||null==(f=c.defaults)?void 0:f.variant}),y=function(e){var n=e.theme,t=e.prop,r=e.size,i=e.variant,u=e.modifiers;if(!u)return{};var o=Array.isArray(t)?t:[t||""],f=Object.keys((null==n?void 0:n.size)||{}),d=Object.keys((null==n?void 0:n.variant)||{});return o.reduce(function(e,n){var t,o,s=r&&n?null==u||null==(t=u[n])?void 0:t[r]:{},c=i&&n?null==u||null==(o=u[n])?void 0:o[i]:{};return a.default(e,a.default(l.default(n?null==u?void 0:u[n]:{},f,d),s,c,w),w)},{})}({theme:c,size:v(r,b)||(null==c||null==(d=c.defaults)?void 0:d.size),variant:v(i,b)||(null==c||null==(s=c.defaults)?void 0:s.variant),prop:v(u,b),modifiers:null==c?void 0:c.modifier});return[null==c?void 0:c.base,p,m,y].reduce(function(e,n){return a.default(e,n,w)},{})},[u,r,i,t,b,z]);n.useEffect(function(){x(function(){return E()})},[b,E]);var O=n.useCallback(function(){var e=function(e){return z.reduce(function(n,t){return e>=d[t]?t:n},"default")},n=e(p),t=e(window.innerWidth);n!==t&&(m(window.innerWidth),k(t))},[d,z,p,m,k]);n.useEffect(function(){if(j){var e=f.default(O,s);return window.addEventListener("resize",e),O(),function(){return window.removeEventListener("resize",e)}}});var S=n.useState(function(){return E()}),x=S[1];return S[0]},e.useSVMContext=v});
//# sourceMappingURL=index.umd.js.map
{
"name": "react-svm",
"license": "MIT",
"version": "0.1.1",
"version": "0.1.2",
"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