From ef41d17e43ace78921a0d8b59f756abe6e05b285 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Thu, 26 May 2022 10:15:32 +0200 Subject: [PATCH] Add back panels --- src/deck-components/Button.tsx | 8 +++++--- src/deck-components/Panel.tsx | 23 +++++++++++++++++++++++ src/deck-components/index.ts | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 src/deck-components/Panel.tsx diff --git a/src/deck-components/Button.tsx b/src/deck-components/Button.tsx index 79356df..427b54b 100644 --- a/src/deck-components/Button.tsx +++ b/src/deck-components/Button.tsx @@ -18,10 +18,12 @@ interface ButtonProps { onSubmit?(e: SubmitEvent): void; } -const DialogButton = Object.values(CommonUIModule).find((mod: any) => - mod?.render?.toString()?.includes('Object.assign({type:"button"') && mod?.render?.toString()?.includes('DialogButton') +const DialogButton = Object.values(CommonUIModule).find( + (mod: any) => + mod?.render?.toString()?.includes('Object.assign({type:"button"') && + mod?.render?.toString()?.includes('DialogButton'), ) as any; // Button isn't exported, so call DialogButton to grab it -export const Button = DialogButton!.render({}).type as FC // its actually a forwarded ref but that doesn't really matter in usage \ No newline at end of file +export const Button = DialogButton!.render({}).type as FC; // its actually a forwarded ref but that doesn't really matter in usage diff --git a/src/deck-components/Panel.tsx b/src/deck-components/Panel.tsx new file mode 100644 index 0000000..c616fc7 --- /dev/null +++ b/src/deck-components/Panel.tsx @@ -0,0 +1,23 @@ +import { FC } from 'react'; + +import { findModuleChild } from '../webpack'; + +interface PanelSectionProps { + title?: string; + spinner?: boolean; +} + +const [panelSection, mod] = findModuleChild((mod: any) => { + for (let prop in mod) { + if (mod[prop]?.toString()?.includes('.PanelSection')) { + return [mod[prop], mod]; + } + } + return null; +}); + +export const PanelSection = panelSection as FC; + +export const PanelSectionRow = Object.values(mod).filter( + (exp: any) => !exp?.toString()?.includes('.PanelSection'), +)[0] as FC; diff --git a/src/deck-components/index.ts b/src/deck-components/index.ts index 2d31aca..1dcf386 100644 --- a/src/deck-components/index.ts +++ b/src/deck-components/index.ts @@ -2,6 +2,7 @@ export * from './Button'; export * from './ButtonItem'; export * from './Menu'; export * from './Modal'; +export * from './Panel'; export * from './Slider'; export * from './Spinner'; export * from './static-classes';