export declare class BQueryElement { private readonly element; /** * Stores delegated event handlers for cleanup via undelegate(). * Key format: `${event}:${selector}` * @internal */ private readonly delegatedHandlers; /** * Creates a new BQueryElement wrapper. * @param element - The DOM element to wrap */ constructor(element: Element); /** * Exposes the raw DOM element when direct access is needed. * Use sparingly; prefer the wrapper methods for consistency. */ get raw(): Element; /** * Exposes the underlying DOM element. * Provided for spec compatibility and read-only access. */ get node(): Element; /** Add one or more classes. */ addClass(...classNames: string[]): this; /** Remove one or more classes. */ removeClass(...classNames: string[]): this; /** Toggle a class by name. */ toggleClass(className: string, force?: boolean): this; /** Get or set an attribute. */ attr(name: string, value?: string): string | this; /** Remove an attribute. */ removeAttr(name: string): this; /** Toggle an attribute on/off. */ toggleAttr(name: string, force?: boolean): this; /** Get or set a property. */ prop(name: T, value?: Element[T]): Element[T] | this; /** Read or write data attributes in camelCase. */ data(name: string, value?: string): string | this; /** Get or set text content. */ text(value?: string): string | this; /** Set HTML content using a sanitized string. */ /** * Sets sanitized HTML content on the element. * Uses the security module to sanitize input and prevent XSS attacks. * * @param value - The HTML string to set (will be sanitized) * @returns The instance for method chaining * * @example * ```ts * $('#content').html('Hello'); * ``` */ html(value: string): this; /** * Sets HTML content without sanitization. * Use only when you trust the HTML source completely. * * @param value - The raw HTML string to set * @returns The instance for method chaining * * @warning This method bypasses XSS protection. Use with caution. */ htmlUnsafe(value: string): this; /** * Gets or sets CSS styles on the element. * * @param property - A CSS property name or an object of property-value pairs * @param value - The value when setting a single property * @returns The computed style value when getting a single property, or the instance for method chaining when setting * * @example * ```ts * // Get a computed style value * const color = $('#box').css('color'); * * // Set a single property * $('#box').css('color', 'red'); * * // Set multiple properties * $('#box').css({ color: 'red', 'font-size': '16px' }); * ``` */ css(property: string): string; css(property: string, value: string): this; css(property: Record): this; /** * Appends HTML or elements to the end of the element. * * @param content - HTML string or element(s) to append * @returns The instance for method chaining */ append(content: string | Element | Element[]): this; /** * Prepends HTML or elements to the beginning of the element. * * @param content - HTML string or element(s) to prepend * @returns The instance for method chaining */ prepend(content: string | Element | Element[]): this; /** * Inserts content before this element. * * @param content - HTML string or element(s) to insert * @returns The instance for method chaining */ before(content: string | Element | Element[]): this; /** * Inserts content after this element. * * @param content - HTML string or element(s) to insert * @returns The instance for method chaining */ after(content: string | Element | Element[]): this; /** * Wraps the element with the specified wrapper element or tag. * * @param wrapper - Tag name string or Element to wrap with * @returns The instance for method chaining * * @example * ```ts * $('#content').wrap('div'); // Wraps with
* $('#content').wrap(document.createElement('section')); * ``` */ wrap(wrapper: string | Element): this; /** * Removes the parent element, keeping this element in its place. * Essentially the opposite of wrap(). * * **Important**: This method only moves the current element out of its parent * before removing the parent. Any sibling elements will be removed along with * the parent. For unwrapping multiple siblings, use a collection: `$$(siblings).unwrap()`. * * @returns The instance for method chaining * * @example * ```ts * // Before:
Hello
* $('#text').unwrap(); * // After: Hello * ``` */ unwrap(): this; /** * Replaces this element with new content. * * @param content - HTML string (sanitized) or Element to replace with * @returns A new BQueryElement wrapping the replacement element * * @example * ```ts * const newEl = $('#old').replaceWith('
Replaced
'); * ``` */ replaceWith(content: string | Element): BQueryElement; /** * Removes the element from the DOM while keeping the wrapped node available * for later reuse. * * @returns The instance for method chaining * * @example * ```ts * const item = $('#item').detach(); * document.body.appendChild(item.raw); * ``` */ detach(): this; /** * Gets the zero-based index of the element among its element siblings. * * @returns Index within the parent element, or -1 when detached * * @example * ```ts * const index = $('#item').index(); * ``` */ index(): number; /** * Returns all child nodes, including text nodes and comments. * * @returns Array of child nodes * * @example * ```ts * const nodes = $('#content').contents(); * ``` */ contents(): ChildNode[]; /** * Gets the nearest positioned ancestor used for offset calculations. * * @returns The offset parent element, or null when unavailable * * @example * ```ts * const parent = $('#item').offsetParent(); * ``` */ offsetParent(): Element | null; /** * Gets the current position relative to the offset parent. * * @returns Position object with top and left coordinates * * @example * ```ts * const { top, left } = $('#item').position(); * ``` */ position(): { top: number; left: number; }; /** * Gets the inner width of the element (content + padding, excluding border). * * This corresponds to the element's `clientWidth` and mirrors jQuery's * `innerWidth()` method. * * @returns Inner width in pixels, or 0 for non-HTML elements * * @example * ```ts * const innerW = $('#panel').innerWidth(); * ``` */ innerWidth(): number; /** * Gets the inner height of the element (content + padding, excluding border). * * This corresponds to the element's `clientHeight` and mirrors jQuery's * `innerHeight()` method. * * @returns Inner height in pixels, or 0 for non-HTML elements * * @example * ```ts * const innerH = $('#panel').innerHeight(); * ``` */ innerHeight(): number; /** * Gets the outer width of the element, optionally including margins. * * @param includeMargin - When true, include horizontal margins * @returns Outer width in pixels * * @example * ```ts * const width = $('#panel').outerWidth(); * const widthWithMargin = $('#panel').outerWidth(true); * ``` */ outerWidth(includeMargin?: boolean): number; /** * Gets the outer height of the element, optionally including margins. * * @param includeMargin - When true, include vertical margins * @returns Outer height in pixels * * @example * ```ts * const height = $('#panel').outerHeight(); * const heightWithMargin = $('#panel').outerHeight(true); * ``` */ outerHeight(includeMargin?: boolean): number; /** * Scrolls the element into view with configurable behavior. * * @param options - ScrollIntoView options or boolean for legacy behavior * @returns The instance for method chaining * * @example * ```ts * $('#section').scrollTo(); // Smooth scroll * $('#section').scrollTo({ behavior: 'instant', block: 'start' }); * ``` */ scrollTo(options?: ScrollIntoViewOptions | boolean): this; /** * Removes the element from the DOM. * * @returns The instance for method chaining (though element is now detached) */ remove(): this; /** * Clears all child nodes from the element. * * @returns The instance for method chaining */ empty(): this; /** * Clones the element, optionally with all descendants. * * @param deep - If true, clone all descendants (default: true) * @returns A new BQueryElement wrapping the cloned element */ clone(deep?: boolean): BQueryElement; /** * Finds all descendant elements matching the selector. * * @param selector - CSS selector to match * @returns Array of matching elements */ find(selector: string): Element[]; /** * Finds the first descendant element matching the selector. * * @param selector - CSS selector to match * @returns The first matching element or null */ findOne(selector: string): Element | null; /** * Finds the closest ancestor matching the selector. * * @param selector - CSS selector to match * @returns The matching ancestor or null */ closest(selector: string): Element | null; /** * Gets the parent element. * * @returns The parent element or null */ parent(): Element | null; /** * Gets all child elements. * * @returns Array of child elements */ children(): Element[]; /** * Gets all sibling elements. * * @returns Array of sibling elements (excluding this element) */ siblings(): Element[]; /** * Gets the next sibling element. * * @returns The next sibling element or null */ next(): Element | null; /** * Gets the previous sibling element. * * @returns The previous sibling element or null */ prev(): Element | null; /** * Adds an event listener. * * @param event - Event type to listen for * @param handler - Event handler function * @returns The instance for method chaining */ on(event: string, handler: EventListenerOrEventListenerObject): this; /** * Adds a one-time event listener that removes itself after firing. * * @param event - Event type to listen for * @param handler - Event handler function * @returns The instance for method chaining */ once(event: string, handler: EventListener): this; /** * Removes an event listener. * * @param event - Event type * @param handler - The handler to remove * @returns The instance for method chaining */ off(event: string, handler: EventListenerOrEventListenerObject): this; /** * Triggers a custom event on the element. * * @param event - Event type to trigger * @param detail - Optional detail data to include with the event * @returns The instance for method chaining */ trigger(event: string, detail?: unknown): this; /** * Adds a delegated event listener that only triggers for matching descendants. * More efficient than adding listeners to many elements individually. * * Use `undelegate()` to remove the listener later. * * @param event - Event type to listen for * @param selector - CSS selector to match against event targets * @param handler - Event handler function, receives the matched element as context * @returns The instance for method chaining * * @example * ```ts * // Instead of adding listeners to each button: * const handler = (e, target) => console.log('Clicked:', target.textContent); * $('#list').delegate('click', '.item', handler); * * // Later, remove the delegated listener: * $('#list').undelegate('click', '.item', handler); * ``` */ delegate(event: string, selector: string, handler: (event: Event, target: Element) => void): this; /** * Removes a delegated event listener previously added with `delegate()`. * * @param event - Event type that was registered * @param selector - CSS selector that was used * @param handler - The original handler function passed to delegate() * @returns The instance for method chaining * * @example * ```ts * const handler = (e, target) => console.log('Clicked:', target.textContent); * $('#list').delegate('click', '.item', handler); * * // Remove the delegated listener: * $('#list').undelegate('click', '.item', handler); * ``` */ undelegate(event: string, selector: string, handler: (event: Event, target: Element) => void): this; /** * Checks if the element matches a CSS selector. * * @param selector - CSS selector to match against * @returns True if the element matches the selector */ matches(selector: string): boolean; /** * Alias for `matches()`. Checks if the element matches a CSS selector. * * @param selector - CSS selector to match against * @returns True if the element matches the selector * * @example * ```ts * if ($('#el').is('.active')) { * console.log('Element is active'); * } * ``` */ is(selector: string): boolean; /** * Checks if the element has a specific class. * * @param className - Class name to check * @returns True if the element has the class */ hasClass(className: string): boolean; /** * Shows the element by removing the hidden attribute and setting display. * * @param display - Optional display value (default: '') * @returns The instance for method chaining */ show(display?: string): this; /** * Hides the element by setting display to 'none'. * * @returns The instance for method chaining */ hide(): this; /** * Toggles the visibility of the element. * * @param force - Optional force show (true) or hide (false) * @returns The instance for method chaining */ toggle(force?: boolean): this; /** * Focuses the element. * * @returns The instance for method chaining */ focus(): this; /** * Blurs (unfocuses) the element. * * @returns The instance for method chaining */ blur(): this; /** * Gets or sets the value of form elements. * * @param newValue - Optional value to set * @returns The current value when getting, or the instance when setting */ val(newValue?: string): string | this; /** * Serializes form data to a plain object. * Only works on form elements; returns empty object for non-forms. * * For security hardening, the returned object uses a null prototype, * so inherited members like `hasOwnProperty` are not available directly. * Prefer `Object.keys()` or `Object.prototype.hasOwnProperty.call(...)` * when checking for fields on the serialized result. * * @returns Object with form field names as keys and values * * @example * ```ts * // For a form with * const data = $('#myForm').serialize(); * // { email: 'test@example.com' } * Object.prototype.hasOwnProperty.call(data, 'email'); // true * ``` */ serialize(): Record; /** * Serializes form data to a URL-encoded query string. * * @returns URL-encoded string suitable for form submission * * @example * ```ts * const queryString = $('#myForm').serializeString(); * // 'email=test%40example.com&name=John' * ``` */ serializeString(): string; /** * Gets the bounding client rectangle of the element. * * @returns The element's bounding rectangle */ rect(): DOMRect; /** * Gets the offset dimensions (width, height, top, left). * * @returns Object with offset dimensions */ offset(): { width: number; height: number; top: number; left: number; }; /** * Internal method to insert content at a specified position. * @internal */ private insertContent; } //# sourceMappingURL=element.d.ts.map