@opentiny/tiny-vue-mcp 0.0.1-beta.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -8,13 +8,14 @@ export declare const createMcpTools: (instance: any, { server, business }: {
8
8
  server: McpServer;
9
9
  business: Business;
10
10
  }, componentMcpConfig: ComponentMcpConfig) => void;
11
- export declare const getTinyVueMcpConfig: ({ t, }: {
12
- t: ((path: string) => string) | null;
11
+ export declare const getTinyVueMcpConfig: ({ t }?: {
12
+ t?: ((path: string) => string) | null;
13
13
  }) => {
14
14
  name: string;
15
15
  version: string;
16
16
  components: {
17
17
  Grid: import('./src/utils/defineComponentTool').RealComponentTool;
18
18
  BaseSelect: import('./src/utils/defineComponentTool').RealComponentTool;
19
+ Button: import('./src/utils/defineComponentTool').RealComponentTool;
19
20
  };
20
21
  };
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- import { defineTool as n } from "./src/utils/defineTool.js";
2
- import { default as C } from "./src/lang/zh-CN.js";
3
- import { default as S } from "./src/lang/en.js";
1
+ import { defineTool as i } from "./src/utils/defineTool.js";
2
+ import { default as x } from "./src/lang/zh-CN.js";
3
+ import { default as T } from "./src/lang/en.js";
4
4
  import { getGridConfig as f } from "./src/grid/index.js";
5
5
  import { getBaseSelectConfig as m } from "./src/base-select/index.js";
6
- import { i18n as o } from "./src/utils/locale.js";
7
- const g = (e, { server: t, business: r }, i) => {
8
- n({ business: r, componentMcpConfig: i, instance: e, server: t });
9
- }, l = ({
10
- t: e
11
- }) => (o && (o.t = e), {
6
+ import { i18n as e } from "./src/utils/locale.js";
7
+ import { getButtonConfig as p } from "./src/button/index.js";
8
+ const l = (o, { server: t, business: r }, n) => {
9
+ i({ business: r, componentMcpConfig: n, instance: o, server: t });
10
+ }, d = ({ t: o } = {}) => (e && o && (e.t = o), {
12
11
  name: "tiny-vue-mcp",
13
12
  version: "0.0.1",
14
13
  components: {
15
14
  Grid: f(),
16
- BaseSelect: m()
15
+ BaseSelect: m(),
16
+ Button: p()
17
17
  }
18
18
  });
19
19
  export {
20
- g as createMcpTools,
21
- S as enUS,
22
- l as getTinyVueMcpConfig,
23
- o as i18n,
24
- C as zhCN
20
+ l as createMcpTools,
21
+ T as enUS,
22
+ d as getTinyVueMcpConfig,
23
+ e as i18n,
24
+ x as zhCN
25
25
  };
@@ -1,16 +1,37 @@
1
- import { z as s } from "zod";
2
- import { defineComponentTool as n } from "../utils/defineComponentTool.js";
3
- import { t as e } from "../utils/locale.js";
4
- const a = () => n({
1
+ import { z as c } from "zod";
2
+ import { defineComponentTool as l } from "../utils/defineComponentTool.js";
3
+ import { t as s } from "../utils/locale.js";
4
+ const b = () => l({
5
5
  name: "base_select_component_tools",
6
- description: e("ai.baseSelect.description"),
6
+ description: s("ai.baseSelect.description"),
7
7
  tools: {
8
8
  openMenu: {
9
- paramsSchema: s.boolean().describe(e("ai.baseSelect.openMenu")),
10
- cb: (o, t) => (o.state.visible = t, { type: "text", text: "success" })
9
+ paramsSchema: c.boolean().describe(s("ai.baseSelect.openMenu")),
10
+ cb: (e, t) => (e.state.visible = t, { type: "text", text: "success" })
11
+ },
12
+ selectByLabel: {
13
+ paramsSchema: c.string().describe(s("ai.baseSelect.selectByLabel")),
14
+ cb: (e, t) => {
15
+ const a = (e.state.cachedOptions || []).find((o) => o.label === t);
16
+ return a ? (e.updateModelValue(a.value), { type: "text", text: "success" }) : { type: "text", text: `Option with label "${t}" not found.` };
17
+ }
18
+ },
19
+ clearValue: {
20
+ paramsSchema: c.string().describe(s("ai.baseSelect.clearValue")),
21
+ cb: (e, t) => (e.updateModelValue(""), { type: "text", text: "success" })
22
+ },
23
+ getOptions: {
24
+ paramsSchema: c.string().describe(s("ai.baseSelect.getOptions")),
25
+ cb: (e, t) => {
26
+ const a = (e.state.cachedOptions || []).map((o) => ({
27
+ label: o.label,
28
+ value: o.value
29
+ }));
30
+ return { type: "text", text: JSON.stringify(a) };
31
+ }
11
32
  }
12
33
  }
13
34
  });
14
35
  export {
15
- a as getBaseSelectConfig
36
+ b as getBaseSelectConfig
16
37
  };
@@ -0,0 +1,5 @@
1
+ export declare const resources: {
2
+ zh: any;
3
+ en: any;
4
+ };
5
+ export declare const getButtonConfig: () => import('../utils/defineComponentTool').RealComponentTool;
@@ -0,0 +1,16 @@
1
+ import { z as i } from "zod";
2
+ import { defineComponentTool as n } from "../utils/defineComponentTool.js";
3
+ import { t } from "../utils/locale.js";
4
+ const p = () => n({
5
+ name: "button_component_tools",
6
+ description: t("ai.button.description"),
7
+ tools: {
8
+ triggerClick: {
9
+ paramsSchema: i.boolean().describe(t("ai.button.triggerClick")),
10
+ cb: (o, e) => (o.handleClick(e), { type: "text", text: "success" })
11
+ }
12
+ }
13
+ });
14
+ export {
15
+ p as getButtonConfig
16
+ };
@@ -1,36 +1,71 @@
1
- import { z as r } from "zod";
1
+ import { z as o } from "zod";
2
2
  import { defineComponentTool as s } from "../utils/defineComponentTool.js";
3
3
  import { t as a } from "../utils/locale.js";
4
4
  const p = () => s({
5
5
  name: "grid_component_tools",
6
6
  description: a("ai.grid.description"),
7
7
  tools: {
8
- scollToRow: {
9
- paramsSchema: r.number().optional().describe(a("ai.grid.scrollToRow")),
10
- cb: (t, e) => {
11
- const o = t.getData()[e];
12
- if (o)
13
- return t.scrollToRow(o), { type: "text", text: "success" };
8
+ scrollToRow: {
9
+ paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.scrollToRow")),
10
+ cb: (e, t) => {
11
+ const r = e.getRowById(t._RID);
12
+ if (r)
13
+ return e.scrollToRow(r), { type: "text", text: "success" };
14
+ }
15
+ },
16
+ getColumns: {
17
+ paramsSchema: o.boolean().optional().describe(a("ai.grid.getColumns")),
18
+ cb: (e) => {
19
+ const r = e.getColumns().filter((i) => i.property && i.title).map((i) => ({
20
+ property: i.property,
21
+ title: i.title
22
+ }));
23
+ return { type: "text", text: JSON.stringify(r) };
14
24
  }
15
25
  },
16
26
  getTableData: {
17
- paramsSchema: r.boolean().optional().describe(a("ai.grid.getTableData")),
18
- cb: (t) => {
19
- const e = t.getData();
20
- return { type: "text", text: JSON.stringify(e) };
27
+ paramsSchema: o.boolean().optional().describe(a("ai.grid.getTableData")),
28
+ cb: (e) => {
29
+ const t = e.getTableData().tableData;
30
+ return { type: "text", text: JSON.stringify(t) };
21
31
  }
22
32
  },
23
33
  setSelection: {
24
- paramsSchema: r.number().optional().describe(a("ai.grid.setSelection")),
25
- cb: (t, e) => {
26
- const o = t.getData()[e];
27
- if (o)
28
- return t.setSelection(o, !0), { type: "text", text: "success" };
34
+ paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.setSelection")),
35
+ cb: (e, t) => {
36
+ const r = e.getRowById(t._RID);
37
+ if (r)
38
+ return e.setSelection(r, !0), { type: "text", text: "success" };
29
39
  }
30
40
  },
31
41
  setAllSelection: {
32
- paramsSchema: r.boolean().optional().describe(a("ai.grid.setAllSelection")),
33
- cb: (t, e) => (t.setAllSelection(e), { type: "text", text: "success" })
42
+ paramsSchema: o.boolean().optional().describe(a("ai.grid.setAllSelection")),
43
+ cb: (e, t) => (e.setAllSelection(t), { type: "text", text: "success" })
44
+ },
45
+ insertRow: {
46
+ paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.insertRow")),
47
+ cb: (e, t) => (e.insert(t), { type: "text", text: "success" })
48
+ },
49
+ updateRow: {
50
+ paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.updateRow")),
51
+ cb: (e, t) => {
52
+ if (t) {
53
+ const r = e.getRowById(t._RID);
54
+ if (r)
55
+ return Object.assign(r, t), { type: "text", text: "success" };
56
+ }
57
+ return { type: "text", text: "failed" };
58
+ }
59
+ },
60
+ removeRow: {
61
+ paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.removeRow")),
62
+ cb: (e, t) => {
63
+ if (t) {
64
+ const r = e.getRowById(t._RID);
65
+ return e.remove(r), { type: "text", text: "success" };
66
+ }
67
+ return { type: "text", text: "failed" };
68
+ }
34
69
  }
35
70
  }
36
71
  });
@@ -4,12 +4,23 @@ declare const _default: {
4
4
  description: string;
5
5
  scrollToRow: string;
6
6
  getTableData: string;
7
+ getColumns: string;
7
8
  setSelection: string;
8
9
  setAllSelection: string;
10
+ insertRow: string;
11
+ updateRow: string;
12
+ removeRow: string;
9
13
  };
10
14
  baseSelect: {
11
15
  description: string;
12
16
  openMenu: string;
17
+ selectByLabel: string;
18
+ clearValue: string;
19
+ getOptions: string;
20
+ };
21
+ button: {
22
+ description: string;
23
+ triggerClick: string;
13
24
  };
14
25
  };
15
26
  };
@@ -1,15 +1,26 @@
1
1
  const e = {
2
2
  ai: {
3
3
  grid: {
4
- description: "Grid component related tool set, including scrolling to the specified row, table full selection, etc.",
5
- scrollToRow: "Scroll to the specified row,need to get the table data first,then scroll to the row according to the index of the data in the table data",
6
- getTableData: "Get the table data",
7
- setSelection: "Select the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting",
8
- setAllSelection: "Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting"
4
+ description: "Grid component related tool set, including scrolling to specified row, table full selection and other functions",
5
+ scrollToRow: 'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
6
+ getTableData: "Get table data",
7
+ getColumns: 'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
8
+ setSelection: 'Select a row in the table, need to pass the data to be selected, requirement: scroll to the row before selecting, requirement: the data must contain the "_RID" field',
9
+ setAllSelection: "Set table full selection status, true: select all, false: cancel all selection",
10
+ insertRow: "Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format",
11
+ updateRow: 'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
12
+ removeRow: 'Remove specified row in the table, need to pass the data to be removed, requirement: the data must contain the "_RID" field'
9
13
  },
10
14
  baseSelect: {
11
- description: "Base select component related tool set, including opening the drop-down panel",
12
- openMenu: "Open the drop-down panel"
15
+ description: "Dropdown component related tool set, including getting dropdown data, selecting dropdown data, clearing selected value and other functions",
16
+ openMenu: "Open dropdown panel",
17
+ selectByLabel: "Select dropdown data by label",
18
+ clearValue: "Clear dropdown value",
19
+ getOptions: "Query all option values of the dropdown select"
20
+ },
21
+ button: {
22
+ description: "Button component related tool set",
23
+ triggerClick: "Button click, click the button"
13
24
  }
14
25
  }
15
26
  };
@@ -4,12 +4,23 @@ declare const _default: {
4
4
  description: string;
5
5
  scrollToRow: string;
6
6
  getTableData: string;
7
+ getColumns: string;
7
8
  setSelection: string;
8
9
  setAllSelection: string;
10
+ insertRow: string;
11
+ updateRow: string;
12
+ removeRow: string;
9
13
  };
10
14
  baseSelect: {
11
15
  description: string;
12
16
  openMenu: string;
17
+ selectByLabel: string;
18
+ clearValue: string;
19
+ getOptions: string;
20
+ };
21
+ button: {
22
+ description: string;
23
+ triggerClick: string;
13
24
  };
14
25
  };
15
26
  };
@@ -2,14 +2,25 @@ const e = {
2
2
  ai: {
3
3
  grid: {
4
4
  description: "表格组件相关工具集合,包含滚动到指定行、表格全选等功能",
5
- scrollToRow: "滚动到指定行,要先获取表格数据,然后根据表格数据中的索引确定滚动行",
5
+ scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
6
6
  getTableData: "获取表格数据",
7
- setSelection: "选中表格一条数据,需要先获取表格数据,然后根据表格数据中的索引选中数据,要求:选中之前先滚动到选中行",
8
- setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选"
7
+ getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
8
+ setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求:选中之前先滚动到选中行,要求数据中包含"_RID"字段',
9
+ setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选",
10
+ insertRow: "插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据",
11
+ updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
12
+ removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
9
13
  },
10
14
  baseSelect: {
11
- description: "下拉组件相关工具集合,包含获取下拉数据、选中下拉数据等功能",
12
- openMenu: "打开下拉面板"
15
+ description: "下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能",
16
+ openMenu: "打开下拉面板",
17
+ selectByLabel: "根据标签选中下拉数据",
18
+ clearValue: "清除下拉值",
19
+ getOptions: "查询下拉选择的所有选项值"
20
+ },
21
+ button: {
22
+ description: "按钮组件相关工具集合",
23
+ triggerClick: "按钮点击,点击按钮"
13
24
  }
14
25
  }
15
26
  };
package/index.ts CHANGED
@@ -1,37 +1,35 @@
1
- import { defineTool } from "./src/utils/defineTool";
2
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import type { Business, ComponentMcpConfig } from "./src/utils/defineTool";
4
- import zhCN from "./src/lang/zh-CN";
5
- import enUS from "./src/lang/en";
6
- import { getGridConfig } from "./src/grid";
7
- import { getBaseSelectConfig } from "./src/base-select";
8
- import { i18n } from "./src/utils/locale";
1
+ import { defineTool } from './src/utils/defineTool'
2
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3
+ import type { Business, ComponentMcpConfig } from './src/utils/defineTool'
4
+ import zhCN from './src/lang/zh-CN'
5
+ import enUS from './src/lang/en'
6
+ import { getGridConfig } from './src/grid'
7
+ import { getBaseSelectConfig } from './src/base-select'
8
+ import { i18n } from './src/utils/locale'
9
+ import { getButtonConfig } from './src/button'
9
10
 
10
- export { zhCN, enUS, i18n };
11
+ export { zhCN, enUS, i18n }
11
12
 
12
13
  export const createMcpTools = (
13
14
  instance: any,
14
15
  { server, business }: { server: McpServer; business: Business },
15
16
  componentMcpConfig: ComponentMcpConfig
16
17
  ) => {
17
- defineTool({ business, componentMcpConfig, instance, server });
18
- };
18
+ defineTool({ business, componentMcpConfig, instance, server })
19
+ }
19
20
 
20
- export const getTinyVueMcpConfig = ({
21
- t,
22
- }: {
23
- t: ((path: string) => string) | null;
24
- }) => {
25
- if (i18n) {
26
- i18n.t = t;
21
+ export const getTinyVueMcpConfig = ({ t }: { t?: ((path: string) => string) | null } = {}) => {
22
+ if (i18n && t) {
23
+ i18n.t = t
27
24
  }
28
25
 
29
26
  return {
30
- name: "tiny-vue-mcp",
31
- version: "0.0.1",
27
+ name: 'tiny-vue-mcp',
28
+ version: '0.0.1',
32
29
  components: {
33
30
  Grid: getGridConfig(),
34
31
  BaseSelect: getBaseSelectConfig(),
35
- },
36
- };
37
- };
32
+ Button: getButtonConfig()
33
+ }
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-vue-mcp",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -20,6 +20,40 @@ export const getBaseSelectConfig = () =>
20
20
  instance.state.visible = value
21
21
  return { type: 'text', text: 'success' }
22
22
  }
23
+ },
24
+ selectByLabel: {
25
+ paramsSchema: z.string().describe(t('ai.baseSelect.selectByLabel')),
26
+
27
+ cb: (instance, value) => {
28
+ const options = instance.state.cachedOptions || []
29
+ const targetOption = options.find((option) => option.label === value)
30
+ if (targetOption) {
31
+ instance.updateModelValue(targetOption.value)
32
+ return { type: 'text', text: 'success' }
33
+ } else {
34
+ return { type: 'text', text: `Option with label "${value}" not found.` }
35
+ }
36
+ }
37
+ },
38
+ clearValue: {
39
+ paramsSchema: z.string().describe(t('ai.baseSelect.clearValue')),
40
+
41
+ cb: (instance, value) => {
42
+ instance.updateModelValue('')
43
+ return { type: 'text', text: 'success' }
44
+ }
45
+ },
46
+ getOptions: {
47
+ paramsSchema: z.string().describe(t('ai.baseSelect.getOptions')),
48
+
49
+ cb: (instance, value) => {
50
+ const options = instance.state.cachedOptions || []
51
+ const cleanOptions = options.map((option) => ({
52
+ label: option.label,
53
+ value: option.value
54
+ }))
55
+ return { type: 'text', text: JSON.stringify(cleanOptions) }
56
+ }
23
57
  }
24
58
  }
25
59
  })
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod'
2
+ import { defineComponentTool } from '../utils/defineComponentTool'
3
+ import resourcesZh from './resouces.zh.md?raw'
4
+ import resourcesEn from './resouces.en.md?raw'
5
+ import { t } from '../utils/locale'
6
+
7
+ export const resources = {
8
+ zh: resourcesZh,
9
+ en: resourcesEn
10
+ }
11
+
12
+ export const getButtonConfig = () =>
13
+ defineComponentTool({
14
+ name: 'button_component_tools',
15
+ description: t('ai.button.description'),
16
+ tools: {
17
+ triggerClick: {
18
+ paramsSchema: z.boolean().describe(t('ai.button.triggerClick')),
19
+ cb: (instance, value) => {
20
+ instance.handleClick(value)
21
+ return { type: 'text', text: 'success' }
22
+ }
23
+ }
24
+ }
25
+ })
@@ -0,0 +1,3 @@
1
+ # Button
2
+
3
+ Button component
@@ -0,0 +1,3 @@
1
+ # Button 按钮组件
2
+
3
+ Button 是标准的按钮组件。
package/src/grid/index.ts CHANGED
@@ -1,60 +1,97 @@
1
- import { z } from "zod";
2
- import { defineComponentTool } from "../utils/defineComponentTool";
3
- import resourcesZh from "./resouces.zh.md?raw";
4
- import resourcesEn from "./resouces.en.md?raw";
5
- import { t } from "../utils/locale";
1
+ import { z } from 'zod'
2
+ import { defineComponentTool } from '../utils/defineComponentTool'
3
+ import resourcesZh from './resouces.zh.md?raw'
4
+ import resourcesEn from './resouces.en.md?raw'
5
+ import { t } from '../utils/locale'
6
6
 
7
7
  export const resources = {
8
8
  zh: resourcesZh,
9
- en: resourcesEn,
10
- };
9
+ en: resourcesEn
10
+ }
11
11
 
