Compare commits
2 Commits
main
...
features/c
Author | SHA1 | Date | |
---|---|---|---|
|
c3da99eeee | ||
|
0e7bd87cee |
@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
import { Constructor } from "type-fest";
|
import { Constructor } from "type-fest";
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ import { lazyWebpack, proxyLazy } from "../../utils";
|
|||||||
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "../../utils/modal";
|
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "../../utils/modal";
|
||||||
import { OptionType, Plugin } from "../../utils/types";
|
import { OptionType, Plugin } from "../../utils/types";
|
||||||
import { filters } from "../../webpack";
|
import { filters } from "../../webpack";
|
||||||
import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "../../webpack/common";
|
import { Button, FluxDispatcher, React, Text, Tooltip, UserStore, UserUtils } from "../../webpack/common";
|
||||||
import ErrorBoundary from "../ErrorBoundary";
|
import ErrorBoundary from "../ErrorBoundary";
|
||||||
import { Flex } from "../Flex";
|
import { Flex } from "../Flex";
|
||||||
import {
|
import {
|
||||||
@ -33,7 +34,7 @@ import {
|
|||||||
SettingInputComponent,
|
SettingInputComponent,
|
||||||
SettingNumericComponent,
|
SettingNumericComponent,
|
||||||
SettingSelectComponent,
|
SettingSelectComponent,
|
||||||
SettingSliderComponent,
|
SettingSliderComponent
|
||||||
} from "./components";
|
} from "./components";
|
||||||
|
|
||||||
const UserSummaryItem = lazyWebpack(filters.byCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
|
const UserSummaryItem = lazyWebpack(filters.byCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
|
|
||||||
import { PluginOptionBoolean } from "../../../utils/types";
|
import { PluginOptionBoolean } from "../../../utils/types";
|
||||||
import { Forms, React, Select } from "../../../webpack/common";
|
import { React, Select } from "../../../webpack/common";
|
||||||
import { ISettingElementProps } from ".";
|
import { ISettingElementProps } from ".";
|
||||||
|
|
||||||
export function SettingBooleanComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps<PluginOptionBoolean>) {
|
export function SettingBooleanComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps<PluginOptionBoolean>) {
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
|
|
||||||
import { OptionType, PluginOptionNumber } from "../../../utils/types";
|
import { OptionType, PluginOptionNumber } from "../../../utils/types";
|
||||||
import { Forms, React, TextInput } from "../../../webpack/common";
|
import { React, TextInput } from "../../../webpack/common";
|
||||||
import { ISettingElementProps } from ".";
|
import { ISettingElementProps } from ".";
|
||||||
|
|
||||||
const MAX_SAFE_NUMBER = BigInt(Number.MAX_SAFE_INTEGER);
|
const MAX_SAFE_NUMBER = BigInt(Number.MAX_SAFE_INTEGER);
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { FormSection, FormText, FormTitle } from "@components/Forms";
|
||||||
|
import Select from "@components/Select";
|
||||||
|
|
||||||
import { PluginOptionSelect } from "../../../utils/types";
|
import { PluginOptionSelect } from "../../../utils/types";
|
||||||
import { Forms, React, Select } from "../../../webpack/common";
|
import { React } from "../../../webpack/common";
|
||||||
import { ISettingElementProps } from ".";
|
import { ISettingElementProps } from ".";
|
||||||
|
|
||||||
export function SettingSelectComponent({ option, pluginSettings, onChange, onError, id }: ISettingElementProps<PluginOptionSelect>) {
|
export function SettingSelectComponent({ option, pluginSettings, onChange, onError, id }: ISettingElementProps<PluginOptionSelect>) {
|
||||||
@ -41,8 +44,8 @@ export function SettingSelectComponent({ option, pluginSettings, onChange, onErr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection>
|
<FormSection>
|
||||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
<FormTitle>{option.description}</FormTitle>
|
||||||
<Select
|
<Select
|
||||||
isDisabled={option.disabled?.() ?? false}
|
isDisabled={option.disabled?.() ?? false}
|
||||||
options={option.options}
|
options={option.options}
|
||||||
@ -54,7 +57,7 @@ export function SettingSelectComponent({ option, pluginSettings, onChange, onErr
|
|||||||
serialize={v => String(v)}
|
serialize={v => String(v)}
|
||||||
{...option.componentProps}
|
{...option.componentProps}
|
||||||
/>
|
/>
|
||||||
{error && <Forms.FormText style={{ color: "var(--text-danger)" }}>{error}</Forms.FormText>}
|
{error && <FormText style={{ color: "var(--text-danger)" }}>{error}</FormText>}
|
||||||
</Forms.FormSection>
|
</FormSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
|
|
||||||
import { PluginOptionSlider } from "../../../utils/types";
|
import { PluginOptionSlider } from "../../../utils/types";
|
||||||
import { Forms, React, Slider } from "../../../webpack/common";
|
import { React, Slider } from "../../../webpack/common";
|
||||||
import { ISettingElementProps } from ".";
|
import { ISettingElementProps } from ".";
|
||||||
|
|
||||||
export function makeRange(start: number, end: number, step = 1) {
|
export function makeRange(start: number, end: number, step = 1) {
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
|
|
||||||
import { PluginOptionString } from "../../../utils/types";
|
import { PluginOptionString } from "../../../utils/types";
|
||||||
import { Forms, React, TextInput } from "../../../webpack/common";
|
import { React, TextInput } from "../../../webpack/common";
|
||||||
import { ISettingElementProps } from ".";
|
import { ISettingElementProps } from ".";
|
||||||
|
|
||||||
export function SettingInputComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps<PluginOptionString>) {
|
export function SettingInputComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps<PluginOptionString>) {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { FormDivider, FormSection, FormText, FormTitle } from "@components/Forms";
|
||||||
|
|
||||||
import Plugins from "~plugins";
|
import Plugins from "~plugins";
|
||||||
|
|
||||||
import { showNotice } from "../../api/Notices";
|
import { showNotice } from "../../api/Notices";
|
||||||
@ -26,7 +28,7 @@ import { ChangeList } from "../../utils/ChangeList";
|
|||||||
import { classes, lazyWebpack } from "../../utils/misc";
|
import { classes, lazyWebpack } from "../../utils/misc";
|
||||||
import { Plugin } from "../../utils/types";
|
import { Plugin } from "../../utils/types";
|
||||||
import { filters } from "../../webpack";
|
import { filters } from "../../webpack";
|
||||||
import { Alerts, Button, Forms, Margins, Parser, React, Switch, Text, TextInput, Toasts, Tooltip } from "../../webpack/common";
|
import { Alerts, Button, Margins, Parser, React, Switch, Text, TextInput, Toasts, Tooltip } from "../../webpack/common";
|
||||||
import ErrorBoundary from "../ErrorBoundary";
|
import ErrorBoundary from "../ErrorBoundary";
|
||||||
import { ErrorCard } from "../ErrorCard";
|
import { ErrorCard } from "../ErrorCard";
|
||||||
import { Flex } from "../Flex";
|
import { Flex } from "../Flex";
|
||||||
@ -235,10 +237,10 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection tag="h1" title="Vencord">
|
<FormSection tag="h1" title="Vencord">
|
||||||
<Forms.FormTitle tag="h5" className={classes(Margins.marginTop20, Margins.marginBottom8)}>
|
<FormTitle tag="h5" className={classes(Margins.marginTop20, Margins.marginBottom8)}>
|
||||||
Plugins
|
Plugins
|
||||||
</Forms.FormTitle>
|
</FormTitle>
|
||||||
|
|
||||||
<ReloadRequiredCard plugins={[...changes.getChanges()]} style={{ marginBottom: 16 }} />
|
<ReloadRequiredCard plugins={[...changes.getChanges()]} style={{ marginBottom: 16 }} />
|
||||||
|
|
||||||
@ -275,10 +277,10 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
: <Text variant="text-md/normal">No plugins meet search criteria.</Text>
|
: <Text variant="text-md/normal">No plugins meet search criteria.</Text>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<Forms.FormDivider />
|
<FormDivider />
|
||||||
<Forms.FormTitle tag="h5" className={classes(Margins.marginTop20, Margins.marginBottom8)}>
|
<FormTitle tag="h5" className={classes(Margins.marginTop20, Margins.marginBottom8)}>
|
||||||
Required Plugins
|
Required Plugins
|
||||||
</Forms.FormTitle>
|
</FormTitle>
|
||||||
<div style={styles.PluginsGrid}>
|
<div style={styles.PluginsGrid}>
|
||||||
{sortedPlugins?.length ? sortedPlugins
|
{sortedPlugins?.length ? sortedPlugins
|
||||||
.filter(a => a.required || dependencyCheck(a.name, depMap).length && pluginFilter(a))
|
.filter(a => a.required || dependencyCheck(a.name, depMap).length && pluginFilter(a))
|
||||||
@ -303,15 +305,15 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
: <Text variant="text-md/normal">No plugins meet search criteria.</Text>
|
: <Text variant="text-md/normal">No plugins meet search criteria.</Text>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</Forms.FormSection >
|
</FormSection>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function makeDependencyList(deps: string[]) {
|
function makeDependencyList(deps: string[]) {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Forms.FormText>This plugin is required by:</Forms.FormText>
|
<FormText>This plugin is required by:</FormText>
|
||||||
{deps.map((dep: string) => <Forms.FormText style={{ margin: "0 auto" }}>{dep}</Forms.FormText>)}
|
{deps.map((dep: string) => <FormText style={{ margin: "0 auto" }}>{dep}</FormText>)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { FormDivider, FormSection, FormText, FormTitle } from "@components/Forms";
|
||||||
|
|
||||||
import { useSettings } from "../api/settings";
|
import { useSettings } from "../api/settings";
|
||||||
import { ChangeList } from "../utils/ChangeList";
|
import { ChangeList } from "../utils/ChangeList";
|
||||||
import IpcEvents from "../utils/IpcEvents";
|
import IpcEvents from "../utils/IpcEvents";
|
||||||
import { useAwaiter } from "../utils/misc";
|
import { useAwaiter } from "../utils/misc";
|
||||||
import { Alerts, Button, Forms, Margins, Parser, React, Switch } from "../webpack/common";
|
import { Alerts, Button, Margins, Parser, React, Switch } from "../webpack/common";
|
||||||
import ErrorBoundary from "./ErrorBoundary";
|
import ErrorBoundary from "./ErrorBoundary";
|
||||||
import { Flex } from "./Flex";
|
import { Flex } from "./Flex";
|
||||||
import { launchMonacoEditor } from "./Monaco";
|
import { launchMonacoEditor } from "./Monaco";
|
||||||
@ -51,14 +53,14 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection tag="h1" title="Vencord">
|
<FormSection tag="h1" title="Vencord">
|
||||||
<Forms.FormTitle tag="h5">
|
<FormTitle tag="h5">
|
||||||
Settings
|
Settings
|
||||||
</Forms.FormTitle>
|
</FormTitle>
|
||||||
|
|
||||||
<Forms.FormText>
|
<FormText>
|
||||||
Settings Directory: <code style={{ userSelect: "text", cursor: "text" }}>{settingsDir}</code>
|
Settings Directory: <code style={{ userSelect: "text", cursor: "text" }}>{settingsDir}</code>
|
||||||
</Forms.FormText>
|
</FormText>
|
||||||
|
|
||||||
{!IS_WEB && <Flex className={Margins.marginBottom20} style={{ marginTop: 8 }}>
|
{!IS_WEB && <Flex className={Margins.marginBottom20} style={{ marginTop: 8 }}>
|
||||||
<Button
|
<Button
|
||||||
@ -92,7 +94,7 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
Open QuickCSS File
|
Open QuickCSS File
|
||||||
</Button>}
|
</Button>}
|
||||||
|
|
||||||
<Forms.FormDivider />
|
<FormDivider />
|
||||||
<Switch
|
<Switch
|
||||||
value={settings.useQuickCss}
|
value={settings.useQuickCss}
|
||||||
onChange={(v: boolean) => settings.useQuickCss = v}
|
onChange={(v: boolean) => settings.useQuickCss = v}
|
||||||
@ -114,6 +116,6 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
>
|
>
|
||||||
Get notified about new Updates
|
Get notified about new Updates
|
||||||
</Switch>}
|
</Switch>}
|
||||||
</Forms.FormSection >
|
</FormSection>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
|
|
||||||
import gitHash from "~git-hash";
|
import gitHash from "~git-hash";
|
||||||
|
|
||||||
import { classes, useAwaiter } from "../utils/misc";
|
import { classes, useAwaiter } from "../utils/misc";
|
||||||
import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "../utils/updater";
|
import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "../utils/updater";
|
||||||
import { Alerts, Button, Card, Forms, Margins, Parser, React, Toasts } from "../webpack/common";
|
import { Alerts, Button, Card, Margins, Parser, React, Toasts } from "../webpack/common";
|
||||||
import ErrorBoundary from "./ErrorBoundary";
|
import ErrorBoundary from "./ErrorBoundary";
|
||||||
import { ErrorCard } from "./ErrorCard";
|
import { ErrorCard } from "./ErrorCard";
|
||||||
import { Flex } from "./Flex";
|
import { Flex } from "./Flex";
|
||||||
|
@ -16,12 +16,14 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Forms } from "@components";
|
||||||
|
|
||||||
import { lazyWebpack } from "../utils";
|
import { lazyWebpack } from "../utils";
|
||||||
import { Devs } from "../utils/constants";
|
import { Devs } from "../utils/constants";
|
||||||
import definePlugin, { OptionType } from "../utils/types";
|
import definePlugin, { OptionType } from "../utils/types";
|
||||||
import { Settings } from "../Vencord";
|
import { Settings } from "../Vencord";
|
||||||
import { filters } from "../webpack";
|
import { filters } from "../webpack";
|
||||||
import { Forms, React } from "../webpack/common";
|
import { React } from "../webpack/common";
|
||||||
|
|
||||||
const KbdStyles = lazyWebpack(filters.byProps(["key", "removeBuildOverride"]));
|
const KbdStyles = lazyWebpack(filters.byProps(["key", "removeBuildOverride"]));
|
||||||
|
|
||||||
@ -76,7 +78,7 @@ export default definePlugin({
|
|||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
|
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
|
||||||
<Forms.FormText variant="text-md/normal">
|
<Forms.FormText>
|
||||||
You can enable client DevTools{" "}
|
You can enable client DevTools{" "}
|
||||||
<kbd className={KbdStyles.key}>{modKey}</kbd> +{" "}
|
<kbd className={KbdStyles.key}>{modKey}</kbd> +{" "}
|
||||||
<kbd className={KbdStyles.key}>{altKey}</kbd> +{" "}
|
<kbd className={KbdStyles.key}>{altKey}</kbd> +{" "}
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Forms, React } from "../../../webpack/common";
|
import { Forms } from "@components";
|
||||||
|
|
||||||
|
import { React } from "../../../webpack/common";
|
||||||
|
|
||||||
export default function PronounsAboutComponent() {
|
export default function PronounsAboutComponent() {
|
||||||
return (
|
return (
|
||||||
|
@ -33,6 +33,7 @@ export let UserStore: Stores.UserStore;
|
|||||||
export let SelectedChannelStore: Stores.SelectedChannelStore;
|
export let SelectedChannelStore: Stores.SelectedChannelStore;
|
||||||
export let ChannelStore: Stores.ChannelStore;
|
export let ChannelStore: Stores.ChannelStore;
|
||||||
|
|
||||||
|
/** @deprecated import from "@components/Forms" instead */
|
||||||
export const Forms = {} as {
|
export const Forms = {} as {
|
||||||
FormTitle: Components.FormTitle;
|
FormTitle: Components.FormTitle;
|
||||||
FormSection: any;
|
FormSection: any;
|
||||||
@ -47,6 +48,7 @@ export let Router: any;
|
|||||||
export let TextInput: any;
|
export let TextInput: any;
|
||||||
export let Text: (props: TextProps) => JSX.Element;
|
export let Text: (props: TextProps) => JSX.Element;
|
||||||
|
|
||||||
|
/** @deprecated import from "@components/Select" instead */
|
||||||
export const Select = lazyWebpack(filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
|
export const Select = lazyWebpack(filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
|
||||||
export const Slider = lazyWebpack(filters.byCode("closestMarkerIndex", "stickToMarkers"));
|
export const Slider = lazyWebpack(filters.byCode("closestMarkerIndex", "stickToMarkers"));
|
||||||
|
|
||||||
@ -78,6 +80,7 @@ const ToastPosition = {
|
|||||||
BOTTOM: 1
|
BOTTOM: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @deprecated import from "@components/Toasts" instead */
|
||||||
export const Toasts = {
|
export const Toasts = {
|
||||||
Type: ToastType,
|
Type: ToastType,
|
||||||
Position: ToastPosition,
|
Position: ToastPosition,
|
||||||
|
82
src/webpack/components/Forms.tsx
Normal file
82
src/webpack/components/Forms.tsx
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2022 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { filters, proxyWaitFor } from "../webpack";
|
||||||
|
|
||||||
|
export enum Tag {
|
||||||
|
H1 = "h1",
|
||||||
|
H2 = "h2",
|
||||||
|
H3 = "h3",
|
||||||
|
H4 = "h4",
|
||||||
|
H5 = "h5",
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FormTitleProps extends React.PropsWithChildren<React.HTMLProps<HTMLDivElement>> {
|
||||||
|
tag?: Tag | `${Tag}`;
|
||||||
|
disabled?: boolean;
|
||||||
|
required?: boolean;
|
||||||
|
error?: string;
|
||||||
|
faded?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FormSectionProps extends React.PropsWithChildren {
|
||||||
|
title?: React.ReactNode;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
titleId?: string;
|
||||||
|
tag?: Tag | `${Tag}`;
|
||||||
|
titleClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum FormTextType {
|
||||||
|
DEFAULT = "default",
|
||||||
|
INPUT_PLACEHOLDER = "placeholder",
|
||||||
|
DESCRIPTION = "description",
|
||||||
|
LABEL_BOLD = "labelBold",
|
||||||
|
LABEL_SELECTED = "labelSelected",
|
||||||
|
LABEL_DESCRIPTOR = "labelDescriptor",
|
||||||
|
ERROR = "error",
|
||||||
|
SUCCESS = "success",
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FormTextProps extends React.PropsWithChildren<React.HTMLProps<HTMLDivElement>> {
|
||||||
|
type?: FormTextType;
|
||||||
|
selectable?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FormDividerProps {
|
||||||
|
className?: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FormTitle: (props: FormTitleProps) => JSX.Element = proxyWaitFor(filters.byCode("errorSeparator"));
|
||||||
|
export const FormSection: (props: FormSectionProps) => JSX.Element = proxyWaitFor(filters.byCode("titleClassName", "sectionTitle"));
|
||||||
|
export const FormText: (props: FormTextProps) => JSX.Element = proxyWaitFor(m => m.Types?.INPUT_PLACEHOLDER);
|
||||||
|
export const FormDivider: (props: FormDividerProps) => JSX.Element = proxyWaitFor(m => {
|
||||||
|
if (typeof m !== "function") return false;
|
||||||
|
const s = m.toString();
|
||||||
|
return s.length < 200 && s.includes("divider");
|
||||||
|
});
|
||||||
|
|
||||||
|
export const Forms = {
|
||||||
|
FormTitle,
|
||||||
|
FormSection,
|
||||||
|
FormText,
|
||||||
|
FormDivider
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Forms;
|
73
src/webpack/components/Select.tsx
Normal file
73
src/webpack/components/Select.tsx
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2022 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { lazyWebpack } from "src/utils";
|
||||||
|
|
||||||
|
import { filters } from "../webpack";
|
||||||
|
|
||||||
|
export enum Look {
|
||||||
|
FILLED,
|
||||||
|
CUSTOM
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum Position {
|
||||||
|
TOP = "top",
|
||||||
|
LEFT = "left",
|
||||||
|
RIGHT = "right",
|
||||||
|
BOTTOM = "bottom",
|
||||||
|
CENTER = "center",
|
||||||
|
WINDOW_CENTER = "window_center",
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SelectOption {
|
||||||
|
value: any;
|
||||||
|
label: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
key?: React.Key;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SelectProps {
|
||||||
|
options: SelectOption[];
|
||||||
|
placeholder?: string;
|
||||||
|
className?: string;
|
||||||
|
isDisabled?: boolean;
|
||||||
|
maxVisibleItems?: number;
|
||||||
|
look?: Look;
|
||||||
|
autoFocus?: boolean;
|
||||||
|
popoutWidth?: number;
|
||||||
|
clearable?: boolean;
|
||||||
|
onClose?(): void;
|
||||||
|
onOpen?(): void;
|
||||||
|
renderOptionLabel?(option: SelectOption): React.ReactNode;
|
||||||
|
renderOptionValue?(option: SelectOption[]): React.ReactNode;
|
||||||
|
popoutClassName?: string;
|
||||||
|
popoutPosition?: Position;
|
||||||
|
optionClassName?: string;
|
||||||
|
closeOnSelect?: boolean;
|
||||||
|
select?(value: any): void;
|
||||||
|
isSelected?(value: any): boolean;
|
||||||
|
serialize?(value: any): string;
|
||||||
|
clear?(): void;
|
||||||
|
hideIcon?: boolean;
|
||||||
|
"aria-label"?: string;
|
||||||
|
"aria-labelledby"?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Select: (props: SelectProps) => JSX.Element = lazyWebpack(filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
|
||||||
|
|
||||||
|
export default Select;
|
60
src/webpack/components/Toasts.tsx
Normal file
60
src/webpack/components/Toasts.tsx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2022 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { lazyWebpack } from "../../utils";
|
||||||
|
import { filters } from "../webpack";
|
||||||
|
|
||||||
|
export enum ToastType {
|
||||||
|
MESSAGE = 0,
|
||||||
|
SUCCESS,
|
||||||
|
FAILURE,
|
||||||
|
CUSTOM
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ToastPosition {
|
||||||
|
TOP = 0,
|
||||||
|
BOTTOM,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ToastOptions {
|
||||||
|
position?: ToastPosition;
|
||||||
|
timeout?: number;
|
||||||
|
duration?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ToastProps {
|
||||||
|
message: string;
|
||||||
|
type: ToastType;
|
||||||
|
id: string;
|
||||||
|
options?: ToastOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const showToast = lazyWebpack(filters.byCode("currentToast?"));
|
||||||
|
const popToast = lazyWebpack(filters.byCode("currentToast:null"));
|
||||||
|
|
||||||
|
export const ToastAPI = {
|
||||||
|
show(props: ToastProps): void {
|
||||||
|
return showToast(props);
|
||||||
|
},
|
||||||
|
|
||||||
|
pop(): void {
|
||||||
|
return popToast();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ToastAPI;
|
21
src/webpack/components/index.ts
Normal file
21
src/webpack/components/index.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2022 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * as Forms from "./Forms";
|
||||||
|
export * as Select from "./Select";
|
||||||
|
export * as Toasts from "./Toasts";
|
@ -180,6 +180,12 @@ export function waitFor(filter: string | string[] | FilterFn, callback: Callback
|
|||||||
subscriptions.set(filter, callback);
|
subscriptions.set(filter, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function proxyWaitFor(filter: string | string[] | FilterFn, mapper = m => m) {
|
||||||
|
let v;
|
||||||
|
waitFor(filter, m => v = mapper(m));
|
||||||
|
return proxyLazy(() => v);
|
||||||
|
}
|
||||||
|
|
||||||
export function addListener(callback: CallbackFn) {
|
export function addListener(callback: CallbackFn) {
|
||||||
listeners.add(callback);
|
listeners.add(callback);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,12 @@
|
|||||||
// https://esbuild.github.io/api/#jsx-factory
|
// https://esbuild.github.io/api/#jsx-factory
|
||||||
"jsxFactory": "Vencord.Webpack.Common.React.createElement",
|
"jsxFactory": "Vencord.Webpack.Common.React.createElement",
|
||||||
"jsxFragmentFactory": "Vencord.Webpack.Common.React.Fragment",
|
"jsxFragmentFactory": "Vencord.Webpack.Common.React.Fragment",
|
||||||
"jsx": "react"
|
"jsx": "react",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@components": ["src/webpack/components/index.ts"],
|
||||||
|
"@components/*": ["src/webpack/components/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user