UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

115 lines (113 loc) 3.88 kB
/* * 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 React, { ChangeEvent } from 'react'; import { DetailedItem } from '../../models/Item'; import LookupTable from '../../models/LookupTable'; import { StateStylingProps } from '../../models/UiConfig'; import GlobalState from '../../models/GlobalState'; import { PathNavigatorStateProps } from './PathNavigator'; import { SystemIconDescriptor } from '../SystemIcon'; export type PathNavigatorUIClassKey = | 'root' | 'body' | 'searchRoot' | 'breadcrumbsRoot' | 'breadcrumbsSearch' | 'paginationRoot'; export interface PathNavigatorUIProps { state: PathNavigatorStateProps; /** * Item lookup table (indexed by path) **/ itemsByPath: LookupTable<DetailedItem>; /** * Styling props (classes and/or styles) applied to the widget's header icon element **/ icon?: SystemIconDescriptor; /** * Styling props (classes and/or styles) applied to the widget's container element **/ container?: Partial<StateStylingProps>; /** * Widget's top title/label **/ title: string; /** * Widget's search keyword **/ keyword: string; /** * **/ classes?: Partial<Record<PathNavigatorUIClassKey, string>>; /** * **/ siteLocales?: GlobalState['uiConfig']['siteLocales']; /** * Prop called to determine which items are highlighted as active/selected **/ computeActiveItems?: (items: DetailedItem[]) => string[]; /** * Prop fired when the widget's accordion header is clicked **/ onChangeCollapsed: (collapsed: boolean) => void; /** * Prop fired when either button of the widget header is clicked (language or options button) **/ onHeaderButtonClick?: (element: Element, type: 'options' | 'language') => void; /** * Prop fired when the current directory item menu is clicked */ onCurrentParentMenu?: (element: Element) => void; /** * Prop fired when the search button is clicked. Omit to hide search button. **/ onSearch?: (keyword: string) => void; /** * Prop fired when a breadcrumb item is clicked **/ onBreadcrumbSelected: (item: DetailedItem, event: React.SyntheticEvent) => void; /** * Prop fired when an item is checked in when the widget is in "selection" mode **/ onSelectItem?: (item: DetailedItem, checked: boolean) => void; /** * **/ onPathSelected: (item: DetailedItem) => void; /** * Prop fired when the widget determines the clicked item is "previewable". * It may be fired by the widget's default onItemClicked handler or via the "view" * button of each item when the clicked item is not a folder **/ onPreview?: (item: DetailedItem) => void; /** * Prop fired when a list item options button is clicked **/ onOpenItemMenu?: (element: Element, item: DetailedItem) => void; /** * Prop fired when a list item itself is clicked (anywhere but it's buttons) **/ onItemClicked?(item: DetailedItem, event?: React.MouseEvent): void; /** * **/ onPageChanged?: (page: number) => void; onRowsPerPageChange?: (e: ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => void; } export declare function PathNavigatorUI(props: PathNavigatorUIProps): React.JSX.Element; export default PathNavigatorUI;