mokkun 0.1.4 → 0.1.6
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/README.md +18 -6
- package/bin/cli.mjs +21 -7
- package/bin/viewer.html +6 -50
- package/dist/mokkun.css +1 -1
- package/dist/mokkun.esm.js +4898 -2913
- package/dist/mokkun.esm.js.map +1 -1
- package/dist/mokkun.js +359 -322
- package/dist/mokkun.js.map +1 -1
- package/dist/types/loader/file-loader.d.ts +2 -0
- package/dist/types/parser/key-normalizer.d.ts +24 -0
- package/dist/types/renderer/components/app-header.d.ts +2 -0
- package/dist/types/renderer/components/dialog/action-dialog.d.ts +61 -0
- package/dist/types/renderer/components/dialog/base-dialog.d.ts +125 -0
- package/dist/types/renderer/components/dialog/dialog-types.d.ts +96 -0
- package/dist/types/renderer/components/form-fields.d.ts +0 -3
- package/dist/types/renderer/components/tabs.d.ts +6 -0
- package/dist/types/renderer/layouts/index.d.ts +5 -0
- package/dist/types/renderer/layouts/shell.d.ts +7 -0
- package/dist/types/renderer/layouts/types.d.ts +34 -0
- package/dist/types/renderer/screen-renderer.d.ts +7 -12
- package/dist/types/renderer/utils/dummy-data.d.ts +0 -14
- package/dist/types/renderer/utils/field-helpers.d.ts +23 -0
- package/dist/types/renderer/utils/icons.d.ts +13 -0
- package/dist/types/types/schema.d.ts +22 -6
- package/dist/types/types/theme.d.ts +1 -1
- package/package.json +3 -1
- package/dist/example.html +0 -225
package/README.md
CHANGED
|
@@ -78,6 +78,16 @@ https://raw.githubusercontent.com/tango238/mokkun/main/schema.json
|
|
|
78
78
|
画面間のナビゲーション(actions の navigate)も設定してください。
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
### エディタで補完を使う
|
|
82
|
+
|
|
83
|
+
YAML の先頭行に次のモードラインを書くと、[YAML Language Server](https://github.com/redhat-developer/yaml-language-server)(VS Code の YAML 拡張など)でキー補完とバリデーションが効きます。
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/tango238/mokkun/main/schema.json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
リポジトリ内では `.vscode/settings.json` の `"yaml.schemas": { "./schema.json": ["examples/*.yaml", "*.mokkun.yaml"] }` で、`examples/*.yaml` と `*.mokkun.yaml` に自動適用できます。
|
|
90
|
+
|
|
81
91
|
### 生成した YAML をモックとして表示する
|
|
82
92
|
|
|
83
93
|
AI が生成した YAML を `.yaml` ファイルとして保存し、`npx mokkun` で表示できます。
|
|
@@ -161,8 +171,8 @@ mokkun/
|
|
|
161
171
|
|
|
162
172
|
| コンポーネント | 説明 |
|
|
163
173
|
|---------------|------|
|
|
164
|
-
|
|
|
165
|
-
|
|
|
174
|
+
| appHeader | アプリケーションヘッダー(ロゴ、テナント切替、ユーザーメニュー。`systemName` で左上のシステム名を指定) |
|
|
175
|
+
| appNavi | アプリナビゲーション(主要機能の切り替え) |
|
|
166
176
|
| heading | 見出し |
|
|
167
177
|
| tabs | タブ |
|
|
168
178
|
| accordion_panel | アコーディオン |
|
|
@@ -195,9 +205,11 @@ mokkun/
|
|
|
195
205
|
|
|
196
206
|
## YAML構造
|
|
197
207
|
|
|
208
|
+
YAML のキーは camelCase が正規形です。snake_case のキー(teamkit の generate-ui 出力など)も互換として引き続き受け付けます。
|
|
209
|
+
|
|
198
210
|
```yaml
|
|
199
211
|
view:
|
|
200
|
-
|
|
212
|
+
myScreen:
|
|
201
213
|
title: "画面タイトル"
|
|
202
214
|
description: "画面の説明"
|
|
203
215
|
fields:
|
|
@@ -211,13 +223,13 @@ view:
|
|
|
211
223
|
label: "送信"
|
|
212
224
|
style: "primary"
|
|
213
225
|
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
commonComponents:
|
|
227
|
+
myComponent:
|
|
216
228
|
type: "field_group"
|
|
217
229
|
fields: []
|
|
218
230
|
|
|
219
231
|
validations:
|
|
220
|
-
|
|
232
|
+
myRule:
|
|
221
233
|
rules:
|
|
222
234
|
required: true
|
|
223
235
|
min: 1
|
package/bin/cli.mjs
CHANGED
|
@@ -13,11 +13,16 @@ const distDir = resolve(__dirname, '../dist')
|
|
|
13
13
|
const args = process.argv.slice(2)
|
|
14
14
|
let yamlFile = null
|
|
15
15
|
let port = 3333
|
|
16
|
+
let theme = 'light'
|
|
17
|
+
const VALID_THEMES = ['light', 'dark']
|
|
16
18
|
|
|
17
19
|
for (let i = 0; i < args.length; i++) {
|
|
18
20
|
if (args[i] === '--port' || args[i] === '-p') {
|
|
19
21
|
port = parseInt(args[i + 1], 10)
|
|
20
22
|
i++
|
|
23
|
+
} else if (args[i] === '--theme' || args[i] === '-t') {
|
|
24
|
+
theme = args[i + 1]
|
|
25
|
+
i++
|
|
21
26
|
} else if (args[i] === '--help' || args[i] === '-h') {
|
|
22
27
|
printHelp()
|
|
23
28
|
process.exit(0)
|
|
@@ -26,6 +31,12 @@ for (let i = 0; i < args.length; i++) {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
// Validate theme
|
|
35
|
+
if (!VALID_THEMES.includes(theme)) {
|
|
36
|
+
console.warn(`Warning: Unknown theme "${theme}". Falling back to light. Valid themes: ${VALID_THEMES.join(', ')}`)
|
|
37
|
+
theme = 'light'
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
function printHelp() {
|
|
30
41
|
console.log(`
|
|
31
42
|
mokkun - YAML-based form & mockup viewer
|
|
@@ -34,13 +45,15 @@ Usage:
|
|
|
34
45
|
npx mokkun [options] [yaml-file]
|
|
35
46
|
|
|
36
47
|
Options:
|
|
37
|
-
-p, --port <port>
|
|
38
|
-
-
|
|
48
|
+
-p, --port <port> Port number (default: 3333)
|
|
49
|
+
-t, --theme <theme> Theme: light, dark (default: light)
|
|
50
|
+
-h, --help Show this help
|
|
39
51
|
|
|
40
52
|
Examples:
|
|
41
|
-
npx mokkun
|
|
42
|
-
npx mokkun ./my-form.yaml
|
|
43
|
-
npx mokkun -p 8080 form.yaml
|
|
53
|
+
npx mokkun # Start with built-in sample
|
|
54
|
+
npx mokkun ./my-form.yaml # Open specific YAML file
|
|
55
|
+
npx mokkun -p 8080 form.yaml # Custom port
|
|
56
|
+
npx mokkun --theme light form.yaml # Use light theme
|
|
44
57
|
`)
|
|
45
58
|
}
|
|
46
59
|
|
|
@@ -76,12 +89,12 @@ const MIME_TYPES = {
|
|
|
76
89
|
|
|
77
90
|
// Generate viewer HTML
|
|
78
91
|
function generateViewerHtml() {
|
|
79
|
-
const yamlParam = yamlFile ? `yaml=${encodeURIComponent('/__yaml__/' + basename(yamlFile))}` : ''
|
|
80
92
|
const viewerHtmlPath = resolve(__dirname, 'viewer.html')
|
|
81
93
|
let html = readFileSync(viewerHtmlPath, 'utf-8')
|
|
82
|
-
if (
|
|
94
|
+
if (yamlFile) {
|
|
83
95
|
html = html.replace('/* __YAML_URL__ */ null', JSON.stringify('/__yaml__/' + basename(yamlFile)))
|
|
84
96
|
}
|
|
97
|
+
html = html.replace('/* __THEME__ */ \'light\'', JSON.stringify(theme))
|
|
85
98
|
return html
|
|
86
99
|
}
|
|
87
100
|
|
|
@@ -136,6 +149,7 @@ server.listen(port, () => {
|
|
|
136
149
|
if (yamlFile) {
|
|
137
150
|
console.log(`Serving: ${yamlFile}`)
|
|
138
151
|
}
|
|
152
|
+
console.log(`Theme: ${theme}`)
|
|
139
153
|
console.log('Press Ctrl+C to stop.\n')
|
|
140
154
|
|
|
141
155
|
// Open browser
|
package/bin/viewer.html
CHANGED
|
@@ -73,29 +73,6 @@
|
|
|
73
73
|
|
|
74
74
|
.toolbar-spacer { flex: 1; }
|
|
75
75
|
|
|
76
|
-
.theme-toggle {
|
|
77
|
-
display: flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
gap: 8px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.theme-toggle button {
|
|
83
|
-
padding: 8px 16px;
|
|
84
|
-
border-radius: 6px;
|
|
85
|
-
border: 1px solid #3a3a5a;
|
|
86
|
-
background: transparent;
|
|
87
|
-
color: #fff;
|
|
88
|
-
font-size: 14px;
|
|
89
|
-
cursor: pointer;
|
|
90
|
-
transition: all 0.2s;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.theme-toggle button:hover { background: #3a3a5a; }
|
|
94
|
-
.theme-toggle button.active {
|
|
95
|
-
background: #6366f1;
|
|
96
|
-
border-color: #6366f1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
76
|
#mokkun-app {
|
|
100
77
|
margin-top: 60px;
|
|
101
78
|
flex: 1;
|
|
@@ -137,12 +114,6 @@
|
|
|
137
114
|
</div>
|
|
138
115
|
|
|
139
116
|
<div class="toolbar-spacer"></div>
|
|
140
|
-
|
|
141
|
-
<div class="theme-toggle">
|
|
142
|
-
<button id="lofi-theme" class="active">Lo-Fi</button>
|
|
143
|
-
<button id="light-theme">Light</button>
|
|
144
|
-
<button id="dark-theme">Dark</button>
|
|
145
|
-
</div>
|
|
146
117
|
</div>
|
|
147
118
|
|
|
148
119
|
<div id="mokkun-app">
|
|
@@ -155,31 +126,16 @@
|
|
|
155
126
|
(function() {
|
|
156
127
|
var mokkunInstance = null;
|
|
157
128
|
var screenSelect = document.getElementById('screen-select');
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var
|
|
161
|
-
var currentTheme = 'lofi';
|
|
129
|
+
|
|
130
|
+
// Theme injected by CLI (default: light)
|
|
131
|
+
var currentTheme = /* __THEME__ */ 'light';
|
|
162
132
|
|
|
163
133
|
// YAML URL injected by CLI (or null for sample)
|
|
164
134
|
var yamlUrl = /* __YAML_URL__ */ null;
|
|
165
135
|
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
document.body.classList.toggle('dark-theme', theme === 'dark');
|
|
170
|
-
document.documentElement.setAttribute('data-theme', theme);
|
|
171
|
-
lofiThemeBtn.classList.toggle('active', theme === 'lofi');
|
|
172
|
-
lightThemeBtn.classList.toggle('active', theme === 'light');
|
|
173
|
-
darkThemeBtn.classList.toggle('active', theme === 'dark');
|
|
174
|
-
if (mokkunInstance) mokkunInstance.setTheme(theme);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Set initial theme
|
|
178
|
-
document.documentElement.setAttribute('data-theme', 'lofi');
|
|
179
|
-
|
|
180
|
-
lofiThemeBtn.addEventListener('click', function() { setTheme('lofi'); });
|
|
181
|
-
lightThemeBtn.addEventListener('click', function() { setTheme('light'); });
|
|
182
|
-
darkThemeBtn.addEventListener('click', function() { setTheme('dark'); });
|
|
136
|
+
// Apply theme
|
|
137
|
+
document.body.classList.toggle('dark-theme', currentTheme === 'dark');
|
|
138
|
+
document.documentElement.setAttribute('data-theme', currentTheme);
|
|
183
139
|
|
|
184
140
|
// Screen change
|
|
185
141
|
screenSelect.addEventListener('change', function() {
|