Broadleaf Microservices
  • v1.0.0-latest-prod

Commerce Shared React Types

Types provided by @broadleaf/commerce-shared-react.

AppAuthProviderProps

extends AuthProviderProps

The AppAuthProvider will supply defaults for redirectUri, silentRedirectUri, onRedirectCallback. It also sets credentials to true.

Property Type Description

clientDiscoveryMode?

'static' | 'dynamic'

AuthSessionManagerProps

Property Type Description

children?

React.ReactNode

keepAlive?

boolean

Whether to automatically try to extend active sessions up to the max time a token is valid. Default is true.

keepAliveIntervalInMinutes?

number

The interval at which to check if the session should be extended. Default is 10. keepAlive must be true.

logoutActions?

() ⇒ Promise<void>

Actions to perform during logout like clearing caches.

logoutReturnToUrl?

string

The URL to return to after log out. Default is /. Must be relative.

CanceledRequestError

extends Error

Property Type Description

CANCEL

boolean

ClientDiscoveryResult

Response from the auth server for a request to resolve the authorized client for a given application token. This is used to determine the clientId and serverId to use for the client in subsequent API requests. This is used when clientDiscoveryMode is set to dynamic.

Property Type Description

clientId

string

ID of the Authorized Client

serverId

string

ID of the parent Authorization Server

ClientProviderProps

Property Type Description

baseHost

string

children?

ReactNode

ClientRegistryKeyOptions

Defines the options used to build the key when registering a Client. This is similar to ClientOptions used to configure a new client, but excludes some options that would make the hit rate too low like PreviewOptions, which has a unique token for each session.

Property Type Description

applicationToken?

string

Application token to be used for this specific operation.

baseURL?

string

Base URL for the axios client.

baseHost?

string

Concatenated with the basePath to create the default baseURL. Ignored if baseURL is provided.

basePath?

string

Concatenated with the baseHost to create the default baseURL. Ignored if baseURL is provided.

locale?

string

The current locale for the operation. This value will be added as an Accept-Language header on the requst.

ClientsState

Property Type Description

getClient

<T extends Client>(name: string) ⇒ T

CookieSetOptions

Property Type Description

path?

string

expires?

Date

maxAge?

number

domain?

string

secure?

boolean

httpOnly?

boolean

sameSite?

boolean | 'none' | 'lax' | 'strict'

encode?

(value: string) ⇒ string

FormattedAmountOrZeroProps

Property Type Description

children?

React.ReactNode

className?

string

fallbackClassName?

string

fallbackCurrency

string

monetaryAmount?

MonetaryAmount

LocaleProviderProps

extends LocaleStateOptions

Property Type Description

children?

React.ReactNode

LocaleState

Property Type Description

allowedLocales

Array<string>

currentLocale

string

currentLanguage

string

The locale without the region, e.g, en not en-US

setAllowedLocales

(allowedLocales: Array<string>) ⇒ void

LocaleStateOptions

Property Type Description

cachedState?

string

Cached locale cookie value.

cookieName?

string

The name of the locale cookie. Default is blLocale

cookieMaxAge?

number

The max age for the locale cookie. Default value is 3600 seconds.

defaultLocale?

string

The default locale to use for the application. Default value is en-US

getUrlQuery?

() ⇒ URLSearchParams

Method to use to get query parameters from the URL. Defaults to using the Location API.

This is used to get the locale from a query parameter. The name should be the same as cookieName.

overrideSetCookie?

( cookieName: string, value: unknown, options: CookieSetOptions ) ⇒ void

Callback to set the locale cookie’s value instead of the default method.

LocalizedMessages

Property Type Description

[key: string]

| Record<string, string> | Record<string, MessageFormatElement[]>

LocationState

Contains browser Location information. This is useful to get Location information regardless of whether server side or client side rendering is ongoing or whether reverse proxy is fronting the app.

Property Type Description

host

string

The hostname of the URL.

origin

string

The origin portion of the URL.

pathname

string

The path portion of the URL.

protocol

string

The protocol portions of the URL.

search

string

The query string portion of the URL.

url

string

The full URL.

userAgent

string

The user-agent string for the current browser.

LocationProviderProps

extends LocationStateOptions

Property Type Description

children?

