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

@bemto/core

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bemto/core - npm Package Compare versions

Comparing version 0.1.0-alpha.3 to 0.1.0-alpha.4

62

dist/bemto.cjs.js

@@ -120,2 +120,12 @@ 'use strict';

var normalizeElementOption = function normalizeElementOption(input) {
if (_typeof(input) === 'object') {
return input;
}
return {
component: input
};
};
var isNully = function isNully(val) {

@@ -127,22 +137,45 @@ return val === undefined || val === null || val === false;

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(props).reduce(function (result, prop) {
var rootProps = _objectSpread({
className: ''
}, props[rootElem]);
var propsReducer = function propsReducer(ac, prop) {
if (prop.indexOf('__') === 0) {
if (prop !== rootElem && !isNully(props[prop])) {
result.elements[prop] = normalizeElementProp(props[prop]);
if (!ac.elements[prop]) {
ac.elements[prop] = {};
}
ac.elements[prop].props = normalizeElementProp(props[prop]);
}
} else if (prop.indexOf('_') === 0) {
result.modifiers[prop] = props[prop];
ac.modifiers[prop] = props[prop];
} else {
result.rootProps[prop] = props[prop];
rootProps[prop] = props[prop];
}
return result;
}, {
rootProps: _objectSpread({
className: ''
}, props[rootElem]),
return ac;
};
var optionsElementsReducer = function optionsElementsReducer(ac, elem) {
if (elem.indexOf('__') === 0) {
if (props[elem] !== null && props[elem] !== false) {
ac[elem] = normalizeElementOption(options[elem]);
}
}
return ac;
};
var result = {
blockNames: (options.block || props.className || '').split(/\s+/),
elements: {},
elements: Object.keys(options).reduce(optionsElementsReducer, {}),
modifiers: {}
};
Object.keys(props).reduce(propsReducer, result);
result.elements[rootElem] = _objectSpread({}, result.elements[rootElem], {
props: rootProps
});
return result;
};

@@ -175,4 +208,3 @@

var result = filterProps(props, options);
result.rootProps.className = [result.rootProps.className, getModifiers(result.blockNames, result.modifiers).join(' ')].join(' ').trim();
result.elements[rootElem] = result.rootProps;
result.elements[rootElem].props.className = [result.elements[rootElem].props.className, getModifiers(result.blockNames, result.modifiers).join(' ')].join(' ').trim();

@@ -186,6 +218,6 @@ result.getProps = function (el, props) {

elemBlock = result.blockNames.join(' ');
elemProps = _objectSpread({}, options[el || rootElem], result.rootProps);
elemProps = _objectSpread({}, result.elements[rootElem].props);
} else {
elemBlock = getElement(result.blockNames, el).join(' ');
elemProps = _objectSpread({}, options[el || rootElem], result.elements[el]);
elemProps = _objectSpread({}, result.elements[el] && result.elements[el].props);
elemProps.className = [elemBlock, elemProps.className].join(' ').trim();

@@ -197,3 +229,3 @@ }

block: elemBlock
}).rootProps;
}).elements[rootElem].props;
var className = elemProps.className;

@@ -200,0 +232,0 @@ elemProps = _objectSpread({}, elemProps, handledProps);

