mortise-tenon-design 0.3.0 → 0.4.0-beta.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 +4 -6
- package/es/components/component-neo/index.mjs.map +1 -1
- package/es/components/component-neo/src/component-neo.vue.mjs +13 -13
- package/es/components/component-neo/src/component-neo.vue.mjs.map +1 -1
- package/es/components/component-neo/src/hooks/use-component-neo.mjs +10 -10
- package/es/components/component-neo/src/hooks/use-component-neo.mjs.map +1 -1
- package/es/components/component-neo/src/hooks/use-component-state.mjs +22 -20
- package/es/components/component-neo/src/hooks/use-component-state.mjs.map +1 -1
- package/es/components/expand/index.mjs +4 -6
- package/es/components/expand/index.mjs.map +1 -1
- package/es/components/sort/index.mjs +3 -5
- package/es/components/sort/index.mjs.map +1 -1
- package/es/components/sort/src/sort.mjs +15 -15
- package/es/components/sort/src/sort.mjs.map +1 -1
- package/es/components/table/index.mjs +4 -6
- package/es/components/table/index.mjs.map +1 -1
- package/es/components/utils/install.mjs +9 -0
- package/es/components/utils/install.mjs.map +1 -0
- package/es/core/build-design/installer.mjs +24 -0
- package/es/core/build-design/installer.mjs.map +1 -0
- package/es/core/build-design/package.json.mjs +5 -0
- package/es/core/build-design/package.json.mjs.map +1 -0
- package/es/index.mjs +12 -10
- package/es/index.mjs.map +1 -1
- package/lib/components/component-neo/index.js +1 -1
- package/lib/components/component-neo/index.js.map +1 -1
- package/lib/components/component-neo/src/component-neo.vue.js +1 -1
- package/lib/components/component-neo/src/component-neo.vue.js.map +1 -1
- package/lib/components/component-neo/src/hooks/use-component-neo.js +1 -1
- package/lib/components/component-neo/src/hooks/use-component-neo.js.map +1 -1
- package/lib/components/component-neo/src/hooks/use-component-state.js +1 -1
- package/lib/components/component-neo/src/hooks/use-component-state.js.map +1 -1
- package/lib/components/expand/index.js +1 -1
- package/lib/components/expand/index.js.map +1 -1
- package/lib/components/sort/index.js +1 -1
- package/lib/components/sort/index.js.map +1 -1
- package/lib/components/sort/src/sort.js +1 -1
- package/lib/components/sort/src/sort.js.map +1 -1
- package/lib/components/table/index.js +1 -1
- package/lib/components/table/index.js.map +1 -1
- package/lib/components/utils/install.js +2 -0
- package/lib/components/utils/install.js.map +1 -0
- package/lib/core/build-design/installer.js +2 -0
- package/lib/core/build-design/installer.js.map +1 -0
- package/lib/core/build-design/package.json.js +2 -0
- package/lib/core/build-design/package.json.js.map +1 -0
- package/lib/index.js +1 -1
- package/package.json +6 -1
- package/types/component-neo/index.d.ts +5 -5
- package/types/component-neo/src/component-neo.d.ts +2 -1
- package/types/component-neo/src/component-neo.vue.d.ts +1 -1
- package/types/component-neo/src/hooks/use-component-neo.d.ts +2 -2
- package/types/component-neo/src/hooks/use-component-state.d.ts +13 -5
- package/types/sort/src/sort.d.ts +1 -1
- package/types/utils/install.d.ts +2 -0
@@ -1,11 +1,9 @@
|
|
1
|
-
import o from "
|
1
|
+
import { withInstall as o } from "../utils/install.mjs";
|
2
|
+
import t from "./src/component-neo.vue.mjs";
|
2
3
|
import "vue";
|
3
4
|
import "./src/hooks/use-component-state.mjs";
|
4
|
-
|
5
|
-
o.name && m.component(o.name, o);
|
6
|
-
};
|
7
|
-
const i = o;
|
5
|
+
const n = o(t);
|
8
6
|
export {
|
9
|
-
|
7
|
+
n as MtComponentNeo
|
10
8
|
};
|
11
9
|
//# sourceMappingURL=index.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/component-neo/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/component-neo/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport ComponentNeo from './src/component-neo.vue';\r\n\r\nexport const MtComponentNeo = withInstall(ComponentNeo);\r\n\r\nexport * from './src/component-neo';\r\nexport * from './src/hooks/use-component-neo';\r\n"],"names":["MtComponentNeo","withInstall","ComponentNeo"],"mappings":";;;;AAGa,MAAAA,IAAiBC,EAAYC,CAAY;"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { defineComponent as
|
1
|
+
import { defineComponent as g, useAttrs as _, computed as n, unref as h, h as l, Comment as k, watch as w, nextTick as x, renderSlot as I, createBlock as S, openBlock as b, resolveDynamicComponent as j } from "vue";
|
2
2
|
import { useComponentState as q } from "./hooks/use-component-state.mjs";
|
3
|
-
const
|
3
|
+
const D = /* @__PURE__ */ g({
|
4
4
|
name: "MtComponentNeo",
|
5
5
|
inheritAttrs: !1,
|
6
6
|
__name: "component-neo",
|
@@ -10,25 +10,25 @@ const S = /* @__PURE__ */ N({
|
|
10
10
|
},
|
11
11
|
emits: ["toggleComponent"],
|
12
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 = (
|
14
|
-
const
|
15
|
-
for (const
|
16
|
-
typeof m.value[
|
17
|
-
return Object.assign(
|
18
|
-
}), e = n(() => y.value || s.is), p = n(() => e.value ? l(e.value, u.value) : l(
|
19
|
-
return
|
20
|
-
await
|
21
|
-
}), v({ componentRef: a }), (
|
13
|
+
const s = i, d = f, { initComponent: C } = q(), { componentRef: a, componentNeo: y, componentAttrs: m, componentSlots: A } = C(s.uniqueId), c = (o) => a.value = o, N = _(), u = n(() => {
|
14
|
+
const o = {};
|
15
|
+
for (const t in m.value)
|
16
|
+
typeof m.value[t] < "u" && (o[t] = h(m.value[t]));
|
17
|
+
return Object.assign(o, N);
|
18
|
+
}), e = n(() => y.value || s.is), p = n(() => e.value ? l(e.value, u.value, A.value) : l(k, "ComponentNeo is empty")), r = n(() => typeof e.value == "object" && "name" in e.value ? e.value.name : void 0);
|
19
|
+
return w(e, async () => {
|
20
|
+
await x(), d("toggleComponent", r.value, a.value);
|
21
|
+
}), v({ componentRef: a }), (o, t) => I(o.$slots, "default", {
|
22
22
|
Component: p.value,
|
23
23
|
compRef: c,
|
24
24
|
attrs: u.value,
|
25
25
|
compName: r.value
|
26
26
|
}, () => [
|
27
|
-
(b(),
|
27
|
+
(b(), S(j(p.value), { ref: c }))
|
28
28
|
]);
|
29
29
|
}
|
30
30
|
});
|
31
31
|
export {
|
32
|
-
|
32
|
+
D as default
|
33
33
|
};
|
34
34
|
//# sourceMappingURL=component-neo.vue.mjs.map
|
@@ -1 +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,
|
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, componentSlots } = 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, unknown> = {};\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, componentSlots.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","componentSlots","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,GAAgB,gBAAAC,MAAmBL,EAAcJ,EAAM,QAAQ,GAC7FU,IAAU,CAACC,MAAgBL,EAAa,QAAQK,GAEhDC,IAAcC,EAAS,GAEvBC,IAAYC,EAAS,MAAM;AAC/B,YAAMC,IAAoC,CAAC;AAEhC,iBAAAC,KAAOT,EAAe;AAC/B,QAAI,OAAOA,EAAe,MAAMS,CAAG,IAAM,QACvCD,EAASC,CAAG,IAAIC,EAAMV,EAAe,MAAMS,CAAG,CAAC;AAG5C,aAAA,OAAO,OAAOD,GAAUJ,CAAW;AAAA,IAAA,CAC3C,GAEKO,IAAeJ,EAAS,MAAMR,EAAa,SAASP,EAAM,EAAE,GAE5DoB,IAAYL,EAAS,MACjBI,EAAa,QAA8CE,EAAEF,EAAa,OAAOL,EAAU,OAAOL,EAAe,KAAK,IAAjGY,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,GACfvB,EAAK,mBAAmBqB,EAAS,OAAOjB,EAAa,KAAK;AAAA,IAAA,CAC3D,GAEYoB,EAAA,EAAE,cAAApB,GAAc;;;;;;;;;;"}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import { nextTick as
|
2
|
-
import { useComponentState as
|
3
|
-
function
|
4
|
-
const { setComponent: i, getComponent: s } =
|
5
|
-
async function
|
1
|
+
import { nextTick as u } from "vue";
|
2
|
+
import { useComponentState as C } from "./use-component-state.mjs";
|
3
|
+
function g(r = "") {
|
4
|
+
const { setComponent: i, getComponent: s } = C();
|
5
|
+
async function p(t, c, f) {
|
6
6
|
var l;
|
7
7
|
try {
|
8
8
|
const a = typeof t == "function" ? (await t()).default : t, n = {};
|
9
9
|
for (let e in c) {
|
10
10
|
const o = c[e];
|
11
|
-
e.startsWith("vModel:") ? (e = e.replace("vModel:", ""), n[e] = o, n[`onUpdate:${e}`] = (
|
12
|
-
"value" in o && (o.value =
|
11
|
+
e.startsWith("vModel:") ? (e = e.replace("vModel:", ""), n[e] = o, n[`onUpdate:${e}`] = (m) => {
|
12
|
+
"value" in o && (o.value = m);
|
13
13
|
}) : n[e] = o;
|
14
14
|
}
|
15
|
-
return i(r, a, n), await
|
15
|
+
return i(r, { comp: a, attrs: n, slots: f || {} }), await u(), (l = s(r)) == null ? void 0 : l.Instance.value;
|
16
16
|
} catch (a) {
|
17
17
|
console.error(a);
|
18
18
|
}
|
@@ -22,10 +22,10 @@ function d(r = "") {
|
|
22
22
|
var t;
|
23
23
|
return (t = s(r)) == null ? void 0 : t.Instance.value;
|
24
24
|
},
|
25
|
-
toggleComponent:
|
25
|
+
toggleComponent: p
|
26
26
|
};
|
27
27
|
}
|
28
28
|
export {
|
29
|
-
|
29
|
+
g as useComponentNeo
|
30
30
|
};
|
31
31
|
//# sourceMappingURL=use-component-neo.mjs.map
|
@@ -1 +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
|
1
|
+
{"version":3,"file":"use-component-neo.mjs","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-neo.ts"],"sourcesContent":["import type { VNode } from 'vue';\r\nimport type { ComponentSlots, InstanceComponent } from '../component-neo';\r\nimport { nextTick } 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.组件类型 3.VNode\r\n * @param attrs 组件属性,可使用`on事件`方式添加事件方法,属性支持Ref类型进行绑定以实现动态变化, 支持通过{'vModal:value': value}方式双向绑定数据\r\n * @param slots 组件插槽\r\n */\r\n async function toggleComponent(comp?: DynamicComponent, attrs?: Record<string, any>, slots?: ComponentSlots) {\r\n try {\r\n const renderComp = typeof comp === 'function' ? (await (comp as ImportComponentFn)()).default : comp;\r\n const renderAttrs: Record<string, unknown> = {};\r\n for (let key in attrs) {\r\n const bindValue = attrs[key];\r\n // 兼容vModel\r\n if (key.startsWith('vModel:')) {\r\n key = key.replace('vModel:', '');\r\n renderAttrs[key] = bindValue;\r\n renderAttrs[`onUpdate:${key}`] = (value: unknown) => {\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, { comp: renderComp, attrs: renderAttrs, slots: slots || {} });\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","slots","renderComp","renderAttrs","key","bindValue","value","nextTick","_a","e"],"mappings":";;AAQgB,SAAAA,EAAgBC,IAAW,IAAI;AAC7C,QAAM,EAAE,cAAAC,GAAc,cAAAC,EAAa,IAAIC,EAAkB;AAQ1C,iBAAAC,EAAgBC,GAAyBC,GAA6BC,GAAwB;;AACvG,QAAA;AACF,YAAMC,IAAa,OAAOH,KAAS,cAAc,MAAOA,EAAA,GAA8B,UAAUA,GAC1FI,IAAuC,CAAC;AAC9C,eAASC,KAAOJ,GAAO;AACf,cAAAK,IAAYL,EAAMI,CAAG;AAEvB,QAAAA,EAAI,WAAW,SAAS,KACpBA,IAAAA,EAAI,QAAQ,WAAW,EAAE,GAC/BD,EAAYC,CAAG,IAAIC,GACnBF,EAAY,YAAYC,CAAG,EAAE,IAAI,CAACE,MAAmB;AACnD,UAAI,WAAWD,MACbA,EAAU,QAAQC;AAAA,QAEtB,KAGAH,EAAYC,CAAG,IAAIC;AAAA,MACrB;AAEW,aAAAV,EAAAD,GAAU,EAAE,MAAMQ,GAAY,OAAOC,GAAa,OAAOF,KAAS,CAAA,GAAI,GACnF,MAAMM,EAAS,IACRC,IAAAZ,EAAaF,CAAQ,MAArB,gBAAAc,EAAwB,SAAS;AAAA,aAEnCC,GAAG;AACR,cAAQ,MAAMA,CAAC;AAAA,IAAA;AAAA,EACjB;AAEK,SAAA;AAAA,IACL,iBAAiB,MAAA;;AAAM,cAAAD,IAAAZ,EAAaF,CAAQ,MAArB,gBAAAc,EAAwB,SAAS;AAAA;AAAA,IACxD,iBAAAV;AAAA,EACF;AACF;"}
|
@@ -1,34 +1,36 @@
|
|
1
|
-
import { createGlobalState as
|
2
|
-
import { ref as
|
3
|
-
const
|
1
|
+
import { createGlobalState as v } from "@vueuse/core";
|
2
|
+
import { ref as c, shallowRef as i, onBeforeUnmount as C } from "vue";
|
3
|
+
const M = v(() => {
|
4
4
|
const a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
5
|
-
function
|
6
|
-
let
|
7
|
-
|
8
|
-
Instance:
|
5
|
+
function l(t = "") {
|
6
|
+
let o = n.get(t);
|
7
|
+
o || (o = {
|
8
|
+
Instance: c(),
|
9
9
|
comp: i(),
|
10
|
-
attrs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
attrs: c({}),
|
11
|
+
slots: c({})
|
12
|
+
}, n.set(t, o), C(() => m(t)));
|
13
|
+
const e = a.get(t);
|
14
|
+
return e && (o.comp.value = e.comp, o.attrs.value = e.attrs, o.slots.value = e.slots), {
|
15
|
+
componentRef: o.Instance,
|
16
|
+
componentNeo: o.comp,
|
17
|
+
componentAttrs: o.attrs,
|
18
|
+
componentSlots: o.slots
|
17
19
|
};
|
18
20
|
}
|
19
21
|
function p(t = "") {
|
20
22
|
return n.get(t);
|
21
23
|
}
|
22
|
-
function
|
24
|
+
function m(t = "") {
|
23
25
|
a.delete(t), n.delete(t);
|
24
26
|
}
|
25
|
-
function
|
26
|
-
const
|
27
|
-
|
27
|
+
function u(t = "", o) {
|
28
|
+
const { comp: e, attrs: r, slots: f } = o, s = p(t);
|
29
|
+
s && (s.comp.value = e, s.attrs.value = r, s.slots.value = f), a.set(t, { comp: e, attrs: r, slots: f });
|
28
30
|
}
|
29
|
-
return { initComponent:
|
31
|
+
return { initComponent: l, setComponent: u, getComponent: p, removeComponent: m };
|
30
32
|
});
|
31
33
|
export {
|
32
|
-
|
34
|
+
M as useComponentState
|
33
35
|
};
|
34
36
|
//# sourceMappingURL=use-component-state.mjs.map
|
@@ -1 +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,
|
1
|
+
{"version":3,"file":"use-component-state.mjs","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-state.ts"],"sourcesContent":["import type { Ref, ShallowRef, VNode } from 'vue';\r\nimport type { ComponentSlots, InstanceComponent } from '../component-neo';\r\nimport { createGlobalState } from '@vueuse/core';\r\nimport { onBeforeUnmount, ref, shallowRef } 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, unknown>>\r\n /** 插槽 */\r\n slots: Ref<ComponentSlots>\r\n}\r\n\r\ninterface ComponentData {\r\n comp?: InstanceComponent | VNode\r\n attrs: Record<string, unknown>\r\n slots: ComponentSlots\r\n}\r\n\r\n/** 组件状态 */\r\nexport const useComponentState = createGlobalState(() => {\r\n /** 缓存组件数据,组件未实例化时,可先缓存后赋值 */\r\n const dataBufferMap = new Map<string, ComponentData>();\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, unknown>>({}),\r\n slots: ref<ComponentSlots>({}),\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 componentRefs.slots.value = bufferData.slots;\r\n }\r\n\r\n return {\r\n componentRef: componentRefs.Instance,\r\n componentNeo: componentRefs.comp,\r\n componentAttrs: componentRefs.attrs,\r\n componentSlots: componentRefs.slots,\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 = '', args: ComponentData) {\r\n const { comp, attrs, slots } = args;\r\n const componentRefs = getComponent(uniqueId);\r\n if (componentRefs) {\r\n componentRefs.comp.value = comp;\r\n componentRefs.attrs.value = attrs;\r\n componentRefs.slots.value = slots;\r\n }\r\n dataBufferMap.set(uniqueId, { comp, attrs, slots });\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","args","comp","attrs","slots"],"mappings":";;AAuBa,MAAAA,IAAoBC,EAAkB,MAAM;AAEjD,QAAAC,wBAAoB,IAA2B,GAE/CC,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,EAA6B,EAAE;AAAA,MACtC,OAAOA,EAAoB,CAAE,CAAA;AAAA,IAC/B,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,OACzBL,EAAA,MAAM,QAAQK,EAAW,QAGlC;AAAA,MACL,cAAcL,EAAc;AAAA,MAC5B,cAAcA,EAAc;AAAA,MAC5B,gBAAgBA,EAAc;AAAA,MAC9B,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;AAIzB,WAAAQ,EAAaR,IAAW,IAAIS,GAAqB;AACxD,UAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,OAAAC,EAAU,IAAAH,GACzBR,IAAgBM,EAAaP,CAAQ;AAC3C,IAAIC,MACFA,EAAc,KAAK,QAAQS,GAC3BT,EAAc,MAAM,QAAQU,GAC5BV,EAAc,MAAM,QAAQW,IAE9Bf,EAAc,IAAIG,GAAU,EAAE,MAAAU,GAAM,OAAAC,GAAO,OAAAC,GAAO;AAAA,EAAA;AAGpD,SAAO,EAAE,eAAAb,GAAe,cAAAS,GAAc,cAAAD,GAAc,iBAAAF,EAAgB;AACtE,CAAC;"}
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
const a = n;
|
1
|
+
import { withInstall as t } from "../utils/install.mjs";
|
2
|
+
import o from "./src/expand.vue.mjs";
|
3
|
+
const m = t(o);
|
6
4
|
export {
|
7
|
-
|
5
|
+
m as MtExpand
|
8
6
|
};
|
9
7
|
//# sourceMappingURL=index.mjs.map
|
10
8
|
import './src/expand.css';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Expand from './src/expand.vue';\r\n\r\nexport const MtExpand = withInstall(Expand);\r\n\r\nexport * from './src/expand';\r\n"],"names":["MtExpand","withInstall","Expand"],"mappings":";;AAGa,MAAAA,IAAWC,EAAYC,CAAM;"}
|
@@ -1,9 +1,7 @@
|
|
1
|
+
import { withInstall as t } from "../utils/install.mjs";
|
1
2
|
import o from "./src/sort.mjs";
|
2
|
-
|
3
|
-
o.name && t.component(o.name, o);
|
4
|
-
};
|
5
|
-
const m = o;
|
3
|
+
const i = t(o);
|
6
4
|
export {
|
7
|
-
|
5
|
+
i as MtSort
|
8
6
|
};
|
9
7
|
//# sourceMappingURL=index.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/sort/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/sort/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Sort from './src/sort';\r\n\r\nexport const MtSort = withInstall(Sort);\r\n\r\nexport * from './src/sort';\r\n"],"names":["MtSort","withInstall","Sort"],"mappings":";;AAGa,MAAAA,IAASC,EAAYC,CAAI;"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { defineComponent as l, computed as
|
2
|
-
const
|
1
|
+
import { defineComponent as l, computed as y } from "vue";
|
2
|
+
const h = l({
|
3
3
|
name: "MtSort",
|
4
4
|
props: {
|
5
5
|
/** 排序配置 */
|
@@ -14,34 +14,34 @@ const d = l({
|
|
14
14
|
}
|
15
15
|
},
|
16
16
|
setup(t, { slots: s }) {
|
17
|
-
const o =
|
18
|
-
var
|
19
|
-
const e = ((
|
17
|
+
const o = y(() => {
|
18
|
+
var i;
|
19
|
+
const e = ((i = s.default) == null ? void 0 : i.call(s)) || [], n = a(t.keyName, e), r = Array.from(new Set(t.sortList)).map((c) => n[c]).filter(Boolean);
|
20
20
|
return u(t.keyName, e, t.sortList, r);
|
21
21
|
});
|
22
22
|
return () => o.value;
|
23
23
|
}
|
24
24
|
});
|
25
|
-
function
|
25
|
+
function a(t, s, o = {}) {
|
26
26
|
return s.forEach((e) => {
|
27
27
|
var r;
|
28
28
|
const n = (r = e.props) == null ? void 0 : r[t];
|
29
29
|
if (n) {
|
30
|
-
o[n] ? console.warn(`<mt-sort
|
30
|
+
o[n] ? console.warn(`<mt-sort> ${t}: ${n} repeat`) : o[n] = e;
|
31
31
|
return;
|
32
32
|
}
|
33
|
-
Array.isArray(e.children) &&
|
33
|
+
Array.isArray(e.children) && a(t, e.children, o);
|
34
34
|
}), o;
|
35
35
|
}
|
36
36
|
function u(t, s, o, e) {
|
37
37
|
const n = [];
|
38
38
|
return s.forEach((r) => {
|
39
|
-
var
|
40
|
-
const
|
41
|
-
if (
|
42
|
-
const
|
43
|
-
if (
|
44
|
-
n.push(
|
39
|
+
var c;
|
40
|
+
const i = (c = r.props) == null ? void 0 : c[t];
|
41
|
+
if (i && o.includes(i)) {
|
42
|
+
const f = e.shift();
|
43
|
+
if (f) {
|
44
|
+
n.push(f);
|
45
45
|
return;
|
46
46
|
}
|
47
47
|
}
|
@@ -49,6 +49,6 @@ function u(t, s, o, e) {
|
|
49
49
|
}), n;
|
50
50
|
}
|
51
51
|
export {
|
52
|
-
|
52
|
+
h as default
|
53
53
|
};
|
54
54
|
//# sourceMappingURL=sort.mjs.map
|
@@ -1 +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
|
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 SortProps {\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> ${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,aAAaH,CAAO,KAAKG,CAAO,SAAS,IAGtDF,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;"}
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
const t = e;
|
1
|
+
import { withInstall as t } from "../utils/install.mjs";
|
2
|
+
import o from "./src/table.vue.mjs";
|
3
|
+
const m = t(o);
|
6
4
|
export {
|
7
|
-
|
5
|
+
m as MtTable
|
8
6
|
};
|
9
7
|
//# sourceMappingURL=index.mjs.map
|
10
8
|
import './src/table.css';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/table/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/table/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Table from './src/table.vue';\r\n\r\nexport const MtTable = withInstall(Table);\r\n\r\nexport * from './src/table';\r\n"],"names":["MtTable","withInstall","Table"],"mappings":";;AAGa,MAAAA,IAAUC,EAAYC,CAAK;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"install.mjs","sources":["../../../../../packages/components/utils/install.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\r\n\r\nexport function withInstall<T extends Component>(comp: T) {\r\n (comp as T & Plugin).install = (app: App): void => {\r\n if (comp.name) {\r\n app.component(comp.name, comp);\r\n }\r\n };\r\n return comp;\r\n}\r\n"],"names":["withInstall","comp","app"],"mappings":"AAEO,SAASA,EAAiCC,GAAS;AACvD,SAAAA,EAAoB,UAAU,CAACC,MAAmB;AACjD,IAAID,EAAK,QACHC,EAAA,UAAUD,EAAK,MAAMA,CAAI;AAAA,EAEjC,GACOA;AACT;"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { MtComponentNeo as e } from "../../components/component-neo/index.mjs";
|
2
|
+
import { MtExpand as m } from "../../components/expand/index.mjs";
|
3
|
+
import { MtSort as i } from "../../components/sort/index.mjs";
|
4
|
+
import { MtTable as l } from "../../components/table/index.mjs";
|
5
|
+
import { version as s } from "./package.json.mjs";
|
6
|
+
const o = Symbol("MT_INSTALLED_KEY");
|
7
|
+
function f(r = []) {
|
8
|
+
return {
|
9
|
+
version: s,
|
10
|
+
install: (t) => {
|
11
|
+
t[o] || (t[o] = !0, r.forEach((n) => t.use(n)));
|
12
|
+
}
|
13
|
+
};
|
14
|
+
}
|
15
|
+
const L = f([
|
16
|
+
e,
|
17
|
+
m,
|
18
|
+
i,
|
19
|
+
l
|
20
|
+
]);
|
21
|
+
export {
|
22
|
+
L as default
|
23
|
+
};
|
24
|
+
//# sourceMappingURL=installer.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"installer.mjs","sources":["../../../../../packages/core/build-design/installer.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\r\nimport {\r\n MtComponentNeo,\r\n MtExpand,\r\n MtSort,\r\n MtTable,\r\n} from '@mortise-tenon/components';\r\nimport { version } from './package.json';\r\n\r\nconst INSTALLED_KEY = Symbol('MT_INSTALLED_KEY');\r\n\r\nfunction makeInstaller(components: Component[] = []) {\r\n const install = (app: App & { [INSTALLED_KEY]?: boolean }) => {\r\n if (app[INSTALLED_KEY])\r\n return;\r\n\r\n app[INSTALLED_KEY] = true;\r\n components.forEach(c => app.use(c as Plugin));\r\n };\r\n\r\n return {\r\n version,\r\n install,\r\n };\r\n}\r\n\r\nexport default makeInstaller([\r\n MtComponentNeo,\r\n MtExpand,\r\n MtSort,\r\n MtTable,\r\n]);\r\n"],"names":["INSTALLED_KEY","makeInstaller","components","version","app","c","installer","MtComponentNeo","MtExpand","MtSort","MtTable"],"mappings":";;;;;AASA,MAAMA,IAAgB,OAAO,kBAAkB;AAE/C,SAASC,EAAcC,IAA0B,IAAI;AAS5C,SAAA;AAAA,IACL,SAAAC;AAAA,IACA,SAVc,CAACC,MAA6C;AAC5D,MAAIA,EAAIJ,CAAa,MAGrBI,EAAIJ,CAAa,IAAI,IACrBE,EAAW,QAAQ,CAAAG,MAAKD,EAAI,IAAIC,CAAW,CAAC;AAAA,IAC9C;AAAA,EAKA;AACF;AAEA,MAAAC,IAAeL,EAAc;AAAA,EAC3BM;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AACF,CAAC;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/es/index.mjs
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
1
|
+
import t from "./core/build-design/installer.mjs";
|
2
|
+
import { MtComponentNeo as p } from "./components/component-neo/index.mjs";
|
3
|
+
import { MtExpand as f } from "./components/expand/index.mjs";
|
4
|
+
import { MtSort as n } from "./components/sort/index.mjs";
|
5
|
+
import { MtTable as l } from "./components/table/index.mjs";
|
6
|
+
import { useComponentNeo as s } from "./components/component-neo/src/hooks/use-component-neo.mjs";
|
6
7
|
export {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
p as MtComponentNeo,
|
9
|
+
f as MtExpand,
|
10
|
+
n as MtSort,
|
11
|
+
l as MtTable,
|
12
|
+
t as default,
|
13
|
+
s as useComponentNeo
|
12
14
|
};
|
13
15
|
//# 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":";;;;;;"}
|
@@ -1,2 +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");
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.js"),t=require("./src/component-neo.vue.js");require("vue");require("./src/hooks/use-component-state.js");const o=e.withInstall(t.default);exports.MtComponentNeo=o;
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/components/component-neo/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/component-neo/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport ComponentNeo from './src/component-neo.vue';\r\n\r\nexport const MtComponentNeo = withInstall(ComponentNeo);\r\n\r\nexport * from './src/component-neo';\r\nexport * from './src/hooks/use-component-neo';\r\n"],"names":["MtComponentNeo","withInstall","ComponentNeo"],"mappings":"4NAGa,MAAAA,EAAiBC,cAAYC,EAAY,OAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),_=require("./hooks/use-component-state.js"),A=e.defineComponent({name:"MtComponentNeo",inheritAttrs:!1,__name:"component-neo",props:{uniqueId:{default:""},is:{}},emits:["toggleComponent"],setup(l,{expose:i,emit:v}){const c=l,d=v,{initComponent:f}=_.useComponentState(),{componentRef:u,componentNeo:C,componentAttrs:s,componentSlots:g}=f(c.uniqueId),a=o=>u.value=o,y=e.useAttrs(),m=e.computed(()=>{const o={};for(const n in s.value)typeof s.value[n]<"u"&&(o[n]=e.unref(s.value[n]));return Object.assign(o,y)}),t=e.computed(()=>C.value||c.is),p=e.computed(()=>t.value?e.h(t.value,m.value,g.value):e.h(e.Comment,"ComponentNeo is empty")),r=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",r.value,u.value)}),i({componentRef:u}),(o,n)=>e.renderSlot(o.$slots,"default",{Component:p.value,compRef:a,attrs:m.value,compName:r.value},()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p.value),{ref:a}))])}});exports.default=A;
|
2
2
|
//# sourceMappingURL=component-neo.vue.js.map
|
@@ -1 +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,
|
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, componentSlots } = 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, unknown> = {};\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, componentSlots.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","componentSlots","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,EAAgB,eAAAC,GAAmBL,EAAcJ,EAAM,QAAQ,EAC7FU,EAAWC,GAAgBL,EAAa,MAAQK,EAEhDC,EAAcC,EAAAA,SAAS,EAEvBC,EAAYC,EAAAA,SAAS,IAAM,CAC/B,MAAMC,EAAoC,CAAC,EAEhC,UAAAC,KAAOT,EAAe,MAC3B,OAAOA,EAAe,MAAMS,CAAG,EAAM,MACvCD,EAASC,CAAG,EAAIC,EAAAA,MAAMV,EAAe,MAAMS,CAAG,CAAC,GAG5C,OAAA,OAAO,OAAOD,EAAUJ,CAAW,CAAA,CAC3C,EAEKO,EAAeJ,EAAAA,SAAS,IAAMR,EAAa,OAASP,EAAM,EAAE,EAE5DoB,EAAYL,EAAAA,SAAS,IACjBI,EAAa,MAA8CE,IAAEF,EAAa,MAAOL,EAAU,MAAOL,EAAe,KAAK,EAAjGY,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,EACfvB,EAAK,kBAAmBqB,EAAS,MAAOjB,EAAa,KAAK,CAAA,CAC3D,EAEYoB,EAAA,CAAE,aAAApB,EAAc"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("vue"),C=require("./use-component-state.js");function v(r=""){const{setComponent:u,getComponent:a}=C.useComponentState();async function i(t,c,p){var l;try{const s=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}`]=f=>{"value"in o&&(o.value=f)}):n[e]=o}return u(r,{comp:s,attrs:n,slots:p||{}}),await m.nextTick(),(l=a(r))==null?void 0:l.Instance.value}catch(s){console.error(s)}}return{getComponentRef:()=>{var t;return(t=a(r))==null?void 0:t.Instance.value},toggleComponent:i}}exports.useComponentNeo=v;
|
2
2
|
//# sourceMappingURL=use-component-neo.js.map
|
@@ -1 +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
|
1
|
+
{"version":3,"file":"use-component-neo.js","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-neo.ts"],"sourcesContent":["import type { VNode } from 'vue';\r\nimport type { ComponentSlots, InstanceComponent } from '../component-neo';\r\nimport { nextTick } 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.组件类型 3.VNode\r\n * @param attrs 组件属性,可使用`on事件`方式添加事件方法,属性支持Ref类型进行绑定以实现动态变化, 支持通过{'vModal:value': value}方式双向绑定数据\r\n * @param slots 组件插槽\r\n */\r\n async function toggleComponent(comp?: DynamicComponent, attrs?: Record<string, any>, slots?: ComponentSlots) {\r\n try {\r\n const renderComp = typeof comp === 'function' ? (await (comp as ImportComponentFn)()).default : comp;\r\n const renderAttrs: Record<string, unknown> = {};\r\n for (let key in attrs) {\r\n const bindValue = attrs[key];\r\n // 兼容vModel\r\n if (key.startsWith('vModel:')) {\r\n key = key.replace('vModel:', '');\r\n renderAttrs[key] = bindValue;\r\n renderAttrs[`onUpdate:${key}`] = (value: unknown) => {\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, { comp: renderComp, attrs: renderAttrs, slots: slots || {} });\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","slots","renderComp","renderAttrs","key","bindValue","value","nextTick","_a","e"],"mappings":"6IAQgB,SAAAA,EAAgBC,EAAW,GAAI,CAC7C,KAAM,CAAE,aAAAC,EAAc,aAAAC,CAAa,EAAIC,oBAAkB,EAQ1C,eAAAC,EAAgBC,EAAyBC,EAA6BC,EAAwB,OACvG,GAAA,CACF,MAAMC,EAAa,OAAOH,GAAS,YAAc,MAAOA,EAAA,GAA8B,QAAUA,EAC1FI,EAAuC,CAAC,EAC9C,QAASC,KAAOJ,EAAO,CACf,MAAAK,EAAYL,EAAMI,CAAG,EAEvBA,EAAI,WAAW,SAAS,GACpBA,EAAAA,EAAI,QAAQ,UAAW,EAAE,EAC/BD,EAAYC,CAAG,EAAIC,EACnBF,EAAY,YAAYC,CAAG,EAAE,EAAKE,GAAmB,CAC/C,UAAWD,IACbA,EAAU,MAAQC,EAEtB,GAGAH,EAAYC,CAAG,EAAIC,CACrB,CAEW,OAAAV,EAAAD,EAAU,CAAE,KAAMQ,EAAY,MAAOC,EAAa,MAAOF,GAAS,CAAA,EAAI,EACnF,MAAMM,WAAS,GACRC,EAAAZ,EAAaF,CAAQ,IAArB,YAAAc,EAAwB,SAAS,YAEnCC,EAAG,CACR,QAAQ,MAAMA,CAAC,CAAA,CACjB,CAEK,MAAA,CACL,gBAAiB,IAAA,OAAM,OAAAD,EAAAZ,EAAaF,CAAQ,IAArB,YAAAc,EAAwB,SAAS,OACxD,gBAAAV,CACF,CACF"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vueuse/core"),n=require("vue"),v=i.createGlobalState(()=>{const a=new Map,s=new Map;function f(t=""){let e=s.get(t);e||(e={Instance:n.ref(),comp:n.shallowRef(),attrs:n.ref({}),slots:n.ref({})},s.set(t,e),n.onBeforeUnmount(()=>p(t)));const o=a.get(t);return o&&(e.comp.value=o.comp,e.attrs.value=o.attrs,e.slots.value=o.slots),{componentRef:e.Instance,componentNeo:e.comp,componentAttrs:e.attrs,componentSlots:e.slots}}function r(t=""){return s.get(t)}function p(t=""){a.delete(t),s.delete(t)}function u(t="",e){const{comp:o,attrs:l,slots:m}=e,c=r(t);c&&(c.comp.value=o,c.attrs.value=l,c.slots.value=m),a.set(t,{comp:o,attrs:l,slots:m})}return{initComponent:f,setComponent:u,getComponent:r,removeComponent:p}});exports.useComponentState=v;
|
2
2
|
//# sourceMappingURL=use-component-state.js.map
|
@@ -1 +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,
|
1
|
+
{"version":3,"file":"use-component-state.js","sources":["../../../../../../../packages/components/component-neo/src/hooks/use-component-state.ts"],"sourcesContent":["import type { Ref, ShallowRef, VNode } from 'vue';\r\nimport type { ComponentSlots, InstanceComponent } from '../component-neo';\r\nimport { createGlobalState } from '@vueuse/core';\r\nimport { onBeforeUnmount, ref, shallowRef } 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, unknown>>\r\n /** 插槽 */\r\n slots: Ref<ComponentSlots>\r\n}\r\n\r\ninterface ComponentData {\r\n comp?: InstanceComponent | VNode\r\n attrs: Record<string, unknown>\r\n slots: ComponentSlots\r\n}\r\n\r\n/** 组件状态 */\r\nexport const useComponentState = createGlobalState(() => {\r\n /** 缓存组件数据,组件未实例化时,可先缓存后赋值 */\r\n const dataBufferMap = new Map<string, ComponentData>();\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, unknown>>({}),\r\n slots: ref<ComponentSlots>({}),\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 componentRefs.slots.value = bufferData.slots;\r\n }\r\n\r\n return {\r\n componentRef: componentRefs.Instance,\r\n componentNeo: componentRefs.comp,\r\n componentAttrs: componentRefs.attrs,\r\n componentSlots: componentRefs.slots,\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 = '', args: ComponentData) {\r\n const { comp, attrs, slots } = args;\r\n const componentRefs = getComponent(uniqueId);\r\n if (componentRefs) {\r\n componentRefs.comp.value = comp;\r\n componentRefs.attrs.value = attrs;\r\n componentRefs.slots.value = slots;\r\n }\r\n dataBufferMap.set(uniqueId, { comp, attrs, slots });\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","args","comp","attrs","slots"],"mappings":"iIAuBaA,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,EAA6B,IAAA,EAAE,EACtC,MAAOA,EAAoB,IAAA,CAAE,CAAA,CAC/B,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,MACzBL,EAAA,MAAM,MAAQK,EAAW,OAGlC,CACL,aAAcL,EAAc,SAC5B,aAAcA,EAAc,KAC5B,eAAgBA,EAAc,MAC9B,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,CAIzB,SAAAQ,EAAaR,EAAW,GAAIS,EAAqB,CACxD,KAAM,CAAE,KAAAC,EAAM,MAAAC,EAAO,MAAAC,CAAU,EAAAH,EACzBR,EAAgBM,EAAaP,CAAQ,EACvCC,IACFA,EAAc,KAAK,MAAQS,EAC3BT,EAAc,MAAM,MAAQU,EAC5BV,EAAc,MAAM,MAAQW,GAE9Bf,EAAc,IAAIG,EAAU,CAAE,KAAAU,EAAM,MAAAC,EAAO,MAAAC,EAAO,CAAA,CAGpD,MAAO,CAAE,cAAAb,EAAe,aAAAS,EAAc,aAAAD,EAAc,gBAAAF,CAAgB,CACtE,CAAC"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./src/expand.vue.js")
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.js"),e=require("./src/expand.vue.js"),n=t.withInstall(e.default);exports.MtExpand=n;
|
2
2
|
//# sourceMappingURL=index.js.map
|
3
3
|
require('./src/expand.css');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/expand/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Expand from './src/expand.vue';\r\n\r\nexport const MtExpand = withInstall(Expand);\r\n\r\nexport * from './src/expand';\r\n"],"names":["MtExpand","withInstall","Expand"],"mappings":"wJAGaA,EAAWC,cAAYC,EAAM,OAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./src/sort.js")
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.js"),e=require("./src/sort.js"),r=t.withInstall(e.default);exports.MtSort=r;
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/components/sort/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/sort/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Sort from './src/sort';\r\n\r\nexport const MtSort = withInstall(Sort);\r\n\r\nexport * from './src/sort';\r\n"],"names":["MtSort","withInstall","Sort"],"mappings":"kJAGaA,EAASC,cAAYC,EAAI,OAAA"}
|
@@ -1,2 +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
|
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> ${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
2
|
//# sourceMappingURL=sort.js.map
|
@@ -1 +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
|
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 SortProps {\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> ${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,aAAaH,CAAO,KAAKG,CAAO,SAAS,EAGtDF,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"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./src/table.vue.js")
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/install.js"),e=require("./src/table.vue.js"),l=t.withInstall(e.default);exports.MtTable=l;
|
2
2
|
//# sourceMappingURL=index.js.map
|
3
3
|
require('./src/table.css');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/components/table/index.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/table/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Table from './src/table.vue';\r\n\r\nexport const MtTable = withInstall(Table);\r\n\r\nexport * from './src/table';\r\n"],"names":["MtTable","withInstall","Table"],"mappings":"uJAGaA,EAAUC,cAAYC,EAAK,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"install.js","sources":["../../../../../packages/components/utils/install.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\r\n\r\nexport function withInstall<T extends Component>(comp: T) {\r\n (comp as T & Plugin).install = (app: App): void => {\r\n if (comp.name) {\r\n app.component(comp.name, comp);\r\n }\r\n };\r\n return comp;\r\n}\r\n"],"names":["withInstall","comp","app"],"mappings":"gFAEO,SAASA,EAAiCC,EAAS,CACvD,OAAAA,EAAoB,QAAWC,GAAmB,CAC7CD,EAAK,MACHC,EAAA,UAAUD,EAAK,KAAMA,CAAI,CAEjC,EACOA,CACT"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../../components/component-neo/index.js"),s=require("../../components/expand/index.js"),u=require("../../components/sort/index.js"),l=require("../../components/table/index.js"),c=require("./package.json.js"),t=Symbol("MT_INSTALLED_KEY");function a(n=[]){const r=e=>{e[t]||(e[t]=!0,n.forEach(o=>e.use(o)))};return{version:c.version,install:r}}const d=a([i.MtComponentNeo,s.MtExpand,u.MtSort,l.MtTable]);exports.default=d;
|
2
|
+
//# sourceMappingURL=installer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"installer.js","sources":["../../../../../packages/core/build-design/installer.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\r\nimport {\r\n MtComponentNeo,\r\n MtExpand,\r\n MtSort,\r\n MtTable,\r\n} from '@mortise-tenon/components';\r\nimport { version } from './package.json';\r\n\r\nconst INSTALLED_KEY = Symbol('MT_INSTALLED_KEY');\r\n\r\nfunction makeInstaller(components: Component[] = []) {\r\n const install = (app: App & { [INSTALLED_KEY]?: boolean }) => {\r\n if (app[INSTALLED_KEY])\r\n return;\r\n\r\n app[INSTALLED_KEY] = true;\r\n components.forEach(c => app.use(c as Plugin));\r\n };\r\n\r\n return {\r\n version,\r\n install,\r\n };\r\n}\r\n\r\nexport default makeInstaller([\r\n MtComponentNeo,\r\n MtExpand,\r\n MtSort,\r\n MtTable,\r\n]);\r\n"],"names":["INSTALLED_KEY","makeInstaller","components","install","app","c","version","installer","MtComponentNeo","MtExpand","MtSort","MtTable"],"mappings":"6UASMA,EAAgB,OAAO,kBAAkB,EAE/C,SAASC,EAAcC,EAA0B,GAAI,CAC7C,MAAAC,EAAWC,GAA6C,CACxDA,EAAIJ,CAAa,IAGrBI,EAAIJ,CAAa,EAAI,GACrBE,EAAW,QAAQG,GAAKD,EAAI,IAAIC,CAAW,CAAC,EAC9C,EAEO,MAAA,CAAA,QACLC,EAAA,QACA,QAAAH,CACF,CACF,CAEA,MAAAI,EAAeN,EAAc,CAC3BO,EAAA,eACAC,EAAA,SACAC,EAAA,OACAC,EAAAA,OACF,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./core/build-design/installer.js"),t=require("./components/component-neo/index.js"),o=require("./components/expand/index.js"),n=require("./components/sort/index.js"),r=require("./components/table/index.js"),u=require("./components/component-neo/src/hooks/use-component-neo.js");exports.default=e.default;exports.MtComponentNeo=t.MtComponentNeo;exports.MtExpand=o.MtExpand;exports.MtSort=n.MtSort;exports.MtTable=r.MtTable;exports.useComponentNeo=u.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.
|
4
|
+
"version": "0.4.0-beta.1",
|
5
5
|
"description": "榫卯组件库",
|
6
6
|
"author": "nixwai",
|
7
7
|
"license": "ISC",
|
@@ -9,6 +9,11 @@
|
|
9
9
|
"type": "git",
|
10
10
|
"url": "https://github.com/nixwai/mortise-tenon"
|
11
11
|
},
|
12
|
+
"exports": {
|
13
|
+
"./global": {
|
14
|
+
"types": "./global.d.ts"
|
15
|
+
}
|
16
|
+
},
|
12
17
|
"main": "lib/index.js",
|
13
18
|
"module": "es/index.mjs",
|
14
19
|
"types": "types/index.d.ts",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export declare const MtComponentNeo: {
|
2
|
-
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('.').ComponentNeoProps> & Readonly<{
|
3
3
|
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
4
4
|
}>, {
|
5
5
|
componentRef: import('vue').Ref<any, any>;
|
@@ -14,7 +14,7 @@ export declare const MtComponentNeo: {
|
|
14
14
|
C: {};
|
15
15
|
M: {};
|
16
16
|
Defaults: {};
|
17
|
-
}, Readonly<import('
|
17
|
+
}, Readonly<import('.').ComponentNeoProps> & Readonly<{
|
18
18
|
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
19
19
|
}>, {
|
20
20
|
componentRef: import('vue').Ref<any, any>;
|
@@ -24,7 +24,7 @@ export declare const MtComponentNeo: {
|
|
24
24
|
__isFragment?: never;
|
25
25
|
__isTeleport?: never;
|
26
26
|
__isSuspense?: never;
|
27
|
-
} & import('vue').ComponentOptionsBase<Readonly<import('
|
27
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('.').ComponentNeoProps> & Readonly<{
|
28
28
|
onToggleComponent?: ((name?: string | undefined, ref?: any) => any) | undefined;
|
29
29
|
}>, {
|
30
30
|
componentRef: import('vue').Ref<any, any>;
|
@@ -39,12 +39,12 @@ export declare const MtComponentNeo: {
|
|
39
39
|
[key: string]: any;
|
40
40
|
}>;
|
41
41
|
compRef: (el: Element) => Element;
|
42
|
-
attrs: Record<string,
|
42
|
+
attrs: Record<string, unknown> & {
|
43
43
|
[x: string]: unknown;
|
44
44
|
};
|
45
45
|
compName: any;
|
46
46
|
}): any;
|
47
47
|
};
|
48
48
|
});
|
49
|
-
export * from './src/component-neo
|
49
|
+
export * from './src/component-neo';
|
50
50
|
export * from './src/hooks/use-component-neo';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Component, DefineComponent } from 'vue';
|
1
|
+
import { Component, DefineComponent, VNode } from 'vue';
|
2
2
|
export interface ComponentNeoProps {
|
3
3
|
/** 唯一标识 */
|
4
4
|
uniqueId?: string;
|
@@ -6,3 +6,4 @@ export interface ComponentNeoProps {
|
|
6
6
|
is?: string | Component;
|
7
7
|
}
|
8
8
|
export type InstanceComponent = DefineComponent<any, any, any, any, any, any, any, any, any, any>;
|
9
|
+
export type ComponentSlots = Record<string, (arg: any) => VNode>;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { InstanceComponent } from '../component-neo';
|
2
1
|
import { VNode } from 'vue';
|
2
|
+
import { ComponentSlots, InstanceComponent } from '../component-neo';
|
3
3
|
export type ImportComponentFn = () => Promise<Record<string, any>>;
|
4
4
|
export type DynamicComponent = InstanceComponent | ImportComponentFn | VNode;
|
5
5
|
export declare function useComponentNeo(uniqueId?: string): {
|
6
6
|
getComponentRef: () => any;
|
7
|
-
toggleComponent: (comp
|
7
|
+
toggleComponent: (comp?: DynamicComponent, attrs?: Record<string, any>, slots?: ComponentSlots) => Promise<any>;
|
8
8
|
};
|
@@ -1,21 +1,29 @@
|
|
1
|
-
import { InstanceComponent } from '../component-neo';
|
2
1
|
import { Ref, ShallowRef, VNode } from 'vue';
|
2
|
+
import { ComponentSlots, InstanceComponent } from '../component-neo';
|
3
3
|
interface ComponentRefsType {
|
4
|
-
/**
|
4
|
+
/** 引用实例 */
|
5
5
|
Instance: Ref<any>;
|
6
6
|
/** 组件 */
|
7
7
|
comp: ShallowRef<InstanceComponent | VNode | undefined>;
|
8
8
|
/** 属性 */
|
9
|
-
attrs: Ref<Record<string,
|
9
|
+
attrs: Ref<Record<string, unknown>>;
|
10
|
+
/** 插槽 */
|
11
|
+
slots: Ref<ComponentSlots>;
|
12
|
+
}
|
13
|
+
interface ComponentData {
|
14
|
+
comp?: InstanceComponent | VNode;
|
15
|
+
attrs: Record<string, unknown>;
|
16
|
+
slots: ComponentSlots;
|
10
17
|
}
|
11
18
|
/** 组件状态 */
|
12
19
|
export declare const useComponentState: () => {
|
13
20
|
initComponent: (uniqueId?: string) => {
|
14
21
|
componentRef: Ref<any, any>;
|
15
22
|
componentNeo: ShallowRef<any>;
|
16
|
-
componentAttrs: Ref<Record<string,
|
23
|
+
componentAttrs: Ref<Record<string, unknown>, Record<string, unknown>>;
|
24
|
+
componentSlots: Ref<ComponentSlots, ComponentSlots>;
|
17
25
|
};
|
18
|
-
setComponent: (uniqueId: string | undefined,
|
26
|
+
setComponent: (uniqueId: string | undefined, args: ComponentData) => void;
|
19
27
|
getComponent: (uniqueId?: string) => ComponentRefsType | undefined;
|
20
28
|
removeComponent: (uniqueId?: string) => void;
|
21
29
|
};
|
package/types/sort/src/sort.d.ts
CHANGED