测试
This commit is contained in:
2
frontend/node_modules/element-plus/es/components/slot/index.d.ts
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/slot/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { OnlyChild as ElOnlyChild } from './src/only-child';
|
||||
export * from './src/only-child';
|
||||
2
frontend/node_modules/element-plus/es/components/slot/index.mjs
generated
vendored
Normal file
2
frontend/node_modules/element-plus/es/components/slot/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { OnlyChild as ElOnlyChild, OnlyChild } from './src/only-child.mjs';
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/slot/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/slot/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
||||
7
frontend/node_modules/element-plus/es/components/slot/src/only-child.d.ts
generated
vendored
Normal file
7
frontend/node_modules/element-plus/es/components/slot/src/only-child.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { Ref, VNode } from 'vue';
|
||||
export declare const OnlyChild: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
||||
export type OnlyChildExpose = {
|
||||
forwardRef: Ref<HTMLElement>;
|
||||
};
|
||||
60
frontend/node_modules/element-plus/es/components/slot/src/only-child.mjs
generated
vendored
Normal file
60
frontend/node_modules/element-plus/es/components/slot/src/only-child.mjs
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { defineComponent, inject, withDirectives, cloneVNode, Comment, Fragment, createVNode, Text } from 'vue';
|
||||
import { FORWARD_REF_INJECTION_KEY, useForwardRefDirective } from '../../../hooks/use-forward-ref/index.mjs';
|
||||
import { NOOP, isObject } from '@vue/shared';
|
||||
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
||||
|
||||
const NAME = "ElOnlyChild";
|
||||
const OnlyChild = defineComponent({
|
||||
name: NAME,
|
||||
setup(_, {
|
||||
slots,
|
||||
attrs
|
||||
}) {
|
||||
var _a;
|
||||
const forwardRefInjection = inject(FORWARD_REF_INJECTION_KEY);
|
||||
const forwardRefDirective = useForwardRefDirective((_a = forwardRefInjection == null ? void 0 : forwardRefInjection.setForwardRef) != null ? _a : NOOP);
|
||||
return () => {
|
||||
var _a2;
|
||||
const defaultSlot = (_a2 = slots.default) == null ? void 0 : _a2.call(slots, attrs);
|
||||
if (!defaultSlot)
|
||||
return null;
|
||||
const [firstLegitNode, length] = findFirstLegitChild(defaultSlot);
|
||||
if (!firstLegitNode) {
|
||||
return null;
|
||||
}
|
||||
return withDirectives(cloneVNode(firstLegitNode, attrs), [[forwardRefDirective]]);
|
||||
};
|
||||
}
|
||||
});
|
||||
function findFirstLegitChild(node) {
|
||||
if (!node)
|
||||
return [null, 0];
|
||||
const children = node;
|
||||
const len = children.filter((c) => c.type !== Comment).length;
|
||||
for (const child of children) {
|
||||
if (isObject(child)) {
|
||||
switch (child.type) {
|
||||
case Comment:
|
||||
continue;
|
||||
case Text:
|
||||
case "svg":
|
||||
return [wrapTextContent(child), len];
|
||||
case Fragment:
|
||||
return findFirstLegitChild(child.children);
|
||||
default:
|
||||
return [child, len];
|
||||
}
|
||||
}
|
||||
return [wrapTextContent(child), len];
|
||||
}
|
||||
return [null, 0];
|
||||
}
|
||||
function wrapTextContent(s) {
|
||||
const ns = useNamespace("only-child");
|
||||
return createVNode("span", {
|
||||
"class": ns.e("content")
|
||||
}, [s]);
|
||||
}
|
||||
|
||||
export { OnlyChild };
|
||||
//# sourceMappingURL=only-child.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/components/slot/src/only-child.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/components/slot/src/only-child.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"only-child.mjs","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"],"names":["NAME","OnlyChild","defineComponent","name","slots","attrs","forwardRefInjection","inject","FORWARD_REF_INJECTION_KEY","forwardRefDirective","useForwardRefDirective","setForwardRef","NOOP","defaultSlot","debugWarn","findFirstLegitChild","children","len","filter","child","wrapTextContent"],"mappings":";;;;;AAkBA,MAAMA,IAAI,GAAG,aAAb,CAAA;AAEaC,MAAAA,SAAS,GAAGC,eAAe,CAAC;AACvCC,EAAAA,IAAI,EAAEH,IADiC;;IAElC,KAAA;IAAMI,KAAF;AAASC,GAAAA,EAAAA;AAAT,IAAkB,IAAA,EAAA,CAAA;AACzB,IAAA,MAAMC,mBAAmB,GAAGC,MAAM,CAACC,yBAAD,CAAlC,CAAA;IACA,MAAMC,mBAAmB,GAAGC,sBAAsB,CAChDJ,yBAAqBK,IAAAA,IAAAA,GAAiBC,KAAAA,CADU,GAAlD,mBAAA,CAAA,aAAA,KAAA,IAAA,GAAA,EAAA,GAAA,IAAA,CAAA,CAAA;AAGA,IAAA,OAAO,MAAM;AACX,MAAA,IAAA;AACA,MAAA,MAAKC,WAAa,GAAA,CAAA,GAAA,GAAA,KAAA,CAAA,OAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,GAAA,CAAA,IAAA,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA;MAClB,IAAM,CAAA;;MAEN,qBAAqB,EAAA,MAAA,CAAA,GAAA,mBAAA,CAAA,WAAA,CAAA,CAAA;AACnBC,MAAAA,IAAAA,CAAAA,cAAgB,EAAA;AAEjB,QAAA,OAAA,IAAA,CAAA;;;AAKD,KAAA,CAAA;;AAIH,CAAA,EAAA;;AAxBsC,EAAlC,IAAA,CAAA,IAAA;;AA2BP,EAASC,MAAAA,QAAAA,GAAAA,IAAAA,CAAAA;EAGP,SAAA,GAAW,QA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