@@ -116,2 +116,12 @@ function _typeof(obj) {

var normalizeElementOption = function normalizeElementOption(input) {
if (_typeof(input) === 'object') {
return input;
}
return {
component: input
};
};
var isNully = function isNully(val) {

@@ -123,22 +133,45 @@ return val === undefined || val === null || val === false;

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(props).reduce(function (result, prop) {
var rootProps = _objectSpread({
className: ''
}, props[rootElem]);
var propsReducer = function propsReducer(ac, prop) {
if (prop.indexOf('__') === 0) {
if (prop !== rootElem && !isNully(props[prop])) {
result.elements[prop] = normalizeElementProp(props[prop]);
if (!ac.elements[prop]) {
ac.elements[prop] = {};
}
ac.elements[prop].props = normalizeElementProp(props[prop]);
}
} else if (prop.indexOf('_') === 0) {
result.modifiers[prop] = props[prop];
ac.modifiers[prop] = props[prop];
} else {
result.rootProps[prop] = props[prop];
rootProps[prop] = props[prop];
}
return result;
}, {
rootProps: _objectSpread({
className: ''
}, props[rootElem]),
return ac;
};
var optionsElementsReducer = function optionsElementsReducer(ac, elem) {
if (elem.indexOf('__') === 0) {
if (props[elem] !== null && props[elem] !== false) {
ac[elem] = normalizeElementOption(options[elem]);
}
}
return ac;
};
var result = {
blockNames: (options.block || props.className || '').split(/\s+/),
elements: {},
elements: Object.keys(options).reduce(optionsElementsReducer, {}),
modifiers: {}
};
Object.keys(props).reduce(propsReducer, result);
result.elements[rootElem] = _objectSpread({}, result.elements[rootElem], {
props: rootProps
});
return result;
};

@@ -171,4 +204,3 @@

var result = filterProps(props, options);
result.rootProps.className = [result.rootProps.className, getModifiers(result.blockNames, result.modifiers).join(' ')].join(' ').trim();
result.elements[rootElem] = result.rootProps;
result.elements[rootElem].props.className = [result.elements[rootElem].props.className, getModifiers(result.blockNames, result.modifiers).join(' ')].join(' ').trim();

@@ -182,6 +214,6 @@ result.getProps = function (el, props) {

elemBlock = result.blockNames.join(' ');
elemProps = _objectSpread({}, options[el || rootElem], result.rootProps);
elemProps = _objectSpread({}, result.elements[rootElem].props);
} else {
elemBlock = getElement(result.blockNames, el).join(' ');
elemProps = _objectSpread({}, options[el || rootElem], result.elements[el]);
elemProps = _objectSpread({}, result.elements[el] && result.elements[el].props);
elemProps.className = [elemBlock, elemProps.className].join(' ').trim();

@@ -193,3 +225,3 @@ }

block: elemBlock
}).rootProps;
}).elements[rootElem].props;
var className = elemProps.className;

