feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
@@ -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 };
@@ -0,0 +1,3 @@
import { COLLECTION_ITEM_SIGN, createCollectionWithScope } from "./src/collection.mjs";
export { COLLECTION_ITEM_SIGN, createCollectionWithScope };
@@ -0,0 +1,13 @@
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
@@ -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"}
@@ -0,0 +1,11 @@
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
@@ -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,uDAAe,gBAAgB;CAC7B,MAAM;CACN,cAAc;CACf,CAAA"}
@@ -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 };
@@ -0,0 +1,57 @@
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
@@ -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;AAyD9B,QAAO;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;AAEzC,SAAI,CAAC,aAAc,QAAO,EAAE;KAC5B,MAAM,eAAe,MAAM,KACzB,aAAa,iBAAiB,IAAI,qBAAqB,GAAG,CAC3D;AAID,YAFc,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAEtB,MACV,GAAG,MAAM,aAAa,QAAQ,EAAE,IAAK,GAAG,aAAa,QAAQ,EAAE,IAAK,CACtE;;AAGH,YAAQ,0BAA0B;KAChC;KACA;KACA;KACD,CAAC;;GAEL,CAAC;EAiCA,kBA/BuB,OAAO,OAAO,EAAE,EAAEC,yBAAgB;GACzD,MAAM;GACN,MAAM,GAAY,EAAE,SAAuB;IACzC,MAAM,oBAAoB,KAAkB;IAC5C,MAAM,sBAAsB,OAAO,0BAA0B,OAAU;AAEvE,YAAQ,+BAA+B,EACrC,mBACD,CAAC;AAEF,oBAAgB;KACd,MAAM,mBAAmB,MAAM,kBAAkB;AACjD,SAAI,iBACF,qBAAoB,QAAQ,IAAI,kBAAkB;MAChD,KAAK;MACL,GAAG;MACJ,CAAC;MAEJ;AAEF,0BAAsB;KACpB,MAAM,mBAAmB,MAAM,kBAAkB;AACjD,yBAAoB,QAAQ,OAAO,iBAAiB;MACpD;;GAEL,CAAC;EAOD"}
@@ -0,0 +1,8 @@
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
@@ -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,kDAAe,gBAAgB,EAC7B,cAAc,OACf,CAAA"}
@@ -0,0 +1,13 @@
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
@@ -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"}
@@ -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 };