MCPcopy Create free account
hub / github.com/freecodexyz/free-code / SearchBox

Function SearchBox

src/components/SearchBox.tsx:14–71  ·  view source on GitHub ↗
(t0)

Source from the content-addressed store, hash-verified

12 borderless?: boolean;
13};
14export function SearchBox(t0) {
15 const $ = _c(17);
16 const {
17 query,
18 placeholder: t1,
19 isFocused,
20 isTerminalFocused,
21 prefix: t2,
22 width,
23 cursorOffset,
24 borderless: t3
25 } = t0;
26 const placeholder = t1 === undefined ? "Search\u2026" : t1;
27 const prefix = t2 === undefined ? "\u2315" : t2;
28 const borderless = t3 === undefined ? false : t3;
29 const offset = cursorOffset ?? query.length;
30 const t4 = borderless ? undefined : "round";
31 const t5 = isFocused ? "suggestion" : undefined;
32 const t6 = !isFocused;
33 const t7 = borderless ? 0 : 1;
34 const t8 = !isFocused;
35 let t9;
36 if ($[0] !== isFocused || $[1] !== isTerminalFocused || $[2] !== offset || $[3] !== placeholder || $[4] !== query) {
37 t9 = isFocused ? <>{query ? isTerminalFocused ? <><Text>{query.slice(0, offset)}</Text><Text inverse={true}>{offset < query.length ? query[offset] : " "}</Text>{offset < query.length && <Text>{query.slice(offset + 1)}</Text>}</> : <Text>{query}</Text> : isTerminalFocused ? <><Text inverse={true}>{placeholder.charAt(0)}</Text><Text dimColor={true}>{placeholder.slice(1)}</Text></> : <Text dimColor={true}>{placeholder}</Text>}</> : query ? <Text>{query}</Text> : <Text>{placeholder}</Text>;
38 $[0] = isFocused;
39 $[1] = isTerminalFocused;
40 $[2] = offset;
41 $[3] = placeholder;
42 $[4] = query;
43 $[5] = t9;
44 } else {
45 t9 = $[5];
46 }
47 let t10;
48 if ($[6] !== prefix || $[7] !== t8 || $[8] !== t9) {
49 t10 = <Text dimColor={t8}>{prefix}{" "}{t9}</Text>;
50 $[6] = prefix;
51 $[7] = t8;
52 $[8] = t9;
53 $[9] = t10;
54 } else {
55 t10 = $[9];
56 }
57 let t11;
58 if ($[10] !== t10 || $[11] !== t4 || $[12] !== t5 || $[13] !== t6 || $[14] !== t7 || $[15] !== width) {
59 t11 = <Box flexShrink={0} borderStyle={t4} borderColor={t5} borderDimColor={t6} paddingX={t7} width={width}>{t10}</Box>;
60 $[10] = t10;
61 $[11] = t4;
62 $[12] = t5;
63 $[13] = t6;
64 $[14] = t7;
65 $[15] = width;
66 $[16] = t11;
67 } else {
68 t11 = $[16];
69 }
70 return t11;
71}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected