完全跑通1.0版本
This commit is contained in:
17
frontend/node_modules/element-plus/es/components/loading/index.d.ts
generated
vendored
Normal file
17
frontend/node_modules/element-plus/es/components/loading/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { LoadingOptions, LoadingOptionsResolved, LoadingParentElement } from "./src/types.js";
|
||||
import { LoadingInstance } from "./src/loading.js";
|
||||
import Loading from "./src/service.js";
|
||||
import vLoading, { ElementLoading, LoadingBinding } from "./src/directive.js";
|
||||
import { App, AppContext, Directive } from "vue";
|
||||
|
||||
//#region ../../packages/components/loading/index.d.ts
|
||||
declare const ElLoading: {
|
||||
install(app: App): void;
|
||||
directive: Directive<ElementLoading, LoadingBinding>;
|
||||
service: {
|
||||
(options?: LoadingOptions, context?: AppContext | null): LoadingInstance;
|
||||
_context: AppContext | null;
|
||||
};
|
||||
};
|
||||
//#endregion
|
||||
export { ElLoading, ElLoading as default, vLoading as ElLoadingDirective, vLoading, Loading as ElLoadingService, type LoadingInstance, LoadingOptions, LoadingOptionsResolved, LoadingParentElement };
|
||||
17
frontend/node_modules/element-plus/es/components/loading/index.mjs
generated
vendored
Normal file
17
frontend/node_modules/element-plus/es/components/loading/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import Loading from "./src/service.mjs";
|
||||
import vLoading from "./src/directive.mjs";
|
||||
//#region ../../packages/components/loading/index.ts
|
||||
const ElLoading = {
|
||||
install(app) {
|
||||
Loading._context = app._context;
|
||||
vLoading._context = app._context;
|
||||
app.directive("loading", vLoading);
|
||||
app.config.globalProperties.$loading = Loading;
|
||||
},
|
||||
directive: vLoading,
|
||||
service: Loading
|
||||
};
|
||||
//#endregion
|
||||
export { ElLoading, ElLoading as default, vLoading as ElLoadingDirective, vLoading, Loading as ElLoadingService };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/loading/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/loading/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/components/loading/index.ts"],"sourcesContent":["import Loading from './src/service'\nimport vLoading from './src/directive'\n\nimport type { App, AppContext, Directive } from 'vue'\nimport type { ElementLoading, LoadingBinding } from './src/directive'\n\n// installer and everything in all\nexport const ElLoading = {\n install(app: App) {\n Loading._context = app._context\n ;(\n vLoading as Directive<ElementLoading, LoadingBinding> & {\n _context: AppContext | null\n }\n )._context = app._context\n app.directive('loading', vLoading)\n app.config.globalProperties.$loading = Loading\n },\n directive: vLoading,\n service: Loading,\n}\n\nexport default ElLoading\nexport { vLoading, vLoading as ElLoadingDirective, Loading as ElLoadingService }\n\nexport * from './src/types'\nexport type { LoadingInstance } from './src/loading'\n"],"mappings":";;;AAOA,MAAa,YAAY;CACvB,QAAQ,KAAU;EAChB,QAAQ,WAAW,IAAI;EACtB,SAIC,WAAW,IAAI;EACjB,IAAI,UAAU,WAAW,SAAS;EAClC,IAAI,OAAO,iBAAiB,WAAW;;CAEzC,WAAW;CACX,SAAS;CACV"}
|
||||
16
frontend/node_modules/element-plus/es/components/loading/src/directive.d.ts
generated
vendored
Normal file
16
frontend/node_modules/element-plus/es/components/loading/src/directive.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { LoadingOptions } from "./types.js";
|
||||
import { LoadingInstance } from "./loading.js";
|
||||
import { Directive, UnwrapRef } from "vue";
|
||||
|
||||
//#region ../../packages/components/loading/src/directive.d.ts
|
||||
declare const INSTANCE_KEY: unique symbol;
|
||||
type LoadingBinding = boolean | UnwrapRef<LoadingOptions>;
|
||||
interface ElementLoading extends HTMLElement {
|
||||
[INSTANCE_KEY]?: {
|
||||
instance: LoadingInstance;
|
||||
options: LoadingOptions;
|
||||
};
|
||||
}
|
||||
declare const vLoading: Directive<ElementLoading, LoadingBinding>;
|
||||
//#endregion
|
||||
export { ElementLoading, LoadingBinding, vLoading as default };
|
||||
70
frontend/node_modules/element-plus/es/components/loading/src/directive.mjs
generated
vendored
Normal file
70
frontend/node_modules/element-plus/es/components/loading/src/directive.mjs
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import { isObject, isString } from "../../../utils/types.mjs";
|
||||
import { hyphenate } from "../../../utils/strings.mjs";
|
||||
import Loading from "./service.mjs";
|
||||
import { isRef, ref } from "vue";
|
||||
//#region ../../packages/components/loading/src/directive.ts
|
||||
const INSTANCE_KEY = Symbol("ElLoading");
|
||||
const getAttributeName = (name) => {
|
||||
return `element-loading-${hyphenate(name)}`;
|
||||
};
|
||||
const createInstance = (el, binding) => {
|
||||
const vm = binding.instance;
|
||||
const getBindingProp = (key) => isObject(binding.value) ? binding.value[key] : void 0;
|
||||
const resolveExpression = (key) => {
|
||||
return ref(isString(key) && vm?.[key] || key);
|
||||
};
|
||||
const getProp = (name) => resolveExpression(getBindingProp(name) || el.getAttribute(getAttributeName(name)));
|
||||
const fullscreen = getBindingProp("fullscreen") ?? binding.modifiers.fullscreen;
|
||||
const options = {
|
||||
text: getProp("text"),
|
||||
svg: getProp("svg"),
|
||||
svgViewBox: getProp("svgViewBox"),
|
||||
spinner: getProp("spinner"),
|
||||
background: getProp("background"),
|
||||
customClass: getProp("customClass"),
|
||||
fullscreen,
|
||||
target: getBindingProp("target") ?? (fullscreen ? void 0 : el),
|
||||
body: getBindingProp("body") ?? binding.modifiers.body,
|
||||
lock: getBindingProp("lock") ?? binding.modifiers.lock
|
||||
};
|
||||
const instance = Loading(options);
|
||||
instance._context = vLoading._context;
|
||||
el[INSTANCE_KEY] = {
|
||||
options,
|
||||
instance
|
||||
};
|
||||
};
|
||||
const updateOptions = (originalOptions, newOptions) => {
|
||||
for (const key of Object.keys(originalOptions)) if (isRef(originalOptions[key])) originalOptions[key].value = newOptions[key];
|
||||
};
|
||||
const vLoading = {
|
||||
mounted(el, binding) {
|
||||
if (binding.value) createInstance(el, binding);
|
||||
},
|
||||
updated(el, binding) {
|
||||
const instance = el[INSTANCE_KEY];
|
||||
if (!binding.value) {
|
||||
instance?.instance.close();
|
||||
el[INSTANCE_KEY] = null;
|
||||
return;
|
||||
}
|
||||
if (!instance) createInstance(el, binding);
|
||||
else updateOptions(instance.options, isObject(binding.value) ? binding.value : {
|
||||
text: el.getAttribute(getAttributeName("text")),
|
||||
svg: el.getAttribute(getAttributeName("svg")),
|
||||
svgViewBox: el.getAttribute(getAttributeName("svgViewBox")),
|
||||
spinner: el.getAttribute(getAttributeName("spinner")),
|
||||
background: el.getAttribute(getAttributeName("background")),
|
||||
customClass: el.getAttribute(getAttributeName("customClass"))
|
||||
});
|
||||
},
|
||||
unmounted(el) {
|
||||
el[INSTANCE_KEY]?.instance.close();
|
||||
el[INSTANCE_KEY] = null;
|
||||
}
|
||||
};
|
||||
vLoading._context = null;
|
||||
//#endregion
|
||||
export { vLoading as default };
|
||||
|
||||
//# sourceMappingURL=directive.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/loading/src/directive.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/loading/src/directive.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"directive.mjs","names":[],"sources":["../../../../../../packages/components/loading/src/directive.ts"],"sourcesContent":["// @ts-nocheck\nimport { isRef, ref } from 'vue'\nimport { hyphenate, isObject, isString } from '@element-plus/utils'\nimport Loading from './service'\n\nimport type { Directive, DirectiveBinding, UnwrapRef } from 'vue'\nimport type { LoadingOptions } from './types'\nimport type { LoadingInstance } from './loading'\n\nconst INSTANCE_KEY = Symbol('ElLoading')\nconst getAttributeName = (name: string) => {\n return `element-loading-${hyphenate(name)}`\n}\n\nexport type LoadingBinding = boolean | UnwrapRef<LoadingOptions>\nexport interface ElementLoading extends HTMLElement {\n [INSTANCE_KEY]?: {\n instance: LoadingInstance\n options: LoadingOptions\n }\n}\n\nconst createInstance = (\n el: ElementLoading,\n binding: DirectiveBinding<LoadingBinding>\n) => {\n const vm = binding.instance\n\n const getBindingProp = <K extends keyof LoadingOptions>(\n key: K\n ): LoadingOptions[K] =>\n isObject(binding.value) ? binding.value[key] : undefined\n\n const resolveExpression = (key: any) => {\n const data = (isString(key) && vm?.[key]) || key\n return ref(data)\n }\n\n const getProp = <K extends keyof LoadingOptions>(name: K) =>\n resolveExpression(\n getBindingProp(name) || el.getAttribute(getAttributeName(name))\n )\n\n const fullscreen =\n getBindingProp('fullscreen') ?? binding.modifiers.fullscreen\n\n const options: LoadingOptions = {\n text: getProp('text'),\n svg: getProp('svg'),\n svgViewBox: getProp('svgViewBox'),\n spinner: getProp('spinner'),\n background: getProp('background'),\n customClass: getProp('customClass'),\n fullscreen,\n target: getBindingProp('target') ?? (fullscreen ? undefined : el),\n body: getBindingProp('body') ?? binding.modifiers.body,\n lock: getBindingProp('lock') ?? binding.modifiers.lock,\n }\n const instance = Loading(options)\n instance._context = vLoading._context\n el[INSTANCE_KEY] = {\n options,\n instance,\n }\n}\n\nconst updateOptions = (\n originalOptions: LoadingOptions,\n newOptions: UnwrapRef<LoadingOptions>\n) => {\n for (const key of Object.keys(originalOptions)) {\n if (isRef(originalOptions[key]))\n originalOptions[key].value = newOptions[key]\n }\n}\n\nconst vLoading: Directive<ElementLoading, LoadingBinding> = {\n mounted(el, binding) {\n if (binding.value) {\n createInstance(el, binding)\n }\n },\n updated(el, binding) {\n const instance = el[INSTANCE_KEY]\n if (!binding.value) {\n instance?.instance.close()\n el[INSTANCE_KEY] = null\n return\n }\n\n if (!instance) createInstance(el, binding)\n else {\n updateOptions(\n instance.options,\n isObject(binding.value)\n ? binding.value\n : {\n text: el.getAttribute(getAttributeName('text')),\n svg: el.getAttribute(getAttributeName('svg')),\n svgViewBox: el.getAttribute(getAttributeName('svgViewBox')),\n spinner: el.getAttribute(getAttributeName('spinner')),\n background: el.getAttribute(getAttributeName('background')),\n customClass: el.getAttribute(getAttributeName('customClass')),\n }\n )\n }\n },\n unmounted(el) {\n el[INSTANCE_KEY]?.instance.close()\n el[INSTANCE_KEY] = null\n },\n}\n\nvLoading._context = null\nexport default vLoading\n"],"mappings":";;;;;AASA,MAAM,eAAe,OAAO,YAAY;AACxC,MAAM,oBAAoB,SAAiB;CACzC,OAAO,mBAAmB,UAAU,KAAK;;AAW3C,MAAM,kBACJ,IACA,YACG;CACH,MAAM,KAAK,QAAQ;CAEnB,MAAM,kBACJ,QAEA,SAAS,QAAQ,MAAM,GAAG,QAAQ,MAAM,OAAO,KAAA;CAEjD,MAAM,qBAAqB,QAAa;EAEtC,OAAO,IADO,SAAS,IAAI,IAAI,KAAK,QAAS,IAC7B;;CAGlB,MAAM,WAA2C,SAC/C,kBACE,eAAe,KAAK,IAAI,GAAG,aAAa,iBAAiB,KAAK,CAAC,CAChE;CAEH,MAAM,aACJ,eAAe,aAAa,IAAI,QAAQ,UAAU;CAEpD,MAAM,UAA0B;EAC9B,MAAM,QAAQ,OAAO;EACrB,KAAK,QAAQ,MAAM;EACnB,YAAY,QAAQ,aAAa;EACjC,SAAS,QAAQ,UAAU;EAC3B,YAAY,QAAQ,aAAa;EACjC,aAAa,QAAQ,cAAc;EACnC;EACA,QAAQ,eAAe,SAAS,KAAK,aAAa,KAAA,IAAY;EAC9D,MAAM,eAAe,OAAO,IAAI,QAAQ,UAAU;EAClD,MAAM,eAAe,OAAO,IAAI,QAAQ,UAAU;EACnD;CACD,MAAM,WAAW,QAAQ,QAAQ;CACjC,SAAS,WAAW,SAAS;CAC7B,GAAG,gBAAgB;EACjB;EACA;EACD;;AAGH,MAAM,iBACJ,iBACA,eACG;CACH,KAAK,MAAM,OAAO,OAAO,KAAK,gBAAgB,EAC5C,IAAI,MAAM,gBAAgB,KAAK,EAC7B,gBAAgB,KAAK,QAAQ,WAAW;;AAI9C,MAAM,WAAsD;CAC1D,QAAQ,IAAI,SAAS;EACnB,IAAI,QAAQ,OACV,eAAe,IAAI,QAAQ;;CAG/B,QAAQ,IAAI,SAAS;EACnB,MAAM,WAAW,GAAG;EACpB,IAAI,CAAC,QAAQ,OAAO;GAClB,UAAU,SAAS,OAAO;GAC1B,GAAG,gBAAgB;GACnB;;EAGF,IAAI,CAAC,UAAU,eAAe,IAAI,QAAQ;OAExC,cACE,SAAS,SACT,SAAS,QAAQ,MAAM,GACnB,QAAQ,QACR;GACE,MAAM,GAAG,aAAa,iBAAiB,OAAO,CAAC;GAC/C,KAAK,GAAG,aAAa,iBAAiB,MAAM,CAAC;GAC7C,YAAY,GAAG,aAAa,iBAAiB,aAAa,CAAC;GAC3D,SAAS,GAAG,aAAa,iBAAiB,UAAU,CAAC;GACrD,YAAY,GAAG,aAAa,iBAAiB,aAAa,CAAC;GAC3D,aAAa,GAAG,aAAa,iBAAiB,cAAc,CAAC;GAC9D,CACN;;CAGL,UAAU,IAAI;EACZ,GAAG,eAAe,SAAS,OAAO;EAClC,GAAG,gBAAgB;;CAEtB;AAED,SAAS,WAAW"}
|
||||
39
frontend/node_modules/element-plus/es/components/loading/src/loading.d.ts
generated
vendored
Normal file
39
frontend/node_modules/element-plus/es/components/loading/src/loading.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { LoadingOptionsResolved, LoadingParentElement } from "./types.js";
|
||||
import * as _$vue from "vue";
|
||||
import { AppContext, VNode } from "vue";
|
||||
|
||||
//#region ../../packages/components/loading/src/loading.d.ts
|
||||
declare function createLoadingComponent(options: LoadingOptionsResolved, appContext: AppContext | null): {
|
||||
setText: (text: string | VNode | VNode[]) => void;
|
||||
removeElLoadingChild: () => void;
|
||||
close: () => void;
|
||||
handleAfterLeave: () => void;
|
||||
vm: _$vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, _$vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}, {}, {}, string, _$vue.ComponentProvideOptions>, {}, {}, "", {}, any>;
|
||||
$el: HTMLElement;
|
||||
originalPosition: _$vue.Ref<string, string>;
|
||||
originalOverflow: _$vue.Ref<string, string>;
|
||||
visible: _$vue.Ref<boolean, boolean>;
|
||||
parent: _$vue.Ref<LoadingParentElement, LoadingParentElement>;
|
||||
background: _$vue.Ref<string, string>;
|
||||
svg: _$vue.Ref<string, string>;
|
||||
svgViewBox: _$vue.Ref<string, string>;
|
||||
spinner: _$vue.Ref<string | boolean, string | boolean>;
|
||||
text: _$vue.Ref<string | VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[], string | VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[]>;
|
||||
fullscreen: _$vue.Ref<boolean, boolean>;
|
||||
lock: _$vue.Ref<boolean, boolean>;
|
||||
customClass: _$vue.Ref<string, string>;
|
||||
target: _$vue.Ref<HTMLElement, HTMLElement>;
|
||||
beforeClose?: _$vue.Ref<(() => boolean) | undefined, (() => boolean) | undefined> | undefined;
|
||||
closed?: _$vue.Ref<(() => void) | undefined, (() => void) | undefined> | undefined;
|
||||
};
|
||||
type LoadingInstance = ReturnType<typeof createLoadingComponent>;
|
||||
//#endregion
|
||||
export { LoadingInstance, createLoadingComponent };
|
||||
103
frontend/node_modules/element-plus/es/components/loading/src/loading.mjs
generated
vendored
Normal file
103
frontend/node_modules/element-plus/es/components/loading/src/loading.mjs
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
import { removeClass } from "../../../utils/dom/style.mjs";
|
||||
import { useGlobalComponentSettings } from "../../config-provider/src/hooks/use-global-config.mjs";
|
||||
import { Transition, createApp, createVNode, defineComponent, h, reactive, ref, toRefs, vShow, withCtx, withDirectives } from "vue";
|
||||
//#region ../../packages/components/loading/src/loading.ts
|
||||
function createLoadingComponent(options, appContext) {
|
||||
let afterLeaveTimer;
|
||||
const afterLeaveFlag = ref(false);
|
||||
const data = reactive({
|
||||
...options,
|
||||
originalPosition: "",
|
||||
originalOverflow: "",
|
||||
visible: false
|
||||
});
|
||||
function setText(text) {
|
||||
data.text = text;
|
||||
}
|
||||
function destroySelf() {
|
||||
const target = data.parent;
|
||||
const ns = vm.ns;
|
||||
if (!target.vLoadingAddClassList) {
|
||||
let loadingNumber = target.getAttribute("loading-number");
|
||||
loadingNumber = Number.parseInt(loadingNumber) - 1;
|
||||
if (!loadingNumber) {
|
||||
removeClass(target, ns.bm("parent", "relative"));
|
||||
target.removeAttribute("loading-number");
|
||||
} else target.setAttribute("loading-number", loadingNumber.toString());
|
||||
removeClass(target, ns.bm("parent", "hidden"));
|
||||
}
|
||||
removeElLoadingChild();
|
||||
loadingInstance.unmount();
|
||||
}
|
||||
function removeElLoadingChild() {
|
||||
vm.$el?.parentNode?.removeChild(vm.$el);
|
||||
}
|
||||
function close() {
|
||||
if (options.beforeClose && !options.beforeClose()) return;
|
||||
afterLeaveFlag.value = true;
|
||||
clearTimeout(afterLeaveTimer);
|
||||
afterLeaveTimer = setTimeout(handleAfterLeave, 400);
|
||||
data.visible = false;
|
||||
options.closed?.();
|
||||
}
|
||||
function handleAfterLeave() {
|
||||
if (!afterLeaveFlag.value) return;
|
||||
const target = data.parent;
|
||||
afterLeaveFlag.value = false;
|
||||
target.vLoadingAddClassList = void 0;
|
||||
destroySelf();
|
||||
}
|
||||
const loadingInstance = createApp(defineComponent({
|
||||
name: "ElLoading",
|
||||
setup(_, { expose }) {
|
||||
const { ns, zIndex } = useGlobalComponentSettings("loading");
|
||||
expose({
|
||||
ns,
|
||||
zIndex
|
||||
});
|
||||
return () => {
|
||||
const svg = data.spinner || data.svg;
|
||||
const spinner = h("svg", {
|
||||
class: "circular",
|
||||
viewBox: data.svgViewBox ? data.svgViewBox : "0 0 50 50",
|
||||
...svg ? { innerHTML: svg } : {}
|
||||
}, [h("circle", {
|
||||
class: "path",
|
||||
cx: "25",
|
||||
cy: "25",
|
||||
r: "20",
|
||||
fill: "none"
|
||||
})]);
|
||||
const spinnerText = data.text ? h("p", { class: ns.b("text") }, [data.text]) : void 0;
|
||||
return h(Transition, {
|
||||
name: ns.b("fade"),
|
||||
onAfterLeave: handleAfterLeave
|
||||
}, { default: withCtx(() => [withDirectives(createVNode("div", {
|
||||
style: { backgroundColor: data.background || "" },
|
||||
class: [
|
||||
ns.b("mask"),
|
||||
data.customClass,
|
||||
ns.is("fullscreen", data.fullscreen)
|
||||
]
|
||||
}, [h("div", { class: ns.b("spinner") }, [spinner, spinnerText])]), [[vShow, data.visible]])]) });
|
||||
};
|
||||
}
|
||||
}));
|
||||
Object.assign(loadingInstance._context, appContext ?? {});
|
||||
const vm = loadingInstance.mount(document.createElement("div"));
|
||||
return {
|
||||
...toRefs(data),
|
||||
setText,
|
||||
removeElLoadingChild,
|
||||
close,
|
||||
handleAfterLeave,
|
||||
vm,
|
||||
get $el() {
|
||||
return vm.$el;
|
||||
}
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
export { createLoadingComponent };
|
||||
|
||||
//# sourceMappingURL=loading.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/loading/src/loading.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/loading/src/loading.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
11
frontend/node_modules/element-plus/es/components/loading/src/service.d.ts
generated
vendored
Normal file
11
frontend/node_modules/element-plus/es/components/loading/src/service.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { LoadingOptions } from "./types.js";
|
||||
import { LoadingInstance } from "./loading.js";
|
||||
import { AppContext } from "vue";
|
||||
|
||||
//#region ../../packages/components/loading/src/service.d.ts
|
||||
declare const Loading: {
|
||||
(options?: LoadingOptions, context?: AppContext | null): LoadingInstance;
|
||||
_context: AppContext | null;
|
||||
};
|
||||
//#endregion
|
||||
export { Loading as default };
|
||||
97
frontend/node_modules/element-plus/es/components/loading/src/service.mjs
generated
vendored
Normal file
97
frontend/node_modules/element-plus/es/components/loading/src/service.mjs
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import { isClient } from "../../../utils/browser.mjs";
|
||||
import { isString } from "../../../utils/types.mjs";
|
||||
import { addClass, getStyle, removeClass } from "../../../utils/dom/style.mjs";
|
||||
import { createLoadingComponent } from "./loading.mjs";
|
||||
import { nextTick } from "vue";
|
||||
//#region ../../packages/components/loading/src/service.ts
|
||||
let fullscreenInstance = void 0;
|
||||
const Loading = function(options = {}, context) {
|
||||
if (!isClient) return void 0;
|
||||
const resolved = resolveOptions(options);
|
||||
if (resolved.fullscreen && fullscreenInstance) return fullscreenInstance;
|
||||
const instance = createLoadingComponent({
|
||||
...resolved,
|
||||
closed: () => {
|
||||
resolved.closed?.();
|
||||
if (resolved.fullscreen) fullscreenInstance = void 0;
|
||||
}
|
||||
}, context ?? Loading._context);
|
||||
addStyle(resolved, resolved.parent, instance);
|
||||
addClassList(resolved, resolved.parent, instance);
|
||||
resolved.parent.vLoadingAddClassList = () => addClassList(resolved, resolved.parent, instance);
|
||||
/**
|
||||
* add loading-number to parent.
|
||||
* because if a fullscreen loading is triggered when somewhere
|
||||
* a v-loading.body was triggered before and it's parent is
|
||||
* document.body which with a margin , the fullscreen loading's
|
||||
* destroySelf function will remove 'el-loading-parent--relative',
|
||||
* and then the position of v-loading.body will be error.
|
||||
*/
|
||||
let loadingNumber = resolved.parent.getAttribute("loading-number");
|
||||
if (!loadingNumber) loadingNumber = "1";
|
||||
else loadingNumber = `${Number.parseInt(loadingNumber) + 1}`;
|
||||
resolved.parent.setAttribute("loading-number", loadingNumber);
|
||||
resolved.parent.appendChild(instance.$el);
|
||||
nextTick(() => instance.visible.value = resolved.visible);
|
||||
if (resolved.fullscreen) fullscreenInstance = instance;
|
||||
return instance;
|
||||
};
|
||||
const resolveOptions = (options) => {
|
||||
let target;
|
||||
if (isString(options.target)) target = document.querySelector(options.target) ?? document.body;
|
||||
else target = options.target || document.body;
|
||||
return {
|
||||
parent: target === document.body || options.body ? document.body : target,
|
||||
background: options.background || "",
|
||||
svg: options.svg || "",
|
||||
svgViewBox: options.svgViewBox || "",
|
||||
spinner: options.spinner || false,
|
||||
text: options.text || "",
|
||||
fullscreen: target === document.body && (options.fullscreen ?? true),
|
||||
lock: options.lock ?? false,
|
||||
customClass: options.customClass || "",
|
||||
visible: options.visible ?? true,
|
||||
beforeClose: options.beforeClose,
|
||||
closed: options.closed,
|
||||
target
|
||||
};
|
||||
};
|
||||
const addStyle = async (options, parent, instance) => {
|
||||
const { nextZIndex } = instance.vm.zIndex || instance.vm._.exposed.zIndex;
|
||||
const maskStyle = {};
|
||||
if (options.fullscreen) {
|
||||
instance.originalPosition.value = getStyle(document.body, "position");
|
||||
instance.originalOverflow.value = getStyle(document.body, "overflow");
|
||||
maskStyle.zIndex = nextZIndex();
|
||||
} else if (options.parent === document.body) {
|
||||
instance.originalPosition.value = getStyle(document.body, "position");
|
||||
/**
|
||||
* await dom render when visible is true in init,
|
||||
* because some component's height maybe 0.
|
||||
* e.g. el-table.
|
||||
*/
|
||||
await nextTick();
|
||||
for (const property of ["top", "left"]) {
|
||||
const scroll = property === "top" ? "scrollTop" : "scrollLeft";
|
||||
maskStyle[property] = `${options.target.getBoundingClientRect()[property] + document.body[scroll] + document.documentElement[scroll] - Number.parseInt(getStyle(document.body, `margin-${property}`), 10)}px`;
|
||||
}
|
||||
for (const property of ["height", "width"]) maskStyle[property] = `${options.target.getBoundingClientRect()[property]}px`;
|
||||
} else instance.originalPosition.value = getStyle(parent, "position");
|
||||
for (const [key, value] of Object.entries(maskStyle)) instance.$el.style[key] = value;
|
||||
};
|
||||
const addClassList = (options, parent, instance) => {
|
||||
const ns = instance.vm.ns || instance.vm._.exposed.ns;
|
||||
if (![
|
||||
"absolute",
|
||||
"fixed",
|
||||
"sticky"
|
||||
].includes(instance.originalPosition.value)) addClass(parent, ns.bm("parent", "relative"));
|
||||
else removeClass(parent, ns.bm("parent", "relative"));
|
||||
if (options.fullscreen && options.lock) addClass(parent, ns.bm("parent", "hidden"));
|
||||
else removeClass(parent, ns.bm("parent", "hidden"));
|
||||
};
|
||||
Loading._context = null;
|
||||
//#endregion
|
||||
export { Loading as default };
|
||||
|
||||
//# sourceMappingURL=service.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/loading/src/service.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/loading/src/service.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51
frontend/node_modules/element-plus/es/components/loading/src/types.d.ts
generated
vendored
Normal file
51
frontend/node_modules/element-plus/es/components/loading/src/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { MaybeRef, VNode } from "vue";
|
||||
|
||||
//#region ../../packages/components/loading/src/types.d.ts
|
||||
type LoadingOptionsResolved = {
|
||||
parent: LoadingParentElement;
|
||||
/**
|
||||
* @description background color of the mask
|
||||
*/
|
||||
background: MaybeRef<string>;
|
||||
svg: MaybeRef<string>;
|
||||
svgViewBox: MaybeRef<string>;
|
||||
/**
|
||||
* @description class name of the custom spinner
|
||||
*/
|
||||
spinner: MaybeRef<boolean | string>;
|
||||
/**
|
||||
* @description loading text that displays under the spinner
|
||||
*/
|
||||
text: MaybeRef<string | VNode | VNode[]>;
|
||||
/**
|
||||
* @description same as the `fullscreen` modifier of `v-loading`
|
||||
*/
|
||||
fullscreen: boolean;
|
||||
/**
|
||||
* @description same as the `lock` modifier of `v-loading`
|
||||
*/
|
||||
lock: boolean;
|
||||
/**
|
||||
* @description custom class name for Loading
|
||||
*/
|
||||
customClass: MaybeRef<string>;
|
||||
visible: boolean;
|
||||
target: HTMLElement;
|
||||
beforeClose?: () => boolean;
|
||||
closed?: () => void;
|
||||
};
|
||||
type LoadingOptions = Partial<Omit<LoadingOptionsResolved, 'parent' | 'target'> & {
|
||||
/**
|
||||
* @description the DOM node Loading needs to cover. Accepts a DOM object or a string. If it's a string, it will be passed to `document.querySelector` to get the corresponding DOM node
|
||||
*/
|
||||
target: HTMLElement | string;
|
||||
/**
|
||||
* @description same as the `body` modifier of `v-loading`
|
||||
*/
|
||||
body: boolean;
|
||||
}>;
|
||||
interface LoadingParentElement extends HTMLElement {
|
||||
vLoadingAddClassList?: () => void;
|
||||
}
|
||||
//#endregion
|
||||
export { LoadingOptions, LoadingOptionsResolved, LoadingParentElement };
|
||||
0
frontend/node_modules/element-plus/es/components/loading/src/types.mjs
generated
vendored
Normal file
0
frontend/node_modules/element-plus/es/components/loading/src/types.mjs
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/loading/style/css.mjs
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/loading/style/css.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../base/style/css.mjs";
|
||||
import "element-plus/theme-chalk/el-loading.css";
|
||||
2
frontend/node_modules/element-plus/es/components/loading/style/index.mjs
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/loading/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../base/style/index.mjs";
|
||||
import "element-plus/theme-chalk/src/loading.scss";
|
||||
Reference in New Issue
Block a user