Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react/src/components/EmbeddedIFrameWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const EmbeddedIFrameWrapper = (
handleCloseInstance: () => void
}
): JSX.Element => {
const { open, sessionSpace, ready, iframe } = useContext(FlatfileContext)
const { open, sessionSpace, ready, iframe, spaceUrl } =
useContext(FlatfileContext)

const [showExitWarnModal, setShowExitWarnModal] = useState(false)
const {
Expand All @@ -32,7 +33,6 @@ export const EmbeddedIFrameWrapper = (
iframeStyles,
mountElement = 'flatfile_iFrameContainer',
preload = true,
spaceUrl,
} = props
const spacesUrl = spaceUrl ?? 'https://platform.flatfile.com/s'
const preloadUrl = `${spacesUrl}/space-init`
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/components/FlatfileContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface FlatfileContextType {
publishableKey?: string
environmentId?: string
apiUrl: string
spaceUrl: string
open: boolean
onClose: MutableRefObject<null | undefined | (() => void)>
setOpen: (open: boolean) => void
Expand Down Expand Up @@ -66,6 +67,7 @@ export const FlatfileContext = createContext<FlatfileContextType>({
publishableKey: undefined,
environmentId: undefined,
apiUrl: '',
spaceUrl: '',
open: true,
onClose: createRef<(() => void) | undefined>(),
setOpen: () => {},
Expand Down
10 changes: 6 additions & 4 deletions packages/react/src/components/FlatfileProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const FlatfileProvider: React.FC<ExclusiveFlatfileProviderProps> = ({
publishableKey,
accessToken,
environmentId,
apiUrl = 'https://platform.flatfile.com/api',
baseUrl = 'https://platform.flatfile.com',
config,
}) => {
const onClose = useRef<undefined | (() => void)>()
Expand All @@ -62,6 +62,9 @@ export const FlatfileProvider: React.FC<ExclusiveFlatfileProviderProps> = ({
}
}

const apiUrl = `${baseUrl}/api`
const spaceUrl = `${baseUrl}/s`

const [createSpace, setCreateSpace] = useState<{
document?: Flatfile.DocumentConfig
workbook?: Flatfile.CreateWorkbookConfig
Expand Down Expand Up @@ -272,9 +275,7 @@ export const FlatfileProvider: React.FC<ExclusiveFlatfileProviderProps> = ({
setInternalAccessToken(null)
setSessionSpace(undefined)

const spacesUrl =
FLATFILE_PROVIDER_CONFIG.spaceUrl ?? 'https://platform.flatfile.com/s'
const preloadUrl = `${spacesUrl}/space-init`
const preloadUrl = `${spaceUrl}/space-init`

const spaceLink = sessionSpace?.space?.guestLink ?? null
const iFrameSrc = FLATFILE_PROVIDER_CONFIG.preload
Expand Down Expand Up @@ -372,6 +373,7 @@ export const FlatfileProvider: React.FC<ExclusiveFlatfileProviderProps> = ({
...(publishableKey ? { publishableKey } : {}),
...(internalAccessToken ? { accessToken: internalAccessToken } : {}),
apiUrl,
spaceUrl,
environmentId,
open,
onClose,
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/types/IFlatfileProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export type Exclusive<T, U> =
export interface BaseSpace {
children: ReactNode
environmentId?: string
/** @deprecated Use baseUrl instead */
apiUrl?: string
baseUrl?: string
config?: IFrameTypes
}

Expand Down
1 change: 0 additions & 1 deletion packages/react/src/types/iFrameProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type IFrameTypes = Partial<
| 'exitSecondaryButtonText'
| 'displayAsModal'
| 'closeSpace'
| 'spaceUrl'
> & {
preload?: boolean
resetOnClose?: boolean
Expand Down