完全跑通1.0版本

This commit is contained in:
2026-05-26 12:56:03 +08:00
parent 2ece5174a7
commit 93c714a93b
11557 changed files with 1648225 additions and 36 deletions

View File

@@ -0,0 +1,3 @@
import { CollectionItem, ElCollectionInjectionContext, ElCollectionItemInjectionContext } from "./src/tokens.js";
import { COLLECTION_ITEM_SIGN, createCollectionWithScope } from "./src/collection.js";
export { COLLECTION_ITEM_SIGN, CollectionItem, ElCollectionInjectionContext, ElCollectionItemInjectionContext, createCollectionWithScope };

View File

@@ -0,0 +1,2 @@
import { COLLECTION_ITEM_SIGN, createCollectionWithScope } from "./src/collection.mjs";
export { COLLECTION_ITEM_SIGN, createCollectionWithScope };

View File

@@ -0,0 +1,12 @@
import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_export-helper.mjs";
import collection_item_vue_vue_type_script_lang_default from "./collection-item.vue_vue_type_script_lang.mjs";
import { renderSlot } from "vue";
//#region ../../packages/components/collection/src/collection-item.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return renderSlot(_ctx.$slots, "default");
}
var collection_item_default = /* @__PURE__ */ _plugin_vue_export_helper_default(collection_item_vue_vue_type_script_lang_default, [["render", _sfc_render]]);
//#endregion
export { collection_item_default as default };
//# sourceMappingURL=collection-item.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"collection-item.mjs","names":[],"sources":["../../../../../../packages/components/collection/src/collection-item.vue"],"sourcesContent":["<template>\n <slot />\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n name: 'ElCollectionItem',\n inheritAttrs: false,\n})\n</script>\n"],"mappings":";;;;;QACE,WAAQ,KAAA,QAAA,UAAA"}

View File

@@ -0,0 +1,7 @@
import * as _$vue from "vue";
//#region ../../packages/components/collection/src/collection-item.vue.d.ts
declare const _default: typeof __VLS_export;
declare const __VLS_export: _$vue.DefineComponent<{}, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
//#endregion
export { _default as default };

View File

@@ -0,0 +1,10 @@
import { defineComponent } from "vue";
//#region ../../packages/components/collection/src/collection-item.vue?vue&type=script&lang.ts
var collection_item_vue_vue_type_script_lang_default = defineComponent({
name: "ElCollectionItem",
inheritAttrs: false
});
//#endregion
export { collection_item_vue_vue_type_script_lang_default as default };
//# sourceMappingURL=collection-item.vue_vue_type_script_lang.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"collection-item.vue_vue_type_script_lang.mjs","names":[],"sources":["../../../../../../packages/components/collection/src/collection-item.vue"],"sourcesContent":["<template>\n <slot />\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n name: 'ElCollectionItem',\n inheritAttrs: false,\n})\n</script>\n"],"mappings":";;AAOA,IAAA,mDAAe,gBAAgB;CAC7B,MAAM;CACN,cAAc;CACf,CAAA"}

View File

