🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@pega/lists-react

Package Overview
Dependencies
Maintainers
16
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pega/lists-react

Repeating view structures such as Table, Gallery(Repeating layouts), Kanban etc.

8.0.0-build.54.2
latest
npm
Version published
Weekly downloads
420
-25.27%
Maintainers
16
Weekly downloads
 
Created
Source

Welcome to @pega/lists-react

To import

import { RepeatingStructures } from '@pega/lists-react';

To consume

<RepeatingStructures
  meta={meta}
  ref={compRef}
  apiContext={{
    ...apiContext,
    stateUpdateCallback
  }}
  renderFactory={renderFactory}
  formatters={repeatFormatters}
  additionalInfo={additionalInfo}
  ...
/>

Table configuration (meta - prop)

PropertyValue typeMandatoryDefault valueNotes
itemKeyStringYesName of a field to use as the key of the rendered item(s) in the view. This field need not necessarily be one of the fields configured for display as part of the field definitions array. This field is directly looked up in the item data.
patchQueryFieldsString arrayNoArray of fields(extra) to be included in a query
sortOrderString arrayNo['asc', 'desc', null]Array denoting sort operation order. Default is a tri-state sort
displayDensityArray of optionsNo[{ name: 'Short', id: '1' }, { name: 'Medium', id: '2' },{ name: 'Tall', id: '3' },{ name: 'Full content', id: '4' }]A map of names(for display) and id(for persistence). The id values have specific behavior(s) associated with them
heightObjectNoheight: { minHeight: 600 }Height of the view. Full set of options include height: { minHeight: 600, /* Minimum height in pixels to the view */, height: 700, /* Explicit height in pixels - fitHeightToElement option is ignored */ fitHeightToElement: el, /* Fit view to a specific HTML element (or string query selector) in the DOM heightwise */ deltaAdjustment: 10 /* A height adjustment value in pixels */ autoSize: true /* Responsively Height will be adjusted on window resize only if you have given fitHeightToElement */, maxHeight: 800, /* Maximum height value in pixels to the view or a css variable (--view-height) */}
toggleFieldVisibilityBooleanNotrueAllow show/hide of fields
groupingBooleanNotrueAllow grouping on fields
templateStringYesTableDetermines the view of a Repeating Structure, values:['Table','Gallery','Timeline']
basicModeBooleanNofalseDisplay views ['Table','Gallery','Timeline'] with full or condensed toolbar. Default shows full toolbar.
editingBooleanNofalseAllow editing on fields
deletingBooleanNofalseAllow deleting of rows
personalizationBooleanNotrueAllow personalization views
enableAppDefaultBooleanNofalseEnable app default personalization options
nonPersonalizationViewNameStringNoInitial viewName to be shown for non personalized view
reorderFieldsBooleanNotrueAllow field reordering through a drag and drop action
reorderItems (experimental)BooleanNofalseAllow row reordering through a drag and drop action
dragHandle (experimental)BooleanNofalseAllow to add a column for drag handle
globalSearchBooleanNotrueBrings in a search widget to allow searching across all text type fields
toolbarBooleanNotrueDisplay toolbar on the view
showCountBooleanNotrueDisplay count in toolbar
defaultRowHeightStringNoundefinedRow density id value from displayDensity options
allowBulkActionsbooleanNofalseRenders the 'Bulk actions' button in the table toolbar, which gets enabled on row selection
dateFunctionsObjectNoundefinedEnables date-functions like MONTHS/WEEKS/... during Grouping and Filtering. (Object structure)
relativeDatesBooleanNofalseEnables Relative Dates, such as "Last 7 days" or "Current Year", in Filtering for DateTime or Date_Only values.
footerBooleanNotrueDisplay footer on the view
dynamicFieldTemplatesObjectNodynamicFieldTemplates: [{ name: 'Comma separated', value: 'comma',selected: true }, { name: 'Space separated', value: 'space' }, { name: 'Multi line', value: 'multiline' }, { name: 'Forward slash', value: 'forwardslash' }]Templates for dynamic fields. See section on Dynamic fields
titleStringNo'<label not set>'Repeating Structure Title
iconStringNo'picture'Repeating Structure Icon
headerBarBooleanNofalseDisplay Header Bar
showHeaderIconsBooleanNotrueDisplay Respective Header Icons at field labels based on type
rowActionsArray<object>No[]list of available static actions for an editable table with following properties[{ text: 'Open in a new tab', id: 'row-new-tab', onClick: () => {} }]
selectionModeStringNo[]Decides type of row selection mode (radio for single/ checkbox for multi) possible values single / multi / multi-on-hover
toolbarActionsArray<Object>No[]List of available static actions at table level (shown in toolbar/ header bar) with following properties [{ text: 'Add', tooltip: 'Add story', id: 'Add', onClick: () => {}}]
selectionCountThresholdNumberNoDisplays select-all checkbox if selectionMode is multi-on-hover and the records count is not greater than threshold
disableSelectionOnLoadBooleanNofalseTo Disable/Enable selection of rows
requiredOnLoadBooleanNofalseTo show asterisk(*) symbol on table header in case of Data Reference/Embedded views. (Note: This works perfectly if the personalization is off.)
timezoneStringNoTimezone which is passed to formatter
localeStringNodocument.documentElement.langLocale which is passed to formatter function
refreshActionObjectNoAction to support manual Refresh from consumer of Repeating structure. Whenever Repeating structure is notified with Refresh action It will show a banner by consuming this action info.
Structure : {id: 'uniqueId for banner', message: To show specific message on banner related to refresh notification, action : { text: Action button text, onClick: Function to be executed on click of action that will perform refresh of data based on consumer apiContext logic}}
Example: {id: 'refreshBanner', message: 'New records have been added',action: { text: 'Click to refresh.', onClick }}

