@morya-ui/mcp 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -67,206 +67,206 @@ function generatedPageCode(patternId, intent, locale) {
67
67
  const emptyImports = isEmpty ? ', MDataView' : '';
68
68
  const wizardImports = isWizard ? ', MStepper' : '';
69
69
  const settingsImports = isSettings ? ', MTabs' : '';
70
- const script = `<script setup lang="ts">
71
- import { ref } from 'vue'
72
- import { MButton, MCard, MConfigProvider, MInput, MTag, zhCN${layoutImports}${listImports}${formImports}${dashboardImports}${detailImports}${emptyImports}${wizardImports}${settingsImports} } from 'morya-ui'
73
-
74
- const loading = ref(false)
75
- const error = ref('')
76
- ${isList ? `const keyword = ref('')
77
- const rows = ref<Record<string, unknown>[]>([])
78
- const columns = [{ key: 'name', label: '${zh ? '名称' : 'Name'}' }, { key: 'status', label: '${zh ? '状态' : 'Status'}' }]
79
- ` : ''}${isForm || isAuth || isWizard ? `const model = ref({ name: '' })
80
- ` : ''}${isDashboard ? `const metrics = ref([
81
- { label: '${zh ? '总用户' : 'Users'}', value: '0' },
82
- { label: '${zh ? '今日活跃' : 'Active today'}', value: '0' },
83
- ])
84
- ` : ''}${isWizard ? `const activeStep = ref(0)
85
- ` : ''}
86
-
87
- async function submit() {
88
- loading.value = true
89
- error.value = ''
90
- try {
91
- // Replace with the page API request.
92
- } finally {
93
- loading.value = false
94
- }
95
- }
70
+ const script = `<script setup lang="ts">
71
+ import { ref } from 'vue'
72
+ import { MButton, MCard, MConfigProvider, MInput, MTag, zhCN${layoutImports}${listImports}${formImports}${dashboardImports}${detailImports}${emptyImports}${wizardImports}${settingsImports} } from 'morya-ui'
73
+
74
+ const loading = ref(false)
75
+ const error = ref('')
76
+ ${isList ? `const keyword = ref('')
77
+ const rows = ref<Record<string, unknown>[]>([])
78
+ const columns = [{ key: 'name', label: '${zh ? '名称' : 'Name'}' }, { key: 'status', label: '${zh ? '状态' : 'Status'}' }]
79
+ ` : ''}${isForm || isAuth || isWizard ? `const model = ref({ name: '' })
80
+ ` : ''}${isDashboard ? `const metrics = ref([
81
+ { label: '${zh ? '总用户' : 'Users'}', value: '0' },
82
+ { label: '${zh ? '今日活跃' : 'Active today'}', value: '0' },
83
+ ])
84
+ ` : ''}${isWizard ? `const activeStep = ref(0)
85
+ ` : ''}
86
+
87
+ async function submit() {
88
+ loading.value = true
89
+ error.value = ''
90
+ try {
91
+ // Replace with the page API request.
92
+ } finally {
93
+ loading.value = false
94
+ }
95
+ }
96
96
  </script>`;
97
- const listContent = ` <section class="m-generated-filters" aria-label="${zh ? '筛选' : 'Filters'}">
98
- <MSpace wrap>
99
- <MInput v-model="keyword" placeholder="${zh ? '搜索关键词' : 'Search keyword'}" clearable style="width: 14rem" />
100
- <MButton severity="primary">${zh ? '查询' : 'Search'}</MButton>
101
- <MButton severity="secondary">${zh ? '重置' : 'Reset'}</MButton>
102
- </MSpace>
103
- </section>
104
- <header class="m-generated-toolbar">
105
- <h1 class="m-generated-title">${title}</h1>
106
- <MButton severity="primary">${zh ? '新建' : 'Create'}</MButton>
107
- </header>
108
- <MTable :columns="columns" :rows="rows" :loading="loading" paginator :rows-per-page="10" striped bordered row-key="id">
109
- <template #empty>
110
- <p class="m-generated-muted">${zh ? '暂无数据' : 'No data yet'}</p>
111
- </template>
97
+ const listContent = ` <section class="m-generated-filters" aria-label="${zh ? '筛选' : 'Filters'}">
98
+ <MSpace wrap>
99
+ <MInput v-model="keyword" placeholder="${zh ? '搜索关键词' : 'Search keyword'}" clearable style="width: 14rem" />
100
+ <MButton severity="primary">${zh ? '查询' : 'Search'}</MButton>
101
+ <MButton severity="secondary">${zh ? '重置' : 'Reset'}</MButton>
102
+ </MSpace>
103
+ </section>
104
+ <header class="m-generated-toolbar">
105
+ <h1 class="m-generated-title">${title}</h1>
106
+ <MButton severity="primary">${zh ? '新建' : 'Create'}</MButton>
107
+ </header>
108
+ <MTable :columns="columns" :rows="rows" :loading="loading" paginator :rows-per-page="10" striped bordered row-key="id">
109
+ <template #empty>
110
+ <p class="m-generated-muted">${zh ? '暂无数据' : 'No data yet'}</p>
111
+ </template>
112
112
  </MTable>`;
113
- const formContent = ` <header class="m-generated-intro">
114
- <h1 class="m-generated-title">${title}</h1>
115
- <p class="m-generated-muted">${zh ? '填写表单并保存。' : 'Fill in the form and save.'}</p>
116
- </header>
117
- <MForm class="m-generated-form" @submit.prevent="submit">
118
- <MFormItem label="${zh ? '名称' : 'Name'}" name="name" required>
119
- <MInput v-model="model.name" fluid />
120
- </MFormItem>
121
- <footer class="m-generated-actions">
122
- <MButton native-type="submit" severity="primary" :loading="loading">${zh ? '保存' : 'Save'}</MButton>
123
- <MButton severity="secondary">${zh ? '取消' : 'Cancel'}</MButton>
124
- </footer>
113
+ const formContent = ` <header class="m-generated-intro">
114
+ <h1 class="m-generated-title">${title}</h1>
115
+ <p class="m-generated-muted">${zh ? '填写表单并保存。' : 'Fill in the form and save.'}</p>
116
+ </header>
117
+ <MForm class="m-generated-form" @submit.prevent="submit">
118
+ <MFormItem label="${zh ? '名称' : 'Name'}" name="name" required>
119
+ <MInput v-model="model.name" fluid />
120
+ </MFormItem>
121
+ <footer class="m-generated-actions">
122
+ <MButton native-type="submit" severity="primary" :loading="loading">${zh ? '保存' : 'Save'}</MButton>
123
+ <MButton severity="secondary">${zh ? '取消' : 'Cancel'}</MButton>
124
+ </footer>
125
125
  </MForm>`;
126
- const dashboardContent = ` <h1 class="m-generated-title">${title}</h1>
127
- <MGrid :cols="2" :x-gap="16" :y-gap="16" responsive="screen">
128
- <MGridItem v-for="metric in metrics" :key="metric.label" :span="1">
129
- <MCard>
130
- <p class="m-generated-muted">{{ metric.label }}</p>
131
- <strong class="m-generated-metric">{{ metric.value }}</strong>
132
- </MCard>
133
- </MGridItem>
134
- </MGrid>
135
- <MCard :title="${zh ? '趋势概览' : 'Trend overview'}">
136
- <MSkeleton v-if="loading" height="8rem" />
137
- <p v-else class="m-generated-muted">${zh ? '接入图表或业务组件。' : 'Connect charts or business widgets here.'}</p>
126
+ const dashboardContent = ` <h1 class="m-generated-title">${title}</h1>
127
+ <MGrid :cols="2" :x-gap="16" :y-gap="16" responsive="screen">
128
+ <MGridItem v-for="metric in metrics" :key="metric.label" :span="1">
129
+ <MCard>
130
+ <p class="m-generated-muted">{{ metric.label }}</p>
131
+ <strong class="m-generated-metric">{{ metric.value }}</strong>
132
+ </MCard>
133
+ </MGridItem>
134
+ </MGrid>
135
+ <MCard :title="${zh ? '趋势概览' : 'Trend overview'}">
136
+ <MSkeleton v-if="loading" height="8rem" />
137
+ <p v-else class="m-generated-muted">${zh ? '接入图表或业务组件。' : 'Connect charts or business widgets here.'}</p>
138
138
  </MCard>`;
139
- const detailContent = ` <header class="m-generated-toolbar">
140
- <div>
141
- <h1 class="m-generated-title">${title}</h1>
142
- <MTag value="${zh ? '正常' : 'Active'}" severity="success" />
143
- </div>
144
- <MButton severity="primary" outlined>${zh ? '编辑' : 'Edit'}</MButton>
145
- </header>
146
- <MCard>
147
- <MDivider />
148
- <dl class="m-generated-details">
149
- <div><dt>${zh ? '名称' : 'Name'}</dt><dd>${zh ? '示例资源' : 'Example resource'}</dd></div>
150
- <div><dt>${zh ? '更新时间' : 'Updated'}</dt><dd>—</dd></div>
151
- </dl>
139
+ const detailContent = ` <header class="m-generated-toolbar">
140
+ <div>
141
+ <h1 class="m-generated-title">${title}</h1>
142
+ <MTag value="${zh ? '正常' : 'Active'}" severity="success" />
143
+ </div>
144
+ <MButton severity="primary" outlined>${zh ? '编辑' : 'Edit'}</MButton>
145
+ </header>
146
+ <MCard>
147
+ <MDivider />
148
+ <dl class="m-generated-details">
149
+ <div><dt>${zh ? '名称' : 'Name'}</dt><dd>${zh ? '示例资源' : 'Example resource'}</dd></div>
150
+ <div><dt>${zh ? '更新时间' : 'Updated'}</dt><dd>—</dd></div>
151
+ </dl>
152
152
  </MCard>`;
153
- const settingsContent = ` <h1 class="m-generated-title">${title}</h1>
154
- <MTabs :value="'general'" :items="[{ label: '${zh ? '常规' : 'General'}', value: 'general' }]" />
155
- <MForm class="m-generated-form" @submit.prevent="submit">
156
- <MFormItem label="${zh ? '显示名称' : 'Display name'}" name="name">
157
- <MInput v-model="model.name" fluid />
158
- </MFormItem>
159
- <MButton native-type="submit" severity="primary" :loading="loading">${zh ? '保存设置' : 'Save settings'}</MButton>
153
+ const settingsContent = ` <h1 class="m-generated-title">${title}</h1>
154
+ <MTabs :value="'general'" :items="[{ label: '${zh ? '常规' : 'General'}', value: 'general' }]" />
155
+ <MForm class="m-generated-form" @submit.prevent="submit">
156
+ <MFormItem label="${zh ? '显示名称' : 'Display name'}" name="name">
157
+ <MInput v-model="model.name" fluid />
158
+ </MFormItem>
159
+ <MButton native-type="submit" severity="primary" :loading="loading">${zh ? '保存设置' : 'Save settings'}</MButton>
160
160
  </MForm>`;
161
161
  let innerTemplate = '';
162
162
  if (isList) {
163
- innerTemplate = `<MConfigProvider :locale="zhCN">
164
- <MLayout has-sider class="m-generated-page">
165
- <MLayoutSider class="m-generated-sider" />
166
- <MLayout>
167
- <MLayoutHeader class="m-generated-header">
168
- <MBreadcrumb :model="[{ label: '${zh ? '首页' : 'Home'}', to: '/' }, { label: '${title}' }]" />
169
- </MLayoutHeader>
170
- <MLayoutContent class="m-generated-content">
171
- ${listContent}
172
- </MLayoutContent>
173
- </MLayout>
174
- </MLayout>
163
+ innerTemplate = `<MConfigProvider :locale="zhCN">
164
+ <MLayout has-sider class="m-generated-page">
165
+ <MLayoutSider class="m-generated-sider" />
166
+ <MLayout>
167
+ <MLayoutHeader class="m-generated-header">
168
+ <MBreadcrumb :model="[{ label: '${zh ? '首页' : 'Home'}', to: '/' }, { label: '${title}' }]" />
169
+ </MLayoutHeader>
170
+ <MLayoutContent class="m-generated-content">
171
+ ${listContent}
172
+ </MLayoutContent>
173
+ </MLayout>
174
+ </MLayout>
175
175
  </MConfigProvider>`;
176
176
  }
177
177
  else if (useLayoutShell) {
178
178
  const content = isDashboard ? dashboardContent : isDetail ? detailContent : isSettings ? settingsContent : formContent;
179
- innerTemplate = `<MConfigProvider :locale="zhCN">
180
- <MLayout class="m-generated-page">
181
- <MLayoutHeader class="m-generated-header">
182
- <MBreadcrumb :model="[{ label: '${zh ? '首页' : 'Home'}', to: '/' }, { label: '${title}' }]" />
183
- </MLayoutHeader>
184
- <MLayoutContent class="m-generated-content">
185
- ${content}
186
- </MLayoutContent>
187
- </MLayout>
179
+ innerTemplate = `<MConfigProvider :locale="zhCN">
180
+ <MLayout class="m-generated-page">
181
+ <MLayoutHeader class="m-generated-header">
182
+ <MBreadcrumb :model="[{ label: '${zh ? '首页' : 'Home'}', to: '/' }, { label: '${title}' }]" />
183
+ </MLayoutHeader>
184
+ <MLayoutContent class="m-generated-content">
185
+ ${content}
186
+ </MLayoutContent>
187
+ </MLayout>
188
188
  </MConfigProvider>`;
189
189
  }
190
190
  else if (isAuth) {
191
- innerTemplate = `<MConfigProvider :locale="zhCN">
192
- <main class="m-generated-page m-generated-auth">
193
- <MCard>
194
- <MForm label-position="top" @submit.prevent="submit">
195
- <MFormItem label="${zh ? '邮箱' : 'Email'}" name="email">
196
- <MInput type="email" fluid />
197
- </MFormItem>
198
- <MFormItem label="${zh ? '密码' : 'Password'}" name="password">
199
- <MInput type="password" fluid />
200
- </MFormItem>
201
- <MButton native-type="submit" severity="primary" :loading="loading" fluid>${zh ? '登录' : 'Sign in'}</MButton>
202
- </MForm>
203
- </MCard>
204
- </main>
191
+ innerTemplate = `<MConfigProvider :locale="zhCN">
192
+ <main class="m-generated-page m-generated-auth">
193
+ <MCard>
194
+ <MForm label-position="top" @submit.prevent="submit">
195
+ <MFormItem label="${zh ? '邮箱' : 'Email'}" name="email">
196
+ <MInput type="email" fluid />
197
+ </MFormItem>
198
+ <MFormItem label="${zh ? '密码' : 'Password'}" name="password">
199
+ <MInput type="password" fluid />
200
+ </MFormItem>
201
+ <MButton native-type="submit" severity="primary" :loading="loading" fluid>${zh ? '登录' : 'Sign in'}</MButton>
202
+ </MForm>
203
+ </MCard>
204
+ </main>
205
205
  </MConfigProvider>`;
206
206
  }
207
207
  else if (isEmpty) {
208
- innerTemplate = `<MConfigProvider :locale="zhCN">
209
- <main class="m-generated-page">
210
- <MCard>
211
- <MDataView :value="[]">
212
- <template #empty>
213
- <div class="m-generated-empty">
214
- <strong>${zh ? '暂无内容' : 'Nothing here yet'}</strong>
215
- <p class="m-generated-muted">${zh ? '创建第一条记录开始使用。' : 'Create your first record to get started.'}</p>
216
- <MButton severity="primary" @click="submit">${zh ? '创建' : 'Create'}</MButton>
217
- </div>
218
- </template>
219
- </MDataView>
220
- </MCard>
221
- </main>
208
+ innerTemplate = `<MConfigProvider :locale="zhCN">
209
+ <main class="m-generated-page">
210
+ <MCard>
211
+ <MDataView :value="[]">
212
+ <template #empty>
213
+ <div class="m-generated-empty">
214
+ <strong>${zh ? '暂无内容' : 'Nothing here yet'}</strong>
215
+ <p class="m-generated-muted">${zh ? '创建第一条记录开始使用。' : 'Create your first record to get started.'}</p>
216
+ <MButton severity="primary" @click="submit">${zh ? '创建' : 'Create'}</MButton>
217
+ </div>
218
+ </template>
219
+ </MDataView>
220
+ </MCard>
221
+ </main>
222
222
  </MConfigProvider>`;
223
223
  }
224
224
  else if (isWizard) {
225
- innerTemplate = `<MConfigProvider :locale="zhCN">
226
- <main class="m-generated-page">
227
- <MCard>
228
- <MStepper v-model="activeStep" :items="[${zh ? "'基本信息', '确认'" : "'Details', 'Confirm'"}]" />
229
- <MForm label-position="top" @submit.prevent="submit">
230
- <MFormItem label="${zh ? '名称' : 'Name'}" name="name"><MInput v-model="model.name" fluid /></MFormItem>
231
- <MButton native-type="submit" severity="primary" :loading="loading">${zh ? '下一步' : 'Next'}</MButton>
232
- </MForm>
233
- </MCard>
234
- </main>
225
+ innerTemplate = `<MConfigProvider :locale="zhCN">
226
+ <main class="m-generated-page">
227
+ <MCard>
228
+ <MStepper v-model="activeStep" :items="[${zh ? "'基本信息', '确认'" : "'Details', 'Confirm'"}]" />
229
+ <MForm label-position="top" @submit.prevent="submit">
230
+ <MFormItem label="${zh ? '名称' : 'Name'}" name="name"><MInput v-model="model.name" fluid /></MFormItem>
231
+ <MButton native-type="submit" severity="primary" :loading="loading">${zh ? '下一步' : 'Next'}</MButton>
232
+ </MForm>
233
+ </MCard>
234
+ </main>
235
235
  </MConfigProvider>`;
236
236
  }
237
237
  else {
238
- innerTemplate = `<MConfigProvider :locale="zhCN">
239
- <main class="m-generated-page">
240
- <MCard>
241
- <p class="m-generated-muted">${zh ? '将此区域替换为页面内容。' : 'Replace this area with page content.'}</p>
242
- <MTag value="${zh ? '示例' : 'Example'}" severity="info" />
243
- </MCard>
244
- </main>
238
+ innerTemplate = `<MConfigProvider :locale="zhCN">
239
+ <main class="m-generated-page">
240
+ <MCard>
241
+ <p class="m-generated-muted">${zh ? '将此区域替换为页面内容。' : 'Replace this area with page content.'}</p>
242
+ <MTag value="${zh ? '示例' : 'Example'}" severity="info" />
243
+ </MCard>
244
+ </main>
245
245
  </MConfigProvider>`;
246
246
  }
247
- const template = `<template>
248
- ${innerTemplate}
249
- <p v-if="error" role="alert" class="m-generated-error">${'{{ error }}'}</p>
247
+ const template = `<template>
248
+ ${innerTemplate}
249
+ <p v-if="error" role="alert" class="m-generated-error">${'{{ error }}'}</p>
250
250
  </template>`;
251
- const style = `<style scoped>
252
- .m-generated-page { min-height: 100vh; background: var(--m-color-surface); }
253
- .m-generated-sider { border-right: 1px solid var(--m-color-border); }
254
- .m-generated-header { padding: var(--m-space-4) var(--m-space-6); border-bottom: 1px solid var(--m-color-border); }
255
- .m-generated-content { padding: var(--m-space-6); display: flex; flex-direction: column; gap: var(--m-space-4); }
256
- .m-generated-filters { padding: var(--m-space-4); background: color-mix(in srgb, var(--m-color-border) 25%, transparent); border-radius: var(--m-radius-md); border: 1px solid var(--m-color-border); }
257
- .m-generated-toolbar, .m-generated-actions { display: flex; gap: var(--m-space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
258
- .m-generated-title { margin: 0; font-size: var(--m-font-size-lg); font-weight: 600; color: var(--m-color-text); }
259
- .m-generated-intro { margin-bottom: var(--m-space-2); }
260
- .m-generated-form { padding: var(--m-space-6); border: 1px solid var(--m-color-border); border-radius: var(--m-radius-md); box-shadow: var(--m-shadow-sm); }
261
- .m-generated-auth { display: grid; place-items: center; padding: var(--m-space-8); max-width: 24rem; margin: 0 auto; }
262
- .m-generated-metric { display: block; font-size: var(--m-font-size-lg); margin: var(--m-space-2) 0; }
263
- .m-generated-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--m-space-4); margin: 0; }
264
- .m-generated-details dt { color: var(--m-color-text-muted); font-size: var(--m-font-size-sm); }
265
- .m-generated-details dd { margin: var(--m-space-1) 0 0; }
266
- .m-generated-empty { display: grid; gap: var(--m-space-2); justify-items: center; padding: var(--m-space-8); text-align: center; }
267
- .m-generated-muted { margin: 0; color: var(--m-color-text-muted); }
268
- .m-generated-error { color: var(--m-color-danger); padding: 0 var(--m-space-6); }
269
- @media (max-width: 48rem) { .m-generated-content { padding: var(--m-space-4); } .m-generated-details { grid-template-columns: 1fr; } }
251
+ const style = `<style scoped>
252
+ .m-generated-page { min-height: 100vh; background: var(--m-color-surface); }
253
+ .m-generated-sider { border-right: 1px solid var(--m-color-border); }
254
+ .m-generated-header { padding: var(--m-space-4) var(--m-space-6); border-bottom: 1px solid var(--m-color-border); }
255
+ .m-generated-content { padding: var(--m-space-6); display: flex; flex-direction: column; gap: var(--m-space-4); }
256
+ .m-generated-filters { padding: var(--m-space-4); background: color-mix(in srgb, var(--m-color-border) 25%, transparent); border-radius: var(--m-radius-md); border: 1px solid var(--m-color-border); }
257
+ .m-generated-toolbar, .m-generated-actions { display: flex; gap: var(--m-space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
258
+ .m-generated-title { margin: 0; font-size: var(--m-font-size-lg); font-weight: 600; color: var(--m-color-text); }
259
+ .m-generated-intro { margin-bottom: var(--m-space-2); }
260
+ .m-generated-form { padding: var(--m-space-6); border: 1px solid var(--m-color-border); border-radius: var(--m-radius-md); box-shadow: var(--m-shadow-sm); }
261
+ .m-generated-auth { display: grid; place-items: center; padding: var(--m-space-8); max-width: 24rem; margin: 0 auto; }
262
+ .m-generated-metric { display: block; font-size: var(--m-font-size-lg); margin: var(--m-space-2) 0; }
263
+ .m-generated-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--m-space-4); margin: 0; }
264
+ .m-generated-details dt { color: var(--m-color-text-muted); font-size: var(--m-font-size-sm); }
265
+ .m-generated-details dd { margin: var(--m-space-1) 0 0; }
266
+ .m-generated-empty { display: grid; gap: var(--m-space-2); justify-items: center; padding: var(--m-space-8); text-align: center; }
267
+ .m-generated-muted { margin: 0; color: var(--m-color-text-muted); }
268
+ .m-generated-error { color: var(--m-color-danger); padding: 0 var(--m-space-6); }
269
+ @media (max-width: 48rem) { .m-generated-content { padding: var(--m-space-4); } .m-generated-details { grid-template-columns: 1fr; } }
270
270
  </style>`;
271
271
  return { script, template, style };
272
272
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morya-ui/mcp",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.1",
5
5
  "description": "MCP server for morya-ui — component docs, examples, and usage guidance for AI coding agents.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/morya-space/morya-ui/tree/main/packages/ui-mcp#readme",