Skip to content

Commit 91a28e0

Browse files
committed
fix: add missing widget props
1 parent b011843 commit 91a28e0

File tree

1 file changed

+85
-2
lines changed
  • packages/decap-cms-core/src/types

1 file changed

+85
-2
lines changed

packages/decap-cms-core/src/types/index.ts

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,21 +464,104 @@ export interface PreviewStyle extends PreviewStyleOptions {
464464
value: string;
465465
}
466466

467+
export interface QueryHit {
468+
data: Record<string, unknown>;
469+
path: string;
470+
slug: string;
471+
i18n?: Record<string, unknown>;
472+
}
473+
467474
export interface CmsWidgetControlProps<T = any> {
475+
// Core props
468476
value: T;
469477
field: Map<string, any>;
470-
onChange: (value: T) => void;
478+
onChange: (value: T, metadata?: Record<string, unknown>) => void;
471479
forID: string;
472480
classNameWrapper: string;
481+
setActiveStyle: () => void;
482+
setInactiveStyle: () => void;
483+
484+
// Media related props
485+
getAsset?: (path: string) => { url: string; path: string };
486+
mediaPaths?: Map<string, string>;
487+
onAddAsset?: (path: string, file: { url: string; path: string }) => void;
488+
onRemoveInsertedMedia?: (path: string) => void;
489+
onOpenMediaLibrary?: (options: {
490+
allow_multiple?: boolean;
491+
config?: Record<string, unknown>;
492+
}) => void;
493+
onClearMediaControl?: () => void;
494+
onRemoveMediaControl?: (path: string) => void;
495+
onPersistMedia?: (path: string) => void;
496+
497+
// Validation related props
498+
validate?: (skipWrapped?: Record<string, unknown>) => void;
499+
hasError?: boolean;
500+
501+
// Object and List widget related props
502+
onChangeObject?: (value: Record<string, unknown>) => void;
503+
onValidateObject?: (value: Record<string, unknown>) => { error: boolean | string };
504+
editorControl?: React.ElementType;
505+
resolveWidget?: (name: string) => CmsWidget;
506+
widget?: CmsWidget;
507+
getEditorComponents?: () => {
508+
id: string;
509+
label: string;
510+
icon?: string;
511+
fields?: Map<string, any>[];
512+
}[];
513+
clearFieldErrors?: (path: string) => void;
514+
fieldsErrors?: Map<string, any>;
515+
516+
// Additional props
517+
t: (key: string, options?: Record<string, unknown>) => string; // Translation function
518+
isDisabled?: boolean;
519+
hasActiveStyle?: boolean;
520+
classNameWidget?: string;
521+
classNameWidgetActive?: string;
522+
classNameLabel?: string;
523+
classNameLabelActive?: string;
524+
locale?: string;
525+
controlRef?: (ref: React.RefObject<any>) => void;
526+
metadata?: Map<string, unknown>;
527+
query?: (
528+
id: string,
529+
collection: string,
530+
searchFields: string[],
531+
value: string,
532+
file?: string,
533+
) => Promise<{
534+
payload: {
535+
hits: QueryHit[];
536+
};
537+
}>;
538+
queryHits?: QueryHit[];
539+
clearSearch?: () => void;
540+
isFetching?: boolean;
541+
loadEntry?: (collection: string, slug: string) => Promise<{ payload: Record<string, unknown> }>;
542+
isEditorComponent?: boolean;
543+
isNewEditorComponent?: boolean;
544+
parentIds?: string[];
545+
isFieldDuplicate?: (field: Map<string, any>) => boolean;
546+
isFieldHidden?: (field: Map<string, any>) => boolean;
547+
isParentListCollapsed?: boolean;
548+
entry?: Map<string, any>;
549+
collection?: Map<string, any>;
550+
config?: CmsConfig;
551+
getRemarkPlugins?: () => Array<Pluggable>;
473552
}
474553

475554
export interface CmsWidgetPreviewProps<T = any> {
476555
value: T;
477556
field: Map<string, any>;
478-
metadata: Map<string, any>;
557+
metadata?: Map<string, unknown>;
479558
getAsset: GetAssetFunction;
480559
entry: Map<string, any>;
481560
fieldsMetaData: Map<string, any>;
561+
resolveWidget?: (name: string) => CmsWidget;
562+
getRemarkPlugins?: () => Array<Pluggable>;
563+
collection?: Map<string, any>; // Immutable.Map representation of a CmsCollection object
564+
t?: (key: string, options?: Record<string, unknown>) => string;
482565
}
483566

484567
export interface CmsWidgetParam {

0 commit comments

Comments
 (0)