@bemto/core
Advanced tools
Comparing version 0.1.0-alpha.2 to 0.1.0-alpha.3
@@ -5,60 +5,124 @@ 'use strict'; | ||
const initialSettings = { | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
var initialSettings = { | ||
rootElem: '__Root', | ||
omitTrueModValue: true, | ||
getters: { | ||
modifier: key => key.indexOf('_') === 0 ? key.substring(1) : key, | ||
element: key => key.indexOf('__') === 0 ? key.substring(2) : key, | ||
modifier: function modifier(key) { | ||
return key.indexOf('_') === 0 ? key.substring(1) : key; | ||
}, | ||
element: function element(key) { | ||
return key.indexOf('__') === 0 ? key.substring(2) : key; | ||
} | ||
}, | ||
templates: { | ||
modifier: (block, modifier) => `${block}_${modifier}`, | ||
modifierValue: (key, value) => `${key}_${value}`, | ||
element: (block, element) => `${block}__${element}`, | ||
}, | ||
modifier: function modifier(block, _modifier) { | ||
return "".concat(block, "_").concat(_modifier); | ||
}, | ||
modifierValue: function modifierValue(key, value) { | ||
return "".concat(key, "_").concat(value); | ||
}, | ||
element: function element(block, _element) { | ||
return "".concat(block, "__").concat(_element); | ||
} | ||
} | ||
}; | ||
const getMethodsWithSettings = ({ | ||
omitTrueModValue, | ||
getters, | ||
templates, | ||
rootElem | ||
}) => { | ||
const renderModifier = (className, mod, value) => templates.modifier( | ||
className, | ||
typeof value === 'boolean' && omitTrueModValue | ||
? getters.modifier(mod) | ||
: templates.modifierValue(getters.modifier(mod), value), | ||
); | ||
var getMethodsWithSettings = function getMethodsWithSettings(_ref) { | ||
var omitTrueModValue = _ref.omitTrueModValue, | ||
getters = _ref.getters, | ||
templates = _ref.templates, | ||
rootElem = _ref.rootElem; | ||
const renderElement = (className, el) => | ||
templates.element(className, getters.element(el)); | ||
var renderModifier = function renderModifier(className, mod, value) { | ||
return templates.modifier(className, typeof value === 'boolean' && omitTrueModValue ? getters.modifier(mod) : templates.modifierValue(getters.modifier(mod), value)); | ||
}; | ||
const getModifiers = (blockNames, modifiers) => Object.keys(modifiers) | ||
.reduce((result, modifier) => { | ||
var renderElement = function renderElement(className, el) { | ||
return templates.element(className, getters.element(el)); | ||
}; | ||
var getModifiers = function getModifiers(blockNames, modifiers) { | ||
return Object.keys(modifiers).reduce(function (result, modifier) { | ||
if (modifiers[modifier]) { | ||
blockNames.map(part => result.push( | ||
renderModifier(part, modifier, modifiers[modifier]) | ||
)); | ||
blockNames.map(function (part) { | ||
return result.push(renderModifier(part, modifier, modifiers[modifier])); | ||
}); | ||
} | ||
return result; | ||
}, []); | ||
}; | ||
const getElement = (blockNames, element) => | ||
blockNames.map(part => renderElement(part, element)); | ||
var getElement = function getElement(blockNames, element) { | ||
return blockNames.map(function (part) { | ||
return renderElement(part, element); | ||
}); | ||
}; | ||
const normalizeElementProp = (input) => { | ||
if ( | ||
typeof input === 'object' | ||
&& !(input instanceof Array) | ||
&& !input.props // treat as components, should go to children | ||
var normalizeElementProp = function normalizeElementProp(input) { | ||
if (_typeof(input) === 'object' && !(input instanceof Array) && !input.props // treat as components, should go to children | ||
) { | ||
return input; | ||
} | ||
return { children: input }; | ||
return input; | ||
} | ||
return { | ||
children: input | ||
}; | ||
}; | ||
const isNully = val => val === undefined || val === null || val === false; | ||
var isNully = function isNully(val) { | ||
return val === undefined || val === null || val === false; | ||
}; | ||
const filterProps = (props, options = {}) => | ||
Object.keys(props).reduce((result, prop) => { | ||
var filterProps = function filterProps(props) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return Object.keys(props).reduce(function (result, prop) { | ||
if (prop.indexOf('__') === 0) { | ||
@@ -73,50 +137,53 @@ if (prop !== rootElem && !isNully(props[prop])) { | ||
} | ||
return result; | ||
}, { | ||
rootProps: { className: '', ...props[rootElem] }, | ||
rootProps: _objectSpread({ | ||
className: '' | ||
}, props[rootElem]), | ||
blockNames: (options.block || props.className || '').split(/\s+/), | ||
elements: {}, | ||
modifiers: {}, | ||
modifiers: {} | ||
}); | ||
}; | ||
return { getModifiers, getElement, filterProps }; | ||
return { | ||
getModifiers: getModifiers, | ||
getElement: getElement, | ||
filterProps: filterProps | ||
}; | ||
}; | ||
const bemtoFactory = (settings) => { | ||
const { rootElem } = settings; | ||
var bemtoFactory = function bemtoFactory(settings) { | ||
var rootElem = settings.rootElem; // TODO: implement proper mergeSettings() | ||
// TODO: implement proper mergeSettings() | ||
const withSettings = (settings) => bemtoFactory({ | ||
...initialSettings, | ||
...settings, | ||
getters: { ...initialSettings.getters, ...settings.getters }, | ||
templates: { ...initialSettings.templates, ...settings.templates }, | ||
}); | ||
var withSettings = function withSettings(settings) { | ||
return bemtoFactory(_objectSpread({}, initialSettings, settings, { | ||
getters: _objectSpread({}, initialSettings.getters, settings.getters), | ||
templates: _objectSpread({}, initialSettings.templates, settings.templates) | ||
})); | ||
}; | ||
const { | ||
getModifiers, | ||
getElement, | ||
filterProps | ||
} = getMethodsWithSettings(settings); | ||
var _getMethodsWithSettin = getMethodsWithSettings(settings), | ||
getModifiers = _getMethodsWithSettin.getModifiers, | ||
getElement = _getMethodsWithSettin.getElement, | ||
filterProps = _getMethodsWithSettin.filterProps; | ||
const bemto = (props, options = {}) => { | ||
const result = filterProps(props, options); | ||
var bemto = function bemto(props) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
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.rootProps.className = [ | ||
result.rootProps.className, | ||
getModifiers(result.blockNames, result.modifiers).join(' '), | ||
].join(' ').trim(); | ||
result.getProps = function (el, props) { | ||
var isRoot = !el || el === rootElem; | ||
var elemProps; | ||
var elemBlock; | ||
result.elements[rootElem] = result.rootProps; | ||
result.getProps = (el, props) => { | ||
const isRoot = !el || el === rootElem; | ||
let elemProps; | ||
let elemBlock; | ||
if (isRoot) { | ||
elemBlock = result.blockNames.join(' '); | ||
elemProps = { ...options[el || rootElem], ...result.rootProps }; | ||
elemProps = _objectSpread({}, options[el || rootElem], result.rootProps); | ||
} else { | ||
elemBlock = getElement(result.blockNames, el).join(' '); | ||
elemProps = { ...options[el || rootElem], ...result.elements[el] }; | ||
elemProps = _objectSpread({}, options[el || rootElem], result.elements[el]); | ||
elemProps.className = [elemBlock, elemProps.className].join(' ').trim(); | ||
@@ -126,19 +193,27 @@ } | ||
if (props) { | ||
const handledProps = bemto(props, { block: elemBlock }).rootProps; | ||
const className = elemProps.className; | ||
elemProps = { ...elemProps, ...handledProps }; | ||
elemProps.className = | ||
[className, handledProps.className].join(' ').trim(); | ||
var handledProps = bemto(props, { | ||
block: elemBlock | ||
}).rootProps; | ||
var className = elemProps.className; | ||
elemProps = _objectSpread({}, elemProps, handledProps); | ||
elemProps.className = [className, handledProps.className].join(' ').trim(); | ||
} | ||
return elemProps; | ||
}; | ||
return result; | ||
}; | ||
return { withSettings, bemto }; | ||
return { | ||
withSettings: withSettings, | ||
bemto: bemto | ||
}; | ||
}; | ||
const { withSettings, bemto } = bemtoFactory(initialSettings); | ||
var _bemtoFactory = bemtoFactory(initialSettings), | ||
withSettings = _bemtoFactory.withSettings, | ||
bemto = _bemtoFactory.bemto; | ||
exports.bemto = bemto; | ||
exports.withSettings = withSettings; | ||
exports.bemto = bemto; |
@@ -1,59 +0,123 @@ | ||
const initialSettings = { | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
var initialSettings = { | ||
rootElem: '__Root', | ||
omitTrueModValue: true, | ||
getters: { | ||
modifier: key => key.indexOf('_') === 0 ? key.substring(1) : key, | ||
element: key => key.indexOf('__') === 0 ? key.substring(2) : key, | ||
modifier: function modifier(key) { | ||
return key.indexOf('_') === 0 ? key.substring(1) : key; | ||
}, | ||
element: function element(key) { | ||
return key.indexOf('__') === 0 ? key.substring(2) : key; | ||
} | ||
}, | ||
templates: { | ||
modifier: (block, modifier) => `${block}_${modifier}`, | ||
modifierValue: (key, value) => `${key}_${value}`, | ||
element: (block, element) => `${block}__${element}`, | ||
}, | ||
modifier: function modifier(block, _modifier) { | ||
return "".concat(block, "_").concat(_modifier); | ||
}, | ||
modifierValue: function modifierValue(key, value) { | ||
return "".concat(key, "_").concat(value); | ||
}, | ||
element: function element(block, _element) { | ||
return "".concat(block, "__").concat(_element); | ||
} | ||
} | ||
}; | ||
const getMethodsWithSettings = ({ | ||
omitTrueModValue, | ||
getters, | ||
templates, | ||
rootElem | ||
}) => { | ||
const renderModifier = (className, mod, value) => templates.modifier( | ||
className, | ||
typeof value === 'boolean' && omitTrueModValue | ||
? getters.modifier(mod) | ||
: templates.modifierValue(getters.modifier(mod), value), | ||
); | ||
var getMethodsWithSettings = function getMethodsWithSettings(_ref) { | ||
var omitTrueModValue = _ref.omitTrueModValue, | ||
getters = _ref.getters, | ||
templates = _ref.templates, | ||
rootElem = _ref.rootElem; | ||
const renderElement = (className, el) => | ||
templates.element(className, getters.element(el)); | ||
var renderModifier = function renderModifier(className, mod, value) { | ||
return templates.modifier(className, typeof value === 'boolean' && omitTrueModValue ? getters.modifier(mod) : templates.modifierValue(getters.modifier(mod), value)); | ||
}; | ||
const getModifiers = (blockNames, modifiers) => Object.keys(modifiers) | ||
.reduce((result, modifier) => { | ||
var renderElement = function renderElement(className, el) { | ||
return templates.element(className, getters.element(el)); | ||
}; | ||
var getModifiers = function getModifiers(blockNames, modifiers) { | ||
return Object.keys(modifiers).reduce(function (result, modifier) { | ||
if (modifiers[modifier]) { | ||
blockNames.map(part => result.push( | ||
renderModifier(part, modifier, modifiers[modifier]) | ||
)); | ||
blockNames.map(function (part) { | ||
return result.push(renderModifier(part, modifier, modifiers[modifier])); | ||
}); | ||
} | ||
return result; | ||
}, []); | ||
}; | ||
const getElement = (blockNames, element) => | ||
blockNames.map(part => renderElement(part, element)); | ||
var getElement = function getElement(blockNames, element) { | ||
return blockNames.map(function (part) { | ||
return renderElement(part, element); | ||
}); | ||
}; | ||
const normalizeElementProp = (input) => { | ||
if ( | ||
typeof input === 'object' | ||
&& !(input instanceof Array) | ||
&& !input.props // treat as components, should go to children | ||
var normalizeElementProp = function normalizeElementProp(input) { | ||
if (_typeof(input) === 'object' && !(input instanceof Array) && !input.props // treat as components, should go to children | ||
) { | ||
return input; | ||
} | ||
return { children: input }; | ||
return input; | ||
} | ||
return { | ||
children: input | ||
}; | ||
}; | ||
const isNully = val => val === undefined || val === null || val === false; | ||
var isNully = function isNully(val) { | ||
return val === undefined || val === null || val === false; | ||
}; | ||
const filterProps = (props, options = {}) => | ||
Object.keys(props).reduce((result, prop) => { | ||
var filterProps = function filterProps(props) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return Object.keys(props).reduce(function (result, prop) { | ||
if (prop.indexOf('__') === 0) { | ||
@@ -68,50 +132,53 @@ if (prop !== rootElem && !isNully(props[prop])) { | ||
} | ||
return result; | ||
}, { | ||
rootProps: { className: '', ...props[rootElem] }, | ||
rootProps: _objectSpread({ | ||
className: '' | ||
}, props[rootElem]), | ||
blockNames: (options.block || props.className || '').split(/\s+/), | ||
elements: {}, | ||
modifiers: {}, | ||
modifiers: {} | ||
}); | ||
}; | ||
return { getModifiers, getElement, filterProps }; | ||
return { | ||
getModifiers: getModifiers, | ||
getElement: getElement, | ||
filterProps: filterProps | ||
}; | ||
}; | ||
const bemtoFactory = (settings) => { | ||
const { rootElem } = settings; | ||
var bemtoFactory = function bemtoFactory(settings) { | ||
var rootElem = settings.rootElem; // TODO: implement proper mergeSettings() | ||
// TODO: implement proper mergeSettings() | ||
const withSettings = (settings) => bemtoFactory({ | ||
...initialSettings, | ||
...settings, | ||
getters: { ...initialSettings.getters, ...settings.getters }, | ||
templates: { ...initialSettings.templates, ...settings.templates }, | ||
}); | ||
var withSettings = function withSettings(settings) { | ||
return bemtoFactory(_objectSpread({}, initialSettings, settings, { | ||
getters: _objectSpread({}, initialSettings.getters, settings.getters), | ||
templates: _objectSpread({}, initialSettings.templates, settings.templates) | ||
})); | ||
}; | ||
const { | ||
getModifiers, | ||
getElement, | ||
filterProps | ||
} = getMethodsWithSettings(settings); | ||
var _getMethodsWithSettin = getMethodsWithSettings(settings), | ||
getModifiers = _getMethodsWithSettin.getModifiers, | ||
getElement = _getMethodsWithSettin.getElement, | ||
filterProps = _getMethodsWithSettin.filterProps; | ||
const bemto = (props, options = {}) => { | ||
const result = filterProps(props, options); | ||
var bemto = function bemto(props) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
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.rootProps.className = [ | ||
result.rootProps.className, | ||
getModifiers(result.blockNames, result.modifiers).join(' '), | ||
].join(' ').trim(); | ||
result.getProps = function (el, props) { | ||
var isRoot = !el || el === rootElem; | ||
var elemProps; | ||
var elemBlock; | ||
result.elements[rootElem] = result.rootProps; | ||
result.getProps = (el, props) => { | ||
const isRoot = !el || el === rootElem; | ||
let elemProps; | ||
let elemBlock; | ||
if (isRoot) { | ||
elemBlock = result.blockNames.join(' '); | ||
elemProps = { ...options[el || rootElem], ...result.rootProps }; | ||
elemProps = _objectSpread({}, options[el || rootElem], result.rootProps); | ||
} else { | ||
elemBlock = getElement(result.blockNames, el).join(' '); | ||
elemProps = { ...options[el || rootElem], ...result.elements[el] }; | ||
elemProps = _objectSpread({}, options[el || rootElem], result.elements[el]); | ||
elemProps.className = [elemBlock, elemProps.className].join(' ').trim(); | ||
@@ -121,18 +188,26 @@ } | ||
if (props) { | ||
const handledProps = bemto(props, { block: elemBlock }).rootProps; | ||
const className = elemProps.className; | ||
elemProps = { ...elemProps, ...handledProps }; | ||
elemProps.className = | ||
[className, handledProps.className].join(' ').trim(); | ||
var handledProps = bemto(props, { | ||
block: elemBlock | ||
}).rootProps; | ||
var className = elemProps.className; | ||
elemProps = _objectSpread({}, elemProps, handledProps); | ||
elemProps.className = [className, handledProps.className].join(' ').trim(); | ||
} | ||
return elemProps; | ||
}; | ||
return result; | ||
}; | ||
return { withSettings, bemto }; | ||
return { | ||
withSettings: withSettings, | ||
bemto: bemto | ||
}; | ||
}; | ||
const { withSettings, bemto } = bemtoFactory(initialSettings); | ||
var _bemtoFactory = bemtoFactory(initialSettings), | ||
withSettings = _bemtoFactory.withSettings, | ||
bemto = _bemtoFactory.bemto; | ||
export { withSettings, bemto }; | ||
export { bemto, withSettings }; |
@@ -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.withSettings=o,e.bemto=r,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 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})}); |
{ | ||
"name": "@bemto/core", | ||
"version": "0.1.0-alpha.2", | ||
"version": "0.1.0-alpha.3", | ||
"description": "", | ||
@@ -22,3 +22,3 @@ "author": "Roman Komarov <kizu@kizu.ru>", | ||
"test": "yarn build:testing && jest", | ||
"prepare": "yarn lint && yarn build && yarn test" | ||
"prepublishOnly": "yarn lint && yarn build && yarn test" | ||
}, | ||
@@ -32,17 +32,3 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.3.4", | ||
"@babel/preset-env": "^7.3.4", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-jest": "^24.5.0", | ||
"babel-plugin-transform-object-assign": "^6.22.0", | ||
"eslint": "^5.15.3", | ||
"jest": "^24.5.0", | ||
"prettier": "^1.16.4", | ||
"rollup": "^1.6.0", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^9.2.1", | ||
"rollup-plugin-node-resolve": "^4.0.1", | ||
"rollup-plugin-size-snapshot": "^0.8.0", | ||
"rollup-plugin-uglify": "^6.0.2" | ||
"@bemto/dev-core-setup": "^0.1.0" | ||
}, | ||
@@ -49,0 +35,0 @@ "jest": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18754
1
373
1