完全跑通1.0版本

This commit is contained in:
2026-05-26 12:56:03 +08:00
parent 2ece5174a7
commit 93c714a93b
11557 changed files with 1648225 additions and 36 deletions

View File

@@ -0,0 +1,28 @@
import * as _$vue from "vue";
import { InjectionKey, Ref } from "vue";
//#region ../../packages/hooks/use-namespace/index.d.ts
declare const defaultNamespace = "el";
declare const namespaceContextKey: InjectionKey<Ref<string | undefined>>;
declare const useGetDerivedNamespace: (namespaceOverrides?: Ref<string | undefined>) => _$vue.ComputedRef<string>;
declare const useNamespace: (block: string, namespaceOverrides?: Ref<string | undefined>) => {
namespace: _$vue.ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
type UseNamespaceReturn = ReturnType<typeof useNamespace>;
//#endregion
export { UseNamespaceReturn, defaultNamespace, namespaceContextKey, useGetDerivedNamespace, useNamespace };

View File

@@ -0,0 +1,68 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../_virtual/_rolldown/runtime.js");
let vue = require("vue");
//#region ../../packages/hooks/use-namespace/index.ts
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 || ((0, vue.getCurrentInstance)() ? (0, vue.inject)(namespaceContextKey, (0, vue.ref)("el")) : (0, vue.ref)("el"));
return (0, vue.computed)(() => {
return (0, vue.unref)(derivedNamespace) || "el";
});
};
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
};
};
//#endregion
exports.defaultNamespace = defaultNamespace;
exports.namespaceContextKey = namespaceContextKey;
exports.useGetDerivedNamespace = useGetDerivedNamespace;
exports.useNamespace = useNamespace;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long