* okay, this is a long one. Initial commit to a long running list of commits and new features. * multiple refactors, additions ect * forgor to remove these * Address Gemini's comments. * small security fixes * lord its done * this has been ticking me off for a while * lint * fix(commandPalette): resolve stylelint specificity ordering * general fixes * refactor of query boxes * fix query prompt offset * fix: lint * bunch bullshit * Discard changes to package.json * graph bullshit * fix cursor offset * more finnicky math bullshit * variable support * fixes * fixes2 * but can it run doom? * delete useless shit * Delete assets/commandPaletteDoom directory * more bullshit lol * fixes * fix: replace command palette doom runtime * fix: localize bell dismiss icon * fix(commandPalette): harden runtime behavior and typing * fix(commandPalette): import React from webpack common * fix(commandPalette): avoid React forwardRef dependency --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
/*
|
|
* Vencord, a Discord client mod
|
|
* Copyright (c) 2026 Vendicated and contributors
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
import { CogWheel, CopyIcon, LinkIcon, MainSettingsIcon, NotesIcon, PluginIcon, RestartIcon } from "@components/Icons";
|
|
import type { ComponentType } from "react";
|
|
|
|
type IconComponent = ComponentType<{ className?: string; size?: string; height?: number; width?: number; }>;
|
|
|
|
export type CustomCommandIconId =
|
|
| "auto"
|
|
| "alias"
|
|
| "quicklink"
|
|
| "sequence"
|
|
| "settings"
|
|
| "notes"
|
|
| "plugin"
|
|
| "gear";
|
|
|
|
interface CustomCommandIconMeta {
|
|
id: CustomCommandIconId;
|
|
label: string;
|
|
icon: IconComponent;
|
|
}
|
|
|
|
const CUSTOM_COMMAND_ICON_META: CustomCommandIconMeta[] = [
|
|
{ id: "auto", label: "Auto", icon: CogWheel },
|
|
{ id: "alias", label: "Alias", icon: CopyIcon },
|
|
{ id: "quicklink", label: "Quicklink", icon: LinkIcon },
|
|
{ id: "sequence", label: "Sequence", icon: RestartIcon },
|
|
{ id: "settings", label: "Settings", icon: MainSettingsIcon },
|
|
{ id: "notes", label: "Notes", icon: NotesIcon },
|
|
{ id: "plugin", label: "Plugin", icon: PluginIcon },
|
|
{ id: "gear", label: "Gear", icon: CogWheel }
|
|
];
|
|
|
|
const CUSTOM_COMMAND_ICON_MAP = new Map<CustomCommandIconId, IconComponent>(
|
|
CUSTOM_COMMAND_ICON_META.map(item => [item.id, item.icon])
|
|
);
|
|
|
|
const CUSTOM_COMMAND_ICON_ID_SET = new Set<CustomCommandIconId>(
|
|
CUSTOM_COMMAND_ICON_META.map(item => item.id)
|
|
);
|
|
|
|
export function isCustomCommandIconId(value: unknown): value is CustomCommandIconId {
|
|
return typeof value === "string" && CUSTOM_COMMAND_ICON_ID_SET.has(value as CustomCommandIconId);
|
|
}
|
|
|
|
export function getCustomCommandIconMetaList() {
|
|
return CUSTOM_COMMAND_ICON_META;
|
|
}
|
|
|
|
export function resolveCustomCommandDefaultIconId(actionType: "command" | "settings" | "url" | "macro"): Exclude<CustomCommandIconId, "auto"> {
|
|
switch (actionType) {
|
|
case "command":
|
|
return "alias";
|
|
case "url":
|
|
return "quicklink";
|
|
case "macro":
|
|
return "sequence";
|
|
case "settings":
|
|
return "settings";
|
|
default:
|
|
return "gear";
|
|
}
|
|
}
|
|
|
|
export function getCustomCommandIconById(iconId: CustomCommandIconId): IconComponent {
|
|
return CUSTOM_COMMAND_ICON_MAP.get(iconId) ?? CogWheel;
|
|
}
|