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

注文詳細ブロック

ViewOrder は、MUI 上に構築された制御型の注文詳細表示ブロックです。

インストール​

npm install @nodeblocks/frontend-view-order-block@0.4.0

必要なもの​

項目用途
labels.headerTitleヘッダー内のメイン見出し
labels.statusTextステータスバッジの値。設定するとヘッダーに ViewOrder.Status が表示される
data注文フィールドを Record<string, ReactNode>(行のキーがラベルになる)または値のみの行用の ReactNode[] で渡す
labels.status (任意)ステータスバッジ上のラベル(デフォルト 'Status')
statusColor (任意)ステータスバッジの背景色
注文データはアプリ側で管理する

ViewOrder は注文の状態を保持しません — ページから labels、data、任意の statusColor を渡してください。オブジェクト形式の data ではキーが行ラベルになり、値は文字列または React ノード(リンク、画像、レイアウト)にできます。ヘッダーにステータスバッジを表示するには labels.statusText を設定します。

コード例​

ライブエディター
function Example() {
  const labels = {
    headerTitle: '注文詳細',
    statusText: '処理中',
    status: '現在のステータス',
  };

  const data = {
    '注文 ID': '#12345',
    お客様: '山田太郎',
    日付: '2024-01-15',
    合計: '$199.99',
  };

  return (
    <ViewOrder labels={labels} statusColor="#e3f2fd" data={data} />
  );
}
結果
Loading...

主要プロパティ​

コアプロパティ​

プロパティ型必須デフォルト説明
dataRecord<string, ReactNode> | ReactNode[]いいえ-行コンテンツ: オブジェクトのキーがフィールドラベルになり、配列は値のみの行をレンダリングする
labels{ headerTitle?: string; subheaderTitle?: string; status?: string; statusText?: string }いいえ{}ヘッダータイトル、任意のサブヘッダー、ステータスバッジのコピー(statusText でデフォルトヘッダーにバッジを表示)

コンテンツプロパティ​

プロパティ型必須デフォルト説明
labels.headerTitlestringいいえ-ViewOrder.Header 内のメイン見出し
labels.subheaderTitlestringいいえ-ヘッダー下のセカンダリ行(ViewOrder.Subheader)
labels.statusstringいいえ'Status'ステータスバッジ上のラベル(ViewOrder.Status)
labels.statusTextstringいいえ-ステータスバッジの値。設定するとデフォルトヘッダーに表示される
statusColorstringいいえ-ステータスバッジの背景。未設定時は theme.palette.grey[50] にフォールバック
layout'one-column' | 'two-column'いいえ'two-column'行レイアウト: キー/値の積み上げ vs 横並びの2列

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

プロパティ型必須デフォルト説明
childrenBlocksOverride | ReactNodeいいえ-複合 JSX の子、または blocks と blockOrder を返す関数オーバーライド
classNamestringいいえ-ルートスタック(nbb-view-order)のクラス名
sxSxPropsいいえ-ルートスタック用の MUI システムスタイル

ViewOrder は StackProps(children を除く)を継承します。デフォルトの defaultBlockOrder: header、subheader、itemList、item、itemKey、itemValue。

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

サブコンポーネントはコンテキストから読み取り、同じコンテンツキーをプロパティとして受け取り、ローカルでオーバーライドできます。

サブコンポーネント主要プロパティ継承ベース
ViewOrder.Headerlabels(headerTitle、status、statusText)、children、className、sxStackPropsStack + Typography + statusText 設定時は ViewOrder.Status
ViewOrder.Statuslabels(status、statusText)、statusColor、children、className、sxStackPropsStack + Box + Typography
ViewOrder.Subheaderlabels(subheaderTitle、headerTitle、headerActionButton)、children、className、sxStackPropsStack + Typography
ViewOrder.ItemListdata、children、className、sxListPropsList(component="dl")+ ViewOrder.Item 行
ViewOrder.Itemlayout、children、className、sxListItemPropsListItem
ViewOrder.Item.Keylayout、children、className、sxTypographyPropsTypography(component="dt"、variant="subtitle1")
ViewOrder.Item.Valuelayout、children、className、sxTypographyPropsTypography(component="dd"、variant="body2")

デフォルト UI ブロック​

ブロックベース備考
ViewOrder (ルート)Stackspacing={3} の縦レイアウト(nbb-view-order)
header (ViewOrder.Header)StackheaderTitle + labels.statusText 設定時は任意の ViewOrder.Status
subheader (ViewOrder.Subheader)Stacklabels.subheaderTitle またはカスタム children があるときにレンダリング
itemList (ViewOrder.ItemList)Listdata オブジェクトのエントリまたは配列の値をキー/値行にマッピング

デフォルトのルートレンダリング順: header → subheader → itemList。

TypeScript​

import * as React from 'react';
import { ViewOrder } from '@nodeblocks/frontend-view-order-block';
import type { ReactNode } from 'react';

type OrderLabels = {
headerTitle?: string;
subheaderTitle?: string;
status?: string;
statusText?: string;
};

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

export function OrderDetailView() {
const labels: OrderLabels = {
headerTitle: '注文詳細',
status: '現在のステータス',
statusText: '処理中',
};

const data: OrderData = {
'注文 ID': '#12345',
お客様: '山田太郎',
日付: '2024-01-15',
合計: '$199.99',
};

return <ViewOrder labels={labels} statusColor="#e3f2fd" data={data} />;
}