///
import { BulkControlActionBase, IndexListAreaBulkControlAction, IndexListAreaBulkControlsProps, IndexListAreaPaginationProps, PaginationOptions } from '../../areas/IndexList';
import { CustomViewType, IndexListControlAreaViewsProps, IndexListControlAreaViewsStaticProps } from '../../areas/ListControl';
import { ApiPayloadOptions } from '../../pages/fetcher';
import { ApiFnOrObject, BaseResource, StandardUIApi } from '../../pages/types';
import { SetNotificationType } from '../../Provider';
import { ApiSearchParams } from '../../templates/IndexPage/types';
import { MetaData } from '../../templates/IndexPage/types/meta';
import { ExecuteDeleteType, RequestMethodType } from '../../types';
export type IndexResourceContainerBulkControlAction = IndexListAreaBulkControlAction | (BulkControlActionBase & {
execute?: never;
/**
* ApiContainer, StandardUIRouter経由の場合はこちらを利用
* ApiConfig.bulkActions内のkeyが一致するAPIを
* このメソッドの返り値をリクエストパラメータとして呼び出す
*/
encodeParams: (resources: R[], options?: {
/**
* ページを跨いで全てのレコードを対象にするか
*/
isAllPageSelected: boolean;
/**
* 追加情報の指定
*/
additionalFields: Record;
/**
* 現在の検索条件
*/
searchQuery: ApiSearchParams;
}) => Promise | any;
});
export type IndexResourceContainerBulkControlsProps = {
/**
* Dropdownに表示する項目
*/
actions: IndexResourceContainerBulkControlAction[];
/**
* 現在のページを全選択した場合に、全レコードを対象にできるか
*/
canSelectAllPage?: boolean;
};
export type IndexResourceContainerProps, ResourcesIndexResponse, ResourcesIndexRecord extends BaseResource[], ResourcesShowParams, ResourcesShowResponse, ResourcesCreateResponse, ResourcesUpdateResponse, ResourcesDestroyParams, ResourcesDestroyResponse, ViewsIndexParams, ViewsIndexResponse, ViewsIndexRecord extends CustomViewType[], ViewsShowResponse> = {
/**
* APIの設定
* - 一覧で表示するリソースの設定: resources
* - カスタムビューの設定: views
* - 一括操作の設定: bulkActions
*/
apis?: {
resources: ApiFnOrObject<{
index: StandardUIApi;
create?: StandardUIApi, ResourcesCreateResponse, ResourcesIndexRecord[number]>;
show?: StandardUIApi;
update?: StandardUIApi, ResourcesUpdateResponse, ResourcesIndexRecord[number]>;
destroy?: StandardUIApi;
}>;
views?: ApiFnOrObject<{
index: StandardUIApi;
create?: StandardUIApi, ViewsShowResponse, ViewsIndexRecord[number]>;
update?: StandardUIApi, ViewsShowResponse, ViewsIndexRecord[number]>;
destroy?: StandardUIApi, never, never>;
}>;
bulkActions?: {
[key: string]: ApiFnOrObject>;
};
};
/**
* APIリクエスト時にエラーが発生した場合に、エラーレスポンスを任意の形式に変換するための関数
* must be memoize
*/
errorResponseToJSON?: (response: Response) => Promise;
/**
* ビューの設定
* - apis.views を指定している場合
* このpropsでは、カスタムビュー以外の設定を指定します(システムビューの利用も行いたい場合に指定してください)
* また、IndexResourceContainer の children の props にある views を、 IndexListControlArea や IndexPageTemplate に指定してください
*
* - apis.views を未指定の場合
* このpropsを指定する必要はありません
* IndexListControlArea コンポーネントに views の props を直接指定してください
*/
views?: IndexListControlAreaViewsStaticProps;
/**
* 一括操作の設定
* - apis.bulkActions を指定している場合
* 必ず一括操作の一覧を指定してください
* また、IndexResourceContainer の children の props にある bulkControls を、 IndexListArea や IndexPageTemplate に指定してください
*
* - apis.bulkActions を未指定の場合
* このpropsを指定する必要はありません
* IndexListArea コンポーネントに bulkControls の props を直接指定してください
*/
bulkControls?: IndexResourceContainerBulkControlsProps;
/**
* ページネーションのオプション設定
*
* ページ番号を切り替えた場合等のクエリパラメーターや、ページあたりの表示件数など、ページネーションの汎用的な設定を行います
* また、IndexResourceContainer の children の props にある pagination を、 IndexListArea や IndexPageTemplate に指定してください
*/
pagination?: PaginationOptions;
/**
* 原則としてchildrenには IndexPageContainer を指定してください
* children は関数になっているため、以下のように記述してください
* {(props) => ...}
*/
children: (props: IndexResourceContainerChildrenProps) => React.ReactNode;
/**
* @deprecated StandardUIProviderで設定してください
*/
setNotification?: SetNotificationType;
/**
* @deprecated StandardUIProviderで設定してください
*/
apiPayloadOptions?: ApiPayloadOptions;
/**
* @deprecated StandardUIProviderで設定してください
*/
requestHeaders?: Partial>>;
};
export type IndexResourceContainerChildrenProps = Record, ResourcesIndexRecord extends BaseResource[] = BaseResource[]> = {
/**
* APIから取得したリソースの一覧
* @use IndexListArea or IndexPageTemplate
*/
resources: ResourcesIndexRecord;
/**
* フィルターやページネーションなど、標準UIコンポーネント内部でパラメーターが変更された際に呼び出されるハンドラ
* @use ListControlArea or IndexPageTemplate
*/
onChangeSearchParams: (params: ResourcesIndexParams) => void;
/**
* リソースの読み込み中
* true の場合は skeleton が表示されます
* @use IndexListArea or IndexPageTemplate
*/
isLoading: boolean;
/**
* キャッシュがある状態でリソースの再読み込み中
* true の場合はスピナーが表示されます
* @use IndexListArea or IndexPageTemplate
*/
isValidating: boolean;
/**
* 画面全体に Loading を表示して、ユーザーの操作を制限する
* @use IndexPageContainer or IndexPageTemplate
*/
isLoadingAll: boolean;
/**
* ビューの設定
* @use ListControlArea or IndexPageTemplate
*/
views?: IndexListControlAreaViewsProps;
/**
* ページネーション
* @use IndexListArea or IndexPageTemplate
*/
pagination?: IndexListAreaPaginationProps;
/**
* 一括操作
* @use IndexListArea or IndexPageTemplate
*/
bulkControls?: IndexListAreaBulkControlsProps;
/**
* 一覧リソースを再取得する際に呼び出される関数
* @use IndexPageContainer or IndexPageTemplate
*/
refetchResources: () => Promise;
/**
* ページネーションを含むメタデータ
* @use IndexPageContainer or IndexPageTemplate
*/
meta?: MetaData;
/**
* リクエストパラメータ、レスポンスのフォーマット設定
* Templateではparameters.conditionのみ使用可能
* onChangeSearchParamsの引数における範囲や比較のフォーマットを指定できる
* @use IndexPageContainer or IndexPageTemplate
*/
apiPayloadOptions?: ApiPayloadOptions;
/**
* レコードを削除する際の処理
* 成功orエラーのレスポンスを受け取る
* @use IndexListArea or IndexPageTemplate
*/
executeDelete?: ExecuteDeleteType;
/**
* 操作に対してフィードバックとしてMessageBlockを表示する
* @use IndexPageContainer or IndexPageTemplate
*/
setNotification?: SetNotificationType;
};