@pega/lists-core 9.0.0-build.29.2 → 9.0.0-build.29.21

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.
Files changed (79) hide show
  1. package/lib/index.d.ts +1 -1
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +1 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/src/core/RsInternal.d.ts +23 -0
  6. package/lib/src/core/RsInternal.d.ts.map +1 -1
  7. package/lib/src/core/RsInternal.js +17 -0
  8. package/lib/src/core/RsInternal.js.map +1 -1
  9. package/lib/src/core/a11y/BaseA11y.d.ts.map +1 -1
  10. package/lib/src/core/a11y/BaseA11y.js +2 -1
  11. package/lib/src/core/a11y/BaseA11y.js.map +1 -1
  12. package/lib/src/core/constants.d.ts +4 -0
  13. package/lib/src/core/constants.d.ts.map +1 -1
  14. package/lib/src/core/constants.js +16 -1
  15. package/lib/src/core/constants.js.map +1 -1
  16. package/lib/src/core/features/featureFactory.d.ts +5 -0
  17. package/lib/src/core/features/featureFactory.d.ts.map +1 -1
  18. package/lib/src/core/features/featureFactory.js +5 -3
  19. package/lib/src/core/features/featureFactory.js.map +1 -1
  20. package/lib/src/core/features/uIFeatures/afterRender/animation.d.ts.map +1 -1
  21. package/lib/src/core/features/uIFeatures/afterRender/animation.js +5 -2
  22. package/lib/src/core/features/uIFeatures/afterRender/animation.js.map +1 -1
  23. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/autoSize.d.ts.map +1 -1
  24. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/autoSize.js +3 -1
  25. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/autoSize.js.map +1 -1
  26. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/index.d.ts +2 -2
  27. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/index.d.ts.map +1 -1
  28. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/index.js +71 -33
  29. package/lib/src/core/features/uIFeatures/afterRender/columnSizing/index.js.map +1 -1
  30. package/lib/src/core/features/uIFeatures/beforeRender/adjustHeight.d.ts +4 -1
  31. package/lib/src/core/features/uIFeatures/beforeRender/adjustHeight.d.ts.map +1 -1
  32. package/lib/src/core/features/uIFeatures/beforeRender/adjustHeight.js +15 -14
  33. package/lib/src/core/features/uIFeatures/beforeRender/adjustHeight.js.map +1 -1
  34. package/lib/src/core/features/uIFeatures/beforeRender/animation.d.ts.map +1 -1
  35. package/lib/src/core/features/uIFeatures/beforeRender/animation.js +3 -2
  36. package/lib/src/core/features/uIFeatures/beforeRender/animation.js.map +1 -1
  37. package/lib/src/core/features/uIFeatures/beforeRender/columnReOrder.d.ts.map +1 -1
  38. package/lib/src/core/features/uIFeatures/beforeRender/columnReOrder.js +18 -15
  39. package/lib/src/core/features/uIFeatures/beforeRender/columnReOrder.js.map +1 -1
  40. package/lib/src/core/features/uIFeatures/beforeRender/columnSizing/resize.d.ts +1 -1
  41. package/lib/src/core/features/uIFeatures/beforeRender/columnSizing/resize.d.ts.map +1 -1
  42. package/lib/src/core/features/uIFeatures/beforeRender/columnSizing/resize.js +6 -7
  43. package/lib/src/core/features/uIFeatures/beforeRender/columnSizing/resize.js.map +1 -1
  44. package/lib/src/core/features/uIFeatures/beforeRender/prepareColumns.d.ts +13 -2
  45. package/lib/src/core/features/uIFeatures/beforeRender/prepareColumns.d.ts.map +1 -1
  46. package/lib/src/core/features/uIFeatures/beforeRender/prepareColumns.js +88 -114
  47. package/lib/src/core/features/uIFeatures/beforeRender/prepareColumns.js.map +1 -1
  48. package/lib/src/core/features/uIFeatures/beforeRender/rowDragDrop.d.ts.map +1 -1
  49. package/lib/src/core/features/uIFeatures/beforeRender/rowDragDrop.js +14 -10
  50. package/lib/src/core/features/uIFeatures/beforeRender/rowDragDrop.js.map +1 -1
  51. package/lib/src/core/features/uIFeatures/beforeRender/stateHydration.d.ts.map +1 -1
  52. package/lib/src/core/features/uIFeatures/beforeRender/stateHydration.js +4 -3
  53. package/lib/src/core/features/uIFeatures/beforeRender/stateHydration.js.map +1 -1
  54. package/lib/src/core/features/uIFeatures/beforeRender/stateSanitization.d.ts.map +1 -1
  55. package/lib/src/core/features/uIFeatures/beforeRender/stateSanitization.js +2 -1
  56. package/lib/src/core/features/uIFeatures/beforeRender/stateSanitization.js.map +1 -1
  57. package/lib/src/core/features/uIFeatures/index.d.ts.map +1 -1
  58. package/lib/src/core/generators/ViewGenerator.js +1 -1
  59. package/lib/src/core/generators/ViewGenerator.js.map +1 -1
  60. package/lib/src/core/reducers/personalizationReducer.d.ts +1 -1
  61. package/lib/src/core/test/junitMocks.d.ts +2 -0
  62. package/lib/src/core/test/junitMocks.d.ts.map +1 -1
  63. package/lib/src/core/test/junitMocks.js +4 -0
  64. package/lib/src/core/test/junitMocks.js.map +1 -1
  65. package/lib/src/core/utils/util.d.ts +24 -0
  66. package/lib/src/core/utils/util.d.ts.map +1 -1
  67. package/lib/src/core/utils/util.js +78 -4
  68. package/lib/src/core/utils/util.js.map +1 -1
  69. package/lib/types/ApiContext.types.d.ts +11 -2
  70. package/lib/types/ApiContext.types.d.ts.map +1 -1
  71. package/lib/types/ApiContext.types.js.map +1 -1
  72. package/lib/types/Meta.types.d.ts +24 -2
  73. package/lib/types/Meta.types.d.ts.map +1 -1
  74. package/lib/types/Meta.types.js +4 -0
  75. package/lib/types/Meta.types.js.map +1 -1
  76. package/lib/types.d.ts +4 -2
  77. package/lib/types.d.ts.map +1 -1
  78. package/lib/types.js.map +1 -1
  79. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"featureFactory.js","sourceRoot":"","sources":["../../../../src/core/features/featureFactory.ts"],"names":[],"mappings":"AAaA,OAAO,UAAU,MAAM,cAAc,CAAC;AA6CtC,SAAS,aAAa;IACpB,MAAM,QAAQ,GAGV;QACF,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,EAAE;KAChB,CAAC;IACF,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY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AE;QACT,qBAAkE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACpF,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,CAAC;gBACtC,OAAO,CAAC;oBACN,OAAO,EAAE,UAAU,CAAC,OAAO;oBAC3B,UAAU,EAAE,UAAU,CAAC,UAAU;oBACjC,UAAU,EAAE,UAAU,CAAC,UAAU;oBACjC,QAAQ,EAAE,UAAU,CAAC,kBAAkB,EAAG,CAAC,QAAQ;oBACnD,gBAAgB,EAAE,UAAU,CAAC,kBAAkB,EAAG,CAAC,gBAAgB;oBACnE,QAAQ,EAAE,UAAU,CAAC,kBAAkB,EAAG,CAAC,QAAQ;iBACpD,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,UAAsB;IAEtB,OAAO,CAAC,8BAA8B,CAAC,UAAU,CAAC,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAC,CAAC;AACjG,CAAC","sourcesContent":["import type { State } from 'pega-repeating-structures-core/lib/types/State.types';\n\nimport type View from '../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type Column from '../generators/ColumnGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type Row from '../generators/RowGenerator';\nimport type RsInternal from '../RsInternal';\nimport type RsProps from '../RsProps';\nimport type StateResolver from '../StateResolver';\nimport type RsStore from '../RsStore';\nimport type { Action } from '../actions/actions.types';\n\nimport uiFeatures from './uIFeatures';\n\nexport type FeatureProps<WithQueuedActions extends boolean = false> = {\n /** Returns reference to current {@link View} */\n getView: () => View;\n /** Returns reference to {@link RsStore} */\n getRsStore: () => RsStore;\n /** Returns reference to {@link RsProps} */\n getRsProps: () => RsProps;\n /** Returns reference to latest/current {@link State} */\n getState: () => State;\n /** Returns the stable {@link State} before the actions in the queue started executing. */\n getOriginalState: StateResolver['getOriginalState'];\n /** A dispatcher to dispatch RS actions. */\n dispatch: StateResolver['dispatch'];\n} & (WithQueuedActions extends true\n ? {\n /** A queue of current actions that are dispatched. */\n queuedActions: Action[];\n }\n : // For better readability keeping {} rather than Record<string, never>.\n // eslint-disable-next-line @typescript-eslint/ban-types\n {});\n\nexport type BeforeRenderFeatureProps = FeatureProps<true>;\n\nexport type MiddleWareFeatureProps = {\n /** Reference to RsInternal object. */\n rsInternal: RsInternal;\n /** Returns reference to latest/current {@link State}. */\n getState: () => State;\n /** Returns the stable {@link State} before the actions in the queue started executing. */\n getOriginalState: StateResolver['getOriginalState'];\n /** A dispatcher to dispatch RS actions. */\n dispatch: StateResolver['dispatch'];\n /** A queue of current actions that are dispatched. */\n queuedActions: Action[];\n};\n\n/** A feature is a function that runs based on a particular state slice change and produces immutable generator({@link View}, {@link Row}, {@link Column}) objects. It may also {@link StateResolver.dispatch dispatch} an action. */\nexport type Feature<WithQueuedActions extends boolean = false> = (\n rsInternal: RsInternal\n) => ((featureProps: FeatureProps<WithQueuedActions>) => void) | void;\n\nexport type UIFeatures = ReturnType<typeof getUIFeatures>;\nfunction getUIFeatures() {\n const features: {\n beforeRender: Feature<true>[];\n afterRender: Feature[];\n } = {\n beforeRender: [],\n afterRender: []\n };\n features.beforeRender.push(uiFeatures.beforeRender.scrollToTop);\n features.beforeRender.push(uiFeatures.beforeRender.busyIndicator);\n features.beforeRender.push(uiFeatures.beforeRender.personalization);\n // Reset dataApi context so that new count and data could be fetched on change of personalization\n features.beforeRender.push(uiFeatures.beforeRender.resetFetch);\n features.beforeRender.push(uiFeatures.beforeRender.changePersonalisation);\n // changeTemplate must run before any feature that reads view.template so that\n // the resolved runtime template (e.g. Gallery after a Table→Gallery switch)\n // is visible to downstream height, column, and layout calculations.\n features.beforeRender.push(uiFeatures.beforeRender.changeTemplate);\n features.beforeRender.push(uiFeatures.beforeRender.prepareColumns);\n features.beforeRender.push(uiFeatures.beforeRender.columnFormatter);\n features.beforeRender.push(uiFeatures.beforeRender.ColumnDisplayMode);\n /* customColumn feature injects field definitions for custom fields, so stateSanitization feature should run after customColumn */\n features.beforeRender.push(uiFeatures.beforeRender.customColumn);\n features.beforeRender.push(uiFeatures.beforeRender.columnAlias);\n features.beforeRender.push(uiFeatures.beforeRender.stateSanitization);\n features.beforeRender.push(uiFeatures.beforeRender.stateHydration);\n features.beforeRender.push(uiFeatures.beforeRender.conditionalStyleFormat);\n features.beforeRender.push(uiFeatures.beforeRender.columnToggle);\n // ORDER: if any feature is going to generate some markup, then it should come before columnSizing feature\n // If reordering or moving records is enabled then rowDragDrop handler size has to be calculated and picked by column sizing\n features.beforeRender.push(uiFeatures.beforeRender.errorColumn);\n features.beforeRender.push(uiFeatures.beforeRender.rowDragDrop);\n features.beforeRender.push(uiFeatures.beforeRender.columnSizing);\n features.beforeRender.push(uiFeatures.beforeRender.adjustHeight);\n features.beforeRender.push(uiFeatures.beforeRender.freeze);\n // columnOrder is required for both columnVisualOrder and columnReorder feature\n features.beforeRender.push(uiFeatures.beforeRender.columnOrder);\n features.beforeRender.push(uiFeatures.beforeRender.columnVisualOrder);\n // Columns header should be rendered as soon as it is available. Features making calculation on columns should be before this.\n features.beforeRender.push(uiFeatures.beforeRender.renderHeader);\n features.beforeRender.push(uiFeatures.beforeRender.refresh);\n features.beforeRender.push(uiFeatures.beforeRender.rowHeight);\n features.beforeRender.push(uiFeatures.beforeRender.animation);\n features.beforeRender.push(uiFeatures.beforeRender.prepareRows);\n // We have to inject this feature always as we are generating instance\n // level data with same to avoid condition block in UI.\n\n features.beforeRender.push(uiFeatures.beforeRender.grouping);\n features.beforeRender.push(uiFeatures.beforeRender.filter);\n features.beforeRender.push(uiFeatures.beforeRender.columnSort);\n features.beforeRender.push(uiFeatures.beforeRender.columnResize);\n features.beforeRender.push(uiFeatures.beforeRender.adjustHeightToFitRecords);\n\n features.beforeRender.push(uiFeatures.beforeRender.columnReOrder);\n features.beforeRender.push(uiFeatures.beforeRender.rowSelect);\n features.beforeRender.push(uiFeatures.beforeRender.toggleSelectAllCheckbox);\n features.beforeRender.push(uiFeatures.beforeRender.aggregation);\n features.beforeRender.push(uiFeatures.beforeRender.moveRecords);\n features.beforeRender.push(uiFeatures.beforeRender.toggleHeaderIcons);\n\n features.afterRender.push(uiFeatures.afterRender.animation);\n features.afterRender.push(uiFeatures.afterRender.columnAutoSizing);\n features.afterRender.push(uiFeatures.afterRender.customizeParentContainer);\n\n return features;\n}\n\n/**\n * Initializes and returns before render features which run when any action is dispatched in the queue.\n * @param rsInternal - RsInternal reference.\n */\nfunction initializeBeforeRenderFeatures(rsInternal: RsInternal) {\n const features = getUIFeatures();\n const beforeRenderUIFeatures = features.beforeRender.map(t => t(rsInternal)).filter(Boolean);\n return (featureProps: MiddleWareFeatureProps) => {\n return (beforeRenderUIFeatures as ((featureProps: BeforeRenderFeatureProps) => void)[]).reduce<\n Promise<void | null>\n >(async (p, feature) => {\n return p.then(() => {\n if (!featureProps.rsInternal.getRsStore().isMounted) return null;\n return feature({\n getView: featureProps.rsInternal.getView,\n getRsStore: featureProps.rsInternal.getRsStore,\n getRsProps: featureProps.rsInternal.getRsProps,\n getState: featureProps.getState,\n getOriginalState: featureProps.getOriginalState,\n dispatch: featureProps.dispatch,\n queuedActions: featureProps.queuedActions\n });\n });\n }, Promise.resolve());\n };\n}\n\n/**\n * Initializes and returns after render features which run after the render is completed.\n * @param rsInternal RsInternal reference.\n */\nfunction initializeAfterRenderFeatures(rsInternal: RsInternal) {\n const features = getUIFeatures();\n const afterRenderUIFeatures = features.afterRender.map(t => t(rsInternal)).filter(Boolean);\n\n return () => {\n (afterRenderUIFeatures as ((featureProps: FeatureProps) => void)[]).forEach(feature => {\n if (rsInternal.getRsStore().isMounted) {\n feature({\n getView: rsInternal.getView,\n getRsStore: rsInternal.getRsStore,\n getRsProps: rsInternal.getRsProps,\n getState: rsInternal.getRsStateResolver()!.getState,\n getOriginalState: rsInternal.getRsStateResolver()!.getOriginalState,\n dispatch: rsInternal.getRsStateResolver()!.dispatch\n });\n }\n });\n };\n}\n\n/**\n * Initializes and return before and after render features.\n * @param rsInternal\n */\nexport default function initializeFeatures(\n rsInternal: RsInternal\n): [(featureProps: MiddleWareFeatureProps) => Promise<void | null>, () => void] {\n return [initializeBeforeRenderFeatures(rsInternal), initializeAfterRenderFeatures(rsInternal)];\n}\n"]}
