@openrails/contentkit-ui 0.90.1 → 0.90.3

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/README.md CHANGED
@@ -738,10 +738,12 @@ access revision current; signed-out viewers do not fetch an inbox.
738
738
  ### Reader header controls
739
739
 
740
740
  `SearchBox` is an inline input with a downward suggestions/recent-search panel,
741
- including loading and empty states. Set `presentation="header"` for a full-width
742
- panel below the nearest semantic header (or the input): a dimmed backdrop, a
743
- centered text list with colored type icons and recent-search dates, and no
744
- thumbnails. Its mobile/desktop scroll limit is 70vh/60vh. The default inline
741
+ including loading and empty states. Set `presentation="header"` for a portal
742
+ panel directly below the input, matching its width and following it on resize
743
+ or scroll: a dimmed backdrop, text rows with colored type icons, and no
744
+ thumbnails. Recent-search dates appear when the panel is wide enough. The panel
745
+ slides downward when opened and honors reduced motion. Its mobile/desktop
746
+ scroll limit is 70vh/60vh. The default inline
745
747
  presentation is unchanged. Both presentations keep the provider's result order;
746
748
  the host owns search-page navigation.
747
749
  `ReaderSettings` combines language selection and content filters in one dialog:
@@ -16,7 +16,7 @@ export interface SearchBoxProps {
16
16
  labels?: Labels;
17
17
  /** The reader's recent searches while the box is empty. Default true. */
18
18
  recent?: boolean;
19
- /** Header-wide dropdown under the nearest header/banner; default stays inline. */
19
+ /** A portal dropdown anchored to the header field; default stays inline. */
20
20
  presentation?: "inline" | "header";
21
21
  client?: ContentKitClient;
22
22
  className?: string;
@@ -47,12 +47,23 @@ var D = {
47
47
  }
48
48
  };
