@procore/data-table 14.14.0 → 14.15.0

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.
@@ -3,10 +3,11 @@ import { uniqBy, prop, startsWith, mergeDeepRight, equals, omit, intersection, i
3
3
  import { useI18nContext, Select, Input, UNSAFE_useOverlayTriggerContext, Card, Flex, Box, SegmentedController, Calendar, useDateTime, OverlayTrigger, isEventSource, DateInput, UNSAFE_isValidYearRange, DateSelect, PillSelect, TextArea, UNSAFE_useMenuImperativeControlNavigation, UNSAFE_Menu, UNSAFE_menuItemsWrapperAttribute, Spinner as Spinner$1, FlexList, Typography, Tooltip, Button, Required, MultiSelect, colors, Form, spacing, Switch, Panel, UNSAFE_StyledFilterTokenLabel, typographyWeights, SelectButton, StyledSelectButton, StyledSelectButtonLabel, StyledButton, StyledSelectArrow, Popover, UNSAFE_StyledSuperSelectTrigger, UNSAFE_StyledSuperSelectLabel, UNSAFE_StyledSuperSelectArrow, DateTimeProvider, useField, Label, UNSAFE_mergeRefs, ContactItem as ContactItem$1, ToggleButton, Link, AvatarStack, Pill, Typeahead, Pagination, UNSAFE_FilterToken, UNSAFE_SuperSelect, Avatar, H3, Checkbox, useI18n, I18nContext, UNSAFE_useSuperSelectContext, DropdownFlyout, useVisibility, StyledDropdownFlyoutLabel, StyledDropdownFlyoutExpandIcon, EmptyState as EmptyState$1 } from '@procore/core-react';
4
4
  import classnames from 'classnames/bind';
5
5
  import debounce5 from 'lodash.debounce';
6
- import { Error as Error$1, Grip, Pencil, Building, Clear, Calendar as Calendar$1, ArrowDown, ArrowUp, CaretDown, CaretRight, CaretsInVertical, CaretsOutVerticalWithLine, CaretsOutVertical, CaretsIn, CaretsOut } from '@procore/core-icons';
6
+ import { Error as Error$1, Grip, ExternalLink, Pencil, Building, Clear, Calendar as Calendar$1, ArrowDown, ArrowUp, CaretDown, CaretRight, CaretsInVertical, CaretsOutVerticalWithLine, CaretsOutVertical, CaretsIn, CaretsOut } from '@procore/core-icons';
7
7
  import classNames from 'classnames';
8
8
  import { isDate, parseISO, isSameDay, formatISO, isBefore } from 'date-fns';
9
9
  import { formatNumber, formatCurrency, formatPercentage } from '@procore/labs-financials-utils';
10
+ import { format } from '@procore/labs-financials-utils/dist/format';
10
11
  import { detectPrng, factory } from 'ulid';
11
12
  import { useToastAlertContext, ToastAlertProvider } from '@procore/toast-alert';
12
13
  import ReactDOM, { createPortal } from 'react-dom';
@@ -1407,7 +1408,7 @@ ag-grid, ag-grid-angular, ag-grid-ng2, ag-grid-polymer, ag-grid-aurelia {
1407
1408
  animation-iteration-count: infinite;
1408
1409
  animation-name: ag-shake-left-to-right;
1409
1410
  }
1410
- @keyframes _ag-shake-left-to-right_1c24o_369 {
1411
+ @keyframes _ag-shake-left-to-right_ye2ai_369 {
1411
1412
  from {
1412
1413
  padding-left: 6px;
1413
1414
  padding-right: 2px;
@@ -5408,7 +5409,7 @@ input[class^=ag-][type=button]:focus, button[class^=ag-]:focus {
5408
5409
  animation-iteration-count: infinite;
5409
5410
  animation-timing-function: linear;
5410
5411
  }
5411
- @keyframes _spin_1c24o_1 {
5412
+ @keyframes _spin_ye2ai_1 {
5412
5413
  from {
5413
5414
  transform: rotate(0deg);
5414
5415
  }
@@ -7493,10 +7494,15 @@ input[class^=ag-][type=range]:disabled {
7493
7494
  }
7494
7495
  .ag-theme-alpine.ag-theme-alpine .ag-row--dt-active {
7495
7496
  background-color: #e4ecfb;
7496
- border-left: 4px solid #2066df;
7497
7497
  }
7498
- .ag-theme-alpine.ag-theme-alpine .ag-row--dt-active > .ag-cell {
7499
- padding-left: 12px;
7498
+ .ag-theme-alpine.ag-theme-alpine .ag-row--dt-active::before {
7499
+ background-color: #2066df;
7500
+ content: "";
7501
+ width: 4px;
7502
+ height: 100%;
7503
+ position: absolute;
7504
+ top: 0;
7505
+ left: 0;
7500
7506
  }
7501
7507
  .ag-theme-alpine.ag-theme-alpine .ag-row--dt-overdue span {
7502
7508
  color: #e61920;
@@ -7908,7 +7914,7 @@ input[class^=ag-][type=range]:disabled {
7908
7914
  padding-left: 16px;
7909
7915
  }
7910
7916
 
7911
- div._contextPanel_1c24o_7148 {
7917
+ div._contextPanel_ye2ai_7153 {
7912
7918
  width: 400px;
7913
7919
  transition: all ease 500ms;
7914
7920
  flex: 0 0 auto;
@@ -7917,7 +7923,7 @@ div._contextPanel_1c24o_7148 {
7917
7923
  border: 1px solid #d6dadc;
7918
7924
  display: flex;
7919
7925
  }
7920
- div._contextPanel--hidden_1c24o_7157 {
7926
+ div._contextPanel--hidden_ye2ai_7162 {
7921
7927
  border: none;
7922
7928
  overflow: hidden;
7923
7929
  padding: 0px;
@@ -7925,50 +7931,50 @@ div._contextPanel--hidden_1c24o_7157 {
7925
7931
  width: 0px;
7926
7932
  }
7927
7933
 
7928
- ._contextPanelWrapper_1c24o_7165 {
7934
+ ._contextPanelWrapper_ye2ai_7170 {
7929
7935
  position: relative;
7930
7936
  flex-grow: 1;
7931
7937
  }
7932
7938
 
7933
- ._contextPanelBody_1c24o_7170 {
7939
+ ._contextPanelBody_ye2ai_7175 {
7934
7940
  width: clamp(380px, 400px, 100%);
7935
7941
  }
7936
7942
 
7937
- ._contextPanel-stickyHeader_1c24o_7174 {
7943
+ ._contextPanel-stickyHeader_ye2ai_7179 {
7938
7944
  background-color: #ffffff;
7939
7945
  position: sticky;
7940
7946
  top: 0;
7941
7947
  z-index: 5;
7942
7948
  }
7943
7949
 
7944
- ._filters-list_1c24o_7181 {
7950
+ ._filters-list_ye2ai_7186 {
7945
7951
  padding: 0;
7946
7952
  margin: 0;
7947
7953
  }
7948
- ._filters-list_1c24o_7181 ol {
7954
+ ._filters-list_ye2ai_7186 ol {
7949
7955
  padding: 0;
7950
7956
  margin: 0;
7951
7957
  }
7952
7958
 
7953
- ._col-drag-column-icon_1c24o_7190 {
7959
+ ._col-drag-column-icon_ye2ai_7195 {
7954
7960
  color: #6a767c;
7955
7961
  }
7956
7962
 
7957
- ._tabular-nums_1c24o_7194 {
7963
+ ._tabular-nums_ye2ai_7199 {
7958
7964
  font-variant-numeric: tabular-nums;
7959
7965
  }`;
7960
7966
  document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css));
7961
7967
  var styles_default = {
7962
- "contextPanel": "_contextPanel_1c24o_7148",
7963
- "contextPanel--hidden": "_contextPanel--hidden_1c24o_7157",
7964
- "contextPanelWrapper": "_contextPanelWrapper_1c24o_7165",
7965
- "contextPanelBody": "_contextPanelBody_1c24o_7170",
7966
- "contextPanel-stickyHeader": "_contextPanel-stickyHeader_1c24o_7174",
7967
- "filters-list": "_filters-list_1c24o_7181",
7968
- "col-drag-column-icon": "_col-drag-column-icon_1c24o_7190",
7969
- "tabular-nums": "_tabular-nums_1c24o_7194",
7970
- "ag-shake-left-to-right": "_ag-shake-left-to-right_1c24o_369",
7971
- "spin": "_spin_1c24o_1"
7968
+ "contextPanel": "_contextPanel_ye2ai_7153",
7969
+ "contextPanel--hidden": "_contextPanel--hidden_ye2ai_7162",
7970
+ "contextPanelWrapper": "_contextPanelWrapper_ye2ai_7170",
7971
+ "contextPanelBody": "_contextPanelBody_ye2ai_7175",
7972
+ "contextPanel-stickyHeader": "_contextPanel-stickyHeader_ye2ai_7179",
7973
+ "filters-list": "_filters-list_ye2ai_7186",
7974
+ "col-drag-column-icon": "_col-drag-column-icon_ye2ai_7195",
7975
+ "tabular-nums": "_tabular-nums_ye2ai_7199",
7976
+ "ag-shake-left-to-right": "_ag-shake-left-to-right_ye2ai_369",
7977
+ "spin": "_spin_ye2ai_1"
7972
7978
  };
7973
7979
 
7974
7980
  // src/utils/getCellValueTypographyProps.ts
@@ -8642,12 +8648,12 @@ var DateCellValue = ({
8642
8648
  isGroup,
8643
8649
  value
8644
8650
  }) => {
8645
- const { format } = useDateTime();
8651
+ const { format: format2 } = useDateTime();
8646
8652
  if (isGroup || isEmptyValue(value)) {
8647
8653
  return null;
8648
8654
  }
8649
8655
  const parsedValue = getDateObject(value);
8650
- const internalValue = parsedValue ? format(
8656
+ const internalValue = parsedValue ? format2(
8651
8657
  parsedValue,
8652
8658
  columnDefinition.cellRendererParams?.dateFormatType || "numeric-date"
8653
8659
  ) : void 0;
@@ -8713,12 +8719,12 @@ var DateTimeCellValue = ({
8713
8719
  isGroup,
8714
8720
  value
8715
8721
  }) => {
8716
- const { format } = useDateTime();
8722
+ const { format: format2 } = useDateTime();
8717
8723
  if (isGroup || isEmptyValue(value)) {
8718
8724
  return null;
8719
8725
  }
8720
8726
  const parsedValue = getDateObject2(value);
8721
- const internalValue = parsedValue ? format(
8727
+ const internalValue = parsedValue ? format2(
8722
8728
  parsedValue,
8723
8729
  columnDefinition.cellRendererParams?.dateFormatType || "abbr-weekday-abbr-date-at-time"
8724
8730
  ) : void 0;
@@ -16639,7 +16645,7 @@ var calculateOrdinal = (value) => {
16639
16645
  }
16640
16646
  return "th";
16641
16647
  };
16642
- function dateToFormattedString(date, format = "YYYY-MM-DD") {
16648
+ function dateToFormattedString(date, format2 = "YYYY-MM-DD") {
16643
16649
  const fullYear = padStartWidthZeros(date.getFullYear(), 4);
16644
16650
  const months = [
16645
16651
  "January",
@@ -16683,7 +16689,7 @@ function dateToFormattedString(date, format = "YYYY-MM-DD") {
16683
16689
  d: () => `${date.getDay()}`
16684
16690
  };
16685
16691
  const regexp = new RegExp(Object.keys(replace).join("|"), "g");
16686
- return format.replace(regexp, (match) => {
16692
+ return format2.replace(regexp, (match) => {
16687
16693
  if (match in replace) {
16688
16694
  return replace[match]();
16689
16695
  }
@@ -21326,14 +21332,14 @@ var DateFilterModelFormatter = class extends SimpleFilterModelFormatter {
21326
21332
  const isRange = type == SimpleFilter.IN_RANGE || numberOfInputs === 2;
21327
21333
  const dateFrom = parseDateTimeFromString(condition.dateFrom);
21328
21334
  const dateTo = parseDateTimeFromString(condition.dateTo);
21329
- const format = this.dateFilterParams.inRangeFloatingFilterDateFormat;
21335
+ const format2 = this.dateFilterParams.inRangeFloatingFilterDateFormat;
21330
21336
  if (isRange) {
21331
- const formattedFrom = dateFrom !== null ? dateToFormattedString(dateFrom, format) : "null";
21332
- const formattedTo = dateTo !== null ? dateToFormattedString(dateTo, format) : "null";
21337
+ const formattedFrom = dateFrom !== null ? dateToFormattedString(dateFrom, format2) : "null";
21338
+ const formattedTo = dateTo !== null ? dateToFormattedString(dateTo, format2) : "null";
21333
21339
  return `${formattedFrom}-${formattedTo}`;
21334
21340
  }
21335
21341
  if (dateFrom != null) {
21336
- return dateToFormattedString(dateFrom, format);
21342
+ return dateToFormattedString(dateFrom, format2);
21337
21343
  }
21338
21344
  return `${type}`;
21339
21345
  }
@@ -52955,7 +52961,27 @@ var InternalLinkCellRenderer = ({ columnDefinition, isGroup, data, rowHeight, va
52955
52961
  if (isGroup) {
52956
52962
  return /* @__PURE__ */ React76.createElement(Typography, { ...typographyProps, className, weight: "semibold" }, value);
52957
52963
  }
52964
+ const isExternalLink = columnDefinition.cellRendererParams.isExternalLink ?? false;
52958
52965
  const URL = columnDefinition.cellRendererParams.getURL(value, data);
52966
+ if (isExternalLink && value && URL) {
52967
+ return /* @__PURE__ */ React76.createElement(
52968
+ Typography,
52969
+ {
52970
+ ...typographyProps,
52971
+ className,
52972
+ style: { display: "flex", alignItems: "center", gap: "5px" }
52973
+ },
52974
+ internalValue,
52975
+ /* @__PURE__ */ React76.createElement(
52976
+ ExternalLink,
52977
+ {
52978
+ cursor: "pointer",
52979
+ size: "sm",
52980
+ onClick: () => window.open(URL, "_blank")
52981
+ }
52982
+ )
52983
+ );
52984
+ }
52959
52985
  return URL ? /* @__PURE__ */ React76.createElement(Typography, { ...typographyProps, className }, /* @__PURE__ */ React76.createElement(Link, { href: URL }, internalValue)) : /* @__PURE__ */ React76.createElement(Typography, { ...typographyProps }, internalValue);
52960
52986
  };
52961
52987
  var LinkCellRenderer = withDataTableRenderer(
@@ -52983,9 +53009,10 @@ var InternalNumberCellRenderer = ({ columnDefinition, rowPinned, isGroup, value
52983
53009
  }
52984
53010
  return /* @__PURE__ */ React76.createElement(React76.Fragment, null);
52985
53011
  }
52986
- const internalValue = formatNumber(value, {
53012
+ const internalValue = format(value, {
52987
53013
  maxDecimalPrecision: 15,
52988
53014
  minDecimalPrecision: 0,
53015
+ shouldUseGtk: true,
52989
53016
  symbol: "",
52990
53017
  ...columnDefinition.cellRendererParams?.formatConfig
52991
53018
  });
@@ -53366,7 +53393,7 @@ var Renderer9 = ({
53366
53393
  value,
53367
53394
  rowPinned
53368
53395
  }) => {
53369
- const { getColor } = columnDefinition.cellRendererParams;
53396
+ const { getColor, displayAsPill } = columnDefinition.cellRendererParams;
53370
53397
  const I18n = useI18nContext();
53371
53398
  if (isEmptyValue(value)) {
53372
53399
  if (isGroup) {
@@ -53392,7 +53419,7 @@ var Renderer9 = ({
53392
53419
  const typographyProps = getCellValueTypographyProps(
53393
53420
  columnDefinition.cellRendererParams?.typographyProps
53394
53421
  );
53395
- if (isGroup || rowPinned && columnDefinition.aggFunc) {
53422
+ if ((isGroup || rowPinned && columnDefinition.aggFunc) && !displayAsPill) {
53396
53423
  return /* @__PURE__ */ React76.createElement(Typography, { ...typographyProps, weight: "semibold" }, label);
53397
53424
  }
53398
53425
  return /* @__PURE__ */ React76.createElement(Pill, { color: getColor(value), className: cx10("pill-cell") }, label);
@@ -54796,8 +54823,8 @@ function transformToExcelStyles(excelDataFormats) {
54796
54823
  if (excelDataFormats === void 0) {
54797
54824
  return void 0;
54798
54825
  }
54799
- return excelDataFormats.map((format) => {
54800
- const { id, ...rest } = format;
54826
+ return excelDataFormats.map((format2) => {
54827
+ const { id, ...rest } = format2;
54801
54828
  return {
54802
54829
  id: toExcelCellClass(id),
54803
54830
  ...rest
@@ -55853,6 +55880,8 @@ var DataTableCellRenderer = ({
55853
55880
  value
55854
55881
  };
55855
55882
  const hasValue = value !== void 0 && value !== null && value !== "";
55883
+ const isSelectCellComponent = columnDefinition.cellEditor?.render?.displayName === "SelectCellEditor";
55884
+ const URL = isSelectCellComponent && columnDefinition?.cellRendererParams?.getURL ? columnDefinition.cellRendererParams.getURL(value) : null;
55856
55885
  const startEditing = useCallback(
55857
55886
  () => api.startEditingCell({
55858
55887
  rowIndex: node.rowIndex,
@@ -55860,34 +55889,54 @@ var DataTableCellRenderer = ({
55860
55889
  }),
55861
55890
  [column2, node]
55862
55891
  );
55863
- return /* @__PURE__ */ React76.createElement(React76.Fragment, null, shouldDisplayRowCheckbox(columnApi, column2, node) && /* @__PURE__ */ React76.createElement(Box, { paddingLeft: "sm" }, /* @__PURE__ */ React76.createElement(RowCheckbox, { api, data, node })), columnDefinition.editable ? /* @__PURE__ */ React76.createElement(
55864
- PseudoInlineEditorWrapper,
55865
- {
55866
- showArrow: editorType === "select",
55867
- onClick: startEditing,
55868
- onClear: columnDefinition.cellEditorParams?.clearable && hasValue ? () => {
55869
- setValue?.(null);
55870
- } : void 0,
55871
- showCalendar: editorType === "date",
55872
- rightAligned: colDef.type === "rightAligned",
55873
- hasValue,
55874
- alwaysShowEditors: columnDefinition.cellEditorParams?.alwaysShowPseudoEditors,
55875
- ...validationOutput
55876
- },
55877
- /* @__PURE__ */ React76.createElement(Component4, { ...componentParams })
55878
- ) : /* @__PURE__ */ React76.createElement(
55879
- NonEditorWrapper,
55892
+ return /* @__PURE__ */ React76.createElement(React76.Fragment, null, shouldDisplayRowCheckbox(columnApi, column2, node) && /* @__PURE__ */ React76.createElement(Box, { paddingLeft: "sm" }, /* @__PURE__ */ React76.createElement(RowCheckbox, { api, data, node })), /* @__PURE__ */ React76.createElement(
55893
+ Flex,
55880
55894
  {
55881
- rightAligned: colDef.type === "rightAligned",
55882
- ...validationOutput,
55883
- rowPinned: Boolean(componentParams.rowPinned),
55884
- isGroup: Boolean(componentParams.isGroup)
55895
+ gap: "5px",
55896
+ alignItems: "center",
55897
+ justifyContent: "center",
55898
+ style: { width: "100%" }
55885
55899
  },
55886
- /* @__PURE__ */ React76.createElement(
55887
- Component4,
55900
+ columnDefinition.editable ? /* @__PURE__ */ React76.createElement(
55901
+ PseudoInlineEditorWrapper,
55902
+ {
55903
+ showArrow: editorType === "select",
55904
+ onClick: startEditing,
55905
+ onClear: columnDefinition.cellEditorParams?.clearable && hasValue ? () => {
55906
+ setValue?.(null);
55907
+ } : void 0,
55908
+ showCalendar: editorType === "date",
55909
+ rightAligned: colDef.type === "rightAligned",
55910
+ hasValue,
55911
+ alwaysShowEditors: columnDefinition.cellEditorParams?.alwaysShowPseudoEditors,
55912
+ ...validationOutput
55913
+ },
55914
+ /* @__PURE__ */ React76.createElement(Component4, { ...componentParams })
55915
+ ) : /* @__PURE__ */ React76.createElement(
55916
+ NonEditorWrapper,
55888
55917
  {
55889
- ...componentParams,
55890
- tableRef: columnDefinition.cellRendererParams.tableRef
55918
+ rightAligned: colDef.type === "rightAligned",
55919
+ ...validationOutput,
55920
+ rowPinned: Boolean(componentParams.rowPinned),
55921
+ isGroup: Boolean(componentParams.isGroup)
55922
+ },
55923
+ /* @__PURE__ */ React76.createElement(
55924
+ Component4,
55925
+ {
55926
+ ...componentParams,
55927
+ tableRef: columnDefinition.cellRendererParams.tableRef
55928
+ }
55929
+ )
55930
+ ),
55931
+ URL && /* @__PURE__ */ React76.createElement(
55932
+ ExternalLink,
55933
+ {
55934
+ cursor: "pointer",
55935
+ size: "sm",
55936
+ onClick: (e) => {
55937
+ e.stopPropagation();
55938
+ window.open(URL, "_blank");
55939
+ }
55891
55940
  }
55892
55941
  )
55893
55942
  ));
@@ -61429,14 +61478,14 @@ var protection_default = protection;
61429
61478
  // ../../node_modules/@ag-grid-enterprise/excel-export/dist/esm/es6/excelExport/files/xml/styles/numberFormat.mjs
61430
61479
  var numberFormat = {
61431
61480
  getTemplate(styleProperties) {
61432
- const { format } = styleProperties.numberFormat;
61481
+ const { format: format2 } = styleProperties.numberFormat;
61433
61482
  return {
61434
61483
  name: "NumberFormat",
61435
61484
  properties: {
61436
61485
  prefixedAttributes: [{
61437
61486
  prefix: "ss:",
61438
61487
  map: {
61439
- Format: format
61488
+ Format: format2
61440
61489
  }
61441
61490
  }]
61442
61491
  }
@@ -63387,15 +63436,15 @@ var registerFill = (fill) => {
63387
63436
  }
63388
63437
  return pos;
63389
63438
  };
63390
- var registerNumberFmt = (format) => {
63391
- format = _.utf8_encode(format);
63392
- if (numberFormatMap[format]) {
63393
- return numberFormatMap[format];
63439
+ var registerNumberFmt = (format2) => {
63440
+ format2 = _.utf8_encode(format2);
63441
+ if (numberFormatMap[format2]) {
63442
+ return numberFormatMap[format2];
63394
63443
  }
63395
- let pos = registeredNumberFmts.findIndex((currentFormat) => currentFormat.formatCode === format);
63444
+ let pos = registeredNumberFmts.findIndex((currentFormat) => currentFormat.formatCode === format2);
63396
63445
  if (pos === -1) {
63397
63446
  pos = registeredNumberFmts.length + 164;
63398
- registeredNumberFmts.push({ formatCode: format, numFmtId: pos });
63447
+ registeredNumberFmts.push({ formatCode: format2, numFmtId: pos });
63399
63448
  } else {
63400
63449
  pos = registeredNumberFmts[pos].numFmtId;
63401
63450
  }
@@ -80515,44 +80564,73 @@ function generateHTMLString({
80515
80564
  if (exportedDocument.querySelector(".ag-header-container") && showTableHeaderOnEveryPage) {
80516
80565
  const tableHeaderStylesElement = exportedDocument.createElement("style");
80517
80566
  tableHeaderStylesElement.innerHTML = `
80567
+ /* Original header styles */
80518
80568
  .ag-header-container {
80519
80569
  height: ${TABLE_HEADER_HEIGHT}px;
80520
80570
  background: ${colors.gray96};
80521
80571
  border-bottom: 1px solid #d6dadc;
80522
- break-before: page;
80572
+ }
80573
+ /* Cloned header styles */
80574
+ .paginated-header {
80575
+ height: ${TABLE_HEADER_HEIGHT}px;
80576
+ background: ${colors.gray96};
80577
+ border-bottom: 1px solid #d6dadc;
80578
+ /* Ensure cloned headers start on a new page */
80579
+ page-break-before: always;
80523
80580
  }
80524
80581
  `;
80525
80582
  exportedDocument.head.appendChild(tableHeaderStylesElement);
80526
- const tableHeader = exportedDocument.querySelector(".ag-header-container").cloneNode(true);
80583
+ const tableHeaderElement = exportedDocument.querySelector(
80584
+ ".ag-header-container"
80585
+ );
80586
+ if (!tableHeaderElement) {
80587
+ return reject(new Error("Table header container not found."));
80588
+ }
80589
+ const tableHeader = tableHeaderElement.cloneNode(true);
80590
+ tableHeader.classList.add("paginated-header");
80527
80591
  const tableRowsContainer = exportedDocument.querySelector(
80528
80592
  ".ag-center-cols-container"
80529
80593
  );
80530
- const totalRows = tableRowsContainer.children.length;
80531
- const maxPageContentHeight = pageHeight - pageFormat.marginInPixels.top - pageFormat.marginInPixels.bottom;
80532
- let pageContentHeight = TABLE_HEADER_HEIGHT;
80533
- let currentPage = 1;
80534
- for (let index = 0; index < totalRows; index++) {
80535
- const getScaledRowHeight = (row3) => {
80536
- const scale = pageHeight / tableWidth;
80537
- let rowHeight2 = Number(row3.style.height.replace("px", ""));
80538
- if (scale < 1) {
80539
- rowHeight2 *= scale;
80594
+ if (!tableRowsContainer) {
80595
+ console.error("Table rows container not found.");
80596
+ return;
80597
+ }
80598
+ const allRows = Array.from(
80599
+ tableRowsContainer.children
80600
+ );
80601
+ tableRowsContainer.innerHTML = "";
80602
+ const maxPageContentHeight = pageHeight - (pageFormat.marginInPixels?.top ?? DEFAULT_PAGE_MARGIN) - (pageFormat.marginInPixels?.bottom ?? DEFAULT_PAGE_MARGIN) - TABLE_HEADER_HEIGHT;
80603
+ let currentPageContentHeight = 0;
80604
+ let rowsInCurrentPage = [];
80605
+ let isFirstPage = true;
80606
+ const appendPage = () => {
80607
+ if (rowsInCurrentPage.length > 0) {
80608
+ if (!isFirstPage) {
80609
+ tableRowsContainer.appendChild(tableHeader.cloneNode(true));
80610
+ } else {
80611
+ isFirstPage = false;
80540
80612
  }
80541
- return rowHeight2;
80542
- };
80543
- const row2 = tableRowsContainer.children[index + currentPage - 1];
80544
- const rowHeight = getScaledRowHeight(row2);
80545
- if (pageContentHeight + rowHeight >= maxPageContentHeight) {
80546
- tableRowsContainer.insertBefore(
80547
- tableHeader.cloneNode(true),
80548
- row2
80613
+ rowsInCurrentPage.forEach(
80614
+ (row2) => tableRowsContainer.appendChild(row2)
80549
80615
  );
80550
- currentPage += 1;
80551
- pageContentHeight = TABLE_HEADER_HEIGHT;
80552
- } else {
80553
- pageContentHeight += rowHeight;
80616
+ rowsInCurrentPage = [];
80617
+ currentPageContentHeight = 0;
80554
80618
  }
80555
- }
80619
+ };
80620
+ allRows.forEach((row2) => {
80621
+ let rowHeight = parseFloat(row2.style.height.replace("px", "")) || row2.offsetHeight;
80622
+ const scale = pageHeight / tableWidth;
80623
+ if (scale < 1) {
80624
+ rowHeight *= scale;
80625
+ }
80626
+ if (currentPageContentHeight + rowHeight > maxPageContentHeight) {
80627
+ appendPage();
80628
+ isFirstPage = false;
80629
+ }
80630
+ rowsInCurrentPage.push(row2);
80631
+ currentPageContentHeight += rowHeight;
80632
+ });
80633
+ appendPage();
80556
80634
  }
80557
80635
  resolve(exportedDocument.getElementsByTagName("html")[0].outerHTML);
80558
80636
  }, 2e3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/data-table",
3
- "version": "14.14.0",
3
+ "version": "14.15.0",
4
4
  "description": "Complex data grid built on top of ag-grid, with DST components and styles.",
5
5
  "type": "module",
6
6
  "main": "dist/legacy/index.cjs",
@@ -111,7 +111,7 @@
111
111
  "@procore/core-css": "10.17.0",
112
112
  "@procore/core-icons": "12.2.0",
113
113
  "@procore/core-prettier": "10.2.0",
114
- "@procore/core-react": "12.11.0",
114
+ "@procore/core-react": "12.12.0",
115
115
  "@procore/eslint-config": "10.0.0",
116
116
  "@procore/globalization-toolkit": "3.1.0",
117
117
  "@procore/labs-financials-utils": "3.0.1",