adds paths to local ts declarations
This commit is contained in:
@@ -40,7 +40,7 @@
|
|||||||
"@faceless-ui/modal": "^1.0.4",
|
"@faceless-ui/modal": "^1.0.4",
|
||||||
"@faceless-ui/scroll-info": "^1.1.1",
|
"@faceless-ui/scroll-info": "^1.1.1",
|
||||||
"@faceless-ui/window-info": "^1.2.2",
|
"@faceless-ui/window-info": "^1.2.2",
|
||||||
"@payloadcms/config-provider": "0.0.7",
|
"@payloadcms/config-provider": "0.0.9",
|
||||||
"@typescript-eslint/parser": "4.0.1",
|
"@typescript-eslint/parser": "4.0.1",
|
||||||
"@udecode/slate-plugins": "^0.64.3",
|
"@udecode/slate-plugins": "^0.64.3",
|
||||||
"ajv": "^6.12.6",
|
"ajv": "^6.12.6",
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ import PropTypes from 'prop-types';
|
|||||||
import { useConfig } from '@payloadcms/config-provider';
|
import { useConfig } from '@payloadcms/config-provider';
|
||||||
import { useSearchParams } from '../SearchParams';
|
import { useSearchParams } from '../SearchParams';
|
||||||
|
|
||||||
const Context = createContext({});
|
const Context = createContext('');
|
||||||
|
|
||||||
export const LocaleProvider = ({ children }) => {
|
export const LocaleProvider: React.FC = ({ children }) => {
|
||||||
const { localization } = useConfig();
|
const { localization } = useConfig();
|
||||||
const defaultLocale = (localization && localization.defaultLocale) ? localization.defaultLocale : 'en';
|
const defaultLocale = (localization && localization.defaultLocale) ? localization.defaultLocale : 'en';
|
||||||
const [locale, setLocale] = useState(defaultLocale);
|
const [locale, setLocale] = useState<string>(defaultLocale);
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const localeFromParams = searchParams.locale;
|
const localeFromParams = searchParams.locale;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (localeFromParams && localization.locales.indexOf(localeFromParams) > -1) setLocale(localeFromParams);
|
if (localeFromParams && localization.locales.indexOf(localeFromParams) > -1) setLocale(localeFromParams as string);
|
||||||
}, [localeFromParams, localization]);
|
}, [localeFromParams, localization]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -25,7 +25,7 @@ export const LocaleProvider = ({ children }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useLocale = () => useContext(Context);
|
export const useLocale = (): string => useContext(Context);
|
||||||
|
|
||||||
LocaleProvider.propTypes = {
|
LocaleProvider.propTypes = {
|
||||||
children: PropTypes.oneOfType([
|
children: PropTypes.oneOfType([
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ const Meta: React.FC<Props> = ({
|
|||||||
keywords = 'CMS, Admin, Dashboard',
|
keywords = 'CMS, Admin, Dashboard',
|
||||||
}) => {
|
}) => {
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const titleSuffix = config?.admin?.meta?.titleSuffix ?? '- Payload';
|
const titleSuffix = config.admin.meta?.titleSuffix ?? '- Payload';
|
||||||
const favicon = config?.admin?.meta?.favicon ?? payloadFavicon;
|
const favicon = config.admin.meta.favicon ?? payloadFavicon;
|
||||||
const ogImage = config?.admin?.meta?.ogImage ?? payloadOgImage;
|
const ogImage = config.admin.meta.ogImage ?? payloadOgImage;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Helmet
|
<Helmet
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
const Portal = ({ children }) => ReactDOM.createPortal(children, document.getElementById('portal'));
|
const Portal = ({ children }: { children: React.ReactNode}): React.ReactPortal => ReactDOM.createPortal(children, document.getElementById('portal'));
|
||||||
|
|
||||||
export default Portal;
|
export default Portal;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import { Props } from './types';
|
||||||
|
|
||||||
const RenderCustomComponent = (props) => {
|
const RenderCustomComponent: React.FC<Props> = (props) => {
|
||||||
const { CustomComponent, DefaultComponent, componentProps } = props;
|
const { CustomComponent, DefaultComponent, componentProps } = props;
|
||||||
|
|
||||||
if (CustomComponent) {
|
if (CustomComponent) {
|
||||||
@@ -15,22 +15,4 @@ const RenderCustomComponent = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
RenderCustomComponent.defaultProps = {
|
|
||||||
path: undefined,
|
|
||||||
componentProps: {},
|
|
||||||
CustomComponent: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
RenderCustomComponent.propTypes = {
|
|
||||||
path: PropTypes.string,
|
|
||||||
DefaultComponent: PropTypes.oneOfType([
|
|
||||||
PropTypes.shape({}),
|
|
||||||
PropTypes.func,
|
|
||||||
PropTypes.node,
|
|
||||||
PropTypes.element,
|
|
||||||
]).isRequired,
|
|
||||||
CustomComponent: PropTypes.func,
|
|
||||||
componentProps: PropTypes.shape({}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export default RenderCustomComponent;
|
export default RenderCustomComponent;
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export type Props = {
|
||||||
|
CustomComponent: React.FC
|
||||||
|
DefaultComponent: React.FC
|
||||||
|
componentProps: unknown
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import qs from 'qs';
|
|||||||
|
|
||||||
const Context = createContext({});
|
const Context = createContext({});
|
||||||
|
|
||||||
export const SearchParamsProvider = ({ children }) => {
|
export const SearchParamsProvider: React.FC = ({ children }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const params = qs.parse(
|
const params = qs.parse(
|
||||||
@@ -27,4 +27,4 @@ SearchParamsProvider.propTypes = {
|
|||||||
]).isRequired,
|
]).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSearchParams = () => useContext(Context);
|
export const useSearchParams = (): qs.ParsedQs => useContext(Context);
|
||||||
|
|||||||
22
src/types/assets/index.d.ts
vendored
22
src/types/assets/index.d.ts
vendored
@@ -1,22 +0,0 @@
|
|||||||
declare module '*.svg' {
|
|
||||||
import React = require('react');
|
|
||||||
|
|
||||||
export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>;
|
|
||||||
const src: string;
|
|
||||||
export default src;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '*.jpg' {
|
|
||||||
const content: string;
|
|
||||||
export default content;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '*.png' {
|
|
||||||
const content: string;
|
|
||||||
export default content;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '*.json' {
|
|
||||||
const content: string;
|
|
||||||
export default content;
|
|
||||||
}
|
|
||||||
@@ -18,16 +18,21 @@
|
|||||||
"payload/config": [
|
"payload/config": [
|
||||||
"src/admin/types/config" // Webpack alias to user config
|
"src/admin/types/config" // Webpack alias to user config
|
||||||
],
|
],
|
||||||
|
"@payloadcms/payload/config": [
|
||||||
|
"src/config/types.ts"
|
||||||
|
],
|
||||||
|
"@payloadcms/payload/auth": [
|
||||||
|
"src/auth/types.ts"
|
||||||
|
],
|
||||||
|
"@payloadcms/payload/types": [
|
||||||
|
"src/types/index.ts"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
||||||
// "typeRoots": [
|
|
||||||
// "./src",
|
|
||||||
// "./node_modules/@types"
|
|
||||||
// ]
|
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/"
|
"src/"
|
||||||
@@ -38,6 +43,6 @@
|
|||||||
"build",
|
"build",
|
||||||
"src/tests",
|
"src/tests",
|
||||||
"src/tests/**/*.spec.ts",
|
"src/tests/**/*.spec.ts",
|
||||||
// "node_modules/"
|
"node_modules"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1360,10 +1360,10 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
mkdirp "^1.0.4"
|
mkdirp "^1.0.4"
|
||||||
|
|
||||||
"@payloadcms/config-provider@0.0.7":
|
"@payloadcms/config-provider@0.0.9":
|
||||||
version "0.0.7"
|
version "0.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/@payloadcms/config-provider/-/config-provider-0.0.7.tgz#c225f29cf1737e039c95bd54ba25be5e32550ae1"
|
resolved "https://registry.yarnpkg.com/@payloadcms/config-provider/-/config-provider-0.0.9.tgz#b2f89bb64418b96c04ff8e08a7d39f82eb6fa281"
|
||||||
integrity sha512-qiiz5i/BRPkU6wyBg01Cf5pikfYxudanIjONdpTx7Z4xaUN67OZ0SDCfRno5LGrUupsFgxlEfSIXFGWb9h4gdw==
|
integrity sha512-M8Lgp7tw0uIIKSJ5MjLsP3yS5406cmUEWtdnH/zshq3uRNGYmvlg/hOmFl0pJpZdut9An+qCFVhvjSTaQAok/Q==
|
||||||
|
|
||||||
"@popperjs/core@^2.4.4":
|
"@popperjs/core@^2.4.4":
|
||||||
version "2.5.4"
|
version "2.5.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user