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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表示系: badge / chip / status → chip-label、timeline → list、map → image 枠
|
|
3
|
+
*/
|
|
4
|
+
import type { FieldV2 } from '../../types/schema-v2';
|
|
5
|
+
import { type Ctl } from './control-label';
|
|
6
|
+
/** badge / chip / status。値があれば項目名 + チップ、無ければチップのみ(ラベルを二重に出さない) */
|
|
7
|
+
export declare function renderChip(c: Ctl): string;
|
|
8
|
+
export interface TimelineRow {
|
|
9
|
+
time: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* timeline の行。value({ at, label, text? }[])を優先し、なければ props.items({ time, title, description? }[])
|
|
15
|
+
*/
|
|
16
|
+
export declare function timelineRows(f: FieldV2): TimelineRow[];
|
|
17
|
+
/** 日時・ラベル・本文の順序なしリスト。readonly の値としても使う */
|
|
18
|
+
export declare function timelineList(f: FieldV2, labelledBy?: string): string;
|
|
19
|
+
/** timeline(value の { at, label, text? }[]、または props.items) */
|
|
20
|
+
export declare function renderTimeline(c: Ctl): string;
|
|
21
|
+
/** 地図は image の枠に「地図」プレースホルダー */
|
|
22
|
+
export declare function renderMap(c: Ctl): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* file の accept / multiple / maxSize と、サポートテキストへの自動追記
|
|
3
|
+
*/
|
|
4
|
+
import type { FieldV2 } from '../../types/schema-v2';
|
|
5
|
+
/** `<input accept>` の値 */
|
|
6
|
+
export declare function acceptAttr(accept: FieldV2['accept']): string | undefined;
|
|
7
|
+
/** 形式名(「PDF・JPEG・PNG」の形) */
|
|
8
|
+
export declare function acceptLabel(accept: FieldV2['accept']): string | undefined;
|
|
9
|
+
/** 複数選択か(first-class の multiple。props.multiple も受け付ける) */
|
|
10
|
+
export declare function isMultiple(f: FieldV2): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* サポートテキストに自動で足す「形式: …/1ファイル 10MB まで」。
|
|
13
|
+
* help が形式名・容量をすでに書いているときは、その部分を足さない(重複させない)。
|
|
14
|
+
*/
|
|
15
|
+
export declare function fileSupportLine(f: FieldV2): string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* file → file-upload / photo_grid → file-upload + 画像グリッド
|
|
3
|
+
* DADS の file-upload は JS(カスタム要素)で一覧を更新する。選択ボタンと一覧更新は mount.ts で行う。
|
|
4
|
+
*/
|
|
5
|
+
import { type Ctl } from './control-label';
|
|
6
|
+
/** file-upload は label が for で input を指す。ボタンのラベル参照用に label へ id を付ける */
|
|
7
|
+
export declare function renderFile(c: Ctl): string;
|
|
8
|
+
/** 画像グリッド(props.photos: [{ src, alt }])+ 追加用 file-upload */
|
|
9
|
+
export declare function renderPhotoGrid(c: Ctl): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field 層: component(と条件)から DADS 部品への振り分け
|
|
3
|
+
*
|
|
4
|
+
* | component | 条件 | DADS 部品 |
|
|
5
|
+
* |---|---|---|
|
|
6
|
+
* | text / number / time / duration / combobox | | input-text |
|
|
7
|
+
* | textarea | | textarea |
|
|
8
|
+
* | date | | date-picker(inline は calendar)|
|
|
9
|
+
* | file / photo_grid | | file-upload |
|
|
10
|
+
* | select | | select(multiple は checkbox、segmented は radio)|
|
|
11
|
+
* | radio / checkbox / toggle | | radio / checkbox / switch |
|
|
12
|
+
* | browser | | select(階層は optgroup)|
|
|
13
|
+
* | badge / chip / status | | chip-label |
|
|
14
|
+
* | timeline / map | | list / image |
|
|
15
|
+
*/
|
|
16
|
+
import type { FieldV2 } from '../../types/schema-v2';
|
|
17
|
+
import { type FieldOpts } from './control-label';
|
|
18
|
+
export type { FieldOpts } from './control-label';
|
|
19
|
+
/** 1 項目を form-control-label でラップした HTML にする */
|
|
20
|
+
export declare function renderFieldV2(field: FieldV2, opts: FieldOpts): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* select / browser(階層は optgroup)と、select の変種の振り分け
|
|
3
|
+
*/
|
|
4
|
+
import type { OptionV2 } from '../../types/schema-v2';
|
|
5
|
+
import { type Ctl } from './control-label';
|
|
6
|
+
interface BrowserItem {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
children?: BrowserItem[];
|
|
10
|
+
}
|
|
11
|
+
export declare function option(o: OptionV2 | BrowserItem, current: string): string;
|
|
12
|
+
/** select 1 つ(form-control-label の外側)。一覧セルの入力欄からも使う */
|
|
13
|
+
export declare function selectControl(c: Ctl, body: string, ariaLabel?: string): string;
|
|
14
|
+
export declare function renderSelect(c: Ctl): string;
|
|
15
|
+
/** 階層を持つ項目は optgroup、持たない項目は option(props.items は { value, label, children? }) */
|
|
16
|
+
export declare function renderBrowser(c: Ctl): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* input-text 系: text / number / time / duration / combobox
|
|
3
|
+
*/
|
|
4
|
+
import { type Ctl } from './control-label';
|
|
5
|
+
interface InputOpts {
|
|
6
|
+
type: string;
|
|
7
|
+
inputmode?: string;
|
|
8
|
+
list?: string;
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
step?: number;
|
|
12
|
+
/** 入力欄の後ろに付ける単位(同じ control の中) */
|
|
13
|
+
unit?: string;
|
|
14
|
+
/** ラベルを持たない場所(一覧セル)で使う aria-label */
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
}
|
|
17
|
+
/** input-text 1 つ(form-control-label の外側)。一覧セルの入力欄からも使う */
|
|
18
|
+
export declare function inputText(c: Ctl, o: InputOpts): string;
|
|
19
|
+
export declare function renderText(c: Ctl): string;
|
|
20
|
+
export declare function renderNumber(c: Ctl): string;
|
|
21
|
+
export declare function renderTime(c: Ctl): string;
|
|
22
|
+
/** 数値入力 + 単位(unit、なければ props.unit、既定「分」) */
|
|
23
|
+
export declare function renderDuration(c: Ctl): string;
|
|
24
|
+
/** input-text + datalist(候補は options のラベル) */
|
|
25
|
+
export declare function renderCombobox(c: Ctl): string;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DADS が使う SVG アイコン
|
|
3
|
+
* 取得元: design-system-example-components-html の各コンポーネント HTML(dads/NOTICE.md 参照)
|
|
4
|
+
*/
|
|
5
|
+
/** select / horizontal-menu の下向きシェブロン */
|
|
6
|
+
export declare const chevronDown: (cls: string) => string;
|
|
7
|
+
export declare const breadcrumbSeparator = "<svg class=\"dads-breadcrumb__separator-icon\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\"><path d=\"M4.5 11L4 10.5L8 6.5L4 2.5L4.5 2L9 6.5L4.5 11Z\" fill=\"currentcolor\" /></svg>";
|
|
8
|
+
export declare const accordionChevron = "<svg class=\"dads-accordion__icon-svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M3.3 7.3L12 16L20.7 7.3\" fill=\"none\" stroke=\"currentcolor\" stroke-width=\"2\"/></svg>";
|
|
9
|
+
export declare const closeIcon = "<svg class=\"dads-notification-banner__close-icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6.4 18.6-1-1 5.5-5.6-5.6-5.6 1.1-1 5.6 5.5 5.6-5.6 1 1.1L13 12l5.6 5.6-1 1L12 13l-5.6 5.6Z\" fill=\"currentcolor\"/></svg>";
|
|
10
|
+
export declare const modalCloseIcon = "<svg class=\"dads-modal-dialog__close-icon\" width=\"24\" height=\"24\" viewBox=\"0 0 120 120\" aria-hidden=\"true\"><path d=\"M32 95L25 88L53 60L25 32L32 25L60 53L88 25L95 32L67 60L95 88L88 95L60 67L32 95Z\" fill=\"currentcolor\"/></svg>";
|
|
11
|
+
/** notification-banner の種別アイコン */
|
|
12
|
+
export declare const bannerIcons: {
|
|
13
|
+
readonly 'info-1': "<svg class=\"dads-notification-banner__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"インフォメーション\"><circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"currentcolor\"/><circle cx=\"12\" cy=\"8\" r=\"1\" fill=\"Canvas\"/><path d=\"M11 11h2v6h-2z\" fill=\"Canvas\"/></svg>";
|
|
14
|
+
readonly success: "<svg class=\"dads-notification-banner__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"成功\"><circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"currentcolor\"/><path d=\"m17.6 9.6-7 7-4.3-4.3L7.7 11l2.9 2.9 5.7-5.6 1.3 1.4Z\" fill=\"Canvas\"/></svg>";
|
|
15
|
+
readonly warning: "<svg class=\"dads-notification-banner__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"警告\"><path d=\"M1 21 12 2l11 19H1Z\" fill=\"currentcolor\"/><path d=\"M13 15h-2v-5h2v5Z\" fill=\"Canvas\"/><circle cx=\"12\" cy=\"17\" r=\"1\" fill=\"Canvas\"/></svg>";
|
|
16
|
+
readonly error: "<svg class=\"dads-notification-banner__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"エラー\"><path d=\"M8.25 21 3 15.75v-7.5L8.25 3h7.5L21 8.25v7.5L15.75 21h-7.5Z\" fill=\"currentcolor\"/><path d=\"m12 13.4-2.85 2.85-1.4-1.4L10.6 12 7.75 9.15l1.4-1.4L12 10.6l2.85-2.85 1.4 1.4L13.4 12l2.85 2.85-1.4 1.4L12 13.4Z\" fill=\"Canvas\"/></svg>";
|
|
17
|
+
};
|
|
18
|
+
/** step-navigation の完了アイコン(DADS 原文のまま) */
|
|
19
|
+
export declare const stepCompleted = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><circle cx=\"12\" cy=\"12\" r=\"12\" fill=\"#666\"/><path d=\"M10 17.5 19.8 8l-1.5-1.5-8.1 8-4.1-4L4.5 12l5.6 5.5Z\" fill=\"#fff\"/></svg>";
|
|
20
|
+
export declare const pageNavPrev = "<svg class=\"dads-button__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m7.9 12 8-8-1.4-1.4L5.1 12l9.4 9.4 1.4-1.4z\" fill=\"currentcolor\"/></svg>";
|
|
21
|
+
export declare const pageNavNext = "<svg class=\"dads-button__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 2.6 7.6 4l8 8-8 8L9 21.4l9.4-9.4z\" fill=\"currentcolor\"/></svg>";
|
|
22
|
+
/** table の並べ替えアイコン(none / ascending / descending) */
|
|
23
|
+
export declare const sortIcons: {
|
|
24
|
+
readonly none: "M17 18.11L21.27 14L22 14.7L16.5 20L11 14.7L11.73 14L16 18.12V4H17V18.12ZM8 5.88L12.27 10L13 9.3L7.5 4L2 9.3L2.73 10L7 5.88V20H8V5.88Z";
|
|
25
|
+
readonly ascending: "M17 18.12L21.27 14L22 14.7L16.5 20L11 14.7L11.73 14L16 18.12V4H17V18.12ZM14 8.92L11.73 11L9 8.52V20H6V8.52L3.27 11L1 8.93L7.5 3L14 8.93Z";
|
|
26
|
+
readonly descending: "M7 5.88L2.73 10L2 9.3L7.5 4L13 9.3L12.27 10L8 5.88V20H7V5.88ZM10 15.08L12.27 13L15 15.48V4H18V15.48L20.73 13L23 15.07L16.5 21L10 15.07Z";
|
|
27
|
+
};
|
|
28
|
+
export declare const sortSvg: (path: string) => string;
|
|
29
|
+
export declare const calendarPrev = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" role=\"img\" aria-label=\"\u524D\u306E\u6708\"><path d=\"m5.27 8 5.33-5.33-.93-.94L3.4 8l6.27 6.27.93-.94L5.27 8Z\" fill=\"currentcolor\" /></svg>";
|
|
30
|
+
export declare const calendarNext = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" role=\"img\" aria-label=\"\u6B21\u306E\u6708\"><path d=\"m6 1.73-.93.94L10.4 8l-5.33 5.33.93.94L12.27 8 6 1.73Z\" fill=\"currentcolor\" /></svg>";
|
|
31
|
+
export declare const switchCheck = "<svg class=\"dads-switch-on-off__icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" aria-hidden=\"true\"><path d=\"m10.4 16.3-4.1-4.1 1.2-1.3 2.9 2.9 6-6.1 1.3 1.2z\" fill=\"currentcolor\"/></svg>";
|
|
32
|
+
export declare const disclosureIcon = "<svg class=\"dads-disclosure__icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><circle cx=\"12\" cy=\"12\" r=\"11\" fill=\"currentcolor\"/><circle class=\"dads-disclosure__icon-circle\" cx=\"12\" cy=\"12\" r=\"8\" fill=\"currentcolor\"/><path class=\"dads-disclosure__icon-triangle\" d=\"M17 10H7L12 15L17 10Z\" fill=\"Canvas\"/></svg>";
|
|
33
|
+
export declare const calendarButtonIcon = "<svg class=\"dads-date-picker__calendar-icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"\u30AB\u30EC\u30F3\u30C0\u30FC\"><rect x=\"5\" y=\"10\" width=\"14\" height=\"10\" fill=\"Canvas\"/><path d=\"M9 16.5C7.62 16.5 6.5 15.38 6.5 14C6.5 12.62 7.62 11.5 9 11.5C10.38 11.5 11.5 12.62 11.5 14C11.5 15.38 10.38 16.5 9 16.5ZM5 22C3.9 22 3 21.09 3 20V6C3 4.91 3.91 4 5 4H6V2H8V4H16V2H18V4H19C20.09 4 21 4.91 21 6V20C21 21.09 20.09 22 19 22H5ZM5 20H19V10H5V20Z\" fill=\"currentcolor\"/></svg><svg class=\"dads-date-picker__calendar-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M12 17.1L3 8L4 7L12 15L20 7L21 8L12 17.1Z\" fill=\"currentcolor\" /></svg>";
|
|
34
|
+
/** 新規タブで開くリンクのアイコン(上流 link/new-tab.html) */
|
|
35
|
+
export declare const externalIcon = "<svg class=\"dads-link__icon\" width=\"16\" height=\"16\" viewBox=\"0 0 48 48\" role=\"img\" aria-label=\"\u65B0\u898F\u30BF\u30D6\u3067\u958B\u304D\u307E\u3059\"><path d=\"M22 6V9H9V39H39V26H42V42H6V6H22ZM42 6V20H39V11.2L21 29L19 27L36.8 9H28V6H42Z\" fill=\"currentcolor\"/></svg>";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mokkun v2 レンダラー(DADS 準拠)
|
|
3
|
+
* v2 文書を旧フォーマットへ変換せずに直接描画する。
|
|
4
|
+
*
|
|
5
|
+
* - renderViewV2: HTML 文字列を返す(SSR / 静的出力)
|
|
6
|
+
* - mountViewV2: container に描画し、イベントを結線して V2Controller を返す
|
|
7
|
+
*
|
|
8
|
+
* 設計: docs/format-redesign/03-renderer-v2.md
|
|
9
|
+
*/
|
|
10
|
+
import type { MokkunV2Schema } from '../types/schema-v2';
|
|
11
|
+
import { V2_VIEW_STATES, type V2RenderOptions, type V2ViewState } from './context';
|
|
12
|
+
/** onAction の付随情報 */
|
|
13
|
+
export interface V2ActionPayload {
|
|
14
|
+
/** Section.actions / list.bulkActions のとき、操作が属する Section の id */
|
|
15
|
+
section?: string;
|
|
16
|
+
/** list.bulkActions のとき、選択されている行の ID(行の `id`、なければ先頭列の値、なければ 1 始まりの通し番号) */
|
|
17
|
+
selectedRows?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface V2Callbacks {
|
|
20
|
+
/** グローバルナビ・パンくず・navigate アクションで遷移先 view を通知する */
|
|
21
|
+
onNavigate?: (view: string) => void;
|
|
22
|
+
/** navigate 以外のアクション(submit / custom / reset)を実行したとき。Section 内の操作は payload を持つ */
|
|
23
|
+
onAction?: (actionId: string, kind: string, payload?: V2ActionPayload) => void;
|
|
24
|
+
/** true のとき、遷移時に location.hash も書き換える(既定 false) */
|
|
25
|
+
syncHash?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface V2Controller {
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* view を HTML 文字列にする。出力は `.mokkun-v2` ルート要素で包まれる。
|
|
32
|
+
* view 名が存在しないときは空のルートにエラー文を入れて返す。
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderViewV2(schema: MokkunV2Schema, viewName: string, options?: V2RenderOptions): string;
|
|
35
|
+
/**
|
|
36
|
+
* container に view を描画して振る舞いを結線する。
|
|
37
|
+
* destroy() でイベントを外し、DADS の CSS 注入も解除する(二重に呼んでも何も起きない)。
|
|
38
|
+
* 同じ container に destroy() せずに続けて mount すると、前の mount のイベントが残って重複して結線される。
|
|
39
|
+
* 作り直すときは先に前の V2Controller の destroy() を呼ぶこと。
|
|
40
|
+
*/
|
|
41
|
+
export declare function mountViewV2(container: HTMLElement, schema: MokkunV2Schema, viewName: string, callbacks?: V2Callbacks & V2RenderOptions, options?: V2RenderOptions): V2Controller;
|
|
42
|
+
export { holdV2Styles } from './styles';
|
|
43
|
+
export { V2_VIEW_STATES };
|
|
44
|
+
export { availableStates, parseViewState, resolveRole, resolveViewState, V2_STATE_LABELS } from './view-state';
|
|
45
|
+
export type { V2RenderOptions, V2ViewState };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一覧のセル: 型ごとの表示(status = chip-label、date、number 右寄せ)、リンク(column.to)、入力欄(column.field)
|
|
3
|
+
*/
|
|
4
|
+
import type { ListColumnV2 } from '../types/schema-v2';
|
|
5
|
+
import { type ListRow } from './list-data';
|
|
6
|
+
export declare function renderCell(col: ListColumnV2, row: ListRow, index: number, base: string): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一覧(kind: list)の行データと、セルの型ごとの値の整形
|
|
3
|
+
* 行は list.rows(代表行)が優先。なければ列の id / ラベル / type からダミーを作る。
|
|
4
|
+
*/
|
|
5
|
+
import type { ListColumnV2, ListV2 } from '../types/schema-v2';
|
|
6
|
+
import type { ViewContext } from './context';
|
|
7
|
+
export type CellKind = 'id' | 'date' | 'number' | 'status' | 'text';
|
|
8
|
+
/** 列の種類。type があればそれに従い、なければ id / ラベルから推測する(従来どおり) */
|
|
9
|
+
export declare function columnKind(col: ListColumnV2): CellKind;
|
|
10
|
+
/**
|
|
11
|
+
* 状態列のダミー値に使うラベル。同じ view の status / select / radio などの選択肢から借りる
|
|
12
|
+
* (項目 id が列 id と同じか、列 id を含むもの。「すべて」は除く)。無ければ undefined
|
|
13
|
+
*/
|
|
14
|
+
export declare function statusLabelsFor(col: ListColumnV2, ctx: ViewContext): string[] | undefined;
|
|
15
|
+
/** 列の id / ラベルから推測したダミー値 */
|
|
16
|
+
export declare function dummyCell(col: ListColumnV2, row: number, ctx?: ViewContext): string;
|
|
17
|
+
export interface ListRow {
|
|
18
|
+
/** 行 ID。選択行の payload(selectedRows)と入力欄の name に使う。一覧の中で一意 */
|
|
19
|
+
id: string;
|
|
20
|
+
values: Record<string, unknown>;
|
|
21
|
+
/** 1 ページ目に収まらない行(rows と pageSize があるとき。並べ替えのあとで表示を決め直す) */
|
|
22
|
+
pageHidden: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 行 ID を一意にする。空のキーと重複したキーには `#<行の添字(0 始まり)>` を付ける
|
|
26
|
+
* (付けたあとも既存のキーと重なるなら、重ならなくなるまで `#` を足す)
|
|
27
|
+
*/
|
|
28
|
+
export declare function uniqueRowKeys(keys: string[]): string[];
|
|
29
|
+
/** 表示する行。empty 状態では 0 行。rows があればそれ(pageSize があれば 2 ページ目以降は pageHidden)、なければダミー行 */
|
|
30
|
+
export declare function listRows(list: ListV2, ctx: ViewContext): {
|
|
31
|
+
rows: ListRow[];
|
|
32
|
+
total: number;
|
|
33
|
+
given: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** 日付を「2026年11月7日」にする。YYYY-MM は「2026年11月」。解釈できない値はそのまま */
|
|
36
|
+
export declare function formatDateCell(value: unknown): string;
|
|
37
|
+
/** 数値セル: 数値(と数字だけの文字列)は桁区切りにする。単位付きの文字列はそのまま */
|
|
38
|
+
export declare function formatNumberCell(value: unknown): string;
|
|
39
|
+
/**
|
|
40
|
+
* 状態ラベル → チップの色(03-renderer-v2.md の表と同じ。上から順に最初に当たったものを使う)
|
|
41
|
+
*
|
|
42
|
+
* | 順 | 当たるラベル | 色 |
|
|
43
|
+
* |---|---|---|
|
|
44
|
+
* | 1 | 不承認・不承諾・非承認・不可・却下 | error(red) |
|
|
45
|
+
* | 2 | 未〜・不〜・非〜で始まる(未完了・不備)、〜予定、〜なし で終わる | neutral(gray) |
|
|
46
|
+
* | 3 | 〜待ち で終わる(承認待ち・キャンセル待ち) | warning(yellow) |
|
|
47
|
+
* | 4 | 間近・保留・注意・期限・差戻 | warning(yellow) |
|
|
48
|
+
* | 5 | 要確認・要対応・エラー・欠品・失敗・取下・無効・廃番 | error(red) |
|
|
49
|
+
* | 6 | 〜済(対応済み・送信済み・受付済)・完了・承認・内定・有効・適正・販売中・成功・受理 | success(green) |
|
|
50
|
+
* | 7 | 処理中・審査中・確認中・準備中・対応中・配送中・進行中 | info(light-blue) |
|
|
51
|
+
* | 8 | それ以外(キャンセル・受付・下書きなど) | neutral(gray) |
|
|
52
|
+
*/
|
|
53
|
+
export declare function statusColor(label: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 部品ごとの小さな振る舞い: switch / file-upload / table の並べ替え / tab / submenu / dialog
|
|
3
|
+
*/
|
|
4
|
+
/** switch の状態を aria-checked と、フォーム送信用の hidden input の両方へ反映する */
|
|
5
|
+
export declare function setSwitch(button: HTMLElement, on: boolean): void;
|
|
6
|
+
export declare function toggleSwitch(button: HTMLElement): void;
|
|
7
|
+
/** 選択済みファイルを一覧に反映する(DADS の file-upload JS の最小相当) */
|
|
8
|
+
export declare function updateFileList(input: HTMLInputElement): void;
|
|
9
|
+
/** 並べ替えヘッダーのクリック。none → ascending → descending → ascending … */
|
|
10
|
+
export declare function sortTable(button: HTMLElement): void;
|
|
11
|
+
/** rows と pageSize があるときは、並べ替えた全行の先頭 pageSize 件だけを表示する(2 ページ目以降は hidden) */
|
|
12
|
+
export declare function applyPage(list: HTMLElement | null): void;
|
|
13
|
+
export declare function selectTab(tab: HTMLElement): void;
|
|
14
|
+
/** 矢印キー / Home / End で隣のタブへ */
|
|
15
|
+
export declare function moveTabFocus(tab: HTMLElement, key: string): boolean;
|
|
16
|
+
export declare function setSubmenu(button: HTMLElement, open: boolean): void;
|
|
17
|
+
export declare function closeAllSubmenus(root: ParentNode): void;
|
|
18
|
+
export declare function openDialog(dialog: HTMLDialogElement): void;
|
|
19
|
+
export declare function closeDialog(dialog: HTMLDialogElement): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* repeatable: グループの追加・削除、添字の再採番、min / max の反映
|
|
3
|
+
*/
|
|
4
|
+
export declare function syncAllRepeatables(root: ParentNode): void;
|
|
5
|
+
/** クリックされたボタンが追加 / 削除なら処理して true を返す */
|
|
6
|
+
export declare function handleRepeatClick(target: Element): boolean;
|
|
7
|
+
/** フォームのリセット後: 繰り返しグループを min 件に戻す(超過分は削除) */
|
|
8
|
+
export declare function resetRepeatables(root: ParentNode): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section 単位の操作: reset(その Section の項目だけ初期値に戻す)、一括操作が使う選択行の収集
|
|
3
|
+
*/
|
|
4
|
+
/** 行の選択チェックボックス/ラジオで選ばれている行 ID(list.bulkActions の payload.selectedRows) */
|
|
5
|
+
export declare function selectedRowIds(root: HTMLElement, sectionId: string | undefined): string[];
|
|
6
|
+
/**
|
|
7
|
+
* その Section の入力欄だけを初期値に戻す(ネイティブの form.reset() はフォーム全体を戻してしまう)。
|
|
8
|
+
* 繰り返しは min 件に戻し、switch とファイル一覧も追随させる。
|
|
9
|
+
*/
|
|
10
|
+
export declare function resetSection(root: HTMLElement, sectionId: string | undefined): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 条件: 参照先項目の現在値で、visibleWhen(項目ラッパー/セクションの hidden)と
|
|
3
|
+
* requiredWhen(必須/任意の表示と required 属性)を切り替える
|
|
4
|
+
*/
|
|
5
|
+
import { type Token } from './condition';
|
|
6
|
+
/** 項目の現在値。複数選択(data-multiple)は選択値の配列、単一 checkbox / switch は 'true' / 'false' */
|
|
7
|
+
export declare function readValue(field: HTMLElement): Token;
|
|
8
|
+
/** root 内の [data-visible-when] をすべて評価する */
|
|
9
|
+
export declare function evaluateVisibility(root: ParentNode): void;
|
|
10
|
+
/** root 内の [data-required-when] をすべて評価し、「※必須」「※任意」と required 属性を切り替える */
|
|
11
|
+
export declare function evaluateRequired(root: ParentNode): void;
|
|
12
|
+
/** visibleWhen と requiredWhen を評価する */
|
|
13
|
+
export declare function evaluateConditions(root: ParentNode): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mountViewV2 の振る舞い結線(イベント委譲)
|
|
3
|
+
* - 遷移: グローバルナビ・パンくず・navigate アクション → callbacks.onNavigate
|
|
4
|
+
* - 確認ダイアログ: アクションボタンで開き、確定ボタンでアクションを実行
|
|
5
|
+
* - visibleWhen / repeatable / accordion 以外の DADS 部品の最小限の JS
|
|
6
|
+
*/
|
|
7
|
+
import type { V2Callbacks } from './index';
|
|
8
|
+
/** イベントを結線する。戻り値で解除 */
|
|
9
|
+
export declare function attachV2Behavior(root: HTMLElement, callbacks: V2Callbacks): () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ロール指定(Action.role / NavGroup.role / Notice.role)の評価
|
|
3
|
+
*/
|
|
4
|
+
import type { RoleSpecV2 } from '../types/schema-v2';
|
|
5
|
+
/**
|
|
6
|
+
* 現在のロールで表示するか。role の省略は全ロール、現在のロールが未選択なら常に表示する
|
|
7
|
+
* (ロールを選ばない既存の挙動を変えない)。
|
|
8
|
+
*/
|
|
9
|
+
export declare function visibleForRole(role: RoleSpecV2 | undefined, current: string | undefined): boolean;
|
|
10
|
+
/** ローカル日付 YYYY-MM-DD */
|
|
11
|
+
export declare function isoDate(date: Date): string;
|
|
12
|
+
/** until が今日より前なら期限切れ(当日までは表示する) */
|
|
13
|
+
export declare function isExpired(until: string | undefined, today: string): boolean;
|
|
14
|
+
/** 今日(YYYY-MM-DD)。YYYY-MM-DD の文字列か有効な Date だけ受け付け、それ以外は実行時の日付にする */
|
|
15
|
+
export declare function resolveToday(today: Date | string | undefined): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kind: form の項目グリッドと repeatable
|
|
3
|
+
*/
|
|
4
|
+
import type { SectionV2 } from '../types/schema-v2';
|
|
5
|
+
import { type ViewContext } from './context';
|
|
6
|
+
/** 添字付きの DOM id / name の区切り。mount.ts が繰り返しの再採番に使う */
|
|
7
|
+
export declare const GROUP_SEP = "__";
|
|
8
|
+
/** 項目グリッド。group を渡すと繰り返しグループ内(id / name に添字を付ける) */
|
|
9
|
+
export declare function renderFieldGrid(section: SectionV2, ctx: ViewContext, group?: number): string;
|
|
10
|
+
/** 繰り返し: min 件を初期表示し、追加用に <template> を持つ */
|
|
11
|
+
export declare function renderRepeatable(section: SectionV2, ctx: ViewContext): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kind: list → table(ソート可能列は sortable-header)+ page-navigation
|
|
3
|
+
* 行は list.rows(代表行)があればそれを、なければ list-data.ts のダミー(3 行)
|
|
4
|
+
* 検索と bulkActions(選択した行への操作)は表の上の同じ行に置く
|
|
5
|
+
*/
|
|
6
|
+
import type { SectionV2 } from '../types/schema-v2';
|
|
7
|
+
import { type ViewContext } from './context';
|
|
8
|
+
export declare function renderList(section: SectionV2, ctx: ViewContext): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kind: readonly / summary → description-list(term = ラベル、description = 値)
|
|
3
|
+
*/
|
|
4
|
+
import type { FieldV2, SectionV2 } from '../types/schema-v2';
|
|
5
|
+
import type { ViewContext } from './context';
|
|
6
|
+
/** 表示値(options があればラベルに置換、値なしは -) */
|
|
7
|
+
export declare function displayText(f: FieldV2): string;
|
|
8
|
+
export declare function renderReadonly(section: SectionV2, ctx: ViewContext): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section 層: kind / reveal / repeatable の出し分け
|
|
3
|
+
*
|
|
4
|
+
* - reveal: collapsed が 1 つだけ → DADS disclosure(見出しはサマリー自身)
|
|
5
|
+
* - collapsed が連続 → 1 つの積み重ねた DADS accordion(各サマリー = セクション名)
|
|
6
|
+
* - visibleWhen はセクション要素自身に付ける(見出しごと隠れる)
|
|
7
|
+
*/
|
|
8
|
+
import type { SectionV2 } from '../types/schema-v2';
|
|
9
|
+
import { type ViewContext } from './context';
|
|
10
|
+
/** Section の DOM id(toc・タブのリンク先) */
|
|
11
|
+
export declare function sectionDomId(ctx: ViewContext, section: SectionV2): string;
|
|
12
|
+
/** 通常(open)のセクション */
|
|
13
|
+
export declare function renderSection(section: SectionV2, ctx: ViewContext): string;
|
|
14
|
+
/** セクション列を描画する。連続する collapsed は 1 つの accordion にまとめ、1 つだけなら disclosure */
|
|
15
|
+
export declare function renderSections(sections: SectionV2[], ctx: ViewContext): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DADS の CSS を v2 描画中だけ document に差し込む。
|
|
3
|
+
*
|
|
4
|
+
* DADS の global.css は html / a / :focus-visible などの要素セレクタを含むため、
|
|
5
|
+
* ライブラリの CSS(mokkun.css)に静的に含めると v1 画面まで再スタイルされる。
|
|
6
|
+
* そのため ?inline で文字列として取り込み、v2 を描画している間だけ <style> として挿入する。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* スタイルを 1 つ保持する。戻り値の release で解放する(二重に呼んでも 1 回分しか減らない)。
|
|
10
|
+
* 画面遷移で「古い view を destroy → 新しい view を mount」する間に <style> が外れて付け直されないよう、
|
|
11
|
+
* 呼び出し側は destroy の前に hold し、mount の後に release する。
|
|
12
|
+
*/
|
|
13
|
+
export declare function holdV2Styles(): () => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2 レンダラー共通ユーティリティ
|
|
3
|
+
* HTML 文字列を組み立てるための最小限のヘルパー(DOM に依存しない)
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* ユーザー由来のテキストを HTML(要素内・属性値)に埋め込めるようエスケープする
|
|
7
|
+
*/
|
|
8
|
+
export declare function esc(value: unknown): string;
|
|
9
|
+
type AttrValue = string | number | boolean | null | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* 属性文字列を組み立てる。true は値なし属性、false / null / undefined は出力しない。
|
|
12
|
+
* 先頭に空白を含むため、そのままタグ名の直後に連結できる。
|
|
13
|
+
*/
|
|
14
|
+
export declare function attrs(map: Record<string, AttrValue>): string;
|
|
15
|
+
/** 値を比較用の文字列にする(YAML の数値・真偽値と DOM の文字列値を揃える) */
|
|
16
|
+
export declare function str(value: unknown): string;
|
|
17
|
+
/** props から文字列を取り出す */
|
|
18
|
+
export declare function propString(props: Record<string, unknown> | undefined, key: string): string | undefined;
|
|
19
|
+
/** props から有限の数値を取り出す */
|
|
20
|
+
export declare function propNumber(props: Record<string, unknown> | undefined, key: string): number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* リンク・画像の URL を http / https / mailto に限る(javascript: などは '#' に置き換える)。
|
|
23
|
+
* 相対 URL は許可する。
|
|
24
|
+
*/
|
|
25
|
+
export declare function safeUrl(url: unknown): string;
|
|
26
|
+
/** props の配列から、指定キーが文字列のオブジェクトだけを取り出す */
|
|
27
|
+
export declare function objectItems<T extends object>(value: unknown, requiredStringKey: string): T[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View の状態表示(ビューアーの「状態」切替)
|
|
3
|
+
* - 既定(normal)は状態バナーを出さない。success / error は選ばれた 1 つだけ、同時には出さない
|
|
4
|
+
* - loading は DADS の progress-indicator(スピナー)。フォームの代わりに出す
|
|
5
|
+
* - empty は一覧の空表示(section-list.ts)で扱う
|
|
6
|
+
*/
|
|
7
|
+
import type { MokkunV2Schema } from '../types/schema-v2';
|
|
8
|
+
import { type V2ViewState, type ViewContext } from './context';
|
|
9
|
+
/** states.success / error のバナー。選ばれた状態の分だけ出す */
|
|
10
|
+
export declare function renderStates(ctx: ViewContext): string;
|
|
11
|
+
/** 読み込み中(上流 progress-indicator の spinner-loop.html、stacked / 大)。不確定進捗なので data-indeterminate を静的に付ける */
|
|
12
|
+
export declare function renderLoading(ctx: ViewContext): string;
|
|
13
|
+
/** 状態の表示名(ビューアーの選択肢) */
|
|
14
|
+
export declare const V2_STATE_LABELS: Record<V2ViewState, string>;
|
|
15
|
+
/**
|
|
16
|
+
* view が選べる状態。normal は常に、success / error / loading は対応する states.* があるとき、
|
|
17
|
+
* empty は states.empty か、list.empty を持つ一覧があるとき(一覧の空文言は list.empty が正)
|
|
18
|
+
*/
|
|
19
|
+
export declare function availableStates(schema: MokkunV2Schema, viewName: string): V2ViewState[];
|
|
20
|
+
/** URL パラメータなどの文字列を状態にする(不正は normal) */
|
|
21
|
+
export declare function parseViewState(value: unknown): V2ViewState;
|
|
22
|
+
/** view で選べない状態なら normal に戻す(不正な値も normal) */
|
|
23
|
+
export declare function resolveViewState(schema: MokkunV2Schema, viewName: string, state: unknown): V2ViewState;
|
|
24
|
+
/** app.roles にあるロールだけ(それ以外は未選択=すべて) */
|
|
25
|
+
export declare function resolveRole(schema: MokkunV2Schema, role: unknown): string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View 層: 見出し、ゴール、手順ナビ、状態バナー、アクション、レイアウト(stack / tabs / sectioned)
|
|
3
|
+
*/
|
|
4
|
+
import { type ViewContext } from './context';
|
|
5
|
+
/** flow の手順ナビ(step-navigation, horizontal)。前の step は completed、現在の step は reached */
|
|
6
|
+
export declare function renderStepNavigation(ctx: ViewContext): string;
|
|
7
|
+
/** View 本体(main の中身): パンくずは app-shell 側で前置する */
|
|
8
|
+
export declare function renderViewBody(ctx: ViewContext): string;
|