* feat: add improved search * wip: add support for sorting, rename use-options to use-query-options, add use-options for local usage, add pages search group * feat: add help links from manage layout to help search mode * feat: add additional search engines * feat: add group search details * refactor: improve users search group type * feat: add apps search group, add disabled search interaction * feat: add integrations and boards for search * wip: hook issue with react * fix: hook issue regarding actions and interactions * chore: address pull request feedback * fix: format issues * feat: add additional global actions to search * chore: remove unused code * fix: search engine short key * fix: typecheck issues * fix: deepsource issues * fix: eslint issue * fix: lint issues * fix: unordered dependencies * chore: address pull request feedback
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import Link from "next/link";
|
|
import { Spotlight } from "@mantine/spotlight";
|
|
|
|
import type { inferSearchInteractionOptions } from "../../../lib/interaction";
|
|
import classes from "./action-item.module.css";
|
|
|
|
interface ChildrenActionItemProps {
|
|
childrenOptions: inferSearchInteractionOptions<"children">;
|
|
query: string;
|
|
action: ReturnType<inferSearchInteractionOptions<"children">["useActions"]>[number];
|
|
}
|
|
|
|
export const ChildrenActionItem = ({ childrenOptions, action, query }: ChildrenActionItemProps) => {
|
|
const interaction = action.useInteraction(childrenOptions.option, query);
|
|
|
|
const renderRoot =
|
|
interaction.type === "link"
|
|
? (props: Record<string, unknown>) => {
|
|
return <Link href={interaction.href} target={interaction.newTab ? "_blank" : undefined} {...props} />;
|
|
}
|
|
: undefined;
|
|
|
|
const onClick = interaction.type === "javaScript" ? interaction.onSelect : undefined;
|
|
|
|
return (
|
|
<Spotlight.Action renderRoot={renderRoot} onClick={onClick} className={classes.spotlightAction}>
|
|
<action.component {...childrenOptions.option} />
|
|
</Spotlight.Action>
|
|
);
|
|
};
|