12
12
  export const getGridConfig = () =>
13
13
  defineComponentTool({
14
- name: "grid_component_tools",
15
- description: t("ai.grid.description"),
14
+ name: 'grid_component_tools',
15
+ description: t('ai.grid.description'),
16
16
  tools: {
17
- scollToRow: {
18
- paramsSchema: z.number().optional().describe(t("ai.grid.scrollToRow")),
17
+ scrollToRow: {
18
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.scrollToRow')),
19
19
  cb: (instance, value) => {
20
- const tableData = instance.getData();
21
- const targetRow = tableData[value];
20
+ const targetRow = instance.getRowById(value._RID)
22
21
  if (targetRow) {
23
- instance.scrollToRow(targetRow);
24
- return { type: "text", text: "success" };
22
+ instance.scrollToRow(targetRow)
23
+ return { type: 'text', text: 'success' }
25
24
  }
26
- },
25
+ }
26
+ },
27
+ getColumns: {
28
+ paramsSchema: z.boolean().optional().describe(t('ai.grid.getColumns')),
29
+ cb: (instance) => {
30
+ const columns = instance.getColumns()
31
+ const result = columns
32
+ .filter((col: any) => col.property && col.title)
33
+ .map((column: any) => ({
34
+ property: column.property,
35
+ title: column.title
36
+ }))
37
+ return { type: 'text', text: JSON.stringify(result) }
38
+ }
27
39
  },
28
40
  getTableData: {
29
- paramsSchema: z
30
- .boolean()
31
- .optional()
32
- .describe(t("ai.grid.getTableData")),
41
+ paramsSchema: z.boolean().optional().describe(t('ai.grid.getTableData')),
33
42
  cb: (instance) => {
34
- const tableData = instance.getData();
35
- return { type: "text", text: JSON.stringify(tableData) };
36
- },
43
+ const tableData = instance.getTableData().tableData
44
+
45
+ return { type: 'text', text: JSON.stringify(tableData) }
46
+ }
37
47
  },
38
48
  setSelection: {
39
- paramsSchema: z.number().optional().describe(t("ai.grid.setSelection")),
49
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.setSelection')),
40
50
  cb: (instance, value) => {
41
- const tableData = instance.getData();
42
- const targetRow = tableData[value];
51
+ const targetRow = instance.getRowById(value._RID)
43
52
  if (targetRow) {
44
- instance.setSelection(targetRow, true);
45
- return { type: "text", text: "success" };
53
+ instance.setSelection(targetRow, true)
54
+ return { type: 'text', text: 'success' }
46
55
  }
47
- },
56
+ }
48
57
  },
49
58
  setAllSelection: {
50
- paramsSchema: z
51
- .boolean()
52
- .optional()
53
- .describe(t("ai.grid.setAllSelection")),
59
+ paramsSchema: z.boolean().optional().describe(t('ai.grid.setAllSelection')),
60
+ cb: (instance, value) => {
61
+ instance.setAllSelection(value)
62
+ return { type: 'text', text: 'success' }
63
+ }
64
+ },
65
+ insertRow: {
66
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.insertRow')),
54
67
  cb: (instance, value) => {
55
- instance.setAllSelection(value);
56
- return { type: "text", text: "success" };
57
- },
68
+ instance.insert(value)
69
+ return { type: 'text', text: 'success' }
70
+ }
58
71
  },
