mokkun 0.1.6 → 0.2.0
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/bin/viewer.html +76 -1
- package/dist/example.html +225 -0
- package/dist/mokkun.esm.js +8662 -5797
- package/dist/mokkun.esm.js.map +1 -1
- package/dist/mokkun.js +592 -231
- package/dist/mokkun.js.map +1 -1
- package/dist/types/lib.d.ts +32 -3
- package/dist/types/loader/file-loader.d.ts +5 -1
- package/dist/types/parser/index.d.ts +1 -0
- package/dist/types/parser/v2/compile-expand.d.ts +23 -0
- package/dist/types/parser/v2/compile-field.d.ts +28 -0
- package/dist/types/parser/v2/compile-section.d.ts +6 -0
- package/dist/types/parser/v2/compile-v2.d.ts +14 -0
- package/dist/types/parser/v2/compile-warnings.d.ts +17 -0
- package/dist/types/parser/v2/file-spec.d.ts +24 -0
- package/dist/types/parser/v2/index.d.ts +5 -0
- package/dist/types/parser/v2/iso-date.d.ts +10 -0
- package/dist/types/parser/v2/parse-v2.d.ts +24 -0
- package/dist/types/parser/v2/validate-action.d.ts +11 -0
- package/dist/types/parser/v2/validate-app.d.ts +9 -0
- package/dist/types/parser/v2/validate-context.d.ts +41 -0
- package/dist/types/parser/v2/validate-field.d.ts +17 -0
- package/dist/types/parser/v2/validate-keys.d.ts +29 -0
- package/dist/types/parser/v2/validate-list.d.ts +5 -0
- package/dist/types/parser/v2/validate-v2.d.ts +6 -0
- package/dist/types/parser/v2/validate-view.d.ts +6 -0
- package/dist/types/parser/yaml-parser.d.ts +10 -0
- package/dist/types/renderer/screen-renderer.d.ts +4 -0
- package/dist/types/renderer-v2/actions.d.ts +30 -0
- package/dist/types/renderer-v2/app-shell.d.ts +15 -0
- package/dist/types/renderer-v2/condition.d.ts +19 -0
- package/dist/types/renderer-v2/context.d.ts +37 -0
- package/dist/types/renderer-v2/fields/choice.d.ts +12 -0
- package/dist/types/renderer-v2/fields/control-label.d.ts +57 -0
- package/dist/types/renderer-v2/fields/date.d.ts +6 -0
- package/dist/types/renderer-v2/fields/display.d.ts +22 -0
- package/dist/types/renderer-v2/fields/file-support.d.ts +15 -0
- package/dist/types/renderer-v2/fields/file.d.ts +9 -0
- package/dist/types/renderer-v2/fields/index.d.ts +20 -0
- package/dist/types/renderer-v2/fields/select.d.ts +17 -0
- package/dist/types/renderer-v2/fields/text.d.ts +26 -0
- package/dist/types/renderer-v2/fields/textarea.d.ts +5 -0
- package/dist/types/renderer-v2/fields/toggle.d.ts +6 -0
- package/dist/types/renderer-v2/icons.d.ts +35 -0
- package/dist/types/renderer-v2/index.d.ts +45 -0
- package/dist/types/renderer-v2/list-cells.d.ts +6 -0
- package/dist/types/renderer-v2/list-data.d.ts +53 -0
- package/dist/types/renderer-v2/mount-parts.d.ts +19 -0
- package/dist/types/renderer-v2/mount-repeat.d.ts +8 -0
- package/dist/types/renderer-v2/mount-section.d.ts +10 -0
- package/dist/types/renderer-v2/mount-visibility.d.ts +13 -0
- package/dist/types/renderer-v2/mount.d.ts +9 -0
- package/dist/types/renderer-v2/role.d.ts +15 -0
- package/dist/types/renderer-v2/section-fields.d.ts +11 -0
- package/dist/types/renderer-v2/section-list.d.ts +8 -0
- package/dist/types/renderer-v2/section-readonly.d.ts +8 -0
- package/dist/types/renderer-v2/section.d.ts +15 -0
- package/dist/types/renderer-v2/styles.d.ts +13 -0
- package/dist/types/renderer-v2/util.d.ts +28 -0
- package/dist/types/renderer-v2/view-state.d.ts +25 -0
- package/dist/types/renderer-v2/view.d.ts +8 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/schema-v2.d.ts +270 -0
- package/dist/types/types/schema.d.ts +11 -0
- package/package.json +1 -1
package/bin/viewer.html
CHANGED
|
@@ -72,6 +72,9 @@
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
.toolbar-spacer { flex: 1; }
|
|
75
|
+
.toolbar-section[hidden] { display: none; }
|
|
76
|
+
.toolbar select { min-width: 120px; }
|
|
77
|
+
.toolbar select option:disabled { color: #8a8aa8; }
|
|
75
78
|
|
|
76
79
|
#mokkun-app {
|
|
77
80
|
margin-top: 60px;
|
|
@@ -113,6 +116,16 @@
|
|
|
113
116
|
</select>
|
|
114
117
|
</div>
|
|
115
118
|
|
|
119
|
+
<!-- v2 文書のときだけ表示: 状態(通常 / 成功 / エラー / 空 / 読み込み中)とロール -->
|
|
120
|
+
<div class="toolbar-section" id="state-section" hidden>
|
|
121
|
+
<label for="state-select">状態:</label>
|
|
122
|
+
<select id="state-select"></select>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="toolbar-section" id="role-section" hidden>
|
|
125
|
+
<label for="role-select">ロール:</label>
|
|
126
|
+
<select id="role-select"></select>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
116
129
|
<div class="toolbar-spacer"></div>
|
|
117
130
|
</div>
|
|
118
131
|
|
|
@@ -137,12 +150,58 @@
|
|
|
137
150
|
document.body.classList.toggle('dark-theme', currentTheme === 'dark');
|
|
138
151
|
document.documentElement.setAttribute('data-theme', currentTheme);
|
|
139
152
|
|
|
153
|
+
var stateSelect = document.getElementById('state-select');
|
|
154
|
+
var roleSelect = document.getElementById('role-select');
|
|
155
|
+
var params = new URLSearchParams(window.location.search);
|
|
156
|
+
// 状態の表示名はライブラリ(Mokkun.utils)のものを使う
|
|
157
|
+
var STATE_LABELS = Mokkun.utils.V2_STATE_LABELS;
|
|
158
|
+
|
|
159
|
+
// 状態セレクト: 現在の画面が持つ states.* に対応するものだけ選べる
|
|
160
|
+
function refreshStateSelect() {
|
|
161
|
+
var section = document.getElementById('state-section');
|
|
162
|
+
if (!mokkunInstance || !mokkunInstance.schemaV2) { section.hidden = true; return; }
|
|
163
|
+
section.hidden = false;
|
|
164
|
+
var enabled = mokkunInstance.getAvailableStates();
|
|
165
|
+
stateSelect.innerHTML = '';
|
|
166
|
+
Object.keys(STATE_LABELS).forEach(function(key) {
|
|
167
|
+
var opt = document.createElement('option');
|
|
168
|
+
opt.value = key;
|
|
169
|
+
opt.textContent = STATE_LABELS[key];
|
|
170
|
+
opt.disabled = enabled.indexOf(key) < 0;
|
|
171
|
+
stateSelect.appendChild(opt);
|
|
172
|
+
});
|
|
173
|
+
stateSelect.value = mokkunInstance.viewState;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ロールセレクト: app.roles(と「すべて」)。roles が無い文書では出さない
|
|
177
|
+
function buildRoleSelect() {
|
|
178
|
+
var section = document.getElementById('role-section');
|
|
179
|
+
var schema = mokkunInstance && mokkunInstance.schemaV2;
|
|
180
|
+
var roles = (schema && schema.app.roles) || [];
|
|
181
|
+
section.hidden = roles.length === 0;
|
|
182
|
+
roleSelect.innerHTML = '';
|
|
183
|
+
[''].concat(roles).forEach(function(role) {
|
|
184
|
+
var opt = document.createElement('option');
|
|
185
|
+
opt.value = role;
|
|
186
|
+
opt.textContent = role || 'すべて';
|
|
187
|
+
roleSelect.appendChild(opt);
|
|
188
|
+
});
|
|
189
|
+
roleSelect.value = mokkunInstance.role || '';
|
|
190
|
+
}
|
|
191
|
+
|
|
140
192
|
// Screen change
|
|
141
193
|
screenSelect.addEventListener('change', function() {
|
|
142
194
|
if (mokkunInstance && screenSelect.value) {
|
|
143
195
|
mokkunInstance.showScreen(screenSelect.value);
|
|
196
|
+
refreshStateSelect();
|
|
144
197
|
}
|
|
145
198
|
});
|
|
199
|
+
stateSelect.addEventListener('change', function() {
|
|
200
|
+
if (mokkunInstance) mokkunInstance.setState(stateSelect.value);
|
|
201
|
+
});
|
|
202
|
+
roleSelect.addEventListener('change', function() {
|
|
203
|
+
if (mokkunInstance) mokkunInstance.setRole(roleSelect.value || undefined);
|
|
204
|
+
});
|
|
146
205
|
|
|
147
206
|
// Sample YAML for when no file is specified
|
|
148
207
|
var sampleYaml = [
|
|
@@ -185,7 +244,11 @@
|
|
|
185
244
|
var options = {
|
|
186
245
|
container: '#mokkun-app',
|
|
187
246
|
theme: currentTheme,
|
|
247
|
+
initialScreen: params.get('screen') || undefined,
|
|
248
|
+
initialState: params.get('state') || undefined,
|
|
249
|
+
role: params.get('role') || undefined,
|
|
188
250
|
onReady: function(instance) {
|
|
251
|
+
mokkunInstance = instance;
|
|
189
252
|
var screens = instance.getScreenNames();
|
|
190
253
|
screenSelect.innerHTML = '';
|
|
191
254
|
screens.forEach(function(name) {
|
|
@@ -194,7 +257,19 @@
|
|
|
194
257
|
opt.textContent = name;
|
|
195
258
|
screenSelect.appendChild(opt);
|
|
196
259
|
});
|
|
197
|
-
screenSelect.value = screens[0] || '';
|
|
260
|
+
screenSelect.value = instance.currentScreen || screens[0] || '';
|
|
261
|
+
refreshStateSelect();
|
|
262
|
+
buildRoleSelect();
|
|
263
|
+
// 旧フォーマットへ変換したときに落ちるキーはコンソールにだけ出す(画面には出さない)
|
|
264
|
+
if (instance.schemaV2) {
|
|
265
|
+
Mokkun.utils.compileV2Warnings(instance.schemaV2).forEach(function(w) {
|
|
266
|
+
console.warn('[mokkun] 旧フォーマット変換: ' + w.path + ': ' + w.message);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
onNavigate: function(from, to) {
|
|
271
|
+
screenSelect.value = to;
|
|
272
|
+
refreshStateSelect();
|
|
198
273
|
},
|
|
199
274
|
onError: function(error) {
|
|
200
275
|
document.getElementById('mokkun-app').innerHTML =
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="ja">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Mokkun v0.2.0 - Example</title>
|
|
7
|
+
<!-- Load Mokkun CSS -->
|
|
8
|
+
<link rel="stylesheet" href="./mokkun.css">
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
margin: 0;
|
|
12
|
+
min-height: 100vh;
|
|
13
|
+
background: var(--mokkun-bg-primary, #f5f5f5);
|
|
14
|
+
}
|
|
15
|
+
#mokkun-app {
|
|
16
|
+
max-width: 800px;
|
|
17
|
+
margin: 0 auto;
|
|
18
|
+
padding: 20px;
|
|
19
|
+
}
|
|
20
|
+
.demo-header {
|
|
21
|
+
text-align: center;
|
|
22
|
+
padding: 20px 0;
|
|
23
|
+
margin-bottom: 20px;
|
|
24
|
+
border-bottom: 1px solid var(--mokkun-border-color, #ddd);
|
|
25
|
+
}
|
|
26
|
+
.demo-header h1 {
|
|
27
|
+
margin: 0 0 8px 0;
|
|
28
|
+
color: var(--mokkun-text-primary, #333);
|
|
29
|
+
}
|
|
30
|
+
.demo-header p {
|
|
31
|
+
margin: 0;
|
|
32
|
+
color: var(--mokkun-text-secondary, #666);
|
|
33
|
+
}
|
|
34
|
+
.demo-controls {
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: 10px;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
}
|
|
41
|
+
.demo-controls button {
|
|
42
|
+
padding: 8px 16px;
|
|
43
|
+
border: 1px solid var(--mokkun-border-color, #ddd);
|
|
44
|
+
border-radius: 4px;
|
|
45
|
+
background: var(--mokkun-bg-secondary, #fff);
|
|
46
|
+
color: var(--mokkun-text-primary, #333);
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
}
|
|
49
|
+
.demo-controls button:hover {
|
|
50
|
+
background: var(--mokkun-bg-hover, #f0f0f0);
|
|
51
|
+
}
|
|
52
|
+
.demo-controls button.active {
|
|
53
|
+
background: var(--mokkun-primary, #007bff);
|
|
54
|
+
color: white;
|
|
55
|
+
border-color: var(--mokkun-primary, #007bff);
|
|
56
|
+
}
|
|
57
|
+
</style>
|
|
58
|
+
</head>
|
|
59
|
+
<body>
|
|
60
|
+
<div id="mokkun-app">
|
|
61
|
+
<div class="demo-header">
|
|
62
|
+
<h1>Mokkun v0.2.0</h1>
|
|
63
|
+
<p>YAML-based Presentation & Form Builder</p>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="demo-controls">
|
|
66
|
+
<button onclick="setTheme('light')" id="theme-light">Light</button>
|
|
67
|
+
<button onclick="setTheme('dark')" id="theme-dark">Dark</button>
|
|
68
|
+
<button onclick="setTheme('bootstrap')" id="theme-bootstrap">Bootstrap</button>
|
|
69
|
+
</div>
|
|
70
|
+
<div id="content"></div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<!-- Load Mokkun JS (UMD bundle) -->
|
|
74
|
+
<script src="./mokkun.js"></script>
|
|
75
|
+
|
|
76
|
+
<script>
|
|
77
|
+
// Sample YAML content
|
|
78
|
+
const yamlContent = `
|
|
79
|
+
view:
|
|
80
|
+
demo:
|
|
81
|
+
title: お問い合わせフォーム
|
|
82
|
+
description: 以下のフォームに必要事項をご記入ください
|
|
83
|
+
fields:
|
|
84
|
+
- id: name
|
|
85
|
+
type: text
|
|
86
|
+
label: お名前
|
|
87
|
+
required: true
|
|
88
|
+
placeholder: 山田 太郎
|
|
89
|
+
- id: email
|
|
90
|
+
type: text
|
|
91
|
+
label: メールアドレス
|
|
92
|
+
input_type: email
|
|
93
|
+
required: true
|
|
94
|
+
placeholder: example@email.com
|
|
95
|
+
- id: category
|
|
96
|
+
type: select
|
|
97
|
+
label: お問い合わせ種別
|
|
98
|
+
required: true
|
|
99
|
+
options:
|
|
100
|
+
- label: 選択してください
|
|
101
|
+
value: ""
|
|
102
|
+
- label: 製品について
|
|
103
|
+
value: product
|
|
104
|
+
- label: サービスについて
|
|
105
|
+
value: service
|
|
106
|
+
- label: その他
|
|
107
|
+
value: other
|
|
108
|
+
- id: message
|
|
109
|
+
type: textarea
|
|
110
|
+
label: お問い合わせ内容
|
|
111
|
+
rows: 5
|
|
112
|
+
required: true
|
|
113
|
+
placeholder: お問い合わせ内容をご記入ください
|
|
114
|
+
- id: newsletter
|
|
115
|
+
type: checkbox
|
|
116
|
+
label: メールマガジンを受け取る
|
|
117
|
+
actions:
|
|
118
|
+
- id: submit
|
|
119
|
+
type: submit
|
|
120
|
+
label: 送信する
|
|
121
|
+
style: primary
|
|
122
|
+
- id: reset
|
|
123
|
+
type: reset
|
|
124
|
+
label: クリア
|
|
125
|
+
style: secondary
|
|
126
|
+
|
|
127
|
+
wizard_demo:
|
|
128
|
+
title: ウィザードデモ
|
|
129
|
+
description: ステップ形式の入力フォーム
|
|
130
|
+
wizard:
|
|
131
|
+
show_progress: true
|
|
132
|
+
allow_back: true
|
|
133
|
+
steps:
|
|
134
|
+
- id: step1
|
|
135
|
+
title: 基本情報
|
|
136
|
+
fields:
|
|
137
|
+
- id: company
|
|
138
|
+
type: text
|
|
139
|
+
label: 会社名
|
|
140
|
+
required: true
|
|
141
|
+
- id: department
|
|
142
|
+
type: text
|
|
143
|
+
label: 部署名
|
|
144
|
+
- id: step2
|
|
145
|
+
title: 連絡先
|
|
146
|
+
fields:
|
|
147
|
+
- id: phone
|
|
148
|
+
type: text
|
|
149
|
+
label: 電話番号
|
|
150
|
+
placeholder: "03-1234-5678"
|
|
151
|
+
- id: fax
|
|
152
|
+
type: text
|
|
153
|
+
label: FAX番号
|
|
154
|
+
- id: step3
|
|
155
|
+
title: 確認
|
|
156
|
+
description: 入力内容をご確認ください
|
|
157
|
+
fields:
|
|
158
|
+
- id: terms
|
|
159
|
+
type: checkbox
|
|
160
|
+
label: 利用規約に同意する
|
|
161
|
+
required: true
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
let mokkunInstance = null;
|
|
165
|
+
let currentTheme = 'light';
|
|
166
|
+
|
|
167
|
+
// Initialize Mokkun
|
|
168
|
+
async function initMokkun() {
|
|
169
|
+
try {
|
|
170
|
+
mokkunInstance = await Mokkun.init({
|
|
171
|
+
container: '#content',
|
|
172
|
+
yamlContent: yamlContent,
|
|
173
|
+
theme: currentTheme,
|
|
174
|
+
onReady: function(instance) {
|
|
175
|
+
console.log('Mokkun initialized!');
|
|
176
|
+
console.log('Available screens:', instance.getScreenNames());
|
|
177
|
+
console.log('Version:', Mokkun.VERSION);
|
|
178
|
+
updateThemeButtons();
|
|
179
|
+
},
|
|
180
|
+
onError: function(error) {
|
|
181
|
+
console.error('Mokkun initialization failed:', error);
|
|
182
|
+
document.getElementById('content').innerHTML =
|
|
183
|
+
'<div style="color: red; padding: 20px;">Error: ' + error.message + '</div>';
|
|
184
|
+
},
|
|
185
|
+
onSubmit: function(screenName, formData) {
|
|
186
|
+
console.log('Form submitted:', { screenName, formData });
|
|
187
|
+
alert('フォームが送信されました!\nコンソールでデータを確認できます。');
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.error('Failed to initialize:', error);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Theme switching
|
|
196
|
+
function setTheme(themeId) {
|
|
197
|
+
currentTheme = themeId;
|
|
198
|
+
if (mokkunInstance) {
|
|
199
|
+
mokkunInstance.setTheme(themeId);
|
|
200
|
+
}
|
|
201
|
+
updateThemeButtons();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function updateThemeButtons() {
|
|
205
|
+
document.querySelectorAll('.demo-controls button').forEach(btn => {
|
|
206
|
+
btn.classList.remove('active');
|
|
207
|
+
});
|
|
208
|
+
const activeBtn = document.getElementById('theme-' + currentTheme);
|
|
209
|
+
if (activeBtn) {
|
|
210
|
+
activeBtn.classList.add('active');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Screen navigation
|
|
215
|
+
window.showScreen = function(screenName) {
|
|
216
|
+
if (mokkunInstance) {
|
|
217
|
+
mokkunInstance.showScreen(screenName);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// Initialize on page load
|
|
222
|
+
initMokkun();
|
|
223
|
+
</script>
|
|
224
|
+
</body>
|
|
225
|
+
</html>
|