-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 4.32 KB
/
index.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Classes",[],t):"object"==typeof exports?exports.Classes=t():e.Classes=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o="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},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=Object.assign({elementSymbol:"__",modificationSymbol:"--",baseClass:"",Modifiers:new n.a("--")},t),this.baseClass=t.baseClass,this.elementSymbol=t.elementSymbol,this.modificationSymbol=t.modificationSymbol,this.classesArr=[],this.Modifiers=t.Modifiers}return i(e,[{key:"classList",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(void 0===r)return this.baseClass;var n="m"===Object.keys(r)[0]&&"object"===(void 0===r?"undefined":o(r));return this.classesArr=[],(r=e.optionsFactory(r)).forEach(function(r){r=e.optionsFactory(r)[0];var n=Object.keys(r)[0],o=r.m;"m"!==n?r[n]&&(t.classesArr=t.Modifiers.addModifiersToElement(o,n,t.classesArr)):t.classesArr=t.Modifiers.addModifiersToElement(o,t.baseClass,t.classesArr)}),this.classesArr=n?this.classesArr:this.classesArr.map(function(e){return[t.baseClass,e].join(t.elementSymbol)}),this.classesArr.join(" ").trim()}},{key:"result",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;return void 0===e?{className:this.baseClass}:{className:this.classList(e)}}}],[{key:"optionsFactory",value:function(e){var t,r,n;return"object"!==(void 0===e?"undefined":o(e))||Array.isArray(e)||(e=[e]),"string"==typeof e&&(e=[(t={},r=e,n=!0,r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t)]),e}},{key:"getClassesList",value:function(e){var t=[];if(Array.isArray(e))return e.join(" ");for(var r in e)e[r]&&t.push(r);return t.join(" ")}},{key:"resultList",value:function(t){return{className:e.getClassesList(t)}}}]),e}();t.default=s},function(e,t,r){"use strict";var n="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},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}var s=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"--";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modificationSymbol=t}return o(e,[{key:"modifiersObjectMap",value:function(e){var t=[];return Object.keys(e).map(function(r){return e[r]&&t.push(r)}),t}},{key:"elementModifiersFactory",value:function(e){return e?"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e)?"string"==typeof e?[e]:e:this.modifiersObjectMap(e):[]}},{key:"addModifiersToElement",value:function(e,t,r){var n=this,o=[].concat(i(r));o.includes(t)||o.push(t);var s=this.elementModifiersFactory(e).map(function(e){return[t,e].join(n.modificationSymbol)});return s.length&&o.push.apply(o,i(s)),o}}]),e}();t.a=s}]).default});