@infinite-table/infinite-react 1.3.18 → 1.3.19

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/index.d.ts CHANGED
@@ -1125,6 +1125,7 @@ interface InfiniteTableSetupState<T> {
1125
1125
  point: PointCoords;
1126
1126
  }) | null;
1127
1127
  columnMenuVisibleForColumnId: string | null;
1128
+ columnMenuTargetRef: MutableRefObject<HTMLElement | null>;
1128
1129
  columnMenuVisibleKey: string | number;
1129
1130
  filterOperatorMenuVisibleForColumnId: string | null;
1130
1131
  onColumnHeaderHeightCSSVarChange: SubscriptionCallback<number>;
package/index.dev.js CHANGED
@@ -8680,7 +8680,19 @@ function InfiniteTableHeaderCell(props) {
8680
8680
  renderParam2.renderBag.menuIcon = /* @__PURE__ */ React42.createElement(
8681
8681
  RenderHeaderCellHookComponent,
8682
8682
  {
8683
- render: column.renderMenuIcon,
8683
+ render: (param) => {
8684
+ if (typeof column.renderMenuIcon !== "function") {
8685
+ return null;
8686
+ }
8687
+ const result = column.renderMenuIcon(param);
8688
+ if (result) {
8689
+ if (result.type === MenuIconCmp || result.type === MenuIcon) {
8690
+ return result;
8691
+ }
8692
+ return /* @__PURE__ */ React42.createElement(MenuIconCmp, __spreadValues({}, menuIconProps), result);
8693
+ }
8694
+ return null;
8695
+ },
8684
8696
  renderParam: __spreadProps(__spreadValues({}, renderParam2), {
8685
8697
  renderBag: __spreadValues({}, renderParam2.renderBag)
8686
8698
  })
@@ -14876,6 +14888,7 @@ function initSetupState2() {
14876
14888
  brain,
14877
14889
  headerBrain,
14878
14890
  domRef,
14891
+ columnMenuTargetRef: (0, import_react42.createRef)(),
14879
14892
  editingValueRef: (0, import_react42.createRef)(),
14880
14893
  scrollerDOMRef: (0, import_react42.createRef)(),
14881
14894
  portalDOMRef: (0, import_react42.createRef)(),
@@ -15025,6 +15038,7 @@ var cleanupState = (state) => {
15025
15038
  state.onColumnMenuClick.destroy();
15026
15039
  state.onFilterOperatorMenuClick.destroy();
15027
15040
  state.domRef.current = null;
15041
+ state.columnMenuTargetRef.current = null;
15028
15042
  state.scrollerDOMRef.current = null;
15029
15043
  state.portalDOMRef.current = null;
15030
15044
  state.onRowHeightCSSVarChange.destroy();
@@ -16655,7 +16669,7 @@ var useLicense = (licenseKey = "") => {
16655
16669
  const valid = (0, import_react49.useMemo)(() => {
16656
16670
  let valid2 = isValidLicense(licenseKey, {
16657
16671
  publishedAt: 1624970570587,
16658
- version: "1.3.18"
16672
+ version: "1.3.19"
16659
16673
  });
16660
16674
  if (!licenseKey && !valid2 && isInsidePlayground) {
16661
16675
  return true;
@@ -19138,7 +19152,8 @@ function defaultGetColumnMenuItems(_items, params) {
19138
19152
  disabled: col.computedVisible && api.getVisibleColumnsCount() === 1,
19139
19153
  checked: col.computedVisible,
19140
19154
  onChange: (checked) => {
19141
- api.setVisibilityForColumn(col.id, !!checked);
19155
+ const visible = !!checked;
19156
+ api.setVisibilityForColumn(col.id, visible);
19142
19157
  requestAnimationFrame(() => {
19143
19158
  api.realignColumnContextMenu();
19144
19159
  });
@@ -19217,6 +19232,7 @@ function getMenuForColumn(columnId, context, onHideIntent) {
19217
19232
  // src/components/InfiniteTable/hooks/useColumnMenu.ts
19218
19233
  var menuIconSelector = `[${MenuIconDataAttributes["data-name"]}="${MenuIconDataAttributesValues["data-name"]}"]`;
19219
19234
  function showMenuForColumn(options) {
19235
+ var _a;
19220
19236
  const { columnId, context, clearAll, showOverlay } = options;
19221
19237
  const { getState, actions } = context;
19222
19238
  function onHideIntent() {
@@ -19229,6 +19245,12 @@ function showMenuForColumn(options) {
19229
19245
  target = getState().domRef.current.querySelector(
19230
19246
  iconSelector
19231
19247
  );
19248
+ if (!target) {
19249
+ target = (_a = getState().columnMenuTargetRef.current) != null ? _a : void 0;
19250
+ if (!(target == null ? void 0 : target.parentElement)) {
19251
+ target = void 0;
19252
+ }
19253
+ }
19232
19254
  }
19233
19255
  if (!target) {
19234
19256
  console.warn(`Cannot show column menu for column "${columnId}"`);
@@ -19261,6 +19283,7 @@ function useColumnMenu() {
19261
19283
  if (!info) {
19262
19284
  return;
19263
19285
  }
19286
+ state.columnMenuTargetRef.current = info.target;
19264
19287
  actions2.contextMenuVisibleFor = null;
19265
19288
  actions2.cellContextMenuVisibleFor = null;
19266
19289
  actions2.filterOperatorMenuVisibleForColumnId = null;
@@ -19269,10 +19292,8 @@ function useColumnMenu() {
19269
19292
  }, []);
19270
19293
  const { columnMenuVisibleForColumnId, columnMenuVisibleKey } = getState();
19271
19294
  (0, import_react57.useEffect)(() => {
19272
- const {
19273
- columnMenuVisibleForColumnId: columnContextMenuVisibleForColumnId
19274
- } = getState();
19275
- if (columnContextMenuVisibleForColumnId) {
19295
+ const { columnMenuVisibleForColumnId: columnMenuVisibleForColumnId2, columnMenuTargetRef } = getState();
19296
+ if (columnMenuVisibleForColumnId2) {
19276
19297
  let handleMouseDown2 = function(event) {
19277
19298
  if (event.__insideMenu !== true) {
19278
19299
  clearAll();
@@ -19282,7 +19303,7 @@ function useColumnMenu() {
19282
19303
  var handleMouseDown = handleMouseDown2;
19283
19304
  document.documentElement.addEventListener("mousedown", handleMouseDown2);
19284
19305
  showMenuForColumn({
19285
- columnId: columnContextMenuVisibleForColumnId,
19306
+ columnId: columnMenuVisibleForColumnId2,
19286
19307
  context,
19287
19308
  clearAll,
19288
19309
  showOverlay
@@ -19294,6 +19315,7 @@ function useColumnMenu() {
19294
19315
  );
19295
19316
  };
19296
19317
  } else {
19318
+ columnMenuTargetRef.current = null;
19297
19319
  clearAll();
19298
19320
  }
19299
19321
  return () => {
package/index.dev.mjs CHANGED
@@ -8666,7 +8666,19 @@ function InfiniteTableHeaderCell(props) {
8666
8666
  renderParam2.renderBag.menuIcon = /* @__PURE__ */ React42.createElement(
8667
8667
  RenderHeaderCellHookComponent,
8668
8668
  {
8669
- render: column.renderMenuIcon,
8669
+ render: (param) => {
8670
+ if (typeof column.renderMenuIcon !== "function") {
8671
+ return null;
8672
+ }
8673
+ const result = column.renderMenuIcon(param);
8674
+ if (result) {
8675
+ if (result.type === MenuIconCmp || result.type === MenuIcon) {
8676
+ return result;
8677
+ }
8678
+ return /* @__PURE__ */ React42.createElement(MenuIconCmp, __spreadValues({}, menuIconProps), result);
8679
+ }
8680
+ return null;
8681
+ },
8670
8682
  renderParam: __spreadProps(__spreadValues({}, renderParam2), {
8671
8683
  renderBag: __spreadValues({}, renderParam2.renderBag)
8672
8684
  })
@@ -14866,6 +14878,7 @@ function initSetupState2() {
14866
14878
  brain,
14867
14879
  headerBrain,
14868
14880
  domRef,
14881
+ columnMenuTargetRef: createRef(),
14869
14882
  editingValueRef: createRef(),
14870
14883
  scrollerDOMRef: createRef(),
14871
14884
  portalDOMRef: createRef(),
@@ -15015,6 +15028,7 @@ var cleanupState = (state) => {
15015
15028
  state.onColumnMenuClick.destroy();
15016
15029
  state.onFilterOperatorMenuClick.destroy();
15017
15030
  state.domRef.current = null;
15031
+ state.columnMenuTargetRef.current = null;
15018
15032
  state.scrollerDOMRef.current = null;
15019
15033
  state.portalDOMRef.current = null;
15020
15034
  state.onRowHeightCSSVarChange.destroy();
@@ -16645,7 +16659,7 @@ var useLicense = (licenseKey = "") => {
16645
16659
  const valid = useMemo11(() => {
16646
16660
  let valid2 = isValidLicense(licenseKey, {
16647
16661
  publishedAt: 1624970570587,
16648
- version: "1.3.18"
16662
+ version: "1.3.19"
16649
16663
  });
16650
16664
  if (!licenseKey && !valid2 && isInsidePlayground) {
16651
16665
  return true;
@@ -19138,7 +19152,8 @@ function defaultGetColumnMenuItems(_items, params) {
19138
19152
  disabled: col.computedVisible && api.getVisibleColumnsCount() === 1,
19139
19153
  checked: col.computedVisible,
19140
19154
  onChange: (checked) => {
19141
- api.setVisibilityForColumn(col.id, !!checked);
19155
+ const visible = !!checked;
19156
+ api.setVisibilityForColumn(col.id, visible);
19142
19157
  requestAnimationFrame(() => {
19143
19158
  api.realignColumnContextMenu();
19144
19159
  });
@@ -19217,6 +19232,7 @@ function getMenuForColumn(columnId, context, onHideIntent) {
19217
19232
  // src/components/InfiniteTable/hooks/useColumnMenu.ts
19218
19233
  var menuIconSelector = `[${MenuIconDataAttributes["data-name"]}="${MenuIconDataAttributesValues["data-name"]}"]`;
19219
19234
  function showMenuForColumn(options) {
19235
+ var _a;
19220
19236
  const { columnId, context, clearAll, showOverlay } = options;
19221
19237
  const { getState, actions } = context;
19222
19238
  function onHideIntent() {
@@ -19229,6 +19245,12 @@ function showMenuForColumn(options) {
19229
19245
  target = getState().domRef.current.querySelector(
19230
19246
  iconSelector
19231
19247
  );
19248
+ if (!target) {
19249
+ target = (_a = getState().columnMenuTargetRef.current) != null ? _a : void 0;
19250
+ if (!(target == null ? void 0 : target.parentElement)) {
19251
+ target = void 0;
19252
+ }
19253
+ }
19232
19254
  }
19233
19255
  if (!target) {
19234
19256
  console.warn(`Cannot show column menu for column "${columnId}"`);
@@ -19261,6 +19283,7 @@ function useColumnMenu() {
19261
19283
  if (!info) {
19262
19284
  return;
19263
19285
  }
19286
+ state.columnMenuTargetRef.current = info.target;
19264
19287
  actions2.contextMenuVisibleFor = null;
19265
19288
  actions2.cellContextMenuVisibleFor = null;
19266
19289
  actions2.filterOperatorMenuVisibleForColumnId = null;
@@ -19269,10 +19292,8 @@ function useColumnMenu() {
19269
19292
  }, []);
19270
19293
  const { columnMenuVisibleForColumnId, columnMenuVisibleKey } = getState();
19271
19294
  useEffect35(() => {
19272
- const {
19273
- columnMenuVisibleForColumnId: columnContextMenuVisibleForColumnId
19274
- } = getState();
19275
- if (columnContextMenuVisibleForColumnId) {
19295
+ const { columnMenuVisibleForColumnId: columnMenuVisibleForColumnId2, columnMenuTargetRef } = getState();
19296
+ if (columnMenuVisibleForColumnId2) {
19276
19297
  let handleMouseDown2 = function(event) {
19277
19298
  if (event.__insideMenu !== true) {
19278
19299
  clearAll();
@@ -19282,7 +19303,7 @@ function useColumnMenu() {
19282
19303
  var handleMouseDown = handleMouseDown2;
19283
19304
  document.documentElement.addEventListener("mousedown", handleMouseDown2);
19284
19305
  showMenuForColumn({
19285
- columnId: columnContextMenuVisibleForColumnId,
19306
+ columnId: columnMenuVisibleForColumnId2,
19286
19307
  context,
19287
19308
  clearAll,
19288
19309
  showOverlay
@@ -19294,6 +19315,7 @@ function useColumnMenu() {
19294
19315
  );
19295
19316
  };
19296
19317
  } else {
19318
+ columnMenuTargetRef.current = null;
19297
19319
  clearAll();
19298
19320
  }
19299
19321
  return () => {