@infinite-table/infinite-react 10.2.1 → 11.0.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/README.md +3 -3
- package/index.css +1 -1
- package/index.d.ts +95 -87
- package/index.dev.js +1179 -1019
- package/index.dev.mjs +1179 -1019
- package/index.js +9 -9
- package/index.mjs +9 -9
- package/package.json +2 -2
package/index.dev.js
CHANGED
|
@@ -1975,6 +1975,62 @@ function computePropsDiff(params) {
|
|
|
1975
1975
|
rawUpdatedPropsCount
|
|
1976
1976
|
};
|
|
1977
1977
|
}
|
|
1978
|
+
function applyPropsDiff(params) {
|
|
1979
|
+
const {
|
|
1980
|
+
currentProps,
|
|
1981
|
+
prevProps,
|
|
1982
|
+
state,
|
|
1983
|
+
propsToForward,
|
|
1984
|
+
propsToStateSet,
|
|
1985
|
+
dispatch,
|
|
1986
|
+
actions,
|
|
1987
|
+
onPropChange: onPropChange2,
|
|
1988
|
+
onPropsChange,
|
|
1989
|
+
beforeDispatch
|
|
1990
|
+
} = params;
|
|
1991
|
+
const diff = computePropsDiff({
|
|
1992
|
+
currentProps,
|
|
1993
|
+
prevProps,
|
|
1994
|
+
state,
|
|
1995
|
+
propsToForward,
|
|
1996
|
+
propsToStateSet
|
|
1997
|
+
});
|
|
1998
|
+
const {
|
|
1999
|
+
newMappedState,
|
|
2000
|
+
newMappedStateCount,
|
|
2001
|
+
updatedPropsToState,
|
|
2002
|
+
updatedPropsToStateCount,
|
|
2003
|
+
rawUpdatedProps,
|
|
2004
|
+
rawUpdatedPropsCount
|
|
2005
|
+
} = diff;
|
|
2006
|
+
if (updatedPropsToStateCount === 0 && newMappedStateCount === 0) {
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
2009
|
+
beforeDispatch?.(diff);
|
|
2010
|
+
dispatch({
|
|
2011
|
+
payload: {
|
|
2012
|
+
mappedState: newMappedStateCount ? newMappedState : null,
|
|
2013
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
if (onPropChange2) {
|
|
2017
|
+
for (const prop in rawUpdatedProps) {
|
|
2018
|
+
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
2019
|
+
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
2020
|
+
onPropChange2(
|
|
2021
|
+
{ name: prop, newValue, oldValue },
|
|
2022
|
+
currentProps,
|
|
2023
|
+
actions,
|
|
2024
|
+
state
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
if (onPropsChange && rawUpdatedPropsCount) {
|
|
2030
|
+
onPropsChange(rawUpdatedProps, currentProps, actions, state);
|
|
2031
|
+
}
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
1978
2034
|
|
|
1979
2035
|
// src/components/hooks/useComponentState/index.tsx
|
|
1980
2036
|
var ComponentContext;
|
|
@@ -2070,79 +2126,56 @@ function buildManagedComponent(config) {
|
|
|
2070
2126
|
const effectFn = config.layoutEffect ? import_react9.useLayoutEffect : import_react9.useEffect;
|
|
2071
2127
|
effectFn(() => {
|
|
2072
2128
|
const currentProps = props;
|
|
2073
|
-
const {
|
|
2074
|
-
newMappedState,
|
|
2075
|
-
newMappedStateCount,
|
|
2076
|
-
updatedPropsToState,
|
|
2077
|
-
updatedPropsToStateCount,
|
|
2078
|
-
rawUpdatedProps,
|
|
2079
|
-
rawUpdatedPropsCount
|
|
2080
|
-
} = computePropsDiff({
|
|
2129
|
+
const dispatched = applyPropsDiff({
|
|
2081
2130
|
currentProps,
|
|
2082
2131
|
prevProps,
|
|
2083
2132
|
state,
|
|
2084
2133
|
propsToForward,
|
|
2085
|
-
propsToStateSet: propsToStateSetRef.current
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
} : void 0,
|
|
2107
|
-
updatedPropsToStateCount > 0 ? {
|
|
2108
|
-
name: "Updated props",
|
|
2109
|
-
value: Object.keys(updatedPropsToState).join(", ")
|
|
2110
|
-
} : void 0,
|
|
2111
|
-
updatedPropsToStateCount > 0 || updatedPropsToState ? {
|
|
2112
|
-
name: "Details",
|
|
2113
|
-
value: "The time for this marker is not accurate. The marker is only displayed so you can easily identify the props that triggered the rerender."
|
|
2114
|
-
} : void 0
|
|
2115
|
-
].filter(notNullable)
|
|
2116
|
-
});
|
|
2117
|
-
}
|
|
2118
|
-
const action = {
|
|
2119
|
-
payload: {
|
|
2120
|
-
mappedState: newMappedStateCount ? newMappedState : null,
|
|
2121
|
-
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
2122
|
-
}
|
|
2123
|
-
};
|
|
2124
|
-
skipTriggerParentStateChangeRef.current = true;
|
|
2125
|
-
dispatch(action);
|
|
2126
|
-
if (config.onPropChange) {
|
|
2127
|
-
for (var prop in rawUpdatedProps)
|
|
2128
|
-
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
2129
|
-
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
2130
|
-
config.onPropChange(
|
|
2131
|
-
{ name: prop, newValue, oldValue },
|
|
2132
|
-
props,
|
|
2133
|
-
actions,
|
|
2134
|
-
state
|
|
2135
|
-
);
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
if (config.onPropsChange && rawUpdatedPropsCount) {
|
|
2139
|
-
config.onPropsChange(
|
|
2140
|
-
rawUpdatedProps,
|
|
2141
|
-
props,
|
|
2142
|
-
actions,
|
|
2143
|
-
state
|
|
2134
|
+
propsToStateSet: propsToStateSetRef.current,
|
|
2135
|
+
dispatch,
|
|
2136
|
+
actions,
|
|
2137
|
+
onPropChange: config.onPropChange,
|
|
2138
|
+
onPropsChange: config.onPropsChange,
|
|
2139
|
+
beforeDispatch: ({
|
|
2140
|
+
newMappedState,
|
|
2141
|
+
newMappedStateCount,
|
|
2142
|
+
updatedPropsToState,
|
|
2143
|
+
updatedPropsToStateCount
|
|
2144
|
+
}) => {
|
|
2145
|
+
const debugId = state.debugId;
|
|
2146
|
+
const marker = debugId ? getMarker(debugId).track.ComponentState.label.PropUpdate.start() : void 0;
|
|
2147
|
+
const debugChannelName = config.debugName ? typeof config.debugName === "function" ? `${config.debugName(currentProps)}:rerender` : `${config.debugName}:rerender` : "rerender";
|
|
2148
|
+
const logger2 = dbg(debugChannelName);
|
|
2149
|
+
logger2(
|
|
2150
|
+
"Triggered by new values for the following props",
|
|
2151
|
+
...[
|
|
2152
|
+
...Object.keys(newMappedState ?? {}),
|
|
2153
|
+
...Object.keys(updatedPropsToState ?? {})
|
|
2154
|
+
]
|
|
2144
2155
|
);
|
|
2156
|
+
if (marker) {
|
|
2157
|
+
marker.end({
|
|
2158
|
+
label: debugChannelName,
|
|
2159
|
+
details: [
|
|
2160
|
+
newMappedStateCount > 0 ? {
|
|
2161
|
+
name: "Updated properties",
|
|
2162
|
+
value: Object.keys(newMappedState).join(", ")
|
|
2163
|
+
} : void 0,
|
|
2164
|
+
updatedPropsToStateCount > 0 ? {
|
|
2165
|
+
name: "Updated props",
|
|
2166
|
+
value: Object.keys(updatedPropsToState).join(", ")
|
|
2167
|
+
} : void 0,
|
|
2168
|
+
updatedPropsToStateCount > 0 || updatedPropsToState ? {
|
|
2169
|
+
name: "Details",
|
|
2170
|
+
value: "The time for this marker is not accurate. The marker is only displayed so you can easily identify the props that triggered the rerender."
|
|
2171
|
+
} : void 0
|
|
2172
|
+
].filter(notNullable)
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2145
2175
|
}
|
|
2176
|
+
});
|
|
2177
|
+
if (dispatched) {
|
|
2178
|
+
skipTriggerParentStateChangeRef.current = true;
|
|
2146
2179
|
}
|
|
2147
2180
|
});
|
|
2148
2181
|
effectFn(() => {
|
|
@@ -2526,7 +2559,7 @@ var HeaderFilterOperatorCls = "_12zfob12q _16lm1iw1p _16lm1iw2h _16lm1iw2j _16lm
|
|
|
2526
2559
|
var HeaderFilterOperatorIconRecipe = createRuntimeFn({ defaultClassName: "_12zfob12r _16lm1iw1 _16lm1iw23", variantClassNames: { disabled: { true: "_12zfob12s", false: "_12zfob12t" } }, defaultVariants: {}, compoundVariants: [] });
|
|
2527
2560
|
var HeaderFilterRecipe = createRuntimeFn({ defaultClassName: "_12zfob12n _16lm1iw1p _16lm1iw2h _16lm1iw2k _16lm1iw1", variantClassNames: { active: { true: "_12zfob12o", false: "_12zfob12p" } }, defaultVariants: {}, compoundVariants: [] });
|
|
2528
2561
|
var HeaderGroupCls = "_12zfob12m _16lm1iw1p _16lm1iw2h _16lm1iw2j";
|
|
2529
|
-
var HeaderMenuIconCls = createRuntimeFn({ defaultClassName: "_12zfob127 _16lm1iw1
|
|
2562
|
+
var HeaderMenuIconCls = createRuntimeFn({ defaultClassName: "_12zfob127 _16lm1iw1 _16lm1iw39", variantClassNames: { menuVisible: { true: "_12zfob128" }, reserveSpaceWhenHidden: { true: "_12zfob129", false: "_12zfob12a" } }, defaultVariants: {}, compoundVariants: [[{ menuVisible: true, reserveSpaceWhenHidden: false }, "_12zfob12b"]] });
|
|
2530
2563
|
var HeaderScrollbarPlaceholderCls = "_12zfob1b _16lm1iw2";
|
|
2531
2564
|
var HeaderSortIconCls = "_16lm1iw1";
|
|
2532
2565
|
var HeaderSortIconIndexCls = "_12zfob16";
|
|
@@ -3773,8 +3806,7 @@ function getColumnApiForColumn(colOrColId, param) {
|
|
|
3773
3806
|
}
|
|
3774
3807
|
|
|
3775
3808
|
// src/components/InfiniteTable/components/InfiniteTableHeader/getColumnLabel.ts
|
|
3776
|
-
function
|
|
3777
|
-
const col = typeof colIdOrCol === "string" ? context.getComputed().computedColumnsMap.get(colIdOrCol) : colIdOrCol;
|
|
3809
|
+
function getColumnLabelHeaderParam(col, context, renderLocation) {
|
|
3778
3810
|
const {
|
|
3779
3811
|
api,
|
|
3780
3812
|
getComputed,
|
|
@@ -3786,35 +3818,47 @@ function getColumnLabel(colIdOrCol, context, renderLocation) {
|
|
|
3786
3818
|
const dataSourceState = getDataSourceState();
|
|
3787
3819
|
const { allRowsSelected, someRowsSelected, selectionMode } = dataSourceState;
|
|
3788
3820
|
const computed = getComputed();
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3821
|
+
const columnApi = getColumnApiForColumn(col.id, {
|
|
3822
|
+
...context,
|
|
3823
|
+
actions,
|
|
3824
|
+
dataSourceActions,
|
|
3825
|
+
dataSourceApi
|
|
3826
|
+
});
|
|
3827
|
+
return {
|
|
3828
|
+
horizontalLayoutPageIndex: null,
|
|
3829
|
+
column: col,
|
|
3830
|
+
columnApi,
|
|
3831
|
+
dataSourceApi,
|
|
3832
|
+
renderLocation,
|
|
3833
|
+
dragging: false,
|
|
3834
|
+
columnsMap: computed.computedColumnsMap,
|
|
3835
|
+
columnSortInfo: col.computedSortInfo,
|
|
3836
|
+
columnFilterValue: col.computedFilterValue,
|
|
3837
|
+
filtered: col.computedFiltered,
|
|
3838
|
+
allRowsSelected,
|
|
3839
|
+
someRowsSelected,
|
|
3840
|
+
selectionMode,
|
|
3841
|
+
api,
|
|
3842
|
+
renderBag: {
|
|
3843
|
+
header: col.name || col.id || ""
|
|
3844
|
+
}
|
|
3845
|
+
};
|
|
3846
|
+
}
|
|
3847
|
+
function getColumnLabel(colIdOrCol, context, renderLocation, bind) {
|
|
3848
|
+
const col = typeof colIdOrCol === "string" ? context.getComputed().computedColumnsMap.get(colIdOrCol) : colIdOrCol;
|
|
3849
|
+
const header = col.header;
|
|
3850
|
+
if (typeof header === "function") {
|
|
3851
|
+
const param = getColumnLabelHeaderParam(col, context, renderLocation);
|
|
3852
|
+
const label = header(param) ?? null;
|
|
3853
|
+
return bind ? bind(label, param) : label;
|
|
3816
3854
|
}
|
|
3817
|
-
|
|
3855
|
+
if (header) {
|
|
3856
|
+
return bind ? bind(
|
|
3857
|
+
header,
|
|
3858
|
+
getColumnLabelHeaderParam(col, context, renderLocation)
|
|
3859
|
+
) : header;
|
|
3860
|
+
}
|
|
3861
|
+
return col.name || col.id || "";
|
|
3818
3862
|
}
|
|
3819
3863
|
|
|
3820
3864
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableColumnHeaderFilterContext.ts
|
|
@@ -11854,9 +11898,10 @@ var React28 = __toESM(require("react"));
|
|
|
11854
11898
|
var import_react21 = require("react");
|
|
11855
11899
|
|
|
11856
11900
|
// src/components/InfiniteTable/components/icons/SortIcon/SortIcon.css.ts
|
|
11857
|
-
var SortIconCls = "
|
|
11858
|
-
var SortIconDirectionCls = { asc: "
|
|
11859
|
-
var SortIconLineCls = "
|
|
11901
|
+
var SortIconCls = "_1b8djff1 _16lm1iw1";
|
|
11902
|
+
var SortIconDirectionCls = { asc: "_1b8djff2", desc: "_1b8djff3", none: "_1b8djff4" };
|
|
11903
|
+
var SortIconLineCls = "_1b8djff5";
|
|
11904
|
+
var SortIconLineWidthVarName = "--_1b8djff0";
|
|
11860
11905
|
|
|
11861
11906
|
// src/components/InfiniteTable/components/icons/SortIcon/shared.ts
|
|
11862
11907
|
var defaultLineStyle3 = {
|
|
@@ -11926,7 +11971,11 @@ function SortIcon(props) {
|
|
|
11926
11971
|
"div",
|
|
11927
11972
|
{
|
|
11928
11973
|
"data-name": "sort-icon",
|
|
11929
|
-
style: {
|
|
11974
|
+
style: {
|
|
11975
|
+
...style2,
|
|
11976
|
+
width: size,
|
|
11977
|
+
[SortIconLineWidthVarName]: `${lineWidth}px`
|
|
11978
|
+
},
|
|
11930
11979
|
className: join(
|
|
11931
11980
|
className,
|
|
11932
11981
|
InfiniteIconClassName,
|
|
@@ -23173,6 +23222,9 @@ function deepEqual(a, b) {
|
|
|
23173
23222
|
if (a === b) return true;
|
|
23174
23223
|
if (a == null || b == null) return a === b;
|
|
23175
23224
|
if (typeof a !== typeof b) return false;
|
|
23225
|
+
if (a instanceof Date || b instanceof Date) {
|
|
23226
|
+
return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
23227
|
+
}
|
|
23176
23228
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
23177
23229
|
if (a.length !== b.length) return false;
|
|
23178
23230
|
for (let i = 0, len = a.length; i < len; i++) {
|
|
@@ -29605,8 +29657,8 @@ function getLicenseStatus(licenseKey = "", options) {
|
|
|
29605
29657
|
return "valid";
|
|
29606
29658
|
}
|
|
29607
29659
|
const result = checkLicense(licenseKey, {
|
|
29608
|
-
publishedAt:
|
|
29609
|
-
version: "
|
|
29660
|
+
publishedAt: 1795695384921,
|
|
29661
|
+
version: "11.0.0"
|
|
29610
29662
|
});
|
|
29611
29663
|
if (result === "invalid" && !licenseKey) {
|
|
29612
29664
|
return "missing";
|
|
@@ -30905,6 +30957,14 @@ var deriveStateFromProps2 = (params) => {
|
|
|
30905
30957
|
var React61 = __toESM(require("react"));
|
|
30906
30958
|
var import_react58 = require("react");
|
|
30907
30959
|
|
|
30960
|
+
// src/components/Menu/MenuContext.ts
|
|
30961
|
+
var import_react56 = require("react");
|
|
30962
|
+
var MenuContext = (0, import_react56.createContext)(null);
|
|
30963
|
+
function useMenuContext() {
|
|
30964
|
+
const contextValue = (0, import_react56.useContext)(MenuContext);
|
|
30965
|
+
return contextValue;
|
|
30966
|
+
}
|
|
30967
|
+
|
|
30908
30968
|
// src/components/Menu/menuDomUtils.ts
|
|
30909
30969
|
function getMenuItemRect(menuId, itemKey) {
|
|
30910
30970
|
const cells = getMenuItemNodes(menuId, itemKey);
|
|
@@ -30946,6 +31006,180 @@ function getFirstCheckBoxInsideMenuItem(menuId, itemKey) {
|
|
|
30946
31006
|
return null;
|
|
30947
31007
|
}
|
|
30948
31008
|
|
|
31009
|
+
// src/components/Menu/menuKeyboardNav.ts
|
|
31010
|
+
function hideMenuAndParents(getState) {
|
|
31011
|
+
const state = getState();
|
|
31012
|
+
state.onHideIntent?.(state);
|
|
31013
|
+
}
|
|
31014
|
+
function runMenuItemClick(event, item, context) {
|
|
31015
|
+
const { getState, setActiveItemKey, setKeyboardActiveItemKey, hideAll } = context;
|
|
31016
|
+
setKeyboardActiveItemKey(item.key);
|
|
31017
|
+
setActiveItemKey(item.key);
|
|
31018
|
+
if (item.originalMenuItem.onClick) {
|
|
31019
|
+
item.originalMenuItem.onClick(event);
|
|
31020
|
+
}
|
|
31021
|
+
const onActionParam = {
|
|
31022
|
+
key: item.key,
|
|
31023
|
+
item: item.originalMenuItem,
|
|
31024
|
+
hideMenu: hideAll
|
|
31025
|
+
};
|
|
31026
|
+
if (item.originalMenuItem.onAction) {
|
|
31027
|
+
item.originalMenuItem.onAction(onActionParam);
|
|
31028
|
+
}
|
|
31029
|
+
const { onAction } = getState();
|
|
31030
|
+
if (onAction) {
|
|
31031
|
+
onAction(onActionParam);
|
|
31032
|
+
}
|
|
31033
|
+
if (item.originalMenuItem.hideMenuOnAction) {
|
|
31034
|
+
hideAll();
|
|
31035
|
+
}
|
|
31036
|
+
}
|
|
31037
|
+
function handleMenuKeyDown(keyboardEvent, context) {
|
|
31038
|
+
const {
|
|
31039
|
+
getState,
|
|
31040
|
+
setActiveItemKey,
|
|
31041
|
+
setKeyboardActiveItemKey,
|
|
31042
|
+
destroy,
|
|
31043
|
+
getSubmenuApi,
|
|
31044
|
+
isMounted,
|
|
31045
|
+
onItemClick
|
|
31046
|
+
} = context;
|
|
31047
|
+
const { runtimeItems, runtimeSelectableItems, keyboardActiveItemKey } = getState();
|
|
31048
|
+
const keyboardActiveIndex = runtimeItems.findIndex(
|
|
31049
|
+
(runtimeItem) => runtimeItem.type === "item" && runtimeItem.key === keyboardActiveItemKey
|
|
31050
|
+
);
|
|
31051
|
+
let newKeyboardActiveItemKey = keyboardActiveItemKey;
|
|
31052
|
+
const keyboardActiveItem = runtimeItems[keyboardActiveIndex];
|
|
31053
|
+
const validKeys3 = {
|
|
31054
|
+
ArrowUp: () => {
|
|
31055
|
+
const newActiveItem = runtimeItems.slice(0, keyboardActiveIndex).filter((item) => item.type === "item" && !item.disabled).pop();
|
|
31056
|
+
if (newActiveItem && newActiveItem.type === "item" && newActiveItem.key) {
|
|
31057
|
+
newKeyboardActiveItemKey = newActiveItem.key;
|
|
31058
|
+
}
|
|
31059
|
+
},
|
|
31060
|
+
ArrowDown: () => {
|
|
31061
|
+
const newActiveItem = runtimeItems.slice(keyboardActiveIndex + 1).filter((item) => item.type === "item" && !item.disabled)[0];
|
|
31062
|
+
if (newActiveItem && newActiveItem.type === "item" && newActiveItem.key) {
|
|
31063
|
+
newKeyboardActiveItemKey = newActiveItem.key;
|
|
31064
|
+
}
|
|
31065
|
+
},
|
|
31066
|
+
Home: () => {
|
|
31067
|
+
validKeys3.PageUp();
|
|
31068
|
+
},
|
|
31069
|
+
End: () => {
|
|
31070
|
+
validKeys3.PageDown();
|
|
31071
|
+
},
|
|
31072
|
+
PageUp: () => {
|
|
31073
|
+
newKeyboardActiveItemKey = runtimeSelectableItems[0].key;
|
|
31074
|
+
},
|
|
31075
|
+
PageDown: () => {
|
|
31076
|
+
newKeyboardActiveItemKey = runtimeSelectableItems[runtimeSelectableItems.length - 1].key;
|
|
31077
|
+
},
|
|
31078
|
+
ArrowLeft: () => {
|
|
31079
|
+
setActiveItemKey(null);
|
|
31080
|
+
if (getState().parentMenuId) {
|
|
31081
|
+
destroy();
|
|
31082
|
+
}
|
|
31083
|
+
},
|
|
31084
|
+
ArrowRight: () => {
|
|
31085
|
+
if (!keyboardActiveItem) {
|
|
31086
|
+
return;
|
|
31087
|
+
}
|
|
31088
|
+
setActiveItemKey(keyboardActiveItem.key);
|
|
31089
|
+
raf(() => {
|
|
31090
|
+
const submenuApi = getSubmenuApi();
|
|
31091
|
+
if (isMounted() && submenuApi && submenuApi.getParentMenuId() === getState().menuId) {
|
|
31092
|
+
submenuApi.focus();
|
|
31093
|
+
}
|
|
31094
|
+
});
|
|
31095
|
+
},
|
|
31096
|
+
Enter: () => {
|
|
31097
|
+
if (!keyboardActiveItem) {
|
|
31098
|
+
return;
|
|
31099
|
+
}
|
|
31100
|
+
if (keyboardActiveItem.originalMenuItem?.menu) {
|
|
31101
|
+
if (getSubmenuApi()) {
|
|
31102
|
+
validKeys3.ArrowLeft();
|
|
31103
|
+
return;
|
|
31104
|
+
}
|
|
31105
|
+
setActiveItemKey(keyboardActiveItem.key);
|
|
31106
|
+
} else {
|
|
31107
|
+
onItemClick(keyboardEvent, keyboardActiveItem);
|
|
31108
|
+
}
|
|
31109
|
+
},
|
|
31110
|
+
" ": () => {
|
|
31111
|
+
if (!keyboardActiveItem) {
|
|
31112
|
+
return;
|
|
31113
|
+
}
|
|
31114
|
+
if (!keyboardActiveItem.originalMenuItem.menu) {
|
|
31115
|
+
onItemClick(keyboardEvent, keyboardActiveItem);
|
|
31116
|
+
}
|
|
31117
|
+
const checkbox = getFirstCheckBoxInsideMenuItem(
|
|
31118
|
+
getState().menuId,
|
|
31119
|
+
keyboardActiveItem.key
|
|
31120
|
+
);
|
|
31121
|
+
if (!checkbox) {
|
|
31122
|
+
return;
|
|
31123
|
+
}
|
|
31124
|
+
checkbox.click();
|
|
31125
|
+
},
|
|
31126
|
+
Escape: () => {
|
|
31127
|
+
validKeys3.ArrowLeft();
|
|
31128
|
+
const state = getState();
|
|
31129
|
+
if (!state.parentMenuId) {
|
|
31130
|
+
state.onHideIntent?.(state);
|
|
31131
|
+
}
|
|
31132
|
+
}
|
|
31133
|
+
};
|
|
31134
|
+
const fn = validKeys3[keyboardEvent.key];
|
|
31135
|
+
if (fn) {
|
|
31136
|
+
fn();
|
|
31137
|
+
keyboardEvent.preventDefault();
|
|
31138
|
+
}
|
|
31139
|
+
if (newKeyboardActiveItemKey != keyboardActiveItemKey) {
|
|
31140
|
+
setKeyboardActiveItemKey(newKeyboardActiveItemKey);
|
|
31141
|
+
}
|
|
31142
|
+
}
|
|
31143
|
+
function createMenuFocus(context) {
|
|
31144
|
+
const {
|
|
31145
|
+
getState,
|
|
31146
|
+
setFocused,
|
|
31147
|
+
setKeyboardActiveItemKey,
|
|
31148
|
+
shouldSelectFirstItemOnFocus,
|
|
31149
|
+
hideAll
|
|
31150
|
+
} = context;
|
|
31151
|
+
const onMenuFocus = () => {
|
|
31152
|
+
setFocused(true);
|
|
31153
|
+
setTimeout(() => {
|
|
31154
|
+
const domNode = getState().domRef.current;
|
|
31155
|
+
if (shouldSelectFirstItemOnFocus() && domNode && domNode === document.activeElement && getState().keyboardActiveItemKey == null) {
|
|
31156
|
+
setKeyboardActiveItemKey(
|
|
31157
|
+
getState().runtimeSelectableItems[0]?.key ?? null
|
|
31158
|
+
);
|
|
31159
|
+
}
|
|
31160
|
+
});
|
|
31161
|
+
};
|
|
31162
|
+
const api = {
|
|
31163
|
+
hideMenu: hideAll,
|
|
31164
|
+
focus: () => {
|
|
31165
|
+
const domNode = getState().domRef.current;
|
|
31166
|
+
if (domNode) {
|
|
31167
|
+
domNode.focus();
|
|
31168
|
+
setTimeout(() => {
|
|
31169
|
+
const node = getState().domRef.current;
|
|
31170
|
+
if (node && node !== document.activeElement) {
|
|
31171
|
+
node.focus();
|
|
31172
|
+
}
|
|
31173
|
+
}, 10);
|
|
31174
|
+
onMenuFocus();
|
|
31175
|
+
}
|
|
31176
|
+
},
|
|
31177
|
+
getMenuId: () => getState().menuId,
|
|
31178
|
+
getParentMenuId: () => getState().parentMenuId
|
|
31179
|
+
};
|
|
31180
|
+
return { api, onMenuFocus };
|
|
31181
|
+
}
|
|
31182
|
+
|
|
30949
31183
|
// src/utils/pageGeometry/Triangle.ts
|
|
30950
31184
|
var Triangle = class extends ConvexPoly {
|
|
30951
31185
|
// uncommenting this here breaks our tests - WHAT????
|
|
@@ -31162,12 +31396,150 @@ var MenuTriangleContext = class {
|
|
|
31162
31396
|
}
|
|
31163
31397
|
};
|
|
31164
31398
|
|
|
31165
|
-
// src/components/Menu/
|
|
31166
|
-
|
|
31167
|
-
|
|
31168
|
-
|
|
31169
|
-
|
|
31170
|
-
return
|
|
31399
|
+
// src/components/Menu/menuViewShared.ts
|
|
31400
|
+
function getActiveSubmenuItem(runtimeItems, activeItemKey) {
|
|
31401
|
+
const activeItem = runtimeItems.filter(
|
|
31402
|
+
(item) => item.type === "item" && activeItemKey === item.key
|
|
31403
|
+
)[0];
|
|
31404
|
+
return activeItem && activeItem.menu ? activeItem : null;
|
|
31405
|
+
}
|
|
31406
|
+
function getSubmenuOverlayParams(menuId, item, constrainTo) {
|
|
31407
|
+
const alignTo = getMenuItemRect(menuId, item.key);
|
|
31408
|
+
if (!alignTo) {
|
|
31409
|
+
return null;
|
|
31410
|
+
}
|
|
31411
|
+
return {
|
|
31412
|
+
id: `${menuId}-submenu`,
|
|
31413
|
+
alignTo,
|
|
31414
|
+
alignPosition: [
|
|
31415
|
+
["TopLeft", "TopRight"],
|
|
31416
|
+
["TopRight", "TopLeft"]
|
|
31417
|
+
],
|
|
31418
|
+
constrainTo
|
|
31419
|
+
};
|
|
31420
|
+
}
|
|
31421
|
+
function getSubmenuProps(item, context) {
|
|
31422
|
+
const {
|
|
31423
|
+
parentMenuId,
|
|
31424
|
+
constrainTo,
|
|
31425
|
+
api,
|
|
31426
|
+
hideAll,
|
|
31427
|
+
setSubmenuApi,
|
|
31428
|
+
setActiveItemKey,
|
|
31429
|
+
setKeyboardActiveItemKey
|
|
31430
|
+
} = context;
|
|
31431
|
+
let itemMenu = item.menu;
|
|
31432
|
+
if (!itemMenu) {
|
|
31433
|
+
return null;
|
|
31434
|
+
}
|
|
31435
|
+
if (typeof itemMenu === "function") {
|
|
31436
|
+
itemMenu = itemMenu();
|
|
31437
|
+
}
|
|
31438
|
+
const submenu = itemMenu;
|
|
31439
|
+
return {
|
|
31440
|
+
parentMenuItemKey: item.key,
|
|
31441
|
+
parentMenuId,
|
|
31442
|
+
constrainTo,
|
|
31443
|
+
...submenu,
|
|
31444
|
+
autoFocus: false,
|
|
31445
|
+
onShow: (state, submenuApi) => {
|
|
31446
|
+
submenu?.onShow?.(state, submenuApi);
|
|
31447
|
+
setSubmenuApi(submenuApi);
|
|
31448
|
+
},
|
|
31449
|
+
onHideIntent: (state) => {
|
|
31450
|
+
submenu?.onHideIntent?.(state);
|
|
31451
|
+
hideAll();
|
|
31452
|
+
},
|
|
31453
|
+
onHide: (state) => {
|
|
31454
|
+
if (state.focused) {
|
|
31455
|
+
setActiveItemKey(null);
|
|
31456
|
+
setKeyboardActiveItemKey(item.key);
|
|
31457
|
+
api.focus();
|
|
31458
|
+
}
|
|
31459
|
+
}
|
|
31460
|
+
};
|
|
31461
|
+
}
|
|
31462
|
+
function createMenuTriangleHandlers(getState, onItemActivate) {
|
|
31463
|
+
return new MenuTriangleContext({
|
|
31464
|
+
parentMenuId: getState().parentMenuId,
|
|
31465
|
+
onItemActivate,
|
|
31466
|
+
itemHasSubMenu: (itemKey) => {
|
|
31467
|
+
const item = getState().runtimeItems.filter(
|
|
31468
|
+
(item2) => item2.type === "item" && item2.key === itemKey && item2.menu
|
|
31469
|
+
)[0];
|
|
31470
|
+
return !!item;
|
|
31471
|
+
},
|
|
31472
|
+
getMenuRectFor: (itemKey) => {
|
|
31473
|
+
const selector2 = `[data-submenu-for="${itemKey}"]`;
|
|
31474
|
+
const menuNode = document.querySelector(selector2);
|
|
31475
|
+
if (!menuNode) {
|
|
31476
|
+
return void 0;
|
|
31477
|
+
}
|
|
31478
|
+
return Rectangle.from(menuNode.getBoundingClientRect());
|
|
31479
|
+
}
|
|
31480
|
+
}).getHandlers();
|
|
31481
|
+
}
|
|
31482
|
+
function getMenuGridStyle(state, style2, toCssWidth = (width) => width) {
|
|
31483
|
+
const { columns, runtimeItems, wrapLabels } = state;
|
|
31484
|
+
const gridTemplateColumns = columns.map((col) => {
|
|
31485
|
+
return toCssWidth(
|
|
31486
|
+
col.width || (typeof col.flex === "number" ? `${col.flex}fr` : col.flex) || "auto"
|
|
31487
|
+
);
|
|
31488
|
+
}).join(" ");
|
|
31489
|
+
const result = {
|
|
31490
|
+
...style2,
|
|
31491
|
+
gridTemplateColumns,
|
|
31492
|
+
gridTemplateRows: runtimeItems.map(() => `auto`).join(" ")
|
|
31493
|
+
};
|
|
31494
|
+
if (!wrapLabels) {
|
|
31495
|
+
result.whiteSpace = "nowrap";
|
|
31496
|
+
}
|
|
31497
|
+
return result;
|
|
31498
|
+
}
|
|
31499
|
+
function getMenuItemCells(item, columns, index, flags) {
|
|
31500
|
+
const { active, keyboardActive, pressed } = flags;
|
|
31501
|
+
const key = item.value.key;
|
|
31502
|
+
const className = join(
|
|
31503
|
+
MenuItemCls({
|
|
31504
|
+
active,
|
|
31505
|
+
disabled: !!item.disabled,
|
|
31506
|
+
keyboardActive,
|
|
31507
|
+
pressed: pressed || active
|
|
31508
|
+
}),
|
|
31509
|
+
item.className
|
|
31510
|
+
);
|
|
31511
|
+
const cells = [];
|
|
31512
|
+
let spanIndex = 0;
|
|
31513
|
+
columns.forEach((col, i) => {
|
|
31514
|
+
const target = item.value;
|
|
31515
|
+
const field = col.field || col.name;
|
|
31516
|
+
const start = i + 1;
|
|
31517
|
+
const end = start + item.span;
|
|
31518
|
+
if (start < spanIndex) {
|
|
31519
|
+
return;
|
|
31520
|
+
}
|
|
31521
|
+
spanIndex = end;
|
|
31522
|
+
cells.push({
|
|
31523
|
+
key: `${key}-${field}`,
|
|
31524
|
+
column: col,
|
|
31525
|
+
value: target[field],
|
|
31526
|
+
style: {
|
|
31527
|
+
...col.style,
|
|
31528
|
+
...item.style,
|
|
31529
|
+
gridColumnStart: start,
|
|
31530
|
+
gridColumnEnd: end
|
|
31531
|
+
},
|
|
31532
|
+
className,
|
|
31533
|
+
dataAttributes: {
|
|
31534
|
+
"data-menu-column-id": `${item.parentMenuId}-col-${col.name}`,
|
|
31535
|
+
"data-menu-col-name": `${col.name}`,
|
|
31536
|
+
"data-menu-row-id": `${item.parentMenuId}-row-${index}`,
|
|
31537
|
+
"data-menu-row-index": `${index}`,
|
|
31538
|
+
"data-menu-item-key": `${item.key}`
|
|
31539
|
+
}
|
|
31540
|
+
});
|
|
31541
|
+
});
|
|
31542
|
+
return cells;
|
|
31171
31543
|
}
|
|
31172
31544
|
|
|
31173
31545
|
// src/components/hooks/useMounted.ts
|
|
@@ -31186,84 +31558,29 @@ function useMounted() {
|
|
|
31186
31558
|
|
|
31187
31559
|
// src/components/Menu/Menu.tsx
|
|
31188
31560
|
function renderSubmenuForItem(item, config) {
|
|
31189
|
-
const {
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
setActiveItemKey,
|
|
31193
|
-
setKeyboardActiveItemKey,
|
|
31194
|
-
constrainTo,
|
|
31195
|
-
onHideIntent,
|
|
31196
|
-
api
|
|
31197
|
-
} = config;
|
|
31198
|
-
const overlayId = `${parentMenuId}-submenu`;
|
|
31199
|
-
let itemMenu = item.menu;
|
|
31200
|
-
if (!itemMenu) {
|
|
31561
|
+
const overlayId = `${config.parentMenuId}-submenu`;
|
|
31562
|
+
const submenuProps = getSubmenuProps(item, config);
|
|
31563
|
+
if (!submenuProps) {
|
|
31201
31564
|
return null;
|
|
31202
31565
|
}
|
|
31203
|
-
|
|
31204
|
-
itemMenu = itemMenu();
|
|
31205
|
-
}
|
|
31206
|
-
return /* @__PURE__ */ React61.createElement(
|
|
31207
|
-
Menu,
|
|
31208
|
-
{
|
|
31209
|
-
key: overlayId,
|
|
31210
|
-
parentMenuItemKey: item.key,
|
|
31211
|
-
parentMenuId,
|
|
31212
|
-
constrainTo,
|
|
31213
|
-
...itemMenu,
|
|
31214
|
-
autoFocus: false,
|
|
31215
|
-
onShow: (state, api2) => {
|
|
31216
|
-
itemMenu?.onShow?.(state, api2);
|
|
31217
|
-
setSubmenuApi(api2);
|
|
31218
|
-
},
|
|
31219
|
-
onHideIntent: (state) => {
|
|
31220
|
-
itemMenu?.onHideIntent?.(state);
|
|
31221
|
-
onHideIntent(state);
|
|
31222
|
-
},
|
|
31223
|
-
onHide: (state) => {
|
|
31224
|
-
if (state.focused) {
|
|
31225
|
-
setActiveItemKey(null);
|
|
31226
|
-
setKeyboardActiveItemKey(item.key);
|
|
31227
|
-
api.focus();
|
|
31228
|
-
}
|
|
31229
|
-
}
|
|
31230
|
-
}
|
|
31231
|
-
);
|
|
31566
|
+
return /* @__PURE__ */ React61.createElement(Menu, { key: overlayId, ...submenuProps });
|
|
31232
31567
|
}
|
|
31233
31568
|
function useSubmenus({
|
|
31234
31569
|
onItemActivate
|
|
31235
31570
|
}) {
|
|
31236
31571
|
const { getState } = useMenuContext();
|
|
31237
|
-
const [{ onItemEnter, onItemLeave }] = (0, import_react58.useState)(
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
onItemActivate(null);
|
|
31243
|
-
return;
|
|
31244
|
-
}
|
|
31245
|
-
const item = getState().runtimeItems.filter(
|
|
31246
|
-
(item2) => item2.type === "item" && item2.key === itemKey
|
|
31247
|
-
)[0];
|
|
31248
|
-
onItemActivate(item);
|
|
31249
|
-
},
|
|
31250
|
-
itemHasSubMenu: (itemKey) => {
|
|
31251
|
-
const item = getState().runtimeItems.filter(
|
|
31252
|
-
(item2) => item2.type === "item" && item2.key === itemKey && item2.menu
|
|
31253
|
-
)[0];
|
|
31254
|
-
return !!item;
|
|
31255
|
-
},
|
|
31256
|
-
getMenuRectFor: (itemKey) => {
|
|
31257
|
-
const selector2 = `[data-submenu-for="${itemKey}"]`;
|
|
31258
|
-
const menuNode = document.querySelector(selector2);
|
|
31259
|
-
if (!menuNode) {
|
|
31260
|
-
return void 0;
|
|
31261
|
-
}
|
|
31262
|
-
const rect = Rectangle.from(menuNode.getBoundingClientRect());
|
|
31263
|
-
return rect;
|
|
31572
|
+
const [{ onItemEnter, onItemLeave }] = (0, import_react58.useState)(
|
|
31573
|
+
() => createMenuTriangleHandlers(getState, (itemKey) => {
|
|
31574
|
+
if (!itemKey) {
|
|
31575
|
+
onItemActivate(null);
|
|
31576
|
+
return;
|
|
31264
31577
|
}
|
|
31265
|
-
|
|
31266
|
-
|
|
31578
|
+
const item = getState().runtimeItems.filter(
|
|
31579
|
+
(item2) => item2.type === "item" && item2.key === itemKey
|
|
31580
|
+
)[0];
|
|
31581
|
+
onItemActivate(item);
|
|
31582
|
+
})
|
|
31583
|
+
);
|
|
31267
31584
|
return {
|
|
31268
31585
|
onItemEnter: (0, import_react58.useCallback)(onItemEnter, []),
|
|
31269
31586
|
onItemLeave: (0, import_react58.useCallback)(onItemLeave, [])
|
|
@@ -31272,6 +31589,7 @@ function useSubmenus({
|
|
|
31272
31589
|
function MenuComponent(props) {
|
|
31273
31590
|
const { domProps } = props;
|
|
31274
31591
|
const {
|
|
31592
|
+
componentState,
|
|
31275
31593
|
componentState: {
|
|
31276
31594
|
columns,
|
|
31277
31595
|
runtimeItems,
|
|
@@ -31280,8 +31598,6 @@ function MenuComponent(props) {
|
|
|
31280
31598
|
keyboardActiveItemKey,
|
|
31281
31599
|
constrainTo,
|
|
31282
31600
|
destroyed,
|
|
31283
|
-
onAction,
|
|
31284
|
-
wrapLabels,
|
|
31285
31601
|
onShow,
|
|
31286
31602
|
onHide,
|
|
31287
31603
|
autoFocus,
|
|
@@ -31299,62 +31615,56 @@ function MenuComponent(props) {
|
|
|
31299
31615
|
}, []);
|
|
31300
31616
|
const isMounted = useMounted();
|
|
31301
31617
|
const [submenuApi, setSubmenuApi] = (0, import_react58.useState)(null);
|
|
31618
|
+
const shouldSelectFirstItemOnFocus = (0, import_react58.useRef)(true);
|
|
31619
|
+
const [{ api, onMenuFocus, hideAll }] = (0, import_react58.useState)(() => {
|
|
31620
|
+
const hideAll2 = () => hideMenuAndParents(getState);
|
|
31621
|
+
return {
|
|
31622
|
+
hideAll: hideAll2,
|
|
31623
|
+
...createMenuFocus({
|
|
31624
|
+
getState,
|
|
31625
|
+
setFocused: (focused) => {
|
|
31626
|
+
componentActions.focused = focused;
|
|
31627
|
+
},
|
|
31628
|
+
setKeyboardActiveItemKey,
|
|
31629
|
+
shouldSelectFirstItemOnFocus: () => shouldSelectFirstItemOnFocus.current,
|
|
31630
|
+
hideAll: hideAll2
|
|
31631
|
+
})
|
|
31632
|
+
};
|
|
31633
|
+
});
|
|
31302
31634
|
let renderedChildren = null;
|
|
31303
31635
|
(0, import_react58.useLayoutEffect)(() => {
|
|
31304
31636
|
const { runtimeItems: runtimeItems2 } = getState();
|
|
31305
|
-
const activeItem = runtimeItems2
|
|
31306
|
-
|
|
31307
|
-
)[0];
|
|
31308
|
-
if (!activeItem || !activeItem.menu) {
|
|
31637
|
+
const activeItem = getActiveSubmenuItem(runtimeItems2, activeItemKey);
|
|
31638
|
+
if (!activeItem) {
|
|
31309
31639
|
setSubmenuApi(null);
|
|
31310
31640
|
clearAll();
|
|
31311
31641
|
return;
|
|
31312
31642
|
}
|
|
31313
|
-
|
|
31314
|
-
|
|
31315
|
-
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31325
|
-
|
|
31326
|
-
|
|
31327
|
-
|
|
31328
|
-
|
|
31329
|
-
["TopLeft", "TopRight"],
|
|
31330
|
-
["TopRight", "TopLeft"]
|
|
31331
|
-
],
|
|
31332
|
-
constrainTo
|
|
31333
|
-
});
|
|
31334
|
-
}
|
|
31335
|
-
return;
|
|
31643
|
+
const overlayParams = getSubmenuOverlayParams(
|
|
31644
|
+
menuId,
|
|
31645
|
+
activeItem,
|
|
31646
|
+
constrainTo
|
|
31647
|
+
);
|
|
31648
|
+
const menu = () => renderSubmenuForItem(activeItem, {
|
|
31649
|
+
constrainTo,
|
|
31650
|
+
setSubmenuApi,
|
|
31651
|
+
setActiveItemKey,
|
|
31652
|
+
setKeyboardActiveItemKey,
|
|
31653
|
+
parentMenuId: menuId,
|
|
31654
|
+
hideAll,
|
|
31655
|
+
api
|
|
31656
|
+
});
|
|
31657
|
+
if (overlayParams) {
|
|
31658
|
+
showOverlay(menu, overlayParams);
|
|
31336
31659
|
}
|
|
31337
31660
|
}, [activeItemKey]);
|
|
31338
31661
|
const onItemClick = (event, item) => {
|
|
31339
|
-
|
|
31340
|
-
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
key: item.key,
|
|
31346
|
-
item: item.originalMenuItem,
|
|
31347
|
-
hideMenu: hideAll
|
|
31348
|
-
};
|
|
31349
|
-
if (item.originalMenuItem.onAction) {
|
|
31350
|
-
item.originalMenuItem.onAction(onActionParam);
|
|
31351
|
-
}
|
|
31352
|
-
if (onAction) {
|
|
31353
|
-
onAction(onActionParam);
|
|
31354
|
-
}
|
|
31355
|
-
if (item.originalMenuItem.hideMenuOnAction) {
|
|
31356
|
-
hideAll();
|
|
31357
|
-
}
|
|
31662
|
+
runMenuItemClick(event, item, {
|
|
31663
|
+
getState,
|
|
31664
|
+
setActiveItemKey,
|
|
31665
|
+
setKeyboardActiveItemKey,
|
|
31666
|
+
hideAll
|
|
31667
|
+
});
|
|
31358
31668
|
};
|
|
31359
31669
|
const {
|
|
31360
31670
|
showOverlay,
|
|
@@ -31392,158 +31702,27 @@ function MenuComponent(props) {
|
|
|
31392
31702
|
onClick: onItemClick
|
|
31393
31703
|
}
|
|
31394
31704
|
));
|
|
31395
|
-
const
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
...domProps.style,
|
|
31400
|
-
gridTemplateColumns,
|
|
31401
|
-
gridTemplateRows: runtimeItems.map(() => `auto`).join(" ")
|
|
31402
|
-
};
|
|
31403
|
-
if (!wrapLabels) {
|
|
31404
|
-
style2.whiteSpace = "nowrap";
|
|
31405
|
-
}
|
|
31705
|
+
const style2 = getMenuGridStyle(
|
|
31706
|
+
componentState,
|
|
31707
|
+
domProps.style
|
|
31708
|
+
);
|
|
31406
31709
|
function handleKeydown(keyboardEvent) {
|
|
31407
|
-
|
|
31408
|
-
|
|
31409
|
-
|
|
31410
|
-
|
|
31411
|
-
|
|
31412
|
-
|
|
31413
|
-
const validKeys3 = {
|
|
31414
|
-
ArrowUp: () => {
|
|
31415
|
-
const newActiveItem = runtimeItems2.slice(0, keyboardActiveIndex).filter((item) => item.type === "item" && !item.disabled).pop();
|
|
31416
|
-
if (newActiveItem && newActiveItem.type === "item" && newActiveItem.key) {
|
|
31417
|
-
newKeyboardActiveItemKey = newActiveItem.key;
|
|
31418
|
-
}
|
|
31419
|
-
},
|
|
31420
|
-
ArrowDown: () => {
|
|
31421
|
-
const newActiveItem = runtimeItems2.slice(keyboardActiveIndex + 1).filter((item) => item.type === "item" && !item.disabled)[0];
|
|
31422
|
-
if (newActiveItem && newActiveItem.type === "item" && newActiveItem.key) {
|
|
31423
|
-
newKeyboardActiveItemKey = newActiveItem.key;
|
|
31424
|
-
}
|
|
31425
|
-
},
|
|
31426
|
-
Home: () => {
|
|
31427
|
-
validKeys3.PageUp();
|
|
31428
|
-
},
|
|
31429
|
-
End: () => {
|
|
31430
|
-
validKeys3.PageDown();
|
|
31431
|
-
},
|
|
31432
|
-
PageUp: () => {
|
|
31433
|
-
newKeyboardActiveItemKey = runtimeSelectableItems[0].key;
|
|
31434
|
-
},
|
|
31435
|
-
PageDown: () => {
|
|
31436
|
-
newKeyboardActiveItemKey = runtimeSelectableItems[runtimeSelectableItems.length - 1].key;
|
|
31437
|
-
},
|
|
31438
|
-
ArrowLeft: () => {
|
|
31439
|
-
setActiveItemKey(null);
|
|
31440
|
-
if (getState().parentMenuId) {
|
|
31441
|
-
componentActions.destroyed = true;
|
|
31442
|
-
}
|
|
31443
|
-
},
|
|
31444
|
-
ArrowRight: () => {
|
|
31445
|
-
if (!keyboardActiveItem) {
|
|
31446
|
-
return;
|
|
31447
|
-
}
|
|
31448
|
-
setActiveItemKey(keyboardActiveItem.key);
|
|
31449
|
-
raf(() => {
|
|
31450
|
-
if (isMounted() && submenuApi && submenuApi.getParentMenuId() === getState().menuId) {
|
|
31451
|
-
submenuApi.focus();
|
|
31452
|
-
}
|
|
31453
|
-
});
|
|
31454
|
-
},
|
|
31455
|
-
Enter: () => {
|
|
31456
|
-
if (!keyboardActiveItem) {
|
|
31457
|
-
return;
|
|
31458
|
-
}
|
|
31459
|
-
if (keyboardActiveItem.originalMenuItem?.menu) {
|
|
31460
|
-
if (keyboardActiveItem && keyboardActiveItem.originalMenuItem.menu && submenuApi) {
|
|
31461
|
-
validKeys3.ArrowLeft();
|
|
31462
|
-
return;
|
|
31463
|
-
}
|
|
31464
|
-
if (keyboardActiveItem) {
|
|
31465
|
-
setActiveItemKey(keyboardActiveItem.key);
|
|
31466
|
-
}
|
|
31467
|
-
} else {
|
|
31468
|
-
onItemClick(
|
|
31469
|
-
keyboardEvent,
|
|
31470
|
-
keyboardActiveItem
|
|
31471
|
-
);
|
|
31472
|
-
}
|
|
31473
|
-
},
|
|
31474
|
-
" ": () => {
|
|
31475
|
-
if (!keyboardActiveItem) {
|
|
31476
|
-
return;
|
|
31477
|
-
}
|
|
31478
|
-
if (!keyboardActiveItem.originalMenuItem.menu) {
|
|
31479
|
-
onItemClick(
|
|
31480
|
-
keyboardEvent,
|
|
31481
|
-
keyboardActiveItem
|
|
31482
|
-
);
|
|
31483
|
-
}
|
|
31484
|
-
const checkbox = getFirstCheckBoxInsideMenuItem(
|
|
31485
|
-
menuId,
|
|
31486
|
-
keyboardActiveItem.key
|
|
31487
|
-
);
|
|
31488
|
-
if (!checkbox) {
|
|
31489
|
-
return;
|
|
31490
|
-
}
|
|
31491
|
-
checkbox.click();
|
|
31710
|
+
handleMenuKeyDown(keyboardEvent, {
|
|
31711
|
+
getState,
|
|
31712
|
+
setActiveItemKey,
|
|
31713
|
+
setKeyboardActiveItemKey,
|
|
31714
|
+
destroy: () => {
|
|
31715
|
+
componentActions.destroyed = true;
|
|
31492
31716
|
},
|
|
31493
|
-
|
|
31494
|
-
|
|
31495
|
-
|
|
31496
|
-
|
|
31497
|
-
|
|
31498
|
-
}
|
|
31499
|
-
}
|
|
31500
|
-
};
|
|
31501
|
-
const fn = validKeys3[keyboardEvent.key];
|
|
31502
|
-
if (fn) {
|
|
31503
|
-
fn();
|
|
31504
|
-
keyboardEvent.preventDefault();
|
|
31505
|
-
}
|
|
31506
|
-
if (newKeyboardActiveItemKey != keyboardActiveItemKey) {
|
|
31507
|
-
setKeyboardActiveItemKey(newKeyboardActiveItemKey);
|
|
31508
|
-
}
|
|
31717
|
+
// the submenu api of this render: the raf of ArrowRight reads it
|
|
31718
|
+
getSubmenuApi: () => submenuApi,
|
|
31719
|
+
isMounted,
|
|
31720
|
+
onItemClick
|
|
31721
|
+
});
|
|
31509
31722
|
}
|
|
31510
31723
|
function onMenuBlur() {
|
|
31511
31724
|
componentActions.focused = false;
|
|
31512
31725
|
}
|
|
31513
|
-
const onMenuFocus = (0, import_react58.useCallback)(function() {
|
|
31514
|
-
componentActions.focused = true;
|
|
31515
|
-
setTimeout(() => {
|
|
31516
|
-
if (shouldSelectFirstItemOnFocus.current && domRef.current && domRef.current === document.activeElement && getState().keyboardActiveItemKey == null) {
|
|
31517
|
-
setKeyboardActiveItemKey(
|
|
31518
|
-
getState().runtimeSelectableItems[0]?.key ?? null
|
|
31519
|
-
);
|
|
31520
|
-
}
|
|
31521
|
-
});
|
|
31522
|
-
}, []);
|
|
31523
|
-
const shouldSelectFirstItemOnFocus = (0, import_react58.useRef)(true);
|
|
31524
|
-
const hideAll = (0, import_react58.useCallback)(() => {
|
|
31525
|
-
const state = getState();
|
|
31526
|
-
state.onHideIntent?.(state);
|
|
31527
|
-
}, [getState]);
|
|
31528
|
-
const [api] = (0, import_react58.useState)(() => {
|
|
31529
|
-
const result2 = {
|
|
31530
|
-
hideMenu: hideAll,
|
|
31531
|
-
focus: () => {
|
|
31532
|
-
if (domRef.current) {
|
|
31533
|
-
domRef.current.focus();
|
|
31534
|
-
setTimeout(() => {
|
|
31535
|
-
if (domRef.current && domRef.current !== document.activeElement) {
|
|
31536
|
-
domRef.current.focus();
|
|
31537
|
-
}
|
|
31538
|
-
}, 10);
|
|
31539
|
-
onMenuFocus();
|
|
31540
|
-
}
|
|
31541
|
-
},
|
|
31542
|
-
getMenuId: () => getState().menuId,
|
|
31543
|
-
getParentMenuId: () => getState().parentMenuId
|
|
31544
|
-
};
|
|
31545
|
-
return result2;
|
|
31546
|
-
});
|
|
31547
31726
|
const refCallback = (0, import_react58.useCallback)((node) => {
|
|
31548
31727
|
if (node) {
|
|
31549
31728
|
domRef.current = node;
|
|
@@ -31588,44 +31767,20 @@ function MenuComponent(props) {
|
|
|
31588
31767
|
function RuntimeItemRenderer(props) {
|
|
31589
31768
|
const [pressed, setPressed] = React61.useState(false);
|
|
31590
31769
|
const { columns, item, index, active, keyboardActive } = props;
|
|
31591
|
-
const key = item.type === "item" ? item.value.key : index;
|
|
31592
31770
|
let content = null;
|
|
31593
31771
|
if (item.type === "decoration") {
|
|
31594
31772
|
content = /* @__PURE__ */ React61.createElement("div", { style: item.style }, item.value);
|
|
31595
31773
|
} else {
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
31599
|
-
|
|
31600
|
-
|
|
31601
|
-
const
|
|
31602
|
-
if (start < spanIndex) {
|
|
31603
|
-
return null;
|
|
31604
|
-
}
|
|
31605
|
-
spanIndex = end;
|
|
31606
|
-
const style2 = {
|
|
31607
|
-
...col.style,
|
|
31608
|
-
...item.style,
|
|
31609
|
-
gridColumnStart: start,
|
|
31610
|
-
gridColumnEnd: end
|
|
31611
|
-
};
|
|
31774
|
+
content = getMenuItemCells(item, columns, index, {
|
|
31775
|
+
active,
|
|
31776
|
+
keyboardActive,
|
|
31777
|
+
pressed
|
|
31778
|
+
}).map((cell) => {
|
|
31779
|
+
const col = cell.column;
|
|
31612
31780
|
const domProps = {
|
|
31613
|
-
style:
|
|
31614
|
-
|
|
31615
|
-
|
|
31616
|
-
"data-menu-col-name": `${col.name}`,
|
|
31617
|
-
"data-menu-row-id": `${item.parentMenuId}-row-${index}`,
|
|
31618
|
-
"data-menu-row-index": `${index}`,
|
|
31619
|
-
"data-menu-item-key": `${item.key}`,
|
|
31620
|
-
className: join(
|
|
31621
|
-
MenuItemCls({
|
|
31622
|
-
active,
|
|
31623
|
-
disabled: !!item.disabled,
|
|
31624
|
-
keyboardActive,
|
|
31625
|
-
pressed: pressed || props.active
|
|
31626
|
-
}),
|
|
31627
|
-
item.className
|
|
31628
|
-
),
|
|
31781
|
+
style: cell.style,
|
|
31782
|
+
...cell.dataAttributes,
|
|
31783
|
+
className: cell.className,
|
|
31629
31784
|
onPointerEnter: (event) => {
|
|
31630
31785
|
if (!item.disabled) {
|
|
31631
31786
|
props.onItemEnter?.(item, event);
|
|
@@ -31655,17 +31810,17 @@ function RuntimeItemRenderer(props) {
|
|
|
31655
31810
|
return col.render ? /* @__PURE__ */ React61.createElement(
|
|
31656
31811
|
RenderHookComponent,
|
|
31657
31812
|
{
|
|
31658
|
-
key:
|
|
31813
|
+
key: cell.key,
|
|
31659
31814
|
render: col.render,
|
|
31660
31815
|
renderParam: {
|
|
31661
|
-
item:
|
|
31816
|
+
item: item.value,
|
|
31662
31817
|
column: col,
|
|
31663
|
-
value:
|
|
31818
|
+
value: cell.value,
|
|
31664
31819
|
domProps
|
|
31665
31820
|
}
|
|
31666
31821
|
}
|
|
31667
|
-
) : /* @__PURE__ */ React61.createElement("div", { key:
|
|
31668
|
-
})
|
|
31822
|
+
) : /* @__PURE__ */ React61.createElement("div", { key: cell.key, ...domProps }, cell.value);
|
|
31823
|
+
});
|
|
31669
31824
|
}
|
|
31670
31825
|
return /* @__PURE__ */ React61.createElement("div", { className: MenuRowCls }, content);
|
|
31671
31826
|
}
|
|
@@ -31730,9 +31885,64 @@ Menu[propToIdentifyMenu] = true;
|
|
|
31730
31885
|
|
|
31731
31886
|
// src/components/InfiniteTable/utils/defaultGetColumnMenuItems.tsx
|
|
31732
31887
|
var React63 = __toESM(require("react"));
|
|
31733
|
-
|
|
31734
|
-
|
|
31735
|
-
|
|
31888
|
+
|
|
31889
|
+
// src/components/InfiniteTable/utils/contextMenuUtilsShared.ts
|
|
31890
|
+
function getMenuItemsAndColumns(menuDefinition) {
|
|
31891
|
+
let items = menuDefinition ? Array.isArray(menuDefinition) ? menuDefinition : menuDefinition.items : null;
|
|
31892
|
+
const columns = menuDefinition && !Array.isArray(menuDefinition) ? menuDefinition.columns : void 0;
|
|
31893
|
+
return {
|
|
31894
|
+
items,
|
|
31895
|
+
columns
|
|
31896
|
+
};
|
|
31897
|
+
}
|
|
31898
|
+
function getMenuVisibilityProps(onHideIntent) {
|
|
31899
|
+
const onRootMouseDown = (event) => {
|
|
31900
|
+
event.__insideMenu = true;
|
|
31901
|
+
};
|
|
31902
|
+
const onHide = (state) => {
|
|
31903
|
+
state.domRef.current?.parentNode?.removeEventListener(
|
|
31904
|
+
"mousedown",
|
|
31905
|
+
onRootMouseDown
|
|
31906
|
+
);
|
|
31907
|
+
};
|
|
31908
|
+
return {
|
|
31909
|
+
onShow: (state) => {
|
|
31910
|
+
state.domRef.current?.parentNode?.addEventListener(
|
|
31911
|
+
"mousedown",
|
|
31912
|
+
onRootMouseDown
|
|
31913
|
+
);
|
|
31914
|
+
},
|
|
31915
|
+
onHide,
|
|
31916
|
+
onHideIntent: (state) => {
|
|
31917
|
+
onHide(state);
|
|
31918
|
+
onHideIntent?.();
|
|
31919
|
+
}
|
|
31920
|
+
};
|
|
31921
|
+
}
|
|
31922
|
+
function getMenuDefaultProps(config) {
|
|
31923
|
+
const menuDefaultProps = {
|
|
31924
|
+
columns: [],
|
|
31925
|
+
items: [],
|
|
31926
|
+
autoFocus: true,
|
|
31927
|
+
...getMenuVisibilityProps(config.onHideIntent)
|
|
31928
|
+
};
|
|
31929
|
+
return menuDefaultProps;
|
|
31930
|
+
}
|
|
31931
|
+
function getLazyMenuProps(menuDefinition, menuDefaultProps) {
|
|
31932
|
+
const { items, columns } = getMenuItemsAndColumns(menuDefinition);
|
|
31933
|
+
if (items && items.length) {
|
|
31934
|
+
return {
|
|
31935
|
+
...menuDefaultProps,
|
|
31936
|
+
items: items || [],
|
|
31937
|
+
columns
|
|
31938
|
+
};
|
|
31939
|
+
}
|
|
31940
|
+
return null;
|
|
31941
|
+
}
|
|
31942
|
+
|
|
31943
|
+
// src/components/InfiniteTable/utils/menuItemsShared.ts
|
|
31944
|
+
function getDefaultColumnMenuItems(params, binder) {
|
|
31945
|
+
const { columnApi, column, getComputed, api, dataSourceApi } = params;
|
|
31736
31946
|
const sortable = columnApi.isSortable();
|
|
31737
31947
|
const sortItems = sortable ? [
|
|
31738
31948
|
{
|
|
@@ -31813,25 +32023,22 @@ function defaultGetColumnMenuItems(_items, params) {
|
|
|
31813
32023
|
const colItems = [];
|
|
31814
32024
|
const computed = getComputed();
|
|
31815
32025
|
computed.computedColumnsMapInInitialOrder.forEach((col, id) => {
|
|
31816
|
-
const label = getColumnLabel(col
|
|
32026
|
+
const label = binder.getColumnLabel(col);
|
|
31817
32027
|
colItems.push({
|
|
31818
32028
|
key: id,
|
|
31819
32029
|
label,
|
|
31820
|
-
check:
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
checked
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
api.
|
|
31829
|
-
|
|
31830
|
-
api.realignColumnContextMenu();
|
|
31831
|
-
});
|
|
31832
|
-
}
|
|
32030
|
+
check: binder.renderCheckBox({
|
|
32031
|
+
key: col.id,
|
|
32032
|
+
disabled: col.computedVisible && api.getVisibleColumnsCount() === 1,
|
|
32033
|
+
checked: col.computedVisible,
|
|
32034
|
+
onChange: (checked) => {
|
|
32035
|
+
const visible = !!checked;
|
|
32036
|
+
api.setVisibilityForColumn(col.id, visible);
|
|
32037
|
+
requestAnimationFrame(() => {
|
|
32038
|
+
api.realignColumnContextMenu();
|
|
32039
|
+
});
|
|
31833
32040
|
}
|
|
31834
|
-
)
|
|
32041
|
+
})
|
|
31835
32042
|
});
|
|
31836
32043
|
});
|
|
31837
32044
|
return {
|
|
@@ -31856,21 +32063,18 @@ function defaultGetColumnMenuItems(_items, params) {
|
|
|
31856
32063
|
if (col.groupByForColumn) {
|
|
31857
32064
|
return;
|
|
31858
32065
|
}
|
|
31859
|
-
const label = getColumnLabel(col
|
|
32066
|
+
const label = binder.getColumnLabel(col);
|
|
31860
32067
|
colItems.push({
|
|
31861
32068
|
key: id,
|
|
31862
32069
|
label,
|
|
31863
|
-
check:
|
|
31864
|
-
|
|
31865
|
-
|
|
31866
|
-
|
|
31867
|
-
|
|
31868
|
-
|
|
31869
|
-
onChange: () => {
|
|
31870
|
-
dataSourceApi.toggleGroupByField(col.field);
|
|
31871
|
-
}
|
|
32070
|
+
check: binder.renderCheckBox({
|
|
32071
|
+
key: col.id,
|
|
32072
|
+
disabled: !col.computedGroupable,
|
|
32073
|
+
checked: col.computedGroupedBy,
|
|
32074
|
+
onChange: () => {
|
|
32075
|
+
dataSourceApi.toggleGroupByField(col.field);
|
|
31872
32076
|
}
|
|
31873
|
-
)
|
|
32077
|
+
})
|
|
31874
32078
|
});
|
|
31875
32079
|
});
|
|
31876
32080
|
return {
|
|
@@ -31886,15 +32090,12 @@ function defaultGetColumnMenuItems(_items, params) {
|
|
|
31886
32090
|
}
|
|
31887
32091
|
].filter((x) => !!x);
|
|
31888
32092
|
}
|
|
31889
|
-
|
|
31890
|
-
// src/components/InfiniteTable/utils/getMenuForColumn.tsx
|
|
31891
|
-
function getMenuForColumn(columnId, context, onHideIntent) {
|
|
32093
|
+
function getColumnMenuProps(columnId, context, onHideIntent, getDefaultItems) {
|
|
31892
32094
|
if (columnId == null) {
|
|
31893
32095
|
return null;
|
|
31894
32096
|
}
|
|
31895
32097
|
const { getComputed, getState } = context;
|
|
31896
|
-
const {
|
|
31897
|
-
const MenuCmp = components2?.Menu ?? Menu;
|
|
32098
|
+
const { getColumnMenuItems } = getState();
|
|
31898
32099
|
const column = getComputed().computedColumnsMap.get(columnId);
|
|
31899
32100
|
if (!column) {
|
|
31900
32101
|
return null;
|
|
@@ -31904,79 +32105,257 @@ function getMenuForColumn(columnId, context, onHideIntent) {
|
|
|
31904
32105
|
columnApi: getColumnApiForColumn(column.id, context),
|
|
31905
32106
|
...context
|
|
31906
32107
|
};
|
|
31907
|
-
const defaultItems =
|
|
32108
|
+
const defaultItems = getDefaultItems(param);
|
|
31908
32109
|
const items = getColumnMenuItems ? getColumnMenuItems(defaultItems, param) : defaultItems;
|
|
31909
|
-
const onRootMouseDown = (event) => {
|
|
31910
|
-
event.__insideMenu = true;
|
|
31911
|
-
};
|
|
31912
|
-
const onHide = (state) => {
|
|
31913
|
-
state.domRef.current?.parentNode?.removeEventListener(
|
|
31914
|
-
"mousedown",
|
|
31915
|
-
onRootMouseDown
|
|
31916
|
-
);
|
|
31917
|
-
};
|
|
31918
32110
|
if (!items || !items.length) {
|
|
31919
32111
|
return null;
|
|
31920
32112
|
}
|
|
31921
|
-
return
|
|
31922
|
-
|
|
31923
|
-
|
|
31924
|
-
|
|
31925
|
-
|
|
31926
|
-
onShow: (state) => {
|
|
31927
|
-
state.domRef.current?.parentNode?.addEventListener(
|
|
31928
|
-
"mousedown",
|
|
31929
|
-
onRootMouseDown
|
|
31930
|
-
);
|
|
31931
|
-
},
|
|
31932
|
-
onHide,
|
|
31933
|
-
onHideIntent: (state) => {
|
|
31934
|
-
onHide(state);
|
|
31935
|
-
onHideIntent?.();
|
|
31936
|
-
}
|
|
31937
|
-
}
|
|
31938
|
-
);
|
|
31939
|
-
}
|
|
31940
|
-
|
|
31941
|
-
// src/components/InfiniteTable/utils/menuOverlayTargets.ts
|
|
31942
|
-
function resolveMenuElement(element) {
|
|
31943
|
-
return typeof element === "function" ? element() : element;
|
|
31944
|
-
}
|
|
31945
|
-
function getMenuConstrainTo(state) {
|
|
31946
|
-
return resolveMenuElement(state.menuConstrainTo) ?? state.domRef.current;
|
|
32113
|
+
return {
|
|
32114
|
+
autoFocus: true,
|
|
32115
|
+
items,
|
|
32116
|
+
...getMenuVisibilityProps(onHideIntent)
|
|
32117
|
+
};
|
|
31947
32118
|
}
|
|
31948
|
-
function
|
|
31949
|
-
if (
|
|
31950
|
-
return
|
|
32119
|
+
function getFilterOperatorMenuProps(columnId, context, onHideIntent, binder) {
|
|
32120
|
+
if (columnId == null) {
|
|
32121
|
+
return null;
|
|
31951
32122
|
}
|
|
31952
|
-
|
|
31953
|
-
|
|
31954
|
-
|
|
31955
|
-
|
|
31956
|
-
|
|
31957
|
-
|
|
31958
|
-
|
|
32123
|
+
const {
|
|
32124
|
+
getComputed,
|
|
32125
|
+
getState,
|
|
32126
|
+
getDataSourceState,
|
|
32127
|
+
actions,
|
|
32128
|
+
dataSourceApi,
|
|
32129
|
+
dataSourceActions,
|
|
32130
|
+
api
|
|
32131
|
+
} = context;
|
|
32132
|
+
const { getFilterOperatorMenuItems } = getState();
|
|
32133
|
+
const column = getComputed().computedColumnsMap.get(columnId);
|
|
32134
|
+
if (!column) {
|
|
32135
|
+
return null;
|
|
32136
|
+
}
|
|
32137
|
+
const { filterTypes } = getDataSourceState();
|
|
32138
|
+
const columnFilterType = filterTypes[column.computedFilterType];
|
|
32139
|
+
if (!columnFilterType) {
|
|
32140
|
+
return null;
|
|
32141
|
+
}
|
|
32142
|
+
const operatorItems = columnFilterType.operators.map((operator) => {
|
|
32143
|
+
const key = operator.name;
|
|
32144
|
+
const checked = column.computedFilterValue ? column.computedFilterValue.filter.operator === key : key === columnFilterType.defaultOperator;
|
|
31959
32145
|
return {
|
|
31960
|
-
|
|
31961
|
-
|
|
32146
|
+
key,
|
|
32147
|
+
icon: binder.renderOperatorIcon(operator),
|
|
32148
|
+
label: binder.renderOperatorLabel(operator.label ?? operator.name),
|
|
32149
|
+
onAction: () => {
|
|
32150
|
+
api.setColumnFilterOperator(columnId, key);
|
|
32151
|
+
},
|
|
32152
|
+
checked: checked ? binder.renderDoneIcon() : null
|
|
31962
32153
|
};
|
|
31963
32154
|
});
|
|
31964
|
-
const
|
|
32155
|
+
const firstItems = [
|
|
32156
|
+
{
|
|
32157
|
+
key: "close",
|
|
32158
|
+
label: "Close Menu",
|
|
32159
|
+
icon: null,
|
|
32160
|
+
onAction: () => {
|
|
32161
|
+
api.hideFilterOperatorMenu();
|
|
32162
|
+
}
|
|
32163
|
+
},
|
|
32164
|
+
{
|
|
32165
|
+
key: "reset",
|
|
32166
|
+
label: "Reset",
|
|
32167
|
+
icon: binder.renderClearIcon(),
|
|
32168
|
+
disabled: !column.computedFiltered,
|
|
32169
|
+
onAction: () => {
|
|
32170
|
+
api.clearColumnFilter(columnId);
|
|
32171
|
+
}
|
|
32172
|
+
},
|
|
32173
|
+
"-"
|
|
32174
|
+
];
|
|
32175
|
+
const defaultItems = [...firstItems, ...operatorItems];
|
|
32176
|
+
const param = {
|
|
32177
|
+
column,
|
|
32178
|
+
api,
|
|
32179
|
+
getState,
|
|
32180
|
+
getDataSourceState,
|
|
32181
|
+
getComputed,
|
|
32182
|
+
actions,
|
|
32183
|
+
dataSourceApi,
|
|
32184
|
+
dataSourceActions,
|
|
32185
|
+
columnFilterValue: column.computedFilterValue,
|
|
32186
|
+
filterTypes
|
|
32187
|
+
};
|
|
32188
|
+
const items = getFilterOperatorMenuItems ? getFilterOperatorMenuItems(defaultItems, param) : defaultItems;
|
|
32189
|
+
return {
|
|
32190
|
+
autoFocus: true,
|
|
32191
|
+
columns: [
|
|
32192
|
+
{
|
|
32193
|
+
name: "icon"
|
|
32194
|
+
},
|
|
32195
|
+
{ name: "label" },
|
|
32196
|
+
{ name: "checked" }
|
|
32197
|
+
],
|
|
32198
|
+
items,
|
|
32199
|
+
...getMenuVisibilityProps(onHideIntent)
|
|
32200
|
+
};
|
|
32201
|
+
}
|
|
32202
|
+
function getContextMenuContent(menuDefinition, menuDefaultProps, binder) {
|
|
32203
|
+
const preventDefault = menuDefinition instanceof Promise ? true : Array.isArray(menuDefinition) ? true : !!(menuDefinition && Array.isArray(menuDefinition.items));
|
|
32204
|
+
if (menuDefinition instanceof Promise) {
|
|
31965
32205
|
return {
|
|
31966
|
-
|
|
32206
|
+
menu: binder.renderLazyMenu(menuDefinition, menuDefaultProps),
|
|
32207
|
+
preventDefault
|
|
31967
32208
|
};
|
|
31968
|
-
}
|
|
31969
|
-
const
|
|
31970
|
-
|
|
31971
|
-
|
|
31972
|
-
|
|
32209
|
+
}
|
|
32210
|
+
const { items, columns } = getMenuItemsAndColumns(menuDefinition);
|
|
32211
|
+
if (!items || !items.length) {
|
|
32212
|
+
return { menu: null, preventDefault: Array.isArray(items) };
|
|
32213
|
+
}
|
|
32214
|
+
return {
|
|
32215
|
+
preventDefault,
|
|
32216
|
+
menu: binder.renderMenu({ ...menuDefaultProps, columns, items })
|
|
32217
|
+
};
|
|
32218
|
+
}
|
|
32219
|
+
function getCellContextMenuContent(cellLocation, context, onHideIntent, binder) {
|
|
32220
|
+
const { columnId, rowIndex, event } = cellLocation;
|
|
32221
|
+
const { getComputed, getState } = context;
|
|
32222
|
+
const { getCellContextMenuItems } = getState();
|
|
32223
|
+
const { computedColumnsMap } = getComputed();
|
|
32224
|
+
const column = computedColumnsMap.get(columnId);
|
|
32225
|
+
const cellContext = {
|
|
32226
|
+
...getCellContext({
|
|
32227
|
+
...context,
|
|
32228
|
+
rowIndex,
|
|
32229
|
+
columnId: column.id
|
|
32230
|
+
}),
|
|
32231
|
+
event
|
|
32232
|
+
};
|
|
32233
|
+
if (!column || !getCellContextMenuItems) {
|
|
32234
|
+
return {
|
|
32235
|
+
cellContext,
|
|
32236
|
+
menu: null,
|
|
32237
|
+
preventDefault: false
|
|
32238
|
+
};
|
|
32239
|
+
}
|
|
32240
|
+
const menuDefaultProps = getMenuDefaultProps({
|
|
32241
|
+
onHideIntent
|
|
32242
|
+
});
|
|
32243
|
+
const menuDefinition = getCellContextMenuItems(cellContext, context);
|
|
32244
|
+
return {
|
|
32245
|
+
cellContext,
|
|
32246
|
+
...getContextMenuContent(menuDefinition, menuDefaultProps, binder)
|
|
32247
|
+
};
|
|
32248
|
+
}
|
|
32249
|
+
function getTableContextMenuContent(menuLocation, context, onHideIntent, binder) {
|
|
32250
|
+
const { getState, getComputed } = context;
|
|
32251
|
+
const { getContextMenuItems } = getState();
|
|
32252
|
+
const { computedColumnsMap } = getComputed();
|
|
32253
|
+
const column = menuLocation.columnId ? computedColumnsMap.get(menuLocation.columnId) : void 0;
|
|
32254
|
+
const cellContext = column ? {
|
|
32255
|
+
...menuLocation,
|
|
32256
|
+
...getCellContext({
|
|
32257
|
+
...context,
|
|
32258
|
+
rowIndex: menuLocation.rowIndex,
|
|
32259
|
+
columnId: column.id
|
|
32260
|
+
})
|
|
32261
|
+
} : menuLocation;
|
|
32262
|
+
if (!getContextMenuItems) {
|
|
32263
|
+
return { cellContext, menu: null, preventDefault: false };
|
|
32264
|
+
}
|
|
32265
|
+
const menuDefaultProps = getMenuDefaultProps({
|
|
32266
|
+
onHideIntent
|
|
32267
|
+
});
|
|
32268
|
+
const menuDefinition = getContextMenuItems(cellContext, context);
|
|
32269
|
+
return {
|
|
32270
|
+
cellContext,
|
|
32271
|
+
...getContextMenuContent(menuDefinition, menuDefaultProps, binder)
|
|
32272
|
+
};
|
|
32273
|
+
}
|
|
32274
|
+
|
|
32275
|
+
// src/components/InfiniteTable/utils/defaultGetColumnMenuItems.tsx
|
|
32276
|
+
function defaultGetColumnMenuItems(_items, params) {
|
|
32277
|
+
const CheckBoxCmp = params.getState().components?.CheckBox || InfiniteCheckBox;
|
|
32278
|
+
return getDefaultColumnMenuItems(params, {
|
|
32279
|
+
renderCheckBox: ({ key, ...props }) => /* @__PURE__ */ React63.createElement(CheckBoxCmp, { key, ...props }),
|
|
32280
|
+
getColumnLabel: (col) => getColumnLabel(col, params, "column-menu")
|
|
32281
|
+
});
|
|
32282
|
+
}
|
|
32283
|
+
|
|
32284
|
+
// src/components/InfiniteTable/utils/getMenuForColumn.tsx
|
|
32285
|
+
function getMenuForColumn(columnId, context, onHideIntent) {
|
|
32286
|
+
const MenuCmp = context.getState().components?.Menu ?? Menu;
|
|
32287
|
+
const menuProps = getColumnMenuProps(
|
|
32288
|
+
columnId,
|
|
32289
|
+
context,
|
|
32290
|
+
onHideIntent,
|
|
32291
|
+
(param) => defaultGetColumnMenuItems([], param)
|
|
31973
32292
|
);
|
|
32293
|
+
return menuProps ? /* @__PURE__ */ React64.createElement(MenuCmp, { ...menuProps }) : null;
|
|
31974
32294
|
}
|
|
31975
32295
|
|
|
31976
|
-
// src/components/InfiniteTable/
|
|
31977
|
-
|
|
32296
|
+
// src/components/InfiniteTable/utils/menuOverlayTargets.ts
|
|
32297
|
+
function resolveMenuElement(element) {
|
|
32298
|
+
return typeof element === "function" ? element() : element;
|
|
32299
|
+
}
|
|
32300
|
+
function getMenuConstrainTo(state) {
|
|
32301
|
+
return resolveMenuElement(state.menuConstrainTo) ?? state.domRef.current;
|
|
32302
|
+
}
|
|
32303
|
+
function getMenuPortalContainer(getState, menuPortalContainer, defaultContainer) {
|
|
32304
|
+
if (!menuPortalContainer) {
|
|
32305
|
+
return defaultContainer || false;
|
|
32306
|
+
}
|
|
32307
|
+
return () => resolveMenuElement(menuPortalContainer) ?? (defaultContainer || getState().portalDOMRef.current);
|
|
32308
|
+
}
|
|
32309
|
+
|
|
32310
|
+
// src/components/InfiniteTable/utils/menuOverlayShared.ts
|
|
32311
|
+
var CONTEXT_MENU_OFFSET = 5;
|
|
32312
|
+
var CONTEXT_MENU_ALIGN_POSITIONS = [
|
|
32313
|
+
["TopLeft", "BottomLeft"],
|
|
32314
|
+
["TopRight", "BottomRight"],
|
|
32315
|
+
["BottomLeft", "BottomLeft"],
|
|
32316
|
+
["BottomRight", "BottomRight"],
|
|
32317
|
+
["TopCenter", "TopLeft"],
|
|
32318
|
+
["BottomCenter", "TopLeft"],
|
|
32319
|
+
["CenterLeft", "TopLeft"],
|
|
32320
|
+
["CenterRight", "TopLeft"]
|
|
32321
|
+
];
|
|
32322
|
+
var FILTER_OPERATOR_MENU_OFFSET = 10;
|
|
32323
|
+
function closeMenuOnOutsideMouseDown(close) {
|
|
32324
|
+
function handleMouseDown(event) {
|
|
32325
|
+
if (event.__insideMenu !== true) {
|
|
32326
|
+
close();
|
|
32327
|
+
}
|
|
32328
|
+
}
|
|
32329
|
+
document.documentElement.addEventListener("mousedown", handleMouseDown);
|
|
32330
|
+
return () => {
|
|
32331
|
+
document.documentElement.removeEventListener("mousedown", handleMouseDown);
|
|
32332
|
+
};
|
|
32333
|
+
}
|
|
32334
|
+
function menuVisibilityEffect(visible, clearAll, hide) {
|
|
32335
|
+
if (visible) {
|
|
32336
|
+
return closeMenuOnOutsideMouseDown(() => {
|
|
32337
|
+
clearAll();
|
|
32338
|
+
hide();
|
|
32339
|
+
});
|
|
32340
|
+
}
|
|
32341
|
+
clearAll();
|
|
32342
|
+
return void 0;
|
|
32343
|
+
}
|
|
32344
|
+
function getColumnMenuClickHandler(context) {
|
|
32345
|
+
const { getState, actions } = context;
|
|
32346
|
+
return (info) => {
|
|
32347
|
+
if (!info) {
|
|
32348
|
+
return;
|
|
32349
|
+
}
|
|
32350
|
+
getState().columnMenuTargetRef.current = info.target;
|
|
32351
|
+
actions.contextMenuVisibleFor = null;
|
|
32352
|
+
actions.cellContextMenuVisibleFor = null;
|
|
32353
|
+
actions.filterOperatorMenuVisibleForColumnId = null;
|
|
32354
|
+
actions.columnMenuVisibleForColumnId = info.column.id;
|
|
32355
|
+
};
|
|
32356
|
+
}
|
|
31978
32357
|
function showMenuForColumn(options) {
|
|
31979
|
-
const { columnId, context, clearAll,
|
|
32358
|
+
const { columnId, context, clearAll, show } = options;
|
|
31980
32359
|
const { getState, actions } = context;
|
|
31981
32360
|
const { columnMenuTargetRef, domRef } = getState();
|
|
31982
32361
|
function onHideIntent() {
|
|
@@ -31991,7 +32370,7 @@ function showMenuForColumn(options) {
|
|
|
31991
32370
|
}
|
|
31992
32371
|
}
|
|
31993
32372
|
if (!target) {
|
|
31994
|
-
const iconSelector = `[
|
|
32373
|
+
const iconSelector = `[data-column-id="${columnId}"] ${menuIconSelector}`;
|
|
31995
32374
|
target = getState().domRef.current.querySelector(
|
|
31996
32375
|
iconSelector
|
|
31997
32376
|
);
|
|
@@ -32001,7 +32380,7 @@ function showMenuForColumn(options) {
|
|
|
32001
32380
|
return;
|
|
32002
32381
|
}
|
|
32003
32382
|
columnMenuTargetRef.current = null;
|
|
32004
|
-
|
|
32383
|
+
show(onHideIntent, {
|
|
32005
32384
|
constrainTo: getMenuConstrainTo(getState()),
|
|
32006
32385
|
id: "column-menu",
|
|
32007
32386
|
alignTo: target,
|
|
@@ -32011,17 +32390,180 @@ function showMenuForColumn(options) {
|
|
|
32011
32390
|
]
|
|
32012
32391
|
});
|
|
32013
32392
|
}
|
|
32393
|
+
function columnMenuVisibilityEffect(context, overlay) {
|
|
32394
|
+
const { getState, actions } = context;
|
|
32395
|
+
const { clearAll } = overlay;
|
|
32396
|
+
const { columnMenuVisibleForColumnId, columnMenuTargetRef } = getState();
|
|
32397
|
+
if (columnMenuVisibleForColumnId) {
|
|
32398
|
+
const cleanup = closeMenuOnOutsideMouseDown(() => {
|
|
32399
|
+
clearAll();
|
|
32400
|
+
actions.columnMenuVisibleForColumnId = null;
|
|
32401
|
+
});
|
|
32402
|
+
showMenuForColumn({
|
|
32403
|
+
columnId: columnMenuVisibleForColumnId,
|
|
32404
|
+
context,
|
|
32405
|
+
clearAll,
|
|
32406
|
+
show: (onHideIntent, params) => overlay.show(columnMenuVisibleForColumnId, onHideIntent, params)
|
|
32407
|
+
});
|
|
32408
|
+
return cleanup;
|
|
32409
|
+
}
|
|
32410
|
+
columnMenuTargetRef.current = null;
|
|
32411
|
+
clearAll();
|
|
32412
|
+
return void 0;
|
|
32413
|
+
}
|
|
32414
|
+
function getContextMenuRect(event) {
|
|
32415
|
+
const point = {
|
|
32416
|
+
top: event.clientY,
|
|
32417
|
+
left: event.clientX
|
|
32418
|
+
};
|
|
32419
|
+
const rect = Rectangle.fromPoint(point);
|
|
32420
|
+
rect.width += CONTEXT_MENU_OFFSET;
|
|
32421
|
+
rect.height += CONTEXT_MENU_OFFSET;
|
|
32422
|
+
return { point, rect };
|
|
32423
|
+
}
|
|
32424
|
+
function getCellContextMenuHandler(context, overlay) {
|
|
32425
|
+
const { actions, getState, getDataSourceState } = context;
|
|
32426
|
+
const { clearAll } = overlay;
|
|
32427
|
+
return (info) => {
|
|
32428
|
+
if (!info) {
|
|
32429
|
+
return;
|
|
32430
|
+
}
|
|
32431
|
+
const { event } = info;
|
|
32432
|
+
function onHideIntent() {
|
|
32433
|
+
clearAll();
|
|
32434
|
+
actions.cellContextMenuVisibleFor = null;
|
|
32435
|
+
}
|
|
32436
|
+
const content = overlay.getContent(info, onHideIntent);
|
|
32437
|
+
const { cellContext, preventDefault } = content;
|
|
32438
|
+
const { rect } = getContextMenuRect(event);
|
|
32439
|
+
overlay.show(content, {
|
|
32440
|
+
constrainTo: getMenuConstrainTo(getState()),
|
|
32441
|
+
id: "cell-context-menu",
|
|
32442
|
+
alignTo: rect,
|
|
32443
|
+
alignPosition: CONTEXT_MENU_ALIGN_POSITIONS
|
|
32444
|
+
});
|
|
32445
|
+
if (preventDefault) {
|
|
32446
|
+
event.preventDefault();
|
|
32447
|
+
}
|
|
32448
|
+
actions.cellContextMenuVisibleFor = {
|
|
32449
|
+
columnId: info.columnId,
|
|
32450
|
+
rowId: info.rowId,
|
|
32451
|
+
rowIndex: info.rowIndex,
|
|
32452
|
+
colIndex: info.colIndex
|
|
32453
|
+
};
|
|
32454
|
+
const { onCellContextMenu } = getState();
|
|
32455
|
+
if (onCellContextMenu) {
|
|
32456
|
+
onCellContextMenu(
|
|
32457
|
+
{
|
|
32458
|
+
...cellContext,
|
|
32459
|
+
getState,
|
|
32460
|
+
getDataSourceState
|
|
32461
|
+
},
|
|
32462
|
+
event
|
|
32463
|
+
);
|
|
32464
|
+
}
|
|
32465
|
+
};
|
|
32466
|
+
}
|
|
32467
|
+
function getTableContextMenuHandler(context, overlay) {
|
|
32468
|
+
const { actions, getState } = context;
|
|
32469
|
+
const { clearAll } = overlay;
|
|
32470
|
+
return (info) => {
|
|
32471
|
+
if (!info) {
|
|
32472
|
+
return;
|
|
32473
|
+
}
|
|
32474
|
+
const { event } = info;
|
|
32475
|
+
function onHideIntent() {
|
|
32476
|
+
clearAll();
|
|
32477
|
+
actions.contextMenuVisibleFor = null;
|
|
32478
|
+
}
|
|
32479
|
+
const content = overlay.getContent(info, onHideIntent);
|
|
32480
|
+
const { cellContext, preventDefault } = content;
|
|
32481
|
+
const { point, rect } = getContextMenuRect(event);
|
|
32482
|
+
overlay.show(content, {
|
|
32483
|
+
constrainTo: getMenuConstrainTo(getState()),
|
|
32484
|
+
id: "table-context-menu",
|
|
32485
|
+
alignTo: rect,
|
|
32486
|
+
alignPosition: CONTEXT_MENU_ALIGN_POSITIONS
|
|
32487
|
+
});
|
|
32488
|
+
if (preventDefault) {
|
|
32489
|
+
event.preventDefault();
|
|
32490
|
+
}
|
|
32491
|
+
actions.contextMenuVisibleFor = {
|
|
32492
|
+
point,
|
|
32493
|
+
...info
|
|
32494
|
+
};
|
|
32495
|
+
const { onContextMenu } = getState();
|
|
32496
|
+
if (onContextMenu) {
|
|
32497
|
+
onContextMenu(
|
|
32498
|
+
{
|
|
32499
|
+
...context,
|
|
32500
|
+
...cellContext
|
|
32501
|
+
},
|
|
32502
|
+
event
|
|
32503
|
+
);
|
|
32504
|
+
}
|
|
32505
|
+
};
|
|
32506
|
+
}
|
|
32507
|
+
function getFilterOperatorMenuClickHandler(context, overlay) {
|
|
32508
|
+
const { getState, actions } = context;
|
|
32509
|
+
const { clearAll } = overlay;
|
|
32510
|
+
return (info) => {
|
|
32511
|
+
if (!info) {
|
|
32512
|
+
return;
|
|
32513
|
+
}
|
|
32514
|
+
const { target, column } = info;
|
|
32515
|
+
function onHideIntent() {
|
|
32516
|
+
clearAll();
|
|
32517
|
+
actions.filterOperatorMenuVisibleForColumnId = null;
|
|
32518
|
+
}
|
|
32519
|
+
const alignTo = target?.parentElement || target;
|
|
32520
|
+
const rect = Rectangle.from(alignTo.getBoundingClientRect());
|
|
32521
|
+
rect.top -= FILTER_OPERATOR_MENU_OFFSET;
|
|
32522
|
+
rect.left -= FILTER_OPERATOR_MENU_OFFSET;
|
|
32523
|
+
rect.width += 2 * FILTER_OPERATOR_MENU_OFFSET;
|
|
32524
|
+
rect.height += 2 * FILTER_OPERATOR_MENU_OFFSET;
|
|
32525
|
+
overlay.show(column.id, onHideIntent, {
|
|
32526
|
+
constrainTo: getMenuConstrainTo(getState()),
|
|
32527
|
+
id: "filter-operator-menu",
|
|
32528
|
+
alignTo: rect,
|
|
32529
|
+
alignPosition: [
|
|
32530
|
+
["TopLeft", "BottomLeft"],
|
|
32531
|
+
["TopRight", "BottomRight"]
|
|
32532
|
+
]
|
|
32533
|
+
});
|
|
32534
|
+
actions.contextMenuVisibleFor = null;
|
|
32535
|
+
actions.cellContextMenuVisibleFor = null;
|
|
32536
|
+
actions.columnMenuVisibleForColumnId = null;
|
|
32537
|
+
actions.filterOperatorMenuVisibleForColumnId = column.id;
|
|
32538
|
+
};
|
|
32539
|
+
}
|
|
32540
|
+
|
|
32541
|
+
// src/components/InfiniteTable/hooks/useMenuPortalContainer.ts
|
|
32542
|
+
var import_react59 = require("react");
|
|
32543
|
+
function useMenuPortalContainer() {
|
|
32544
|
+
const { getState, menuPortalContainer } = useInfiniteTableSelector((ctx) => {
|
|
32545
|
+
return {
|
|
32546
|
+
getState: ctx.getState,
|
|
32547
|
+
menuPortalContainer: ctx.state.menuPortalContainer
|
|
32548
|
+
};
|
|
32549
|
+
});
|
|
32550
|
+
const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
|
|
32551
|
+
return {
|
|
32552
|
+
portalDOMRef: ctx.getMasterState().portalDOMRef
|
|
32553
|
+
};
|
|
32554
|
+
}) || {};
|
|
32555
|
+
const defaultContainer = portalDOMRef?.current;
|
|
32556
|
+
return (0, import_react59.useMemo)(
|
|
32557
|
+
() => getMenuPortalContainer(getState, menuPortalContainer, defaultContainer),
|
|
32558
|
+
[getState, menuPortalContainer, defaultContainer]
|
|
32559
|
+
);
|
|
32560
|
+
}
|
|
32561
|
+
|
|
32562
|
+
// src/components/InfiniteTable/hooks/useColumnMenu.ts
|
|
32014
32563
|
function useColumnMenu() {
|
|
32015
32564
|
const context = useInfiniteTableStableContext();
|
|
32016
|
-
const {
|
|
32017
|
-
getState,
|
|
32018
|
-
actions,
|
|
32019
|
-
columnMenuVisibleForColumnId,
|
|
32020
|
-
columnMenuVisibleKey
|
|
32021
|
-
} = useInfiniteTableSelector((ctx) => {
|
|
32565
|
+
const { columnMenuVisibleForColumnId, columnMenuVisibleKey } = useInfiniteTableSelector((ctx) => {
|
|
32022
32566
|
return {
|
|
32023
|
-
getState: ctx.getState,
|
|
32024
|
-
actions: ctx.actions,
|
|
32025
32567
|
columnMenuVisibleForColumnId: ctx.state.columnMenuVisibleForColumnId,
|
|
32026
32568
|
columnMenuVisibleKey: ctx.state.columnMenuVisibleKey
|
|
32027
32569
|
};
|
|
@@ -32034,47 +32576,16 @@ function useColumnMenu() {
|
|
|
32034
32576
|
portalContainer: useMenuPortalContainer()
|
|
32035
32577
|
});
|
|
32036
32578
|
(0, import_react60.useEffect)(() => {
|
|
32037
|
-
|
|
32038
|
-
return state.onColumnMenuClick.onChange((info) => {
|
|
32039
|
-
if (!info) {
|
|
32040
|
-
return;
|
|
32041
|
-
}
|
|
32042
|
-
state.columnMenuTargetRef.current = info.target;
|
|
32043
|
-
actions.contextMenuVisibleFor = null;
|
|
32044
|
-
actions.cellContextMenuVisibleFor = null;
|
|
32045
|
-
actions.filterOperatorMenuVisibleForColumnId = null;
|
|
32046
|
-
actions.columnMenuVisibleForColumnId = info.column.id;
|
|
32047
|
-
});
|
|
32579
|
+
return context.getState().onColumnMenuClick.onChange(getColumnMenuClickHandler(context));
|
|
32048
32580
|
}, []);
|
|
32049
32581
|
(0, import_react60.useEffect)(() => {
|
|
32050
|
-
|
|
32051
|
-
|
|
32052
|
-
|
|
32053
|
-
|
|
32054
|
-
|
|
32055
|
-
|
|
32056
|
-
|
|
32057
|
-
};
|
|
32058
|
-
var handleMouseDown = handleMouseDown2;
|
|
32059
|
-
document.documentElement.addEventListener("mousedown", handleMouseDown2);
|
|
32060
|
-
showMenuForColumn({
|
|
32061
|
-
columnId: columnMenuVisibleForColumnId2,
|
|
32062
|
-
context,
|
|
32063
|
-
clearAll,
|
|
32064
|
-
showOverlay
|
|
32065
|
-
});
|
|
32066
|
-
return () => {
|
|
32067
|
-
document.documentElement.removeEventListener(
|
|
32068
|
-
"mousedown",
|
|
32069
|
-
handleMouseDown2
|
|
32070
|
-
);
|
|
32071
|
-
};
|
|
32072
|
-
} else {
|
|
32073
|
-
columnMenuTargetRef.current = null;
|
|
32074
|
-
clearAll();
|
|
32075
|
-
}
|
|
32076
|
-
return () => {
|
|
32077
|
-
};
|
|
32582
|
+
return columnMenuVisibilityEffect(context, {
|
|
32583
|
+
clearAll,
|
|
32584
|
+
show: (columnId, onHideIntent, params) => showOverlay(
|
|
32585
|
+
() => getMenuForColumn(columnId, context, onHideIntent),
|
|
32586
|
+
params
|
|
32587
|
+
)
|
|
32588
|
+
});
|
|
32078
32589
|
}, [columnMenuVisibleForColumnId, columnMenuVisibleKey]);
|
|
32079
32590
|
return { menuPortal };
|
|
32080
32591
|
}
|
|
@@ -32257,149 +32768,59 @@ function useOnEditPersisted() {
|
|
|
32257
32768
|
};
|
|
32258
32769
|
if (persisted instanceof Error) {
|
|
32259
32770
|
onEditPersistError?.({ ...params, error: persisted });
|
|
32260
|
-
} else {
|
|
32261
|
-
onEditPersistSuccess?.(params);
|
|
32262
|
-
}
|
|
32263
|
-
}
|
|
32264
|
-
}, [persisted]);
|
|
32265
|
-
}
|
|
32266
|
-
function useEditingCallbackProps() {
|
|
32267
|
-
useOnEditCancelled();
|
|
32268
|
-
useOnEditRejected();
|
|
32269
|
-
useOnEditAccepted();
|
|
32270
|
-
useOnEditPersisted();
|
|
32271
|
-
useFocusOnEditStop();
|
|
32272
|
-
}
|
|
32273
|
-
|
|
32274
|
-
// src/components/InfiniteTable/hooks/useColumnFilterOperatorMenu.ts
|
|
32275
|
-
var import_react63 = require("react");
|
|
32276
|
-
|
|
32277
|
-
// src/components/InfiniteTable/utils/getFilterOperatorMenuForColumn.tsx
|
|
32278
|
-
var React68 = __toESM(require("react"));
|
|
32279
|
-
|
|
32280
|
-
// src/components/InfiniteTable/components/icons/ClearIcon.tsx
|
|
32281
|
-
var React66 = __toESM(require("react"));
|
|
32282
|
-
var ClearIcon = (props) => {
|
|
32283
|
-
return /* @__PURE__ */ React66.createElement(Icon, { ...props, icon: "clear" }, /* @__PURE__ */ React66.createElement("path", { d: iconPaths.clear[0] }));
|
|
32284
|
-
};
|
|
32285
|
-
|
|
32286
|
-
// src/components/InfiniteTable/components/icons/DoneIcon.tsx
|
|
32287
|
-
var React67 = __toESM(require("react"));
|
|
32288
|
-
var DoneIcon = (props) => {
|
|
32289
|
-
return /* @__PURE__ */ React67.createElement(Icon, { ...props, icon: "done" }, /* @__PURE__ */ React67.createElement("path", { d: iconPaths.done[0] }));
|
|
32290
|
-
};
|
|
32291
|
-
|
|
32292
|
-
// src/components/InfiniteTable/utils/getFilterOperatorMenuForColumn.tsx
|
|
32293
|
-
function getFilterOperatorMenuForColumn(columnId, context, onHideIntent) {
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
getState,
|
|
32300
|
-
getDataSourceState,
|
|
32301
|
-
actions,
|
|
32302
|
-
dataSourceApi,
|
|
32303
|
-
dataSourceActions,
|
|
32304
|
-
api
|
|
32305
|
-
} = context;
|
|
32306
|
-
const { components: components2, getFilterOperatorMenuItems } = getState();
|
|
32307
|
-
const MenuCmp = components2?.Menu ?? Menu;
|
|
32308
|
-
const column = getComputed().computedColumnsMap.get(columnId);
|
|
32309
|
-
if (!column) {
|
|
32310
|
-
return null;
|
|
32311
|
-
}
|
|
32312
|
-
const onRootMouseDown = (event) => {
|
|
32313
|
-
event.__insideMenu = true;
|
|
32314
|
-
};
|
|
32315
|
-
const onHide = (state) => {
|
|
32316
|
-
state.domRef.current?.parentNode?.removeEventListener(
|
|
32317
|
-
"mousedown",
|
|
32318
|
-
onRootMouseDown
|
|
32319
|
-
);
|
|
32320
|
-
};
|
|
32321
|
-
const { filterTypes } = getDataSourceState();
|
|
32322
|
-
const columnFilterType = filterTypes[column.computedFilterType];
|
|
32323
|
-
if (!columnFilterType) {
|
|
32324
|
-
return null;
|
|
32325
|
-
}
|
|
32326
|
-
const operatorItems = columnFilterType.operators.map((operator) => {
|
|
32327
|
-
const key = operator.name;
|
|
32328
|
-
const checked = column.computedFilterValue ? column.computedFilterValue.filter.operator === key : key === columnFilterType.defaultOperator;
|
|
32329
|
-
const IconCmp = operator.components?.Icon ?? FilterIcon;
|
|
32330
|
-
return {
|
|
32331
|
-
key,
|
|
32332
|
-
icon: /* @__PURE__ */ React68.createElement(IconCmp, null),
|
|
32333
|
-
label: /* @__PURE__ */ React68.createElement(React68.Fragment, null, operator.label ?? operator.name),
|
|
32334
|
-
onAction: () => {
|
|
32335
|
-
api.setColumnFilterOperator(columnId, key);
|
|
32336
|
-
},
|
|
32337
|
-
checked: checked ? /* @__PURE__ */ React68.createElement(DoneIcon, { size: 16 }) : null
|
|
32338
|
-
};
|
|
32339
|
-
});
|
|
32340
|
-
const firstItems = [
|
|
32341
|
-
{
|
|
32342
|
-
key: "close",
|
|
32343
|
-
label: "Close Menu",
|
|
32344
|
-
icon: null,
|
|
32345
|
-
onAction: () => {
|
|
32346
|
-
api.hideFilterOperatorMenu();
|
|
32347
|
-
}
|
|
32348
|
-
},
|
|
32349
|
-
{
|
|
32350
|
-
key: "reset",
|
|
32351
|
-
label: "Reset",
|
|
32352
|
-
icon: /* @__PURE__ */ React68.createElement(ClearIcon, null),
|
|
32353
|
-
disabled: !column.computedFiltered,
|
|
32354
|
-
onAction: () => {
|
|
32355
|
-
api.clearColumnFilter(columnId);
|
|
32356
|
-
}
|
|
32357
|
-
},
|
|
32358
|
-
"-"
|
|
32359
|
-
];
|
|
32360
|
-
const defaultItems = [...firstItems, ...operatorItems];
|
|
32361
|
-
const param = {
|
|
32362
|
-
column,
|
|
32363
|
-
api,
|
|
32364
|
-
getState,
|
|
32365
|
-
getDataSourceState,
|
|
32366
|
-
getComputed,
|
|
32367
|
-
actions,
|
|
32368
|
-
dataSourceApi,
|
|
32369
|
-
dataSourceActions,
|
|
32370
|
-
columnFilterValue: column.computedFilterValue,
|
|
32371
|
-
filterTypes
|
|
32372
|
-
};
|
|
32373
|
-
const items = getFilterOperatorMenuItems ? getFilterOperatorMenuItems(defaultItems, param) : defaultItems;
|
|
32374
|
-
return /* @__PURE__ */ React68.createElement(
|
|
32375
|
-
MenuCmp,
|
|
32771
|
+
} else {
|
|
32772
|
+
onEditPersistSuccess?.(params);
|
|
32773
|
+
}
|
|
32774
|
+
}
|
|
32775
|
+
}, [persisted]);
|
|
32776
|
+
}
|
|
32777
|
+
function useEditingCallbackProps() {
|
|
32778
|
+
useOnEditCancelled();
|
|
32779
|
+
useOnEditRejected();
|
|
32780
|
+
useOnEditAccepted();
|
|
32781
|
+
useOnEditPersisted();
|
|
32782
|
+
useFocusOnEditStop();
|
|
32783
|
+
}
|
|
32784
|
+
|
|
32785
|
+
// src/components/InfiniteTable/hooks/useColumnFilterOperatorMenu.ts
|
|
32786
|
+
var import_react63 = require("react");
|
|
32787
|
+
|
|
32788
|
+
// src/components/InfiniteTable/utils/getFilterOperatorMenuForColumn.tsx
|
|
32789
|
+
var React68 = __toESM(require("react"));
|
|
32790
|
+
|
|
32791
|
+
// src/components/InfiniteTable/components/icons/ClearIcon.tsx
|
|
32792
|
+
var React66 = __toESM(require("react"));
|
|
32793
|
+
var ClearIcon = (props) => {
|
|
32794
|
+
return /* @__PURE__ */ React66.createElement(Icon, { ...props, icon: "clear" }, /* @__PURE__ */ React66.createElement("path", { d: iconPaths.clear[0] }));
|
|
32795
|
+
};
|
|
32796
|
+
|
|
32797
|
+
// src/components/InfiniteTable/components/icons/DoneIcon.tsx
|
|
32798
|
+
var React67 = __toESM(require("react"));
|
|
32799
|
+
var DoneIcon = (props) => {
|
|
32800
|
+
return /* @__PURE__ */ React67.createElement(Icon, { ...props, icon: "done" }, /* @__PURE__ */ React67.createElement("path", { d: iconPaths.done[0] }));
|
|
32801
|
+
};
|
|
32802
|
+
|
|
32803
|
+
// src/components/InfiniteTable/utils/getFilterOperatorMenuForColumn.tsx
|
|
32804
|
+
function getFilterOperatorMenuForColumn(columnId, context, onHideIntent) {
|
|
32805
|
+
const MenuCmp = context.getState().components?.Menu ?? Menu;
|
|
32806
|
+
const menuProps = getFilterOperatorMenuProps(
|
|
32807
|
+
columnId,
|
|
32808
|
+
context,
|
|
32809
|
+
onHideIntent,
|
|
32376
32810
|
{
|
|
32377
|
-
|
|
32378
|
-
|
|
32379
|
-
|
|
32380
|
-
name: "icon"
|
|
32381
|
-
},
|
|
32382
|
-
{ name: "label" },
|
|
32383
|
-
{ name: "checked" }
|
|
32384
|
-
],
|
|
32385
|
-
items,
|
|
32386
|
-
onShow: (state) => {
|
|
32387
|
-
state.domRef.current?.parentNode?.addEventListener(
|
|
32388
|
-
"mousedown",
|
|
32389
|
-
onRootMouseDown
|
|
32390
|
-
);
|
|
32811
|
+
renderOperatorIcon: (operator) => {
|
|
32812
|
+
const IconCmp = operator.components?.Icon ?? FilterIcon;
|
|
32813
|
+
return /* @__PURE__ */ React68.createElement(IconCmp, null);
|
|
32391
32814
|
},
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
onHideIntent?.();
|
|
32396
|
-
}
|
|
32815
|
+
renderOperatorLabel: (label) => /* @__PURE__ */ React68.createElement(React68.Fragment, null, label),
|
|
32816
|
+
renderClearIcon: () => /* @__PURE__ */ React68.createElement(ClearIcon, null),
|
|
32817
|
+
renderDoneIcon: () => /* @__PURE__ */ React68.createElement(DoneIcon, { size: 16 })
|
|
32397
32818
|
}
|
|
32398
32819
|
);
|
|
32820
|
+
return menuProps ? /* @__PURE__ */ React68.createElement(MenuCmp, { ...menuProps }) : null;
|
|
32399
32821
|
}
|
|
32400
32822
|
|
|
32401
32823
|
// src/components/InfiniteTable/hooks/useColumnFilterOperatorMenu.ts
|
|
32402
|
-
var OFFSET2 = 10;
|
|
32403
32824
|
function useColumnFilterOperatorMenu() {
|
|
32404
32825
|
const stableContext = useInfiniteTableStableContext();
|
|
32405
32826
|
const { getState, actions } = stableContext;
|
|
@@ -32411,66 +32832,28 @@ function useColumnFilterOperatorMenu() {
|
|
|
32411
32832
|
portalContainer: useMenuPortalContainer()
|
|
32412
32833
|
});
|
|
32413
32834
|
(0, import_react63.useEffect)(() => {
|
|
32414
|
-
|
|
32415
|
-
|
|
32416
|
-
|
|
32417
|
-
|
|
32418
|
-
|
|
32419
|
-
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
|
|
32424
|
-
|
|
32425
|
-
|
|
32426
|
-
|
|
32427
|
-
rect.left -= OFFSET2;
|
|
32428
|
-
rect.width += 2 * OFFSET2;
|
|
32429
|
-
rect.height += 2 * OFFSET2;
|
|
32430
|
-
showOverlay(
|
|
32431
|
-
() => getFilterOperatorMenuForColumn(
|
|
32432
|
-
column.id,
|
|
32433
|
-
stableContext,
|
|
32434
|
-
onHideIntent
|
|
32435
|
-
),
|
|
32436
|
-
{
|
|
32437
|
-
constrainTo: getMenuConstrainTo(getState()),
|
|
32438
|
-
id: "filter-operator-menu",
|
|
32439
|
-
alignTo: rect,
|
|
32440
|
-
alignPosition: [
|
|
32441
|
-
["TopLeft", "BottomLeft"],
|
|
32442
|
-
["TopRight", "BottomRight"]
|
|
32443
|
-
]
|
|
32444
|
-
}
|
|
32445
|
-
);
|
|
32446
|
-
actions.contextMenuVisibleFor = null;
|
|
32447
|
-
actions.cellContextMenuVisibleFor = null;
|
|
32448
|
-
actions.columnMenuVisibleForColumnId = null;
|
|
32449
|
-
actions.filterOperatorMenuVisibleForColumnId = column.id;
|
|
32450
|
-
});
|
|
32835
|
+
return getState().onFilterOperatorMenuClick.onChange(
|
|
32836
|
+
getFilterOperatorMenuClickHandler(stableContext, {
|
|
32837
|
+
clearAll,
|
|
32838
|
+
show: (columnId, onHideIntent, params) => showOverlay(
|
|
32839
|
+
() => getFilterOperatorMenuForColumn(
|
|
32840
|
+
columnId,
|
|
32841
|
+
stableContext,
|
|
32842
|
+
onHideIntent
|
|
32843
|
+
),
|
|
32844
|
+
params
|
|
32845
|
+
)
|
|
32846
|
+
})
|
|
32847
|
+
);
|
|
32451
32848
|
}, []);
|
|
32452
32849
|
(0, import_react63.useEffect)(() => {
|
|
32453
|
-
|
|
32454
|
-
|
|
32455
|
-
|
|
32456
|
-
|
|
32457
|
-
|
|
32458
|
-
|
|
32459
|
-
|
|
32460
|
-
};
|
|
32461
|
-
var handleMouseDown = handleMouseDown2;
|
|
32462
|
-
document.documentElement.addEventListener("mousedown", handleMouseDown2);
|
|
32463
|
-
return () => {
|
|
32464
|
-
document.documentElement.removeEventListener(
|
|
32465
|
-
"mousedown",
|
|
32466
|
-
handleMouseDown2
|
|
32467
|
-
);
|
|
32468
|
-
};
|
|
32469
|
-
} else {
|
|
32470
|
-
clearAll();
|
|
32471
|
-
}
|
|
32472
|
-
return () => {
|
|
32473
|
-
};
|
|
32850
|
+
return menuVisibilityEffect(
|
|
32851
|
+
getState().filterOperatorMenuVisibleForColumnId,
|
|
32852
|
+
clearAll,
|
|
32853
|
+
() => {
|
|
32854
|
+
actions.filterOperatorMenuVisibleForColumnId = null;
|
|
32855
|
+
}
|
|
32856
|
+
);
|
|
32474
32857
|
}, [getState().filterOperatorMenuVisibleForColumnId]);
|
|
32475
32858
|
return { menuPortal };
|
|
32476
32859
|
}
|
|
@@ -32483,159 +32866,46 @@ var React70 = __toESM(require("react"));
|
|
|
32483
32866
|
|
|
32484
32867
|
// src/components/InfiniteTable/utils/contextMenuUtils.tsx
|
|
32485
32868
|
var React69 = __toESM(require("react"));
|
|
32486
|
-
|
|
32487
|
-
// src/components/InfiniteTable/utils/contextMenuUtilsShared.ts
|
|
32488
|
-
function getMenuItemsAndColumns(menuDefinition) {
|
|
32489
|
-
let items = menuDefinition ? Array.isArray(menuDefinition) ? menuDefinition : menuDefinition.items : null;
|
|
32490
|
-
const columns = menuDefinition && !Array.isArray(menuDefinition) ? menuDefinition.columns : void 0;
|
|
32491
|
-
return {
|
|
32492
|
-
items,
|
|
32493
|
-
columns
|
|
32494
|
-
};
|
|
32495
|
-
}
|
|
32496
|
-
function getMenuDefaultProps(config) {
|
|
32497
|
-
const onRootMouseDown = (event) => {
|
|
32498
|
-
event.__insideMenu = true;
|
|
32499
|
-
};
|
|
32500
|
-
const onHide = (state) => {
|
|
32501
|
-
state.domRef.current?.parentNode?.removeEventListener(
|
|
32502
|
-
"mousedown",
|
|
32503
|
-
onRootMouseDown
|
|
32504
|
-
);
|
|
32505
|
-
};
|
|
32506
|
-
const menuDefaultProps = {
|
|
32507
|
-
columns: [],
|
|
32508
|
-
items: [],
|
|
32509
|
-
autoFocus: true,
|
|
32510
|
-
onShow: (state) => {
|
|
32511
|
-
state.domRef.current?.parentNode?.addEventListener(
|
|
32512
|
-
"mousedown",
|
|
32513
|
-
onRootMouseDown
|
|
32514
|
-
);
|
|
32515
|
-
},
|
|
32516
|
-
onHide,
|
|
32517
|
-
onHideIntent: (state) => {
|
|
32518
|
-
onHide(state);
|
|
32519
|
-
config.onHideIntent?.();
|
|
32520
|
-
}
|
|
32521
|
-
};
|
|
32522
|
-
return menuDefaultProps;
|
|
32523
|
-
}
|
|
32524
|
-
|
|
32525
|
-
// src/components/InfiniteTable/utils/contextMenuUtils.tsx
|
|
32526
32869
|
function getLazyMenu(menuDefinition, menuDefaultProps, MenuCmp) {
|
|
32527
32870
|
if (!menuDefinition) {
|
|
32528
32871
|
return null;
|
|
32529
32872
|
}
|
|
32530
32873
|
const updater = buildSubscriptionCallback();
|
|
32531
32874
|
menuDefinition.then((menuDefinition2) => {
|
|
32532
|
-
const
|
|
32533
|
-
if (
|
|
32534
|
-
updater(
|
|
32535
|
-
/* @__PURE__ */ React69.createElement(MenuCmp, { ...menuDefaultProps, items: items || [], columns })
|
|
32536
|
-
);
|
|
32875
|
+
const menuProps = getLazyMenuProps(menuDefinition2, menuDefaultProps);
|
|
32876
|
+
if (menuProps) {
|
|
32877
|
+
updater(/* @__PURE__ */ React69.createElement(MenuCmp, { ...menuProps }));
|
|
32537
32878
|
}
|
|
32538
32879
|
});
|
|
32539
32880
|
return /* @__PURE__ */ React69.createElement(AvoidReactDiff, { updater });
|
|
32540
32881
|
}
|
|
32541
32882
|
|
|
32542
32883
|
// src/components/InfiniteTable/utils/getCellContextMenu.tsx
|
|
32543
|
-
function
|
|
32544
|
-
const
|
|
32545
|
-
const { getComputed, getState } = context;
|
|
32546
|
-
const { components: components2, getCellContextMenuItems } = getState();
|
|
32547
|
-
const MenuCmp = components2?.Menu ?? Menu;
|
|
32548
|
-
const { computedColumnsMap } = getComputed();
|
|
32549
|
-
const column = computedColumnsMap.get(columnId);
|
|
32550
|
-
const cellContext = {
|
|
32551
|
-
...getCellContext({
|
|
32552
|
-
...context,
|
|
32553
|
-
rowIndex,
|
|
32554
|
-
columnId: column.id
|
|
32555
|
-
}),
|
|
32556
|
-
event
|
|
32557
|
-
};
|
|
32558
|
-
if (!column || !getCellContextMenuItems) {
|
|
32559
|
-
return {
|
|
32560
|
-
cellContext,
|
|
32561
|
-
menu: null,
|
|
32562
|
-
preventDefault: false
|
|
32563
|
-
};
|
|
32564
|
-
}
|
|
32565
|
-
const menuDefaultProps = getMenuDefaultProps({
|
|
32566
|
-
onHideIntent
|
|
32567
|
-
});
|
|
32568
|
-
const menuDefinition = getCellContextMenuItems(cellContext, context);
|
|
32569
|
-
const preventDefault = menuDefinition instanceof Promise ? true : Array.isArray(menuDefinition) ? true : !!(menuDefinition && Array.isArray(menuDefinition.items));
|
|
32570
|
-
if (menuDefinition instanceof Promise) {
|
|
32571
|
-
return {
|
|
32572
|
-
cellContext,
|
|
32573
|
-
menu: getLazyMenu(menuDefinition, menuDefaultProps, MenuCmp),
|
|
32574
|
-
preventDefault
|
|
32575
|
-
};
|
|
32576
|
-
}
|
|
32577
|
-
const { items, columns } = getMenuItemsAndColumns(menuDefinition);
|
|
32578
|
-
if (!items || !items.length) {
|
|
32579
|
-
return { cellContext, menu: null, preventDefault: Array.isArray(items) };
|
|
32580
|
-
}
|
|
32884
|
+
function getContextMenuBinder(context) {
|
|
32885
|
+
const MenuCmp = context.getState().components?.Menu ?? Menu;
|
|
32581
32886
|
return {
|
|
32582
|
-
|
|
32583
|
-
|
|
32584
|
-
cellContext
|
|
32887
|
+
renderMenu: (props) => /* @__PURE__ */ React70.createElement(MenuCmp, { ...props }),
|
|
32888
|
+
renderLazyMenu: (menuDefinition, menuDefaultProps) => getLazyMenu(menuDefinition, menuDefaultProps, MenuCmp)
|
|
32585
32889
|
};
|
|
32586
32890
|
}
|
|
32891
|
+
function getCellContextMenu(cellLocation, context, onHideIntent) {
|
|
32892
|
+
return getCellContextMenuContent(
|
|
32893
|
+
cellLocation,
|
|
32894
|
+
context,
|
|
32895
|
+
onHideIntent,
|
|
32896
|
+
getContextMenuBinder(context)
|
|
32897
|
+
);
|
|
32898
|
+
}
|
|
32587
32899
|
function getTableContextMenu(menuLocation, context, onHideIntent) {
|
|
32588
|
-
|
|
32589
|
-
|
|
32590
|
-
|
|
32591
|
-
|
|
32592
|
-
|
|
32593
|
-
|
|
32594
|
-
...menuLocation,
|
|
32595
|
-
...getCellContext({
|
|
32596
|
-
...context,
|
|
32597
|
-
rowIndex: menuLocation.rowIndex,
|
|
32598
|
-
columnId: column.id
|
|
32599
|
-
})
|
|
32600
|
-
} : menuLocation;
|
|
32601
|
-
if (!getContextMenuItems) {
|
|
32602
|
-
return { cellContext, menu: null, preventDefault: false };
|
|
32603
|
-
}
|
|
32604
|
-
const menuDefaultProps = getMenuDefaultProps({
|
|
32605
|
-
onHideIntent
|
|
32606
|
-
});
|
|
32607
|
-
const menuDefinition = getContextMenuItems(cellContext, context);
|
|
32608
|
-
const preventDefault = menuDefinition instanceof Promise ? true : Array.isArray(menuDefinition) ? true : !!(menuDefinition && Array.isArray(menuDefinition.items));
|
|
32609
|
-
if (menuDefinition instanceof Promise) {
|
|
32610
|
-
return {
|
|
32611
|
-
cellContext,
|
|
32612
|
-
menu: getLazyMenu(menuDefinition, menuDefaultProps, MenuCmp),
|
|
32613
|
-
preventDefault
|
|
32614
|
-
};
|
|
32615
|
-
}
|
|
32616
|
-
const { items, columns } = getMenuItemsAndColumns(menuDefinition);
|
|
32617
|
-
if (!items || !items.length) {
|
|
32618
|
-
return { cellContext, menu: null, preventDefault: Array.isArray(items) };
|
|
32619
|
-
}
|
|
32620
|
-
return {
|
|
32621
|
-
preventDefault,
|
|
32622
|
-
menu: /* @__PURE__ */ React70.createElement(MenuCmp, { ...menuDefaultProps, columns, items }),
|
|
32623
|
-
cellContext
|
|
32624
|
-
};
|
|
32900
|
+
return getTableContextMenuContent(
|
|
32901
|
+
menuLocation,
|
|
32902
|
+
context,
|
|
32903
|
+
onHideIntent,
|
|
32904
|
+
getContextMenuBinder(context)
|
|
32905
|
+
);
|
|
32625
32906
|
}
|
|
32626
32907
|
|
|
32627
32908
|
// src/components/InfiniteTable/hooks/useContextMenu.ts
|
|
32628
|
-
var OFFSET3 = 5;
|
|
32629
|
-
var ALIGN_POSITIONS = [
|
|
32630
|
-
["TopLeft", "BottomLeft"],
|
|
32631
|
-
["TopRight", "BottomRight"],
|
|
32632
|
-
["BottomLeft", "BottomLeft"],
|
|
32633
|
-
["BottomRight", "BottomRight"],
|
|
32634
|
-
["TopCenter", "TopLeft"],
|
|
32635
|
-
["BottomCenter", "TopLeft"],
|
|
32636
|
-
["CenterLeft", "TopLeft"],
|
|
32637
|
-
["CenterRight", "TopLeft"]
|
|
32638
|
-
];
|
|
32639
32909
|
function useCellContextMenu() {
|
|
32640
32910
|
const context = useInfiniteTableStableContext();
|
|
32641
32911
|
const { getState, actions } = context;
|
|
@@ -32647,78 +32917,22 @@ function useCellContextMenu() {
|
|
|
32647
32917
|
portalContainer: useMenuPortalContainer()
|
|
32648
32918
|
});
|
|
32649
32919
|
(0, import_react64.useEffect)(() => {
|
|
32650
|
-
|
|
32651
|
-
|
|
32652
|
-
|
|
32653
|
-
|
|
32654
|
-
|
|
32655
|
-
}
|
|
32656
|
-
|
|
32657
|
-
function onHideIntent() {
|
|
32658
|
-
clearAll();
|
|
32659
|
-
actions2.cellContextMenuVisibleFor = null;
|
|
32660
|
-
}
|
|
32661
|
-
const { menu, cellContext, preventDefault } = getCellContextMenu(
|
|
32662
|
-
info,
|
|
32663
|
-
context,
|
|
32664
|
-
onHideIntent
|
|
32665
|
-
);
|
|
32666
|
-
const rect = Rectangle.fromPoint({
|
|
32667
|
-
top: event.clientY,
|
|
32668
|
-
left: event.clientX
|
|
32669
|
-
});
|
|
32670
|
-
rect.width += OFFSET3;
|
|
32671
|
-
rect.height += OFFSET3;
|
|
32672
|
-
showOverlay(menu, {
|
|
32673
|
-
constrainTo: getMenuConstrainTo(getState2()),
|
|
32674
|
-
id: "cell-context-menu",
|
|
32675
|
-
alignTo: rect,
|
|
32676
|
-
alignPosition: ALIGN_POSITIONS
|
|
32677
|
-
});
|
|
32678
|
-
if (preventDefault) {
|
|
32679
|
-
event.preventDefault();
|
|
32680
|
-
}
|
|
32681
|
-
actions2.cellContextMenuVisibleFor = {
|
|
32682
|
-
columnId: info.columnId,
|
|
32683
|
-
rowId: info.rowId,
|
|
32684
|
-
rowIndex: info.rowIndex,
|
|
32685
|
-
colIndex: info.colIndex
|
|
32686
|
-
};
|
|
32687
|
-
const { onCellContextMenu } = getState2();
|
|
32688
|
-
if (onCellContextMenu) {
|
|
32689
|
-
onCellContextMenu(
|
|
32690
|
-
{
|
|
32691
|
-
...cellContext,
|
|
32692
|
-
getState: getState2,
|
|
32693
|
-
getDataSourceState
|
|
32694
|
-
},
|
|
32695
|
-
event
|
|
32696
|
-
);
|
|
32697
|
-
}
|
|
32698
|
-
});
|
|
32920
|
+
return getState().cellContextMenu.onChange(
|
|
32921
|
+
getCellContextMenuHandler(context, {
|
|
32922
|
+
clearAll,
|
|
32923
|
+
getContent: (info, onHideIntent) => getCellContextMenu(info, context, onHideIntent),
|
|
32924
|
+
show: ({ menu }, params) => showOverlay(menu, params)
|
|
32925
|
+
})
|
|
32926
|
+
);
|
|
32699
32927
|
}, []);
|
|
32700
32928
|
(0, import_react64.useEffect)(() => {
|
|
32701
|
-
|
|
32702
|
-
|
|
32703
|
-
|
|
32704
|
-
|
|
32705
|
-
|
|
32706
|
-
|
|
32707
|
-
|
|
32708
|
-
};
|
|
32709
|
-
var handleMouseDown = handleMouseDown2;
|
|
32710
|
-
document.documentElement.addEventListener("mousedown", handleMouseDown2);
|
|
32711
|
-
return () => {
|
|
32712
|
-
document.documentElement.removeEventListener(
|
|
32713
|
-
"mousedown",
|
|
32714
|
-
handleMouseDown2
|
|
32715
|
-
);
|
|
32716
|
-
};
|
|
32717
|
-
} else {
|
|
32718
|
-
clearAll();
|
|
32719
|
-
}
|
|
32720
|
-
return () => {
|
|
32721
|
-
};
|
|
32929
|
+
return menuVisibilityEffect(
|
|
32930
|
+
getState().cellContextMenuVisibleFor,
|
|
32931
|
+
clearAll,
|
|
32932
|
+
() => {
|
|
32933
|
+
actions.cellContextMenuVisibleFor = null;
|
|
32934
|
+
}
|
|
32935
|
+
);
|
|
32722
32936
|
}, [getState().cellContextMenuVisibleFor]);
|
|
32723
32937
|
return { menuPortal };
|
|
32724
32938
|
}
|
|
@@ -32733,76 +32947,22 @@ function useTableContextMenu() {
|
|
|
32733
32947
|
portalContainer: useMenuPortalContainer()
|
|
32734
32948
|
});
|
|
32735
32949
|
(0, import_react64.useEffect)(() => {
|
|
32736
|
-
|
|
32737
|
-
|
|
32738
|
-
|
|
32739
|
-
|
|
32740
|
-
|
|
32741
|
-
}
|
|
32742
|
-
|
|
32743
|
-
function onHideIntent() {
|
|
32744
|
-
clearAll();
|
|
32745
|
-
actions2.contextMenuVisibleFor = null;
|
|
32746
|
-
}
|
|
32747
|
-
const { menu, cellContext, preventDefault } = getTableContextMenu(
|
|
32748
|
-
info,
|
|
32749
|
-
context,
|
|
32750
|
-
onHideIntent
|
|
32751
|
-
);
|
|
32752
|
-
const point = {
|
|
32753
|
-
top: event.clientY,
|
|
32754
|
-
left: event.clientX
|
|
32755
|
-
};
|
|
32756
|
-
const rect = Rectangle.fromPoint(point);
|
|
32757
|
-
rect.width += OFFSET3;
|
|
32758
|
-
rect.height += OFFSET3;
|
|
32759
|
-
showOverlay(menu, {
|
|
32760
|
-
constrainTo: getMenuConstrainTo(getState2()),
|
|
32761
|
-
id: "table-context-menu",
|
|
32762
|
-
alignTo: rect,
|
|
32763
|
-
alignPosition: ALIGN_POSITIONS
|
|
32764
|
-
});
|
|
32765
|
-
if (preventDefault) {
|
|
32766
|
-
event.preventDefault();
|
|
32767
|
-
}
|
|
32768
|
-
actions2.contextMenuVisibleFor = {
|
|
32769
|
-
point,
|
|
32770
|
-
...info
|
|
32771
|
-
};
|
|
32772
|
-
const { onContextMenu } = getState2();
|
|
32773
|
-
if (onContextMenu) {
|
|
32774
|
-
onContextMenu(
|
|
32775
|
-
{
|
|
32776
|
-
...context,
|
|
32777
|
-
...cellContext
|
|
32778
|
-
},
|
|
32779
|
-
event
|
|
32780
|
-
);
|
|
32781
|
-
}
|
|
32782
|
-
});
|
|
32950
|
+
return getState().contextMenu.onChange(
|
|
32951
|
+
getTableContextMenuHandler(context, {
|
|
32952
|
+
clearAll,
|
|
32953
|
+
getContent: (info, onHideIntent) => getTableContextMenu(info, context, onHideIntent),
|
|
32954
|
+
show: ({ menu }, params) => showOverlay(menu, params)
|
|
32955
|
+
})
|
|
32956
|
+
);
|
|
32783
32957
|
}, []);
|
|
32784
32958
|
(0, import_react64.useEffect)(() => {
|
|
32785
|
-
|
|
32786
|
-
|
|
32787
|
-
|
|
32788
|
-
|
|
32789
|
-
|
|
32790
|
-
|
|
32791
|
-
|
|
32792
|
-
};
|
|
32793
|
-
var handleMouseDown = handleMouseDown2;
|
|
32794
|
-
document.documentElement.addEventListener("mousedown", handleMouseDown2);
|
|
32795
|
-
return () => {
|
|
32796
|
-
document.documentElement.removeEventListener(
|
|
32797
|
-
"mousedown",
|
|
32798
|
-
handleMouseDown2
|
|
32799
|
-
);
|
|
32800
|
-
};
|
|
32801
|
-
} else {
|
|
32802
|
-
clearAll();
|
|
32803
|
-
}
|
|
32804
|
-
return () => {
|
|
32805
|
-
};
|
|
32959
|
+
return menuVisibilityEffect(
|
|
32960
|
+
getState().contextMenuVisibleFor,
|
|
32961
|
+
clearAll,
|
|
32962
|
+
() => {
|
|
32963
|
+
actions.contextMenuVisibleFor = null;
|
|
32964
|
+
}
|
|
32965
|
+
);
|
|
32806
32966
|
}, [getState().contextMenuVisibleFor]);
|
|
32807
32967
|
return { menuPortal };
|
|
32808
32968
|
}
|