49
49
  function O(e, t, n, r) {
50
- let [i, a] = f(0);
50
+ let [i, a] = f({
51
+ top: 0,
52
+ left: 0,
53
+ width: 0
54
+ });
51
55
  return l(() => {
52
56
  if (!e || !t || !n.current) return;
53
- let i = n.current.closest("header, [role=\"banner\"]") ?? r.current ?? n.current, o = n.current.ownerDocument.defaultView;
57
+ let i = r.current ?? n.current, o = n.current.ownerDocument.defaultView;
54
58
  if (!o) return;
55
- let s = () => a(Math.max(0, Math.min(o.innerHeight, i.getBoundingClientRect().bottom)));
59
+ let s = () => {
60
+ let e = i.getBoundingClientRect();
61
+ a({
62
+ top: Math.max(0, Math.min(o.innerHeight, e.bottom + 4)),
63
+ left: e.left,
64
+ width: e.width
65
+ });
66
+ };
56
67
  s();
57
68
  let c = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(s);
58
69
  return c?.observe(i), o.addEventListener("resize", s), o.addEventListener("scroll", s, !0), o.visualViewport?.addEventListener("resize", s), o.visualViewport?.addEventListener("scroll", s), () => {
@@ -75,22 +86,22 @@ function k({ kind: e }) {
75
86
  "aria-hidden": !0
76
87
  });
77
88
  }
78
- function A({ value: e, formatter: t }) {
89
+ function ne({ value: e, formatter: t }) {
79
90
  return !e || Number.isNaN(Date.parse(e)) ? null : /* @__PURE__ */ m("time", {
80
91
  dateTime: e,
81
92
  className: "shrink-0 text-xs text-muted-foreground",
82
93
  children: t.format(new Date(e))
83
94
  });
84
95
  }
85
- function j(l) {
86
- let { t: y, error: b, language: x } = t(), C = te(), w = c(r)?.navigate, [D, j] = f(l.defaultValue ?? ""), [M, N] = f(!1), [P, F] = f(-1), I = d(null), L = d(null), R = d(null), z = l.presentation === "header", B = O(M, z, I, R), V = u(() => new Intl.DateTimeFormat(x, { dateStyle: "short" }), [x]), H = !D.trim(), U = o(D, {
96
+ function A(l) {
97
+ let { t: y, error: b, language: x } = t(), C = te(), w = c(r)?.navigate, [D, A] = f(l.defaultValue ?? ""), [j, M] = f(!1), [N, P] = f(-1), F = d(null), I = d(null), L = d(null), R = l.presentation === "header", z = O(j, R, F, L), { top: B } = z, V = u(() => new Intl.DateTimeFormat(x, { dateStyle: "short" }), [x]), H = !D.trim(), U = o(D, {
87
98
  kind: l.kind,
88
99
  group_kinds: l.groupKinds,
89
100
  client: l.client
90
101
  }), W = a({
91
- enabled: l.recent !== !1 && M && H,
102
+ enabled: l.recent !== !1 && j && H,
92
103
  client: l.client
93
- }), ne = u(() => H ? W.searches.map((e) => ({
104
+ }), re = u(() => H ? W.searches.map((e) => ({
94
105
  type: "recent",
95
106
  query: e.query,
96
107
  searchedAt: e.searched_at
@@ -105,31 +116,31 @@ function j(l) {
105
116
  W.searches,
106
117
  U.contents,
107
118
  U.groups
108
- ]), G = H || U.query === D.trim(), K = G ? ne : [], q = K[P], re = H ? W.loading : !G || U.loading, J = H && l.recent !== !1, ie = H ? !z && J && !W.error ? "contents.noRecentSearches" : "contents.searchHint" : "contents.noResults";
119
+ ]), G = H || U.query === D.trim(), K = G ? re : [], q = K[N], ie = H ? W.loading : !G || U.loading, J = H && l.recent !== !1, ae = H ? !R && J && !W.error ? "contents.noRecentSearches" : "contents.searchHint" : "contents.noResults";
109
120
  ee(() => {
110
- if (!M) return;
121
+ if (!j) return;
111
122
  let e = (e) => {
112
- !I.current?.contains(e.target) && !L.current?.contains(e.target) && N(!1);
123
+ !F.current?.contains(e.target) && !I.current?.contains(e.target) && M(!1);
113
124
  };
114
125
  return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
115
- }, [M]);
126
+ }, [j]);
116
127
  let Y = () => {
117
- N(!0);
128
+ M(!0);
118
129
  }, X = (e) => {
119
- N(!1), e && l.onSearch(e);
130
+ M(!1), e && l.onSearch(e);
120
131
  }, Z = (e) => {
121
- if (e.type === "recent") return j(e.query), X(e.query);
132
+ if (e.type === "recent") return A(e.query), X(e.query);
122
133
  let t = l.href ? l.href(e.type === "content" ? e.card : e.group) : e.type === "content" ? e.card.path : e.group.path;
123
- N(!1), t && (w ? w(t) : location.assign(t));
134
+ M(!1), t && (w ? w(t) : location.assign(t));
124
135
  }, Q = (e) => {
125
- e.key === "Escape" && (e.preventDefault(), R.current?.focus(), N(!1), F(-1));
136
+ e.key === "Escape" && (e.preventDefault(), L.current?.focus(), M(!1), P(-1));
126
137
  }, $ = /* @__PURE__ */ h(p, { children: [
127
138
  J && /* @__PURE__ */ h("div", {
128
- className: g("flex items-center justify-between gap-2 text-muted-foreground", z ? "mb-4 text-base font-semibold" : "px-2 py-1 text-xs"),
139
+ className: g("flex items-center justify-between gap-2 text-muted-foreground", R ? "mb-4 text-base font-semibold" : "px-2 py-1 text-xs"),
129
140
  children: [/* @__PURE__ */ h("span", {
130
141
  id: `${C}-recent`,
131
142
  className: "flex items-center gap-2",
132
- children: [z && /* @__PURE__ */ m(T, {
143
+ children: [R && /* @__PURE__ */ m(T, {
133
144
  icon: v,
134
145
  strokeWidth: 2,
135
146
  className: "size-5",
@@ -142,26 +153,26 @@ function j(l) {
142
153
  e.preventDefault();
143
154
  },
144
155
  onClick: () => void W.clear(),
145
- children: y(z ? "contents.clearAllRecent" : "contents.clearRecent")
156
+ children: y(R ? "contents.clearAllRecent" : "contents.clearRecent")
146
157
  })]
147
158
  }),
148
159
  /* @__PURE__ */ m("ul", {
149
160
  id: `${C}-list`,
150
161
  role: "listbox",
151
162
  "aria-label": y(H ? "contents.recentSearches" : "contents.suggestions"),
152
- className: g("grid", z && "gap-2"),
163
+ className: g("grid", R && "gap-2"),
153
164
  children: K.map((t, n) => /* @__PURE__ */ m("li", {
154
165
  id: `${C}-${n}`,
155
166
  role: "option",
156
- "aria-selected": n === P,
167
+ "aria-selected": n === N,
157
168
  "data-ckui": "suggestion",
158
169
  "data-type": t.type,
159
- className: g("flex cursor-pointer items-center", z ? t.type === "recent" ? "gap-2 rounded-md p-3 text-base hover:bg-foreground/10" : "gap-3 rounded-md px-4 py-1 text-base font-medium hover:bg-foreground/10" : "gap-2 px-2 py-1.5", n === P && "bg-accent text-accent-foreground"),
160
- onMouseEnter: () => F(n),
170
+ className: g("flex cursor-pointer items-center", R ? t.type === "recent" ? "gap-2 rounded-md p-3 text-base hover:bg-foreground/10" : "gap-3 rounded-md px-4 py-1 text-base font-medium hover:bg-foreground/10" : "gap-2 px-2 py-1.5", n === N && "bg-accent text-accent-foreground"),
171
+ onMouseEnter: () => P(n),
161
172
  onMouseDown: (e) => {
162
173
  e.preventDefault(), Z(t);
163
174
  },
164
- children: z && t.type !== "recent" ? /* @__PURE__ */ h(p, { children: [
175
+ children: R && t.type !== "recent" ? /* @__PURE__ */ h(p, { children: [
165
176
  /* @__PURE__ */ m(k, { kind: t.type === "content" ? t.card.kind : t.group.kind }),
166
177
  /* @__PURE__ */ m("span", {
167
178
  className: "sr-only",
@@ -190,7 +201,7 @@ function j(l) {
190
201
  children: s(l.labels, t.group.kind)
191
202
  })] }) : /* @__PURE__ */ h(p, { children: [
192
203
  /* @__PURE__ */ m(T, {
193
- icon: z ? S : v,
204
+ icon: R ? S : v,
194
205
  strokeWidth: 2,
195
206
  className: "size-4 shrink-0 text-muted-foreground",
196
207
  "aria-hidden": !0
@@ -199,7 +210,7 @@ function j(l) {
199
210
  className: "min-w-0 flex-1 truncate",
200
211
  children: t.query
201
212
  }),
202
- z && /* @__PURE__ */ m(A, {
213
+ R && z.width >= 320 && /* @__PURE__ */ m(ne, {
203
214
  value: t.searchedAt,
204
215
  formatter: V
205
216
  }),
@@ -221,10 +232,10 @@ function j(l) {
221
232
  ] })
222
233
  }, t.type === "content" ? `c:${t.card.id}` : t.type === "group" ? `g:${t.group.id}` : `r:${t.query}`))
223
234
  }),
224
- re ? /* @__PURE__ */ m("div", {
235
+ ie ? /* @__PURE__ */ m("div", {
225
236
  role: "status",
226
- className: g("text-muted-foreground", z ? "flex justify-center py-4" : "px-3 py-2"),
227
- children: z ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", {
237
+ className: g("text-muted-foreground", R ? "flex justify-center py-4" : "px-3 py-2"),
238
+ children: R ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", {
228
239
  className: "size-6 animate-spin rounded-full border-2 border-muted border-t-foreground motion-reduce:animate-none",
229
240
  "aria-hidden": !0
230
241
  }), /* @__PURE__ */ m("span", {
@@ -233,36 +244,36 @@ function j(l) {
233
244
  })] }) : y("contents.loading")
234
245
  }) : !H && U.error ? /* @__PURE__ */ m("p", {
235
246
  role: "alert",
236
- className: g("px-3 py-2 text-destructive", z && "text-center"),
247
+ className: g("px-3 py-2 text-destructive", R && "text-center"),
237
248
  children: b(U.error)
238
249
  }) : K.length === 0 && /* @__PURE__ */ h("div", {
239
250
  role: "status",
240
- className: g("text-muted-foreground", z ? "flex flex-col items-center gap-2 py-8 text-center" : "px-3 py-2"),
241
- children: [z && /* @__PURE__ */ m(T, {
251
+ className: g("text-muted-foreground", R ? "flex flex-col items-center gap-2 py-8 text-center" : "px-3 py-2"),
252
+ children: [R && /* @__PURE__ */ m(T, {
242
253
  icon: S,
243
254
  strokeWidth: 2,
244
255
  className: "size-8",
245
256
  "aria-hidden": !0
246
- }), /* @__PURE__ */ m("p", { children: y(ie, { q: D.trim() }) })]
257
+ }), /* @__PURE__ */ m("p", { children: y(ae, { q: D.trim() }) })]
247
258
  })
248
259
  ] });
249
260
  return /* @__PURE__ */ h(n, {
250
- ref: I,
261
+ ref: F,
251
262
  appearance: l.appearance,
252
263
  className: g("relative text-sm", l.className),
253
264
  "data-ckui": "search-box",
254
265
  onBlur: (e) => {
255
- !e.currentTarget.contains(e.relatedTarget) && !L.current?.contains(e.relatedTarget) && N(!1);
266
+ !e.currentTarget.contains(e.relatedTarget) && !I.current?.contains(e.relatedTarget) && M(!1);
256
267
  },
257
268
  children: [/* @__PURE__ */ h("form", {
258
269
  role: "search",
259
270
  className: "relative",
260
271
  onSubmit: (e) => {
261
- if (e.preventDefault(), M && q) return Z(q);
272
+ if (e.preventDefault(), j && q) return Z(q);
262
273
  X(D.trim());
263
274
  },
264
275
  children: [
265
- z ? /* @__PURE__ */ m("button", {
276
+ R ? /* @__PURE__ */ m("button", {
266
277
  type: "submit",
267
278
  className: "absolute top-1/2 left-2.5 -translate-y-1/2 rounded text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",
268
279
  "aria-label": y("contents.search"),
@@ -279,38 +290,38 @@ function j(l) {
279
290
  "aria-hidden": !0
280
291
  }),
281
292
  /* @__PURE__ */ m(i, {
282
- ref: R,
283
- type: z ? "text" : "search",
293
+ ref: L,
294
+ type: R ? "text" : "search",
284
295
  role: "combobox",
285
296
  "aria-label": y("contents.search"),
286
- "aria-expanded": M,
297
+ "aria-expanded": j,
287
298
  "aria-controls": `${C}-list`,
288
- "aria-activedescendant": M && q ? `${C}-${P}` : void 0,
299
+ "aria-activedescendant": j && q ? `${C}-${N}` : void 0,
289
300
  "aria-autocomplete": "list",
290
301
  autoComplete: "off",
291
- className: g("h-9 ps-8", z && "rounded-full border-border/50 bg-foreground/10 pe-9 text-base shadow-none md:text-base"),
302
+ className: g("h-9 ps-8", R && "rounded-full border-border/50 bg-foreground/10 pe-9 text-base shadow-none md:text-base"),
292
303
  value: D,
293
304
  placeholder: l.placeholder ?? y("contents.searchPlaceholder"),
294
305
  onChange: (e) => {
295
- j(e.target.value), N(!0), F(-1);
306
+ A(e.target.value), M(!0), P(-1);
296
307
  },
297
308
  onFocus: Y,
298
309
  onClick: Y,
299
310
  onKeyDown: (e) => {
300
311
  if (e.key === "Escape") {
301
- e.preventDefault(), N(!1), F(-1);
312
+ e.preventDefault(), M(!1), P(-1);
302
313
  return;
303
314
  }
304
- e.key === "ArrowDown" ? (e.preventDefault(), Y(), F((e) => M ? Math.min(K.length - 1, e + 1) : 0)) : e.key === "ArrowUp" && M && (e.preventDefault(), F((e) => Math.max(-1, e - 1)));
315
+ e.key === "ArrowDown" ? (e.preventDefault(), Y(), P((e) => j ? Math.min(K.length - 1, e + 1) : 0)) : e.key === "ArrowUp" && j && (e.preventDefault(), P((e) => Math.max(-1, e - 1)));
305
316
  }
306
317
  }),
307
- z && (D || M) && /* @__PURE__ */ m("button", {
318
+ R && (D || j) && /* @__PURE__ */ m("button", {
308
319
  type: "button",
309
320
  className: "absolute top-1/2 right-2.5 -translate-y-1/2 rounded p-0.5 text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",
310
321
  "aria-label": y(D ? "contents.clearSearch" : "common.close"),
311
322
  onMouseDown: (e) => e.preventDefault(),
312
323
  onClick: () => {
313
- R.current?.focus(), F(-1), D ? (j(""), N(!0)) : N(!1);
324
+ L.current?.focus(), P(-1), D ? (A(""), M(!0)) : M(!1);
314
325
  },
315
326
  children: /* @__PURE__ */ m(T, {
316
327
  icon: _,
@@ -320,7 +331,7 @@ function j(l) {
320
331
  })
321
332
  })
322
333
  ]
323
- }), M && (z ? E(/* @__PURE__ */ h(n, {
334
+ }), j && (R ? E(/* @__PURE__ */ h(n, {
324
335
  appearance: l.appearance,
325
336
  className: "fixed inset-x-0 bottom-0 z-[70] text-sm",
326
337
  style: { top: B },
@@ -330,24 +341,25 @@ function j(l) {
330
341
  "data-ckui": "search-backdrop",
331
342
  "aria-hidden": !0
332
343
  }), /* @__PURE__ */ m("div", {
333
- ref: L,
334
- className: "relative w-full origin-top animate-in fade-in-0 slide-in-from-top-2 bg-background pt-1.5 text-foreground shadow-lg duration-200 ease-out motion-reduce:animate-none",
344
+ ref: I,
345
+ style: {
346
+ width: z.width,
347
+ marginLeft: z.left
348
+ },
349
+ className: "relative origin-top animate-[search-expand_300ms_ease-out] rounded-lg border border-border bg-background text-foreground shadow-lg transition-none motion-reduce:animate-none",
335
350
  "data-ckui": "search-panel",
336
351
  onKeyDown: Q,
337
352
  children: /* @__PURE__ */ m("div", {
338
- className: "mx-auto w-full max-w-[71rem] px-4 pt-5 md:px-[10%]",
353
+ className: "w-full px-3 pt-3",
339
354
  children: /* @__PURE__ */ m("div", {
340
355
  className: "[--search-max-height:70vh] overflow-y-auto pb-7 md:[--search-max-height:60vh]",
341
356
  style: { maxHeight: `min(var(--search-max-height), calc(100dvh - ${B}px - 1.875rem))` },
342
- children: /* @__PURE__ */ m("div", {
343
- className: H ? "px-4 py-4" : "px-4",
344
- children: $
345
- })
357
+ children: /* @__PURE__ */ m("div", { children: $ })
346
358
  })
347
359
  })
348
360
  })]
349
361
  }), document.body) : /* @__PURE__ */ m("div", {
350
- ref: L,
362
+ ref: I,
351
363
  className: "absolute top-full z-20 mt-1 grid max-h-96 w-full overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md",
352
364
  "data-ckui": "search-panel",
353
365
  onKeyDown: Q,
@@ -356,6 +368,6 @@ function j(l) {
356
368
  });
357
369
  }
358
370
  //#endregion
359
- export { j as SearchBox };
371
+ export { A as SearchBox };
360
372
 
361
373
  //# sourceMappingURL=search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","names":[],"sources":["../../../src/components/content/search.tsx"],"sourcesContent":["import { Cancel01Icon, Clock01Icon, File01Icon, Folder01Icon, Image01Icon, Search01Icon, TagsIcon, UserIcon } from \"@hugeicons/core-free-icons\";\nimport { HugeiconsIcon, type IconSvgElement } from \"@hugeicons/react\";\nimport { cn } from \"cn\";\nimport { useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type RefObject, type KeyboardEvent } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { ContentKitUiAppearance } from \"../../appearance.js\";\nimport type { ContentKitClient } from \"../../client/client.js\";\nimport type { Card, GroupCard } from \"../../client/generated/wire.js\";\nimport { useMessages } from \"../../i18n/context.js\";\nimport { ContentKitContext } from \"../../react/context.js\";\nimport { useRecentSearches, useTypeahead } from \"../../react/discovery.js\";\nimport { ContentKitUiRoot } from \"../../scope.js\";\nimport { Input } from \"#ckui/ui/input\";\nimport { RenditionImg } from \"../rendition-img.js\";\nimport { labelOf, type Labels } from \"../groups/parts.js\";\n\nexport interface SearchBoxProps {\n /** Submits the text: the host shows its search page. */\n onSearch: (q: string) => void;\n /** Suggest contents of this kind only. */\n kind?: string;\n /** The group kinds suggested; every kind with a page by default. */\n groupKinds?: readonly string[];\n defaultValue?: string;\n placeholder?: string;\n /** A suggestion's link; default its canonical path. */\n href?: (item: Card | GroupCard) => string | undefined;\n labels?: Labels;\n /** The reader's recent searches while the box is empty. Default true. */\n recent?: boolean;\n /** Header-wide dropdown under the nearest header/banner; default stays inline. */\n presentation?: \"inline\" | \"header\";\n client?: ContentKitClient;\n className?: string;\n appearance?: ContentKitUiAppearance;\n}\n\ntype Suggestion = { type: \"content\"; card: Card } | { type: \"group\"; group: GroupCard } | { type: \"recent\"; query: string; searchedAt?: string };\n\nconst TYPE_ICONS: Record<string, { icon: IconSvgElement; color: string }> = {\n artist: { icon: UserIcon, color: \"text-blue-500 dark:text-blue-400\" },\n series: { icon: Folder01Icon, color: \"text-yellow-600 dark:text-yellow-400\" },\n gallery: { icon: Image01Icon, color: \"text-green-600 dark:text-green-400\" },\n post: { icon: File01Icon, color: \"text-purple-500 dark:text-purple-400\" },\n blog: { icon: File01Icon, color: \"text-purple-500 dark:text-purple-400\" },\n poll: { icon: File01Icon, color: \"text-purple-500 dark:text-purple-400\" },\n character: { icon: UserIcon, color: \"text-purple-500 dark:text-purple-400\" },\n tag: { icon: TagsIcon, color: \"text-orange-500 dark:text-orange-400\" },\n};\n\nfunction useHeaderTop(open: boolean, enabled: boolean, root: RefObject<HTMLDivElement | null>, input: RefObject<HTMLInputElement | null>): number {\n const [top, setTop] = useState(0);\n useLayoutEffect(() => {\n if (!open || !enabled || !root.current) return;\n const anchor = root.current.closest('header, [role=\"banner\"]') ?? input.current ?? root.current;\n const view = root.current.ownerDocument.defaultView;\n if (!view) return;\n const measure = () => setTop(Math.max(0, Math.min(view.innerHeight, anchor.getBoundingClientRect().bottom)));\n measure();\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(measure);\n observer?.observe(anchor);\n view.addEventListener(\"resize\", measure);\n view.addEventListener(\"scroll\", measure, true);\n view.visualViewport?.addEventListener(\"resize\", measure);\n view.visualViewport?.addEventListener(\"scroll\", measure);\n return () => {\n observer?.disconnect();\n view.removeEventListener(\"resize\", measure);\n view.removeEventListener(\"scroll\", measure, true);\n view.visualViewport?.removeEventListener(\"resize\", measure);\n view.visualViewport?.removeEventListener(\"scroll\", measure);\n };\n }, [open, enabled, root, input]);\n return top;\n}\n\nfunction SearchTypeIcon({ kind }: { kind: string }) {\n const type = TYPE_ICONS[kind];\n return <HugeiconsIcon icon={type?.icon ?? Search01Icon} strokeWidth={2} className={cn(\"size-4 shrink-0\", type?.color ?? \"text-muted-foreground\")} data-search-kind={kind} aria-hidden />;\n}\n\nfunction SearchDate({ value, formatter }: { value?: string; formatter: Intl.DateTimeFormat }) {\n if (!value || Number.isNaN(Date.parse(value))) return null;\n return <time dateTime={value} className=\"shrink-0 text-xs text-muted-foreground\">{formatter.format(new Date(value))}</time>;\n}\n\n/**\n * A search field suggesting contents and groups as the reader types, and\n * recent searches while it is empty; Enter searches, or opens the suggestion chosen.\n */\nexport function SearchBox(p: SearchBoxProps) {\n const { t, error, language } = useMessages();\n const id = useId();\n const navigate = useContext(ContentKitContext)?.navigate;\n const [text, setText] = useState(p.defaultValue ?? \"\");\n const [open, setOpen] = useState(false);\n const [active, setActive] = useState(-1);\n const root = useRef<HTMLDivElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const header = p.presentation === \"header\";\n const top = useHeaderTop(open, header, root, input);\n const dates = useMemo(() => new Intl.DateTimeFormat(language, { dateStyle: \"short\" }), [language]);\n const empty = !text.trim();\n const found = useTypeahead(text, { kind: p.kind, group_kinds: p.groupKinds, client: p.client });\n const recent = useRecentSearches({ enabled: p.recent !== false && open && empty, client: p.client });\n const items = useMemo<Suggestion[]>(\n () =>\n empty\n ? recent.searches.map((r) => ({ type: \"recent\" as const, query: r.query, searchedAt: r.searched_at }))\n : [...found.contents.map((card) => ({ type: \"content\" as const, card })), ...found.groups.map((group) => ({ type: \"group\" as const, group }))],\n [empty, recent.searches, found.contents, found.groups],\n );\n const current = empty || found.query === text.trim();\n const visible = current ? items : [];\n const selected = visible[active];\n const loading = empty ? recent.loading : !current || found.loading;\n const showRecent = empty && p.recent !== false;\n const emptyMessage = empty ? !header && showRecent && !recent.error ? \"contents.noRecentSearches\" : \"contents.searchHint\" : \"contents.noResults\";\n useEffect(() => {\n if (!open) return;\n const outside = (event: PointerEvent) => {\n if (!root.current?.contains(event.target as Node) && !panel.current?.contains(event.target as Node)) setOpen(false);\n };\n document.addEventListener(\"pointerdown\", outside);\n return () => document.removeEventListener(\"pointerdown\", outside);\n }, [open]);\n const reveal = () => {\n setOpen(true);\n };\n const search = (q: string) => {\n setOpen(false);\n if (q) p.onSearch(q);\n };\n const go = (s: Suggestion) => {\n if (s.type === \"recent\") {\n setText(s.query);\n return search(s.query);\n }\n const url = p.href ? p.href(s.type === \"content\" ? s.card : s.group) : s.type === \"content\" ? s.card.path : s.group.path;\n setOpen(false);\n if (!url) return;\n if (navigate) navigate(url);\n else location.assign(url);\n };\n const panelKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n input.current?.focus();\n setOpen(false);\n setActive(-1);\n };\n const results = (<>\n {showRecent && (\n <div className={cn(\"flex items-center justify-between gap-2 text-muted-foreground\", header ? \"mb-4 text-base font-semibold\" : \"px-2 py-1 text-xs\")}>\n <span id={`${id}-recent`} className=\"flex items-center gap-2\">{header && <HugeiconsIcon icon={Clock01Icon} strokeWidth={2} className=\"size-5\" aria-hidden />}{t(\"contents.recentSearches\")}</span>\n {visible.length > 0 && <button\n type=\"button\"\n className=\"rounded px-1 hover:text-foreground\"\n onMouseDown={(e) => {\n e.preventDefault();\n }}\n onClick={() => void recent.clear()}\n >\n {t(header ? \"contents.clearAllRecent\" : \"contents.clearRecent\")}\n </button>}\n </div>\n )}\n <ul id={`${id}-list`} role=\"listbox\" aria-label={empty ? t(\"contents.recentSearches\") : t(\"contents.suggestions\")} className={cn(\"grid\", header && \"gap-2\")}>\n {visible.map((s, i) => (\n <li\n key={s.type === \"content\" ? `c:${s.card.id}` : s.type === \"group\" ? `g:${s.group.id}` : `r:${s.query}`}\n id={`${id}-${i}`}\n role=\"option\"\n aria-selected={i === active}\n data-ckui=\"suggestion\"\n data-type={s.type}\n className={cn(\"flex cursor-pointer items-center\", header ? s.type === \"recent\" ? \"gap-2 rounded-md p-3 text-base hover:bg-foreground/10\" : \"gap-3 rounded-md px-4 py-1 text-base font-medium hover:bg-foreground/10\" : \"gap-2 px-2 py-1.5\", i === active && \"bg-accent text-accent-foreground\")}\n onMouseEnter={() => setActive(i)}\n onMouseDown={(e) => {\n e.preventDefault();\n go(s);\n }}\n >\n {header && s.type !== \"recent\" ? (\n <>\n <SearchTypeIcon kind={s.type === \"content\" ? s.card.kind : s.group.kind} />\n <span className=\"sr-only\">{labelOf(p.labels, s.type === \"content\" ? s.card.kind : s.group.kind)}</span>\n <span className=\"min-w-0 flex-1 truncate\">{s.type === \"content\" ? s.card.title || s.card.code : s.group.name || s.group.slug}</span>\n </>\n ) : s.type === \"content\" ? (\n <>\n <span className=\"h-10 w-8 shrink-0 overflow-hidden rounded bg-muted\">\n <RenditionImg outputs={s.card.cover} alt=\"\" fit=\"cover\" className=\"size-full\" />\n </span>\n <span className=\"min-w-0 truncate\">{s.card.title || s.card.code}</span>\n </>\n ) : s.type === \"group\" ? (\n <>\n <span className=\"min-w-0 flex-1 truncate\">{s.group.name || s.group.slug}</span>\n <span className=\"text-xs text-muted-foreground\">{labelOf(p.labels, s.group.kind)}</span>\n </>\n ) : (\n <>\n <HugeiconsIcon icon={header ? Search01Icon : Clock01Icon} strokeWidth={2} className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"min-w-0 flex-1 truncate\">{s.query}</span>\n {header && <SearchDate value={s.searchedAt} formatter={dates} />}\n <button\n type=\"button\"\n className=\"rounded p-0.5 text-muted-foreground hover:text-foreground\"\n aria-label={t(\"contents.removeRecent\", { q: s.query })}\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onClick={() => void recent.clear(s.query)}\n >\n <HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className=\"size-3.5\" aria-hidden />\n </button>\n </>\n )}\n </li>\n ))}\n </ul>\n {loading ? <div role=\"status\" className={cn(\"text-muted-foreground\", header ? \"flex justify-center py-4\" : \"px-3 py-2\")}>{header ? <><span className=\"size-6 animate-spin rounded-full border-2 border-muted border-t-foreground motion-reduce:animate-none\" aria-hidden /><span className=\"sr-only\">{t(\"contents.loading\")}</span></> : t(\"contents.loading\")}</div>\n : !empty && found.error ? <p role=\"alert\" className={cn(\"px-3 py-2 text-destructive\", header && \"text-center\")}>{error(found.error)}</p>\n : visible.length === 0 && <div role=\"status\" className={cn(\"text-muted-foreground\", header ? \"flex flex-col items-center gap-2 py-8 text-center\" : \"px-3 py-2\")}>{header && <HugeiconsIcon icon={Search01Icon} strokeWidth={2} className=\"size-8\" aria-hidden />}<p>{t(emptyMessage, { q: text.trim() })}</p></div>}\n </>);\n return (\n <ContentKitUiRoot ref={root} appearance={p.appearance} className={cn(\"relative text-sm\", p.className)} data-ckui=\"search-box\" onBlur={(event) => { if (!event.currentTarget.contains(event.relatedTarget) && !panel.current?.contains(event.relatedTarget)) setOpen(false); }}>\n <form\n role=\"search\"\n className=\"relative\"\n onSubmit={(e) => {\n e.preventDefault();\n if (open && selected) return go(selected);\n search(text.trim());\n }}\n >\n {header ? <button type=\"submit\" className=\"absolute top-1/2 left-2.5 -translate-y-1/2 rounded text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring\" aria-label={t(\"contents.search\")}><HugeiconsIcon icon={Search01Icon} strokeWidth={2} className=\"size-4\" aria-hidden /></button>\n : <HugeiconsIcon icon={Search01Icon} strokeWidth={2} className=\"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground\" aria-hidden />}\n <Input\n ref={input}\n type={header ? \"text\" : \"search\"}\n role=\"combobox\"\n aria-label={t(\"contents.search\")}\n aria-expanded={open}\n aria-controls={`${id}-list`}\n aria-activedescendant={open && selected ? `${id}-${active}` : undefined}\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n className={cn(\"h-9 ps-8\", header && \"rounded-full border-border/50 bg-foreground/10 pe-9 text-base shadow-none md:text-base\")}\n value={text}\n placeholder={p.placeholder ?? t(\"contents.searchPlaceholder\")}\n onChange={(e) => {\n setText(e.target.value);\n setOpen(true);\n setActive(-1);\n }}\n onFocus={reveal}\n onClick={reveal}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n setOpen(false);\n setActive(-1);\n return;\n }\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n reveal();\n setActive((a) => open ? Math.min(visible.length - 1, a + 1) : 0);\n } else if (e.key === \"ArrowUp\" && open) {\n e.preventDefault();\n setActive((a) => Math.max(-1, a - 1));\n }\n }}\n />\n {header && (text || open) && (\n <button\n type=\"button\"\n className=\"absolute top-1/2 right-2.5 -translate-y-1/2 rounded p-0.5 text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring\"\n aria-label={text ? t(\"contents.clearSearch\") : t(\"common.close\")}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n input.current?.focus();\n setActive(-1);\n if (text) { setText(\"\"); setOpen(true); }\n else setOpen(false);\n }}\n ><HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className=\"size-4\" aria-hidden /></button>\n )}\n </form>\n {open && (header ? createPortal(\n <ContentKitUiRoot appearance={p.appearance} className=\"fixed inset-x-0 bottom-0 z-[70] text-sm\" style={{ top }} data-ckui=\"search-layer\">\n <div className=\"absolute inset-0 bg-black/30 backdrop-blur-sm\" data-ckui=\"search-backdrop\" aria-hidden />\n <div ref={panel} className=\"relative w-full origin-top animate-in fade-in-0 slide-in-from-top-2 bg-background pt-1.5 text-foreground shadow-lg duration-200 ease-out motion-reduce:animate-none\" data-ckui=\"search-panel\" onKeyDown={panelKeyDown}>\n <div className=\"mx-auto w-full max-w-[71rem] px-4 pt-5 md:px-[10%]\">\n <div className=\"[--search-max-height:70vh] overflow-y-auto pb-7 md:[--search-max-height:60vh]\" style={{ maxHeight: `min(var(--search-max-height), calc(100dvh - ${top}px - 1.875rem))` }}>\n <div className={empty ? \"px-4 py-4\" : \"px-4\"}>{results}</div>\n </div>\n </div>\n </div>\n </ContentKitUiRoot>, document.body,\n ) : <div ref={panel} className=\"absolute top-full z-20 mt-1 grid max-h-96 w-full overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md\" data-ckui=\"search-panel\" onKeyDown={panelKeyDown}>{results}</div>)}\n\n </ContentKitUiRoot>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAuCA,IAAM,IAAsE;CAC1E,QAAQ;EAAE,MAAM;EAAU,OAAO;CAAmC;CACpE,QAAQ;EAAE,MAAM;EAAc,OAAO;CAAuC;CAC5E,SAAS;EAAE,MAAM;EAAa,OAAO;CAAqC;CAC1E,MAAM;EAAE,MAAM;EAAY,OAAO;CAAuC;CACxE,MAAM;EAAE,MAAM;EAAY,OAAO;CAAuC;CACxE,MAAM;EAAE,MAAM;EAAY,OAAO;CAAuC;CACxE,WAAW;EAAE,MAAM;EAAU,OAAO;CAAuC;CAC3E,KAAK;EAAE,MAAM;EAAU,OAAO;CAAuC;AACvE;AAEA,SAAS,EAAa,GAAe,GAAkB,GAAwC,GAAmD;CAChJ,IAAM,CAAC,GAAK,KAAU,EAAS,CAAC;CAsBhC,OArBA,QAAsB;EACpB,IAAI,CAAC,KAAQ,CAAC,KAAW,CAAC,EAAK,SAAS;EACxC,IAAM,IAAS,EAAK,QAAQ,QAAQ,2BAAyB,KAAK,EAAM,WAAW,EAAK,SAClF,IAAO,EAAK,QAAQ,cAAc;EACxC,IAAI,CAAC,GAAM;EACX,IAAM,UAAgB,EAAO,KAAK,IAAI,GAAG,KAAK,IAAI,EAAK,aAAa,EAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;EAC3G,EAAQ;EACR,IAAM,IAAW,OAAO,iBAAmB,MAAc,KAAA,IAAY,IAAI,eAAe,CAAO;EAM/F,OALA,GAAU,QAAQ,CAAM,GACxB,EAAK,iBAAiB,UAAU,CAAO,GACvC,EAAK,iBAAiB,UAAU,GAAS,EAAI,GAC7C,EAAK,gBAAgB,iBAAiB,UAAU,CAAO,GACvD,EAAK,gBAAgB,iBAAiB,UAAU,CAAO,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,WAAW;GAAe,UAAA;EAAa,CAAA,EAElO;;AAEtB"}
1
+ {"version":3,"file":"search.js","names":[],"sources":["../../../src/components/content/search.tsx"],"sourcesContent":["import { Cancel01Icon, Clock01Icon, File01Icon, Folder01Icon, Image01Icon, Search01Icon, TagsIcon, UserIcon } from \"@hugeicons/core-free-icons\";\nimport { HugeiconsIcon, type IconSvgElement } from \"@hugeicons/react\";\nimport { cn } from \"cn\";\nimport { useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type RefObject, type KeyboardEvent } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { ContentKitUiAppearance } from \"../../appearance.js\";\nimport type { ContentKitClient } from \"../../client/client.js\";\nimport type { Card, GroupCard } from \"../../client/generated/wire.js\";\nimport { useMessages } from \"../../i18n/context.js\";\nimport { ContentKitContext } from \"../../react/context.js\";\nimport { useRecentSearches, useTypeahead } from \"../../react/discovery.js\";\nimport { ContentKitUiRoot } from \"../../scope.js\";\nimport { Input } from \"#ckui/ui/input\";\nimport { RenditionImg } from \"../rendition-img.js\";\nimport { labelOf, type Labels } from \"../groups/parts.js\";\n\nexport interface SearchBoxProps {\n /** Submits the text: the host shows its search page. */\n onSearch: (q: string) => void;\n /** Suggest contents of this kind only. */\n kind?: string;\n /** The group kinds suggested; every kind with a page by default. */\n groupKinds?: readonly string[];\n defaultValue?: string;\n placeholder?: string;\n /** A suggestion's link; default its canonical path. */\n href?: (item: Card | GroupCard) => string | undefined;\n labels?: Labels;\n /** The reader's recent searches while the box is empty. Default true. */\n recent?: boolean;\n /** A portal dropdown anchored to the header field; default stays inline. */\n presentation?: \"inline\" | \"header\";\n client?: ContentKitClient;\n className?: string;\n appearance?: ContentKitUiAppearance;\n}\n\ntype Suggestion = { type: \"content\"; card: Card } | { type: \"group\"; group: GroupCard } | { type: \"recent\"; query: string; searchedAt?: string };\n\nconst TYPE_ICONS: Record<string, { icon: IconSvgElement; color: string }> = {\n artist: { icon: UserIcon, color: \"text-blue-500 dark:text-blue-400\" },\n series: { icon: Folder01Icon, color: \"text-yellow-600 dark:text-yellow-400\" },\n gallery: { icon: Image01Icon, color: \"text-green-600 dark:text-green-400\" },\n post: { icon: File01Icon, color: \"text-purple-500 dark:text-purple-400\" },\n blog: { icon: File01Icon, color: \"text-purple-500 dark:text-purple-400\" },\n poll: { icon: File01Icon, color: \"text-purple-500 dark:text-purple-400\" },\n character: { icon: UserIcon, color: \"text-purple-500 dark:text-purple-400\" },\n tag: { icon: TagsIcon, color: \"text-orange-500 dark:text-orange-400\" },\n};\n\nfunction useHeaderAnchor(open: boolean, enabled: boolean, root: RefObject<HTMLDivElement | null>, input: RefObject<HTMLInputElement | null>) {\n const [position, setPosition] = useState({ top: 0, left: 0, width: 0 });\n useLayoutEffect(() => {\n if (!open || !enabled || !root.current) return;\n const anchor = input.current ?? root.current;\n const view = root.current.ownerDocument.defaultView;\n if (!view) return;\n const measure = () => {\n const rect = anchor.getBoundingClientRect();\n setPosition({ top: Math.max(0, Math.min(view.innerHeight, rect.bottom + 4)), left: rect.left, width: rect.width });\n };\n measure();\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(measure);\n observer?.observe(anchor);\n view.addEventListener(\"resize\", measure);\n view.addEventListener(\"scroll\", measure, true);\n view.visualViewport?.addEventListener(\"resize\", measure);\n view.visualViewport?.addEventListener(\"scroll\", measure);\n return () => {\n observer?.disconnect();\n view.removeEventListener(\"resize\", measure);\n view.removeEventListener(\"scroll\", measure, true);\n view.visualViewport?.removeEventListener(\"resize\", measure);\n view.visualViewport?.removeEventListener(\"scroll\", measure);\n };\n }, [open, enabled, root, input]);\n return position;\n}\n\nfunction SearchTypeIcon({ kind }: { kind: string }) {\n const type = TYPE_ICONS[kind];\n return <HugeiconsIcon icon={type?.icon ?? Search01Icon} strokeWidth={2} className={cn(\"size-4 shrink-0\", type?.color ?? \"text-muted-foreground\")} data-search-kind={kind} aria-hidden />;\n}\n\nfunction SearchDate({ value, formatter }: { value?: string; formatter: Intl.DateTimeFormat }) {\n if (!value || Number.isNaN(Date.parse(value))) return null;\n return <time dateTime={value} className=\"shrink-0 text-xs text-muted-foreground\">{formatter.format(new Date(value))}</time>;\n}\n\n/**\n * A search field suggesting contents and groups as the reader types, and\n * recent searches while it is empty; Enter searches, or opens the suggestion chosen.\n */\nexport function SearchBox(p: SearchBoxProps) {\n const { t, error, language } = useMessages();\n const id = useId();\n const navigate = useContext(ContentKitContext)?.navigate;\n const [text, setText] = useState(p.defaultValue ?? \"\");\n const [open, setOpen] = useState(false);\n const [active, setActive] = useState(-1);\n const root = useRef<HTMLDivElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const header = p.presentation === \"header\";\n const anchor = useHeaderAnchor(open, header, root, input);\n const { top } = anchor;\n const dates = useMemo(() => new Intl.DateTimeFormat(language, { dateStyle: \"short\" }), [language]);\n const empty = !text.trim();\n const found = useTypeahead(text, { kind: p.kind, group_kinds: p.groupKinds, client: p.client });\n const recent = useRecentSearches({ enabled: p.recent !== false && open && empty, client: p.client });\n const items = useMemo<Suggestion[]>(\n () =>\n empty\n ? recent.searches.map((r) => ({ type: \"recent\" as const, query: r.query, searchedAt: r.searched_at }))\n : [...found.contents.map((card) => ({ type: \"content\" as const, card })), ...found.groups.map((group) => ({ type: \"group\" as const, group }))],\n [empty, recent.searches, found.contents, found.groups],\n );\n const current = empty || found.query === text.trim();\n const visible = current ? items : [];\n const selected = visible[active];\n const loading = empty ? recent.loading : !current || found.loading;\n const showRecent = empty && p.recent !== false;\n const emptyMessage = empty ? !header && showRecent && !recent.error ? \"contents.noRecentSearches\" : \"contents.searchHint\" : \"contents.noResults\";\n useEffect(() => {\n if (!open) return;\n const outside = (event: PointerEvent) => {\n if (!root.current?.contains(event.target as Node) && !panel.current?.contains(event.target as Node)) setOpen(false);\n };\n document.addEventListener(\"pointerdown\", outside);\n return () => document.removeEventListener(\"pointerdown\", outside);\n }, [open]);\n const reveal = () => {\n setOpen(true);\n };\n const search = (q: string) => {\n setOpen(false);\n if (q) p.onSearch(q);\n };\n const go = (s: Suggestion) => {\n if (s.type === \"recent\") {\n setText(s.query);\n return search(s.query);\n }\n const url = p.href ? p.href(s.type === \"content\" ? s.card : s.group) : s.type === \"content\" ? s.card.path : s.group.path;\n setOpen(false);\n if (!url) return;\n if (navigate) navigate(url);\n else location.assign(url);\n };\n const panelKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n input.current?.focus();\n setOpen(false);\n setActive(-1);\n };\n const results = (<>\n {showRecent && (\n <div className={cn(\"flex items-center justify-between gap-2 text-muted-foreground\", header ? \"mb-4 text-base font-semibold\" : \"px-2 py-1 text-xs\")}>\n <span id={`${id}-recent`} className=\"flex items-center gap-2\">{header && <HugeiconsIcon icon={Clock01Icon} strokeWidth={2} className=\"size-5\" aria-hidden />}{t(\"contents.recentSearches\")}</span>\n {visible.length > 0 && <button\n type=\"button\"\n className=\"rounded px-1 hover:text-foreground\"\n onMouseDown={(e) => {\n e.preventDefault();\n }}\n onClick={() => void recent.clear()}\n >\n {t(header ? \"contents.clearAllRecent\" : \"contents.clearRecent\")}\n </button>}\n </div>\n )}\n <ul id={`${id}-list`} role=\"listbox\" aria-label={empty ? t(\"contents.recentSearches\") : t(\"contents.suggestions\")} className={cn(\"grid\", header && \"gap-2\")}>\n {visible.map((s, i) => (\n <li\n key={s.type === \"content\" ? `c:${s.card.id}` : s.type === \"group\" ? `g:${s.group.id}` : `r:${s.query}`}\n id={`${id}-${i}`}\n role=\"option\"\n aria-selected={i === active}\n data-ckui=\"suggestion\"\n data-type={s.type}\n className={cn(\"flex cursor-pointer items-center\", header ? s.type === \"recent\" ? \"gap-2 rounded-md p-3 text-base hover:bg-foreground/10\" : \"gap-3 rounded-md px-4 py-1 text-base font-medium hover:bg-foreground/10\" : \"gap-2 px-2 py-1.5\", i === active && \"bg-accent text-accent-foreground\")}\n onMouseEnter={() => setActive(i)}\n onMouseDown={(e) => {\n e.preventDefault();\n go(s);\n }}\n >\n {header && s.type !== \"recent\" ? (\n <>\n <SearchTypeIcon kind={s.type === \"content\" ? s.card.kind : s.group.kind} />\n <span className=\"sr-only\">{labelOf(p.labels, s.type === \"content\" ? s.card.kind : s.group.kind)}</span>\n <span className=\"min-w-0 flex-1 truncate\">{s.type === \"content\" ? s.card.title || s.card.code : s.group.name || s.group.slug}</span>\n </>\n ) : s.type === \"content\" ? (\n <>\n <span className=\"h-10 w-8 shrink-0 overflow-hidden rounded bg-muted\">\n <RenditionImg outputs={s.card.cover} alt=\"\" fit=\"cover\" className=\"size-full\" />\n </span>\n <span className=\"min-w-0 truncate\">{s.card.title || s.card.code}</span>\n </>\n ) : s.type === \"group\" ? (\n <>\n <span className=\"min-w-0 flex-1 truncate\">{s.group.name || s.group.slug}</span>\n <span className=\"text-xs text-muted-foreground\">{labelOf(p.labels, s.group.kind)}</span>\n </>\n ) : (\n <>\n <HugeiconsIcon icon={header ? Search01Icon : Clock01Icon} strokeWidth={2} className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"min-w-0 flex-1 truncate\">{s.query}</span>\n {header && anchor.width >= 320 && <SearchDate value={s.searchedAt} formatter={dates} />}\n <button\n type=\"button\"\n className=\"rounded p-0.5 text-muted-foreground hover:text-foreground\"\n aria-label={t(\"contents.removeRecent\", { q: s.query })}\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onClick={() => void recent.clear(s.query)}\n >\n <HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className=\"size-3.5\" aria-hidden />\n </button>\n </>\n )}\n </li>\n ))}\n </ul>\n {loading ? <div role=\"status\" className={cn(\"text-muted-foreground\", header ? \"flex justify-center py-4\" : \"px-3 py-2\")}>{header ? <><span className=\"size-6 animate-spin rounded-full border-2 border-muted border-t-foreground motion-reduce:animate-none\" aria-hidden /><span className=\"sr-only\">{t(\"contents.loading\")}</span></> : t(\"contents.loading\")}</div>\n : !empty && found.error ? <p role=\"alert\" className={cn(\"px-3 py-2 text-destructive\", header && \"text-center\")}>{error(found.error)}</p>\n : visible.length === 0 && <div role=\"status\" className={cn(\"text-muted-foreground\", header ? \"flex flex-col items-center gap-2 py-8 text-center\" : \"px-3 py-2\")}>{header && <HugeiconsIcon icon={Search01Icon} strokeWidth={2} className=\"size-8\" aria-hidden />}<p>{t(emptyMessage, { q: text.trim() })}</p></div>}\n </>);\n return (\n <ContentKitUiRoot ref={root} appearance={p.appearance} className={cn(\"relative text-sm\", p.className)} data-ckui=\"search-box\" onBlur={(event) => { if (!event.currentTarget.contains(event.relatedTarget) && !panel.current?.contains(event.relatedTarget)) setOpen(false); }}>\n <form\n role=\"search\"\n className=\"relative\"\n onSubmit={(e) => {\n e.preventDefault();\n if (open && selected) return go(selected);\n search(text.trim());\n }}\n >\n {header ? <button type=\"submit\" className=\"absolute top-1/2 left-2.5 -translate-y-1/2 rounded text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring\" aria-label={t(\"contents.search\")}><HugeiconsIcon icon={Search01Icon} strokeWidth={2} className=\"size-4\" aria-hidden /></button>\n : <HugeiconsIcon icon={Search01Icon} strokeWidth={2} className=\"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground\" aria-hidden />}\n <Input\n ref={input}\n type={header ? \"text\" : \"search\"}\n role=\"combobox\"\n aria-label={t(\"contents.search\")}\n aria-expanded={open}\n aria-controls={`${id}-list`}\n aria-activedescendant={open && selected ? `${id}-${active}` : undefined}\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n className={cn(\"h-9 ps-8\", header && \"rounded-full border-border/50 bg-foreground/10 pe-9 text-base shadow-none md:text-base\")}\n value={text}\n placeholder={p.placeholder ?? t(\"contents.searchPlaceholder\")}\n onChange={(e) => {\n setText(e.target.value);\n setOpen(true);\n setActive(-1);\n }}\n onFocus={reveal}\n onClick={reveal}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n setOpen(false);\n setActive(-1);\n return;\n }\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n reveal();\n setActive((a) => open ? Math.min(visible.length - 1, a + 1) : 0);\n } else if (e.key === \"ArrowUp\" && open) {\n e.preventDefault();\n setActive((a) => Math.max(-1, a - 1));\n }\n }}\n />\n {header && (text || open) && (\n <button\n type=\"button\"\n className=\"absolute top-1/2 right-2.5 -translate-y-1/2 rounded p-0.5 text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring\"\n aria-label={text ? t(\"contents.clearSearch\") : t(\"common.close\")}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n input.current?.focus();\n setActive(-1);\n if (text) { setText(\"\"); setOpen(true); }\n else setOpen(false);\n }}\n ><HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className=\"size-4\" aria-hidden /></button>\n )}\n </form>\n {open && (header ? createPortal(\n <ContentKitUiRoot appearance={p.appearance} className=\"fixed inset-x-0 bottom-0 z-[70] text-sm\" style={{ top }} data-ckui=\"search-layer\">\n <div className=\"absolute inset-0 bg-black/30 backdrop-blur-sm\" data-ckui=\"search-backdrop\" aria-hidden />\n <div ref={panel} style={{ width: anchor.width, marginLeft: anchor.left }} className=\"relative origin-top animate-[search-expand_300ms_ease-out] rounded-lg border border-border bg-background text-foreground shadow-lg transition-none motion-reduce:animate-none\" data-ckui=\"search-panel\" onKeyDown={panelKeyDown}>\n <div className=\"w-full px-3 pt-3\">\n <div className=\"[--search-max-height:70vh] overflow-y-auto pb-7 md:[--search-max-height:60vh]\" style={{ maxHeight: `min(var(--search-max-height), calc(100dvh - ${top}px - 1.875rem))` }}>\n <div>{results}</div>\n </div>\n </div>\n </div>\n </ContentKitUiRoot>, document.body,\n ) : <div ref={panel} className=\"absolute top-full z-20 mt-1 grid max-h-96 w-full overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md\" data-ckui=\"search-panel\" onKeyDown={panelKeyDown}>{results}</div>)}\n\n </ContentKitUiRoot>\n );\n}\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