@steambrew/client
Version:
A support library for creating plugins with Millennium.
43 lines (42 loc) • 2.27 kB
JavaScript
import { CommonUIModule } from '../webpack';
const CommonDialogDivs = Object.values(CommonUIModule).filter(
/* mar 19 2026 accept both jsx and createElement divs */
(m) => typeof m === 'object' &&
/(jsx\)|createElement)\("div",(\{\.\.\.|\bObject\.assign\(\{},)/.test(m?.render?.toString()));
const MappedDialogDivs = new Map(Object.values(CommonDialogDivs).map((m) => {
try {
const renderedDiv = m.render({});
// Take only the first class name segment as it identifies the element we want
return [renderedDiv.props.className.split(' ')[0], m];
}
catch (e) {
console.error('[DFL:Dialog]: failed to render common dialog component', e);
return [null, null];
}
}));
/** @component React Components */
export const DialogHeader = (MappedDialogDivs.get('DialogHeader') ||
Object.values(CommonUIModule).find((component) => {
const str = component?.render?.toString?.();
return str?.includes('role:"heading"') && str.includes(')("DialogHeader",');
}));
/** @component React Components */
export const DialogSubHeader = MappedDialogDivs.get('DialogSubHeader');
/** @component React Components */
export const DialogFooter = MappedDialogDivs.get('DialogFooter');
/** @component React Components */
export const DialogLabel = MappedDialogDivs.get('DialogLabel');
/** @component React Components */
export const DialogBodyText = MappedDialogDivs.get('DialogBodyText');
/** @component React Components */
export const DialogBody = MappedDialogDivs.get('DialogBody');
/** @component React Components */
export const DialogControlsSection = MappedDialogDivs.get('DialogControlsSection');
/** @component React Components */
export const DialogControlsSectionHeader = MappedDialogDivs.get('DialogControlsSectionHeader');
/** @component React Components */
export const DialogButtonPrimary = Object.values(CommonUIModule).find((mod) => mod?.render?.toString()?.includes('"DialogButton","_DialogLayout","Primary"'));
/** @component React Components */
export const DialogButtonSecondary = Object.values(CommonUIModule).find((mod) => mod?.render?.toString()?.includes('"DialogButton","_DialogLayout","Secondary"'));
/** @component React Components */
export const DialogButton = DialogButtonSecondary;