UNPKG

react-native-leader-line

Version:

React Native port of leader-line library for drawing arrow lines and connectors

159 lines 5.72 kB
/** * @fileoverview Imperative API Wrapper for Leader Line * @description Provides a leader-line compatible imperative API for backward compatibility * @version 1.2.0 * @author Federico Garcia * * @example Basic Usage (leader-line compatibility) * ```tsx * import { LeaderLineImperative } from 'react-native-leader-line'; * * // Create a new leader line (similar to original leader-line) * const line = new LeaderLineImperative(startRef, endRef, { * color: 'coral', * size: 4, * path: 'straight', * endPlug: 'arrow1' * }); * * // Show the line * line.show(); * * // Update properties * line.setOptions({ color: 'blue', size: 6 }); * * // Hide and remove * line.hide(); * line.remove(); * ``` */ import React from 'react'; import { LeaderLineOptions, Point } from '../types'; /** * @interface ImperativeLeaderLineOptions * @description Options for imperative API with leader-line compatibility */ export interface ImperativeLeaderLineOptions extends LeaderLineOptions { /** Show effect type */ showEffectName?: string; /** Hide effect type */ hideEffectName?: string; /** Animation duration in milliseconds */ duration?: number; /** Animation timing function */ timing?: string; /** Visibility state */ visible?: boolean; } /** * @class LeaderLineImperative * @description Imperative API wrapper that mimics the original leader-line library * * This class provides backward compatibility with the original leader-line API * while using React Native Leader Line components under the hood. */ export declare class LeaderLineImperative { private startElement; private endElement; private options; private isVisible; private componentRef; private renderCallback?; /** * @constructor * @param {React.RefObject<any> | Point} start - Start element ref or point * @param {React.RefObject<any> | Point} end - End element ref or point * @param {ImperativeLeaderLineOptions} options - Configuration options * @param {Function} renderCallback - Callback to render the component */ constructor(start: React.RefObject<any> | Point, end: React.RefObject<any> | Point, options?: ImperativeLeaderLineOptions, renderCallback?: (component: React.ReactElement) => void); /** * @method show * @description Show the leader line with optional effect * @param {string} [effectName] - Show effect name * @param {ImperativeLeaderLineOptions} [animOptions] - Animation options * @returns {LeaderLineImperative} This instance for chaining */ show(effectName?: string, animOptions?: ImperativeLeaderLineOptions): LeaderLineImperative; /** * @method hide * @description Hide the leader line with optional effect * @param {string} [effectName] - Hide effect name * @param {ImperativeLeaderLineOptions} [animOptions] - Animation options * @returns {LeaderLineImperative} This instance for chaining */ hide(effectName?: string, animOptions?: ImperativeLeaderLineOptions): LeaderLineImperative; /** * @method setOptions * @description Update leader line options * @param {ImperativeLeaderLineOptions} newOptions - New options to apply * @returns {LeaderLineImperative} This instance for chaining */ setOptions(newOptions: ImperativeLeaderLineOptions): LeaderLineImperative; /** * @method position * @description Update line position (recalculate attachment points) * @returns {LeaderLineImperative} This instance for chaining */ position(): LeaderLineImperative; /** * @method remove * @description Remove the leader line completely * @returns {void} */ remove(): void; /** * @method getOptions * @description Get current options * @returns {ImperativeLeaderLineOptions} Current options */ getOptions(): ImperativeLeaderLineOptions; /** * @method isShown * @description Check if line is currently visible * @returns {boolean} True if visible */ isShown(): boolean; /** * @private * @method createComponent * @description Create the React component with current options * @param {ImperativeLeaderLineOptions} opts - Options to use * @returns {React.ReactElement} LeaderLine component */ private createComponent; /** * @private * @method isPoint * @description Check if value is a Point * @param {any} value - Value to check * @returns {boolean} True if value is a Point */ private isPoint; } /** * @function createLeaderLine * @description Factory function for creating leader lines (leader-line compatibility) * @param {React.RefObject<any> | Point} start - Start element or point * @param {React.RefObject<any> | Point} end - End element or point * @param {ImperativeLeaderLineOptions} options - Configuration options * @param {Function} renderCallback - Callback to render the component * @returns {LeaderLineImperative} New leader line instance * * @example * ```tsx * const line = createLeaderLine(startRef, endRef, { * color: 'red', * size: 3, * endPlug: 'arrow1' * }, renderComponent); * ``` */ export declare function createLeaderLine(start: React.RefObject<any> | Point, end: React.RefObject<any> | Point, options?: ImperativeLeaderLineOptions, renderCallback?: (component: React.ReactElement) => void): LeaderLineImperative; /** * @constant LEADER_LINE_VERSION * @description Version compatibility with original leader-line */ export declare const LEADER_LINE_VERSION = "1.0.7-react-native"; export default LeaderLineImperative; //# sourceMappingURL=LeaderLineImperative.d.ts.map