/** * @license Copyright (c) 2021-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md. */ import { IconRenderProp } from '@ckbox/components'; import * as React from 'react'; type ApiAssetImageProcessingStatus = 'queued' | 'success' | 'error'; type ApiAssetImageAnalysisProcessingStatus = 'queued' | 'success' | 'error' | 'skipped'; type TokenCallback = () => Promise; type TokenUrl = string | TokenCallback; type ParsedAssetThumbnailMetadata = { /** * Thumbnail blurhash. */ blurHash?: string; /** * Thumbnail width. */ width?: number; /** * Thumbnail height. */ height?: number; /** * MIME type of underlying file. */ mimeType?: string; }; interface ParsedAssetMetadata extends Record { /** * Asset blurhash. */ blurHash?: string; /** * Asset description. */ description: string; /** * Processing status of an image (if asset is an image). */ metadataProcessingStatus?: ApiAssetImageProcessingStatus; /** * AI Analysis processing status of an image (if asset is an image). */ analysisProcessingStatus?: ApiAssetImageAnalysisProcessingStatus; /** * Asset width in px. */ width?: number; /** * Asset height in px. */ height?: number; /** * Custom thumbnail metadata. */ thumbnailMetadata?: ParsedAssetThumbnailMetadata; /** * Set of custom attributes. */ customAttributes?: Record; } interface ParsedAsset extends Record { /** * Asset id. */ id: string; /** * Asset name. */ name: string; /** * Asset file extension. */ extension: string; /** * Converted asset size. */ size?: number; /** * Asset last modification time. */ lastModifiedAt?: string; /** * Asset upload date. */ uploadedAt?: string; /** * Asset metadata. */ metadata: ParsedAssetMetadata; /** * MIME type of underyling file. */ mimeType?: string; /** * Asset category ID. */ categoryId: string; /** * Asset folder ID. Present only if asset belongs to a folder. */ folderId?: string; /** * Asset tags. */ tags: string[]; /** * Maps image width to image URL. URLs link to image in `webp` format. * Provides `default` URL that links to image in its original format. */ imageUrls?: Record; /** * URL to original file. */ url?: string; } interface ParsedCategory { /** * Category id. */ id: string; /** * Total number of assets in the category. */ assetsCount: number; /** * Category name. */ name: string; /** * Allowed extensions. */ extensions: string[]; /** * Indicates whether category is private. */ isPrivate: boolean; } interface ParsedFolder { /** * Folder ID. */ id: string; /** * Folder name. */ name: string; /** * Folder's root category ID. */ categoryId: string; /** * Folder's parent ID. Present unless it's a root folder. */ parentId?: string; /** * Date of folder creation. */ createdAt?: string; /** * Date of last folder update. */ updatedAt?: string; /** * List of children. */ folders: ParsedFolder[]; /** * Number of assets in the folder. */ assetsCount?: number; } interface AssetsConfigOnChooseParams { /** * Chosen asset. */ data: ParsedAsset; } type AssetsConfigOnChooseWithParams = (assets: AssetsConfigOnChooseParams[]) => void; interface AssetsConfig { /** * Callback invoked upon clicking on "Choose" button. * List of currently selected assets is passed as an argument. */ onChoose?: AssetsConfigOnChooseWithParams; } type CategoriesConfig = { /** * Maps category names to custom icons. */ icons?: Record; }; interface ImageEditingOnSaveParams { /** * Saved asset. */ data: ParsedAsset; } interface ImageEditingConfig { /** * Determines whether to show file overwrite checkbox in image editor. */ allowOverwrite?: boolean; } type LanguageConfig = string; type NavigationViewType = 'category' | 'fallback' | 'folder' | 'recent' | 'search' | 'settings' | 'trash'; type NavigationViewBase = { /** * View type. */ type: Type; }; type NavigationViewBaseData = { /** * View data. */ data: Data; }; type NavigationCategoryView = NavigationViewBase<'category'> & NavigationViewBaseData; type NavigationFallbackView = NavigationViewBase<'fallback'>; type NavigationFolderView = NavigationViewBase<'folder'> & NavigationViewBaseData; type NavigationRecentView = NavigationViewBase<'recent'>; type NavigationTrashView = NavigationViewBase<'trash'>; type NavigationSearchView = NavigationViewBase<'search'>; type NavigationSettingsView = NavigationViewBase<'settings'>; type NavigationView = NavigationCategoryView | NavigationFallbackView | NavigationFolderView | NavigationRecentView | NavigationTrashView | NavigationSearchView | NavigationSettingsView; interface NavigationProviderConfig { /** * If set to `false`, last selected view will not be re-opened on startup. */ openLastView?: boolean; /** * Callback invoked upon view change. * * Callback will receive view data: `{ type: 'view-type' }`. * Additionally, if view type is `category` or `folder`, `data` property will be provided that will be category or folder data, respectively. * * @param view current view */ onChange?: (view: NavigationView) => void; /** * ID of the folder that will be opened on startup. * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given folder at start. */ startupFolderId?: string; /** * ID of the category that will be opened on startup. * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given category at start. */ startupCategoryId?: string; /** * If set to `true`, maximize button will be hidden. */ hideMaximizeButton?: boolean; } interface DialogModeProps { /** * Initial dialog height. */ height?: string | number; /** * Toggles dialog. */ open: boolean; /** * Callback invoked upon clicking on close button. */ onClose?: () => void; /** * Initial dialog width. */ width?: string | number; } type DialogProps = boolean | DialogModeProps; type Asset = AssetsConfigOnChooseParams; type CoreBaseProps = { /** * Unique ID used to distinguish various app instances. * If not set, app instances will share common user preferences. */ id?: string; /** * Language options. */ language?: LanguageConfig; /** * Origin of the backend API service. */ serviceOrigin?: string; /** * Theme to use. */ theme?: string; /** * Endpoint address to download the token or a callback that provides the token. */ tokenUrl: TokenUrl; /** * Allows to always display demo label. */ forceDemoLabel?: boolean; /** * Allows to limit choosable extensions. */ choosableFileExtensions?: string[]; /** * Configures Image Editing feature. */ imageEditing?: ImageEditingConfig; }; type CoreCKBoxProps = { /** * Configures assets options. */ assets?: AssetsConfig; /** * Configures categories options. */ categories?: CategoriesConfig; /** * Dialog mode options. */ dialog?: DialogProps; /** * If set to `false`, last selected view will not be re-opened on startup. * * This option is deprecated. Use `view.openLastView` instead. * * @deprecated */ openLastView?: NavigationProviderConfig['openLastView']; /** * ID of the category that will be opened on startup. * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given category at start. * * This option is deprecated. Use `view.startupCategoryId` instead. * * @deprecated */ startupCategoryId?: NavigationProviderConfig['startupCategoryId']; /** * ID of the folder that will be opened on startup. * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given folder at start. * * This option is deprecated. Use `view.startupFolderId` instead. * * @deprecated */ startupFolderId?: NavigationProviderConfig['startupFolderId']; /** * Configures view and navigation-related options. */ view?: NavigationProviderConfig; /** * Upload config options. */ upload?: { dialogMinimizeTimeout?: number; componentsHideTimeout?: number; }; }; type Props = CoreCKBoxProps & CoreBaseProps; type CoreImageEditorBaseProps = { /** * Whether image editor should be open. */ open: boolean; /** * Callback invoked upon closing image editor. */ onClose?: () => void; /** * Callback invoked upon successfully saving edited image. * * @param data saved data */ onSave?: (data: ImageEditingOnSaveParams) => void; }; type CoreImageEditorProps = { /** * ID of an asset to open. */ assetId: string; } & CoreImageEditorBaseProps; type CoreImageEditorFromUrlProps = { /** * URL of an external image. * It must have a supported `Content-Type` header. * CORS restrictions apply. */ imageUrl: string; /** * ID of a category to which image will be uploaded. */ uploadCategoryId: string; } & CoreImageEditorBaseProps; type ImageEditorProps = CoreImageEditorProps & CoreBaseProps; type ImageEditorFromUrlProps = CoreImageEditorFromUrlProps & CoreBaseProps; type UploaderWidgetProps = { /** * Callback invoked upon successfully uploading an asset. * * @param asset uploaded asset */ onUpload?: (asset: ParsedAsset) => void; /** * Callback invoked upon successfully deleting an asset. * * @param asset uploaded asset */ onDelete?: (asset: ParsedAsset) => void; /** * ID of a category to which assets will be uploaded. */ uploadCategoryId?: string; /** * ID of a folder to which assets will be uploaded. */ uploadFolderId?: string; /** * ID of a workspace to which assets will be uploaded. */ workspaceId?: string; } & CoreBaseProps; declare const CoreImageEditor: React.FC; declare const CoreUploaderWidget: React.FC; /** * `CoreApp` is meant to hold all providers that are workspace-agnostic. * These providers should be mounted once in a CKBox instance's lifetime. */ declare const CoreApp: React.FC; /** * Current version of the package. */ declare const CKBOX_VERSION: string | undefined; export { CoreApp as CKBox, CoreImageEditor as CKBoxImageEditor, CoreUploaderWidget as CKBoxWidget, CKBOX_VERSION as version }; export type { Asset, ImageEditorFromUrlProps, ImageEditorProps, Props, UploaderWidgetProps };