Skip to content

Commit 261162c

Browse files
committed
fix(components): update for latest beta
1 parent f8fda38 commit 261162c

File tree

7 files changed

+37
-10
lines changed

7 files changed

+37
-10
lines changed

.husky/commit-msg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
npx --no -- commitlint --edit "${1}"

src/components/Dialog.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@ export interface DialogButtonProps extends DialogCommonProps, FooterLegendProps
5252
}
5353

5454
const CommonDialogDivs = Object.values(CommonUIModule).filter(
55-
(m: any) => typeof m === 'object' && m?.render?.toString().includes('createElement("div",{...') ||
56-
m?.render?.toString().includes('createElement("div",Object.assign({},'),
55+
(m: any) => typeof m === 'object' &&
56+
// New
57+
(
58+
m?.render?.toString().includes('jsx)("div",{...') ||
59+
m?.render?.toString().includes('jsx)("div",Object.assign({},')
60+
) ||
61+
// Old
62+
(
63+
m?.render?.toString().includes('createElement("div",{...') ||
64+
m?.render?.toString().includes('createElement("div",Object.assign({},')
65+
)
5766
);
5867
const MappedDialogDivs = new Map(
5968
Object.values(CommonDialogDivs).map((m: any) => {

src/components/ProgressBar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export const ProgressBar = findModuleExport((e: Export) =>
2828
) as FC<ProgressBarProps>;
2929

3030
export const ProgressBarWithInfo = findModuleExport((e: Export) =>
31-
e?.toString?.()?.includes('.ProgressBarFieldStatus},'),
31+
// new || old
32+
e?.toString?.()?.includes('.ProgressBarFieldStatus,children') || e?.toString?.()?.includes('.ProgressBarFieldStatus},'),
3233
) as FC<ProgressBarWithInfoProps>;
3334

3435
const progressBarItemRegex = createPropListRegex(["indeterminate", "nTransitionSec", "nProgress"]);

src/components/Scroll.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export const ScrollPanel = ScrollingModuleProps.find((prop: any) =>
1111
) as FC<{ children?: ReactNode }>;
1212

1313
export const ScrollPanelGroup: FC<{ children?: ReactNode }> = findModuleExport((e: Export) =>
14-
e?.render?.toString().includes('.FocusVisibleChild()),[])'),
14+
// new || old
15+
e?.render?.toString().includes('.FocusVisibleChild(),[])') || e?.render?.toString().includes('.FocusVisibleChild()),[])'),
1516
);

src/components/Spinner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { FC, SVGAttributes } from 'react';
33
import { IconsModule } from '../webpack';
44

55
// TODO type this and other icons?
6-
export const Spinner = Object.values(IconsModule)?.find(
7-
(mod: any) => mod?.toString && /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString()),
6+
export const Spinner = IconsModule && Object.values(IconsModule)?.find(
7+
(mod: any) => mod?.toString && /Spinner\),children:\[\(0,\w+\.jsx\)\("path",\{d:"M18 /.test(mod.toString()) || /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString()),
88
) as FC<SVGAttributes<SVGElement>>;

src/utils/react/fc.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
4242
};
4343
component.prototype.isReactComponent = true;
4444
let stubsApplied = false;
45+
const patchJsx = window.SP_REACTDOM.version.startsWith("19.");
46+
let oldJsx = window.SP_JSX?.jsx;
47+
let oldJsxs = window.SP_JSX?.jsxs;
4548
let oldCreateElement = window.SP_REACT.createElement;
4649

4750
const applyStubsIfNeeded = () => {
@@ -55,6 +58,18 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
5558
loggingEnabled && console.trace("createElement trace");
5659
return Object.create(component.prototype);
5760
};
61+
if (patchJsx) {
62+
window.SP_JSX.jsx = () => {
63+
loggingEnabled && logger.debug("jsx hook called");
64+
loggingEnabled && console.trace("jsx trace");
65+
return Object.create(component.prototype);
66+
}
67+
window.SP_JSX.jsxs = () => {
68+
loggingEnabled && logger.debug("jsxs hook called");
69+
loggingEnabled && console.trace("jsxs trace");
70+
return Object.create(component.prototype);
71+
}
72+
}
5873
}
5974
}
6075

@@ -64,6 +79,10 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
6479
stubsApplied = false;
6580
removeHookStubs();
6681
window.SP_REACT.createElement = oldCreateElement;
82+
if (patchJsx) {
83+
window.SP_JSX.jsx = oldJsx;
84+
window.SP_JSX.jsxs = oldJsxs;
85+
}
6786
}
6887
}
6988

src/webpack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const CommonUIModule = findModule((m: Module) => {
154154
});
155155

156156
export const IconsModule = findModuleByExport(
157-
(e) => e?.toString && /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(e.toString()),
157+
(e) => e?.toString && /Spinner\),children:\[\(0,\w+\.jsx\)\("path",\{d:"M18 /.test(e.toString()) || /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(e.toString()),
158158
);
159159

160160
export const ReactRouter = findModuleByExport((e) => e.computeRootMatch);

0 commit comments

Comments
 (0)