mortise-tenon-design 0.4.0 → 0.6.0

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.
Files changed (145) hide show
  1. package/dist/es/index.mjs +13 -0
  2. package/{es/core/build-design → dist/es}/package.json.mjs +1 -1
  3. package/{es/components → dist/es/src}/expand/index.mjs +0 -1
  4. package/dist/es/src/expand/index.mjs.map +1 -0
  5. package/dist/es/src/expand/src/expand.css +1 -0
  6. package/{es/components → dist/es/src}/expand/src/expand.vue.mjs +2 -2
  7. package/dist/es/src/expand/src/expand.vue2.mjs +36 -0
  8. package/dist/es/src/expand/src/expand.vue2.mjs.map +1 -0
  9. package/dist/es/src/installer.mjs +24 -0
  10. package/dist/es/src/installer.mjs.map +1 -0
  11. package/dist/es/src/resize/index.mjs +7 -0
  12. package/dist/es/src/resize/index.mjs.map +1 -0
  13. package/dist/es/src/resize/src/resize.css +1 -0
  14. package/dist/es/src/resize/src/resize.vue.mjs +8 -0
  15. package/dist/es/src/resize/src/resize.vue.mjs.map +1 -0
  16. package/dist/es/src/resize/src/resize.vue2.mjs +84 -0
  17. package/dist/es/src/resize/src/resize.vue2.mjs.map +1 -0
  18. package/dist/es/src/sort/index.mjs.map +1 -0
  19. package/dist/es/src/sort/src/sort.mjs +51 -0
  20. package/dist/es/src/sort/src/sort.mjs.map +1 -0
  21. package/{es/components → dist/es/src}/table/index.mjs +0 -1
  22. package/dist/es/src/table/index.mjs.map +1 -0
  23. package/dist/es/src/table/src/table.css +1 -0
  24. package/{es/components → dist/es/src}/table/src/table.vue.mjs +1 -1
  25. package/dist/es/src/table/src/table.vue2.mjs +82 -0
  26. package/dist/es/src/table/src/table.vue2.mjs.map +1 -0
  27. package/dist/es/src/utils/install.mjs.map +1 -0
  28. package/dist/lib/index.js +2 -0
  29. package/{lib/core/build-design → dist/lib}/package.json.js +1 -1
  30. package/{lib/components → dist/lib/src}/expand/index.js +0 -1
  31. package/dist/lib/src/expand/index.js.map +1 -0
  32. package/dist/lib/src/expand/src/expand.css +1 -0
  33. package/{lib/components → dist/lib/src}/expand/src/expand.vue.js +1 -1
  34. package/dist/lib/src/expand/src/expand.vue2.js +2 -0
  35. package/dist/lib/src/expand/src/expand.vue2.js.map +1 -0
  36. package/dist/lib/src/installer.js +2 -0
  37. package/dist/lib/src/installer.js.map +1 -0
  38. package/{lib/components/component-neo → dist/lib/src/resize}/index.js +1 -1
  39. package/dist/lib/src/resize/index.js.map +1 -0
  40. package/dist/lib/src/resize/src/resize.css +1 -0
  41. package/dist/lib/src/resize/src/resize.vue.js +2 -0
  42. package/dist/lib/src/resize/src/resize.vue.js.map +1 -0
  43. package/dist/lib/src/resize/src/resize.vue2.js +2 -0
  44. package/dist/lib/src/resize/src/resize.vue2.js.map +1 -0
  45. package/dist/lib/src/sort/index.js.map +1 -0
  46. package/dist/lib/src/sort/src/sort.js +2 -0
  47. package/dist/lib/src/sort/src/sort.js.map +1 -0
  48. package/{lib/components → dist/lib/src}/table/index.js +0 -1
  49. package/dist/lib/src/table/index.js.map +1 -0
  50. package/dist/lib/src/table/src/table.css +1 -0
  51. package/{lib/components → dist/lib/src}/table/src/table.vue.js +1 -1
  52. package/dist/lib/src/table/src/table.vue2.js +2 -0
  53. package/dist/lib/src/table/src/table.vue2.js.map +1 -0
  54. package/dist/lib/src/utils/install.js.map +1 -0
  55. package/dist/types/expand/src/expand.d.ts +17 -0
  56. package/{types → dist/types}/index.d.ts +1 -1
  57. package/dist/types/resize/index.d.ts +47 -0
  58. package/dist/types/resize/src/resize.d.ts +29 -0
  59. package/dist/types/resize/src/resize.vue.d.ts +34 -0
  60. package/global.d.ts +11 -11
  61. package/package.json +8 -9
  62. package/es/components/component-neo/index.mjs +0 -9
  63. package/es/components/component-neo/index.mjs.map +0 -1
  64. package/es/components/component-neo/src/component-neo.vue.mjs +0 -34
  65. package/es/components/component-neo/src/component-neo.vue.mjs.map +0 -1
  66. package/es/components/component-neo/src/component-neo.vue2.mjs +0 -5
  67. package/es/components/component-neo/src/component-neo.vue2.mjs.map +0 -1
  68. package/es/components/component-neo/src/hooks/use-component-neo.mjs +0 -31
  69. package/es/components/component-neo/src/hooks/use-component-neo.mjs.map +0 -1
  70. package/es/components/component-neo/src/hooks/use-component-state.mjs +0 -36
  71. package/es/components/component-neo/src/hooks/use-component-state.mjs.map +0 -1
  72. package/es/components/expand/index.mjs.map +0 -1
  73. package/es/components/expand/src/expand.css +0 -1
  74. package/es/components/expand/src/expand.vue2.mjs +0 -41
  75. package/es/components/expand/src/expand.vue2.mjs.map +0 -1
  76. package/es/components/index.mjs +0 -13
  77. package/es/components/installer.mjs +0 -24
  78. package/es/components/installer.mjs.map +0 -1
  79. package/es/components/sort/index.mjs.map +0 -1
  80. package/es/components/sort/src/sort.mjs +0 -54
  81. package/es/components/sort/src/sort.mjs.map +0 -1
  82. package/es/components/table/index.mjs.map +0 -1
  83. package/es/components/table/src/table.css +0 -1
  84. package/es/components/table/src/table.vue2.mjs +0 -100
  85. package/es/components/table/src/table.vue2.mjs.map +0 -1
  86. package/es/components/utils/install.mjs.map +0 -1
  87. package/es/index.mjs +0 -15
  88. package/es/index.mjs.map +0 -1
  89. package/lib/components/component-neo/index.js.map +0 -1
  90. package/lib/components/component-neo/src/component-neo.vue.js +0 -2
  91. package/lib/components/component-neo/src/component-neo.vue.js.map +0 -1
  92. package/lib/components/component-neo/src/component-neo.vue2.js +0 -2
  93. package/lib/components/component-neo/src/component-neo.vue2.js.map +0 -1
  94. package/lib/components/component-neo/src/hooks/use-component-neo.js +0 -2
  95. package/lib/components/component-neo/src/hooks/use-component-neo.js.map +0 -1
  96. package/lib/components/component-neo/src/hooks/use-component-state.js +0 -2
  97. package/lib/components/component-neo/src/hooks/use-component-state.js.map +0 -1
  98. package/lib/components/expand/index.js.map +0 -1
  99. package/lib/components/expand/src/expand.css +0 -1
  100. package/lib/components/expand/src/expand.vue2.js +0 -2
  101. package/lib/components/expand/src/expand.vue2.js.map +0 -1
  102. package/lib/components/index.js +0 -2
  103. package/lib/components/installer.js +0 -2
  104. package/lib/components/installer.js.map +0 -1
  105. package/lib/components/sort/index.js.map +0 -1
  106. package/lib/components/sort/src/sort.js +0 -2
  107. package/lib/components/sort/src/sort.js.map +0 -1
  108. package/lib/components/table/index.js.map +0 -1
  109. package/lib/components/table/src/table.css +0 -1
  110. package/lib/components/table/src/table.vue2.js +0 -2
  111. package/lib/components/table/src/table.vue2.js.map +0 -1
  112. package/lib/components/utils/install.js.map +0 -1
  113. package/lib/index.js +0 -2
  114. package/lib/index.js.map +0 -1
  115. package/types/component-neo/index.d.ts +0 -50
  116. package/types/component-neo/src/component-neo.d.ts +0 -9
  117. package/types/component-neo/src/component-neo.vue.d.ts +0 -35
  118. package/types/component-neo/src/hooks/use-component-neo.d.ts +0 -8
  119. package/types/component-neo/src/hooks/use-component-state.d.ts +0 -30
  120. package/types/expand/src/expand.d.ts +0 -8
  121. /package/{es → dist/es}/_virtual/_plugin-vue_export-helper.mjs +0 -0
  122. /package/{es → dist/es}/_virtual/_plugin-vue_export-helper.mjs.map +0 -0
  123. /package/{es/components → dist/es}/index.mjs.map +0 -0
  124. /package/{es/core/build-design → dist/es}/package.json.mjs.map +0 -0
  125. /package/{es/components → dist/es/src}/expand/src/expand.vue.mjs.map +0 -0
  126. /package/{es/components → dist/es/src}/sort/index.mjs +0 -0
  127. /package/{es/components → dist/es/src}/table/src/table.vue.mjs.map +0 -0
  128. /package/{es/components → dist/es/src}/utils/install.mjs +0 -0
  129. /package/{lib → dist/lib}/_virtual/_plugin-vue_export-helper.js +0 -0
  130. /package/{lib → dist/lib}/_virtual/_plugin-vue_export-helper.js.map +0 -0
  131. /package/{lib/components → dist/lib}/index.js.map +0 -0
  132. /package/{lib/core/build-design → dist/lib}/package.json.js.map +0 -0
  133. /package/{lib/components → dist/lib/src}/expand/src/expand.vue.js.map +0 -0
  134. /package/{lib/components → dist/lib/src}/sort/index.js +0 -0
  135. /package/{lib/components → dist/lib/src}/table/src/table.vue.js.map +0 -0
  136. /package/{lib/components → dist/lib/src}/utils/install.js +0 -0
  137. /package/{types → dist/types}/expand/index.d.ts +0 -0
  138. /package/{types → dist/types}/expand/src/expand.vue.d.ts +0 -0
  139. /package/{types → dist/types}/installer.d.ts +0 -0
  140. /package/{types → dist/types}/sort/index.d.ts +0 -0
  141. /package/{types → dist/types}/sort/src/sort.d.ts +0 -0
  142. /package/{types → dist/types}/table/index.d.ts +0 -0
  143. /package/{types → dist/types}/table/src/table.d.ts +0 -0
  144. /package/{types → dist/types}/table/src/table.vue.d.ts +0 -0
  145. /package/{types → dist/types}/utils/install.d.ts +0 -0
