@hanzo/ui 8.0.109 → 8.0.110
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/dist/product/Palette.cjs +16 -7
- package/dist/product/Palette.d.ts +16 -5
- package/dist/product/Palette.d.ts.map +1 -1
- package/dist/product/Palette.js +17 -8
- package/dist/product/Palette.js.map +1 -1
- package/dist/product/match.cjs +44 -1
- package/dist/product/match.d.ts +33 -0
- package/dist/product/match.d.ts.map +1 -1
- package/dist/product/match.js +41 -0
- package/dist/product/match.js.map +1 -1
- package/package.json +1 -1
package/dist/product/Palette.cjs
CHANGED
|
@@ -31,24 +31,33 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
31
31
|
* its personality: hanzo.app keeps its live project preview and console keeps its
|
|
32
32
|
* `>` AI mode by passing them, not by forking this.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
* the empty-query behaviour all live in `match.ts` as pure
|
|
36
|
-
* `shouldFilter` is off and the Command primitive is left holding
|
|
37
|
-
* the view — which is also what makes
|
|
34
|
+
* Which rows exist is `rows`. The safe-methods-browse rule, the per-group cap,
|
|
35
|
+
* the empty-query behaviour and the ask row all live in `match.ts` as pure
|
|
36
|
+
* functions, so `shouldFilter` is off and the Command primitive is left holding
|
|
37
|
+
* the cursor and the view — which is also what makes them testable without a
|
|
38
|
+
* DOM. This component renders into a portal, so a test cannot read its rows at
|
|
39
|
+
* all; a rule kept here instead would be a rule nothing can check.
|
|
38
40
|
*/
|
|
39
41
|
const react_1 = require("react");
|
|
40
42
|
const gui_1 = require("@hanzo/gui");
|
|
41
43
|
const gui_2 = require("../backends/gui/index.cjs");
|
|
42
44
|
const match_1 = require("./match.cjs");
|
|
43
|
-
function Palette({ open, onOpenChange, ops, onRun, active, onActive, search: controlled, onSearch, placeholder = "Search commands…", empty = "No results found.", limit, children, footer, height = 320, title = "Search commands", }) {
|
|
45
|
+
function Palette({ open, onOpenChange, ops, onRun, active, onActive, search: controlled, onSearch, placeholder = "Search commands…", empty = "No results found.", limit, children, footer, height = 320, title = "Search commands", onAsk, }) {
|
|
44
46
|
const [own, setOwn] = (0, react_1.useState)("");
|
|
45
47
|
const search = controlled ?? own;
|
|
46
48
|
const setSearch = (s) => {
|
|
47
49
|
setOwn(s);
|
|
48
50
|
onSearch?.(s);
|
|
49
51
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
+
const question = search.trim();
|
|
53
|
+
const groups = (0, react_1.useMemo)(() => (0, match_1.rows)(ops, search, limit, !!onAsk), [ops, search, limit, onAsk]);
|
|
54
|
+
const run = (op) => {
|
|
55
|
+
if (op.id === match_1.ASK && onAsk)
|
|
56
|
+
onAsk(question);
|
|
57
|
+
else
|
|
58
|
+
onRun(op);
|
|
59
|
+
};
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)(gui_2.CommandDialog, { open: open, onOpenChange: onOpenChange, title: title, description: placeholder, value: active, onValueChange: onActive, shouldFilter: false, children: [(0, jsx_runtime_1.jsx)(gui_2.CommandInput, { value: search, onValueChange: setSearch, placeholder: placeholder, color: "$color", placeholderTextColor: "$color11" }), (0, jsx_runtime_1.jsxs)(gui_1.XStack, { minH: height, children: [(0, jsx_runtime_1.jsxs)(gui_2.CommandList, { maxH: height, width: children ? "50%" : "100%", borderRightWidth: children ? 1 : 0, borderColor: "$borderColor", pt: "$1", pb: "$4", children: [groups.length === 0 && ((0, jsx_runtime_1.jsx)(gui_2.CommandEmpty, { children: (0, jsx_runtime_1.jsx)(gui_1.SizableText, { color: "$color11", children: empty }) })), groups.map(([group, items]) => ((0, jsx_runtime_1.jsx)(gui_2.CommandGroup, { heading: group, children: items.map((op) => ((0, jsx_runtime_1.jsxs)(gui_2.CommandItem, { value: op.id, onSelect: () => run(op), gap: "$2", children: [op.icon, (0, jsx_runtime_1.jsxs)(gui_1.XStack, { flex: 1, items: "center", gap: "$2", overflow: "hidden", children: [(0, jsx_runtime_1.jsx)(gui_1.SizableText, { numberOfLines: 1, shrink: 0, children: op.label }), op.hint ? ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { numberOfLines: 1, flex: 1, fontSize: "$1", color: "$color11", children: op.hint })) : null] }), (0, jsx_runtime_1.jsx)(Method, { of: op }), op.end] }, op.id))) }, group)))] }), children ? (0, jsx_runtime_1.jsx)(gui_1.YStack, { width: "50%", children: children }) : null] }), footer ? ((0, jsx_runtime_1.jsx)(gui_1.XStack, { items: "center", gap: "$4", borderTopWidth: 1, borderColor: "$borderColor", px: "$3", py: "$2", children: footer })) : null] }));
|
|
52
61
|
}
|
|
53
62
|
/**
|
|
54
63
|
* The method, at the end of the row, for route commands only.
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
* its personality: hanzo.app keeps its live project preview and console keeps its
|
|
27
27
|
* `>` AI mode by passing them, not by forking this.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
* the empty-query behaviour all live in `match.ts` as pure
|
|
31
|
-
* `shouldFilter` is off and the Command primitive is left holding
|
|
32
|
-
* the view — which is also what makes
|
|
29
|
+
* Which rows exist is `rows`. The safe-methods-browse rule, the per-group cap,
|
|
30
|
+
* the empty-query behaviour and the ask row all live in `match.ts` as pure
|
|
31
|
+
* functions, so `shouldFilter` is off and the Command primitive is left holding
|
|
32
|
+
* the cursor and the view — which is also what makes them testable without a
|
|
33
|
+
* DOM. This component renders into a portal, so a test cannot read its rows at
|
|
34
|
+
* all; a rule kept here instead would be a rule nothing can check.
|
|
33
35
|
*/
|
|
34
36
|
import { type ReactNode } from "react";
|
|
35
37
|
import { type Op } from "./match.js";
|
|
@@ -62,6 +64,15 @@ export type PaletteProps = {
|
|
|
62
64
|
height?: number;
|
|
63
65
|
/** The dialog's accessible name. */
|
|
64
66
|
title?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Take whatever was typed and answer it, when the list cannot.
|
|
69
|
+
*
|
|
70
|
+
* Supplied, the bar ends with one "Ask AI: …" row for any non-empty query, so
|
|
71
|
+
* a search that matches nothing is a question rather than a dead end. Absent,
|
|
72
|
+
* the bar behaves exactly as it did — a surface with nothing to ask does not
|
|
73
|
+
* grow a row that goes nowhere.
|
|
74
|
+
*/
|
|
75
|
+
onAsk?: (question: string) => void;
|
|
65
76
|
};
|
|
66
|
-
export declare function Palette({ open, onOpenChange, ops, onRun, active, onActive, search: controlled, onSearch, placeholder, empty, limit, children, footer, height, title, }: PaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
export declare function Palette({ open, onOpenChange, ops, onRun, active, onActive, search: controlled, onSearch, placeholder, empty, limit, children, footer, height, title, onAsk, }: PaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
67
78
|
//# sourceMappingURL=Palette.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Palette.d.ts","sourceRoot":"","sources":["../../src/product/Palette.tsx"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"Palette.d.ts","sourceRoot":"","sources":["../../src/product/Palette.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAA;AAWzD,OAAO,EAAmB,KAAK,EAAE,EAAE,MAAM,SAAS,CAAA;AAElD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,oEAAoE;IACpE,GAAG,EAAE,EAAE,EAAE,CAAA;IACT,0DAA0D;IAC1D,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,IAAI,CAAA;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC,CAAA;AAED,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EAAE,UAAU,EAClB,QAAQ,EACR,WAAgC,EAChC,KAA2B,EAC3B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAY,EACZ,KAAyB,EACzB,KAAK,GACN,EAAE,YAAY,2CA8Gd"}
|
package/dist/product/Palette.js
CHANGED
|
@@ -28,24 +28,33 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
28
28
|
* its personality: hanzo.app keeps its live project preview and console keeps its
|
|
29
29
|
* `>` AI mode by passing them, not by forking this.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
* the empty-query behaviour all live in `match.ts` as pure
|
|
33
|
-
* `shouldFilter` is off and the Command primitive is left holding
|
|
34
|
-
* the view — which is also what makes
|
|
31
|
+
* Which rows exist is `rows`. The safe-methods-browse rule, the per-group cap,
|
|
32
|
+
* the empty-query behaviour and the ask row all live in `match.ts` as pure
|
|
33
|
+
* functions, so `shouldFilter` is off and the Command primitive is left holding
|
|
34
|
+
* the cursor and the view — which is also what makes them testable without a
|
|
35
|
+
* DOM. This component renders into a portal, so a test cannot read its rows at
|
|
36
|
+
* all; a rule kept here instead would be a rule nothing can check.
|
|
35
37
|
*/
|
|
36
38
|
import { useMemo, useState } from "react";
|
|
37
39
|
import { SizableText, XStack, YStack } from "@hanzo/gui";
|
|
38
40
|
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "../backends/gui/index.js";
|
|
39
|
-
import { SAFE,
|
|
40
|
-
export function Palette({ open, onOpenChange, ops, onRun, active, onActive, search: controlled, onSearch, placeholder = "Search commands…", empty = "No results found.", limit, children, footer, height = 320, title = "Search commands", }) {
|
|
41
|
+
import { ASK, SAFE, rows } from "./match.js";
|
|
42
|
+
export function Palette({ open, onOpenChange, ops, onRun, active, onActive, search: controlled, onSearch, placeholder = "Search commands…", empty = "No results found.", limit, children, footer, height = 320, title = "Search commands", onAsk, }) {
|
|
41
43
|
const [own, setOwn] = useState("");
|
|
42
44
|
const search = controlled ?? own;
|
|
43
45
|
const setSearch = (s) => {
|
|
44
46
|
setOwn(s);
|
|
45
47
|
onSearch?.(s);
|
|
46
48
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const question = search.trim();
|
|
50
|
+
const groups = useMemo(() => rows(ops, search, limit, !!onAsk), [ops, search, limit, onAsk]);
|
|
51
|
+
const run = (op) => {
|
|
52
|
+
if (op.id === ASK && onAsk)
|
|
53
|
+
onAsk(question);
|
|
54
|
+
else
|
|
55
|
+
onRun(op);
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs(CommandDialog, { open: open, onOpenChange: onOpenChange, title: title, description: placeholder, value: active, onValueChange: onActive, shouldFilter: false, children: [_jsx(CommandInput, { value: search, onValueChange: setSearch, placeholder: placeholder, color: "$color", placeholderTextColor: "$color11" }), _jsxs(XStack, { minH: height, children: [_jsxs(CommandList, { maxH: height, width: children ? "50%" : "100%", borderRightWidth: children ? 1 : 0, borderColor: "$borderColor", pt: "$1", pb: "$4", children: [groups.length === 0 && (_jsx(CommandEmpty, { children: _jsx(SizableText, { color: "$color11", children: empty }) })), groups.map(([group, items]) => (_jsx(CommandGroup, { heading: group, children: items.map((op) => (_jsxs(CommandItem, { value: op.id, onSelect: () => run(op), gap: "$2", children: [op.icon, _jsxs(XStack, { flex: 1, items: "center", gap: "$2", overflow: "hidden", children: [_jsx(SizableText, { numberOfLines: 1, shrink: 0, children: op.label }), op.hint ? (_jsx(SizableText, { numberOfLines: 1, flex: 1, fontSize: "$1", color: "$color11", children: op.hint })) : null] }), _jsx(Method, { of: op }), op.end] }, op.id))) }, group)))] }), children ? _jsx(YStack, { width: "50%", children: children }) : null] }), footer ? (_jsx(XStack, { items: "center", gap: "$4", borderTopWidth: 1, borderColor: "$borderColor", px: "$3", py: "$2", children: footer })) : null] }));
|
|
49
58
|
}
|
|
50
59
|
/**
|
|
51
60
|
* The method, at the end of the row, for route commands only.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Palette.js","sourceRoot":"","sources":["../../src/product/Palette.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ
|
|
1
|
+
{"version":3,"file":"Palette.js","sourceRoot":"","sources":["../../src/product/Palette.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAW,MAAM,SAAS,CAAA;AA0ClD,MAAM,UAAU,OAAO,CAAC,EACtB,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,KAAK,EACL,MAAM,EACN,QAAQ,EACR,M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D,EACT,KAAC,MAAM,IAAC,EAAE,EAAE,EAAE,GAAI,EACjB,EAAE,CAAC,GAAG,KApBS,EAAE,CAAC,EAAE,CAqBT,CACf,CAAC,IAxBe,KAAK,CAyBT,CAChB,CAAC,IACU,EACb,QAAQ,CAAC,CAAC,CAAC,KAAC,MAAM,IAAC,KAAK,EAAC,KAAK,YAAE,QAAQ,GAAU,CAAC,CAAC,CAAC,IAAI,IACnD,EACR,MAAM,CAAC,CAAC,CAAC,CACR,KAAC,MAAM,IACL,KAAK,EAAC,QAAQ,EACd,GAAG,EAAC,IAAI,EACR,cAAc,EAAE,CAAC,EACjB,WAAW,EAAC,cAAc,EAC1B,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,YAEN,MAAM,GACA,CACV,CAAC,CAAC,CAAC,IAAI,IACM,CACjB,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,MAAM,CAAC,EAAE,EAAE,EAAc;IAChC,IAAI,EAAE,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IACxC,OAAO,CACL,KAAC,WAAW,IACV,MAAM,EAAE,CAAC,EACT,UAAU,EAAC,OAAO,EAClB,QAAQ,EAAE,EAAE,EACZ,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,YAEhD,EAAE,CAAC,MAAM,GACE,CACf,CAAA;AACH,CAAC"}
|
package/dist/product/match.cjs
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
'use client';"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.survivors = exports.match = exports.SAFE = void 0;
|
|
3
|
+
exports.rows = exports.survivors = exports.match = exports.askOp = exports.ASK_GROUP = exports.ASK = exports.SAFE = void 0;
|
|
4
4
|
const command_logic_1 = require("../backends/gui/command.logic.cjs");
|
|
5
5
|
/** The one method that is safe to stumble onto: no side effect, idempotent. */
|
|
6
6
|
exports.SAFE = 'GET';
|
|
7
|
+
/**
|
|
8
|
+
* The row that makes a question the answer when nothing else is.
|
|
9
|
+
*
|
|
10
|
+
* A command list is finite and a question is not, so "no results" is never the
|
|
11
|
+
* right end of a palette — the AI is the one thing that can take a query nobody
|
|
12
|
+
* indexed. Every Hanzo palette ends this way, and it must LOOK the same in all
|
|
13
|
+
* of them, so the label is built here rather than typed out per surface.
|
|
14
|
+
*
|
|
15
|
+
* It is a plain `Op`, which is why it needs nothing else: it files under its own
|
|
16
|
+
* group, carries no method (it runs in the page, not against a route), and
|
|
17
|
+
* reaches the host through the same `onRun` every other row uses.
|
|
18
|
+
*
|
|
19
|
+
* `@hanzogui/shell` states this same rule for the palettes it draws. The two
|
|
20
|
+
* cannot import from each other — shell is deliberately dependency-free so it
|
|
21
|
+
* drops into a Vite app with no provider, which is the whole reason it exists —
|
|
22
|
+
* so the string is asserted equal by test rather than shared by import.
|
|
23
|
+
*/
|
|
24
|
+
exports.ASK = 'ask';
|
|
25
|
+
exports.ASK_GROUP = 'Ask';
|
|
26
|
+
const askOp = (question) => ({
|
|
27
|
+
id: exports.ASK,
|
|
28
|
+
group: exports.ASK_GROUP,
|
|
29
|
+
label: `Ask AI: ${question}`,
|
|
30
|
+
});
|
|
31
|
+
exports.askOp = askOp;
|
|
7
32
|
/**
|
|
8
33
|
* Whether `op` survives `search`, and how well. `0` hides it.
|
|
9
34
|
*
|
|
@@ -74,3 +99,21 @@ const survivors = (ops, search, limit = 50) => {
|
|
|
74
99
|
return out;
|
|
75
100
|
};
|
|
76
101
|
exports.survivors = survivors;
|
|
102
|
+
/**
|
|
103
|
+
* What the bar actually shows: what survived the search, then the way out.
|
|
104
|
+
*
|
|
105
|
+
* The ask row is APPENDED rather than filtered. It answers the query by
|
|
106
|
+
* definition — its own label contains it — so putting it through `survivors`
|
|
107
|
+
* would score a row against itself, and the one row that must be present
|
|
108
|
+
* exactly when nothing else is would be at the mercy of the ranker.
|
|
109
|
+
*
|
|
110
|
+
* It lives here rather than in the component for the same reason every other
|
|
111
|
+
* rule about which rows exist does: `Palette` renders into a portal, so no test
|
|
112
|
+
* can read its rows, and a rule that cannot be tested is a rule that drifts.
|
|
113
|
+
*/
|
|
114
|
+
const rows = (ops, search, limit, canAsk = false) => {
|
|
115
|
+
const found = (0, exports.survivors)(ops, search, limit);
|
|
116
|
+
const question = search.trim();
|
|
117
|
+
return canAsk && question ? [...found, [exports.ASK_GROUP, [(0, exports.askOp)(question)]]] : found;
|
|
118
|
+
};
|
|
119
|
+
exports.rows = rows;
|
package/dist/product/match.d.ts
CHANGED
|
@@ -36,6 +36,26 @@ export interface Op {
|
|
|
36
36
|
}
|
|
37
37
|
/** The one method that is safe to stumble onto: no side effect, idempotent. */
|
|
38
38
|
export declare const SAFE = "GET";
|
|
39
|
+
/**
|
|
40
|
+
* The row that makes a question the answer when nothing else is.
|
|
41
|
+
*
|
|
42
|
+
* A command list is finite and a question is not, so "no results" is never the
|
|
43
|
+
* right end of a palette — the AI is the one thing that can take a query nobody
|
|
44
|
+
* indexed. Every Hanzo palette ends this way, and it must LOOK the same in all
|
|
45
|
+
* of them, so the label is built here rather than typed out per surface.
|
|
46
|
+
*
|
|
47
|
+
* It is a plain `Op`, which is why it needs nothing else: it files under its own
|
|
48
|
+
* group, carries no method (it runs in the page, not against a route), and
|
|
49
|
+
* reaches the host through the same `onRun` every other row uses.
|
|
50
|
+
*
|
|
51
|
+
* `@hanzogui/shell` states this same rule for the palettes it draws. The two
|
|
52
|
+
* cannot import from each other — shell is deliberately dependency-free so it
|
|
53
|
+
* drops into a Vite app with no provider, which is the whole reason it exists —
|
|
54
|
+
* so the string is asserted equal by test rather than shared by import.
|
|
55
|
+
*/
|
|
56
|
+
export declare const ASK = "ask";
|
|
57
|
+
export declare const ASK_GROUP = "Ask";
|
|
58
|
+
export declare const askOp: (question: string) => Op;
|
|
39
59
|
/**
|
|
40
60
|
* Whether `op` survives `search`, and how well. `0` hides it.
|
|
41
61
|
*
|
|
@@ -75,4 +95,17 @@ export declare const match: (op: Op, search: string) => number;
|
|
|
75
95
|
* be — the cap is what keeps one keystroke's cost bounded whatever was typed.
|
|
76
96
|
*/
|
|
77
97
|
export declare const survivors: (ops: Op[], search: string, limit?: number) => Array<[string, Op[]]>;
|
|
98
|
+
/**
|
|
99
|
+
* What the bar actually shows: what survived the search, then the way out.
|
|
100
|
+
*
|
|
101
|
+
* The ask row is APPENDED rather than filtered. It answers the query by
|
|
102
|
+
* definition — its own label contains it — so putting it through `survivors`
|
|
103
|
+
* would score a row against itself, and the one row that must be present
|
|
104
|
+
* exactly when nothing else is would be at the mercy of the ranker.
|
|
105
|
+
*
|
|
106
|
+
* It lives here rather than in the component for the same reason every other
|
|
107
|
+
* rule about which rows exist does: `Palette` renders into a portal, so no test
|
|
108
|
+
* can read its rows, and a rule that cannot be tested is a rule that drifts.
|
|
109
|
+
*/
|
|
110
|
+
export declare const rows: (ops: Op[], search: string, limit?: number, canAsk?: boolean) => Array<[string, Op[]]>;
|
|
78
111
|
//# sourceMappingURL=match.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/product/match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC;;;;;;;GAOG;AACH,MAAM,WAAW,EAAE;IACjB,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAA;IACV,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAA;IACb,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qCAAqC;IACrC,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,8DAA8D;IAC9D,GAAG,CAAC,EAAE,SAAS,C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AAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,EAAE,EAAE,EAAE,QAAQ,MAAM,EAAE,cAAU,KAAG,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAiBrF,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,EAAE,EAAE,EACT,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,gBAAc,KACb,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAItB,CAAA"}
|
package/dist/product/match.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
'use client';import { score } from '../backends/gui/command.logic.js';
|
|
2
2
|
/** The one method that is safe to stumble onto: no side effect, idempotent. */
|
|
3
3
|
export const SAFE = 'GET';
|
|
4
|
+
/**
|
|
5
|
+
* The row that makes a question the answer when nothing else is.
|
|
6
|
+
*
|
|
7
|
+
* A command list is finite and a question is not, so "no results" is never the
|
|
8
|
+
* right end of a palette — the AI is the one thing that can take a query nobody
|
|
9
|
+
* indexed. Every Hanzo palette ends this way, and it must LOOK the same in all
|
|
10
|
+
* of them, so the label is built here rather than typed out per surface.
|
|
11
|
+
*
|
|
12
|
+
* It is a plain `Op`, which is why it needs nothing else: it files under its own
|
|
13
|
+
* group, carries no method (it runs in the page, not against a route), and
|
|
14
|
+
* reaches the host through the same `onRun` every other row uses.
|
|
15
|
+
*
|
|
16
|
+
* `@hanzogui/shell` states this same rule for the palettes it draws. The two
|
|
17
|
+
* cannot import from each other — shell is deliberately dependency-free so it
|
|
18
|
+
* drops into a Vite app with no provider, which is the whole reason it exists —
|
|
19
|
+
* so the string is asserted equal by test rather than shared by import.
|
|
20
|
+
*/
|
|
21
|
+
export const ASK = 'ask';
|
|
22
|
+
export const ASK_GROUP = 'Ask';
|
|
23
|
+
export const askOp = (question) => ({
|
|
24
|
+
id: ASK,
|
|
25
|
+
group: ASK_GROUP,
|
|
26
|
+
label: `Ask AI: ${question}`,
|
|
27
|
+
});
|
|
4
28
|
/**
|
|
5
29
|
* Whether `op` survives `search`, and how well. `0` hides it.
|
|
6
30
|
*
|
|
@@ -69,4 +93,21 @@ export const survivors = (ops, search, limit = 50) => {
|
|
|
69
93
|
}
|
|
70
94
|
return out;
|
|
71
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* What the bar actually shows: what survived the search, then the way out.
|
|
98
|
+
*
|
|
99
|
+
* The ask row is APPENDED rather than filtered. It answers the query by
|
|
100
|
+
* definition — its own label contains it — so putting it through `survivors`
|
|
101
|
+
* would score a row against itself, and the one row that must be present
|
|
102
|
+
* exactly when nothing else is would be at the mercy of the ranker.
|
|
103
|
+
*
|
|
104
|
+
* It lives here rather than in the component for the same reason every other
|
|
105
|
+
* rule about which rows exist does: `Palette` renders into a portal, so no test
|
|
106
|
+
* can read its rows, and a rule that cannot be tested is a rule that drifts.
|
|
107
|
+
*/
|
|
108
|
+
export const rows = (ops, search, limit, canAsk = false) => {
|
|
109
|
+
const found = survivors(ops, search, limit);
|
|
110
|
+
const question = search.trim();
|
|
111
|
+
return canAsk && question ? [...found, [ASK_GROUP, [askOp(question)]]] : found;
|
|
112
|
+
};
|
|
72
113
|
//# sourceMappingURL=match.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/product/match.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AA2BrD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAM,EAAE,MAAc,EAAU,EAAE;IACtD,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACrC,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,KAAK,SAAS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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAClC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,GAAS,EACT,MAAc,EACd,KAAc,EACd,MAAM,GAAG,KAAK,EACS,EAAE;IACzB,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC9B,OAAO,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAChF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/ui",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.110",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Hanzo UI — the one canonical Hanzo component library, on @hanzo/gui + @hanzo/design. ONE substrate: every component renders through @hanzo/gui primitives, so the same import works on web, native (expo) and desktop (Tauri). Self-contained (theme.css), presentational, host-agnostic, clean-room.",
|
|
6
6
|
"exports": {
|