@procore/data-table 14.20.0 → 14.21.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 14.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 627bb577d1: Expose onCellFocused event on data-table
8
+
9
+ ### Patch Changes
10
+
11
+ - 72a02060f5: Fixed some issues with sublocations on LocationFilterRenderer. Added documentation.
12
+ - 60f16d8d57: Fix 'include sublocations' checkbox and sublocations initial selection
13
+
3
14
  ## 14.20.0
4
15
 
5
16
  ### Minor Changes
@@ -54096,19 +54096,34 @@ var ServerSideLocationFilterRenderer = React77__default.default.forwardRef(
54096
54096
  determineSelectedState(value)
54097
54097
  );
54098
54098
  const [disabledValues, setDisabledValues] = React77__default.default.useState([]);
54099
+ const enableSublocationsInitialValue = value.some(
54100
+ (selected) => {
54101
+ var _a2;
54102
+ return (_a2 = selected.sublocations) == null ? void 0 : _a2.length;
54103
+ }
54104
+ );
54105
+ const getUniqDisabledValues = () => {
54106
+ const newDisabledValues = [];
54107
+ value.forEach((location) => {
54108
+ newDisabledValues.push(...findSublocations(location));
54109
+ });
54110
+ const uniqDisabledValues = ramda.uniqBy(ramda.prop("id"), newDisabledValues).filter(
54111
+ ({ id }) => !selectedValueIds.includes(id)
54112
+ );
54113
+ return uniqDisabledValues;
54114
+ };
54115
+ React77.useEffect(() => {
54116
+ if (enableSublocationsInitialValue && options.length) {
54117
+ setDisabledValues(getUniqDisabledValues());
54118
+ setEnableSublocations(true);
54119
+ }
54120
+ }, [options]);
54099
54121
  const [enableSublocations, setEnableSublocations] = React77__default.default.useState(false);
54100
54122
  const onSelectSublocations = React77__default.default.useCallback(() => {
54101
54123
  if (enableSublocations) {
54102
54124
  setDisabledValues([]);
54103
54125
  } else {
54104
- const newDisabledValues = [];
54105
- value.forEach((location) => {
54106
- newDisabledValues.push(...findSublocations(location));
54107
- });
54108
- const uniqDisabledValues = ramda.uniqBy(ramda.prop("id"), newDisabledValues).filter(
54109
- ({ id }) => !selectedValueIds.includes(id)
54110
- );
54111
- setDisabledValues(uniqDisabledValues);
54126
+ setDisabledValues(getUniqDisabledValues());
54112
54127
  }
54113
54128
  setEnableSublocations(!enableSublocations);
54114
54129
  }, [enableSublocations, value, selectedValueIds, options]);
@@ -54164,18 +54179,18 @@ var ServerSideLocationFilterRenderer = React77__default.default.forwardRef(
54164
54179
  const findSublocations = (selected) => {
54165
54180
  return options.filter((option) => {
54166
54181
  return ramda.startsWith(
54167
- `${getLabel3(selected).toLowerCase()} > `,
54168
- getLabel3(option).toLowerCase()
54169
- );
54182
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
54183
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
54184
+ ) && option.id !== selected.id;
54170
54185
  });
54171
54186
  };
54172
54187
  const handleSelectSublocations = (selected) => {
54173
54188
  if (enableSublocations) {
54174
54189
  const filteredOptions = options.filter((option) => {
54175
54190
  return ramda.startsWith(
54176
- `${getLabel3(selected).toLowerCase()} > `,
54177
- getLabel3(option).toLowerCase()
54178
- );
54191
+ getLabel3(selected).toLowerCase().replace(/ /g, ""),
54192
+ getLabel3(option).toLowerCase().replace(/ /g, "")
54193
+ ) && option.id !== selected.id;
54179
54194
  });
54180
54195
  return filteredOptions;
54181
54196
  } else {
@@ -54231,6 +54246,8 @@ var ServerSideLocationFilterRenderer = React77__default.default.forwardRef(
54231
54246
  {
54232
54247
  block: true,
54233
54248
  onClear: () => {
54249
+ setEnableSublocations(false);
54250
+ setDisabledValues([]);
54234
54251
  onChange([]);
54235
54252
  },
54236
54253
  label: `${I18n.t("dataTable.filters.locationFilter.locations")} ${value.length ? `(${value.length})` : ""}`
@@ -83083,6 +83100,7 @@ var Table = (props) => {
83083
83100
  onGridReady,
83084
83101
  onColumnEverythingChanged: props.onColumnEverythingChanged,
83085
83102
  onModelUpdated,
83103
+ onCellFocused: props.onCellFocused,
83086
83104
  onRowDragEnd,
83087
83105
  onRowDragMove,
83088
83106
  onRowGroupOpened: internalRowGroupOpened,
@@ -84098,9 +84116,9 @@ var LocationQuickFilterRenderer = ({
84098
84116
  const findSublocations = (selected) => {
84099
84117
  return options.filter((option) => {
84100
84118
  return ramda.startsWith(
84101
- `${getLabel3(selected).toLowerCase()} > `,
84102
- getLabel3(option).toLowerCase()
84103
- );
84119
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
84120
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
84121
+ ) && option.id !== selected.id;
84104
84122
  });
84105
84123
  };
84106
84124
  const handleSelectSublocations = (selected) => {
@@ -84163,6 +84181,8 @@ var LocationQuickFilterRenderer = ({
84163
84181
  "dataTable.filters.locationFilter.locations"
84164
84182
  )}${triggerLabel}`,
84165
84183
  onClear: () => {
84184
+ setEnableSublocations(false);
84185
+ setDisabledValues([]);
84166
84186
  onChange([]);
84167
84187
  },
84168
84188
  block: true
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, CellFocusedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -985,6 +985,7 @@ interface TableProps<TRow = any, TBottomRow = any> {
985
985
  onSelectAll?: (param: SelectAllState.All | SelectAllState.None) => void;
986
986
  onTableReady?: (tableApi: TableApi, tableApiRef: React.RefObject<TableApi>) => void;
987
987
  onColumnEverythingChanged?: (changeEvent: ColumnEverythingChangedEvent) => void;
988
+ onCellFocused?: (event: CellFocusedEvent) => void;
988
989
  onFirstDataRendered?: (event: FirstDataRenderedEvent) => void;
989
990
  paginateChildRows?: boolean;
990
991
  pagination?: boolean;
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, CellFocusedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -985,6 +985,7 @@ interface TableProps<TRow = any, TBottomRow = any> {
985
985
  onSelectAll?: (param: SelectAllState.All | SelectAllState.None) => void;
986
986
  onTableReady?: (tableApi: TableApi, tableApiRef: React.RefObject<TableApi>) => void;
987
987
  onColumnEverythingChanged?: (changeEvent: ColumnEverythingChangedEvent) => void;
988
+ onCellFocused?: (event: CellFocusedEvent) => void;
988
989
  onFirstDataRendered?: (event: FirstDataRenderedEvent) => void;
989
990
  paginateChildRows?: boolean;
990
991
  pagination?: boolean;
@@ -1,4 +1,4 @@
1
- import React77, { useState, forwardRef, useContext, useRef, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, useEffect, Component as Component$1, createElement } from 'react';
1
+ import React77, { useEffect, useState, forwardRef, useContext, useRef, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, Component as Component$1, createElement } from 'react';
2
2
  import { uniqBy, prop, startsWith, mergeDeepRight, equals, omit, intersection, isNil, mergeDeepLeft, isEmpty, groupBy } from 'ramda';
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, SelectButton, StyledSelectButton, typographyWeights, StyledSelectButtonLabel, StyledButton, StyledSelectArrow, Popover, UNSAFE_StyledSuperSelectTrigger, UNSAFE_StyledSuperSelectLabel, UNSAFE_StyledSuperSelectArrow, UNSAFE_StyledFilterTokenLabel, DateTimeProvider, useField, Label, UNSAFE_mergeRefs, ContactItem as ContactItem$1, ToggleButton, Link, AvatarStack, Pill, Typeahead, Pagination, UNSAFE_SuperSelect, UNSAFE_FilterToken, Avatar, H3, useI18n, I18nContext, UNSAFE_useSuperSelectContext, Checkbox, DropdownFlyout, useVisibility, StyledDropdownFlyoutLabel, StyledDropdownFlyoutExpandIcon, EmptyState as EmptyState$1 } from '@procore/core-react';
4
4
  import classnames from 'classnames/bind';
@@ -54082,19 +54082,34 @@ var ServerSideLocationFilterRenderer = React77.forwardRef(
54082
54082
  determineSelectedState(value)
54083
54083
  );
54084
54084
  const [disabledValues, setDisabledValues] = React77.useState([]);
54085
+ const enableSublocationsInitialValue = value.some(
54086
+ (selected) => {
54087
+ var _a2;
54088
+ return (_a2 = selected.sublocations) == null ? void 0 : _a2.length;
54089
+ }
54090
+ );
54091
+ const getUniqDisabledValues = () => {
54092
+ const newDisabledValues = [];
54093
+ value.forEach((location) => {
54094
+ newDisabledValues.push(...findSublocations(location));
54095
+ });
54096
+ const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
54097
+ ({ id }) => !selectedValueIds.includes(id)
54098
+ );
54099
+ return uniqDisabledValues;
54100
+ };
54101
+ useEffect(() => {
54102
+ if (enableSublocationsInitialValue && options.length) {
54103
+ setDisabledValues(getUniqDisabledValues());
54104
+ setEnableSublocations(true);
54105
+ }
54106
+ }, [options]);
54085
54107
  const [enableSublocations, setEnableSublocations] = React77.useState(false);
54086
54108
  const onSelectSublocations = React77.useCallback(() => {
54087
54109
  if (enableSublocations) {
54088
54110
  setDisabledValues([]);
54089
54111
  } else {
54090
- const newDisabledValues = [];
54091
- value.forEach((location) => {
54092
- newDisabledValues.push(...findSublocations(location));
54093
- });
54094
- const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
54095
- ({ id }) => !selectedValueIds.includes(id)
54096
- );
54097
- setDisabledValues(uniqDisabledValues);
54112
+ setDisabledValues(getUniqDisabledValues());
54098
54113
  }
54099
54114
  setEnableSublocations(!enableSublocations);
54100
54115
  }, [enableSublocations, value, selectedValueIds, options]);
@@ -54150,18 +54165,18 @@ var ServerSideLocationFilterRenderer = React77.forwardRef(
54150
54165
  const findSublocations = (selected) => {
54151
54166
  return options.filter((option) => {
54152
54167
  return startsWith(
54153
- `${getLabel3(selected).toLowerCase()} > `,
54154
- getLabel3(option).toLowerCase()
54155
- );
54168
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
54169
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
54170
+ ) && option.id !== selected.id;
54156
54171
  });
54157
54172
  };
54158
54173
  const handleSelectSublocations = (selected) => {
54159
54174
  if (enableSublocations) {
54160
54175
  const filteredOptions = options.filter((option) => {
54161
54176
  return startsWith(
54162
- `${getLabel3(selected).toLowerCase()} > `,
54163
- getLabel3(option).toLowerCase()
54164
- );
54177
+ getLabel3(selected).toLowerCase().replace(/ /g, ""),
54178
+ getLabel3(option).toLowerCase().replace(/ /g, "")
54179
+ ) && option.id !== selected.id;
54165
54180
  });
54166
54181
  return filteredOptions;
54167
54182
  } else {
@@ -54217,6 +54232,8 @@ var ServerSideLocationFilterRenderer = React77.forwardRef(
54217
54232
  {
54218
54233
  block: true,
54219
54234
  onClear: () => {
54235
+ setEnableSublocations(false);
54236
+ setDisabledValues([]);
54220
54237
  onChange([]);
54221
54238
  },
54222
54239
  label: `${I18n.t("dataTable.filters.locationFilter.locations")} ${value.length ? `(${value.length})` : ""}`
@@ -83069,6 +83086,7 @@ var Table = (props) => {
83069
83086
  onGridReady,
83070
83087
  onColumnEverythingChanged: props.onColumnEverythingChanged,
83071
83088
  onModelUpdated,
83089
+ onCellFocused: props.onCellFocused,
83072
83090
  onRowDragEnd,
83073
83091
  onRowDragMove,
83074
83092
  onRowGroupOpened: internalRowGroupOpened,
@@ -84084,9 +84102,9 @@ var LocationQuickFilterRenderer = ({
84084
84102
  const findSublocations = (selected) => {
84085
84103
  return options.filter((option) => {
84086
84104
  return startsWith(
84087
- `${getLabel3(selected).toLowerCase()} > `,
84088
- getLabel3(option).toLowerCase()
84089
- );
84105
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
84106
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
84107
+ ) && option.id !== selected.id;
84090
84108
  });
84091
84109
  };
84092
84110
  const handleSelectSublocations = (selected) => {
@@ -84149,6 +84167,8 @@ var LocationQuickFilterRenderer = ({
84149
84167
  "dataTable.filters.locationFilter.locations"
84150
84168
  )}${triggerLabel}`,
84151
84169
  onClear: () => {
84170
+ setEnableSublocations(false);
84171
+ setDisabledValues([]);
84152
84172
  onChange([]);
84153
84173
  },
84154
84174
  block: true
@@ -54052,19 +54052,31 @@ var ServerSideLocationFilterRenderer = React77__default.default.forwardRef(
54052
54052
  determineSelectedState(value)
54053
54053
  );
54054
54054
  const [disabledValues, setDisabledValues] = React77__default.default.useState([]);
54055
+ const enableSublocationsInitialValue = value.some(
54056
+ (selected) => selected.sublocations?.length
54057
+ );
54058
+ const getUniqDisabledValues = () => {
54059
+ const newDisabledValues = [];
54060
+ value.forEach((location) => {
54061
+ newDisabledValues.push(...findSublocations(location));
54062
+ });
54063
+ const uniqDisabledValues = ramda.uniqBy(ramda.prop("id"), newDisabledValues).filter(
54064
+ ({ id }) => !selectedValueIds.includes(id)
54065
+ );
54066
+ return uniqDisabledValues;
54067
+ };
54068
+ React77.useEffect(() => {
54069
+ if (enableSublocationsInitialValue && options.length) {
54070
+ setDisabledValues(getUniqDisabledValues());
54071
+ setEnableSublocations(true);
54072
+ }
54073
+ }, [options]);
54055
54074
  const [enableSublocations, setEnableSublocations] = React77__default.default.useState(false);
54056
54075
  const onSelectSublocations = React77__default.default.useCallback(() => {
54057
54076
  if (enableSublocations) {
54058
54077
  setDisabledValues([]);
54059
54078
  } else {
54060
- const newDisabledValues = [];
54061
- value.forEach((location) => {
54062
- newDisabledValues.push(...findSublocations(location));
54063
- });
54064
- const uniqDisabledValues = ramda.uniqBy(ramda.prop("id"), newDisabledValues).filter(
54065
- ({ id }) => !selectedValueIds.includes(id)
54066
- );
54067
- setDisabledValues(uniqDisabledValues);
54079
+ setDisabledValues(getUniqDisabledValues());
54068
54080
  }
54069
54081
  setEnableSublocations(!enableSublocations);
54070
54082
  }, [enableSublocations, value, selectedValueIds, options]);
@@ -54120,18 +54132,18 @@ var ServerSideLocationFilterRenderer = React77__default.default.forwardRef(
54120
54132
  const findSublocations = (selected) => {
54121
54133
  return options.filter((option) => {
54122
54134
  return ramda.startsWith(
54123
- `${getLabel3(selected).toLowerCase()} > `,
54124
- getLabel3(option).toLowerCase()
54125
- );
54135
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
54136
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
54137
+ ) && option.id !== selected.id;
54126
54138
  });
54127
54139
  };
54128
54140
  const handleSelectSublocations = (selected) => {
54129
54141
  if (enableSublocations) {
54130
54142
  const filteredOptions = options.filter((option) => {
54131
54143
  return ramda.startsWith(
54132
- `${getLabel3(selected).toLowerCase()} > `,
54133
- getLabel3(option).toLowerCase()
54134
- );
54144
+ getLabel3(selected).toLowerCase().replace(/ /g, ""),
54145
+ getLabel3(option).toLowerCase().replace(/ /g, "")
54146
+ ) && option.id !== selected.id;
54135
54147
  });
54136
54148
  return filteredOptions;
54137
54149
  } else {
@@ -54187,6 +54199,8 @@ var ServerSideLocationFilterRenderer = React77__default.default.forwardRef(
54187
54199
  {
54188
54200
  block: true,
54189
54201
  onClear: () => {
54202
+ setEnableSublocations(false);
54203
+ setDisabledValues([]);
54190
54204
  onChange([]);
54191
54205
  },
54192
54206
  label: `${I18n.t("dataTable.filters.locationFilter.locations")} ${value.length ? `(${value.length})` : ""}`
@@ -82874,6 +82888,7 @@ var Table = (props) => {
82874
82888
  onGridReady,
82875
82889
  onColumnEverythingChanged: props.onColumnEverythingChanged,
82876
82890
  onModelUpdated,
82891
+ onCellFocused: props.onCellFocused,
82877
82892
  onRowDragEnd,
82878
82893
  onRowDragMove,
82879
82894
  onRowGroupOpened: internalRowGroupOpened,
@@ -83879,9 +83894,9 @@ var LocationQuickFilterRenderer = ({
83879
83894
  const findSublocations = (selected) => {
83880
83895
  return options.filter((option) => {
83881
83896
  return ramda.startsWith(
83882
- `${getLabel3(selected).toLowerCase()} > `,
83883
- getLabel3(option).toLowerCase()
83884
- );
83897
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
83898
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
83899
+ ) && option.id !== selected.id;
83885
83900
  });
83886
83901
  };
83887
83902
  const handleSelectSublocations = (selected) => {
@@ -83944,6 +83959,8 @@ var LocationQuickFilterRenderer = ({
83944
83959
  "dataTable.filters.locationFilter.locations"
83945
83960
  )}${triggerLabel}`,
83946
83961
  onClear: () => {
83962
+ setEnableSublocations(false);
83963
+ setDisabledValues([]);
83947
83964
  onChange([]);
83948
83965
  },
83949
83966
  block: true
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, CellFocusedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -985,6 +985,7 @@ interface TableProps<TRow = any, TBottomRow = any> {
985
985
  onSelectAll?: (param: SelectAllState.All | SelectAllState.None) => void;
986
986
  onTableReady?: (tableApi: TableApi, tableApiRef: React.RefObject<TableApi>) => void;
987
987
  onColumnEverythingChanged?: (changeEvent: ColumnEverythingChangedEvent) => void;
988
+ onCellFocused?: (event: CellFocusedEvent) => void;
988
989
  onFirstDataRendered?: (event: FirstDataRenderedEvent) => void;
989
990
  paginateChildRows?: boolean;
990
991
  pagination?: boolean;
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, CellFocusedEvent, TabToNextCellParams, CellPosition, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -985,6 +985,7 @@ interface TableProps<TRow = any, TBottomRow = any> {
985
985
  onSelectAll?: (param: SelectAllState.All | SelectAllState.None) => void;
986
986
  onTableReady?: (tableApi: TableApi, tableApiRef: React.RefObject<TableApi>) => void;
987
987
  onColumnEverythingChanged?: (changeEvent: ColumnEverythingChangedEvent) => void;
988
+ onCellFocused?: (event: CellFocusedEvent) => void;
988
989
  onFirstDataRendered?: (event: FirstDataRenderedEvent) => void;
989
990
  paginateChildRows?: boolean;
990
991
  pagination?: boolean;
@@ -1,4 +1,4 @@
1
- import React77, { useState, forwardRef, useContext, useRef, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, useEffect, Component as Component$1, createElement } from 'react';
1
+ import React77, { useEffect, useState, forwardRef, useContext, useRef, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, Component as Component$1, createElement } from 'react';
2
2
  import { uniqBy, prop, startsWith, mergeDeepRight, equals, omit, intersection, isNil, mergeDeepLeft, isEmpty, groupBy } from 'ramda';
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, SelectButton, StyledSelectButton, typographyWeights, StyledSelectButtonLabel, StyledButton, StyledSelectArrow, Popover, UNSAFE_StyledSuperSelectTrigger, UNSAFE_StyledSuperSelectLabel, UNSAFE_StyledSuperSelectArrow, UNSAFE_StyledFilterTokenLabel, DateTimeProvider, useField, Label, UNSAFE_mergeRefs, ContactItem as ContactItem$1, ToggleButton, Link, AvatarStack, Pill, Typeahead, Pagination, UNSAFE_SuperSelect, UNSAFE_FilterToken, Avatar, H3, useI18n, I18nContext, UNSAFE_useSuperSelectContext, Checkbox, DropdownFlyout, useVisibility, StyledDropdownFlyoutLabel, StyledDropdownFlyoutExpandIcon, EmptyState as EmptyState$1 } from '@procore/core-react';
4
4
  import classnames from 'classnames/bind';
@@ -54038,19 +54038,31 @@ var ServerSideLocationFilterRenderer = React77.forwardRef(
54038
54038
  determineSelectedState(value)
54039
54039
  );
54040
54040
  const [disabledValues, setDisabledValues] = React77.useState([]);
54041
+ const enableSublocationsInitialValue = value.some(
54042
+ (selected) => selected.sublocations?.length
54043
+ );
54044
+ const getUniqDisabledValues = () => {
54045
+ const newDisabledValues = [];
54046
+ value.forEach((location) => {
54047
+ newDisabledValues.push(...findSublocations(location));
54048
+ });
54049
+ const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
54050
+ ({ id }) => !selectedValueIds.includes(id)
54051
+ );
54052
+ return uniqDisabledValues;
54053
+ };
54054
+ useEffect(() => {
54055
+ if (enableSublocationsInitialValue && options.length) {
54056
+ setDisabledValues(getUniqDisabledValues());
54057
+ setEnableSublocations(true);
54058
+ }
54059
+ }, [options]);
54041
54060
  const [enableSublocations, setEnableSublocations] = React77.useState(false);
54042
54061
  const onSelectSublocations = React77.useCallback(() => {
54043
54062
  if (enableSublocations) {
54044
54063
  setDisabledValues([]);
54045
54064
  } else {
54046
- const newDisabledValues = [];
54047
- value.forEach((location) => {
54048
- newDisabledValues.push(...findSublocations(location));
54049
- });
54050
- const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
54051
- ({ id }) => !selectedValueIds.includes(id)
54052
- );
54053
- setDisabledValues(uniqDisabledValues);
54065
+ setDisabledValues(getUniqDisabledValues());
54054
54066
  }
54055
54067
  setEnableSublocations(!enableSublocations);
54056
54068
  }, [enableSublocations, value, selectedValueIds, options]);
@@ -54106,18 +54118,18 @@ var ServerSideLocationFilterRenderer = React77.forwardRef(
54106
54118
  const findSublocations = (selected) => {
54107
54119
  return options.filter((option) => {
54108
54120
  return startsWith(
54109
- `${getLabel3(selected).toLowerCase()} > `,
54110
- getLabel3(option).toLowerCase()
54111
- );
54121
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
54122
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
54123
+ ) && option.id !== selected.id;
54112
54124
  });
54113
54125
  };
54114
54126
  const handleSelectSublocations = (selected) => {
54115
54127
  if (enableSublocations) {
54116
54128
  const filteredOptions = options.filter((option) => {
54117
54129
  return startsWith(
54118
- `${getLabel3(selected).toLowerCase()} > `,
54119
- getLabel3(option).toLowerCase()
54120
- );
54130
+ getLabel3(selected).toLowerCase().replace(/ /g, ""),
54131
+ getLabel3(option).toLowerCase().replace(/ /g, "")
54132
+ ) && option.id !== selected.id;
54121
54133
  });
54122
54134
  return filteredOptions;
54123
54135
  } else {
@@ -54173,6 +54185,8 @@ var ServerSideLocationFilterRenderer = React77.forwardRef(
54173
54185
  {
54174
54186
  block: true,
54175
54187
  onClear: () => {
54188
+ setEnableSublocations(false);
54189
+ setDisabledValues([]);
54176
54190
  onChange([]);
54177
54191
  },
54178
54192
  label: `${I18n.t("dataTable.filters.locationFilter.locations")} ${value.length ? `(${value.length})` : ""}`
@@ -82860,6 +82874,7 @@ var Table = (props) => {
82860
82874
  onGridReady,
82861
82875
  onColumnEverythingChanged: props.onColumnEverythingChanged,
82862
82876
  onModelUpdated,
82877
+ onCellFocused: props.onCellFocused,
82863
82878
  onRowDragEnd,
82864
82879
  onRowDragMove,
82865
82880
  onRowGroupOpened: internalRowGroupOpened,
@@ -83865,9 +83880,9 @@ var LocationQuickFilterRenderer = ({
83865
83880
  const findSublocations = (selected) => {
83866
83881
  return options.filter((option) => {
83867
83882
  return startsWith(
83868
- `${getLabel3(selected).toLowerCase()} > `,
83869
- getLabel3(option).toLowerCase()
83870
- );
83883
+ getLabel3(selected).toLowerCase().replace(/\s+>\s+/g, " > "),
83884
+ getLabel3(option).toLowerCase().replace(/\s+>\s+/g, " > ")
83885
+ ) && option.id !== selected.id;
83871
83886
  });
83872
83887
  };
83873
83888
  const handleSelectSublocations = (selected) => {
@@ -83930,6 +83945,8 @@ var LocationQuickFilterRenderer = ({
83930
83945
  "dataTable.filters.locationFilter.locations"
83931
83946
  )}${triggerLabel}`,
83932
83947
  onClear: () => {
83948
+ setEnableSublocations(false);
83949
+ setDisabledValues([]);
83933
83950
  onChange([]);
83934
83951
  },
83935
83952
  block: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/data-table",
3
- "version": "14.20.0",
3
+ "version": "14.21.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",