All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.Select.kt Maven / Gradle / Ivy

The newest version!
package com.juul.krayon.selection

import com.juul.krayon.element.Element
import com.juul.krayon.element.ElementSelector

/** See analogous [d3 function](https://github.com/d3/d3-selection#selection_select). */
public fun  Selection.select(
    selector: ElementSelector,
): Selection = select { query(selector) }

/** See analogous [d3 function](https://github.com/d3/d3-selection#selection_select). */
public inline fun  Selection.select(
    crossinline select: E1.(Arguments) -> E2?,
): Selection {
    val arguments = Arguments.Buffer()
    return Selection(
        groups.map { group ->
            Group(
                group.parent,
                group.nodes.mapIndexed { index, node ->
                    node?.select(arguments(node.data as D, index, group.nodes))
                        ?.also { it.data = node.data }
                },
            )
        },
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy