Skip to main content

customWidgetContext

customWidgetContext is a React Context provided by Protrak to every custom widget. It exposes two objects: protrakUtils (utility functions and hooks) and protrakComponents (pre-built UI components).

const { protrakUtils, protrakComponents } =
React.useContext(customWidgetContext);

protrakUtils

UtilityDescription
useProtrakApiHook for calling Protrak REST APIs with automatic auth
protrakApiClientLow-level HTTP client for use inside promiseFn
useProtrakMultiApiHook for parallel API calls
useTypeLayoutConfigFetches and caches type layout configuration
formatDateFormats a date/datetime string using tenant timezone and format
dateUtilsAdvanced date formatting, parsing, and validation functions
dateMnemonics / parseDateInterprets dynamic date expressions like $StartOfToday(+7d)
generateGuid / isEmptyGuid / EMPTY_GUIDUUID generation and checking
objectUtilsisEmpty, isArrayOfObject
queryStringUtilstoQueryString, parseQueryString
numberUtilsround(number, decimalPlaces)
keyValueStoragelocalStorage wrapper with error handling
useRouterAccess current URL, params, and navigate programmatically
fieldUtilsgetVisibleUniqueFields — filter field config arrays
EnumsPlatform-wide string constants (AttributeTypes, AllowedOperations, etc.)
getAESEncryptedString / getAESDecryptedStringAES string encryption / decryption

protrakComponents

Layout & Containers

ComponentDescription
Box, ContainerFundamental layout wrappers
GridCSS Grid layout
BorderBoxBox with a visible border
TitleOnBorderBordered section with a title label

Typography

ComponentDescription
H1 – H5Heading components
TextStandard body text
CaptionSmall secondary text
LabelForm field label

Form Inputs

ComponentDescription
TextBoxSingle-line text input
TextAreaMulti-line text input
InputBoxMUI-styled input with label and error state
DropdownSingle-select dropdown
AsyncDropdownDropdown with async data loading
PicklistProtrak-styled select
ArrowSelectorLeft/right arrow navigation between options
RadioButtonGroupGroup of radio buttons
RadioButtonIndividual radio button
CheckboxGroupGroup of checkboxes
BooleanToggle / checkbox for boolean values
CurrencyCurrency-formatted numeric input

Buttons & Actions

ComponentDescription
Button, ButtonEnumsVersatile button with multiple appearances and sizes
MenuButtonButton that opens a dropdown action menu
MenuStandalone action menu list
ExportCSVButtonPre-built CSV export button

Date & Time

ComponentDescription
FormattedDateDisplays a date using tenant format
FormattedDateTimeDisplays a datetime using tenant format
ProtrakDateDate picker input
ProtrakDateTimeDate + time picker input

Data Display

ComponentDescription
InstanceGridForCustomWidgetFull-featured grid for displaying Protrak instances
LocalDataGridClient-side-only data grid for in-memory arrays
downloadExcelFromSchemaUtility to export grid data to Excel

Modals & Dialogs

ComponentDescription
ModalCentred overlay modal
TopAlignedModalModal anchored to the top of the screen
MuiDialogMUI-based dialog with configurable size and actions
ErrorModalPre-styled error dialog
CloneModalContainerModal for clone workflows

Attribute Renderers (Protrak Field Types)

ComponentDescription
AttributeGeneric renderer — auto-selects type
TextAttributeText field renderer
NumericAttributeNumeric field renderer
BooleanAttributeBoolean / toggle renderer
PicklistAttributePicklist dropdown renderer
DateAttributeDate field renderer
DateTimeAttributeDateTime field renderer
CurrencyAttributeCurrency field renderer
ExpressionAttributeCalculated expression renderer
RichtextAttributeRich-text (HTML) renderer
AllUsersAttributeUser field renderer
AllUsersUser selector component
ReferenceAttributeReference field renderer
ReferenceAttributePaginateDropDownPaginated reference selector
AttachmentAttributeAttachment field renderer
AttachmentUploaderFile upload control
NameAttributeInstance name with link
StateAttributeState badge renderer
ComponentDescription
InstanceLinkHyperlink to a Protrak instance view/edit page

Feedback & Status

ComponentDescription
SpinnerLoading spinner
ErrorMessageInline error text
HelpTextIconInfo icon (ⓘ) with tooltip
CloneLoadingStateLoading overlay for clone operations

Decorative & Layout Helpers

ComponentDescription
HorizontalLineVisual horizontal divider
VerticalSeparatorVisual vertical divider
RotateRotates its children by a given angle
TimelineHeaderStyled timeline section header
ImageRenders an image from a Protrak file ID
FileDownloaderTriggers a file download
ProtrakFontAwesomeIconProtrak-themed FontAwesome icons
getAESEncryptedString, getAESDecryptedStringAES encryption utilities