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

commonMain.SelectAll.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_selectAll). */
public fun  Selection.selectAll(
    selector: ElementSelector,
): Selection = selectAll { queryAll(selector) }

/** See analogous [d3 function](https://github.com/d3/d3-selection#selection_selectAll). */
public inline fun  Selection.selectAll(
    crossinline select: E1.(Arguments) -> Sequence,
): Selection {
    val arguments = Arguments.Buffer()
    return Selection(
        groups.flatMap { group ->
            group.nodes.asSequence()
                .withIndex()
                .filter { (_, node) -> node != null }
                .map { (index, node) ->
                    node as Element
                    Group(
                        node,
                        node.select(arguments(node.data as D, index, group.nodes))
                            .onEach { it.data = node.data }
                            .toList(),
                    )
                }
        },
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy