完全跑通1.0版本
This commit is contained in:
2
frontend/node_modules/element-plus/lib/components/slot/index.d.ts
generated
vendored
Normal file
2
frontend/node_modules/element-plus/lib/components/slot/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { OnlyChild, OnlyChildExpose } from "./src/only-child.js";
|
||||
export { OnlyChild as ElOnlyChild, OnlyChild, OnlyChildExpose };
|
||||
4
frontend/node_modules/element-plus/lib/components/slot/index.js
generated
vendored
Normal file
4
frontend/node_modules/element-plus/lib/components/slot/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const require_only_child = require("./src/only-child.js");
|
||||
exports.ElOnlyChild = require_only_child.OnlyChild;
|
||||
exports.OnlyChild = require_only_child.OnlyChild;
|
||||
12
frontend/node_modules/element-plus/lib/components/slot/src/only-child.d.ts
generated
vendored
Normal file
12
frontend/node_modules/element-plus/lib/components/slot/src/only-child.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as _$vue from "vue";
|
||||
import { Ref, VNode } from "vue";
|
||||
|
||||
//#region ../../packages/components/slot/src/only-child.d.ts
|
||||
declare const OnlyChild: _$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>;
|
||||
type OnlyChildExpose = {
|
||||
forwardRef: Ref<HTMLElement>;
|
||||
};
|
||||
//#endregion
|
||||
export { OnlyChild, OnlyChildExpose };
|
||||
53
frontend/node_modules/element-plus/lib/components/slot/src/only-child.js
generated
vendored
Normal file
53
frontend/node_modules/element-plus/lib/components/slot/src/only-child.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
require("../../../_virtual/_rolldown/runtime.js");
|
||||
const require_error = require("../../../utils/error.js");
|
||||
const require_index = require("../../../hooks/use-namespace/index.js");
|
||||
const require_index$1 = require("../../../hooks/use-forward-ref/index.js");
|
||||
let vue = require("vue");
|
||||
let _vue_shared = require("@vue/shared");
|
||||
//#region ../../packages/components/slot/src/only-child.tsx
|
||||
const NAME = "ElOnlyChild";
|
||||
const OnlyChild = /* @__PURE__ */ (0, vue.defineComponent)({
|
||||
name: NAME,
|
||||
setup(_, { slots, attrs }) {
|
||||
const forwardRefDirective = require_index$1.useForwardRefDirective((0, vue.inject)(require_index$1.FORWARD_REF_INJECTION_KEY)?.setForwardRef ?? _vue_shared.NOOP);
|
||||
return () => {
|
||||
const defaultSlot = slots.default?.(attrs);
|
||||
if (!defaultSlot) return null;
|
||||
const [firstLegitNode, length] = findFirstLegitChild(defaultSlot);
|
||||
if (!firstLegitNode) {
|
||||
require_error.debugWarn(NAME, "no valid child node found");
|
||||
return null;
|
||||
}
|
||||
if (length > 1) require_error.debugWarn(NAME, "requires exact only one valid child.");
|
||||
return (0, vue.withDirectives)((0, vue.cloneVNode)(firstLegitNode, attrs), [[forwardRefDirective]]);
|
||||
};
|
||||
}
|
||||
});
|
||||
function findFirstLegitChild(node) {
|
||||
if (!node) return [null, 0];
|
||||
const children = node;
|
||||
const len = children.filter((c) => c.type !== vue.Comment).length;
|
||||
for (const child of children) {
|
||||
/**
|
||||
* when user uses h(Fragment, [text]) to render plain string,
|
||||
* this switch case just cannot handle, when the value is primitives
|
||||
* we should just return the wrapped string
|
||||
*/
|
||||
if ((0, _vue_shared.isObject)(child)) switch (child.type) {
|
||||
case vue.Comment: continue;
|
||||
case vue.Text:
|
||||
case "svg": return [wrapTextContent(child), len];
|
||||
case vue.Fragment: return findFirstLegitChild(child.children);
|
||||
default: return [child, len];
|
||||
}
|
||||
return [wrapTextContent(child), len];
|
||||
}
|
||||
return [null, 0];
|
||||
}
|
||||
function wrapTextContent(s) {
|
||||
return (0, vue.createVNode)("span", { "class": require_index.useNamespace("only-child").e("content") }, [s]);
|
||||
}
|
||||
//#endregion
|
||||
exports.OnlyChild = OnlyChild;
|
||||
|
||||
//# sourceMappingURL=only-child.js.map
|
||||
1
frontend/node_modules/element-plus/lib/components/slot/src/only-child.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/components/slot/src/only-child.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"only-child.js","names":["Comment","Fragment","Text","cloneVNode","defineComponent","inject","withDirectives","createVNode","_createVNode","NOOP","debugWarn","isObject","FORWARD_REF_INJECTION_KEY","useForwardRefDirective","useNamespace","NAME","OnlyChild","name","setup","_","slots","attrs","forwardRefInjection","forwardRefDirective","setForwardRef","defaultSlot","default","firstLegitNode","length","findFirstLegitChild","node","children","len","filter","c","type","child","wrapTextContent","s","ns","e"],"sources":["../../../../../../packages/components/slot/src/only-child.tsx"],"sourcesContent":["import {\n Comment,\n Fragment,\n Text,\n cloneVNode,\n defineComponent,\n inject,\n withDirectives,\n} from 'vue'\nimport { NOOP, debugWarn, isObject } from '@element-plus/utils'\nimport {\n FORWARD_REF_INJECTION_KEY,\n useForwardRefDirective,\n useNamespace,\n} from '@element-plus/hooks'\n\nimport type { Ref, VNode } from 'vue'\n\nconst NAME = 'ElOnlyChild'\n\nexport const OnlyChild = defineComponent({\n name: NAME,\n setup(_, { slots, attrs }) {\n const forwardRefInjection = inject(FORWARD_REF_INJECTION_KEY)\n const forwardRefDirective = useForwardRefDirective(\n forwardRefInjection?.setForwardRef ?? NOOP\n )\n return () => {\n const defaultSlot = slots.default?.(attrs)\n if (!defaultSlot) return null\n const [firstLegitNode, length] = findFirstLegitChild(defaultSlot)\n\n if (!firstLegitNode) {\n debugWarn(NAME, 'no valid child node found')\n return null\n }\n if (length > 1) {\n debugWarn(NAME, 'requires exact only one valid child.')\n }\n\n return withDirectives(cloneVNode(firstLegitNode!, attrs), [\n [forwardRefDirective],\n ])\n }\n },\n})\n\nfunction findFirstLegitChild(\n node: VNode[] | undefined\n): [VNode | null, number] {\n if (!node) return [null, 0]\n const children = node as VNode[]\n const len = children.filter((c) => c.type !== Comment).length\n\n for (const child of children) {\n /**\n * when user uses h(Fragment, [text]) to render plain string,\n * this switch case just cannot handle, when the value is primitives\n * we should just return the wrapped string\n */\n if (isObject(child)) {\n switch (child.type) {\n case Comment:\n continue\n case Text:\n case 'svg':\n return [wrapTextContent(child), len]\n case Fragment:\n return findFirstLegitChild(child.children as VNode[])\n default:\n return [child, len]\n }\n }\n return [wrapTextContent(child), len]\n }\n return [null, 0]\n}\n\nfunction wrapTextContent(s: string | VNode) {\n const ns = useNamespace('only-child')\n return <span class={ns.e('content')}>{s}</span>\n}\n\nexport type OnlyChildExpose = {\n forwardRef: Ref<HTMLElement>\n}\n"],"mappings":";;;;;;;AAkBA,MAAMe,OAAO;AAEb,MAAaC,YAAYZ,iBAAAA,GAAAA,IAAAA,iBAAgB;CACvCa,MAAMF;CACNG,MAAMC,GAAG,EAAEC,OAAOC,SAAS;EAEzB,MAAME,sBAAsBV,gBAAAA,wBAAAA,GAAAA,IAAAA,QADOD,gBAAAA,0BAEd,EAAEY,iBAAiBf,YAAAA,KACvC;EACD,aAAa;GACX,MAAMgB,cAAcL,MAAMM,UAAUL,MAAM;GAC1C,IAAI,CAACI,aAAa,OAAO;GACzB,MAAM,CAACE,gBAAgBC,UAAUC,oBAAoBJ,YAAY;GAEjE,IAAI,CAACE,gBAAgB;IACnBjB,cAAAA,UAAUK,MAAM,4BAA4B;IAC5C,OAAO;;GAET,IAAIa,SAAS,GACXlB,cAAAA,UAAUK,MAAM,uCAAuC;GAGzD,QAAA,GAAA,IAAA,iBAAA,GAAA,IAAA,YAAiCY,gBAAiBN,MAAM,EAAE,CACxD,CAACE,oBAAoB,CACtB,CAAC;;;CAGP,CAAC;AAEF,SAASM,oBACPC,MACwB;CACxB,IAAI,CAACA,MAAM,OAAO,CAAC,MAAM,EAAE;CAC3B,MAAMC,WAAWD;CACjB,MAAME,M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