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

組織作成ブロック

CreateOrganizationコンポーネントは、React、TypeScript、MUIで構築された完全にカスタマイズ可能でアクセシブルな組織登録フォームです。react-hook-formを使用したフォームバリデーション、マルチセクション組織、柔軟なカスタマイズオプションを備えた完全なビジネス登録インターフェースを提供します。


🚀 インストール

npm install @nodeblocks/frontend-create-organization-block@0.2.0

📖 使用法

import {CreateOrganization} from '@nodeblocks/frontend-create-organization-block';
ライブエディター
function SimpleCreateOrganization() {
  const handleCreateOrganization = (data) => {
    console.log('組織が作成されました:', data);
  };

  return (
    <CreateOrganization
      onCreateOrganization={handleCreateOrganization}
      termsOfUseUrl="#terms"
      privacyAgreementUrl="#privacy"
      sx={{maxWidth: 600, mx: 'auto', p: 3}}
    >
      <CreateOrganization.Title>組織を作成</CreateOrganization.Title>
      <CreateOrganization.Description>
        以下のフォームにご記入いただき、貴社の組織を登録してください
      </CreateOrganization.Description>
      <CreateOrganization.Form>
        <CreateOrganization.Form.AccountHolder>
          <CreateOrganization.Form.AccountHolder.SectionTitle>
            アカウント責任者情報
          </CreateOrganization.Form.AccountHolder.SectionTitle>
          <CreateOrganization.Form.AccountHolder.Name />
          <CreateOrganization.Form.AccountHolder.Email />
          <CreateOrganization.Form.AccountHolder.Contact />
        </CreateOrganization.Form.AccountHolder>
        <CreateOrganization.Form.CompanyInformation>
          <CreateOrganization.Form.CompanyInformation.SectionTitle>
            会社情報
          </CreateOrganization.Form.CompanyInformation.SectionTitle>
          <CreateOrganization.Form.CompanyInformation.CompanyName />
        </CreateOrganization.Form.CompanyInformation>
        <CreateOrganization.Form.Compliance>
          <CreateOrganization.Form.Compliance.CheckUserAgreement />
          <CreateOrganization.Form.Compliance.CheckPrivacyAgreement />
        </CreateOrganization.Form.Compliance>
        <CreateOrganization.Form.SubmitButton>送信</CreateOrganization.Form.SubmitButton>
      </CreateOrganization.Form>
    </CreateOrganization>
  );
}
結果
Loading...

🔧 プロパティリファレンス

メインコンポーネントのプロパティ

プロパティデフォルト説明
onCreateOrganization(data: T) => void必須フォームが送信されたときにトリガーされるコールバック関数
defaultValuesDefaultValues<T>undefinedreact-hook-form用のデフォルトフォーム値
onChange(setError, getValues) => voidundefinedフォーム値が変更されたときのコールバック
termsOfUseUrlstring"/terms-of-use"利用規約リンクのURL
privacyAgreementUrlstring"/privacy-policy"プライバシーポリシーリンクのURL
classNamestringundefinedスタイリング用の追加CSSクラス名
childrenBlocksOverrideundefinedデフォルトブロックをオーバーライドする関数

注意: メインコンポーネントはMUI Stackプロパティを継承します。ルートコンテナはデフォルトでspacing={4}sx={{ p: 3 }}を使用します。

サブコンポーネント

CreateOrganization.Title

プロパティデフォルト説明
childrenReactNode"Create your Organization"タイトルコンテンツ
classNamestringundefined追加CSSクラス名

注意: MUI Typographyプロパティを継承します。variant="h4"component="h2"、中央揃えテキストと太字フォントを使用します。

CreateOrganization.Description

プロパティデフォルト説明
childrenReactNodeデフォルト説明テキスト説明コンテンツ
classNamestringundefined追加CSSクラス名

注意: MUI Typographyプロパティを継承します。variant="body2"、セカンダリテキストカラー、中央揃えを使用します。

CreateOrganization.Form

プロパティデフォルト説明
childrenBlocksOverrideundefinedフォームコンテンツセクション
classNamestringundefined追加CSSクラス名

注意: MUI Stackプロパティを継承し、component="form"として使用します。デフォルトでspacing={6}を使用します。

CreateOrganization.Form.AccountHolder

プロパティデフォルト説明
childrenBlocksOverrideundefinedアカウント責任者フィールド
classNamestringundefined追加CSSクラス名

注意: MUI Stackプロパティを継承します。デフォルトでspacing={4}を使用します。