@@ -196,0 +228,0 @@ elemProps = _objectSpread({}, elemProps, handledProps);

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).bemto={})}(this,function(e){"use strict";function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},t=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),t.forEach(function(e){var t,o,r;t=n,r=i[o=e],o in t?Object.defineProperty(t,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[o]=r})}return n}var i={rootElem:"__Root",omitTrueModValue:!0,getters:{modifier:function(e){return 0===e.indexOf("_")?e.substring(1):e},element:function(e){return 0===e.indexOf("__")?e.substring(2):e}},templates:{modifier:function(e,t){return"".concat(e,"_").concat(t)},modifierValue:function(e,t){return"".concat(e,"_").concat(t)},element:function(e,t){return"".concat(e,"__").concat(t)}}},c=function(e){var c=e.omitTrueModValue,u=e.getters,f=e.templates,i=e.rootElem;return{getModifiers:function(e,s){return Object.keys(s).reduce(function(n,i){return s[i]&&e.map(function(e){return n.push((t=e,r=s[o=i],f.modifier(t,"boolean"==typeof r&&c?u.modifier(o):f.modifierValue(u.modifier(o),r))));var t,o,r}),n},[])},getElement:function(e,r){return e.map(function(e){return t=e,o=r,f.element(t,u.element(o));var t,o})},filterProps:function(n){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(n).reduce(function(e,t){var o,r;return 0===t.indexOf("__")?t!==i&&null!=(r=n[t])&&!1!==r&&(e.elements[t]="object"!==s(o=n[t])||o instanceof Array||o.props?{children:o}:o):0===t.indexOf("_")?e.modifiers[t]=n[t]:e.rootProps[t]=n[t],e},{rootProps:a({className:""},n[i]),blockNames:(e.block||n.className||"").split(/\s+/),elements:{},modifiers:{}})}}},t=function t(e){var f=e.rootElem,o=c(e),r=o.getModifiers,l=o.getElement,n=o.filterProps;return{withSettings:function(e){return t(a({},i,e,{getters:a({},i.getters,e.getters),templates:a({},i.templates,e.templates)}))},bemto:function s(e){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},u=n(e,c);return u.rootProps.className=[u.rootProps.className,r(u.blockNames,u.modifiers).join(" ")].join(" ").trim(),u.elements[f]=u.rootProps,u.getProps=function(e,t){var o,r;if(e&&e!==f?(r=l(u.blockNames,e).join(" "),(o=a({},c[e||f],u.elements[e])).className=[r,o.className].join(" ").trim()):(r=u.blockNames.join(" "),o=a({},c[e||f],u.rootProps)),t){var n=s(t,{block:r}).rootProps,i=o.className;(o=a({},o,n)).className=[i,n.className].join(" ").trim()}return o},u}}}(i),o=t.withSettings,r=t.bemto;e.bemto=r,e.withSettings=o,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).bemto={})}(this,function(e){"use strict";function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},t=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),t.forEach(function(e){var t,n,o;t=r,o=i[n=e],n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o})}return r}var i={rootElem:"__Root",omitTrueModValue:!0,getters:{modifier:function(e){return 0===e.indexOf("_")?e.substring(1):e},element:function(e){return 0===e.indexOf("__")?e.substring(2):e}},templates:{modifier:function(e,t){return"".concat(e,"_").concat(t)},modifierValue:function(e,t){return"".concat(e,"_").concat(t)},element:function(e,t){return"".concat(e,"__").concat(t)}}},s=function(e){var c=e.omitTrueModValue,l=e.getters,u=e.templates,s=e.rootElem;return{getModifiers:function(e,s){return Object.keys(s).reduce(function(r,i){return s[i]&&e.map(function(e){return r.push((t=e,o=s[n=i],u.modifier(t,"boolean"==typeof o&&c?l.modifier(n):u.modifierValue(l.modifier(n),o))));var t,n,o}),r},[])},getElement:function(e,o){return e.map(function(e){return t=e,n=o,u.element(t,l.element(n));var t,n})},filterProps:function(r){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=f({className:""},r[s]),e={blockNames:(o.block||r.className||"").split(/\s+/),elements:Object.keys(o).reduce(function(e,t){var n;return 0===t.indexOf("__")&&null!==r[t]&&!1!==r[t]&&(e[t]="object"===m(n=o[t])?n:{component:n}),e},{}),modifiers:{}};return Object.keys(r).reduce(function(e,t){var n,o;return 0===t.indexOf("__")?t!==s&&null!=(o=r[t])&&!1!==o&&(e.elements[t]||(e.elements[t]={}),e.elements[t].props="object"!==m(n=r[t])||n instanceof Array||n.props?{children:n}:n):0===t.indexOf("_")?e.modifiers[t]=r[t]:i[t]=r[t],e},e),e.elements[s]=f({},e.elements[s],{props:i}),e}}},t=function t(e){var l=e.rootElem,n=s(e),o=n.getModifiers,u=n.getElement,r=n.filterProps;return{withSettings:function(e){return t(f({},i,e,{getters:f({},i.getters,e.getters),templates:f({},i.templates,e.templates)}))},bemto:function s(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=r(e,t);return c.elements[l].props.className=[c.elements[l].props.className,o(c.blockNames,c.modifiers).join(" ")].join(" ").trim(),c.getProps=function(e,t){var n,o;if(e&&e!==l?(o=u(c.blockNames,e).join(" "),(n=f({},c.elements[e]&&c.elements[e].props)).className=[o,n.className].join(" ").trim()):(o=c.blockNames.join(" "),n=f({},c.elements[l].props)),t){var r=s(t,{block:o}).elements[l].props,i=n.className;(n=f({},n,r)).className=[i,r.className].join(" ").trim()}return n},c}}}(i),n=t.withSettings,o=t.bemto;e.bemto=o,e.withSettings=n,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@bemto/core",
"version": "0.1.0-alpha.3",
"version": "0.1.0-alpha.4",
"description": "",

@@ -26,6 +26,9 @@ "author": "Roman Komarov <kizu@kizu.ru>",

"type": "git",
"url": ""
"url": "git+https://github.com/bemto/core.git"
},
"dependencies": {
"bugs": {
"url": "https://github.com/bemto/core/issues"
},
"homepage": "https://github.com/bemto/core#readme", "dependencies": {
},
"devDependencies": {

@@ -32,0 +35,0 @@ "@bemto/dev-core-setup": "^0.1.0"

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