59
- },
60
- });
72
+ updateRow: {
73
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.updateRow')),
74
+ cb: (instance, value) => {
75
+ if (value) {
76
+ const targetRow = instance.getRowById(value._RID)
77
+ if (targetRow) {
78
+ Object.assign(targetRow, value)
79
+ return { type: 'text', text: 'success' }
80
+ }
81
+ }
82
+ return { type: 'text', text: 'failed' }
83
+ }
84
+ },
85
+ removeRow: {
86
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.removeRow')),
87
+ cb: (instance, value) => {
88
+ if (value) {
89
+ const row = instance.getRowById(value._RID)
90
+ instance.remove(row)
91
+ return { type: 'text', text: 'success' }
92
+ }
93
+ return { type: 'text', text: 'failed' }
94
+ }
95
+ }
96
+ }
97
+ })
package/src/lang/en.ts CHANGED
@@ -2,18 +2,33 @@ export default {
2
2
  ai: {
3
3
  grid: {
4
4
  description:
5
- 'Grid component related tool set, including scrolling to the specified row, table full selection, etc.',
5
+ 'Grid component related tool set, including scrolling to specified row, table full selection and other functions',
6
6
  scrollToRow:
7
- 'Scroll to the specified row,need to get the table data first,then scroll to the row according to the index of the data in the table data',
8
- getTableData: 'Get the table data',
7
+ 'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
8
+ getTableData: 'Get table data',
9
+ getColumns:
10
+ 'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
9
11
  setSelection:
10
- 'Select the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting',
11
- setAllSelection:
12
- 'Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting'
12
+ 'Select a row in the table, need to pass the data to be selected, requirement: scroll to the row before selecting, requirement: the data must contain the "_RID" field',
13
+ setAllSelection: 'Set table full selection status, true: select all, false: cancel all selection',
14
+ insertRow:
15
+ 'Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format',
16
+ updateRow:
17
+ 'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
18
+ removeRow:
19
+ 'Remove specified row in the table, need to pass the data to be removed, requirement: the data must contain the "_RID" field'
13
20
  },
14
21
  baseSelect: {
15
- description: 'Base select component related tool set, including opening the drop-down panel',
16
- openMenu: 'Open the drop-down panel'
22
+ description:
23
+ 'Dropdown component related tool set, including getting dropdown data, selecting dropdown data, clearing selected value and other functions',
24
+ openMenu: 'Open dropdown panel',
25
+ selectByLabel: 'Select dropdown data by label',
26
+ clearValue: 'Clear dropdown value',
27
+ getOptions: 'Query all option values of the dropdown select'
28
+ },
29
+ button: {
30
+ description: 'Button component related tool set',
31
+ triggerClick: 'Button click, click the button'
17
32
  }
18
33
  }
19
34
  }
