From 4a73ea65fdba4245c0f7f0532ca7840f36030b9c Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Wed, 19 Apr 2023 11:02:01 -0400 Subject: [PATCH] chore: fix linting errors and export more hooks --- .../media-library/common/MediaLibrary.tsx | 2 +- packages/core/src/index.ts | 9 +++++++++ packages/core/src/lib/hooks/index.ts | 4 ++++ packages/core/src/types/global.d.ts | 16 +++++++++++++++- .../core/src/widgets/file/withFileControl.tsx | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/core/src/components/media-library/common/MediaLibrary.tsx b/packages/core/src/components/media-library/common/MediaLibrary.tsx index 188e0732..e224ae9a 100644 --- a/packages/core/src/components/media-library/common/MediaLibrary.tsx +++ b/packages/core/src/components/media-library/common/MediaLibrary.tsx @@ -194,7 +194,7 @@ const MediaLibrary: FC> = ({ setSelectedFile(asset); }, - [canInsert, selectedFile?.key], + [canInsert, forFolder, selectedFile?.key], ); const scrollContainerRef = useRef(null); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 4faba23a..d954ce9d 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -6,6 +6,10 @@ import useMediaAsset from './lib/hooks/useMediaAsset'; import useMediaInsert from './lib/hooks/useMediaInsert'; import useUUID from './lib/hooks/useUUID'; import Registry from './lib/registry'; +import useEntries from './lib/hooks/useEntries'; +import useHasChildErrors from './lib/hooks/useHasChildErrors'; +import useMediaFiles from './lib/hooks/useMediaFiles'; +import useFolderSupport from './lib/hooks/useFolderSupport'; export * from './backends'; export * from './interface'; @@ -25,8 +29,13 @@ if (typeof window !== 'undefined') { window.useEffect = window.useEffect || useEffect; window.useCallback = window.useCallback || useCallback; window.h = window.h || createElement; + + window.useEntries = window.useEntries || useEntries; + window.useFolderSupport = window.useFolderSupport || useFolderSupport; + window.useHasChildErrors = window.useHasChildErrors || useHasChildErrors; window.useIsMediaAsset = window.useIsMediaAsset || useIsMediaAsset; window.useMediaAsset = window.useMediaAsset || useMediaAsset; + window.useMediaFiles = window.useMediaFiles || useMediaFiles; window.useMediaInsert = window.useMediaInsert || useMediaInsert; window.useUUID = window.useUUID || useUUID; } diff --git a/packages/core/src/lib/hooks/index.ts b/packages/core/src/lib/hooks/index.ts index afa5e9b7..8d762a4a 100644 --- a/packages/core/src/lib/hooks/index.ts +++ b/packages/core/src/lib/hooks/index.ts @@ -1,4 +1,8 @@ +export { default as useEntries } from './useEntries'; +export { default as useFolderSupport } from './useFolderSupport'; +export { default as useHasChildErrors } from './useHasChildErrors'; export { default as useIsMediaAsset } from './useIsMediaAsset'; export { default as useMediaAsset } from './useMediaAsset'; +export { default as useMediaFiles } from './useMediaFiles'; export { default as useMediaInsert } from './useMediaInsert'; export { default as useUUID } from './useUUID'; diff --git a/packages/core/src/types/global.d.ts b/packages/core/src/types/global.d.ts index 925152ce..7d52af57 100644 --- a/packages/core/src/types/global.d.ts +++ b/packages/core/src/types/global.d.ts @@ -3,7 +3,16 @@ export {}; import type { Config } from '../interface'; import type CmsAPI from '../index'; import type { createElement, useEffect, useState, useMemo, useCallback } from 'react'; -import type { useIsMediaAsset, useMediaAsset, useMediaInsert, useUUID } from '../lib/hooks'; +import type { + useEntries, + useFolderSupport, + useHasChildErrors, + useIsMediaAsset, + useMediaAsset, + useMediaFiles, + useMediaInsert, + useUUID, +} from '../lib/hooks'; declare global { interface Window { @@ -15,8 +24,13 @@ declare global { useMemo: useMemo; useEffect: useEffect; useCallback: useCallback; + + useEntries: useEntries; + useFolderSupport: useFolderSupport; + useHasChildErrors: useHasChildErrors; useIsMediaAsset: useIsMediaAsset; useMediaAsset: useMediaAsset; + useMediaFiles: useMediaFiles; useMediaInsert: useMediaInsert; useUUID: useUUID; } diff --git a/packages/core/src/widgets/file/withFileControl.tsx b/packages/core/src/widgets/file/withFileControl.tsx index 74b4d188..206a0224 100644 --- a/packages/core/src/widgets/file/withFileControl.tsx +++ b/packages/core/src/widgets/file/withFileControl.tsx @@ -294,6 +294,7 @@ const withFileControl = ({ forImage = false }: WithFileControlProps = {}) => { ); }, [ + forFolder, internalValue, renderedImagesLinks, handleOpenMediaLibrary,