This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import type { MaybeRef } from '@vueuse/core';
import type { App, Ref } from 'vue';
import type { ConfigProviderContext } from '../constants';
export declare function useGlobalConfig<K extends keyof ConfigProviderContext, D extends ConfigProviderContext[K]>(key: K, defaultValue?: D): Ref<Exclude<ConfigProviderContext[K], undefined> | D>;
export declare function useGlobalConfig(): Ref<ConfigProviderContext>;
export declare function useGlobalComponentSettings(block: string, sizeFallback?: MaybeRef<ConfigProviderContext['size']>): {
ns: {
namespace: import("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;
};
locale: import("element-plus/es/hooks").LocaleContext;
zIndex: {
initialZIndex: import("vue").ComputedRef<number>;
currentZIndex: import("vue").ComputedRef<number>;
nextZIndex: () => number;
};
size: import("vue").ComputedRef<"small" | "" | "default" | "large">;
};
export declare const provideGlobalConfig: (config: MaybeRef<ConfigProviderContext>, app?: App, global?: boolean) => import("vue").ComputedRef<Partial<import("element-plus").ConfigProviderProps>> | undefined;

View File

@@ -0,0 +1,94 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var constants = require('../constants.js');
var index = require('../../../../hooks/use-namespace/index.js');
var index$2 = require('../../../../hooks/use-z-index/index.js');
var index$1 = require('../../../../hooks/use-locale/index.js');
var index$3 = require('../../../../hooks/use-size/index.js');
var index$4 = require('../../../../hooks/use-empty-values/index.js');
var objects = require('../../../../utils/objects.js');
const globalConfig = vue.ref();
function useGlobalConfig(key, defaultValue = void 0) {
const config = vue.getCurrentInstance() ? vue.inject(constants.configProviderContextKey, globalConfig) : globalConfig;
if (key) {
return vue.computed(() => {
var _a, _b;
return (_b = (_a = config.value) == null ? void 0 : _a[key]) != null ? _b : defaultValue;
});
} else {
return config;
}
}
function useGlobalComponentSettings(block, sizeFallback) {
const config = useGlobalConfig();
const ns = index.useNamespace(block, vue.computed(() => {
var _a;
return ((_a = config.value) == null ? void 0 : _a.namespace) || index.defaultNamespace;
}));
const locale = index$1.useLocale(vue.computed(() => {
var _a;
return (_a = config.value) == null ? void 0 : _a.locale;
}));
const zIndex = index$2.useZIndex(vue.computed(() => {
var _a;
return ((_a = config.value) == null ? void 0 : _a.zIndex) || index$2.defaultInitialZIndex;
}));
const size = vue.computed(() => {
var _a;
return vue.unref(sizeFallback) || ((_a = config.value) == null ? void 0 : _a.size) || "";
});
provideGlobalConfig(vue.computed(() => vue.unref(config) || {}));
return {
ns,
locale,
zIndex,
size
};
}
const provideGlobalConfig = (config, app, global = false) => {
var _a;
const inSetup = !!vue.getCurrentInstance();
const oldConfig = inSetup ? useGlobalConfig() : void 0;
const provideFn = (_a = app == null ? void 0 : app.provide) != null ? _a : inSetup ? vue.provide : void 0;
if (!provideFn) {
return;
}
const context = vue.computed(() => {
const cfg = vue.unref(config);
if (!(oldConfig == null ? void 0 : oldConfig.value))
return cfg;
return mergeConfig(oldConfig.value, cfg);
});
provideFn(constants.configProviderContextKey, context);
provideFn(index$1.localeContextKey, vue.computed(() => context.value.locale));
provideFn(index.namespaceContextKey, vue.computed(() => context.value.namespace));
provideFn(index$2.zIndexContextKey, vue.computed(() => context.value.zIndex));
provideFn(index$3.SIZE_INJECTION_KEY, {
size: vue.computed(() => context.value.size || "")
});
provideFn(index$4.emptyValuesContextKey, vue.computed(() => ({
emptyValues: context.value.emptyValues,
valueOnClear: context.value.valueOnClear
})));
if (global || !globalConfig.value) {
globalConfig.value = context.value;
}
return context;
};
const mergeConfig = (a, b) => {
const keys = [.../* @__PURE__ */ new Set([...objects.keysOf(a), ...objects.keysOf(b)])];
const obj = {};
for (const key of keys) {
obj[key] = b[key] !== void 0 ? b[key] : a[key];
}
return obj;
};
exports.provideGlobalConfig = provideGlobalConfig;
exports.useGlobalComponentSettings = useGlobalComponentSettings;
exports.useGlobalConfig = useGlobalConfig;
//# sourceMappingURL=use-global-config.js.map

File diff suppressed because one or more lines are too long