mortise-tenon-design 0.5.0 → 0.6.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/dist/es/index.mjs +9 -11
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/package.json.mjs +1 -1
- package/dist/es/src/expand/index.mjs.map +1 -1
- package/dist/es/src/expand/src/expand.css +1 -1
- package/dist/es/src/expand/src/expand.vue.mjs +1 -1
- package/dist/es/src/expand/src/expand.vue2.mjs +11 -12
- package/dist/es/src/expand/src/expand.vue2.mjs.map +1 -1
- package/dist/es/src/installer.mjs +9 -9
- package/dist/es/src/installer.mjs.map +1 -1
- package/dist/es/src/resize/index.mjs +8 -0
- package/dist/es/src/resize/index.mjs.map +1 -0
- package/dist/es/src/resize/src/resize.css +1 -0
- package/dist/es/src/resize/src/resize.vue.mjs +8 -0
- package/dist/es/src/resize/src/resize.vue.mjs.map +1 -0
- package/dist/es/src/resize/src/resize.vue2.mjs +84 -0
- package/dist/es/src/resize/src/resize.vue2.mjs.map +1 -0
- package/dist/es/src/sort/index.mjs.map +1 -1
- package/dist/es/src/sort/src/sort.mjs +25 -28
- package/dist/es/src/sort/src/sort.mjs.map +1 -1
- package/dist/es/src/table/index.mjs.map +1 -1
- package/dist/es/src/table/src/table.vue2.mjs +59 -77
- package/dist/es/src/table/src/table.vue2.mjs.map +1 -1
- package/dist/es/src/utils/install.mjs.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/package.json.js +1 -1
- package/dist/lib/src/expand/index.js.map +1 -1
- package/dist/lib/src/expand/src/expand.css +1 -1
- package/dist/lib/src/expand/src/expand.vue.js +1 -1
- package/dist/lib/src/expand/src/expand.vue2.js +1 -1
- package/dist/lib/src/expand/src/expand.vue2.js.map +1 -1
- package/dist/lib/src/installer.js +1 -1
- package/dist/lib/src/installer.js.map +1 -1
- package/dist/lib/src/{component-neo → resize}/index.js +2 -1
- package/dist/lib/src/resize/index.js.map +1 -0
- package/dist/lib/src/resize/src/resize.css +1 -0
- package/dist/lib/src/resize/src/resize.vue.js +2 -0
- package/dist/lib/src/resize/src/resize.vue.js.map +1 -0
- package/dist/lib/src/resize/src/resize.vue2.js +2 -0
- package/dist/lib/src/resize/src/resize.vue2.js.map +1 -0
- package/dist/lib/src/sort/index.js.map +1 -1
- package/dist/lib/src/sort/src/sort.js +1 -1
- package/dist/lib/src/sort/src/sort.js.map +1 -1
- package/dist/lib/src/table/index.js.map +1 -1
- package/dist/lib/src/table/src/table.vue2.js +1 -1
- package/dist/lib/src/table/src/table.vue2.js.map +1 -1
- package/dist/lib/src/utils/install.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/resize/index.d.ts +47 -0
- package/dist/types/resize/src/resize.d.ts +29 -0
- package/dist/types/resize/src/resize.vue.d.ts +34 -0
- package/global.d.ts +2 -2
- package/package.json +3 -2
- package/dist/es/src/component-neo/index.mjs +0 -9
- package/dist/es/src/component-neo/index.mjs.map +0 -1
- package/dist/es/src/component-neo/src/component-neo.vue.mjs +0 -34
- package/dist/es/src/component-neo/src/component-neo.vue.mjs.map +0 -1
- package/dist/es/src/component-neo/src/component-neo.vue2.mjs +0 -5
- package/dist/es/src/component-neo/src/component-neo.vue2.mjs.map +0 -1
- package/dist/es/src/component-neo/src/hooks/use-component-neo.mjs +0 -29
- package/dist/es/src/component-neo/src/hooks/use-component-neo.mjs.map +0 -1
- package/dist/es/src/component-neo/src/hooks/use-component-state.mjs +0 -36
- package/dist/es/src/component-neo/src/hooks/use-component-state.mjs.map +0 -1
- package/dist/lib/src/component-neo/index.js.map +0 -1
- package/dist/lib/src/component-neo/src/component-neo.vue.js +0 -2
- package/dist/lib/src/component-neo/src/component-neo.vue.js.map +0 -1
- package/dist/lib/src/component-neo/src/component-neo.vue2.js +0 -2
- package/dist/lib/src/component-neo/src/component-neo.vue2.js.map +0 -1
- package/dist/lib/src/component-neo/src/hooks/use-component-neo.js +0 -2
- package/dist/lib/src/component-neo/src/hooks/use-component-neo.js.map +0 -1
- package/dist/lib/src/component-neo/src/hooks/use-component-state.js +0 -2
- package/dist/lib/src/component-neo/src/hooks/use-component-state.js.map +0 -1
- package/dist/types/component-neo/index.d.ts +0 -48
- package/dist/types/component-neo/src/component-neo.d.ts +0 -9
- package/dist/types/component-neo/src/component-neo.vue.d.ts +0 -33
- package/dist/types/component-neo/src/hooks/use-component-neo.d.ts +0 -8
- package/dist/types/component-neo/src/hooks/use-component-state.d.ts +0 -30
package/dist/lib/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./src/installer.js"),t=require("./src/
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./src/installer.js"),t=require("./src/expand/index.js"),r=require("./src/resize/index.js"),i=require("./src/sort/index.js"),n=require("./src/table/index.js");exports.default=e.default;exports.MtExpand=t.MtExpand;exports.MtResize=r.MtResize;exports.MtSort=i.MtSort;exports.MtTable=n.MtTable;
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/package.json.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.6.1";exports.version=e;
|
2
2
|
//# sourceMappingURL=package.json.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/expand/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport Expand from './src/expand.vue';\n\nexport const MtExpand = withInstall(Expand);\n\nexport * from './src/expand';\n"],"names":["MtExpand","withInstall","Expand"],"mappings":"wJAGaA,EAAWC,
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/expand/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport Expand from './src/expand.vue';\n\nexport const MtExpand = withInstall(Expand);\n\nexport * from './src/expand';\n"],"names":["MtExpand","withInstall","Expand"],"mappings":"wJAGaA,EAAWC,EAAAA,YAAYC,EAAAA,OAAM"}
|
@@ -1 +1 @@
|
|
1
|
-
.mt-expand[data-v-
|
1
|
+
.mt-expand[data-v-80e6c6dd]{overflow:hidden}.mt-expand-transition[data-v-80e6c6dd]{transition:height var(--662fdf4a) ease-in-out}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./expand.vue2.js");;/* empty css */const t=require("../../../_virtual/_plugin-vue_export-helper.js"),u=t.default(e.default,[["__scopeId","data-v-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./expand.vue2.js");;/* empty css */const t=require("../../../_virtual/_plugin-vue_export-helper.js"),u=t.default(e.default,[["__scopeId","data-v-80e6c6dd"]]);exports.default=u;
|
2
2
|
//# sourceMappingURL=expand.vue.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@vueuse/core"),c=e.defineComponent({name:"MtExpand",__name:"expand",props:{open:{type:Boolean,default:!1},targetRange:{default:0},transitionTime:{default:200}},setup(u){e.useCssVars(
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@vueuse/core"),c=e.defineComponent({name:"MtExpand",__name:"expand",props:{open:{type:Boolean,default:!1},targetRange:{default:0},transitionTime:{default:200}},setup(u){e.useCssVars(n=>({"662fdf4a":l.value}));const t=u,l=e.computed(()=>`${t.transitionTime}ms`),a=e.ref(),o=e.ref(0);r.useResizeObserver(a,r.useDebounceFn(()=>{o.value=a.value?.scrollHeight||0},200));const s=e.computed(()=>o.value>t.targetRange),i=e.computed(()=>!o.value&&t.open?{}:{height:`${!s.value||t.open?o.value:t.targetRange}px`});return(n,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"contentRef",ref:a,class:e.normalizeClass(["mt-expand",{"mt-expand-transition":!!n.transitionTime}]),style:e.normalizeStyle(i.value)},[e.renderSlot(n.$slots,"default",{open:n.open,isOutRange:s.value},void 0,!0)],6))}});exports.default=c;
|
2
2
|
//# sourceMappingURL=expand.vue2.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"expand.vue2.js","sources":["../../../../../src/expand/src/expand.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ExpandProps } from './expand.ts';\nimport { useDebounceFn, useResizeObserver } from '@vueuse/core';\nimport { computed, ref } from 'vue';\n\ndefineOptions({ name: 'MtExpand' });\n\nconst props = withDefaults(defineProps<ExpandProps>(), {\n open: false,\n targetRange: 0,\n transitionTime: 200,\n});\n\nconst transitionDuration = computed(() => `${props.transitionTime}ms`);\n\n/** 容器实例 */\nconst contentRef = ref<HTMLDivElement>();\n/** 容器的范围 */\nconst contentRange = ref(0);\n// 监听容器变化\nuseResizeObserver(contentRef, useDebounceFn(() => {\n contentRange.value = contentRef.value?.scrollHeight || 0;\n}, 200));\n\n/** 是否超出目标范围 */\nconst isOutRange = computed(() => contentRange.value > props.targetRange);\n\n/** 展开或收起后容器样式 */\nconst contentStyle = computed(() => {\n if (!contentRange.value) {\n return {};\n }\n const size = !isOutRange.value || props.open ? contentRange.value : props.targetRange;\n return { height: `${size}px` };\n});\n</script>\n\n<template>\n <div\n ref=\"contentRef\"\n class=\"mt-expand\"\n :class=\"{ 'mt-expand-transition': !!transitionTime }\"\n :style=\"contentStyle\"\n >\n <slot :open=\"open\" :is-out-range=\"isOutRange\" />\n </div>\n</template>\n\n<style lang=\"scss\" scoped>\n.mt-expand {\n overflow: hidden;\n}\n\n.mt-expand-transition {\n transition: height v-bind(transitionDuration) ease-in-out;\n}\n</style>\n"],"names":["props","__props","transitionDuration","computed","contentRef","ref","contentRange","useResizeObserver","useDebounceFn","
|
1
|
+
{"version":3,"file":"expand.vue2.js","sources":["../../../../../src/expand/src/expand.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ExpandProps } from './expand.ts';\nimport { useDebounceFn, useResizeObserver } from '@vueuse/core';\nimport { computed, ref } from 'vue';\n\ndefineOptions({ name: 'MtExpand' });\n\nconst props = withDefaults(defineProps<ExpandProps>(), {\n open: false,\n targetRange: 0,\n transitionTime: 200,\n});\n\nconst transitionDuration = computed(() => `${props.transitionTime}ms`);\n\n/** 容器实例 */\nconst contentRef = ref<HTMLDivElement>();\n/** 容器的范围 */\nconst contentRange = ref(0);\n// 监听容器变化\nuseResizeObserver(contentRef, useDebounceFn(() => {\n contentRange.value = contentRef.value?.scrollHeight || 0;\n}, 200));\n\n/** 是否超出目标范围 */\nconst isOutRange = computed(() => contentRange.value > props.targetRange);\n\n/** 展开或收起后容器样式 */\nconst contentStyle = computed(() => {\n if (!contentRange.value && props.open) {\n return {};\n }\n const size = !isOutRange.value || props.open ? contentRange.value : props.targetRange;\n return { height: `${size}px` };\n});\n</script>\n\n<template>\n <div\n ref=\"contentRef\"\n class=\"mt-expand\"\n :class=\"{ 'mt-expand-transition': !!transitionTime }\"\n :style=\"contentStyle\"\n >\n <slot :open=\"open\" :is-out-range=\"isOutRange\" />\n </div>\n</template>\n\n<style lang=\"scss\" scoped>\n.mt-expand {\n overflow: hidden;\n}\n\n.mt-expand-transition {\n transition: height v-bind(transitionDuration) ease-in-out;\n}\n</style>\n"],"names":["props","__props","transitionDuration","computed","contentRef","ref","contentRange","useResizeObserver","useDebounceFn","isOutRange","contentStyle"],"mappings":"+VAOA,MAAMA,EAAQC,EAMRC,EAAqBC,EAAAA,SAAS,IAAM,GAAGH,EAAM,cAAc,IAAI,EAG/DI,EAAaC,EAAAA,IAAA,EAEbC,EAAeD,EAAAA,IAAI,CAAC,EAE1BE,oBAAkBH,EAAYI,EAAAA,cAAc,IAAM,CAChDF,EAAa,MAAQF,EAAW,OAAO,cAAgB,CACzD,EAAG,GAAG,CAAC,EAGP,MAAMK,EAAaN,EAAAA,SAAS,IAAMG,EAAa,MAAQN,EAAM,WAAW,EAGlEU,EAAeP,EAAAA,SAAS,IACxB,CAACG,EAAa,OAASN,EAAM,KACxB,CAAA,EAGF,CAAE,OAAQ,GADJ,CAACS,EAAW,OAAST,EAAM,KAAOM,EAAa,MAAQN,EAAM,WAClD,IAAA,CACzB"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../package.json.js"),s=require("./expand/index.js"),u=require("./resize/index.js"),l=require("./sort/index.js"),c=require("./table/index.js"),t=Symbol("MT_INSTALLED_KEY");function a(r=[]){const n=e=>{e[t]||(e[t]=!0,r.forEach(i=>e.use(i)))};return{version:o.version,install:n}}const d=a([s.MtExpand,u.MtResize,l.MtSort,c.MtTable]);exports.default=d;
|
2
2
|
//# sourceMappingURL=installer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"installer.js","sources":["../../../src/installer.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\nimport { version } from '../package.json';\nimport {
|
1
|
+
{"version":3,"file":"installer.js","sources":["../../../src/installer.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\nimport { version } from '../package.json';\nimport { MtExpand } from './expand';\nimport { MtResize } from './resize';\nimport { MtSort } from './sort';\nimport { MtTable } from './table';\n\nconst INSTALLED_KEY = Symbol('MT_INSTALLED_KEY');\n\nfunction makeInstaller(components: Component[] = []) {\n const install = (app: App & { [INSTALLED_KEY]?: boolean }) => {\n if (app[INSTALLED_KEY]) { return; }\n\n app[INSTALLED_KEY] = true;\n components.forEach(c => app.use(c as Plugin));\n };\n\n return {\n version,\n install,\n };\n}\n\nconst installer = makeInstaller([\n MtExpand,\n MtResize,\n MtSort,\n MtTable,\n]);\n\nexport default installer;\n"],"names":["INSTALLED_KEY","makeInstaller","components","install","app","c","version","installer","MtExpand","MtResize","MtSort","MtTable"],"mappings":"2QAOMA,EAAgB,OAAO,kBAAkB,EAE/C,SAASC,EAAcC,EAA0B,GAAI,CACnD,MAAMC,EAAWC,GAA6C,CACxDA,EAAIJ,CAAa,IAErBI,EAAIJ,CAAa,EAAI,GACrBE,EAAW,QAAQG,GAAKD,EAAI,IAAIC,CAAW,CAAC,EAC9C,EAEA,MAAO,CAAA,QACLC,EAAAA,QACA,QAAAH,CAAA,CAEJ,CAEA,MAAMI,EAAYN,EAAc,CAC9BO,EAAAA,SACAC,EAAAA,SACAC,EAAAA,OACAC,EAAAA,OACF,CAAC"}
|
@@ -1,2 +1,3 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.js"),t=require("./src/
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils/install.js"),t=require("./src/resize.vue.js"),i=e.withInstall(t.default);exports.MtResize=i;
|
2
2
|
//# sourceMappingURL=index.js.map
|
3
|
+
require('./src/resize.css');
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/resize/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\r\nimport Resize from './src/resize.vue';\r\n\r\nexport const MtResize = withInstall(Resize);\r\n\r\nexport * from './src/resize';\r\n"],"names":["MtResize","withInstall","Resize"],"mappings":"wJAGaA,EAAWC,EAAAA,YAAYC,EAAAA,OAAM"}
|
@@ -0,0 +1 @@
|
|
1
|
+
.mt-resize[data-v-d512c549]{position:relative;overflow:visible}.mt-resize .left-box[data-v-d512c549]{position:absolute;top:4px;left:-4px;width:8px;height:calc(100% - 8px);cursor:w-resize}.mt-resize .right-box[data-v-d512c549]{position:absolute;top:4px;right:-4px;width:8px;height:calc(100% - 8px);cursor:e-resize}.mt-resize .top-box[data-v-d512c549]{position:absolute;top:-4px;left:4px;width:calc(100% - 8px);height:8px;cursor:n-resize}.mt-resize .bottom-box[data-v-d512c549]{position:absolute;bottom:-4px;left:4px;width:calc(100% - 8px);height:8px;cursor:s-resize}.mt-resize .left-top-box[data-v-d512c549]{position:absolute;top:-4px;left:-4px;width:8px;height:8px;cursor:nw-resize}.mt-resize .right-top-box[data-v-d512c549]{position:absolute;top:-4px;right:-4px;width:8px;height:8px;cursor:ne-resize}.mt-resize .left-bottom-box[data-v-d512c549]{position:absolute;bottom:-4px;left:-4px;width:8px;height:8px;cursor:sw-resize}.mt-resize .right-bottom-box[data-v-d512c549]{position:absolute;right:-4px;bottom:-4px;width:8px;height:8px;cursor:se-resize}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./resize.vue2.js");;/* empty css */const t=require("../../../_virtual/_plugin-vue_export-helper.js"),u=t.default(e.default,[["__scopeId","data-v-d512c549"]]);exports.default=u;
|
2
|
+
//# sourceMappingURL=resize.vue.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resize.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"),v=require("dom-transform-tool"),B=e.defineComponent({name:"MtResize",__name:"resize",props:{disabled:{type:Boolean,default:!1},offset:{},directions:{default:()=>["right"]},lockAspectRatio:{type:Boolean,default:!1},grid:{default:()=>[.5,.5]}},emits:["resize"],setup(p,{emit:m}){const i=p,f=m,u=e.ref(),a=e.ref("");function n(l,t){a.value=t,v.domResize({event:l,direction:t,target:u.value,offset:i.offset,lockAspectRatio:i.lockAspectRatio,grid:i.grid,callback:(o,k)=>{f("resize",o,k)}})}const r=e.computed(()=>i.directions.includes("left")),s=e.computed(()=>i.directions.includes("right")),d=e.computed(()=>i.directions.includes("top")),c=e.computed(()=>i.directions.includes("bottom"));return(l,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"contentRef",ref:u,class:"mt-resize"},[l.disabled?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[r.value&&!l.lockAspectRatio?(e.openBlock(),e.createElementBlock("div",{key:0,class:"left-box",onPointerdown:t[0]||(t[0]=e.withModifiers(o=>n(o,"left"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),s.value&&!l.lockAspectRatio?(e.openBlock(),e.createElementBlock("div",{key:1,class:"right-box",onPointerdown:t[1]||(t[1]=e.withModifiers(o=>n(o,"right"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),d.value&&!l.lockAspectRatio?(e.openBlock(),e.createElementBlock("div",{key:2,class:"top-box",onPointerdown:t[2]||(t[2]=e.withModifiers(o=>n(o,"top"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),c.value&&!l.lockAspectRatio?(e.openBlock(),e.createElementBlock("div",{key:3,class:"bottom-box",onPointerdown:t[3]||(t[3]=e.withModifiers(o=>n(o,"bottom"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),r.value&&d.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"left-top-box",onPointerdown:t[4]||(t[4]=e.withModifiers(o=>n(o,"left-top"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),s.value&&d.value?(e.openBlock(),e.createElementBlock("div",{key:5,class:"right-top-box",onPointerdown:t[5]||(t[5]=e.withModifiers(o=>n(o,"right-top"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),r.value&&c.value?(e.openBlock(),e.createElementBlock("div",{key:6,class:"left-bottom-box",onPointerdown:t[6]||(t[6]=e.withModifiers(o=>n(o,"left-bottom"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0),s.value&&c.value?(e.openBlock(),e.createElementBlock("div",{key:7,class:"right-bottom-box",onPointerdown:t[7]||(t[7]=e.withModifiers(o=>n(o,"right-bottom"),["stop","prevent"]))},null,32)):e.createCommentVNode("",!0)],64)),e.renderSlot(l.$slots,"default",{direction:a.value},void 0,!0)],512))}});exports.default=B;
|
2
|
+
//# sourceMappingURL=resize.vue2.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resize.vue2.js","sources":["../../../../../src/resize/src/resize.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { DomResizeContent, DomResizeDirection, DomResizeStyle } from 'dom-transform-tool';\r\nimport type { ResizeProps } from './resize';\r\nimport { domResize } from 'dom-transform-tool';\r\nimport { computed, ref } from 'vue';\r\n\r\ndefineOptions({ name: 'MtResize' });\r\n\r\nconst props = withDefaults(\r\n defineProps<ResizeProps>(),\r\n {\r\n disabled: false,\r\n directions: () => ['right'],\r\n lockAspectRatio: false,\r\n grid: () => [0.5, 0.5],\r\n },\r\n);\r\n\r\nconst emit = defineEmits<{\r\n (e: 'resize', content: DomResizeContent, style: DomResizeStyle): void\r\n}>();\r\n\r\n/** 元素实例 */\r\nconst contentRef = ref<HTMLDivElement>();\r\n/** 调整的方向 */\r\nconst resizeDirection = ref('');\r\n/** 调整函数 */\r\nfunction handleResize(event: PointerEvent, direction: DomResizeDirection) {\r\n resizeDirection.value = direction;\r\n domResize({\r\n event,\r\n direction,\r\n target: contentRef.value,\r\n offset: props.offset,\r\n lockAspectRatio: props.lockAspectRatio,\r\n grid: props.grid,\r\n callback: (content, style) => {\r\n emit('resize', content, style);\r\n },\r\n });\r\n};\r\n\r\nconst isLeftDir = computed(() => props.directions.includes('left'));\r\nconst isRightDir = computed(() => props.directions.includes('right'));\r\nconst isTopDir = computed(() => props.directions.includes('top'));\r\nconst isBottomDir = computed(() => props.directions.includes('bottom'));\r\n</script>\r\n\r\n<template>\r\n <div\r\n ref=\"contentRef\"\r\n class=\"mt-resize\"\r\n >\r\n <template v-if=\"!disabled\">\r\n <div v-if=\"isLeftDir && !lockAspectRatio\" class=\"left-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'left')\" />\r\n <div v-if=\"isRightDir && !lockAspectRatio\" class=\"right-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'right')\" />\r\n <div v-if=\"isTopDir && !lockAspectRatio\" class=\"top-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'top')\" />\r\n <div v-if=\"isBottomDir && !lockAspectRatio\" class=\"bottom-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'bottom')\" />\r\n <div v-if=\"isLeftDir && isTopDir\" class=\"left-top-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'left-top')\" />\r\n <div v-if=\"isRightDir && isTopDir\" class=\"right-top-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'right-top')\" />\r\n <div v-if=\"isLeftDir && isBottomDir\" class=\"left-bottom-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'left-bottom')\" />\r\n <div v-if=\"isRightDir && isBottomDir\" class=\"right-bottom-box\" @pointerdown.stop.prevent=\"(e) => handleResize(e, 'right-bottom')\" />\r\n </template>\r\n <slot :direction=\"resizeDirection\" />\r\n </div>\r\n</template>\r\n\r\n<style scoped lang=\"scss\">\r\n.mt-resize {\r\n position: relative;\r\n overflow: visible;\r\n\r\n .left-box {\r\n position: absolute;\r\n top: 4px;\r\n left: -4px;\r\n width: 8px;\r\n height: calc(100% - 8px);\r\n cursor: w-resize;\r\n }\r\n\r\n .right-box {\r\n position: absolute;\r\n top: 4px;\r\n right: -4px;\r\n width: 8px;\r\n height: calc(100% - 8px);\r\n cursor: e-resize;\r\n }\r\n\r\n .top-box {\r\n position: absolute;\r\n top: -4px;\r\n left: 4px;\r\n width: calc(100% - 8px);\r\n height: 8px;\r\n cursor: n-resize;\r\n }\r\n\r\n .bottom-box {\r\n position: absolute;\r\n bottom: -4px;\r\n left: 4px;\r\n width: calc(100% - 8px);\r\n height: 8px;\r\n cursor: s-resize;\r\n }\r\n\r\n .left-top-box {\r\n position: absolute;\r\n top: -4px;\r\n left: -4px;\r\n width: 8px;\r\n height: 8px;\r\n cursor: nw-resize;\r\n }\r\n\r\n .right-top-box {\r\n position: absolute;\r\n top: -4px;\r\n right: -4px;\r\n width: 8px;\r\n height: 8px;\r\n cursor: ne-resize;\r\n }\r\n\r\n .left-bottom-box {\r\n position: absolute;\r\n bottom: -4px;\r\n left: -4px;\r\n width: 8px;\r\n height: 8px;\r\n cursor: sw-resize;\r\n }\r\n\r\n .right-bottom-box {\r\n position: absolute;\r\n right: -4px;\r\n bottom: -4px;\r\n width: 8px;\r\n height: 8px;\r\n cursor: se-resize;\r\n }\r\n}\r\n</style>\r\n"],"names":["props","__props","emit","__emit","contentRef","ref","resizeDirection","handleResize","event","direction","domResize","content","style","isLeftDir","computed","isRightDir","isTopDir","isBottomDir"],"mappings":"wZAQA,MAAMA,EAAQC,EAURC,EAAOC,EAKPC,EAAaC,EAAAA,IAAA,EAEbC,EAAkBD,EAAAA,IAAI,EAAE,EAE9B,SAASE,EAAaC,EAAqBC,EAA+B,CACxEH,EAAgB,MAAQG,EACxBC,YAAU,CACR,MAAAF,EACA,UAAAC,EACA,OAAQL,EAAW,MACnB,OAAQJ,EAAM,OACd,gBAAiBA,EAAM,gBACvB,KAAMA,EAAM,KACZ,SAAU,CAACW,EAASC,IAAU,CAC5BV,EAAK,SAAUS,EAASC,CAAK,CAC/B,CAAA,CACD,CACH,CAEA,MAAMC,EAAYC,EAAAA,SAAS,IAAMd,EAAM,WAAW,SAAS,MAAM,CAAC,EAC5De,EAAaD,EAAAA,SAAS,IAAMd,EAAM,WAAW,SAAS,OAAO,CAAC,EAC9DgB,EAAWF,EAAAA,SAAS,IAAMd,EAAM,WAAW,SAAS,KAAK,CAAC,EAC1DiB,EAAcH,EAAAA,SAAS,IAAMd,EAAM,WAAW,SAAS,QAAQ,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/sort/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport Sort from './src/sort';\n\nexport const MtSort = withInstall(Sort);\n\nexport * from './src/sort';\n"],"names":["MtSort","withInstall","Sort"],"mappings":"kJAGaA,EAASC,
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/sort/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport Sort from './src/sort';\n\nexport const MtSort = withInstall(Sort);\n\nexport * from './src/sort';\n"],"names":["MtSort","withInstall","Sort"],"mappings":"kJAGaA,EAASC,EAAAA,YAAYC,EAAAA,OAAI"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("vue"),f=c.defineComponent({name:"MtSort",props:{sortList:{type:Array,default:()=>[]},keyName:{type:String,default:"sort-key"}},setup(r,{slots:o}){const n=c.computed(()=>{const t=o.default?.()||[],e=a(r.keyName,t),s=Array.from(new Set(r.sortList)).map(u=>e[u]).filter(Boolean);return l(r.keyName,t,r.sortList,s)});return()=>n.value}});function a(r,o,n={}){return o.forEach(t=>{const e=t.props?.[r];if(e){n[e]?console.warn(`<mt-sort> ${r}: ${e} repeat`):n[e]=t;return}Array.isArray(t.children)&&a(r,t.children,n)}),n}function l(r,o,n,t){const e=[];return o.forEach(s=>{const u=s.props?.[r];if(u&&n.includes(u)){const i=t.shift();if(i){e.push(i);return}}Array.isArray(s.children)&&(s={...s},s.children=l(r,s.children,n,t)),e.push(s)}),e}exports.default=f;
|
2
2
|
//# sourceMappingURL=sort.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sort.js","sources":["../../../../../src/sort/src/sort.ts"],"sourcesContent":["import type { PropType, VNode } from 'vue';\nimport { computed, defineComponent } from 'vue';\n\nexport interface SortProps {\n /** 排序配置 */\n sortList?: (string | number)[]\n /** 排序key名 */\n keyName?: string\n}\n\nexport default defineComponent({\n name: 'MtSort',\n props: {\n /** 排序配置 */\n sortList: {\n type: Array as PropType<(string | number)[]>,\n default: () => [],\n },\n /** 排序key名 */\n keyName: {\n type: String,\n default: 'sort-key',\n },\n },\n setup(props, { slots }) {\n const renderVNodes = computed(() => {\n const vNodeList = slots.default?.() || [];\n const sortVNodeMap = getVNodeMap(props.keyName, vNodeList);\n const sortVNodeList = Array.from(new Set(props.sortList)).map(key => sortVNodeMap[key]).filter(Boolean);\n return sortDefaultVNodes(props.keyName, vNodeList, props.sortList, sortVNodeList);\n });\n\n return () => renderVNodes.value;\n },\n});\n\n/** 获取插槽中需要排序的节点 */\nfunction getVNodeMap(keyName: string, vNodeList: VNode[], vNodeMap: Record<(string | number), VNode> = {}) {\n vNodeList.forEach((item) => {\n const sortKey = item.props?.[keyName];\n if (sortKey) {\n if (vNodeMap[sortKey]) {\n console.warn(`<mt-sort> ${keyName}: ${sortKey} repeat`);\n }\n else {\n vNodeMap[sortKey] = item;\n }\n return;\n }\n if (Array.isArray(item.children)) {\n getVNodeMap(keyName, item.children as VNode[], vNodeMap);\n }\n });\n return vNodeMap;\n}\n\n/** 根据排序后的节点跟换位置 */\nfunction sortDefaultVNodes(keyName: string, vNodeList: VNode[], sortList: (string | number)[], sortVNodeList: VNode[]) {\n const newList: VNode[] = [];\n vNodeList.forEach((vNode) => {\n const sortKey = vNode.props?.[keyName];\n if (sortKey && sortList.includes(sortKey)) {\n const sortVNode = sortVNodeList.shift();\n if (sortVNode) {\n newList.push(sortVNode);\n return;\n }\n }\n if (Array.isArray(vNode.children)) {\n vNode = { ...vNode }; // 避免修改原节点数据\n vNode.children = sortDefaultVNodes(keyName, vNode.children as VNode[], sortList, sortVNodeList);\n }\n newList.push(vNode);\n });\n return newList;\n}\n"],"names":["Sort","defineComponent","props","slots","renderVNodes","computed","vNodeList","
|
1
|
+
{"version":3,"file":"sort.js","sources":["../../../../../src/sort/src/sort.ts"],"sourcesContent":["import type { PropType, VNode } from 'vue';\nimport { computed, defineComponent } from 'vue';\n\nexport interface SortProps {\n /** 排序配置 */\n sortList?: (string | number)[]\n /** 排序key名 */\n keyName?: string\n}\n\nexport default defineComponent({\n name: 'MtSort',\n props: {\n /** 排序配置 */\n sortList: {\n type: Array as PropType<(string | number)[]>,\n default: () => [],\n },\n /** 排序key名 */\n keyName: {\n type: String,\n default: 'sort-key',\n },\n },\n setup(props, { slots }) {\n const renderVNodes = computed(() => {\n const vNodeList = slots.default?.() || [];\n const sortVNodeMap = getVNodeMap(props.keyName, vNodeList);\n const sortVNodeList = Array.from(new Set(props.sortList)).map(key => sortVNodeMap[key]).filter(Boolean);\n return sortDefaultVNodes(props.keyName, vNodeList, props.sortList, sortVNodeList);\n });\n\n return () => renderVNodes.value;\n },\n});\n\n/** 获取插槽中需要排序的节点 */\nfunction getVNodeMap(keyName: string, vNodeList: VNode[], vNodeMap: Record<(string | number), VNode> = {}) {\n vNodeList.forEach((item) => {\n const sortKey = item.props?.[keyName];\n if (sortKey) {\n if (vNodeMap[sortKey]) {\n console.warn(`<mt-sort> ${keyName}: ${sortKey} repeat`);\n }\n else {\n vNodeMap[sortKey] = item;\n }\n return;\n }\n if (Array.isArray(item.children)) {\n getVNodeMap(keyName, item.children as VNode[], vNodeMap);\n }\n });\n return vNodeMap;\n}\n\n/** 根据排序后的节点跟换位置 */\nfunction sortDefaultVNodes(keyName: string, vNodeList: VNode[], sortList: (string | number)[], sortVNodeList: VNode[]) {\n const newList: VNode[] = [];\n vNodeList.forEach((vNode) => {\n const sortKey = vNode.props?.[keyName];\n if (sortKey && sortList.includes(sortKey)) {\n const sortVNode = sortVNodeList.shift();\n if (sortVNode) {\n newList.push(sortVNode);\n return;\n }\n }\n if (Array.isArray(vNode.children)) {\n vNode = { ...vNode }; // 避免修改原节点数据\n vNode.children = sortDefaultVNodes(keyName, vNode.children as VNode[], sortList, sortVNodeList);\n }\n newList.push(vNode);\n });\n return newList;\n}\n"],"names":["Sort","defineComponent","props","slots","renderVNodes","computed","vNodeList","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,CAAC,EAGlB,QAAS,CACP,KAAM,OACN,QAAS,UAAA,CACX,EAEF,MAAMC,EAAO,CAAE,MAAAC,GAAS,CACtB,MAAMC,EAAeC,EAAAA,SAAS,IAAM,CAClC,MAAMC,EAAYH,EAAM,UAAA,GAAe,CAAA,EACjCI,EAAeC,EAAYN,EAAM,QAASI,CAAS,EACnDG,EAAgB,MAAM,KAAK,IAAI,IAAIP,EAAM,QAAQ,CAAC,EAAE,OAAWK,EAAaG,CAAG,CAAC,EAAE,OAAO,OAAO,EACtG,OAAOC,EAAkBT,EAAM,QAASI,EAAWJ,EAAM,SAAUO,CAAa,CAClF,CAAC,EAED,MAAO,IAAML,EAAa,KAC5B,CACF,CAAC,EAGD,SAASI,EAAYI,EAAiBN,EAAoBO,EAA6C,CAAA,EAAI,CACzG,OAAAP,EAAU,QAASQ,GAAS,CAC1B,MAAMC,EAAUD,EAAK,QAAQF,CAAO,EACpC,GAAIG,EAAS,CACPF,EAASE,CAAO,EAClB,QAAQ,KAAK,aAAaH,CAAO,KAAKG,CAAO,SAAS,EAGtDF,EAASE,CAAO,EAAID,EAEtB,MACF,CACI,MAAM,QAAQA,EAAK,QAAQ,GAC7BN,EAAYI,EAASE,EAAK,SAAqBD,CAAQ,CAE3D,CAAC,EACMA,CACT,CAGA,SAASF,EAAkBC,EAAiBN,EAAoBU,EAA+BP,EAAwB,CACrH,MAAMQ,EAAmB,CAAA,EACzB,OAAAX,EAAU,QAASY,GAAU,CAC3B,MAAMH,EAAUG,EAAM,QAAQN,CAAO,EACrC,GAAIG,GAAWC,EAAS,SAASD,CAAO,EAAG,CACzC,MAAMI,EAAYV,EAAc,MAAA,EAChC,GAAIU,EAAW,CACbF,EAAQ,KAAKE,CAAS,EACtB,MACF,CACF,CACI,MAAM,QAAQD,EAAM,QAAQ,IAC9BA,EAAQ,CAAE,GAAGA,CAAA,EACbA,EAAM,SAAWP,EAAkBC,EAASM,EAAM,SAAqBF,EAAUP,CAAa,GAEhGQ,EAAQ,KAAKC,CAAK,CACpB,CAAC,EACMD,CACT"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/table/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport Table from './src/table.vue';\n\nexport const MtTable = withInstall(Table);\n\nexport * from './src/table';\n"],"names":["MtTable","withInstall","Table"],"mappings":"uJAGaA,EAAUC,
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/table/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport Table from './src/table.vue';\n\nexport const MtTable = withInstall(Table);\n\nexport * from './src/table';\n"],"names":["MtTable","withInstall","Table"],"mappings":"uJAGaA,EAAUC,EAAAA,YAAYC,EAAAA,OAAK"}
|
@@ -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"),B={class:"mt-table"},h=["colspan","rowspan"],g=["colspan","rowspan"],f=e.defineComponent({name:"MtTable",__name:"table",props:{data:{default:()=>[]},config:{default:()=>[]}},setup(d){const m=d,u=e.computed(()=>m.config.map(t=>({...t,columns:t.columns.filter(a=>a.title)}))),p=e.computed(()=>m.config.map(t=>({...t,columns:t.columns.filter(a=>a.dataKey)}))),k=e.computed(()=>{const t=u.value.map(l=>l.columns.reduce((o,n)=>o+(n.head?.colSpan||1),0)),a=p.value.map(l=>l.columns.reduce((o,n)=>o+(n.cell?.colSpan||1),0));return Math.max(...t,...a)}),y=e.computed(()=>{const t=u.value.map(a=>a.columns.map(l=>l.head?.colSpan||0));return i(t)}),S=e.computed(()=>{const t=p.value.map(a=>a.columns.map(l=>l.cell?.colSpan||0));return i(t)});function i(t){return t.map(a=>{const l=a.filter(Boolean),o=l.reduce((r,s)=>r+s,0);let n=a.length-l.length,c=k.value-o;return a.map(r=>(!r&&c>0&&(r=Math.ceil(c/n),n--,c-=r),r))})}return(t,a)=>(e.openBlock(),e.createElementBlock("table",B,[e.createElementVNode("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,(l,o)=>(e.openBlock(),e.createElementBlock("tr",{key:o,style:e.normalizeStyle(l.headStyle)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.columns,(n,c)=>(e.openBlock(),e.createElementBlock("th",{key:`${n.title}-${c}`,colspan:y.value[o][c],rowspan:n.head?.rowSpan,style:e.normalizeStyle(n.head?.style)},[e.renderSlot(t.$slots,"header",{column:n,columnIndex:c,row:l,rowIndex:o},()=>[e.createTextVNode(e.toDisplayString(n.title),1)],!0)],12,h))),128))],4))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data,(l,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(n,c)=>(e.openBlock(),e.createElementBlock("tr",{key:c,style:e.normalizeStyle(n.rowStyle)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,(r,s)=>(e.openBlock(),e.createElementBlock("td",{key:`${r.dataKey}-${s}`,colspan:S.value[c][s],rowspan:r.cell?.rowSpan,style:e.normalizeStyle(r.cell?.style)},[e.renderSlot(t.$slots,"cell",{column:r,columnIndex:s,dataIndex:o,record:l,row:n,rowIndex:c},()=>[e.createTextVNode(e.toDisplayString(l[r.dataKey]),1)],!0)],12,g))),128))],4))),128))],64))),128))])]))}});exports.default=f;
|
2
2
|
//# sourceMappingURL=table.vue2.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table.vue2.js","sources":["../../../../../src/table/src/table.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { TableProps } from './table';\nimport { computed } from 'vue';\n\ndefineOptions({ name: 'MtTable' });\n\nconst props = withDefaults(defineProps<TableProps>(), {\n data: () => [],\n config: () => [],\n});\n\n/** 表头配置 */\nconst headConfig = computed(() => {\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.title) }));\n});\n\n/** 数据配置 */\nconst dataConfig = computed(() => {\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.dataKey) }));\n});\n\n/** 最大列数 */\nconst maxColSpan = computed(() => {\n const handReduce = headConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.head?.colSpan || 1), 0));\n const cellReduce = dataConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.cell?.colSpan || 1), 0));\n return Math.max(...handReduce, ...cellReduce);\n});\n\n/** 表头列合并 */\nconst headColSpan = computed(() => {\n const colSpanList = headConfig.value.map(item => item.columns.map(column => column.head?.colSpan || 0));\n return getColSpanData(colSpanList);\n});\n\n/** 数据列合并 */\nconst dataColSpan = computed(() => {\n const colSpanList = dataConfig.value.map(item => item.columns.map(column => column.cell?.colSpan || 0));\n return getColSpanData(colSpanList);\n});\n\n/** 获取合并列数组 */\nfunction getColSpanData(colSpanList: number[][]) {\n return colSpanList.map((columns) => {\n const colSpanColumns = columns.filter(Boolean); // 已分配colSpan的列\n const beenColSpan = colSpanColumns.reduce((pur, cur) => pur + cur, 0); // 总colSpan\n let remainCount = columns.length - colSpanColumns.length; // 剩余未配置colSpan的列数\n let remainColSpan = maxColSpan.value - beenColSpan; // 剩余可分配的colSpan\n return columns.map((colSpan) => {\n if (!colSpan && remainColSpan > 0) {\n colSpan = Math.ceil(remainColSpan / remainCount); // 每列平均分配colSpan\n remainCount--;\n remainColSpan -= colSpan;\n }\n return colSpan;\n });\n });\n}\n</script>\n\n<template>\n <table class=\"mt-table\">\n <!-- 表头 -->\n <thead>\n <tr\n v-for=\"(row, rowIndex) in headConfig\"\n :key=\"rowIndex\"\n :style=\"row.headStyle\"\n >\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.title}-${columnIndex}`\">\n <th\n :colspan=\"headColSpan[rowIndex][columnIndex]\"\n :rowspan=\"column.head?.rowSpan\"\n :style=\"column.head?.style\"\n >\n <slot\n :column=\"column\"\n :column-index=\"columnIndex\"\n :row=\"row\"\n :row-index=\"rowIndex\"\n name=\"header\"\n >\n {{ column.title }}\n </slot>\n </th>\n </template>\n </tr>\n </thead>\n <!-- 表体 -->\n <tbody>\n <template\n v-for=\"(record, dataIndex) in data\"\n :key=\"dataIndex\"\n >\n <tr\n v-for=\"(row, rowIndex) in dataConfig\"\n :key=\"rowIndex\"\n :style=\"row.rowStyle\"\n >\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.dataKey}-${columnIndex}`\">\n <td\n :colspan=\"dataColSpan[rowIndex][columnIndex]\"\n :rowspan=\"column.cell?.rowSpan\"\n :style=\"column.cell?.style\"\n >\n <slot\n :column=\"column\"\n :column-index=\"columnIndex\"\n :data-index=\"dataIndex\"\n name=\"cell\"\n :record=\"record\"\n :row=\"row\"\n :row-index=\"rowIndex\"\n >\n {{ record[column.dataKey!] }}\n </slot>\n </td>\n </template>\n </tr>\n </template>\n </tbody>\n </table>\n</template>\n\n<style lang=\"scss\" scoped>\n.mt-table {\n width: 100%;\n max-width: 100%;\n border-spacing: 0;\n border-collapse: collapse;\n\n thead {\n tr {\n th {\n padding: 8px 16px;\n border: 1px #f0f0f0 solid;\n }\n }\n }\n\n tbody {\n tr {\n td {\n padding: 16px;\n border: 1px #f0f0f0 solid;\n }\n }\n }\n}\n</style>\n"],"names":["props","__props","headConfig","computed","rowItem","column","dataConfig","maxColSpan","handReduce","item","pre","cur","
|
1
|
+
{"version":3,"file":"table.vue2.js","sources":["../../../../../src/table/src/table.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { TableProps } from './table';\nimport { computed } from 'vue';\n\ndefineOptions({ name: 'MtTable' });\n\nconst props = withDefaults(defineProps<TableProps>(), {\n data: () => [],\n config: () => [],\n});\n\n/** 表头配置 */\nconst headConfig = computed(() => {\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.title) }));\n});\n\n/** 数据配置 */\nconst dataConfig = computed(() => {\n return props.config.map(rowItem => ({ ...rowItem, columns: rowItem.columns.filter(column => column.dataKey) }));\n});\n\n/** 最大列数 */\nconst maxColSpan = computed(() => {\n const handReduce = headConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.head?.colSpan || 1), 0));\n const cellReduce = dataConfig.value.map(item => item.columns.reduce((pre, cur) => pre + (cur.cell?.colSpan || 1), 0));\n return Math.max(...handReduce, ...cellReduce);\n});\n\n/** 表头列合并 */\nconst headColSpan = computed(() => {\n const colSpanList = headConfig.value.map(item => item.columns.map(column => column.head?.colSpan || 0));\n return getColSpanData(colSpanList);\n});\n\n/** 数据列合并 */\nconst dataColSpan = computed(() => {\n const colSpanList = dataConfig.value.map(item => item.columns.map(column => column.cell?.colSpan || 0));\n return getColSpanData(colSpanList);\n});\n\n/** 获取合并列数组 */\nfunction getColSpanData(colSpanList: number[][]) {\n return colSpanList.map((columns) => {\n const colSpanColumns = columns.filter(Boolean); // 已分配colSpan的列\n const beenColSpan = colSpanColumns.reduce((pur, cur) => pur + cur, 0); // 总colSpan\n let remainCount = columns.length - colSpanColumns.length; // 剩余未配置colSpan的列数\n let remainColSpan = maxColSpan.value - beenColSpan; // 剩余可分配的colSpan\n return columns.map((colSpan) => {\n if (!colSpan && remainColSpan > 0) {\n colSpan = Math.ceil(remainColSpan / remainCount); // 每列平均分配colSpan\n remainCount--;\n remainColSpan -= colSpan;\n }\n return colSpan;\n });\n });\n}\n</script>\n\n<template>\n <table class=\"mt-table\">\n <!-- 表头 -->\n <thead>\n <tr\n v-for=\"(row, rowIndex) in headConfig\"\n :key=\"rowIndex\"\n :style=\"row.headStyle\"\n >\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.title}-${columnIndex}`\">\n <th\n :colspan=\"headColSpan[rowIndex][columnIndex]\"\n :rowspan=\"column.head?.rowSpan\"\n :style=\"column.head?.style\"\n >\n <slot\n :column=\"column\"\n :column-index=\"columnIndex\"\n :row=\"row\"\n :row-index=\"rowIndex\"\n name=\"header\"\n >\n {{ column.title }}\n </slot>\n </th>\n </template>\n </tr>\n </thead>\n <!-- 表体 -->\n <tbody>\n <template\n v-for=\"(record, dataIndex) in data\"\n :key=\"dataIndex\"\n >\n <tr\n v-for=\"(row, rowIndex) in dataConfig\"\n :key=\"rowIndex\"\n :style=\"row.rowStyle\"\n >\n <template v-for=\"(column, columnIndex) in row.columns\" :key=\"`${column.dataKey}-${columnIndex}`\">\n <td\n :colspan=\"dataColSpan[rowIndex][columnIndex]\"\n :rowspan=\"column.cell?.rowSpan\"\n :style=\"column.cell?.style\"\n >\n <slot\n :column=\"column\"\n :column-index=\"columnIndex\"\n :data-index=\"dataIndex\"\n name=\"cell\"\n :record=\"record\"\n :row=\"row\"\n :row-index=\"rowIndex\"\n >\n {{ record[column.dataKey!] }}\n </slot>\n </td>\n </template>\n </tr>\n </template>\n </tbody>\n </table>\n</template>\n\n<style lang=\"scss\" scoped>\n.mt-table {\n width: 100%;\n max-width: 100%;\n border-spacing: 0;\n border-collapse: collapse;\n\n thead {\n tr {\n th {\n padding: 8px 16px;\n border: 1px #f0f0f0 solid;\n }\n }\n }\n\n tbody {\n tr {\n td {\n padding: 16px;\n border: 1px #f0f0f0 solid;\n }\n }\n }\n}\n</style>\n"],"names":["props","__props","headConfig","computed","rowItem","column","dataConfig","maxColSpan","handReduce","item","pre","cur","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,IAAQD,GAAOC,EAAI,MAAM,SAAW,GAAI,CAAC,CAAC,EAC9GC,EAAaN,EAAW,MAAM,IAAIG,GAAQA,EAAK,QAAQ,OAAO,CAACC,EAAKC,IAAQD,GAAOC,EAAI,MAAM,SAAW,GAAI,CAAC,CAAC,EACpH,OAAO,KAAK,IAAI,GAAGH,EAAY,GAAGI,CAAU,CAC9C,CAAC,EAGKC,EAAcV,EAAAA,SAAS,IAAM,CACjC,MAAMW,EAAcZ,EAAW,MAAM,IAAIO,GAAQA,EAAK,QAAQ,IAAIJ,GAAUA,EAAO,MAAM,SAAW,CAAC,CAAC,EACtG,OAAOU,EAAeD,CAAW,CACnC,CAAC,EAGKE,EAAcb,EAAAA,SAAS,IAAM,CACjC,MAAMW,EAAcR,EAAW,MAAM,IAAIG,GAAQA,EAAK,QAAQ,IAAIJ,GAAUA,EAAO,MAAM,SAAW,CAAC,CAAC,EACtG,OAAOU,EAAeD,CAAW,CACnC,CAAC,EAGD,SAASC,EAAeD,EAAyB,CAC/C,OAAOA,EAAY,IAAKG,GAAY,CAClC,MAAMC,EAAiBD,EAAQ,OAAO,OAAO,EACvCE,EAAcD,EAAe,OAAO,CAACE,EAAKT,IAAQS,EAAMT,EAAK,CAAC,EACpE,IAAIU,EAAcJ,EAAQ,OAASC,EAAe,OAC9CI,EAAgBf,EAAW,MAAQY,EACvC,OAAOF,EAAQ,IAAKM,IACd,CAACA,GAAWD,EAAgB,IAC9BC,EAAU,KAAK,KAAKD,EAAgBD,CAAW,EAC/CA,IACAC,GAAiBC,GAEZA,EACR,CACH,CAAC,CACH"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"install.js","sources":["../../../../src/utils/install.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\n\nexport function withInstall<T extends Component>(comp: T) {\n (comp as T & Plugin).install = (app: App): void => {\n if (comp.name) {\n app.component(comp.name, comp);\n }\n };\n return comp;\n}\n"],"names":["withInstall","comp","app"],"mappings":"gFAEO,SAASA,EAAiCC,EAAS,CACvD,OAAAA,EAAoB,QAAWC,GAAmB,CAC7CD,EAAK,
|
1
|
+
{"version":3,"file":"install.js","sources":["../../../../src/utils/install.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\n\nexport function withInstall<T extends Component>(comp: T) {\n (comp as T & Plugin).install = (app: App): void => {\n if (comp.name) {\n app.component(comp.name, comp);\n }\n };\n return comp;\n}\n"],"names":["withInstall","comp","app"],"mappings":"gFAEO,SAASA,EAAiCC,EAAS,CACvD,OAAAA,EAAoB,QAAWC,GAAmB,CAC7CD,EAAK,MACPC,EAAI,UAAUD,EAAK,KAAMA,CAAI,CAEjC,EACOA,CACT"}
|
package/dist/types/index.d.ts
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
export declare const MtResize: {
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('.').ResizeProps> & Readonly<{
|
3
|
+
onResize?: ((content: import('dom-transform-tool').DomResizeContent, style: import('dom-transform-tool').DomResizeStyle) => any) | undefined;
|
4
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
5
|
+
resize: (content: import('dom-transform-tool').DomResizeContent, style: import('dom-transform-tool').DomResizeStyle) => any;
|
6
|
+
}, import('vue').PublicProps, {
|
7
|
+
disabled: boolean;
|
8
|
+
directions: import('.').Direction[];
|
9
|
+
lockAspectRatio: boolean;
|
10
|
+
grid: number[];
|
11
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
12
|
+
contentRef: HTMLDivElement;
|
13
|
+
}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
14
|
+
P: {};
|
15
|
+
B: {};
|
16
|
+
D: {};
|
17
|
+
C: {};
|
18
|
+
M: {};
|
19
|
+
Defaults: {};
|
20
|
+
}, Readonly<import('.').ResizeProps> & Readonly<{
|
21
|
+
onResize?: ((content: import('dom-transform-tool').DomResizeContent, style: import('dom-transform-tool').DomResizeStyle) => any) | undefined;
|
22
|
+
}>, {}, {}, {}, {}, {
|
23
|
+
disabled: boolean;
|
24
|
+
directions: import('.').Direction[];
|
25
|
+
lockAspectRatio: boolean;
|
26
|
+
grid: number[];
|
27
|
+
}>;
|
28
|
+
__isFragment?: never;
|
29
|
+
__isTeleport?: never;
|
30
|
+
__isSuspense?: never;
|
31
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('.').ResizeProps> & Readonly<{
|
32
|
+
onResize?: ((content: import('dom-transform-tool').DomResizeContent, style: import('dom-transform-tool').DomResizeStyle) => any) | undefined;
|
33
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
34
|
+
resize: (content: import('dom-transform-tool').DomResizeContent, style: import('dom-transform-tool').DomResizeStyle) => any;
|
35
|
+
}, string, {
|
36
|
+
disabled: boolean;
|
37
|
+
directions: import('.').Direction[];
|
38
|
+
lockAspectRatio: boolean;
|
39
|
+
grid: number[];
|
40
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
41
|
+
$slots: {
|
42
|
+
default?(_: {
|
43
|
+
direction: string;
|
44
|
+
}): any;
|
45
|
+
};
|
46
|
+
});
|
47
|
+
export * from './src/resize';
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export interface ResizeProps {
|
2
|
+
/**
|
3
|
+
* 是否禁用
|
4
|
+
* @default false
|
5
|
+
*/
|
6
|
+
disabled?: boolean;
|
7
|
+
/**
|
8
|
+
* 使用偏移,适用于元素脱离文档流时使用
|
9
|
+
*/
|
10
|
+
offset?: 'transform' | 'position' | 'translate';
|
11
|
+
/**
|
12
|
+
* 可调整的方向
|
13
|
+
* @default ['right']
|
14
|
+
*/
|
15
|
+
directions?: Direction[];
|
16
|
+
/**
|
17
|
+
* 锁定纵横比,directions至少需要设置两个方向横向与纵向方向的值
|
18
|
+
* @default false
|
19
|
+
*/
|
20
|
+
lockAspectRatio?: boolean;
|
21
|
+
/**
|
22
|
+
* 网格对齐,固定每次调整的最小距离,默认[0.5,0.5],单位px,使用小数注意精度问题,建议使用0.5的倍数
|
23
|
+
*/
|
24
|
+
grid?: number[];
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* 可调整的方向
|
28
|
+
*/
|
29
|
+
export type Direction = 'left' | 'right' | 'top' | 'bottom';
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { DomResizeContent, DomResizeStyle } from 'dom-transform-tool';
|
2
|
+
import { ResizeProps } from './resize';
|
3
|
+
declare function __VLS_template(): {
|
4
|
+
attrs: Partial<{}>;
|
5
|
+
slots: {
|
6
|
+
default?(_: {
|
7
|
+
direction: string;
|
8
|
+
}): any;
|
9
|
+
};
|
10
|
+
refs: {
|
11
|
+
contentRef: HTMLDivElement;
|
12
|
+
};
|
13
|
+
rootEl: HTMLDivElement;
|
14
|
+
};
|
15
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
16
|
+
declare const __VLS_component: import('vue').DefineComponent<ResizeProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
17
|
+
resize: (content: DomResizeContent, style: DomResizeStyle) => any;
|
18
|
+
}, string, import('vue').PublicProps, Readonly<ResizeProps> & Readonly<{
|
19
|
+
onResize?: ((content: DomResizeContent, style: DomResizeStyle) => any) | undefined;
|
20
|
+
}>, {
|
21
|
+
disabled: boolean;
|
22
|
+
directions: import('./resize').Direction[];
|
23
|
+
lockAspectRatio: boolean;
|
24
|
+
grid: number[];
|
25
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
26
|
+
contentRef: HTMLDivElement;
|
27
|
+
}, HTMLDivElement>;
|
28
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
29
|
+
export default _default;
|
30
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
31
|
+
new (): {
|
32
|
+
$slots: S;
|
33
|
+
};
|
34
|
+
};
|
package/global.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
// GlobalComponents for Volar
|
2
2
|
declare module 'vue' {
|
3
3
|
export interface GlobalComponents {
|
4
|
-
MtComponentNeo: typeof import('mortise-tenon-design')['MtComponentNeo']
|
5
4
|
MtExpand: typeof import('mortise-tenon-design')['MtExpand']
|
5
|
+
MtResize: typeof import('mortise-tenon-design')['MtResize']
|
6
6
|
MtSort: typeof import('mortise-tenon-design')['MtSort']
|
7
7
|
MtTable: typeof import('mortise-tenon-design')['MtTable']
|
8
8
|
}
|
9
9
|
}
|
10
10
|
|
11
|
-
export {};
|
11
|
+
export { };
|
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.6.1",
|
5
5
|
"description": "榫卯组件库",
|
6
6
|
"author": "nixwai",
|
7
7
|
"license": "ISC",
|
@@ -20,7 +20,8 @@
|
|
20
20
|
"vue": "^3.4.0"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"@vueuse/core": "^
|
23
|
+
"@vueuse/core": "^13.7.0",
|
24
|
+
"dom-transform-tool": "^0.1.0",
|
24
25
|
"lodash-es": "^4.17.21"
|
25
26
|
}
|
26
27
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/component-neo/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport ComponentNeo from './src/component-neo.vue';\n\nexport const MtComponentNeo = withInstall(ComponentNeo);\n\nexport * from './src/component-neo';\nexport * from './src/hooks/use-component-neo';\n"],"names":["MtComponentNeo","withInstall","ComponentNeo"],"mappings":";;;;AAGa,MAAAA,IAAiBC,EAAYC,CAAY;"}
|
@@ -1,34 +0,0 @@
|
|
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
|
-
import { useComponentState as q } from "./hooks/use-component-state.mjs";
|
3
|
-
const D = /* @__PURE__ */ g({
|
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, 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
|
-
Component: p.value,
|
23
|
-
compRef: c,
|
24
|
-
attrs: u.value,
|
25
|
-
compName: r.value
|
26
|
-
}, () => [
|
27
|
-
(b(), S(j(p.value), { ref: c }))
|
28
|
-
]);
|
29
|
-
}
|
30
|
-
});
|
31
|
-
export {
|
32
|
-
D as default
|
33
|
-
};
|
34
|
-
//# sourceMappingURL=component-neo.vue.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"component-neo.vue.mjs","sources":["../../../../../src/component-neo/src/component-neo.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ComponentNeoProps } from './component-neo';\nimport { Comment, computed, h, nextTick, unref, useAttrs, watch } from 'vue';\nimport { useComponentState } from './hooks/use-component-state';\n\ndefineOptions({ name: 'MtComponentNeo', inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<ComponentNeoProps>(),\n { uniqueId: '', onToggle: () => { } },\n);\n\nconst emit = defineEmits<{\n (e: 'toggleComponent', name?: string, ref?: any): void\n}>();\n\nconst { initComponent } = useComponentState();\nconst { componentRef, componentNeo, componentAttrs, componentSlots } = initComponent(props.uniqueId);\nconst compRef = (el: Element) => componentRef.value = el;\n\nconst commonAttrs: Record<string, unknown> = useAttrs();\n/** 结合注入的属性和公共属性 */\nconst compAttrs = computed(() => {\n const newAttrs: Record<string, unknown> = {};\n // 仅传入有值的属性\n for (const key in componentAttrs.value) {\n if (typeof componentAttrs.value[key] !== 'undefined') {\n newAttrs[key] = unref(componentAttrs.value[key]); // 支持ref数据转入\n }\n }\n return Object.assign(newAttrs, commonAttrs);\n});\n\nconst compInstance = computed(() => componentNeo.value || props.is);\n\nconst compVNode = computed(() => {\n return !compInstance.value ? h(Comment, 'ComponentNeo is empty') : h(compInstance.value, compAttrs.value, componentSlots.value);\n});\n\nconst compName = computed(() => {\n return typeof compInstance.value === 'object' && 'name' in compInstance.value ? compInstance.value.name : undefined;\n});\n\n// 监听组件切换,触发回调\nwatch(compInstance, async () => {\n await nextTick();\n emit('toggleComponent', compName.value, componentRef.value);\n});\n\ndefineExpose({ componentRef });\n</script>\n\n<template>\n <!-- eslint-disable-next-line vue/attribute-hyphenation -->\n <slot :Component=\"compVNode\" :compRef=\"compRef\" :attrs=\"compAttrs\" :compName=\"compName\">\n <component :is=\"compVNode\" :ref=\"compRef\" />\n </slot>\n</template>\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,IAAuCC,EAAS,GAEhDC,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 +0,0 @@
|
|
1
|
-
{"version":3,"file":"component-neo.vue2.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { isRef as u, nextTick as d } from "vue";
|
2
|
-
import { useComponentState as C } from "./use-component-state.mjs";
|
3
|
-
function y(r = "") {
|
4
|
-
const { setComponent: f, getComponent: s } = C();
|
5
|
-
async function i(t, l, p) {
|
6
|
-
var c;
|
7
|
-
try {
|
8
|
-
const a = typeof t == "function" ? (await t()).default : t, o = {};
|
9
|
-
for (let e in l) {
|
10
|
-
const n = l[e];
|
11
|
-
e.startsWith("vModel:") || e === "vModel" ? (e = e.replace(/^(vModel):?/, "") || "modelValue", o[e] = n, u(n) && (o[`onUpdate:${e}`] = (m) => n.value = m)) : o[e] = n;
|
12
|
-
}
|
13
|
-
return f(r, { comp: a, attrs: o, slots: p || {} }), await d(), (c = s(r)) == null ? void 0 : c.Instance.value;
|
14
|
-
} catch (a) {
|
15
|
-
console.error(a);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
return {
|
19
|
-
getComponentRef: () => {
|
20
|
-
var t;
|
21
|
-
return (t = s(r)) == null ? void 0 : t.Instance.value;
|
22
|
-
},
|
23
|
-
toggleComponent: i
|
24
|
-
};
|
25
|
-
}
|
26
|
-
export {
|
27
|
-
y as useComponentNeo
|
28
|
-
};
|
29
|
-
//# sourceMappingURL=use-component-neo.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-component-neo.mjs","sources":["../../../../../../src/component-neo/src/hooks/use-component-neo.ts"],"sourcesContent":["import type { VNode } from 'vue';\nimport type { ComponentSlots, InstanceComponent } from '../component-neo';\nimport { isRef, nextTick } from 'vue';\nimport { useComponentState } from './use-component-state';\n\nexport type ImportComponentFn = () => Promise<Record<string, any>>;\nexport type DynamicComponent = InstanceComponent | ImportComponentFn | VNode;\n\nexport function useComponentNeo(uniqueId = '') {\n const { setComponent, getComponent } = useComponentState();\n\n /**\n * 切换渲染的组件\n * @param comp 组件,支持传入,1.import动态导入 2.组件类型 3.VNode\n * @param attrs 组件属性,可使用`on事件`方式添加事件方法,属性支持Ref类型进行绑定以实现动态变化, 支持通过{'vModal:value': value}方式双向绑定数据\n * @param slots 组件插槽\n */\n async function toggleComponent(comp?: DynamicComponent, attrs?: Record<string, any>, slots?: ComponentSlots) {\n try {\n const renderComp = typeof comp === 'function' ? (await (comp as ImportComponentFn)()).default : comp;\n const renderAttrs: Record<string, unknown> = {};\n for (let key in attrs) {\n const bindValue = attrs[key];\n // 兼容vModel\n if (key.startsWith('vModel:') || key === 'vModel') {\n key = key.replace(/^(vModel):?/, '') || 'modelValue';\n renderAttrs[key] = bindValue;\n if (isRef(bindValue)) {\n renderAttrs[`onUpdate:${key}`] = (value: unknown) => bindValue.value = value;\n }\n }\n else {\n renderAttrs[key] = bindValue;\n }\n }\n setComponent(uniqueId, { comp: renderComp, attrs: renderAttrs, slots: slots || {} });\n await nextTick();\n return getComponent(uniqueId)?.Instance.value;\n }\n catch (e) {\n console.error(e);\n }\n }\n return {\n getComponentRef: () => getComponent(uniqueId)?.Instance.value,\n toggleComponent,\n };\n};\n"],"names":["useComponentNeo","uniqueId","setComponent","getComponent","useComponentState","toggleComponent","comp","attrs","slots","renderComp","renderAttrs","key","bindValue","isRef","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;AAE3B,QAAIA,EAAI,WAAW,SAAS,KAAKA,MAAQ,YACvCA,IAAMA,EAAI,QAAQ,eAAe,EAAE,KAAK,cACxCD,EAAYC,CAAG,IAAIC,GACfC,EAAMD,CAAS,MACjBF,EAAY,YAAYC,CAAG,EAAE,IAAI,CAACG,MAAmBF,EAAU,QAAQE,MAIzEJ,EAAYC,CAAG,IAAIC;AAAA,MACrB;AAEW,aAAAV,EAAAD,GAAU,EAAE,MAAMQ,GAAY,OAAOC,GAAa,OAAOF,KAAS,CAAA,GAAI,GACnF,MAAMO,EAAS,IACRC,IAAAb,EAAaF,CAAQ,MAArB,gBAAAe,EAAwB,SAAS;AAAA,aAEnCC,GAAG;AACR,cAAQ,MAAMA,CAAC;AAAA,IAAA;AAAA,EACjB;AAEK,SAAA;AAAA,IACL,iBAAiB,MAAA;;AAAM,cAAAD,IAAAb,EAAaF,CAAQ,MAArB,gBAAAe,EAAwB,SAAS;AAAA;AAAA,IACxD,iBAAAX;AAAA,EACF;AACF;"}
|
@@ -1,36 +0,0 @@
|
|
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
|
-
const a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
5
|
-
function l(t = "") {
|
6
|
-
let o = n.get(t);
|
7
|
-
o || (o = {
|
8
|
-
Instance: c(),
|
9
|
-
comp: i(),
|
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
|
19
|
-
};
|
20
|
-
}
|
21
|
-
function p(t = "") {
|
22
|
-
return n.get(t);
|
23
|
-
}
|
24
|
-
function m(t = "") {
|
25
|
-
a.delete(t), n.delete(t);
|
26
|
-
}
|
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 });
|
30
|
-
}
|
31
|
-
return { initComponent: l, setComponent: u, getComponent: p, removeComponent: m };
|
32
|
-
});
|
33
|
-
export {
|
34
|
-
M as useComponentState
|
35
|
-
};
|
36
|
-
//# sourceMappingURL=use-component-state.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-component-state.mjs","sources":["../../../../../../src/component-neo/src/hooks/use-component-state.ts"],"sourcesContent":["import type { Ref, ShallowRef, VNode } from 'vue';\nimport type { ComponentSlots, InstanceComponent } from '../component-neo';\nimport { createGlobalState } from '@vueuse/core';\nimport { onBeforeUnmount, ref, shallowRef } from 'vue';\n\ninterface ComponentRefsType {\n /** 引用实例 */\n Instance: Ref<any>\n /** 组件 */\n comp: ShallowRef<InstanceComponent | VNode | undefined>\n /** 属性 */\n attrs: Ref<Record<string, unknown>>\n /** 插槽 */\n slots: Ref<ComponentSlots>\n}\n\ninterface ComponentData {\n comp?: InstanceComponent | VNode\n attrs: Record<string, unknown>\n slots: ComponentSlots\n}\n\n/** 组件状态 */\nexport const useComponentState = createGlobalState(() => {\n /** 缓存组件数据,组件未实例化时,可先缓存后赋值 */\n const dataBufferMap = new Map<string, ComponentData>();\n /** 实例化后的组件 */\n const componentRefsMap = new Map<string, ComponentRefsType>();\n /** 初始化组件 */\n function initComponent(uniqueId = '') {\n let componentRefs = componentRefsMap.get(uniqueId);\n if (!componentRefs) {\n componentRefs = {\n Instance: ref(),\n comp: shallowRef<InstanceComponent | VNode>(),\n attrs: ref<Record<string, unknown>>({}),\n slots: ref<ComponentSlots>({}),\n };\n componentRefsMap.set(uniqueId, componentRefs);\n onBeforeUnmount(() => removeComponent(uniqueId));\n }\n // 使用缓存数据初始化数据\n const bufferData = dataBufferMap.get(uniqueId);\n if (bufferData) {\n componentRefs.comp.value = bufferData.comp;\n componentRefs.attrs.value = bufferData.attrs;\n componentRefs.slots.value = bufferData.slots;\n }\n\n return {\n componentRef: componentRefs.Instance,\n componentNeo: componentRefs.comp,\n componentAttrs: componentRefs.attrs,\n componentSlots: componentRefs.slots,\n };\n }\n\n /** 获取实例 */\n function getComponent(uniqueId = '') {\n return componentRefsMap.get(uniqueId);\n }\n\n /** 移除实例 */\n function removeComponent(uniqueId = '') {\n dataBufferMap.delete(uniqueId);\n componentRefsMap.delete(uniqueId);\n }\n\n /** 设置组件数据 */\n function setComponent(uniqueId = '', args: ComponentData) {\n const { comp, attrs, slots } = args;\n const componentRefs = getComponent(uniqueId);\n if (componentRefs) {\n componentRefs.comp.value = comp;\n componentRefs.attrs.value = attrs;\n componentRefs.slots.value = slots;\n }\n dataBufferMap.set(uniqueId, { comp, attrs, slots });\n }\n\n return { initComponent, setComponent, getComponent, removeComponent };\n});\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 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/component-neo/index.ts"],"sourcesContent":["import { withInstall } from '../utils/install';\nimport ComponentNeo from './src/component-neo.vue';\n\nexport const MtComponentNeo = withInstall(ComponentNeo);\n\nexport * from './src/component-neo';\nexport * from './src/hooks/use-component-neo';\n"],"names":["MtComponentNeo","withInstall","ComponentNeo"],"mappings":"4NAGa,MAAAA,EAAiBC,cAAYC,EAAY,OAAA"}
|
@@ -1,2 +0,0 @@
|
|
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
|
-
//# sourceMappingURL=component-neo.vue.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"component-neo.vue.js","sources":["../../../../../src/component-neo/src/component-neo.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ComponentNeoProps } from './component-neo';\nimport { Comment, computed, h, nextTick, unref, useAttrs, watch } from 'vue';\nimport { useComponentState } from './hooks/use-component-state';\n\ndefineOptions({ name: 'MtComponentNeo', inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<ComponentNeoProps>(),\n { uniqueId: '', onToggle: () => { } },\n);\n\nconst emit = defineEmits<{\n (e: 'toggleComponent', name?: string, ref?: any): void\n}>();\n\nconst { initComponent } = useComponentState();\nconst { componentRef, componentNeo, componentAttrs, componentSlots } = initComponent(props.uniqueId);\nconst compRef = (el: Element) => componentRef.value = el;\n\nconst commonAttrs: Record<string, unknown> = useAttrs();\n/** 结合注入的属性和公共属性 */\nconst compAttrs = computed(() => {\n const newAttrs: Record<string, unknown> = {};\n // 仅传入有值的属性\n for (const key in componentAttrs.value) {\n if (typeof componentAttrs.value[key] !== 'undefined') {\n newAttrs[key] = unref(componentAttrs.value[key]); // 支持ref数据转入\n }\n }\n return Object.assign(newAttrs, commonAttrs);\n});\n\nconst compInstance = computed(() => componentNeo.value || props.is);\n\nconst compVNode = computed(() => {\n return !compInstance.value ? h(Comment, 'ComponentNeo is empty') : h(compInstance.value, compAttrs.value, componentSlots.value);\n});\n\nconst compName = computed(() => {\n return typeof compInstance.value === 'object' && 'name' in compInstance.value ? compInstance.value.name : undefined;\n});\n\n// 监听组件切换,触发回调\nwatch(compInstance, async () => {\n await nextTick();\n emit('toggleComponent', compName.value, componentRef.value);\n});\n\ndefineExpose({ componentRef });\n</script>\n\n<template>\n <!-- eslint-disable-next-line vue/attribute-hyphenation -->\n <slot :Component=\"compVNode\" :compRef=\"compRef\" :attrs=\"compAttrs\" :compName=\"compName\">\n <component :is=\"compVNode\" :ref=\"compRef\" />\n </slot>\n</template>\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,EAAuCC,EAAAA,SAAS,EAEhDC,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"}
|