mortise-tenon-design 0.1.11 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/component-neo/index.mjs +11 -0
- package/es/components/component-neo/index.mjs.map +1 -0
- package/es/components/component-neo/src/component-neo.vue.mjs +34 -0
- package/es/components/component-neo/src/component-neo.vue.mjs.map +1 -0
- package/es/components/component-neo/src/component-neo.vue2.mjs +5 -0
- package/es/components/component-neo/src/component-neo.vue2.mjs.map +1 -0
- package/es/components/component-neo/src/hooks/use-component-neo.mjs +31 -0
- package/es/components/component-neo/src/hooks/use-component-neo.mjs.map +1 -0
- package/es/components/component-neo/src/hooks/use-component-state.mjs +34 -0
- package/es/components/component-neo/src/hooks/use-component-state.mjs.map +1 -0
- package/es/components/expand/index.mjs.map +1 -1
- package/es/components/expand/src/expand.vue2.mjs +4 -4
- package/es/components/sort/index.mjs +9 -0
- package/es/components/sort/index.mjs.map +1 -0
- package/es/components/sort/src/sort.mjs +54 -0
- package/es/components/sort/src/sort.mjs.map +1 -0
- package/es/components/table/index.mjs +10 -0
- package/es/components/table/index.mjs.map +1 -0
- package/es/components/table/src/table.css +1 -0
- package/es/components/table/src/table.vue.mjs +8 -0
- package/es/components/table/src/table.vue.mjs.map +1 -0
- package/es/components/table/src/table.vue2.mjs +100 -0
- package/es/components/table/src/table.vue2.mjs.map +1 -0
- package/es/index.mjs +10 -2
- package/es/index.mjs.map +1 -1
- package/lib/components/component-neo/index.js +2 -0
- package/lib/components/component-neo/index.js.map +1 -0
- package/lib/components/component-neo/src/component-neo.vue.js +2 -0
- package/lib/components/component-neo/src/component-neo.vue.js.map +1 -0
- package/lib/components/component-neo/src/component-neo.vue2.js +2 -0
- package/lib/components/component-neo/src/component-neo.vue2.js.map +1 -0
- package/lib/components/component-neo/src/hooks/use-component-neo.js +2 -0
- package/lib/components/component-neo/src/hooks/use-component-neo.js.map +1 -0
- package/lib/components/component-neo/src/hooks/use-component-state.js +2 -0
- package/lib/components/component-neo/src/hooks/use-component-state.js.map +1 -0
- package/lib/components/expand/index.js.map +1 -1
- package/lib/components/sort/index.js +2 -0
- package/lib/components/sort/index.js.map +1 -0
- package/lib/components/sort/src/sort.js +2 -0
- package/lib/components/sort/src/sort.js.map +1 -0
- package/lib/components/table/index.js +3 -0
- package/lib/components/table/index.js.map +1 -0
- package/lib/components/table/src/table.css +1 -0
- package/lib/components/table/src/table.vue.js +2 -0
- package/lib/components/table/src/table.vue.js.map +1 -0
- package/lib/components/table/src/table.vue2.js +2 -0
- package/lib/components/table/src/table.vue2.js.map +1 -0
- package/lib/index.js +1 -1
- package/package.json +7 -3
- package/types/component-neo/index.d.ts +50 -0
- package/types/component-neo/src/component-neo.d.ts +8 -0
- package/types/component-neo/src/component-neo.vue.d.ts +35 -0
- package/types/component-neo/src/hooks/use-component-neo.d.ts +8 -0
- package/types/component-neo/src/hooks/use-component-state.d.ts +22 -0
- package/types/expand/index.d.ts +7 -4
- package/types/expand/src/expand.vue.d.ts +5 -2
- package/types/index.d.ts +3 -0
- package/types/sort/index.d.ts +25 -0
- package/types/sort/src/sort.d.ts +36 -0
- package/types/table/index.d.ts +48 -0
- package/types/table/src/table.d.ts +38 -0
- package/types/table/src/table.vue.d.ts +42 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
import o from "./src/component-neo.vue.mjs";
|
2
|
+
import "vue";
|
3
|
+
import "./src/hooks/use-component-state.mjs";
|
4
|
+
o.install = (m) => {
|
5
|
+
o.name && m.component(o.name, o);
|
6
|
+
};
|
7
|
+
const i = o;
|
8
|
+
export {
|
9
|
+
i as MtComponentNeo
|
10
|
+
};
|
11
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/component-neo/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport ComponentNeo from './src/component-neo.vue';\r\n\r\nComponentNeo.install = (app: App): void => {\r\n if (ComponentNeo.name) {\r\n app.component(ComponentNeo.name, ComponentNeo);\r\n }\r\n};\r\n\r\nexport const MtComponentNeo = ComponentNeo;\r\n\r\nexport * from './src/component-neo.vue';\r\nexport * from './src/hooks/use-component-neo';\r\n"],"names":["ComponentNeo","app","MtComponentNeo"],"mappings":";;;AAGAA,EAAa,UAAU,CAACC,MAAmB;AACzC,EAAID,EAAa,QACXC,EAAA,UAAUD,EAAa,MAAMA,CAAY;AAEjD;AAEO,MAAME,IAAiBF;"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { defineComponent as N, useAttrs as g, computed as n, unref as _, h as l, Comment as h, watch as k, nextTick as w, renderSlot as x, createBlock as I, openBlock as b, resolveDynamicComponent as j } from "vue";
|
2
|
+
import { useComponentState as q } from "./hooks/use-component-state.mjs";
|
3
|
+
const S = /* @__PURE__ */ N({
|
4
|
+
name: "MtComponentNeo",
|
5
|
+
inheritAttrs: !1,
|
6
|
+
__name: "component-neo",
|
7
|
+
props: {
|
8
|
+
uniqueId: { default: "" },
|
9
|
+
is: {}
|
10
|
+
},
|
11
|
+
emits: ["toggleComponent"],
|
12
|
+
setup(i, { expose: v, emit: f }) {
|
13
|
+
const s = i, d = f, { initComponent: C } = q(), { componentRef: a, componentNeo: y, componentAttrs: m } = C(s.uniqueId), c = (t) => a.value = t, A = g(), u = n(() => {
|
14
|
+
const t = {};
|
15
|
+
for (const o in m.value)
|
16
|
+
typeof m.value[o] < "u" && (t[o] = _(m.value[o]));
|
17
|
+
return Object.assign(t, A);
|
18
|
+
}), e = n(() => y.value || s.is), p = n(() => e.value ? l(e.value, u.value) : l(h, "componentNeo is empty")), r = n(() => typeof e.value == "object" && "name" in e.value ? e.value.name : void 0);
|
19
|
+
return k(e, async () => {
|
20
|
+
await w(), d("toggleComponent", r.value, a.value);
|
21
|
+
}), v({ componentRef: a }), (t, o) => x(t.$slots, "default", {
|
22
|
+
Component: p.value,
|
23
|
+
compRef: c,
|
24
|
+
attrs: u.value,
|
25
|
+
compName: r.value
|
26
|
+
}, () => [
|
27
|
+
(b(), I(j(p.value), { ref: c }))
|
28
|
+
]);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
export {
|
32
|
+
S as default
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=component-neo.vue.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"component-neo.vue.mjs","sources":["../../../../../../packages/components/component-neo/src/component-neo.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { ComponentNeoProps } from './component-neo';\r\nimport { Comment, computed, h, nextTick, unref, useAttrs, watch } from 'vue';\r\nimport { useComponentState } from './hooks/use-component-state';\r\n\r\ndefineOptions({ name: 'MtComponentNeo', inheritAttrs: false });\r\n\r\nconst props = withDefaults(\r\n defineProps<ComponentNeoProps>(),\r\n { uniqueId: '', onToggle: () => { } },\r\n);\r\n\r\nconst emit = defineEmits<{\r\n (e: 'toggleComponent', name?: string, ref?: any): void\r\n}>();\r\n\r\nconst { initComponent } = useComponentState();\r\nconst { componentRef, componentNeo, componentAttrs } = initComponent(props.uniqueId);\r\nconst compRef = (el: Element) => componentRef.value = el;\r\n\r\nconst commonAttrs = useAttrs();\r\n/** 结合注入的属性和公共属性 */\r\nconst compAttrs = computed(() => {\r\n const newAttrs: Record<string, any> = {};\r\n // 仅传入有值的属性\r\n for (const key in componentAttrs.value) {\r\n if (typeof componentAttrs.value[key] !== 'undefined') {\r\n newAttrs[key] = unref(componentAttrs.value[key]); // 支持ref数据转入\r\n }\r\n }\r\n return Object.assign(newAttrs, commonAttrs);\r\n});\r\n\r\nconst compInstance = computed(() => componentNeo.value || props.is);\r\n\r\nconst compVNode = computed(() => {\r\n return !compInstance.value ? h(Comment, 'componentNeo is empty') : h(compInstance.value, compAttrs.value);\r\n});\r\n\r\nconst compName = computed(() => {\r\n return typeof compInstance.value === 'object' && 'name' in compInstance.value ? compInstance.value.name : undefined;\r\n});\r\n\r\n// 监听组件切换,触发回调\r\nwatch(compInstance, async () => {\r\n await nextTick();\r\n emit('toggleComponent', compName.value, componentRef.value);\r\n});\r\n\r\ndefineExpose({ componentRef });\r\n</script>\r\n\r\n<template>\r\n <!-- eslint-disable-next-line vue/attribute-hyphenation -->\r\n <slot :Component=\"compVNode\" :compRef=\"compRef\" :attrs=\"compAttrs\" :compName=\"compName\">\r\n <component :is=\"compVNode\" :ref=\"compRef\" />\r\n </slot>\r\n</template>\r\n"],"names":["props","__props","emit","__emit","initComponent","useComponentState","componentRef","componentNeo","componentAttrs","compRef","el","commonAttrs","useAttrs","compAttrs","computed","newAttrs","key","unref","compInstance","compVNode","h","Comment","compName","watch","nextTick","__expose"],"mappings":";;;;;;;;;;;;AAOA,UAAMA,IAAQC,GAKRC,IAAOC,GAIP,EAAE,eAAAC,EAAc,IAAIC,EAAkB,GACtC,EAAE,cAAAC,GAAc,cAAAC,GAAc,gBAAAC,EAAmB,IAAAJ,EAAcJ,EAAM,QAAQ,GAC7ES,IAAU,CAACC,MAAgBJ,EAAa,QAAQI,GAEhDC,IAAcC,EAAS,GAEvBC,IAAYC,EAAS,MAAM;AAC/B,YAAMC,IAAgC,CAAC;AAE5B,iBAAAC,KAAOR,EAAe;AAC/B,QAAI,OAAOA,EAAe,MAAMQ,CAAG,IAAM,QACvCD,EAASC,CAAG,IAAIC,EAAMT,EAAe,MAAMQ,CAAG,CAAC;AAG5C,aAAA,OAAO,OAAOD,GAAUJ,CAAW;AAAA,IAAA,CAC3C,GAEKO,IAAeJ,EAAS,MAAMP,EAAa,SAASP,EAAM,EAAE,GAE5DmB,IAAYL,EAAS,MACjBI,EAAa,QAA8CE,EAAEF,EAAa,OAAOL,EAAU,KAAK,IAA3EO,EAAEC,GAAS,uBAAuB,CAChE,GAEKC,IAAWR,EAAS,MACjB,OAAOI,EAAa,SAAU,YAAY,UAAUA,EAAa,QAAQA,EAAa,MAAM,OAAO,MAC3G;AAGD,WAAAK,EAAML,GAAc,YAAY;AAC9B,YAAMM,EAAS,GACftB,EAAK,mBAAmBoB,EAAS,OAAOhB,EAAa,KAAK;AAAA,IAAA,CAC3D,GAEYmB,EAAA,EAAE,cAAAnB,GAAc;;;;;;;;;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"component-neo.vue2.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { nextTick as m } from "vue";
|
2
|
+
import { useComponentState as u } from "./use-component-state.mjs";
|
3
|
+
function d(r = "") {
|
4
|
+
const { setComponent: i, getComponent: s } = u();
|
5
|
+
async function f(t, c) {
|
6
|
+
var l;
|
7
|
+
try {
|
8
|
+
const a = typeof t == "function" ? (await t()).default : t, n = {};
|
9
|
+
for (let e in c) {
|
10
|
+
const o = c[e];
|
11
|
+
e.startsWith("vModel:") ? (e = e.replace("vModel:", ""), n[e] = o, n[`onUpdate:${e}`] = (p) => {
|
12
|
+
"value" in o && (o.value = p);
|
13
|
+
}) : n[e] = o;
|
14
|
+
}
|
15
|
+
return i(r, a, n), await m(), (l = s(r)) == null ? void 0 : l.Instance.value;
|
16
|
+
} catch (a) {
|
17
|
+
console.error(a);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return {
|
21
|
+
getComponentRef: () => {
|
22
|
+
var t;
|
23
|
+
return (t = s(r)) == null ? void 0 : t.Instance.value;
|
24
|
+
},
|
25
|
+
toggleComponent: f
|
26
|
+
};
|
27
|
+
}
|
28
|
+
export {
|
29
|
+
d as useComponentNeo
|
30
|
+
};
|
31
|
+
//# sourceMappingURL=use-component-neo.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-component-neo.mjs","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-neo.ts"],"sourcesContent":["import type { InstanceComponent } from '../component-neo';\r\nimport { nextTick, type VNode } from 'vue';\r\nimport { useComponentState } from './use-component-state';\r\n\r\nexport type ImportComponentFn = () => Promise<Record<string, any>>;\r\nexport type DynamicComponent = InstanceComponent | ImportComponentFn | VNode;\r\n\r\nexport function useComponentNeo(uniqueId = '') {\r\n const { setComponent, getComponent } = useComponentState();\r\n\r\n /**\r\n * 切换渲染的组件\r\n * @param comp 组件,可传入两种类型,1.直接函数格式返回import动态导入 2.组件类型\r\n * @param attrs 组件属性,可使用`on事件`方式添加事件方法,属性支持Ref类型进行绑定以实现动态变化, 支持通过{'vModal:value': value}方式双向绑定数据\r\n */\r\n async function toggleComponent(comp: DynamicComponent, attrs?: Record<string, any>) {\r\n try {\r\n const renderComp = typeof comp === 'function' ? (await (comp as ImportComponentFn)()).default : comp;\r\n const renderAttrs: Record<string, any> = {};\r\n for (let key in attrs) {\r\n const bindValue = attrs[key];\r\n // 兼容vModal\r\n if (key.startsWith('vModel:')) {\r\n key = key.replace('vModel:', '');\r\n renderAttrs[key] = bindValue;\r\n renderAttrs[`onUpdate:${key}`] = (value: any) => {\r\n if ('value' in bindValue) {\r\n bindValue.value = value;\r\n }\r\n };\r\n }\r\n else {\r\n renderAttrs[key] = bindValue;\r\n }\r\n }\r\n setComponent(uniqueId, renderComp, renderAttrs);\r\n await nextTick();\r\n return getComponent(uniqueId)?.Instance.value;\r\n }\r\n catch (e) {\r\n console.error(e);\r\n }\r\n }\r\n return {\r\n getComponentRef: () => getComponent(uniqueId)?.Instance.value,\r\n toggleComponent,\r\n };\r\n};\r\n"],"names":["useComponentNeo","uniqueId","setComponent","getComponent","useComponentState","toggleComponent","comp","attrs","renderComp","renderAttrs","key","bindValue","value","nextTick","_a","e"],"mappings":";;AAOgB,SAAAA,EAAgBC,IAAW,IAAI;AAC7C,QAAM,EAAE,cAAAC,GAAc,cAAAC,EAAa,IAAIC,EAAkB;AAO1C,iBAAAC,EAAgBC,GAAwBC,GAA6B;;AAC9E,QAAA;AACF,YAAMC,IAAa,OAAOF,KAAS,cAAc,MAAOA,EAAA,GAA8B,UAAUA,GAC1FG,IAAmC,CAAC;AAC1C,eAASC,KAAOH,GAAO;AACf,cAAAI,IAAYJ,EAAMG,CAAG;AAEvB,QAAAA,EAAI,WAAW,SAAS,KACpBA,IAAAA,EAAI,QAAQ,WAAW,EAAE,GAC/BD,EAAYC,CAAG,IAAIC,GACnBF,EAAY,YAAYC,CAAG,EAAE,IAAI,CAACE,MAAe;AAC/C,UAAI,WAAWD,MACbA,EAAU,QAAQC;AAAA,QAEtB,KAGAH,EAAYC,CAAG,IAAIC;AAAA,MACrB;AAEW,aAAAT,EAAAD,GAAUO,GAAYC,CAAW,GAC9C,MAAMI,EAAS,IACRC,IAAAX,EAAaF,CAAQ,MAArB,gBAAAa,EAAwB,SAAS;AAAA,aAEnCC,GAAG;AACR,cAAQ,MAAMA,CAAC;AAAA,IAAA;AAAA,EACjB;AAEK,SAAA;AAAA,IACL,iBAAiB,MAAA;;AAAM,cAAAD,IAAAX,EAAaF,CAAQ,MAArB,gBAAAa,EAAwB,SAAS;AAAA;AAAA,IACxD,iBAAAT;AAAA,EACF;AACF;"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { createGlobalState as l } from "@vueuse/core";
|
2
|
+
import { ref as m, shallowRef as i, onBeforeUnmount as u } from "vue";
|
3
|
+
const R = l(() => {
|
4
|
+
const a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
5
|
+
function f(t = "") {
|
6
|
+
let e = n.get(t);
|
7
|
+
e || (e = {
|
8
|
+
Instance: m(),
|
9
|
+
comp: i(),
|
10
|
+
attrs: m({})
|
11
|
+
}, n.set(t, e), u(() => r(t)));
|
12
|
+
const o = a.get(t);
|
13
|
+
return o && (e.comp.value = o.comp, e.attrs.value = o.attrs), {
|
14
|
+
componentRef: e.Instance,
|
15
|
+
componentNeo: e.comp,
|
16
|
+
componentAttrs: e.attrs
|
17
|
+
};
|
18
|
+
}
|
19
|
+
function p(t = "") {
|
20
|
+
return n.get(t);
|
21
|
+
}
|
22
|
+
function r(t = "") {
|
23
|
+
a.delete(t), n.delete(t);
|
24
|
+
}
|
25
|
+
function s(t = "", e, o) {
|
26
|
+
const c = p(t);
|
27
|
+
c && (c.comp.value = e, c.attrs.value = o), a.set(t, { comp: e, attrs: o });
|
28
|
+
}
|
29
|
+
return { initComponent: f, setComponent: s, getComponent: p, removeComponent: r };
|
30
|
+
});
|
31
|
+
export {
|
32
|
+
R as useComponentState
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=use-component-state.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-component-state.mjs","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-state.ts"],"sourcesContent":["import type { InstanceComponent } from '../component-neo';\r\nimport { createGlobalState } from '@vueuse/core';\r\nimport { onBeforeUnmount, ref, type Ref, shallowRef, type ShallowRef, type VNode } from 'vue';\r\n\r\ninterface ComponentRefsType {\r\n /** 实例 */\r\n Instance: Ref<any>\r\n /** 组件 */\r\n comp: ShallowRef<InstanceComponent | VNode | undefined>\r\n /** 属性 */\r\n attrs: Ref<Record<string, any>>\r\n}\r\n\r\n/** 组件状态 */\r\nexport const useComponentState = createGlobalState(() => {\r\n /** 缓存组件数据,组件未实例化时,可先缓存后赋值 */\r\n const dataBufferMap = new Map<string, { comp: InstanceComponent | VNode, attrs: Record<string, any> }>();\r\n /** 实例化后的组件 */\r\n const componentRefsMap = new Map<string, ComponentRefsType>();\r\n /** 初始化组件 */\r\n function initComponent(uniqueId = '') {\r\n let componentRefs = componentRefsMap.get(uniqueId);\r\n if (!componentRefs) {\r\n componentRefs = {\r\n Instance: ref(),\r\n comp: shallowRef<InstanceComponent | VNode>(),\r\n attrs: ref<Record<string, any>>({}),\r\n };\r\n componentRefsMap.set(uniqueId, componentRefs);\r\n onBeforeUnmount(() => removeComponent(uniqueId));\r\n }\r\n // 使用缓存数据初始化数据\r\n const bufferData = dataBufferMap.get(uniqueId);\r\n if (bufferData) {\r\n componentRefs.comp.value = bufferData.comp;\r\n componentRefs.attrs.value = bufferData.attrs;\r\n }\r\n\r\n return {\r\n componentRef: componentRefs.Instance,\r\n componentNeo: componentRefs.comp,\r\n componentAttrs: componentRefs.attrs,\r\n };\r\n }\r\n\r\n /** 获取实例 */\r\n function getComponent(uniqueId = '') {\r\n return componentRefsMap.get(uniqueId);\r\n }\r\n\r\n /** 移除实例 */\r\n function removeComponent(uniqueId = '') {\r\n dataBufferMap.delete(uniqueId);\r\n componentRefsMap.delete(uniqueId);\r\n }\r\n\r\n /** 设置组件数据 */\r\n function setComponent(uniqueId = '', comp: InstanceComponent | VNode, attrs: Record<string, any>) {\r\n const componentRefs = getComponent(uniqueId);\r\n if (componentRefs) {\r\n componentRefs.comp.value = comp;\r\n componentRefs.attrs.value = attrs;\r\n }\r\n dataBufferMap.set(uniqueId, { comp, attrs });\r\n }\r\n\r\n return { initComponent, setComponent, getComponent, removeComponent };\r\n});\r\n"],"names":["useComponentState","createGlobalState","dataBufferMap","componentRefsMap","initComponent","uniqueId","componentRefs","ref","shallowRef","onBeforeUnmount","removeComponent","bufferData","getComponent","setComponent","comp","attrs"],"mappings":";;AAca,MAAAA,IAAoBC,EAAkB,MAAM;AAEjD,QAAAC,wBAAoB,IAA6E,GAEjGC,wBAAuB,IAA+B;AAEnD,WAAAC,EAAcC,IAAW,IAAI;AAChC,QAAAC,IAAgBH,EAAiB,IAAIE,CAAQ;AACjD,IAAKC,MACaA,IAAA;AAAA,MACd,UAAUC,EAAI;AAAA,MACd,MAAMC,EAAsC;AAAA,MAC5C,OAAOD,EAAyB,CAAE,CAAA;AAAA,IACpC,GACiBJ,EAAA,IAAIE,GAAUC,CAAa,GAC5BG,EAAA,MAAMC,EAAgBL,CAAQ,CAAC;AAG3C,UAAAM,IAAaT,EAAc,IAAIG,CAAQ;AAC7C,WAAIM,MACYL,EAAA,KAAK,QAAQK,EAAW,MACxBL,EAAA,MAAM,QAAQK,EAAW,QAGlC;AAAA,MACL,cAAcL,EAAc;AAAA,MAC5B,cAAcA,EAAc;AAAA,MAC5B,gBAAgBA,EAAc;AAAA,IAChC;AAAA,EAAA;AAIO,WAAAM,EAAaP,IAAW,IAAI;AAC5B,WAAAF,EAAiB,IAAIE,CAAQ;AAAA,EAAA;AAI7B,WAAAK,EAAgBL,IAAW,IAAI;AACtC,IAAAH,EAAc,OAAOG,CAAQ,GAC7BF,EAAiB,OAAOE,CAAQ;AAAA,EAAA;AAIlC,WAASQ,EAAaR,IAAW,IAAIS,GAAiCC,GAA4B;AAC1F,UAAAT,IAAgBM,EAAaP,CAAQ;AAC3C,IAAIC,MACFA,EAAc,KAAK,QAAQQ,GAC3BR,EAAc,MAAM,QAAQS,IAE9Bb,EAAc,IAAIG,GAAU,EAAE,MAAAS,GAAM,OAAAC,GAAO;AAAA,EAAA;AAG7C,SAAO,EAAE,eAAAX,GAAe,cAAAS,GAAc,cAAAD,GAAc,iBAAAF,EAAgB;AACtE,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Expand from './src/expand.vue';\r\n\r\nExpand.install = (app: App): void => {\r\n if (Expand.name) {\r\n app.component(Expand.name, Expand);\r\n }\r\n};\r\n\r\nexport const MtExpand = Expand;\r\n"],"names":["Expand","app","MtExpand"],"mappings":";AAGAA,EAAO,UAAU,CAACC,MAAmB;AACnC,EAAID,EAAO,QACLC,EAAA,UAAUD,EAAO,MAAMA,CAAM;AAErC;AAEO,MAAME,IAAWF;"}
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Expand from './src/expand.vue';\r\n\r\nExpand.install = (app: App): void => {\r\n if (Expand.name) {\r\n app.component(Expand.name, Expand);\r\n }\r\n};\r\n\r\nexport const MtExpand = Expand;\r\n\r\nexport * from './src/expand';\r\n"],"names":["Expand","app","MtExpand"],"mappings":";AAGAA,EAAO,UAAU,CAACC,MAAmB;AACnC,EAAID,EAAO,QACLC,EAAA,UAAUD,EAAO,MAAMA,CAAM;AAErC;AAEO,MAAME,IAAWF;"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { defineComponent as m, useCssVars as p, computed as a, ref as i, onMounted as d,
|
1
|
+
import { defineComponent as m, useCssVars as p, computed as a, ref as i, onMounted as d, createElementBlock as f, openBlock as g, normalizeStyle as v, normalizeClass as R, createElementVNode as x, renderSlot as y } from "vue";
|
2
2
|
import { useResizeObserver as z } from "@vueuse/core";
|
3
3
|
import { debounce as _ } from "lodash-es";
|
4
4
|
const B = /* @__PURE__ */ m({
|
@@ -19,9 +19,9 @@ const B = /* @__PURE__ */ m({
|
|
19
19
|
}, t.transitionTime);
|
20
20
|
return z(o, r), d(() => {
|
21
21
|
r();
|
22
|
-
}), (e, h) => (
|
23
|
-
class:
|
24
|
-
style:
|
22
|
+
}), (e, h) => (g(), f("div", {
|
23
|
+
class: R(["mt-expand", { "mt-expand-transition": !!e.transitionTime }]),
|
24
|
+
style: v(c.value)
|
25
25
|
}, [
|
26
26
|
x("div", {
|
27
27
|
ref_key: "contentRef",
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/sort/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Sort from './src/sort';\r\n\r\nSort.install = (app: App): void => {\r\n if (Sort.name) {\r\n app.component(Sort.name, Sort);\r\n }\r\n};\r\n\r\nexport const MtSort = Sort;\r\n\r\nexport * from './src/sort';\r\n"],"names":["Sort","app","MtSort"],"mappings":";AAGAA,EAAK,UAAU,CAACC,MAAmB;AACjC,EAAID,EAAK,QACHC,EAAA,UAAUD,EAAK,MAAMA,CAAI;AAEjC;AAEO,MAAME,IAASF;"}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { defineComponent as l, computed as p } from "vue";
|
2
|
+
const d = l({
|
3
|
+
name: "MtSort",
|
4
|
+
props: {
|
5
|
+
/** 排序配置 */
|
6
|
+
sortList: {
|
7
|
+
type: Array,
|
8
|
+
default: () => []
|
9
|
+
},
|
10
|
+
/** 排序key名 */
|
11
|
+
keyName: {
|
12
|
+
type: String,
|
13
|
+
default: "sort-key"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
setup(t, { slots: s }) {
|
17
|
+
const o = p(() => {
|
18
|
+
var c;
|
19
|
+
const e = ((c = s.default) == null ? void 0 : c.call(s)) || [], n = f(t.keyName, e), r = Array.from(new Set(t.sortList)).map((i) => n[i]).filter(Boolean);
|
20
|
+
return u(t.keyName, e, t.sortList, r);
|
21
|
+
});
|
22
|
+
return () => o.value;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
function f(t, s, o = {}) {
|
26
|
+
return s.forEach((e) => {
|
27
|
+
var r;
|
28
|
+
const n = (r = e.props) == null ? void 0 : r[t];
|
29
|
+
if (n) {
|
30
|
+
o[n] ? console.warn(`<mt-sort-space> ${t}: ${n} repeat`) : o[n] = e;
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
Array.isArray(e.children) && f(t, e.children, o);
|
34
|
+
}), o;
|
35
|
+
}
|
36
|
+
function u(t, s, o, e) {
|
37
|
+
const n = [];
|
38
|
+
return s.forEach((r) => {
|
39
|
+
var i;
|
40
|
+
const c = (i = r.props) == null ? void 0 : i[t];
|
41
|
+
if (c && o.includes(c)) {
|
42
|
+
const a = e.shift();
|
43
|
+
if (a) {
|
44
|
+
n.push(a);
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
Array.isArray(r.children) && (r = { ...r }, r.children = u(t, r.children, o, e)), n.push(r);
|
49
|
+
}), n;
|
50
|
+
}
|
51
|
+
export {
|
52
|
+
d as default
|
53
|
+
};
|
54
|
+
//# sourceMappingURL=sort.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sort.mjs","sources":["../../../../../../packages/components/sort/src/sort.ts"],"sourcesContent":["import type { PropType, VNode } from 'vue';\r\nimport { computed, defineComponent } from 'vue';\r\n\r\nexport interface SortSpaceProps {\r\n /** 排序配置 */\r\n sortList?: (string | number)[]\r\n /** 排序key名 */\r\n keyName?: string\r\n}\r\n\r\nexport default defineComponent({\r\n name: 'MtSort',\r\n props: {\r\n /** 排序配置 */\r\n sortList: {\r\n type: Array as PropType<(string | number)[]>,\r\n default: () => [],\r\n },\r\n /** 排序key名 */\r\n keyName: {\r\n type: String,\r\n default: 'sort-key',\r\n },\r\n },\r\n setup(props, { slots }) {\r\n const renderVNodes = computed(() => {\r\n const vNodeList = slots.default?.() || [];\r\n const sortVNodeMap = getVNodeMap(props.keyName, vNodeList);\r\n const sortVNodeList = Array.from(new Set(props.sortList)).map(key => sortVNodeMap[key]).filter(Boolean);\r\n return sortDefaultVNodes(props.keyName, vNodeList, props.sortList, sortVNodeList);\r\n });\r\n\r\n return () => renderVNodes.value;\r\n },\r\n});\r\n\r\n/** 获取插槽中需要排序的节点 */\r\nfunction getVNodeMap(keyName: string, vNodeList: VNode[], vNodeMap: Record<(string | number), VNode> = {}) {\r\n vNodeList.forEach((item) => {\r\n const sortKey = item.props?.[keyName];\r\n if (sortKey) {\r\n if (vNodeMap[sortKey]) {\r\n console.warn(`<mt-sort-space> ${keyName}: ${sortKey} repeat`);\r\n }\r\n else {\r\n vNodeMap[sortKey] = item;\r\n }\r\n return;\r\n }\r\n if (Array.isArray(item.children)) {\r\n getVNodeMap(keyName, item.children as VNode[], vNodeMap);\r\n }\r\n });\r\n return vNodeMap;\r\n}\r\n\r\n/** 根据排序后的节点跟换位置 */\r\nfunction sortDefaultVNodes(keyName: string, vNodeList: VNode[], sortList: (string | number)[], sortVNodeList: VNode[]) {\r\n const newList: VNode[] = [];\r\n vNodeList.forEach((vNode) => {\r\n const sortKey = vNode.props?.[keyName];\r\n if (sortKey && sortList.includes(sortKey)) {\r\n const sortVNode = sortVNodeList.shift();\r\n if (sortVNode) {\r\n newList.push(sortVNode);\r\n return;\r\n }\r\n }\r\n if (Array.isArray(vNode.children)) {\r\n vNode = { ...vNode }; // 避免修改原节点数据\r\n vNode.children = sortDefaultVNodes(keyName, vNode.children as VNode[], sortList, sortVNodeList);\r\n }\r\n newList.push(vNode);\r\n });\r\n return newList;\r\n}\r\n"],"names":["Sort","defineComponent","props","slots","renderVNodes","computed","vNodeList","_a","sortVNodeMap","getVNodeMap","sortVNodeList","key","sortDefaultVNodes","keyName","vNodeMap","item","sortKey","sortList","newList","vNode","sortVNode"],"mappings":";AAUA,MAAAA,IAAeC,EAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,IAEL,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS,MAAM,CAAA;AAAA,IACjB;AAAA;AAAA,IAEA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,EAEb;AAAA,EACA,MAAMC,GAAO,EAAE,OAAAC,KAAS;AAChB,UAAAC,IAAeC,EAAS,MAAM;;AAClC,YAAMC,MAAYC,IAAAJ,EAAM,YAAN,gBAAAI,EAAA,KAAAJ,OAAqB,CAAC,GAClCK,IAAeC,EAAYP,EAAM,SAASI,CAAS,GACnDI,IAAgB,MAAM,KAAK,IAAI,IAAIR,EAAM,QAAQ,CAAC,EAAE,IAAI,OAAOM,EAAaG,CAAG,CAAC,EAAE,OAAO,OAAO;AACtG,aAAOC,EAAkBV,EAAM,SAASI,GAAWJ,EAAM,UAAUQ,CAAa;AAAA,IAAA,CACjF;AAED,WAAO,MAAMN,EAAa;AAAA,EAAA;AAE9B,CAAC;AAGD,SAASK,EAAYI,GAAiBP,GAAoBQ,IAA6C,CAAA,GAAI;AAC/F,SAAAR,EAAA,QAAQ,CAACS,MAAS;;AACpB,UAAAC,KAAUT,IAAAQ,EAAK,UAAL,gBAAAR,EAAaM;AAC7B,QAAIG,GAAS;AACP,MAAAF,EAASE,CAAO,IAClB,QAAQ,KAAK,mBAAmBH,CAAO,KAAKG,CAAO,SAAS,IAG5DF,EAASE,CAAO,IAAID;AAEtB;AAAA,IAAA;AAEF,IAAI,MAAM,QAAQA,EAAK,QAAQ,KACjBN,EAAAI,GAASE,EAAK,UAAqBD,CAAQ;AAAA,EACzD,CACD,GACMA;AACT;AAGA,SAASF,EAAkBC,GAAiBP,GAAoBW,GAA+BP,GAAwB;AACrH,QAAMQ,IAAmB,CAAC;AAChB,SAAAZ,EAAA,QAAQ,CAACa,MAAU;;AACrB,UAAAH,KAAUT,IAAAY,EAAM,UAAN,gBAAAZ,EAAcM;AAC9B,QAAIG,KAAWC,EAAS,SAASD,CAAO,GAAG;AACnC,YAAAI,IAAYV,EAAc,MAAM;AACtC,UAAIU,GAAW;AACb,QAAAF,EAAQ,KAAKE,CAAS;AACtB;AAAA,MAAA;AAAA,IACF;AAEF,IAAI,MAAM,QAAQD,EAAM,QAAQ,MACtBA,IAAA,EAAE,GAAGA,EAAM,GACnBA,EAAM,WAAWP,EAAkBC,GAASM,EAAM,UAAqBF,GAAUP,CAAa,IAEhGQ,EAAQ,KAAKC,CAAK;AAAA,EAAA,CACnB,GACMD;AACT;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/table/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Table from './src/table.vue';\r\n\r\nTable.install = (app: App): void => {\r\n if (Table.name) {\r\n app.component(Table.name, Table);\r\n }\r\n};\r\n\r\nexport const MtTable = Table;\r\n\r\nexport * from './src/table';\r\n"],"names":["Table","app","MtTable"],"mappings":";AAGAA,EAAM,UAAU,CAACC,MAAmB;AAClC,EAAID,EAAM,QACJC,EAAA,UAAUD,EAAM,MAAMA,CAAK;AAEnC;AAEO,MAAME,IAAUF;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
.mt-table[data-v-46d3894f]{width:100%;max-width:100%;border-spacing:0;border-collapse:collapse}.mt-table thead tr th[data-v-46d3894f]{padding:8px 16px;border:1px #f0f0f0 solid}.mt-table tbody tr td[data-v-46d3894f]{padding:16px;border:1px #f0f0f0 solid}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table.vue.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import { defineComponent as M, computed as i, createElementBlock as o, openBlock as u, createElementVNode as v, Fragment as p, renderList as d, normalizeStyle as m, renderSlot as _, createTextVNode as k, toDisplayString as b } from "vue";
|
2
|
+
const D = { class: "mt-table" }, E = ["colspan", "rowspan"], N = ["colspan", "rowspan"], T = /* @__PURE__ */ M({
|
3
|
+
name: "MtTable",
|
4
|
+
__name: "table",
|
5
|
+
props: {
|
6
|
+
data: { default: () => [] },
|
7
|
+
config: { default: () => [] }
|
8
|
+
},
|
9
|
+
setup($) {
|
10
|
+
const S = $, h = i(() => S.config.map((t) => ({ ...t, columns: t.columns.filter((s) => s.title) }))), y = i(() => S.config.map((t) => ({ ...t, columns: t.columns.filter((s) => s.dataKey) }))), B = i(() => {
|
11
|
+
const t = h.value.map((a) => a.columns.reduce((e, n) => {
|
12
|
+
var l;
|
13
|
+
return e + (((l = n.head) == null ? void 0 : l.colSpan) || 1);
|
14
|
+
}, 0)), s = y.value.map((a) => a.columns.reduce((e, n) => {
|
15
|
+
var l;
|
16
|
+
return e + (((l = n.cell) == null ? void 0 : l.colSpan) || 1);
|
17
|
+
}, 0));
|
18
|
+
return Math.max(...t, ...s);
|
19
|
+
}), K = i(() => {
|
20
|
+
const t = h.value.map((s) => s.columns.map((a) => {
|
21
|
+
var e;
|
22
|
+
return ((e = a.head) == null ? void 0 : e.colSpan) || 0;
|
23
|
+
}));
|
24
|
+
return f(t);
|
25
|
+
}), L = i(() => {
|
26
|
+
const t = y.value.map((s) => s.columns.map((a) => {
|
27
|
+
var e;
|
28
|
+
return ((e = a.cell) == null ? void 0 : e.colSpan) || 0;
|
29
|
+
}));
|
30
|
+
return f(t);
|
31
|
+
});
|
32
|
+
function f(t) {
|
33
|
+
return t.map((s) => {
|
34
|
+
const a = s.filter(Boolean), e = a.reduce((r, c) => r + c, 0);
|
35
|
+
let n = s.length - a.length, l = B.value - e;
|
36
|
+
return s.map((r) => (!r && l > 0 && (r = Math.ceil(l / n), n--, l -= r), r));
|
37
|
+
});
|
38
|
+
}
|
39
|
+
return (t, s) => (u(), o("table", D, [
|
40
|
+
v("thead", null, [
|
41
|
+
(u(!0), o(p, null, d(h.value, (a, e) => (u(), o("tr", {
|
42
|
+
key: e,
|
43
|
+
style: m(a.headStyle)
|
44
|
+
}, [
|
45
|
+
(u(!0), o(p, null, d(a.columns, (n, l) => {
|
46
|
+
var r, c;
|
47
|
+
return u(), o("th", {
|
48
|
+
key: `${n.title}-${l}`,
|
49
|
+
colspan: K.value[e][l],
|
50
|
+
rowspan: (r = n.head) == null ? void 0 : r.rowSpan,
|
51
|
+
style: m((c = n.head) == null ? void 0 : c.style)
|
52
|
+
}, [
|
53
|
+
_(t.$slots, "header", {
|
54
|
+
column: n,
|
55
|
+
columnIndex: l,
|
56
|
+
row: a,
|
57
|
+
rowIndex: e
|
58
|
+
}, () => [
|
59
|
+
k(b(n.title), 1)
|
60
|
+
], !0)
|
61
|
+
], 12, E);
|
62
|
+
}), 128))
|
63
|
+
], 4))), 128))
|
64
|
+
]),
|
65
|
+
v("tbody", null, [
|
66
|
+
(u(!0), o(p, null, d(t.data, (a, e) => (u(), o(p, { key: e }, [
|
67
|
+
(u(!0), o(p, null, d(y.value, (n, l) => (u(), o("tr", {
|
68
|
+
key: l,
|
69
|
+
style: m(n.rowStyle)
|
70
|
+
}, [
|
71
|
+
(u(!0), o(p, null, d(n.columns, (r, c) => {
|
72
|
+
var C, g;
|
73
|
+
return u(), o("td", {
|
74
|
+
key: `${r.dataKey}-${c}`,
|
75
|
+
colspan: L.value[l][c],
|
76
|
+
rowspan: (C = r.cell) == null ? void 0 : C.rowSpan,
|
77
|
+
style: m((g = r.cell) == null ? void 0 : g.style)
|
78
|
+
}, [
|
79
|
+
_(t.$slots, "cell", {
|
80
|
+
column: r,
|
81
|
+
columnIndex: c,
|
82
|
+
dataIndex: e,
|
83
|
+
record: a,
|
84
|
+
row: n,
|
85
|
+
rowIndex: l
|
86
|
+
}, () => [
|
87
|
+
k(b(a[r.dataKey]), 1)
|
88
|
+
], !0)
|
89
|
+
], 12, N);
|
90
|
+
}), 128))
|
91
|
+
], 4))), 128))
|
92
|
+
], 64))), 128))
|
93
|
+
])
|
94
|
+
]));
|
95
|
+
}
|
96
|
+
});
|
97
|
+
export {
|
98
|
+
T as default
|
99
|
+
};
|
100
|
+
//# sourceMappingURL=table.vue2.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table.vue2.mjs","sources":["../../../../../../packages/components/table/src/table.vue"],"sourcesContent":["<script lang=\"ts\" setup>\r\nimport type { TableProps } from './table';\r\nimport { computed } from 'vue';\r\n\r\ndefineOptions({ name: 'MtTable' });\r\n\r\nconst props = withDefaults(defineProps<TableProps>(), {\r\n data: () => [],\r\n config: () => [],\r\n});\r\n\r\n/** 表头配置 */\r\nconst headConfig = computed(() => {\r\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.title) }));\r\n});\r\n\r\n/** 数据配置 */\r\nconst dataConfig = computed(() => {\r\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.dataKey) }));\r\n});\r\n\r\n/** 最大列数 */\r\nconst maxColSpan = computed(() => {\r\n const handReduce = headConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.head?.colSpan || 1), 0));\r\n const cellReduce = dataConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.cell?.colSpan || 1), 0));\r\n return Math.max(...handReduce, ...cellReduce);\r\n});\r\n\r\n/** 表头列合并 */\r\nconst headColSpan = computed(() => {\r\n const colSpanList = headConfig.value.map(item => item.columns.map(column => column.head?.colSpan || 0));\r\n return getColSpanData(colSpanList);\r\n});\r\n\r\n/** 数据列合并 */\r\nconst dataColSpan = computed(() => {\r\n const colSpanList = dataConfig.value.map(item => item.columns.map(column => column.cell?.colSpan || 0));\r\n return getColSpanData(colSpanList);\r\n});\r\n\r\n/** 获取合并列数组 */\r\nfunction getColSpanData(colSpanList: number[][]) {\r\n return colSpanList.map((columns) => {\r\n const colSpanColumns = columns.filter(Boolean); // 已分配colSpan的列\r\n const beenColSpan = colSpanColumns.reduce((pur, cur) => pur + cur, 0); // 总colSpan\r\n let remainCount = columns.length - colSpanColumns.length; // 剩余未配置colSpan的列数\r\n let remainColSpan = maxColSpan.value - beenColSpan; // 剩余可分配的colSpan\r\n return columns.map((colSpan) => {\r\n if (!colSpan && remainColSpan > 0) {\r\n colSpan = Math.ceil(remainColSpan / remainCount); // 每列平均分配colSpan\r\n remainCount--;\r\n remainColSpan -= colSpan;\r\n }\r\n return colSpan;\r\n });\r\n });\r\n}\r\n</script>\r\n\r\n<template>\r\n <table class=\"mt-table\">\r\n <!-- 表头 -->\r\n <thead>\r\n <tr\r\n v-for=\"(row, rowIndex) in headConfig\"\r\n :key=\"rowIndex\"\r\n :style=\"row.headStyle\"\r\n >\r\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.title}-${columnIndex}`\">\r\n <th\r\n :colspan=\"headColSpan[rowIndex][columnIndex]\"\r\n :rowspan=\"column.head?.rowSpan\"\r\n :style=\"column.head?.style\"\r\n >\r\n <slot\r\n :column=\"column\"\r\n :column-index=\"columnIndex\"\r\n :row=\"row\"\r\n :row-index=\"rowIndex\"\r\n name=\"header\"\r\n >\r\n {{ column.title }}\r\n </slot>\r\n </th>\r\n </template>\r\n </tr>\r\n </thead>\r\n <!-- 表体 -->\r\n <tbody>\r\n <template\r\n v-for=\"(record, dataIndex) in data\"\r\n :key=\"dataIndex\"\r\n >\r\n <tr\r\n v-for=\"(row, rowIndex) in dataConfig\"\r\n :key=\"rowIndex\"\r\n :style=\"row.rowStyle\"\r\n >\r\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.dataKey}-${columnIndex}`\">\r\n <td\r\n :colspan=\"dataColSpan[rowIndex][columnIndex]\"\r\n :rowspan=\"column.cell?.rowSpan\"\r\n :style=\"column.cell?.style\"\r\n >\r\n <slot\r\n :column=\"column\"\r\n :column-index=\"columnIndex\"\r\n :data-index=\"dataIndex\"\r\n name=\"cell\"\r\n :record=\"record\"\r\n :row=\"row\"\r\n :row-index=\"rowIndex\"\r\n >\r\n {{ record[column.dataKey!] }}\r\n </slot>\r\n </td>\r\n </template>\r\n </tr>\r\n </template>\r\n </tbody>\r\n </table>\r\n</template>\r\n\r\n<style lang=\"scss\" scoped>\r\n.mt-table {\r\n width: 100%;\r\n max-width: 100%;\r\n border-spacing: 0;\r\n border-collapse: collapse;\r\n\r\n thead {\r\n tr {\r\n th {\r\n padding: 8px 16px;\r\n border: 1px #f0f0f0 solid;\r\n }\r\n }\r\n }\r\n\r\n tbody {\r\n tr {\r\n td {\r\n padding: 16px;\r\n border: 1px #f0f0f0 solid;\r\n }\r\n }\r\n }\r\n}\r\n</style>\r\n"],"names":["props","__props","headConfig","computed","rowItem","column","dataConfig","maxColSpan","handReduce","item","pre","cur","_a","cellReduce","headColSpan","colSpanList","getColSpanData","dataColSpan","columns","colSpanColumns","beenColSpan","pur","remainCount","remainColSpan","colSpan"],"mappings":";;;;;;;;;AAMA,UAAMA,IAAQC,GAMRC,IAAaC,EAAS,MACnBH,EAAM,OAAO,IAAI,CAAAI,OAAY,EAAE,GAAGA,GAAS,SAASA,EAAQ,QAAQ,OAAO,CAAAC,MAAUA,EAAO,KAAK,IAAI,CAC7G,GAGKC,IAAaH,EAAS,MACnBH,EAAM,OAAO,IAAI,CAAAI,OAAY,EAAE,GAAGA,GAAS,SAASA,EAAQ,QAAQ,OAAO,CAAAC,MAAUA,EAAO,OAAO,IAAI,CAC/G,GAGKE,IAAaJ,EAAS,MAAM;AAChC,YAAMK,IAAaN,EAAW,MAAM,IAAI,CAAAO,MAAQA,EAAK,QAAQ,OAAO,CAACC,GAAKC;;AAAQ,eAAAD,OAAOE,IAAAD,EAAI,SAAJ,gBAAAC,EAAU,YAAW;AAAA,SAAI,CAAC,CAAC,GAC9GC,IAAaP,EAAW,MAAM,IAAI,CAAAG,MAAQA,EAAK,QAAQ,OAAO,CAACC,GAAKC;;AAAQ,eAAAD,OAAOE,IAAAD,EAAI,SAAJ,gBAAAC,EAAU,YAAW;AAAA,SAAI,CAAC,CAAC;AACpH,aAAO,KAAK,IAAI,GAAGJ,GAAY,GAAGK,CAAU;AAAA,IAAA,CAC7C,GAGKC,IAAcX,EAAS,MAAM;AACjC,YAAMY,IAAcb,EAAW,MAAM,IAAI,CAAQO,MAAAA,EAAK,QAAQ,IAAI,CAAUJ,MAAA;;AAAA,iBAAAO,IAAAP,EAAO,SAAP,gBAAAO,EAAa,YAAW;AAAA,OAAC,CAAC;AACtG,aAAOI,EAAeD,CAAW;AAAA,IAAA,CAClC,GAGKE,IAAcd,EAAS,MAAM;AACjC,YAAMY,IAAcT,EAAW,MAAM,IAAI,CAAQG,MAAAA,EAAK,QAAQ,IAAI,CAAUJ,MAAA;;AAAA,iBAAAO,IAAAP,EAAO,SAAP,gBAAAO,EAAa,YAAW;AAAA,OAAC,CAAC;AACtG,aAAOI,EAAeD,CAAW;AAAA,IAAA,CAClC;AAGD,aAASC,EAAeD,GAAyB;AACxC,aAAAA,EAAY,IAAI,CAACG,MAAY;AAC5B,cAAAC,IAAiBD,EAAQ,OAAO,OAAO,GACvCE,IAAcD,EAAe,OAAO,CAACE,GAAKV,MAAQU,IAAMV,GAAK,CAAC;AAChE,YAAAW,IAAcJ,EAAQ,SAASC,EAAe,QAC9CI,IAAgBhB,EAAW,QAAQa;AAChC,eAAAF,EAAQ,IAAI,CAACM,OACd,CAACA,KAAWD,IAAgB,MACpBC,IAAA,KAAK,KAAKD,IAAgBD,CAAW,GAC/CA,KACiBC,KAAAC,IAEZA,EACR;AAAA,MAAA,CACF;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/es/index.mjs
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
-
import {
|
1
|
+
import { MtComponentNeo as e } from "./components/component-neo/index.mjs";
|
2
|
+
import { MtExpand as p } from "./components/expand/index.mjs";
|
3
|
+
import { MtSort as x } from "./components/sort/index.mjs";
|
4
|
+
import { MtTable as n } from "./components/table/index.mjs";
|
5
|
+
import { useComponentNeo as a } from "./components/component-neo/src/hooks/use-component-neo.mjs";
|
2
6
|
export {
|
3
|
-
|
7
|
+
e as MtComponentNeo,
|
8
|
+
p as MtExpand,
|
9
|
+
x as MtSort,
|
10
|
+
n as MtTable,
|
11
|
+
a as useComponentNeo
|
4
12
|
};
|
5
13
|
//# sourceMappingURL=index.mjs.map
|
package/es/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./src/component-neo.vue.js");require("vue");require("./src/hooks/use-component-state.js");e.default.install=t=>{e.default.name&&t.component(e.default.name,e.default)};const o=e.default;exports.MtComponentNeo=o;
|
2
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/component-neo/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport ComponentNeo from './src/component-neo.vue';\r\n\r\nComponentNeo.install = (app: App): void => {\r\n if (ComponentNeo.name) {\r\n app.component(ComponentNeo.name, ComponentNeo);\r\n }\r\n};\r\n\r\nexport const MtComponentNeo = ComponentNeo;\r\n\r\nexport * from './src/component-neo.vue';\r\nexport * from './src/hooks/use-component-neo';\r\n"],"names":["ComponentNeo","app","MtComponentNeo"],"mappings":"2LAGAA,EAAAA,QAAa,QAAWC,GAAmB,CACrCD,EAAAA,QAAa,MACXC,EAAA,UAAUD,UAAa,KAAMA,EAAAA,OAAY,CAEjD,EAEO,MAAME,EAAiBF,EAAAA"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),y=require("./hooks/use-component-state.js"),_=e.defineComponent({name:"MtComponentNeo",inheritAttrs:!1,__name:"component-neo",props:{uniqueId:{default:""},is:{}},emits:["toggleComponent"],setup(l,{expose:i,emit:v}){const s=l,d=v,{initComponent:f}=y.useComponentState(),{componentRef:u,componentNeo:C,componentAttrs:c}=f(s.uniqueId),a=o=>u.value=o,g=e.useAttrs(),m=e.computed(()=>{const o={};for(const n in c.value)typeof c.value[n]<"u"&&(o[n]=e.unref(c.value[n]));return Object.assign(o,g)}),t=e.computed(()=>C.value||s.is),r=e.computed(()=>t.value?e.h(t.value,m.value):e.h(e.Comment,"componentNeo is empty")),p=e.computed(()=>typeof t.value=="object"&&"name"in t.value?t.value.name:void 0);return e.watch(t,async()=>{await e.nextTick(),d("toggleComponent",p.value,u.value)}),i({componentRef:u}),(o,n)=>e.renderSlot(o.$slots,"default",{Component:r.value,compRef:a,attrs:m.value,compName:p.value},()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),{ref:a}))])}});exports.default=_;
|
2
|
+
//# sourceMappingURL=component-neo.vue.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"component-neo.vue.js","sources":["../../../../../../packages/components/component-neo/src/component-neo.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { ComponentNeoProps } from './component-neo';\r\nimport { Comment, computed, h, nextTick, unref, useAttrs, watch } from 'vue';\r\nimport { useComponentState } from './hooks/use-component-state';\r\n\r\ndefineOptions({ name: 'MtComponentNeo', inheritAttrs: false });\r\n\r\nconst props = withDefaults(\r\n defineProps<ComponentNeoProps>(),\r\n { uniqueId: '', onToggle: () => { } },\r\n);\r\n\r\nconst emit = defineEmits<{\r\n (e: 'toggleComponent', name?: string, ref?: any): void\r\n}>();\r\n\r\nconst { initComponent } = useComponentState();\r\nconst { componentRef, componentNeo, componentAttrs } = initComponent(props.uniqueId);\r\nconst compRef = (el: Element) => componentRef.value = el;\r\n\r\nconst commonAttrs = useAttrs();\r\n/** 结合注入的属性和公共属性 */\r\nconst compAttrs = computed(() => {\r\n const newAttrs: Record<string, any> = {};\r\n // 仅传入有值的属性\r\n for (const key in componentAttrs.value) {\r\n if (typeof componentAttrs.value[key] !== 'undefined') {\r\n newAttrs[key] = unref(componentAttrs.value[key]); // 支持ref数据转入\r\n }\r\n }\r\n return Object.assign(newAttrs, commonAttrs);\r\n});\r\n\r\nconst compInstance = computed(() => componentNeo.value || props.is);\r\n\r\nconst compVNode = computed(() => {\r\n return !compInstance.value ? h(Comment, 'componentNeo is empty') : h(compInstance.value, compAttrs.value);\r\n});\r\n\r\nconst compName = computed(() => {\r\n return typeof compInstance.value === 'object' && 'name' in compInstance.value ? compInstance.value.name : undefined;\r\n});\r\n\r\n// 监听组件切换,触发回调\r\nwatch(compInstance, async () => {\r\n await nextTick();\r\n emit('toggleComponent', compName.value, componentRef.value);\r\n});\r\n\r\ndefineExpose({ componentRef });\r\n</script>\r\n\r\n<template>\r\n <!-- eslint-disable-next-line vue/attribute-hyphenation -->\r\n <slot :Component=\"compVNode\" :compRef=\"compRef\" :attrs=\"compAttrs\" :compName=\"compName\">\r\n <component :is=\"compVNode\" :ref=\"compRef\" />\r\n </slot>\r\n</template>\r\n"],"names":["props","__props","emit","__emit","initComponent","useComponentState","componentRef","componentNeo","componentAttrs","compRef","el","commonAttrs","useAttrs","compAttrs","computed","newAttrs","key","unref","compInstance","compVNode","h","Comment","compName","watch","nextTick","__expose"],"mappings":"0VAOA,MAAMA,EAAQC,EAKRC,EAAOC,EAIP,CAAE,cAAAC,CAAc,EAAIC,oBAAkB,EACtC,CAAE,aAAAC,EAAc,aAAAC,EAAc,eAAAC,CAAmB,EAAAJ,EAAcJ,EAAM,QAAQ,EAC7ES,EAAWC,GAAgBJ,EAAa,MAAQI,EAEhDC,EAAcC,EAAAA,SAAS,EAEvBC,EAAYC,EAAAA,SAAS,IAAM,CAC/B,MAAMC,EAAgC,CAAC,EAE5B,UAAAC,KAAOR,EAAe,MAC3B,OAAOA,EAAe,MAAMQ,CAAG,EAAM,MACvCD,EAASC,CAAG,EAAIC,EAAAA,MAAMT,EAAe,MAAMQ,CAAG,CAAC,GAG5C,OAAA,OAAO,OAAOD,EAAUJ,CAAW,CAAA,CAC3C,EAEKO,EAAeJ,EAAAA,SAAS,IAAMP,EAAa,OAASP,EAAM,EAAE,EAE5DmB,EAAYL,EAAAA,SAAS,IACjBI,EAAa,MAA8CE,EAAAA,EAAEF,EAAa,MAAOL,EAAU,KAAK,EAA3EO,EAAAA,EAAEC,EAAAA,QAAS,uBAAuB,CAChE,EAEKC,EAAWR,EAAAA,SAAS,IACjB,OAAOI,EAAa,OAAU,UAAY,SAAUA,EAAa,MAAQA,EAAa,MAAM,KAAO,MAC3G,EAGDK,OAAAA,EAAA,MAAML,EAAc,SAAY,CAC9B,MAAMM,WAAS,EACftB,EAAK,kBAAmBoB,EAAS,MAAOhB,EAAa,KAAK,CAAA,CAC3D,EAEYmB,EAAA,CAAE,aAAAnB,EAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"component-neo.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),C=require("./use-component-state.js");function m(r=""){const{setComponent:l,getComponent:s}=C.useComponentState();async function i(t,c){var u;try{const a=typeof t=="function"?(await t()).default:t,n={};for(let e in c){const o=c[e];e.startsWith("vModel:")?(e=e.replace("vModel:",""),n[e]=o,n[`onUpdate:${e}`]=p=>{"value"in o&&(o.value=p)}):n[e]=o}return l(r,a,n),await f.nextTick(),(u=s(r))==null?void 0:u.Instance.value}catch(a){console.error(a)}}return{getComponentRef:()=>{var t;return(t=s(r))==null?void 0:t.Instance.value},toggleComponent:i}}exports.useComponentNeo=m;
|
2
|
+
//# sourceMappingURL=use-component-neo.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-component-neo.js","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-neo.ts"],"sourcesContent":["import type { InstanceComponent } from '../component-neo';\r\nimport { nextTick, type VNode } from 'vue';\r\nimport { useComponentState } from './use-component-state';\r\n\r\nexport type ImportComponentFn = () => Promise<Record<string, any>>;\r\nexport type DynamicComponent = InstanceComponent | ImportComponentFn | VNode;\r\n\r\nexport function useComponentNeo(uniqueId = '') {\r\n const { setComponent, getComponent } = useComponentState();\r\n\r\n /**\r\n * 切换渲染的组件\r\n * @param comp 组件,可传入两种类型,1.直接函数格式返回import动态导入 2.组件类型\r\n * @param attrs 组件属性,可使用`on事件`方式添加事件方法,属性支持Ref类型进行绑定以实现动态变化, 支持通过{'vModal:value': value}方式双向绑定数据\r\n */\r\n async function toggleComponent(comp: DynamicComponent, attrs?: Record<string, any>) {\r\n try {\r\n const renderComp = typeof comp === 'function' ? (await (comp as ImportComponentFn)()).default : comp;\r\n const renderAttrs: Record<string, any> = {};\r\n for (let key in attrs) {\r\n const bindValue = attrs[key];\r\n // 兼容vModal\r\n if (key.startsWith('vModel:')) {\r\n key = key.replace('vModel:', '');\r\n renderAttrs[key] = bindValue;\r\n renderAttrs[`onUpdate:${key}`] = (value: any) => {\r\n if ('value' in bindValue) {\r\n bindValue.value = value;\r\n }\r\n };\r\n }\r\n else {\r\n renderAttrs[key] = bindValue;\r\n }\r\n }\r\n setComponent(uniqueId, renderComp, renderAttrs);\r\n await nextTick();\r\n return getComponent(uniqueId)?.Instance.value;\r\n }\r\n catch (e) {\r\n console.error(e);\r\n }\r\n }\r\n return {\r\n getComponentRef: () => getComponent(uniqueId)?.Instance.value,\r\n toggleComponent,\r\n };\r\n};\r\n"],"names":["useComponentNeo","uniqueId","setComponent","getComponent","useComponentState","toggleComponent","comp","attrs","renderComp","renderAttrs","key","bindValue","value","nextTick","_a","e"],"mappings":"6IAOgB,SAAAA,EAAgBC,EAAW,GAAI,CAC7C,KAAM,CAAE,aAAAC,EAAc,aAAAC,CAAa,EAAIC,oBAAkB,EAO1C,eAAAC,EAAgBC,EAAwBC,EAA6B,OAC9E,GAAA,CACF,MAAMC,EAAa,OAAOF,GAAS,YAAc,MAAOA,EAAA,GAA8B,QAAUA,EAC1FG,EAAmC,CAAC,EAC1C,QAASC,KAAOH,EAAO,CACf,MAAAI,EAAYJ,EAAMG,CAAG,EAEvBA,EAAI,WAAW,SAAS,GACpBA,EAAAA,EAAI,QAAQ,UAAW,EAAE,EAC/BD,EAAYC,CAAG,EAAIC,EACnBF,EAAY,YAAYC,CAAG,EAAE,EAAKE,GAAe,CAC3C,UAAWD,IACbA,EAAU,MAAQC,EAEtB,GAGAH,EAAYC,CAAG,EAAIC,CACrB,CAEW,OAAAT,EAAAD,EAAUO,EAAYC,CAAW,EAC9C,MAAMI,WAAS,GACRC,EAAAX,EAAaF,CAAQ,IAArB,YAAAa,EAAwB,SAAS,YAEnCC,EAAG,CACR,QAAQ,MAAMA,CAAC,CAAA,CACjB,CAEK,MAAA,CACL,gBAAiB,IAAA,OAAM,OAAAD,EAAAX,EAAaF,CAAQ,IAArB,YAAAa,EAAwB,SAAS,OACxD,gBAAAT,CACF,CACF"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@vueuse/core"),c=require("vue"),u=l.createGlobalState(()=>{const r=new Map,n=new Map;function f(e=""){let t=n.get(e);t||(t={Instance:c.ref(),comp:c.shallowRef(),attrs:c.ref({})},n.set(e,t),c.onBeforeUnmount(()=>p(e)));const o=r.get(e);return o&&(t.comp.value=o.comp,t.attrs.value=o.attrs),{componentRef:t.Instance,componentNeo:t.comp,componentAttrs:t.attrs}}function s(e=""){return n.get(e)}function p(e=""){r.delete(e),n.delete(e)}function m(e="",t,o){const a=s(e);a&&(a.comp.value=t,a.attrs.value=o),r.set(e,{comp:t,attrs:o})}return{initComponent:f,setComponent:m,getComponent:s,removeComponent:p}});exports.useComponentState=u;
|
2
|
+
//# sourceMappingURL=use-component-state.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-component-state.js","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-state.ts"],"sourcesContent":["import type { InstanceComponent } from '../component-neo';\r\nimport { createGlobalState } from '@vueuse/core';\r\nimport { onBeforeUnmount, ref, type Ref, shallowRef, type ShallowRef, type VNode } from 'vue';\r\n\r\ninterface ComponentRefsType {\r\n /** 实例 */\r\n Instance: Ref<any>\r\n /** 组件 */\r\n comp: ShallowRef<InstanceComponent | VNode | undefined>\r\n /** 属性 */\r\n attrs: Ref<Record<string, any>>\r\n}\r\n\r\n/** 组件状态 */\r\nexport const useComponentState = createGlobalState(() => {\r\n /** 缓存组件数据,组件未实例化时,可先缓存后赋值 */\r\n const dataBufferMap = new Map<string, { comp: InstanceComponent | VNode, attrs: Record<string, any> }>();\r\n /** 实例化后的组件 */\r\n const componentRefsMap = new Map<string, ComponentRefsType>();\r\n /** 初始化组件 */\r\n function initComponent(uniqueId = '') {\r\n let componentRefs = componentRefsMap.get(uniqueId);\r\n if (!componentRefs) {\r\n componentRefs = {\r\n Instance: ref(),\r\n comp: shallowRef<InstanceComponent | VNode>(),\r\n attrs: ref<Record<string, any>>({}),\r\n };\r\n componentRefsMap.set(uniqueId, componentRefs);\r\n onBeforeUnmount(() => removeComponent(uniqueId));\r\n }\r\n // 使用缓存数据初始化数据\r\n const bufferData = dataBufferMap.get(uniqueId);\r\n if (bufferData) {\r\n componentRefs.comp.value = bufferData.comp;\r\n componentRefs.attrs.value = bufferData.attrs;\r\n }\r\n\r\n return {\r\n componentRef: componentRefs.Instance,\r\n componentNeo: componentRefs.comp,\r\n componentAttrs: componentRefs.attrs,\r\n };\r\n }\r\n\r\n /** 获取实例 */\r\n function getComponent(uniqueId = '') {\r\n return componentRefsMap.get(uniqueId);\r\n }\r\n\r\n /** 移除实例 */\r\n function removeComponent(uniqueId = '') {\r\n dataBufferMap.delete(uniqueId);\r\n componentRefsMap.delete(uniqueId);\r\n }\r\n\r\n /** 设置组件数据 */\r\n function setComponent(uniqueId = '', comp: InstanceComponent | VNode, attrs: Record<string, any>) {\r\n const componentRefs = getComponent(uniqueId);\r\n if (componentRefs) {\r\n componentRefs.comp.value = comp;\r\n componentRefs.attrs.value = attrs;\r\n }\r\n dataBufferMap.set(uniqueId, { comp, attrs });\r\n }\r\n\r\n return { initComponent, setComponent, getComponent, removeComponent };\r\n});\r\n"],"names":["useComponentState","createGlobalState","dataBufferMap","componentRefsMap","initComponent","uniqueId","componentRefs","ref","shallowRef","onBeforeUnmount","removeComponent","bufferData","getComponent","setComponent","comp","attrs"],"mappings":"iIAcaA,EAAoBC,oBAAkB,IAAM,CAEjD,MAAAC,MAAoB,IAEpBC,MAAuB,IAEpB,SAAAC,EAAcC,EAAW,GAAI,CAChC,IAAAC,EAAgBH,EAAiB,IAAIE,CAAQ,EAC5CC,IACaA,EAAA,CACd,SAAUC,EAAAA,IAAI,EACd,KAAMC,EAAAA,WAAsC,EAC5C,MAAOD,EAAyB,IAAA,CAAE,CAAA,CACpC,EACiBJ,EAAA,IAAIE,EAAUC,CAAa,EAC5BG,kBAAA,IAAMC,EAAgBL,CAAQ,CAAC,GAG3C,MAAAM,EAAaT,EAAc,IAAIG,CAAQ,EAC7C,OAAIM,IACYL,EAAA,KAAK,MAAQK,EAAW,KACxBL,EAAA,MAAM,MAAQK,EAAW,OAGlC,CACL,aAAcL,EAAc,SAC5B,aAAcA,EAAc,KAC5B,eAAgBA,EAAc,KAChC,CAAA,CAIO,SAAAM,EAAaP,EAAW,GAAI,CAC5B,OAAAF,EAAiB,IAAIE,CAAQ,CAAA,CAI7B,SAAAK,EAAgBL,EAAW,GAAI,CACtCH,EAAc,OAAOG,CAAQ,EAC7BF,EAAiB,OAAOE,CAAQ,CAAA,CAIlC,SAASQ,EAAaR,EAAW,GAAIS,EAAiCC,EAA4B,CAC1F,MAAAT,EAAgBM,EAAaP,CAAQ,EACvCC,IACFA,EAAc,KAAK,MAAQQ,EAC3BR,EAAc,MAAM,MAAQS,GAE9Bb,EAAc,IAAIG,EAAU,CAAE,KAAAS,EAAM,MAAAC,EAAO,CAAA,CAG7C,MAAO,CAAE,cAAAX,EAAe,aAAAS,EAAc,aAAAD,EAAc,gBAAAF,CAAgB,CACtE,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Expand from './src/expand.vue';\r\n\r\nExpand.install = (app: App): void => {\r\n if (Expand.name) {\r\n app.component(Expand.name, Expand);\r\n }\r\n};\r\n\r\nexport const MtExpand = Expand;\r\n"],"names":["Expand","app","MtExpand"],"mappings":"uHAGAA,EAAAA,QAAO,QAAWC,GAAmB,CAC/BD,EAAAA,QAAO,MACLC,EAAA,UAAUD,UAAO,KAAMA,EAAAA,OAAM,CAErC,EAEO,MAAME,EAAWF,EAAAA"}
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Expand from './src/expand.vue';\r\n\r\nExpand.install = (app: App): void => {\r\n if (Expand.name) {\r\n app.component(Expand.name, Expand);\r\n }\r\n};\r\n\r\nexport const MtExpand = Expand;\r\n\r\nexport * from './src/expand';\r\n"],"names":["Expand","app","MtExpand"],"mappings":"uHAGAA,EAAAA,QAAO,QAAWC,GAAmB,CAC/BD,EAAAA,QAAO,MACLC,EAAA,UAAUD,UAAO,KAAMA,EAAAA,OAAM,CAErC,EAEO,MAAME,EAAWF,EAAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/sort/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Sort from './src/sort';\r\n\r\nSort.install = (app: App): void => {\r\n if (Sort.name) {\r\n app.component(Sort.name, Sort);\r\n }\r\n};\r\n\r\nexport const MtSort = Sort;\r\n\r\nexport * from './src/sort';\r\n"],"names":["Sort","app","MtSort"],"mappings":"iHAGAA,EAAAA,QAAK,QAAWC,GAAmB,CAC7BD,EAAAA,QAAK,MACHC,EAAA,UAAUD,UAAK,KAAMA,EAAAA,OAAI,CAEjC,EAEO,MAAME,EAASF,EAAAA"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),d=a.defineComponent({name:"MtSort",props:{sortList:{type:Array,default:()=>[]},keyName:{type:String,default:"sort-key"}},setup(e,{slots:s}){const o=a.computed(()=>{var u;const t=((u=s.default)==null?void 0:u.call(s))||[],n=f(e.keyName,t),r=Array.from(new Set(e.sortList)).map(i=>n[i]).filter(Boolean);return l(e.keyName,t,e.sortList,r)});return()=>o.value}});function f(e,s,o={}){return s.forEach(t=>{var r;const n=(r=t.props)==null?void 0:r[e];if(n){o[n]?console.warn(`<mt-sort-space> ${e}: ${n} repeat`):o[n]=t;return}Array.isArray(t.children)&&f(e,t.children,o)}),o}function l(e,s,o,t){const n=[];return s.forEach(r=>{var i;const u=(i=r.props)==null?void 0:i[e];if(u&&o.includes(u)){const c=t.shift();if(c){n.push(c);return}}Array.isArray(r.children)&&(r={...r},r.children=l(e,r.children,o,t)),n.push(r)}),n}exports.default=d;
|
2
|
+
//# sourceMappingURL=sort.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sort.js","sources":["../../../../../../packages/components/sort/src/sort.ts"],"sourcesContent":["import type { PropType, VNode } from 'vue';\r\nimport { computed, defineComponent } from 'vue';\r\n\r\nexport interface SortSpaceProps {\r\n /** 排序配置 */\r\n sortList?: (string | number)[]\r\n /** 排序key名 */\r\n keyName?: string\r\n}\r\n\r\nexport default defineComponent({\r\n name: 'MtSort',\r\n props: {\r\n /** 排序配置 */\r\n sortList: {\r\n type: Array as PropType<(string | number)[]>,\r\n default: () => [],\r\n },\r\n /** 排序key名 */\r\n keyName: {\r\n type: String,\r\n default: 'sort-key',\r\n },\r\n },\r\n setup(props, { slots }) {\r\n const renderVNodes = computed(() => {\r\n const vNodeList = slots.default?.() || [];\r\n const sortVNodeMap = getVNodeMap(props.keyName, vNodeList);\r\n const sortVNodeList = Array.from(new Set(props.sortList)).map(key => sortVNodeMap[key]).filter(Boolean);\r\n return sortDefaultVNodes(props.keyName, vNodeList, props.sortList, sortVNodeList);\r\n });\r\n\r\n return () => renderVNodes.value;\r\n },\r\n});\r\n\r\n/** 获取插槽中需要排序的节点 */\r\nfunction getVNodeMap(keyName: string, vNodeList: VNode[], vNodeMap: Record<(string | number), VNode> = {}) {\r\n vNodeList.forEach((item) => {\r\n const sortKey = item.props?.[keyName];\r\n if (sortKey) {\r\n if (vNodeMap[sortKey]) {\r\n console.warn(`<mt-sort-space> ${keyName}: ${sortKey} repeat`);\r\n }\r\n else {\r\n vNodeMap[sortKey] = item;\r\n }\r\n return;\r\n }\r\n if (Array.isArray(item.children)) {\r\n getVNodeMap(keyName, item.children as VNode[], vNodeMap);\r\n }\r\n });\r\n return vNodeMap;\r\n}\r\n\r\n/** 根据排序后的节点跟换位置 */\r\nfunction sortDefaultVNodes(keyName: string, vNodeList: VNode[], sortList: (string | number)[], sortVNodeList: VNode[]) {\r\n const newList: VNode[] = [];\r\n vNodeList.forEach((vNode) => {\r\n const sortKey = vNode.props?.[keyName];\r\n if (sortKey && sortList.includes(sortKey)) {\r\n const sortVNode = sortVNodeList.shift();\r\n if (sortVNode) {\r\n newList.push(sortVNode);\r\n return;\r\n }\r\n }\r\n if (Array.isArray(vNode.children)) {\r\n vNode = { ...vNode }; // 避免修改原节点数据\r\n vNode.children = sortDefaultVNodes(keyName, vNode.children as VNode[], sortList, sortVNodeList);\r\n }\r\n newList.push(vNode);\r\n });\r\n return newList;\r\n}\r\n"],"names":["Sort","defineComponent","props","slots","renderVNodes","computed","vNodeList","_a","sortVNodeMap","getVNodeMap","sortVNodeList","key","sortDefaultVNodes","keyName","vNodeMap","item","sortKey","sortList","newList","vNode","sortVNode"],"mappings":"mIAUAA,EAAeC,kBAAgB,CAC7B,KAAM,SACN,MAAO,CAEL,SAAU,CACR,KAAM,MACN,QAAS,IAAM,CAAA,CACjB,EAEA,QAAS,CACP,KAAM,OACN,QAAS,UAAA,CAEb,EACA,MAAMC,EAAO,CAAE,MAAAC,GAAS,CAChB,MAAAC,EAAeC,EAAAA,SAAS,IAAM,OAClC,MAAMC,IAAYC,EAAAJ,EAAM,UAAN,YAAAI,EAAA,KAAAJ,KAAqB,CAAC,EAClCK,EAAeC,EAAYP,EAAM,QAASI,CAAS,EACnDI,EAAgB,MAAM,KAAK,IAAI,IAAIR,EAAM,QAAQ,CAAC,EAAE,OAAWM,EAAaG,CAAG,CAAC,EAAE,OAAO,OAAO,EACtG,OAAOC,EAAkBV,EAAM,QAASI,EAAWJ,EAAM,SAAUQ,CAAa,CAAA,CACjF,EAED,MAAO,IAAMN,EAAa,KAAA,CAE9B,CAAC,EAGD,SAASK,EAAYI,EAAiBP,EAAoBQ,EAA6C,CAAA,EAAI,CAC/F,OAAAR,EAAA,QAASS,GAAS,OACpB,MAAAC,GAAUT,EAAAQ,EAAK,QAAL,YAAAR,EAAaM,GAC7B,GAAIG,EAAS,CACPF,EAASE,CAAO,EAClB,QAAQ,KAAK,mBAAmBH,CAAO,KAAKG,CAAO,SAAS,EAG5DF,EAASE,CAAO,EAAID,EAEtB,MAAA,CAEE,MAAM,QAAQA,EAAK,QAAQ,GACjBN,EAAAI,EAASE,EAAK,SAAqBD,CAAQ,CACzD,CACD,EACMA,CACT,CAGA,SAASF,EAAkBC,EAAiBP,EAAoBW,EAA+BP,EAAwB,CACrH,MAAMQ,EAAmB,CAAC,EAChB,OAAAZ,EAAA,QAASa,GAAU,OACrB,MAAAH,GAAUT,EAAAY,EAAM,QAAN,YAAAZ,EAAcM,GAC9B,GAAIG,GAAWC,EAAS,SAASD,CAAO,EAAG,CACnC,MAAAI,EAAYV,EAAc,MAAM,EACtC,GAAIU,EAAW,CACbF,EAAQ,KAAKE,CAAS,EACtB,MAAA,CACF,CAEE,MAAM,QAAQD,EAAM,QAAQ,IACtBA,EAAA,CAAE,GAAGA,CAAM,EACnBA,EAAM,SAAWP,EAAkBC,EAASM,EAAM,SAAqBF,EAAUP,CAAa,GAEhGQ,EAAQ,KAAKC,CAAK,CAAA,CACnB,EACMD,CACT"}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./src/table.vue.js");e.default.install=t=>{e.default.name&&t.component(e.default.name,e.default)};const a=e.default;exports.MtTable=a;
|
2
|
+
//# sourceMappingURL=index.js.map
|
3
|
+
require('./src/table.css');
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/table/index.ts"],"sourcesContent":["import type { App } from 'vue';\r\nimport Table from './src/table.vue';\r\n\r\nTable.install = (app: App): void => {\r\n if (Table.name) {\r\n app.component(Table.name, Table);\r\n }\r\n};\r\n\r\nexport const MtTable = Table;\r\n\r\nexport * from './src/table';\r\n"],"names":["Table","app","MtTable"],"mappings":"sHAGAA,EAAAA,QAAM,QAAWC,GAAmB,CAC9BD,EAAAA,QAAM,MACJC,EAAA,UAAUD,UAAM,KAAMA,EAAAA,OAAK,CAEnC,EAEO,MAAME,EAAUF,EAAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
.mt-table[data-v-46d3894f]{width:100%;max-width:100%;border-spacing:0;border-collapse:collapse}.mt-table thead tr th[data-v-46d3894f]{padding:8px 16px;border:1px #f0f0f0 solid}.mt-table tbody tr td[data-v-46d3894f]{padding:16px;border:1px #f0f0f0 solid}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./table.vue2.js");;/* empty css */const t=require("../../../_virtual/_plugin-vue_export-helper.js"),u=t.default(e.default,[["__scopeId","data-v-46d3894f"]]);exports.default=u;
|
2
|
+
//# sourceMappingURL=table.vue.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),g={class:"mt-table"},f=["colspan","rowspan"],E=["colspan","rowspan"],v=e.defineComponent({name:"MtTable",__name:"table",props:{data:{default:()=>[]},config:{default:()=>[]}},setup(y){const m=y,u=e.computed(()=>m.config.map(l=>({...l,columns:l.columns.filter(c=>c.title)}))),p=e.computed(()=>m.config.map(l=>({...l,columns:l.columns.filter(c=>c.dataKey)}))),S=e.computed(()=>{const l=u.value.map(n=>n.columns.reduce((t,o)=>{var a;return t+(((a=o.head)==null?void 0:a.colSpan)||1)},0)),c=p.value.map(n=>n.columns.reduce((t,o)=>{var a;return t+(((a=o.cell)==null?void 0:a.colSpan)||1)},0));return Math.max(...l,...c)}),B=e.computed(()=>{const l=u.value.map(c=>c.columns.map(n=>{var t;return((t=n.head)==null?void 0:t.colSpan)||0}));return i(l)}),h=e.computed(()=>{const l=p.value.map(c=>c.columns.map(n=>{var t;return((t=n.cell)==null?void 0:t.colSpan)||0}));return i(l)});function i(l){return l.map(c=>{const n=c.filter(Boolean),t=n.reduce((r,s)=>r+s,0);let o=c.length-n.length,a=S.value-t;return c.map(r=>(!r&&a>0&&(r=Math.ceil(a/o),o--,a-=r),r))})}return(l,c)=>(e.openBlock(),e.createElementBlock("table",g,[e.createElementVNode("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,(n,t)=>(e.openBlock(),e.createElementBlock("tr",{key:t,style:e.normalizeStyle(n.headStyle)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,(o,a)=>{var r,s;return e.openBlock(),e.createElementBlock("th",{key:`${o.title}-${a}`,colspan:B.value[t][a],rowspan:(r=o.head)==null?void 0:r.rowSpan,style:e.normalizeStyle((s=o.head)==null?void 0:s.style)},[e.renderSlot(l.$slots,"header",{column:o,columnIndex:a,row:n,rowIndex:t},()=>[e.createTextVNode(e.toDisplayString(o.title),1)],!0)],12,f)}),128))],4))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.data,(n,t)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(o,a)=>(e.openBlock(),e.createElementBlock("tr",{key:a,style:e.normalizeStyle(o.rowStyle)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.columns,(r,s)=>{var d,k;return e.openBlock(),e.createElementBlock("td",{key:`${r.dataKey}-${s}`,colspan:h.value[a][s],rowspan:(d=r.cell)==null?void 0:d.rowSpan,style:e.normalizeStyle((k=r.cell)==null?void 0:k.style)},[e.renderSlot(l.$slots,"cell",{column:r,columnIndex:s,dataIndex:t,record:n,row:o,rowIndex:a},()=>[e.createTextVNode(e.toDisplayString(n[r.dataKey]),1)],!0)],12,E)}),128))],4))),128))],64))),128))])]))}});exports.default=v;
|
2
|
+
//# sourceMappingURL=table.vue2.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table.vue2.js","sources":["../../../../../../packages/components/table/src/table.vue"],"sourcesContent":["<script lang=\"ts\" setup>\r\nimport type { TableProps } from './table';\r\nimport { computed } from 'vue';\r\n\r\ndefineOptions({ name: 'MtTable' });\r\n\r\nconst props = withDefaults(defineProps<TableProps>(), {\r\n data: () => [],\r\n config: () => [],\r\n});\r\n\r\n/** 表头配置 */\r\nconst headConfig = computed(() => {\r\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.title) }));\r\n});\r\n\r\n/** 数据配置 */\r\nconst dataConfig = computed(() => {\r\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.dataKey) }));\r\n});\r\n\r\n/** 最大列数 */\r\nconst maxColSpan = computed(() => {\r\n const handReduce = headConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.head?.colSpan || 1), 0));\r\n const cellReduce = dataConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.cell?.colSpan || 1), 0));\r\n return Math.max(...handReduce, ...cellReduce);\r\n});\r\n\r\n/** 表头列合并 */\r\nconst headColSpan = computed(() => {\r\n const colSpanList = headConfig.value.map(item => item.columns.map(column => column.head?.colSpan || 0));\r\n return getColSpanData(colSpanList);\r\n});\r\n\r\n/** 数据列合并 */\r\nconst dataColSpan = computed(() => {\r\n const colSpanList = dataConfig.value.map(item => item.columns.map(column => column.cell?.colSpan || 0));\r\n return getColSpanData(colSpanList);\r\n});\r\n\r\n/** 获取合并列数组 */\r\nfunction getColSpanData(colSpanList: number[][]) {\r\n return colSpanList.map((columns) => {\r\n const colSpanColumns = columns.filter(Boolean); // 已分配colSpan的列\r\n const beenColSpan = colSpanColumns.reduce((pur, cur) => pur + cur, 0); // 总colSpan\r\n let remainCount = columns.length - colSpanColumns.length; // 剩余未配置colSpan的列数\r\n let remainColSpan = maxColSpan.value - beenColSpan; // 剩余可分配的colSpan\r\n return columns.map((colSpan) => {\r\n if (!colSpan && remainColSpan > 0) {\r\n colSpan = Math.ceil(remainColSpan / remainCount); // 每列平均分配colSpan\r\n remainCount--;\r\n remainColSpan -= colSpan;\r\n }\r\n return colSpan;\r\n });\r\n });\r\n}\r\n</script>\r\n\r\n<template>\r\n <table class=\"mt-table\">\r\n <!-- 表头 -->\r\n <thead>\r\n <tr\r\n v-for=\"(row, rowIndex) in headConfig\"\r\n :key=\"rowIndex\"\r\n :style=\"row.headStyle\"\r\n >\r\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.title}-${columnIndex}`\">\r\n <th\r\n :colspan=\"headColSpan[rowIndex][columnIndex]\"\r\n :rowspan=\"column.head?.rowSpan\"\r\n :style=\"column.head?.style\"\r\n >\r\n <slot\r\n :column=\"column\"\r\n :column-index=\"columnIndex\"\r\n :row=\"row\"\r\n :row-index=\"rowIndex\"\r\n name=\"header\"\r\n >\r\n {{ column.title }}\r\n </slot>\r\n </th>\r\n </template>\r\n </tr>\r\n </thead>\r\n <!-- 表体 -->\r\n <tbody>\r\n <template\r\n v-for=\"(record, dataIndex) in data\"\r\n :key=\"dataIndex\"\r\n >\r\n <tr\r\n v-for=\"(row, rowIndex) in dataConfig\"\r\n :key=\"rowIndex\"\r\n :style=\"row.rowStyle\"\r\n >\r\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.dataKey}-${columnIndex}`\">\r\n <td\r\n :colspan=\"dataColSpan[rowIndex][columnIndex]\"\r\n :rowspan=\"column.cell?.rowSpan\"\r\n :style=\"column.cell?.style\"\r\n >\r\n <slot\r\n :column=\"column\"\r\n :column-index=\"columnIndex\"\r\n :data-index=\"dataIndex\"\r\n name=\"cell\"\r\n :record=\"record\"\r\n :row=\"row\"\r\n :row-index=\"rowIndex\"\r\n >\r\n {{ record[column.dataKey!] }}\r\n </slot>\r\n </td>\r\n </template>\r\n </tr>\r\n </template>\r\n </tbody>\r\n </table>\r\n</template>\r\n\r\n<style lang=\"scss\" scoped>\r\n.mt-table {\r\n width: 100%;\r\n max-width: 100%;\r\n border-spacing: 0;\r\n border-collapse: collapse;\r\n\r\n thead {\r\n tr {\r\n th {\r\n padding: 8px 16px;\r\n border: 1px #f0f0f0 solid;\r\n }\r\n }\r\n }\r\n\r\n tbody {\r\n tr {\r\n td {\r\n padding: 16px;\r\n border: 1px #f0f0f0 solid;\r\n }\r\n }\r\n }\r\n}\r\n</style>\r\n"],"names":["props","__props","headConfig","computed","rowItem","column","dataConfig","maxColSpan","handReduce","item","pre","cur","_a","cellReduce","headColSpan","colSpanList","getColSpanData","dataColSpan","columns","colSpanColumns","beenColSpan","pur","remainCount","remainColSpan","colSpan"],"mappings":"0TAMA,MAAMA,EAAQC,EAMRC,EAAaC,EAAAA,SAAS,IACnBH,EAAM,OAAO,IAAII,IAAY,CAAE,GAAGA,EAAS,QAASA,EAAQ,QAAQ,OAAOC,GAAUA,EAAO,KAAK,GAAI,CAC7G,EAGKC,EAAaH,EAAAA,SAAS,IACnBH,EAAM,OAAO,IAAII,IAAY,CAAE,GAAGA,EAAS,QAASA,EAAQ,QAAQ,OAAOC,GAAUA,EAAO,OAAO,GAAI,CAC/G,EAGKE,EAAaJ,EAAAA,SAAS,IAAM,CAChC,MAAMK,EAAaN,EAAW,MAAM,IAAIO,GAAQA,EAAK,QAAQ,OAAO,CAACC,EAAKC,WAAQ,OAAAD,KAAOE,EAAAD,EAAI,OAAJ,YAAAC,EAAU,UAAW,IAAI,CAAC,CAAC,EAC9GC,EAAaP,EAAW,MAAM,IAAIG,GAAQA,EAAK,QAAQ,OAAO,CAACC,EAAKC,WAAQ,OAAAD,KAAOE,EAAAD,EAAI,OAAJ,YAAAC,EAAU,UAAW,IAAI,CAAC,CAAC,EACpH,OAAO,KAAK,IAAI,GAAGJ,EAAY,GAAGK,CAAU,CAAA,CAC7C,EAGKC,EAAcX,EAAAA,SAAS,IAAM,CACjC,MAAMY,EAAcb,EAAW,MAAM,IAAYO,GAAAA,EAAK,QAAQ,IAAcJ,GAAA,OAAA,QAAAO,EAAAP,EAAO,OAAP,YAAAO,EAAa,UAAW,EAAC,CAAC,EACtG,OAAOI,EAAeD,CAAW,CAAA,CAClC,EAGKE,EAAcd,EAAAA,SAAS,IAAM,CACjC,MAAMY,EAAcT,EAAW,MAAM,IAAYG,GAAAA,EAAK,QAAQ,IAAcJ,GAAA,OAAA,QAAAO,EAAAP,EAAO,OAAP,YAAAO,EAAa,UAAW,EAAC,CAAC,EACtG,OAAOI,EAAeD,CAAW,CAAA,CAClC,EAGD,SAASC,EAAeD,EAAyB,CACxC,OAAAA,EAAY,IAAKG,GAAY,CAC5B,MAAAC,EAAiBD,EAAQ,OAAO,OAAO,EACvCE,EAAcD,EAAe,OAAO,CAACE,EAAKV,IAAQU,EAAMV,EAAK,CAAC,EAChE,IAAAW,EAAcJ,EAAQ,OAASC,EAAe,OAC9CI,EAAgBhB,EAAW,MAAQa,EAChC,OAAAF,EAAQ,IAAKM,IACd,CAACA,GAAWD,EAAgB,IACpBC,EAAA,KAAK,KAAKD,EAAgBD,CAAW,EAC/CA,IACiBC,GAAAC,GAEZA,EACR,CAAA,CACF,CAAA"}
|
package/lib/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./components/expand/index.js");exports.
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./components/component-neo/index.js"),o=require("./components/expand/index.js"),t=require("./components/sort/index.js"),n=require("./components/table/index.js"),r=require("./components/component-neo/src/hooks/use-component-neo.js");exports.MtComponentNeo=e.MtComponentNeo;exports.MtExpand=o.MtExpand;exports.MtSort=t.MtSort;exports.MtTable=n.MtTable;exports.useComponentNeo=r.useComponentNeo;
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "mortise-tenon-design",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1
|
4
|
+
"version": "0.2.1",
|
5
5
|
"description": "榫卯组件库",
|
6
6
|
"author": "nixwai",
|
7
7
|
"license": "ISC",
|
@@ -12,7 +12,11 @@
|
|
12
12
|
"main": "lib/index.js",
|
13
13
|
"module": "es/index.mjs",
|
14
14
|
"types": "types/index.d.ts",
|
15
|
-
"files": [
|
15
|
+
"files": [
|
16
|
+
"es",
|
17
|
+
"lib",
|
18
|
+
"types"
|
19
|
+
],
|
16
20
|
"peerDependencies": {
|
17
21
|
"vue": "^3.4.0"
|
18
22
|
},
|
@@ -20,4 +24,4 @@
|
|
20
24
|
"@vueuse/core": "^11.1.0",
|
21
25
|
"lodash-es": "^4.17.21"
|
22
26
|
}
|
23
|
-
}
|
27
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
export declare const MtComponentNeo: {
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('./src/component-neo').ComponentNeoProps> & Readonly<{
|
3
|
+
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
4
|
+
}>, {
|
5
|
+
componentRef: import('vue').Ref<any, any>;
|
6
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
7
|
+
toggleComponent: (name?: string | undefined, ref?: any) => any;
|
8
|
+
}, import('vue').PublicProps, {
|
9
|
+
uniqueId: string;
|
10
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
11
|
+
P: {};
|
12
|
+
B: {};
|
13
|
+
D: {};
|
14
|
+
C: {};
|
15
|
+
M: {};
|
16
|
+
Defaults: {};
|
17
|
+
}, Readonly<import('./src/component-neo').ComponentNeoProps> & Readonly<{
|
18
|
+
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
19
|
+
}>, {
|
20
|
+
componentRef: import('vue').Ref<any, any>;
|
21
|
+
}, {}, {}, {}, {
|
22
|
+
uniqueId: string;
|
23
|
+
}>;
|
24
|
+
__isFragment?: never;
|
25
|
+
__isTeleport?: never;
|
26
|
+
__isSuspense?: never;
|
27
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('./src/component-neo').ComponentNeoProps> & Readonly<{
|
28
|
+
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
29
|
+
}>, {
|
30
|
+
componentRef: import('vue').Ref<any, any>;
|
31
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
32
|
+
toggleComponent: (name?: string | undefined, ref?: any) => any;
|
33
|
+
}, string, {
|
34
|
+
uniqueId: string;
|
35
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
36
|
+
$slots: {
|
37
|
+
default?(_: {
|
38
|
+
Component: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
39
|
+
[key: string]: any;
|
40
|
+
}>;
|
41
|
+
compRef: (el: Element) => Element;
|
42
|
+
attrs: Record<string, any> & {
|
43
|
+
[x: string]: unknown;
|
44
|
+
};
|
45
|
+
compName: any;
|
46
|
+
}): any;
|
47
|
+
};
|
48
|
+
});
|
49
|
+
export * from './src/component-neo.vue';
|
50
|
+
export * from './src/hooks/use-component-neo';
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Component, DefineComponent } from 'vue';
|
2
|
+
export interface ComponentNeoProps {
|
3
|
+
/** 唯一标识 */
|
4
|
+
uniqueId?: string;
|
5
|
+
/** 渲染的组件 */
|
6
|
+
is?: string | Component;
|
7
|
+
}
|
8
|
+
export type InstanceComponent = DefineComponent<any, any, any, any, any, any, any, any, any, any>;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { ComponentNeoProps } from './component-neo';
|
2
|
+
declare function __VLS_template(): {
|
3
|
+
attrs: Partial<{}>;
|
4
|
+
slots: {
|
5
|
+
default?(_: {
|
6
|
+
Component: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
7
|
+
[key: string]: any;
|
8
|
+
}>;
|
9
|
+
compRef: (el: Element) => Element;
|
10
|
+
attrs: Record<string, any> & {
|
11
|
+
[x: string]: unknown;
|
12
|
+
};
|
13
|
+
compName: any;
|
14
|
+
}): any;
|
15
|
+
};
|
16
|
+
refs: {};
|
17
|
+
rootEl: any;
|
18
|
+
};
|
19
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
20
|
+
declare const __VLS_component: import('vue').DefineComponent<ComponentNeoProps, {
|
21
|
+
componentRef: import('vue').Ref<any, any>;
|
22
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
23
|
+
toggleComponent: (name?: string | undefined, ref?: any) => any;
|
24
|
+
}, string, import('vue').PublicProps, Readonly<ComponentNeoProps> & Readonly<{
|
25
|
+
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
26
|
+
}>, {
|
27
|
+
uniqueId: string;
|
28
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
29
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
30
|
+
export default _default;
|
31
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
32
|
+
new (): {
|
33
|
+
$slots: S;
|
34
|
+
};
|
35
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { InstanceComponent } from '../component-neo';
|
2
|
+
import { VNode } from 'vue';
|
3
|
+
export type ImportComponentFn = () => Promise<Record<string, any>>;
|
4
|
+
export type DynamicComponent = InstanceComponent | ImportComponentFn | VNode;
|
5
|
+
export declare function useComponentNeo(uniqueId?: string): {
|
6
|
+
getComponentRef: () => any;
|
7
|
+
toggleComponent: (comp: DynamicComponent, attrs?: Record<string, any>) => Promise<any>;
|
8
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { InstanceComponent } from '../component-neo';
|
2
|
+
import { Ref, ShallowRef, VNode } from 'vue';
|
3
|
+
interface ComponentRefsType {
|
4
|
+
/** 实例 */
|
5
|
+
Instance: Ref<any>;
|
6
|
+
/** 组件 */
|
7
|
+
comp: ShallowRef<InstanceComponent | VNode | undefined>;
|
8
|
+
/** 属性 */
|
9
|
+
attrs: Ref<Record<string, any>>;
|
10
|
+
}
|
11
|
+
/** 组件状态 */
|
12
|
+
export declare const useComponentState: () => {
|
13
|
+
initComponent: (uniqueId?: string) => {
|
14
|
+
componentRef: Ref<any, any>;
|
15
|
+
componentNeo: ShallowRef<any>;
|
16
|
+
componentAttrs: Ref<Record<string, any>, Record<string, any>>;
|
17
|
+
};
|
18
|
+
setComponent: (uniqueId: string | undefined, comp: InstanceComponent | VNode, attrs: Record<string, any>) => void;
|
19
|
+
getComponent: (uniqueId?: string) => ComponentRefsType | undefined;
|
20
|
+
removeComponent: (uniqueId?: string) => void;
|
21
|
+
};
|
22
|
+
export {};
|
package/types/expand/index.d.ts
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
export declare const MtExpand: {
|
2
|
-
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('.').ExpandProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
|
3
3
|
open: boolean;
|
4
4
|
targetRange: number;
|
5
5
|
transitionTime: number;
|
6
|
-
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
6
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
7
|
+
contentRef: HTMLDivElement;
|
8
|
+
}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
7
9
|
P: {};
|
8
10
|
B: {};
|
9
11
|
D: {};
|
10
12
|
C: {};
|
11
13
|
M: {};
|
12
14
|
Defaults: {};
|
13
|
-
}, Readonly<import('
|
15
|
+
}, Readonly<import('.').ExpandProps> & Readonly<{}>, {}, {}, {}, {}, {
|
14
16
|
open: boolean;
|
15
17
|
targetRange: number;
|
16
18
|
transitionTime: number;
|
@@ -18,7 +20,7 @@ export declare const MtExpand: {
|
|
18
20
|
__isFragment?: never;
|
19
21
|
__isTeleport?: never;
|
20
22
|
__isSuspense?: never;
|
21
|
-
} & import('vue').ComponentOptionsBase<Readonly<import('
|
23
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('.').ExpandProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
|
22
24
|
open: boolean;
|
23
25
|
targetRange: number;
|
24
26
|
transitionTime: number;
|
@@ -30,3 +32,4 @@ export declare const MtExpand: {
|
|
30
32
|
}): any;
|
31
33
|
};
|
32
34
|
});
|
35
|
+
export * from './src/expand';
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { ExpandProps } from './expand.ts';
|
2
2
|
declare function __VLS_template(): {
|
3
|
+
attrs: Partial<{}>;
|
3
4
|
slots: {
|
4
5
|
default?(_: {
|
5
6
|
open: boolean;
|
@@ -9,14 +10,16 @@ declare function __VLS_template(): {
|
|
9
10
|
refs: {
|
10
11
|
contentRef: HTMLDivElement;
|
11
12
|
};
|
12
|
-
|
13
|
+
rootEl: HTMLDivElement;
|
13
14
|
};
|
14
15
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
15
16
|
declare const __VLS_component: import('vue').DefineComponent<ExpandProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ExpandProps> & Readonly<{}>, {
|
16
17
|
open: boolean;
|
17
18
|
targetRange: number;
|
18
19
|
transitionTime: number;
|
19
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
20
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
21
|
+
contentRef: HTMLDivElement;
|
22
|
+
}, HTMLDivElement>;
|
20
23
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
21
24
|
export default _default;
|
22
25
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
package/types/index.d.ts
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
export declare const MtSort: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
2
|
+
sortList: {
|
3
|
+
type: import('vue').PropType<(string | number)[]>;
|
4
|
+
default: () => never[];
|
5
|
+
};
|
6
|
+
keyName: {
|
7
|
+
type: StringConstructor;
|
8
|
+
default: string;
|
9
|
+
};
|
10
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
11
|
+
[key: string]: any;
|
12
|
+
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
13
|
+
sortList: {
|
14
|
+
type: import('vue').PropType<(string | number)[]>;
|
15
|
+
default: () => never[];
|
16
|
+
};
|
17
|
+
keyName: {
|
18
|
+
type: StringConstructor;
|
19
|
+
default: string;
|
20
|
+
};
|
21
|
+
}>> & Readonly<{}>, {
|
22
|
+
sortList: (string | number)[];
|
23
|
+
keyName: string;
|
24
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
25
|
+
export * from './src/sort';
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { PropType, VNode } from 'vue';
|
2
|
+
export interface SortSpaceProps {
|
3
|
+
/** 排序配置 */
|
4
|
+
sortList?: (string | number)[];
|
5
|
+
/** 排序key名 */
|
6
|
+
keyName?: string;
|
7
|
+
}
|
8
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
9
|
+
/** 排序配置 */
|
10
|
+
sortList: {
|
11
|
+
type: PropType<(string | number)[]>;
|
12
|
+
default: () => never[];
|
13
|
+
};
|
14
|
+
/** 排序key名 */
|
15
|
+
keyName: {
|
16
|
+
type: StringConstructor;
|
17
|
+
default: string;
|
18
|
+
};
|
19
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
20
|
+
[key: string]: any;
|
21
|
+
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
22
|
+
/** 排序配置 */
|
23
|
+
sortList: {
|
24
|
+
type: PropType<(string | number)[]>;
|
25
|
+
default: () => never[];
|
26
|
+
};
|
27
|
+
/** 排序key名 */
|
28
|
+
keyName: {
|
29
|
+
type: StringConstructor;
|
30
|
+
default: string;
|
31
|
+
};
|
32
|
+
}>> & Readonly<{}>, {
|
33
|
+
sortList: (string | number)[];
|
34
|
+
keyName: string;
|
35
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
36
|
+
export default _default;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
export declare const MtTable: {
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('.').TableProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
|
3
|
+
data: any[];
|
4
|
+
config: import('.').TableConfig[];
|
5
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLTableElement, import('vue').ComponentProvideOptions, {
|
6
|
+
P: {};
|
7
|
+
B: {};
|
8
|
+
D: {};
|
9
|
+
C: {};
|
10
|
+
M: {};
|
11
|
+
Defaults: {};
|
12
|
+
}, Readonly<import('.').TableProps> & Readonly<{}>, {}, {}, {}, {}, {
|
13
|
+
data: any[];
|
14
|
+
config: import('.').TableConfig[];
|
15
|
+
}>;
|
16
|
+
__isFragment?: never;
|
17
|
+
__isTeleport?: never;
|
18
|
+
__isSuspense?: never;
|
19
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('.').TableProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
|
20
|
+
data: any[];
|
21
|
+
config: import('.').TableConfig[];
|
22
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
23
|
+
$slots: {
|
24
|
+
header?(_: {
|
25
|
+
column: import('.').Column;
|
26
|
+
columnIndex: number;
|
27
|
+
row: {
|
28
|
+
columns: import('.').Column[];
|
29
|
+
rowStyle?: import('vue').CSSProperties;
|
30
|
+
headStyle?: import('vue').CSSProperties;
|
31
|
+
};
|
32
|
+
rowIndex: number;
|
33
|
+
}): any;
|
34
|
+
cell?(_: {
|
35
|
+
column: import('.').Column;
|
36
|
+
columnIndex: number;
|
37
|
+
dataIndex: number;
|
38
|
+
record: any;
|
39
|
+
row: {
|
40
|
+
columns: import('.').Column[];
|
41
|
+
rowStyle?: import('vue').CSSProperties;
|
42
|
+
headStyle?: import('vue').CSSProperties;
|
43
|
+
};
|
44
|
+
rowIndex: number;
|
45
|
+
}): any;
|
46
|
+
};
|
47
|
+
});
|
48
|
+
export * from './src/table';
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { CSSProperties } from 'vue';
|
2
|
+
export interface TableProps {
|
3
|
+
/** 表格数据 */
|
4
|
+
data?: any[];
|
5
|
+
/** 表格配置 */
|
6
|
+
config?: TableConfig[];
|
7
|
+
}
|
8
|
+
/** 表体行 */
|
9
|
+
export interface TableConfig {
|
10
|
+
/** 行体样式 */
|
11
|
+
rowStyle?: CSSProperties;
|
12
|
+
/** 表头样式 */
|
13
|
+
headStyle?: CSSProperties;
|
14
|
+
/** 列配置 */
|
15
|
+
columns: Column[];
|
16
|
+
}
|
17
|
+
/** 标体列 */
|
18
|
+
export interface Column {
|
19
|
+
/** 唯一标识key */
|
20
|
+
key?: string;
|
21
|
+
/** 单元格数据字段(配置了才会显示对应数据列) */
|
22
|
+
dataKey?: string;
|
23
|
+
/** 表头名称(配置了才会显示对应列表头) */
|
24
|
+
title?: string;
|
25
|
+
/** 表头格配置 */
|
26
|
+
head?: CellProps;
|
27
|
+
/** 数据格配置 */
|
28
|
+
cell?: CellProps;
|
29
|
+
}
|
30
|
+
/** 单元格属性 */
|
31
|
+
export interface CellProps {
|
32
|
+
/** 样式 */
|
33
|
+
style?: CSSProperties;
|
34
|
+
/** 占用列数 */
|
35
|
+
colSpan?: number;
|
36
|
+
/** 占用行数 */
|
37
|
+
rowSpan?: number;
|
38
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { TableProps } from './table';
|
2
|
+
declare function __VLS_template(): {
|
3
|
+
attrs: Partial<{}>;
|
4
|
+
slots: {
|
5
|
+
header?(_: {
|
6
|
+
column: import('./table').Column;
|
7
|
+
columnIndex: number;
|
8
|
+
row: {
|
9
|
+
columns: import('./table').Column[];
|
10
|
+
rowStyle?: import('vue').CSSProperties;
|
11
|
+
headStyle?: import('vue').CSSProperties;
|
12
|
+
};
|
13
|
+
rowIndex: number;
|
14
|
+
}): any;
|
15
|
+
cell?(_: {
|
16
|
+
column: import('./table').Column;
|
17
|
+
columnIndex: number;
|
18
|
+
dataIndex: number;
|
19
|
+
record: any;
|
20
|
+
row: {
|
21
|
+
columns: import('./table').Column[];
|
22
|
+
rowStyle?: import('vue').CSSProperties;
|
23
|
+
headStyle?: import('vue').CSSProperties;
|
24
|
+
};
|
25
|
+
rowIndex: number;
|
26
|
+
}): any;
|
27
|
+
};
|
28
|
+
refs: {};
|
29
|
+
rootEl: HTMLTableElement;
|
30
|
+
};
|
31
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
32
|
+
declare const __VLS_component: import('vue').DefineComponent<TableProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<TableProps> & Readonly<{}>, {
|
33
|
+
data: any[];
|
34
|
+
config: import('./table').TableConfig[];
|
35
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLTableElement>;
|
36
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
37
|
+
export default _default;
|
38
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
39
|
+
new (): {
|
40
|
+
$slots: S;
|
41
|
+
};
|
42
|
+
};
|