React.ReactNode

req?

IncomingMessage

cachedState?

LocationState

LocationStateOptions

Property Type Description

forwardedHostHeader?

string

If using a reverse proxy in front of the app, then this is the name of the forwarded host header. Defaults to x-forwarded-host. This is important to use instead of the proxy’s host to accurately resolve things like the current application.

stripPortFromHost?

boolean

Whether to strip the port from the hostname.

PageLoaderProps

Property Type Description

className?

string

loading

boolean

PreviewCountdownMessages

Property Type Description

previewCountdownExpires

MessageDescriptor

[key: string]

MessageDescriptor

Additional custom messages

PreviewCountdownProps

Property Type Description

expirationTime

string

messages

PreviewCountdownMessages

PreviewDatePickerMessages

Property Type Description

previewDatePickerToday

MessageDescriptor

previewDatePickerSubmit

MessageDescriptor

[key: string]

MessageDescriptor

Additional custom messages

PreviewDatePickerProps

Property Type Description

onChange

(arg0?: string) ⇒ void

Change event handler for when a new date is picked.

value

string

The current ISO8601 date string to preview.

messages

PreviewDatePickerMessages

PreviewDispatchAction

Property Type Description

type

string

payload

unknown

PreviewHeaderMessages

extends PreviewCountdownMessages, PreviewDatePickerMessages

Property Type Description

previewHeaderOpenMenu

MessageDescriptor

previewHeaderTitle

MessageDescriptor

previewHeaderExit

MessageDescriptor

[key: string]

MessageDescriptor

Additional custom messages

PreviewHeaderProps

Property Type Description

messages

PreviewHeaderMessages

PreviewLayoutProps

Property Type Description

children?

ReactNode

messages

PreviewMessages

PreviewMessages

extends PreviewHeaderMessages

Property Type Description

[key: string]

MessageDescriptor

Additional custom messages

PreviewParams

Query params used to initiate Preview-on-Site functionality. This should exist when redirecting from the Admin.

Property Type Description

previewToken?

string

sandboxId?

string

PreviewProviderProps

Property Type Description

cachedSandboxPreview?

PreviewState

children?

React.ReactNode

cookieName?

string

messages

PreviewMessages

PreviewSandboxDropdownProps

Property Type Description

activeColors

SandboxColors

Colors of the active sandbox selected

onChange

(nextSandbox: Sandbox) ⇒ void

Change handler that triggers when the user selects a sandbox.

options

Array<Sandbox>

The set of available sandboxes to choose from.

value

Sandbox

The currently active sandbox.

PreviewSandboxItemProps

Property Type Description

activeColors

SandboxColors

Colors of the active sandbox selected

isActiveSandbox

boolean

Whether or not this item is the active item

onClick

() ⇒ void

Click handler triggered when this item is clicked by a user

sandbox

Sandbox

The sandbox used for rendering the content of this item

PreviewState

Property Type Description

isActive

boolean

whether or not preview is active, i.e. if a preview token is present

isValidated

boolean

whether or not the preview token has been validated

isValidating

boolean

whether or not the preview token is being validated

token

string

the token string to be used in API requests

author?

string

the author whose changes are being previewed

sandboxId

string

the current user sandbox ID

sandboxById

Record<string, Sandbox>

the table of user sandboxes

previewDate?

string

ISO8601 date-time used to preview data at a future date

expirationTime

string

ISO8601 date-time used to indicate when the token expires

errorMessage?

string

an error message if a failure to validate

reload?

boolean

Whether the app needs to be reloaded because so that down-stream requests account for preview options change.

PrimaryButtonProps

extends ButtonTypeProps

Property Type Description

className?

string

disabled?

boolean

rounded?

boolean

spinning?

boolean

SandboxColors

Property Type Description

background

{ primary: string }

The background sandbox colors

text

{ primary: string }

The text sandbox colors

SecondaryButtonProps

extends ButtonTypeProps

Property Type Description

className?

string

disabled?

boolean

rounded?

boolean

spinning?

boolean

TenantProviderProps

Property Type Description

children?

ReactNode

cookieState?

TenantState

TenantState

Property Type Description

application?

Application

tenant?

Tenant

applicationToken?

string

error?

string

resolving

boolean