@procore/data-table 14.12.2 → 14.13.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.
@@ -1,5 +1,5 @@
1
1
  import React76, { useState, forwardRef, useContext, useRef, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, useEffect, Component as Component$1, createElement } from 'react';
2
- import { startsWith, mergeDeepRight, equals, omit, intersection, isNil, mergeDeepLeft, isEmpty, groupBy } from 'ramda';
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, 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';
@@ -12790,8 +12790,8 @@ var GridOptionsValidator = class GridOptionsValidator2 {
12790
12790
  enterMovesDownAfterEdit: { version: "30", newProp: "enterNavigatesVerticallyAfterEdit", copyToNewProp: true }
12791
12791
  };
12792
12792
  }
12793
- pickOneWarning(prop1, prop2) {
12794
- console.warn(`AG Grid: ${prop1} and ${prop2} do not work with each other, you need to pick one.`);
12793
+ pickOneWarning(prop1, prop22) {
12794
+ console.warn(`AG Grid: ${prop1} and ${prop22} do not work with each other, you need to pick one.`);
12795
12795
  }
12796
12796
  init() {
12797
12797
  this.checkForDeprecated();
@@ -12813,7 +12813,7 @@ var GridOptionsValidator = class GridOptionsValidator2 {
12813
12813
  this.pickOneWarning("groupRemoveSingleChildren", "groupHideOpenParents");
12814
12814
  }
12815
12815
  if (this.gridOptionsService.isRowModelType("serverSide")) {
12816
- const msg = (prop, alt) => `AG Grid: '${prop}' is not supported on the Server-Side Row Model.` + (alt ? ` Please use ${alt} instead.` : "");
12816
+ const msg = (prop3, alt) => `AG Grid: '${prop3}' is not supported on the Server-Side Row Model.` + (alt ? ` Please use ${alt} instead.` : "");
12817
12817
  if (this.gridOptionsService.exists("groupDefaultExpanded")) {
12818
12818
  console.warn(msg("groupDefaultExpanded", "isServerSideGroupOpenByDefault callback"));
12819
12819
  }
@@ -12829,7 +12829,7 @@ var GridOptionsValidator = class GridOptionsValidator2 {
12829
12829
  } else if (this.gridOptionsService.is("enableRangeHandle") || this.gridOptionsService.is("enableFillHandle")) {
12830
12830
  console.warn("AG Grid: 'enableRangeHandle' or 'enableFillHandle' will not work unless 'enableRangeSelection' is set to true");
12831
12831
  }
12832
- const validateRegistered = (prop, module) => this.gridOptionsService.exists(prop) && ModuleRegistry.__assertRegistered(module, prop, this.gridOptionsService.getGridId());
12832
+ const validateRegistered = (prop3, module) => this.gridOptionsService.exists(prop3) && ModuleRegistry.__assertRegistered(module, prop3, this.gridOptionsService.getGridId());
12833
12833
  validateRegistered("sideBar", ModuleNames.SideBarModule);
12834
12834
  validateRegistered("statusBar", ModuleNames.StatusBarModule);
12835
12835
  validateRegistered("enableCharts", ModuleNames.GridChartsModule);
@@ -52153,15 +52153,15 @@ var DataTypeService = class DataTypeService2 extends BeanStub {
52153
52153
  ["valueGetter", void 0],
52154
52154
  ["valueParser", void 0],
52155
52155
  ["refData", void 0]
52156
- ].some(([prop, comparisonValue]) => this.doesColDefPropPreventInference(colDef, propsToCheckForInference, prop, comparisonValue));
52156
+ ].some(([prop3, comparisonValue]) => this.doesColDefPropPreventInference(colDef, propsToCheckForInference, prop3, comparisonValue));
52157
52157
  }
52158
- doesColDefPropPreventInference(colDef, checkProps, prop, comparisonValue) {
52159
- if (!checkProps[prop]) {
52158
+ doesColDefPropPreventInference(colDef, checkProps, prop3, comparisonValue) {
52159
+ if (!checkProps[prop3]) {
52160
52160
  return false;
52161
52161
  }
52162
- const value = colDef[prop];
52162
+ const value = colDef[prop3];
52163
52163
  if (value === null) {
52164
- checkProps[prop] = false;
52164
+ checkProps[prop3] = false;
52165
52165
  return false;
52166
52166
  } else {
52167
52167
  return comparisonValue === void 0 ? !!value : value === comparisonValue;
@@ -53821,6 +53821,7 @@ var LocationFilterOverlay = React76.forwardRef(
53821
53821
  enableSublocations,
53822
53822
  selectState,
53823
53823
  options,
53824
+ disabledOptions,
53824
53825
  columnDefinition,
53825
53826
  value
53826
53827
  }, ref) => {
@@ -53842,6 +53843,7 @@ var LocationFilterOverlay = React76.forwardRef(
53842
53843
  return onSelectAll();
53843
53844
  }
53844
53845
  if (selection.item.id === includeSublocationOption.id) {
53846
+ _onSelect(selection);
53845
53847
  return onSelectSublocations();
53846
53848
  }
53847
53849
  return _onSelect(selection);
@@ -53911,8 +53913,9 @@ var LocationFilterOverlay = React76.forwardRef(
53911
53913
  {
53912
53914
  key: getId3(item),
53913
53915
  item,
53914
- selected: value.map(({ id }) => id).includes(getId3(item)),
53915
- suggested: i === 0
53916
+ selected: value.map(({ id }) => id).includes(getId3(item)) || disabledOptions.map(({ id }) => id).includes(getId3(item)),
53917
+ suggested: i === 0,
53918
+ disabled: disabledOptions.map(({ id }) => id).includes(getId3(item))
53916
53919
  },
53917
53920
  getLabel3(item)
53918
53921
  );
@@ -53942,10 +53945,23 @@ var ServerSideLocationFilterRenderer = React76.forwardRef(
53942
53945
  const [selectState, setSelectState] = React76.useState(
53943
53946
  determineSelectedState(value)
53944
53947
  );
53948
+ const [disabledValues, setDisabledValues] = React76.useState([]);
53945
53949
  const [enableSublocations, setEnableSublocations] = React76.useState(false);
53946
53950
  const onSelectSublocations = React76.useCallback(() => {
53951
+ if (enableSublocations) {
53952
+ setDisabledValues([]);
53953
+ } else {
53954
+ const newDisabledValues = [];
53955
+ value.forEach((location) => {
53956
+ newDisabledValues.push(...findSublocations(location));
53957
+ });
53958
+ const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
53959
+ ({ id }) => !selectedValueIds.includes(id)
53960
+ );
53961
+ setDisabledValues(uniqDisabledValues);
53962
+ }
53947
53963
  setEnableSublocations(!enableSublocations);
53948
- }, [enableSublocations]);
53964
+ }, [enableSublocations, value, selectedValueIds, options]);
53949
53965
  const I18n = useI18nContext();
53950
53966
  const selectRef = React76.useRef(null);
53951
53967
  const onSelectAll = React76.useCallback(() => {
@@ -53961,17 +53977,47 @@ var ServerSideLocationFilterRenderer = React76.forwardRef(
53961
53977
  }
53962
53978
  }, [options, selectState, selectedValueIds]);
53963
53979
  const onSelect = (selection) => {
53964
- if (selection.item.id === "select_all" || selection.item.id === "include_sublocations") {
53980
+ if (selection.item.id === "select_all") {
53965
53981
  return;
53966
53982
  }
53967
- let newSelections = selectedValueIds.includes(getId3(selection.item)) ? removeSelections(selection.item, value) : [
53968
- ...value,
53969
- ...handleSelectSublocations(selection.item),
53970
- selection.item
53971
- ];
53983
+ if (selection.item.id === "include_sublocations") {
53984
+ return onChange(
53985
+ value.map((item) => ({
53986
+ ...item,
53987
+ sublocations: enableSublocations ? [] : findSublocations(item)
53988
+ }))
53989
+ );
53990
+ }
53991
+ let newSelections = [];
53992
+ if (selectedValueIds.includes(getId3(selection.item))) {
53993
+ newSelections = removeSelections(selection.item, value);
53994
+ } else {
53995
+ newSelections = [...value, selection.item];
53996
+ const sublocationsToDisable = handleSelectSublocations(selection.item);
53997
+ const newDisabledValues = [
53998
+ ...disabledValues,
53999
+ ...sublocationsToDisable.filter(
54000
+ ({ id }) => !selectedValueIds.includes(id)
54001
+ )
54002
+ ];
54003
+ setDisabledValues(newDisabledValues);
54004
+ }
53972
54005
  setSelectState(determineSelectedState(newSelections));
53973
54006
  setSelectedValueIds(newSelections.map(({ id }) => id));
53974
- onChange(newSelections);
54007
+ onChange(
54008
+ newSelections.map((item) => ({
54009
+ ...item,
54010
+ sublocations: handleSelectSublocations(item)
54011
+ }))
54012
+ );
54013
+ };
54014
+ const findSublocations = (selected) => {
54015
+ return options.filter((option) => {
54016
+ return startsWith(
54017
+ `${getLabel3(selected).toLowerCase()} > `,
54018
+ getLabel3(option).toLowerCase()
54019
+ );
54020
+ });
53975
54021
  };
53976
54022
  const handleSelectSublocations = (selected) => {
53977
54023
  if (enableSublocations) {
@@ -53989,14 +54035,16 @@ var ServerSideLocationFilterRenderer = React76.forwardRef(
53989
54035
  const removeSelections = React76.useCallback(
53990
54036
  function(selection, selected) {
53991
54037
  const sublocations = handleSelectSublocations(selection);
53992
- return enableSublocations ? selected.filter(
53993
- (item) => ![
53994
- ...sublocations.map(({ id }) => id),
53995
- getId3(selection)
53996
- ].includes(item.id)
53997
- ) : selected.filter((item) => getId3(item) !== getId3(selection));
54038
+ const disabledValueIds = disabledValues.map(({ id }) => id);
54039
+ const sublocationsToRemoveFromDisabledIds = sublocations.filter(({ id }) => disabledValueIds.includes(id)).map(({ id }) => id);
54040
+ setDisabledValues(
54041
+ disabledValues.filter(
54042
+ ({ id }) => !sublocationsToRemoveFromDisabledIds.includes(id)
54043
+ )
54044
+ );
54045
+ return selected.filter((item) => getId3(item) !== getId3(selection));
53998
54046
  },
53999
- [enableSublocations]
54047
+ [enableSublocations, disabledValues]
54000
54048
  );
54001
54049
  React76.useEffect(() => {
54002
54050
  setSelectState(determineSelectedState(value));
@@ -54007,6 +54055,7 @@ var ServerSideLocationFilterRenderer = React76.forwardRef(
54007
54055
  columnDefinition,
54008
54056
  value,
54009
54057
  options,
54058
+ disabledOptions: disabledValues,
54010
54059
  enableSublocations,
54011
54060
  getId: getId3,
54012
54061
  getLabel: getLabel3,
@@ -79644,6 +79693,11 @@ var ja_JP_default = {
79644
79693
  }
79645
79694
  };
79646
79695
 
79696
+ // src/locales/pl-PL.json
79697
+ var pl_PL_default = {
79698
+ dataTable: {}
79699
+ };
79700
+
79647
79701
  // src/locales/pseudo.json
79648
79702
  var pseudo_default = {
79649
79703
  dataTable: {
@@ -80260,7 +80314,8 @@ var translations = {
80260
80314
  pseudo: pseudo_default,
80261
80315
  "pt-BR": pt_BR_default,
80262
80316
  "th-TH": th_TH_default,
80263
- "zh-SG": zh_SG_default
80317
+ "zh-SG": zh_SG_default,
80318
+ "pl-PL": pl_PL_default
80264
80319
  };
80265
80320
  var PRINCE_XML_DPI = 96;
80266
80321
  var DEFAULT_PAGE_MARGIN = 40;
@@ -83616,6 +83671,7 @@ var LocationQuickFilterOverlay = React76.forwardRef(
83616
83671
  enableSublocations,
83617
83672
  selectState,
83618
83673
  options,
83674
+ disabledOptions,
83619
83675
  columnDefinition,
83620
83676
  value
83621
83677
  }, ref) => {
@@ -83643,6 +83699,7 @@ var LocationQuickFilterOverlay = React76.forwardRef(
83643
83699
  return onSelectAll();
83644
83700
  }
83645
83701
  if (selection.item.id === includeSublocationOption.id) {
83702
+ _onSelect(selection);
83646
83703
  return onSelectSublocations();
83647
83704
  }
83648
83705
  return _onSelect(selection);
@@ -83712,8 +83769,9 @@ var LocationQuickFilterOverlay = React76.forwardRef(
83712
83769
  {
83713
83770
  key: getId3(item),
83714
83771
  item,
83715
- selected: value.map(({ id }) => id).includes(getId3(item)),
83716
- suggested: i === 0
83772
+ selected: value.map(({ id }) => id).includes(getId3(item)) || disabledOptions.map(({ id }) => id).includes(getId3(item)),
83773
+ suggested: i === 0,
83774
+ disabled: disabledOptions.map(({ id }) => id).includes(getId3(item))
83717
83775
  },
83718
83776
  getLabel3(item)
83719
83777
  );
@@ -83759,10 +83817,23 @@ var LocationQuickFilterRenderer = ({
83759
83817
  const [selectState, setSelectState] = React76.useState(
83760
83818
  determineSelectedState(value)
83761
83819
  );
83820
+ const [disabledValues, setDisabledValues] = React76.useState([]);
83762
83821
  const [enableSublocations, setEnableSublocations] = React76.useState(false);
83763
83822
  const onSelectSublocations = React76.useCallback(() => {
83823
+ if (enableSublocations) {
83824
+ setDisabledValues([]);
83825
+ } else {
83826
+ const newDisabledValues = [];
83827
+ value.forEach((location) => {
83828
+ newDisabledValues.push(...findSublocations(location));
83829
+ });
83830
+ const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
83831
+ ({ id }) => !selectedValueIds.includes(id)
83832
+ );
83833
+ setDisabledValues(uniqDisabledValues);
83834
+ }
83764
83835
  setEnableSublocations(!enableSublocations);
83765
- }, [enableSublocations]);
83836
+ }, [enableSublocations, value, selectedValueIds, options]);
83766
83837
  const onSelectAll = React76.useCallback(() => {
83767
83838
  if (selectState === "none" || selectState === "partial") {
83768
83839
  setSelectState("all");
@@ -83776,22 +83847,51 @@ var LocationQuickFilterRenderer = ({
83776
83847
  }
83777
83848
  }, [options, selectState, selectedValueIds]);
83778
83849
  const onSelect = (selection) => {
83779
- if (selection.item.id === "select_all" || selection.item.id === "include_sublocations") {
83850
+ if (selection.item.id === "select_all") {
83780
83851
  return;
83781
83852
  }
83782
- let newSelections = selectedValueIds.includes(getId3(selection.item)) ? removeSelections(selection.item, value) : [...value, ...handleSelectSublocations(selection.item), selection.item];
83853
+ if (selection.item.id === "include_sublocations") {
83854
+ return onChange(
83855
+ value.map((item) => ({
83856
+ ...item,
83857
+ sublocations: enableSublocations ? [] : findSublocations(item)
83858
+ }))
83859
+ );
83860
+ }
83861
+ let newSelections = [];
83862
+ if (selectedValueIds.includes(getId3(selection.item))) {
83863
+ newSelections = removeSelections(selection.item, value);
83864
+ } else {
83865
+ newSelections = [...value, selection.item];
83866
+ const sublocationsToDisable = handleSelectSublocations(selection.item);
83867
+ const newDisabledValues = [
83868
+ ...disabledValues,
83869
+ ...sublocationsToDisable.filter(
83870
+ ({ id }) => !selectedValueIds.includes(id)
83871
+ )
83872
+ ];
83873
+ setDisabledValues(newDisabledValues);
83874
+ }
83783
83875
  setSelectState(determineSelectedState(newSelections));
83784
83876
  setSelectedValueIds(newSelections.map(({ id }) => id));
83785
- onChange(newSelections);
83877
+ onChange(
83878
+ newSelections.map((item) => ({
83879
+ ...item,
83880
+ sublocations: handleSelectSublocations(item)
83881
+ }))
83882
+ );
83883
+ };
83884
+ const findSublocations = (selected) => {
83885
+ return options.filter((option) => {
83886
+ return startsWith(
83887
+ `${getLabel3(selected).toLowerCase()} > `,
83888
+ getLabel3(option).toLowerCase()
83889
+ );
83890
+ });
83786
83891
  };
83787
83892
  const handleSelectSublocations = (selected) => {
83788
83893
  if (enableSublocations) {
83789
- const filteredOptions = options.filter((option) => {
83790
- return startsWith(
83791
- `${getLabel3(selected).toLowerCase()} > `,
83792
- getLabel3(option).toLowerCase()
83793
- );
83794
- });
83894
+ const filteredOptions = findSublocations(selected);
83795
83895
  return filteredOptions;
83796
83896
  } else {
83797
83897
  return [];
@@ -83800,13 +83900,16 @@ var LocationQuickFilterRenderer = ({
83800
83900
  const removeSelections = React76.useCallback(
83801
83901
  function(selection, selected) {
83802
83902
  const sublocations = handleSelectSublocations(selection);
83803
- return enableSublocations ? selected.filter(
83804
- (item) => ![...sublocations.map(({ id }) => id), getId3(selection)].includes(
83805
- item.id
83903
+ const disabledValueIds = disabledValues.map(({ id }) => id);
83904
+ const sublocationsToRemoveFromDisabledIds = sublocations.filter(({ id }) => disabledValueIds.includes(id)).map(({ id }) => id);
83905
+ setDisabledValues(
83906
+ disabledValues.filter(
83907
+ ({ id }) => !sublocationsToRemoveFromDisabledIds.includes(id)
83806
83908
  )
83807
- ) : selected.filter((item) => getId3(item) !== getId3(selection));
83909
+ );
83910
+ return selected.filter((item) => getId3(item) !== getId3(selection));
83808
83911
  },
83809
- [enableSublocations]
83912
+ [enableSublocations, disabledValues]
83810
83913
  );
83811
83914
  React76.useEffect(() => {
83812
83915
  setSelectState(determineSelectedState(value));
@@ -83821,6 +83924,7 @@ var LocationQuickFilterRenderer = ({
83821
83924
  selectState,
83822
83925
  value,
83823
83926
  options,
83927
+ disabledOptions: disabledValues,
83824
83928
  getId: getId3,
83825
83929
  getLabel: getLabel3,
83826
83930
  loading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/data-table",
3
- "version": "14.12.2",
3
+ "version": "14.13.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.1.0",
113
113
  "@procore/core-prettier": "10.2.0",
114
- "@procore/core-react": "12.9.0",
114
+ "@procore/core-react": "12.10.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",