@qikbar/qikbar 0.0.25 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/bin/qikbar.mjs +203 -0
- package/dist/ai/agent.d.ts +42 -0
- package/dist/ai/byok.d.ts +29 -0
- package/dist/ai/embeddings.d.ts +51 -0
- package/dist/ai/index.d.ts +12 -0
- package/dist/ai/mcp.d.ts +84 -0
- package/dist/ai/providers.d.ts +82 -0
- package/dist/ai/sse.d.ts +9 -0
- package/dist/ai.js +54 -0
- package/dist/ai.js.map +7 -0
- package/dist/chunks/bar-P3SCR4SJ.js +2555 -0
- package/dist/chunks/bar-P3SCR4SJ.js.map +7 -0
- package/dist/chunks/chunk-5FI7DNG7.js +271 -0
- package/dist/chunks/chunk-5FI7DNG7.js.map +7 -0
- package/dist/chunks/chunk-INTEVQYK.js +108 -0
- package/dist/chunks/chunk-INTEVQYK.js.map +7 -0
- package/dist/chunks/chunk-JHQAIXM7.js +458 -0
- package/dist/chunks/chunk-JHQAIXM7.js.map +7 -0
- package/dist/chunks/chunk-MPTP2EWW.js +8 -0
- package/dist/chunks/chunk-MPTP2EWW.js.map +7 -0
- package/dist/chunks/chunk-MRHKJ2FZ.js +419 -0
- package/dist/chunks/chunk-MRHKJ2FZ.js.map +7 -0
- package/dist/chunks/chunk-N4Y2Z6YD.js +69 -0
- package/dist/chunks/chunk-N4Y2Z6YD.js.map +7 -0
- package/dist/chunks/chunk-OLXZNYZ4.js +193 -0
- package/dist/chunks/chunk-OLXZNYZ4.js.map +7 -0
- package/dist/chunks/chunk-PQEHV3D4.js +124 -0
- package/dist/chunks/chunk-PQEHV3D4.js.map +7 -0
- package/dist/chunks/chunk-R2AY6LRL.js +575 -0
- package/dist/chunks/chunk-R2AY6LRL.js.map +7 -0
- package/dist/chunks/chunk-TIM4VBM4.js +98 -0
- package/dist/chunks/chunk-TIM4VBM4.js.map +7 -0
- package/dist/chunks/chunk-YCVJQ7U3.js +52 -0
- package/dist/chunks/chunk-YCVJQ7U3.js.map +7 -0
- package/dist/chunks/launcher-B5MGOPEQ.js +37 -0
- package/dist/chunks/launcher-B5MGOPEQ.js.map +7 -0
- package/dist/core/define.d.ts +40 -0
- package/dist/core/frecency.d.ts +16 -0
- package/dist/core/hotkeys.d.ts +39 -0
- package/dist/core/labels.d.ts +98 -0
- package/dist/core/launcher.d.ts +8 -0
- package/dist/core/lazy.d.ts +60 -0
- package/dist/core/search.d.ts +42 -0
- package/dist/core/storage.d.ts +5 -0
- package/dist/core/types.d.ts +737 -0
- package/dist/element/index.d.ts +56 -0
- package/dist/element.js +146 -0
- package/dist/element.js.map +7 -0
- package/dist/extensions/index.d.ts +30 -0
- package/dist/extensions/math.d.ts +14 -0
- package/dist/extensions.js +476 -0
- package/dist/extensions.js.map +7 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +7 -0
- package/dist/locales/index.d.ts +24 -0
- package/dist/locales.js +810 -0
- package/dist/locales.js.map +7 -0
- package/dist/qikbar.global.js +302 -0
- package/dist/qikbar.global.js.map +7 -0
- package/dist/react/index.d.ts +66 -0
- package/dist/react.js +121 -0
- package/dist/react.js.map +7 -0
- package/dist/server/index.d.ts +66 -0
- package/dist/server.js +129 -0
- package/dist/server.js.map +7 -0
- package/dist/solid/index.d.ts +42 -0
- package/dist/solid.js +93 -0
- package/dist/solid.js.map +7 -0
- package/dist/styles.css +253 -0
- package/dist/svelte/index.d.ts +58 -0
- package/dist/svelte.js +55 -0
- package/dist/svelte.js.map +7 -0
- package/dist/theme.d.ts +5 -0
- package/dist/theme.js +20 -0
- package/dist/theme.js.map +7 -0
- package/dist/ui/bar.d.ts +338 -0
- package/dist/ui/dom.d.ts +21 -0
- package/dist/ui/icons.d.ts +93 -0
- package/dist/ui/markdown.d.ts +10 -0
- package/dist/ui/nav.d.ts +8 -0
- package/dist/ui/styles.d.ts +6 -0
- package/dist/ui/themes.d.ts +27 -0
- package/dist/ui/views.d.ts +156 -0
- package/dist/ui/webmcp.d.ts +33 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.js +50 -0
- package/dist/utils.js.map +7 -0
- package/dist/vue/index.d.ts +74 -0
- package/dist/vue.js +122 -0
- package/dist/vue.js.map +7 -0
- package/package.json +129 -43
- package/dist/qikbar.es.js +0 -8748
- package/dist/qikbar.umd.js +0 -113
- package/dist/types/boot.d.ts +0 -72
- package/dist/types/index.d.ts +0 -1
- package/dist/types/init.d.ts +0 -2
- package/dist/types/main.d.ts +0 -4
- package/dist/types/shared/AsyncRoot.d.ts +0 -5
- package/dist/types/shared/CommandFooter.d.ts +0 -5
- package/dist/types/shared/Crumbs.d.ts +0 -6
- package/dist/types/shared/Details.d.ts +0 -3
- package/dist/types/shared/ErrorBoundary.d.ts +0 -15
- package/dist/types/shared/Icon.d.ts +0 -4
- package/dist/types/shared/List.d.ts +0 -30
- package/dist/types/shared/Qikbar.d.ts +0 -5
- package/dist/types/shared/Root.d.ts +0 -4
- package/dist/types/shared/Search.d.ts +0 -1
- package/dist/types/shared/commandContext.d.ts +0 -8
- package/dist/types/shared/useDebounce.d.ts +0 -1
- package/dist/types/utils/liquid.d.ts +0 -4
- package/dist/types/vite-env.d.ts +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<qik-bar>`: Qikbar as a custom element. Works in plain HTML, HTMX, Angular,
|
|
3
|
+
* Rails, Django, Laravel — anywhere you can write a tag.
|
|
4
|
+
*
|
|
5
|
+
* ```html
|
|
6
|
+
* <script type="module">import '@qikbar/qikbar/element'</script>
|
|
7
|
+
*
|
|
8
|
+
* <qik-bar placeholder="Search Acme…" launcher="touch">
|
|
9
|
+
* <qik-command href="/settings" section="Navigation" icon="settings">Settings</qik-command>
|
|
10
|
+
* <qik-command id="theme" shortcut="mod+shift+l">Toggle theme</qik-command>
|
|
11
|
+
* </qik-bar>
|
|
12
|
+
*
|
|
13
|
+
* <script>
|
|
14
|
+
* document.getElementById('theme').addEventListener('run', toggleTheme)
|
|
15
|
+
* </script>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Set the `config` property for anything attributes can't express (sources,
|
|
19
|
+
* extensions, AI). Events: `qikbar-open`, `qikbar-close`, `qikbar-run`, `qikbar-event`.
|
|
20
|
+
*/
|
|
21
|
+
import type { QikbarConfig, QikbarInstance } from '../core/types.js';
|
|
22
|
+
declare const Base: typeof HTMLElement;
|
|
23
|
+
export declare class QikbarElement extends Base {
|
|
24
|
+
static get observedAttributes(): ("placeholder" | "footer" | "touch" | "hotkey" | "theme" | "appearance" | "inline" | "namespace" | "launcher" | "webmcp")[];
|
|
25
|
+
private instance?;
|
|
26
|
+
private extra;
|
|
27
|
+
private unregister?;
|
|
28
|
+
private observer?;
|
|
29
|
+
private offs;
|
|
30
|
+
/** The Qikbar instance (created when the element connects). */
|
|
31
|
+
get bar(): QikbarInstance | undefined;
|
|
32
|
+
/** Extra configuration: sources, extensions, ai, navigate, … Merged over attributes. */
|
|
33
|
+
get config(): QikbarConfig;
|
|
34
|
+
set config(value: QikbarConfig);
|
|
35
|
+
private attrConfig;
|
|
36
|
+
private fullConfig;
|
|
37
|
+
/** Inline bars render into a child so `<qik-command>` markup is untouched. */
|
|
38
|
+
private mountPoint;
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
disconnectedCallback(): void;
|
|
41
|
+
attributeChangedCallback(name: string, oldValue: string | null, value: string | null): void;
|
|
42
|
+
private remount;
|
|
43
|
+
private syncCommands;
|
|
44
|
+
open(options?: Parameters<QikbarInstance['open']>[0]): void;
|
|
45
|
+
close(): void;
|
|
46
|
+
toggle(): void;
|
|
47
|
+
ask(prompt?: string): void;
|
|
48
|
+
}
|
|
49
|
+
/** Register the element (done automatically on import with the default tag). */
|
|
50
|
+
export declare function defineQikbarElement(tag?: string): void;
|
|
51
|
+
declare global {
|
|
52
|
+
interface HTMLElementTagNameMap {
|
|
53
|
+
'qik-bar': QikbarElement;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {};
|
package/dist/element.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createQikbar
|
|
3
|
+
} from "./chunks/chunk-OLXZNYZ4.js";
|
|
4
|
+
import "./chunks/chunk-5FI7DNG7.js";
|
|
5
|
+
import "./chunks/chunk-N4Y2Z6YD.js";
|
|
6
|
+
import "./chunks/chunk-MRHKJ2FZ.js";
|
|
7
|
+
import "./chunks/chunk-INTEVQYK.js";
|
|
8
|
+
import "./chunks/chunk-YCVJQ7U3.js";
|
|
9
|
+
import "./chunks/chunk-PQEHV3D4.js";
|
|
10
|
+
import "./chunks/chunk-TIM4VBM4.js";
|
|
11
|
+
import {
|
|
12
|
+
__publicField
|
|
13
|
+
} from "./chunks/chunk-MPTP2EWW.js";
|
|
14
|
+
|
|
15
|
+
// src/element/index.ts
|
|
16
|
+
var Base = typeof HTMLElement < "u" ? HTMLElement : class {
|
|
17
|
+
}, ATTRS = ["placeholder", "hotkey", "theme", "appearance", "inline", "namespace", "launcher", "touch", "webmcp", "footer"];
|
|
18
|
+
function readCommands(host) {
|
|
19
|
+
return [...host.querySelectorAll(":scope > qik-command, :scope > qik-commands > qik-command")].map((el, i) => {
|
|
20
|
+
let attr = (name) => el.getAttribute(name) ?? void 0, title = attr("title") ?? (el.textContent ?? "").replace(/\s+/g, " ").trim(), item = {
|
|
21
|
+
id: el.id || attr("command-id") || `el:${i}:${title}`,
|
|
22
|
+
title,
|
|
23
|
+
subtitle: attr("subtitle"),
|
|
24
|
+
description: attr("description"),
|
|
25
|
+
section: attr("section") ?? el.closest("qik-commands")?.getAttribute("section") ?? void 0,
|
|
26
|
+
icon: attr("icon"),
|
|
27
|
+
keywords: attr("keywords")?.split(",").map((k) => k.trim()).filter(Boolean),
|
|
28
|
+
shortcut: attr("shortcut"),
|
|
29
|
+
href: attr("href"),
|
|
30
|
+
url: attr("url")
|
|
31
|
+
};
|
|
32
|
+
return !item.href && !item.url && (item.run = () => {
|
|
33
|
+
let ev = new CustomEvent("run", { bubbles: !0, cancelable: !0, detail: { item } });
|
|
34
|
+
return el.dispatchEvent(ev), el.hasAttribute("keep-open") ? !1 : void 0;
|
|
35
|
+
}), item;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
var QikbarElement = class extends Base {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
__publicField(this, "instance");
|
|
42
|
+
__publicField(this, "extra", {});
|
|
43
|
+
__publicField(this, "unregister");
|
|
44
|
+
__publicField(this, "observer");
|
|
45
|
+
__publicField(this, "offs", []);
|
|
46
|
+
}
|
|
47
|
+
static get observedAttributes() {
|
|
48
|
+
return [...ATTRS];
|
|
49
|
+
}
|
|
50
|
+
/** The Qikbar instance (created when the element connects). */
|
|
51
|
+
get bar() {
|
|
52
|
+
return this.instance;
|
|
53
|
+
}
|
|
54
|
+
/** Extra configuration: sources, extensions, ai, navigate, … Merged over attributes. */
|
|
55
|
+
get config() {
|
|
56
|
+
return this.extra;
|
|
57
|
+
}
|
|
58
|
+
set config(value) {
|
|
59
|
+
let prev = this.extra;
|
|
60
|
+
if (this.extra = { ...value }, !this.instance) return;
|
|
61
|
+
let changed = {};
|
|
62
|
+
for (let key of /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(this.extra)]))
|
|
63
|
+
Object.is(prev[key], this.extra[key]) || (changed[key] = this.extra[key]);
|
|
64
|
+
"inline" in changed ? this.remount() : this.instance.configure(changed);
|
|
65
|
+
}
|
|
66
|
+
attrConfig() {
|
|
67
|
+
let a = (name) => this.getAttribute(name), flag = (name) => {
|
|
68
|
+
let v = a(name);
|
|
69
|
+
return v == null ? void 0 : v === "" || v === "true" ? !0 : v === "false" ? !1 : v;
|
|
70
|
+
}, out = {};
|
|
71
|
+
a("placeholder") != null && (out.placeholder = a("placeholder"));
|
|
72
|
+
let hotkey = a("hotkey");
|
|
73
|
+
hotkey != null && (out.hotkey = hotkey === "false" || hotkey === "none" ? !1 : hotkey.split(/\s*,\s*/)), a("theme") && (out.theme = a("theme")), a("appearance") && (out.appearance = a("appearance")), a("namespace") && (out.namespace = a("namespace")), a("footer") && (out.footer = a("footer"));
|
|
74
|
+
let launcher = flag("launcher");
|
|
75
|
+
launcher !== void 0 && (out.launcher = launcher === "touch" ? "touch" : !!launcher);
|
|
76
|
+
let touch = flag("touch");
|
|
77
|
+
touch !== void 0 && (out.touch = touch === "auto" ? "auto" : !!touch);
|
|
78
|
+
let webmcp = flag("webmcp");
|
|
79
|
+
return webmcp !== void 0 && (out.webmcp = !!webmcp), out;
|
|
80
|
+
}
|
|
81
|
+
fullConfig() {
|
|
82
|
+
let config = { ...this.attrConfig(), ...this.extra };
|
|
83
|
+
return this.hasAttribute("inline") && (config.inline = this.mountPoint()), config;
|
|
84
|
+
}
|
|
85
|
+
/** Inline bars render into a child so `<qik-command>` markup is untouched. */
|
|
86
|
+
mountPoint() {
|
|
87
|
+
let el = this.querySelector(":scope > [data-qikbar-mount]");
|
|
88
|
+
return el || (el = document.createElement("div"), el.dataset.qikbarMount = "", this.append(el)), el;
|
|
89
|
+
}
|
|
90
|
+
connectedCallback() {
|
|
91
|
+
if (this.instance) return;
|
|
92
|
+
this.hasAttribute("inline") || (this.style.display = "contents");
|
|
93
|
+
let bar = createQikbar(this.fullConfig());
|
|
94
|
+
this.instance = bar;
|
|
95
|
+
let fire = (type, detail) => this.dispatchEvent(new CustomEvent(type, { detail, bubbles: !0, composed: !0 }));
|
|
96
|
+
this.offs.push(
|
|
97
|
+
bar.on("open", () => fire("qikbar-open")),
|
|
98
|
+
bar.on("close", () => fire("qikbar-close")),
|
|
99
|
+
bar.on("run", (detail) => fire("qikbar-run", detail)),
|
|
100
|
+
bar.on("event", (detail) => fire("qikbar-event", detail))
|
|
101
|
+
), this.syncCommands(), this.observer = new MutationObserver((records) => {
|
|
102
|
+
records.some((r) => !r.target.closest?.("[data-qikbar-mount], .qb-root")) && this.syncCommands();
|
|
103
|
+
}), this.observer.observe(this, { childList: !0, subtree: !0, attributes: !0, characterData: !0 });
|
|
104
|
+
}
|
|
105
|
+
disconnectedCallback() {
|
|
106
|
+
this.observer?.disconnect(), this.observer = void 0;
|
|
107
|
+
for (let off of this.offs) off();
|
|
108
|
+
this.offs = [], this.unregister?.(), this.unregister = void 0, this.instance?.destroy(), this.instance = void 0, this.querySelector(":scope > [data-qikbar-mount]")?.remove();
|
|
109
|
+
}
|
|
110
|
+
attributeChangedCallback(name, oldValue, value) {
|
|
111
|
+
if (!(!this.instance || oldValue === value)) {
|
|
112
|
+
if (name === "inline") return this.remount();
|
|
113
|
+
this.instance.configure(this.attrConfig());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
remount() {
|
|
117
|
+
this.disconnectedCallback(), this.connectedCallback();
|
|
118
|
+
}
|
|
119
|
+
syncCommands() {
|
|
120
|
+
this.unregister?.();
|
|
121
|
+
let commands = readCommands(this);
|
|
122
|
+
this.unregister = commands.length ? this.instance?.register(commands) : void 0;
|
|
123
|
+
}
|
|
124
|
+
open(options) {
|
|
125
|
+
this.instance?.open(options);
|
|
126
|
+
}
|
|
127
|
+
close() {
|
|
128
|
+
this.instance?.close();
|
|
129
|
+
}
|
|
130
|
+
toggle() {
|
|
131
|
+
this.instance?.toggle();
|
|
132
|
+
}
|
|
133
|
+
ask(prompt) {
|
|
134
|
+
this.instance?.ask(prompt);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
function defineQikbarElement(tag = "qik-bar") {
|
|
138
|
+
typeof customElements > "u" || customElements.get(tag) || customElements.define(tag, class extends QikbarElement {
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
defineQikbarElement();
|
|
142
|
+
export {
|
|
143
|
+
QikbarElement,
|
|
144
|
+
defineQikbarElement
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/element/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * `<qik-bar>`: Qikbar as a custom element. Works in plain HTML, HTMX, Angular,\n * Rails, Django, Laravel \u2014 anywhere you can write a tag.\n *\n * ```html\n * <script type=\"module\">import '@qikbar/qikbar/element'</script>\n *\n * <qik-bar placeholder=\"Search Acme\u2026\" launcher=\"touch\">\n * <qik-command href=\"/settings\" section=\"Navigation\" icon=\"settings\">Settings</qik-command>\n * <qik-command id=\"theme\" shortcut=\"mod+shift+l\">Toggle theme</qik-command>\n * </qik-bar>\n *\n * <script>\n * document.getElementById('theme').addEventListener('run', toggleTheme)\n * </script>\n * ```\n *\n * Set the `config` property for anything attributes can't express (sources,\n * extensions, AI). Events: `qikbar-open`, `qikbar-close`, `qikbar-run`, `qikbar-event`.\n */\n\nimport { createQikbar } from '../index.js'\nimport type { Appearance, Item, QikbarConfig, QikbarInstance, ThemePresetName } from '../core/types.js'\n\nconst Base: typeof HTMLElement = typeof HTMLElement !== 'undefined' ? HTMLElement : (class {} as unknown as typeof HTMLElement)\n\nconst ATTRS = ['placeholder', 'hotkey', 'theme', 'appearance', 'inline', 'namespace', 'launcher', 'touch', 'webmcp', 'footer'] as const\n\n/** Read `<qik-command>` children into commands. */\nfunction readCommands(host: HTMLElement): Item[] {\n return [...host.querySelectorAll<HTMLElement>(':scope > qik-command, :scope > qik-commands > qik-command')].map((el, i) => {\n const attr = (name: string) => el.getAttribute(name) ?? undefined\n const title = attr('title') ?? (el.textContent ?? '').replace(/\\s+/g, ' ').trim()\n const item: Item = {\n id: el.id || attr('command-id') || `el:${i}:${title}`,\n title,\n subtitle: attr('subtitle'),\n description: attr('description'),\n section: attr('section') ?? el.closest('qik-commands')?.getAttribute('section') ?? undefined,\n icon: attr('icon'),\n keywords: attr('keywords')\n ?.split(',')\n .map((k) => k.trim())\n .filter(Boolean),\n shortcut: attr('shortcut'),\n href: attr('href'),\n url: attr('url'),\n }\n if (!item.href && !item.url) {\n item.run = () => {\n const ev = new CustomEvent('run', { bubbles: true, cancelable: true, detail: { item } })\n el.dispatchEvent(ev)\n return el.hasAttribute('keep-open') ? false : undefined\n }\n }\n return item\n })\n}\n\nexport class QikbarElement extends Base {\n static get observedAttributes() {\n return [...ATTRS]\n }\n\n private instance?: QikbarInstance\n private extra: QikbarConfig = {}\n private unregister?: () => void\n private observer?: MutationObserver\n private offs: (() => void)[] = []\n\n /** The Qikbar instance (created when the element connects). */\n get bar(): QikbarInstance | undefined {\n return this.instance\n }\n\n /** Extra configuration: sources, extensions, ai, navigate, \u2026 Merged over attributes. */\n get config(): QikbarConfig {\n return this.extra\n }\n set config(value: QikbarConfig) {\n const prev = this.extra\n this.extra = { ...value }\n if (!this.instance) return\n const changed: Partial<QikbarConfig> = {}\n for (const key of new Set([...Object.keys(prev), ...Object.keys(this.extra)]) as Set<keyof QikbarConfig>) {\n if (!Object.is(prev[key], this.extra[key])) (changed as any)[key] = this.extra[key]\n }\n if ('inline' in changed) this.remount()\n else this.instance.configure(changed)\n }\n\n private attrConfig(): QikbarConfig {\n const a = (name: string) => this.getAttribute(name)\n const flag = (name: string) => {\n const v = a(name)\n return v == null ? undefined : v === '' || v === 'true' ? true : v === 'false' ? false : v\n }\n const out: QikbarConfig = {}\n if (a('placeholder') != null) out.placeholder = a('placeholder')!\n const hotkey = a('hotkey')\n if (hotkey != null) out.hotkey = hotkey === 'false' || hotkey === 'none' ? false : hotkey.split(/\\s*,\\s*/)\n if (a('theme')) out.theme = a('theme') as ThemePresetName\n if (a('appearance')) out.appearance = a('appearance') as Appearance\n if (a('namespace')) out.namespace = a('namespace')!\n if (a('footer')) out.footer = a('footer')!\n const launcher = flag('launcher')\n if (launcher !== undefined) out.launcher = launcher === 'touch' ? 'touch' : !!launcher\n const touch = flag('touch')\n if (touch !== undefined) out.touch = touch === 'auto' ? 'auto' : !!touch\n const webmcp = flag('webmcp')\n if (webmcp !== undefined) out.webmcp = !!webmcp\n return out\n }\n\n private fullConfig(): QikbarConfig {\n const config: QikbarConfig = { ...this.attrConfig(), ...this.extra }\n if (this.hasAttribute('inline')) config.inline = this.mountPoint()\n return config\n }\n\n /** Inline bars render into a child so `<qik-command>` markup is untouched. */\n private mountPoint(): HTMLElement {\n let el = this.querySelector<HTMLElement>(':scope > [data-qikbar-mount]')\n if (!el) {\n el = document.createElement('div')\n el.dataset.qikbarMount = ''\n this.append(el)\n }\n return el\n }\n\n connectedCallback() {\n if (this.instance) return\n if (!this.hasAttribute('inline')) this.style.display = 'contents'\n const bar = createQikbar(this.fullConfig())\n this.instance = bar\n const fire = (type: string, detail?: unknown) => this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }))\n this.offs.push(\n bar.on('open', () => fire('qikbar-open')),\n bar.on('close', () => fire('qikbar-close')),\n bar.on('run', (detail) => fire('qikbar-run', detail)),\n bar.on('event', (detail) => fire('qikbar-event', detail)),\n )\n this.syncCommands()\n this.observer = new MutationObserver((records) => {\n if (records.some((r) => !(r.target as Element).closest?.('[data-qikbar-mount], .qb-root'))) this.syncCommands()\n })\n this.observer.observe(this, { childList: true, subtree: true, attributes: true, characterData: true })\n }\n\n disconnectedCallback() {\n this.observer?.disconnect()\n this.observer = undefined\n for (const off of this.offs) off()\n this.offs = []\n this.unregister?.()\n this.unregister = undefined\n this.instance?.destroy()\n this.instance = undefined\n this.querySelector(':scope > [data-qikbar-mount]')?.remove()\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, value: string | null) {\n if (!this.instance || oldValue === value) return\n if (name === 'inline') return this.remount()\n this.instance.configure(this.attrConfig())\n }\n\n private remount() {\n this.disconnectedCallback()\n this.connectedCallback()\n }\n\n private syncCommands() {\n this.unregister?.()\n const commands = readCommands(this)\n this.unregister = commands.length ? this.instance?.register(commands) : undefined\n }\n\n open(options?: Parameters<QikbarInstance['open']>[0]) {\n this.instance?.open(options)\n }\n close() {\n this.instance?.close()\n }\n toggle() {\n this.instance?.toggle()\n }\n ask(prompt?: string) {\n this.instance?.ask(prompt)\n }\n}\n\n/** Register the element (done automatically on import with the default tag). */\nexport function defineQikbarElement(tag = 'qik-bar') {\n if (typeof customElements === 'undefined' || customElements.get(tag)) return\n customElements.define(tag, class extends QikbarElement {})\n}\n\ndefineQikbarElement()\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qik-bar': QikbarElement\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAwBA,IAAM,OAA2B,OAAO,cAAgB,MAAc,cAAe,MAAM;AAAC,GAEtF,QAAQ,CAAC,eAAe,UAAU,SAAS,cAAc,UAAU,aAAa,YAAY,SAAS,UAAU,QAAQ;AAG7H,SAAS,aAAa,MAA2B;AAC/C,SAAO,CAAC,GAAG,KAAK,iBAA8B,2DAA2D,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM;AACzH,QAAM,OAAO,CAAC,SAAiB,GAAG,aAAa,IAAI,KAAK,QAClD,QAAQ,KAAK,OAAO,MAAM,GAAG,eAAe,IAAI,QAAQ,QAAQ,GAAG,EAAE,KAAK,GAC1E,OAAa;AAAA,MACjB,IAAI,GAAG,MAAM,KAAK,YAAY,KAAK,MAAM,CAAC,IAAI,KAAK;AAAA,MACnD;AAAA,MACA,UAAU,KAAK,UAAU;AAAA,MACzB,aAAa,KAAK,aAAa;AAAA,MAC/B,SAAS,KAAK,SAAS,KAAK,GAAG,QAAQ,cAAc,GAAG,aAAa,SAAS,KAAK;AAAA,MACnF,MAAM,KAAK,MAAM;AAAA,MACjB,UAAU,KAAK,UAAU,GACrB,MAAM,GAAG,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,MACjB,UAAU,KAAK,UAAU;AAAA,MACzB,MAAM,KAAK,MAAM;AAAA,MACjB,KAAK,KAAK,KAAK;AAAA,IACjB;AACA,WAAI,CAAC,KAAK,QAAQ,CAAC,KAAK,QACtB,KAAK,MAAM,MAAM;AACf,UAAM,KAAK,IAAI,YAAY,OAAO,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,EAEA,KAAK,SAAiD;AACpD,SAAK,UAAU,KAAK,OAAO;AAAA,EAC7B;AAAA,EACA,QAAQ;AACN,SAAK,UAAU,MAAM;AAAA,EACvB;AAAA,EACA,SAAS;AACP,SAAK,UAAU,OAAO;AAAA,EACxB;AAAA,EACA,IAAI,QAAiB;AACnB,SAAK,UAAU,IAAI,MAAM;AAAA,EAC3B;AACF;AAGO,SAAS,oBAAoB,MAAM,WAAW;AACnD,EAAI,OAAO,iBAAmB,OAAe,eAAe,IAAI,GAAG,KACnE,eAAe,OAAO,KAAK,cAAc,cAAc;AAAA,EAAC,CAAC;AAC3D;AAEA,oBAAoB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in extensions. Each is a plain `Extension` object — read the source to
|
|
3
|
+
* learn the extension API, or copy one as a starting point for your own.
|
|
4
|
+
*/
|
|
5
|
+
import type { Extension } from '../core/types.js';
|
|
6
|
+
export { convert, evaluate, formatNumber } from './math.js';
|
|
7
|
+
/** Type math or conversions straight into the bar: `12 * (3 + 4)`, `15% of 80`, `5 km in mi`. */
|
|
8
|
+
export declare function calculator(): Extension;
|
|
9
|
+
export type ThemeMode = 'light' | 'dark' | 'system';
|
|
10
|
+
export interface ThemeSwitcherOptions {
|
|
11
|
+
/** Apply a theme. Default: toggles the `dark` class and `color-scheme` on `<html>` and saves to localStorage. */
|
|
12
|
+
set?: (mode: ThemeMode) => void;
|
|
13
|
+
/** Shortcut for "Toggle Theme". Default `"mod+shift+l"`. */
|
|
14
|
+
shortcut?: string | false;
|
|
15
|
+
storageKey?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Light / dark / system theme commands. */
|
|
18
|
+
export declare function themeSwitcher(options?: ThemeSwitcherOptions): Extension;
|
|
19
|
+
export interface PageOptions {
|
|
20
|
+
/** Index headings on the current page so users can jump to them. Default `"h1[id], h2[id], h3[id]"`. Set `false` to disable. */
|
|
21
|
+
headings?: string | false;
|
|
22
|
+
}
|
|
23
|
+
/** Browser and page utilities: back/forward, copy URL, scroll, print, share, jump to heading. */
|
|
24
|
+
export declare function page(options?: PageOptions): Extension;
|
|
25
|
+
/** AI commands that work on the current page or selected text. Requires `ai` to be configured. */
|
|
26
|
+
export declare function aiActions(): Extension;
|
|
27
|
+
/** A "Keyboard Shortcuts" command listing every shortcut in your app. */
|
|
28
|
+
export declare function shortcuts(): Extension;
|
|
29
|
+
/** Format a shortcut for display outside the bar, e.g. in a button: `"⌘K"`. */
|
|
30
|
+
export declare function shortcutLabel(hotkey: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A safe arithmetic evaluator (no `eval`). Supports + - * / % ^ **, parentheses,
|
|
3
|
+
* implicit multiplication ("2pi", "3(4+1)"), percentages ("15% of 80", "200 + 10%"),
|
|
4
|
+
* constants, common functions and unit conversions ("5 km in miles").
|
|
5
|
+
*/
|
|
6
|
+
export declare function evaluate(expression: string): number;
|
|
7
|
+
/** "5 km in miles" → { value, unit } or undefined. */
|
|
8
|
+
export declare function convert(input: string): {
|
|
9
|
+
value: number;
|
|
10
|
+
unit: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
export declare function formatNumber(v: number): string;
|
|
13
|
+
/** Heuristic: does the query look like something to calculate? */
|
|
14
|
+
export declare function looksLikeMath(q: string): boolean;
|