/** * Entry module for SelectiveUI. * * This file exposes the public API surface of the library: * - version/name metadata * - DOM binding helpers (bind/find/rebind/destroy) * - effector factory for imperative effects * * Notes: * - CSS imports below are *side-effect imports* used by bundlers (Vite/Webpack/Rollup) * to include component styles in the final bundle. */ /** Base/global styles for SelectiveUI. */ import "../css/index.css"; /** Component-level styles (imported for side-effects during bundling). */ import "../css/components/selectbox.css"; import "../css/components/placeholder.css"; import "../css/components/directive.css"; import "../css/components/popup/empty-state.css"; import "../css/components/popup/loading-state.css"; import "../css/views/group-view.css"; import "../css/components/popup/popup.css"; import "../css/components/searchbox.css"; import "../css/components/option-handle.css"; import "../css/views/option-view.css"; import "../css/components/accessorybox.css"; import { Selective } from "./utils/selective"; import { Effector } from "./services/effector"; import type { SelectiveActionApi, SelectiveOptions, SelectiveUIGlobal, } from "./types/utils/selective.type"; import type { SelectivePlugin } from "./types/plugins/plugin.type"; import type { EffectorInterface } from "./types/services/effector.type"; import { Libs } from "./utils/libs"; const __LIB_VERSION__ = "LIB_VERSION"; const __LIB_NAME__ = "LIB_NAME"; declare global { var GLOBAL_SEUI: SelectiveUIGlobal; } if (typeof globalThis.GLOBAL_SEUI == "undefined") { const SECLASS = new Selective(); globalThis.GLOBAL_SEUI = { version: __LIB_VERSION__, name: __LIB_NAME__, bind: SECLASS.bind.bind(SECLASS), find: SECLASS.find.bind(SECLASS), destroy: SECLASS.destroy.bind(SECLASS), effector: Effector.bind(Effector), rebind: SECLASS.rebind.bind(SECLASS), registerPlugin: SECLASS.registerPlugin.bind(SECLASS), unregisterPlugin: SECLASS.unregisterPlugin.bind(SECLASS), } as SelectiveUIGlobal; let domInitialized = false; function init(): void { if (domInitialized) return; domInitialized = true; document.addEventListener("mousedown", () => { const sels = Libs.getBindedCommand(); if (sels.length > 0) { const actionApi = SECLASS.find(sels.join(", ")); if (!actionApi.isEmpty) actionApi.close(); } }); SECLASS.Observer(); } if (typeof document !== "undefined") { if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", init); } else { init(); } } console.log(`[${__LIB_NAME__}] v${__LIB_VERSION__} loaded successfully`); } else { console.warn( `[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). ` + `Using existing instance. Please remove duplicate