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.
Files changed (65) hide show
  1. package/bin/viewer.html +76 -1
  2. package/dist/example.html +225 -0
  3. package/dist/mokkun.esm.js +8662 -5797
  4. package/dist/mokkun.esm.js.map +1 -1
  5. package/dist/mokkun.js +592 -231
  6. package/dist/mokkun.js.map +1 -1
  7. package/dist/types/lib.d.ts +32 -3
  8. package/dist/types/loader/file-loader.d.ts +5 -1
  9. package/dist/types/parser/index.d.ts +1 -0
  10. package/dist/types/parser/v2/compile-expand.d.ts +23 -0
  11. package/dist/types/parser/v2/compile-field.d.ts +28 -0
  12. package/dist/types/parser/v2/compile-section.d.ts +6 -0
  13. package/dist/types/parser/v2/compile-v2.d.ts +14 -0
  14. package/dist/types/parser/v2/compile-warnings.d.ts +17 -0
  15. package/dist/types/parser/v2/file-spec.d.ts +24 -0
  16. package/dist/types/parser/v2/index.d.ts +5 -0
  17. package/dist/types/parser/v2/iso-date.d.ts +10 -0
  18. package/dist/types/parser/v2/parse-v2.d.ts +24 -0
  19. package/dist/types/parser/v2/validate-action.d.ts +11 -0
  20. package/dist/types/parser/v2/validate-app.d.ts +9 -0
  21. package/dist/types/parser/v2/validate-context.d.ts +41 -0
  22. package/dist/types/parser/v2/validate-field.d.ts +17 -0
  23. package/dist/types/parser/v2/validate-keys.d.ts +29 -0
  24. package/dist/types/parser/v2/validate-list.d.ts +5 -0
  25. package/dist/types/parser/v2/validate-v2.d.ts +6 -0
  26. package/dist/types/parser/v2/validate-view.d.ts +6 -0
  27. package/dist/types/parser/yaml-parser.d.ts +10 -0
  28. package/dist/types/renderer/screen-renderer.d.ts +4 -0
  29. package/dist/types/renderer-v2/actions.d.ts +30 -0
  30. package/dist/types/renderer-v2/app-shell.d.ts +15 -0
  31. package/dist/types/renderer-v2/condition.d.ts +19 -0
  32. package/dist/types/renderer-v2/context.d.ts +37 -0
  33. package/dist/types/renderer-v2/fields/choice.d.ts +12 -0
  34. package/dist/types/renderer-v2/fields/control-label.d.ts +57 -0
  35. package/dist/types/renderer-v2/fields/date.d.ts +6 -0
  36. package/dist/types/renderer-v2/fields/display.d.ts +22 -0
  37. package/dist/types/renderer-v2/fields/file-support.d.ts +15 -0
  38. package/dist/types/renderer-v2/fields/file.d.ts +9 -0
  39. package/dist/types/renderer-v2/fields/index.d.ts +20 -0
  40. package/dist/types/renderer-v2/fields/select.d.ts +17 -0
  41. package/dist/types/renderer-v2/fields/text.d.ts +26 -0
  42. package/dist/types/renderer-v2/fields/textarea.d.ts +5 -0
  43. package/dist/types/renderer-v2/fields/toggle.d.ts +6 -0
  44. package/dist/types/renderer-v2/icons.d.ts +35 -0
  45. package/dist/types/renderer-v2/index.d.ts +45 -0
  46. package/dist/types/renderer-v2/list-cells.d.ts +6 -0
  47. package/dist/types/renderer-v2/list-data.d.ts +53 -0
  48. package/dist/types/renderer-v2/mount-parts.d.ts +19 -0
  49. package/dist/types/renderer-v2/mount-repeat.d.ts +8 -0
  50. package/dist/types/renderer-v2/mount-section.d.ts +10 -0
  51. package/dist/types/renderer-v2/mount-visibility.d.ts +13 -0
  52. package/dist/types/renderer-v2/mount.d.ts +9 -0
  53. package/dist/types/renderer-v2/role.d.ts +15 -0
  54. package/dist/types/renderer-v2/section-fields.d.ts +11 -0
  55. package/dist/types/renderer-v2/section-list.d.ts +8 -0
  56. package/dist/types/renderer-v2/section-readonly.d.ts +8 -0
  57. package/dist/types/renderer-v2/section.d.ts +15 -0
  58. package/dist/types/renderer-v2/styles.d.ts +13 -0
  59. package/dist/types/renderer-v2/util.d.ts +28 -0
  60. package/dist/types/renderer-v2/view-state.d.ts +25 -0
  61. package/dist/types/renderer-v2/view.d.ts +8 -0
  62. package/dist/types/types/index.d.ts +1 -0
  63. package/dist/types/types/schema-v2.d.ts +270 -0
  64. package/dist/types/types/schema.d.ts +11 -0
  65. package/package.json +1 -1
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Mokkun v2 フォーマット 型定義
3
+ * 6層(App / Flow / View / Section / Field / Component)を入れ子にした YAML 構造。
4
+ * 仕様: docs/format-redesign/02-schema-v2.md
5
+ * 正規形は camelCase。内部では compileV2 で旧フォーマット(MokkunSchema)へ変換する。
6
+ */
7
+ /**
8
+ * v2 YAML のルート構造
9
+ */
10
+ export interface MokkunV2Schema {
11
+ /** フォーマットバージョン(2 固定) */
12
+ mokkun: 2;
13
+ /** App 層 */
14
+ app: AppV2;
15
+ /** Flow 層(name → Flow) */
16
+ flows?: Record<string, FlowV2>;
17
+ /** View 層(name → View) */
18
+ views: Record<string, ViewV2>;
19
+ /** 再利用可能な Section(name → Section の一部) */
20
+ patterns?: Record<string, PatternV2>;
21
+ /** 共通バリデーション(name → ルール) */
22
+ rules?: Record<string, RuleV2>;
23
+ }
24
+ export type AppLayoutV2 = 'shell' | 'plain';
25
+ export interface AppHeaderV2 {
26
+ systemName?: string;
27
+ userName?: string;
28
+ userEmail?: string;
29
+ tenantName?: string;
30
+ helpUrl?: string;
31
+ }
32
+ export interface NavItemV2 {
33
+ /** views のキー */
34
+ view: string;
35
+ /** 省略時は view の title */
36
+ label?: string;
37
+ icon?: string;
38
+ }
39
+ /** ロール指定(文字列または配列。省略は全ロール) */
40
+ export type RoleSpecV2 = string | string[];
41
+ export interface NavGroupV2 {
42
+ group: string;
43
+ items: NavItemV2[];
44
+ /** このロールにだけ表示する(省略は全ロール)。app.roles の値 */
45
+ role?: RoleSpecV2;
46
+ }
47
+ export type NoticeVariantV2 = 'info' | 'success' | 'warning' | 'error';
48
+ export interface NoticeV2 {
49
+ variant?: NoticeVariantV2;
50
+ message: string;
51
+ dismissible?: boolean;
52
+ /** このロールにだけ表示する(省略は全ロール)。app.roles の値 */
53
+ role?: RoleSpecV2;
54
+ /** 掲示期限(ISO 日付 YYYY-MM-DD)。今日がこれより後なら表示しない */
55
+ until?: string;
56
+ }
57
+ export interface AppV2 {
58
+ name: string;
59
+ layout?: AppLayoutV2;
60
+ header?: AppHeaderV2;
61
+ roles?: string[];
62
+ navigation?: NavGroupV2[];
63
+ notifications?: NoticeV2[];
64
+ }
65
+ export interface FlowStepV2 {
66
+ view: string;
67
+ /** 省略時は view の title */
68
+ label?: string;
69
+ }
70
+ export interface FlowV2 {
71
+ name: string;
72
+ outcome: string;
73
+ role?: string;
74
+ steps: FlowStepV2[];
75
+ progress?: 'stepper' | 'none';
76
+ resumable?: boolean;
77
+ }
78
+ export type ViewLayoutV2 = 'stack' | 'tabs' | 'sectioned';
79
+ export type ActionKindV2 = 'submit' | 'navigate' | 'custom' | 'reset';
80
+ export type ActionPlacementV2 = 'header' | 'footer' | 'sticky';
81
+ export type ActionStyleV2 = 'primary' | 'secondary' | 'tertiary' | 'danger';
82
+ export interface ActionConfirmV2 {
83
+ message: string;
84
+ danger?: boolean;
85
+ }
86
+ export interface ActionV2 {
87
+ id: string;
88
+ label: string;
89
+ kind?: ActionKindV2;
90
+ /** navigate の遷移先 view */
91
+ to?: string;
92
+ placement?: ActionPlacementV2;
93
+ style?: ActionStyleV2;
94
+ confirm?: ActionConfirmV2;
95
+ /** このロールにだけ表示する(省略は全ロール)。app.roles の値 */
96
+ role?: RoleSpecV2;
97
+ }
98
+ export interface StateMessageV2 {
99
+ message: string;
100
+ }
101
+ export interface ViewStatesV2 {
102
+ empty?: StateMessageV2;
103
+ loading?: StateMessageV2;
104
+ success?: StateMessageV2;
105
+ error?: StateMessageV2;
106
+ }
107
+ export interface ViewV2 {
108
+ title: string;
109
+ goal: string;
110
+ nav?: string;
111
+ role?: string;
112
+ layout?: ViewLayoutV2;
113
+ description?: string;
114
+ primaryAction?: ActionV2;
115
+ secondaryActions?: ActionV2[];
116
+ states?: ViewStatesV2;
117
+ sections: SectionV2[];
118
+ }
119
+ export type SectionKindV2 = 'form' | 'list' | 'readonly' | 'summary';
120
+ export interface RepeatableV2 {
121
+ min?: number;
122
+ max?: number;
123
+ addLabel?: string;
124
+ }
125
+ /** 条件で使える値 */
126
+ export type ConditionValueV2 = string | number | boolean;
127
+ /**
128
+ * 条件(visibleWhen / requiredWhen)。equals / notEquals / in のうち 1 つだけを書く。
129
+ * - equals: item の値が等しい
130
+ * - notEquals: item の値が等しくない
131
+ * - in: item の値が配列のどれかと等しい
132
+ */
133
+ export interface ConditionV2 {
134
+ item: string;
135
+ equals?: ConditionValueV2;
136
+ notEquals?: ConditionValueV2;
137
+ in?: ConditionValueV2[];
138
+ }
139
+ /** 一覧セルの型(既定 text) */
140
+ export type ListColumnTypeV2 = 'text' | 'status' | 'date' | 'number';
141
+ /** 一覧セルに置ける入力(item / label は持たない)。text / number / select / checkbox のみ */
142
+ export type ListColumnFieldV2 = Omit<FieldV2, 'item' | 'label'>;
143
+ export interface ListColumnV2 {
144
+ id: string;
145
+ label: string;
146
+ sortable?: boolean;
147
+ /** セルの型。status はチップ、date は日本語の日付、number は右寄せ */
148
+ type?: ListColumnTypeV2;
149
+ /** セルを遷移リンクにする view 名(rows 内の値がリンクの文言になる) */
150
+ to?: string;
151
+ /** セルに入力欄を置く(list.rows が必要。name は `<rowKey>.<columnId>`) */
152
+ field?: ListColumnFieldV2;
153
+ }
154
+ export interface ListRowActionV2 {
155
+ id: string;
156
+ label: string;
157
+ kind?: ActionKindV2;
158
+ to?: string;
159
+ }
160
+ export interface ListV2 {
161
+ columns: ListColumnV2[];
162
+ rowActions?: ListRowActionV2[];
163
+ search?: boolean;
164
+ paging?: {
165
+ pageSize?: number;
166
+ };
167
+ selection?: 'none' | 'single' | 'multiple';
168
+ empty?: string;
169
+ /** 選択した行への操作(selection が multiple のときだけ)。行 ID は onAction の payload.selectedRows */
170
+ bulkActions?: ActionV2[];
171
+ /** 代表行(キーは列 id)。あればダミー行の代わりに使う */
172
+ rows?: Array<Record<string, unknown>>;
173
+ }
174
+ export interface SectionV2 {
175
+ id: string;
176
+ title: string;
177
+ purpose?: string;
178
+ kind?: SectionKindV2;
179
+ reveal?: 'open' | 'collapsed';
180
+ repeatable?: RepeatableV2;
181
+ note?: string;
182
+ columns?: 1 | 2 | 3;
183
+ visibleWhen?: ConditionV2;
184
+ /** patterns のキー */
185
+ use?: string;
186
+ fields?: FieldV2[];
187
+ list?: ListV2;
188
+ /** 見出し行に置く操作(primary は不可)。確認画面の修正する、絞り込みの検索・リセットなど */
189
+ actions?: ActionV2[];
190
+ }
191
+ /** patterns の値(fields と note のみ。use のネストは非対応) */
192
+ export interface PatternV2 {
193
+ fields?: FieldV2[];
194
+ note?: string;
195
+ }
196
+ export type ComponentV2 = 'text' | 'number' | 'textarea' | 'date' | 'time' | 'duration' | 'file' | 'photo_grid' | 'select' | 'combobox' | 'radio' | 'checkbox' | 'toggle' | 'browser' | 'badge' | 'chip' | 'status' | 'timeline' | 'map';
197
+ /** 有効な component 一覧(パーサーとテストで共有) */
198
+ export declare const VALID_COMPONENTS_V2: readonly ComponentV2[];
199
+ /** 入力欄の幅(xs ≈ 6rem / sm ≈ 10rem / md ≈ 20rem / lg ≈ 30rem / full = 100%)。旧レンダラーでは無視 */
200
+ export type FieldWidthV2 = 'xs' | 'sm' | 'md' | 'lg' | 'full';
201
+ export interface OptionV2 {
202
+ value: string | number | boolean;
203
+ label: string;
204
+ }
205
+ /** 共通バリデーションルール */
206
+ export interface RuleV2 {
207
+ required?: boolean | string;
208
+ min?: number | string;
209
+ max?: number | string;
210
+ pattern?: string | {
211
+ regex: string;
212
+ message: string;
213
+ };
214
+ custom?: string;
215
+ message?: string;
216
+ }
217
+ /** file の accept(キーワードまたは拡張子・MIME タイプの配列) */
218
+ export type FileAcceptV2 = 'image' | 'pdf' | 'document' | string | string[];
219
+ export type DatePrecisionV2 = 'day' | 'month';
220
+ export interface FieldLinkV2 {
221
+ label: string;
222
+ href: string;
223
+ }
224
+ /** timeline の構造化された値 */
225
+ export interface TimelineEntryV2 {
226
+ at: string;
227
+ label: string;
228
+ text?: string;
229
+ }
230
+ export interface FieldV2 {
231
+ /** 業務の名詞。id として使う */
232
+ item: string;
233
+ label: string;
234
+ component: ComponentV2;
235
+ required?: boolean;
236
+ whyRequired?: string;
237
+ example?: string;
238
+ help?: string;
239
+ format?: string;
240
+ default?: unknown;
241
+ options?: OptionV2[];
242
+ multiple?: boolean;
243
+ variant?: string;
244
+ inline?: boolean;
245
+ /** file の種別。image / pdf / document、または拡張子・MIME タイプの配列 */
246
+ accept?: FileAcceptV2;
247
+ /** file の 1 ファイルあたりの上限(例 "10MB"。KB / MB / GB) */
248
+ maxSize?: string;
249
+ /** 入力欄の後ろに付ける単位(円・件など) */
250
+ unit?: string;
251
+ /** date の精度。month は年月だけ(visibleWhen の値は `y-m`) */
252
+ precision?: DatePrecisionV2;
253
+ /** HTML の autocomplete トークン。date では `bday` が bday-year/month/day になる */
254
+ autocomplete?: string;
255
+ /** サポートテキストの後ろに出すリンク */
256
+ links?: FieldLinkV2[];
257
+ /** この条件が成り立つときだけ必須(required: true とは併用しない) */
258
+ requiredWhen?: ConditionV2;
259
+ /** summary / readonly の値を遷移リンクにする view 名 */
260
+ to?: string;
261
+ value?: unknown;
262
+ readonly?: boolean;
263
+ /** 文字列は rules のキー */
264
+ rules?: Array<string | RuleV2>;
265
+ visibleWhen?: ConditionV2;
266
+ /** 入力欄の幅 */
267
+ width?: FieldWidthV2;
268
+ /** component 固有の追加設定(旧フィールド属性をそのまま渡す) */
269
+ props?: Record<string, unknown>;
270
+ }
@@ -153,6 +153,8 @@ export interface ScreenDefinition {
153
153
  title: string;
154
154
  /** 画面の説明 */
155
155
  description?: string;
156
+ /** 画面の目的(v2 の goal など) */
157
+ purpose?: string;
156
158
  /** アプリケーションヘッダー設定 */
157
159
  app_header?: AppHeaderConfigSchema;
158
160
  /** アプリケーションナビゲーション設定 */
@@ -982,6 +984,8 @@ export interface TooltipField extends Omit<BaseInputField, 'placeholder'> {
982
984
  */
983
985
  export interface BadgeField extends BaseInputField {
984
986
  type: 'badge';
987
+ /** 表示値(指定時はラベルの代わりに表示する) */
988
+ value?: string | number;
985
989
  /** バッジのカラー */
986
990
  color?: 'gray' | 'blue' | 'green' | 'yellow' | 'red';
987
991
  /** サイズ */
@@ -1261,6 +1265,8 @@ export interface TimelineField extends BaseInputField {
1261
1265
  */
1262
1266
  export interface ChipField extends BaseInputField {
1263
1267
  type: 'chip';
1268
+ /** 表示テキスト(未指定時は label) */
1269
+ value?: string | number;
1264
1270
  /** バリアント */
1265
1271
  variant?: 'default' | 'primary' | 'success' | 'warning' | 'danger';
1266
1272
  /** 削除可能 */
@@ -1271,6 +1277,8 @@ export interface ChipField extends BaseInputField {
1271
1277
  */
1272
1278
  export interface StatusLabelField extends BaseInputField {
1273
1279
  type: 'status_label';
1280
+ /** 表示テキスト(未指定時は label) */
1281
+ value?: string | number;
1274
1282
  /** バリアント */
1275
1283
  variant?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
1276
1284
  }
@@ -1335,6 +1343,8 @@ export interface AccordionPanelField extends BaseInputField {
1335
1343
  type: 'accordion_panel';
1336
1344
  /** 初期状態で開く */
1337
1345
  defaultOpen?: boolean;
1346
+ /** パネル内に表示するフィールド(静的レンダリング用) */
1347
+ fields?: InputField[];
1338
1348
  }
1339
1349
  /**
1340
1350
  * セクションナビフィールド
@@ -1369,6 +1379,7 @@ export interface StepperField extends BaseInputField {
1369
1379
  id: string;
1370
1380
  label: string;
1371
1381
  completed?: boolean;
1382
+ status?: StepStatus | StepStatusWithText;
1372
1383
  }>;
1373
1384
  /** 現在のステップ */
1374
1385
  currentStep?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mokkun",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "description": "YAML-based presentation and form builder",
5
5
  "type": "module",
6
6
  "bin": {