UNPKG

adwaveui

Version:

Interactive Web Components inspired by the Gtk Adwaita theme.

43 lines (41 loc) 1.04 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/base-elements.ts import { sig, VSignal } from "@ncpa0cpl/vanilla-jsx/signals"; import { Attribute, registerDependencyHandler } from "wc_toolkit"; registerDependencyHandler({ detect(v) { return v instanceof VSignal; }, onChange(sig2, cb) { const cbRef = { current: /* @__PURE__ */ __name(() => { cbRef.current = cb; }, "current") }; return sig2.add(() => cbRef.current()).detach; } }); Attribute.extend((Attr) => { return class AttributeWithSignal extends Attr { constructor() { super(...arguments); this.signal = sig(); } static { __name(this, "AttributeWithSignal"); } onCreatedCallback() { this.onChange((value) => { if (typeof value === "function") { this.signal.dispatch(() => value); return; } this.signal.dispatch(value ?? void 0); }); } }; });