@@ -0,0 +1,2 @@
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
+ //# sourceMappingURL=table.vue2.js.map
@@ -0,0 +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","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"}
@@ -0,0 +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,MACPC,EAAI,UAAUD,EAAK,KAAMA,CAAI,CAEjC,EACOA,CACT"}
@@ -0,0 +1,17 @@
1
+ export interface ExpandProps {
2
+ /**
3
+ * 控制是否展开
4
+ * @default false
5
+ */
6
+ open?: boolean;
7
+ /**
8
+ * 达到可调整的目标范围(px)
9
+ * @default 0
10
+ */
11
+ targetRange?: number;
12
+ /**
13
+ * 动画过渡时间(ms)
14
+ * @default 200
15
+ */
16
+ transitionTime?: number;
17
+ }
@@ -1,6 +1,6 @@
1
1
  import { default as installer } from './installer';
2
- export * from './component-neo';
3
2
  export * from './expand';
3
+ export * from './resize';
4
4
  export * from './sort';
5
5
  export * from './table';
6
6
  export default installer;
@@ -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
- // GlobalComponents for Volar
2
- declare module 'vue' {
3
- export interface GlobalComponents {
4
- MtComponentNeo: typeof import('mortise-tenon-design')['MtComponentNeo']
5
- MtExpand: typeof import('mortise-tenon-design')['MtExpand']
6
- MtSort: typeof import('mortise-tenon-design')['MtSort']
7
- MtTable: typeof import('mortise-tenon-design')['MtTable']
8
- }
9
- }
10
-
11
- export {};
1
+ // GlobalComponents for Volar
2
+ declare module 'vue' {
3
+ export interface GlobalComponents {
4
+ MtExpand: typeof import('mortise-tenon-design')['MtExpand']
5
+ MtResize: typeof import('mortise-tenon-design')['MtResize']
6
+ MtSort: typeof import('mortise-tenon-design')['MtSort']
7
+ MtTable: typeof import('mortise-tenon-design')['MtTable']
8
+ }
9
+ }
10
+
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.0",
4
+ "version": "0.6.0",
5
5
  "description": "榫卯组件库",
6
6
  "author": "nixwai",
7
7
  "license": "ISC",
@@ -9,20 +9,19 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/nixwai/mortise-tenon"
11
11
  },
12
- "main": "lib/index.js",
13
- "module": "es/index.mjs",
14
- "types": "types/index.d.ts",
12
+ "main": "dist/lib/index.js",
13
+ "module": "dist/es/index.mjs",
14
+ "types": "dist/types/index.d.ts",
15
15
  "files": [
16
- "es",
17
- "global.d.ts",
18
- "lib",
19
- "types"
16
+ "dist",
17
+ "global.d.ts"
20
18
  ],
21
19
  "peerDependencies": {
22
20
  "vue": "^3.4.0"
23
21
  },
24
22
  "dependencies": {
25
- "@vueuse/core": "^11.1.0",
23
+ "@vueuse/core": "^13.7.0",
24
+ "dom-transform-tool": "^0.1.0",
26
25
  "lodash-es": "^4.17.21"
27
26
  }
28
27
  }
@@ -1,9 +0,0 @@
1
- import { withInstall as o } from "../utils/install.mjs";
2
- import t from "./src/component-neo.vue.mjs";
3
- import "vue";
4
- import "./src/hooks/use-component-state.mjs";
5
- const n = o(t);
6
- export {
7
- n as MtComponentNeo
8
- };
9
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
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,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":["../../../../../../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,5 +0,0 @@
1
- import f from "./component-neo.vue.mjs";
2
- export {
3
- f as default
4
- };
5
- //# sourceMappingURL=component-neo.vue2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component-neo.vue2.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,31 +0,0 @@
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
- var l;
7
- try {
8
- const a = typeof t == "function" ? (await t()).default : t, n = {};
9
- for (let e in c) {
10
- const o = c[e];
11
- e.startsWith("vModel:") ? (e = e.replace("vModel:", ""), n[e] = o, n[`onUpdate:${e}`] = (m) => {
12
- "value" in o && (o.value = m);
13
- }) : n[e] = o;
14
- }
15
- return i(r, { comp: a, attrs: n, slots: f || {} }), await u(), (l = s(r)) == null ? void 0 : l.Instance.value;
16
- } catch (a) {
17
- console.error(a);
18
- }
19
- }
20
- return {
21
- getComponentRef: () => {
22
- var t;
23
- return (t = s(r)) == null ? void 0 : t.Instance.value;
24
- },
25
- toggleComponent: p
26
- };
27
- }
28
- export {
29
- g as useComponentNeo
30
- };
31
- //# sourceMappingURL=use-component-neo.mjs.map
@@ -1 +0,0 @@
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,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":["../../../../../../../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 +0,0 @@
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 +0,0 @@
1
- .mt-expand[data-v-60128610]{overflow:hidden}.mt-expand-transition[data-v-60128610]{transition:height var(--2863d212) ease-in-out}
@@ -1,41 +0,0 @@
1
- import { defineComponent as m, useCssVars as p, computed as a, ref as i, onMounted as d, createElementBlock as f, openBlock as g, normalizeStyle as v, normalizeClass as R, createElementVNode as x, renderSlot as y } from "vue";
2
- import { useResizeObserver as z } from "@vueuse/core";
3
- import { debounce as _ } from "lodash-es";
4
- const B = /* @__PURE__ */ m({
5
- name: "MtExpand",
6
- __name: "expand",
7
- props: {
8
- open: { type: Boolean, default: !1 },
9
- targetRange: { default: 0 },
10
- transitionTime: { default: 200 }
11
- },
12
- setup(l) {
13
- p((e) => ({
14
- "2863d212": u.value
15
- }));
16
- const t = l, u = a(() => `${t.transitionTime}ms`), n = i(0), s = a(() => n.value > t.targetRange), c = a(() => ({ height: `${!s.value || t.open ? n.value : t.targetRange}px` })), o = i(), r = _(() => {
17
- var e;
18
- n.value = (e = o.value) == null ? void 0 : e.offsetHeight;
19
- }, t.transitionTime);
20
- return z(o, r), d(() => {
21
- r();
22
- }), (e, h) => (g(), f("div", {
23
- class: R(["mt-expand", { "mt-expand-transition": !!e.transitionTime }]),
24
- style: v(c.value)
25
- }, [
26
- x("div", {
27
- ref_key: "contentRef",
28
- ref: o
29
- }, [
30
- y(e.$slots, "default", {
31
- open: e.open,
32
- isOutRange: s.value
33
- }, void 0, !0)
34
- ], 512)
35
- ], 6));
36
- }
37
- });
38
- export {
39
- B as default
40
- };
41
- //# sourceMappingURL=expand.vue2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expand.vue2.mjs","sources":["../../../../../../packages/components/expand/src/expand.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { ExpandProps } from './expand.ts';\r\nimport { useResizeObserver } from '@vueuse/core';\r\nimport { debounce } from 'lodash-es';\r\nimport { computed, onMounted, ref } from 'vue';\r\n\r\ndefineOptions({ name: 'MtExpand' });\r\n\r\nconst props = withDefaults(defineProps<ExpandProps>(), {\r\n open: false,\r\n targetRange: 0,\r\n transitionTime: 200,\r\n});\r\n\r\nconst transitionDuration = computed(() => `${props.transitionTime}ms`);\r\n\r\n/** 内容的范围 */\r\nconst contentRange = ref(0);\r\n\r\n/** 是否超出目标范围 */\r\nconst isOutRange = computed(() => contentRange.value > props.targetRange);\r\n\r\n/** 展开或收起后内容样式 */\r\nconst contentStyle = computed(() => {\r\n const size = !isOutRange.value || props.open ? contentRange.value : props.targetRange;\r\n return { height: `${size}px` };\r\n});\r\n\r\n/** 内容实例 */\r\nconst contentRef = ref();\r\n\r\n/** 获取内容实际范围 */\r\nconst getContentRange = debounce(() => {\r\n contentRange.value = contentRef.value?.offsetHeight;\r\n}, props.transitionTime);\r\n\r\n// 监听内容高度变化\r\nuseResizeObserver(contentRef, getContentRange);\r\n\r\n// 初始化内容\r\nonMounted(() => {\r\n getContentRange();\r\n});\r\n</script>\r\n\r\n<template>\r\n <div\r\n class=\"mt-expand\"\r\n :class=\"{ 'mt-expand-transition': !!transitionTime }\"\r\n :style=\"contentStyle\"\r\n >\r\n <div ref=\"contentRef\">\r\n <slot :open=\"open\" :is-out-range=\"isOutRange\" />\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<style lang=\"scss\" scoped>\r\n.mt-expand {\r\n overflow: hidden;\r\n}\r\n\r\n.mt-expand-transition {\r\n transition: height v-bind(transitionDuration) ease-in-out;\r\n}\r\n</style>\r\n"],"names":["props","__props","transitionDuration","computed","contentRange","ref","isOutRange","contentStyle","contentRef","getContentRange","debounce","_a","useResizeObserver","onMounted"],"mappings":";;;;;;;;;;;;;;;AAQA,UAAMA,IAAQC,GAMRC,IAAqBC,EAAS,MAAM,GAAGH,EAAM,cAAc,IAAI,GAG/DI,IAAeC,EAAI,CAAC,GAGpBC,IAAaH,EAAS,MAAMC,EAAa,QAAQJ,EAAM,WAAW,GAGlEO,IAAeJ,EAAS,OAErB,EAAE,QAAQ,GADJ,CAACG,EAAW,SAASN,EAAM,OAAOI,EAAa,QAAQJ,EAAM,WAClD,KAAK,EAC9B,GAGKQ,IAAaH,EAAI,GAGjBI,IAAkBC,EAAS,MAAM;;AACxB,MAAAN,EAAA,SAAQO,IAAAH,EAAW,UAAX,gBAAAG,EAAkB;AAAA,IAAA,GACtCX,EAAM,cAAc;AAGvB,WAAAY,EAAkBJ,GAAYC,CAAe,GAG7CI,EAAU,MAAM;AACE,MAAAJ,EAAA;AAAA,IAAA,CACjB;;;;;;;;;;;;;;;;"}
@@ -1,13 +0,0 @@
1
- import t from "./installer.mjs";
2
- import { MtComponentNeo as p } from "./component-neo/index.mjs";
3
- import { MtExpand as f } from "./expand/index.mjs";
4
- import { MtSort as a } from "./sort/index.mjs";
5
- import { MtTable as n } from "./table/index.mjs";
6
- export {
7
- p as MtComponentNeo,
8
- f as MtExpand,
9
- a as MtSort,
10
- n as MtTable,
11
- t as default
12
- };
13
- //# sourceMappingURL=index.mjs.map
@@ -1,24 +0,0 @@
1
- import { version as e } from "../core/build-design/package.json.mjs";
2
- import { MtComponentNeo as m } from "./component-neo/index.mjs";
3
- import { MtExpand as i } from "./expand/index.mjs";
4
- import { MtSort as l } from "./sort/index.mjs";
5
- import { MtTable as s } from "./table/index.mjs";
6
- const o = Symbol("MT_INSTALLED_KEY");
7
- function f(r = []) {
8
- return {
9
- version: e,
10
- install: (t) => {
11
- t[o] || (t[o] = !0, r.forEach((n) => t.use(n)));
12
- }
13
- };
14
- }
15
- const L = f([
16
- m,
17
- i,
18
- l,
19
- s
20
- ]);
21
- export {
22
- L as default
23
- };
24
- //# sourceMappingURL=installer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"installer.mjs","sources":["../../../../packages/components/installer.ts"],"sourcesContent":["import type { App, Component, Plugin } from 'vue';\r\nimport { version } from '../core/build-design/package.json';\r\nimport { MtComponentNeo } from './component-neo';\r\nimport { MtExpand } from './expand';\r\nimport { MtSort } from './sort';\r\nimport { MtTable } from './table';\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\nconst installer = makeInstaller([\r\n MtComponentNeo,\r\n MtExpand,\r\n MtSort,\r\n MtTable,\r\n]);\r\n\r\nexport default installer;\r\n"],"names":["INSTALLED_KEY","makeInstaller","components","version","app","c","installer","MtComponentNeo","MtExpand","MtSort","MtTable"],"mappings":";;;;;AAOA,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,MAAMC,IAAYL,EAAc;AAAA,EAC9BM;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AACF,CAAC;"}
@@ -1 +0,0 @@
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,54 +0,0 @@
1
- import { defineComponent as l, computed as y } from "vue";
2
- const h = l({
3
- name: "MtSort",
4
- props: {
5
- /** 排序配置 */
6
- sortList: {
7
- type: Array,
8
- default: () => []
9
- },
10
- /** 排序key名 */
11
- keyName: {
12
- type: String,
13
- default: "sort-key"
14
- }
15
- },
16
- setup(t, { slots: s }) {
17
- const o = 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
- return u(t.keyName, e, t.sortList, r);
21
- });
22
- return () => o.value;
23
- }
24
- });
25
- function a(t, s, o = {}) {
26
- return s.forEach((e) => {
27
- var r;
28
- const n = (r = e.props) == null ? void 0 : r[t];
29
- if (n) {
30
- o[n] ? console.warn(`<mt-sort> ${t}: ${n} repeat`) : o[n] = e;
31
- return;
32
- }
33
- Array.isArray(e.children) && a(t, e.children, o);
34
- }), o;
35
- }
36
- function u(t, s, o, e) {
37
- const n = [];
38
- return s.forEach((r) => {
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
- return;
46
- }
47
- }
48
- Array.isArray(r.children) && (r = { ...r }, r.children = u(t, r.children, o, e)), n.push(r);
49
- }), n;
50
- }
51
- export {
52
- h as default
53
- };
54
- //# sourceMappingURL=sort.mjs.map
@@ -1 +0,0 @@
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 +0,0 @@
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;"}
@@ -1 +0,0 @@
1
- .mt-table[data-v-46d3894f]{width:100%;max-width:100%;border-spacing:0;border-collapse:collapse}.mt-table thead tr th[data-v-46d3894f]{padding:8px 16px;border:1px #f0f0f0 solid}.mt-table tbody tr td[data-v-46d3894f]{padding:16px;border:1px #f0f0f0 solid}