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

ViewAttributeSelectionブロック

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

インストール

npm install @nodeblocks/frontend-view-attribute-selection-block

必要なもの

項目用途
labels.headerTitleヘッダーのセクションタイトル(デフォルト 職種
data選択された属性。値のみの行には ReactNode[]、各行にラベルが必要な場合は Record<string, ReactNode>
labels.headerActionButton + headerAction(任意)アウトラインのヘッダーボタンのラベル(デフォルト 編集)とクリックハンドラー
labels.subheaderTitle(任意)ヘッダー下の補助行
layout(任意)one-column はキー/値の行を縦に積み、two-column は横並びに表示(デフォルト)
属性データはアプリ側で管理する

ViewAttributeSelection は選択状態を内部で保持しません — ページから labelsdata、任意の headerAction を渡してください。行が値のみの場合(選択された職種のリストなど)は ReactNode[] を使用します。各属性カテゴリに独自のラベルが必要な場合(例: one-column レイアウトのスキル領域)はオブジェクトを使用します。ヘッダーの編集ボタンを表示するには labels.headerActionButtonheaderAction を設定します。

コード例

ライブエディター
function Example() {
  const data = [
    <Box key="roles" sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
      <Typography variant="body2">フロントエンドエンジニア(未選択)</Typography>
      <Typography variant="body2">バックエンドエンジニア(5年)</Typography>
      <Typography variant="body2">データベースエンジニア(5年)</Typography>
    </Box>,
  ];

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

主要プロパティ

コアプロパティ

プロパティ必須デフォルト説明
dataRecord<string, ReactNode> | ReactNode[]いいえ[]行の内容: オブジェクトのキーがフィールドラベルになり、配列は値のみの行をレンダリング
labels{ headerTitle?: string; headerActionButton?: string; subheaderTitle?: string }いいえ{}(下記のブロックデフォルトとマージ)ヘッダータイトル、任意のアクションボタンラベル、サブヘッダーのコピー

コンテンツプロパティ

プロパティ必須デフォルト説明
labels.headerTitlestringいいえ職種ViewAttributeSelection.Header のメイン見出し
labels.subheaderTitlestringいいえundefinedヘッダー下の補助行(ViewAttributeSelection.Subheader
labels.headerActionButtonstringいいえ編集アウトラインのヘッダーボタンのラベル。labels.headerActionButton または headerAction が設定されている場合に表示されます。
headerAction() => voidいいえundefinedデフォルトのヘッダーアクションボタンがクリックされたときに呼び出されます。
layout'one-column' | 'two-column'いいえ'two-column'行レイアウト: キー/値を縦に積むか、横並びの列にするか

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

プロパティ必須デフォルト説明
childrenBlocksOverride | ReactNodeいいえundefined複合 JSX の子、または blocksblockOrder を返す関数オーバーライド
classNamestringいいえundefinedルートスタックのクラス名(nbb-view-attribute-selection
sxSxPropsいいえundefinedルートスタック用の MUI システムスタイル(デフォルトレンダリングには margin: 'auto' を含む)

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

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

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

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

デフォルト UI ブロック

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

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

TypeScript

import * as React from 'react';
import { ViewAttributeSelection } from '@nodeblocks/frontend-view-attribute-selection-block';
import type { ReactNode } from 'react';

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

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

export function AttributeSelectionDetailView() {
const labels: AttributeSelectionLabels = {
headerTitle: '担当職種',
headerActionButton: '職種を編集',
};

const data: AttributeSelectionData = [
<div key="roles">
<div>フロントエンドエンジニア(未選択)</div>
<div>バックエンドエンジニア(5年)</div>
</div>,
];

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