メインコンテンツまでスキップ

ViewBasicInformationブロック

ViewBasicInformation は、MUI 上に構築されたキー・バリュー表示ブロックで、ヘッダー(タイトルと任意のアクションボタン)、任意のサブヘッダーを備えています。

インストール

npm install @nodeblocks/frontend-view-basic-information-block

必要なもの

項目用途
labels.headerTitleヘッダーのメイン見出し(デフォルト 基本情報
dataフィールド行を Record<string, ReactNode>(行キーがラベルになる)または値のみの行用の ReactNode[] として渡す
labels.headerActionButton + headerAction (任意)アウトラインのヘッダーボタンのラベル(デフォルト 編集)とクリックハンドラー
labels.subheaderTitle (任意)ヘッダー下のセカンダリ行
基本情報データはアプリ側で管理する

ViewBasicInformation は状態を保持しません — ページから labelsdata、任意の headerAction を渡してください。オブジェクト形式の data のキーが行ラベルになり、値は文字列または React ノード(複数行テキスト、リンク、カスタムレイアウト)にできます。labels.headerActionButtonheaderAction を設定すると、ヘッダーアクションボタンが表示されます。

コード例

ライブエディター
function Example() {
  const data = {
    氏名: (
      <div>
        <div>Hanako Iwata</div>
        <div>IWATA HANAKO</div>
      </div>
    ),
    住所: '1-1-1 Higashiyoshinocho, Tokushima-shi, Tokushima 771-0801',
    電話番号: '+81 90-1111-1111',
  };

  return <ViewBasicInformation data={data} />;
}
結果
Loading...

主要プロパティ

コアプロパティ

プロパティ必須デフォルト説明
dataRecord<string, ReactNode> | ReactNode[]いいえ{ 氏名: <></>, 住所: <></>, 連絡先電話番号: <></> }行コンテンツ: オブジェクトのキーがフィールドラベルになる; 配列は値のみの行をレンダリング
labels{ headerTitle?: string; headerActionButton?: string; subheaderTitle?: string }いいえ{ headerTitle: '基本情報', headerActionButton: '編集' }ヘッダータイトル、任意のアクションボタンラベル、任意のサブヘッダーのテキスト

コンテンツプロパティ

プロパティ必須デフォルト説明
labels.headerTitlestringいいえ基本情報ViewBasicInformation.Header のメイン見出し
labels.subheaderTitlestringいいえundefinedヘッダー下のセカンダリ行(ViewBasicInformation.Subheader
labels.headerActionButtonstringいいえ編集アウトラインのヘッダーボタンのラベル; labels.headerActionButton または headerAction が設定されている場合(または ViewBasicInformation.HeaderActionButton に渡されている場合)に表示
headerAction() => voidいいえundefinedデフォルトのヘッダーアクションボタンがクリックされたときに呼び出される

レイアウトと構成プロパティ

プロパティ必須デフォルト説明
childrenBlocksOverride | ReactNodeいいえundefined複合 JSX の子、または blocksblockOrder を返す関数オーバーライド
classNamestringいいえundefinedルートスタックのクラス名(nbb-view-basic-information
sxSxPropsいいえ[{ margin: 'auto' }, ...sx]ルートスタック用の MUI システムスタイル; デフォルトレンダーは margin: 'auto' を先頭に追加

ViewBasicInformationStackPropschildren を除く)を継承します。デフォルトの defaultBlockOrder: headersubheaderitemListitemitemKeyitemValue

サブコンポーネントのプロパティ

サブコンポーネントはコンテキストから読み取り、同じコンテンツキーをプロパティとして渡すとローカルで上書きできます。

サブコンポーネント主要プロパティ継承ベース
ViewBasicInformation.HeaderlabelsheaderTitleheaderActionButton)、headerActionchildrenclassNamesxStackPropsStack + Typography + 任意の ViewBasicInformation.HeaderActionButton
ViewBasicInformation.HeaderActionButtonlabelsheaderActionButton)、headerActionchildrenclassNameonClickButtonPropsButtonvariant="outlined"size="medium"
ViewBasicInformation.SubheaderlabelssubheaderTitleheaderTitleheaderActionButton)、childrenclassNamesxStackPropsStack + Typography
ViewBasicInformation.ItemListdatachildrenclassNamesxListPropsListcomponent="dl")+ ViewBasicInformation.Item
ViewBasicInformation.ItemchildrenclassNamesxListItemPropsListItem
ViewBasicInformation.Item.KeychildrenclassNamesxTypographyPropsTypographycomponent="dt"variant="subtitle1"
ViewBasicInformation.Item.ValuechildrenclassNamesxTypographyPropsTypographycomponent="dd"variant="body2"

デフォルト UI ブロック

ブロックベース備考
ViewBasicInformation(ルート)Stackspacing={3}margin: 'auto' の縦レイアウト(nbb-view-basic-information
headerViewBasicInformation.HeaderStacklabels.headerTitlelabels.headerActionButton、またはカスタム children が設定されている場合にレンダリング; headerAction または labels.headerActionButton が設定されている場合は ViewBasicInformation.HeaderActionButton を含む
subheaderViewBasicInformation.SubheaderStacklabels.subheaderTitle またはカスタム children が設定されている場合にレンダリング
itemListViewBasicInformation.ItemListListdata オブジェクトのエントリまたは配列の値をキー/バリュー行にマッピング

デフォルトのルートレンダリング順序: headersubheaderitemList

TypeScript

import * as React from 'react';
import { ViewBasicInformation } from '@nodeblocks/frontend-view-basic-information-block';
import type { ReactNode } from 'react';

type BasicInformationLabels = {
headerTitle?: string;
headerActionButton?: string;
subheaderTitle?: string;
};

type BasicInformationData = Record<string, ReactNode> | ReactNode[];

export function BasicInformationDetailView() {
const labels: BasicInformationLabels = {
headerTitle: '基本情報',
headerActionButton: '編集',
};

const data: BasicInformationData = {
氏名: 'Hanako Iwata',
住所: '1-1-1 Higashiyoshinocho, Tokushima-shi, Tokushima 771-0801',
電話番号: '+81 90-1111-1111',
};

return (
<ViewBasicInformation
labels={labels}
data={data}
headerAction={() => {
/* 遷移または編集ダイアログを開く */
}}
/>
);
}