mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-23 11:28:48 +02:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fe986aaba | ||
|
|
bc2bec4b83 | ||
|
|
a99fb4a22d | ||
|
|
d8794ef4d3 | ||
|
|
23ed5dd157 | ||
|
|
210b0389f7 | ||
|
|
198f96abb5 | ||
|
|
244ae128da | ||
|
|
377d7adde8 | ||
|
|
f34b9de97f |
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,3 +1,30 @@
|
|||||||
|
# [0.6.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v0.5.1...v0.6.0) (2022-06-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **husky:** wrong script for husky caused problems when installing ([bc2bec4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/bc2bec4b839d691e20beb090327a359c9e93f1cc))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **dropdown:** add dropdown ([a99fb4a](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/a99fb4a22dcea3b6cd2a52f0dbd274d9a10f2e35))
|
||||||
|
* **sidebar-navigation:** add sidebar navigation component ([d8794ef](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/d8794ef4d36b25e600123d41696b0d5cc10dc2af))
|
||||||
|
|
||||||
|
## [0.5.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v0.5.0...v0.5.1) (2022-06-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **classes:** switch static-classes to findModule ([244ae12](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/244ae128da03e0687f1ba0b0e5b5b548b581277a))
|
||||||
|
|
||||||
|
# [0.5.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v0.4.2...v0.5.0) (2022-06-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **utils:** add joinClassNames util ([f34b9de](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/f34b9de97f61eb5b075d6adedfcacfa5e097943b))
|
||||||
|
|
||||||
## [0.4.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v0.4.1...v0.4.2) (2022-06-06)
|
## [0.4.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v0.4.1...v0.4.2) (2022-06-06)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "0.4.2",
|
"version": "0.6.0",
|
||||||
"description": "A library for building decky plugins",
|
"description": "A library for building decky plugins",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"dev": "tsc -b -w",
|
"dev": "tsc -b -w",
|
||||||
"prepack": "npm run build",
|
"prepack": "npm run build",
|
||||||
"test": "echo 'No tests for now!'",
|
"test": "echo 'No tests for now!'",
|
||||||
"postinstall": "husky install",
|
"prepare": "husky install",
|
||||||
"commit": "git-cz"
|
"commit": "git-cz"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
50
src/deck-components/Dropdown.tsx
Normal file
50
src/deck-components/Dropdown.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { ReactNode, VFC } from 'react';
|
||||||
|
|
||||||
|
import { CommonUIModule } from '../webpack';
|
||||||
|
|
||||||
|
export interface SingleDropdownOption {
|
||||||
|
data: number;
|
||||||
|
label: string;
|
||||||
|
|
||||||
|
options?: never;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MultiDropdownOption {
|
||||||
|
label: string;
|
||||||
|
options: DropdownOption[];
|
||||||
|
|
||||||
|
data?: never;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DropdownOption = SingleDropdownOption | MultiDropdownOption;
|
||||||
|
|
||||||
|
export interface DropdownProps {
|
||||||
|
rgOptions: DropdownOption[];
|
||||||
|
selectedOption: number | null;
|
||||||
|
disabled?: boolean;
|
||||||
|
onMenuWillOpen?(showMenu: () => void): void;
|
||||||
|
onMenuOpened?(): void;
|
||||||
|
onChange?(data: SingleDropdownOption): void;
|
||||||
|
contextMenuPositionOptions?: any;
|
||||||
|
menuLabel?: string;
|
||||||
|
strDefaultLabel?: string;
|
||||||
|
renderButtonValue?(element: ReactNode): ReactNode;
|
||||||
|
focusable?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Dropdown = Object.values(CommonUIModule).find(
|
||||||
|
(mod: any) => mod?.prototype?.SetSelectedOption && mod?.prototype?.BuildMenu,
|
||||||
|
) as VFC<DropdownProps>;
|
||||||
|
|
||||||
|
export interface DropdownItemProps extends DropdownProps {
|
||||||
|
label?: string;
|
||||||
|
tooltip?: string;
|
||||||
|
description?: string;
|
||||||
|
layout?: 'below';
|
||||||
|
bottomSeparator?: boolean;
|
||||||
|
indentLevel?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DropdownItem = Object.values(CommonUIModule).find((mod: any) =>
|
||||||
|
mod?.toString()?.includes('"dropDownControlRef","description"'),
|
||||||
|
) as VFC<DropdownItemProps>;
|
||||||
25
src/deck-components/SidebarNavigation.tsx
Normal file
25
src/deck-components/SidebarNavigation.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { ReactNode, VFC } from 'react';
|
||||||
|
|
||||||
|
import { Module, findModuleChild } from '../webpack';
|
||||||
|
|
||||||
|
export interface SidebarNavigationPages {
|
||||||
|
title: string;
|
||||||
|
route: string;
|
||||||
|
content: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SidebarNavigationProps {
|
||||||
|
title?: string;
|
||||||
|
pages: SidebarNavigationPages[];
|
||||||
|
showTitle?: boolean;
|
||||||
|
disableRouteReporting?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SidebarNavigation = findModuleChild((mod: Module) => {
|
||||||
|
for (let prop in mod) {
|
||||||
|
if (mod[prop]?.toString()?.includes('"disableRouteReporting"')) {
|
||||||
|
return mod[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}) as VFC<SidebarNavigationProps>;
|
||||||
@@ -25,5 +25,3 @@ export interface TextFieldProps {
|
|||||||
export const TextField = Object.values(CommonUIModule).find(
|
export const TextField = Object.values(CommonUIModule).find(
|
||||||
(mod: Module) => mod?.validateUrl && mod?.validateEmail,
|
(mod: Module) => mod?.validateUrl && mod?.validateEmail,
|
||||||
) as VFC<TextFieldProps>;
|
) as VFC<TextFieldProps>;
|
||||||
|
|
||||||
console.log(TextField);
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
export * from './Button';
|
export * from './Button';
|
||||||
export * from './ButtonItem';
|
export * from './ButtonItem';
|
||||||
|
export * from './Dropdown';
|
||||||
export * from './Menu';
|
export * from './Menu';
|
||||||
export * from './Modal';
|
export * from './Modal';
|
||||||
export * from './Panel';
|
export * from './Panel';
|
||||||
export * from './Router';
|
export * from './Router';
|
||||||
|
export * from './SidebarNavigation';
|
||||||
export * from './Slider';
|
export * from './Slider';
|
||||||
export * from './Spinner';
|
export * from './Spinner';
|
||||||
export * from './static-classes';
|
export * from './static-classes';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { findModuleChild } from '../webpack';
|
import { findModule } from '../webpack';
|
||||||
|
|
||||||
type StaticClasses = Record<
|
type StaticClasses = Record<
|
||||||
| 'ActiveTab'
|
| 'ActiveTab'
|
||||||
@@ -157,26 +157,32 @@ type QuickAccessControlsClasses = Record<
|
|||||||
string
|
string
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const staticClasses: StaticClasses = findModuleChild((mod) => {
|
export const staticClasses: StaticClasses = findModule((mod) => {
|
||||||
if (typeof mod !== 'object') return false;
|
if (typeof mod !== 'object') return false;
|
||||||
|
|
||||||
if (mod.TransitionMenuDelay) {
|
if (mod.TransitionMenuDelay) {
|
||||||
return mod;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const gamepadDialogClasses: GamepadDialogClasses = findModuleChild((mod) => {
|
export const gamepadDialogClasses: GamepadDialogClasses = findModule((mod) => {
|
||||||
if (typeof mod !== 'object') return false;
|
if (typeof mod !== 'object') return false;
|
||||||
|
|
||||||
if (mod.WithFirstRow) {
|
if (mod.WithFirstRow) {
|
||||||
return mod;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const quickAccessControlsClasses: QuickAccessControlsClasses = findModuleChild((mod) => {
|
export const quickAccessControlsClasses: QuickAccessControlsClasses = findModule((mod) => {
|
||||||
if (typeof mod !== 'object') return false;
|
if (typeof mod !== 'object') return false;
|
||||||
|
|
||||||
if (mod.PanelSectionRow) {
|
if (mod.PanelSectionRow) {
|
||||||
return mod;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -85,3 +85,7 @@ export function unpatch(obj: any, name: any): void {
|
|||||||
export function getReactInstance(o: HTMLElement | Element | Node) {
|
export function getReactInstance(o: HTMLElement | Element | Node) {
|
||||||
return o[Object.keys(o).find(k => k.startsWith('__reactInternalInstance')) as string]
|
return o[Object.keys(o).find(k => k.startsWith('__reactInternalInstance')) as string]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function joinClassNames(...classes: string[]): string {
|
||||||
|
return classes.join(" ");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user