| displayFeatures | Object | No | displayFeatures:{filter:true, grouping:true, sort:true} | Allow display of features-Group, Sort, Filter |

Field configuration

fieldDefs

A mandatory array of objects with the following keys

PropertyValue typeMandatoryDefault valueNotes
typeStringYesnumber or text or date or datetime
nameStringYesActual field name in data
idStringYesPersistent ID of the field, typically the same as the name
labelStringYes
categoryArray<Object>NoCategory of the field which should of the format [{label:'categoryName'}] where index denotes the level of category. ClassName for regular fields and association name for associated fields. Example: category:[{label:'Bugs class'}]
showCategoryInHeaderLabelBooleanNofalseShow category in header label. The header will be displayed in format {categoryName}.{label} where categoryName will be all the category's labels combined with .(dot) notation
tooltipStringNoCurrent Field's formatted valueDefines Field whose value needs to be shown as HelperText e.g tooltip: 'pzDescription' field value for pyID field
showTooltipBooleanNotrueEnable/Disable tooltip on column
widthNumberNo150Pixel width of the field
minWidthNumberNo90Minimum width in pixels, field width cannot be resized below this threshold
filterBooleanNotrueAllow filtering on this field
filterPickListBooleanNofalseFilter popup presents a pick list to choose values from
sortBooleanNotrueAllow sorting
sortDirectionStringNoasc or desc. Allows sorting on load. If this property is present, then sortPriority is mandatory
sortPriorityNumberNoSets the priority on filed for multi sorting(1 takes highest precedence). Allows sorting on load. If this property is present, then sortDirection is mandatory
groupingBooleanNotrueEnable grouping
resizeBooleanNotrueEnable resizing
reorderFieldsBooleanNotrueAllows reordering of column.
freezeBooleanNotrueEnable freezing
fillAvailableSpaceBooleanNofalsefield will resize to available excess width. First field definition will be honoured if configured on multiple columns.
requiredBooleanNofalseAn asterisk will be added in the table header cell right after the label
toggleBooleanNotrueEnable field show/hide
showBooleanNotrueField shows in the view by default. Can be set to false to toggle it in later
showMenuBooleanNotrueShow/hide field level Header menu
aggregationBooleanNotrueAllow aggregation on column
combineColumnBooleanNotrueAllow combining columns
customizeColumnBooleanNotrueAllow customizing column label and formatting
noContextMenuBooleanNofalseDisable context menu at cells
contextMenuOptionsArray<Object>No[]This property extends options provided on right click in a cell context. Object structure: { id: <string(required)>, icon: <optional>, label: <required>, show: <bool(optional)>, disabled: <bool(optional)> onClick: <Func(target, field, rowContext)(optional)> }
cellRendererStringNoName of a custom component that is made available through the render factory. Check section on cellRenderer
hierarchicalInfoObjectNoEnable 'Hierarchical' display mode on column if hierarchicalInfo exists. Object structure: {parentId: string, materializedPathId: string, targetId: string, sortById:<string(optional)>}
cellAlignStringNoAlign cell to left/right/center. Values accepted: 'left', 'right', 'center'
hideGroupColumnNameLabelbooleanNofalseColumn name label in group header will be hidden when set to 'true'
filterParamsObjectNoTODOFilter options for various field

API Context

APIArgumentsMandatoryNotes
stateUpdateCallbackstate: updated state from the componentNoThis api gets called with updated state whenever it gets modified
setSelectedRowsselectedRows: selected rows data on the tableYesThis api sets the selected rows data on the state
getSelectedRowsThis api gets the selected rows data from the state

Formatters

Value typeMandatoryNotes
ObjectNoObject of formatter functions mapping where each function accepts 2 parameters, (inputValue, Options). Options is an object having properties: {locale, timezone, rowData, fieldDef, translate}

