chore/ts dep compat (#535)

* chore: ensures typescript dependency compatibility

* chore: updates dependencies

* chore: updates window-info breakpoints
This commit is contained in:
James Mikrut
2022-04-20 09:16:36 -04:00
committed by GitHub
parent 8a997c82be
commit b7f47c9bb1
18 changed files with 1479 additions and 1576 deletions

View File

@@ -16,4 +16,5 @@ export type RenderedTypeProps = {
className?: string
onClick?: onClick
to: string
children?: React.ReactNode
}

View File

@@ -9,6 +9,7 @@ export type Props = {
}
export type RenderedTypeProps = {
children: React.ReactNode
className?: string,
to: string,
onClick?: () => void,

View File

@@ -155,7 +155,6 @@ const Popup: React.FC<Props> = (props) => {
className={`${baseClass}__wrap`}
// TODO: color ::after with bg color
>
<div
className={`${baseClass}__scroll`}
style={{

View File

@@ -2,7 +2,7 @@ import { CSSProperties } from 'react';
export type Props = {
className?: string
render?: (any) => void,
render?: (any) => React.ReactNode,
children?: React.ReactNode,
verticalAlign?: 'top' | 'bottom'
horizontalAlign?: 'left' | 'center' | 'right',

View File

@@ -32,7 +32,7 @@ const UploadCard: React.FC<Props> = (props) => {
collection={collection}
/>
<div className={`${baseClass}__filename`}>
{doc?.filename}
{typeof doc?.filename === 'string' ? doc?.filename : '[Untitled]'}
</div>
</div>
);

View File

@@ -1,6 +1,6 @@
import React, { useReducer, useState, useCallback, useEffect } from 'react';
import { useConfig } from '@payloadcms/config-provider';
import { Props, Option, ValueWithRelation } from './types';
import { Props, Option, ValueWithRelation, GetResults } from './types';
import optionsReducer from './optionsReducer';
import useDebounce from '../../../../../hooks/useDebounce';
import ReactSelect from '../../../ReactSelect';
@@ -38,7 +38,7 @@ const RelationshipField: React.FC<Props> = (props) => {
dispatchOptions({ type: 'ADD', data, relation, hasMultipleRelations, collection });
}, [collections, hasMultipleRelations]);
const getResults = useCallback(async ({
const getResults = useCallback<GetResults>(async ({
lastFullyLoadedRelation: lastFullyLoadedRelationArg,
lastLoadedPage: lastLoadedPageArg,
search: searchArg,

View File

@@ -33,3 +33,5 @@ export type ValueWithRelation = {
relationTo: string
value: string
}
export type GetResults = (args: { lastFullyLoadedRelation?: number, lastLoadedPage?: number, search?: string }) => Promise<void>

View File

@@ -20,7 +20,7 @@ import wait from '../../../../utilities/wait';
import { Field } from '../../../../fields/config/types';
import buildInitialState from './buildInitialState';
import errorMessages from './errorMessages';
import { Context as FormContextType, Props, SubmitOptions } from './types';
import { Context as FormContextType, GetDataByPath, Props, SubmitOptions } from './types';
import { SubmittedContext, ProcessingContext, ModifiedContext, FormContext, FormWatchContext } from './context';
import buildStateFromSchema from './buildStateFromSchema';
import { useOperation } from '../../utilities/OperationProvider';
@@ -298,7 +298,7 @@ const Form: React.FC<Props> = (props) => {
const getField = useCallback((path: string) => contextRef.current.fields[path], [contextRef]);
const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [contextRef]);
const getSiblingData = useCallback((path: string) => getSiblingDataFunc(contextRef.current.fields, path), [contextRef]);
const getDataByPath = useCallback((path: string) => getDataByPathFunc(contextRef.current.fields, path), [contextRef]);
const getDataByPath = useCallback<GetDataByPath>((path: string) => getDataByPathFunc(contextRef.current.fields, path), [contextRef]);
const getUnflattenedValues = useCallback(() => reduceFieldsToValues(contextRef.current.fields), [contextRef]);
const createFormData = useCallback((overrides: any = {}) => {

View File

@@ -8,6 +8,7 @@ import RenderFields from '../../../RenderFields';
import FormSubmit from '../../../Submit';
import Upload from '../../../../views/collections/Edit/Upload';
import { NegativeFieldGutterProvider } from '../../../FieldTypeGutter/context';
import ViewDescription from '../../../../elements/ViewDescription';
import { Props } from './types';
import './index.scss';
@@ -72,7 +73,9 @@ const AddUploadModal: React.FC<Props> = (props) => {
/>
</div>
{description && (
<div className={`${baseClass}__sub-header`}>{description}</div>
<div className={`${baseClass}__sub-header`}>
<ViewDescription description={description} />
</div>
)}
</header>
<Upload

View File

@@ -12,11 +12,12 @@ import UploadGallery from '../../../../elements/UploadGallery';
import { Props } from './types';
import PerPage from '../../../../elements/PerPage';
import formatFields from '../../../../views/collections/List/formatFields';
import './index.scss';
import { getFilterOptionsQuery } from '../../getFilterOptionsQuery';
import { useDocumentInfo } from '../../../../utilities/DocumentInfo';
import { useWatchForm } from '../../../Form/context';
import ViewDescription from '../../../../elements/ViewDescription';
import './index.scss';
const baseClass = 'select-existing-upload-modal';
@@ -117,7 +118,9 @@ const SelectExistingUploadModal: React.FC<Props> = (props) => {
/>
</div>
{description && (
<div className={`${baseClass}__sub-header`}>{description}</div>
<div className={`${baseClass}__sub-header`}>
<ViewDescription description={description} />
</div>
)}
</header>
<ListControls

View File

@@ -33,7 +33,7 @@ const CompareVersion: React.FC<Props> = (props) => {
const getResults = useCallback(async ({
lastLoadedPage: lastLoadedPageArg,
} = {}) => {
}) => {
const query: {
[key: string]: unknown
where: Where

View File

@@ -20,7 +20,7 @@ const DefaultCell: React.FC<Props> = (props) => {
const { routes: { admin } } = useConfig();
let WrapElement: React.ComponentType | string = 'span';
let WrapElement: React.ComponentType<any> | string = 'span';
const wrapElementProps: {
to?: string

View File

@@ -22,10 +22,10 @@ const Index = () => (
<React.Fragment>
<ConfigProvider config={config}>
<WindowInfoProvider breakpoints={{
xs: 400,
s: 768,
m: 1024,
l: 1440,
xs: '(max-width: 400px)',
s: '(max-width: 768px)',
m: '(max-width: 1024px)',
l: '(max-width: 1440px)',
}}
>
<ScrollInfoProvider>

View File

@@ -1,15 +1,22 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { DeepRequired } from 'ts-essentials';
import { PaginateModel, PassportLocalModel } from 'mongoose';
import { PaginateModel } from 'mongoose';
import { GraphQLType } from 'graphql';
import { Access, GeneratePreviewURL } from '../../config/types';
import { Access, GeneratePreviewURL, EntityDescription } from '../../config/types';
import { Field } from '../../fields/config/types';
import { PayloadRequest } from '../../express/types';
import { IncomingAuthType, Auth } from '../../auth/types';
import { IncomingUploadType, Upload } from '../../uploads/types';
import { IncomingCollectionVersions, SanitizedCollectionVersions } from '../../versions/types';
export interface CollectionModel extends PaginateModel<any>, PassportLocalModel<any> {
type Register<T = any> = (doc: T, password: string) => T;
interface PassportLocalModel {
register: Register
authenticate: any
}
export interface CollectionModel extends PaginateModel<any>, PassportLocalModel {
buildQuery: (query: unknown, locale?: string) => Record<string, unknown>
}
@@ -128,7 +135,7 @@ export type CollectionAdminOptions = {
/**
* Custom description for collection
*/
description?: string | (() => string) | React.FC;
description?: EntityDescription;
disableDuplicate?: boolean;
/**
* Hide the API URL within the Edit view

View File

@@ -5,7 +5,7 @@ import { Options } from 'express-fileupload';
import { Configuration } from 'webpack';
import SMTPConnection from 'nodemailer/lib/smtp-connection';
import GraphQL from 'graphql';
import { ConnectionOptions } from 'mongoose';
import { ConnectOptions } from 'mongoose';
import React from 'react';
import { LoggerOptions } from 'pino';
import { Payload } from '..';
@@ -63,7 +63,7 @@ export function hasTransportOptions(emailConfig: EmailOptions): emailConfig is E
export type InitOptions = {
express?: Express;
mongoURL: string;
mongoOptions?: ConnectionOptions;
mongoOptions?: ConnectOptions;
secret: string;
license?: string;
email?: EmailOptions;
@@ -187,3 +187,5 @@ export type SanitizedConfig = Omit<DeepRequired<Config>, 'collections' | 'global
globals: SanitizedGlobalConfig[]
paths: { [key: string]: string };
}
export type EntityDescription = string | (() => string) | React.ComponentType

View File

@@ -181,9 +181,9 @@ export type UIField = {
width?: string
condition?: Condition
components?: {
Filter?: React.ComponentType;
Cell?: React.ComponentType;
Field: React.ComponentType;
Filter?: React.ComponentType<any>;
Cell?: React.ComponentType<any>;
Field: React.ComponentType<any>;
}
}
type: 'ui';