1
+ {"version":3,"file":"featureFactory.js","sourceRoot":"","sources":["../../../../src/core/features/featureFactory.ts"],"names":[],"mappings":"AAcA,OAAO,UAAU,MAAM,cAAc,CAAC;AAiDtC,SAAS,aAAa;IACpB,MAAM,QAAQ,GAGV;QACF,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,EAAE;KAChB,CAAC;IACF,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAChE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAClE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IACpE,iGAAiG;IACjG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC/D,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;IAC1E,8EAA8E;IAC9E,4EAA4E;IAC5E,oEAAoE;IACpE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACnE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACnE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IACpE,QAAQ,CAAC,YAAY,CAAC,IAAI,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AC,8BAA8B,CAAC,UAAU,CAAC,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAC,CAAC;AACjG,CAAC","sourcesContent":["import type { State } from 'pega-repeating-structures-core/lib/types/State.types';\n\nimport type View from '../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type Column from '../generators/ColumnGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type Row from '../generators/RowGenerator';\nimport type RsInternal from '../RsInternal';\nimport type { BrowserContext } from '../RsInternal';\nimport type RsProps from '../RsProps';\nimport type StateResolver from '../StateResolver';\nimport type RsStore from '../RsStore';\nimport type { Action } from '../actions/actions.types';\n\nimport uiFeatures from './uIFeatures';\n\nexport type FeatureProps<WithQueuedActions extends boolean = false> = {\n /** Returns reference to current {@link View} */\n getView: () => View;\n /** Returns reference to {@link RsStore} */\n getRsStore: () => RsStore;\n /** Returns reference to {@link RsProps} */\n getRsProps: () => RsProps;\n /** Returns reference to latest/current {@link State} */\n getState: () => State;\n /** Returns the stable {@link State} before the actions in the queue started executing. */\n getOriginalState: StateResolver['getOriginalState'];\n /** A dispatcher to dispatch RS actions. */\n dispatch: StateResolver['dispatch'];\n /** Frame-aware browser environment context. Use {@link BrowserContext.document} and\n * {@link BrowserContext.window} instead of the global `document` and `window` so that\n * features work correctly when rendered inside an iFrame. */\n browserContext: BrowserContext;\n} & (WithQueuedActions extends true\n ? {\n /** A queue of current actions that are dispatched. */\n queuedActions: Action[];\n }\n : // For better readability keeping {} rather than Record<string, never>.\n // eslint-disable-next-line @typescript-eslint/ban-types\n {});\n\nexport type BeforeRenderFeatureProps = FeatureProps<true>;\n\nexport type MiddleWareFeatureProps = {\n /** Reference to RsInternal object. */\n rsInternal: RsInternal;\n /** Returns reference to latest/current {@link State}. */\n getState: () => State;\n /** Returns the stable {@link State} before the actions in the queue started executing. */\n getOriginalState: StateResolver['getOriginalState'];\n /** A dispatcher to dispatch RS actions. */\n dispatch: StateResolver['dispatch'];\n /** A queue of current actions that are dispatched. */\n queuedActions: Action[];\n};\n\n/** A feature is a function that runs based on a particular state slice change and produces immutable generator({@link View}, {@link Row}, {@link Column}) objects. It may also {@link StateResolver.dispatch dispatch} an action. */\nexport type Feature<WithQueuedActions extends boolean = false> = (\n rsInternal: RsInternal\n) => ((featureProps: FeatureProps<WithQueuedActions>) => void) | void;\n\nexport type UIFeatures = ReturnType<typeof getUIFeatures>;\nfunction getUIFeatures() {\n const features: {\n beforeRender: Feature<true>[];\n afterRender: Feature[];\n } = {\n beforeRender: [],\n afterRender: []\n };\n features.beforeRender.push(uiFeatures.beforeRender.scrollToTop);\n features.beforeRender.push(uiFeatures.beforeRender.busyIndicator);\n features.beforeRender.push(uiFeatures.beforeRender.personalization);\n // Reset dataApi context so that new count and data could be fetched on change of personalization\n features.beforeRender.push(uiFeatures.beforeRender.resetFetch);\n features.beforeRender.push(uiFeatures.beforeRender.changePersonalisation);\n // changeTemplate must run before any feature that reads view.template so that\n // the resolved runtime template (e.g. Gallery after a Table→Gallery switch)\n // is visible to downstream height, column, and layout calculations.\n features.beforeRender.push(uiFeatures.beforeRender.changeTemplate);\n features.beforeRender.push(uiFeatures.beforeRender.prepareColumns);\n features.beforeRender.push(uiFeatures.beforeRender.columnFormatter);\n features.beforeRender.push(uiFeatures.beforeRender.ColumnDisplayMode);\n /* customColumn feature injects field definitions for custom fields, so stateSanitization feature should run after customColumn */\n features.beforeRender.push(uiFeatures.beforeRender.customColumn);\n features.beforeRender.push(uiFeatures.beforeRender.columnAlias);\n features.beforeRender.push(uiFeatures.beforeRender.stateSanitization);\n features.beforeRender.push(uiFeatures.beforeRender.stateHydration);\n features.beforeRender.push(uiFeatures.beforeRender.conditionalStyleFormat);\n features.beforeRender.push(uiFeatures.beforeRender.columnToggle);\n // ORDER: if any feature is going to generate some markup, then it should come before columnSizing feature\n // If reordering or moving records is enabled then rowDragDrop handler size has to be calculated and picked by column sizing\n features.beforeRender.push(uiFeatures.beforeRender.errorColumn);\n features.beforeRender.push(uiFeatures.beforeRender.rowDragDrop);\n features.beforeRender.push(uiFeatures.beforeRender.columnSizing);\n features.beforeRender.push(uiFeatures.beforeRender.adjustHeight);\n features.beforeRender.push(uiFeatures.beforeRender.freeze);\n // columnOrder is required for both columnVisualOrder and columnReorder feature\n features.beforeRender.push(uiFeatures.beforeRender.columnOrder);\n features.beforeRender.push(uiFeatures.beforeRender.columnVisualOrder);\n // Columns header should be rendered as soon as it is available. Features making calculation on columns should be before this.\n features.beforeRender.push(uiFeatures.beforeRender.renderHeader);\n features.beforeRender.push(uiFeatures.beforeRender.refresh);\n features.beforeRender.push(uiFeatures.beforeRender.rowHeight);\n features.beforeRender.push(uiFeatures.beforeRender.animation);\n features.beforeRender.push(uiFeatures.beforeRender.prepareRows);\n // We have to inject this feature always as we are generating instance\n // level data with same to avoid condition block in UI.\n\n features.beforeRender.push(uiFeatures.beforeRender.grouping);\n features.beforeRender.push(uiFeatures.beforeRender.filter);\n features.beforeRender.push(uiFeatures.beforeRender.columnSort);\n features.beforeRender.push(uiFeatures.beforeRender.columnResize);\n features.beforeRender.push(uiFeatures.beforeRender.adjustHeightToFitRecords);\n\n features.beforeRender.push(uiFeatures.beforeRender.columnReOrder);\n features.beforeRender.push(uiFeatures.beforeRender.rowSelect);\n features.beforeRender.push(uiFeatures.beforeRender.toggleSelectAllCheckbox);\n features.beforeRender.push(uiFeatures.beforeRender.aggregation);\n features.beforeRender.push(uiFeatures.beforeRender.moveRecords);\n features.beforeRender.push(uiFeatures.beforeRender.toggleHeaderIcons);\n\n features.afterRender.push(uiFeatures.afterRender.animation);\n features.afterRender.push(uiFeatures.afterRender.columnAutoSizing);\n features.afterRender.push(uiFeatures.afterRender.customizeParentContainer);\n\n return features;\n}\n\n/**\n * Initializes and returns before render features which run when any action is dispatched in the queue.\n * @param rsInternal - RsInternal reference.\n */\nfunction initializeBeforeRenderFeatures(rsInternal: RsInternal) {\n const features = getUIFeatures();\n const beforeRenderUIFeatures = features.beforeRender.map(t => t(rsInternal)).filter(Boolean);\n return (featureProps: MiddleWareFeatureProps) => {\n return (beforeRenderUIFeatures as ((featureProps: BeforeRenderFeatureProps) => void)[]).reduce<\n Promise<void | null>\n >(async (p, feature) => {\n return p.then(() => {\n if (!featureProps.rsInternal.getRsStore().isMounted) return null;\n return feature({\n getView: featureProps.rsInternal.getView,\n getRsStore: featureProps.rsInternal.getRsStore,\n getRsProps: featureProps.rsInternal.getRsProps,\n getState: featureProps.getState,\n getOriginalState: featureProps.getOriginalState,\n dispatch: featureProps.dispatch,\n queuedActions: featureProps.queuedActions,\n browserContext: featureProps.rsInternal.getBrowserContext()\n });\n });\n }, Promise.resolve());\n };\n}\n\n/**\n * Initializes and returns after render features which run after the render is completed.\n * @param rsInternal RsInternal reference.\n */\nfunction initializeAfterRenderFeatures(rsInternal: RsInternal) {\n const features = getUIFeatures();\n const afterRenderUIFeatures = features.afterRender.map(t => t(rsInternal)).filter(Boolean);\n\n return () => {\n (afterRenderUIFeatures as ((featureProps: FeatureProps) => void)[]).forEach(feature => {\n if (rsInternal.getRsStore().isMounted && rsInternal.getRsStateResolver()) {\n feature({\n getView: rsInternal.getView,\n getRsStore: rsInternal.getRsStore,\n getRsProps: rsInternal.getRsProps,\n getState: rsInternal.getRsStateResolver().getState,\n getOriginalState: rsInternal.getRsStateResolver().getOriginalState,\n dispatch: rsInternal.getRsStateResolver().dispatch,\n browserContext: rsInternal.getBrowserContext()\n });\n }\n });\n };\n}\n\n/**\n * Initializes and return before and after render features.\n * @param rsInternal\n */\nexport default function initializeFeatures(\n rsInternal: RsInternal\n): [(featureProps: MiddleWareFeatureProps) => Promise<void | null>, () => void] {\n return [initializeBeforeRenderFeatures(rsInternal), initializeAfterRenderFeatures(rsInternal)];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/afterRender/animation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAmIzD;;;;;;;;;;;;;;;;;;;GAmBG;+BAKuB,cAAc,YAAY;AAJpD,wBA8BE"}
1
+ {"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/afterRender/animation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAuIzD;;;;;;;;;;;;;;;;;;;GAmBG;+BAKuB,cAAc,YAAY;AAJpD,wBA8BE"}
@@ -1,3 +1,4 @@
1
+ import { isInstance } from '@pega/cosmos-react-core';
1
2
  import { withMemoization } from '../../../utils/util';
2
3
  /**
3
4
  * Triggers animation on a {@link domNode} in X and Y direction by {@link deltaX} and {@link deltaY} respectively.
@@ -41,7 +42,9 @@ const rowAnimation = ([{ getState, getView, getRsStore }]) => {
41
42
  // Calculate the bounding box
42
43
  const newBoundingBox = new Map();
43
44
  rowContainer?.childNodes.forEach(n => {
44
- if (n.nodeType === Node.ELEMENT_NODE && n instanceof Element && n.hasAttribute?.('data-key'))
45
+ if (n.nodeType === Node.ELEMENT_NODE &&
46
+ isInstance(n, Element) &&
47
+ n.hasAttribute?.('data-key'))
45
48
  newBoundingBox.set(n.getAttribute('data-key'), n.getBoundingClientRect());
46
49
  });
47
50
  for (const [key, value] of newBoundingBox) {
@@ -90,7 +93,7 @@ const columnAnimation = ([{ getState, getView, getRsStore }]) => {
90
93
  .getItemElement()
91
94
  .childNodes.forEach(cell => {
92
95
  if (cell.nodeType === Node.ELEMENT_NODE &&
93
- cell instanceof Element &&
96
+ isInstance(cell, Element) &&
94
97
  cell.hasAttribute?.('data-col-id')) {
95
98
  newColBoundingBox.set(cell.getAttribute('data-col-id'), cell.getBoundingClientRect());
96
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"animation.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/afterRender/animation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,C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Q;YACd,KAAK,CAAC,aAAa;YACnB,KAAK,CAAC,YAAY;YAClB,KAAK,CAAC,OAAO;YACb,YAAY,CAAC,UAAU,EAAE,CAAC,4BAA4B;SACvD,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { State } from '../../../../../types/State.types';\nimport { withMemoization } from '../../../utils/util';\nimport type { FeatureProps } from '../../featureFactory';\n// Used in JsDoc.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type RsStore from '../../../RsStore';\n\n/**\n * Triggers animation on a {@link domNode} in X and Y direction by {@link deltaX} and {@link deltaY} respectively.\n * @param domNode - Dom node on which animation should be triggered.\n * @param deltaX - Range of movement on X axis.\n * @param deltaY - Range of movement on Y axis\n * @returns void\n */\nfunction animate(domNode: HTMLElement, deltaX = 150, deltaY = 150) {\n if (!domNode) return;\n if (deltaY || deltaX) {\n requestAnimationFrame(() => {\n // Ensure that it inverts immediately\n domNode.style.transition = 'transform 0s';\n // Before the DOM paints, Invert it to its old\n domNode.style.transform = `translate3d(${deltaX}px, ${deltaY}px, 0)`;\n\n requestAnimationFrame(() => {\n domNode.style.removeProperty('transform');\n domNode.style.removeProperty('transition');\n });\n });\n }\n}\n\n/**\n * Triggers column animation.\n * @param featureProps - A tuple containing an object of feature props.\n * @returns void\n */\nconst rowAnimation = ([{ getState, getView, getRsStore }]: [featureProps: FeatureProps]) => {\n const { featuresToAvoid } = getState();\n const rsStore = getRsStore();\n let avoidRowAnimation = false;\n if (featuresToAvoid?.includes('rowAnimation')) {\n avoidRowAnimation = true;\n }\n // Row animation\n if (!avoidRowAnimation && rsStore.oldBoundingBox?.size) {\n const pNode = getView().getDomContainer();\n const rowContainer = pNode?.querySelector('.row-container'); // row container should wrap all the rows.\n\n // Calculate the bounding box\n const newBoundingBox = new Map();\n rowContainer?.childNodes.forEach(n => {\n if (n.nodeType === Node.ELEMENT_NODE && n instanceof Element && n.hasAttribute?.('data-key'))\n newBoundingBox.set(n.getAttribute('data-key'), n.getBoundingClientRect());\n });\n\n for (const [key, value] of newBoundingBox) {\n const rowNode = rowContainer?.querySelector<HTMLElement>(`[data-key='${CSS.escape(key)}']`);\n if (rsStore.oldBoundingBox.has(key)) {\n // Those elements that were in the dom earlier as well\n const deltaY = rsStore.oldBoundingBox.get(key)!.top - value.top;\n const deltaX = rsStore.oldBoundingBox.get(key)!.left - value.left;\n animate(rowNode!, deltaX, deltaY);\n } else {\n // Those elements that came in now\n animate(rowNode!, 0);\n }\n }\n rsStore.oldBoundingBox = null;\n }\n};\n\n/**\n * Evaluates if column animation needs to be skipped based on {@link State.featuresToAvoid}\n * @param featuresToAvoid\n * @returns boolean - true if columnAnimation should be skipped otherwise false.\n */\nfunction avoidColumnAnimation(featuresToAvoid: State['featuresToAvoid']) {\n return featuresToAvoid?.includes('columnAnimation');\n}\n/**\n * Triggers column animation.\n * @param featureProps - A tuple containing an object of feature props.\n * @returns void\n */\nconst columnAnimation = ([{ getState, getView, getRsStore }]: [featureProps: FeatureProps]) => {\n const { featuresToAvoid } = getState();\n const rsStore = getRsStore();\n\n if (rsStore.skipColumnAnimationOnNextRun) {\n rsStore.skipColumnAnimationOnNextRun = false;\n return;\n }\n\n // Column animation\n if (!avoidColumnAnimation(featuresToAvoid) && rsStore.oldColumnBoundingBox?.size) {\n const pNode = getView().getDomContainer();\n\n // Calculate the bounding box\n const newColBoundingBox = new Map<string, DOMRect>();\n if (getView().getItemElement()) {\n getView()\n .getItemElement()!\n .childNodes.forEach(cell => {\n if (\n cell.nodeType === Node.ELEMENT_NODE &&\n cell instanceof Element &&\n cell.hasAttribute?.('data-col-id')\n ) {\n newColBoundingBox.set(cell.getAttribute('data-col-id')!, cell.getBoundingClientRect());\n }\n });\n }\n const visibleColumns = getView().getVisibleColumns();\n rsStore.oldColumnBoundingBox.forEach((value, key) => {\n if (newColBoundingBox.has(key)) {\n const deltaX = value.left - newColBoundingBox.get(key)!.left;\n const domNodes = pNode?.querySelectorAll<HTMLElement>(`[data-col-id='${key}']`);\n if (deltaX) {\n // FIXME: skipping animation on the last column because in case a record is added like in embedded tables, a vertical scrollbar appears momentarily which shifts the last column to left and this triggers unnecessary animation on last column.\n const currentColumn = visibleColumns.find(col => col.field.id === key);\n if (currentColumn?.isLastColumn) {\n return;\n }\n domNodes?.forEach(domNode => {\n animate(domNode, deltaX, 0);\n });\n }\n }\n });\n rsStore.oldColumnBoundingBox = null;\n }\n};\n\n/**\n * Handles animations for rows and columns\n * The animations are triggered based on changes to specific state properties:\n *\n * ### Row Animation Triggers\n * - {@link State.filterExpression}\n * - search text\n * - {@link State.sortingOrder}\n * - {@link State.groups}\n * - {@link State.refresh}\n * - {@link State.selectedHeightOption}\n *\n * ### Column Animation Triggers\n * - {@link State.freezeColumns}\n * - {@link State.colOrder}\n * - {@link State.hiddenColumns}\n * - {@link State.columnWidths}\n * - {@link State.refresh}\n * - {@link RsStore.skipColumnAnimationOnNextRun}\n */\nexport default () => {\n const memoizedRowAnimation = withMemoization(rowAnimation);\n const memoizedColumnAnimation = withMemoization(columnAnimation);\n\n return function execute(featureProps: FeatureProps) {\n const state = featureProps.getState();\n memoizedRowAnimation(\n [featureProps],\n [\n state.filterExpression,\n // @ts-expect-error Property 'searchText' does not exist on type 'State' but exists on view.state\n state.searchText,\n state.sortingOrder,\n state.groups,\n state.refresh,\n state.selectedHeightOption\n ]\n );\n memoizedColumnAnimation(\n [featureProps],\n [\n state.freezeColumns,\n state.colOrder,\n state.hiddenColumns,\n state.columnWidths,\n state.refresh,\n featureProps.getRsStore().skipColumnAnimationOnNextRun\n ]\n );\n };\n};\n"]}
1
+ {"version":3,"file":"animation.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/afterRender/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMtD;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,OAAoB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AAC,aAAa;YACnB,KAAK,CAAC,YAAY;YAClB,KAAK,CAAC,OAAO;YACb,YAAY,CAAC,UAAU,EAAE,CAAC,4BAA4B;SACvD,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { isInstance } from '@pega/cosmos-react-core';\n\nimport type { State } from '../../../../../types/State.types';\nimport { withMemoization } from '../../../utils/util';\nimport type { FeatureProps } from '../../featureFactory';\n// Used in JsDoc.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type RsStore from '../../../RsStore';\n\n/**\n * Triggers animation on a {@link domNode} in X and Y direction by {@link deltaX} and {@link deltaY} respectively.\n * @param domNode - Dom node on which animation should be triggered.\n * @param deltaX - Range of movement on X axis.\n * @param deltaY - Range of movement on Y axis\n * @returns void\n */\nfunction animate(domNode: HTMLElement, deltaX = 150, deltaY = 150) {\n if (!domNode) return;\n if (deltaY || deltaX) {\n requestAnimationFrame(() => {\n // Ensure that it inverts immediately\n domNode.style.transition = 'transform 0s';\n // Before the DOM paints, Invert it to its old\n domNode.style.transform = `translate3d(${deltaX}px, ${deltaY}px, 0)`;\n\n requestAnimationFrame(() => {\n domNode.style.removeProperty('transform');\n domNode.style.removeProperty('transition');\n });\n });\n }\n}\n\n/**\n * Triggers column animation.\n * @param featureProps - A tuple containing an object of feature props.\n * @returns void\n */\nconst rowAnimation = ([{ getState, getView, getRsStore }]: [featureProps: FeatureProps]) => {\n const { featuresToAvoid } = getState();\n const rsStore = getRsStore();\n let avoidRowAnimation = false;\n if (featuresToAvoid?.includes('rowAnimation')) {\n avoidRowAnimation = true;\n }\n // Row animation\n if (!avoidRowAnimation && rsStore.oldBoundingBox?.size) {\n const pNode = getView().getDomContainer();\n const rowContainer = pNode?.querySelector('.row-container'); // row container should wrap all the rows.\n\n // Calculate the bounding box\n const newBoundingBox = new Map();\n rowContainer?.childNodes.forEach(n => {\n if (\n n.nodeType === Node.ELEMENT_NODE &&\n isInstance(n, Element) &&\n n.hasAttribute?.('data-key')\n )\n newBoundingBox.set(n.getAttribute('data-key'), n.getBoundingClientRect());\n });\n\n for (const [key, value] of newBoundingBox) {\n const rowNode = rowContainer?.querySelector<HTMLElement>(`[data-key='${CSS.escape(key)}']`);\n if (rsStore.oldBoundingBox.has(key)) {\n // Those elements that were in the dom earlier as well\n const deltaY = rsStore.oldBoundingBox.get(key)!.top - value.top;\n const deltaX = rsStore.oldBoundingBox.get(key)!.left - value.left;\n animate(rowNode!, deltaX, deltaY);\n } else {\n // Those elements that came in now\n animate(rowNode!, 0);\n }\n }\n rsStore.oldBoundingBox = null;\n }\n};\n\n/**\n * Evaluates if column animation needs to be skipped based on {@link State.featuresToAvoid}\n * @param featuresToAvoid\n * @returns boolean - true if columnAnimation should be skipped otherwise false.\n */\nfunction avoidColumnAnimation(featuresToAvoid: State['featuresToAvoid']) {\n return featuresToAvoid?.includes('columnAnimation');\n}\n/**\n * Triggers column animation.\n * @param featureProps - A tuple containing an object of feature props.\n * @returns void\n */\nconst columnAnimation = ([{ getState, getView, getRsStore }]: [featureProps: FeatureProps]) => {\n const { featuresToAvoid } = getState();\n const rsStore = getRsStore();\n\n if (rsStore.skipColumnAnimationOnNextRun) {\n rsStore.skipColumnAnimationOnNextRun = false;\n return;\n }\n\n // Column animation\n if (!avoidColumnAnimation(featuresToAvoid) && rsStore.oldColumnBoundingBox?.size) {\n const pNode = getView().getDomContainer();\n\n // Calculate the bounding box\n const newColBoundingBox = new Map<string, DOMRect>();\n if (getView().getItemElement()) {\n getView()\n .getItemElement()!\n .childNodes.forEach(cell => {\n if (\n cell.nodeType === Node.ELEMENT_NODE &&\n isInstance(cell, Element) &&\n cell.hasAttribute?.('data-col-id')\n ) {\n newColBoundingBox.set(cell.getAttribute('data-col-id')!, cell.getBoundingClientRect());\n }\n });\n }\n const visibleColumns = getView().getVisibleColumns();\n rsStore.oldColumnBoundingBox.forEach((value, key) => {\n if (newColBoundingBox.has(key)) {\n const deltaX = value.left - newColBoundingBox.get(key)!.left;\n const domNodes = pNode?.querySelectorAll<HTMLElement>(`[data-col-id='${key}']`);\n if (deltaX) {\n // FIXME: skipping animation on the last column because in case a record is added like in embedded tables, a vertical scrollbar appears momentarily which shifts the last column to left and this triggers unnecessary animation on last column.\n const currentColumn = visibleColumns.find(col => col.field.id === key);\n if (currentColumn?.isLastColumn) {\n return;\n }\n domNodes?.forEach(domNode => {\n animate(domNode, deltaX, 0);\n });\n }\n }\n });\n rsStore.oldColumnBoundingBox = null;\n }\n};\n\n/**\n * Handles animations for rows and columns\n * The animations are triggered based on changes to specific state properties:\n *\n * ### Row Animation Triggers\n * - {@link State.filterExpression}\n * - search text\n * - {@link State.sortingOrder}\n * - {@link State.groups}\n * - {@link State.refresh}\n * - {@link State.selectedHeightOption}\n *\n * ### Column Animation Triggers\n * - {@link State.freezeColumns}\n * - {@link State.colOrder}\n * - {@link State.hiddenColumns}\n * - {@link State.columnWidths}\n * - {@link State.refresh}\n * - {@link RsStore.skipColumnAnimationOnNextRun}\n */\nexport default () => {\n const memoizedRowAnimation = withMemoization(rowAnimation);\n const memoizedColumnAnimation = withMemoization(columnAnimation);\n\n return function execute(featureProps: FeatureProps) {\n const state = featureProps.getState();\n memoizedRowAnimation(\n [featureProps],\n [\n state.filterExpression,\n // @ts-expect-error Property 'searchText' does not exist on type 'State' but exists on view.state\n state.searchText,\n state.sortingOrder,\n state.groups,\n state.refresh,\n state.selectedHeightOption\n ]\n );\n memoizedColumnAnimation(\n [featureProps],\n [\n state.freezeColumns,\n state.colOrder,\n state.hiddenColumns,\n state.columnWidths,\n state.refresh,\n featureProps.getRsStore().skipColumnAnimationOnNextRun\n ]\n );\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"autoSize.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/autoSize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAmD7D,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EAC/C,aAAa,UAAQ,GACpB,MAAM,CASR;AACD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EAAE,EACjB,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EAC/C,KAAK,CAAC,EAAE,OAAO;;EAmChB"}
1
+ {"version":3,"file":"autoSize.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/autoSize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAmD7D,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EAC/C,aAAa,UAAQ,GACpB,MAAM,CAWR;AACD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EAAE,EACjB,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EAC/C,KAAK,CAAC,EAAE,OAAO;;EAmChB"}
@@ -37,8 +37,10 @@ function calculateColumnWidth(column, domContainer, forceAutoSize = false) {
37
37
  export function autoSizeOfColumn(col, domContainer, forceAutoSize = false) {
38
38
  // Set to max-content to measure actual content width
39
39
  domContainer.style.setProperty(`--col-width-${col.field.idHash}`, MAX_CONTENT);
40
+ domContainer.setAttribute('data-content-size-measuring', 'true');
40
41
  const columnWidth = calculateColumnWidth(col, domContainer, forceAutoSize);
41
42
  domContainer.style.setProperty(`--col-width-${col.field.idHash}`, `${col.currentWidth}px`);
43
+ domContainer.removeAttribute('data-content-size-measuring');
42
44
  return columnWidth;
43
45
  }
44
46
  /**
@@ -51,7 +53,7 @@ export function autoSizeOfColumn(col, domContainer, forceAutoSize = false) {
51
53
  */
52
54
  export function autoSizeOfColumns(columns, domContainer, reset) {
53
55
  const columnAutoSizes = {};
54
- const visibleColumns = columns[0].parent.getVisibleColumns(true);
56
+ const visibleColumns = columns.filter(col => !col.hidden);
55
57
  // Set CSS variables for all columns that need auto-sizing first (single batch write)
56
58
  visibleColumns.forEach(column => {
57
59
  domContainer.style.setProperty(`--col-width-${column.field.idHash}`, MAX_CONTENT);
@@ -1 +1 @@
1
- {"version":3,"file":"autoSize.js","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/autoSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D;;;;;;;GAOG;AAEH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,SAAS,oBAAoB,CAC3B,MAAc,EACd,YAA+C,EAC/C,aAAa,GAAG,KAAK;IAErB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,+CAA+C;QAC/C,MAAM,iBAAiB,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACxD,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAC1B,YAAY,CAAC,gBAAgB,CAAc,iBAAiB,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CACjF,CAAC;IAEF,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC;QACnC,IAAI,SAA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CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAEjE,wFAAwF;IACxF,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC9B,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,IAAI,KAAK,KAAK,SAAS,CAAC,EAAE,CAAC;YAClD,+IAA+I;YAC/I,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,mBAAmB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;YACjF,MAAM,WAAW,GAAG,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;YAE9E,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;QACjD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,YAAY,CAAC,eAAe,CAAC,6BAA6B,CAAC,CAAC;IAC5D,mFAAmF;IACnF,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC9B,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,YAAY,CAAC,KAAK,CAAC,WAAW,CAC5B,eAAe,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,EACpC,GAAG,MAAM,CAAC,YAAY,IAAI,CAC3B,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { ColumnResizePayload } from '../../../../actions/actions.types';\nimport { rowSelectColumnMeta } from '../../../../constants';\nimport type Column from '../../../../generators/ColumnGenerator';\nimport type View from '../../../../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { FieldDef } from '../../../../../../types/Meta.types';\n\n/**\n * Calculates the width of column based on their content size. If a column already has a width specified in {@link FieldDef.width} or through {@link column.getPersonalizedWidth personalization}, then that width will be honored over content size width.\n *\n * @param column - A column object representing column in the view.\n * @param domContainer - The HTML element that acts as the container for RS.\n * @param forceAutoSize - A boolean flag that indicates whether to force a recalculation of column widths.\n * @returns column width in pixels.\n */\n\nconst MAX_CONTENT = 'max-content';\nconst ROUNDING_BUFFER = 1;\nfunction calculateColumnWidth(\n column: Column,\n domContainer: NonNullable<View['domContainer']>,\n forceAutoSize = false\n) {\n if (!forceAutoSize) {\n // This will be executed in case of reset width\n const personalizedWidth = column.getPersonalizedWidth();\n if (personalizedWidth) {\n return personalizedWidth;\n }\n if (column.field.width) {\n return column.field.width;\n }\n }\n\n const cellsList = Array.from(\n domContainer.querySelectorAll<HTMLElement>(`[data-col-id=\"${column.field.id}\"]`)\n );\n\n let maxContentWidth = 0;\n cellsList.forEach(cell => {\n const cellWidth = cell.offsetWidth;\n if (cellWidth > maxContentWidth) {\n maxContentWidth = cellWidth;\n }\n });\n\n /* buffer to prevent content clipping due to offsetWidth rounding */\n const maxColumnWidth = maxContentWidth + ROUNDING_BUFFER;\n\n return column.field.maxWidth && maxColumnWidth > column.field.maxWidth\n ? column.field.maxWidth\n : maxColumnWidth;\n}\n\nexport function autoSizeOfColumn(\n col: Column,\n domContainer: NonNullable<View['domContainer']>,\n forceAutoSize = false\n): number {\n // Set to max-content to measure actual content width\n domContainer.style.setProperty(`--col-width-${col.field.idHash}`, MAX_CONTENT);\n\n const columnWidth = calculateColumnWidth(col, domContainer, forceAutoSize);\n\n domContainer.style.setProperty(`--col-width-${col.field.idHash}`, `${col.currentWidth}px`);\n\n return columnWidth;\n}\n/**\n * Calculates the width of columns based on their content size. If a column already has a width specified in {@link FieldDef.width} or through {@link column.getPersonalizedWidth personalization}, then that width will be honored over content size width.\n *\n * @param columns - An array of `Column` objects representing the columns in the view.\n * @param domContainer - The HTML element that acts as the container for RS.\n * @param reset - A boolean flag that indicates whether to force a recalculation of column widths.\n * @returns An object containing width for each column.\n */\nexport function autoSizeOfColumns(\n columns: Column[],\n domContainer: NonNullable<View['domContainer']>,\n reset?: boolean\n) {\n const columnAutoSizes: ColumnResizePayload['data'] = {};\n\n const visibleColumns = columns[0].parent.getVisibleColumns(true);\n\n // Set CSS variables for all columns that need auto-sizing first (single batch write)\n visibleColumns.forEach(column => {\n domContainer.style.setProperty(`--col-width-${column.field.idHash}`, MAX_CONTENT);\n });\n domContainer.setAttribute('data-content-size-measuring', 'true');\n\n // Now calculate widths for all columns (each does its own DOM reading in batch context)\n visibleColumns.forEach(column => {\n if (!(column.currentWidth && reset === undefined)) {\n // always calculate the content based width for row selection column because it's width will change depending on if grouping is applied or not.\n const forceAutosize = column.field.id === rowSelectColumnMeta.field.id || !reset;\n const columnWidth = calculateColumnWidth(column, domContainer, forceAutosize);\n\n columnAutoSizes[column.field.id] = columnWidth;\n }\n });\n\n domContainer.removeAttribute('data-content-size-measuring');\n // Reset CSS variables back to original widths for columns that had max-content set\n visibleColumns.forEach(column => {\n if (column.currentWidth) {\n domContainer.style.setProperty(\n `--col-width-${column.field.idHash}`,\n `${column.currentWidth}px`\n );\n }\n });\n\n return columnAutoSizes;\n}\n"]}
1
+ {"version":3,"file":"autoSize.js","sourceRoot":"","sources":["../../../../../../../src/core/features/uIFeatures/afterRender/columnSizing/autoSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D;;;;;;;GAOG;AAEH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,SAAS,oBAAoB,CAC3B,MAAc,EACd,YAA+C,EAC/C,aAAa,GAAG,KAAK;IAErB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,+CAA+C;QAC/C,MAAM,iBAAiB,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACxD,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;IA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CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { ColumnResizePayload } from '../../../../actions/actions.types';\nimport { rowSelectColumnMeta } from '../../../../constants';\nimport type Column from '../../../../generators/ColumnGenerator';\nimport type View from '../../../../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { FieldDef } from '../../../../../../types/Meta.types';\n\n/**\n * Calculates the width of column based on their content size. If a column already has a width specified in {@link FieldDef.width} or through {@link column.getPersonalizedWidth personalization}, then that width will be honored over content size width.\n *\n * @param column - A column object representing column in the view.\n * @param domContainer - The HTML element that acts as the container for RS.\n * @param forceAutoSize - A boolean flag that indicates whether to force a recalculation of column widths.\n * @returns column width in pixels.\n */\n\nconst MAX_CONTENT = 'max-content';\nconst ROUNDING_BUFFER = 1;\nfunction calculateColumnWidth(\n column: Column,\n domContainer: NonNullable<View['domContainer']>,\n forceAutoSize = false\n) {\n if (!forceAutoSize) {\n // This will be executed in case of reset width\n const personalizedWidth = column.getPersonalizedWidth();\n if (personalizedWidth) {\n return personalizedWidth;\n }\n if (column.field.width) {\n return column.field.width;\n }\n }\n\n const cellsList = Array.from(\n domContainer.querySelectorAll<HTMLElement>(`[data-col-id=\"${column.field.id}\"]`)\n );\n\n let maxContentWidth = 0;\n cellsList.forEach(cell => {\n const cellWidth = cell.offsetWidth;\n if (cellWidth > maxContentWidth) {\n maxContentWidth = cellWidth;\n }\n });\n\n /* buffer to prevent content clipping due to offsetWidth rounding */\n const maxColumnWidth = maxContentWidth + ROUNDING_BUFFER;\n\n return column.field.maxWidth && maxColumnWidth > column.field.maxWidth\n ? column.field.maxWidth\n : maxColumnWidth;\n}\n\nexport function autoSizeOfColumn(\n col: Column,\n domContainer: NonNullable<View['domContainer']>,\n forceAutoSize = false\n): number {\n // Set to max-content to measure actual content width\n domContainer.style.setProperty(`--col-width-${col.field.idHash}`, MAX_CONTENT);\n domContainer.setAttribute('data-content-size-measuring', 'true');\n\n const columnWidth = calculateColumnWidth(col, domContainer, forceAutoSize);\n\n domContainer.style.setProperty(`--col-width-${col.field.idHash}`, `${col.currentWidth}px`);\n domContainer.removeAttribute('data-content-size-measuring');\n\n return columnWidth;\n}\n/**\n * Calculates the width of columns based on their content size. If a column already has a width specified in {@link FieldDef.width} or through {@link column.getPersonalizedWidth personalization}, then that width will be honored over content size width.\n *\n * @param columns - An array of `Column` objects representing the columns in the view.\n * @param domContainer - The HTML element that acts as the container for RS.\n * @param reset - A boolean flag that indicates whether to force a recalculation of column widths.\n * @returns An object containing width for each column.\n */\nexport function autoSizeOfColumns(\n columns: Column[],\n domContainer: NonNullable<View['domContainer']>,\n reset?: boolean\n) {\n const columnAutoSizes: ColumnResizePayload['data'] = {};\n\n const visibleColumns = columns.filter(col => !col.hidden);\n\n // Set CSS variables for all columns that need auto-sizing first (single batch write)\n visibleColumns.forEach(column => {\n domContainer.style.setProperty(`--col-width-${column.field.idHash}`, MAX_CONTENT);\n });\n domContainer.setAttribute('data-content-size-measuring', 'true');\n\n // Now calculate widths for all columns (each does its own DOM reading in batch context)\n visibleColumns.forEach(column => {\n if (!(column.currentWidth && reset === undefined)) {\n // always calculate the content based width for row selection column because it's width will change depending on if grouping is applied or not.\n const forceAutosize = column.field.id === rowSelectColumnMeta.field.id || !reset;\n const columnWidth = calculateColumnWidth(column, domContainer, forceAutosize);\n\n columnAutoSizes[column.field.id] = columnWidth;\n }\n });\n\n domContainer.removeAttribute('data-content-size-measuring');\n // Reset CSS variables back to original widths for columns that had max-content set\n visibleColumns.forEach(column => {\n if (column.currentWidth) {\n domContainer.style.setProperty(\n `--col-width-${column.field.idHash}`,\n `${column.currentWidth}px`\n );\n }\n });\n\n return columnAutoSizes;\n}\n"]}
@@ -4,8 +4,8 @@ import type { FeatureProps } from '../../../featureFactory';
4
4
  * 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.
5
5
  * @param param featureProps
6
6
  */
7
- export declare function runColumnSizing([{ getState, getView, getRsStore, dispatch }]: [
8
- featureProps: OmitStrict<FeatureProps, 'getOriginalState' | 'getRsProps'>
7
+ export declare function runColumnSizing([{ getView, getRsStore, dispatch }]: [
8
+ featureProps: OmitStrict<FeatureProps, 'getOriginalState' | 'getRsProps' | 'browserContext'>
9
9
  ]): void;
10
10
  /**
11
11
  * Manages the autosizing feature of columns in the view. This includes the following actions:
@@ -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;AAsE5D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE;IAC7E,YAAY,EAAE,UAAU,CAAC,YAAY,EAAE,kBAAkB,GAAG,YAAY,CAAC;CAC1E,QA2DA;AAWD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;+BAMuB,cAAc,YAAY;AALpD,wBA0BE"}
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,wBAmGE"}
@@ -37,7 +37,8 @@ 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([{ getView, dispatch }]) {
40
+ function autoSizeFirstVisualColumn([featureProps]) {
41
+ const { getView, dispatch } = featureProps;
41
42
  const { columns = [], getDomContainer } = getView();
42
43
  const firstVisualCol = columns.find(c => c.isFirstVisualColumn);
43
44
  const domContainer = getDomContainer();
@@ -48,21 +49,21 @@ function autoSizeFirstVisualColumn([{ getView, dispatch }]) {
48
49
  /**
49
50
  * Runs autosizing on out-of-the-box (OOTB) action columns in the view.
50
51
  */
51
- const autosizeOotbActionColumns = ([{ getView, dispatch }]) => {
52
- const { columns = [] } = getView();
52
+ const autosizeOotbActionColumns = ([featureProps]) => {
53
+ const { getView, dispatch } = featureProps;
54
+ const { columns = [], getDomContainer } = getView();
53
55
  const ootbColumns = columns?.filter(col => OOTB_COLUMNS.includes(col.field.id));
54
- if (ootbColumns.length) {
55
- dispatch(actionColumnsAutoSize(ootbColumns, getView().getDomContainer(), true));
56
+ const domContainer = getDomContainer();
57
+ if (ootbColumns.length && domContainer) {
58
+ dispatch(actionColumnsAutoSize(ootbColumns, domContainer, true));
56
59
  }
57
60
  };
58
61
  /**
59
62
  * 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.
60
63
  * @param param featureProps
61
64
  */
62
- export function runColumnSizing([{ getState, getView, getRsStore, dispatch }]) {
63
- const { columns = [], getDomContainer, meta } = getView();
64
- if (meta.template !== TEMPLATES.TABLE)
65
- return;
65
+ export function runColumnSizing([{ getView, getRsStore, dispatch }]) {
66
+ const { columns = [], getDomContainer } = getView();
66
67
  const rsStore = getRsStore();
67
68
  const domContainer = getDomContainer();
68
69
  const runColumnSizingOnRowsAvailable = !rsStore.columnSizingTriggerdOnRowsAvailable && checkDomContainerHasDataRows(domContainer);
@@ -75,30 +76,6 @@ export function runColumnSizing([{ getState, getView, getRsStore, dispatch }]) {
75
76
  }
76
77
  return;
77
78
  }
78
- /**
79
- * If one of the table's ancestors is in a hidden state, the autosize calculations will not function correctly
80
- * since the domContainer's offsetWidth will be 0. To address this scenario, a resize observer is attached for this use case.
81
- * It triggers autosize whenever the offsetWidth of the domContainer increases from 0 once the ancestors are
82
- * made visible. */
83
- if (domContainer?.offsetWidth === 0) {
84
- const observer = new ResizeObserver(entries => {
85
- for (const entry of entries) {
86
- if (entry.contentRect.width > 0) {
87
- runColumnSizing([
88
- {
89
- getState,
90
- getView,
91
- getRsStore,
92
- dispatch
93
- }
94
- ]);
95
- observer.unobserve(entry.target);
96
- }
97
- }
98
- });
99
- observer.observe(domContainer);
100
- return;
101
- }
102
79
  rsStore.autosizeTriggered = true;
103
80
  // skipping column animation on next run if column size changed after personalization change or delete
104
81
  rsStore.skipColumnAnimationOnNextRun = true;
@@ -150,10 +127,71 @@ export default () => {
150
127
  const memoizedResetAutosizeStatus = withMemoization(resetAutosizeStatus);
151
128
  const memoizedAutosizeFirstVisualColumn = withMemoization(autoSizeFirstVisualColumn);
152
129
  const memoizedAutosizeOotbActionColumns = withMemoization(autosizeOotbActionColumns);
130
+ let domContainerResizeObserver = null;
131
+ let observedDomContainer = null;
153
132
  return function execute(featureProps) {
133
+ /**
134
+ * Column sizing is Table-only. When template switches away from Table, clear any pending observer.
135
+ * This prevents an observer created in a previous hidden-Table render from firing late and
136
+ * triggering sizing work against the current non-Table template
137
+ */
138
+ if (featureProps.getView().template !== TEMPLATES.TABLE) {
139
+ domContainerResizeObserver?.disconnect();
140
+ domContainerResizeObserver = null;
141
+ observedDomContainer = null;
142
+ return;
143
+ }
154
144
  const state = featureProps.getState();
155
145
  // AutoSize by default
156
146
  memoizedResetAutosizeStatus([featureProps], [state.personalization?.active, state.refresh, state.hiddenColumns, state.customFields]);
147
+ /**
148
+ * If one of the table's ancestors is in a hidden state, the autosize calculations will not
149
+ * function correctly since the domContainer's offsetWidth will be 0. A single ResizeObserver
150
+ * is attached here (once per hidden period) and fires all sizing functions as soon as the
151
+ * container gains width.
152
+ *
153
+ * The memoized versions are called intentionally so their dependency arrays are initialized
154
+ * with the current state values. If the raw functions were called instead, the memoized
155
+ * wrappers would still have no recorded deps and would re-run on the very next `execute`
156
+ * cycle, causing each sizing function to fire twice.
157
+ *
158
+ * Any function that performs sizing calculations should be called within this observer callback.
159
+ */
160
+ const domContainer = featureProps.getView().getDomContainer();
161
+ if (domContainer && domContainer.offsetWidth === 0) {
162
+ if (domContainerResizeObserver && observedDomContainer !== domContainer) {
163
+ // The DOM container was replaced while the observer was still pending (e.g. component remount).
164
+ domContainerResizeObserver.disconnect();
165
+ domContainerResizeObserver = null;
166
+ observedDomContainer = null;
167
+ }
168
+ if (!domContainerResizeObserver) {
169
+ domContainerResizeObserver = new ResizeObserver(entries => {
170
+ for (const entry of entries) {
171
+ if (entry.contentRect.width > 0) {
172
+ const currentState = featureProps.getState();
173
+ memoizedRunColumnSizing([featureProps], [
174
+ currentState.personalization?.active,
175
+ featureProps.getView().rows,
176
+ featureProps.getRsStore().autosizeTriggered,
177
+ currentState.refresh,
178
+ currentState.visibleColumns,
179
+ currentState.forceUpdateFeatures?.forceCalculateAutoWidth
180
+ ]);
181
+ memoizedAutosizeFirstVisualColumn([featureProps], [currentState.groups, currentState.responsive?.sm]);
182
+ memoizedAutosizeOotbActionColumns([featureProps], [currentState.selectedHeightOption]);
183
+ domContainerResizeObserver?.unobserve(entry.target);
184
+ domContainerResizeObserver = null;
185
+ observedDomContainer = null;
186
+ }
187
+ }
188
+ });
189
+ domContainerResizeObserver.observe(domContainer);
190
+ observedDomContainer = domContainer;
191
+ }
192
+ return;
193
+ }
194
+ // These are still needed as the Resize observer will work only once but we need to run sizing on user operations as well
157
195
  memoizedRunColumnSizing([featureProps], [
158
196
  state.personalization?.active,
159
197
  featureProps.getView().rows,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/core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C","sourcesContent":["import type { OmitStrict } from '@pega/cosmos-react-core';\n\nimport {\n actionColumnResize,\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([{ getView, dispatch }]: [featureProps: 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 = ([{ getView, dispatch }]: [featureProps: FeatureProps]) => {\n const { columns = [] } = getView();\n const ootbColumns = columns?.filter(col => OOTB_COLUMNS.includes(col.field.id));\n if (ootbColumns.length) {\n dispatch(actionColumnsAutoSize(ootbColumns, getView().getDomContainer()!, 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([{ getState, getView, getRsStore, dispatch }]: [\n featureProps: OmitStrict<FeatureProps, 'getOriginalState' | 'getRsProps'>\n]) {\n const { columns = [], getDomContainer, meta } = getView();\n\n if (meta.template !== TEMPLATES.TABLE) return;\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 /**\n * If one of the table's ancestors is in a hidden state, the autosize calculations will not function correctly\n * since the domContainer's offsetWidth will be 0. To address this scenario, a resize observer is attached for this use case.\n * It triggers autosize whenever the offsetWidth of the domContainer increases from 0 once the ancestors are\n * made visible. */\n if (domContainer?.offsetWidth === 0) {\n const observer = new ResizeObserver(entries => {\n for (const entry of entries) {\n if (entry.contentRect.width > 0) {\n runColumnSizing([\n {\n getState,\n getView,\n getRsStore,\n dispatch\n }\n ]);\n observer.unobserve(entry.target);\n }\n }\n });\n observer.observe(domContainer);\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.hiddenColumns}\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.hiddenColumns}\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 return function execute(featureProps: FeatureProps) {\n const state = featureProps.getState();\n // AutoSize by default\n memoizedResetAutosizeStatus(\n [featureProps],\n [state.personalization?.active, state.refresh, state.hiddenColumns, state.customFields]\n );\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([featureProps], [state.groups, state.responsive?.sm]);\n memoizedAutosizeOotbActionColumns([featureProps], [state.selectedHeightOption]);\n };\n};\n"]}
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,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAQvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH;;;;;GAKG;AACH,MAAM,2BAA2B,GAAG,CAClC,OAAqC,EACrC,YAAkC,EAClC,EAAE;IACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,YAAY;gBACxB,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,iBAAiB,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;gBACrE,CAAC,CAAC,EAAE,CAAC;YACP,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,4BAA4B,GAAG,CAAC,YAAkC,EAAE,EAAE;IAC1E,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,YAAY,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC,MAA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AAE,uBAAuB;SACnD,CACF,CAAC;QACF,iCAAiC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;QACxF,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 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.hiddenColumns}\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.hiddenColumns}\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.hiddenColumns, 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]\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([featureProps], [state.groups, state.responsive?.sm]);\n memoizedAutosizeOotbActionColumns([featureProps], [state.selectedHeightOption]);\n };\n};\n"]}
@@ -1,11 +1,14 @@
1
1
  import type RsInternal from '../../../RsInternal';
2
2
  import type { BeforeRenderFeatureProps } from '../../featureFactory';
3
+ type AdjustHeightProps = Pick<BeforeRenderFeatureProps, 'getView' | 'dispatch' | 'browserContext'>;
3
4
  /**
4
5
  * Calculates the {@link View.bodyHeight body height} of the view.
5
6
  * @param param.0 {@link BeforeRenderFeatureProps}.
6
7
  * @returns void
7
8
  */
8
- export declare function execute([{ getView, dispatch }]: [featureProps: BeforeRenderFeatureProps]): void;
9
+ export declare function execute([{ getView, dispatch, browserContext }]: [
10
+ featureProps: AdjustHeightProps
11
+ ]): void;
9
12
  /**
10
13
  * Calculates the {@link View.bodyHeight body height} of the view and toggles `resize listener` to the `window`.
11
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"adjustHeight.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/adjustHeight.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AASrE;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,wBAAwB,CAAC,QA6CxF;AAwBD;;;;;;;;;;;;;GAaG;yBAEa,YAAY,UAAU,MAkB5B,cAAc,wBAAwB;AAlBhD,wBA4BE"}
1
+ {"version":3,"file":"adjustHeight.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/adjustHeight.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAKrE,KAAK,iBAAiB,GAAG,IAAI,CAAC,wBAAwB,EAAE,SAAS,GAAG,UAAU,GAAG,gBAAgB,CAAC,CAAC;AAMnG;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,EAAE;IAC/D,YAAY,EAAE,iBAAiB;CAChC,QA6CA;AAwBD;;;;;;;;;;;;;GAaG;yBAEa,YAAY,UAAU,MAsB5B,cAAc,wBAAwB;AAtBhD,wBAgCE"}
@@ -9,7 +9,7 @@ const getVirtualizer = (view) => {
9
9
  * @param param.0 {@link BeforeRenderFeatureProps}.
10
10
  * @returns void
11
11
  */
12
- export function execute([{ getView, dispatch }]) {
12
+ export function execute([{ getView, dispatch, browserContext }]) {
13
13
  // Don't need to calculate height if numberOfRows is defined or view is in basicMode and virtualizer is used
14
14
  // because, virtualizer will set the height to auto which is a contradition
15
15
  const basicMode = getView().meta.basicMode;
@@ -25,17 +25,17 @@ export function execute([{ getView, dispatch }]) {
25
25
  if (typeof fitHeightToElement === 'string') {
26
26
  targetContainerElement =
27
27
  fitHeightToElement === 'document'
28
- ? document.body
29
- : document.querySelector(fitHeightToElement);
28
+ ? browserContext.document.body
29
+ : browserContext.document.querySelector(fitHeightToElement);
30
30
  }
31
31
  else if (fitHeightToElement.nodeType === 1) {
32
32
  targetContainerElement = fitHeightToElement;
33
33
  }
34
34
  else {
35
- targetContainerElement = document.body;
35
+ targetContainerElement = browserContext.document.body;
36
36
  }
37
37
  if (targetContainerElement) {
38
- const computedStyle = window.getComputedStyle(targetContainerElement);
38
+ const computedStyle = browserContext.window.getComputedStyle(targetContainerElement);
39
39
  const totalHeight = parseFloat(computedStyle.height);
40
40
  const paddingTop = parseFloat(computedStyle.paddingTop);
41
41
  const paddingBottom = parseFloat(computedStyle.paddingBottom);
@@ -54,15 +54,15 @@ export function execute([{ getView, dispatch }]) {
54
54
  * @param param.1 Resize listener.
55
55
  * @returns void
56
56
  */
57
- function attachResize([{ getView }, resizeListener]) {
57
+ function attachResize([{ getView, browserContext }, resizeListener]) {
58
58
  const { meta: { height: { height, fitHeightToElement, autoSize = true } = {}, basicMode, numberOfRows } } = getView();
59
59
  const isNumberOfRowsDefined = !!numberOfRows;
60
60
  if (!basicMode && !isNumberOfRowsDefined && !height && fitHeightToElement && autoSize) {
61
- window.removeEventListener('resize', resizeListener);
62
- window.addEventListener('resize', resizeListener);
61
+ browserContext.window.removeEventListener('resize', resizeListener);
62
+ browserContext.window.addEventListener('resize', resizeListener);
63
63
  }
64
64
  else {
65
- window.removeEventListener('resize', resizeListener);
65
+ browserContext.window.removeEventListener('resize', resizeListener);
66
66
  }
67
67
  }
68
68
  /**
@@ -83,16 +83,17 @@ function attachResize([{ getView }, resizeListener]) {
83
83
  export default (rsInternal) => {
84
84
  const { getView, getRsStateResolver, getPubSubUtils } = rsInternal;
85
85
  const { dispatch } = getRsStateResolver();
86
- const instExecute = execute.bind(null, [{ getView, dispatch }]);
87
86
  let timeoutId = null;
88
87
  const resizeListener = () => {
89
88
  // prevent execution of previous setTimeout
90
- clearTimeout(timeoutId);
91
- // change width from the state object after 150 milliseconds
92
- timeoutId = setTimeout(() => instExecute(), 500);
89
+ if (timeoutId) {
90
+ clearTimeout(timeoutId);
91
+ }
92
+ // change width from the state object after 500 milliseconds
93
+ timeoutId = setTimeout(() => execute([{ getView, dispatch, browserContext: rsInternal.getBrowserContext() }]), 500);
93
94
  };
94
95
  getPubSubUtils().subscribe(UNMOUNT, () => {
95
- window.removeEventListener('resize', resizeListener);
96
+ rsInternal.getBrowserContext().window.removeEventListener('resize', resizeListener);
96
97
  });
97
98
  const memoisedExecute = withMemoization(execute);
98
99
  const memoisedAttachResize = withMemoization(attachResize);
@@ -1 +1 @@
1
- {"version":3,"file":"adjustHeight.js","sourceRoot":"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AY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAC/E,CAAC;QACF,oBAAoB,CAClB,CAAC,YAAY,EAAE,cAAc,CAAC,EAC9B,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAC/E,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { UNMOUNT } from '../../../pubSub/events';\nimport { actionForceUpdate } from '../../../actions/actions';\nimport { withMemoization } from '../../../utils/util';\nimport type RsInternal from '../../../RsInternal';\nimport type { BeforeRenderFeatureProps } from '../../featureFactory';\nimport type View from '../../../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Meta } from '../../../../../types/Meta.types';\n\nconst getVirtualizer = (view: View) => {\n return view.virtualizeElements?.rootVirtualiser;\n};\n\n/**\n * Calculates the {@link View.bodyHeight body height} of the view.\n * @param param.0 {@link BeforeRenderFeatureProps}.\n * @returns void\n */\nexport function execute([{ getView, dispatch }]: [featureProps: BeforeRenderFeatureProps]) {\n // Don't need to calculate height if numberOfRows is defined or view is in basicMode and virtualizer is used\n // because, virtualizer will set the height to auto which is a contradition\n const basicMode = getView().meta.basicMode;\n const isVirtualizerUsed = !!getVirtualizer(getView());\n const isNumberOfRowsDefined = !!getView().meta.numberOfRows;\n if (isNumberOfRowsDefined || (basicMode && isVirtualizerUsed)) {\n return;\n }\n\n const {\n meta: { height: { minHeight, fitHeightToElement } = {} }\n } = getView();\n\n if (!getView().getDomContainer() || !fitHeightToElement) return;\n\n let targetContainerElement: HTMLElement | null;\n if (typeof fitHeightToElement === 'string') {\n targetContainerElement =\n fitHeightToElement === 'document'\n ? document.body\n : document.querySelector(fitHeightToElement);\n } else if (fitHeightToElement.nodeType === 1) {\n targetContainerElement = fitHeightToElement;\n } else {\n targetContainerElement = document.body;\n }\n\n if (targetContainerElement) {\n const computedStyle = window.getComputedStyle(targetContainerElement);\n const totalHeight = parseFloat(computedStyle.height);\n const paddingTop = parseFloat(computedStyle.paddingTop);\n const paddingBottom = parseFloat(computedStyle.paddingBottom);\n\n const targetHeight = totalHeight - paddingTop - paddingBottom;\n\n // tableHeight should not be less than minHeight if it's configured\n if (\n (typeof minHeight === 'number' && targetHeight && targetHeight > minHeight) ||\n (!minHeight && targetHeight)\n ) {\n getView().setProp('viewHeight', targetHeight);\n dispatch(actionForceUpdate(false));\n }\n }\n}\n\n/**\n * Toggles the `resize listener` on `window`\n * @param param.0 {@link BeforeRenderFeatureProps}.\n * @param param.1 Resize listener.\n * @returns void\n */\nfunction attachResize([{ getView }, resizeListener]: [\n featureProps: BeforeRenderFeatureProps,\n resizeListener: () => void\n]) {\n const {\n meta: { height: { height, fitHeightToElement, autoSize = true } = {}, basicMode, numberOfRows }\n } = getView();\n const isNumberOfRowsDefined = !!numberOfRows;\n if (!basicMode && !isNumberOfRowsDefined && !height && fitHeightToElement && autoSize) {\n window.removeEventListener('resize', resizeListener);\n window.addEventListener('resize', resizeListener);\n } else {\n window.removeEventListener('resize', resizeListener);\n }\n}\n\n/**\n * Calculates the {@link View.bodyHeight body height} of the view and toggles `resize listener` to the `window`.\n *\n * 1. The `body height` is calculated only on initial mount of the Repeating structures, if following properties are provided in {@link Meta}:\n * - {@link Meta.height}\n * - {@link Meta.numberOfRows}\n *\n * 2. The `resize listener` is attached/removed on initial mount of Repeating structures, after considering the values for following properties in {@link Meta}:\n * - {@link Meta.height}\n * - {@link Meta.numberOfRows}\n *\n * Additionally the `resize listener` will be removed on `UNMOUNT` event publish.\n *\n */\n// TODO: RsCore shouldn't be responsible for height calculations. We should move this feature to React layer.\nexport default (rsInternal: RsInternal) => {\n const { getView, getRsStateResolver, getPubSubUtils } = rsInternal;\n const { dispatch } = getRsStateResolver();\n const instExecute = execute.bind(null, [{ getView, dispatch } as BeforeRenderFeatureProps]);\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n const resizeListener = () => {\n // prevent execution of previous setTimeout\n clearTimeout(timeoutId!);\n // change width from the state object after 150 milliseconds\n timeoutId = setTimeout(() => instExecute(), 500);\n };\n\n getPubSubUtils().subscribe(UNMOUNT, () => {\n window.removeEventListener('resize', resizeListener);\n });\n\n const memoisedExecute = withMemoization(execute);\n const memoisedAttachResize = withMemoization(attachResize);\n return (featureProps: BeforeRenderFeatureProps) => {\n memoisedExecute(\n [featureProps],\n [featureProps.getView().meta.numberOfRows, featureProps.getView().meta.height]\n );\n memoisedAttachResize(\n [featureProps, resizeListener],\n [featureProps.getView().meta.numberOfRows, featureProps.getView().meta.height]\n );\n };\n};\n"]}
1
+ {"version":3,"file":"adjustHeight.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/adjustHeight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAStD,MAAM,cAAc,GAAG,CAAC,IAAU,EAAE,EAAE;IACpC,OAAO,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC;AAClD,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,CAE7D;IACC,4GAA4G;IAC5G,2EAA2E;IAC3E,MAAM,SAAS,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3C,MAAM,iBAAiB,GAAG,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;IACtD,MAAM,qBAAqB,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;IAC5D,IAAI,qBAAqB,IAAI,CAAC,SAAS,IAAI,iBAAiB,CAAC,EAAE,CAAC;QAC9D,OAAO;IACT,C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UAAU,CACpB,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,EACtF,GAAG,CACJ,CAAC;IACJ,CAAC,CAAC;IAEF,cAAc,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE;QACvC,UAAU,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,oBAAoB,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3D,OAAO,CAAC,YAAsC,EAAE,EAAE;QAChD,eAAe,CACb,CAAC,YAAY,CAAC,EACd,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAC/E,CAAC;QACF,oBAAoB,CAClB,CAAC,YAAY,EAAE,cAAc,CAAC,EAC9B,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAC/E,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { UNMOUNT } from '../../../pubSub/events';\nimport { actionForceUpdate } from '../../../actions/actions';\nimport { withMemoization } from '../../../utils/util';\nimport type RsInternal from '../../../RsInternal';\nimport type { BeforeRenderFeatureProps } from '../../featureFactory';\nimport type View from '../../../generators/ViewGenerator';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Meta } from '../../../../../types/Meta.types';\n\ntype AdjustHeightProps = Pick<BeforeRenderFeatureProps, 'getView' | 'dispatch' | 'browserContext'>;\n\nconst getVirtualizer = (view: View) => {\n return view.virtualizeElements?.rootVirtualiser;\n};\n\n/**\n * Calculates the {@link View.bodyHeight body height} of the view.\n * @param param.0 {@link BeforeRenderFeatureProps}.\n * @returns void\n */\nexport function execute([{ getView, dispatch, browserContext }]: [\n featureProps: AdjustHeightProps\n]) {\n // Don't need to calculate height if numberOfRows is defined or view is in basicMode and virtualizer is used\n // because, virtualizer will set the height to auto which is a contradition\n const basicMode = getView().meta.basicMode;\n const isVirtualizerUsed = !!getVirtualizer(getView());\n const isNumberOfRowsDefined = !!getView().meta.numberOfRows;\n if (isNumberOfRowsDefined || (basicMode && isVirtualizerUsed)) {\n return;\n }\n\n const {\n meta: { height: { minHeight, fitHeightToElement } = {} }\n } = getView();\n\n if (!getView().getDomContainer() || !fitHeightToElement) return;\n\n let targetContainerElement: HTMLElement | null;\n if (typeof fitHeightToElement === 'string') {\n targetContainerElement =\n fitHeightToElement === 'document'\n ? browserContext.document.body\n : browserContext.document.querySelector(fitHeightToElement);\n } else if (fitHeightToElement.nodeType === 1) {\n targetContainerElement = fitHeightToElement;\n } else {\n targetContainerElement = browserContext.document.body;\n }\n\n if (targetContainerElement) {\n const computedStyle = browserContext.window.getComputedStyle(targetContainerElement);\n const totalHeight = parseFloat(computedStyle.height);\n const paddingTop = parseFloat(computedStyle.paddingTop);\n const paddingBottom = parseFloat(computedStyle.paddingBottom);\n\n const targetHeight = totalHeight - paddingTop - paddingBottom;\n\n // tableHeight should not be less than minHeight if it's configured\n if (\n (typeof minHeight === 'number' && targetHeight && targetHeight > minHeight) ||\n (!minHeight && targetHeight)\n ) {\n getView().setProp('viewHeight', targetHeight);\n dispatch(actionForceUpdate(false));\n }\n }\n}\n\n/**\n * Toggles the `resize listener` on `window`\n * @param param.0 {@link BeforeRenderFeatureProps}.\n * @param param.1 Resize listener.\n * @returns void\n */\nfunction attachResize([{ getView, browserContext }, resizeListener]: [\n featureProps: AdjustHeightProps,\n resizeListener: () => void\n]) {\n const {\n meta: { height: { height, fitHeightToElement, autoSize = true } = {}, basicMode, numberOfRows }\n } = getView();\n const isNumberOfRowsDefined = !!numberOfRows;\n if (!basicMode && !isNumberOfRowsDefined && !height && fitHeightToElement && autoSize) {\n browserContext.window.removeEventListener('resize', resizeListener);\n browserContext.window.addEventListener('resize', resizeListener);\n } else {\n browserContext.window.removeEventListener('resize', resizeListener);\n }\n}\n\n/**\n * Calculates the {@link View.bodyHeight body height} of the view and toggles `resize listener` to the `window`.\n *\n * 1. The `body height` is calculated only on initial mount of the Repeating structures, if following properties are provided in {@link Meta}:\n * - {@link Meta.height}\n * - {@link Meta.numberOfRows}\n *\n * 2. The `resize listener` is attached/removed on initial mount of Repeating structures, after considering the values for following properties in {@link Meta}:\n * - {@link Meta.height}\n * - {@link Meta.numberOfRows}\n *\n * Additionally the `resize listener` will be removed on `UNMOUNT` event publish.\n *\n */\n// TODO: RsCore shouldn't be responsible for height calculations. We should move this feature to React layer.\nexport default (rsInternal: RsInternal) => {\n const { getView, getRsStateResolver, getPubSubUtils } = rsInternal;\n const { dispatch } = getRsStateResolver();\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n const resizeListener = () => {\n // prevent execution of previous setTimeout\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n // change width from the state object after 500 milliseconds\n timeoutId = setTimeout(\n () => execute([{ getView, dispatch, browserContext: rsInternal.getBrowserContext() }]),\n 500\n );\n };\n\n getPubSubUtils().subscribe(UNMOUNT, () => {\n rsInternal.getBrowserContext().window.removeEventListener('resize', resizeListener);\n });\n\n const memoisedExecute = withMemoization(execute);\n const memoisedAttachResize = withMemoization(attachResize);\n return (featureProps: BeforeRenderFeatureProps) => {\n memoisedExecute(\n [featureProps],\n [featureProps.getView().meta.numberOfRows, featureProps.getView().meta.height]\n );\n memoisedAttachResize(\n [featureProps, resizeListener],\n [featureProps.getView().meta.numberOfRows, featureProps.getView().meta.height]\n );\n };\n};\n"]}