mokkun 0.1.5 → 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 +6 -6
- package/bin/viewer.html +2 -2
- 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/lib.d.ts +80 -0
- package/dist/types/loader/file-loader.d.ts +114 -0
- package/dist/types/loader/index.d.ts +4 -0
- package/dist/types/parser/index.d.ts +4 -0
- package/dist/types/parser/key-normalizer.d.ts +24 -0
- package/dist/types/parser/yaml-parser.d.ts +58 -0
- package/dist/types/renderer/action-handler.d.ts +76 -0
- package/dist/types/renderer/components/accordion-panel.d.ts +144 -0
- package/dist/types/renderer/components/action-buttons.d.ts +183 -0
- package/dist/types/renderer/components/alert-banner.d.ts +43 -0
- package/dist/types/renderer/components/app-header.d.ts +277 -0
- package/dist/types/renderer/components/app-navi.d.ts +167 -0
- package/dist/types/renderer/components/badge.d.ts +134 -0
- package/dist/types/renderer/components/browser.d.ts +134 -0
- package/dist/types/renderer/components/calendar.d.ts +198 -0
- package/dist/types/renderer/components/checkbox.d.ts +132 -0
- package/dist/types/renderer/components/chip.d.ts +120 -0
- package/dist/types/renderer/components/combobox.d.ts +217 -0
- package/dist/types/renderer/components/data-table.d.ts +186 -0
- package/dist/types/renderer/components/date-range-picker.d.ts +203 -0
- package/dist/types/renderer/components/definition-list.d.ts +165 -0
- package/dist/types/renderer/components/delete-confirm-dialog.d.ts +151 -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/disclosure.d.ts +118 -0
- package/dist/types/renderer/components/dropdown.d.ts +220 -0
- package/dist/types/renderer/components/duration-input.d.ts +154 -0
- package/dist/types/renderer/components/duration-picker.d.ts +108 -0
- package/dist/types/renderer/components/field-renderer.d.ts +22 -0
- package/dist/types/renderer/components/float-area.d.ts +196 -0
- package/dist/types/renderer/components/form-fields.d.ts +94 -0
- package/dist/types/renderer/components/form-section.d.ts +118 -0
- package/dist/types/renderer/components/google-map-embed.d.ts +88 -0
- package/dist/types/renderer/components/heading.d.ts +119 -0
- package/dist/types/renderer/components/image-uploader.d.ts +271 -0
- package/dist/types/renderer/components/index.d.ts +48 -0
- package/dist/types/renderer/components/information-panel.d.ts +139 -0
- package/dist/types/renderer/components/input.d.ts +222 -0
- package/dist/types/renderer/components/layout.d.ts +71 -0
- package/dist/types/renderer/components/line-clamp.d.ts +170 -0
- package/dist/types/renderer/components/loader.d.ts +104 -0
- package/dist/types/renderer/components/notification-bar.d.ts +251 -0
- package/dist/types/renderer/components/pagination.d.ts +167 -0
- package/dist/types/renderer/components/photo-manager-renderer.d.ts +9 -0
- package/dist/types/renderer/components/radio-button-panel.d.ts +152 -0
- package/dist/types/renderer/components/radio.d.ts +117 -0
- package/dist/types/renderer/components/repeater.d.ts +116 -0
- package/dist/types/renderer/components/response-message.d.ts +180 -0
- package/dist/types/renderer/components/search-input.d.ts +198 -0
- package/dist/types/renderer/components/section-nav.d.ts +151 -0
- package/dist/types/renderer/components/segmented-control.d.ts +143 -0
- package/dist/types/renderer/components/select.d.ts +98 -0
- package/dist/types/renderer/components/status-label.d.ts +146 -0
- package/dist/types/renderer/components/stepper.d.ts +123 -0
- package/dist/types/renderer/components/tabs.d.ts +185 -0
- package/dist/types/renderer/components/textarea.d.ts +173 -0
- package/dist/types/renderer/components/timeline.d.ts +146 -0
- package/dist/types/renderer/components/toggle.d.ts +109 -0
- package/dist/types/renderer/components/tooltip.d.ts +158 -0
- package/dist/types/renderer/components/wizard.d.ts +118 -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 +53 -0
- package/dist/types/renderer/utils/dom.d.ts +29 -0
- package/dist/types/renderer/utils/dummy-data.d.ts +13 -0
- package/dist/types/renderer/utils/field-helpers.d.ts +90 -0
- package/dist/types/renderer/utils/icons.d.ts +13 -0
- package/dist/types/renderer/utils/index.d.ts +6 -0
- package/dist/types/theme/index.d.ts +6 -0
- package/dist/types/theme/theme-manager.d.ts +102 -0
- package/dist/types/types/field-renderable.d.ts +40 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/schema.d.ts +1701 -0
- package/dist/types/types/theme.d.ts +111 -0
- package/package.json +3 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mokkun Library Entry Point
|
|
3
|
+
* YAML-based presentation and form builder
|
|
4
|
+
*/
|
|
5
|
+
import './style.css';
|
|
6
|
+
import { parseYaml, getScreen, getScreenNames, findFieldById } from './parser';
|
|
7
|
+
import type { MokkunSchema, ScreenDefinition, BuiltInThemeId } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Mokkun initialization options
|
|
10
|
+
*/
|
|
11
|
+
export interface MokkunInitOptions {
|
|
12
|
+
/** Container selector or element */
|
|
13
|
+
container: string | HTMLElement;
|
|
14
|
+
/** URL to YAML file */
|
|
15
|
+
yamlUrl?: string;
|
|
16
|
+
/** Inline YAML content */
|
|
17
|
+
yamlContent?: string;
|
|
18
|
+
/** Initial theme ('light' | 'dark') */
|
|
19
|
+
theme?: BuiltInThemeId | string;
|
|
20
|
+
/** Initial screen to display */
|
|
21
|
+
initialScreen?: string;
|
|
22
|
+
/** Callback when ready */
|
|
23
|
+
onReady?: (instance: MokkunInstance) => void;
|
|
24
|
+
/** Callback on error */
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
/** Callback when navigating between screens */
|
|
27
|
+
onNavigate?: (fromScreen: string, toScreen: string) => void;
|
|
28
|
+
/** Callback when form is submitted */
|
|
29
|
+
onSubmit?: (screenName: string, formData: Record<string, unknown>) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Mokkun instance returned by init()
|
|
33
|
+
*/
|
|
34
|
+
export interface MokkunInstance {
|
|
35
|
+
/** Current schema */
|
|
36
|
+
readonly schema: MokkunSchema | null;
|
|
37
|
+
/** Current screen name */
|
|
38
|
+
readonly currentScreen: string | null;
|
|
39
|
+
/** Navigate to a screen */
|
|
40
|
+
showScreen: (screenName: string) => void;
|
|
41
|
+
/** Get available screen names */
|
|
42
|
+
getScreenNames: () => string[];
|
|
43
|
+
/** Change theme */
|
|
44
|
+
setTheme: (themeId: string) => void;
|
|
45
|
+
/** Get current theme */
|
|
46
|
+
getTheme: () => string | null;
|
|
47
|
+
/** Get current form data */
|
|
48
|
+
getFormData: () => Record<string, unknown> | null;
|
|
49
|
+
/** Destroy instance and cleanup */
|
|
50
|
+
destroy: () => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Initialize Mokkun with the given options
|
|
54
|
+
*/
|
|
55
|
+
declare function init(options: MokkunInitOptions): Promise<MokkunInstance>;
|
|
56
|
+
/**
|
|
57
|
+
* Mokkun - YAML-based presentation and form builder
|
|
58
|
+
*/
|
|
59
|
+
export declare const Mokkun: {
|
|
60
|
+
/** Initialize Mokkun */
|
|
61
|
+
init: typeof init;
|
|
62
|
+
/** Library version */
|
|
63
|
+
VERSION: string;
|
|
64
|
+
/** Utility functions */
|
|
65
|
+
utils: {
|
|
66
|
+
parseYaml: typeof parseYaml;
|
|
67
|
+
getScreen: typeof getScreen;
|
|
68
|
+
getScreenNames: typeof getScreenNames;
|
|
69
|
+
findFieldById: typeof findFieldById;
|
|
70
|
+
};
|
|
71
|
+
/** Theme management */
|
|
72
|
+
theme: {
|
|
73
|
+
apply: (id: string) => boolean;
|
|
74
|
+
getCurrent: () => string | null;
|
|
75
|
+
getAvailable: () => import("./types").ThemeDefinition[];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export type { MokkunSchema, ScreenDefinition, BuiltInThemeId };
|
|
79
|
+
export { Textarea, createTextarea, type TextareaState, type TextareaCallbacks, type TextareaConfig, } from './renderer/components/textarea';
|
|
80
|
+
export { Combobox, type ComboboxOption, type ComboboxConfig, type ComboboxState, type ComboboxCallbacks, } from './renderer/components';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mokkun - File Loader Module
|
|
3
|
+
* YAMLファイルの読み込み機能を提供
|
|
4
|
+
*/
|
|
5
|
+
import type { MokkunSchema } from '../types/schema';
|
|
6
|
+
import type { ParseError } from '../parser/yaml-parser';
|
|
7
|
+
/**
|
|
8
|
+
* ファイル読み込みエラーの種類
|
|
9
|
+
*/
|
|
10
|
+
export type FileLoadErrorType = 'INVALID_FILE_TYPE' | 'FILE_READ_ERROR' | 'FETCH_ERROR' | 'YAML_PARSE_ERROR' | 'NETWORK_ERROR';
|
|
11
|
+
/**
|
|
12
|
+
* ファイル読み込みエラー
|
|
13
|
+
*/
|
|
14
|
+
export interface FileLoadError {
|
|
15
|
+
type: FileLoadErrorType;
|
|
16
|
+
message: string;
|
|
17
|
+
details?: string;
|
|
18
|
+
parseErrors?: ParseError[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ファイル読み込み成功結果
|
|
22
|
+
*/
|
|
23
|
+
export interface FileLoadSuccess {
|
|
24
|
+
success: true;
|
|
25
|
+
schema: MokkunSchema;
|
|
26
|
+
fileName: string;
|
|
27
|
+
source: 'file' | 'url' | 'drop';
|
|
28
|
+
/** 読み込んだ YAML の原文(コメント・順序を保持) */
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* ファイル読み込み失敗結果
|
|
33
|
+
*/
|
|
34
|
+
export interface FileLoadFailure {
|
|
35
|
+
success: false;
|
|
36
|
+
error: FileLoadError;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* ファイル読み込み結果
|
|
40
|
+
*/
|
|
41
|
+
export type FileLoadResult = FileLoadSuccess | FileLoadFailure;
|
|
42
|
+
/**
|
|
43
|
+
* ファイル読み込みコールバック
|
|
44
|
+
*/
|
|
45
|
+
export type FileLoadCallback = (result: FileLoadResult) => void;
|
|
46
|
+
/**
|
|
47
|
+
* ドロップゾーンオプション
|
|
48
|
+
*/
|
|
49
|
+
export interface DropZoneOptions {
|
|
50
|
+
element: HTMLElement;
|
|
51
|
+
onLoad: FileLoadCallback;
|
|
52
|
+
onDragOver?: () => void;
|
|
53
|
+
onDragLeave?: () => void;
|
|
54
|
+
multiple?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* ファイル選択オプション
|
|
58
|
+
*/
|
|
59
|
+
export interface FileSelectOptions {
|
|
60
|
+
onLoad: FileLoadCallback;
|
|
61
|
+
multiple?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* ファイル名が許可された拡張子かチェック
|
|
65
|
+
*/
|
|
66
|
+
export declare function isValidFileName(fileName: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* ファイルタイプが許可されているかチェック
|
|
69
|
+
*/
|
|
70
|
+
export declare function isValidFileType(file: File): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* FileReaderでファイルを読み込み
|
|
73
|
+
*/
|
|
74
|
+
export declare function readFile(file: File, source: 'file' | 'drop'): Promise<FileLoadResult>;
|
|
75
|
+
/**
|
|
76
|
+
* 複数ファイルを読み込み
|
|
77
|
+
*/
|
|
78
|
+
export declare function readFiles(files: FileList | File[], source: 'file' | 'drop'): Promise<FileLoadResult[]>;
|
|
79
|
+
/**
|
|
80
|
+
* URLからYAMLファイルを読み込み
|
|
81
|
+
*/
|
|
82
|
+
export declare function loadFromUrl(url: string): Promise<FileLoadResult>;
|
|
83
|
+
/**
|
|
84
|
+
* URLパラメータからYAMLパスを取得
|
|
85
|
+
*/
|
|
86
|
+
export declare function getYamlUrlFromParams(): string | null;
|
|
87
|
+
/**
|
|
88
|
+
* URLパラメータで指定されたYAMLを読み込み
|
|
89
|
+
*/
|
|
90
|
+
export declare function loadFromUrlParams(): Promise<FileLoadResult | null>;
|
|
91
|
+
/**
|
|
92
|
+
* ファイル選択input要素を作成
|
|
93
|
+
*/
|
|
94
|
+
export declare function createFileInput(options: FileSelectOptions): HTMLInputElement;
|
|
95
|
+
/**
|
|
96
|
+
* ファイル選択ダイアログを開く
|
|
97
|
+
*/
|
|
98
|
+
export declare function openFileDialog(options: FileSelectOptions): void;
|
|
99
|
+
/**
|
|
100
|
+
* ドロップゾーンをセットアップ
|
|
101
|
+
*/
|
|
102
|
+
export declare function setupDropZone(options: DropZoneOptions): () => void;
|
|
103
|
+
/**
|
|
104
|
+
* エラーをフォーマットして表示用文字列に変換
|
|
105
|
+
*/
|
|
106
|
+
export declare function formatFileLoadError(error: FileLoadError): string;
|
|
107
|
+
/**
|
|
108
|
+
* ファイル読み込みUIを生成
|
|
109
|
+
*/
|
|
110
|
+
export declare function renderFileLoaderUI(): string;
|
|
111
|
+
/**
|
|
112
|
+
* ファイルローダーUIにイベントをアタッチ
|
|
113
|
+
*/
|
|
114
|
+
export declare function attachFileLoaderEvents(container: HTMLElement, onLoad: FileLoadCallback): () => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML キー正規化
|
|
3
|
+
*
|
|
4
|
+
* YAML の正規形は camelCase。内部表現は snake_case のまま維持するため、
|
|
5
|
+
* パーサーの入口で camelCase キーを内部の snake_case キーへ変換する。
|
|
6
|
+
* snake_case の YAML(teamkit generate-ui の出力など)は変換せずそのまま通す(後方互換)。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 内部で使用する snake_case キーの完全な集合(ソート済み、113 個)。
|
|
10
|
+
* schema.json のプロパティ名 / src/types/schema.ts のプロパティ名 /
|
|
11
|
+
* yaml-parser.ts が読むキーの和集合。key-normalizer.test.ts で schema.json と突き合わせる。
|
|
12
|
+
*
|
|
13
|
+
* 注意: 内部で元から camelCase のプロパティ(dropdownItems, maxColumns, weekStartsOn, loaderType,
|
|
14
|
+
* showProgress, initialProgress, ariaLabel, defaultValue)は snake_case 版と衝突するため、パーサーは snake 形で読む。
|
|
15
|
+
* definition_list の group/item の maxColumns はレンダラーが camelCase で読むが、静的 renderField では無視される。
|
|
16
|
+
*/
|
|
17
|
+
export declare const KNOWN_KEYS: readonly string[];
|
|
18
|
+
/** snake_case を camelCase に変換(use_24_hour → use24Hour) */
|
|
19
|
+
export declare function toCamel(snake: string): string;
|
|
20
|
+
/** camelCase を snake_case に変換(use24Hour → use_24_hour) */
|
|
21
|
+
export declare function toSnake(camel: string): string;
|
|
22
|
+
/** camelCase キー → 内部 snake_case キー */
|
|
23
|
+
export declare const CAMEL_TO_SNAKE: Record<string, string>;
|
|
24
|
+
export declare function normalizeKeysDeep(value: unknown, parentKey?: string, verbatimSelf?: boolean, isNamedEntry?: boolean): unknown;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mokkun YAML Parser
|
|
3
|
+
* YAMLテキストを型安全にパースする
|
|
4
|
+
*/
|
|
5
|
+
import type { MokkunSchema, ScreenDefinition, InputField, InputFieldType, CommonComponent, ValidationRule } from '../types/schema';
|
|
6
|
+
/**
|
|
7
|
+
* パースエラーの種類
|
|
8
|
+
*/
|
|
9
|
+
export type ParseErrorType = 'YAML_SYNTAX_ERROR' | 'SCHEMA_VALIDATION_ERROR' | 'MISSING_REQUIRED_FIELD' | 'INVALID_FIELD_TYPE' | 'INVALID_VALUE';
|
|
10
|
+
/**
|
|
11
|
+
* パースエラー
|
|
12
|
+
*/
|
|
13
|
+
export interface ParseError {
|
|
14
|
+
type: ParseErrorType;
|
|
15
|
+
message: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* パース結果
|
|
22
|
+
*/
|
|
23
|
+
export type ParseResult<T> = {
|
|
24
|
+
success: true;
|
|
25
|
+
data: T;
|
|
26
|
+
} | {
|
|
27
|
+
success: false;
|
|
28
|
+
errors: ParseError[];
|
|
29
|
+
};
|
|
30
|
+
export declare const VALID_FIELD_TYPES: InputFieldType[];
|
|
31
|
+
/**
|
|
32
|
+
* YAMLテキストをパースしてMokkunSchemaに変換
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseYaml(yamlText: string): ParseResult<MokkunSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* パースエラーを整形して文字列に変換
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatParseErrors(errors: ParseError[]): string;
|
|
39
|
+
/**
|
|
40
|
+
* 画面定義を取得
|
|
41
|
+
*/
|
|
42
|
+
export declare function getScreen(schema: MokkunSchema, screenName: string): ScreenDefinition | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* 全ての画面名を取得
|
|
45
|
+
*/
|
|
46
|
+
export declare function getScreenNames(schema: MokkunSchema): string[];
|
|
47
|
+
/**
|
|
48
|
+
* フィールドをIDで検索
|
|
49
|
+
*/
|
|
50
|
+
export declare function findFieldById(fields: InputField[], fieldId: string): InputField | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* 共通コンポーネントを取得
|
|
53
|
+
*/
|
|
54
|
+
export declare function getCommonComponent(schema: MokkunSchema, componentName: string): CommonComponent | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* バリデーションルールを取得
|
|
57
|
+
*/
|
|
58
|
+
export declare function getValidationRule(schema: MokkunSchema, ruleName: string): ValidationRule | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Handler
|
|
3
|
+
* アクションボタンのイベント処理(確認ダイアログ統合)
|
|
4
|
+
*/
|
|
5
|
+
import { DeleteConfirmDialog, type DeleteConfirmDialogConfig, type DependencyInfo } from './components/delete-confirm-dialog';
|
|
6
|
+
/**
|
|
7
|
+
* アクションハンドラーのコールバック
|
|
8
|
+
*/
|
|
9
|
+
export interface ActionHandlerCallbacks {
|
|
10
|
+
/** submit アクション実行時 */
|
|
11
|
+
onSubmit?: (actionId: string, url?: string, method?: string) => void;
|
|
12
|
+
/** navigate アクション実行時 */
|
|
13
|
+
onNavigate?: (actionId: string, to: string) => void;
|
|
14
|
+
/** custom アクション実行時 */
|
|
15
|
+
onCustom?: (actionId: string, handler: string) => void;
|
|
16
|
+
/** reset アクション実行時 */
|
|
17
|
+
onReset?: (actionId: string) => void;
|
|
18
|
+
/** アクションがキャンセルされた時 */
|
|
19
|
+
onCancel?: (actionId: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 削除確認ダイアログの拡張設定(YAMLから取得する追加情報)
|
|
23
|
+
*/
|
|
24
|
+
export interface DeleteConfirmExtendedConfig {
|
|
25
|
+
/** 依存データを取得する関数 */
|
|
26
|
+
getDependencies?: () => DependencyInfo[] | Promise<DependencyInfo[]>;
|
|
27
|
+
/** 削除対象名を取得する関数 */
|
|
28
|
+
getTargetName?: () => string;
|
|
29
|
+
/** 削除対象タイプ */
|
|
30
|
+
targetType?: string;
|
|
31
|
+
/** 警告メッセージ */
|
|
32
|
+
warningMessage?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* アクションハンドラー
|
|
36
|
+
* ボタンクリック時の処理と確認ダイアログの表示を管理
|
|
37
|
+
*/
|
|
38
|
+
export declare class ActionHandler {
|
|
39
|
+
private container;
|
|
40
|
+
private callbacks;
|
|
41
|
+
private deleteConfirmConfigs;
|
|
42
|
+
private boundClickHandler;
|
|
43
|
+
constructor(container: HTMLElement, callbacks?: ActionHandlerCallbacks, deleteConfirmConfigs?: Map<string, DeleteConfirmExtendedConfig>);
|
|
44
|
+
/**
|
|
45
|
+
* イベントリスナーを設定
|
|
46
|
+
*/
|
|
47
|
+
attach(): void;
|
|
48
|
+
/**
|
|
49
|
+
* イベントリスナーを削除
|
|
50
|
+
*/
|
|
51
|
+
detach(): void;
|
|
52
|
+
/**
|
|
53
|
+
* 削除確認の設定を登録
|
|
54
|
+
*/
|
|
55
|
+
registerDeleteConfirmConfig(actionId: string, config: DeleteConfirmExtendedConfig): void;
|
|
56
|
+
/**
|
|
57
|
+
* クリックイベントハンドラー
|
|
58
|
+
*/
|
|
59
|
+
private handleClick;
|
|
60
|
+
/**
|
|
61
|
+
* 確認ダイアログを表示
|
|
62
|
+
*/
|
|
63
|
+
private showConfirmDialog;
|
|
64
|
+
/**
|
|
65
|
+
* アクションを実行
|
|
66
|
+
*/
|
|
67
|
+
private executeAction;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* コンテナにアクションハンドラーをアタッチ
|
|
71
|
+
*/
|
|
72
|
+
export declare function attachActionHandler(container: HTMLElement, callbacks?: ActionHandlerCallbacks, deleteConfirmConfigs?: Map<string, DeleteConfirmExtendedConfig>): ActionHandler;
|
|
73
|
+
/**
|
|
74
|
+
* 簡易的な確認ダイアログを表示(スタンドアロン使用)
|
|
75
|
+
*/
|
|
76
|
+
export declare function showDeleteConfirmDialog(config: DeleteConfirmDialogConfig, onConfirm: () => void, onCancel?: () => void): DeleteConfirmDialog;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AccordionPanel Component
|
|
3
|
+
* 折りたたみパネルコンポーネント
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* - 複数パネルの同時開閉制御(単一/複数展開モード)
|
|
7
|
+
* - 開閉アニメーション
|
|
8
|
+
* - アイコン付きヘッダー
|
|
9
|
+
* - デフォルト展開状態の設定
|
|
10
|
+
* - キーボード操作対応
|
|
11
|
+
* - アクセシビリティ対応(ARIA属性)
|
|
12
|
+
*/
|
|
13
|
+
import type { InputField } from '../../types/schema';
|
|
14
|
+
/**
|
|
15
|
+
* アコーディオンアイテムの定義
|
|
16
|
+
*/
|
|
17
|
+
export interface AccordionItem {
|
|
18
|
+
/** 一意な識別子 */
|
|
19
|
+
name: string;
|
|
20
|
+
/** ヘッダーテキスト */
|
|
21
|
+
title: string;
|
|
22
|
+
/** ヘッダーアイコン(オプション) */
|
|
23
|
+
icon?: string;
|
|
24
|
+
/** コンテンツ(HTML文字列またはHTMLElement) */
|
|
25
|
+
content: string | HTMLElement;
|
|
26
|
+
/** 無効化 */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* アイコンの配置位置
|
|
31
|
+
*/
|
|
32
|
+
export type IconPosition = 'left' | 'right';
|
|
33
|
+
/**
|
|
34
|
+
* 見出しタイプ
|
|
35
|
+
*/
|
|
36
|
+
export type HeadingType = 'sectionTitle' | 'blockTitle' | 'subBlockTitle' | 'subSubBlockTitle';
|
|
37
|
+
/**
|
|
38
|
+
* アコーディオンパネルの状態
|
|
39
|
+
*/
|
|
40
|
+
export interface AccordionPanelState {
|
|
41
|
+
/** 展開中のパネル名リスト */
|
|
42
|
+
expandedItems: string[];
|
|
43
|
+
/** フォーカスされているアイテムのインデックス */
|
|
44
|
+
focusedIndex: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* アコーディオンパネルのコールバック
|
|
48
|
+
*/
|
|
49
|
+
export interface AccordionPanelCallbacks {
|
|
50
|
+
/** パネル展開時 */
|
|
51
|
+
onExpand?: (name: string) => void;
|
|
52
|
+
/** パネル折りたたみ時 */
|
|
53
|
+
onCollapse?: (name: string) => void;
|
|
54
|
+
/** 展開状態変更時 */
|
|
55
|
+
onChange?: (expandedItems: string[]) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* アコーディオンパネルの設定
|
|
59
|
+
*/
|
|
60
|
+
export interface AccordionPanelConfig {
|
|
61
|
+
/** アコーディオンアイテム */
|
|
62
|
+
items: AccordionItem[];
|
|
63
|
+
/** 複数パネル同時展開を許可(デフォルト: true) */
|
|
64
|
+
expandableMultiply?: boolean;
|
|
65
|
+
/** デフォルトで展開するパネル名のリスト */
|
|
66
|
+
defaultExpanded?: string[];
|
|
67
|
+
/** アイコンの配置位置(デフォルト: left) */
|
|
68
|
+
iconPosition?: IconPosition;
|
|
69
|
+
/** 見出しタイプ(デフォルト: blockTitle) */
|
|
70
|
+
headingType?: HeadingType;
|
|
71
|
+
/** ID属性 */
|
|
72
|
+
id?: string;
|
|
73
|
+
/** カスタムCSSクラス */
|
|
74
|
+
className?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* アコーディオンパネルコンポーネント
|
|
78
|
+
*/
|
|
79
|
+
export declare class AccordionPanel {
|
|
80
|
+
private config;
|
|
81
|
+
private state;
|
|
82
|
+
private callbacks;
|
|
83
|
+
private container;
|
|
84
|
+
private instanceId;
|
|
85
|
+
private itemElements;
|
|
86
|
+
constructor(container: HTMLElement, config: AccordionPanelConfig, callbacks?: AccordionPanelCallbacks);
|
|
87
|
+
/**
|
|
88
|
+
* アコーディオンパネルをレンダリング
|
|
89
|
+
*/
|
|
90
|
+
render(): void;
|
|
91
|
+
/**
|
|
92
|
+
* パネルを展開
|
|
93
|
+
*/
|
|
94
|
+
expand(name: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* パネルを折りたたむ
|
|
97
|
+
*/
|
|
98
|
+
collapse(name: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* パネルの展開/折りたたみを切り替え
|
|
101
|
+
*/
|
|
102
|
+
toggle(name: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* すべてのパネルを展開
|
|
105
|
+
*/
|
|
106
|
+
expandAll(): void;
|
|
107
|
+
/**
|
|
108
|
+
* すべてのパネルを折りたたむ
|
|
109
|
+
*/
|
|
110
|
+
collapseAll(): void;
|
|
111
|
+
/**
|
|
112
|
+
* パネルの展開状態を確認
|
|
113
|
+
*/
|
|
114
|
+
isExpanded(name: string): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* 現在の状態を取得
|
|
117
|
+
*/
|
|
118
|
+
getState(): AccordionPanelState;
|
|
119
|
+
/**
|
|
120
|
+
* アイテムを更新
|
|
121
|
+
*/
|
|
122
|
+
setItems(items: AccordionItem[]): void;
|
|
123
|
+
/**
|
|
124
|
+
* コンポーネントを破棄
|
|
125
|
+
*/
|
|
126
|
+
destroy(): void;
|
|
127
|
+
private createInitialState;
|
|
128
|
+
private renderItem;
|
|
129
|
+
private renderTrigger;
|
|
130
|
+
private renderIcon;
|
|
131
|
+
private renderContent;
|
|
132
|
+
private updateItemState;
|
|
133
|
+
private attachKeyboardEvents;
|
|
134
|
+
private focusNextItem;
|
|
135
|
+
private focusPreviousItem;
|
|
136
|
+
private focusFirstItem;
|
|
137
|
+
private focusLastItem;
|
|
138
|
+
private focusItem;
|
|
139
|
+
static renderField(field: InputField): string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* アコーディオンパネルを作成
|
|
143
|
+
*/
|
|
144
|
+
export declare function createAccordionPanel(container: HTMLElement, config: AccordionPanelConfig, callbacks?: AccordionPanelCallbacks): AccordionPanel;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Button Group Component
|
|
3
|
+
* アクションボタングループコンポーネント
|
|
4
|
+
*
|
|
5
|
+
* 複数のアクションボタンを適切に配置するコンポーネント
|
|
6
|
+
*/
|
|
7
|
+
import type { Action, ConfirmConfig } from '../../types/schema';
|
|
8
|
+
/**
|
|
9
|
+
* アクションボタンの定義
|
|
10
|
+
*/
|
|
11
|
+
export interface ActionButton {
|
|
12
|
+
/** ボタンID */
|
|
13
|
+
id: string;
|
|
14
|
+
/** ボタンタイプ */
|
|
15
|
+
type: 'submit' | 'navigate' | 'custom' | 'reset';
|
|
16
|
+
/** ラベル */
|
|
17
|
+
label: string;
|
|
18
|
+
/** アイコン(オプション) */
|
|
19
|
+
icon?: string;
|
|
20
|
+
/** スタイル */
|
|
21
|
+
style?: 'primary' | 'secondary' | 'danger' | 'link';
|
|
22
|
+
/** 無効化 */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** 遷移先(navigate時) */
|
|
25
|
+
to?: string;
|
|
26
|
+
/** カスタムハンドラー名(custom時) */
|
|
27
|
+
handler?: string;
|
|
28
|
+
/** 確認ダイアログ設定 */
|
|
29
|
+
confirm?: ConfirmConfig;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* ボタン配置
|
|
33
|
+
*/
|
|
34
|
+
export type ButtonAlignment = 'start' | 'center' | 'end' | 'spread';
|
|
35
|
+
/**
|
|
36
|
+
* ActionButtonGroupの設定
|
|
37
|
+
*/
|
|
38
|
+
export interface ActionButtonGroupConfig {
|
|
39
|
+
/** ボタン定義 */
|
|
40
|
+
buttons: ActionButton[];
|
|
41
|
+
/** ボタン配置 */
|
|
42
|
+
alignment?: ButtonAlignment;
|
|
43
|
+
/** ボタン間のギャップ */
|
|
44
|
+
gap?: string;
|
|
45
|
+
/** モバイルでスタック表示 */
|
|
46
|
+
stackOnMobile?: boolean;
|
|
47
|
+
/** 表示可能な最大ボタン数(超過分はオーバーフローメニュー) */
|
|
48
|
+
maxVisibleButtons?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* ActionButtonGroupの状態
|
|
52
|
+
*/
|
|
53
|
+
export interface ActionButtonGroupState {
|
|
54
|
+
/** ボタン定義 */
|
|
55
|
+
buttons: ActionButton[];
|
|
56
|
+
/** ボタン配置 */
|
|
57
|
+
alignment: ButtonAlignment;
|
|
58
|
+
/** ボタン間のギャップ */
|
|
59
|
+
gap: string;
|
|
60
|
+
/** モバイルでスタック表示 */
|
|
61
|
+
stackOnMobile: boolean;
|
|
62
|
+
/** 表示可能な最大ボタン数 */
|
|
63
|
+
maxVisibleButtons?: number;
|
|
64
|
+
/** ローディング中のボタンID */
|
|
65
|
+
loadingButtons: Set<string>;
|
|
66
|
+
/** オーバーフローメニューが開いているか */
|
|
67
|
+
overflowMenuOpen: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* ActionButtonGroupのコールバック
|
|
71
|
+
*/
|
|
72
|
+
export interface ActionButtonGroupCallbacks {
|
|
73
|
+
/** ボタンクリック時 */
|
|
74
|
+
onClick?: (buttonId: string, state: ActionButtonGroupState) => void;
|
|
75
|
+
/** Submit時 */
|
|
76
|
+
onSubmit?: (buttonId: string, state: ActionButtonGroupState) => void;
|
|
77
|
+
/** Navigate時 */
|
|
78
|
+
onNavigate?: (to: string, state: ActionButtonGroupState) => void;
|
|
79
|
+
/** Custom時 */
|
|
80
|
+
onCustom?: (handler: string, state: ActionButtonGroupState) => void;
|
|
81
|
+
/** 確認ダイアログ表示時(trueを返すと処理続行) */
|
|
82
|
+
onConfirm?: (config: ConfirmConfig, state: ActionButtonGroupState) => Promise<boolean>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* アクションボタングループコンポーネント
|
|
86
|
+
*/
|
|
87
|
+
export declare class ActionButtonGroup {
|
|
88
|
+
private config;
|
|
89
|
+
private container;
|
|
90
|
+
private callbacks;
|
|
91
|
+
private state;
|
|
92
|
+
private groupElement;
|
|
93
|
+
private overflowMenuElement;
|
|
94
|
+
constructor(config: ActionButtonGroupConfig, container: HTMLElement, callbacks?: ActionButtonGroupCallbacks);
|
|
95
|
+
/**
|
|
96
|
+
* 初期状態を生成
|
|
97
|
+
*/
|
|
98
|
+
private initializeState;
|
|
99
|
+
/**
|
|
100
|
+
* 現在の状態を取得(深いコピーを返す)
|
|
101
|
+
*/
|
|
102
|
+
getState(): ActionButtonGroupState;
|
|
103
|
+
/**
|
|
104
|
+
* ボタンを取得(コピーを返す)
|
|
105
|
+
*/
|
|
106
|
+
getButton(id: string): ActionButton | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Action配列からConfigを生成
|
|
109
|
+
*/
|
|
110
|
+
static fromActions(actions: Action[]): ActionButtonGroupConfig;
|
|
111
|
+
/**
|
|
112
|
+
* レンダリング
|
|
113
|
+
*/
|
|
114
|
+
render(): void;
|
|
115
|
+
/**
|
|
116
|
+
* グループのクラス名を生成
|
|
117
|
+
*/
|
|
118
|
+
private buildGroupClassName;
|
|
119
|
+
/**
|
|
120
|
+
* ボタンを可視とオーバーフローに分割
|
|
121
|
+
*/
|
|
122
|
+
private splitButtons;
|
|
123
|
+
/**
|
|
124
|
+
* 単一ボタンをレンダリング
|
|
125
|
+
*/
|
|
126
|
+
private renderButton;
|
|
127
|
+
/**
|
|
128
|
+
* ボタンのクラス名を生成
|
|
129
|
+
*/
|
|
130
|
+
private buildButtonClassName;
|
|
131
|
+
/**
|
|
132
|
+
* ボタンタイプを取得
|
|
133
|
+
*/
|
|
134
|
+
private getButtonType;
|
|
135
|
+
/**
|
|
136
|
+
* オーバーフローメニューをレンダリング
|
|
137
|
+
*/
|
|
138
|
+
private renderOverflowMenu;
|
|
139
|
+
/**
|
|
140
|
+
* ボタンクリック時の処理
|
|
141
|
+
*/
|
|
142
|
+
private handleButtonClick;
|
|
143
|
+
/**
|
|
144
|
+
* ローディング状態を設定
|
|
145
|
+
*/
|
|
146
|
+
setLoading(buttonId: string, loading: boolean): void;
|
|
147
|
+
/**
|
|
148
|
+
* 無効化状態を設定
|
|
149
|
+
*/
|
|
150
|
+
setDisabled(buttonId: string, disabled: boolean): void;
|
|
151
|
+
/**
|
|
152
|
+
* ボタンの状態を更新
|
|
153
|
+
*/
|
|
154
|
+
private updateButtonState;
|
|
155
|
+
/**
|
|
156
|
+
* オーバーフローメニューを切り替え
|
|
157
|
+
*/
|
|
158
|
+
toggleOverflowMenu(): void;
|
|
159
|
+
/**
|
|
160
|
+
* オーバーフローメニューを閉じる
|
|
161
|
+
*/
|
|
162
|
+
closeOverflowMenu(): void;
|
|
163
|
+
/**
|
|
164
|
+
* オーバーフローメニューの状態を更新
|
|
165
|
+
*/
|
|
166
|
+
private updateOverflowMenuState;
|
|
167
|
+
/**
|
|
168
|
+
* ボタンを追加
|
|
169
|
+
*/
|
|
170
|
+
addButton(button: ActionButton, index?: number): void;
|
|
171
|
+
/**
|
|
172
|
+
* ボタンを削除
|
|
173
|
+
*/
|
|
174
|
+
removeButton(buttonId: string): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* ボタンを更新
|
|
177
|
+
*/
|
|
178
|
+
updateButton(buttonId: string, updates: Partial<ActionButton>): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* クリーンアップ
|
|
181
|
+
*/
|
|
182
|
+
destroy(): void;
|
|
183
|
+
}
|