import { onDestroy, createElement, createFragment } from "../../lib/skeleton/index.js"; import rxjs, { effect, applyMutation, onClick } from "../../lib/rx.js"; import { animate } from "../../lib/animate.js"; import { loadCSS } from "../../helpers/loader.js"; import { qs } from "../../lib/dom.js"; import { getSelection$, clearSelection } from "./model_files.js"; import "../../components/dropdown.js"; export default async function(render) { const $page = createElement(`
`); render($page); const $scroll = $page.closest(".scroll-y"); effect(rxjs.fromEvent($scroll, "scroll", { passive: true }).pipe( rxjs.map((e) => e.target.scrollTop > 30), rxjs.distinctUntilChanged(), rxjs.startWith(false), rxjs.tap((scrolling) => scrolling ? $scroll.classList.add("scrolling") : $scroll.classList.remove("scrolling")), )); onDestroy(() => clearSelection()); effect(getSelection$().pipe( rxjs.filter((selections) => selections.length === 0), rxjs.mapTo(createFragment(`
`)), applyMutation($page, "replaceChildren"), )); effect(getSelection$().pipe( rxjs.filter((selections) => selections.length > 0), rxjs.tap((selections) => selections.length === 1 && animate($page)), rxjs.map((selections) => createFragment(`
`)), applyMutation($page, "replaceChildren"), rxjs.mergeMap((e) => rxjs.merge( onClick(qs($page, `[data-bind="clear"]`)).pipe( rxjs.tap(() => clearSelection()), ), )), )); } export function init() { return loadCSS(import.meta.url, "./ctrl_submenu.css"); }