feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import * as vue from "vue";
import { InjectionKey, Ref } from "vue";
//#region ../../packages/hooks/use-z-index/index.d.ts
interface ElZIndexInjectionContext {
current: number;
}
declare const defaultInitialZIndex = 2000;
declare const ZINDEX_INJECTION_KEY: InjectionKey<ElZIndexInjectionContext>;
declare const zIndexContextKey: InjectionKey<Ref<number | undefined>>;
declare const useZIndex: (zIndexOverrides?: Ref<number>) => {
initialZIndex: vue.ComputedRef<number>;
currentZIndex: vue.ComputedRef<number>;
nextZIndex: () => number;
};
type UseZIndexReturn = ReturnType<typeof useZIndex>;
//#endregion
export { ElZIndexInjectionContext, UseZIndexReturn, ZINDEX_INJECTION_KEY, defaultInitialZIndex, useZIndex, zIndexContextKey };
+36
View File
@@ -0,0 +1,36 @@
import { isClient } from "../../utils/browser.mjs";
import { isNumber } from "../../utils/types.mjs";
import { debugWarn } from "../../utils/error.mjs";
import { computed, getCurrentInstance, inject, ref, unref } from "vue";
//#region ../../packages/hooks/use-z-index/index.ts
const initial = { current: 0 };
const zIndex = ref(0);
const defaultInitialZIndex = 2e3;
const ZINDEX_INJECTION_KEY = Symbol("elZIndexContextKey");
const zIndexContextKey = Symbol("zIndexContextKey");
const useZIndex = (zIndexOverrides) => {
const increasingInjection = getCurrentInstance() ? inject(ZINDEX_INJECTION_KEY, initial) : initial;
const zIndexInjection = zIndexOverrides || (getCurrentInstance() ? inject(zIndexContextKey, void 0) : void 0);
const initialZIndex = computed(() => {
const zIndexFromInjection = unref(zIndexInjection);
return isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
});
const currentZIndex = computed(() => initialZIndex.value + zIndex.value);
const nextZIndex = () => {
increasingInjection.current++;
zIndex.value = increasingInjection.current;
return currentZIndex.value;
};
if (!isClient && !inject(ZINDEX_INJECTION_KEY)) debugWarn("ZIndexInjection", `Looks like you are using server rendering, you must provide a z-index provider to ensure the hydration process to be succeed
usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
return {
initialZIndex,
currentZIndex,
nextZIndex
};
};
//#endregion
export { ZINDEX_INJECTION_KEY, defaultInitialZIndex, useZIndex, zIndexContextKey };
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/hooks/use-z-index/index.ts"],"sourcesContent":["import { computed, getCurrentInstance, inject, ref, unref } from 'vue'\nimport { debugWarn, isClient, isNumber } from '@element-plus/utils'\n\nimport type { InjectionKey, Ref } from 'vue'\n\nexport interface ElZIndexInjectionContext {\n current: number\n}\n\nconst initial: ElZIndexInjectionContext = {\n current: 0,\n}\n\nconst zIndex = ref(0)\n\nexport const defaultInitialZIndex = 2000\n\n// For SSR\nexport const ZINDEX_INJECTION_KEY: InjectionKey<ElZIndexInjectionContext> =\n Symbol('elZIndexContextKey')\n\nexport const zIndexContextKey: InjectionKey<Ref<number | undefined>> =\n Symbol('zIndexContextKey')\n\nexport const useZIndex = (zIndexOverrides?: Ref<number>) => {\n const increasingInjection = getCurrentInstance()\n ? inject(ZINDEX_INJECTION_KEY, initial)\n : initial\n\n const zIndexInjection =\n zIndexOverrides ||\n (getCurrentInstance() ? inject(zIndexContextKey, undefined) : undefined)\n\n const initialZIndex = computed(() => {\n const zIndexFromInjection = unref(zIndexInjection)\n return isNumber(zIndexFromInjection)\n ? zIndexFromInjection\n : defaultInitialZIndex\n })\n\n const currentZIndex = computed(() => initialZIndex.value + zIndex.value)\n\n const nextZIndex = () => {\n increasingInjection.current++\n zIndex.value = increasingInjection.current\n return currentZIndex.value\n }\n\n if (!isClient && !inject(ZINDEX_INJECTION_KEY)) {\n debugWarn(\n 'ZIndexInjection',\n `Looks like you are using server rendering, you must provide a z-index provider to ensure the hydration process to be succeed\nusage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`\n )\n }\n\n return {\n initialZIndex,\n currentZIndex,\n nextZIndex,\n }\n}\n\nexport type UseZIndexReturn = ReturnType<typeof useZIndex>\n"],"mappings":";;;;;;AASA,MAAM,UAAoC,EACxC,SAAS,GACV;AAED,MAAM,SAAS,IAAI,EAAE;AAErB,MAAa,uBAAuB;AAGpC,MAAa,uBACX,OAAO,qBAAqB;AAE9B,MAAa,mBACX,OAAO,mBAAmB;AAE5B,MAAa,aAAa,oBAAkC;CAC1D,MAAM,sBAAsB,oBAAoB,GAC5C,OAAO,sBAAsB,QAAQ,GACrC;CAEJ,MAAM,kBACJ,oBACC,oBAAoB,GAAG,OAAO,kBAAkB,OAAU,GAAG;CAEhE,MAAM,gBAAgB,eAAe;EACnC,MAAM,sBAAsB,MAAM,gBAAgB;AAClD,SAAO,SAAS,oBAAoB,GAChC,sBACA;GACJ;CAEF,MAAM,gBAAgB,eAAe,cAAc,QAAQ,OAAO,MAAM;CAExE,MAAM,mBAAmB;AACvB,sBAAoB;AACpB,SAAO,QAAQ,oBAAoB;AACnC,SAAO,cAAc;;AAGvB,KAAI,CAAC,YAAY,CAAC,OAAO,qBAAqB,CAC5C,WACE,mBACA;0DAED;AAGH,QAAO;EACL;EACA;EACA;EACD"}