@@ -0,0 +1,46 @@
import { ElCollectionInjectionContext, ElCollectionItemInjectionContext } from "./tokens.js";
import * as _$vue from "vue";
import { InjectionKey, SetupContext } from "vue";
//#region ../../packages/components/collection/src/collection.d.ts
declare const COLLECTION_ITEM_SIGN = "data-el-collection-item";
declare const createCollectionWithScope: (name: string) => {
COLLECTION_INJECTION_KEY: InjectionKey<ElCollectionInjectionContext>;
COLLECTION_ITEM_INJECTION_KEY: InjectionKey<ElCollectionItemInjectionContext>;
ElCollection: {
new (...args: any[]): _$vue.CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, _$vue.PublicProps, {}, true, {}, {}, _$vue.GlobalComponents, _$vue.GlobalDirectives, string, {}, any, _$vue.ComponentProvideOptions, {
P: {};
B: {};
D: {};
C: {};
M: {};
Defaults: {};
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & _$vue.ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, _$vue.GlobalComponents, _$vue.GlobalDirectives, string, _$vue.ComponentProvideOptions> & _$vue.VNodeProps & _$vue.AllowedComponentProps & _$vue.ComponentCustomProps & {
name: string;
setup(): void;
};
ElCollectionItem: {
new (...args: any[]): _$vue.CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, _$vue.PublicProps, {}, true, {}, {}, _$vue.GlobalComponents, _$vue.GlobalDirectives, string, {}, any, _$vue.ComponentProvideOptions, {
P: {};
B: {};
D: {};
C: {};
M: {};
Defaults: {};
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & _$vue.ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, _$vue.GlobalComponents, _$vue.GlobalDirectives, string, _$vue.ComponentProvideOptions> & _$vue.VNodeProps & _$vue.AllowedComponentProps & _$vue.ComponentCustomProps & {
name: string;
setup(_: unknown, {
attrs
}: SetupContext): void;
};
};
//#endregion
export { COLLECTION_ITEM_SIGN, createCollectionWithScope };

View File

@@ -0,0 +1,56 @@
import collection_default from "./collection2.mjs";
import collection_item_default from "./collection-item.mjs";
import { inject, onBeforeUnmount, onMounted, provide, ref, unref } from "vue";
//#region ../../packages/components/collection/src/collection.ts
const COLLECTION_ITEM_SIGN = `data-el-collection-item`;
const createCollectionWithScope = (name) => {
const COLLECTION_NAME = `El${name}Collection`;
const COLLECTION_ITEM_NAME = `${COLLECTION_NAME}Item`;
const COLLECTION_INJECTION_KEY = Symbol(COLLECTION_NAME);
const COLLECTION_ITEM_INJECTION_KEY = Symbol(COLLECTION_ITEM_NAME);
return {
COLLECTION_INJECTION_KEY,
COLLECTION_ITEM_INJECTION_KEY,
ElCollection: Object.assign({}, collection_default, {
name: COLLECTION_NAME,
setup() {
const collectionRef = ref();
const itemMap = /* @__PURE__ */ new Map();
const getItems = (() => {
const collectionEl = unref(collectionRef);
if (!collectionEl) return [];
const orderedNodes = Array.from(collectionEl.querySelectorAll(`[${COLLECTION_ITEM_SIGN}]`));
return [...itemMap.values()].sort((a, b) => orderedNodes.indexOf(a.ref) - orderedNodes.indexOf(b.ref));
});
provide(COLLECTION_INJECTION_KEY, {
itemMap,
getItems,
collectionRef
});
}
}),
ElCollectionItem: Object.assign({}, collection_item_default, {
name: COLLECTION_ITEM_NAME,
setup(_, { attrs }) {
const collectionItemRef = ref();
const collectionInjection = inject(COLLECTION_INJECTION_KEY, void 0);
provide(COLLECTION_ITEM_INJECTION_KEY, { collectionItemRef });
onMounted(() => {
const collectionItemEl = unref(collectionItemRef);
if (collectionItemEl) collectionInjection.itemMap.set(collectionItemEl, {
ref: collectionItemEl,
...attrs
});
});
onBeforeUnmount(() => {
const collectionItemEl = unref(collectionItemRef);
collectionInjection.itemMap.delete(collectionItemEl);
});
}
})
};
};
//#endregion
export { COLLECTION_ITEM_SIGN, createCollectionWithScope };
//# sourceMappingURL=collection.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"collection.mjs","names":["Collection","CollectionItem"],"sources":["../../../../../../packages/components/collection/src/collection.ts"],"sourcesContent":["import { inject, onBeforeUnmount, onMounted, provide, ref, unref } from 'vue'\nimport Collection from './collection.vue'\nimport CollectionItem from './collection-item.vue'\n\nimport type { InjectionKey, SetupContext } from 'vue'\nimport type {\n ElCollectionInjectionContext,\n ElCollectionItemInjectionContext,\n} from './tokens'\n\nexport const COLLECTION_ITEM_SIGN = `data-el-collection-item`\n\n// Make sure the first letter of name is capitalized\nexport const createCollectionWithScope = (name: string) => {\n const COLLECTION_NAME = `El${name}Collection`\n const COLLECTION_ITEM_NAME = `${COLLECTION_NAME}Item`\n const COLLECTION_INJECTION_KEY: InjectionKey<ElCollectionInjectionContext> =\n Symbol(COLLECTION_NAME)\n const COLLECTION_ITEM_INJECTION_KEY: InjectionKey<ElCollectionItemInjectionContext> =\n Symbol(COLLECTION_ITEM_NAME)\n\n const ElCollection = Object.assign({}, Collection, {\n name: COLLECTION_NAME,\n setup() {\n const collectionRef = ref<HTMLElement>()\n const itemMap: ElCollectionInjectionContext['itemMap'] = new Map()\n const getItems = (() => {\n const collectionEl = unref(collectionRef)\n\n if (!collectionEl) return []\n const orderedNodes = Array.from(\n collectionEl.querySelectorAll(`[${COLLECTION_ITEM_SIGN}]`)\n )\n\n const items = [...itemMap.values()]\n\n return items.sort(\n (a, b) => orderedNodes.indexOf(a.ref!) - orderedNodes.indexOf(b.ref!)\n )\n }) as ElCollectionInjectionContext['getItems']\n\n provide(COLLECTION_INJECTION_KEY, {\n itemMap,\n getItems,\n collectionRef,\n })\n },\n })\n\n const ElCollectionItem = Object.assign({}, CollectionItem, {\n name: COLLECTION_ITEM_NAME,\n setup(_: unknown, { attrs }: SetupContext) {\n const collectionItemRef = ref<HTMLElement>()\n const collectionInjection = inject(COLLECTION_INJECTION_KEY, undefined)!\n\n provide(COLLECTION_ITEM_INJECTION_KEY, {\n collectionItemRef,\n })\n\n onMounted(() => {\n const collectionItemEl = unref(collectionItemRef)\n if (collectionItemEl) {\n collectionInjection.itemMap.set(collectionItemEl, {\n ref: collectionItemEl,\n ...attrs,\n })\n }\n })\n\n onBeforeUnmount(() => {\n const collectionItemEl = unref(collectionItemRef)!\n collectionInjection.itemMap.delete(collectionItemEl)\n })\n },\n })\n\n return {\n COLLECTION_INJECTION_KEY,\n COLLECTION_ITEM_INJECTION_KEY,\n ElCollection,\n ElCollectionItem,\n }\n}\n"],"mappings":";;;;AAUA,MAAa,uBAAuB;AAGpC,MAAa,6BAA6B,SAAiB;CACzD,MAAM,kBAAkB,KAAK,KAAK;CAClC,MAAM,uBAAuB,GAAG,gBAAgB;CAChD,MAAM,2BACJ,OAAO,gBAAgB;CACzB,MAAM,gCACJ,OAAO,qBAAqB;CAyD9B,OAAO;EACL;EACA;EACA,cA1DmB,OAAO,OAAO,EAAE,EAAEA,oBAAY;GACjD,MAAM;GACN,QAAQ;IACN,MAAM,gBAAgB,KAAkB;IACxC,MAAM,0BAAmD,IAAI,KAAK;IAClE,MAAM,kBAAkB;KACtB,MAAM,eAAe,MAAM,cAAc;KAEzC,IAAI,CAAC,cAAc,OAAO,EAAE;KAC5B,MAAM,eAAe,MAAM,KACzB,aAAa,iBAAiB,IAAI,qBAAqB,GAAG,CAC3D;KAID,OAAO,CAFQ,GAAG,QAAQ,QAAQ,CAEtB,CAAC,MACV,GAAG,MAAM,aAAa,QAAQ,EAAE,IAAK,GAAG,aAAa,QAAQ,EAAE,IAAK,CACtE;;IAGH,QAAQ,0BAA0B;KAChC;KACA;KACA;KACD,CAAC;;GAEL,CAgCa;EACZ,kBA/BuB,OAAO,OAAO,EAAE,EAAEC,yBAAgB;GACzD,MAAM;GACN,MAAM,GAAY,EAAE,SAAuB;IACzC,MAAM,oBAAoB,KAAkB;IAC5C,MAAM,sBAAsB,OAAO,0BAA0B,KAAA,EAAU;IAEvE,QAAQ,+BAA+B,EACrC,mBACD,CAAC;IAEF,gBAAgB;KACd,MAAM,mBAAmB,MAAM,kBAAkB;KACjD,IAAI,kBACF,oBAAoB,QAAQ,IAAI,kBAAkB;MAChD,KAAK;MACL,GAAG;MACJ,CAAC;MAEJ;IAEF,sBAAsB;KACpB,MAAM,mBAAmB,MAAM,kBAAkB;KACjD,oBAAoB,QAAQ,OAAO,iBAAiB;MACpD;;GAEL,CAMiB;EACjB"}

View File

@@ -0,0 +1,7 @@
import * as _$vue from "vue";
//#region ../../packages/components/collection/src/collection.vue.d.ts
declare const _default: typeof __VLS_export;
declare const __VLS_export: _$vue.DefineComponent<{}, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
//#endregion
export { _default as default };

View File

@@ -0,0 +1,7 @@
import { defineComponent } from "vue";
//#region ../../packages/components/collection/src/collection.vue?vue&type=script&lang.ts
var collection_vue_vue_type_script_lang_default = defineComponent({ inheritAttrs: false });
//#endregion
export { collection_vue_vue_type_script_lang_default as default };
//# sourceMappingURL=collection.vue_vue_type_script_lang.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"collection.vue_vue_type_script_lang.mjs","names":[],"sources":["../../../../../../packages/components/collection/src/collection.vue"],"sourcesContent":["<template>\n <slot />\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n inheritAttrs: false,\n})\n</script>\n"],"mappings":";;AAOA,IAAA,8CAAe,gBAAgB,EAC7B,cAAc,OACf,CAAA"}

View File

@@ -0,0 +1,12 @@
import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_export-helper.mjs";
import collection_vue_vue_type_script_lang_default from "./collection.vue_vue_type_script_lang.mjs";
import { renderSlot } from "vue";
//#region ../../packages/components/collection/src/collection.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return renderSlot(_ctx.$slots, "default");
}
var collection_default = /* @__PURE__ */ _plugin_vue_export_helper_default(collection_vue_vue_type_script_lang_default, [["render", _sfc_render]]);
//#endregion
export { collection_default as default };
//# sourceMappingURL=collection2.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"collection2.mjs","names":[],"sources":["../../../../../../packages/components/collection/src/collection.vue"],"sourcesContent":["<template>\n <slot />\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n inheritAttrs: false,\n})\n</script>\n"],"mappings":";;;;;QACE,WAAQ,KAAA,QAAA,UAAA"}

View File

@@ -0,0 +1,16 @@
import { Ref } from "vue";
//#region ../../packages/components/collection/src/tokens.d.ts
type CollectionItem<T = Record<string, any>> = {
ref: HTMLElement | null;
} & T;
type ElCollectionInjectionContext = {
itemMap: Map<HTMLElement, CollectionItem>;
getItems: <T>() => CollectionItem<T>[];
collectionRef: Ref<HTMLElement | undefined>;
};
type ElCollectionItemInjectionContext = {
collectionItemRef: Ref<HTMLElement | undefined>;
};
//#endregion
export { CollectionItem, ElCollectionInjectionContext, ElCollectionItemInjectionContext };