@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
88 lines (86 loc) • 3.38 kB
TypeScript
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElasticParams, MediaItem, SearchResult } from '../../models/Search';
import { AllItemActions, DetailedItem } from '../../models/Item';
import React from 'react';
import { ContextMenuOption } from '../ContextMenu';
import LookupTable from '../../models/LookupTable';
import { ApiResponse } from '../../models/ApiResponse';
export declare const drawerWidth = 300;
export declare const SORT_AUTO = '-AUTO-';
export declare const initialSearchParameters: ElasticParams;
export declare const actionsToBeShown: AllItemActions[];
export interface URLDrivenSearchProps {
location: Location;
mode?: 'default' | 'select';
embedded?: boolean;
onClose?(): void;
onSelect?(path: string, selected: boolean): any;
onAcceptSelection?(items: string[]): any;
}
export interface SearchParameters extends Partial<ElasticParams> {
path?: string;
}
export interface SearchProps {
mode?: 'default' | 'select';
embedded?: boolean;
initialParameters?: SearchParameters;
onClose?(): void;
onSelect?(path: string, selected: boolean): any;
onAcceptSelection?(items: string[]): any;
}
export interface CheckedFilter {
key: string;
value: string;
}
export declare const setCheckedParameterFromURL: (queryParams: Partial<ElasticParams>) => any;
export declare const serializeSearchFilters: (filters: SearchParameters['filters']) => {};
export declare const deserializeSearchFilters: (filters: any) => {};
interface useSearchStateProps {
searchParameters: ElasticParams;
onSelect?(path: string, selected: boolean): any;
}
interface useSearchStateReturn {
selected: string[];
areAllSelected: boolean;
selectionOptions: ContextMenuOption[];
itemsByPath: LookupTable<DetailedItem>;
guestBase: string;
searchResults: SearchResult;
selectedPath: string;
error: ApiResponse;
drawerOpen: boolean;
currentView: 'grid' | 'list';
isFetching: boolean;
onActionClicked(option: AllItemActions, event: React.MouseEvent<HTMLButtonElement, MouseEvent>): void;
onHeaderButtonClick(event: any, item: MediaItem): void;
handleClearSelected(): void;
handleSelect(path: string, isSelected: boolean): void;
handleSelectAll(checked: boolean): void;
onPreview(item: MediaItem): void;
clearPath(): void;
onSelectedPathChanges(path: string): void;
toggleDrawer(): void;
handleChangeView(): void;
}
/**
* Encapsulates logic to pick sortBy depending on whether there's a keyword.
*/
export declare function prepareSearchParams(
searchParameters: useSearchStateProps['searchParameters']
): useSearchStateProps['searchParameters'];
export declare const useSearchState: ({ searchParameters, onSelect }: useSearchStateProps) => useSearchStateReturn;
export {};