/** * gridstack-item.component.ts 13.0.0 * Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license */ /** * Abstract base class that all custom widgets should extend. * * This class provides the interface needed for GridstackItemComponent to: * - Serialize/deserialize widget data * - Save/restore widget state * - Integrate with Angular lifecycle * * Extend this class when creating custom widgets for dynamic grids. * * @example * ```typescript * @Component({ * selector: 'app-my-widget', * template: '
{{data}}
' * }) * export class MyWidget extends BaseWidget { * data = input(''); // signal input (Angular 17+) — or @Input() data = '' * * override serialize() { * return { data: this.data() }; * } * } * // Register so the widget JSON { component: 'app-my-widget', props: { data: 'hello' } } works: * GridstackComponent.registerComponents([MyWidget]); * ``` */ import { ComponentRef } from '@angular/core'; import { NgCompInputs, NgGridStackWidget } from './types'; import * as i0 from "@angular/core"; /** * Base widget class for GridStack Angular integration. */ export declare abstract class BaseWidget { /** * Complete widget definition including position, size, and Angular-specific data. * Populated automatically when the widget is loaded or saved. */ widgetItem?: NgGridStackWidget; /** @internal set by GridstackComponent to enable signal-based input support via setInput() */ _compRef?: ComponentRef; /** * Override this method to return serializable data for this widget. * * Return an object with properties that map to your component's @Input() fields. * The selector is handled automatically, so only include component-specific data. * * @returns Object containing serializable component data * * @example * ```typescript * serialize() { * return { * title: this.title, * value: this.value, * settings: this.settings * }; * } * ``` */ serialize(): NgCompInputs | undefined; /** * Override this method to handle widget restoration from saved data. * * Use this for complex initialization that goes beyond simple @Input() mapping. * The default implementation automatically assigns input data to component properties. * * @param w The saved widget data including input properties * * @example * ```typescript * override deserialize(w: NgGridStackWidget) { * super.deserialize(w); // Call parent for basic setup * * // Custom initialization logic * if (w.props?.complexData) { * this.processComplexData(w.props.complexData); * } * } * ``` */ deserialize(w: NgGridStackWidget): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }