@procore/data-table 14.13.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,10 +53419,10 @@ 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
- return /* @__PURE__ */ React76.createElement(Pill, { color: getColor(value), className: cx10("pill-cell") }, label?.toUpperCase());
53425
+ return /* @__PURE__ */ React76.createElement(Pill, { color: getColor(value), className: cx10("pill-cell") }, label);
53399
53426
  };
53400
53427
  var PillCellRenderer = withDataTableRenderer(Renderer9, "select");
53401
53428
  var Editor5 = React76.forwardRef(
@@ -53428,7 +53455,7 @@ var Editor5 = React76.forwardRef(
53428
53455
  }
53429
53456
  function getLabel3(item) {
53430
53457
  const unformattedLabel = columnDefinition.getStringFormattedValue?.(item) || "";
53431
- return unformattedLabel.toUpperCase();
53458
+ return unformattedLabel;
53432
53459
  }
53433
53460
  return /* @__PURE__ */ React76.createElement(
53434
53461
  PillSelect,
@@ -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,
55917
+ {
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,
55888
55933
  {
55889
- ...componentParams,
55890
- tableRef: columnDefinition.cellRendererParams.tableRef
55934
+ cursor: "pointer",
55935
+ size: "sm",
55936
+ onClick: (e) => {
55937
+ e.stopPropagation();
55938
+ window.open(URL, "_blank");
55939
+ }
55891
55940
  }
55892
55941
  )
55893
55942
  ));
@@ -56521,9 +56570,10 @@ var GenericHeaderRenderer = (props) => {
56521
56570
  props.api.addEventListener("columnRowGroupChanged", updateExpandedState);
56522
56571
  return () => {
56523
56572
  props.column.removeEventListener("sortChanged", onSortChanged);
56524
- props.api.removeEventListener(
56573
+ removeEventListenerFromGrid(
56525
56574
  "columnRowGroupChanged",
56526
- updateExpandedState
56575
+ updateExpandedState,
56576
+ props.api
56527
56577
  );
56528
56578
  };
56529
56579
  }, [props.column]);
