@pega/lists-core 10.0.0-build.5.2 → 10.0.0-build.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAU1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAyE5D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE;IACnE,YAAY,EAAE,UAAU,CAAC,YAAY,EAAE,kBAAkB,GAAG,YAAY,GAAG,gBAAgB,CAAC;CAC7F,QAgCA;AAWD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;+BAQuB,cAAc,YAAY;AAPpD,wBAsGE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAS1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AA8F5D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE;IACnE,YAAY,EAAE,UAAU,CAAC,YAAY,EAAE,kBAAkB,GAAG,YAAY,GAAG,gBAAgB,CAAC;CAC7F,QAgCA;AAWD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;+BAUuB,cAAc,YAAY;AATpD,wBAwGE"}
@@ -1,7 +1,7 @@
1
- import { actionColumnResize, actionColumnsAutoSize, actionColumnAutoSize, actionForceUpdate } from '../../../../actions/actions';
1
+ import { actionColumnResize, actionColumnsAutoSize, actionForceUpdate } from '../../../../actions/actions';
2
2
  import { TEMPLATES } from '../../../../constants';
3
3
  import { OOTB_COLUMNS, withMemoization } from '../../../../utils/util';
4
- import { autoSizeOfColumns } from './autoSize';
4
+ import { autoSizeOfColumn, autoSizeOfColumns } from './autoSize';
5
5
  /*
6
6
  * If columnWidths are undefined, there is no active personalization invloved in the current view
7
7
  * So triggering auto column sizing, which depends on column content.
@@ -37,13 +37,28 @@ const checkDomContainerHasDataRows = (domContainer) => {
37
37
  * Autosizes the first visual column to account for the expand/collapse button
38
38
  * introduced by grouping.
39
39
  */