Render Factory

Prop keyMandatoryDescriptionReturn type
renderFactoryNoThis should be a factory function which receives two arguments where second argument is optional. First argument value is the cell renderer name (if added in fieldDefs of that column). Second argument value is metadata which contains info configured for that column. It should return a component definition (or an object that contains component definition --> see Return type). This component definition will be used by RepeatingStructures to render a cell with the component provided by renderFactory. If component definition is not provided from render factory or renderFactory is not provided to Repeating structures then cell will be rendered directly with value derived for the cell or the formatted value(if formatter is provided for that column)Repeating structures currently support 2 return types from renderFactory function
  • a component definition function. (OR)
  • an object that contains 2 keys {props: [props that you want to be passed to component along with cellProps], component: [a component definition function]}

Presets

Value typeMandatoryNotes
Array<Array<Object>>NoThis property value comes from authorization

Other Props

PropertyValue typeMandatoryDefault valueNotes
toolBarOptionsArray<Array<Object>>No[]This property extends options provided in toolbar. Object structure: { id: <string(required)>, icon: <optional>, label: <required>, show: <bool(optional)> , onClick: <Func(optional)> }
onViewReadyFunctionNonullThis function acts as a callback that is invoked when the view is ready
onRowClickActionFunctionNonullThis function is invoked when an item/entry is clicked. The corresponding item data is passed into the function on invocation
showExportToExcelOptionBooleanNofalseThis option is shown in the toolbar menu when the ListView is sourced from queryable DataPage
additionalInfoObjectNo`undefinedAdditionalInfo displayed on the toolbar is passed as is to List Toolbar component

State

FeaturePropertyValue typeExample
Column reordercolOrderArray<string> - Array of column idcolOrder: ["A", "custom1590925631168", "2", "3", "D", "10", "11"]
Column resizecolumnWidthsObject - key: columnId, value: column widthcolumnWidths: {10: 132.5, 11: 132.5, 12: 132.5, 2: 235.5, 3: 353}
Column freezefreezeColumnsArray<string> - Array of column idfreezeColumns: ["3", "10"]
Column show/hidehiddenColumnsArray<string> - Array of column idhiddenColumns: ["8", "9"]
DensityselectedHeightOptionString - id value from displayDensity table configuration propertyselectedHeightOption: "4"
SortsortingOrderArray<object> - [{columnId: string, order: [asc|desc], sequence: number}]javascript sortingOrder: [ {columnId: "2", order: "asc", sequence: 1}, {columnId: "A", order: "desc", sequence: 2} ]
FilterfilterExpressionObject - output of condition builderRefer - Condition builder documentation
GroupgroupsArray<object> - [{columnId: string, level: number, order: [asc|desc]}]groups: [ {columnId: "F", level: 0, order: "asc"}, {columnId: "D", level: 1, order: "asc"} ]
AggregationaggregationInfoArray<object> - [{columnId: string, type: [Sum|Max|Min|Avg]}]aggregationInfo: [ {columnId: "D", type: "Max"}, {columnId: "11", type: "Avg"} ]
Merge columncustomFieldsArray<object> - [{id: string - should be unique, expression: array, primaryColumnId: string, label: string }]customFields: [ { id: 'custom4', label: 'MyCustomColumn', primaryColumnId: '2', expression: ['2', '1', ['template1'], '3', ['template2'] ] } ]

Reference to the Component ("compRef" in below example)

APIs exposed on the component ref are accessible via compRef.current.<API_NAME> (like compRef.current.refreshView)

API_NAMEDefault valuesNotesExample
refreshViewrefreshView api is used to re-render the already loaded table to re-fetch the data and re-fetch selections using apiContext.getSelectedRows api (if any of the selection mode is enabled). You can provide two arguments to refreshView; 1. stateToReset (<object>) - (ex: you want to remove grouping before triggering re-render). Currently, supported state flushing of only ['filterExpression', 'search', 'selectedRows'], 2. featuresToAvoid (Array<string>) - to avoid re-running of the following features - ['rowAnimation', 'columnAnimation']compRef.current.refreshView({ filterExpression: true, search: true }, ['rowAnimation']);
moveListRecordsapiContext.moveListRecords api is used to consume a dx api which invokes a OOTB data transform. api flow: 1. invokes dx api with necessary payload, 2. dx api is configured with activity which invokes a data transform based on the payload & path param received 3. returns success response object with {refresh: true} 4. based on this flag it triggers refresh strategy which fetch new set of datacompRef.current.apiContext.moveListRecords({sourceID, destinationID})
dispatchActiondispatchAction(action,payload) is used to trigger specific actions to the table with a specific payload. Below actions are available:
'toggleDisableSelection' - it supports enable/disable of selection of rows. Payload should be a boolean in order to enable disable the selection.
'updateDebugInfo' - Show the stats of API call for debugging purposes. The payload must be an object.
'toggleRequired' - It supports show/hide of asterisk(*) sign in case of embedded/data reference tables, To show/hide of warning sign in case required condition is not met. The payload must be an object.
'notifyDataRefresh' - To show notification banner for refresh of data by consuming refreshAction from meta
'clearDataRefreshNotification' - To reset the refresh that was notified by consumer by sending 'notifyDataRefresh' action
'userConfirmationAction' - Display a generic confirmation modal with cancel and submit action. This will return a promise.
'setInExternalState' - To set something in table external state. By default the externalState will take part in personalization of table.
'updateSelectedRows' - To force re-fetch the selections using apiContext.getSelectedRows.
Disable the selection - compRef.current.dispatchAction('toggleDisableSelection',true)
Pass API stats - compRef.current.dispatchAction('updateDebugInfo', {className: "ABC", dataPage: "D_Page", dataSource: "RDBMS", timeTaken: "1.2 s", insightId: "someId"})
Show/Hide Required UX(asterisk(*) & warning sign) - cosmosTableRef.current?.dispatchAction('toggleRequired',{required, validatemessage
Notify the data refresh - compRef.current.dispatchAction('notifyDataRefresh')
Clear the notification of data refresh - compRef.current.dispatchAction('clearDataRefreshNotification')
Show confirmation modal - compRef.current.dispatchAction(USER_CONFIRMATION_ACTION, {labels: {header, description, submitButtonLabel, cancelButtonLabel}}): Promise<any>
Set in external state - compRef.current.dispatchAction('setInExternalState', {PromotedFilters: {[filterExpression payload]}})
updateSelectedRows - compRef.current.dispatchAction('updateSelectedRows')
getActiveViewInfogetActiveViewInfo() returns {id, name, isDirty} of current active viewcompRef.current.getActiveViewInfo()
setHiddenColumnssetHiddenColumns(columns,{ dragHandle: boolean }) sets the hiddenColumns property in component state and re-renders with features appropriately, the second parameter is an optional payload that can be used for hidding and showing the columns provided by repeating structurescompRef.current.setHiddenColumns('pyLabel', 'pyDescription')
setColumnOrdersetColumnOrder(columns) sets the colOrder property in component state and re-renders with features appropriatelycompRef.current.setColumnOrder('pyID', 'pxCommitDateTime', ',pxUpdateDateTime', 'pyStatusWork')
setFiltersetFilter(filter) sets the filterExpression property in component state and re-renders with features appropriately. The new filter must consist of a top-level AND condition in ConditionBuilder format.compRef.current.setFilter({ "condition": { "comparator": "IS_TRUE", "lhs": { "field": "IsActive" } } })
setGroupingsetGrouping(groups) sets the groups property in component state and re-renders with features appropriatelycompRef.current.setGrouping([{ "columnId": "Status", "order": "asc", "level": 0 }])
setSortingsetSorting(groups) sets the sortingOrder property in component state and re-renders with features appropriatelycompRef.current.setSorting([{ "columnId": "Priority", "order": "asc", "sequence": 1 }])

Cell renderers

Dynamic field templates and renderers

**

Accessibility

Keyboard

Navigation in the toolbar component

  • The Toolbar component can be traversed with the tab key.
  • Popover elements such as: Filter, Sort, Group by, and Toolbar more elements can be navigated by tab key.
  • On reaching the last element, pressing the tab will focus on the first element performing circular navigation.
  • Similarly, if focus is on first element, then pressing SHIFT+TAB will focus the last focusable element.
  • Pressing escape will close the popover and puts the focus back to the action button i.e. filter, sort, group by, and more toolbar button.

Navigation in the table

  • The first focus will be on the table's first header cell if earlier no navigation has been done.
  • To navigate between the cells, use the arrow keys.
  • Pressing enter on the cell can turn the cell in edit mode if it is editable.
    • Pressing enter again will submit the data
    • Pressing escape will discard the changes and turn the cell back to read mode.
  • To focus out from the table cells, press the tab key and focus will be shifted to the next focusable element on the page after table.
  • Next time when navigated again to the table, the last visited cell will be focused.

Translations

  • RepeatingStructures uses the cosmos, hence translations are fetched from useConfiguration hook exposed by cosmos-core.
  • Note: Configuration component which is a provider component of cosmos accepts the translations prop, in which make sure to send the translations required for RepeatingStructure component as part of {lists: {'Sort': 'Translation of Sort'}}

Note to this repo code owners / Dev's:

  • Every time a user facing / listening string is added in a component:
    • Make sure to add the new translation in the pyGenericFields localisation rule under the cosmosFields.fields.lists category.
    • Then raise a PR to Cosmos translations pack defintions file to update the same key string.

FAQs

Package last updated on 27 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts