@procore/data-table 14.12.2 → 14.14.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 +18 -0
- package/dist/legacy/index.cjs +308 -64
- package/dist/legacy/index.d.cts +10 -0
- package/dist/legacy/index.d.ts +10 -0
- package/dist/legacy/index.js +309 -65
- package/dist/modern/index.cjs +295 -53
- package/dist/modern/index.d.cts +10 -0
- package/dist/modern/index.d.ts +10 -0
- package/dist/modern/index.js +296 -54
- package/package.json +3 -3
package/dist/modern/index.js
CHANGED
|
@@ -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,
|
|
12794
|
-
console.warn(`AG Grid: ${prop1} and ${
|
|
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 = (
|
|
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 = (
|
|
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(([
|
|
52156
|
+
].some(([prop3, comparisonValue]) => this.doesColDefPropPreventInference(colDef, propsToCheckForInference, prop3, comparisonValue));
|
|
52157
52157
|
}
|
|
52158
|
-
doesColDefPropPreventInference(colDef, checkProps,
|
|
52159
|
-
if (!checkProps[
|
|
52158
|
+
doesColDefPropPreventInference(colDef, checkProps, prop3, comparisonValue) {
|
|
52159
|
+
if (!checkProps[prop3]) {
|
|
52160
52160
|
return false;
|
|
52161
52161
|
}
|
|
52162
|
-
const value = colDef[
|
|
52162
|
+
const value = colDef[prop3];
|
|
52163
52163
|
if (value === null) {
|
|
52164
|
-
checkProps[
|
|
52164
|
+
checkProps[prop3] = false;
|
|
52165
52165
|
return false;
|
|
52166
52166
|
} else {
|
|
52167
52167
|
return comparisonValue === void 0 ? !!value : value === comparisonValue;
|
|
@@ -53395,7 +53395,7 @@ var Renderer9 = ({
|
|
|
53395
53395
|
if (isGroup || rowPinned && columnDefinition.aggFunc) {
|
|
53396
53396
|
return /* @__PURE__ */ React76.createElement(Typography, { ...typographyProps, weight: "semibold" }, label);
|
|
53397
53397
|
}
|
|
53398
|
-
return /* @__PURE__ */ React76.createElement(Pill, { color: getColor(value), className: cx10("pill-cell") }, label
|
|
53398
|
+
return /* @__PURE__ */ React76.createElement(Pill, { color: getColor(value), className: cx10("pill-cell") }, label);
|
|
53399
53399
|
};
|
|
53400
53400
|
var PillCellRenderer = withDataTableRenderer(Renderer9, "select");
|
|
53401
53401
|
var Editor5 = React76.forwardRef(
|
|
@@ -53428,7 +53428,7 @@ var Editor5 = React76.forwardRef(
|
|
|
53428
53428
|
}
|
|
53429
53429
|
function getLabel3(item) {
|
|
53430
53430
|
const unformattedLabel = columnDefinition.getStringFormattedValue?.(item) || "";
|
|
53431
|
-
return unformattedLabel
|
|
53431
|
+
return unformattedLabel;
|
|
53432
53432
|
}
|
|
53433
53433
|
return /* @__PURE__ */ React76.createElement(
|
|
53434
53434
|
PillSelect,
|
|
@@ -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"
|
|
53980
|
+
if (selection.item.id === "select_all") {
|
|
53965
53981
|
return;
|
|
53966
53982
|
}
|
|
53967
|
-
|
|
53968
|
-
|
|
53969
|
-
|
|
53970
|
-
|
|
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(
|
|
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
|
-
|
|
53993
|
-
|
|
53994
|
-
|
|
53995
|
-
|
|
53996
|
-
|
|
53997
|
-
|
|
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,
|
|
@@ -56472,9 +56521,10 @@ var GenericHeaderRenderer = (props) => {
|
|
|
56472
56521
|
props.api.addEventListener("columnRowGroupChanged", updateExpandedState);
|
|
56473
56522
|
return () => {
|
|
56474
56523
|
props.column.removeEventListener("sortChanged", onSortChanged);
|
|
56475
|
-
|
|
56524
|
+
removeEventListenerFromGrid(
|
|
56476
56525
|
"columnRowGroupChanged",
|
|
56477
|
-
updateExpandedState
|
|
56526
|
+
updateExpandedState,
|
|
56527
|
+
props.api
|
|
56478
56528
|
);
|
|
56479
56529
|
};
|
|
56480
56530
|
}, [props.column]);
|
|
@@ -57540,6 +57590,7 @@ var InternalTableContext = React76.createContext({
|
|
|
57540
57590
|
getRowHeight: () => () => rowSize.md,
|
|
57541
57591
|
grandTotalsLabelInnerRenderer: void 0,
|
|
57542
57592
|
gridApi: void 0,
|
|
57593
|
+
localStoragePersistenceKey: void 0,
|
|
57543
57594
|
onBulkEditUpdate: () => Promise.resolve(),
|
|
57544
57595
|
onServerSideDataRequest: void 0,
|
|
57545
57596
|
onTableConfigChange: () => {
|
|
@@ -57556,6 +57607,7 @@ var InternalTableContext = React76.createContext({
|
|
|
57556
57607
|
setRowHeight: () => {
|
|
57557
57608
|
},
|
|
57558
57609
|
showExpandCollapseAllToggle: false,
|
|
57610
|
+
expandCollapseStateRef: null,
|
|
57559
57611
|
tableRef: null,
|
|
57560
57612
|
getColumnDefinition: () => void 0,
|
|
57561
57613
|
setSelectedGroupIndex: () => {
|
|
@@ -77970,6 +78022,61 @@ var buildDetailRowsConfig_ = (detailRowConfig, {
|
|
|
77970
78022
|
};
|
|
77971
78023
|
};
|
|
77972
78024
|
|
|
78025
|
+
// src/utils/expandRows.ts
|
|
78026
|
+
var getGroupRowState = (gridApi, groupDefaultExpanded = 0) => {
|
|
78027
|
+
const expandedRoutes = [];
|
|
78028
|
+
const collapsedRoutes = [];
|
|
78029
|
+
if (gridApi) {
|
|
78030
|
+
gridApi.forEachNode((node) => {
|
|
78031
|
+
const route = node.getRoute();
|
|
78032
|
+
if (route) {
|
|
78033
|
+
const routePath = route.join(",");
|
|
78034
|
+
const defaultExpandLevel = groupDefaultExpanded === -1 ? Infinity : groupDefaultExpanded;
|
|
78035
|
+
if (node.level > defaultExpandLevel - 1) {
|
|
78036
|
+
if (node.expanded) {
|
|
78037
|
+
expandedRoutes.push(routePath);
|
|
78038
|
+
}
|
|
78039
|
+
} else if (!node.expanded) {
|
|
78040
|
+
collapsedRoutes.push(routePath);
|
|
78041
|
+
}
|
|
78042
|
+
}
|
|
78043
|
+
});
|
|
78044
|
+
}
|
|
78045
|
+
return { expandedRoutes, collapsedRoutes };
|
|
78046
|
+
};
|
|
78047
|
+
var setExpandCollapseRow = (gridApi, tableConfig, groupDefaultExpanded = 0) => {
|
|
78048
|
+
const expandedRoutes = tableConfig.groupRowState?.expandedRoutes ?? [];
|
|
78049
|
+
const collapsedRoutes = tableConfig.groupRowState?.collapsedRoutes ?? [];
|
|
78050
|
+
gridApi.forEachNode((node) => {
|
|
78051
|
+
const route = node.getRoute();
|
|
78052
|
+
if (route) {
|
|
78053
|
+
const routePath = route.join(",");
|
|
78054
|
+
const defaultExpandLevel = groupDefaultExpanded === -1 ? Infinity : groupDefaultExpanded;
|
|
78055
|
+
if (node.level > defaultExpandLevel - 1) {
|
|
78056
|
+
if (expandedRoutes.includes(routePath)) {
|
|
78057
|
+
node.setExpanded(true);
|
|
78058
|
+
}
|
|
78059
|
+
} else if (collapsedRoutes.includes(routePath)) {
|
|
78060
|
+
node.setExpanded(false);
|
|
78061
|
+
}
|
|
78062
|
+
}
|
|
78063
|
+
});
|
|
78064
|
+
};
|
|
78065
|
+
var isRowOpenedByDefault = (node, tableConfig, groupDefaultExpanded = 0) => {
|
|
78066
|
+
const expandedRoutes = tableConfig?.groupRowState?.expandedRoutes ?? [];
|
|
78067
|
+
const collapsedRoutes = tableConfig?.groupRowState?.collapsedRoutes ?? [];
|
|
78068
|
+
const route = node.getRoute();
|
|
78069
|
+
if (!route) {
|
|
78070
|
+
return false;
|
|
78071
|
+
}
|
|
78072
|
+
const routePath = route.join(",");
|
|
78073
|
+
const defaultExpandLevel = groupDefaultExpanded === -1 ? Infinity : groupDefaultExpanded;
|
|
78074
|
+
if (node.level > defaultExpandLevel - 1) {
|
|
78075
|
+
return expandedRoutes.includes(routePath);
|
|
78076
|
+
} else
|
|
78077
|
+
return !collapsedRoutes.includes(routePath);
|
|
78078
|
+
};
|
|
78079
|
+
|
|
77973
78080
|
// src/utils/getRootRowNode.ts
|
|
77974
78081
|
function getRootRowNode(rowNode) {
|
|
77975
78082
|
return rowNode.level > 0 && rowNode.parent ? getRootRowNode(rowNode.parent) : rowNode;
|
|
@@ -79644,6 +79751,11 @@ var ja_JP_default = {
|
|
|
79644
79751
|
}
|
|
79645
79752
|
};
|
|
79646
79753
|
|
|
79754
|
+
// src/locales/pl-PL.json
|
|
79755
|
+
var pl_PL_default = {
|
|
79756
|
+
dataTable: {}
|
|
79757
|
+
};
|
|
79758
|
+
|
|
79647
79759
|
// src/locales/pseudo.json
|
|
79648
79760
|
var pseudo_default = {
|
|
79649
79761
|
dataTable: {
|
|
@@ -80260,7 +80372,8 @@ var translations = {
|
|
|
80260
80372
|
pseudo: pseudo_default,
|
|
80261
80373
|
"pt-BR": pt_BR_default,
|
|
80262
80374
|
"th-TH": th_TH_default,
|
|
80263
|
-
"zh-SG": zh_SG_default
|
|
80375
|
+
"zh-SG": zh_SG_default,
|
|
80376
|
+
"pl-PL": pl_PL_default
|
|
80264
80377
|
};
|
|
80265
80378
|
var PRINCE_XML_DPI = 96;
|
|
80266
80379
|
var DEFAULT_PAGE_MARGIN = 40;
|
|
@@ -80485,6 +80598,7 @@ var useTableApi = ({
|
|
|
80485
80598
|
columnApi,
|
|
80486
80599
|
columnDefinitions,
|
|
80487
80600
|
gridApi,
|
|
80601
|
+
groupDefaultExpanded,
|
|
80488
80602
|
setLoadingStatus,
|
|
80489
80603
|
wrapperRef
|
|
80490
80604
|
}) => {
|
|
@@ -80676,10 +80790,33 @@ var useTableApi = ({
|
|
|
80676
80790
|
const setSearchValue = React76.useCallback(
|
|
80677
80791
|
(value) => {
|
|
80678
80792
|
gridApi?.setQuickFilter(value);
|
|
80793
|
+
gridApi?.forEachNodeAfterFilterAndSort((node) => {
|
|
80794
|
+
if (node.id) {
|
|
80795
|
+
const currentNode = rowSelectionRef?.current.affectedRows[node.id];
|
|
80796
|
+
if (currentNode && currentNode.selectedState === rowSelectionState.selected) {
|
|
80797
|
+
node.setSelected(true, false, "checkboxSelected");
|
|
80798
|
+
}
|
|
80799
|
+
}
|
|
80800
|
+
});
|
|
80679
80801
|
resetPagination();
|
|
80802
|
+
gridApi?.redrawRows();
|
|
80680
80803
|
},
|
|
80681
|
-
[gridApi]
|
|
80804
|
+
[gridApi, rowSelectionRef.current]
|
|
80682
80805
|
);
|
|
80806
|
+
React76.useEffect(() => {
|
|
80807
|
+
function handleRowSelection(event) {
|
|
80808
|
+
if (event.node.displayed && event.node.id) {
|
|
80809
|
+
rowSelectionRef.current.affectedRows[event.node.id] = {
|
|
80810
|
+
node: event.node,
|
|
80811
|
+
selectedState: event.node.isSelected() ? rowSelectionState.selected : rowSelectionState.unselected
|
|
80812
|
+
};
|
|
80813
|
+
}
|
|
80814
|
+
}
|
|
80815
|
+
gridApi?.addEventListener && gridApi.addEventListener("rowSelected", handleRowSelection);
|
|
80816
|
+
return () => {
|
|
80817
|
+
removeEventListenerFromGrid("rowSelected", handleRowSelection, gridApi);
|
|
80818
|
+
};
|
|
80819
|
+
}, [gridApi]);
|
|
80683
80820
|
const setLoading = React76.useCallback((loading, message = "") => {
|
|
80684
80821
|
setLoadingStatus({
|
|
80685
80822
|
loading,
|
|
@@ -80740,6 +80877,7 @@ var useTableApi = ({
|
|
|
80740
80877
|
adjustRowDragIcon(gridApi, columnApi);
|
|
80741
80878
|
});
|
|
80742
80879
|
}
|
|
80880
|
+
setExpandCollapseRow(gridApi, config, groupDefaultExpanded);
|
|
80743
80881
|
},
|
|
80744
80882
|
[columnApi, gridApi, internalSetRowHeight, filterStorage.setSelectedFilters]
|
|
80745
80883
|
);
|
|
@@ -80831,7 +80969,8 @@ var useTableApi = ({
|
|
|
80831
80969
|
columnApi,
|
|
80832
80970
|
rowHeight,
|
|
80833
80971
|
filterStorage,
|
|
80834
|
-
rowSelectionRef
|
|
80972
|
+
rowSelectionRef,
|
|
80973
|
+
groupDefaultExpanded
|
|
80835
80974
|
}),
|
|
80836
80975
|
[columnApi, gridApi, rowHeight, filterStorage]
|
|
80837
80976
|
);
|
|
@@ -81099,7 +81238,6 @@ function buildPartialTableApi({
|
|
|
81099
81238
|
focusField && gridApi?.setFocusedCell(rowIndex, focusField);
|
|
81100
81239
|
};
|
|
81101
81240
|
return {
|
|
81102
|
-
getVisibleRowNodes,
|
|
81103
81241
|
applyTransaction,
|
|
81104
81242
|
applyServerSideTransaction,
|
|
81105
81243
|
collapseAll,
|
|
@@ -81114,6 +81252,7 @@ function buildPartialTableApi({
|
|
|
81114
81252
|
getSelectedRows: getSelectedRows2,
|
|
81115
81253
|
getServerSideSelectionState,
|
|
81116
81254
|
getTableConfiguration,
|
|
81255
|
+
getVisibleRowNodes,
|
|
81117
81256
|
refreshCells,
|
|
81118
81257
|
setPinnedBottomRowData,
|
|
81119
81258
|
setRowData,
|
|
@@ -81231,6 +81370,12 @@ var DataTable = ({
|
|
|
81231
81370
|
const [rowHeight, setRowHeight] = React76.useState(
|
|
81232
81371
|
initialTableConfig?.rowHeight || rowSize.md
|
|
81233
81372
|
);
|
|
81373
|
+
const expandCollapseStateRef = React76.useRef(
|
|
81374
|
+
initialTableConfig?.groupRowState || {
|
|
81375
|
+
expandedRoutes: [],
|
|
81376
|
+
collapsedRoutes: []
|
|
81377
|
+
}
|
|
81378
|
+
);
|
|
81234
81379
|
const rowHeightRef = React76.useRef(
|
|
81235
81380
|
initialTableConfig?.rowHeight || rowSize.md
|
|
81236
81381
|
);
|
|
@@ -81276,12 +81421,14 @@ var DataTable = ({
|
|
|
81276
81421
|
if (localStoragePersistenceKey) {
|
|
81277
81422
|
storage.local.setItem(localStoragePersistenceKey, {
|
|
81278
81423
|
...config,
|
|
81424
|
+
groupRowState: expandCollapseStateRef.current,
|
|
81279
81425
|
rowHeight: rowHeightRef.current,
|
|
81280
81426
|
serverFilters: filterStorage.filtersState
|
|
81281
81427
|
});
|
|
81282
81428
|
}
|
|
81283
81429
|
onTableConfigChange?.({
|
|
81284
81430
|
...config,
|
|
81431
|
+
groupRowState: expandCollapseStateRef.current,
|
|
81285
81432
|
rowHeight: rowHeightRef.current,
|
|
81286
81433
|
serverFilters: filterStorage.filtersState
|
|
81287
81434
|
});
|
|
@@ -81390,6 +81537,7 @@ var DataTable = ({
|
|
|
81390
81537
|
onServerSideDataRequest,
|
|
81391
81538
|
onTableConfigChange: internalOnTableConfigChange,
|
|
81392
81539
|
rowSelectionRef,
|
|
81540
|
+
expandCollapseStateRef,
|
|
81393
81541
|
rowHeight,
|
|
81394
81542
|
searchStorage,
|
|
81395
81543
|
selectedGroupIndex,
|
|
@@ -81491,8 +81639,10 @@ var Table = (props) => {
|
|
|
81491
81639
|
columnDefinitions: internalTableContext.columnDefinitions,
|
|
81492
81640
|
gridApi,
|
|
81493
81641
|
setLoadingStatus,
|
|
81494
|
-
wrapperRef
|
|
81642
|
+
wrapperRef,
|
|
81643
|
+
groupDefaultExpanded: props.groupDefaultExpanded
|
|
81495
81644
|
});
|
|
81645
|
+
const initialTableConfig = internalTableContext.initialTableConfig;
|
|
81496
81646
|
React76.useImperativeHandle(internalTableContext.tableRef, () => tableApi, [
|
|
81497
81647
|
tableApi
|
|
81498
81648
|
]);
|
|
@@ -81999,6 +82149,34 @@ var Table = (props) => {
|
|
|
81999
82149
|
document.getElementsByClassName("ag-body-viewport")[0]?.clientWidth
|
|
82000
82150
|
);
|
|
82001
82151
|
}, [setViewportWidth]);
|
|
82152
|
+
const isClientSideGroupOpenByDefault = React76.useCallback(
|
|
82153
|
+
(params) => {
|
|
82154
|
+
const node = params.rowNode;
|
|
82155
|
+
if (!node) {
|
|
82156
|
+
return false;
|
|
82157
|
+
}
|
|
82158
|
+
return isRowOpenedByDefault(
|
|
82159
|
+
node,
|
|
82160
|
+
initialTableConfig,
|
|
82161
|
+
props.groupsAlwaysExpanded ? -1 : props.groupDefaultExpanded
|
|
82162
|
+
);
|
|
82163
|
+
},
|
|
82164
|
+
[initialTableConfig, props.groupDefaultExpanded]
|
|
82165
|
+
);
|
|
82166
|
+
const isServerSideGroupOpenByDefault = React76.useCallback(
|
|
82167
|
+
(params) => {
|
|
82168
|
+
const node = params.rowNode;
|
|
82169
|
+
if (!node) {
|
|
82170
|
+
return false;
|
|
82171
|
+
}
|
|
82172
|
+
return isRowOpenedByDefault(
|
|
82173
|
+
node,
|
|
82174
|
+
initialTableConfig,
|
|
82175
|
+
props.groupsAlwaysExpanded ? -1 : props.groupDefaultExpanded
|
|
82176
|
+
);
|
|
82177
|
+
},
|
|
82178
|
+
[initialTableConfig, props.groupDefaultExpanded]
|
|
82179
|
+
);
|
|
82002
82180
|
const onGridReady = (params) => {
|
|
82003
82181
|
internalTableContext.setGridApi(params.api);
|
|
82004
82182
|
internalTableContext.setColumnApi(params.columnApi);
|
|
@@ -82025,13 +82203,26 @@ var Table = (props) => {
|
|
|
82025
82203
|
};
|
|
82026
82204
|
const internalRowGroupOpened = React76.useCallback(
|
|
82027
82205
|
(event) => {
|
|
82206
|
+
if (internalTableContext.expandCollapseStateRef) {
|
|
82207
|
+
internalTableContext.expandCollapseStateRef.current = getGroupRowState(
|
|
82208
|
+
gridApi,
|
|
82209
|
+
props.groupDefaultExpanded
|
|
82210
|
+
);
|
|
82211
|
+
}
|
|
82212
|
+
internalTableContext.onTableConfigChange();
|
|
82028
82213
|
props.onRowGroupOpened?.({
|
|
82029
82214
|
expanded: event.expanded,
|
|
82030
82215
|
node: serializeNode(event.node),
|
|
82031
82216
|
rowIndex: event.rowIndex
|
|
82032
82217
|
});
|
|
82033
82218
|
},
|
|
82034
|
-
[
|
|
82219
|
+
[
|
|
82220
|
+
props.onRowGroupOpened,
|
|
82221
|
+
internalTableContext.onTableConfigChange,
|
|
82222
|
+
tableApi?.getTableConfiguration(),
|
|
82223
|
+
internalTableContext.expandCollapseStateRef?.current,
|
|
82224
|
+
gridApi
|
|
82225
|
+
]
|
|
82035
82226
|
);
|
|
82036
82227
|
const getGroupRowAgg = React76.useCallback(
|
|
82037
82228
|
(params) => {
|
|
@@ -82183,6 +82374,8 @@ var Table = (props) => {
|
|
|
82183
82374
|
alwaysAggregateAtRootLevel: !onSSDR,
|
|
82184
82375
|
autoGroupColumnDef: decoratedAutoGroupColDef,
|
|
82185
82376
|
cacheBlockSize: props.paginationPageSize || defaultPaginationPageSize,
|
|
82377
|
+
isGroupOpenByDefault: isClientSideGroupOpenByDefault,
|
|
82378
|
+
isServerSideGroupOpenByDefault,
|
|
82186
82379
|
defaultColDef,
|
|
82187
82380
|
enableGroupEdit: internalTableContext.enableGroupEditAndValidation,
|
|
82188
82381
|
enableCellTextSelection: internalTableContext.enableCellTextSelection,
|
|
@@ -83616,6 +83809,7 @@ var LocationQuickFilterOverlay = React76.forwardRef(
|
|
|
83616
83809
|
enableSublocations,
|
|
83617
83810
|
selectState,
|
|
83618
83811
|
options,
|
|
83812
|
+
disabledOptions,
|
|
83619
83813
|
columnDefinition,
|
|
83620
83814
|
value
|
|
83621
83815
|
}, ref) => {
|
|
@@ -83643,6 +83837,7 @@ var LocationQuickFilterOverlay = React76.forwardRef(
|
|
|
83643
83837
|
return onSelectAll();
|
|
83644
83838
|
}
|
|
83645
83839
|
if (selection.item.id === includeSublocationOption.id) {
|
|
83840
|
+
_onSelect(selection);
|
|
83646
83841
|
return onSelectSublocations();
|
|
83647
83842
|
}
|
|
83648
83843
|
return _onSelect(selection);
|
|
@@ -83712,8 +83907,9 @@ var LocationQuickFilterOverlay = React76.forwardRef(
|
|
|
83712
83907
|
{
|
|
83713
83908
|
key: getId3(item),
|
|
83714
83909
|
item,
|
|
83715
|
-
selected: value.map(({ id }) => id).includes(getId3(item)),
|
|
83716
|
-
suggested: i === 0
|
|
83910
|
+
selected: value.map(({ id }) => id).includes(getId3(item)) || disabledOptions.map(({ id }) => id).includes(getId3(item)),
|
|
83911
|
+
suggested: i === 0,
|
|
83912
|
+
disabled: disabledOptions.map(({ id }) => id).includes(getId3(item))
|
|
83717
83913
|
},
|
|
83718
83914
|
getLabel3(item)
|
|
83719
83915
|
);
|
|
@@ -83759,10 +83955,23 @@ var LocationQuickFilterRenderer = ({
|
|
|
83759
83955
|
const [selectState, setSelectState] = React76.useState(
|
|
83760
83956
|
determineSelectedState(value)
|
|
83761
83957
|
);
|
|
83958
|
+
const [disabledValues, setDisabledValues] = React76.useState([]);
|
|
83762
83959
|
const [enableSublocations, setEnableSublocations] = React76.useState(false);
|
|
83763
83960
|
const onSelectSublocations = React76.useCallback(() => {
|
|
83961
|
+
if (enableSublocations) {
|
|
83962
|
+
setDisabledValues([]);
|
|
83963
|
+
} else {
|
|
83964
|
+
const newDisabledValues = [];
|
|
83965
|
+
value.forEach((location) => {
|
|
83966
|
+
newDisabledValues.push(...findSublocations(location));
|
|
83967
|
+
});
|
|
83968
|
+
const uniqDisabledValues = uniqBy(prop("id"), newDisabledValues).filter(
|
|
83969
|
+
({ id }) => !selectedValueIds.includes(id)
|
|
83970
|
+
);
|
|
83971
|
+
setDisabledValues(uniqDisabledValues);
|
|
83972
|
+
}
|
|
83764
83973
|
setEnableSublocations(!enableSublocations);
|
|
83765
|
-
}, [enableSublocations]);
|
|
83974
|
+
}, [enableSublocations, value, selectedValueIds, options]);
|
|
83766
83975
|
const onSelectAll = React76.useCallback(() => {
|
|
83767
83976
|
if (selectState === "none" || selectState === "partial") {
|
|
83768
83977
|
setSelectState("all");
|
|
@@ -83776,22 +83985,51 @@ var LocationQuickFilterRenderer = ({
|
|
|
83776
83985
|
}
|
|
83777
83986
|
}, [options, selectState, selectedValueIds]);
|
|
83778
83987
|
const onSelect = (selection) => {
|
|
83779
|
-
if (selection.item.id === "select_all"
|
|
83988
|
+
if (selection.item.id === "select_all") {
|
|
83780
83989
|
return;
|
|
83781
83990
|
}
|
|
83782
|
-
|
|
83991
|
+
if (selection.item.id === "include_sublocations") {
|
|
83992
|
+
return onChange(
|
|
83993
|
+
value.map((item) => ({
|
|
83994
|
+
...item,
|
|
83995
|
+
sublocations: enableSublocations ? [] : findSublocations(item)
|
|
83996
|
+
}))
|
|
83997
|
+
);
|
|
83998
|
+
}
|
|
83999
|
+
let newSelections = [];
|
|
84000
|
+
if (selectedValueIds.includes(getId3(selection.item))) {
|
|
84001
|
+
newSelections = removeSelections(selection.item, value);
|
|
84002
|
+
} else {
|
|
84003
|
+
newSelections = [...value, selection.item];
|
|
84004
|
+
const sublocationsToDisable = handleSelectSublocations(selection.item);
|
|
84005
|
+
const newDisabledValues = [
|
|
84006
|
+
...disabledValues,
|
|
84007
|
+
...sublocationsToDisable.filter(
|
|
84008
|
+
({ id }) => !selectedValueIds.includes(id)
|
|
84009
|
+
)
|
|
84010
|
+
];
|
|
84011
|
+
setDisabledValues(newDisabledValues);
|
|
84012
|
+
}
|
|
83783
84013
|
setSelectState(determineSelectedState(newSelections));
|
|
83784
84014
|
setSelectedValueIds(newSelections.map(({ id }) => id));
|
|
83785
|
-
onChange(
|
|
84015
|
+
onChange(
|
|
84016
|
+
newSelections.map((item) => ({
|
|
84017
|
+
...item,
|
|
84018
|
+
sublocations: handleSelectSublocations(item)
|
|
84019
|
+
}))
|
|
84020
|
+
);
|
|
84021
|
+
};
|
|
84022
|
+
const findSublocations = (selected) => {
|
|
84023
|
+
return options.filter((option) => {
|
|
84024
|
+
return startsWith(
|
|
84025
|
+
`${getLabel3(selected).toLowerCase()} > `,
|
|
84026
|
+
getLabel3(option).toLowerCase()
|
|
84027
|
+
);
|
|
84028
|
+
});
|
|
83786
84029
|
};
|
|
83787
84030
|
const handleSelectSublocations = (selected) => {
|
|
83788
84031
|
if (enableSublocations) {
|
|
83789
|
-
const filteredOptions =
|
|
83790
|
-
return startsWith(
|
|
83791
|
-
`${getLabel3(selected).toLowerCase()} > `,
|
|
83792
|
-
getLabel3(option).toLowerCase()
|
|
83793
|
-
);
|
|
83794
|
-
});
|
|
84032
|
+
const filteredOptions = findSublocations(selected);
|
|
83795
84033
|
return filteredOptions;
|
|
83796
84034
|
} else {
|
|
83797
84035
|
return [];
|
|
@@ -83800,13 +84038,16 @@ var LocationQuickFilterRenderer = ({
|
|
|
83800
84038
|
const removeSelections = React76.useCallback(
|
|
83801
84039
|
function(selection, selected) {
|
|
83802
84040
|
const sublocations = handleSelectSublocations(selection);
|
|
83803
|
-
|
|
83804
|
-
|
|
83805
|
-
|
|
84041
|
+
const disabledValueIds = disabledValues.map(({ id }) => id);
|
|
84042
|
+
const sublocationsToRemoveFromDisabledIds = sublocations.filter(({ id }) => disabledValueIds.includes(id)).map(({ id }) => id);
|
|
84043
|
+
setDisabledValues(
|
|
84044
|
+
disabledValues.filter(
|
|
84045
|
+
({ id }) => !sublocationsToRemoveFromDisabledIds.includes(id)
|
|
83806
84046
|
)
|
|
83807
|
-
)
|
|
84047
|
+
);
|
|
84048
|
+
return selected.filter((item) => getId3(item) !== getId3(selection));
|
|
83808
84049
|
},
|
|
83809
|
-
[enableSublocations]
|
|
84050
|
+
[enableSublocations, disabledValues]
|
|
83810
84051
|
);
|
|
83811
84052
|
React76.useEffect(() => {
|
|
83812
84053
|
setSelectState(determineSelectedState(value));
|
|
@@ -83821,6 +84062,7 @@ var LocationQuickFilterRenderer = ({
|
|
|
83821
84062
|
selectState,
|
|
83822
84063
|
value,
|
|
83823
84064
|
options,
|
|
84065
|
+
disabledOptions: disabledValues,
|
|
83824
84066
|
getId: getId3,
|
|
83825
84067
|
getLabel: getLabel3,
|
|
83826
84068
|
loading,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@procore/data-table",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.14.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",
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
"@dotenvx/dotenvx": "1.6.4",
|
|
110
110
|
"@ngneat/falso": "6.4.0",
|
|
111
111
|
"@procore/core-css": "10.17.0",
|
|
112
|
-
"@procore/core-icons": "12.
|
|
112
|
+
"@procore/core-icons": "12.2.0",
|
|
113
113
|
"@procore/core-prettier": "10.2.0",
|
|
114
|
-
"@procore/core-react": "12.
|
|
114
|
+
"@procore/core-react": "12.11.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",
|