import { getGlobal } from "@nevoland/get-global"; import { clsx } from "clsx"; import { type JSX, type Ref, toChildArray } from "preact"; import { forwardRef } from "preact/compat"; import { flex } from "../tools/flex.js"; import { merge } from "../tools/merge.js"; import type { FlexProps } from "../types"; const IS_FIREFOX = /Gecko\/\d/i.test(getGlobal().navigator?.userAgent); function FlexForwarded( { Component = "div", class: realClassName, className = realClassName, style, children, direction, align, wrap = false, scroll = false, overflow = scroll ? "auto" : IS_FIREFOX && (direction !== undefined || align !== undefined) && toChildArray(children).some( (child) => (child as { props?: { scroll?: boolean } }).props?.scroll === true, ) ? "hidden" : undefined, gap, width, minWidth, maxWidth, height, minHeight, maxHeight, noShrink, ...props }: FlexProps & Omit, keyof FlexProps>, ref?: Ref, ) { const currentDirection = direction ?? (align === undefined ? undefined : "horizontal"); const currentAlign = align ?? (direction !== undefined ? "top-left" : undefined); return ( {children} ); } /** * Creates a `div` element with abstracted CSS Flexbox properties. */ export const Flex = forwardRef(FlexForwarded) as typeof FlexForwarded;