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

ViewOrderブロック

ViewOrder は、MUI 上に構築されたキー・値表示ブロックで、ヘッダー(タイトルとステータスバッジ)と任意のサブヘッダーを備えています。

インストール

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

必要なもの

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

ViewOrder は注文の状態を保持しません — ページから labelsdata、任意の 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[]いいえundefined行コンテンツ: オブジェクトのキーがフィールドラベルになり、配列は値のみの行をレンダリングする
labels{ headerTitle?: string; subheaderTitle?: string; status?: string; statusText?: string }いいえ{}ヘッダータイトル、任意のサブヘッダー、ステータスバッジのコピー(statusText でデフォルトヘッダーにバッジを表示)

コンテンツプロパティ

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

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

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

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

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

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

サブコンポーネント主要プロパティ継承ベース
ViewOrder.HeaderlabelsheaderTitlestatusstatusText)、childrenclassNamesxStackPropsStack + Typography + statusText 設定時は ViewOrder.Status
ViewOrder.StatuslabelsstatusstatusText)、statusColorchildrenclassNamesxStackPropsStack + Box + Typography
ViewOrder.SubheaderlabelssubheaderTitleheaderTitleheaderActionButton)、childrenclassNamesxStackPropsStack + Typography
ViewOrder.ItemListdatachildrenclassNamesxListPropsListcomponent="dl")+ ViewOrder.Item
ViewOrder.ItemlayoutchildrenclassNamesxListItemPropsListItem
ViewOrder.Item.KeylayoutchildrenclassNamesxTypographyPropsTypographycomponent="dt"variant="subtitle1"
ViewOrder.Item.ValuelayoutchildrenclassNamesxTypographyPropsTypographycomponent="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 オブジェクトのエントリまたは配列の値をキー/値行にマッピング

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

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} />;
}