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,5 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_collection = require('./src/collection.js');
exports.COLLECTION_ITEM_SIGN = require_collection.COLLECTION_ITEM_SIGN;
exports.createCollectionWithScope = require_collection.createCollectionWithScope;
@@ -0,0 +1,15 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require__plugin_vue_export_helper = require('../../../_virtual/_plugin-vue_export-helper.js');
const require_collection_item_vue_vue_type_script_lang = require('./collection-item.vue_vue_type_script_lang.js');
let vue = require("vue");
//#region ../../packages/components/collection/src/collection-item.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return (0, vue.renderSlot)(_ctx.$slots, "default");
}
var collection_item_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_collection_item_vue_vue_type_script_lang.default, [["render", _sfc_render]]);
//#endregion
exports.default = collection_item_default;
//# sourceMappingURL=collection-item.js.map
@@ -0,0 +1 @@
{"version":3,"file":"collection-item.js","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":";;;;;;;;4BACU,KAAA,QAAA,UAAA"}
@@ -0,0 +1,12 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
let vue = require("vue");
//#region ../../packages/components/collection/src/collection-item.vue?vue&type=script&lang.ts
var collection_item_vue_vue_type_script_lang_default = (0, vue.defineComponent)({
name: "ElCollectionItem",
inheritAttrs: false
});
//#endregion
exports.default = collection_item_vue_vue_type_script_lang_default;
//# sourceMappingURL=collection-item.vue_vue_type_script_lang.js.map
@@ -0,0 +1 @@
{"version":3,"file":"collection-item.vue_vue_type_script_lang.js","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,gFAA+B;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,60 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_collection = require('./collection2.js');
const require_collection_item = require('./collection-item.js');
let vue = require("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({}, require_collection.default, {
name: COLLECTION_NAME,
setup() {
const collectionRef = (0, vue.ref)();
const itemMap = /* @__PURE__ */ new Map();
const getItems = (() => {
const collectionEl = (0, vue.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));
});
(0, vue.provide)(COLLECTION_INJECTION_KEY, {
itemMap,
getItems,
collectionRef
});
}
}),
ElCollectionItem: Object.assign({}, require_collection_item.default, {
name: COLLECTION_ITEM_NAME,
setup(_, { attrs }) {
const collectionItemRef = (0, vue.ref)();
const collectionInjection = (0, vue.inject)(COLLECTION_INJECTION_KEY, void 0);
(0, vue.provide)(COLLECTION_ITEM_INJECTION_KEY, { collectionItemRef });
(0, vue.onMounted)(() => {
const collectionItemEl = (0, vue.unref)(collectionItemRef);
if (collectionItemEl) collectionInjection.itemMap.set(collectionItemEl, {
ref: collectionItemEl,
...attrs
});
});
(0, vue.onBeforeUnmount)(() => {
const collectionItemEl = (0, vue.unref)(collectionItemRef);
collectionInjection.itemMap.delete(collectionItemEl);
});
}
})
};
};
//#endregion
exports.COLLECTION_ITEM_SIGN = COLLECTION_ITEM_SIGN;
exports.createCollectionWithScope = createCollectionWithScope;
//# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
{"version":3,"file":"collection.js","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,4BAAY;GACjD,MAAM;GACN,QAAQ;IACN,MAAM,8BAAkC;IACxC,MAAM,0BAAmD,IAAI,KAAK;IAClE,MAAM,kBAAkB;KACtB,MAAM,8BAAqB,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,qBAAQ,0BAA0B;KAChC;KACA;KACA;KACD,CAAC;;GAEL,CAAC;EAiCA,kBA/BuB,OAAO,OAAO,EAAE,EAAEC,iCAAgB;GACzD,MAAM;GACN,MAAM,GAAY,EAAE,SAAuB;IACzC,MAAM,kCAAsC;IAC5C,MAAM,sCAA6B,0BAA0B,OAAU;AAEvE,qBAAQ,+BAA+B,EACrC,mBACD,CAAC;AAEF,6BAAgB;KACd,MAAM,kCAAyB,kBAAkB;AACjD,SAAI,iBACF,qBAAoB,QAAQ,IAAI,kBAAkB;MAChD,KAAK;MACL,GAAG;MACJ,CAAC;MAEJ;AAEF,mCAAsB;KACpB,MAAM,kCAAyB,kBAAkB;AACjD,yBAAoB,QAAQ,OAAO,iBAAiB;MACpD;;GAEL,CAAC;EAOD"}
@@ -0,0 +1,9 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
let vue = require("vue");
//#region ../../packages/components/collection/src/collection.vue?vue&type=script&lang.ts
var collection_vue_vue_type_script_lang_default = (0, vue.defineComponent)({ inheritAttrs: false });
//#endregion
exports.default = collection_vue_vue_type_script_lang_default;
//# sourceMappingURL=collection.vue_vue_type_script_lang.js.map
@@ -0,0 +1 @@
{"version":3,"file":"collection.vue_vue_type_script_lang.js","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,2EAA+B,EAC7B,cAAc,OACf,CAAA"}
@@ -0,0 +1,15 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require__plugin_vue_export_helper = require('../../../_virtual/_plugin-vue_export-helper.js');
const require_collection_vue_vue_type_script_lang = require('./collection.vue_vue_type_script_lang.js');
let vue = require("vue");
//#region ../../packages/components/collection/src/collection.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return (0, vue.renderSlot)(_ctx.$slots, "default");
}
var collection_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_collection_vue_vue_type_script_lang.default, [["render", _sfc_render]]);
//#endregion
exports.default = collection_default;
//# sourceMappingURL=collection2.js.map
@@ -0,0 +1 @@
{"version":3,"file":"collection2.js","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":";;;;;;;;4BACU,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 };
@@ -0,0 +1 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });