mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-20 18:10:08 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00d27d1373 | ||
|
|
5f0470c351 | ||
|
|
c77d6edaae | ||
|
|
c44c66facd | ||
|
|
276e4eccd2 | ||
|
|
2fc2060a6c | ||
|
|
1143a9f3e0 | ||
|
|
5a5218a7c4 | ||
|
|
8a887ca858 | ||
|
|
0ce1b5499d | ||
|
|
554163cc5d | ||
|
|
d6b00b0733 | ||
|
|
f8ddf210f0 | ||
|
|
4024b76918 | ||
|
|
245dd0f3cf | ||
|
|
7161e757e9 | ||
|
|
c60d1e9787 | ||
|
|
0e0e0d204a | ||
|
|
e5120928d3 | ||
|
|
abbd3cddae |
@@ -6,7 +6,8 @@
|
|||||||
{
|
{
|
||||||
"preset": "angular",
|
"preset": "angular",
|
||||||
"releaseRules": [
|
"releaseRules": [
|
||||||
{"type": "chore", "scope": "classes", "release": "patch"}
|
{"type": "chore", "scope": "classes", "release": "patch"},
|
||||||
|
{"type": "*", "scope": "docs", "release": false}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
70
CHANGELOG.md
70
CHANGELOG.md
@@ -1,3 +1,73 @@
|
|||||||
|
# [3.7.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.6.1...v3.7.0) (2022-10-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **modal:** support for latest steamos preview ([5f0470c](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/5f0470c351dc4ecb24ea3e928ff0b0199c399fa4))
|
||||||
|
|
||||||
|
## [3.6.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.6.0...v3.6.1) (2022-10-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **plugin:** export RoutePatch ([#39](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/39)) ([c44c66f](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/c44c66facd4e158aa4fe0a69f62a2ca3add805c1))
|
||||||
|
|
||||||
|
# [3.6.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.6...v3.6.0) (2022-10-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **plugin:** add alwaysRender ([2fc2060](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/2fc2060a6c0d9414d1c36a1a022fdc6f2cd7f8bb))
|
||||||
|
|
||||||
|
## [3.5.6](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.5...v3.5.6) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Dialog:** remove not exported dialog button ([#37](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/37)) ([5a5218a](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/5a5218a7c43f6a90fc4de5f7a0cd524d1cd298d6))
|
||||||
|
|
||||||
|
## [3.5.5](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.4...v3.5.5) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **sidebarnavigation:** no dont ([0ce1b54](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/0ce1b5499df699f602aa83ab87ad8b246d133eac))
|
||||||
|
|
||||||
|
## [3.5.4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.3...v3.5.4) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **sidebarnavigation:** allow null pags ([d6b00b0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/d6b00b07337f7a9d38813eeec7c0a848d5c15f17))
|
||||||
|
|
||||||
|
## [3.5.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.2...v3.5.3) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **tabs:** fix props and add example ([4024b76](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/4024b76918eea43e43a24c162a937877f18627f0))
|
||||||
|
|
||||||
|
## [3.5.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.1...v3.5.2) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Tabs:** make onShowTab required ([7161e75](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/7161e757e9c98d677510e03eb2606ce58152f3b1))
|
||||||
|
|
||||||
|
## [3.5.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.0...v3.5.1) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Tabs:** actually export it lmao ([0e0e0d2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/0e0e0d204adc8d888f05e98edb6c1a1a171d00bb))
|
||||||
|
|
||||||
|
# [3.5.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.4.0...v3.5.0) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **Tabs:** initial tabs component, props, docs ([abbd3cd](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/abbd3cddae24039cbc9b7d955924431e8fbacf94))
|
||||||
|
|
||||||
# [3.4.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.3.5...v3.4.0) (2022-10-06)
|
# [3.4.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.3.5...v3.4.0) (2022-10-06)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "3.4.0",
|
"version": "3.7.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "3.4.0",
|
"version": "3.7.0",
|
||||||
"license": "LGPL-2.1",
|
"license": "LGPL-2.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "^1.2.6"
|
"minimist": "^1.2.6"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "3.4.0",
|
"version": "3.7.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",
|
||||||
|
|||||||
@@ -51,13 +51,6 @@ export const DialogButtonSecondary = Object.values(CommonUIModule).find(
|
|||||||
mod?.render?.toString()?.includes('Secondary')
|
mod?.render?.toString()?.includes('Secondary')
|
||||||
) as FC<DialogButtonProps>;
|
) as FC<DialogButtonProps>;
|
||||||
|
|
||||||
export const DialogButtonSmall = Object.values(CommonUIModule).find(
|
|
||||||
(mod: any) =>
|
|
||||||
mod?.render?.toString()?.includes('Object.assign({type:"button"') &&
|
|
||||||
mod?.render?.toString()?.includes('DialogButton') &&
|
|
||||||
mod?.render?.toString()?.includes('Small')
|
|
||||||
) as FC<DialogButtonProps>;
|
|
||||||
|
|
||||||
// This is the "main" button. The Primary can act as a submit button,
|
// This is the "main" button. The Primary can act as a submit button,
|
||||||
// therefore secondary is chosen (also for backwards comp. reasons)
|
// therefore secondary is chosen (also for backwards comp. reasons)
|
||||||
export const DialogButton = DialogButtonSecondary;
|
export const DialogButton = DialogButtonSecondary;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { FC, ReactNode } from 'react';
|
import { FC, ReactNode } from 'react';
|
||||||
|
import { findSP } from '../utils';
|
||||||
import { findModuleChild } from '../webpack';
|
import { findModuleChild } from '../webpack';
|
||||||
|
|
||||||
// All of the popout options + strTitle are related. Proper usage is not yet known...
|
// All of the popout options + strTitle are related. Proper usage is not yet known...
|
||||||
@@ -27,7 +28,7 @@ export interface ShowModalResult {
|
|||||||
Update: (modal: ReactNode) => void;
|
Update: (modal: ReactNode) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const showModal: (modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => Promise<ShowModalResult> = findModuleChild((m) => {
|
const showModalRaw: (modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => Promise<ShowModalResult> = findModuleChild((m) => {
|
||||||
if (typeof m !== 'object') return undefined;
|
if (typeof m !== 'object') return undefined;
|
||||||
for (let prop in m) {
|
for (let prop in m) {
|
||||||
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
||||||
@@ -36,6 +37,10 @@ export const showModal: (modal: ReactNode, parent?: EventTarget, props?: ShowMod
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const showModal = (modal: ReactNode, parent?: EventTarget, props?: ShowModalProps): Promise<ShowModalResult> => {
|
||||||
|
return showModalRaw(modal, parent || findSP(), props)
|
||||||
|
}
|
||||||
|
|
||||||
export interface ModalRootProps {
|
export interface ModalRootProps {
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
onCancel?(): void;
|
onCancel?(): void;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ReactNode, VFC } from 'react';
|
|||||||
|
|
||||||
import { Module, findModuleChild } from '../webpack';
|
import { Module, findModuleChild } from '../webpack';
|
||||||
|
|
||||||
export interface SidebarNavigationPages {
|
export interface SidebarNavigationPage {
|
||||||
title: string;
|
title: string;
|
||||||
content: ReactNode;
|
content: ReactNode;
|
||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
@@ -16,7 +16,7 @@ export interface SidebarNavigationPages {
|
|||||||
|
|
||||||
export interface SidebarNavigationProps {
|
export interface SidebarNavigationProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
pages: SidebarNavigationPages[];
|
pages: SidebarNavigationPage[];
|
||||||
showTitle?: boolean;
|
showTitle?: boolean;
|
||||||
disableRouteReporting?: boolean;
|
disableRouteReporting?: boolean;
|
||||||
page?: string;
|
page?: string;
|
||||||
|
|||||||
74
src/deck-components/Tabs.tsx
Normal file
74
src/deck-components/Tabs.tsx
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { FC, ReactNode } from 'react';
|
||||||
|
import { findModule } from '../webpack';
|
||||||
|
import { FooterLegendProps } from './FooterLegend';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Individual tab objects for the Tabs component
|
||||||
|
*
|
||||||
|
* `id` ID of this tab, can be used with activeTab to auto-focus a given tab
|
||||||
|
* `title` Title shown in the header bar
|
||||||
|
* `renderTabAddon` Return a {@link ReactNode} to render it next to the tab title, i.e. the counts for each tab on the Media page
|
||||||
|
* `content` Content of the tab
|
||||||
|
* `footer` Sets up button handlers and labels
|
||||||
|
*/
|
||||||
|
export interface Tab {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
renderTabAddon?: () => ReactNode;
|
||||||
|
content: ReactNode;
|
||||||
|
footer?: FooterLegendProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Props for the {@link Tabs}
|
||||||
|
*
|
||||||
|
* `tabs` array of {@link Tab}
|
||||||
|
* `activeTab` tab currently active, needs to be one of the tabs {@link Tab.id}, must be set using a `useState` in the `onShowTab` handler
|
||||||
|
* `onShowTab` Called when the active tab should change, needs to set `activeTab`. See example.
|
||||||
|
* `autoFocusContents` Whether to automatically focus the tab contents or not.
|
||||||
|
* `footer` Sets up button handlers and labels
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const Component: FC = () => {
|
||||||
|
* const [currentTab, setCurrentTab] = useState<string>("Tab1");
|
||||||
|
*
|
||||||
|
* return (
|
||||||
|
* <Tabs
|
||||||
|
* title="Theme Manager"
|
||||||
|
* activeTab={currentTabRoute}
|
||||||
|
* onShowTab={(tabID: string) => {
|
||||||
|
* setCurrentTabRoute(tabID);
|
||||||
|
* }}
|
||||||
|
* tabs={[
|
||||||
|
* {
|
||||||
|
* title: "Tab 1",
|
||||||
|
* content: <Tab1Component />,
|
||||||
|
* id: "Tab1",
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* title: "Tab 2",
|
||||||
|
* content: <Tab2Component />,
|
||||||
|
* id: "Tab2",
|
||||||
|
* },
|
||||||
|
* ]}
|
||||||
|
* />
|
||||||
|
* );
|
||||||
|
* };
|
||||||
|
*/
|
||||||
|
export interface TabsProps {
|
||||||
|
tabs: Tab[];
|
||||||
|
activeTab: string;
|
||||||
|
onShowTab: (tab: string) => void;
|
||||||
|
autoFocusContents?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabs component as used in the library and media tabs. See {@link TabsProps}
|
||||||
|
*/
|
||||||
|
export const Tabs = Object.values(findModule((m) => {
|
||||||
|
if (typeof m !== 'object') return false;
|
||||||
|
for (let prop in m) {
|
||||||
|
if (m[prop]?.Unbleed) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})).find((x: any) => x?.type?.toString()?.includes("((function(){")) as FC<TabsProps>;
|
||||||
@@ -17,6 +17,7 @@ export * from './SliderField';
|
|||||||
export * from './Spinner';
|
export * from './Spinner';
|
||||||
export * from './static-classes';
|
export * from './static-classes';
|
||||||
export * from './SteamSpinner';
|
export * from './SteamSpinner';
|
||||||
|
export * from './Tabs';
|
||||||
export * from './TextField';
|
export * from './TextField';
|
||||||
export * from './Toggle';
|
export * from './Toggle';
|
||||||
export * from './ToggleField';
|
export * from './ToggleField';
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface Plugin {
|
|||||||
icon: JSX.Element;
|
icon: JSX.Element;
|
||||||
content?: JSX.Element;
|
content?: JSX.Element;
|
||||||
onDismount?(): void;
|
onDismount?(): void;
|
||||||
|
alwaysRender?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ServerResponseSuccess<TRes> {
|
interface ServerResponseSuccess<TRes> {
|
||||||
@@ -20,7 +21,7 @@ interface ServerResponseError {
|
|||||||
|
|
||||||
export type ServerResponse<TRes> = ServerResponseSuccess<TRes> | ServerResponseError;
|
export type ServerResponse<TRes> = ServerResponseSuccess<TRes> | ServerResponseError;
|
||||||
|
|
||||||
type RoutePatch = (route: RouteProps) => RouteProps;
|
export type RoutePatch = (route: RouteProps) => RouteProps;
|
||||||
|
|
||||||
export interface RouterHook {
|
export interface RouterHook {
|
||||||
addRoute(path: string, component: ComponentType, props?: Omit<RouteProps, 'path' | 'children'>): void;
|
addRoute(path: string, component: ComponentType, props?: Omit<RouteProps, 'path' | 'children'>): void;
|
||||||
@@ -37,8 +38,8 @@ export interface ToastData {
|
|||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
contentClassName?: string;
|
contentClassName?: string;
|
||||||
duration?: number
|
duration?: number;
|
||||||
critical?: boolean
|
critical?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Toaster {
|
export interface Toaster {
|
||||||
|
|||||||
@@ -7,4 +7,16 @@ export function joinClassNames(...classes: string[]): string {
|
|||||||
|
|
||||||
export function sleep(ms: number) {
|
export function sleep(ms: number) {
|
||||||
return new Promise(res => setTimeout(res, ms));
|
return new Promise(res => setTimeout(res, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the SP window, since it is a render target as of {10-19-2022}'s beta
|
||||||
|
*/
|
||||||
|
export function findSP(): Window {
|
||||||
|
// old (SP as host)
|
||||||
|
if (document.title == 'SP') return window;
|
||||||
|
// new (SP as popup)
|
||||||
|
return FocusNavController.m_ActiveContext.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root
|
||||||
|
.Element.ownerDocument.defaultView;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user