UNPKG

@prisma-cms/component

Version:
67 lines (66 loc) 2.92 kB
import React, { PureComponent } from 'react'; import URI from 'urijs'; import { PrismaCmsContext } from '@prisma-cms/context'; import { PrismaCmsComponentError, PrismaCmsComponentProps, PrismaCmsComponentState } from './interfaces'; import { MutationOptions, QueryOptions } from '@apollo/client'; export * from './interfaces'; export default class PrismaCmsComponent<P extends PrismaCmsComponentProps = PrismaCmsComponentProps, S extends PrismaCmsComponentState = PrismaCmsComponentState> extends PureComponent<P, S> { static contextType: React.Context<PrismaCmsContext>; /** * PrismaCmsContext */ context: PrismaCmsContext; static defaultProps: { errorDelay: number; }; constructor(props: P); initLocales(locales: Record<string, any> | undefined): void; createLexicon(locale: Record<string, any>): Record<string, any>; addLexicon(lang: string, locale: Record<string, any>): any; lexicon(word: string, options?: Record<string, any>): any; /** * @deprecated Will be remove in next major version */ query(params: QueryOptions): any; mutate(params: MutationOptions): Promise<any>; private request; renderField(field: Record<string, any> & { props: Record<string, any> & { key?: string; }; }): React.ReactNode | null; onChange(event: React.ChangeEvent<HTMLInputElement>): void; onChangeBind: (event: React.ChangeEvent<HTMLInputElement>) => void; onFocus(event: React.FocusEvent<HTMLInputElement>): void; onFocusBind: (event: React.FocusEvent<HTMLInputElement>) => void; resetError(name: string): void; updateObject(data: P['_dirty']): void; prepareDirty(data: P['_dirty']): P['_dirty'] | undefined; prepareNewState<K extends keyof S>(newState: Pick<S, K> | S | null): Pick<S, K> | S | null; getLocation(): Location; getLocationUri(): URI; getLocationQuery(field: string): any; onFilterFieldChange(event: React.ChangeEvent<HTMLInputElement>): void; setFilters(data: Record<string, any>): void; /** * Простая проверка выставлены ли фильтры или нет */ hasFilters(): boolean; /** * Получаем фильтры из адресной строки */ getFilters(): S["filters"] | {}; addFilterCondition(where: Record<string, any>, key: string, value: any): Record<string, any> & { [x: string]: any; }; cleanFilters(): void; canEdit(): boolean; getObject(): P["object"] | undefined; getCurrentUser(): any; addError(error: PrismaCmsComponentError | string): string | PrismaCmsComponentError; removeError(error: PrismaCmsComponentError): void; closeError(error: PrismaCmsComponentError): void; closeErrorBind: (error: PrismaCmsComponentError) => void; renderErrors(): (JSX.Element | null)[] | null; render(): React.ReactNode; }