declare global { export type SVGAttributeValue = ValueOrFactory; // SVG attribute types that accept string values for all SVG properties // This is needed because SVG DOM properties like 'width' are SVGAnimatedLength, // but we set them as strings using setAttribute() // Supports state-dependent values (functions) for dynamic attributes export type SVGAttributes = { // Common SVG attributes width?: SVGAttributeValue; height?: SVGAttributeValue; viewBox?: SVGAttributeValue; fill?: SVGAttributeValue; stroke?: SVGAttributeValue; "stroke-width"?: SVGAttributeValue; "stroke-linecap"?: SVGAttributeValue<"butt" | "round" | "square">; "stroke-linejoin"?: SVGAttributeValue<"miter" | "round" | "bevel">; "stroke-dasharray"?: SVGAttributeValue; "stroke-dashoffset"?: SVGAttributeValue; opacity?: SVGAttributeValue; "fill-opacity"?: SVGAttributeValue; "stroke-opacity"?: SVGAttributeValue; transform?: SVGAttributeValue; className?: SVGAttributeValue; id?: SVGAttributeValue; // Inline style, as on HTML elements: an object, or a function returning one style?: ValueOrFactory; // Path attributes d?: SVGAttributeValue; // Circle/Ellipse attributes cx?: SVGAttributeValue; cy?: SVGAttributeValue; r?: SVGAttributeValue; rx?: SVGAttributeValue; ry?: SVGAttributeValue; // Line attributes x1?: SVGAttributeValue; y1?: SVGAttributeValue; x2?: SVGAttributeValue; y2?: SVGAttributeValue; // Rect attributes x?: SVGAttributeValue; y?: SVGAttributeValue; // Polygon/Polyline attributes points?: SVGAttributeValue; // Text attributes "text-anchor"?: SVGAttributeValue<"start" | "middle" | "end">; "dominant-baseline"?: SVGAttributeValue; "font-family"?: SVGAttributeValue; "font-size"?: SVGAttributeValue; "font-weight"?: SVGAttributeValue; // Gradient attributes offset?: SVGAttributeValue; "stop-color"?: SVGAttributeValue; "stop-opacity"?: SVGAttributeValue; // Use element href?: SVGAttributeValue; // Filter attributes filter?: SVGAttributeValue; // Clipping and masking "clip-path"?: SVGAttributeValue; mask?: SVGAttributeValue; // Allow any other string attributes (including state-dependent functions) // Using a more restrictive type to maintain type safety. Every key above // must also satisfy this signature, so it admits the style type too. } & SVGEventAttributes & { [K in string]?: SVGAttributeValue | ValueOrFactory | SVGEventAttributes[keyof SVGEventAttributes]; }; // SVG element modifier types export type SVGRenderable = | Primitive | SVGAttributes | SVGElementTagNameMap[TTagName] | SVGElement | Node; export type SVGElementModifier = | SVGRenderable | ValueFactory | ((parent: SVGElementTagNameMap[TTagName], index: number) => SVGElement | Node); // Allow SVG element and Node builders as children export type SVGElementModifierFn = ( parent: SVGElementTagNameMap[TTagName], index: number, ) => SVGElementModifier | Node | void; export type SVGElementModifierLike = | SVGElementModifier | SVGElementModifierFn // on() / when() results: they only touch the parent via namespace-agnostic DOM APIs. | NodeModFn; export type DetachedSVGElementFactory< TTagName extends SVGTagName = SVGTagName, > = SVGElementModifierFn & (( parent?: SVGElementTagNameMap[TTagName] | ExpandedElement, index?: number, ) => SVGElementTagNameMap[TTagName]); // SVG builder type - returns a NodeModFn-compatible function // Parameters are optional to allow standalone usage (e.g., svg()() for creating detached SVG) // but the function signature is compatible with NodeModFn when used as a child export type ExpandedSVGElementBuilder< TTagName extends keyof SVGElementTagNameMap = keyof SVGElementTagNameMap, > = ( ...rawMods: readonly SVGElementModifierLike[] ) => DetachedSVGElementFactory; } export {};