/* * Vencord, a Discord client mod * Copyright (c) 2025 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { proxyLazy } from "@utils/lazy"; import { findByCodeLazy, findComponentByCodeLazy, findLazy } from "@webpack"; import { AnchorProps, AvatarProps, BadgeShapesType, CheckboxGroupOption, CircleBadgeProps, ClickableProps, ColorPickerProps, ColorPickerWithSwatchesProps, ColorSwatchProps, CustomColorButtonProps, DefaultColorButtonProps, GradientColor, IconBadgeProps, ListboxItem, ManaBaseRadioGroupProps, ManaButtonProps, ManaCalendarProps, ManaCheckboxGroupProps, ManaCheckboxProps, ManaComboboxProps, ManaDatePickerProps, ManaListboxProps, ManaPopoverProps, ManaRichTooltipProps, ManaSelectOption, ManaSelectProps, ManaSwitchProps, ManaTextAreaProps, ManaTextButtonProps, ManaTextInputProps, ManaTooltipProps, NoticeProps, NoticeType, NumberBadgeProps, PaginatorProps, PopoverAction, ProgressBarProps, RadioOption, SearchBarProps, SliderProps, SpinnerProps, StandaloneRadioIndicatorProps, TabBarComponent, TabBarHeaderProps, TabBarItemProps, TabBarProps, TabBarSeparatorProps, TextBadgeProps } from "../types"; export type { AnchorProps, AvatarProps, BadgeShapesType, CheckboxGroupOption, CircleBadgeProps, ColorPickerProps, ColorPickerWithSwatchesProps, ColorSwatchProps, CustomColorButtonProps, DefaultColorButtonProps, GradientColor, IconBadgeProps, ListboxItem, ManaBaseRadioGroupProps, ManaButtonProps, ManaCalendarProps, ManaCheckboxGroupProps, ManaCheckboxProps, ManaComboboxProps, ManaDatePickerProps, ManaListboxProps, ManaPopoverProps, ManaRichTooltipProps, ManaSelectOption, ManaSelectProps, ManaSwitchProps, ManaTextAreaProps, ManaTextButtonProps, ManaTextInputProps, ManaTooltipProps, NoticeProps, NoticeType, NumberBadgeProps, PaginatorProps, PopoverAction, ProgressBarProps, RadioOption, SearchBarProps, SliderProps, SpinnerProps, StandaloneRadioIndicatorProps, TabBarComponent, TabBarHeaderProps, TabBarItemProps, TabBarProps, TabBarSeparatorProps, TextBadgeProps }; export const Anchor = findComponentByCodeLazy("anchorUnderlineOnHover", "useDefaultUnderlineStyles") as React.ComponentType; export const ManaButton = findComponentByCodeLazy('"data-mana-component":"button"') as React.ComponentType; export const ManaTextButton = findComponentByCodeLazy('"data-mana-component":"text-button"') as React.ComponentType; export const ManaSwitch = findComponentByCodeLazy('"data-mana-component":"switch"') as React.ComponentType; export const ManaTextInput = findComponentByCodeLazy('"data-mana-component":"text-input"') as React.ComponentType; export const ManaTextArea = findComponentByCodeLazy('"data-mana-component":"text-area"') as React.ComponentType; export const ManaCheckbox = findComponentByCodeLazy('"data-mana-component":"checkbox"') as React.ComponentType; export const ManaSelect = findComponentByCodeLazy('"data-mana-component":"select"') as React.ComponentType; export const ManaTooltip = findComponentByCodeLazy('"data-mana-component":"tooltip"') as React.ComponentType; export const ManaCalendar = findComponentByCodeLazy('"data-mana-component":"calendar"') as React.ComponentType; export const ManaDatePicker = findComponentByCodeLazy('"data-mana-component":"date-picker"') as React.ComponentType; export const ManaRichTooltip = findComponentByCodeLazy('"data-mana-component":"rich-tooltip"') as React.ComponentType; export const ManaCombobox = findComponentByCodeLazy("itemToString", "multiSelect", "maxVisibleItems") as React.ComponentType; export const ManaListbox = findComponentByCodeLazy('"data-mana-component":"listbox"') as React.ComponentType; export const ManaCheckboxGroup = findComponentByCodeLazy('"data-mana-component":"checkbox-group"') as React.ComponentType; export const ManaBaseRadioGroup = findComponentByCodeLazy('"data-mana-component":"BaseRadioGroup"') as React.ComponentType; export const StandaloneRadioIndicator = findComponentByCodeLazy("standaloneRadioIndicator", "animateIn", "animateOut") as React.ComponentType; export const ManaPopover = findComponentByCodeLazy('"data-mana-component":"popover"') as React.ComponentType; export const Slider = findComponentByCodeLazy("stickToMarkers", "onMarkerRender", "grabberClassName") as React.ComponentType; export const Avatar = findComponentByCodeLazy("statusTooltip", "statusBackdropColor", "isSpeaking") as React.ComponentType; export const ProgressBar = findComponentByCodeLazy("progressContainer", "labelledBy", "aria-valuenow") as React.ComponentType; export const Spinner = findComponentByCodeLazy("spinningCircleSimple", "pulsingEllipsis", "wanderingCubes") as React.ComponentType; export const SearchBar = findComponentByCodeLazy("#{intl::SEARCH}", "clearable", "autoComplete") as React.ComponentType; export const Paginator2 = findComponentByCodeLazy("#{intl::BACK}", "#{intl::NEXT}", "renderPageWrapper") as React.ComponentType; export const Notice = findComponentByCodeLazy("messageType", "iconDiv", "actionContainer") as React.ComponentType; export const ColorPicker = findComponentByCodeLazy("#{intl::USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR}", "showEyeDropper") as React.ComponentType; const ColorPickerModule = findLazy(m => { const values = Object.values(m); return values.length === 4 && values.some(v => typeof v === "function" && v.toString?.().includes('id:"color-picker"')) && values.some(v => typeof v === "function" && v.toString?.().includes("isDefault:!0")); }); function getColorPickerExport(check: (fn: Function) => boolean): React.ComponentType { for (const value of Object.values(ColorPickerModule)) { if (typeof value === "function" && check(value)) return value as React.ComponentType; } return (() => null) as React.ComponentType; } export const ColorPickerWithSwatches: React.ComponentType = proxyLazy(() => getColorPickerExport(fn => fn.toString().includes('id:"color-picker"')) ); export const ColorSwatch: React.ComponentType = proxyLazy(() => getColorPickerExport(fn => fn.toString().includes("isDefault") && fn.toString().includes("isCustom") && fn.toString().includes("colorPickerSwatch")) ); export const DefaultColorButton: React.ComponentType = proxyLazy(() => getColorPickerExport(fn => fn.toString().includes("isDefault:!0") && fn.toString().includes("allowBlackCustomColor")) ); export const CustomColorButton: React.ComponentType = proxyLazy(() => getColorPickerExport(fn => fn.toString().includes("isCustom:!0") && fn.toString().includes("presets")) ); const BadgeModule = findLazy(m => { const values = Object.values(m); return values.length < 15 && values.some(v => typeof v === "function" && v.toString?.().includes("numberBadge")) && values.some(v => typeof v === "object" && (v as BadgeShapesType)?.ROUND && (v as BadgeShapesType)?.ROUND_LEFT); }); function getBadgeExport(check: (fn: Function) => boolean): React.ComponentType { for (const value of Object.values(BadgeModule)) { if (typeof value === "function" && check(value)) return value as React.ComponentType; } return (() => null) as React.ComponentType; } export const NumberBadge: React.ComponentType = proxyLazy(() => getBadgeExport(fn => fn.toString().includes("numberBadge"))); export const TextBadge: React.ComponentType = proxyLazy(() => getBadgeExport(fn => fn.toString().includes("textBadge"))); export const IconBadge: React.ComponentType = proxyLazy(() => getBadgeExport(fn => fn.toString().includes("iconBadge"))); export const CircleBadge: React.ComponentType = proxyLazy(() => getBadgeExport(fn => fn.toString().includes("disableColor") && !fn.toString().includes("iconBadge") && !fn.toString().includes("textBadge") && !fn.toString().includes("numberBadge") && !fn.toString().includes("premiumBadge"))); export const BadgeShapes = proxyLazy(() => Object.values(BadgeModule).find(v => typeof v === "object" && (v as BadgeShapesType)?.ROUND) as BadgeShapesType ?? { ROUND: "", ROUND_LEFT: "", ROUND_RIGHT: "", SQUARE: "" }); export const TabBar = findByCodeLazy("this.tabBarRef", "renderChildren") as TabBarComponent; export const Clickable = findByCodeLazy("ignoreKeyPress", "renderNonInteractive") as React.ComponentType;