/*! * FrontAlign v1.0.9 * (c) Eyruz Badalzada * Released under the MIT License * https://www.frontalign.dev */ /** * Status variant colors used across Alert and Toast components. */ export type StatusVariant = | "success" | "danger" | "warning" | "info" | "default"; /** * The reason that triggered a modal close event. */ export type ModalCloseReason = | "dismiss" | "confirm" | "esc" | "backdrop" | "guard-exit"; /** * Functional type of a Modal instance. */ export type ModalType = "alert" | "confirm" | "custom"; // Toast export interface ToastOptions { /** The text content to display inside the toast. */ message?: string; /** Visual theme and semantic status of the toast. Default: 'default' */ status?: StatusVariant; /** Vertical position of the toast container on the screen. Default: 'bottom' */ position?: "top" | "bottom"; /** How long (in ms) the toast stays visible before auto-dismissing. Default: 4000 */ duration?: number; /** If true, removes all existing toasts in the same container before showing this one. Default: false */ dismissPrevious?: boolean; /** Whether to display a status-related icon inside the toast. Default: false */ showIcon?: boolean; /** If true, fully removes the Toast instance from the internal registry after dismissal. Default: false */ autoClean?: boolean; } /** * Component for displaying short-lived notifications (Toasts) on the screen. * Instantiated via static `Toast.show()`. * * @example * Toast.show({ * message: "Data saved successfully!", * status: "success", * position: "top", * duration: 3000 * }); */ export class Toast { /** Private constructor to enforce the use of `Toast.show()`. */ private constructor(); /** Read-only map of all active Toast instances, keyed by their internal ID. */ static readonly instances: Map; /** Factory method that creates a Toast and immediately mounts it into the DOM. */ static show(options?: ToastOptions): Toast; /** Removes the toast instance immediately from the screen. */ remove(): void; /** Clears internal state and removes this instance from the global registry. */ dispose(): void; } // Alert export interface AlertOptions { /** The text content to display within the alert. */ message?: string; /** Visual theme and semantic status of the alert. Default: 'default' */ status?: StatusVariant; /** Whether to display a status-related icon. Default: false */ hasIcon?: boolean; /** If true, displays a close button to dismiss the alert. Default: true */ dismissible?: boolean; /** Placement relative to the anchor element. Default: 'before' */ position?: "before" | "after"; /** Enables or disables entry/exit transition animations. Default: true */ animated?: boolean; /** The type of animation effect to use during dismiss transitions. Default: 'fade' */ animation?: "fade" | "slide"; /** Whether to show a decorative border around the alert box. Default: false */ bordered?: boolean; /** If true, calls `dispose()` after the alert is removed from the DOM. Default: false */ autoClean?: boolean; } /** * Component for creating static, dismissible warning or alert messages. * Instantiated via static `Alert.create()`. * * @example * Alert.create('#form-container', { * message: 'Please fill out all required fields.', * status: 'danger', * position: 'before', * animation: 'slide' * }); */ export class Alert { /** Private constructor to enforce the use of `Alert.create()`. */ private constructor(); /** Static factory that creates an Alert instance and immediately mounts it. */ static create( selector: string | Element, options?: AlertOptions, ): Alert | null; /** Cleans internal references and releases memory state. */ dispose(): void; } // Modal export interface ModalOptions { /** The title text displayed inside the modal header. */ heading?: string; /** The main body text content of the modal. */ content?: string; /** Vertical alignment of the dialog frame on the viewport. Default: 'center' */ align?: "top" | "center" | "bottom"; /** If true, releases modal references after closing. Default: false */ dispose?: boolean; /** Text label for the primary dismiss button (Alert modals only). Default: 'OK' */ dismissText?: string; /** Redirect URL triggered when the confirm button is clicked. */ confirmUrl?: string; /** Labels for dual-action confirm modals. */ actions?: { cancelText?: string; confirmText?: string }; /** Decorative status icon configuration. */ icon?: { visible?: boolean; type?: "none" | "success" | "error" | "warning" | "info"; }; /** Disables standard close interactions forcing user to use the guard button. Default: false */ guardMode?: boolean; guardButtonText?: string; guardButtonClass?: string; guardButtonUrl?: string; /** Whether pressing Escape closes the modal. Default: true (false for confirm) */ closeOnEsc?: boolean; /** Whether to render a dark backdrop overlay behind the modal. Default: true */ backdrop?: boolean; /** Whether clicking the backdrop closes the modal. Default: true (false for confirm) */ backdropClose?: boolean; /** If true, automatically moves focus into the modal dialog on open. Default: true */ focusFirst?: boolean; /** CSS selector of a pre-existing DOM element to use as the modal wrapper (Custom modals only). */ id?: string; // Callbacks /** Callback executed before the modal opens. Return `false` to cancel. */ onOpen?: (modalEl: HTMLElement) => boolean | void; /** Callback executed after the modal opening animation completes. */ onOpened?: (modalEl: HTMLElement) => void; /** Callback executed before the modal closes. Return `false` to cancel. */ onClose?: (modalEl: HTMLElement, reason: ModalCloseReason) => boolean | void; /** Callback executed after the modal is fully closed. */ onClosed?: (modalEl: HTMLElement, reason: ModalCloseReason) => void; } /** * Advanced Promise-based Modal/Dialog component. * Instantiated via static methods like `Modal.alert()` or `Modal.confirm()`. * * @example * // Simple alert * await Modal.alert({ heading: 'Success', content: 'Process completed.' }); * * @example * // Confirm dialog * const confirmed = await Modal.confirm({ * heading: 'Delete Account', * content: 'Are you absolutely sure?' * }); * if (confirmed) { ... } */ export class Modal { /** Private constructor to enforce the use of static factory methods. */ private constructor(); static readonly TRANSITION_DURATION: number; static readonly TRANSITION_BUFFER: number; /** Adds a modal request into the shared modal queue. */ static enqueue(item: any): void; /** Opens a promise-based confirm dialog. Returns `true` if confirmed, `false` if cancelled. */ static confirm(options?: ModalOptions): Promise; /** Opens a promise-based informational alert modal. */ static alert(options?: ModalOptions): Promise; /** Opens a custom modal using an existing DOM element. */ static custom(options?: ModalOptions): Promise; /** Queued modal variants that open sequentially. Waits for the previous to close. */ static readonly queue: { alert(options?: ModalOptions): Promise; confirm(options?: ModalOptions): Promise; }; /** Releases modal references and internal memory state. */ dispose(): void; } // Carousel export interface CarouselAutoplayOptions { enabled?: boolean; interval?: number; pauseOnHover?: boolean; pauseOnSwipe?: boolean; } export interface CarouselThumbnailOptions { enabled?: boolean; clickable?: boolean; } export interface CarouselOptions { /** Transition mode. Default: 'slide' */ mode?: "slide" | "fade"; autoplay?: CarouselAutoplayOptions; controls?: boolean; pager?: boolean; thumbnails?: CarouselThumbnailOptions; swipe?: boolean; loop?: boolean; } /** * Interactive Slider/Carousel component for images or content with swipe support. * Instantiated via static `Carousel.create()`. * * @example * const slider = Carousel.create('#hero-slider', { * mode: 'fade', * loop: true, * autoplay: { interval: 5000 } * }); * * // Programmatic control * slider.next(); * slider.go(3); */ export class Carousel { static defaults: Required; /** Read-only map of all active Carousel instances. */ static readonly instances: Map; /** Static factory that creates, builds, and returns a carousel instance. */ static create( selector: string | Element, options?: CarouselOptions, ): Carousel | null; /** Retrieves an active Carousel instance by its internal ID. */ static get(id: string): Carousel | undefined; /** Navigates to a specific slide index (1-based). */ go(index: number): void; /** Navigates to the next slide. */ next(): void; /** Navigates to the previous slide. */ prev(): void; /** Fully disposes the carousel instance and removes all event listeners. */ dispose(): void; } // Tooltip export type TooltipPlacement = "auto" | "top" | "bottom" | "left" | "right"; export interface TooltipOptions { message?: string; placement?: TooltipPlacement; hasArrow?: boolean; autoClean?: boolean; } /** * Small informational text box that appears when hovering or focusing an element. * * @example * const tip = new Tooltip('#copy-btn', { * message: 'Copy to clipboard', * placement: 'top' * }); */ export class Tooltip { constructor(selector: string | Element, options?: TooltipOptions); /** Creates and appends the tooltip element, then makes it visible. */ create(): void; /** Removes the tooltip element from the DOM. */ remove(): void; /** Returns the Tooltip instance currently bound to the given element, if any. */ static getInstance(element: Element): Tooltip | undefined; /** Initializes all tooltips on the page based on the given selector. */ static init(selector?: string): Tooltip[]; /** Removes the tooltip and unbinds all event listeners. */ dispose(): void; } // Popover export type PopoverPlacement = | "auto" | "top" | "bottom" | "left" | "right" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end"; export type PopoverTrigger = "click" | "manual"; export interface PopoverOptions { /** The title of the popover header. */ title?: string; /** The text content or HTML Node for the popover body. */ content?: string | Node; /** CSS selector for an existing DOM element to use as content. */ target?: string; /** Preferred placement relative to the anchor element. Default: 'auto' */ placement?: PopoverPlacement; /** How the popover is triggered. Default: 'click' */ trigger?: PopoverTrigger; hasArrow?: boolean; closeOnOutsideClick?: boolean; closeOnEscape?: boolean; /** Distance in pixels between the target element and the popover. Default: 10 */ offset?: number; autoClean?: boolean; } /** * Content-rich dropdown/popover panel providing more information than a standard Tooltip. * * @example * const popover = new Popover('#info-btn', { * title: 'User Details', * content: 'Additional information goes here.', * placement: 'right-start', * trigger: 'click' * }); */ export class Popover { constructor(selector: string | Element, options?: PopoverOptions); /** Shows the popover on the screen. */ show(): void; /** Hides the popover. */ hide(): void; /** Toggles the popover visibility state. */ toggle(): void; /** Recalculates and updates the popover's position (useful during scroll/resize). */ update(): void; /** Returns the Popover instance bound to the given element. */ static getInstance(element: Element): Popover | undefined; /** Initializes popovers globally based on the selector. */ static init(selector?: string): Popover[]; /** Destroys the popover and removes event listeners. */ dispose(): void; } // Select(Custom like Sleect2) export interface SelectOptionItem { value: string | number; name: string; icon?: string; } export interface SelectOptions { inputName?: string; /** Enables multi-selection with tag-based display. Default: false */ multiple?: boolean; defaultValue?: string | number | Array | null; /** Array of option objects populating the dropdown list. */ data?: SelectOptionItem[]; /** Renders a text input inside the dropdown for filtering options. Default: false */ search?: boolean; placeholder?: string; } /** * Custom, searchable, and tag-supported component replacing the standard HTML