アカウント責任者サブコンポーネント:

コンポーネントデフォルト名デフォルトラベル必須
AccountHolder.SectionTitle-"Account Holder Contact Information"-
AccountHolder.NameapplicationUserName"Name"はい
AccountHolder.EmailapplicationUserEmail"Email"はい
AccountHolder.ContactapplicationUserPhoneNumber"Phone Number"はい

CreateOrganization.Form.CompanyInformation

プロパティデフォルト説明
childrenBlocksOverrideundefined会社情報フィールド
classNamestringundefined追加CSSクラス名

注意: MUI Stackプロパティを継承します。デフォルトでspacing={4}を使用します。

会社情報サブコンポーネント:

コンポーネントデフォルト名デフォルトラベル必須
CompanyInformation.SectionTitle-"Company Information"-
CompanyInformation.CompanyNamecompanyName"Company Name"はい
CompanyInformation.CompanyCapitalcapitalRange"Capital Range"はい
CompanyInformation.CompanySizenumberOfEmployees"Number of Employees"はい
CompanyInformation.HomePageUrlcompanyUrl"Home Page URL"はい
CompanyInformation.AdditionalInformationadditionalInformation"Additional Information"いいえ

CreateOrganization.Form.CompanyInformation.CompanyAddress

プロパティデフォルト説明
childrenBlocksOverrideundefined住所フィールド
classNamestringundefined追加CSSクラス名

注意: MUI Stackプロパティを継承します。デフォルトでspacing={2.5}を使用します。

会社住所サブコンポーネント:

コンポーネントデフォルト名デフォルトラベル必須
CompanyAddress.LocationTitle-"Head Office Location"-
CompanyAddress.PostCodepostcode"Post Code"はい
CompanyAddress.Prefectureprefecture"Prefecture"はい
CompanyAddress.CitycityTownVillage"City"はい
CompanyAddress.TownAddresstownStreetBuilding"Address"はい
CompanyAddress.RepresentativePersonNamerepresentivePersonName"Representative Name"はい
CompanyAddress.RepresentativeContactrepresentativePhoneNumber"Representative Phone Number"はい

注意: 都道府県フィールドは47都道府県がオプションとして事前設定されています。

CreateOrganization.Form.Compliance

プロパティデフォルト説明
childrenBlocksOverrideundefinedコンプライアンスチェックボックス
classNamestringundefined追加CSSクラス名

注意: MUI Stackプロパティを継承します。デフォルトでspacing={3}direction="row"justifyContent="center"を使用します。

コンプライアンスサブコンポーネント:

コンポーネントデフォルト名説明
Compliance.CheckUserAgreementuserAgreement利用規約同意チェックボックス
Compliance.CheckPrivacyAgreementprivacyPolicyプライバシーポリシー同意チェックボックス

CreateOrganization.Form.SubmitButton

プロパティデフォルト説明
childrenReactNode"Submit"ボタンテキスト
classNamestringundefined追加CSSクラス名

注意: MUI Buttonプロパティを継承します。variant="contained"size="large"type="submit"を使用します。フォームが無効な場合、ボタンは無効化されます。


🎨 Configuration examples

Custom Title Styling

<CreateOrganization.Title
sx={{
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
WebkitBackgroundClip: 'text',
WebkitTextFillColor: 'transparent',
fontSize: '2rem',
fontWeight: 700,
}}
>
組織を登録
</CreateOrganization.Title>

Custom Field Labels

<CreateOrganization.Form.AccountHolder.Name 
label="氏名"
placeholder="氏名を入力してください"
/>

Custom Select Options

<CreateOrganization.Form.CompanyInformation.CompanyCapital 
options={[
{ value: 'small', label: '100万円未満' },
{ value: 'medium', label: '100万円 - 1億円' },
{ value: 'large', label: '1億円以上' },
]}
/>

Using Block Override Pattern

<CreateOrganization onCreateOrganization={handleSubmit} termsOfUseUrl="#terms" privacyAgreementUrl="#privacy">
{({defaultBlocks, defaultBlockOrder}) => ({
blocks: {
form: {
...defaultBlocks.form,
props: {
...defaultBlocks.form.props,
sx: {
bgcolor: 'background.paper',
borderRadius: 4,
p: 4,
},
},
},
},
blockOrder: defaultBlockOrder,
})}
</CreateOrganization>

🔧 TypeScriptサポート

包括的な型定義による完全なTypeScriptサポート:

