mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-25 15:58:31 +00:00
Merge branch 'Vendicated:main' into main
This commit is contained in:
commit
30baa33ba3
19 changed files with 254 additions and 65 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import Logger from "@utils/Logger";
|
||||||
|
import { Margins } from "@utils/margins";
|
||||||
import { LazyComponent } from "@utils/misc";
|
import { LazyComponent } from "@utils/misc";
|
||||||
import { Margins, React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
|
|
||||||
import { ErrorCard } from "./ErrorCard";
|
import { ErrorCard } from "./ErrorCard";
|
||||||
|
|
||||||
|
@ -84,15 +85,13 @@ const ErrorBoundary = LazyComponent(() => {
|
||||||
const msg = this.props.message || "An error occurred while rendering this Component. More info can be found below and in your console.";
|
const msg = this.props.message || "An error occurred while rendering this Component. More info can be found below and in your console.";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorCard style={{
|
<ErrorCard style={{ overflow: "hidden" }}>
|
||||||
overflow: "hidden",
|
|
||||||
}}>
|
|
||||||
<h1>Oh no!</h1>
|
<h1>Oh no!</h1>
|
||||||
<p>{msg}</p>
|
<p>{msg}</p>
|
||||||
<code>
|
<code>
|
||||||
{this.state.message}
|
{this.state.message}
|
||||||
{!!this.state.stack && (
|
{!!this.state.stack && (
|
||||||
<pre className={Margins.marginTop8}>
|
<pre className={Margins.top8}>
|
||||||
{this.state.stack}
|
{this.state.stack}
|
||||||
</pre>
|
</pre>
|
||||||
)}
|
)}
|
||||||
|
|
7
src/components/ErrorCard.css
Normal file
7
src/components/ErrorCard.css
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.vc-error-card {
|
||||||
|
padding: 2em;
|
||||||
|
background-color: #e7828430;
|
||||||
|
border: 1px solid #e78284;
|
||||||
|
border-radius: 5px;
|
||||||
|
color: var(--text-normal, white);
|
||||||
|
}
|
|
@ -16,24 +16,15 @@
|
||||||
* 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 { Card } from "@webpack/common";
|
import "./ErrorCard.css";
|
||||||
|
|
||||||
interface Props {
|
import { classes } from "@utils/misc";
|
||||||
style?: React.CSSProperties;
|
import type { HTMLProps } from "react";
|
||||||
className?: string;
|
|
||||||
}
|
export function ErrorCard(props: React.PropsWithChildren<HTMLProps<HTMLDivElement>>) {
|
||||||
export function ErrorCard(props: React.PropsWithChildren<Props>) {
|
|
||||||
return (
|
return (
|
||||||
<Card className={props.className} style={
|
<div {...props} className={classes(props.className, "vc-error-card")}>
|
||||||
{
|
|
||||||
padding: "2em",
|
|
||||||
backgroundColor: "#e7828430",
|
|
||||||
borderColor: "#e78284",
|
|
||||||
color: "var(--text-normal)",
|
|
||||||
...props.style
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
{props.children}
|
{props.children}
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: '"Menu API',
|
find: '"Menu API',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /function.{0,80}type===(.{1,3})\..{1,3}\).{0,50}navigable:.+?Menu API/s,
|
match: /function.{0,80}type===(\i)\).{0,50}navigable:.+?Menu API/s,
|
||||||
replace: (m, mod) => {
|
replace: (m, mod) => {
|
||||||
let nicenNames = "";
|
let nicenNames = "";
|
||||||
const redefines = [] as string[];
|
const redefines = [] as string[];
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
import * as Webpack from "@webpack";
|
||||||
|
import { extract, filters, findAll, search } from "@webpack";
|
||||||
|
import { React } from "@webpack/common";
|
||||||
|
|
||||||
const WEB_ONLY = (f: string) => () => {
|
const WEB_ONLY = (f: string) => () => {
|
||||||
throw new Error(`'${f}' is Discord Desktop only.`);
|
throw new Error(`'${f}' is Discord Desktop only.`);
|
||||||
|
@ -29,19 +32,48 @@ export default definePlugin({
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
|
|
||||||
getShortcuts() {
|
getShortcuts() {
|
||||||
|
function newFindWrapper(filterFactory: (props: any) => Webpack.FilterFn) {
|
||||||
|
const cache = new Map<string, any>();
|
||||||
|
|
||||||
|
return function (filterProps: any) {
|
||||||
|
const cacheKey = String(filterProps);
|
||||||
|
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
||||||
|
|
||||||
|
const matches = findAll(filterFactory(filterProps));
|
||||||
|
|
||||||
|
const result = (() => {
|
||||||
|
switch (matches.length) {
|
||||||
|
case 0: return null;
|
||||||
|
case 1: return matches[0];
|
||||||
|
default:
|
||||||
|
const uniqueMatches = [...new Set(matches)];
|
||||||
|
if (uniqueMatches.length > 1)
|
||||||
|
console.warn(`Warning: This filter matches ${matches.length} modules. Make it more specific!\n`, uniqueMatches);
|
||||||
|
|
||||||
|
return matches[0];
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
if (result && cacheKey) cache.set(cacheKey, result);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
toClip: IS_WEB ? WEB_ONLY("toClip") : window.DiscordNative.clipboard.copy,
|
|
||||||
fromClip: IS_WEB ? WEB_ONLY("fromClip") : window.DiscordNative.clipboard.read,
|
|
||||||
wp: Vencord.Webpack,
|
wp: Vencord.Webpack,
|
||||||
wpc: Vencord.Webpack.wreq.c,
|
wpc: Webpack.wreq.c,
|
||||||
wreq: Vencord.Webpack.wreq,
|
wreq: Webpack.wreq,
|
||||||
wpsearch: Vencord.Webpack.search,
|
wpsearch: search,
|
||||||
wpex: Vencord.Webpack.extract,
|
wpex: extract,
|
||||||
wpexs: (code: string) => Vencord.Webpack.extract(Vencord.Webpack.findModuleId(code)!),
|
wpexs: (code: string) => Vencord.Webpack.extract(Vencord.Webpack.findModuleId(code)!),
|
||||||
findByProps: Vencord.Webpack.findByProps,
|
find: newFindWrapper(f => f),
|
||||||
find: Vencord.Webpack.find,
|
findAll,
|
||||||
Plugins: Vencord.Plugins,
|
findByProps: newFindWrapper(filters.byProps),
|
||||||
React: Vencord.Webpack.Common.React,
|
findAllByProps: (...props: string[]) => findAll(filters.byProps(...props)),
|
||||||
|
findByCode: newFindWrapper(filters.byCode),
|
||||||
|
findAllByCode: (code: string) => findAll(filters.byCode(code)),
|
||||||
|
PluginsApi: Vencord.Plugins,
|
||||||
|
plugins: Vencord.Plugins.plugins,
|
||||||
|
React,
|
||||||
Settings: Vencord.Settings,
|
Settings: Vencord.Settings,
|
||||||
Api: Vencord.Api,
|
Api: Vencord.Api,
|
||||||
reload: () => location.reload(),
|
reload: () => location.reload(),
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/settings";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { isTruthy } from "@utils/guards";
|
||||||
import { useAwaiter } from "@utils/misc";
|
import { useAwaiter } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { filters, findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
import { filters, findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
||||||
|
@ -56,11 +57,11 @@ interface ActivityAssets {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Activity {
|
interface Activity {
|
||||||
state: string;
|
state?: string;
|
||||||
details?: string;
|
details?: string;
|
||||||
timestamps?: {
|
timestamps?: {
|
||||||
start?: Number;
|
start?: number;
|
||||||
end?: Number;
|
end?: number;
|
||||||
};
|
};
|
||||||
assets?: ActivityAssets;
|
assets?: ActivityAssets;
|
||||||
buttons?: Array<string>;
|
buttons?: Array<string>;
|
||||||
|
@ -70,7 +71,7 @@ interface Activity {
|
||||||
button_urls?: Array<string>;
|
button_urls?: Array<string>;
|
||||||
};
|
};
|
||||||
type: ActivityType;
|
type: ActivityType;
|
||||||
flags: Number;
|
flags: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ActivityType {
|
enum ActivityType {
|
||||||
|
@ -93,13 +94,13 @@ const numOpt = (description: string) => ({
|
||||||
onChange: setRpc
|
onChange: setRpc
|
||||||
}) as const;
|
}) as const;
|
||||||
|
|
||||||
const choice = (label: string, value: any, _default?: Boolean) => ({
|
const choice = (label: string, value: any, _default?: boolean) => ({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
default: _default
|
default: _default
|
||||||
}) as const;
|
}) as const;
|
||||||
|
|
||||||
const choiceOpt = (description: string, options) => ({
|
const choiceOpt = <T,>(description: string, options: T) => ({
|
||||||
type: OptionType.SELECT,
|
type: OptionType.SELECT,
|
||||||
description,
|
description,
|
||||||
onChange: setRpc,
|
onChange: setRpc,
|
||||||
|
@ -173,13 +174,13 @@ async function createActivity(): Promise<Activity | undefined> {
|
||||||
activity.buttons = [
|
activity.buttons = [
|
||||||
buttonOneText,
|
buttonOneText,
|
||||||
buttonTwoText
|
buttonTwoText
|
||||||
].filter(Boolean);
|
].filter(isTruthy);
|
||||||
|
|
||||||
activity.metadata = {
|
activity.metadata = {
|
||||||
button_urls: [
|
button_urls: [
|
||||||
buttonOneURL,
|
buttonOneURL,
|
||||||
buttonTwoURL
|
buttonTwoURL
|
||||||
].filter(Boolean)
|
].filter(isTruthy)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,12 +207,10 @@ async function createActivity(): Promise<Activity | undefined> {
|
||||||
delete activity[k];
|
delete activity[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
// WHAT DO YOU WANT FROM ME
|
|
||||||
// eslint-disable-next-line consistent-return
|
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setRpc(disable?: Boolean) {
|
async function setRpc(disable?: boolean) {
|
||||||
const activity: Activity | undefined = await createActivity();
|
const activity: Activity | undefined = await createActivity();
|
||||||
|
|
||||||
FluxDispatcher.dispatch({
|
FluxDispatcher.dispatch({
|
||||||
|
|
|
@ -34,7 +34,7 @@ interface Activity {
|
||||||
state: string;
|
state: string;
|
||||||
details?: string;
|
details?: string;
|
||||||
timestamps?: {
|
timestamps?: {
|
||||||
start?: Number;
|
start?: number;
|
||||||
};
|
};
|
||||||
assets?: ActivityAssets;
|
assets?: ActivityAssets;
|
||||||
buttons?: Array<string>;
|
buttons?: Array<string>;
|
||||||
|
@ -43,8 +43,8 @@ interface Activity {
|
||||||
metadata?: {
|
metadata?: {
|
||||||
button_urls?: Array<string>;
|
button_urls?: Array<string>;
|
||||||
};
|
};
|
||||||
type: Number;
|
type: number;
|
||||||
flags: Number;
|
flags: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TrackData {
|
interface TrackData {
|
||||||
|
|
|
@ -30,10 +30,10 @@ export default definePlugin({
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: ".revealSpoiler=function",
|
find: ".removeObscurity=function",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.revealSpoiler=function\((.{1,2})\){/,
|
match: /\.removeObscurity=function\((\i)\){/,
|
||||||
replace: ".revealSpoiler=function($1){$self.reveal($1);"
|
replace: ".removeObscurity=function($1){$self.reveal($1);"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
91
src/plugins/supportHelper.tsx
Normal file
91
src/plugins/supportHelper.tsx
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 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 { DataStore } from "@api/index";
|
||||||
|
import { Devs, SUPPORT_CHANNEL_ID } from "@utils/constants";
|
||||||
|
import { makeCodeblock } from "@utils/misc";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { isOutdated } from "@utils/updater";
|
||||||
|
import { Alerts, FluxDispatcher, Forms, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
|
import gitHash from "~git-hash";
|
||||||
|
import plugins from "~plugins";
|
||||||
|
|
||||||
|
import settings from "./settings";
|
||||||
|
|
||||||
|
const REMEMBER_DISMISS_KEY = "Vencord-SupportHelper-Dismiss";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "SupportHelper",
|
||||||
|
required: true,
|
||||||
|
description: "Helps me provide support to you",
|
||||||
|
authors: [Devs.Ven],
|
||||||
|
|
||||||
|
commands: [{
|
||||||
|
name: "vencord-debug",
|
||||||
|
description: "Send Vencord Debug info",
|
||||||
|
predicate: ctx => ctx.channel.id === SUPPORT_CHANNEL_ID,
|
||||||
|
execute() {
|
||||||
|
const { RELEASE_CHANNEL } = window.GLOBAL_ENV;
|
||||||
|
|
||||||
|
const debugInfo = `
|
||||||
|
**Vencord Debug Info**
|
||||||
|
|
||||||
|
> Discord Branch: ${RELEASE_CHANNEL}
|
||||||
|
> Client: ${typeof DiscordNative === "undefined" ? window.armcord ? "Armcord" : `Web (${navigator.userAgent})` : `Desktop (Electron v${settings.electronVersion})`}
|
||||||
|
> Platform: ${window.navigator.platform}
|
||||||
|
> Vencord Version: ${gitHash}${settings.additionalInfo}
|
||||||
|
> Outdated: ${isOutdated}
|
||||||
|
> Enabled Plugins:
|
||||||
|
${makeCodeblock(Object.keys(plugins).filter(Vencord.Plugins.isPluginEnabled).join(", "))}
|
||||||
|
`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: debugInfo.trim()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
|
rememberDismiss() {
|
||||||
|
DataStore.set(REMEMBER_DISMISS_KEY, gitHash);
|
||||||
|
},
|
||||||
|
|
||||||
|
start() {
|
||||||
|
FluxDispatcher.subscribe("CHANNEL_SELECT", async ({ channelId }) => {
|
||||||
|
if (channelId !== SUPPORT_CHANNEL_ID) return;
|
||||||
|
|
||||||
|
const myId = BigInt(UserStore.getCurrentUser().id);
|
||||||
|
if (Object.values(Devs).some(d => d.id === myId)) return;
|
||||||
|
|
||||||
|
if (isOutdated && gitHash !== await DataStore.get(REMEMBER_DISMISS_KEY)) {
|
||||||
|
Alerts.show({
|
||||||
|
title: "Hold on!",
|
||||||
|
body: <div>
|
||||||
|
<Forms.FormText>You are using an outdated version of Vencord! Chances are, your issue is already fixed.</Forms.FormText>
|
||||||
|
<Forms.FormText>
|
||||||
|
Please first update using the Updater Page in Settings, or use the VencordInstaller (Update Vencord Button)
|
||||||
|
to do so, in case you can't access the Updater page.
|
||||||
|
</Forms.FormText>
|
||||||
|
</div>,
|
||||||
|
onCancel: this.rememberDismiss,
|
||||||
|
onConfirm: this.rememberDismiss
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -24,7 +24,7 @@ import { findByCodeLazy } from "@webpack";
|
||||||
import { GuildMemberStore, React, RelationshipStore } from "@webpack/common";
|
import { GuildMemberStore, React, RelationshipStore } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
const Avatar = findByCodeLazy(".Positions.TOP,spacing:");
|
const Avatar = findByCodeLazy('"top",spacing:');
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showAvatars: {
|
showAvatars: {
|
||||||
|
|
|
@ -48,7 +48,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// channel mentions
|
// channel mentions
|
||||||
find: ".EMOJI_IN_MESSAGE_HOVER",
|
find: ".shouldCloseDefaultModals",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /onClick:(\i)(?=,.{0,30}className:"channelMention")/,
|
match: /onClick:(\i)(?=,.{0,30}className:"channelMention")/,
|
||||||
replace: "onClick:(_vcEv)=>(_vcEv.detail>=2||_vcEv.target.className.includes('MentionText'))&&($1)()",
|
replace: "onClick:(_vcEv)=>(_vcEv.detail>=2||_vcEv.target.className.includes('MentionText'))&&($1)()",
|
||||||
|
|
|
@ -22,6 +22,7 @@ import gitRemote from "~git-remote";
|
||||||
export const WEBPACK_CHUNK = "webpackChunkdiscord_app";
|
export const WEBPACK_CHUNK = "webpackChunkdiscord_app";
|
||||||
export const REACT_GLOBAL = "Vencord.Webpack.Common.React";
|
export const REACT_GLOBAL = "Vencord.Webpack.Common.React";
|
||||||
export const VENCORD_USER_AGENT = `Vencord/${gitHash}${gitRemote ? ` (https://github.com/${gitRemote})` : ""}`;
|
export const VENCORD_USER_AGENT = `Vencord/${gitHash}${gitRemote ? ` (https://github.com/${gitRemote})` : ""}`;
|
||||||
|
export const SUPPORT_CHANNEL_ID = "1026515880080842772";
|
||||||
|
|
||||||
// Add yourself here if you made a plugin
|
// Add yourself here if you made a plugin
|
||||||
export const Devs = /* #__PURE__*/ Object.freeze({
|
export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
|
|
25
src/utils/guards.ts
Normal file
25
src/utils/guards.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 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 function isTruthy<T>(item: T): item is Exclude<T, 0 | "" | false | null | undefined> {
|
||||||
|
return Boolean(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isNonNullish<T>(item: T): item is Exclude<T, null | undefined> {
|
||||||
|
return item != null;
|
||||||
|
}
|
|
@ -141,8 +141,8 @@ export function humanFriendlyJoin(elements: any[], mapper: (e: any) => string =
|
||||||
* Calls .join(" ") on the arguments
|
* Calls .join(" ") on the arguments
|
||||||
* classes("one", "two") => "one two"
|
* classes("one", "two") => "one two"
|
||||||
*/
|
*/
|
||||||
export function classes(...classes: string[]) {
|
export function classes(...classes: Array<string | null | undefined>) {
|
||||||
return classes.filter(c => typeof c === "string").join(" ");
|
return classes.filter(Boolean).join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -229,9 +229,12 @@ type PluginSettingType<O extends PluginSettingDef> = O extends PluginSettingStri
|
||||||
O extends PluginSettingSliderDef ? number :
|
O extends PluginSettingSliderDef ? number :
|
||||||
O extends PluginSettingComponentDef ? any :
|
O extends PluginSettingComponentDef ? any :
|
||||||
never;
|
never;
|
||||||
|
type PluginSettingDefaultType<O extends PluginSettingDef> = O extends PluginSettingSelectDef ? (
|
||||||
|
O["options"] extends { default?: boolean; }[] ? O["options"][number]["value"] : undefined
|
||||||
|
) : O extends { default: infer T; } ? T : undefined;
|
||||||
|
|
||||||
type SettingsStore<D extends SettingsDefinition> = {
|
type SettingsStore<D extends SettingsDefinition> = {
|
||||||
[K in keyof D]: PluginSettingType<D[K]>;
|
[K in keyof D]: PluginSettingType<D[K]> | PluginSettingDefaultType<D[K]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** An instance of defined plugin settings */
|
/** An instance of defined plugin settings */
|
||||||
|
|
|
@ -35,7 +35,7 @@ export const Forms = {
|
||||||
export const Card = waitForComponent<t.Card>("Card", m => m.Types?.PRIMARY && m.defaultProps);
|
export const Card = waitForComponent<t.Card>("Card", m => m.Types?.PRIMARY && m.defaultProps);
|
||||||
export const Button = waitForComponent<t.Button>("Button", ["Hovers", "Looks", "Sizes"]);
|
export const Button = waitForComponent<t.Button>("Button", ["Hovers", "Looks", "Sizes"]);
|
||||||
export const Switch = waitForComponent<t.Switch>("Switch", filters.byCode("tooltipNote", "ringTarget"));
|
export const Switch = waitForComponent<t.Switch>("Switch", filters.byCode("tooltipNote", "ringTarget"));
|
||||||
export const Tooltip = waitForComponent<t.Tooltip>("Tooltip", ["Positions", "Colors"]);
|
export const Tooltip = waitForComponent<t.Tooltip>("Tooltip", filters.byCode("shouldShowTooltip:!1", "clickableOnMobile||"));
|
||||||
export const Timestamp = waitForComponent<t.Timestamp>("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"));
|
export const Timestamp = waitForComponent<t.Timestamp>("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"));
|
||||||
export const TextInput = waitForComponent<t.TextInput>("TextInput", ["defaultProps", "Sizes", "contextType"]);
|
export const TextInput = waitForComponent<t.TextInput>("TextInput", ["defaultProps", "Sizes", "contextType"]);
|
||||||
export const TextArea = waitForComponent<t.TextArea>("TextArea", filters.byCode("handleSetRef", "textArea"));
|
export const TextArea = waitForComponent<t.TextArea>("TextArea", filters.byCode("handleSetRef", "textArea"));
|
||||||
|
@ -45,6 +45,10 @@ export const Text = waitForComponent<t.Text>("Text", m => {
|
||||||
return (s.length < 1500 && s.includes("data-text-variant") && s.includes("always-white"));
|
return (s.length < 1500 && s.includes("data-text-variant") && s.includes("always-white"));
|
||||||
});
|
});
|
||||||
export const Select = waitForComponent<t.Select>("Select", filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
|
export const Select = waitForComponent<t.Select>("Select", filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
|
||||||
|
const searchableSelectFilter = filters.byCode("autoFocus", ".Messages.SELECT");
|
||||||
|
export const SearchableSelect = waitForComponent<t.SearchableSelect>("SearchableSelect", m =>
|
||||||
|
m.render && searchableSelectFilter(m.render)
|
||||||
|
);
|
||||||
export const Slider = waitForComponent<t.Slider>("Slider", filters.byCode("closestMarkerIndex", "stickToMarkers"));
|
export const Slider = waitForComponent<t.Slider>("Slider", filters.byCode("closestMarkerIndex", "stickToMarkers"));
|
||||||
export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]);
|
export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]);
|
||||||
|
|
||||||
|
|
48
src/webpack/common/types/components.d.ts
vendored
48
src/webpack/common/types/components.d.ts
vendored
|
@ -90,16 +90,17 @@ export type Tooltip = ComponentType<{
|
||||||
|
|
||||||
/** Tooltip.Colors.BLACK */
|
/** Tooltip.Colors.BLACK */
|
||||||
color?: string;
|
color?: string;
|
||||||
/** Tooltip.Positions.TOP */
|
/** TooltipPositions.TOP */
|
||||||
position?: string;
|
position?: string;
|
||||||
|
|
||||||
tooltipClassName?: string;
|
tooltipClassName?: string;
|
||||||
tooltipContentClassName?: string;
|
tooltipContentClassName?: string;
|
||||||
}> & {
|
}> & {
|
||||||
Positions: Record<"BOTTOM" | "CENTER" | "LEFT" | "RIGHT" | "TOP" | "WINDOW_CENTER", string>;
|
|
||||||
Colors: Record<"BLACK" | "BRAND" | "CUSTOM" | "GREEN" | "GREY" | "PRIMARY" | "RED" | "YELLOW", string>;
|
Colors: Record<"BLACK" | "BRAND" | "CUSTOM" | "GREEN" | "GREY" | "PRIMARY" | "RED" | "YELLOW", string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TooltipPositions = Record<"BOTTOM" | "CENTER" | "LEFT" | "RIGHT" | "TOP" | "WINDOW_CENTER", string>;
|
||||||
|
|
||||||
export type Card = ComponentType<PropsWithChildren<HTMLProps<HTMLDivElement> & {
|
export type Card = ComponentType<PropsWithChildren<HTMLProps<HTMLDivElement> & {
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
outline?: boolean;
|
outline?: boolean;
|
||||||
|
@ -234,6 +235,49 @@ export type Select = ComponentType<PropsWithChildren<{
|
||||||
"aria-labelledby"?: boolean;
|
"aria-labelledby"?: boolean;
|
||||||
}>>;
|
}>>;
|
||||||
|
|
||||||
|
export type SearchableSelect = ComponentType<PropsWithChildren<{
|
||||||
|
placeholder?: string;
|
||||||
|
options: ReadonlyArray<SelectOption>; // TODO
|
||||||
|
value?: SelectOption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* - 0 ~ Filled
|
||||||
|
* - 1 ~ Custom
|
||||||
|
*/
|
||||||
|
look?: 0 | 1;
|
||||||
|
className?: string;
|
||||||
|
popoutClassName?: string;
|
||||||
|
wrapperClassName?: string;
|
||||||
|
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center";
|
||||||
|
optionClassName?: string;
|
||||||
|
|
||||||
|
autoFocus?: boolean;
|
||||||
|
isDisabled?: boolean;
|
||||||
|
clearable?: boolean;
|
||||||
|
closeOnSelect?: boolean;
|
||||||
|
clearOnSelect?: boolean;
|
||||||
|
multi?: boolean;
|
||||||
|
|
||||||
|
onChange(value: any): void;
|
||||||
|
onSearchChange?(value: string): void;
|
||||||
|
|
||||||
|
onClose?(): void;
|
||||||
|
onOpen?(): void;
|
||||||
|
onBlur?(): void;
|
||||||
|
|
||||||
|
renderOptionPrefix?(option: SelectOption): ReactNode;
|
||||||
|
renderOptionSuffix?(option: SelectOption): ReactNode;
|
||||||
|
|
||||||
|
filter?(option: SelectOption[], query: string): SelectOption[];
|
||||||
|
|
||||||
|
centerCaret?: boolean;
|
||||||
|
debounceTime?: number;
|
||||||
|
maxVisibleItems?: number;
|
||||||
|
popoutWidth?: number;
|
||||||
|
|
||||||
|
"aria-labelledby"?: boolean;
|
||||||
|
}>>;
|
||||||
|
|
||||||
export type Slider = ComponentType<PropsWithChildren<{
|
export type Slider = ComponentType<PropsWithChildren<{
|
||||||
initialValue: number;
|
initialValue: number;
|
||||||
defaultValue?: number;
|
defaultValue?: number;
|
||||||
|
|
|
@ -307,13 +307,6 @@ export function findByPropsLazy(...props: string[]) {
|
||||||
return findLazy(filters.byProps(...props));
|
return findLazy(filters.byProps(...props));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find all modules that have the specified properties
|
|
||||||
*/
|
|
||||||
export function findAllByProps(...props: string[]) {
|
|
||||||
return findAll(filters.byProps(...props));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a function by its code
|
* Find a function by its code
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue