Compare commits
4 Commits
v1.0.8
...
feat/relat
Author | SHA1 | Date | |
---|---|---|---|
|
0e06b8d34c | ||
|
b972aa1663 | ||
|
3bf81ee0fa | ||
|
486230a335 |
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.0.8",
|
"version": "1.0.6",
|
||||||
"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,9 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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 { React } from "@webpack/common";
|
import { Margins, React } from "@webpack/common";
|
||||||
|
|
||||||
import { ErrorCard } from "./ErrorCard";
|
import { ErrorCard } from "./ErrorCard";
|
||||||
|
|
||||||
@ -85,13 +84,15 @@ 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={{ overflow: "hidden" }}>
|
<ErrorCard style={{
|
||||||
|
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.top8}>
|
<pre className={Margins.marginTop8}>
|
||||||
{this.state.stack}
|
{this.state.stack}
|
||||||
</pre>
|
</pre>
|
||||||
)}
|
)}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
.vc-error-card {
|
|
||||||
padding: 2em;
|
|
||||||
background-color: #e7828430;
|
|
||||||
border: 1px solid #e78284;
|
|
||||||
border-radius: 5px;
|
|
||||||
color: var(--text-normal, white);
|
|
||||||
}
|
|
@ -16,15 +16,24 @@
|
|||||||
* 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 "./ErrorCard.css";
|
import { Card } from "@webpack/common";
|
||||||
|
|
||||||
import { classes } from "@utils/misc";
|
interface Props {
|
||||||
import type { HTMLProps } from "react";
|
style?: React.CSSProperties;
|
||||||
|
className?: string;
|
||||||
export function ErrorCard(props: React.PropsWithChildren<HTMLProps<HTMLDivElement>>) {
|
}
|
||||||
|
export function ErrorCard(props: React.PropsWithChildren<Props>) {
|
||||||
return (
|
return (
|
||||||
<div {...props} className={classes(props.className, "vc-error-card")}>
|
<Card className={props.className} style={
|
||||||
|
{
|
||||||
|
padding: "2em",
|
||||||
|
backgroundColor: "#e7828430",
|
||||||
|
borderColor: "#e78284",
|
||||||
|
color: "var(--text-normal)",
|
||||||
|
...props.style
|
||||||
|
}
|
||||||
|
}>
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ export default definePlugin({
|
|||||||
{
|
{
|
||||||
find: '"Menu API',
|
find: '"Menu API',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /function.{0,80}type===(\i)\).{0,50}navigable:.+?Menu API/s,
|
match: /function.{0,80}type===(.{1,3})\..{1,3}\).{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,9 +18,6 @@
|
|||||||
|
|
||||||
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.`);
|
||||||
@ -32,48 +29,19 @@ 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 {
|
||||||
wp: Webpack,
|
toClip: IS_WEB ? WEB_ONLY("toClip") : window.DiscordNative.clipboard.copy,
|
||||||
wpc: Webpack.wreq.c,
|
fromClip: IS_WEB ? WEB_ONLY("fromClip") : window.DiscordNative.clipboard.read,
|
||||||
wreq: Webpack.wreq,
|
wp: Vencord.Webpack,
|
||||||
wpsearch: search,
|
wpc: Vencord.Webpack.wreq.c,
|
||||||
wpex: extract,
|
wreq: Vencord.Webpack.wreq,
|
||||||
|
wpsearch: Vencord.Webpack.search,
|
||||||
|
wpex: Vencord.Webpack.extract,
|
||||||
wpexs: (code: string) => Vencord.Webpack.extract(Vencord.Webpack.findModuleId(code)!),
|
wpexs: (code: string) => Vencord.Webpack.extract(Vencord.Webpack.findModuleId(code)!),
|
||||||
find: newFindWrapper(f => f),
|
findByProps: Vencord.Webpack.findByProps,
|
||||||
findAll,
|
find: Vencord.Webpack.find,
|
||||||
findByProps: newFindWrapper(filters.byProps),
|
Plugins: Vencord.Plugins,
|
||||||
findAllByProps: (...props: string[]) => findAll(filters.byProps(...props)),
|
React: Vencord.Webpack.Common.React,
|
||||||
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(),
|
||||||
|
250
src/plugins/relationshipNotifier.ts
Normal file
250
src/plugins/relationshipNotifier.ts
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
/*
|
||||||
|
* 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 { showNotification } from "@api/Notifications";
|
||||||
|
import { definePluginSettings } from "@api/settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { FluxDispatcher, UserUtils } from "@webpack/common";
|
||||||
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
|
enum RelationshipType {
|
||||||
|
NONE = 0,
|
||||||
|
FRIEND = 1,
|
||||||
|
BLOCKED = 2,
|
||||||
|
PENDING_INCOMING = 3,
|
||||||
|
PENDING_OUTGOING = 4,
|
||||||
|
IMPLICIT = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RelationshipPayload {
|
||||||
|
type: "RELATIONSHIP_ADD" | "RELATIONSHIP_REMOVE" | "RELATIONSHIP_UPDATE";
|
||||||
|
relationship: {
|
||||||
|
id: string;
|
||||||
|
type: RelationshipType;
|
||||||
|
since?: Date;
|
||||||
|
nickname?: string;
|
||||||
|
user?: User;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
friend: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Show a notification when a friend is added or removed",
|
||||||
|
options: [{
|
||||||
|
label: "Friend added and removed",
|
||||||
|
value: "ALL",
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
label: "Only when added",
|
||||||
|
value: "CREATE",
|
||||||
|
}, {
|
||||||
|
label: "Only when removed",
|
||||||
|
value: "REMOVE",
|
||||||
|
}, {
|
||||||
|
label: "No notifications",
|
||||||
|
value: "NONE",
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
outgoingRequest: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Show a notification when you send or cancel a friend request",
|
||||||
|
options: [{
|
||||||
|
label: "Request sent and cancelled",
|
||||||
|
value: "ALL",
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
label: "Only when sent",
|
||||||
|
value: "CREATE",
|
||||||
|
}, {
|
||||||
|
label: "Only when cancelled",
|
||||||
|
value: "REMOVE",
|
||||||
|
}, {
|
||||||
|
label: "No notifications",
|
||||||
|
value: "NONE",
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
incomingRequest: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Show a notification when an incoming request is received or cancelled",
|
||||||
|
options: [{
|
||||||
|
label: "Request received and cancelled",
|
||||||
|
value: "ALL",
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
label: "Only when received",
|
||||||
|
value: "CREATE",
|
||||||
|
}, {
|
||||||
|
label: "Only when cancelled",
|
||||||
|
value: "REMOVE",
|
||||||
|
}, {
|
||||||
|
label: "No notifications",
|
||||||
|
value: "NONE",
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
block: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Show a notification when you block or unblock a user",
|
||||||
|
options: [{
|
||||||
|
label: "Blocking and unblocking",
|
||||||
|
value: "ALL",
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
label: "Only when blocking",
|
||||||
|
value: "CREATE",
|
||||||
|
}, {
|
||||||
|
label: "Only when unblocking",
|
||||||
|
value: "REMOVE",
|
||||||
|
}, {
|
||||||
|
label: "No notifications",
|
||||||
|
value: "NONE",
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "RelationshipNotifier",
|
||||||
|
authors: [Devs.Megu],
|
||||||
|
description: "Receive notifications for friend requests, removals, blocks, etc.",
|
||||||
|
settings,
|
||||||
|
|
||||||
|
start() {
|
||||||
|
FluxDispatcher.subscribe("RELATIONSHIP_ADD", onRelationshipUpdate);
|
||||||
|
FluxDispatcher.subscribe("RELATIONSHIP_UPDATE", onRelationshipUpdate);
|
||||||
|
FluxDispatcher.subscribe("RELATIONSHIP_REMOVE", onRelationshipRemove);
|
||||||
|
},
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
FluxDispatcher.unsubscribe("RELATIONSHIP_ADD", onRelationshipUpdate);
|
||||||
|
FluxDispatcher.unsubscribe("RELATIONSHIP_UPDATE", onRelationshipUpdate);
|
||||||
|
FluxDispatcher.unsubscribe("RELATIONSHIP_REMOVE", onRelationshipRemove);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function onRelationshipUpdate({ relationship }: RelationshipPayload) {
|
||||||
|
if (!relationship.id) return;
|
||||||
|
const user = await UserUtils.fetchUser(relationship.id);
|
||||||
|
if (!user) return;
|
||||||
|
|
||||||
|
function onClick() {
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "USER_PROFILE_MODAL_OPEN",
|
||||||
|
userId: user.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (relationship.type) {
|
||||||
|
case RelationshipType.FRIEND: {
|
||||||
|
if (!["ALL", "CREATE"].includes(settings.store.friend)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "Friend Added",
|
||||||
|
body: `${user.username} is now your friend.`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RelationshipType.PENDING_INCOMING: {
|
||||||
|
if (!["ALL", "CREATE"].includes(settings.store.incomingRequest)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "Friend Request Received",
|
||||||
|
body: `${user.username} sent you a friend request.`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RelationshipType.PENDING_OUTGOING: {
|
||||||
|
if (!["ALL", "CREATE"].includes(settings.store.outgoingRequest)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "Friend Request Sent",
|
||||||
|
body: `You sent a friend request to ${user.username}`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RelationshipType.BLOCKED: {
|
||||||
|
if (!["ALL", "CREATE"].includes(settings.store.block)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "User Blocked",
|
||||||
|
body: `You just blocked ${user.username}`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onRelationshipRemove({ relationship }: RelationshipPayload) {
|
||||||
|
if (!relationship.id) return;
|
||||||
|
const user = await UserUtils.fetchUser(relationship.id);
|
||||||
|
if (!user) return;
|
||||||
|
|
||||||
|
function onClick() {
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "USER_PROFILE_MODAL_OPEN",
|
||||||
|
userId: user.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (relationship.type) {
|
||||||
|
case RelationshipType.FRIEND: {
|
||||||
|
if (!["ALL", "REMOVE"].includes(settings.store.friend)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "Friend Removed",
|
||||||
|
body: `${user.username} is no longer on your friends list.`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RelationshipType.PENDING_INCOMING: {
|
||||||
|
if (!["ALL", "REMOVE"].includes(settings.store.incomingRequest)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "Friend Request Cancelled",
|
||||||
|
body: `${user.username} cancelled their friend request.`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RelationshipType.PENDING_OUTGOING: {
|
||||||
|
if (!["ALL", "REMOVE"].includes(settings.store.outgoingRequest)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "Friend Request Cancelled",
|
||||||
|
body: `You cancelled your friend request to ${user.username}`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RelationshipType.BLOCKED: {
|
||||||
|
if (!["ALL", "REMOVE"].includes(settings.store.block)) break;
|
||||||
|
showNotification({
|
||||||
|
title: "User Unblocked",
|
||||||
|
body: `You just unblocked ${user.username}`,
|
||||||
|
icon: user.getAvatarURL(),
|
||||||
|
onClick
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,10 +30,10 @@ export default definePlugin({
|
|||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: ".removeObscurity=function",
|
find: ".revealSpoiler=function",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.removeObscurity=function\((\i)\){/,
|
match: /\.revealSpoiler=function\((.{1,2})\){/,
|
||||||
replace: ".removeObscurity=function($1){$self.reveal($1);"
|
replace: ".revealSpoiler=function($1){$self.reveal($1);"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -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('"top",spacing:');
|
const Avatar = findByCodeLazy(".Positions.TOP,spacing:");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showAvatars: {
|
showAvatars: {
|
||||||
|
@ -48,7 +48,7 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// channel mentions
|
// channel mentions
|
||||||
find: ".shouldCloseDefaultModals",
|
find: ".EMOJI_IN_MESSAGE_HOVER",
|
||||||
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)()",
|
||||||
|
@ -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: Array<string | null | undefined>) {
|
export function classes(...classes: string[]) {
|
||||||
return classes.filter(Boolean).join(" ");
|
return classes.filter(c => typeof c === "string").join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,10 +32,10 @@ export const Forms = {
|
|||||||
FormText: waitForComponent<t.FormText>("FormText", m => m.Types?.INPUT_PLACEHOLDER),
|
FormText: waitForComponent<t.FormText>("FormText", m => m.Types?.INPUT_PLACEHOLDER),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Card = waitForComponent<t.Card>("Card", m => m.Types?.PRIMARY && m.defaultProps);
|
export const Card = waitForComponent<t.Card>("Card", m => m.Types?.PRIMARY === "cardPrimary");
|
||||||
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", filters.byCode("shouldShowTooltip:!1", "clickableOnMobile||"));
|
export const Tooltip = waitForComponent<t.Tooltip>("Tooltip", ["Positions", "Colors"]);
|
||||||
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,10 +45,6 @@ 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,17 +90,16 @@ export type Tooltip = ComponentType<{
|
|||||||
|
|
||||||
/** Tooltip.Colors.BLACK */
|
/** Tooltip.Colors.BLACK */
|
||||||
color?: string;
|
color?: string;
|
||||||
/** TooltipPositions.TOP */
|
/** Tooltip.Positions.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;
|
||||||
@ -235,49 +234,6 @@ 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,6 +307,13 @@ 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
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user