import {CreateOrganization} from '@nodeblocks/frontend-create-organization-block';
import { StackProps } from '@mui/material';
import { DefaultValues, UseFormGetValues, UseFormSetError } from 'react-hook-form';

// デフォルトフォームデータインターフェース
type DefaultCreateOrganizationFormData = {
applicationUserName?: string;
applicationUserEmail?: string;
applicationUserPhoneNumber?: string;
companyName?: string;
postcode?: string;
cityTownVillage?: string;
townStreetBuilding?: string;
representivePersonName?: string;
representativePhoneNumber?: string;
companyUrl?: string;
additionalInformation?: string;
prefecture?: string;
capitalRange?: string;
numberOfEmployees?: string;
userAgreement?: string;
privacyPolicy?: string;
};

// メインコンポーネントプロパティインターフェース
interface CreateOrganizationProps<T extends DefaultCreateOrganizationFormData>
extends Omit<StackProps, 'children' | 'onSubmit' | 'onChange'> {
onCreateOrganization: (data: T) => void;
defaultValues?: DefaultValues<T>;
onChange?: (setError: UseFormSetError<T>, getValues: UseFormGetValues<T>) => void;
termsOfUseUrl?: string;
privacyAgreementUrl?: string;
children?: BlocksOverride;
}

// Custom form data with additional fields
interface CustomOrganizationFormData extends DefaultCreateOrganizationFormData {
customField?: string;
}

// Complete typed example with validation
function TypedCreateOrganization() {
const handleCreateOrganization = (data: CustomOrganizationFormData): void => {
console.log('会社名:', data.companyName);
console.log('アカウント責任者:', data.applicationUserName);
// API call to create organization
};

const handleChange = (
setError: UseFormSetError<CustomOrganizationFormData>,
getValues: UseFormGetValues<CustomOrganizationFormData>,
): void => {
const values = getValues();
// Real-time validation
if (values.companyName && values.companyName.length > 50) {
setError('companyName', {
type: 'maxLength',
message: '会社名は50文字を超えることはできません',
});
}
};

return (
<CreateOrganization<CustomOrganizationFormData>
onCreateOrganization={handleCreateOrganization}
onChange={handleChange}
termsOfUseUrl="/terms"
privacyAgreementUrl="/privacy"
defaultValues={{
applicationUserName: '田中太郎',
applicationUserEmail: 'tanaka@example.com',
}}
sx={{
maxWidth: 600,
mx: 'auto',
p: 3,
border: '1px solid #e5e7eb',
borderRadius: 2,
}}
>
<CreateOrganization.Title>組織を登録</CreateOrganization.Title>
<CreateOrganization.Description>
以下のフォームにご記入いただき、組織プロフィールを作成してください
</CreateOrganization.Description>
<CreateOrganization.Form>
<CreateOrganization.Form.AccountHolder />
<CreateOrganization.Form.CompanyInformation />
<CreateOrganization.Form.Compliance />
<CreateOrganization.Form.SubmitButton>組織を作成</CreateOrganization.Form.SubmitButton>
</CreateOrganization.Form>
</CreateOrganization>
);
}

📝 注意事項

  • ルートコンポーネントはMUIのStackを使用し、デフォルトでspacing={4}sx={{ p: 3 }}パディングを持ちます
  • フォームバリデーションはreact-hook-formmode: 'onBlur'により処理されます
  • 送信ボタンはフォームが無効な場合自動的に無効化されます(!formState.isValid
  • デフォルトタイトルは、childrenが提供されない場合「Create your Organization」です
  • デフォルト説明には、必須フィールドがアスタリスクでマークされることについての説明が含まれます
  • AccountHolderセクションは、名前とメールフィールドを行レイアウトで表示します
  • CompanyAddressCompanyInformation内にネストされ、独自のサブコンポーネントを持ちます
  • 都道府県フィールドは47都道府県が事前設定されています
  • コンプライアンスチェックボックスはtermsOfUseUrlprivacyAgreementUrlプロパティにリンクします
  • すべてのテキストフィールドはデフォルトでfullWidthのMUI TextFieldを使用します
  • セレクトフィールドはMUI TextFieldselectプロパティとdisplayEmptyで使用します
  • チェックボックスフィールドはMUI FormControlLabelCheckboxを使用します
  • すべてのサブコンポーネントはMUIシステムスタイリング用のsxプロパティをサポートします
  • ブロックオーバーライドパターンにより、デフォルトブロックのカスタマイズ、置換、並べ替えが可能です

React、TypeScript、MUIを使用して❤️で構築されました。