2022-07-14 06:45:07 +00:00
|
|
|
import {
|
2022-11-23 02:55:25 +00:00
|
|
|
KBarAnimator,
|
2022-07-14 06:45:07 +00:00
|
|
|
KBarPortal,
|
|
|
|
KBarPositioner,
|
2022-11-23 02:55:25 +00:00
|
|
|
KBarProvider,
|
2022-07-14 06:45:07 +00:00
|
|
|
KBarResults,
|
2022-11-23 02:55:25 +00:00
|
|
|
KBarSearch,
|
2022-07-14 06:45:07 +00:00
|
|
|
useKBar,
|
2022-11-23 02:55:25 +00:00
|
|
|
useMatches,
|
2022-07-14 06:45:07 +00:00
|
|
|
} from "kbar";
|
|
|
|
import { useRouter } from "next/router";
|
2022-12-05 12:13:31 +00:00
|
|
|
import { useMemo } from "react";
|
2022-07-14 06:45:07 +00:00
|
|
|
|
2023-01-18 22:30:25 +00:00
|
|
|
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
|
2022-07-14 06:45:07 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
|
|
import { isMac } from "@calcom/lib/isMac";
|
2023-01-07 17:06:53 +00:00
|
|
|
import { RouterOutputs, trpc } from "@calcom/trpc/react";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Tooltip } from "@calcom/ui";
|
|
|
|
import { FiSearch, FiArrowUp, FiArrowDown, FiCornerDownLeft, FiCommand } from "@calcom/ui/components/icon";
|
2022-07-14 06:45:07 +00:00
|
|
|
|
|
|
|
type shortcutArrayType = {
|
|
|
|
shortcuts?: string[];
|
|
|
|
};
|
|
|
|
|
2023-01-07 17:06:53 +00:00
|
|
|
type EventTypeGroups = RouterOutputs["viewer"]["eventTypes"]["getByViewer"]["eventTypeGroups"];
|
|
|
|
type EventTypeGroup = EventTypeGroups[number];
|
|
|
|
type EventType = EventTypeGroup["eventTypes"][number];
|
|
|
|
|
|
|
|
type KBarAction = {
|
|
|
|
perform: () => Promise<boolean>;
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
section: string;
|
|
|
|
keywords: string;
|
|
|
|
};
|
|
|
|
|
2022-12-05 12:13:31 +00:00
|
|
|
const getApps = Object.values(appStoreMetadata).map(({ name, slug }) => ({
|
|
|
|
id: slug,
|
|
|
|
name,
|
|
|
|
section: "Installable Apps",
|
|
|
|
keywords: `app ${name}`,
|
|
|
|
}));
|
|
|
|
|
2022-07-14 06:45:07 +00:00
|
|
|
export const KBarRoot = ({ children }: { children: React.ReactNode }) => {
|
|
|
|
const router = useRouter();
|
2023-01-07 17:06:53 +00:00
|
|
|
const { data } = trpc.viewer.eventTypes.getByViewer.useQuery();
|
2022-07-14 06:45:07 +00:00
|
|
|
|
|
|
|
// grab link to events
|
|
|
|
// quick nested actions would be extremely useful
|
2022-12-05 12:13:31 +00:00
|
|
|
const appStoreActions = useMemo(
|
|
|
|
() => getApps.map((item) => ({ ...item, perform: () => router.push(`/apps/${item.id}`) })),
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
2023-01-07 17:06:53 +00:00
|
|
|
if (!data) return null;
|
|
|
|
|
|
|
|
const eventTypes =
|
|
|
|
data?.eventTypeGroups.reduce((acc: EventType[], group: EventTypeGroup): EventType[] => {
|
|
|
|
acc.push(...group.eventTypes);
|
|
|
|
return acc;
|
|
|
|
}, [] as EventType[]) || [];
|
|
|
|
|
|
|
|
const eventTypeActions =
|
|
|
|
eventTypes.map(
|
|
|
|
(item: EventType): KBarAction => ({
|
|
|
|
id: `event-type-${item.id}`,
|
|
|
|
name: item.title,
|
|
|
|
section: "event_types_page_title",
|
|
|
|
keywords: "event types",
|
|
|
|
perform: () => router.push(`/event-types/${item.id}`),
|
|
|
|
})
|
|
|
|
) || [];
|
|
|
|
|
2022-07-14 06:45:07 +00:00
|
|
|
const actions = [
|
|
|
|
// {
|
|
|
|
// id: "toggle-idle",
|
|
|
|
// name: "Test Function",
|
|
|
|
// section: "Status",
|
|
|
|
// shortcut: ["t", "f"],
|
|
|
|
// keywords: "set yourself away bookings",
|
|
|
|
// perform: () => alert("Hello World"),
|
|
|
|
// },
|
2022-07-14 11:32:28 +00:00
|
|
|
|
2022-07-14 06:45:07 +00:00
|
|
|
{
|
2022-07-14 11:32:28 +00:00
|
|
|
id: "workflows",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "workflows",
|
|
|
|
section: "workflows",
|
2022-07-14 11:32:28 +00:00
|
|
|
shortcut: ["w", "f"],
|
|
|
|
keywords: "workflows automation",
|
|
|
|
perform: () => router.push("/workflows"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "event-types",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "event_types_page_title",
|
|
|
|
section: "event_types_page_title",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["e", "t"],
|
|
|
|
keywords: "event types",
|
|
|
|
perform: () => router.push("/event-types"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "app-store",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "app_store",
|
|
|
|
section: "apps",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["a", "s"],
|
|
|
|
keywords: "app store",
|
|
|
|
perform: () => router.push("/apps"),
|
|
|
|
},
|
2022-07-14 11:32:28 +00:00
|
|
|
{
|
|
|
|
id: "upcoming-bookings",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "upcoming",
|
|
|
|
section: "bookings",
|
2022-07-14 11:32:28 +00:00
|
|
|
shortcut: ["u", "b"],
|
|
|
|
keywords: "upcoming bookings",
|
|
|
|
perform: () => router.push("/bookings/upcoming"),
|
|
|
|
},
|
2022-07-14 06:45:07 +00:00
|
|
|
{
|
|
|
|
id: "recurring-bookings",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "recurring",
|
|
|
|
section: "bookings",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["r", "b"],
|
|
|
|
keywords: "recurring bookings",
|
|
|
|
perform: () => router.push("/bookings/recurring"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "past-bookings",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "past",
|
|
|
|
section: "bookings",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["p", "b"],
|
|
|
|
keywords: "past bookings",
|
|
|
|
perform: () => router.push("/bookings/past"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "cancelled-bookings",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "cancelled",
|
|
|
|
section: "bookings",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["c", "b"],
|
|
|
|
keywords: "cancelled bookings",
|
|
|
|
perform: () => router.push("/bookings/cancelled"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "schedule",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "availability",
|
|
|
|
section: "availability",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["s", "a"],
|
|
|
|
keywords: "schedule availability",
|
|
|
|
perform: () => router.push("/availability"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "profile",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "profile",
|
|
|
|
section: "profile",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["p", "s"],
|
|
|
|
keywords: "setting profile",
|
2022-12-07 20:53:44 +00:00
|
|
|
perform: () => router.push("/settings/my-account/profile"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "avatar",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "change_avatar",
|
|
|
|
section: "profile",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["c", "a"],
|
|
|
|
keywords: "remove change modify avatar",
|
2022-12-07 20:53:44 +00:00
|
|
|
perform: () => router.push("/settings/my-account/profile"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "timezone",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "timezone",
|
|
|
|
section: "profile",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["c", "t"],
|
|
|
|
keywords: "change modify timezone",
|
2022-11-30 21:52:56 +00:00
|
|
|
perform: () => router.push("/settings/my-account/general"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "brand-color",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "brand_color",
|
|
|
|
section: "profile",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["b", "c"],
|
|
|
|
keywords: "change modify brand color",
|
2022-11-30 21:52:56 +00:00
|
|
|
perform: () => router.push("/settings/my-account/appearance"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "teams",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "teams",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["t", "s"],
|
|
|
|
keywords: "add manage modify team",
|
|
|
|
perform: () => router.push("/settings/teams"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "password",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "change_password",
|
|
|
|
section: "security",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["c", "p"],
|
|
|
|
keywords: "change modify password",
|
2022-12-07 20:53:44 +00:00
|
|
|
perform: () => router.push("/settings/security/password"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "two-factor",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "two_factor_auth",
|
|
|
|
section: "security",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["t", "f", "a"],
|
|
|
|
keywords: "two factor authentication",
|
2022-10-31 18:53:59 +00:00
|
|
|
perform: () => router.push("/settings/security/two-factor-auth"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "impersonation",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "user_impersonation_heading",
|
|
|
|
section: "security",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["u", "i"],
|
|
|
|
keywords: "user impersonation",
|
2022-10-31 18:53:59 +00:00
|
|
|
perform: () => router.push("/settings/security/impersonation"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
Admin Wizard Choose License (#6574)
* Implementation
* i18n
* More i18n
* extracted i18n, needs api to get most recent price, added hint: update later
* Fixing i18n var
* Fix booking filters not working for admin (#6576)
* fix: react-select overflow issue in some modals. (#6587)
* feat: add a disable overflow prop
* feat: use the disable overflow prop
* Tailwind Merge (#6596)
* Tailwind Merge
* Fix merge classNames
* [CAL-808] /availability/single - UI issue on buttons beside time inputs (#6561)
* [CAL-808] /availability/single - UI issue on buttons beside time inputs
* Update apps/web/public/static/locales/en/common.json
* Update packages/features/schedules/components/Schedule.tsx
* create new translation for tooltip
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
* Bye bye submodules (#6585)
* WIP
* Uses ssh instead
* Update .gitignore
* Update .gitignore
* Update Makefile
* Update git-setup.sh
* Update git-setup.sh
* Replaced Makefile with bash script
* Update package.json
* fix: show button on empty string (#6601)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: add delete in dropdown (#6599)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update README.md
* Update README.md
* Changed a neutral- classes to gray (#6603)
* Changed a neutral- classes to gray
* Changed all border-1 to border
* Update package.json
* Test fixes
* Yarn lock fixes
* Fix string equality check in git-setup.sh
* [CAL-811] Avatar icon not redirecting user back to the main page (#6586)
* Remove cursor-pointer, remove old Avatar* files
* Fixed styling for checkedSelect + some cleanup
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* Harsh/add member invite (#6598)
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
* Regenerated lockfile without upgrade (#6610)
* fix: remove annoying outline when <Button /> clicked (#6537)
* fix: remove annoying outline when <Button /> clicked
* Delete yarn.lock
* remove 1 on 1 icon (#6609)
* removed 1-on-1 badge
* changed user to users for group events
* fix: case-sensitivity in apps path (#6552)
* fix: lowercase slug
* fix: make fallback blocking
* Fix FAB (#6611)
* feat: add LocationSelect component (#6571)
* feat: add LocationSelect component
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update booking filters design (#6543)
* Update booking filters
* Add filter on YOUR bookings
* Fix pending members showing up in list
* Reduce the avatar size to 'sm' for now
* Bugfix/dropdown menu trigger as child remove class names (#6614)
* Fix UsernameTextfield to take right height
* Remove className side-effect
* Incorrect resolution version fixed
* Converted mobile DropdownMenuTrigger styles into Button
* v2.5.3
* fix: use items-center (#6618)
* fix tooltip and modal stacking issues (#6491)
* fix tooltip and modal stacking issues
* use z-index in larger screens and less
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* Temporary fix (#6626)
* Fix Ga4 tracking (#6630)
* generic <UpgradeScreen> component (#6594)
* first attempt of <UpgradeScreen>
* changes to icons
* reverted changes back to initial state, needs fix: teams not showing
* WIP
* Fix weird reactnode error
* Fix loading text
* added upgradeTip to routing forms
* icon colors
* create and use hook to check if user has team plan
* use useTeamPlan for upgradeTeamsBadge
* replace huge svg with compressed jpeg
* responsive fixes
* Update packages/ui/components/badge/UpgradeTeamsBadge.tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Give team plan features to E2E tests
* Allow option to make a user part of team int ests
* Remove flash of paywall for team user
* Add team user for typeform tests as well
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* Removing env var to rely on db
* Restoring i18n keys, set loading moved
* Fixing tailwind-preset glob
* Wizard width fix for md+ screens
* Converting licenses options to radix radio
* Applying feedback + other tweaks
* Reverting this, not this PR related
* Unneeded code removal
* Reverting unneeded style change
* Applying feedback
* Removing licenseType
* Upgrades typescript
* Update yarn lock
* Typings
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712)
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713)
* Adds deployment settings to DB (#6706)
* WIP
* Adds DeploymentTheme
* Add missing migrations
* Adds client extensions for deployment
* Cleanup
* Delete migration.sql
* Relying on both, env var and new model
* Restoring env example doc for backward compat
* Maximum call stack size exceeded fix?
* Revert upgrade
* Update index.ts
* Delete index.ts
* Not exposing license key, fixed radio behavior
* Covering undefined env var
* Self contained checkLicense
* Feedback
* Moar feedback
* Feedback
* Feedback
* Feedback
* Cleanup
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com>
Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com>
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com>
Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
2023-02-08 00:23:42 +00:00
|
|
|
{
|
|
|
|
id: "license",
|
|
|
|
name: "choose_a_license",
|
|
|
|
section: "admin",
|
|
|
|
shortcut: ["u", "l"],
|
|
|
|
keywords: "license",
|
|
|
|
perform: () => router.push("/auth/setup?step=1"),
|
|
|
|
},
|
2022-07-14 06:45:07 +00:00
|
|
|
{
|
|
|
|
id: "webhooks",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "Webhooks",
|
|
|
|
section: "developer",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["w", "h"],
|
|
|
|
keywords: "webhook automation",
|
2022-10-31 18:53:59 +00:00
|
|
|
perform: () => router.push("/settings/developer/webhooks"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "api-keys",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "api_keys",
|
|
|
|
section: "developer",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["a", "p", "i"],
|
|
|
|
keywords: "api keys",
|
2022-10-31 18:53:59 +00:00
|
|
|
perform: () => router.push("/settings/developer/api-keys"),
|
2022-07-14 06:45:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "billing",
|
2022-12-07 20:53:44 +00:00
|
|
|
name: "manage_billing",
|
|
|
|
section: "billing",
|
2022-07-14 06:45:07 +00:00
|
|
|
shortcut: ["m", "b"],
|
|
|
|
keywords: "billing view manage",
|
|
|
|
perform: () => router.push("/settings/billing"),
|
|
|
|
},
|
2022-12-05 12:13:31 +00:00
|
|
|
...appStoreActions,
|
2023-01-07 17:06:53 +00:00
|
|
|
...eventTypeActions,
|
2022-07-14 06:45:07 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
return <KBarProvider actions={actions}>{children}</KBarProvider>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const KBarContent = () => {
|
2022-07-14 11:32:28 +00:00
|
|
|
const { t } = useLocale();
|
|
|
|
|
2022-07-14 06:45:07 +00:00
|
|
|
return (
|
|
|
|
<KBarPortal>
|
|
|
|
<KBarPositioner>
|
2022-09-07 15:01:33 +00:00
|
|
|
<KBarAnimator className="z-10 w-full max-w-screen-sm overflow-hidden rounded-md bg-white shadow-lg">
|
2022-07-14 11:32:28 +00:00
|
|
|
<div className="flex items-center justify-center border-b">
|
2023-01-23 23:08:01 +00:00
|
|
|
<FiSearch className="mx-3 h-4 w-4 text-gray-500" />
|
2022-11-30 21:52:56 +00:00
|
|
|
<KBarSearch
|
|
|
|
defaultPlaceholder={t("kbar_search_placeholder")}
|
|
|
|
className="w-full rounded-sm py-2.5 focus-visible:outline-none"
|
|
|
|
/>
|
2022-07-14 11:32:28 +00:00
|
|
|
</div>
|
2022-07-14 06:45:07 +00:00
|
|
|
<RenderResults />
|
2022-07-14 11:32:28 +00:00
|
|
|
<div className="hidden items-center space-x-1 border-t px-2 py-1.5 text-xs text-gray-500 sm:flex">
|
2023-01-23 23:08:01 +00:00
|
|
|
<FiArrowUp className="h-4 w-4" />
|
|
|
|
<FiArrowDown className="h-4 w-4" /> <span className="pr-2">{t("navigate")}</span>
|
|
|
|
<FiCornerDownLeft className="h-4 w-4" />
|
2022-07-14 11:32:28 +00:00
|
|
|
<span className="pr-2">{t("open")}</span>
|
2023-01-23 23:08:01 +00:00
|
|
|
{isMac ? <FiCommand className="h-3 w-3" /> : "CTRL"}
|
2022-07-14 11:32:28 +00:00
|
|
|
<span className="pr-1">+ K </span>
|
|
|
|
<span className="pr-2">{t("close")}</span>
|
|
|
|
</div>
|
2022-07-14 06:45:07 +00:00
|
|
|
</KBarAnimator>
|
2022-07-14 11:32:28 +00:00
|
|
|
<div className="z-1 fixed inset-0 bg-gray-600 bg-opacity-75" />
|
2022-07-14 06:45:07 +00:00
|
|
|
</KBarPositioner>
|
|
|
|
</KBarPortal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const KBarTrigger = () => {
|
|
|
|
const { query } = useKBar();
|
2023-01-07 22:31:15 +00:00
|
|
|
return query ? (
|
2022-07-14 11:32:28 +00:00
|
|
|
<>
|
|
|
|
<Tooltip side="right" content={isMac ? "⌘ + K" : "CTRL + K"}>
|
|
|
|
<button
|
|
|
|
color="minimal"
|
|
|
|
onClick={query.toggle}
|
2023-01-12 16:57:43 +00:00
|
|
|
className="group flex rounded-md py-2 px-3 text-sm font-medium hover:bg-gray-100 lg:p-1 lg:hover:bg-gray-200 lg:hover:text-gray-900">
|
2023-01-23 23:08:01 +00:00
|
|
|
<FiSearch className="h-4 w-4 flex-shrink-0 text-inherit" />
|
2022-07-14 11:32:28 +00:00
|
|
|
</button>
|
|
|
|
</Tooltip>
|
|
|
|
</>
|
2023-01-07 22:31:15 +00:00
|
|
|
) : null;
|
2022-07-14 06:45:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const DisplayShortcuts = (item: shortcutArrayType) => {
|
|
|
|
const shortcuts = item.shortcuts;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span className="space-x-1">
|
|
|
|
{shortcuts?.map((shortcut) => {
|
|
|
|
return (
|
2022-07-14 11:32:28 +00:00
|
|
|
<kbd key={shortcut} className="rounded-sm border bg-white px-2 py-1 text-black hover:bg-gray-100">
|
2022-07-14 06:45:07 +00:00
|
|
|
{shortcut}
|
|
|
|
</kbd>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
function RenderResults() {
|
|
|
|
const { results } = useMatches();
|
2022-12-07 20:53:44 +00:00
|
|
|
const { t } = useLocale();
|
2022-07-14 06:45:07 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<KBarResults
|
|
|
|
items={results}
|
|
|
|
onRender={({ item, active }) =>
|
|
|
|
typeof item === "string" ? (
|
2022-12-07 20:53:44 +00:00
|
|
|
<div className="bg-white p-4 text-xs uppercase text-gray-500">{t(item)}</div>
|
2022-07-14 06:45:07 +00:00
|
|
|
) : (
|
|
|
|
<div
|
|
|
|
// For seeing keyboard up & down navigation in action, we need visual feedback based on "active" prop
|
|
|
|
style={{
|
|
|
|
background: active ? "rgb(245,245,245)" : "#fff",
|
|
|
|
borderLeft: active ? "2px solid black" : "2px solid transparent",
|
|
|
|
}}
|
|
|
|
className="flex items-center justify-between px-4 py-2.5 text-sm hover:cursor-pointer">
|
2022-12-07 20:53:44 +00:00
|
|
|
<span>{t(item.name)}</span>
|
2022-07-14 06:45:07 +00:00
|
|
|
<DisplayShortcuts shortcuts={item.shortcut} />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|