cnd-components-mcp
Version:
An MCP service for Cnd components query | 一个减少 Cnd 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询
66 lines (58 loc) • 1.33 kB
Markdown
```tsx preview
import React from "react";
import { KeyValue } from "@ali/cnd";
const Demo = () => {
return <KeyValue onChange={console.log} />;
};
export default Demo;
```
```tsx preview
import React from "react";
import { KeyValue } from "@ali/cnd";
const Demo = () => {
return <KeyValue value={[{ key: "a", value: 1 }]} onChange={console.log} />;
};
export default Demo;
```
```tsx preview
import React from "react";
import { KeyValue, Button, Field, Form } from "@ali/cnd";
const { customValidate } = KeyValue;
const FORM_LAYOUT = {
labelCol: {
fixedSpan: 6,
},
labelTextAlign: "left",
};
const Demo = () => {
const field = Field.useField();
const { init, validate } = field;
const onValidate = () => {
validate((errors, values) => {
if (errors) return;
});
};
return (
<Form field={field} {...FORM_LAYOUT}>
<Form.Item label="环境变量" required>
<KeyValue
{...init("env", {
rules: [
{
validator: customValidate,
},
],
})}
/>
</Form.Item>
<Button type="primary" onClick={onValidate}>
校验
</Button>
</Form>
);
};
export default Demo;
```