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
@@ -3,8 +3,11 @@
3
3
  * YAML-based presentation and form builder
4
4
  */
5
5
  import './style.css';
6
- import { parseYaml, getScreen, getScreenNames, findFieldById } from './parser';
6
+ import { parseYaml, parseYamlV2, parseV2Document, isV2Document, getScreen, getScreenNames, findFieldById } from './parser';
7
+ import { mountViewV2, renderViewV2, type V2Controller, type V2Callbacks, type V2ViewState } from './renderer-v2';
8
+ import { compileV2Warnings } from './parser/v2/compile-warnings';
7
9
  import type { MokkunSchema, ScreenDefinition, BuiltInThemeId } from './types';
10
+ import type { MokkunV2Schema } from './types/schema-v2';
8
11
  /**
9
12
  * Mokkun initialization options
10
13
  */
@@ -17,8 +20,14 @@ export interface MokkunInitOptions {
17
20
  yamlContent?: string;
18
21
  /** Initial theme ('light' | 'dark') */
19
22
  theme?: BuiltInThemeId | string;
23
+ /** v2 文書で、画面遷移時に location.hash も書き換える(既定 false) */
24
+ syncHash?: boolean;
20
25
  /** Initial screen to display */
21
26
  initialScreen?: string;
27
+ /** v2 文書: 現在のロール(app.roles の値)。ロール外の操作・ナビ・通知を出さない。未指定は全ロール分を表示 */
28
+ role?: string;
29
+ /** v2 文書: 最初の画面の状態(normal / success / error / empty / loading)。既定 normal(状態バナーなし) */
30
+ initialState?: V2ViewState;
22
31
  /** Callback when ready */
23
32
  onReady?: (instance: MokkunInstance) => void;
24
33
  /** Callback on error */
@@ -32,12 +41,24 @@ export interface MokkunInitOptions {
32
41
  * Mokkun instance returned by init()
33
42
  */
34
43
  export interface MokkunInstance {
35
- /** Current schema */
44
+ /** Current schema(v2 文書のときは null。schemaV2 を使う) */
36
45
  readonly schema: MokkunSchema | null;
46
+ /** Current v2 schema(v1 文書のときは null) */
47
+ readonly schemaV2: MokkunV2Schema | null;
37
48
  /** Current screen name */
38
49
  readonly currentScreen: string | null;
39
50
  /** Navigate to a screen */
40
51
  showScreen: (screenName: string) => void;
52
+ /** v2 文書: 現在のロール。変更すると現在の画面を描き直す(undefined は全ロール) */
53
+ setRole: (role: string | undefined) => void;
54
+ /** v2 文書: 現在の画面の状態。変更すると描き直す */
55
+ setState: (viewState: V2ViewState) => void;
56
+ /** v2 文書: 現在の画面で選べる状態(normal は常に。success / error / empty / loading は対応する states.* があるとき) */
57
+ getAvailableStates: () => V2ViewState[];
58
+ /** v2 文書: 現在のロール */
59
+ readonly role: string | undefined;
60
+ /** v2 文書: 現在の画面の状態 */
61
+ readonly viewState: V2ViewState;
41
62
  /** Get available screen names */
42
63
  getScreenNames: () => string[];
43
64
  /** Change theme */
@@ -64,6 +85,10 @@ export declare const Mokkun: {
64
85
  /** Utility functions */
65
86
  utils: {
66
87
  parseYaml: typeof parseYaml;
88
+ parseYamlV2: typeof parseYamlV2;
89
+ compileV2Warnings: typeof compileV2Warnings;
90
+ /** v2 の状態の表示名(ビューアーのセレクトに使う) */
91
+ V2_STATE_LABELS: Record<V2ViewState, string>;
67
92
  getScreen: typeof getScreen;
68
93
  getScreenNames: typeof getScreenNames;
69
94
  findFieldById: typeof findFieldById;
@@ -75,6 +100,10 @@ export declare const Mokkun: {
75
100
  getAvailable: () => import("./types").ThemeDefinition[];
76
101
  };
77
102
  };
78
- export type { MokkunSchema, ScreenDefinition, BuiltInThemeId };
103
+ export type { MokkunSchema, ScreenDefinition, BuiltInThemeId, MokkunV2Schema };
104
+ export { renderViewV2, mountViewV2, parseYamlV2, parseV2Document, isV2Document, compileV2Warnings };
105
+ export type { V2Controller, V2Callbacks, V2ViewState };
106
+ export type { V2RenderOptions, V2ActionPayload } from './renderer-v2';
107
+ export type { V2CompileWarning } from './parser/v2/compile-warnings';
79
108
  export { Textarea, createTextarea, type TextareaState, type TextareaCallbacks, type TextareaConfig, } from './renderer/components/textarea';
80
109
  export { Combobox, type ComboboxOption, type ComboboxConfig, type ComboboxState, type ComboboxCallbacks, } from './renderer/components';
@@ -3,6 +3,7 @@
3
3
  * YAMLファイルの読み込み機能を提供
4
4
  */
5
5
  import type { MokkunSchema } from '../types/schema';
6
+ import type { MokkunV2Schema } from '../types/schema-v2';
6
7
  import type { ParseError } from '../parser/yaml-parser';
7
8
  /**
8
9
  * ファイル読み込みエラーの種類
@@ -22,7 +23,10 @@ export interface FileLoadError {
22
23
  */
23
24
  export interface FileLoadSuccess {
24
25
  success: true;
25
- schema: MokkunSchema;
26
+ /** v1 スキーマ。v2 文書では compileV2 の結果(変換できなければ null) */
27
+ schema: MokkunSchema | null;
28
+ /** v2 文書(mokkun: 2)のとき、検証済みの v2 スキーマ。v2 専用レンダラーの入力 */
29
+ schemaV2?: MokkunV2Schema;
26
30
  fileName: string;
27
31
  source: 'file' | 'url' | 'drop';
28
32
  /** 読み込んだ YAML の原文(コメント・順序を保持) */
@@ -2,3 +2,4 @@
2
2
  * Parser exports
3
3
  */
4
4
  export * from './yaml-parser';
5
+ export * from './v2';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Section の項目展開(patterns の use)。パーサー・コンパイラ・レンダラーで共有する軽量モジュール
3
+ */
4
+ import type { FieldV2, PatternV2, SectionV2 } from '../../types/schema-v2';
5
+ /**
6
+ * 合成フィールド(stepper / 通知 / 一覧など)の id 接頭辞。item と衝突しない。
7
+ * セクション由来は `_v2_s_`(本体)/ `_v2_n_`(note)/ `_v2_p_`(accordion)+ section.id、
8
+ * view 由来は `_v2_` + 固定名で、互いに衝突しない。
9
+ */
10
+ export declare const SYNTH_PREFIX = "_v2_";
11
+ /** section 内の展開済みフィールド(use 由来は id に section.id を前置) */
12
+ export interface ExpandedField {
13
+ field: FieldV2;
14
+ id: string;
15
+ /** patterns 由来か */
16
+ fromPattern: boolean;
17
+ }
18
+ /**
19
+ * section.fields と patterns[use].fields を展開する。
20
+ * pattern 由来のフィールドは id を `<sectionId>_<item>` にし、
21
+ * pattern 内で同じ pattern のフィールドを指す visibleWhen / requiredWhen は前置した id に書き換える。
22
+ */
23
+ export declare function expandSectionFields(section: SectionV2, patterns: Record<string, PatternV2> | undefined): ExpandedField[];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * v2 の Field / Condition を旧フォーマットの InputField / Condition に変換する
3
+ */
4
+ import type { Condition, InputField } from '../../types/schema';
5
+ import type { ConditionV2, FieldV2, RuleV2 } from '../../types/schema-v2';
6
+ import type { ExpandedField } from './compile-expand';
7
+ /** 緩い型のフィールド(旧フォーマットは種類ごとに属性が異なるため) */
8
+ export type LooseField = Record<string, unknown> & {
9
+ id: string;
10
+ type: string;
11
+ label: string;
12
+ };
13
+ /**
14
+ * 条件を旧フォーマットの条件にする。
15
+ * equals → eq、notEquals → ne、in → in(旧スキーマの SimpleCondition が持つ演算子)
16
+ */
17
+ export declare function compileCondition(cond: ConditionV2): Condition;
18
+ /** v2 の accept → 旧 file_upload の accept 配列(image は image_uploader になるため扱わない) */
19
+ export declare function legacyAccept(accept: FieldV2['accept']): string[] | undefined;
20
+ /** timeline の value({ at, label, text? }[])→ 旧 timeline の items */
21
+ export declare function legacyTimelineItems(value: unknown): Array<{
22
+ time: string;
23
+ title: string;
24
+ description?: string;
25
+ }> | undefined;
26
+ export declare function compileField(ef: ExpandedField, ruleDefs: Record<string, RuleV2> | undefined): InputField;
27
+ /** トップレベルのフィールドに section の表示条件を付与(既に条件があるものは維持) */
28
+ export declare function applySectionCondition(fields: InputField[], cond: ConditionV2 | undefined): InputField[];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * v2 の Section を旧フォーマットの FormSection に変換する
3
+ */
4
+ import type { FormSection } from '../../types/schema';
5
+ import type { MokkunV2Schema, SectionV2, ViewV2 } from '../../types/schema-v2';
6
+ export declare function compileSection(section: SectionV2, v2: MokkunV2Schema, view: ViewV2): FormSection;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Mokkun v2 コンパイラ
3
+ * v2 フォーマット(camelCase, 6層)を旧フォーマット(MokkunSchema, snake_case 内部キー)へ変換する。
4
+ * 規則: docs/format-redesign/02-schema-v2.md 末尾の「コンパイル規則」
5
+ * 旧フォーマットで表現できないキーは compileV2Warnings(compile-warnings.ts)が列挙する。
6
+ */
7
+ import type { MokkunSchema } from '../../types/schema';
8
+ import type { MokkunV2Schema } from '../../types/schema-v2';
9
+ export { SYNTH_PREFIX, expandSectionFields, type ExpandedField } from './compile-expand';
10
+ export { compileV2Warnings, type V2CompileWarning } from './compile-warnings';
11
+ /**
12
+ * v2 スキーマを旧フォーマット(MokkunSchema)へコンパイル
13
+ */
14
+ export declare function compileV2(v2: MokkunV2Schema): MokkunSchema;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * v2 → 旧フォーマットの変換で、旧スキーマ/旧レンダラーが表現できずに落ちるキーの一覧。
3
+ * ビューアーはコンソールにだけ出す(画面には出さない)。仕様の「コンパイル規則」の「未対応」と対応する。
4
+ */
5
+ import type { MokkunV2Schema } from '../../types/schema-v2';
6
+ export interface V2CompileWarning {
7
+ /** 対象の位置(パーサーのエラーと同じ書き方。例 views.order_form.sections[0].fields[1]) */
8
+ path: string;
9
+ /** 落ちるキー(例 unit、list.bulkActions) */
10
+ key: string;
11
+ message: string;
12
+ }
13
+ /**
14
+ * compileV2 が旧フォーマットへ変換するときに無視するキーを列挙する(検証済みの v2 スキーマを渡す)。
15
+ * 変換結果は変えない。
16
+ */
17
+ export declare function compileV2Warnings(schema: MokkunV2Schema): V2CompileWarning[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * file の accept / maxSize の仕様(パーサー・コンパイラ・レンダラーで共有)
3
+ */
4
+ /** accept のキーワード */
5
+ export declare const ACCEPT_KEYWORDS: readonly ["image", "pdf", "document"];
6
+ /** accept の配列要素: 拡張子(.pdf)または MIME タイプ(image/png, image/*) */
7
+ export declare const ACCEPT_EXT_PATTERN: RegExp;
8
+ export declare const ACCEPT_MIME_PATTERN: RegExp;
9
+ /** 旧来の HTML accept 文字列(".pdf" "image/png"。カンマ区切りも可)を許す判定 */
10
+ export declare const ACCEPT_LEGACY_PATTERN: RegExp;
11
+ /** maxSize: 正の整数 + KB / MB / GB("0MB" や "010MB" は不可) */
12
+ export declare const MAX_SIZE_PATTERN: RegExp;
13
+ export declare const ACCEPT_FORMS = "image / pdf / document\u3001\u307E\u305F\u306F [\".pdf\", \"image/png\"] \u306E\u3088\u3046\u306A\u62E1\u5F35\u5B50\u30FBMIME \u30BF\u30A4\u30D7\u306E\u914D\u5217";
14
+ export declare const MAX_SIZE_FORMS = "\u6B63\u306E\u6574\u6570 + KB / MB / GB\uFF08\u4F8B: \"10MB\"\uFF09";
15
+ /** 配列要素として正しいか */
16
+ export declare function isAcceptToken(token: unknown): boolean;
17
+ /** キーワード → `<input accept>` */
18
+ export declare const ACCEPT_INPUT_ATTR: Record<string, string>;
19
+ /** キーワード → サポートテキストの形式名 */
20
+ export declare const ACCEPT_LABEL: Record<string, string>;
21
+ /** キーワード → 旧 file_upload の accept(拡張子・MIME タイプの配列) */
22
+ export declare const ACCEPT_LEGACY_LIST: Record<string, string[]>;
23
+ /** "10MB" → バイト数(書式外は undefined) */
24
+ export declare function maxSizeToBytes(text: string | undefined): number | undefined;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * v2 parser exports
3
+ */
4
+ export * from './parse-v2';
5
+ export * from './compile-v2';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ISO 日付(YYYY-MM-DD)と、YAML の日付リテラル(js-yaml が Date にする)の正規化
3
+ */
4
+ /** YYYY-MM-DD として実在する日付か */
5
+ export declare function isIsoDate(text: string): boolean;
6
+ /**
7
+ * 値の中の Date(引用符なしの `2026-11-20` を js-yaml が変換したもの)を、再帰的に UTC の `YYYY-MM-DD` 文字列にする。
8
+ * 元のデータは変更せず、Date を含むときだけ複製する。
9
+ */
10
+ export declare function normalizeDates<T>(value: T): T;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Mokkun v2 パーサー
3
+ * 判別(isV2Document)、構造検証(ajv に依存せず手書き)、compileV2 による旧フォーマットへの変換
4
+ */
5
+ import type { MokkunSchema } from '../../types/schema';
6
+ import type { MokkunV2Schema } from '../../types/schema-v2';
7
+ import type { ParseResult } from '../yaml-parser';
8
+ /**
9
+ * v2 ドキュメントかどうか(トップレベルの `mokkun` が 2)
10
+ */
11
+ export declare function isV2Document(data: unknown): boolean;
12
+ /**
13
+ * トップレベルに `mokkun` キーがあるか(バージョン不一致を v1 として扱わないための判定)
14
+ */
15
+ export declare function hasMokkunVersionKey(data: unknown): boolean;
16
+ /**
17
+ * v2 ドキュメント(yaml.load 済みの生データ)を検証し、検証済みの MokkunV2Schema を返す(コンパイルしない)
18
+ * v2 専用レンダラー(renderer-v2)の入力に使う
19
+ */
20
+ export declare function parseV2Document(raw: unknown): ParseResult<MokkunV2Schema>;
21
+ /**
22
+ * v2 ドキュメント(yaml.load 済みの生データ)を検証し、旧フォーマットへコンパイルする
23
+ */
24
+ export declare function parseV2(data: unknown): ParseResult<MokkunSchema>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Action の検証(View の主・副アクション、rowActions、bulkActions、Section.actions で共通)
3
+ */
4
+ import { type VCtx } from './validate-context';
5
+ export interface ActionCheckOptions {
6
+ /** Section.actions のとき true。primary を持てるのは View だけなので style: primary を拒否する */
7
+ section?: boolean;
8
+ /** list.rowActions[] のとき true。id / label / kind / to だけを持てる(role・confirm・style・placement は不可) */
9
+ row?: boolean;
10
+ }
11
+ export declare function checkAction(v: VCtx, action: unknown, path: string, opts?: ActionCheckOptions): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * App 層(app / navigation / notifications)と Flow 層の検証
3
+ */
4
+ import { type Obj, type VCtx } from './validate-context';
5
+ /** app の形(views が無くても検証できる部分) */
6
+ export declare function checkApp(v: VCtx, app: Obj | undefined): void;
7
+ /** navigation を検証し、載っている view 名の集合を返す(undefined は navigation 未定義) */
8
+ export declare function checkNavigation(v: VCtx, navigation: unknown): Set<string> | undefined;
9
+ export declare function checkFlows(v: VCtx, flows: unknown): void;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * v2 検証の共通部分: 型ガード、列挙値、エラー収集のヘルパー
3
+ */
4
+ import type { ParseError, ParseErrorType } from '../yaml-parser';
5
+ export type Obj = Record<string, unknown>;
6
+ export declare function isObject(value: unknown): value is Obj;
7
+ export declare function isNonEmptyString(value: unknown): value is string;
8
+ export declare const APP_LAYOUTS: string[];
9
+ export declare const FLOW_PROGRESS: string[];
10
+ export declare const VIEW_LAYOUTS: string[];
11
+ export declare const SECTION_KINDS: string[];
12
+ export declare const REVEALS: string[];
13
+ export declare const ACTION_KINDS: string[];
14
+ export declare const ACTION_PLACEMENTS: string[];
15
+ export declare const ACTION_STYLES: string[];
16
+ export declare const FIELD_WIDTHS: string[];
17
+ export declare const SELECTIONS: string[];
18
+ export declare const NOTICE_VARIANTS: string[];
19
+ export declare const PATTERN_KEYS: string[];
20
+ export declare const COLUMN_TYPES: string[];
21
+ export declare const DATE_PRECISIONS: string[];
22
+ /** 一覧セルに置ける入力の component */
23
+ export declare const COLUMN_FIELD_COMPONENTS: string[];
24
+ /** 条件の比較キー(exactly one) */
25
+ export declare const CONDITION_KEYS: string[];
26
+ /** 検証の共有状態(エラーの収集と、参照先の存在確認に使う集合) */
27
+ export interface VCtx {
28
+ add: (type: ParseErrorType, message: string, path: string) => void;
29
+ checkEnum: (value: unknown, allowed: Array<string | number>, path: string, name: string) => void;
30
+ checkString: (value: unknown, path: string, name: string, required?: boolean) => void;
31
+ /** views のキーを参照しているか */
32
+ /** obj に allowed 以外のキーがあればエラー(schema-v2.json の additionalProperties: false に対応) */
33
+ checkKeys: (obj: Obj, allowed: readonly string[], path: string) => void;
34
+ checkViewRef: (name: unknown, path: string) => void;
35
+ /** role(文字列または配列)の形と、app.roles にあるかを確かめる */
36
+ checkRole: (value: unknown, path: string) => void;
37
+ /** トップレベル rules */
38
+ rules: Obj;
39
+ viewNames: Set<string>;
40
+ }
41
+ export declare function createVCtx(errors: ParseError[], data: Obj): VCtx;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Field と Condition の検証
3
+ */
4
+ import { type VCtx } from './validate-context';
5
+ /**
6
+ * 条件(visibleWhen / requiredWhen)の形だけを検証する(参照先の存在は view 単位で後段チェック)。
7
+ * equals / notEquals / in のうちちょうど 1 つが必要。
8
+ */
9
+ export declare function checkConditionShape(v: VCtx, cond: unknown, path: string, name?: string): boolean;
10
+ export interface FieldCheckOptions {
11
+ /** 一覧セルの入力欄(item / label を持たず、component は text / number / select / checkbox のみ) */
12
+ column?: boolean;
13
+ }
14
+ /** 項目の検証。条件の参照先と pattern 由来の展開は view 単位で後段チェックする */
15
+ export declare function checkField(v: VCtx, field: unknown, path: string, opts?: FieldCheckOptions): void;
16
+ /** 条件の参照先 item(形が正しいときだけ) */
17
+ export declare function conditionItem(cond: unknown): string | undefined;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 各オブジェクトに書けるキー(schema-v2.json の additionalProperties: false と同じ)
3
+ */
4
+ export declare const TOP_KEYS: string[];
5
+ export declare const APP_KEYS: string[];
6
+ export declare const HEADER_KEYS: string[];
7
+ export declare const NOTICE_KEYS: string[];
8
+ export declare const NAV_GROUP_KEYS: string[];
9
+ export declare const NAV_ITEM_KEYS: string[];
10
+ export declare const FLOW_KEYS: string[];
11
+ export declare const FLOW_STEP_KEYS: string[];
12
+ export declare const VIEW_KEYS: string[];
13
+ export declare const STATE_KEYS: string[];
14
+ export declare const STATE_MESSAGE_KEYS: string[];
15
+ export declare const SECTION_KEYS: string[];
16
+ export declare const REPEATABLE_KEYS: string[];
17
+ export declare const ACTION_KEYS: string[];
18
+ /** list.rowActions[] は id / label / kind / to だけ(role・confirm・style・placement は持てない) */
19
+ export declare const ROW_ACTION_KEYS: string[];
20
+ export declare const CONFIRM_KEYS: string[];
21
+ export declare const LIST_KEYS: string[];
22
+ export declare const COLUMN_KEYS: string[];
23
+ export declare const PAGING_KEYS: string[];
24
+ export declare const CONDITION_ALLOWED_KEYS: string[];
25
+ export declare const OPTION_KEYS: string[];
26
+ export declare const FIELD_KEYS: string[];
27
+ /** 一覧セルの入力欄: item / label / 条件 / to / links / precision / accept / maxSize / rules / whyRequired / example / format は持てない */
28
+ export declare const COLUMN_FIELD_KEYS: string[];
29
+ export declare const LINK_KEYS: string[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * kind: list の list オブジェクトの検証
3
+ */
4
+ import { type VCtx } from './validate-context';
5
+ export declare function checkList(v: VCtx, list: unknown, sp: string): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * v2 の構造を検証してエラー一覧を返す(ajv に依存せず手書き)。入力が不正でも例外を投げない。
3
+ */
4
+ import type { ParseError } from '../yaml-parser';
5
+ import { type Obj } from './validate-context';
6
+ export declare function validateV2(data: Obj): ParseError[];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * View 層と Section 層の検証(項目 id の重複、条件の参照先、action id の一意性を含む)
3
+ */
4
+ import type { PatternV2 } from '../../types/schema-v2';
5
+ import { type Obj, type VCtx } from './validate-context';
6
+ export declare function checkViews(v: VCtx, views: Obj, patterns: Record<string, PatternV2>, navViews: Set<string> | undefined): void;
@@ -2,6 +2,7 @@
2
2
  * Mokkun YAML Parser
3
3
  * YAMLテキストを型安全にパースする
4
4
  */
5
+ import type { MokkunV2Schema } from '../types/schema-v2';
5
6
  import type { MokkunSchema, ScreenDefinition, InputField, InputFieldType, CommonComponent, ValidationRule } from '../types/schema';
6
7
  /**
7
8
  * パースエラーの種類
@@ -32,6 +33,15 @@ export declare const VALID_FIELD_TYPES: InputFieldType[];
32
33
  * YAMLテキストをパースしてMokkunSchemaに変換
33
34
  */
34
35
  export declare function parseYaml(yamlText: string): ParseResult<MokkunSchema>;
36
+ /**
37
+ * YAMLテキストが v2 フォーマット(トップレベルの `mokkun: 2`)か判定する。YAML として読めない場合は false
38
+ */
39
+ export declare function isV2Yaml(yamlText: string): boolean;
40
+ /**
41
+ * v2 の YAMLテキストをパースし、検証済みの MokkunV2Schema を返す(旧フォーマットへはコンパイルしない)
42
+ * 既存の parseYaml の挙動は変えない
43
+ */
44
+ export declare function parseYamlV2(yamlText: string): ParseResult<MokkunV2Schema>;
35
45
  /**
36
46
  * パースエラーを整形して文字列に変換
37
47
  */
@@ -9,6 +9,10 @@ import { AppNavi } from './components/app-navi';
9
9
  * ウィザード画面をレンダリング
10
10
  */
11
11
  export declare function renderWizardScreen(screen: ScreenDefinition, currentStepIndex?: number): string;
12
+ /**
13
+ * セクションIDを生成(セクション名から安全なIDを生成)
14
+ */
15
+ export declare function generateSectionId(sectionName: string, index: number): string;
12
16
  /**
13
17
  * 通常画面をレンダリング(shell レイアウト固定)
14
18
  */
@@ -0,0 +1,30 @@
1
+ /**
2
+ * アクションボタンと確認ダイアログ(modal-dialog)
3
+ * primaryAction: solid-fill lg / secondary: outline md / tertiary: text md / danger: --button-color を error 色に(mokkun-v2.css の .mk2-button--danger)
4
+ * 並び順(DADS): tertiary が左端、secondary、primary が右端。DOM の順序をそのまま見た目にする(CSS で並べ替えない)
5
+ */
6
+ import type { ActionPlacementV2, ActionV2, ListV2, SectionV2 } from '../types/schema-v2';
7
+ import { type ViewContext } from './context';
8
+ export interface PlacedAction {
9
+ action: ActionV2;
10
+ primary: boolean;
11
+ placement: ActionPlacementV2;
12
+ }
13
+ /** Section.actions(見出し行の操作)。現在のロールで表示するもの */
14
+ export declare function sectionActions(section: SectionV2, ctx: ViewContext): ActionV2[];
15
+ /** list.bulkActions(選択した行への操作)。現在のロールで表示するもの */
16
+ export declare function bulkActions(list: ListV2, ctx: ViewContext): ActionV2[];
17
+ /** 画面のアクションを配置先つきで列挙する。primary が先頭。placement 未指定の secondary は primary に揃える。現在のロールで表示するものだけ */
18
+ export declare function collectActions(ctx: ViewContext): PlacedAction[];
19
+ export declare function dialogId(ctx: ViewContext, action: ActionV2): string;
20
+ /**
21
+ * 操作ボタン 1 つ。Section 内の操作(primary ではない)は extra で data-section / data-bulk を付ける。
22
+ * type: solid-fill は primary、text は tertiary、outline はそれ以外
23
+ */
24
+ export declare function renderActionButton(ctx: ViewContext, action: ActionV2, type: 'solid-fill' | 'outline' | 'text', size: 'lg' | 'md', extra?: Record<string, string | boolean | undefined>): string;
25
+ /** Section の操作(見出し行)。tertiary はテキスト、それ以外は outline md */
26
+ export declare function renderSectionButton(ctx: ViewContext, action: ActionV2, sectionId: string): string;
27
+ /** 指定した配置のアクション群。無ければ空文字 */
28
+ export declare function renderActions(ctx: ViewContext, placement: ActionPlacementV2): string;
29
+ /** action.confirm を持つアクションごとの <dialog>。静的 HTML に含め、mount 時にボタンから開く */
30
+ export declare function renderDialogs(ctx: ViewContext): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * App 層: ヘッダー、グローバルナビ、パンくず、通知
3
+ */
4
+ import type { NoticeVariantV2 } from '../types/schema-v2';
5
+ import type { ViewContext } from './context';
6
+ /** notification-banner(app.notifications / view.states 共通) */
7
+ export declare function renderBanner(id: string, variant: NoticeVariantV2, message: string, dismissible?: boolean): string;
8
+ /** 共通通知。現在のロールに向けたもので、掲示期限(until)が今日より前でないものだけ。id は定義順の通し番号 */
9
+ export declare function renderNotifications(ctx: ViewContext): string;
10
+ /** グローバルナビ: group が 1 項目ならリンク、複数ならサブメニューボタン + menu-list。現在地は aria-current="page" */
11
+ export declare function renderGlobalNav(ctx: ViewContext): string;
12
+ /** ヘッダー: 左にシステム名とアプリ名、右に利用者名とテナント名(utility-link) */
13
+ export declare function renderHeader(ctx: ViewContext): string;
14
+ /** パンくず: アプリ名 › グループ › 画面タイトル */
15
+ export declare function renderBreadcrumb(ctx: ViewContext): string;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 条件(visibleWhen / requiredWhen)の評価。静的描画(既定値)と mount 後(DOM の現在値)で共有する。
3
+ *
4
+ * 比較の対象は「項目の現在値のトークン」: 単一値は文字列、複数選択は選択値の配列、
5
+ * 真偽値系(checkbox / toggle)は 'true' / 'false'、date は `y-m-d`(precision: month は `y-m`)。
6
+ */
7
+ import type { ConditionV2 } from '../types/schema-v2';
8
+ export type Token = string | string[];
9
+ /** data 属性に載せる条件(JSON)。equals / notEquals / in のうち書かれたものだけ */
10
+ export declare function serializeCondition(cond: ConditionV2): string;
11
+ /** 条件を評価する。equals は一致、notEquals は不一致、in は配列のどれかと一致 */
12
+ export declare function matchesCondition(token: Token, cond: ConditionV2): boolean;
13
+ /**
14
+ * date の値のトークン。年・月・日を 0 埋めして `-` でつなぎ、末尾の空の部分は落とす
15
+ * (年月だけなら `2026-11`、全部空なら空文字)。静的描画(既定値)と mount 後(入力欄)で同じ形にするための唯一の組み立て
16
+ */
17
+ export declare function dateToken(year: string, month: string, day: string): string;
18
+ /** 値の文字列(YYYY-MM-DD / YYYY-MM)から date のトークンを作る。precision: month は日を無視する。解釈できない値はそのまま */
19
+ export declare function dateTokenOf(text: string, precision: 'day' | 'month' | undefined): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * v2 レンダラー内部で共有する描画文脈
3
+ */
4
+ import type { ConditionV2, FieldV2, FlowV2, MokkunV2Schema, ViewV2 } from '../types/schema-v2';
5
+ /** view の状態(ビューアーの「状態」切替)。normal は状態バナーなし */
6
+ export type V2ViewState = 'normal' | 'success' | 'error' | 'empty' | 'loading';
7
+ export declare const V2_VIEW_STATES: readonly V2ViewState[];
8
+ /** 描画オプション */
9
+ export interface V2RenderOptions {
10
+ /** 表示する状態。既定 normal(状態バナーを出さない) */
11
+ state?: V2ViewState;
12
+ /** 現在のロール(app.roles の値)。未指定は全ロール分を表示する */
13
+ role?: string;
14
+ /** 通知の期限(Notice.until)判定に使う今日。既定は実行時の日付(テスト用) */
15
+ today?: Date | string;
16
+ }
17
+ export interface ViewContext {
18
+ schema: MokkunV2Schema;
19
+ viewName: string;
20
+ view: ViewV2;
21
+ /** 展開後の項目 id → 項目定義(visibleWhen の初期評価用) */
22
+ fields: Map<string, FieldV2>;
23
+ state: V2ViewState;
24
+ role: string | undefined;
25
+ /** 今日(YYYY-MM-DD) */
26
+ today: string;
27
+ }
28
+ export declare function createContext(schema: MokkunV2Schema, viewName: string, options?: V2RenderOptions): ViewContext | undefined;
29
+ /** DOM id は view 名で前置して、ページ内で一意にする */
30
+ export declare function domId(ctx: ViewContext, ...parts: Array<string | number>): string;
31
+ /** 条件を既定値で評価する(条件がなければ true)。参照先が無ければ false */
32
+ export declare function isInitiallyVisible(cond: ConditionV2 | undefined, ctx: ViewContext): boolean;
33
+ /** view を含み、手順ナビを出す flow(progress: none は除く) */
34
+ export declare function findFlow(schema: MokkunV2Schema, viewName: string): {
35
+ flow: FlowV2;
36
+ index: number;
37
+ } | undefined;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * radio / checkbox の fieldset と、それを使う select の変種
3
+ * - radio: radio の fieldset
4
+ * - checkbox: checkbox 1 つ / multiple は checkbox の fieldset
5
+ * - select multiple: checkbox の fieldset(DADS の指針: 複数選択はチェックボックス)
6
+ * - select segmented: radio の横並び fieldset
7
+ */
8
+ import { type Ctl } from './control-label';
9
+ export declare function renderRadio(c: Ctl, inline?: boolean): string;
10
+ export declare function renderCheckboxGroup(c: Ctl): string;
11
+ /** 単一チェックボックス: ラベルはチェックボックス自身(必須表示も同じ行に) */
12
+ export declare function renderCheckbox(c: Ctl): string;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * form-control-label(DADS)でのラップ
3
+ * 単一コントロールは <label for>、複数コントロール(グループ)は <fieldset> + <legend>。
4
+ * サポートテキスト・エラーテキストは aria-describedby で関連付ける。
5
+ */
6
+ import type { FieldV2 } from '../../types/schema-v2';
7
+ /** 1 項目の描画入力(DOM id / name は呼び出し側で繰り返しグループの添字まで解決済み) */
8
+ export interface FieldOpts {
9
+ /** コントロールの DOM id(view 名で前置済み) */
10
+ domId: string;
11
+ /** フォーム送信名 */
12
+ name: string;
13
+ /** 初期表示で非表示にするか(visibleWhen を既定値で評価した結果) */
14
+ hidden?: boolean;
15
+ /**
16
+ * props.error(項目のエラー文)を描くか。既定 true(単体で呼ぶとき)。View の描画では状態が error のときだけ true
17
+ * (通常の状態ではエラーを出さない)
18
+ */
19
+ showError?: boolean;
20
+ /** 初期表示で必須か(requiredWhen を既定値で評価した結果)。省略は field.required */
21
+ required?: boolean;
22
+ }
23
+ /** コントロール描画用の文脈 */
24
+ export interface Ctl {
25
+ f: FieldV2;
26
+ domId: string;
27
+ name: string;
28
+ hidden: boolean;
29
+ /** 必須として扱うか(requiredWhen のときは条件の評価結果。mount 後は DOM が追随する) */
30
+ required: boolean;
31
+ supportId?: string;
32
+ errorId?: string;
33
+ error?: string;
34
+ /** aria-describedby に入れる id 列(エラー → サポートの順) */
35
+ describedBy?: string;
36
+ /** 初期値 */
37
+ value: unknown;
38
+ }
39
+ export declare function makeCtl(f: FieldV2, o: FieldOpts): Ctl;
40
+ /** サポートテキストの行(help / ファイル形式と容量 / whyRequired / format / example)。placeholder は使わない */
41
+ export declare function supportLines(f: FieldV2): string[];
42
+ /** aria-invalid / aria-describedby の共通属性 */
43
+ export declare function ariaAttrs(c: Ctl): string;
44
+ /** form-control-label 共通のエラー(各コントロールが専用のエラーテキストを持たない場合) */
45
+ export declare function groupError(c: Ctl): string;
46
+ /** 単一コントロール: <div> + <label for> */
47
+ export declare function wrapSingle(c: Ctl, control: string): string;
48
+ /** グループ: <fieldset> + <legend>。aria-describedby は fieldset に付ける */
49
+ export declare function wrapGroup(c: Ctl, control: string, extra?: Record<string, string | boolean | undefined>, opts?: {
50
+ skipError?: boolean;
51
+ }): string;
52
+ /** ラベルを持たない表示用コントロール(チップ・タイムライン等)用のラップ */
53
+ export declare function wrapDisplay(c: Ctl, control: string): string;
54
+ /** 単一チェックボックス用: ラベルはチェックボックス自身が持つ(必須表示はその中に入れる) */
55
+ export declare function wrapInline(c: Ctl, control: string): string;
56
+ /** 必須/任意の表示(単一チェックボックスのラベル内で使う) */
57
+ export declare function requirementHtml(c: Ctl): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * date → date-picker(consolidated)/ inline のときは calendar
3
+ * DADS の date-picker は 年・月・日 の 3 入力。カレンダーのポップオーバーは JS が必要なため出さない。
4
+ */
5
+ import { type Ctl } from './control-label';
6
+ export declare function renderDate(c: Ctl): string;