// This file is auto-generated by "@aria-ui/cli". Do not edit this file directly. import { registerResizableRootElement, type ResizableRootElement, type ResizableRootEvents, type ResizableRootProps as ResizableRootElementProps } from "@prosekit/web/resizable"; import { createEffect, createSignal, mergeProps, splitProps } from "solid-js"; import type { Component, JSX } from "solid-js"; import h from "solid-js/h"; /** Props for the {@link ResizableRoot} Solid component. */ export interface ResizableRootProps { /** * The width of the resizable element. * * @default null */ width?: ResizableRootElementProps['width']; /** * The height of the resizable element. * * @default null */ height?: ResizableRootElementProps['height']; /** * The aspect ratio of the resizable element. * * @default null */ aspectRatio?: ResizableRootElementProps['aspectRatio']; /** Emitted when a resize operation starts. */ onResizeStart?: (event: ResizableRootEvents['resizeStart']) => void; /** Emitted when a resize operation ends. */ onResizeEnd?: (event: ResizableRootEvents['resizeEnd']) => void; } /** A Solid component that renders an `prosekit-resizable-root` custom element. */ export const ResizableRoot: Component> = (props): any => { registerResizableRootElement() const [getElement, setElement] = createSignal(null) const handlers: Array<((event: any) => void) | undefined> = [] const [ elementProps, eventHandlers, restProps ] = splitProps(props, ["aspectRatio","height","width"], ["onResizeEnd","onResizeStart"]) createEffect(() => { const element = getElement() if (!element) return Object.assign(element, { aspectRatio: elementProps.aspectRatio, height: elementProps.height, width: elementProps.width }) handlers.length = 0 handlers.push(eventHandlers.onResizeEnd) handlers.push(eventHandlers.onResizeStart) }) createEffect(() => { const element = getElement() if (!element) return const ac = new AbortController() for (const [index, eventName] of ['resizeEnd', 'resizeStart'].entries()) { element.addEventListener(eventName, (event) => { handlers[index]?.(event) }, { signal: ac.signal }) } return () => ac.abort() }) return () => h( 'prosekit-resizable-root', mergeProps(restProps, { ref: (el: ResizableRootElement | null ) => { setElement(el) }, }), ) };