完全跑通1.0版本
This commit is contained in:
20
frontend/node_modules/element-plus/es/components/infinite-scroll/index.d.ts
generated
vendored
Normal file
20
frontend/node_modules/element-plus/es/components/infinite-scroll/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { SFCWithInstall } from "../../utils/vue/typescript.js";
|
||||
import InfiniteScroll from "./src/index.js";
|
||||
import * as _$vue from "vue";
|
||||
|
||||
//#region ../../packages/components/infinite-scroll/index.d.ts
|
||||
declare const _InfiniteScroll: SFCWithInstall<typeof InfiniteScroll>;
|
||||
declare const ElInfiniteScroll: SFCWithInstall<_$vue.ObjectDirective<HTMLElement & {
|
||||
ElInfiniteScroll: {
|
||||
container: HTMLElement | Window;
|
||||
containerEl: HTMLElement;
|
||||
instance: _$vue.ComponentPublicInstance;
|
||||
delay: number;
|
||||
lastScrollTop: number;
|
||||
cb: () => void;
|
||||
onScroll: () => void;
|
||||
observer?: MutationObserver;
|
||||
};
|
||||
}, () => void, string, any>>;
|
||||
//#endregion
|
||||
export { ElInfiniteScroll, _InfiniteScroll as default };
|
||||
11
frontend/node_modules/element-plus/es/components/infinite-scroll/index.mjs
generated
vendored
Normal file
11
frontend/node_modules/element-plus/es/components/infinite-scroll/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import InfiniteScroll from "./src/index.mjs";
|
||||
//#region ../../packages/components/infinite-scroll/index.ts
|
||||
const _InfiniteScroll = InfiniteScroll;
|
||||
_InfiniteScroll.install = (app) => {
|
||||
app.directive("InfiniteScroll", _InfiniteScroll);
|
||||
};
|
||||
const ElInfiniteScroll = _InfiniteScroll;
|
||||
//#endregion
|
||||
export { ElInfiniteScroll, _InfiniteScroll as default };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/infinite-scroll/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/infinite-scroll/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/components/infinite-scroll/index.ts"],"sourcesContent":["// TODO: remove the directive in 3.0\nimport InfiniteScroll from './src'\n\nimport type { App } from 'vue'\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nconst _InfiniteScroll = InfiniteScroll as SFCWithInstall<typeof InfiniteScroll>\n\n_InfiniteScroll.install = (app: App) => {\n app.directive('InfiniteScroll', _InfiniteScroll)\n}\n\nexport default _InfiniteScroll\nexport const ElInfiniteScroll = _InfiniteScroll\n"],"mappings":";;AAMA,MAAM,kBAAkB;AAExB,gBAAgB,WAAW,QAAa;CACtC,IAAI,UAAU,kBAAkB,gBAAgB;;AAIlD,MAAa,mBAAmB"}
|
||||
23
frontend/node_modules/element-plus/es/components/infinite-scroll/src/index.d.ts
generated
vendored
Normal file
23
frontend/node_modules/element-plus/es/components/infinite-scroll/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentPublicInstance, ObjectDirective } from "vue";
|
||||
|
||||
//#region ../../packages/components/infinite-scroll/src/index.d.ts
|
||||
declare const SCOPE = "ElInfiniteScroll";
|
||||
declare const CHECK_INTERVAL = 50;
|
||||
declare const DEFAULT_DELAY = 200;
|
||||
declare const DEFAULT_DISTANCE = 0;
|
||||
type InfiniteScrollCallback = () => void;
|
||||
type InfiniteScrollEl = HTMLElement & {
|
||||
[SCOPE]: {
|
||||
container: HTMLElement | Window;
|
||||
containerEl: HTMLElement;
|
||||
instance: ComponentPublicInstance;
|
||||
delay: number;
|
||||
lastScrollTop: number;
|
||||
cb: InfiniteScrollCallback;
|
||||
onScroll: () => void;
|
||||
observer?: MutationObserver;
|
||||
};
|
||||
};
|
||||
declare const InfiniteScroll: ObjectDirective<InfiniteScrollEl, InfiniteScrollCallback>;
|
||||
//#endregion
|
||||
export { CHECK_INTERVAL, DEFAULT_DELAY, DEFAULT_DISTANCE, SCOPE, InfiniteScroll as default };
|
||||
126
frontend/node_modules/element-plus/es/components/infinite-scroll/src/index.mjs
generated
vendored
Normal file
126
frontend/node_modules/element-plus/es/components/infinite-scroll/src/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import { getOffsetTopDistance } from "../../../utils/dom/position.mjs";
|
||||
import { isFunction } from "../../../utils/types.mjs";
|
||||
import { throwError } from "../../../utils/error.mjs";
|
||||
import { getScrollContainer } from "../../../utils/dom/scroll.mjs";
|
||||
import { useDeprecated } from "../../../hooks/use-deprecated/index.mjs";
|
||||
import { throttle } from "lodash-unified";
|
||||
import { nextTick } from "vue";
|
||||
//#region ../../packages/components/infinite-scroll/src/index.ts
|
||||
const SCOPE = "ElInfiniteScroll";
|
||||
const CHECK_INTERVAL = 50;
|
||||
const DEFAULT_DELAY = 200;
|
||||
const DEFAULT_DISTANCE = 0;
|
||||
const attributes = {
|
||||
delay: {
|
||||
type: Number,
|
||||
default: 200
|
||||
},
|
||||
distance: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
immediate: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
};
|
||||
const getScrollOptions = (el, instance) => {
|
||||
return Object.entries(attributes).reduce((acm, [name, option]) => {
|
||||
const { type, default: defaultValue } = option;
|
||||
const attrVal = el.getAttribute(`infinite-scroll-${name}`);
|
||||
let value = instance[attrVal] ?? attrVal ?? defaultValue;
|
||||
value = value === "false" ? false : value;
|
||||
value = type(value);
|
||||
acm[name] = Number.isNaN(value) ? defaultValue : value;
|
||||
return acm;
|
||||
}, {});
|
||||
};
|
||||
const destroyObserver = (el) => {
|
||||
const { observer } = el[SCOPE];
|
||||
if (observer) {
|
||||
observer.disconnect();
|
||||
delete el[SCOPE].observer;
|
||||
}
|
||||
};
|
||||
const handleScroll = (el, cb) => {
|
||||
const { container, containerEl, instance, observer, lastScrollTop } = el[SCOPE];
|
||||
const { disabled, distance } = getScrollOptions(el, instance);
|
||||
const { clientHeight, scrollHeight, scrollTop } = containerEl;
|
||||
const delta = scrollTop - lastScrollTop;
|
||||
el[SCOPE].lastScrollTop = scrollTop;
|
||||
if (observer || disabled || delta < 0) return;
|
||||
let shouldTrigger = false;
|
||||
if (container === el) shouldTrigger = scrollHeight - (clientHeight + scrollTop) <= distance;
|
||||
else {
|
||||
const { clientTop, scrollHeight: height } = el;
|
||||
const offsetTop = getOffsetTopDistance(el, containerEl);
|
||||
shouldTrigger = scrollTop + clientHeight >= offsetTop + clientTop + height - distance;
|
||||
}
|
||||
if (shouldTrigger) cb.call(instance);
|
||||
};
|
||||
function checkFull(el, cb) {
|
||||
const { containerEl, instance } = el[SCOPE];
|
||||
const { disabled } = getScrollOptions(el, instance);
|
||||
if (disabled || containerEl.clientHeight === 0) return;
|
||||
if (containerEl.scrollHeight <= containerEl.clientHeight) cb.call(instance);
|
||||
else destroyObserver(el);
|
||||
}
|
||||
const InfiniteScroll = {
|
||||
async mounted(el, binding) {
|
||||
const { instance, value: cb } = binding;
|
||||
useDeprecated({
|
||||
scope: SCOPE,
|
||||
from: "the directive v-infinite-scroll",
|
||||
replacement: "the el-scrollbar infinite scroll",
|
||||
version: "3.0.0",
|
||||
ref: "https://element-plus.org/en-US/component/scrollbar#infinite-scroll"
|
||||
}, true);
|
||||
if (!isFunction(cb)) throwError(SCOPE, "'v-infinite-scroll' binding value must be a function");
|
||||
await nextTick();
|
||||
const { delay, immediate } = getScrollOptions(el, instance);
|
||||
const container = getScrollContainer(el, true);
|
||||
const containerEl = container === window ? document.documentElement : container;
|
||||
const onScroll = throttle(handleScroll.bind(null, el, cb), delay);
|
||||
if (!container) return;
|
||||
el[SCOPE] = {
|
||||
instance,
|
||||
container,
|
||||
containerEl,
|
||||
delay,
|
||||
cb,
|
||||
onScroll,
|
||||
lastScrollTop: containerEl.scrollTop
|
||||
};
|
||||
if (immediate) {
|
||||
const observer = new MutationObserver(throttle(checkFull.bind(null, el, cb), 50));
|
||||
el[SCOPE].observer = observer;
|
||||
observer.observe(el, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
checkFull(el, cb);
|
||||
}
|
||||
container.addEventListener("scroll", onScroll);
|
||||
},
|
||||
unmounted(el) {
|
||||
if (!el["ElInfiniteScroll"]) return;
|
||||
const { container, onScroll } = el[SCOPE];
|
||||
container?.removeEventListener("scroll", onScroll);
|
||||
destroyObserver(el);
|
||||
},
|
||||
async updated(el) {
|
||||
if (!el["ElInfiniteScroll"]) await nextTick();
|
||||
else {
|
||||
const { containerEl, cb, observer } = el[SCOPE];
|
||||
if (containerEl.clientHeight && observer) checkFull(el, cb);
|
||||
}
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
export { CHECK_INTERVAL, DEFAULT_DELAY, DEFAULT_DISTANCE, SCOPE, InfiniteScroll as default };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/infinite-scroll/src/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/infinite-scroll/src/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
frontend/node_modules/element-plus/es/components/infinite-scroll/style/css.mjs
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/infinite-scroll/style/css.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../base/style/css.mjs";
|
||||
import "element-plus/theme-chalk/el-infinite-scroll.css";
|
||||
2
frontend/node_modules/element-plus/es/components/infinite-scroll/style/index.mjs
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/infinite-scroll/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../base/style/index.mjs";
|
||||
import "element-plus/theme-chalk/src/infinite-scroll.scss";
|
||||
Reference in New Issue
Block a user