Skip to content

Commit

Permalink
I hate testing mappings so much
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite committed Oct 15, 2024
1 parent cacf971 commit fc4db42
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 59 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonlight-mod/mappings",
"version": "1.0.5",
"version": "1.0.6",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion src/mappings/discord/actions/ContextMenuActionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import register from "../../../registry";
type ContextMenuActionCreators = {
closeContextMenu: () => void;
// TODO: these have some extra args
openContextMenu: (event: Event, element: () => React.ReactNode) => void;
openContextMenu: (
event: React.SyntheticEvent,
element: () => React.ReactNode
) => void;
openContextMenuLazy: Function;
};

Expand Down
98 changes: 42 additions & 56 deletions src/mappings/discord/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,39 @@ import type {
} from "react";
import * as CSS from "csstype";

type Modify<T, R> = Pick<T, Exclude<keyof T, keyof R>> & R;

// #region TextInput
export enum TextInputSizes {
DEFAULT = "inputDefault",
MINI = "inputMini"
}

export type TextInputProps = Modify<
React.InputHTMLAttributes<HTMLInputElement>,
{
value?: string;
name?: string;
className?: string;
inputClassName?: string;
inputPrefix?: string;
disabled?: boolean;
size?: TextInputSizes;
editable?: boolean;
inputRef?: Ref<any>;
prefixElement?: Component;
focusProps?: PropsWithoutRef<any>;
error?: string;
minLength?: number;
maxLength?: number;
onChange?: (value: string, name: string) => void;
onFocus?: (event: any, name: string) => void;
onBlur?: (event: any, name: string) => void;
}
>;

export interface TextInput
extends ComponentClass<
PropsWithoutRef<{
value?: string;
name?: string;
className?: string;
inputClassName?: string;
inputPrefix?: string;
disabled?: boolean;
size?: TextInputSizes;
editable?: boolean;
inputRef?: Ref<any>;
prefixElement?: Component;
focusProps?: PropsWithoutRef<any>;
error?: string;
minLength?: number;
maxLength?: number;
onChange?: (value: string, name: string) => void;
onFocus?: (event: any, name: string) => void;
onBlur?: (event: any, name: string) => void;
// this is literally just the input element's type field
type?:
| "button"
| "checkbox"
| "color"
| "date"
| "datetime-local"
| "email"
| "file"
| "hidden"
| "image"
| "month"
| "number"
| "password"
| "radio"
| "range"
| "reset"
| "search"
| "submit"
| "tel"
| "text"
| "time"
| "url"
| "week";
}>
> {
extends ComponentClass<PropsWithoutRef<TextInputProps>> {
Sizes: typeof TextInputSizes;
}
// #endregion
Expand Down Expand Up @@ -624,17 +605,22 @@ export type TextVariant =
| "code";

export type Text = ComponentType<
PropsWithChildren<{
className?: string;
style?: CSSProperties;
variant: TextVariant;
tag?: string;
selectable?: boolean;
lineClamp?: number;
color?: string;
tabularNumbers?: boolean;
scaleFontToUserSettings?: boolean;
}>
PropsWithChildren<
Modify<
React.HTMLAttributes<HTMLDivElement>,
{
className?: string;
style?: CSSProperties;
variant: TextVariant;
tag?: string;
selectable?: boolean;
lineClamp?: number;
color?: string;
tabularNumbers?: boolean;
scaleFontToUserSettings?: boolean;
}
>
>
>;
// #endregion

Expand Down
6 changes: 5 additions & 1 deletion src/mappings/discord/utils/HTTPUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ export type HTTPUtilsFunction = (
data: HTTPUtilsRequest
) => Promise<HTTPUtilsResponse>;

type HTTPUtils = {
type HTTP = {
get: HTTPUtilsFunction;
post: HTTPUtilsFunction;
put: HTTPUtilsFunction;
patch: HTTPUtilsFunction;
del: HTTPUtilsFunction;
};

type HTTPUtils = {
HTTP: HTTP;
};

register((moonmap) => {
const name = "discord/utils/HTTPUtils";
moonmap.register({
Expand Down

0 comments on commit fc4db42

Please sign in to comment.