package/src/lang/zh-CN.ts CHANGED
@@ -2,15 +2,26 @@ export default {
2
2
  ai: {
3
3
  grid: {
4
4
  description: '表格组件相关工具集合,包含滚动到指定行、表格全选等功能',
5
- scrollToRow: '滚动到指定行,要先获取表格数据,然后根据表格数据中的索引确定滚动行',
5
+ scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
6
6
  getTableData: '获取表格数据',
7
+ getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
7
8
  setSelection:
8
- '选中表格一条数据,需要先获取表格数据,然后根据表格数据中的索引选中数据,要求:选中之前先滚动到选中行',
9
- setAllSelection: '用来设置表格全选状态,true:全选,false:取消全选'
9
+ '选中或者选择表格一条数据,需要传递需要选中的数据,要求:选中之前先滚动到选中行,要求数据中包含"_RID"字段',
10
+ setAllSelection: '用来设置表格全选状态,true:全选,false:取消全选',
11
+ insertRow: '插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据',
12
+ updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
13
+ removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
10
14
  },
11
15
  baseSelect: {
12
- description: '下拉组件相关工具集合,包含获取下拉数据、选中下拉数据等功能',
13
- openMenu: '打开下拉面板'
16
+ description: '下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能',
17
+ openMenu: '打开下拉面板',
18
+ selectByLabel: '根据标签选中下拉数据',
19
+ clearValue: '清除下拉值',
20
+ getOptions: '查询下拉选择的所有选项值'
21
+ },
22
+ button: {
23
+ description: '按钮组件相关工具集合',
24
+ triggerClick: '按钮点击,点击按钮'
14
25
  }
15
26
  }
16
27
  }
package/vite.config.ts CHANGED
@@ -1,29 +1,29 @@
1
- import { defineConfig } from "vite";
2
- import dts from "vite-plugin-dts";
1
+ import { defineConfig } from 'vite'
2
+ import dts from 'vite-plugin-dts'
3
3
 
4
4
  // https://vite.dev/config/
5
5
  export default defineConfig(() => {
6
6
  return {
7
7
  plugins: [
8
8
  // 生成类型声明文件
9
- dts(),
9
+ dts()
10
10
  ],
11
11
  // 库模式配置
12
12
  build: {
13
13
  lib: {
14
- entry: "./index.ts",
14
+ entry: './index.ts'
15
15
  },
16
16
  rollupOptions: {
17
- external: ["zod"],
18
- input: ["index.ts"],
17
+ external: ['zod'],
18
+ input: ['index.ts'],
19
19
  output: [
20
20
  {
21
- format: "es",
22
- entryFileNames: "[name].js",
23
- preserveModules: true,
24
- },
25
- ],
26
- },
27
- },
28
- };
29
- });
21
+ format: 'es',
22
+ entryFileNames: '[name].js',
23
+ preserveModules: true
24
+ }
25
+ ]
26
+ }
27
+ }
28
+ }
29
+ })