完全跑通1.0版本
This commit is contained in:
18
frontend/node_modules/element-plus/lib/hooks/use-ordered-children/index.d.ts
generated
vendored
Normal file
18
frontend/node_modules/element-plus/lib/hooks/use-ordered-children/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as _$vue from "vue";
|
||||
import { ComponentInternalInstance, VNode } from "vue";
|
||||
|
||||
//#region ../../packages/hooks/use-ordered-children/index.d.ts
|
||||
type ChildEssential = {
|
||||
uid: number;
|
||||
getVnode: () => VNode;
|
||||
};
|
||||
declare const useOrderedChildren: <T extends ChildEssential>(vm: ComponentInternalInstance, childComponentName: string) => {
|
||||
children: _$vue.ShallowRef<T[], T[]>;
|
||||
addChild: (child: T) => void;
|
||||
removeChild: (child: T) => void;
|
||||
ChildrenSorter: _$vue.DefineComponent<{}, () => VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | null, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
||||
};
|
||||
//#endregion
|
||||
export { useOrderedChildren };
|
||||
60
frontend/node_modules/element-plus/lib/hooks/use-ordered-children/index.js
generated
vendored
Normal file
60
frontend/node_modules/element-plus/lib/hooks/use-ordered-children/index.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
require("../../_virtual/_rolldown/runtime.js");
|
||||
const require_vnode = require("../../utils/vue/vnode.js");
|
||||
let vue = require("vue");
|
||||
//#region ../../packages/hooks/use-ordered-children/index.ts
|
||||
const getOrderedChildren = (vm, childComponentName, children) => {
|
||||
return require_vnode.flattedChildren(vm.subTree).filter((n) => (0, vue.isVNode)(n) && n.type?.name === childComponentName && !!n.component).map((n) => n.component.uid).map((uid) => children[uid]).filter((p) => !!p);
|
||||
};
|
||||
const useOrderedChildren = (vm, childComponentName) => {
|
||||
const children = (0, vue.shallowRef)({});
|
||||
const orderedChildren = (0, vue.shallowRef)([]);
|
||||
const nodesMap = /* @__PURE__ */ new WeakMap();
|
||||
const addChild = (child) => {
|
||||
children.value[child.uid] = child;
|
||||
(0, vue.triggerRef)(children);
|
||||
(0, vue.onMounted)(() => {
|
||||
const childNode = child.getVnode().el;
|
||||
const parentNode = childNode.parentNode;
|
||||
if (!nodesMap.has(parentNode)) {
|
||||
nodesMap.set(parentNode, []);
|
||||
const originalFn = parentNode.insertBefore.bind(parentNode);
|
||||
parentNode.insertBefore = (node, anchor) => {
|
||||
if (nodesMap.get(parentNode).some((el) => node === el || anchor === el)) (0, vue.triggerRef)(children);
|
||||
return originalFn(node, anchor);
|
||||
};
|
||||
}
|
||||
nodesMap.get(parentNode).push(childNode);
|
||||
});
|
||||
};
|
||||
const removeChild = (child) => {
|
||||
delete children.value[child.uid];
|
||||
(0, vue.triggerRef)(children);
|
||||
const childNode = child.getVnode().el;
|
||||
const parentNode = childNode.parentNode;
|
||||
const childNodes = nodesMap.get(parentNode);
|
||||
const index = childNodes.indexOf(childNode);
|
||||
childNodes.splice(index, 1);
|
||||
};
|
||||
const sortChildren = () => {
|
||||
orderedChildren.value = getOrderedChildren(vm, childComponentName, children.value);
|
||||
};
|
||||
const IsolatedRenderer = (props) => {
|
||||
return props.render();
|
||||
};
|
||||
return {
|
||||
children: orderedChildren,
|
||||
addChild,
|
||||
removeChild,
|
||||
ChildrenSorter: (0, vue.defineComponent)({ setup(_, { slots }) {
|
||||
return () => {
|
||||
sortChildren();
|
||||
return slots.default ? (0, vue.h)(IsolatedRenderer, { render: slots.default }) : null;
|
||||
};
|
||||
} })
|
||||
};
|
||||
};
|
||||
//#endregion
|
||||
exports.useOrderedChildren = useOrderedChildren;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
frontend/node_modules/element-plus/lib/hooks/use-ordered-children/index.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/hooks/use-ordered-children/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["flattedChildren"],"sources":["../../../../../packages/hooks/use-ordered-children/index.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n isVNode,\n onMounted,\n shallowRef,\n triggerRef,\n} from 'vue'\nimport { flattedChildren } from '@element-plus/utils'\n\nimport type { Component, ComponentInternalInstance, VNode } from 'vue'\n\ntype ChildEssential = {\n uid: number\n getVnode: () => VNode\n}\n\nconst getOrderedChildren = <T>(\n vm: ComponentInternalInstance,\n childComponentName: string,\n children: Record<number, T>\n): T[] => {\n const nodes = flattedChildren(vm.subTree).filter(\n (n): n is VNode =>\n isVNode(n) &&\n (n.type as Component)?.name === childComponentName &&\n !!n.component\n )\n const uids = nodes.map((n) => n.component!.uid)\n return uids.map((uid) => children[uid]).filter((p) => !!p)\n}\n\nexport const useOrderedChildren = <T extends ChildEssential>(\n vm: ComponentInternalInstance,\n childComponentName: string\n) => {\n const children = shallowRef<Record<number, T>>({})\n const orderedChildren = shallowRef<T[]>([])\n const nodesMap = new WeakMap<ParentNode, Node[]>()\n\n const addChild = (child: T) => {\n children.value[child.uid] = child\n triggerRef(children)\n\n onMounted(() => {\n const childNode = child.getVnode().el! as Node\n const parentNode = childNode.parentNode!\n\n if (!nodesMap.has(parentNode)) {\n nodesMap.set(parentNode, [])\n\n const originalFn = parentNode.insertBefore.bind(parentNode)\n parentNode.insertBefore = <T extends Node>(\n node: T,\n anchor: Node | null\n ) => {\n // Schedule a job to update `orderedChildren` if the root element of child components is moved\n const shouldSortChildren = nodesMap\n .get(parentNode)!\n .some((el) => node === el || anchor === el)\n if (shouldSortChildren) triggerRef(children)\n\n return originalFn(node, anchor)\n }\n }\n\n nodesMap.get(parentNode)!.push(childNode)\n })\n }\n\n const removeChild = (child: T) => {\n delete children.value[child.uid]\n triggerRef(children)\n\n const childNode = child.getVnode().el! as Node\n const parentNode = childNode.parentNode!\n const childNodes = nodesMap.get(parentNode)!\n const index = childNodes.indexOf(childNode)\n childNodes.splice(index, 1)\n }\n\n const sortChildren = () => {\n orderedChildren.value = getOrderedChildren(\n vm,\n childComponentName,\n children.value\n )\n }\n\n const IsolatedRenderer = (props: { render: () => VNode[] }) => {\n return props.render()\n }\n\n // TODO: Refactor `el-description` before converting this to a functional component\n const ChildrenSorter = defineComponent({\n setup(_, { slots }) {\n return () => {\n sortChildren()\n\n return slots.default\n ? // Create a new `ReactiveEffect` to ensure `ChildrenSorter` doesn't track any extra dependencies\n // @ts-ignore TODO: Remove this after Vue is upgraded\n h(IsolatedRenderer, {\n render: slots.default,\n })\n : null\n }\n },\n })\n\n return {\n children: orderedChildren,\n addChild,\n removeChild,\n ChildrenSorter,\n }\n}\n"],"mappings":";;;;;AAiBA,MAAM,sBACJ,IACA,oBACA,aACQ;CAQR,OAPcA,cAAAA,gBAAgB,GAAG,QAAQ,CAAC,QACvC,OAAA,GAAA,IAAA,SACS,EAAE,IACT,EAAE,MAAoB,SAAS,sBAChC,CAAC,CAAC,EAAE,UAEU,CAAC,KAAK,MAAM,EAAE,UAAW,IAChC,CAAC,KAAK,QAAQ,SAAS,KAAK,CAAC,QAAQ,MAAM,CAAC,CAAC,EAAE;;AAG5D,MAAa,sBACX,IACA,uBACG;CACH,MAAM,YAAA,GAAA,IAAA,YAAyC,EAAE,CAAC;CAClD,MAAM,mBAAA,GAAA,IAAA,YAAkC,EAAE,CAAC;CAC3C,MAAM,2BAAW,IAAI,SAA6B;CAElD,MAAM,YAAY,UAAa;EAC7B,SAAS,MAAM,MAAM,OAAO;EAC5B,CAAA,GAAA,IAAA,YAAW,SAAS;EAEpB,CAAA,GAAA,IAAA,iBAAgB;GACd,MAAM,YAAY,MAAM,UAAU,CAAC;GACnC,MAAM,aAAa,UAAU;GAE7B,IAAI,CAAC,SAAS,IAAI,WAAW,EAAE;IAC7B,SAAS,IAAI,YAAY,EAAE,CAAC;IAE5B,MAAM,aAAa,WAAW,aAAa,KAAK,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