-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#7670: Use <IsolatedComponent>
for DocumentView
, EphemeralFormContent
, CustomFormComponent
#8200
Changes from 33 commits
46d2207
708ba2b
0671574
386b02c
6a273f9
360f843
e3018e8
4760ee0
a2c75b9
9760393
df1ec00
a6dc0fe
652339a
c5aa5f6
3d139a2
123b53a
16542a2
fb4d8a4
a349a66
efb53fe
f195c5c
ccb84c2
cc46b6a
98384ca
fee63aa
e29f974
34af2e3
98b0f8e
82b3dd4
3313bc3
1334a91
0f559cb
8b2f5e8
3695681
9d86817
bf236b9
c7aaa29
ee2aa0a
de42f14
9db1a1d
4a01ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from "react"; | ||
import { type JsonObject } from "type-fest"; | ||
import { dataStore } from "@/background/messenger/strict/api"; | ||
import { validateRegistryId } from "@/types/helpers"; | ||
|
@@ -46,6 +47,8 @@ import { getOutputReference, validateOutputKey } from "@/runtime/runtimeTypes"; | |
import { type BrickConfig } from "@/bricks/types"; | ||
import { isExpression } from "@/utils/expressionUtils"; | ||
import { getPlatform } from "@/platform/platformContext"; | ||
import IsolatedComponent from "@/components/IsolatedComponent"; | ||
import { type CustomFormComponentProps } from "./CustomFormComponent"; | ||
|
||
interface DatabaseResult { | ||
success: boolean; | ||
|
@@ -297,10 +300,20 @@ export class CustomFormRenderer extends RendererABC { | |
normalizedData, | ||
}); | ||
|
||
// Changed webpackChunkName to de-conflict with the manual entry in webpack used to load in the stylesheets | ||
const { default: CustomFormComponent } = await import( | ||
/* webpackChunkName: "CustomFormRendererComponent" */ | ||
"./CustomFormComponent" | ||
const CustomFormComponent: React.FunctionComponent< | ||
CustomFormComponentProps | ||
> = (props) => ( | ||
<IsolatedComponent | ||
name="CustomFormComponent" | ||
noStyle={disableParentStyles} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
lazy={async () => | ||
import( | ||
/* webpackChunkName: "isolated/CustomFormComponent" */ | ||
"./CustomFormComponent" | ||
) | ||
} | ||
factory={(CustomFormComponent) => <CustomFormComponent {...props} />} | ||
/> | ||
); | ||
|
||
return { | ||
|
@@ -314,7 +327,6 @@ export class CustomFormRenderer extends RendererABC { | |
submitCaption, | ||
className, | ||
stylesheets, | ||
disableParentStyles, | ||
// Option only applies if a custom onSubmit handler is provided | ||
resetOnSubmit: onSubmit != null && postSubmitAction === "reset", | ||
async onSubmit( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from "react"; | ||
import { RendererABC } from "@/types/bricks/rendererTypes"; | ||
import DocumentViewLazy from "./documentView/DocumentViewLazy"; | ||
import { validateRegistryId } from "@/types/helpers"; | ||
import { | ||
type BrickArgs, | ||
|
@@ -28,6 +28,8 @@ import { | |
DOCUMENT_ELEMENT_TYPES, | ||
type DocumentElement, | ||
} from "@/components/documentBuilder/documentBuilderTypes"; | ||
import IsolatedComponent from "@/components/IsolatedComponent"; | ||
import { type DocumentViewProps } from "./documentView/DocumentViewProps"; | ||
|
||
export const DOCUMENT_SCHEMA: Schema = { | ||
$schema: "https://json-schema.org/draft/2019-09/schema#", | ||
|
@@ -107,12 +109,25 @@ export class DocumentRenderer extends RendererABC { | |
}>, | ||
options: BrickOptions, | ||
): Promise<ComponentRef> { | ||
const DocumentView: React.FC<DocumentViewProps> = (props) => ( | ||
<IsolatedComponent | ||
name="DocumentView" | ||
noStyle={disableParentStyles} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
lazy={async () => | ||
import( | ||
/* webpackChunkName: "isolated/DocumentView" */ | ||
"./documentView/DocumentView" | ||
) | ||
} | ||
factory={(DocumentView) => <DocumentView {...props} />} | ||
/> | ||
); | ||
|
||
return { | ||
Component: DocumentViewLazy, | ||
Component: DocumentView, | ||
props: { | ||
body, | ||
stylesheets, | ||
disableParentStyles, | ||
options, | ||
}, | ||
}; | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,10 @@ import { type Target } from "@/types/messengerTypes"; | |
import { validateUUID } from "@/types/helpers"; | ||
import { TOP_LEVEL_FRAME_ID } from "@/domConstants"; | ||
import useAsyncState from "@/hooks/useAsyncState"; | ||
import { EphemeralFormContent } from "./EphemeralFormContent"; | ||
import EmotionShadowRoot from "@/components/EmotionShadowRoot"; | ||
import ErrorBoundary from "@/components/ErrorBoundary"; | ||
import useReportError from "@/hooks/useReportError"; | ||
import IsolatedComponent from "@/components/IsolatedComponent"; | ||
import { type EphemeralFormContentProps } from "./EphemeralFormContent"; | ||
|
||
const ModalLayout: React.FC = ({ children }) => ( | ||
// Don't use React Bootstrap's Modal because we want to customize the classes in the layout | ||
|
@@ -42,6 +42,22 @@ const PanelLayout: React.FC = ({ children }) => ( | |
<div className="p-3">{children}</div> | ||
); | ||
|
||
const EphemeralFormContent: React.FunctionComponent< | ||
EphemeralFormContentProps | ||
> = (props) => ( | ||
<IsolatedComponent | ||
name="EphemeralFormContent" | ||
noStyle={props.definition.disableParentStyles} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
lazy={async () => | ||
import( | ||
/* webpackChunkName: "isolated/EphemeralFormContent" */ | ||
"./EphemeralFormContent" | ||
) | ||
} | ||
factory={(EphemeralFormContent) => <EphemeralFormContent {...props} />} | ||
/> | ||
); | ||
|
||
/** | ||
* @see FormTransformer | ||
*/ | ||
|
@@ -101,14 +117,12 @@ const EphemeralForm: React.FC = () => { | |
return ( | ||
<FormContainer> | ||
<ErrorBoundary> | ||
<EmotionShadowRoot> | ||
<EphemeralFormContent | ||
definition={formDefinition} | ||
target={target} | ||
nonce={nonce} | ||
isModal={isModal} | ||
/> | ||
</EmotionShadowRoot> | ||
<EphemeralFormContent | ||
definition={formDefinition} | ||
target={target} | ||
nonce={nonce} | ||
isModal={isModal} | ||
/> | ||
</ErrorBoundary> | ||
</FormContainer> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disableParentStyles
removed from 2 components because now it's not the Component's responsibility to load its own stylesheets, but it's the loader's (i.e. whereIsolatedComponent
is called)