@@ -57589,6 +57639,7 @@ var InternalTableContext = React76.createContext({
57589
57639
  getRowHeight: () => () => rowSize.md,
57590
57640
  grandTotalsLabelInnerRenderer: void 0,
57591
57641
  gridApi: void 0,
57642
+ localStoragePersistenceKey: void 0,
57592
57643
  onBulkEditUpdate: () => Promise.resolve(),
57593
57644
  onServerSideDataRequest: void 0,
57594
57645
  onTableConfigChange: () => {
@@ -57605,6 +57656,7 @@ var InternalTableContext = React76.createContext({
57605
57656
  setRowHeight: () => {
57606
57657
  },
57607
57658
  showExpandCollapseAllToggle: false,
57659
+ expandCollapseStateRef: null,
57608
57660
  tableRef: null,
57609
57661
  getColumnDefinition: () => void 0,
57610
57662
  setSelectedGroupIndex: () => {
@@ -61426,14 +61478,14 @@ var protection_default = protection;
61426
61478
  // ../../node_modules/@ag-grid-enterprise/excel-export/dist/esm/es6/excelExport/files/xml/styles/numberFormat.mjs
61427
61479
  var numberFormat = {
61428
61480
  getTemplate(styleProperties) {
61429
- const { format } = styleProperties.numberFormat;
61481
+ const { format: format2 } = styleProperties.numberFormat;
61430
61482
  return {
61431
61483
  name: "NumberFormat",
61432
61484
  properties: {
61433
61485
  prefixedAttributes: [{
61434
61486
  prefix: "ss:",
61435
61487
  map: {
61436
- Format: format
61488
+ Format: format2
61437
61489
  }
61438
61490
  }]
61439
61491
  }
@@ -63384,15 +63436,15 @@ var registerFill = (fill) => {
63384
63436
  }
63385
63437
  return pos;
63386
63438
  };
63387
- var registerNumberFmt = (format) => {
63388
- format = _.utf8_encode(format);
63389
- if (numberFormatMap[format]) {
63390
- return numberFormatMap[format];
63439
+ var registerNumberFmt = (format2) => {
63440
+ format2 = _.utf8_encode(format2);
63441
+ if (numberFormatMap[format2]) {
63442
+ return numberFormatMap[format2];
63391
63443
  }
63392
- let pos = registeredNumberFmts.findIndex((currentFormat) => currentFormat.formatCode === format);
63444
+ let pos = registeredNumberFmts.findIndex((currentFormat) => currentFormat.formatCode === format2);
63393
63445
  if (pos === -1) {
63394
63446
  pos = registeredNumberFmts.length + 164;
63395
- registeredNumberFmts.push({ formatCode: format, numFmtId: pos });
63447
+ registeredNumberFmts.push({ formatCode: format2, numFmtId: pos });
63396
63448
  } else {
63397
63449
  pos = registeredNumberFmts[pos].numFmtId;
63398
63450
  }
@@ -78019,6 +78071,61 @@ var buildDetailRowsConfig_ = (detailRowConfig, {
78019
78071
  };
78020
78072
  };
78021
78073
 
78074
+ // src/utils/expandRows.ts
78075
+ var getGroupRowState = (gridApi, groupDefaultExpanded = 0) => {
78076
+ const expandedRoutes = [];
78077
+ const collapsedRoutes = [];
78078
+ if (gridApi) {
78079
+ gridApi.forEachNode((node) => {
78080
+ const route = node.getRoute();
78081
+ if (route) {
78082
+ const routePath = route.join(",");
78083
+ const defaultExpandLevel = groupDefaultExpanded === -1 ? Infinity : groupDefaultExpanded;
78084
+ if (node.level > defaultExpandLevel - 1) {
78085
+ if (node.expanded) {
78086
+ expandedRoutes.push(routePath);
78087
+ }
78088
+ } else if (!node.expanded) {
78089
+ collapsedRoutes.push(routePath);
78090
+ }
78091
+ }
78092
+ });
78093
+ }
78094
+ return { expandedRoutes, collapsedRoutes };
78095
+ };
78096
+ var setExpandCollapseRow = (gridApi, tableConfig, groupDefaultExpanded = 0) => {
78097
+ const expandedRoutes = tableConfig.groupRowState?.expandedRoutes ?? [];
78098
+ const collapsedRoutes = tableConfig.groupRowState?.collapsedRoutes ?? [];
78099
+ gridApi.forEachNode((node) => {
78100
+ const route = node.getRoute();
78101
+ if (route) {
78102
+ const routePath = route.join(",");
78103
+ const defaultExpandLevel = groupDefaultExpanded === -1 ? Infinity : groupDefaultExpanded;
78104
+ if (node.level > defaultExpandLevel - 1) {
78105
+ if (expandedRoutes.includes(routePath)) {
78106
+ node.setExpanded(true);
78107
+ }
78108
+ } else if (collapsedRoutes.includes(routePath)) {
78109
+ node.setExpanded(false);
78110
+ }
78111
+ }
78112
+ });
78113
+ };
78114
+ var isRowOpenedByDefault = (node, tableConfig, groupDefaultExpanded = 0) => {
78115
+ const expandedRoutes = tableConfig?.groupRowState?.expandedRoutes ?? [];
78116
+ const collapsedRoutes = tableConfig?.groupRowState?.collapsedRoutes ?? [];
78117
+ const route = node.getRoute();
78118
+ if (!route) {
78119
+ return false;
78120
+ }
78121
+ const routePath = route.join(",");
78122
+ const defaultExpandLevel = groupDefaultExpanded === -1 ? Infinity : groupDefaultExpanded;
78123
+ if (node.level > defaultExpandLevel - 1) {
78124
+ return expandedRoutes.includes(routePath);
78125
+ } else
78126
+ return !collapsedRoutes.includes(routePath);
78127
+ };
78128
+
78022
78129
  // src/utils/getRootRowNode.ts
78023
78130
  function getRootRowNode(rowNode) {
78024
78131
  return rowNode.level > 0 && rowNode.parent ? getRootRowNode(rowNode.parent) : rowNode;
@@ -80457,44 +80564,73 @@ function generateHTMLString({
80457
80564
  if (exportedDocument.querySelector(".ag-header-container") && showTableHeaderOnEveryPage) {
80458
80565
  const tableHeaderStylesElement = exportedDocument.createElement("style");
80459
80566
  tableHeaderStylesElement.innerHTML = `
80567
+ /* Original header styles */
80460
80568
  .ag-header-container {
80461
80569
  height: ${TABLE_HEADER_HEIGHT}px;
80462
80570
  background: ${colors.gray96};
80463
80571
  border-bottom: 1px solid #d6dadc;
80464
- 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;
80465
80580
  }
80466
80581
  `;
80467
80582
  exportedDocument.head.appendChild(tableHeaderStylesElement);
80468
- 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");
80469
80591
  const tableRowsContainer = exportedDocument.querySelector(
80470
80592
  ".ag-center-cols-container"
80471
80593
  );
80472
- const totalRows = tableRowsContainer.children.length;
80473
- const maxPageContentHeight = pageHeight - pageFormat.marginInPixels.top - pageFormat.marginInPixels.bottom;
80474
- let pageContentHeight = TABLE_HEADER_HEIGHT;
80475
- let currentPage = 1;
80476
- for (let index = 0; index < totalRows; index++) {
80477
- const getScaledRowHeight = (row3) => {
80478
- const scale = pageHeight / tableWidth;
80479
- let rowHeight2 = Number(row3.style.height.replace("px", ""));
80480
- if (scale < 1) {
80481
- 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;
80482
80612
  }
80483
- return rowHeight2;
80484
- };
80485
- const row2 = tableRowsContainer.children[index + currentPage - 1];
80486
- const rowHeight = getScaledRowHeight(row2);
80487
- if (pageContentHeight + rowHeight >= maxPageContentHeight) {
80488
- tableRowsContainer.insertBefore(
80489
- tableHeader.cloneNode(true),
80490
- row2
80613
+ rowsInCurrentPage.forEach(
80614
+ (row2) => tableRowsContainer.appendChild(row2)
80491
80615
  );
80492
- currentPage += 1;
80493
- pageContentHeight = TABLE_HEADER_HEIGHT;
80494
- } else {
80495
- pageContentHeight += rowHeight;
80616
+ rowsInCurrentPage = [];
80617
+ currentPageContentHeight = 0;
80496
80618
  }
80497
- }
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();
80498
80634
  }
80499
80635
  resolve(exportedDocument.getElementsByTagName("html")[0].outerHTML);
80500
80636
  }, 2e3);
@@ -80540,6 +80676,7 @@ var useTableApi = ({
80540
80676
  columnApi,
80541
80677
  columnDefinitions,
80542
80678
  gridApi,
80679
+ groupDefaultExpanded,
80543
80680
  setLoadingStatus,
80544
80681
  wrapperRef
80545
80682
  }) => {
@@ -80731,10 +80868,33 @@ var useTableApi = ({
80731
80868
  const setSearchValue = React76.useCallback(
80732
80869
  (value) => {
80733
80870
  gridApi?.setQuickFilter(value);
80871
+ gridApi?.forEachNodeAfterFilterAndSort((node) => {
80872
+ if (node.id) {
80873
+ const currentNode = rowSelectionRef?.current.affectedRows[node.id];
80874
+ if (currentNode && currentNode.selectedState === rowSelectionState.selected) {
80875
+ node.setSelected(true, false, "checkboxSelected");
80876
+ }
80877
+ }
80878
+ });
80734
80879
  resetPagination();
80880
+ gridApi?.redrawRows();
80735
80881
  },
80736
- [gridApi]
80882
+ [gridApi, rowSelectionRef.current]
80737
80883
  );
80884
+ React76.useEffect(() => {
80885
+ function handleRowSelection(event) {
80886
+ if (event.node.displayed && event.node.id) {
80887
+ rowSelectionRef.current.affectedRows[event.node.id] = {
80888
+ node: event.node,
80889
+ selectedState: event.node.isSelected() ? rowSelectionState.selected : rowSelectionState.unselected
80890
+ };
80891
+ }
80892
+ }
80893
+ gridApi?.addEventListener && gridApi.addEventListener("rowSelected", handleRowSelection);
80894
+ return () => {
80895
+ removeEventListenerFromGrid("rowSelected", handleRowSelection, gridApi);
80896
+ };
80897
+ }, [gridApi]);
80738
80898
  const setLoading = React76.useCallback((loading, message = "") => {
80739
80899
  setLoadingStatus({
80740
80900
  loading,
@@ -80795,6 +80955,7 @@ var useTableApi = ({
80795
80955
  adjustRowDragIcon(gridApi, columnApi);
80796
80956
  });
80797
80957
  }
80958
+ setExpandCollapseRow(gridApi, config, groupDefaultExpanded);
80798
80959
  },
80799
80960
  [columnApi, gridApi, internalSetRowHeight, filterStorage.setSelectedFilters]
80800
80961
  );
@@ -80886,7 +81047,8 @@ var useTableApi = ({
80886
81047
  columnApi,
80887
81048
  rowHeight,
80888
81049
  filterStorage,
80889
- rowSelectionRef
81050
+ rowSelectionRef,
81051
+ groupDefaultExpanded
80890
81052
  }),
80891
81053
  [columnApi, gridApi, rowHeight, filterStorage]
80892
81054
  );
@@ -81154,7 +81316,6 @@ function buildPartialTableApi({
81154
81316
  focusField && gridApi?.setFocusedCell(rowIndex, focusField);
81155
81317
  };
81156
81318
  return {
81157
- getVisibleRowNodes,
81158
81319
  applyTransaction,
81159
81320
  applyServerSideTransaction,
81160
81321
  collapseAll,
@@ -81169,6 +81330,7 @@ function buildPartialTableApi({
81169
81330
  getSelectedRows: getSelectedRows2,
81170
81331
  getServerSideSelectionState,
81171
81332
  getTableConfiguration,
81333
+ getVisibleRowNodes,
81172
81334
  refreshCells,
81173
81335
  setPinnedBottomRowData,
81174
81336
  setRowData,
@@ -81286,6 +81448,12 @@ var DataTable = ({
81286
81448
  const [rowHeight, setRowHeight] = React76.useState(
81287
81449
  initialTableConfig?.rowHeight || rowSize.md
81288
81450
  );
81451
+ const expandCollapseStateRef = React76.useRef(
81452
+ initialTableConfig?.groupRowState || {
81453
+ expandedRoutes: [],
81454
+ collapsedRoutes: []
81455
+ }
81456
+ );
81289
81457
  const rowHeightRef = React76.useRef(
81290
81458
  initialTableConfig?.rowHeight || rowSize.md
81291
81459
  );
@@ -81331,12 +81499,14 @@ var DataTable = ({
81331
81499
  if (localStoragePersistenceKey) {
81332
81500
  storage.local.setItem(localStoragePersistenceKey, {
81333
81501
  ...config,
81502
+ groupRowState: expandCollapseStateRef.current,
81334
81503
  rowHeight: rowHeightRef.current,
81335
81504
  serverFilters: filterStorage.filtersState
81336
81505
  });
81337
81506
  }
81338
81507
  onTableConfigChange?.({
81339
81508
  ...config,
81509
+ groupRowState: expandCollapseStateRef.current,
81340
81510
  rowHeight: rowHeightRef.current,
81341
81511
  serverFilters: filterStorage.filtersState
81342
81512
  });
@@ -81445,6 +81615,7 @@ var DataTable = ({
81445
81615
  onServerSideDataRequest,
81446
81616
  onTableConfigChange: internalOnTableConfigChange,
81447
81617
  rowSelectionRef,
81618
+ expandCollapseStateRef,
81448
81619
  rowHeight,
81449
81620
  searchStorage,
81450
81621
  selectedGroupIndex,
@@ -81546,8 +81717,10 @@ var Table = (props) => {
81546
81717
  columnDefinitions: internalTableContext.columnDefinitions,
81547
81718
  gridApi,
81548
81719
  setLoadingStatus,
81549
- wrapperRef
81720
+ wrapperRef,
81721
+ groupDefaultExpanded: props.groupDefaultExpanded
81550
81722
  });
81723
+ const initialTableConfig = internalTableContext.initialTableConfig;
81551
81724
  React76.useImperativeHandle(internalTableContext.tableRef, () => tableApi, [
81552
81725
  tableApi
81553
81726
  ]);
@@ -82054,6 +82227,34 @@ var Table = (props) => {
82054
82227
  document.getElementsByClassName("ag-body-viewport")[0]?.clientWidth
82055
82228
  );
82056
82229
  }, [setViewportWidth]);
82230
+ const isClientSideGroupOpenByDefault = React76.useCallback(
82231
+ (params) => {
82232
+ const node = params.rowNode;
82233
+ if (!node) {
82234
+ return false;
82235
+ }
82236
+ return isRowOpenedByDefault(
82237
+ node,
82238
+ initialTableConfig,
82239
+ props.groupsAlwaysExpanded ? -1 : props.groupDefaultExpanded
82240
+ );
82241
+ },
82242
+ [initialTableConfig, props.groupDefaultExpanded]
82243
+ );
82244
+ const isServerSideGroupOpenByDefault = React76.useCallback(
82245
+ (params) => {
82246
+ const node = params.rowNode;
82247
+ if (!node) {
82248
+ return false;
82249
+ }
82250
+ return isRowOpenedByDefault(
82251
+ node,
82252
+ initialTableConfig,
82253
+ props.groupsAlwaysExpanded ? -1 : props.groupDefaultExpanded
82254
+ );
82255
+ },
82256
+ [initialTableConfig, props.groupDefaultExpanded]
82257
+ );
82057
82258
  const onGridReady = (params) => {
82058
82259
  internalTableContext.setGridApi(params.api);
82059
82260
  internalTableContext.setColumnApi(params.columnApi);
@@ -82080,13 +82281,26 @@ var Table = (props) => {
82080
82281
  };
82081
82282
  const internalRowGroupOpened = React76.useCallback(
82082
82283
  (event) => {
82284
+ if (internalTableContext.expandCollapseStateRef) {
82285
+ internalTableContext.expandCollapseStateRef.current = getGroupRowState(
82286
+ gridApi,
82287
+ props.groupDefaultExpanded
82288
+ );
82289
+ }
82290
+ internalTableContext.onTableConfigChange();
82083
82291
  props.onRowGroupOpened?.({
82084
82292
  expanded: event.expanded,
82085
82293
  node: serializeNode(event.node),
82086
82294
  rowIndex: event.rowIndex
82087
82295
  });
82088
82296
  },
82089
- [props.onRowGroupOpened]
82297
+ [
82298
+ props.onRowGroupOpened,
82299
+ internalTableContext.onTableConfigChange,
82300
+ tableApi?.getTableConfiguration(),
82301
+ internalTableContext.expandCollapseStateRef?.current,
82302
+ gridApi
82303
+ ]
82090
82304
  );
82091
82305
  const getGroupRowAgg = React76.useCallback(
82092
82306
  (params) => {
@@ -82238,6 +82452,8 @@ var Table = (props) => {
82238
82452
  alwaysAggregateAtRootLevel: !onSSDR,
82239
82453
  autoGroupColumnDef: decoratedAutoGroupColDef,
82240
82454
  cacheBlockSize: props.paginationPageSize || defaultPaginationPageSize,
82455
+ isGroupOpenByDefault: isClientSideGroupOpenByDefault,
82456
+ isServerSideGroupOpenByDefault,
82241
82457
  defaultColDef,
82242
82458
  enableGroupEdit: internalTableContext.enableGroupEditAndValidation,
82243
82459
  enableCellTextSelection: internalTableContext.enableCellTextSelection,