You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.8 KiB
85 lines
2.8 KiB
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
var vue = require('vue');
|
|
|
|
const defaultNamespace = "el";
|
|
const statePrefix = "is-";
|
|
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
let cls = `${namespace}-${block}`;
|
|
if (blockSuffix) {
|
|
cls += `-${blockSuffix}`;
|
|
}
|
|
if (element) {
|
|
cls += `__${element}`;
|
|
}
|
|
if (modifier) {
|
|
cls += `--${modifier}`;
|
|
}
|
|
return cls;
|
|
};
|
|
const namespaceContextKey = Symbol("namespaceContextKey");
|
|
const useGetDerivedNamespace = (namespaceOverrides) => {
|
|
const derivedNamespace = namespaceOverrides || (vue.getCurrentInstance() ? vue.inject(namespaceContextKey, vue.ref(defaultNamespace)) : vue.ref(defaultNamespace));
|
|
const namespace = vue.computed(() => {
|
|
return vue.unref(derivedNamespace) || defaultNamespace;
|
|
});
|
|
return namespace;
|
|
};
|
|
const useNamespace = (block, namespaceOverrides) => {
|
|
const namespace = useGetDerivedNamespace(namespaceOverrides);
|
|
const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
|
|
const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
|
|
const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
|
|
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
|
|
const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
|
|
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
|
|
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
|
|
const is = (name, ...args) => {
|
|
const state = args.length >= 1 ? args[0] : true;
|
|
return name && state ? `${statePrefix}${name}` : "";
|
|
};
|
|
const cssVar = (object) => {
|
|
const styles = {};
|
|
for (const key in object) {
|
|
if (object[key]) {
|
|
styles[`--${namespace.value}-${key}`] = object[key];
|
|
}
|
|
}
|
|
return styles;
|
|
};
|
|
const cssVarBlock = (object) => {
|
|
const styles = {};
|
|
for (const key in object) {
|
|
if (object[key]) {
|
|
styles[`--${namespace.value}-${block}-${key}`] = object[key];
|
|
}
|
|
}
|
|
return styles;
|
|
};
|
|
const cssVarName = (name) => `--${namespace.value}-${name}`;
|
|
const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
|
|
return {
|
|
namespace,
|
|
b,
|
|
e,
|
|
m,
|
|
be,
|
|
em,
|
|
bm,
|
|
bem,
|
|
is,
|
|
cssVar,
|
|
cssVarName,
|
|
cssVarBlock,
|
|
cssVarBlockName
|
|
};
|
|
};
|
|
|
|
exports.defaultNamespace = defaultNamespace;
|
|
exports.namespaceContextKey = namespaceContextKey;
|
|
exports.useGetDerivedNamespace = useGetDerivedNamespace;
|
|
exports.useNamespace = useNamespace;
|
|
//# sourceMappingURL=index.js.map
|