40
- function autoSizeFirstVisualColumn([featureProps]) {
41
- const { getView, dispatch } = featureProps;
40
+ function autoSizeFirstVisualColumnOnGroupChange([featureProps]) {
41
+ const { getView, getState, dispatch } = featureProps;
42
42
  const { columns = [], getDomContainer } = getView();
43
+ const groupingIsActive = Boolean(getState().groups?.length);
44
+ if (!groupingIsActive) {
45
+ return;
46
+ }
43
47
  const firstVisualCol = columns.find(c => c.isFirstVisualColumn);
44
48
  const domContainer = getDomContainer();
45
- if (firstVisualCol && domContainer) {
46
- dispatch(actionColumnAutoSize(firstVisualCol, domContainer, true));
49
+ if (!firstVisualCol || !domContainer) {
50
+ return;
51
+ }
52
+ const calculatedWidth = autoSizeOfColumn(firstVisualCol, domContainer, true);
53
+ // If the calculated width is greater than the current width that means the column was not wide enough to accommodate the expand/collapse button(32px)
54
+ // So we need to dispatch an action to update the column width.
55
+ const shouldDispatch = calculatedWidth > (firstVisualCol.currentWidth ?? 0);
56
+ // TODO: On removal of grouping, we should remove the extra width added to the first visual column. This cannot be handled reliably currently.
57
+ // The correct architecture is to have a dedicated grouped-icon column, that will be shown/hidden based on grouping state, and will not affect the data column width.
58
+ if (shouldDispatch) {
59
+ dispatch(actionColumnResize({
60
+ [firstVisualCol.field.id]: calculatedWidth
61
+ }));
47
62
  }
48
63
  }
49
64
  /**
@@ -125,7 +140,7 @@ function resetAutosizeStatus([{ getRsStore }]) {
125
140
  export default () => {
126
141
  const memoizedRunColumnSizing = withMemoization(runColumnSizing);
127
142
  const memoizedResetAutosizeStatus = withMemoization(resetAutosizeStatus);
128
- const memoizedAutosizeFirstVisualColumn = withMemoization(autoSizeFirstVisualColumn);
143
+ const memoizedAutosizeFirstVisualColumnOnGroupChange = withMemoization(autoSizeFirstVisualColumnOnGroupChange);
129
144
  const memoizedAutosizeOotbActionColumns = withMemoization(autosizeOotbActionColumns);
130
145
  let domContainerResizeObserver = null;
131
146
  let observedDomContainer = null;
@@ -178,7 +193,7 @@ export default () => {
178
193
  currentState.visibleColumns,
179
194
  currentState.forceUpdateFeatures?.forceCalculateAutoWidth
180
195
  ]);
181
- memoizedAutosizeFirstVisualColumn([featureProps], [currentState.groups, currentState.responsive?.sm, currentState.colOrder?.[0]]);
196
+ memoizedAutosizeFirstVisualColumnOnGroupChange([featureProps], [currentState.groups, currentState.responsive?.sm, currentState.colOrder?.[0]]);
182
197
  memoizedAutosizeOotbActionColumns([featureProps], [currentState.selectedHeightOption]);
183
198
  domContainerResizeObserver?.unobserve(entry.target);
184
199
  domContainerResizeObserver = null;
@@ -200,7 +215,7 @@ export default () => {
200
215
  state.visibleColumns,
201
216
  state.forceUpdateFeatures?.forceCalculateAutoWidth
202
217
  ]);
203
- memoizedAutosizeFirstVisualColumn([featureProps], [state.groups, state.responsive?.sm, state.colOrder?.[0]]);
218
+ memoizedAutosizeFirstVisualColumnOnGroupChange([featureProps], [state.groups, state.responsive?.sm, state.colOrder?.[0]]);
204
219
  memoizedAutosizeOotbActionColumns([featureProps], [state.selectedHeightOption]);
205
220
  };
206
221
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE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\n actionColumnsAutoSize,\n actionColumnAutoSize,\n actionForceUpdate\n} from '../../../../actions/actions';\nimport { TEMPLATES } from '../../../../constants';\nimport { OOTB_COLUMNS, withMemoization } from '../../../../utils/util';\nimport type { FeatureProps } from '../../../featureFactory';\nimport type View from '../../../../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { State } from '../../../../../../types/State.types';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type RsStore from '../../../../RsStore';\n\nimport { autoSizeOfColumns } from './autoSize';\n\n/*\n * If columnWidths are undefined, there is no active personalization invloved in the current view\n * So triggering auto column sizing, which depends on column content.\n * in case of nested groupings, skipping group headers from being counted as a row\n */\n/**\n * Checks if {@link View.domContainer dom container} has any rows with visible cells.\n * @param columns\n * @param domContainer\n * @returns true if dom container has any rows available, otherwise false.\n */\nconst checkDomContainerHasAnyRows = (\n columns: NonNullable<View['columns']>,\n domContainer: View['domContainer']\n) => {\n for (const column of columns) {\n if (!column.hidden) {\n const cells = domContainer\n ? domContainer.querySelectorAll(`[data-col-id=\"${column.field.id}\"]`)\n : [];\n if (cells.length > 1) {\n return true;\n }\n }\n }\n return false;\n};\n\n/**\n * Checks if any data rows are available in dom container. It does not includes grouped rows.\n * @returns true if data rows are available, otherwise false.\n */\nconst checkDomContainerHasDataRows = (domContainer: View['domContainer']) => {\n return !!(domContainer && domContainer.querySelectorAll('.row[aria-rowindex]').length);\n};\n\n/**\n * Autosizes the first visual column to account for the expand/collapse button\n * introduced by grouping.\n */\n\nfunction autoSizeFirstVisualColumn([featureProps]: [featureProps: FeatureProps]) {\n const { getView, dispatch } = featureProps;\n const { columns = [], getDomContainer } = getView();\n const firstVisualCol = columns.find(c => c.isFirstVisualColumn);\n const domContainer = getDomContainer();\n if (firstVisualCol && domContainer) {\n dispatch(actionColumnAutoSize(firstVisualCol, domContainer, true));\n }\n}\n\n/**\n * Runs autosizing on out-of-the-box (OOTB) action columns in the view.\n */\nconst autosizeOotbActionColumns = ([featureProps]: [featureProps: FeatureProps]) => {\n const { getView, dispatch } = featureProps;\n const { columns = [], getDomContainer } = getView();\n const ootbColumns = columns?.filter(col => OOTB_COLUMNS.includes(col.field.id));\n const domContainer = getDomContainer();\n if (ootbColumns.length && domContainer) {\n dispatch(actionColumnsAutoSize(ootbColumns, domContainer, true));\n }\n};\n\n/**\n * Executes the autosizing feature on all the columns. It dispatches an action that updates {@link State.columnWidths} slice with the calculated widths for all the columns.\n * @param param featureProps\n */\nexport function runColumnSizing([{ getView, getRsStore, dispatch }]: [\n featureProps: OmitStrict<FeatureProps, 'getOriginalState' | 'getRsProps' | 'browserContext'>\n]) {\n const { columns = [], getDomContainer } = getView();\n\n const rsStore = getRsStore();\n const domContainer = getDomContainer();\n const runColumnSizingOnRowsAvailable =\n !rsStore.columnSizingTriggerdOnRowsAvailable && checkDomContainerHasDataRows(domContainer);\n\n // if there is no group/data row to size in DOM, don't run column sizing\n if (\n !checkDomContainerHasAnyRows(columns, domContainer) ||\n (rsStore.autosizeTriggered && !runColumnSizingOnRowsAvailable)\n ) {\n // if in current render cycle the rows were not painted, check for autosizing in next cycle\n if (!rsStore.autosizeTriggered) {\n dispatch(actionForceUpdate(false, { forceCalculateAutoWidth: true }));\n }\n return;\n }\n\n rsStore.autosizeTriggered = true;\n // skipping column animation on next run if column size changed after personalization change or delete\n rsStore.skipColumnAnimationOnNextRun = true;\n\n if (runColumnSizingOnRowsAvailable) {\n // Fresh column sizing will run only once for a view when the rows are loaded for the first time in DOM\n rsStore.columnSizingTriggerdOnRowsAvailable = true;\n dispatch(actionColumnsAutoSize(columns, domContainer!, true));\n } else {\n // Incremental column sizing on show/hide of columns or table refresh or on view change with grouping applied\n dispatch(actionColumnResize(autoSizeOfColumns(columns, domContainer!)));\n }\n}\n\n/**\n * It resets the {@link RsStore.autosizeTriggered autosize status} on RsStore.\n * @param param featureProps\n */\nfunction resetAutosizeStatus([{ getRsStore }]: [featureProps: FeatureProps]) {\n // This parent flag checks if any type of sizing is triggered on the table including table header/groups/rows.\n getRsStore().autosizeTriggered = false;\n}\n\n/**\n * Manages the autosizing feature of columns in the view. This includes the following actions:\n * 1. **Executing Autosize for All Columns**:\n *\n * This action is triggered when any of the following properties change:\n * - {@link State.personalization.active}\n * - {@link View.rows}\n * - {@link RsStore.autosizeTriggered}\n * - {@link State.refresh}\n * - {@link State.visibleColumns}\n * - {@link State.forceUpdateFeatures.forceCalculateAutoWidth}\n * 2. **Resetting Autosize Status**:\n *\n * This action is triggered when any of the following properties change:\n * - {@link State.personalization.active}\n * - {@link State.refresh}\n * - {@link State.visibleColumns}\n * - {@link State.customFields}\n *\n * 3. **Executing Autosize on First Visual Column**:\n *\n * This action is triggered when any of the following properties change:\n * - {@link State.groups}\n * - {@link State.responsive.sm}\n */\nexport default () => {\n const memoizedRunColumnSizing = withMemoization(runColumnSizing);\n const memoizedResetAutosizeStatus = withMemoization(resetAutosizeStatus);\n const memoizedAutosizeFirstVisualColumn = withMemoization(autoSizeFirstVisualColumn);\n const memoizedAutosizeOotbActionColumns = withMemoization(autosizeOotbActionColumns);\n let domContainerResizeObserver: ResizeObserver | null = null;\n let observedDomContainer: Element | null = null;\n return function execute(featureProps: FeatureProps) {\n /**\n * Column sizing is Table-only. When template switches away from Table, clear any pending observer.\n * This prevents an observer created in a previous hidden-Table render from firing late and\n * triggering sizing work against the current non-Table template\n */\n if (featureProps.getView().template !== TEMPLATES.TABLE) {\n domContainerResizeObserver?.disconnect();\n domContainerResizeObserver = null;\n observedDomContainer = null;\n return;\n }\n const state = featureProps.getState();\n // AutoSize by default\n memoizedResetAutosizeStatus(\n [featureProps],\n [state.personalization?.active, state.refresh, state.visibleColumns, state.customFields]\n );\n\n /**\n * If one of the table's ancestors is in a hidden state, the autosize calculations will not\n * function correctly since the domContainer's offsetWidth will be 0. A single ResizeObserver\n * is attached here (once per hidden period) and fires all sizing functions as soon as the\n * container gains width.\n *\n * The memoized versions are called intentionally so their dependency arrays are initialized\n * with the current state values. If the raw functions were called instead, the memoized\n * wrappers would still have no recorded deps and would re-run on the very next `execute`\n * cycle, causing each sizing function to fire twice.\n *\n * Any function that performs sizing calculations should be called within this observer callback.\n */\n const domContainer = featureProps.getView().getDomContainer();\n if (domContainer && domContainer.offsetWidth === 0) {\n if (domContainerResizeObserver && observedDomContainer !== domContainer) {\n // The DOM container was replaced while the observer was still pending (e.g. component remount).\n domContainerResizeObserver.disconnect();\n domContainerResizeObserver = null;\n observedDomContainer = null;\n }\n\n if (!domContainerResizeObserver) {\n domContainerResizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n if (entry.contentRect.width > 0) {\n const currentState = featureProps.getState();\n memoizedRunColumnSizing(\n [featureProps],\n [\n currentState.personalization?.active,\n featureProps.getView().rows,\n featureProps.getRsStore().autosizeTriggered,\n currentState.refresh,\n currentState.visibleColumns,\n currentState.forceUpdateFeatures?.forceCalculateAutoWidth\n ]\n );\n memoizedAutosizeFirstVisualColumn(\n [featureProps],\n [currentState.groups, currentState.responsive?.sm, currentState.colOrder?.[0]]\n );\n memoizedAutosizeOotbActionColumns(\n [featureProps],\n [currentState.selectedHeightOption]\n );\n domContainerResizeObserver?.unobserve(entry.target);\n domContainerResizeObserver = null;\n observedDomContainer = null;\n }\n }\n });\n domContainerResizeObserver.observe(domContainer);\n observedDomContainer = domContainer;\n }\n return;\n }\n\n // These are still needed as the Resize observer will work only once but we need to run sizing on user operations as well\n memoizedRunColumnSizing(\n [featureProps],\n [\n state.personalization?.active,\n featureProps.getView().rows,\n featureProps.getRsStore().autosizeTriggered,\n state.refresh,\n state.visibleColumns,\n state.forceUpdateFeatures?.forceCalculateAutoWidth\n ]\n );\n memoizedAutosizeFirstVisualColumn(\n [featureProps],\n [state.groups, state.responsive?.sm, state.colOrder?.[0]]\n );\n memoizedAutosizeOotbActionColumns([featureProps], [state.selectedHeightOption]);\n };\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/index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H;QACzH,uBAAuB,CACrB,CAAC,YAAY,CAAC,EACd;YACE,KAAK,CAAC,eAAe,EAAE,MAAM;YAC7B,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI;YAC3B,YAAY,CAAC,UAAU,EAAE,CAAC,iBAAiB;YAC3C,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,cAAc;YACpB,KAAK,CAAC,mBAAmB,EAAE,uBAAuB;SACnD,CACF,CAAC;QACF,8CAA8C,CAC5C,CAAC,YAAY,CAAC,EACd,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAC1D,CAAC;QACF,iCAAiC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { OmitStrict } from '@pega/cosmos-react-core';\n\nimport {\n actionColumnResize,\n actionColumnsAutoSize,\n actionForceUpdate\n} from '../../../../actions/actions';\nimport { TEMPLATES } from '../../../../constants';\nimport { OOTB_COLUMNS, withMemoization } from '../../../../utils/util';\nimport type { FeatureProps } from '../../../featureFactory';\nimport type View from '../../../../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { State } from '../../../../../../types/State.types';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type RsStore from '../../../../RsStore';\n\nimport { autoSizeOfColumn, autoSizeOfColumns } from './autoSize';\n\n/*\n * If columnWidths are undefined, there is no active personalization invloved in the current view\n * So triggering auto column sizing, which depends on column content.\n * in case of nested groupings, skipping group headers from being counted as a row\n */\n/**\n * Checks if {@link View.domContainer dom container} has any rows with visible cells.\n * @param columns\n * @param domContainer\n * @returns true if dom container has any rows available, otherwise false.\n */\nconst checkDomContainerHasAnyRows = (\n columns: NonNullable<View['columns']>,\n domContainer: View['domContainer']\n) => {\n for (const column of columns) {\n if (!column.hidden) {\n const cells = domContainer\n ? domContainer.querySelectorAll(`[data-col-id=\"${column.field.id}\"]`)\n : [];\n if (cells.length > 1) {\n return true;\n }\n }\n }\n return false;\n};\n\n/**\n * Checks if any data rows are available in dom container. It does not includes grouped rows.\n * @returns true if data rows are available, otherwise false.\n */\nconst checkDomContainerHasDataRows = (domContainer: View['domContainer']) => {\n return !!(domContainer && domContainer.querySelectorAll('.row[aria-rowindex]').length);\n};\n\n/**\n * Autosizes the first visual column to account for the expand/collapse button\n * introduced by grouping.\n */\n\nfunction autoSizeFirstVisualColumnOnGroupChange([featureProps]: [featureProps: FeatureProps]) {\n const { getView, getState, dispatch } = featureProps;\n const { columns = [], getDomContainer } = getView();\n const groupingIsActive = Boolean(getState().groups?.length);\n\n if (!groupingIsActive) {\n return;\n }\n\n const firstVisualCol = columns.find(c => c.isFirstVisualColumn);\n const domContainer = getDomContainer();\n if (!firstVisualCol || !domContainer) {\n return;\n }\n\n const calculatedWidth = autoSizeOfColumn(firstVisualCol, domContainer, true);\n // If the calculated width is greater than the current width that means the column was not wide enough to accommodate the expand/collapse button(32px)\n // So we need to dispatch an action to update the column width.\n const shouldDispatch = calculatedWidth > (firstVisualCol.currentWidth ?? 0);\n\n // TODO: On removal of grouping, we should remove the extra width added to the first visual column. This cannot be handled reliably currently.\n // The correct architecture is to have a dedicated grouped-icon column, that will be shown/hidden based on grouping state, and will not affect the data column width.\n if (shouldDispatch) {\n dispatch(\n actionColumnResize({\n [firstVisualCol.field.id]: calculatedWidth\n })\n );\n }\n}\n\n/**\n * Runs autosizing on out-of-the-box (OOTB) action columns in the view.\n */\nconst autosizeOotbActionColumns = ([featureProps]: [featureProps: FeatureProps]) => {\n const { getView, dispatch } = featureProps;\n const { columns = [], getDomContainer } = getView();\n const ootbColumns = columns?.filter(col => OOTB_COLUMNS.includes(col.field.id));\n const domContainer = getDomContainer();\n if (ootbColumns.length && domContainer) {\n dispatch(actionColumnsAutoSize(ootbColumns, domContainer, true));\n }\n};\n\n/**\n * Executes the autosizing feature on all the columns. It dispatches an action that updates {@link State.columnWidths} slice with the calculated widths for all the columns.\n * @param param featureProps\n */\nexport function runColumnSizing([{ getView, getRsStore, dispatch }]: [\n featureProps: OmitStrict<FeatureProps, 'getOriginalState' | 'getRsProps' | 'browserContext'>\n]) {\n const { columns = [], getDomContainer } = getView();\n\n const rsStore = getRsStore();\n const domContainer = getDomContainer();\n const runColumnSizingOnRowsAvailable =\n !rsStore.columnSizingTriggerdOnRowsAvailable && checkDomContainerHasDataRows(domContainer);\n\n // if there is no group/data row to size in DOM, don't run column sizing\n if (\n !checkDomContainerHasAnyRows(columns, domContainer) ||\n (rsStore.autosizeTriggered && !runColumnSizingOnRowsAvailable)\n ) {\n // if in current render cycle the rows were not painted, check for autosizing in next cycle\n if (!rsStore.autosizeTriggered) {\n dispatch(actionForceUpdate(false, { forceCalculateAutoWidth: true }));\n }\n return;\n }\n\n rsStore.autosizeTriggered = true;\n // skipping column animation on next run if column size changed after personalization change or delete\n rsStore.skipColumnAnimationOnNextRun = true;\n\n if (runColumnSizingOnRowsAvailable) {\n // Fresh column sizing will run only once for a view when the rows are loaded for the first time in DOM\n rsStore.columnSizingTriggerdOnRowsAvailable = true;\n dispatch(actionColumnsAutoSize(columns, domContainer!, true));\n } else {\n // Incremental column sizing on show/hide of columns or table refresh or on view change with grouping applied\n dispatch(actionColumnResize(autoSizeOfColumns(columns, domContainer!)));\n }\n}\n\n/**\n * It resets the {@link RsStore.autosizeTriggered autosize status} on RsStore.\n * @param param featureProps\n */\nfunction resetAutosizeStatus([{ getRsStore }]: [featureProps: FeatureProps]) {\n // This parent flag checks if any type of sizing is triggered on the table including table header/groups/rows.\n getRsStore().autosizeTriggered = false;\n}\n\n/**\n * Manages the autosizing feature of columns in the view. This includes the following actions:\n * 1. **Executing Autosize for All Columns**:\n *\n * This action is triggered when any of the following properties change:\n * - {@link State.personalization.active}\n * - {@link View.rows}\n * - {@link RsStore.autosizeTriggered}\n * - {@link State.refresh}\n * - {@link State.visibleColumns}\n * - {@link State.forceUpdateFeatures.forceCalculateAutoWidth}\n * 2. **Resetting Autosize Status**:\n *\n * This action is triggered when any of the following properties change:\n * - {@link State.personalization.active}\n * - {@link State.refresh}\n * - {@link State.visibleColumns}\n * - {@link State.customFields}\n *\n * 3. **Executing Autosize on First Visual Column**:\n *\n * This action is triggered when any of the following properties change:\n * - {@link State.groups}\n * - {@link State.responsive.sm}\n */\nexport default () => {\n const memoizedRunColumnSizing = withMemoization(runColumnSizing);\n const memoizedResetAutosizeStatus = withMemoization(resetAutosizeStatus);\n const memoizedAutosizeFirstVisualColumnOnGroupChange = withMemoization(\n autoSizeFirstVisualColumnOnGroupChange\n );\n const memoizedAutosizeOotbActionColumns = withMemoization(autosizeOotbActionColumns);\n let domContainerResizeObserver: ResizeObserver | null = null;\n let observedDomContainer: Element | null = null;\n return function execute(featureProps: FeatureProps) {\n /**\n * Column sizing is Table-only. When template switches away from Table, clear any pending observer.\n * This prevents an observer created in a previous hidden-Table render from firing late and\n * triggering sizing work against the current non-Table template\n */\n if (featureProps.getView().template !== TEMPLATES.TABLE) {\n domContainerResizeObserver?.disconnect();\n domContainerResizeObserver = null;\n observedDomContainer = null;\n return;\n }\n const state = featureProps.getState();\n // AutoSize by default\n memoizedResetAutosizeStatus(\n [featureProps],\n [state.personalization?.active, state.refresh, state.visibleColumns, state.customFields]\n );\n\n /**\n * If one of the table's ancestors is in a hidden state, the autosize calculations will not\n * function correctly since the domContainer's offsetWidth will be 0. A single ResizeObserver\n * is attached here (once per hidden period) and fires all sizing functions as soon as the\n * container gains width.\n *\n * The memoized versions are called intentionally so their dependency arrays are initialized\n * with the current state values. If the raw functions were called instead, the memoized\n * wrappers would still have no recorded deps and would re-run on the very next `execute`\n * cycle, causing each sizing function to fire twice.\n *\n * Any function that performs sizing calculations should be called within this observer callback.\n */\n const domContainer = featureProps.getView().getDomContainer();\n if (domContainer && domContainer.offsetWidth === 0) {\n if (domContainerResizeObserver && observedDomContainer !== domContainer) {\n // The DOM container was replaced while the observer was still pending (e.g. component remount).\n domContainerResizeObserver.disconnect();\n domContainerResizeObserver = null;\n observedDomContainer = null;\n }\n\n if (!domContainerResizeObserver) {\n domContainerResizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n if (entry.contentRect.width > 0) {\n const currentState = featureProps.getState();\n memoizedRunColumnSizing(\n [featureProps],\n [\n currentState.personalization?.active,\n featureProps.getView().rows,\n featureProps.getRsStore().autosizeTriggered,\n currentState.refresh,\n currentState.visibleColumns,\n currentState.forceUpdateFeatures?.forceCalculateAutoWidth\n ]\n );\n memoizedAutosizeFirstVisualColumnOnGroupChange(\n [featureProps],\n [currentState.groups, currentState.responsive?.sm, currentState.colOrder?.[0]]\n );\n memoizedAutosizeOotbActionColumns(\n [featureProps],\n [currentState.selectedHeightOption]\n );\n domContainerResizeObserver?.unobserve(entry.target);\n domContainerResizeObserver = null;\n observedDomContainer = null;\n }\n }\n });\n domContainerResizeObserver.observe(domContainer);\n observedDomContainer = domContainer;\n }\n return;\n }\n\n // These are still needed as the Resize observer will work only once but we need to run sizing on user operations as well\n memoizedRunColumnSizing(\n [featureProps],\n [\n state.personalization?.active,\n featureProps.getView().rows,\n featureProps.getRsStore().autosizeTriggered,\n state.refresh,\n state.visibleColumns,\n state.forceUpdateFeatures?.forceCalculateAutoWidth\n ]\n );\n memoizedAutosizeFirstVisualColumnOnGroupChange(\n [featureProps],\n [state.groups, state.responsive?.sm, state.colOrder?.[0]]\n );\n memoizedAutosizeOotbActionColumns([featureProps], [state.selectedHeightOption]);\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/features/uIFeatures/index.ts"],"names":[],"mappings":"AAsCA,OAAO,WAAW,MAAM,4BAA4B,CAAC;;;4EAFnD,kEAAsC;6BApBnC,kEAAsC;6BAuE41G,kEAAsC;uBARv6G,kEAEM;;0BA3DwC,kEAChB;;uBAYF,kEACR;6B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;0BAAqtD,sDAA0B;iCAAq9C,sDAA0B;yCA3D5oI,sDAC5B;;;AAYb,wBA6CE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/lists-core",
3
- "version": "10.0.0-build.5.2",
3
+ "version": "10.0.0-build.5.4",
4
4
  "description": "Core headless UI library that the users can use to write their own UI and create repeating structures like table, gallery, timeline etc.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Pegasystems",
@@ -14,8 +14,8 @@
14
14
  "build": "tsc -b tsconfig.build.json"
15
15
  },
16
16
  "dependencies": {
17
- "@pega/cosmos-react-condition-builder": "10.0.0-build.5.2",
18
- "@pega/cosmos-react-core": "10.0.0-build.5.2",
17
+ "@pega/cosmos-react-condition-builder": "10.0.0-build.5.4",
18
+ "@pega/cosmos-react-core": "10.0.0-build.5.4",
19
19
  "@types/lodash-es": "^4.17.12",
20
20
  "dayjs": "^1.11.13",
21
21
  "fast-deep-equal": "^3.1.3",