@morya-ui/mcp 0.3.6 → 0.3.7
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/data/catalog.json +464 -366
- package/data/example-coverage.json +56 -74
- package/dist/decisions.js +6 -16
- package/dist/tools.js +7 -0
- package/package.json +1 -1
package/data/catalog.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-09-
|
|
2
|
+
"generatedAt": "2026-09-29T02:20:54.304Z",
|
|
3
3
|
"library": {
|
|
4
4
|
"name": "morya-ui",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.7"
|
|
6
6
|
},
|
|
7
7
|
"mcp": {
|
|
8
8
|
"name": "@morya-ui/mcp",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.7"
|
|
10
10
|
},
|
|
11
11
|
"components": [
|
|
12
12
|
{
|
|
@@ -6485,6 +6485,10 @@
|
|
|
6485
6485
|
{
|
|
6486
6486
|
"name": "header",
|
|
6487
6487
|
"description": "自定义标题区。"
|
|
6488
|
+
},
|
|
6489
|
+
{
|
|
6490
|
+
"name": "footer",
|
|
6491
|
+
"description": "底部操作区。"
|
|
6488
6492
|
}
|
|
6489
6493
|
],
|
|
6490
6494
|
"methods": [],
|
|
@@ -6516,6 +6520,15 @@
|
|
|
6516
6520
|
"code": "<script setup lang=\"ts\">\nimport { MButton, MDrawer } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst open = ref(false)\nconst position = ref<'left' | 'right' | 'top' | 'bottom'>('right')\n\nfunction openAt(next: 'left' | 'right' | 'top' | 'bottom') {\n position.value = next\n open.value = true\n}\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-3\">\n <MButton label=\"Left\" size=\"small\" @click=\"openAt('left')\" />\n <MButton label=\"Right\" size=\"small\" severity=\"secondary\" @click=\"openAt('right')\" />\n <MButton label=\"Top\" size=\"small\" severity=\"secondary\" @click=\"openAt('top')\" />\n <MButton label=\"Bottom\" size=\"small\" severity=\"secondary\" @click=\"openAt('bottom')\" />\n <MDrawer v-model=\"open\" :header=\"`Position: ${position}`\" :position=\"position\">\n <p style=\"margin:0\">\n Use <code>dismissable</code> to control mask dismiss.\n </p>\n </MDrawer>\n </div>\n</template>",
|
|
6517
6521
|
"locale": "zh-CN"
|
|
6518
6522
|
},
|
|
6523
|
+
{
|
|
6524
|
+
"id": "footer-1",
|
|
6525
|
+
"section": "Footer",
|
|
6526
|
+
"sectionId": "footer",
|
|
6527
|
+
"lang": "vue",
|
|
6528
|
+
"preview": true,
|
|
6529
|
+
"code": "<script setup lang=\"ts\">\nimport { MButton, MDrawer, MSpace } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst open = ref(false)\n</script>\n\n<template>\n <div>\n <MButton label=\"With Footer\" @click=\"open = true\" />\n <MDrawer v-model=\"open\" header=\"Edit details\" position=\"right\" :width=\"360\">\n <p style=\"margin:0\">\n Put primary and secondary actions in the footer slot so the body can scroll independently.\n </p>\n <template #footer>\n <MSpace style=\"justify-content: flex-end; width: 100%\">\n <MButton label=\"Cancel\" severity=\"secondary\" text @click=\"open = false\" />\n <MButton label=\"Save\" @click=\"open = false\" />\n </MSpace>\n </template>\n </MDrawer>\n </div>\n</template>",
|
|
6530
|
+
"locale": "zh-CN"
|
|
6531
|
+
},
|
|
6519
6532
|
{
|
|
6520
6533
|
"id": "import-1",
|
|
6521
6534
|
"section": "Import",
|
|
@@ -6542,6 +6555,15 @@
|
|
|
6542
6555
|
"preview": true,
|
|
6543
6556
|
"code": "<script setup lang=\"ts\">\nimport { MButton, MDrawer } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst open = ref(false)\nconst position = ref<'left' | 'right' | 'top' | 'bottom'>('right')\n\nfunction openAt(next: 'left' | 'right' | 'top' | 'bottom') {\n position.value = next\n open.value = true\n}\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-3\">\n <MButton label=\"Left\" size=\"small\" @click=\"openAt('left')\" />\n <MButton label=\"Right\" size=\"small\" severity=\"secondary\" @click=\"openAt('right')\" />\n <MButton label=\"Top\" size=\"small\" severity=\"secondary\" @click=\"openAt('top')\" />\n <MButton label=\"Bottom\" size=\"small\" severity=\"secondary\" @click=\"openAt('bottom')\" />\n <MDrawer v-model=\"open\" :header=\"`Position: ${position}`\" :position=\"position\">\n <p style=\"margin:0\">\n Use <code>dismissable</code> to control mask dismiss.\n </p>\n </MDrawer>\n </div>\n</template>",
|
|
6544
6557
|
"locale": "en-US"
|
|
6558
|
+
},
|
|
6559
|
+
{
|
|
6560
|
+
"id": "footer-1",
|
|
6561
|
+
"section": "Footer",
|
|
6562
|
+
"sectionId": "footer",
|
|
6563
|
+
"lang": "vue",
|
|
6564
|
+
"preview": true,
|
|
6565
|
+
"code": "<script setup lang=\"ts\">\nimport { MButton, MDrawer, MSpace } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst open = ref(false)\n</script>\n\n<template>\n <div>\n <MButton label=\"With Footer\" @click=\"open = true\" />\n <MDrawer v-model=\"open\" header=\"Edit details\" position=\"right\" :width=\"360\">\n <p style=\"margin:0\">\n Put primary and secondary actions in the footer slot so the body can scroll independently.\n </p>\n <template #footer>\n <MSpace style=\"justify-content: flex-end; width: 100%\">\n <MButton label=\"Cancel\" severity=\"secondary\" text @click=\"open = false\" />\n <MButton label=\"Save\" @click=\"open = false\" />\n </MSpace>\n </template>\n </MDrawer>\n </div>\n</template>",
|
|
6566
|
+
"locale": "en-US"
|
|
6545
6567
|
}
|
|
6546
6568
|
],
|
|
6547
6569
|
"locales": {
|
|
@@ -6569,6 +6591,11 @@
|
|
|
6569
6591
|
"title": "Position",
|
|
6570
6592
|
"body": "支持 `left` / `right` / `top` / `bottom`。\n\n```vue preview src=\"./demos/Position.vue\"\n```"
|
|
6571
6593
|
},
|
|
6594
|
+
{
|
|
6595
|
+
"id": "footer",
|
|
6596
|
+
"title": "Footer",
|
|
6597
|
+
"body": "用 `#footer` 放取消 / 保存等操作;正文区可独立滚动。\n\n```vue preview src=\"./demos/Footer.vue\"\n```"
|
|
6598
|
+
},
|
|
6572
6599
|
{
|
|
6573
6600
|
"id": "props",
|
|
6574
6601
|
"title": "Props",
|
|
@@ -6582,10 +6609,10 @@
|
|
|
6582
6609
|
{
|
|
6583
6610
|
"id": "slots",
|
|
6584
6611
|
"title": "Slots",
|
|
6585
|
-
"body": "| 插槽名 | 说明 |\n| --- | --- |\n| `default` | 抽屉内容。 |\n| `header` | 自定义标题区。 |"
|
|
6612
|
+
"body": "| 插槽名 | 说明 |\n| --- | --- |\n| `default` | 抽屉内容。 |\n| `header` | 自定义标题区。 |\n| `footer` | 底部操作区。 |"
|
|
6586
6613
|
}
|
|
6587
6614
|
],
|
|
6588
|
-
"markdown": "---\ntitle: Drawer\ncategory: 05 / FEEDBACK\ndescription: 侧边抽屉面板。\n---\n\n# Drawer\n\n侧边抽屉,从屏幕边缘滑出,适合导航、筛选或详情面板。\n\n## 引入\n\n```ts\nimport { MButton, MDrawer } from 'morya-ui'\n```\n\n## 基础用法\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Position\n\n支持 `left` / `right` / `top` / `bottom`。\n\n```vue preview src=\"./demos/Position.vue\"\n```\n\n## Props\n\n| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `modelValue` | `boolean` | `false` | 可见性。配合 `v-model` 使用。 |\n| `position` | `'left' \\| 'right' \\| 'top' \\| 'bottom'` | `'left'` | 抽屉出现位置。 |\n| `modal` | `boolean` | `true` | 显示遮罩层。 |\n| `dismissable` | `boolean` | `true` | 点击遮罩关闭。 |\n| `showCloseIcon` | `boolean` | `true` | 显示关闭按钮。 |\n| `header` | `string` | — | 标题文案。 |\n| `width` | `string \\| number` | — | 左右抽屉宽度。 |\n| `height` | `string \\| number` | — | 上下抽屉高度。 |\n| `blockScroll` | `boolean` | `true` | 打开时锁定 `body` 滚动。 |\n| `teleport` | `boolean` | `true` | 浮层 Teleport;默认挂到 `body`。 |\n| `appendTo` | `string \\| HTMLElement \\| 'self' \\| false` | `'body'` | 挂载目标;`'self'` / `false` 就地渲染。 |\n| `transition` | `string \\| false` | `'drawer'` | 进出场动效预设;`false` / `'none'` 关闭。见[动效](/docs/motion)。 |\n| `beforeClose` | [AsyncGuard](/docs/types#AsyncGuard) | — | — |\n| `closeOnEsc` | `boolean` | — | — |\n| `closeOnOutsideClick` | `boolean` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |\n\n\n## Events\n\n| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `update:modelValue` | `boolean` | 可见性变化。 |\n| `show` | — | 打开时触发。 |\n| `hide` | — | 关闭后触发。 |\n| `after-leave` | — | 离场动画结束。 |\n| `close` | — | — |\n\n## Slots\n\n| 插槽名 | 说明 |\n| --- | --- |\n| `default` | 抽屉内容。 |\n| `header` | 自定义标题区。 |\n"
|
|
6615
|
+
"markdown": "---\ntitle: Drawer\ncategory: 05 / FEEDBACK\ndescription: 侧边抽屉面板。\n---\n\n# Drawer\n\n侧边抽屉,从屏幕边缘滑出,适合导航、筛选或详情面板。\n\n## 引入\n\n```ts\nimport { MButton, MDrawer } from 'morya-ui'\n```\n\n## 基础用法\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Position\n\n支持 `left` / `right` / `top` / `bottom`。\n\n```vue preview src=\"./demos/Position.vue\"\n```\n\n## Footer\n\n用 `#footer` 放取消 / 保存等操作;正文区可独立滚动。\n\n```vue preview src=\"./demos/Footer.vue\"\n```\n\n## Props\n\n| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `modelValue` | `boolean` | `false` | 可见性。配合 `v-model` 使用。 |\n| `position` | `'left' \\| 'right' \\| 'top' \\| 'bottom'` | `'left'` | 抽屉出现位置。 |\n| `modal` | `boolean` | `true` | 显示遮罩层。 |\n| `dismissable` | `boolean` | `true` | 点击遮罩关闭。 |\n| `showCloseIcon` | `boolean` | `true` | 显示关闭按钮。 |\n| `header` | `string` | — | 标题文案。 |\n| `width` | `string \\| number` | — | 左右抽屉宽度。 |\n| `height` | `string \\| number` | — | 上下抽屉高度。 |\n| `blockScroll` | `boolean` | `true` | 打开时锁定 `body` 滚动。 |\n| `teleport` | `boolean` | `true` | 浮层 Teleport;默认挂到 `body`。 |\n| `appendTo` | `string \\| HTMLElement \\| 'self' \\| false` | `'body'` | 挂载目标;`'self'` / `false` 就地渲染。 |\n| `transition` | `string \\| false` | `'drawer'` | 进出场动效预设;`false` / `'none'` 关闭。见[动效](/docs/motion)。 |\n| `beforeClose` | [AsyncGuard](/docs/types#AsyncGuard) | — | — |\n| `closeOnEsc` | `boolean` | — | — |\n| `closeOnOutsideClick` | `boolean` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |\n\n\n## Events\n\n| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `update:modelValue` | `boolean` | 可见性变化。 |\n| `show` | — | 打开时触发。 |\n| `hide` | — | 关闭后触发。 |\n| `after-leave` | — | 离场动画结束。 |\n| `close` | — | — |\n\n## Slots\n\n| 插槽名 | 说明 |\n| --- | --- |\n| `default` | 抽屉内容。 |\n| `header` | 自定义标题区。 |\n| `footer` | 底部操作区。 |\n"
|
|
6589
6616
|
},
|
|
6590
6617
|
"en-US": {
|
|
6591
6618
|
"title": "Drawer",
|
|
@@ -6611,6 +6638,11 @@
|
|
|
6611
6638
|
"title": "Position",
|
|
6612
6639
|
"body": "Supports `left` / `right` / `top` / `bottom`.\n\n```vue preview src=\"./demos/Position.vue\"\n```"
|
|
6613
6640
|
},
|
|
6641
|
+
{
|
|
6642
|
+
"id": "footer",
|
|
6643
|
+
"title": "Footer",
|
|
6644
|
+
"body": "Use `#footer` for cancel / save actions; the body scrolls independently.\n\n```vue preview src=\"./demos/Footer.vue\"\n```"
|
|
6645
|
+
},
|
|
6614
6646
|
{
|
|
6615
6647
|
"id": "props",
|
|
6616
6648
|
"title": "Props",
|
|
@@ -6624,10 +6656,10 @@
|
|
|
6624
6656
|
{
|
|
6625
6657
|
"id": "slots",
|
|
6626
6658
|
"title": "Slots",
|
|
6627
|
-
"body": "| Slot | Description |\n| --- | --- |\n| `default` | Drawer content. |\n| `header` | Custom header area. |"
|
|
6659
|
+
"body": "| Slot | Description |\n| --- | --- |\n| `default` | Drawer content. |\n| `header` | Custom header area. |\n| `footer` | Footer actions. |"
|
|
6628
6660
|
}
|
|
6629
6661
|
],
|
|
6630
|
-
"markdown": "---\ntitle: Drawer\ncategory: 05 / FEEDBACK\ndescription: Side drawer panel.\n---\n\n# Drawer\n\nSide drawer that slides in from the screen edge. Suited to navigation, filters, or detail panels.\n\n## Import\n\n```ts\nimport { MButton, MDrawer } from 'morya-ui'\n```\n\n## Basic\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Position\n\nSupports `left` / `right` / `top` / `bottom`.\n\n```vue preview src=\"./demos/Position.vue\"\n```\n\n## Props\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `modelValue` | `boolean` | `false` | Visibility. Use with `v-model`. |\n| `position` | `'left' \\| 'right' \\| 'top' \\| 'bottom'` | `'left'` | Edge the drawer appears from. |\n| `modal` | `boolean` | `true` | Show the overlay mask. |\n| `dismissable` | `boolean` | `true` | Close when clicking the mask. |\n| `showCloseIcon` | `boolean` | `true` | Show the close button. |\n| `header` | `string` | — | Header text. |\n| `width` | `number \\| string` | — | Width for left/right drawers (`number` = px). |\n| `height` | `number \\| string` | — | Height for top/bottom drawers (`number` = px). |\n| `blockScroll` | `boolean` | `true` | Lock `body` scroll while open. |\n| `teleport` | `boolean` | `true` | Overlay Teleport; mounts to `body` by default. |\n| `appendTo` | `string \\| HTMLElement \\| 'self' \\| false` | `'body'` | Mount target; `'self'` / `false` renders in place. |\n| `transition` | `string \\| false` | `'drawer'` | Enter/exit motion preset; `false` / `'none'` disables. See [Motion](/docs/motion). |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |\n\n\n## Events\n\n| Event | Prop | Description |\n| --- | --- | --- |\n| `update:modelValue` | `boolean` | Visibility change. |\n| `show` | — | Emitted when opening. |\n| `hide` | — | Emitted after closing. |\n| `after-leave` | — | Emitted when the leave animation finishes. |\n\n## Slots\n\n| Slot | Description |\n| --- | --- |\n| `default` | Drawer content. |\n| `header` | Custom header area. |\n"
|
|
6662
|
+
"markdown": "---\ntitle: Drawer\ncategory: 05 / FEEDBACK\ndescription: Side drawer panel.\n---\n\n# Drawer\n\nSide drawer that slides in from the screen edge. Suited to navigation, filters, or detail panels.\n\n## Import\n\n```ts\nimport { MButton, MDrawer } from 'morya-ui'\n```\n\n## Basic\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Position\n\nSupports `left` / `right` / `top` / `bottom`.\n\n```vue preview src=\"./demos/Position.vue\"\n```\n\n## Footer\n\nUse `#footer` for cancel / save actions; the body scrolls independently.\n\n```vue preview src=\"./demos/Footer.vue\"\n```\n\n## Props\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `modelValue` | `boolean` | `false` | Visibility. Use with `v-model`. |\n| `position` | `'left' \\| 'right' \\| 'top' \\| 'bottom'` | `'left'` | Edge the drawer appears from. |\n| `modal` | `boolean` | `true` | Show the overlay mask. |\n| `dismissable` | `boolean` | `true` | Close when clicking the mask. |\n| `showCloseIcon` | `boolean` | `true` | Show the close button. |\n| `header` | `string` | — | Header text. |\n| `width` | `number \\| string` | — | Width for left/right drawers (`number` = px). |\n| `height` | `number \\| string` | — | Height for top/bottom drawers (`number` = px). |\n| `blockScroll` | `boolean` | `true` | Lock `body` scroll while open. |\n| `teleport` | `boolean` | `true` | Overlay Teleport; mounts to `body` by default. |\n| `appendTo` | `string \\| HTMLElement \\| 'self' \\| false` | `'body'` | Mount target; `'self'` / `false` renders in place. |\n| `transition` | `string \\| false` | `'drawer'` | Enter/exit motion preset; `false` / `'none'` disables. See [Motion](/docs/motion). |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |\n\n\n## Events\n\n| Event | Prop | Description |\n| --- | --- | --- |\n| `update:modelValue` | `boolean` | Visibility change. |\n| `show` | — | Emitted when opening. |\n| `hide` | — | Emitted after closing. |\n| `after-leave` | — | Emitted when the leave animation finishes. |\n\n## Slots\n\n| Slot | Description |\n| --- | --- |\n| `default` | Drawer content. |\n| `header` | Custom header area. |\n| `footer` | Footer actions. |\n"
|
|
6631
6663
|
}
|
|
6632
6664
|
}
|
|
6633
6665
|
},
|
|
@@ -18197,7 +18229,7 @@
|
|
|
18197
18229
|
{
|
|
18198
18230
|
"id": "horizontal",
|
|
18199
18231
|
"title": "Horizontal",
|
|
18200
|
-
"body": "内容宽度超出容器时显示横向滚动条。`trigger=\"none\"` 与 `always` 都会常显滑块;默认 `trigger=\"hover\"` 在悬停时显示。\n\n`MLayout`、`MDialog`、`MConfirmDialog`、`MDrawer`、`MSplitter`、`MTable`、`MSelect`、`MTreeSelect`、`MDropdown`、`MContextMenu`、`MPopover`、`MConfirmPopup`、`MMenu`(popup)、`MMenubar`、`MTieredMenu`、`MTabs`、`MGallery`、`MTimeline`(horizontal)、`MTextarea`(autosize `maxRows`)、`MTerminal`、`MOrderList`、`MPickList`、`
|
|
18232
|
+
"body": "内容宽度超出容器时显示横向滚动条。`trigger=\"none\"` 与 `always` 都会常显滑块;默认 `trigger=\"hover\"` 在悬停时显示。\n\n`MLayout`、`MDialog`、`MConfirmDialog`、`MDrawer`、`MSplitter`、`MTable`、`MSelect`、`MTreeSelect`、`MDropdown`、`MContextMenu`、`MPopover`、`MConfirmPopup`、`MMenu`(popup)、`MMenubar`、`MTieredMenu`、`MTabs`、`MGallery`、`MTimeline`(horizontal)、`MTextarea`(autosize `maxRows`)、`MTerminal`、`MOrderList`、`MPickList`、`MVirtualScroller` 等组件已内置本组件。\n\n```vue preview src=\"./demos/Horizontal.vue\"\n```"
|
|
18201
18233
|
},
|
|
18202
18234
|
{
|
|
18203
18235
|
"id": "always-native",
|
|
@@ -18235,7 +18267,7 @@
|
|
|
18235
18267
|
"body": "<h4 id=\"ScrollbarAriaOrientation\">ScrollbarAriaOrientation</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype ScrollbarAriaOrientation = 'horizontal' | 'vertical'\n```\n\n<h4 id=\"ScrollbarClassValue\">ScrollbarClassValue</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype ScrollbarClassValue = | string\n | string[]\n | Record<string, boolean>\n | Array<string | Record<string, boolean> | null | undefined | false>\n```"
|
|
18236
18268
|
}
|
|
18237
18269
|
],
|
|
18238
|
-
"markdown": "---\ntitle: Scrollbar\ncategory: 01 / BASIC\ndescription: 可换肤自定义滚动条,提供一致的滚动体验。\n---\n\n# Scrollbar\n\n用于替换浏览器原生滚动条,提供跨浏览器一致的可换肤滚动体验。\n\n## 引入\n\n```ts\nimport { MScrollbar } from 'morya-ui'\n```\n\n## 基础用法\n\n用 `height` 固定可视区域高度;不设时跟随父容器高度。\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Max height\n\n仅当内容超出 `max-height` 时出现滚动条。\n\n```vue preview src=\"./demos/MaxHeight.vue\"\n```\n\n## Horizontal\n\n内容宽度超出容器时显示横向滚动条。`trigger=\"none\"` 与 `always` 都会常显滑块;默认 `trigger=\"hover\"` 在悬停时显示。\n\n`MLayout`、`MDialog`、`MConfirmDialog`、`MDrawer`、`MSplitter`、`MTable`、`MSelect`、`MTreeSelect`、`MDropdown`、`MContextMenu`、`MPopover`、`MConfirmPopup`、`MMenu`(popup)、`MMenubar`、`MTieredMenu`、`MTabs`、`MGallery`、`MTimeline`(horizontal)、`MTextarea`(autosize `maxRows`)、`MTerminal`、`MOrderList`、`MPickList`、`
|
|
18270
|
+
"markdown": "---\ntitle: Scrollbar\ncategory: 01 / BASIC\ndescription: 可换肤自定义滚动条,提供一致的滚动体验。\n---\n\n# Scrollbar\n\n用于替换浏览器原生滚动条,提供跨浏览器一致的可换肤滚动体验。\n\n## 引入\n\n```ts\nimport { MScrollbar } from 'morya-ui'\n```\n\n## 基础用法\n\n用 `height` 固定可视区域高度;不设时跟随父容器高度。\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Max height\n\n仅当内容超出 `max-height` 时出现滚动条。\n\n```vue preview src=\"./demos/MaxHeight.vue\"\n```\n\n## Horizontal\n\n内容宽度超出容器时显示横向滚动条。`trigger=\"none\"` 与 `always` 都会常显滑块;默认 `trigger=\"hover\"` 在悬停时显示。\n\n`MLayout`、`MDialog`、`MConfirmDialog`、`MDrawer`、`MSplitter`、`MTable`、`MSelect`、`MTreeSelect`、`MDropdown`、`MContextMenu`、`MPopover`、`MConfirmPopup`、`MMenu`(popup)、`MMenubar`、`MTieredMenu`、`MTabs`、`MGallery`、`MTimeline`(horizontal)、`MTextarea`(autosize `maxRows`)、`MTerminal`、`MOrderList`、`MPickList`、`MVirtualScroller` 等组件已内置本组件。\n\n```vue preview src=\"./demos/Horizontal.vue\"\n```\n\n## Always / Native\n\n`always` 常显自定义滑块;`native` 使用浏览器原生滚动条。\n\n```vue preview src=\"./demos/AlwaysNative.vue\"\n```\n\n## Manual scroll\n\n通过实例方法 `setScrollTop` / `setScrollLeft` / `scrollTo` / `update` 控制滚动。\n\n```vue preview src=\"./demos/ManualScroll.zh.vue\"\n```\n\n## Infinite scroll\n\n滚动到边缘时触发 `end-reached`,可用于无限加载。\n\n```vue preview src=\"./demos/InfiniteScroll.zh.vue\"\n```\n\n## API\n\n### Props\n\n| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `always` | `boolean` | — | — |\n| `ariaLabel` | `string` | — | — |\n| `ariaOrientation` | `ScrollbarAriaOrientation` | — | — |\n| `distance` | `number` | — | — |\n| `height` | `string \\| number` | — | — |\n| `id` | `string` | — | — |\n| `maxHeight` | `string \\| number` | — | — |\n| `minSize` | `number` | — | — |\n| `native` | `boolean` | — | — |\n| `noresize` | `boolean` | — | — |\n| `role` | `string` | — | — |\n| `tabindex` | `number \\| string` | — | — |\n| `tag` | `string` | — | — |\n| `trigger` | `'hover' \\| 'none'` | — | — |\n| `viewClass` | `ScrollbarClassValue` | — | — |\n| `viewStyle` | `StyleValue` | — | — |\n| `wrapClass` | `ScrollbarClassValue` | — | — |\n| `wrapStyle` | `StyleValue` | — | — |\n| `width` | `string \\| number` | — | 可视区域宽度。 |\n| `maxWidth` | `string \\| number` | — | 最大宽度。 |\n| `ariaMultiselectable` | `boolean` | — | 内容区 `aria-multiselectable`。 |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| height | `string \\| number` | — | 可视区域高度 |\n| maxHeight | `string \\| number` | — | 最大高度 |\n| fitContent | `boolean` | `false` | 随内容增高,配合根节点 CSS `max-height` 使用(下拉面板) |\n| native | `boolean` | `false` | 使用原生滚动条 |\n| wrapStyle / wrapClass | style / class | — | wrap 容器样式 |\n| viewStyle / viewClass | style / class | — | 内容区样式 |\n| noresize | `boolean` | `false` | 不监听尺寸变化 |\n| tag | `string` | `div` | 内容区标签 |\n| always | `boolean` | `false` | 始终显示滑块 |\n| trigger | `'hover' \\| 'none'` | `'hover'` | `none` 常显滑块;`always` 为 true 时仍常显 |\n| minSize | `number` | `20` | 滑块最小尺寸 |\n| id / role / ariaLabel / ariaOrientation | a11y | — | 内容区无障碍属性 |\n| tabindex | `number \\| string` | — | wrap 的 tabindex |\n| distance | `number` | `0` | 触发 `end-reached` 的边缘距离 |\n\n### Events\n\n| Name | Payload |\n| --- | --- |\n| scroll | `{ scrollTop, scrollLeft }` |\n| end-reached | `'top' \\| 'bottom' \\| 'left' \\| 'right'` |\n\n### Expose\n\n| 方法 / 属性 | 说明 |\n| --- | --- |\n| `wrapRef` | wrap 容器元素引用。 |\n| `update()` | 重新计算滑块尺寸与位置。 |\n| `scrollTo(...)` | 滚动到指定位置(同原生 `scrollTo`)。 |\n| `setScrollTop(y)` | 设置纵向滚动位置。 |\n| `setScrollLeft(x)` | 设置横向滚动位置。 |\n| `handleScroll(event)` | wrap 的 scroll 事件处理,可手动转发。 |\n\n## Events\n\n| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `scroll` | `{ scrollTop, scrollLeft }` | 滚动位置变化。 |\n| `end-reached` | `'top' \\| 'bottom' \\| 'left' \\| 'right'` | 滚动到边缘。 |\n\n## Slots\n\n| 插槽名 | 说明 |\n| --- | --- |\n| `default` | 可滚动内容。 |\n\n## 类型\n\n<h4 id=\"ScrollbarAriaOrientation\">ScrollbarAriaOrientation</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype ScrollbarAriaOrientation = 'horizontal' | 'vertical'\n```\n\n<h4 id=\"ScrollbarClassValue\">ScrollbarClassValue</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype ScrollbarClassValue = | string\n | string[]\n | Record<string, boolean>\n | Array<string | Record<string, boolean> | null | undefined | false>\n```\n"
|
|
18239
18271
|
},
|
|
18240
18272
|
"en-US": {
|
|
18241
18273
|
"title": "Scrollbar",
|
|
@@ -18264,7 +18296,7 @@
|
|
|
18264
18296
|
{
|
|
18265
18297
|
"id": "horizontal",
|
|
18266
18298
|
"title": "Horizontal",
|
|
18267
|
-
"body": "A horizontal scrollbar appears when content is wider than the container. `trigger=\"none\"` and `always` keep the thumb visible; the default `trigger=\"hover\"` shows it on hover.\n\n`MLayout`, `MDialog`, `MConfirmDialog`, `MDrawer`, `MSplitter`, `MTable`, `MSelect`, `MTreeSelect`, `MDropdown`, `MContextMenu`, `MPopover`, `MConfirmPopup`, `MMenu` (popup), `MMenubar`, `MTieredMenu`, `MTabs`, `MGallery`, `MTimeline` (horizontal), `MTextarea` (autosize `maxRows`), `MTerminal`, `MOrderList`, `MPickList`,
|
|
18299
|
+
"body": "A horizontal scrollbar appears when content is wider than the container. `trigger=\"none\"` and `always` keep the thumb visible; the default `trigger=\"hover\"` shows it on hover.\n\n`MLayout`, `MDialog`, `MConfirmDialog`, `MDrawer`, `MSplitter`, `MTable`, `MSelect`, `MTreeSelect`, `MDropdown`, `MContextMenu`, `MPopover`, `MConfirmPopup`, `MMenu` (popup), `MMenubar`, `MTieredMenu`, `MTabs`, `MGallery`, `MTimeline` (horizontal), `MTextarea` (autosize `maxRows`), `MTerminal`, `MOrderList`, `MPickList`, and `MVirtualScroller` integrate this component internally.\n\n```vue preview src=\"./demos/Horizontal.vue\"\n```"
|
|
18268
18300
|
},
|
|
18269
18301
|
{
|
|
18270
18302
|
"id": "always-native",
|
|
@@ -18297,7 +18329,7 @@
|
|
|
18297
18329
|
"body": "| Slot | Description |\n| --- | --- |\n| `default` | Scrollable content. |"
|
|
18298
18330
|
}
|
|
18299
18331
|
],
|
|
18300
|
-
"markdown": "---\ntitle: Scrollbar\ncategory: 01 / BASIC\ndescription: Themeable custom scrollbar for a consistent scrolling experience.\n---\n\n# Scrollbar\n\nReplaces the native browser scrollbar with a themeable, cross-browser scrolling experience.\n\n## Import\n\n```ts\nimport { MScrollbar } from 'morya-ui'\n```\n\n## Basic\n\nUse `height` to fix the viewport height. If omitted, it follows the parent height.\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Max height\n\nThe scrollbar appears only when content exceeds `max-height`.\n\n```vue preview src=\"./demos/MaxHeight.vue\"\n```\n\n## Horizontal\n\nA horizontal scrollbar appears when content is wider than the container. `trigger=\"none\"` and `always` keep the thumb visible; the default `trigger=\"hover\"` shows it on hover.\n\n`MLayout`, `MDialog`, `MConfirmDialog`, `MDrawer`, `MSplitter`, `MTable`, `MSelect`, `MTreeSelect`, `MDropdown`, `MContextMenu`, `MPopover`, `MConfirmPopup`, `MMenu` (popup), `MMenubar`, `MTieredMenu`, `MTabs`, `MGallery`, `MTimeline` (horizontal), `MTextarea` (autosize `maxRows`), `MTerminal`, `MOrderList`, `MPickList`,
|
|
18332
|
+
"markdown": "---\ntitle: Scrollbar\ncategory: 01 / BASIC\ndescription: Themeable custom scrollbar for a consistent scrolling experience.\n---\n\n# Scrollbar\n\nReplaces the native browser scrollbar with a themeable, cross-browser scrolling experience.\n\n## Import\n\n```ts\nimport { MScrollbar } from 'morya-ui'\n```\n\n## Basic\n\nUse `height` to fix the viewport height. If omitted, it follows the parent height.\n\n```vue preview src=\"./demos/Basic.vue\"\n```\n\n## Max height\n\nThe scrollbar appears only when content exceeds `max-height`.\n\n```vue preview src=\"./demos/MaxHeight.vue\"\n```\n\n## Horizontal\n\nA horizontal scrollbar appears when content is wider than the container. `trigger=\"none\"` and `always` keep the thumb visible; the default `trigger=\"hover\"` shows it on hover.\n\n`MLayout`, `MDialog`, `MConfirmDialog`, `MDrawer`, `MSplitter`, `MTable`, `MSelect`, `MTreeSelect`, `MDropdown`, `MContextMenu`, `MPopover`, `MConfirmPopup`, `MMenu` (popup), `MMenubar`, `MTieredMenu`, `MTabs`, `MGallery`, `MTimeline` (horizontal), `MTextarea` (autosize `maxRows`), `MTerminal`, `MOrderList`, `MPickList`, and `MVirtualScroller` integrate this component internally.\n\n```vue preview src=\"./demos/Horizontal.vue\"\n```\n\n## Always / Native\n\n`always` keeps the custom thumb visible. `native` uses the browser scrollbar.\n\n```vue preview src=\"./demos/AlwaysNative.vue\"\n```\n\n## Manual scroll\n\nControl scrolling with instance methods `setScrollTop` / `setScrollLeft` / `scrollTo` / `update`.\n\n```vue preview src=\"./demos/ManualScroll.en.vue\"\n```\n\n## Infinite scroll\n\nEmits `end-reached` at the edge. Use it for infinite loading.\n\n```vue preview src=\"./demos/InfiniteScroll.en.vue\"\n```\n\n## API\n\n### Props\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| height | `string \\| number` | — | Viewport height |\n| maxHeight | `string \\| number` | — | Maximum height |\n| fitContent | `boolean` | `false` | Grow with content; pair with CSS `max-height` on the root (dropdown panels) |\n| native | `boolean` | `false` | Use the native scrollbar |\n| wrapStyle / wrapClass | style / class | — | Wrap container styles |\n| viewStyle / viewClass | style / class | — | Content area styles |\n| noresize | `boolean` | `false` | Do not listen for size changes |\n| tag | `string` | `div` | Content area tag |\n| always | `boolean` | `false` | Always show the thumb |\n| trigger | `'hover' \\| 'none'` | `'hover'` | `none` keeps thumbs visible; `always` still wins |\n| minSize | `number` | `20` | Minimum thumb size |\n| id / role / ariaLabel / ariaOrientation | a11y | — | Accessible attributes for the content area |\n| tabindex | `number \\| string` | — | tabindex on the wrap |\n| distance | `number` | `0` | Edge distance that triggers `end-reached` |\n| width | `string \\| number` | — | Viewport width |\n| maxWidth | `string \\| number` | — | Maximum width |\n| ariaMultiselectable | `boolean` | — | `aria-multiselectable` on the content area |\n| pt | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |\n\n### Events\n\n| Name | Payload |\n| --- | --- |\n| scroll | `{ scrollTop, scrollLeft }` |\n| end-reached | `'top' \\| 'bottom' \\| 'left' \\| 'right'` |\n\n### Expose\n\n| Method / Property | Description |\n| --- | --- |\n| `wrapRef` | Reference to the wrap element. |\n| `update()` | Recompute thumb size and position. |\n| `scrollTo(...)` | Scroll to a position (same as native `scrollTo`). |\n| `setScrollTop(y)` | Set vertical scroll offset. |\n| `setScrollLeft(x)` | Set horizontal scroll offset. |\n| `handleScroll(event)` | Wrap scroll handler; forward manually when needed. |\n\n## Events\n\n| Event | Payload | Description |\n| --- | --- | --- |\n| `scroll` | `{ scrollTop, scrollLeft }` | Scroll position change. |\n| `end-reached` | `'top' \\| 'bottom' \\| 'left' \\| 'right'` | Scroll boundary reached. |\n\n## Slots\n\n| Slot | Description |\n| --- | --- |\n| `default` | Scrollable content. |\n"
|
|
18301
18333
|
}
|
|
18302
18334
|
}
|
|
18303
18335
|
},
|
|
@@ -22119,7 +22151,7 @@
|
|
|
22119
22151
|
"description": "服务端分页/排序选项。"
|
|
22120
22152
|
},
|
|
22121
22153
|
{
|
|
22122
|
-
"name": "
|
|
22154
|
+
"name": "serverTotal",
|
|
22123
22155
|
"type": "number",
|
|
22124
22156
|
"default": "0",
|
|
22125
22157
|
"description": "服务端总条数。"
|
|
@@ -22142,17 +22174,107 @@
|
|
|
22142
22174
|
"default": "25",
|
|
22143
22175
|
"description": "每页条数。"
|
|
22144
22176
|
},
|
|
22177
|
+
{
|
|
22178
|
+
"name": "pageSizes",
|
|
22179
|
+
"type": "number[]",
|
|
22180
|
+
"default": "[25, 50, 100]",
|
|
22181
|
+
"description": "分页每页条数选项。"
|
|
22182
|
+
},
|
|
22183
|
+
{
|
|
22184
|
+
"name": "showHeader",
|
|
22185
|
+
"type": "boolean",
|
|
22186
|
+
"default": "true",
|
|
22187
|
+
"description": "是否显示表头。"
|
|
22188
|
+
},
|
|
22189
|
+
{
|
|
22190
|
+
"name": "showRowsPerPage",
|
|
22191
|
+
"type": "boolean",
|
|
22192
|
+
"default": "true",
|
|
22193
|
+
"description": "是否显示每页条数选择器。"
|
|
22194
|
+
},
|
|
22145
22195
|
{
|
|
22146
22196
|
"name": "fill",
|
|
22147
22197
|
"type": "boolean",
|
|
22148
22198
|
"default": "false",
|
|
22149
22199
|
"description": "撑满父级剩余高度(仅全视口主列表配 `MPageContent fill`);表体滚动,分页贴底。设置 `maxHeight` / `tableHeight` 时忽略。"
|
|
22150
22200
|
},
|
|
22201
|
+
{
|
|
22202
|
+
"name": "columnWidths",
|
|
22203
|
+
"type": "Record<string, number> | null",
|
|
22204
|
+
"default": "null",
|
|
22205
|
+
"description": "列宽(`v-model:column-widths`)。"
|
|
22206
|
+
},
|
|
22207
|
+
{
|
|
22208
|
+
"name": "virtual",
|
|
22209
|
+
"type": "boolean",
|
|
22210
|
+
"default": "false",
|
|
22211
|
+
"description": "行虚拟滚动(需高度;展开行时跳过)。"
|
|
22212
|
+
},
|
|
22213
|
+
{
|
|
22214
|
+
"name": "virtualRowHeight",
|
|
22215
|
+
"type": "number",
|
|
22216
|
+
"default": "40",
|
|
22217
|
+
"description": "虚拟行高估算。"
|
|
22218
|
+
},
|
|
22219
|
+
{
|
|
22220
|
+
"name": "hiddenColumns",
|
|
22221
|
+
"type": "string[] | null",
|
|
22222
|
+
"default": "null",
|
|
22223
|
+
"description": "隐藏列键(`v-model:hidden-columns`)。"
|
|
22224
|
+
},
|
|
22225
|
+
{
|
|
22226
|
+
"name": "columnOrder",
|
|
22227
|
+
"type": "string[] | null",
|
|
22228
|
+
"default": "null",
|
|
22229
|
+
"description": "叶列顺序(`v-model:column-order`)。"
|
|
22230
|
+
},
|
|
22231
|
+
{
|
|
22232
|
+
"name": "showFooter",
|
|
22233
|
+
"type": "boolean",
|
|
22234
|
+
"default": "false",
|
|
22235
|
+
"description": "显示表尾。"
|
|
22236
|
+
},
|
|
22237
|
+
{
|
|
22238
|
+
"name": "footerMethod",
|
|
22239
|
+
"type": "TableFooterMethod | null",
|
|
22240
|
+
"default": "null",
|
|
22241
|
+
"description": "表尾数据。"
|
|
22242
|
+
},
|
|
22243
|
+
{
|
|
22244
|
+
"name": "spanMethod",
|
|
22245
|
+
"type": "TableSpanMethod | null",
|
|
22246
|
+
"default": "null",
|
|
22247
|
+
"description": "单元格合并。"
|
|
22248
|
+
},
|
|
22249
|
+
{
|
|
22250
|
+
"name": "treeConfig",
|
|
22251
|
+
"type": "TableTreeConfig | null",
|
|
22252
|
+
"default": "null",
|
|
22253
|
+
"description": "树形行。"
|
|
22254
|
+
},
|
|
22255
|
+
{
|
|
22256
|
+
"name": "expandConfig",
|
|
22257
|
+
"type": "TableExpandConfig | null",
|
|
22258
|
+
"default": "null",
|
|
22259
|
+
"description": "详情展开配置(与树互斥)。"
|
|
22260
|
+
},
|
|
22261
|
+
{
|
|
22262
|
+
"name": "checkboxConfig",
|
|
22263
|
+
"type": "TableCheckboxConfig | null",
|
|
22264
|
+
"default": "null",
|
|
22265
|
+
"description": "多选:级联 / `checkMethod` / `checkRowKeys` / `trigger` / `reserve`。"
|
|
22266
|
+
},
|
|
22267
|
+
{
|
|
22268
|
+
"name": "radioConfig",
|
|
22269
|
+
"type": "TableRadioConfig | null",
|
|
22270
|
+
"default": "null",
|
|
22271
|
+
"description": "单选:`strict` / `checkMethod` / `trigger`。"
|
|
22272
|
+
},
|
|
22151
22273
|
{
|
|
22152
22274
|
"name": "expandable",
|
|
22153
22275
|
"type": "boolean",
|
|
22154
22276
|
"default": "false",
|
|
22155
|
-
"description": "显示展开列(也可由 `#expansion`
|
|
22277
|
+
"description": "显示展开列(也可由 `#expansion` 或 `expandConfig` 启用)。"
|
|
22156
22278
|
},
|
|
22157
22279
|
{
|
|
22158
22280
|
"name": "striped",
|
|
@@ -22292,12 +22414,6 @@
|
|
|
22292
22414
|
"default": "—",
|
|
22293
22415
|
"description": "—"
|
|
22294
22416
|
},
|
|
22295
|
-
{
|
|
22296
|
-
"name": "clickEventType",
|
|
22297
|
-
"type": "TableClickEventType",
|
|
22298
|
-
"default": "—",
|
|
22299
|
-
"description": "—"
|
|
22300
|
-
},
|
|
22301
22417
|
{
|
|
22302
22418
|
"name": "clickRowToExpand",
|
|
22303
22419
|
"type": "boolean",
|
|
@@ -22370,18 +22486,6 @@
|
|
|
22370
22486
|
"default": "—",
|
|
22371
22487
|
"description": "—"
|
|
22372
22488
|
},
|
|
22373
|
-
{
|
|
22374
|
-
"name": "hideHeader",
|
|
22375
|
-
"type": "boolean",
|
|
22376
|
-
"default": "—",
|
|
22377
|
-
"description": "—"
|
|
22378
|
-
},
|
|
22379
|
-
{
|
|
22380
|
-
"name": "hideRowsPerPage",
|
|
22381
|
-
"type": "boolean",
|
|
22382
|
-
"default": "—",
|
|
22383
|
-
"description": "—"
|
|
22384
|
-
},
|
|
22385
22489
|
{
|
|
22386
22490
|
"name": "indexColumnWidth",
|
|
22387
22491
|
"type": "number",
|
|
@@ -22400,36 +22504,6 @@
|
|
|
22400
22504
|
"default": "—",
|
|
22401
22505
|
"description": "—"
|
|
22402
22506
|
},
|
|
22403
|
-
{
|
|
22404
|
-
"name": "preventContextMenuRow",
|
|
22405
|
-
"type": "boolean",
|
|
22406
|
-
"default": "—",
|
|
22407
|
-
"description": "—"
|
|
22408
|
-
},
|
|
22409
|
-
{
|
|
22410
|
-
"name": "rowsItems",
|
|
22411
|
-
"type": "number[]",
|
|
22412
|
-
"default": "—",
|
|
22413
|
-
"description": "—"
|
|
22414
|
-
},
|
|
22415
|
-
{
|
|
22416
|
-
"name": "rowsOfPageSeparatorMessage",
|
|
22417
|
-
"type": "string",
|
|
22418
|
-
"default": "—",
|
|
22419
|
-
"description": "—"
|
|
22420
|
-
},
|
|
22421
|
-
{
|
|
22422
|
-
"name": "rowsPerPageMessage",
|
|
22423
|
-
"type": "string",
|
|
22424
|
-
"default": "—",
|
|
22425
|
-
"description": "—"
|
|
22426
|
-
},
|
|
22427
|
-
{
|
|
22428
|
-
"name": "showHeader",
|
|
22429
|
-
"type": "boolean",
|
|
22430
|
-
"default": "—",
|
|
22431
|
-
"description": "—"
|
|
22432
|
-
},
|
|
22433
22507
|
{
|
|
22434
22508
|
"name": "showIndex",
|
|
22435
22509
|
"type": "boolean",
|
|
@@ -22460,12 +22534,6 @@
|
|
|
22460
22534
|
"default": "—",
|
|
22461
22535
|
"description": "—"
|
|
22462
22536
|
},
|
|
22463
|
-
{
|
|
22464
|
-
"name": "tableNodeId",
|
|
22465
|
-
"type": "string",
|
|
22466
|
-
"default": "—",
|
|
22467
|
-
"description": "—"
|
|
22468
|
-
},
|
|
22469
22537
|
{
|
|
22470
22538
|
"name": "pt",
|
|
22471
22539
|
"type": "[RootPassThrough](/docs/types#RootPassThrough) `{ root? }",
|
|
@@ -22479,16 +22547,36 @@
|
|
|
22479
22547
|
"payload": "{ sortField?, sortOrder? }",
|
|
22480
22548
|
"description": "排序变化。"
|
|
22481
22549
|
},
|
|
22482
|
-
{
|
|
22483
|
-
"name": "page",
|
|
22484
|
-
"payload": "number",
|
|
22485
|
-
"description": "页码变化。"
|
|
22486
|
-
},
|
|
22487
22550
|
{
|
|
22488
22551
|
"name": "row-click",
|
|
22489
|
-
"payload": "{ row, index }",
|
|
22552
|
+
"payload": "{ row, index }`, `Event",
|
|
22490
22553
|
"description": "行单击。"
|
|
22491
22554
|
},
|
|
22555
|
+
{
|
|
22556
|
+
"name": "row-dblclick",
|
|
22557
|
+
"payload": "{ row, index }`, `Event",
|
|
22558
|
+
"description": "行双击。"
|
|
22559
|
+
},
|
|
22560
|
+
{
|
|
22561
|
+
"name": "row-contextmenu",
|
|
22562
|
+
"payload": "item`, `MouseEvent",
|
|
22563
|
+
"description": "行右键。"
|
|
22564
|
+
},
|
|
22565
|
+
{
|
|
22566
|
+
"name": "select-row",
|
|
22567
|
+
"payload": "TableItem",
|
|
22568
|
+
"description": "选中一行。"
|
|
22569
|
+
},
|
|
22570
|
+
{
|
|
22571
|
+
"name": "deselect-row",
|
|
22572
|
+
"payload": "TableItem",
|
|
22573
|
+
"description": "取消选中一行。"
|
|
22574
|
+
},
|
|
22575
|
+
{
|
|
22576
|
+
"name": "select-all",
|
|
22577
|
+
"payload": "—",
|
|
22578
|
+
"description": "全选当前页。"
|
|
22579
|
+
},
|
|
22492
22580
|
{
|
|
22493
22581
|
"name": "current-change",
|
|
22494
22582
|
"payload": "row | null, oldRow | null",
|
|
@@ -22519,31 +22607,11 @@
|
|
|
22519
22607
|
"payload": "string | number | null",
|
|
22520
22608
|
"description": "当前行键 v-model。"
|
|
22521
22609
|
},
|
|
22522
|
-
{
|
|
22523
|
-
"name": "contextmenuRow",
|
|
22524
|
-
"payload": "—",
|
|
22525
|
-
"description": "—"
|
|
22526
|
-
},
|
|
22527
|
-
{
|
|
22528
|
-
"name": "deselectRow",
|
|
22529
|
-
"payload": "—",
|
|
22530
|
-
"description": "—"
|
|
22531
|
-
},
|
|
22532
22610
|
{
|
|
22533
22611
|
"name": "filter",
|
|
22534
22612
|
"payload": "—",
|
|
22535
22613
|
"description": "—"
|
|
22536
22614
|
},
|
|
22537
|
-
{
|
|
22538
|
-
"name": "selectAll",
|
|
22539
|
-
"payload": "—",
|
|
22540
|
-
"description": "—"
|
|
22541
|
-
},
|
|
22542
|
-
{
|
|
22543
|
-
"name": "selectRow",
|
|
22544
|
-
"payload": "—",
|
|
22545
|
-
"description": "—"
|
|
22546
|
-
},
|
|
22547
22615
|
{
|
|
22548
22616
|
"name": "update:expandedRowKeys",
|
|
22549
22617
|
"payload": "—",
|
|
@@ -22555,17 +22623,22 @@
|
|
|
22555
22623
|
"description": "—"
|
|
22556
22624
|
},
|
|
22557
22625
|
{
|
|
22558
|
-
"name": "update:
|
|
22559
|
-
"payload": "
|
|
22560
|
-
"description": "
|
|
22626
|
+
"name": "update:columnWidths",
|
|
22627
|
+
"payload": "Record<string, number>",
|
|
22628
|
+
"description": "列宽 v-model。"
|
|
22561
22629
|
},
|
|
22562
22630
|
{
|
|
22563
|
-
"name": "
|
|
22564
|
-
"payload": "
|
|
22565
|
-
"description": "
|
|
22631
|
+
"name": "update:hiddenColumns",
|
|
22632
|
+
"payload": "string[]",
|
|
22633
|
+
"description": "隐藏列 v-model。"
|
|
22566
22634
|
},
|
|
22567
22635
|
{
|
|
22568
|
-
"name": "
|
|
22636
|
+
"name": "update:columnOrder",
|
|
22637
|
+
"payload": "string[]",
|
|
22638
|
+
"description": "列顺序 v-model。"
|
|
22639
|
+
},
|
|
22640
|
+
{
|
|
22641
|
+
"name": "update:selectedItem",
|
|
22569
22642
|
"payload": "—",
|
|
22570
22643
|
"description": "—"
|
|
22571
22644
|
}
|
|
@@ -22573,7 +22646,11 @@
|
|
|
22573
22646
|
"slots": [
|
|
22574
22647
|
{
|
|
22575
22648
|
"name": "cell-{key}",
|
|
22576
|
-
"description": "列 `{key}` 单元格,作用域 `{ row, value, column }
|
|
22649
|
+
"description": "列 `{key}` 单元格,作用域 `{ row, value, column }`(可自行实现编辑器)。"
|
|
22650
|
+
},
|
|
22651
|
+
{
|
|
22652
|
+
"name": "footer",
|
|
22653
|
+
"description": "自定义表尾。"
|
|
22577
22654
|
},
|
|
22578
22655
|
{
|
|
22579
22656
|
"name": "body-cell",
|
|
@@ -22616,8 +22693,8 @@
|
|
|
22616
22693
|
"description": "自定义 `header` 内容。"
|
|
22617
22694
|
},
|
|
22618
22695
|
{
|
|
22619
|
-
"name": "header
|
|
22620
|
-
"description": "
|
|
22696
|
+
"name": "header-{key}",
|
|
22697
|
+
"description": "列头插槽(键名大小写与 `columns[].key` 一致)。"
|
|
22621
22698
|
}
|
|
22622
22699
|
],
|
|
22623
22700
|
"methods": [
|
|
@@ -22675,7 +22752,107 @@
|
|
|
22675
22752
|
},
|
|
22676
22753
|
{
|
|
22677
22754
|
"name": "setFilters",
|
|
22678
|
-
"description": "
|
|
22755
|
+
"description": "设置 / 清空筛选。"
|
|
22756
|
+
},
|
|
22757
|
+
{
|
|
22758
|
+
"name": "clearFilter",
|
|
22759
|
+
"description": "设置 / 清空筛选。"
|
|
22760
|
+
},
|
|
22761
|
+
{
|
|
22762
|
+
"name": "setColumnWidths",
|
|
22763
|
+
"description": "设置列宽(等同 `v-model:column-widths`)。"
|
|
22764
|
+
},
|
|
22765
|
+
{
|
|
22766
|
+
"name": "setHiddenColumns",
|
|
22767
|
+
"description": "设置隐藏列键(等同 `v-model:hidden-columns`)。"
|
|
22768
|
+
},
|
|
22769
|
+
{
|
|
22770
|
+
"name": "setColumnOrder",
|
|
22771
|
+
"description": "设置叶列顺序(等同 `v-model:column-order`)。"
|
|
22772
|
+
},
|
|
22773
|
+
{
|
|
22774
|
+
"name": "clearSort",
|
|
22775
|
+
"description": "清空排序。"
|
|
22776
|
+
},
|
|
22777
|
+
{
|
|
22778
|
+
"name": "getCheckboxRecords",
|
|
22779
|
+
"description": "当前多选行。"
|
|
22780
|
+
},
|
|
22781
|
+
{
|
|
22782
|
+
"name": "setCheckboxRow",
|
|
22783
|
+
"description": "设置行选中状态。"
|
|
22784
|
+
},
|
|
22785
|
+
{
|
|
22786
|
+
"name": "clearCheckboxRow",
|
|
22787
|
+
"description": "清空多选。"
|
|
22788
|
+
},
|
|
22789
|
+
{
|
|
22790
|
+
"name": "isCheckedByCheckboxRow",
|
|
22791
|
+
"description": "行是否选中。"
|
|
22792
|
+
},
|
|
22793
|
+
{
|
|
22794
|
+
"name": "isAllCheckboxChecked",
|
|
22795
|
+
"description": "当前页是否全选。"
|
|
22796
|
+
},
|
|
22797
|
+
{
|
|
22798
|
+
"name": "getCheckboxIndeterminateRecords",
|
|
22799
|
+
"description": "半选行(树级联)。"
|
|
22800
|
+
},
|
|
22801
|
+
{
|
|
22802
|
+
"name": "scrollTo",
|
|
22803
|
+
"description": "滚动定位。"
|
|
22804
|
+
},
|
|
22805
|
+
{
|
|
22806
|
+
"name": "scrollToRow",
|
|
22807
|
+
"description": "滚动定位。"
|
|
22808
|
+
},
|
|
22809
|
+
{
|
|
22810
|
+
"name": "setRowExpand",
|
|
22811
|
+
"description": "详情展开(非树模式)。"
|
|
22812
|
+
},
|
|
22813
|
+
{
|
|
22814
|
+
"name": "setAllRowExpand",
|
|
22815
|
+
"description": "详情展开(非树模式)。"
|
|
22816
|
+
},
|
|
22817
|
+
{
|
|
22818
|
+
"name": "toggleRowExpand",
|
|
22819
|
+
"description": "详情展开(非树模式)。"
|
|
22820
|
+
},
|
|
22821
|
+
{
|
|
22822
|
+
"name": "clearRowExpand",
|
|
22823
|
+
"description": "详情展开(非树模式)。"
|
|
22824
|
+
},
|
|
22825
|
+
{
|
|
22826
|
+
"name": "isRowExpandByRow",
|
|
22827
|
+
"description": "详情展开(非树模式)。"
|
|
22828
|
+
},
|
|
22829
|
+
{
|
|
22830
|
+
"name": "getRowExpandRecords",
|
|
22831
|
+
"description": "详情展开(非树模式)。"
|
|
22832
|
+
},
|
|
22833
|
+
{
|
|
22834
|
+
"name": "setTreeExpand",
|
|
22835
|
+
"description": "树节点展开。"
|
|
22836
|
+
},
|
|
22837
|
+
{
|
|
22838
|
+
"name": "setAllTreeExpand",
|
|
22839
|
+
"description": "树节点展开。"
|
|
22840
|
+
},
|
|
22841
|
+
{
|
|
22842
|
+
"name": "toggleTreeExpand",
|
|
22843
|
+
"description": "树节点展开。"
|
|
22844
|
+
},
|
|
22845
|
+
{
|
|
22846
|
+
"name": "clearTreeExpand",
|
|
22847
|
+
"description": "树节点展开。"
|
|
22848
|
+
},
|
|
22849
|
+
{
|
|
22850
|
+
"name": "isTreeExpandByRow",
|
|
22851
|
+
"description": "树节点展开。"
|
|
22852
|
+
},
|
|
22853
|
+
{
|
|
22854
|
+
"name": "getTreeExpandRecords",
|
|
22855
|
+
"description": "树节点展开。"
|
|
22679
22856
|
}
|
|
22680
22857
|
],
|
|
22681
22858
|
"examples": [
|
|
@@ -22721,7 +22898,7 @@
|
|
|
22721
22898
|
"sectionId": "固定列",
|
|
22722
22899
|
"lang": "vue",
|
|
22723
22900
|
"preview": true,
|
|
22724
|
-
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\n\nconst columns = [\n { key: 'name', label: '姓名', width: 120, fixed: 'left' as const },\n { key: 'q1', label: 'Q1 营收', width: 140 },\n { key: 'q2', label: 'Q2 营收', width: 140 },\n { key: 'q3', label: 'Q3 营收', width: 140 },\n { key: 'action', label: '操作', width: 100 },\n]\nconst rows = [\n { id: 1, name: 'Ada', q1: '12.4万', q2: '13.1万', q3: '14.0万', action: '编辑' },\n { id: 2, name: 'Lin', q1: '9.8万', q2: '10.2万', q3: '11.5万', action: '编辑' },\n]\n</script>\n\n<template>\n <MTable :columns=\"columns\" :rows=\"rows\" bordered :paginator=\"false\" />\n</template>",
|
|
22901
|
+
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\n\nconst columns = [\n { key: 'name', label: '姓名', width: 120, fixed: 'left' as const },\n { key: 'q1', label: 'Q1 营收', width: 140 },\n { key: 'q2', label: 'Q2 营收', width: 140 },\n { key: 'q3', label: 'Q3 营收', width: 140 },\n { key: 'action', label: '操作', width: 100, fixed: 'right' as const },\n]\nconst rows = [\n { id: 1, name: 'Ada', q1: '12.4万', q2: '13.1万', q3: '14.0万', action: '编辑' },\n { id: 2, name: 'Lin', q1: '9.8万', q2: '10.2万', q3: '11.5万', action: '编辑' },\n]\n</script>\n\n<template>\n <MTable :columns=\"columns\" :rows=\"rows\" bordered :paginator=\"false\" />\n</template>",
|
|
22725
22902
|
"locale": "zh-CN"
|
|
22726
22903
|
},
|
|
22727
22904
|
{
|
|
@@ -22730,7 +22907,34 @@
|
|
|
22730
22907
|
"sectionId": "展开行与列渲染",
|
|
22731
22908
|
"lang": "vue",
|
|
22732
22909
|
"preview": true,
|
|
22733
|
-
"code": "<script setup lang=\"ts\">\nimport type {
|
|
22910
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableItem } from 'morya-ui'\nimport { MTable } from 'morya-ui'\n\ntype Row = { id: number; name: string; role: string; extra: string }\n\nconst columns = [\n { key: 'name', label: '姓名' },\n { key: 'role', label: '角色' },\n]\nconst rows: Row[] = [{ id: 1, name: 'Ada', role: '设计师', extra: '设计系统细节' }]\n\nfunction extraOf(row: TableItem) {\n return (row as Row).extra\n}\n</script>\n\n<template>\n <MTable :columns=\"columns\" :rows=\"rows\" expandable bordered :paginator=\"false\">\n <template #expansion=\"{ row }\">\n {{ extraOf(row) }}\n </template>\n </MTable>\n</template>",
|
|
22911
|
+
"locale": "zh-CN"
|
|
22912
|
+
},
|
|
22913
|
+
{
|
|
22914
|
+
"id": "列宽拖拽与表头筛选-1",
|
|
22915
|
+
"section": "列宽拖拽与表头筛选",
|
|
22916
|
+
"sectionId": "列宽拖拽与表头筛选",
|
|
22917
|
+
"lang": "vue",
|
|
22918
|
+
"preview": true,
|
|
22919
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableColumnDefinition } from 'morya-ui'\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns: TableColumnDefinition[] = [\n {\n key: 'name',\n label: '姓名',\n width: 140,\n resizable: true,\n filterable: true,\n },\n {\n key: 'status',\n label: '状态',\n width: 120,\n resizable: true,\n filterable: true,\n filters: [\n { text: '草稿', value: 'Draft' },\n { text: '上线', value: 'Live' },\n ],\n },\n { key: 'role', label: '角色', minWidth: 120 },\n]\n\nconst rows = [\n { id: 1, name: 'Ada', status: 'Draft', role: 'Designer' },\n { id: 2, name: 'Lin', status: 'Live', role: 'Engineer' },\n { id: 3, name: 'Kai', status: 'Live', role: 'Engineer' },\n { id: 4, name: 'Mia', status: 'Draft', role: 'Designer' },\n]\n\nconst columnWidths = ref<Record<string, number>>({})\n</script>\n\n<template>\n <MTable\n v-model:column-widths=\"columnWidths\"\n :columns=\"columns\"\n :rows=\"rows\"\n bordered\n :paginator=\"false\"\n />\n</template>",
|
|
22920
|
+
"locale": "zh-CN"
|
|
22921
|
+
},
|
|
22922
|
+
{
|
|
22923
|
+
"id": "虚拟滚动-1",
|
|
22924
|
+
"section": "虚拟滚动",
|
|
22925
|
+
"sectionId": "虚拟滚动",
|
|
22926
|
+
"lang": "vue",
|
|
22927
|
+
"preview": true,
|
|
22928
|
+
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\n\nconst columns = [\n { key: 'id', label: 'ID', width: 80 },\n { key: 'name', label: '姓名', minWidth: 160 },\n]\n\nconst rows = Array.from({ length: 5000 }, (_, i) => ({\n id: i + 1,\n name: `行 ${i + 1}`,\n}))\n</script>\n\n<template>\n <MTable\n :columns=\"columns\"\n :rows=\"rows\"\n virtual\n :virtual-row-height=\"40\"\n :max-height=\"320\"\n bordered\n :paginator=\"false\"\n />\n</template>",
|
|
22929
|
+
"locale": "zh-CN"
|
|
22930
|
+
},
|
|
22931
|
+
{
|
|
22932
|
+
"id": "多级表头-表尾与合并-1",
|
|
22933
|
+
"section": "多级表头、表尾与合并",
|
|
22934
|
+
"sectionId": "多级表头-表尾与合并",
|
|
22935
|
+
"lang": "vue",
|
|
22936
|
+
"preview": true,
|
|
22937
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns: TableColumnDefinition[] = [\n {\n key: 'info',\n label: '基本信息',\n children: [\n { key: 'name', label: '姓名' },\n { key: 'role', label: '角色' },\n ],\n },\n { key: 'score', label: '分数', align: 'end' },\n]\n\nconst rows = ref<TableItem[]>([\n { id: 1, name: 'Ada', role: 'Designer', score: 96 },\n { id: 2, name: 'Lin', role: 'Engineer', score: 88 },\n { id: 3, name: 'Kai', role: 'Engineer', score: 91 },\n])\n\nconst hiddenColumns = ref<string[]>([])\n</script>\n\n<template>\n <MTable\n v-model:hidden-columns=\"hiddenColumns\"\n :columns=\"columns\"\n :rows=\"rows\"\n bordered\n show-footer\n :footer-method=\"({ data }) => [[\n '合计',\n '',\n data.reduce((sum, row) => sum + Number(row.score ?? 0), 0),\n ]]\"\n :span-method=\"({ column, rowIndex }) => {\n if (column.value === 'role' && rowIndex === 1) return { rowspan: 2, colspan: 1 }\n if (column.value === 'role' && rowIndex === 2) return { rowspan: 0, colspan: 0 }\n return { rowspan: 1, colspan: 1 }\n }\"\n :paginator=\"false\"\n />\n</template>",
|
|
22734
22938
|
"locale": "zh-CN"
|
|
22735
22939
|
},
|
|
22736
22940
|
{
|
|
@@ -22742,13 +22946,22 @@
|
|
|
22742
22946
|
"code": "<script setup lang=\"ts\">\nimport { MButton, MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst loading = ref(false)\nconst columns = [\n { key: 'name', label: '姓名', minWidth: 120 },\n { key: 'role', label: '角色', minWidth: 120 },\n]\n</script>\n\n<template>\n <div class=\"grid gap-3\">\n <MButton :label=\"loading ? '结束加载' : '开始加载'\" @click=\"loading = !loading\" />\n <MTable\n :columns=\"columns\"\n :rows=\"[]\"\n :loading=\"loading\"\n empty-text=\"还没有数据\"\n empty-description=\"创建第一条记录后会显示在这里\"\n :paginator=\"false\"\n />\n </div>\n</template>",
|
|
22743
22947
|
"locale": "zh-CN"
|
|
22744
22948
|
},
|
|
22949
|
+
{
|
|
22950
|
+
"id": "树形表格-1",
|
|
22951
|
+
"section": "树形表格",
|
|
22952
|
+
"sectionId": "树形表格",
|
|
22953
|
+
"lang": "vue",
|
|
22954
|
+
"preview": true,
|
|
22955
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns: TableColumnDefinition[] = [\n { key: 'name', label: '名称' },\n { key: 'size', label: '大小' },\n]\n\nconst rows = ref<TableItem[]>([\n {\n id: 1,\n name: '应用',\n size: '100kb',\n children: [\n { id: 11, name: 'Vue', size: '25kb' },\n { id: 12, name: 'React', size: '30kb' },\n ],\n },\n {\n id: 2,\n name: '文档',\n size: '40kb',\n children: [{ id: 21, name: 'README.md', size: '4kb' }],\n },\n])\n\nconst expandedRowKeys = ref<Array<string | number>>([1])\nconst selection = ref<TableItem[]>([])\n</script>\n\n<template>\n <MTable\n v-model:expanded-row-keys=\"expandedRowKeys\"\n v-model:selection=\"selection\"\n selection-mode=\"multiple\"\n :columns=\"columns\"\n :rows=\"rows\"\n :tree-config=\"{ childrenField: 'children', indent: 16 }\"\n :checkbox-config=\"{ checkStrictly: false }\"\n bordered\n :paginator=\"false\"\n />\n</template>",
|
|
22956
|
+
"locale": "zh-CN"
|
|
22957
|
+
},
|
|
22745
22958
|
{
|
|
22746
22959
|
"id": "服务端模式-1",
|
|
22747
22960
|
"section": "服务端模式",
|
|
22748
22961
|
"sectionId": "服务端模式",
|
|
22749
22962
|
"lang": "vue",
|
|
22750
22963
|
"preview": true,
|
|
22751
|
-
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns = [\n { key: 'name', label: '项目', sortable: true, minWidth: 140 },\n { key: 'owner', label: '负责人', minWidth: 100 },\n]\nconst rows = ref([\n { id: 1, name: 'Landing', owner: 'Ada' },\n { id: 2, name: 'Dashboard', owner: 'Lin' },\n])\nconst serverOptions = ref({ page: 1, rowsPerPage: 10, sortBy: 'name', sortType: 'asc' as const })\nconst total = ref(42)\n</script>\n\n<template>\n <MTable\n v-model:server-options=\"serverOptions\"\n :columns=\"columns\"\n :rows=\"rows\"\n :server-
|
|
22964
|
+
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns = [\n { key: 'name', label: '项目', sortable: true, minWidth: 140 },\n { key: 'owner', label: '负责人', minWidth: 100 },\n]\nconst rows = ref([\n { id: 1, name: 'Landing', owner: 'Ada' },\n { id: 2, name: 'Dashboard', owner: 'Lin' },\n])\nconst serverOptions = ref({ page: 1, rowsPerPage: 10, sortBy: 'name', sortType: 'asc' as const })\nconst total = ref(42)\n</script>\n\n<template>\n <MTable\n v-model:server-options=\"serverOptions\"\n :columns=\"columns\"\n :rows=\"rows\"\n :server-total=\"total\"\n :loading=\"false\"\n />\n</template>",
|
|
22752
22965
|
"locale": "zh-CN"
|
|
22753
22966
|
},
|
|
22754
22967
|
{
|
|
@@ -22775,7 +22988,7 @@
|
|
|
22775
22988
|
"sectionId": "类型",
|
|
22776
22989
|
"lang": "ts",
|
|
22777
22990
|
"preview": false,
|
|
22778
|
-
"code": "type
|
|
22991
|
+
"code": "type TableFilterOption = | { field: string; comparison: 'between'; criteria: [number, number] }\n | { field: string; comparison: '=' | '!='; criteria: number | string }\n | { field: string; comparison: '>' | '>=' | '<' | '<='; criteria: number }\n | { field: number | string; comparison: 'in'; criteria: number[] | string[] }\n | { field: string; comparison: (value: unknown, criteria: string) => boolean; criteria: string }",
|
|
22779
22992
|
"locale": "zh-CN"
|
|
22780
22993
|
},
|
|
22781
22994
|
{
|
|
@@ -22784,7 +22997,7 @@
|
|
|
22784
22997
|
"sectionId": "类型",
|
|
22785
22998
|
"lang": "ts",
|
|
22786
22999
|
"preview": false,
|
|
22787
|
-
"code": "type
|
|
23000
|
+
"code": "type TableHeaderItemClassName = string | ((header: TableHeader, columnNumber: number) => string)",
|
|
22788
23001
|
"locale": "zh-CN"
|
|
22789
23002
|
},
|
|
22790
23003
|
{
|
|
@@ -22793,7 +23006,7 @@
|
|
|
22793
23006
|
"sectionId": "类型",
|
|
22794
23007
|
"lang": "ts",
|
|
22795
23008
|
"preview": false,
|
|
22796
|
-
"code": "type
|
|
23009
|
+
"code": "type TableBodyRowClassName = string | ((item: TableItem, rowNumber: number) => string)",
|
|
22797
23010
|
"locale": "zh-CN"
|
|
22798
23011
|
},
|
|
22799
23012
|
{
|
|
@@ -22802,7 +23015,7 @@
|
|
|
22802
23015
|
"sectionId": "类型",
|
|
22803
23016
|
"lang": "ts",
|
|
22804
23017
|
"preview": false,
|
|
22805
|
-
"code": "type
|
|
23018
|
+
"code": "type TableBodyItemClassName = string | ((column: string, rowNumber: number) => string)",
|
|
22806
23019
|
"locale": "zh-CN"
|
|
22807
23020
|
},
|
|
22808
23021
|
{
|
|
@@ -22811,7 +23024,7 @@
|
|
|
22811
23024
|
"sectionId": "类型",
|
|
22812
23025
|
"lang": "ts",
|
|
22813
23026
|
"preview": false,
|
|
22814
|
-
"code": "
|
|
23027
|
+
"code": "interface TableTreeConfig {\n childrenField?: string // default 'children'\n indent?: number // default 16\n expandAll?: boolean\n accordion?: boolean\n trigger?: 'default' | 'row'\n lazy?: boolean\n hasChildField?: string // default 'hasChild'\n loadMethod?: (row: TableItem) => Promise<TableItem[]> | TableItem[]\n transform?: boolean // flat parentId → tree\n rowField?: string\n parentField?: string // default 'parentId'\n treeNode?: string // column key for toggler; default first column\n showLine?: boolean\n}",
|
|
22815
23028
|
"locale": "zh-CN"
|
|
22816
23029
|
},
|
|
22817
23030
|
{
|
|
@@ -22820,7 +23033,7 @@
|
|
|
22820
23033
|
"sectionId": "类型",
|
|
22821
23034
|
"lang": "ts",
|
|
22822
23035
|
"preview": false,
|
|
22823
|
-
"code": "interface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'
|
|
23036
|
+
"code": "interface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n render?: (row: TableItem) => unknown\n showOverflowTooltip?: boolean\n}",
|
|
22824
23037
|
"locale": "zh-CN"
|
|
22825
23038
|
},
|
|
22826
23039
|
{
|
|
@@ -22877,6 +23090,42 @@
|
|
|
22877
23090
|
"code": "<script setup lang=\"ts\">\nimport type { TableItem } from 'morya-ui'\nimport { MTable } from 'morya-ui'\n\ntype Row = { id: number; name: string; role: string; extra: string }\n\nconst columns = [\n { key: 'name', label: 'Name' },\n { key: 'role', label: 'Role' },\n]\nconst rows: Row[] = [{ id: 1, name: 'Ada', role: 'Designer', extra: 'Design system' }]\n\nfunction extraOf(row: TableItem) {\n return (row as Row).extra\n}\n</script>\n\n<template>\n <MTable :columns=\"columns\" :rows=\"rows\" expandable bordered :paginator=\"false\">\n <template #expansion=\"{ row }\">\n {{ extraOf(row) }}\n </template>\n </MTable>\n</template>",
|
|
22878
23091
|
"locale": "en-US"
|
|
22879
23092
|
},
|
|
23093
|
+
{
|
|
23094
|
+
"id": "fixed-columns-1",
|
|
23095
|
+
"section": "Fixed columns",
|
|
23096
|
+
"sectionId": "fixed-columns",
|
|
23097
|
+
"lang": "vue",
|
|
23098
|
+
"preview": true,
|
|
23099
|
+
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\n\nconst columns = [\n { key: 'name', label: 'Name', width: 120, fixed: 'left' as const },\n { key: 'q1', label: 'Q1 Revenue', width: 140 },\n { key: 'q2', label: 'Q2 Revenue', width: 140 },\n { key: 'q3', label: 'Q3 Revenue', width: 140 },\n { key: 'action', label: 'Action', width: 100, fixed: 'right' as const },\n]\nconst rows = [\n { id: 1, name: 'Ada', q1: '124k', q2: '131k', q3: '140k', action: 'Edit' },\n { id: 2, name: 'Lin', q1: '98k', q2: '102k', q3: '115k', action: 'Edit' },\n]\n</script>\n\n<template>\n <MTable :columns=\"columns\" :rows=\"rows\" bordered :paginator=\"false\" />\n</template>",
|
|
23100
|
+
"locale": "en-US"
|
|
23101
|
+
},
|
|
23102
|
+
{
|
|
23103
|
+
"id": "column-resize-and-header-filters-1",
|
|
23104
|
+
"section": "Column resize and header filters",
|
|
23105
|
+
"sectionId": "column-resize-and-header-filters",
|
|
23106
|
+
"lang": "vue",
|
|
23107
|
+
"preview": true,
|
|
23108
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableColumnDefinition } from 'morya-ui'\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns: TableColumnDefinition[] = [\n {\n key: 'name',\n label: 'Name',\n width: 140,\n resizable: true,\n filterable: true,\n },\n {\n key: 'status',\n label: 'Status',\n width: 120,\n resizable: true,\n filterable: true,\n filters: [\n { text: 'Draft', value: 'Draft' },\n { text: 'Live', value: 'Live' },\n ],\n },\n { key: 'role', label: 'Role', minWidth: 120 },\n]\n\nconst rows = [\n { id: 1, name: 'Ada', status: 'Draft', role: 'Designer' },\n { id: 2, name: 'Lin', status: 'Live', role: 'Engineer' },\n { id: 3, name: 'Kai', status: 'Live', role: 'Engineer' },\n { id: 4, name: 'Mia', status: 'Draft', role: 'Designer' },\n]\n\nconst columnWidths = ref<Record<string, number>>({})\n</script>\n\n<template>\n <MTable\n v-model:column-widths=\"columnWidths\"\n :columns=\"columns\"\n :rows=\"rows\"\n bordered\n :paginator=\"false\"\n />\n</template>",
|
|
23109
|
+
"locale": "en-US"
|
|
23110
|
+
},
|
|
23111
|
+
{
|
|
23112
|
+
"id": "virtual-scroll-1",
|
|
23113
|
+
"section": "Virtual scroll",
|
|
23114
|
+
"sectionId": "virtual-scroll",
|
|
23115
|
+
"lang": "vue",
|
|
23116
|
+
"preview": true,
|
|
23117
|
+
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\n\nconst columns = [\n { key: 'id', label: 'ID', width: 80 },\n { key: 'name', label: 'Name', minWidth: 160 },\n]\n\nconst rows = Array.from({ length: 5000 }, (_, i) => ({\n id: i + 1,\n name: `Row ${i + 1}`,\n}))\n</script>\n\n<template>\n <MTable\n :columns=\"columns\"\n :rows=\"rows\"\n virtual\n :virtual-row-height=\"40\"\n :max-height=\"320\"\n bordered\n :paginator=\"false\"\n />\n</template>",
|
|
23118
|
+
"locale": "en-US"
|
|
23119
|
+
},
|
|
23120
|
+
{
|
|
23121
|
+
"id": "multi-header-footer-and-merges-1",
|
|
23122
|
+
"section": "Multi-header, footer, and merges",
|
|
23123
|
+
"sectionId": "multi-header-footer-and-merges",
|
|
23124
|
+
"lang": "vue",
|
|
23125
|
+
"preview": true,
|
|
23126
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns: TableColumnDefinition[] = [\n {\n key: 'info',\n label: 'Info',\n children: [\n { key: 'name', label: 'Name' },\n { key: 'role', label: 'Role' },\n ],\n },\n { key: 'score', label: 'Score', align: 'end' },\n]\n\nconst rows = ref<TableItem[]>([\n { id: 1, name: 'Ada', role: 'Designer', score: 96 },\n { id: 2, name: 'Lin', role: 'Engineer', score: 88 },\n { id: 3, name: 'Kai', role: 'Engineer', score: 91 },\n])\n\nconst hiddenColumns = ref<string[]>([])\n</script>\n\n<template>\n <MTable\n v-model:hidden-columns=\"hiddenColumns\"\n :columns=\"columns\"\n :rows=\"rows\"\n bordered\n show-footer\n :footer-method=\"({ data }) => [[\n 'Total',\n '',\n data.reduce((sum, row) => sum + Number(row.score ?? 0), 0),\n ]]\"\n :span-method=\"({ column, rowIndex }) => {\n if (column.value === 'role' && rowIndex === 1) return { rowspan: 2, colspan: 1 }\n if (column.value === 'role' && rowIndex === 2) return { rowspan: 0, colspan: 0 }\n return { rowspan: 1, colspan: 1 }\n }\"\n :paginator=\"false\"\n />\n</template>",
|
|
23127
|
+
"locale": "en-US"
|
|
23128
|
+
},
|
|
22880
23129
|
{
|
|
22881
23130
|
"id": "empty-and-loading-1",
|
|
22882
23131
|
"section": "Empty and loading",
|
|
@@ -22886,6 +23135,24 @@
|
|
|
22886
23135
|
"code": "<script setup lang=\"ts\">\nimport { MButton, MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst loading = ref(false)\nconst columns = [\n { key: 'name', label: 'Name', minWidth: 120 },\n { key: 'role', label: 'Role', minWidth: 120 },\n]\n</script>\n\n<template>\n <div class=\"grid gap-3\">\n <MButton :label=\"loading ? 'Stop loading' : 'Start loading'\" @click=\"loading = !loading\" />\n <MTable\n :columns=\"columns\"\n :rows=\"[]\"\n :loading=\"loading\"\n empty-text=\"No data yet\"\n empty-description=\"Records will appear here after you create the first one\"\n :paginator=\"false\"\n />\n </div>\n</template>",
|
|
22887
23136
|
"locale": "en-US"
|
|
22888
23137
|
},
|
|
23138
|
+
{
|
|
23139
|
+
"id": "tree-table-1",
|
|
23140
|
+
"section": "Tree table",
|
|
23141
|
+
"sectionId": "tree-table",
|
|
23142
|
+
"lang": "vue",
|
|
23143
|
+
"preview": true,
|
|
23144
|
+
"code": "<script setup lang=\"ts\">\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns: TableColumnDefinition[] = [\n { key: 'name', label: 'Name' },\n { key: 'size', label: 'Size' },\n]\n\nconst rows = ref<TableItem[]>([\n {\n id: 1,\n name: 'Applications',\n size: '100kb',\n children: [\n { id: 11, name: 'Vue', size: '25kb' },\n { id: 12, name: 'React', size: '30kb' },\n ],\n },\n {\n id: 2,\n name: 'Documents',\n size: '40kb',\n children: [{ id: 21, name: 'README.md', size: '4kb' }],\n },\n])\n\nconst expandedRowKeys = ref<Array<string | number>>([1])\nconst selection = ref<TableItem[]>([])\n</script>\n\n<template>\n <MTable\n v-model:expanded-row-keys=\"expandedRowKeys\"\n v-model:selection=\"selection\"\n selection-mode=\"multiple\"\n :columns=\"columns\"\n :rows=\"rows\"\n :tree-config=\"{ childrenField: 'children', indent: 16 }\"\n :checkbox-config=\"{ checkStrictly: false }\"\n bordered\n :paginator=\"false\"\n />\n</template>",
|
|
23145
|
+
"locale": "en-US"
|
|
23146
|
+
},
|
|
23147
|
+
{
|
|
23148
|
+
"id": "server-mode-1",
|
|
23149
|
+
"section": "Server mode",
|
|
23150
|
+
"sectionId": "server-mode",
|
|
23151
|
+
"lang": "vue",
|
|
23152
|
+
"preview": true,
|
|
23153
|
+
"code": "<script setup lang=\"ts\">\nimport { MTable } from 'morya-ui'\nimport { ref } from 'vue'\n\nconst columns = [\n { key: 'name', label: '项目', sortable: true, minWidth: 140 },\n { key: 'owner', label: '负责人', minWidth: 100 },\n]\nconst rows = ref([\n { id: 1, name: 'Landing', owner: 'Ada' },\n { id: 2, name: 'Dashboard', owner: 'Lin' },\n])\nconst serverOptions = ref({ page: 1, rowsPerPage: 10, sortBy: 'name', sortType: 'asc' as const })\nconst total = ref(42)\n</script>\n\n<template>\n <MTable\n v-model:server-options=\"serverOptions\"\n :columns=\"columns\"\n :rows=\"rows\"\n :server-total=\"total\"\n :loading=\"false\"\n />\n</template>",
|
|
23154
|
+
"locale": "en-US"
|
|
23155
|
+
},
|
|
22889
23156
|
{
|
|
22890
23157
|
"id": "types-1",
|
|
22891
23158
|
"section": "Types",
|
|
@@ -22901,7 +23168,7 @@
|
|
|
22901
23168
|
"sectionId": "types",
|
|
22902
23169
|
"lang": "ts",
|
|
22903
23170
|
"preview": false,
|
|
22904
|
-
"code": "interface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'
|
|
23171
|
+
"code": "interface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n render?: (row: TableItem) => unknown\n filterable?: boolean\n filters?: TableColumnFilter[]\n resizable?: boolean\n children?: TableColumnDefinition[]\n showOverflowTooltip?: boolean\n}",
|
|
22905
23172
|
"locale": "en-US"
|
|
22906
23173
|
},
|
|
22907
23174
|
{
|
|
@@ -22922,7 +23189,7 @@
|
|
|
22922
23189
|
{
|
|
22923
23190
|
"id": "overview",
|
|
22924
23191
|
"title": "",
|
|
22925
|
-
"body": "# Table\n\n`MTable` 用于展示结构化行数据。通过 `columns` 定义列、`rows`
|
|
23192
|
+
"body": "# Table\n\n`MTable` 用于展示结构化行数据。通过 `columns` 定义列、`rows` 传入数据;内置客户端排序、筛选、分页与行选择,也支持服务端分页模式。多选表头「全选」仅作用于当前页。\n\n列宽规则:\n\n- 设置了 `width` 的列为固定宽度\n- 未设 `width` 的列以 `minWidth`(默认 `80`)为弹性下限;`fit` 为 `true`(默认)时,剩余宽度按比例分配给弹性列\n- 总最小宽度超出容器时出现横向滚动\n- 需要表体自己滚动时用 `maxHeight` / `tableHeight`;与 `MLayout` 根滚动叠用时优先固定表高,避免双层滚动条\n- 全视口主列表可用 `MPageContent fill` + `MTable fill paginator`(表体滚动、分页贴底);嵌入表或短页不必使用 `fill`"
|
|
22926
23193
|
},
|
|
22927
23194
|
{
|
|
22928
23195
|
"id": "引入",
|
|
@@ -22937,65 +23204,90 @@
|
|
|
22937
23204
|
{
|
|
22938
23205
|
"id": "行选择",
|
|
22939
23206
|
"title": "行选择",
|
|
22940
|
-
"body": "多选配合 `selection-mode=\"multiple\"` 与 `v-model:selection`;单选使用 `selection-mode=\"single\"` 与 `v-model:selected-item
|
|
23207
|
+
"body": "多选配合 `selection-mode=\"multiple\"` 与 `v-model:selection`;单选使用 `selection-mode=\"single\"` 与 `v-model:selected-item`。表头全选仅选中当前页。\n\n```vue preview src=\"./demos/Selection.zh.vue\"\n```"
|
|
22941
23208
|
},
|
|
22942
23209
|
{
|
|
22943
23210
|
"id": "筛选与分页",
|
|
22944
23211
|
"title": "筛选与分页",
|
|
22945
|
-
"body": "客户端筛选可通过 `search-value` / `filter-options`;分页开启 `paginator` 并配合 `v-model:page` 与 `rows-per-page
|
|
23212
|
+
"body": "客户端筛选可通过 `search-value` / `filter-options`;分页开启 `paginator` 并配合 `v-model:page` 与 `rows-per-page`(受控同步)。\n\n```vue preview src=\"./demos/FilterAndPagination.zh.vue\"\n```"
|
|
22946
23213
|
},
|
|
22947
23214
|
{
|
|
22948
23215
|
"id": "固定列",
|
|
22949
23216
|
"title": "固定列",
|
|
22950
|
-
"body": "列定义中设置 `fixed: 'left'`
|
|
23217
|
+
"body": "列定义中设置 `fixed: 'left' | 'right'`(或 `fixed: true` 视为左固定)。\n\n```vue preview src=\"./demos/FixedColumns.zh.vue\"\n```"
|
|
22951
23218
|
},
|
|
22952
23219
|
{
|
|
22953
23220
|
"id": "展开行与列渲染",
|
|
22954
23221
|
"title": "展开行与列渲染",
|
|
22955
|
-
"body": "列可通过 `render`
|
|
23222
|
+
"body": "列可通过 `render` 或 `#cell-{key}` 自定义单元格。展开行设置 `expandable`(或 `expandConfig`),详情由 `#expansion` 提供。树模式下 `expandedRowKeys` 用于树节点展开,不可同时用于详情展开。\n\n```vue preview src=\"./demos/ExpandableRows.zh.vue\"\n```"
|
|
23223
|
+
},
|
|
23224
|
+
{
|
|
23225
|
+
"id": "列宽拖拽与表头筛选",
|
|
23226
|
+
"title": "列宽拖拽与表头筛选",
|
|
23227
|
+
"body": "列设置 `resizable` 可拖拽改宽(`v-model:column-widths`);`filterable` 显示表头筛选,可选 `filters` 为多选选项,否则为文本包含筛选。\n\n```vue preview src=\"./demos/ResizeAndFilter.zh.vue\"\n```"
|
|
23228
|
+
},
|
|
23229
|
+
{
|
|
23230
|
+
"id": "虚拟滚动",
|
|
23231
|
+
"title": "虚拟滚动",
|
|
23232
|
+
"body": "开启 `virtual`,并提供 `maxHeight` / `tableHeight` / `fill` 之一。展开行场景会自动降级为普通渲染。\n\n```vue preview src=\"./demos/VirtualScroll.zh.vue\"\n```"
|
|
23233
|
+
},
|
|
23234
|
+
{
|
|
23235
|
+
"id": "多级表头-表尾与合并",
|
|
23236
|
+
"title": "多级表头、表尾与合并",
|
|
23237
|
+
"body": "列支持 `children` 多级表头;`show-footer` + `footer-method` 渲染合计;`span-method` 合并单元格。\n\n```vue preview src=\"./demos/GridFeatures.zh.vue\"\n```"
|
|
22956
23238
|
},
|
|
22957
23239
|
{
|
|
22958
23240
|
"id": "空态与加载",
|
|
22959
23241
|
"title": "空态与加载",
|
|
22960
|
-
"body": "```vue preview src=\"./demos/
|
|
23242
|
+
"body": "```vue preview src=\"./demos/EmptyAndLoading.zh.vue\"\n```"
|
|
23243
|
+
},
|
|
23244
|
+
{
|
|
23245
|
+
"id": "树形表格",
|
|
23246
|
+
"title": "树形表格",
|
|
23247
|
+
"body": "传入 `tree-config` 启用树模式:嵌套 `children`,或 `transform` + `parentId` 扁平数据。展开状态用 `v-model:expanded-row-keys`。支持 `expandAll` / `expandRowKeys`、`accordion`、`trigger`、`toggleMethod`、懒加载 `lazy` + `loadMethod`。\n\n实例方法:`setTreeExpand`、`setAllTreeExpand`、`toggleTreeExpand`、`isTreeExpandByRow`、`getTreeExpandRecords`、`clearTreeExpand`。\n\n树 + 多选时默认父子级联与半选(`checkbox-config.check-strictly=false`);`checkMethod` 可禁用单行勾选。\n\n```vue preview src=\"./demos/Tree.zh.vue\"\n```"
|
|
22961
23248
|
},
|
|
22962
23249
|
{
|
|
22963
23250
|
"id": "服务端模式",
|
|
22964
23251
|
"title": "服务端模式",
|
|
22965
|
-
"body": "传入 `server-options` 与 `server-
|
|
23252
|
+
"body": "传入 `server-options` 与 `server-total`,通过 `v-model:server-options` 同步页码、每页条数与排序字段。\n\n```vue preview src=\"./demos/Demo7.vue\"\n```"
|
|
23253
|
+
},
|
|
23254
|
+
{
|
|
23255
|
+
"id": "breaking-changes",
|
|
23256
|
+
"title": "Breaking changes",
|
|
23257
|
+
"body": "- 移除内置单元格编辑:`editConfig`、列 `editable`、`edit-change`、`#edit-{key}`;请用 `#cell-{key}` / `render` 自定义\n- 移除 `MTreeTable`(含 `morya-ui/tree-table`);树表改用 `MTable` + `treeConfig`\n- `serverItemsLength` → `serverTotal`;`rowsItems` → `pageSizes`\n- `hideHeader` 移除;改用 `showHeader`(默认 `true`)\n- `hideRowsPerPage` 移除;改用 `showRowsPerPage`(默认 `true`)\n- 移除:`clickEventType`、`rowsPerPageMessage`、`rowsOfPageSeparatorMessage`、`preventContextMenuRow`、`tableNodeId`\n- 事件:`contextmenuRow` → `row-contextmenu`;`selectRow` / `deselectRow` / `selectAll` → `select-row` / `deselect-row` / `select-all`\n- 移除事件:`updatePageItems`、`updateTotalItems`、`page`(保留 `update:page`)\n- 行交互:始终同时支持单击 / 双击(`row-click` / `row-dblclick`);右键始终 `preventDefault` 并抛出 `row-contextmenu`"
|
|
22966
23258
|
},
|
|
22967
23259
|
{
|
|
22968
23260
|
"id": "tablecolumndefinition",
|
|
22969
23261
|
"title": "TableColumnDefinition",
|
|
22970
|
-
"body": "| 字段 | 类型 | 说明 |\n| --- | --- | --- |\n| `key` | `string` | 列字段名(绑定行数据的键)。 |\n| `label` | `string` | 列头文案。 |\n| `width` | `number` | 固定列宽(px)。 |\n| `minWidth` | `number` | 弹性列最小宽度,默认 `80`。 |\n| `sortable` | `boolean` | 是否可排序。 |\n| `fixed` | `boolean \\| 'left' \\| 'right'` |
|
|
23262
|
+
"body": "| 字段 | 类型 | 说明 |\n| --- | --- | --- |\n| `key` | `string` | 列字段名(绑定行数据的键)。 |\n| `label` | `string` | 列头文案。 |\n| `width` | `number` | 固定列宽(px)。 |\n| `minWidth` | `number` | 弹性列最小宽度,默认 `80`。 |\n| `sortable` | `boolean` | 是否可排序。 |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | 固定列;`true` 等同 `'left'`。 |\n| `align` | `'start' \\| 'center' \\| 'end'` | 单元格对齐。 |\n| `render` | `(row) => unknown` | 自定义单元格渲染。 |\n| `showOverflowTooltip` | `boolean` | 该列文本溢出时显示 Tooltip。 |\n| `resizable` | `boolean` | 可拖拽调整列宽。 |\n| `filterable` | `boolean` | 显示表头筛选。 |\n| `filters` | `TableColumnFilter[]` | 表头筛选选项;省略则为文本筛选。 |\n| `children` | `TableColumnDefinition[]` | 多级表头子列。 |"
|
|
22971
23263
|
},
|
|
22972
23264
|
{
|
|
22973
23265
|
"id": "props",
|
|
22974
23266
|
"title": "Props",
|
|
22975
|
-
"body": "| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | 列定义。 |\n| `rows` | `TableItem[]` | — | 行数据。 |\n| `fit` | `boolean` | `true` | 弹性列是否撑满表格宽度。 |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | 行选择模式。 |\n| `selection` | `TableItem[] \\| null` | `null` | 多选绑定(`v-model:selection`)。 |\n| `selectedItem` | `TableItem \\| null` | `null` | 单选绑定(`v-model:selected-item`)。 |\n| `serverOptions` | `TableServerOptions \\| null` | `null` | 服务端分页/排序选项。 |\n| `
|
|
23267
|
+
"body": "| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | 列定义。 |\n| `rows` | `TableItem[]` | — | 行数据。 |\n| `fit` | `boolean` | `true` | 弹性列是否撑满表格宽度。 |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | 行选择模式。 |\n| `selection` | `TableItem[] \\| null` | `null` | 多选绑定(`v-model:selection`)。 |\n| `selectedItem` | `TableItem \\| null` | `null` | 单选绑定(`v-model:selected-item`)。 |\n| `serverOptions` | `TableServerOptions \\| null` | `null` | 服务端分页/排序选项。 |\n| `serverTotal` | `number` | `0` | 服务端总条数。 |\n| `paginator` | `boolean` | `false` | 显示内置分页页脚。 |\n| `page` | `number` | `1` | 当前页(`v-model:page`)。 |\n| `rowsPerPage` | `number` | `25` | 每页条数。 |\n| `pageSizes` | `number[]` | `[25, 50, 100]` | 分页每页条数选项。 |\n| `showHeader` | `boolean` | `true` | 是否显示表头。 |\n| `showRowsPerPage` | `boolean` | `true` | 是否显示每页条数选择器。 |\n| `fill` | `boolean` | `false` | 撑满父级剩余高度(仅全视口主列表配 `MPageContent fill`);表体滚动,分页贴底。设置 `maxHeight` / `tableHeight` 时忽略。 |\n| `columnWidths` | `Record<string, number> \\| null` | `null` | 列宽(`v-model:column-widths`)。 |\n| `virtual` | `boolean` | `false` | 行虚拟滚动(需高度;展开行时跳过)。 |\n| `virtualRowHeight` | `number` | `40` | 虚拟行高估算。 |\n| `hiddenColumns` | `string[] \\| null` | `null` | 隐藏列键(`v-model:hidden-columns`)。 |\n| `columnOrder` | `string[] \\| null` | `null` | 叶列顺序(`v-model:column-order`)。 |\n| `showFooter` | `boolean` | `false` | 显示表尾。 |\n| `footerMethod` | `TableFooterMethod \\| null` | `null` | 表尾数据。 |\n| `spanMethod` | `TableSpanMethod \\| null` | `null` | 单元格合并。 |\n| `treeConfig` | `TableTreeConfig \\| null` | `null` | 树形行。 |\n| `expandConfig` | `TableExpandConfig \\| null` | `null` | 详情展开配置(与树互斥)。 |\n| `checkboxConfig` | `TableCheckboxConfig \\| null` | `null` | 多选:级联 / `checkMethod` / `checkRowKeys` / `trigger` / `reserve`。 |\n| `radioConfig` | `TableRadioConfig \\| null` | `null` | 单选:`strict` / `checkMethod` / `trigger`。 |\n| `expandable` | `boolean` | `false` | 显示展开列(也可由 `#expansion` 或 `expandConfig` 启用)。 |\n| `striped` | `boolean` | `false` | 斑马纹行。 |\n| `bordered` | `boolean` | `false` | 单元格边框。 |\n| `highlightCurrent` | `boolean` | `false` | 高亮当前行,配合 `v-model:current-row-key`。 |\n| `rowHover` | `boolean` | `true` | 行 hover 高亮。 |\n| `sortField` / `sortOrder` | — | — | 受控排序字段与方向。 |\n| `sortMode` | `'client' \\| 'emit'` | `'client'` | 客户端排序或仅抛出排序事件。 |\n| `searchField` / `searchValue` | — | — | 客户端搜索。 |\n| `filterOptions` | `TableFilterOption[]` | `null` | 结构化筛选条件。 |\n| `loading` | `boolean` | `false` | 加载中。 |\n| `emptyText` | `string` | — | 空数据文案。 |\n| `emptyDescription` | `string` | — | 空数据补充说明。 |\n| `maxHeight` | `number \\| null` | `null` | 表格最大高度,超出滚动。 |\n| `showOverflowTooltip` | `boolean` | `false` | 全局单元格溢出 Tooltip。 |\n| `rowKey` | `string` | `'id'` | 行唯一键字段。 |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | 表格密度。 |\n| `ariaLabel` | `string` | — | — |\n| `bodyExpandRowClassName` | `TableBodyRowClassName` | — | — |\n| `bodyItemClassName` | `TableBodyItemClassName` | — | — |\n| `bodyRowClassName` | `TableBodyRowClassName` | — | — |\n| `bodyTextDirection` | `TableTextDirection` | — | — |\n| `checkboxColumnWidth` | `number \\| null` | — | — |\n| `clickRowToExpand` | `boolean` | — | — |\n| `currentRowKey` | `string \\| number \\| null` | — | — |\n| `expandColumnWidth` | `number` | — | — |\n| `expandedRowKeys` | `Array<string \\| number>` | — | — |\n| `filters` | `Record<string, unknown> \\| null` | — | — |\n| `fixedCheckbox` | `boolean` | — | — |\n| `fixedExpand` | `boolean` | — | — |\n| `fixedHeader` | `boolean` | — | — |\n| `fixedIndex` | `boolean` | — | — |\n| `headerClassName` | `string` | — | — |\n| `headerItemClassName` | `TableHeaderItemClassName` | — | — |\n| `headerTextDirection` | `TableTextDirection` | — | — |\n| `indexColumnWidth` | `number` | — | — |\n| `multiSort` | `boolean` | — | — |\n| `mustSort` | `boolean` | — | — |\n| `showIndex` | `boolean` | — | — |\n| `showIndexSymbol` | `string` | — | — |\n| `tableClassName` | `string` | — | — |\n| `tableHeight` | `number \\| null` | — | — |\n| `tableMinHeight` | `number` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |"
|
|
22976
23268
|
},
|
|
22977
23269
|
{
|
|
22978
23270
|
"id": "slots",
|
|
22979
23271
|
"title": "Slots",
|
|
22980
|
-
"body": "| 插槽 | 说明 |\n| --- | --- |\n| `cell-{key}` | 列 `{key}` 单元格,作用域 `{ row, value, column }
|
|
23272
|
+
"body": "| 插槽 | 说明 |\n| --- | --- |\n| `cell-{key}` | 列 `{key}` 单元格,作用域 `{ row, value, column }`(可自行实现编辑器)。 |\n| `footer` | 自定义表尾。 |\n| `body-cell` | 任意单元格,作用域 `{ row, column, value }`。 |\n| `expansion` | 展开行内容,作用域 `{ row }`。 |\n| `empty` | 自定义空态。 |\n| `loading` | 自定义加载态。 |\n| `pagination` | 自定义分页区域。 |\n| `body` | 自定义 `body` 内容。 |\n| `body-append` | 自定义 `body-append` 内容。 |\n| `body-prepend` | 自定义 `body-prepend` 内容。 |\n| `customize-headers` | 自定义 `customize-headers` 内容。 |\n| `header` | 自定义 `header` 内容。 |\n| `header-{key}` | 列头插槽(键名大小写与 `columns[].key` 一致)。 |"
|
|
22981
23273
|
},
|
|
22982
23274
|
{
|
|
22983
23275
|
"id": "events",
|
|
22984
23276
|
"title": "Events",
|
|
22985
|
-
"body": "| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | 排序变化。 |\n| `
|
|
23277
|
+
"body": "| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | 排序变化。 |\n| `row-click` | `{ row, index }`, `Event` | 行单击。 |\n| `row-dblclick` | `{ row, index }`, `Event` | 行双击。 |\n| `row-contextmenu` | `item`, `MouseEvent` | 行右键。 |\n| `select-row` | `TableItem` | 选中一行。 |\n| `deselect-row` | `TableItem` | 取消选中一行。 |\n| `select-all` | — | 全选当前页。 |\n| `current-change` | `row \\| null, oldRow \\| null` | 当前高亮行变化。 |\n| `expand` | `{ row, expanded }` | 行展开。 |\n| `update:selection` | `TableItem[]` | 多选 v-model。 |\n| `update:page` | `number` | 页码 v-model。 |\n| `update:server-options` | `TableServerOptions` | 服务端选项 v-model。 |\n| `update:current-row-key` | `string \\| number \\| null` | 当前行键 v-model。 |\n| `filter` | — | — |\n| `update:expandedRowKeys` | — | — |\n| `update:filters` | — | — |\n| `update:columnWidths` | `Record<string, number>` | 列宽 v-model。 |\n| `update:hiddenColumns` | `string[]` | 隐藏列 v-model。 |\n| `update:columnOrder` | `string[]` | 列顺序 v-model。 |\n| `update:selectedItem` | — | — |"
|
|
22986
23278
|
},
|
|
22987
23279
|
{
|
|
22988
23280
|
"id": "实例方法",
|
|
22989
23281
|
"title": "实例方法",
|
|
22990
|
-
"body": "通过 `ref`
|
|
23282
|
+
"body": "通过 `ref` 可访问分页、筛选、选择、滚动与展开控制:\n\n| 方法 / 属性 | 说明 |\n| --- | --- |\n| `currentPageFirstIndex` | 当前页首条记录的索引(无数据时为 `-1`)。 |\n| `currentPageLastIndex` | 当前页末条记录的索引。 |\n| `clientItemsLength` | 数据总条数(服务端模式下为服务端总数)。 |\n| `maxPaginationNumber` | 最大页码。 |\n| `currentPaginationNumber` | 当前页码。 |\n| `isLastPage` / `isFirstPage` | 是否末页 / 首页。 |\n| `nextPage()` / `prevPage()` | 下一页 / 上一页。 |\n| `updatePage(page)` | 跳到指定页码。 |\n| `rowsPerPageOptions` | 每页条数选项。 |\n| `rowsPerPageActiveOption` | 当前生效的每页条数。 |\n| `updateRowsPerPageActiveOption(n)` | 修改每页条数。 |\n| `setFilters(filters)` / `clearFilter()` | 设置 / 清空筛选。 |\n| `setColumnWidths(widths)` | 设置列宽(等同 `v-model:column-widths`)。 |\n| `setHiddenColumns(keys)` | 设置隐藏列键(等同 `v-model:hidden-columns`)。 |\n| `setColumnOrder(keys)` | 设置叶列顺序(等同 `v-model:column-order`)。 |\n| `clearSort()` | 清空排序。 |\n| `getCheckboxRecords()` | 当前多选行。 |\n| `setCheckboxRow(rows, checked)` | 设置行选中状态。 |\n| `clearCheckboxRow()` | 清空多选。 |\n| `isCheckedByCheckboxRow(row)` | 行是否选中。 |\n| `isAllCheckboxChecked()` | 当前页是否全选。 |\n| `getCheckboxIndeterminateRecords()` | 半选行(树级联)。 |\n| `scrollTo(...)` / `scrollToRow(row)` | 滚动定位。 |\n| `setRowExpand` / `setAllRowExpand` / `toggleRowExpand` / `clearRowExpand` / `isRowExpandByRow` / `getRowExpandRecords` | 详情展开(非树模式)。 |\n| `setTreeExpand` / `setAllTreeExpand` / `toggleTreeExpand` / `clearTreeExpand` / `isTreeExpandByRow` / `getTreeExpandRecords` | 树节点展开。 |"
|
|
22991
23283
|
},
|
|
22992
23284
|
{
|
|
22993
23285
|
"id": "类型",
|
|
22994
23286
|
"title": "类型",
|
|
22995
|
-
"body": "<h4 id=\"TableItem\">TableItem</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n<h4 id=\"TableTextDirection\">TableTextDirection</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableTextDirection = 'left' | 'center' | 'right'\n```\n\n<h4 id=\"
|
|
23287
|
+
"body": "<h4 id=\"TableItem\">TableItem</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n<h4 id=\"TableTextDirection\">TableTextDirection</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableTextDirection = 'left' | 'center' | 'right'\n```\n\n<h4 id=\"TableFilterOption\">TableFilterOption</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableFilterOption = | { field: string; comparison: 'between'; criteria: [number, number] }\n | { field: string; comparison: '=' | '!='; criteria: number | string }\n | { field: string; comparison: '>' | '>=' | '<' | '<='; criteria: number }\n | { field: number | string; comparison: 'in'; criteria: number[] | string[] }\n | { field: string; comparison: (value: unknown, criteria: string) => boolean; criteria: string }\n```\n\n<h4 id=\"TableHeaderItemClassName\">TableHeaderItemClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableHeaderItemClassName = string | ((header: TableHeader, columnNumber: number) => string)\n```\n\n<h4 id=\"TableBodyRowClassName\">TableBodyRowClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableBodyRowClassName = string | ((item: TableItem, rowNumber: number) => string)\n```\n\n<h4 id=\"TableBodyItemClassName\">TableBodyItemClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableBodyItemClassName = string | ((column: string, rowNumber: number) => string)\n```\n\n\n\n<h4 id=\"TableTreeConfig\">TableTreeConfig</h4>\n\n```ts\ninterface TableTreeConfig {\n childrenField?: string // default 'children'\n indent?: number // default 16\n expandAll?: boolean\n accordion?: boolean\n trigger?: 'default' | 'row'\n lazy?: boolean\n hasChildField?: string // default 'hasChild'\n loadMethod?: (row: TableItem) => Promise<TableItem[]> | TableItem[]\n transform?: boolean // flat parentId → tree\n rowField?: string\n parentField?: string // default 'parentId'\n treeNode?: string // column key for toggler; default first column\n showLine?: boolean\n}\n```\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\n列定义,传给 `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n render?: (row: TableItem) => unknown\n showOverflowTooltip?: boolean\n}\n```\n\n<h4 id=\"TableServerOptions\">TableServerOptions</h4>\n\n服务端分页/排序时传给 `serverOptions`,配合 `serverTotal`:\n\n```ts\ninterface TableServerOptions {\n page: number\n rowsPerPage: number\n sortBy?: string | string[]\n sortType?: 'asc' | 'desc' | ('asc' | 'desc')[]\n}\n```\n\n更多见 [API 类型](/docs/types)。"
|
|
22996
23288
|
}
|
|
22997
23289
|
],
|
|
22998
|
-
"markdown": "---\ntitle: Table\ncategory: 03 / DATA\ndescription: 数据表格。支持排序、筛选、选择、分页、固定列与空/加载态。列宽支持 width / minWidth / fit。\n---\n\n# Table\n\n`MTable` 用于展示结构化行数据。通过 `columns` 定义列、`rows` 传入数据;内置客户端排序、筛选、分页与行选择,也支持服务端分页模式。\n\n列宽规则:\n\n- 设置了 `width` 的列为固定宽度\n- 未设 `width` 的列以 `minWidth`(默认 `80`)为弹性下限;`fit` 为 `true`(默认)时,剩余宽度按比例分配给弹性列\n- 总最小宽度超出容器时出现横向滚动\n- 需要表体自己滚动时用 `maxHeight` / `tableHeight`;与 `MLayout` 根滚动叠用时优先固定表高,避免双层滚动条\n- **全视口主列表(按需)**:`MPageContent fill` + `MTable fill paginator`——表体滚动、分页贴底;嵌入表/短页不要硬套 `fill`\n\n## 引入\n\n```ts\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable, MTag } from 'morya-ui'\n```\n\n## 基础用法\n\n```vue preview src=\"./demos/Basic.zh.vue\"\n```\n\n## 行选择\n\n多选配合 `selection-mode=\"multiple\"` 与 `v-model:selection`;单选使用 `selection-mode=\"single\"` 与 `v-model:selected-item`。\n\n```vue preview src=\"./demos/Selection.zh.vue\"\n```\n\n## 筛选与分页\n\n客户端筛选可通过 `search-value` / `filter-options`;分页开启 `paginator` 并配合 `v-model:page` 与 `rows-per-page`。\n\n```vue preview src=\"./demos/FilterAndPagination.zh.vue\"\n```\n\n## 固定列\n\n列定义中设置 `fixed: 'left'` 可冻结左侧列(当前批次支持左固定)。\n\n```vue preview src=\"./demos/ExpandableRows.zh.vue\"\n```\n\n## 展开行与列渲染\n\n列可通过 `render` 函数渲染;展开行设置 `expandable`,详情内容由插槽 `expansion` 提供。`cell-{key}` 插槽优先于 `render`。\n\n```vue preview src=\"./demos/EmptyAndLoading.zh.vue\"\n```\n\n## 空态与加载\n\n```vue preview src=\"./demos/Demo6.vue\"\n```\n\n## 服务端模式\n\n传入 `server-options` 与 `server-items-length`,通过 `v-model:server-options` 同步页码、每页条数与排序字段。\n\n```vue preview src=\"./demos/Demo7.vue\"\n```\n\n## TableColumnDefinition\n\n| 字段 | 类型 | 说明 |\n| --- | --- | --- |\n| `key` | `string` | 列字段名(绑定行数据的键)。 |\n| `label` | `string` | 列头文案。 |\n| `width` | `number` | 固定列宽(px)。 |\n| `minWidth` | `number` | 弹性列最小宽度,默认 `80`。 |\n| `sortable` | `boolean` | 是否可排序。 |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | 固定列;当前实现左固定。 |\n| `align` | `'start' \\| 'center' \\| 'end'` | 单元格对齐。 |\n| `render` | `(row) => unknown` | 自定义单元格渲染。 |\n| `showOverflowTooltip` | `boolean` | 该列文本溢出时显示 Tooltip。 |\n\n## Props\n\n| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | 列定义。 |\n| `rows` | `TableItem[]` | — | 行数据。 |\n| `fit` | `boolean` | `true` | 弹性列是否撑满表格宽度。 |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | 行选择模式。 |\n| `selection` | `TableItem[] \\| null` | `null` | 多选绑定(`v-model:selection`)。 |\n| `selectedItem` | `TableItem \\| null` | `null` | 单选绑定(`v-model:selected-item`)。 |\n| `serverOptions` | `TableServerOptions \\| null` | `null` | 服务端分页/排序选项。 |\n| `serverItemsLength` | `number` | `0` | 服务端总条数。 |\n| `paginator` | `boolean` | `false` | 显示内置分页页脚。 |\n| `page` | `number` | `1` | 当前页(`v-model:page`)。 |\n| `rowsPerPage` | `number` | `25` | 每页条数。 |\n| `fill` | `boolean` | `false` | 撑满父级剩余高度(仅全视口主列表配 `MPageContent fill`);表体滚动,分页贴底。设置 `maxHeight` / `tableHeight` 时忽略。 |\n| `expandable` | `boolean` | `false` | 显示展开列(也可由 `#expansion` 插槽隐式启用)。 |\n| `striped` | `boolean` | `false` | 斑马纹行。 |\n| `bordered` | `boolean` | `false` | 单元格边框。 |\n| `highlightCurrent` | `boolean` | `false` | 高亮当前行,配合 `v-model:current-row-key`。 |\n| `rowHover` | `boolean` | `true` | 行 hover 高亮。 |\n| `sortField` / `sortOrder` | — | — | 受控排序字段与方向。 |\n| `sortMode` | `'client' \\| 'emit'` | `'client'` | 客户端排序或仅抛出排序事件。 |\n| `searchField` / `searchValue` | — | — | 客户端搜索。 |\n| `filterOptions` | `TableFilterOption[]` | `null` | 结构化筛选条件。 |\n| `loading` | `boolean` | `false` | 加载中。 |\n| `emptyText` | `string` | — | 空数据文案。 |\n| `emptyDescription` | `string` | — | 空数据补充说明。 |\n| `maxHeight` | `number \\| null` | `null` | 表格最大高度,超出滚动。 |\n| `showOverflowTooltip` | `boolean` | `false` | 全局单元格溢出 Tooltip。 |\n| `rowKey` | `string` | `'id'` | 行唯一键字段。 |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | 表格密度。 |\n| `ariaLabel` | `string` | — | — |\n| `bodyExpandRowClassName` | `TableBodyRowClassName` | — | — |\n| `bodyItemClassName` | `TableBodyItemClassName` | — | — |\n| `bodyRowClassName` | `TableBodyRowClassName` | — | — |\n| `bodyTextDirection` | `TableTextDirection` | — | — |\n| `checkboxColumnWidth` | `number \\| null` | — | — |\n| `clickEventType` | `TableClickEventType` | — | — |\n| `clickRowToExpand` | `boolean` | — | — |\n| `currentRowKey` | `string \\| number \\| null` | — | — |\n| `expandColumnWidth` | `number` | — | — |\n| `expandedRowKeys` | `Array<string \\| number>` | — | — |\n| `filters` | `Record<string, unknown> \\| null` | — | — |\n| `fixedCheckbox` | `boolean` | — | — |\n| `fixedExpand` | `boolean` | — | — |\n| `fixedHeader` | `boolean` | — | — |\n| `fixedIndex` | `boolean` | — | — |\n| `headerClassName` | `string` | — | — |\n| `headerItemClassName` | `TableHeaderItemClassName` | — | — |\n| `headerTextDirection` | `TableTextDirection` | — | — |\n| `hideHeader` | `boolean` | — | — |\n| `hideRowsPerPage` | `boolean` | — | — |\n| `indexColumnWidth` | `number` | — | — |\n| `multiSort` | `boolean` | — | — |\n| `mustSort` | `boolean` | — | — |\n| `preventContextMenuRow` | `boolean` | — | — |\n| `rowsItems` | `number[]` | — | — |\n| `rowsOfPageSeparatorMessage` | `string` | — | — |\n| `rowsPerPageMessage` | `string` | — | — |\n| `showHeader` | `boolean` | — | — |\n| `showIndex` | `boolean` | — | — |\n| `showIndexSymbol` | `string` | — | — |\n| `tableClassName` | `string` | — | — |\n| `tableHeight` | `number \\| null` | — | — |\n| `tableMinHeight` | `number` | — | — |\n| `tableNodeId` | `string` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |\n\n\n## Slots\n\n| 插槽 | 说明 |\n| --- | --- |\n| `cell-{key}` | 列 `{key}` 单元格,作用域 `{ row, value, column }`。 |\n| `body-cell` | 任意单元格,作用域 `{ row, column, value }`。 |\n| `expansion` | 展开行内容,作用域 `{ row }`。 |\n| `empty` | 自定义空态。 |\n| `loading` | 自定义加载态。 |\n| `pagination` | 自定义分页区域。 |\n| `body` | 自定义 `body` 内容。 |\n| `body-append` | 自定义 `body-append` 内容。 |\n| `body-prepend` | 自定义 `body-prepend` 内容。 |\n| `customize-headers` | 自定义 `customize-headers` 内容。 |\n| `header` | 自定义 `header` 内容。 |\n| `header-*` | 动态插槽(前缀 `header-`)。 |\n\n## Events\n\n| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | 排序变化。 |\n| `page` | `number` | 页码变化。 |\n| `row-click` | `{ row, index }` | 行单击。 |\n| `current-change` | `row \\| null, oldRow \\| null` | 当前高亮行变化。 |\n| `expand` | `{ row, expanded }` | 行展开。 |\n| `update:selection` | `TableItem[]` | 多选 v-model。 |\n| `update:page` | `number` | 页码 v-model。 |\n| `update:server-options` | `TableServerOptions` | 服务端选项 v-model。 |\n| `update:current-row-key` | `string \\| number \\| null` | 当前行键 v-model。 |\n| `contextmenuRow` | — | — |\n| `deselectRow` | — | — |\n| `filter` | — | — |\n| `selectAll` | — | — |\n| `selectRow` | — | — |\n| `update:expandedRowKeys` | — | — |\n| `update:filters` | — | — |\n| `update:selectedItem` | — | — |\n| `updatePageItems` | — | — |\n| `updateTotalItems` | — | — |\n\n## 实例方法\n\n通过 `ref` 可访问以下分页与筛选控制:\n\n| 方法 / 属性 | 说明 |\n| --- | --- |\n| `currentPageFirstIndex` | 当前页首条记录的索引(无数据时为 `-1`)。 |\n| `currentPageLastIndex` | 当前页末条记录的索引。 |\n| `clientItemsLength` | 数据总条数(服务端模式下为服务端总数)。 |\n| `maxPaginationNumber` | 最大页码。 |\n| `currentPaginationNumber` | 当前页码。 |\n| `isLastPage` / `isFirstPage` | 是否末页 / 首页。 |\n| `nextPage()` / `prevPage()` | 下一页 / 上一页。 |\n| `updatePage(page)` | 跳到指定页码。 |\n| `rowsPerPageOptions` | 每页条数选项。 |\n| `rowsPerPageActiveOption` | 当前生效的每页条数。 |\n| `updateRowsPerPageActiveOption(n)` | 修改每页条数。 |\n| `setFilters(filters)` | 程序化设置筛选条件。 |\n\n## 类型\n\n<h4 id=\"TableItem\">TableItem</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n<h4 id=\"TableTextDirection\">TableTextDirection</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableTextDirection = 'left' | 'center' | 'right'\n```\n\n<h4 id=\"TableClickEventType\">TableClickEventType</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableClickEventType = 'single' | 'double'\n```\n\n<h4 id=\"TableFilterOption\">TableFilterOption</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableFilterOption = | { field: string; comparison: 'between'; criteria: [number, number] }\n | { field: string; comparison: '=' | '!='; criteria: number | string }\n | { field: string; comparison: '>' | '>=' | '<' | '<='; criteria: number }\n | { field: number | string; comparison: 'in'; criteria: number[] | string[] }\n | { field: string; comparison: (value: unknown, criteria: string) => boolean; criteria: string }\n```\n\n<h4 id=\"TableHeaderItemClassName\">TableHeaderItemClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableHeaderItemClassName = string | ((header: TableHeader, columnNumber: number) => string)\n```\n\n<h4 id=\"TableBodyRowClassName\">TableBodyRowClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableBodyRowClassName = string | ((item: TableItem, rowNumber: number) => string)\n```\n\n<h4 id=\"TableBodyItemClassName\">TableBodyItemClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableBodyItemClassName = string | ((column: string, rowNumber: number) => string)\n```\n\n\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\n列定义,传给 `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end' | 'left' | 'right'\n render?: (row: TableItem) => unknown\n filterable?: boolean\n filters?: { label: string; value: string | number }[]\n showOverflowTooltip?: boolean\n}\n```\n\n<h4 id=\"TableServerOptions\">TableServerOptions</h4>\n\n服务端分页/排序时传给 `serverOptions`,配合 `serverItemsLength`:\n\n```ts\ninterface TableServerOptions {\n page: number\n rowsPerPage: number\n sortBy?: string | string[]\n sortType?: 'asc' | 'desc' | ('asc' | 'desc')[]\n}\n```\n\n更多见 [API 类型](/docs/types)。\n"
|
|
23290
|
+
"markdown": "---\ntitle: Table\ncategory: 03 / DATA\ndescription: 数据表格。支持排序、筛选、选择、分页、固定列与空/加载态。列宽支持 width / minWidth / fit。\n---\n\n# Table\n\n`MTable` 用于展示结构化行数据。通过 `columns` 定义列、`rows` 传入数据;内置客户端排序、筛选、分页与行选择,也支持服务端分页模式。多选表头「全选」仅作用于当前页。\n\n列宽规则:\n\n- 设置了 `width` 的列为固定宽度\n- 未设 `width` 的列以 `minWidth`(默认 `80`)为弹性下限;`fit` 为 `true`(默认)时,剩余宽度按比例分配给弹性列\n- 总最小宽度超出容器时出现横向滚动\n- 需要表体自己滚动时用 `maxHeight` / `tableHeight`;与 `MLayout` 根滚动叠用时优先固定表高,避免双层滚动条\n- 全视口主列表可用 `MPageContent fill` + `MTable fill paginator`(表体滚动、分页贴底);嵌入表或短页不必使用 `fill`\n\n## 引入\n\n```ts\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable, MTag } from 'morya-ui'\n```\n\n## 基础用法\n\n```vue preview src=\"./demos/Basic.zh.vue\"\n```\n\n## 行选择\n\n多选配合 `selection-mode=\"multiple\"` 与 `v-model:selection`;单选使用 `selection-mode=\"single\"` 与 `v-model:selected-item`。表头全选仅选中当前页。\n\n```vue preview src=\"./demos/Selection.zh.vue\"\n```\n\n## 筛选与分页\n\n客户端筛选可通过 `search-value` / `filter-options`;分页开启 `paginator` 并配合 `v-model:page` 与 `rows-per-page`(受控同步)。\n\n```vue preview src=\"./demos/FilterAndPagination.zh.vue\"\n```\n\n## 固定列\n\n列定义中设置 `fixed: 'left' | 'right'`(或 `fixed: true` 视为左固定)。\n\n```vue preview src=\"./demos/FixedColumns.zh.vue\"\n```\n\n## 展开行与列渲染\n\n列可通过 `render` 或 `#cell-{key}` 自定义单元格。展开行设置 `expandable`(或 `expandConfig`),详情由 `#expansion` 提供。树模式下 `expandedRowKeys` 用于树节点展开,不可同时用于详情展开。\n\n```vue preview src=\"./demos/ExpandableRows.zh.vue\"\n```\n\n## 列宽拖拽与表头筛选\n\n列设置 `resizable` 可拖拽改宽(`v-model:column-widths`);`filterable` 显示表头筛选,可选 `filters` 为多选选项,否则为文本包含筛选。\n\n```vue preview src=\"./demos/ResizeAndFilter.zh.vue\"\n```\n\n## 虚拟滚动\n\n开启 `virtual`,并提供 `maxHeight` / `tableHeight` / `fill` 之一。展开行场景会自动降级为普通渲染。\n\n```vue preview src=\"./demos/VirtualScroll.zh.vue\"\n```\n\n## 多级表头、表尾与合并\n\n列支持 `children` 多级表头;`show-footer` + `footer-method` 渲染合计;`span-method` 合并单元格。\n\n```vue preview src=\"./demos/GridFeatures.zh.vue\"\n```\n\n## 空态与加载\n\n```vue preview src=\"./demos/EmptyAndLoading.zh.vue\"\n```\n\n## 树形表格\n\n传入 `tree-config` 启用树模式:嵌套 `children`,或 `transform` + `parentId` 扁平数据。展开状态用 `v-model:expanded-row-keys`。支持 `expandAll` / `expandRowKeys`、`accordion`、`trigger`、`toggleMethod`、懒加载 `lazy` + `loadMethod`。\n\n实例方法:`setTreeExpand`、`setAllTreeExpand`、`toggleTreeExpand`、`isTreeExpandByRow`、`getTreeExpandRecords`、`clearTreeExpand`。\n\n树 + 多选时默认父子级联与半选(`checkbox-config.check-strictly=false`);`checkMethod` 可禁用单行勾选。\n\n```vue preview src=\"./demos/Tree.zh.vue\"\n```\n\n## 服务端模式\n\n传入 `server-options` 与 `server-total`,通过 `v-model:server-options` 同步页码、每页条数与排序字段。\n\n```vue preview src=\"./demos/Demo7.vue\"\n```\n\n## Breaking changes\n\n- 移除内置单元格编辑:`editConfig`、列 `editable`、`edit-change`、`#edit-{key}`;请用 `#cell-{key}` / `render` 自定义\n- 移除 `MTreeTable`(含 `morya-ui/tree-table`);树表改用 `MTable` + `treeConfig`\n- `serverItemsLength` → `serverTotal`;`rowsItems` → `pageSizes`\n- `hideHeader` 移除;改用 `showHeader`(默认 `true`)\n- `hideRowsPerPage` 移除;改用 `showRowsPerPage`(默认 `true`)\n- 移除:`clickEventType`、`rowsPerPageMessage`、`rowsOfPageSeparatorMessage`、`preventContextMenuRow`、`tableNodeId`\n- 事件:`contextmenuRow` → `row-contextmenu`;`selectRow` / `deselectRow` / `selectAll` → `select-row` / `deselect-row` / `select-all`\n- 移除事件:`updatePageItems`、`updateTotalItems`、`page`(保留 `update:page`)\n- 行交互:始终同时支持单击 / 双击(`row-click` / `row-dblclick`);右键始终 `preventDefault` 并抛出 `row-contextmenu`\n\n## TableColumnDefinition\n\n| 字段 | 类型 | 说明 |\n| --- | --- | --- |\n| `key` | `string` | 列字段名(绑定行数据的键)。 |\n| `label` | `string` | 列头文案。 |\n| `width` | `number` | 固定列宽(px)。 |\n| `minWidth` | `number` | 弹性列最小宽度,默认 `80`。 |\n| `sortable` | `boolean` | 是否可排序。 |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | 固定列;`true` 等同 `'left'`。 |\n| `align` | `'start' \\| 'center' \\| 'end'` | 单元格对齐。 |\n| `render` | `(row) => unknown` | 自定义单元格渲染。 |\n| `showOverflowTooltip` | `boolean` | 该列文本溢出时显示 Tooltip。 |\n| `resizable` | `boolean` | 可拖拽调整列宽。 |\n| `filterable` | `boolean` | 显示表头筛选。 |\n| `filters` | `TableColumnFilter[]` | 表头筛选选项;省略则为文本筛选。 |\n| `children` | `TableColumnDefinition[]` | 多级表头子列。 |\n\n## Props\n\n| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | 列定义。 |\n| `rows` | `TableItem[]` | — | 行数据。 |\n| `fit` | `boolean` | `true` | 弹性列是否撑满表格宽度。 |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | 行选择模式。 |\n| `selection` | `TableItem[] \\| null` | `null` | 多选绑定(`v-model:selection`)。 |\n| `selectedItem` | `TableItem \\| null` | `null` | 单选绑定(`v-model:selected-item`)。 |\n| `serverOptions` | `TableServerOptions \\| null` | `null` | 服务端分页/排序选项。 |\n| `serverTotal` | `number` | `0` | 服务端总条数。 |\n| `paginator` | `boolean` | `false` | 显示内置分页页脚。 |\n| `page` | `number` | `1` | 当前页(`v-model:page`)。 |\n| `rowsPerPage` | `number` | `25` | 每页条数。 |\n| `pageSizes` | `number[]` | `[25, 50, 100]` | 分页每页条数选项。 |\n| `showHeader` | `boolean` | `true` | 是否显示表头。 |\n| `showRowsPerPage` | `boolean` | `true` | 是否显示每页条数选择器。 |\n| `fill` | `boolean` | `false` | 撑满父级剩余高度(仅全视口主列表配 `MPageContent fill`);表体滚动,分页贴底。设置 `maxHeight` / `tableHeight` 时忽略。 |\n| `columnWidths` | `Record<string, number> \\| null` | `null` | 列宽(`v-model:column-widths`)。 |\n| `virtual` | `boolean` | `false` | 行虚拟滚动(需高度;展开行时跳过)。 |\n| `virtualRowHeight` | `number` | `40` | 虚拟行高估算。 |\n| `hiddenColumns` | `string[] \\| null` | `null` | 隐藏列键(`v-model:hidden-columns`)。 |\n| `columnOrder` | `string[] \\| null` | `null` | 叶列顺序(`v-model:column-order`)。 |\n| `showFooter` | `boolean` | `false` | 显示表尾。 |\n| `footerMethod` | `TableFooterMethod \\| null` | `null` | 表尾数据。 |\n| `spanMethod` | `TableSpanMethod \\| null` | `null` | 单元格合并。 |\n| `treeConfig` | `TableTreeConfig \\| null` | `null` | 树形行。 |\n| `expandConfig` | `TableExpandConfig \\| null` | `null` | 详情展开配置(与树互斥)。 |\n| `checkboxConfig` | `TableCheckboxConfig \\| null` | `null` | 多选:级联 / `checkMethod` / `checkRowKeys` / `trigger` / `reserve`。 |\n| `radioConfig` | `TableRadioConfig \\| null` | `null` | 单选:`strict` / `checkMethod` / `trigger`。 |\n| `expandable` | `boolean` | `false` | 显示展开列(也可由 `#expansion` 或 `expandConfig` 启用)。 |\n| `striped` | `boolean` | `false` | 斑马纹行。 |\n| `bordered` | `boolean` | `false` | 单元格边框。 |\n| `highlightCurrent` | `boolean` | `false` | 高亮当前行,配合 `v-model:current-row-key`。 |\n| `rowHover` | `boolean` | `true` | 行 hover 高亮。 |\n| `sortField` / `sortOrder` | — | — | 受控排序字段与方向。 |\n| `sortMode` | `'client' \\| 'emit'` | `'client'` | 客户端排序或仅抛出排序事件。 |\n| `searchField` / `searchValue` | — | — | 客户端搜索。 |\n| `filterOptions` | `TableFilterOption[]` | `null` | 结构化筛选条件。 |\n| `loading` | `boolean` | `false` | 加载中。 |\n| `emptyText` | `string` | — | 空数据文案。 |\n| `emptyDescription` | `string` | — | 空数据补充说明。 |\n| `maxHeight` | `number \\| null` | `null` | 表格最大高度,超出滚动。 |\n| `showOverflowTooltip` | `boolean` | `false` | 全局单元格溢出 Tooltip。 |\n| `rowKey` | `string` | `'id'` | 行唯一键字段。 |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | 表格密度。 |\n| `ariaLabel` | `string` | — | — |\n| `bodyExpandRowClassName` | `TableBodyRowClassName` | — | — |\n| `bodyItemClassName` | `TableBodyItemClassName` | — | — |\n| `bodyRowClassName` | `TableBodyRowClassName` | — | — |\n| `bodyTextDirection` | `TableTextDirection` | — | — |\n| `checkboxColumnWidth` | `number \\| null` | — | — |\n| `clickRowToExpand` | `boolean` | — | — |\n| `currentRowKey` | `string \\| number \\| null` | — | — |\n| `expandColumnWidth` | `number` | — | — |\n| `expandedRowKeys` | `Array<string \\| number>` | — | — |\n| `filters` | `Record<string, unknown> \\| null` | — | — |\n| `fixedCheckbox` | `boolean` | — | — |\n| `fixedExpand` | `boolean` | — | — |\n| `fixedHeader` | `boolean` | — | — |\n| `fixedIndex` | `boolean` | — | — |\n| `headerClassName` | `string` | — | — |\n| `headerItemClassName` | `TableHeaderItemClassName` | — | — |\n| `headerTextDirection` | `TableTextDirection` | — | — |\n| `indexColumnWidth` | `number` | — | — |\n| `multiSort` | `boolean` | — | — |\n| `mustSort` | `boolean` | — | — |\n| `showIndex` | `boolean` | — | — |\n| `showIndexSymbol` | `string` | — | — |\n| `tableClassName` | `string` | — | — |\n| `tableHeight` | `number \\| null` | — | — |\n| `tableMinHeight` | `number` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |\n\n\n## Slots\n\n| 插槽 | 说明 |\n| --- | --- |\n| `cell-{key}` | 列 `{key}` 单元格,作用域 `{ row, value, column }`(可自行实现编辑器)。 |\n| `footer` | 自定义表尾。 |\n| `body-cell` | 任意单元格,作用域 `{ row, column, value }`。 |\n| `expansion` | 展开行内容,作用域 `{ row }`。 |\n| `empty` | 自定义空态。 |\n| `loading` | 自定义加载态。 |\n| `pagination` | 自定义分页区域。 |\n| `body` | 自定义 `body` 内容。 |\n| `body-append` | 自定义 `body-append` 内容。 |\n| `body-prepend` | 自定义 `body-prepend` 内容。 |\n| `customize-headers` | 自定义 `customize-headers` 内容。 |\n| `header` | 自定义 `header` 内容。 |\n| `header-{key}` | 列头插槽(键名大小写与 `columns[].key` 一致)。 |\n\n## Events\n\n| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | 排序变化。 |\n| `row-click` | `{ row, index }`, `Event` | 行单击。 |\n| `row-dblclick` | `{ row, index }`, `Event` | 行双击。 |\n| `row-contextmenu` | `item`, `MouseEvent` | 行右键。 |\n| `select-row` | `TableItem` | 选中一行。 |\n| `deselect-row` | `TableItem` | 取消选中一行。 |\n| `select-all` | — | 全选当前页。 |\n| `current-change` | `row \\| null, oldRow \\| null` | 当前高亮行变化。 |\n| `expand` | `{ row, expanded }` | 行展开。 |\n| `update:selection` | `TableItem[]` | 多选 v-model。 |\n| `update:page` | `number` | 页码 v-model。 |\n| `update:server-options` | `TableServerOptions` | 服务端选项 v-model。 |\n| `update:current-row-key` | `string \\| number \\| null` | 当前行键 v-model。 |\n| `filter` | — | — |\n| `update:expandedRowKeys` | — | — |\n| `update:filters` | — | — |\n| `update:columnWidths` | `Record<string, number>` | 列宽 v-model。 |\n| `update:hiddenColumns` | `string[]` | 隐藏列 v-model。 |\n| `update:columnOrder` | `string[]` | 列顺序 v-model。 |\n| `update:selectedItem` | — | — |\n\n## 实例方法\n\n通过 `ref` 可访问分页、筛选、选择、滚动与展开控制:\n\n| 方法 / 属性 | 说明 |\n| --- | --- |\n| `currentPageFirstIndex` | 当前页首条记录的索引(无数据时为 `-1`)。 |\n| `currentPageLastIndex` | 当前页末条记录的索引。 |\n| `clientItemsLength` | 数据总条数(服务端模式下为服务端总数)。 |\n| `maxPaginationNumber` | 最大页码。 |\n| `currentPaginationNumber` | 当前页码。 |\n| `isLastPage` / `isFirstPage` | 是否末页 / 首页。 |\n| `nextPage()` / `prevPage()` | 下一页 / 上一页。 |\n| `updatePage(page)` | 跳到指定页码。 |\n| `rowsPerPageOptions` | 每页条数选项。 |\n| `rowsPerPageActiveOption` | 当前生效的每页条数。 |\n| `updateRowsPerPageActiveOption(n)` | 修改每页条数。 |\n| `setFilters(filters)` / `clearFilter()` | 设置 / 清空筛选。 |\n| `setColumnWidths(widths)` | 设置列宽(等同 `v-model:column-widths`)。 |\n| `setHiddenColumns(keys)` | 设置隐藏列键(等同 `v-model:hidden-columns`)。 |\n| `setColumnOrder(keys)` | 设置叶列顺序(等同 `v-model:column-order`)。 |\n| `clearSort()` | 清空排序。 |\n| `getCheckboxRecords()` | 当前多选行。 |\n| `setCheckboxRow(rows, checked)` | 设置行选中状态。 |\n| `clearCheckboxRow()` | 清空多选。 |\n| `isCheckedByCheckboxRow(row)` | 行是否选中。 |\n| `isAllCheckboxChecked()` | 当前页是否全选。 |\n| `getCheckboxIndeterminateRecords()` | 半选行(树级联)。 |\n| `scrollTo(...)` / `scrollToRow(row)` | 滚动定位。 |\n| `setRowExpand` / `setAllRowExpand` / `toggleRowExpand` / `clearRowExpand` / `isRowExpandByRow` / `getRowExpandRecords` | 详情展开(非树模式)。 |\n| `setTreeExpand` / `setAllTreeExpand` / `toggleTreeExpand` / `clearTreeExpand` / `isTreeExpandByRow` / `getTreeExpandRecords` | 树节点展开。 |\n\n## 类型\n\n<h4 id=\"TableItem\">TableItem</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n<h4 id=\"TableTextDirection\">TableTextDirection</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableTextDirection = 'left' | 'center' | 'right'\n```\n\n<h4 id=\"TableFilterOption\">TableFilterOption</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableFilterOption = | { field: string; comparison: 'between'; criteria: [number, number] }\n | { field: string; comparison: '=' | '!='; criteria: number | string }\n | { field: string; comparison: '>' | '>=' | '<' | '<='; criteria: number }\n | { field: number | string; comparison: 'in'; criteria: number[] | string[] }\n | { field: string; comparison: (value: unknown, criteria: string) => boolean; criteria: string }\n```\n\n<h4 id=\"TableHeaderItemClassName\">TableHeaderItemClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableHeaderItemClassName = string | ((header: TableHeader, columnNumber: number) => string)\n```\n\n<h4 id=\"TableBodyRowClassName\">TableBodyRowClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableBodyRowClassName = string | ((item: TableItem, rowNumber: number) => string)\n```\n\n<h4 id=\"TableBodyItemClassName\">TableBodyItemClassName</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ntype TableBodyItemClassName = string | ((column: string, rowNumber: number) => string)\n```\n\n\n\n<h4 id=\"TableTreeConfig\">TableTreeConfig</h4>\n\n```ts\ninterface TableTreeConfig {\n childrenField?: string // default 'children'\n indent?: number // default 16\n expandAll?: boolean\n accordion?: boolean\n trigger?: 'default' | 'row'\n lazy?: boolean\n hasChildField?: string // default 'hasChild'\n loadMethod?: (row: TableItem) => Promise<TableItem[]> | TableItem[]\n transform?: boolean // flat parentId → tree\n rowField?: string\n parentField?: string // default 'parentId'\n treeNode?: string // column key for toggler; default first column\n showLine?: boolean\n}\n```\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\n列定义,传给 `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n render?: (row: TableItem) => unknown\n showOverflowTooltip?: boolean\n}\n```\n\n<h4 id=\"TableServerOptions\">TableServerOptions</h4>\n\n服务端分页/排序时传给 `serverOptions`,配合 `serverTotal`:\n\n```ts\ninterface TableServerOptions {\n page: number\n rowsPerPage: number\n sortBy?: string | string[]\n sortType?: 'asc' | 'desc' | ('asc' | 'desc')[]\n}\n```\n\n更多见 [API 类型](/docs/types)。\n"
|
|
22999
23291
|
},
|
|
23000
23292
|
"en-US": {
|
|
23001
23293
|
"title": "Table",
|
|
@@ -23004,7 +23296,7 @@
|
|
|
23004
23296
|
{
|
|
23005
23297
|
"id": "overview",
|
|
23006
23298
|
"title": "",
|
|
23007
|
-
"body": "# Table\n\n`MTable` displays structured row data. Define columns with `columns`, pass data with `rows`, and use built-in client-side sort, filter, pagination, and row selection—or switch to server-driven pagination.\n\nColumn width rules:\n\n- Columns with `width` use a fixed width\n- Columns without `width` are flexible with a `minWidth` lower bound (default `80`); when `fit` is `true` (default), remaining width is distributed proportionally\n- Horizontal scrolling appears when the total minimum width exceeds the container\n- Prefer `maxHeight` / `tableHeight` when the table body should scroll on its own; when nested under `MLayout` root scroll, fix the table height to avoid stacked scrollbars\n-
|
|
23299
|
+
"body": "# Table\n\n`MTable` displays structured row data. Define columns with `columns`, pass data with `rows`, and use built-in client-side sort, filter, pagination, and row selection—or switch to server-driven pagination. Header “select all” applies to the current page only.\n\nColumn width rules:\n\n- Columns with `width` use a fixed width\n- Columns without `width` are flexible with a `minWidth` lower bound (default `80`); when `fit` is `true` (default), remaining width is distributed proportionally\n- Horizontal scrolling appears when the total minimum width exceeds the container\n- Prefer `maxHeight` / `tableHeight` when the table body should scroll on its own; when nested under `MLayout` root scroll, fix the table height to avoid stacked scrollbars\n- For full-viewport main lists, use `MPageContent fill` + `MTable fill paginator` (body scrolls; pagination at the bottom). Skip `fill` for embedded or short tables."
|
|
23008
23300
|
},
|
|
23009
23301
|
{
|
|
23010
23302
|
"id": "import",
|
|
@@ -23029,45 +23321,80 @@
|
|
|
23029
23321
|
{
|
|
23030
23322
|
"id": "expandable-rows",
|
|
23031
23323
|
"title": "Expandable rows",
|
|
23032
|
-
"body": "Set `expandable` and provide the
|
|
23324
|
+
"body": "Customize cells with `render` or `#cell-{key}`. Set `expandable` (or `expandConfig`) and provide the `#expansion` slot. In tree mode, `expandedRowKeys` controls tree nodes and cannot be used for detail expansion at the same time.\n\n```vue preview src=\"./demos/ExpandableRows.en.vue\"\n```"
|
|
23325
|
+
},
|
|
23326
|
+
{
|
|
23327
|
+
"id": "fixed-columns",
|
|
23328
|
+
"title": "Fixed columns",
|
|
23329
|
+
"body": "Set `fixed: 'left' | 'right'` on a column (or `fixed: true` for left).\n\n```vue preview src=\"./demos/FixedColumns.en.vue\"\n```"
|
|
23330
|
+
},
|
|
23331
|
+
{
|
|
23332
|
+
"id": "column-resize-and-header-filters",
|
|
23333
|
+
"title": "Column resize and header filters",
|
|
23334
|
+
"body": "Set `resizable` to drag column widths (`v-model:column-widths`). Set `filterable` for a header filter; optional `filters` for checkbox options, otherwise free-text contains.\n\n```vue preview src=\"./demos/ResizeAndFilter.en.vue\"\n```"
|
|
23335
|
+
},
|
|
23336
|
+
{
|
|
23337
|
+
"id": "virtual-scroll",
|
|
23338
|
+
"title": "Virtual scroll",
|
|
23339
|
+
"body": "Enable `virtual` with `maxHeight` / `tableHeight` / `fill`. Expandable tables skip virtualization.\n\n```vue preview src=\"./demos/VirtualScroll.en.vue\"\n```"
|
|
23340
|
+
},
|
|
23341
|
+
{
|
|
23342
|
+
"id": "multi-header-footer-and-merges",
|
|
23343
|
+
"title": "Multi-header, footer, and merges",
|
|
23344
|
+
"body": "Use column `children` for grouped headers; `show-footer` + `footer-method` for summaries; `span-method` for merges.\n\n```vue preview src=\"./demos/GridFeatures.en.vue\"\n```"
|
|
23033
23345
|
},
|
|
23034
23346
|
{
|
|
23035
23347
|
"id": "empty-and-loading",
|
|
23036
23348
|
"title": "Empty and loading",
|
|
23037
23349
|
"body": "```vue preview src=\"./demos/EmptyAndLoading.en.vue\"\n```"
|
|
23038
23350
|
},
|
|
23351
|
+
{
|
|
23352
|
+
"id": "tree-table",
|
|
23353
|
+
"title": "Tree table",
|
|
23354
|
+
"body": "Pass `tree-config` for hierarchical rows: nested `children`, or flat `parentId` with `transform`. Bind expand state with `v-model:expanded-row-keys`. Supports `expandAll` / `expandRowKeys`, `accordion`, `trigger`, `toggleMethod`, and lazy `loadMethod`.\n\nInstance methods: `setTreeExpand`, `setAllTreeExpand`, `toggleTreeExpand`, `isTreeExpandByRow`, `getTreeExpandRecords`, `clearTreeExpand`.\n\nWith multi-select, parent/child cascade and indeterminate are on by default (`checkbox-config.check-strictly=false`). Use `checkMethod` to disable specific rows.\n\n```vue preview src=\"./demos/Tree.en.vue\"\n```"
|
|
23355
|
+
},
|
|
23356
|
+
{
|
|
23357
|
+
"id": "server-mode",
|
|
23358
|
+
"title": "Server mode",
|
|
23359
|
+
"body": "Pass `server-options` with `server-total`, and sync page / page size / sort via `v-model:server-options`.\n\n```vue preview src=\"./demos/Demo7.vue\"\n```"
|
|
23360
|
+
},
|
|
23361
|
+
{
|
|
23362
|
+
"id": "breaking-changes",
|
|
23363
|
+
"title": "Breaking changes",
|
|
23364
|
+
"body": "- Removed built-in cell editing: `editConfig`, column `editable`, `edit-change`, `#edit-{key}`; use `#cell-{key}` / `render` instead\n- Removed `MTreeTable` (including `morya-ui/tree-table`); use `MTable` + `treeConfig`\n- `serverItemsLength` → `serverTotal`\n- `rowsItems` → `pageSizes`\n- Removed `hideHeader`; use `showHeader` (default `true`)\n- Removed `hideRowsPerPage`; use `showRowsPerPage` (default `true`)\n- Removed: `clickEventType`, `rowsPerPageMessage`, `rowsOfPageSeparatorMessage`, `preventContextMenuRow`, `tableNodeId`\n- Events: `contextmenuRow` → `row-contextmenu`; `selectRow` / `deselectRow` / `selectAll` → `select-row` / `deselect-row` / `select-all`\n- Removed events: `updatePageItems`, `updateTotalItems`, `page` (keep `update:page`)\n- Row interaction: click and dblclick always emit (`row-click` / `row-dblclick`); context menu always `preventDefault`s and emits `row-contextmenu`"
|
|
23365
|
+
},
|
|
23039
23366
|
{
|
|
23040
23367
|
"id": "tablecolumndefinition",
|
|
23041
23368
|
"title": "TableColumnDefinition",
|
|
23042
|
-
"body": "| Field | Type | Description |\n| --- | --- | --- |\n| `key` | `string` | Field name bound to row data. |\n| `label` | `string` | Column header text. |\n| `width` | `number` | Fixed width in px. |\n| `minWidth` | `number` | Flex column minimum width; default `80`. |\n| `sortable` | `boolean` | Enable sorting. |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | Freeze column (left freeze supported). |\n| `align` | `'start' \\| 'center' \\| 'end'` | Cell alignment. |\n| `render` | `(row) => unknown` | Custom cell renderer. |\n| `showOverflowTooltip` | `boolean` | Tooltip when cell text overflows. |"
|
|
23369
|
+
"body": "| Field | Type | Description |\n| --- | --- | --- |\n| `key` | `string` | Field name bound to row data. |\n| `label` | `string` | Column header text. |\n| `width` | `number` | Fixed width in px. |\n| `minWidth` | `number` | Flex column minimum width; default `80`. |\n| `sortable` | `boolean` | Enable sorting. |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | Freeze column (left freeze supported). |\n| `align` | `'start' \\| 'center' \\| 'end'` | Cell alignment. |\n| `render` | `(row) => unknown` | Custom cell renderer. |\n| `showOverflowTooltip` | `boolean` | Tooltip when cell text overflows. |\n| `resizable` | `boolean` | Drag to resize column width. |\n| `filterable` | `boolean` | Show header filter trigger. |\n| `filters` | `TableColumnFilter[]` | Header filter options; omit for text filter. |\n| `children` | `TableColumnDefinition[]` | Nested columns for multi-level headers. |"
|
|
23043
23370
|
},
|
|
23044
23371
|
{
|
|
23045
23372
|
"id": "props",
|
|
23046
23373
|
"title": "Props",
|
|
23047
|
-
"body": "| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | Column definitions. |\n| `rows` | `TableItem[]` | — | Row data. |\n| `fit` | `boolean` | `true` | Flexible columns fill remaining width. |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | Row selection mode. |\n| `selection` | `TableItem[] \\| null` | `null` | Multi-select (`v-model:selection`). |\n| `paginator` | `boolean` | `false` | Built-in pagination footer. |\n| `page` | `number` | `1` | Current page (`v-model:page`). |\n| `rowsPerPage` | `number` | `25` | Page size. |\n| `fill` | `boolean` | `false` | Fill remaining parent height (only for full-viewport main lists with `MPageContent fill`). Body scrolls; paginator stays at the bottom. Ignored when `maxHeight` / `tableHeight` is set. |\n| `striped` / `bordered` | `boolean` | `false` | Striped rows / cell borders. |\n| `highlightCurrent` | `boolean` | `false` | Highlight current row. |\n| `loading` / `emptyText` / `emptyDescription` | — | — | Loading and empty states. |\n| `maxHeight` | `number \\| null` | `null` | Scrollable body max height. |\n| `rowKey` | `string` | `'id'` | Stable row key field. |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | Table density. |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |"
|
|
23374
|
+
"body": "| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | Column definitions. |\n| `rows` | `TableItem[]` | — | Row data. |\n| `fit` | `boolean` | `true` | Flexible columns fill remaining width. |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | Row selection mode. |\n| `selection` | `TableItem[] \\| null` | `null` | Multi-select (`v-model:selection`). |\n| `selectedItem` | `TableItem \\| null` | `null` | Single-select (`v-model:selected-item`). |\n| `serverOptions` | `TableServerOptions \\| null` | `null` | Server paging/sort options. |\n| `serverTotal` | `number` | `0` | Total row count in server mode. |\n| `paginator` | `boolean` | `false` | Built-in pagination footer. |\n| `page` | `number` | `1` | Current page (`v-model:page`). |\n| `rowsPerPage` | `number` | `25` | Page size. |\n| `pageSizes` | `number[]` | `[25, 50, 100]` | Page size options. |\n| `showHeader` | `boolean` | `true` | Show table header. |\n| `showRowsPerPage` | `boolean` | `true` | Show page-size picker. |\n| `fill` | `boolean` | `false` | Fill remaining parent height (only for full-viewport main lists with `MPageContent fill`). Body scrolls; paginator stays at the bottom. Ignored when `maxHeight` / `tableHeight` is set. |\n| `treeConfig` | `TableTreeConfig \\| null` | `null` | Tree rows. |\n| `expandConfig` | `TableExpandConfig \\| null` | `null` | Detail expand (mutually exclusive with tree). |\n| `checkboxConfig` | `TableCheckboxConfig \\| null` | `null` | Multi-select options. |\n| `radioConfig` | `TableRadioConfig \\| null` | `null` | Single-select options. |\n| `striped` / `bordered` | `boolean` | `false` | Striped rows / cell borders. |\n| `highlightCurrent` | `boolean` | `false` | Highlight current row. |\n| `loading` / `emptyText` / `emptyDescription` | — | — | Loading and empty states. |\n| `maxHeight` | `number \\| null` | `null` | Scrollable body max height. |\n| `rowKey` | `string` | `'id'` | Stable row key field. |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | Table density. |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |"
|
|
23048
23375
|
},
|
|
23049
23376
|
{
|
|
23050
23377
|
"id": "slots",
|
|
23051
23378
|
"title": "Slots",
|
|
23052
|
-
"body": "| Slot | Description |\n| --- | --- |\n| `cell-{key}` | Cell for column `{key}`; scope `{ row, value, column }
|
|
23379
|
+
"body": "| Slot | Description |\n| --- | --- |\n| `cell-{key}` | Cell for column `{key}`; scope `{ row, value, column }` (use this for custom editors). |\n| `body-cell` | Any cell; scope `{ row, column, value }`. |\n| `expansion` | Expanded row; scope `{ row }`. |\n| `empty` / `loading` | Empty and loading placeholders. |\n| `header-{key}` | Header slot (exact key case). |"
|
|
23053
23380
|
},
|
|
23054
23381
|
{
|
|
23055
23382
|
"id": "events",
|
|
23056
23383
|
"title": "Events",
|
|
23057
|
-
"body": "| Event | Payload | Description |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | Sort changed. |\n| `
|
|
23384
|
+
"body": "| Event | Payload | Description |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | Sort changed. |\n| `row-click` | `{ row, index }`, `Event` | Row clicked. |\n| `row-dblclick` | `{ row, index }`, `Event` | Row double-clicked. |\n| `row-contextmenu` | `item`, `MouseEvent` | Row context menu. |\n| `select-row` / `deselect-row` | `TableItem` | Row selection toggled. |\n| `select-all` | — | Select all on current page. |\n| `current-change` | `row \\| null, oldRow \\| null` | Current row changed. |\n| `update:selection` | `TableItem[]` | Selection v-model. |\n| `update:page` | `number` | Page v-model. |"
|
|
23058
23385
|
},
|
|
23059
23386
|
{
|
|
23060
23387
|
"id": "instance",
|
|
23061
23388
|
"title": "Instance",
|
|
23062
|
-
"body": "Pagination and
|
|
23389
|
+
"body": "Pagination, filter, selection, scroll, and expand controls via `ref`:\n\n| Method / Property | Description |\n| --- | --- |\n| `currentPageFirstIndex` | Index of the first record on the current page (`-1` when empty). |\n| `currentPageLastIndex` | Index of the last record on the current page. |\n| `clientItemsLength` | Total item count (server total in server mode). |\n| `maxPaginationNumber` | Last page number. |\n| `currentPaginationNumber` | Current page number. |\n| `isLastPage` / `isFirstPage` | Whether the current page is the last / first. |\n| `nextPage()` / `prevPage()` | Go to the next / previous page. |\n| `updatePage(page)` | Jump to a page. |\n| `rowsPerPageOptions` | Rows-per-page options. |\n| `rowsPerPageActiveOption` | Active rows-per-page value. |\n| `updateRowsPerPageActiveOption(n)` | Change rows per page. |\n| `setFilters(filters)` / `clearFilter()` | Set / clear filters. |\n| `setColumnWidths(widths)` | Set column widths (same as `v-model:column-widths`). |\n| `setHiddenColumns(keys)` | Set hidden column keys (same as `v-model:hidden-columns`). |\n| `setColumnOrder(keys)` | Set leaf column order (same as `v-model:column-order`). |\n| `clearSort()` | Clear sort. |\n| `getCheckboxRecords()` / `setCheckboxRow` / `clearCheckboxRow` / `isCheckedByCheckboxRow` / `isAllCheckboxChecked` | Selection APIs. |\n| `scrollTo(...)` / `scrollToRow(row)` | Scroll helpers. |\n| `setRowExpand` / `toggleRowExpand` / `clearRowExpand` / … | Detail expand (non-tree). |\n| `setTreeExpand` / `toggleTreeExpand` / `clearTreeExpand` / … | Tree expand. |"
|
|
23063
23390
|
},
|
|
23064
23391
|
{
|
|
23065
23392
|
"id": "types",
|
|
23066
23393
|
"title": "Types",
|
|
23067
|
-
"body": "<h4 id=\"TableItem\">TableItem</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\nColumn definition passed to `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'
|
|
23394
|
+
"body": "<h4 id=\"TableItem\">TableItem</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\nColumn definition passed to `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n render?: (row: TableItem) => unknown\n filterable?: boolean\n filters?: TableColumnFilter[]\n resizable?: boolean\n children?: TableColumnDefinition[]\n showOverflowTooltip?: boolean\n}\n```\n\n<h4 id=\"TableServerOptions\">TableServerOptions</h4>\n\nServer-side paging/sorting payload for `serverOptions`, with `serverTotal`:\n\n```ts\ninterface TableServerOptions {\n page: number\n rowsPerPage: number\n sortBy?: string | string[]\n sortType?: 'asc' | 'desc' | ('asc' | 'desc')[]\n}\n```\n\n`TableItem` is `Record<string, unknown>`. See also [API types](/docs/types)."
|
|
23068
23395
|
}
|
|
23069
23396
|
],
|
|
23070
|
-
"markdown": "---\ntitle: Table\ncategory: 03 / DATA\ndescription: Data table with sorting, filtering, selection, pagination, frozen columns, and empty/loading states. Column width supports width / minWidth / fit.\n---\n\n# Table\n\n`MTable` displays structured row data. Define columns with `columns`, pass data with `rows`, and use built-in client-side sort, filter, pagination, and row selection—or switch to server-driven pagination.\n\nColumn width rules:\n\n- Columns with `width` use a fixed width\n- Columns without `width` are flexible with a `minWidth` lower bound (default `80`); when `fit` is `true` (default), remaining width is distributed proportionally\n- Horizontal scrolling appears when the total minimum width exceeds the container\n- Prefer `maxHeight` / `tableHeight` when the table body should scroll on its own; when nested under `MLayout` root scroll, fix the table height to avoid stacked scrollbars\n- **Full-viewport main lists (when it fits):** `MPageContent fill` + `MTable fill paginator` — body scrolls; pagination at the page bottom. Skip `fill` for embedded/short tables\n\n## Import\n\n```ts\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable, MTag } from 'morya-ui'\n```\n\n## Basic\n\n```vue preview src=\"./demos/Basic.en.vue\"\n```\n\n## Selection\n\nUse `selection-mode=\"multiple\"` with `v-model:selection`, or `selection-mode=\"single\"` with `v-model:selected-item`.\n\n```vue preview src=\"./demos/Selection.en.vue\"\n```\n\n## Filter and pagination\n\nUse `search-value` / `filter-options` for client filtering. Enable `paginator` with `v-model:page` and `rows-per-page`.\n\n```vue preview src=\"./demos/FilterAndPagination.en.vue\"\n```\n\n## Expandable rows\n\nSet `expandable` and provide the `expansion` slot. Column `render` works for custom cells; a `cell-{key}` slot overrides `render`.\n\n```vue preview src=\"./demos/ExpandableRows.en.vue\"\n```\n\n## Empty and loading\n\n```vue preview src=\"./demos/EmptyAndLoading.en.vue\"\n```\n\n## TableColumnDefinition\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `key` | `string` | Field name bound to row data. |\n| `label` | `string` | Column header text. |\n| `width` | `number` | Fixed width in px. |\n| `minWidth` | `number` | Flex column minimum width; default `80`. |\n| `sortable` | `boolean` | Enable sorting. |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | Freeze column (left freeze supported). |\n| `align` | `'start' \\| 'center' \\| 'end'` | Cell alignment. |\n| `render` | `(row) => unknown` | Custom cell renderer. |\n| `showOverflowTooltip` | `boolean` | Tooltip when cell text overflows. |\n\n## Props\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | Column definitions. |\n| `rows` | `TableItem[]` | — | Row data. |\n| `fit` | `boolean` | `true` | Flexible columns fill remaining width. |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | Row selection mode. |\n| `selection` | `TableItem[] \\| null` | `null` | Multi-select (`v-model:selection`). |\n| `paginator` | `boolean` | `false` | Built-in pagination footer. |\n| `page` | `number` | `1` | Current page (`v-model:page`). |\n| `rowsPerPage` | `number` | `25` | Page size. |\n| `fill` | `boolean` | `false` | Fill remaining parent height (only for full-viewport main lists with `MPageContent fill`). Body scrolls; paginator stays at the bottom. Ignored when `maxHeight` / `tableHeight` is set. |\n| `striped` / `bordered` | `boolean` | `false` | Striped rows / cell borders. |\n| `highlightCurrent` | `boolean` | `false` | Highlight current row. |\n| `loading` / `emptyText` / `emptyDescription` | — | — | Loading and empty states. |\n| `maxHeight` | `number \\| null` | `null` | Scrollable body max height. |\n| `rowKey` | `string` | `'id'` | Stable row key field. |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | Table density. |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |\n\n\n## Slots\n\n| Slot | Description |\n| --- | --- |\n| `cell-{key}` | Cell for column `{key}`; scope `{ row, value, column }`. |\n| `body-cell` | Any cell; scope `{ row, column, value }`. |\n| `expansion` | Expanded row; scope `{ row }`. |\n| `empty` / `loading` | Empty and loading placeholders. |\n\n## Events\n\n| Event | Payload | Description |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | Sort changed. |\n| `page` | `number` | Page changed. |\n| `row-click` | `{ row, index }` | Row clicked. |\n| `current-change` | `row \\| null, oldRow \\| null` | Current row changed. |\n| `update:selection` | `TableItem[]` | Selection v-model. |\n| `update:page` | `number` | Page v-model. |\n\n## Instance\n\nPagination and filter controls exposed via `ref`:\n\n| Method / Property | Description |\n| --- | --- |\n| `currentPageFirstIndex` | Index of the first record on the current page (`-1` when empty). |\n| `currentPageLastIndex` | Index of the last record on the current page. |\n| `clientItemsLength` | Total item count (server total in server mode). |\n| `maxPaginationNumber` | Last page number. |\n| `currentPaginationNumber` | Current page number. |\n| `isLastPage` / `isFirstPage` | Whether the current page is the last / first. |\n| `nextPage()` / `prevPage()` | Go to the next / previous page. |\n| `updatePage(page)` | Jump to a page. |\n| `rowsPerPageOptions` | Rows-per-page options. |\n| `rowsPerPageActiveOption` | Active rows-per-page value. |\n| `updateRowsPerPageActiveOption(n)` | Change rows per page. |\n| `setFilters(filters)` | Set filters programmatically. |\n\n## Types\n\n<h4 id=\"TableItem\">TableItem</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\nColumn definition passed to `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end' | 'left' | 'right'\n render?: (row: TableItem) => unknown\n filterable?: boolean\n filters?: { label: string; value: string | number }[]\n showOverflowTooltip?: boolean\n}\n```\n\n<h4 id=\"TableServerOptions\">TableServerOptions</h4>\n\nServer-side paging/sorting payload for `serverOptions`, with `serverItemsLength`:\n\n```ts\ninterface TableServerOptions {\n page: number\n rowsPerPage: number\n sortBy?: string | string[]\n sortType?: 'asc' | 'desc' | ('asc' | 'desc')[]\n}\n```\n\n`TableItem` is `Record<string, unknown>`. See also [API types](/docs/types).\n"
|
|
23397
|
+
"markdown": "---\ntitle: Table\ncategory: 03 / DATA\ndescription: Data table with sorting, filtering, selection, pagination, frozen columns, and empty/loading states. Column width supports width / minWidth / fit.\n---\n\n# Table\n\n`MTable` displays structured row data. Define columns with `columns`, pass data with `rows`, and use built-in client-side sort, filter, pagination, and row selection—or switch to server-driven pagination. Header “select all” applies to the current page only.\n\nColumn width rules:\n\n- Columns with `width` use a fixed width\n- Columns without `width` are flexible with a `minWidth` lower bound (default `80`); when `fit` is `true` (default), remaining width is distributed proportionally\n- Horizontal scrolling appears when the total minimum width exceeds the container\n- Prefer `maxHeight` / `tableHeight` when the table body should scroll on its own; when nested under `MLayout` root scroll, fix the table height to avoid stacked scrollbars\n- For full-viewport main lists, use `MPageContent fill` + `MTable fill paginator` (body scrolls; pagination at the bottom). Skip `fill` for embedded or short tables.\n\n## Import\n\n```ts\nimport type { TableColumnDefinition, TableItem } from 'morya-ui'\nimport { MTable, MTag } from 'morya-ui'\n```\n\n## Basic\n\n```vue preview src=\"./demos/Basic.en.vue\"\n```\n\n## Selection\n\nUse `selection-mode=\"multiple\"` with `v-model:selection`, or `selection-mode=\"single\"` with `v-model:selected-item`.\n\n```vue preview src=\"./demos/Selection.en.vue\"\n```\n\n## Filter and pagination\n\nUse `search-value` / `filter-options` for client filtering. Enable `paginator` with `v-model:page` and `rows-per-page`.\n\n```vue preview src=\"./demos/FilterAndPagination.en.vue\"\n```\n\n## Expandable rows\n\nCustomize cells with `render` or `#cell-{key}`. Set `expandable` (or `expandConfig`) and provide the `#expansion` slot. In tree mode, `expandedRowKeys` controls tree nodes and cannot be used for detail expansion at the same time.\n\n```vue preview src=\"./demos/ExpandableRows.en.vue\"\n```\n\n## Fixed columns\n\nSet `fixed: 'left' | 'right'` on a column (or `fixed: true` for left).\n\n```vue preview src=\"./demos/FixedColumns.en.vue\"\n```\n\n## Column resize and header filters\n\nSet `resizable` to drag column widths (`v-model:column-widths`). Set `filterable` for a header filter; optional `filters` for checkbox options, otherwise free-text contains.\n\n```vue preview src=\"./demos/ResizeAndFilter.en.vue\"\n```\n\n## Virtual scroll\n\nEnable `virtual` with `maxHeight` / `tableHeight` / `fill`. Expandable tables skip virtualization.\n\n```vue preview src=\"./demos/VirtualScroll.en.vue\"\n```\n\n## Multi-header, footer, and merges\n\nUse column `children` for grouped headers; `show-footer` + `footer-method` for summaries; `span-method` for merges.\n\n```vue preview src=\"./demos/GridFeatures.en.vue\"\n```\n\n## Empty and loading\n\n```vue preview src=\"./demos/EmptyAndLoading.en.vue\"\n```\n\n## Tree table\n\nPass `tree-config` for hierarchical rows: nested `children`, or flat `parentId` with `transform`. Bind expand state with `v-model:expanded-row-keys`. Supports `expandAll` / `expandRowKeys`, `accordion`, `trigger`, `toggleMethod`, and lazy `loadMethod`.\n\nInstance methods: `setTreeExpand`, `setAllTreeExpand`, `toggleTreeExpand`, `isTreeExpandByRow`, `getTreeExpandRecords`, `clearTreeExpand`.\n\nWith multi-select, parent/child cascade and indeterminate are on by default (`checkbox-config.check-strictly=false`). Use `checkMethod` to disable specific rows.\n\n```vue preview src=\"./demos/Tree.en.vue\"\n```\n\n## Server mode\n\nPass `server-options` with `server-total`, and sync page / page size / sort via `v-model:server-options`.\n\n```vue preview src=\"./demos/Demo7.vue\"\n```\n\n## Breaking changes\n\n- Removed built-in cell editing: `editConfig`, column `editable`, `edit-change`, `#edit-{key}`; use `#cell-{key}` / `render` instead\n- Removed `MTreeTable` (including `morya-ui/tree-table`); use `MTable` + `treeConfig`\n- `serverItemsLength` → `serverTotal`\n- `rowsItems` → `pageSizes`\n- Removed `hideHeader`; use `showHeader` (default `true`)\n- Removed `hideRowsPerPage`; use `showRowsPerPage` (default `true`)\n- Removed: `clickEventType`, `rowsPerPageMessage`, `rowsOfPageSeparatorMessage`, `preventContextMenuRow`, `tableNodeId`\n- Events: `contextmenuRow` → `row-contextmenu`; `selectRow` / `deselectRow` / `selectAll` → `select-row` / `deselect-row` / `select-all`\n- Removed events: `updatePageItems`, `updateTotalItems`, `page` (keep `update:page`)\n- Row interaction: click and dblclick always emit (`row-click` / `row-dblclick`); context menu always `preventDefault`s and emits `row-contextmenu`\n\n## TableColumnDefinition\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `key` | `string` | Field name bound to row data. |\n| `label` | `string` | Column header text. |\n| `width` | `number` | Fixed width in px. |\n| `minWidth` | `number` | Flex column minimum width; default `80`. |\n| `sortable` | `boolean` | Enable sorting. |\n| `fixed` | `boolean \\| 'left' \\| 'right'` | Freeze column (left freeze supported). |\n| `align` | `'start' \\| 'center' \\| 'end'` | Cell alignment. |\n| `render` | `(row) => unknown` | Custom cell renderer. |\n| `showOverflowTooltip` | `boolean` | Tooltip when cell text overflows. |\n| `resizable` | `boolean` | Drag to resize column width. |\n| `filterable` | `boolean` | Show header filter trigger. |\n| `filters` | `TableColumnFilter[]` | Header filter options; omit for text filter. |\n| `children` | `TableColumnDefinition[]` | Nested columns for multi-level headers. |\n\n## Props\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `columns` | `TableColumnDefinition[]` | — | Column definitions. |\n| `rows` | `TableItem[]` | — | Row data. |\n| `fit` | `boolean` | `true` | Flexible columns fill remaining width. |\n| `selectionMode` | `'single' \\| 'multiple' \\| null` | `null` | Row selection mode. |\n| `selection` | `TableItem[] \\| null` | `null` | Multi-select (`v-model:selection`). |\n| `selectedItem` | `TableItem \\| null` | `null` | Single-select (`v-model:selected-item`). |\n| `serverOptions` | `TableServerOptions \\| null` | `null` | Server paging/sort options. |\n| `serverTotal` | `number` | `0` | Total row count in server mode. |\n| `paginator` | `boolean` | `false` | Built-in pagination footer. |\n| `page` | `number` | `1` | Current page (`v-model:page`). |\n| `rowsPerPage` | `number` | `25` | Page size. |\n| `pageSizes` | `number[]` | `[25, 50, 100]` | Page size options. |\n| `showHeader` | `boolean` | `true` | Show table header. |\n| `showRowsPerPage` | `boolean` | `true` | Show page-size picker. |\n| `fill` | `boolean` | `false` | Fill remaining parent height (only for full-viewport main lists with `MPageContent fill`). Body scrolls; paginator stays at the bottom. Ignored when `maxHeight` / `tableHeight` is set. |\n| `treeConfig` | `TableTreeConfig \\| null` | `null` | Tree rows. |\n| `expandConfig` | `TableExpandConfig \\| null` | `null` | Detail expand (mutually exclusive with tree). |\n| `checkboxConfig` | `TableCheckboxConfig \\| null` | `null` | Multi-select options. |\n| `radioConfig` | `TableRadioConfig \\| null` | `null` | Single-select options. |\n| `striped` / `bordered` | `boolean` | `false` | Striped rows / cell borders. |\n| `highlightCurrent` | `boolean` | `false` | Highlight current row. |\n| `loading` / `emptyText` / `emptyDescription` | — | — | Loading and empty states. |\n| `maxHeight` | `number \\| null` | `null` | Scrollable body max height. |\n| `rowKey` | `string` | `'id'` | Stable row key field. |\n| `size` | `'sm' \\| 'md' \\| 'lg'` | — | Table density. |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |\n\n\n## Slots\n\n| Slot | Description |\n| --- | --- |\n| `cell-{key}` | Cell for column `{key}`; scope `{ row, value, column }` (use this for custom editors). |\n| `body-cell` | Any cell; scope `{ row, column, value }`. |\n| `expansion` | Expanded row; scope `{ row }`. |\n| `empty` / `loading` | Empty and loading placeholders. |\n| `header-{key}` | Header slot (exact key case). |\n\n## Events\n\n| Event | Payload | Description |\n| --- | --- | --- |\n| `sort` | `{ sortField?, sortOrder? }` | Sort changed. |\n| `row-click` | `{ row, index }`, `Event` | Row clicked. |\n| `row-dblclick` | `{ row, index }`, `Event` | Row double-clicked. |\n| `row-contextmenu` | `item`, `MouseEvent` | Row context menu. |\n| `select-row` / `deselect-row` | `TableItem` | Row selection toggled. |\n| `select-all` | — | Select all on current page. |\n| `current-change` | `row \\| null, oldRow \\| null` | Current row changed. |\n| `update:selection` | `TableItem[]` | Selection v-model. |\n| `update:page` | `number` | Page v-model. |\n\n## Instance\n\nPagination, filter, selection, scroll, and expand controls via `ref`:\n\n| Method / Property | Description |\n| --- | --- |\n| `currentPageFirstIndex` | Index of the first record on the current page (`-1` when empty). |\n| `currentPageLastIndex` | Index of the last record on the current page. |\n| `clientItemsLength` | Total item count (server total in server mode). |\n| `maxPaginationNumber` | Last page number. |\n| `currentPaginationNumber` | Current page number. |\n| `isLastPage` / `isFirstPage` | Whether the current page is the last / first. |\n| `nextPage()` / `prevPage()` | Go to the next / previous page. |\n| `updatePage(page)` | Jump to a page. |\n| `rowsPerPageOptions` | Rows-per-page options. |\n| `rowsPerPageActiveOption` | Active rows-per-page value. |\n| `updateRowsPerPageActiveOption(n)` | Change rows per page. |\n| `setFilters(filters)` / `clearFilter()` | Set / clear filters. |\n| `setColumnWidths(widths)` | Set column widths (same as `v-model:column-widths`). |\n| `setHiddenColumns(keys)` | Set hidden column keys (same as `v-model:hidden-columns`). |\n| `setColumnOrder(keys)` | Set leaf column order (same as `v-model:column-order`). |\n| `clearSort()` | Clear sort. |\n| `getCheckboxRecords()` / `setCheckboxRow` / `clearCheckboxRow` / `isCheckedByCheckboxRow` / `isAllCheckboxChecked` | Selection APIs. |\n| `scrollTo(...)` / `scrollToRow(row)` | Scroll helpers. |\n| `setRowExpand` / `toggleRowExpand` / `clearRowExpand` / … | Detail expand (non-tree). |\n| `setTreeExpand` / `toggleTreeExpand` / `clearTreeExpand` / … | Tree expand. |\n\n## Types\n\n<h4 id=\"TableItem\">TableItem</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ntype TableItem = Record<string, unknown>\n```\n\n\n\n<h4 id=\"TableColumnDefinition\">TableColumnDefinition</h4>\n\nColumn definition passed to `columns`:\n\n```ts\ninterface TableColumnDefinition {\n key: string\n label: string\n width?: number\n minWidth?: number\n sortable?: boolean\n fixed?: boolean | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n render?: (row: TableItem) => unknown\n filterable?: boolean\n filters?: TableColumnFilter[]\n resizable?: boolean\n children?: TableColumnDefinition[]\n showOverflowTooltip?: boolean\n}\n```\n\n<h4 id=\"TableServerOptions\">TableServerOptions</h4>\n\nServer-side paging/sorting payload for `serverOptions`, with `serverTotal`:\n\n```ts\ninterface TableServerOptions {\n page: number\n rowsPerPage: number\n sortBy?: string | string[]\n sortType?: 'asc' | 'desc' | ('asc' | 'desc')[]\n}\n```\n\n`TableItem` is `Record<string, unknown>`. See also [API types](/docs/types).\n"
|
|
23071
23398
|
}
|
|
23072
23399
|
}
|
|
23073
23400
|
},
|
|
@@ -26376,235 +26703,6 @@
|
|
|
26376
26703
|
}
|
|
26377
26704
|
}
|
|
26378
26705
|
},
|
|
26379
|
-
{
|
|
26380
|
-
"id": "TreeTable",
|
|
26381
|
-
"name": "TreeTable",
|
|
26382
|
-
"exportName": "MTreeTable",
|
|
26383
|
-
"category": "03 / DATA",
|
|
26384
|
-
"description": "可展开的树形表格。",
|
|
26385
|
-
"descriptionEn": "Expandable tree table.",
|
|
26386
|
-
"import": "import { MTreeTable } from 'morya-ui'",
|
|
26387
|
-
"props": [
|
|
26388
|
-
{
|
|
26389
|
-
"name": "value",
|
|
26390
|
-
"type": "TreeTableNode[]",
|
|
26391
|
-
"default": "—",
|
|
26392
|
-
"description": "树形行数据。"
|
|
26393
|
-
},
|
|
26394
|
-
{
|
|
26395
|
-
"name": "columns",
|
|
26396
|
-
"type": "TreeTableColumn[]",
|
|
26397
|
-
"default": "—",
|
|
26398
|
-
"description": "列定义。"
|
|
26399
|
-
},
|
|
26400
|
-
{
|
|
26401
|
-
"name": "emptyMessage",
|
|
26402
|
-
"type": "string",
|
|
26403
|
-
"default": "—",
|
|
26404
|
-
"description": "—"
|
|
26405
|
-
},
|
|
26406
|
-
{
|
|
26407
|
-
"name": "expandedKeys",
|
|
26408
|
-
"type": "Record<string, boolean>",
|
|
26409
|
-
"default": "—",
|
|
26410
|
-
"description": "—"
|
|
26411
|
-
},
|
|
26412
|
-
{
|
|
26413
|
-
"name": "pt",
|
|
26414
|
-
"type": "[RootPassThrough](/docs/types#RootPassThrough) `{ root? }",
|
|
26415
|
-
"default": "—",
|
|
26416
|
-
"description": "DOM 透传,见 [样式与 attrs](/docs/attrs)."
|
|
26417
|
-
}
|
|
26418
|
-
],
|
|
26419
|
-
"events": [
|
|
26420
|
-
{
|
|
26421
|
-
"name": "node-expand",
|
|
26422
|
-
"payload": "TreeTableNode",
|
|
26423
|
-
"description": "节点展开。"
|
|
26424
|
-
},
|
|
26425
|
-
{
|
|
26426
|
-
"name": "node-collapse",
|
|
26427
|
-
"payload": "TreeTableNode",
|
|
26428
|
-
"description": "节点折叠。"
|
|
26429
|
-
},
|
|
26430
|
-
{
|
|
26431
|
-
"name": "update:expandedKeys",
|
|
26432
|
-
"payload": "—",
|
|
26433
|
-
"description": "—"
|
|
26434
|
-
}
|
|
26435
|
-
],
|
|
26436
|
-
"slots": [
|
|
26437
|
-
{
|
|
26438
|
-
"name": "expansion",
|
|
26439
|
-
"description": "展开行 `{ row }`。"
|
|
26440
|
-
},
|
|
26441
|
-
{
|
|
26442
|
-
"name": "empty",
|
|
26443
|
-
"description": "自定义 `empty` 内容。"
|
|
26444
|
-
}
|
|
26445
|
-
],
|
|
26446
|
-
"methods": [],
|
|
26447
|
-
"examples": [
|
|
26448
|
-
{
|
|
26449
|
-
"id": "引入-1",
|
|
26450
|
-
"section": "引入",
|
|
26451
|
-
"sectionId": "引入",
|
|
26452
|
-
"lang": "ts",
|
|
26453
|
-
"preview": false,
|
|
26454
|
-
"code": "import { MTreeTable } from 'morya-ui'",
|
|
26455
|
-
"locale": "zh-CN"
|
|
26456
|
-
},
|
|
26457
|
-
{
|
|
26458
|
-
"id": "基础用法-1",
|
|
26459
|
-
"section": "基础用法",
|
|
26460
|
-
"sectionId": "基础用法",
|
|
26461
|
-
"lang": "vue",
|
|
26462
|
-
"preview": true,
|
|
26463
|
-
"code": "<script setup lang=\"ts\">\nimport { MTreeTable } from 'morya-ui'\n\nconst columns = [\n { field: 'name', header: '名称' },\n { field: 'size', header: '大小' },\n]\nconst value = [\n {\n key: '0',\n data: { name: '应用', size: '100kb' },\n children: [\n { key: '0-0', data: { name: 'Vue', size: '25kb' } },\n { key: '0-1', data: { name: 'React', size: '30kb' } },\n ],\n },\n]\n</script>\n\n<template>\n <MTreeTable :value=\"value\" :columns=\"columns\" />\n</template>",
|
|
26464
|
-
"locale": "zh-CN"
|
|
26465
|
-
},
|
|
26466
|
-
{
|
|
26467
|
-
"id": "类型-1",
|
|
26468
|
-
"section": "类型",
|
|
26469
|
-
"sectionId": "类型",
|
|
26470
|
-
"lang": "ts",
|
|
26471
|
-
"preview": false,
|
|
26472
|
-
"code": "interface TreeTableColumn {\n field: string\n header: string\n}",
|
|
26473
|
-
"locale": "zh-CN"
|
|
26474
|
-
},
|
|
26475
|
-
{
|
|
26476
|
-
"id": "类型-2",
|
|
26477
|
-
"section": "类型",
|
|
26478
|
-
"sectionId": "类型",
|
|
26479
|
-
"lang": "ts",
|
|
26480
|
-
"preview": false,
|
|
26481
|
-
"code": "interface TreeTableNode {\n key: string\n data: Record<string, unknown>\n children?: TreeTableNode[]\n}",
|
|
26482
|
-
"locale": "zh-CN"
|
|
26483
|
-
},
|
|
26484
|
-
{
|
|
26485
|
-
"id": "import-1",
|
|
26486
|
-
"section": "Import",
|
|
26487
|
-
"sectionId": "import",
|
|
26488
|
-
"lang": "ts",
|
|
26489
|
-
"preview": false,
|
|
26490
|
-
"code": "import { MTreeTable } from 'morya-ui'",
|
|
26491
|
-
"locale": "en-US"
|
|
26492
|
-
},
|
|
26493
|
-
{
|
|
26494
|
-
"id": "basic-1",
|
|
26495
|
-
"section": "Basic",
|
|
26496
|
-
"sectionId": "basic",
|
|
26497
|
-
"lang": "vue",
|
|
26498
|
-
"preview": true,
|
|
26499
|
-
"code": "<script setup lang=\"ts\">\nimport { MTreeTable } from 'morya-ui'\n\nconst columns = [\n { field: 'name', header: 'Name' },\n { field: 'size', header: 'Size' },\n]\nconst value = [\n {\n key: '0',\n data: { name: 'Applications', size: '100kb' },\n children: [\n { key: '0-0', data: { name: 'Vue', size: '25kb' } },\n { key: '0-1', data: { name: 'React', size: '30kb' } },\n ],\n },\n]\n</script>\n\n<template>\n <MTreeTable :value=\"value\" :columns=\"columns\" />\n</template>",
|
|
26500
|
-
"locale": "en-US"
|
|
26501
|
-
},
|
|
26502
|
-
{
|
|
26503
|
-
"id": "types-1",
|
|
26504
|
-
"section": "Types",
|
|
26505
|
-
"sectionId": "types",
|
|
26506
|
-
"lang": "ts",
|
|
26507
|
-
"preview": false,
|
|
26508
|
-
"code": "interface TreeTableColumn {\n field: string\n header: string\n}",
|
|
26509
|
-
"locale": "en-US"
|
|
26510
|
-
},
|
|
26511
|
-
{
|
|
26512
|
-
"id": "types-2",
|
|
26513
|
-
"section": "Types",
|
|
26514
|
-
"sectionId": "types",
|
|
26515
|
-
"lang": "ts",
|
|
26516
|
-
"preview": false,
|
|
26517
|
-
"code": "interface TreeTableNode {\n key: string\n data: Record<string, unknown>\n children?: TreeTableNode[]\n}",
|
|
26518
|
-
"locale": "en-US"
|
|
26519
|
-
}
|
|
26520
|
-
],
|
|
26521
|
-
"locales": {
|
|
26522
|
-
"zh-CN": {
|
|
26523
|
-
"title": "TreeTable",
|
|
26524
|
-
"description": "可展开的树形表格。",
|
|
26525
|
-
"sections": [
|
|
26526
|
-
{
|
|
26527
|
-
"id": "overview",
|
|
26528
|
-
"title": "",
|
|
26529
|
-
"body": "# TreeTable\n\n用列配置展示带 children 的树形数据。"
|
|
26530
|
-
},
|
|
26531
|
-
{
|
|
26532
|
-
"id": "引入",
|
|
26533
|
-
"title": "引入",
|
|
26534
|
-
"body": "```ts\nimport { MTreeTable } from 'morya-ui'\n```"
|
|
26535
|
-
},
|
|
26536
|
-
{
|
|
26537
|
-
"id": "基础用法",
|
|
26538
|
-
"title": "基础用法",
|
|
26539
|
-
"body": "```vue preview src=\"./demos/Basic.zh.vue\"\n```"
|
|
26540
|
-
},
|
|
26541
|
-
{
|
|
26542
|
-
"id": "props",
|
|
26543
|
-
"title": "Props",
|
|
26544
|
-
"body": "| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `value` | `TreeTableNode[]` | — | 树形行数据。 |\n| `columns` | `TreeTableColumn[]` | — | 列定义。 |\n| `emptyMessage` | `string` | — | — |\n| `expandedKeys` | `Record<string, boolean>` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |"
|
|
26545
|
-
},
|
|
26546
|
-
{
|
|
26547
|
-
"id": "events",
|
|
26548
|
-
"title": "Events",
|
|
26549
|
-
"body": "| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `node-expand` | `TreeTableNode` | 节点展开。 |\n| `node-collapse` | `TreeTableNode` | 节点折叠。 |\n| `update:expandedKeys` | — | — |"
|
|
26550
|
-
},
|
|
26551
|
-
{
|
|
26552
|
-
"id": "slots",
|
|
26553
|
-
"title": "Slots",
|
|
26554
|
-
"body": "| 插槽名 | 说明 |\n| --- | --- |\n| `expansion` | 展开行 `{ row }`。 |\n| `empty` | 自定义 `empty` 内容。 |"
|
|
26555
|
-
},
|
|
26556
|
-
{
|
|
26557
|
-
"id": "类型",
|
|
26558
|
-
"title": "类型",
|
|
26559
|
-
"body": "<h4 id=\"TreeTableColumn\">TreeTableColumn</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ninterface TreeTableColumn {\n field: string\n header: string\n}\n```\n\n<h4 id=\"TreeTableNode\">TreeTableNode</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ninterface TreeTableNode {\n key: string\n data: Record<string, unknown>\n children?: TreeTableNode[]\n}\n```"
|
|
26560
|
-
}
|
|
26561
|
-
],
|
|
26562
|
-
"markdown": "---\ntitle: TreeTable\ncategory: 03 / DATA\ndescription: 可展开的树形表格。\n---\n\n# TreeTable\n\n用列配置展示带 children 的树形数据。\n\n## 引入\n\n```ts\nimport { MTreeTable } from 'morya-ui'\n```\n\n## 基础用法\n\n```vue preview src=\"./demos/Basic.zh.vue\"\n```\n\n## Props\n\n| 参数 | 类型 | 默认值 | 说明 |\n| --- | --- | --- | --- |\n| `value` | `TreeTableNode[]` | — | 树形行数据。 |\n| `columns` | `TreeTableColumn[]` | — | 列定义。 |\n| `emptyMessage` | `string` | — | — |\n| `expandedKeys` | `Record<string, boolean>` | — | — |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | DOM 透传,见 [样式与 attrs](/docs/attrs). |\n\n\n## Events\n\n| 事件名 | 参数 | 说明 |\n| --- | --- | --- |\n| `node-expand` | `TreeTableNode` | 节点展开。 |\n| `node-collapse` | `TreeTableNode` | 节点折叠。 |\n| `update:expandedKeys` | — | — |\n\n## Slots\n\n| 插槽名 | 说明 |\n| --- | --- |\n| `expansion` | 展开行 `{ row }`。 |\n| `empty` | 自定义 `empty` 内容。 |\n\n## 类型\n\n<h4 id=\"TreeTableColumn\">TreeTableColumn</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ninterface TreeTableColumn {\n field: string\n header: string\n}\n```\n\n<h4 id=\"TreeTableNode\">TreeTableNode</h4>\n\n完整定义见源码 `types.ts`。\n\n```ts\ninterface TreeTableNode {\n key: string\n data: Record<string, unknown>\n children?: TreeTableNode[]\n}\n```\n"
|
|
26563
|
-
},
|
|
26564
|
-
"en-US": {
|
|
26565
|
-
"title": "TreeTable",
|
|
26566
|
-
"description": "Expandable tree table.",
|
|
26567
|
-
"sections": [
|
|
26568
|
-
{
|
|
26569
|
-
"id": "overview",
|
|
26570
|
-
"title": "",
|
|
26571
|
-
"body": "# TreeTable\n\nDisplay tree data with children using column configuration."
|
|
26572
|
-
},
|
|
26573
|
-
{
|
|
26574
|
-
"id": "import",
|
|
26575
|
-
"title": "Import",
|
|
26576
|
-
"body": "```ts\nimport { MTreeTable } from 'morya-ui'\n```"
|
|
26577
|
-
},
|
|
26578
|
-
{
|
|
26579
|
-
"id": "basic",
|
|
26580
|
-
"title": "Basic",
|
|
26581
|
-
"body": "```vue preview src=\"./demos/Basic.en.vue\"\n```"
|
|
26582
|
-
},
|
|
26583
|
-
{
|
|
26584
|
-
"id": "props",
|
|
26585
|
-
"title": "Props",
|
|
26586
|
-
"body": "| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `value` | `TreeTableNode[]` | — | Tree row data. |\n| `columns` | `TreeTableColumn[]` | — | Column definitions. |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |"
|
|
26587
|
-
},
|
|
26588
|
-
{
|
|
26589
|
-
"id": "events",
|
|
26590
|
-
"title": "Events",
|
|
26591
|
-
"body": "| Event | Prop | Description |\n| --- | --- | --- |\n| `node-expand` | `TreeTableNode` | Emitted when a node expands. |\n| `node-collapse` | `TreeTableNode` | Emitted when a node collapses. |"
|
|
26592
|
-
},
|
|
26593
|
-
{
|
|
26594
|
-
"id": "slots",
|
|
26595
|
-
"title": "Slots",
|
|
26596
|
-
"body": "| Slot | Description |\n| --- | --- |\n| `expansion` | Expanded row `{ row }`. |"
|
|
26597
|
-
},
|
|
26598
|
-
{
|
|
26599
|
-
"id": "types",
|
|
26600
|
-
"title": "Types",
|
|
26601
|
-
"body": "<h4 id=\"TreeTableColumn\">TreeTableColumn</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ninterface TreeTableColumn {\n field: string\n header: string\n}\n```\n\n<h4 id=\"TreeTableNode\">TreeTableNode</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ninterface TreeTableNode {\n key: string\n data: Record<string, unknown>\n children?: TreeTableNode[]\n}\n```"
|
|
26602
|
-
}
|
|
26603
|
-
],
|
|
26604
|
-
"markdown": "---\ntitle: TreeTable\ncategory: 03 / DATA\ndescription: Expandable tree table.\n---\n\n# TreeTable\n\nDisplay tree data with children using column configuration.\n\n## Import\n\n```ts\nimport { MTreeTable } from 'morya-ui'\n```\n\n## Basic\n\n```vue preview src=\"./demos/Basic.en.vue\"\n```\n\n## Props\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `value` | `TreeTableNode[]` | — | Tree row data. |\n| `columns` | `TreeTableColumn[]` | — | Column definitions. |\n| `pt` | [RootPassThrough](/docs/types#RootPassThrough) `{ root? }` | — | Pass-through; see [Styling & attrs](/docs/attrs). |\n\n\n## Events\n\n| Event | Prop | Description |\n| --- | --- | --- |\n| `node-expand` | `TreeTableNode` | Emitted when a node expands. |\n| `node-collapse` | `TreeTableNode` | Emitted when a node collapses. |\n\n## Slots\n\n| Slot | Description |\n| --- | --- |\n| `expansion` | Expanded row `{ row }`. |\n\n## Types\n\n<h4 id=\"TreeTableColumn\">TreeTableColumn</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ninterface TreeTableColumn {\n field: string\n header: string\n}\n```\n\n<h4 id=\"TreeTableNode\">TreeTableNode</h4>\n\nSee source `types.ts` for the full definition.\n\n```ts\ninterface TreeTableNode {\n key: string\n data: Record<string, unknown>\n children?: TreeTableNode[]\n}\n```\n"
|
|
26605
|
-
}
|
|
26606
|
-
}
|
|
26607
|
-
},
|
|
26608
26706
|
{
|
|
26609
26707
|
"id": "VirtualScroller",
|
|
26610
26708
|
"name": "VirtualScroller",
|