@infinite-table/infinite-react 10.1.2 → 10.1.3

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.dev.mjs CHANGED
@@ -26970,6 +26970,8 @@ var forwardProps4 = (_setupState) => {
26970
26970
  getColumnMenuItems: 1,
26971
26971
  getCellContextMenuItems: 1,
26972
26972
  getContextMenuItems: 1,
26973
+ menuPortalContainer: 1,
26974
+ menuConstrainTo: 1,
26973
26975
  columnPinning: 1,
26974
26976
  editable: 1,
26975
26977
  columnDefaultEditable: 1,
@@ -28714,7 +28716,7 @@ var useLicense = (licenseKey = "") => {
28714
28716
  }
28715
28717
  let valid2 = isValidLicense(licenseKey, {
28716
28718
  publishedAt: 1624970570587,
28717
- version: "10.1.2"
28719
+ version: "10.1.3"
28718
28720
  });
28719
28721
  if (!licenseKey && !valid2 && isInsidePlayground) {
28720
28722
  return true;
@@ -29687,7 +29689,9 @@ function useOverlayPortal(content, portalContainer) {
29687
29689
  }
29688
29690
  getContainer();
29689
29691
  }, [portalContainer]);
29690
- return portalContainer ? container ? createPortal2(content, container) : (
29692
+ const currentContainer = typeof portalContainer === "function" ? portalContainer() : null;
29693
+ const targetContainer = isHTMLElement2(currentContainer) ? currentContainer : container;
29694
+ return portalContainer ? targetContainer ? createPortal2(content, targetContainer) : (
29691
29695
  // we're probably still fetching the container
29692
29696
  /* @__PURE__ */ React57.createElement(React57.Fragment, null)
29693
29697
  ) : portalContainer === null || portalContainer === false ? content : /* @__PURE__ */ React57.createElement(DefaultOverlayPortal, null, content);
@@ -31046,6 +31050,41 @@ function getMenuForColumn(columnId, context, onHideIntent) {
31046
31050
  );
31047
31051
  }
31048
31052
 
31053
+ // src/components/InfiniteTable/utils/menuOverlayTargets.ts
31054
+ function resolveMenuElement(element) {
31055
+ return typeof element === "function" ? element() : element;
31056
+ }
31057
+ function getMenuConstrainTo(state) {
31058
+ return resolveMenuElement(state.menuConstrainTo) ?? state.domRef.current;
31059
+ }
31060
+ function getMenuPortalContainer(getState, menuPortalContainer, defaultContainer) {
31061
+ if (!menuPortalContainer) {
31062
+ return defaultContainer || false;
31063
+ }
31064
+ return () => resolveMenuElement(menuPortalContainer) ?? (defaultContainer || getState().portalDOMRef.current);
31065
+ }
31066
+
31067
+ // src/components/InfiniteTable/hooks/useMenuPortalContainer.ts
31068
+ import { useMemo as useMemo19 } from "react";
31069
+ function useMenuPortalContainer() {
31070
+ const { getState, menuPortalContainer } = useInfiniteTableSelector((ctx) => {
31071
+ return {
31072
+ getState: ctx.getState,
31073
+ menuPortalContainer: ctx.state.menuPortalContainer
31074
+ };
31075
+ });
31076
+ const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31077
+ return {
31078
+ portalDOMRef: ctx.getMasterState().portalDOMRef
31079
+ };
31080
+ }) || {};
31081
+ const defaultContainer = portalDOMRef?.current;
31082
+ return useMemo19(
31083
+ () => getMenuPortalContainer(getState, menuPortalContainer, defaultContainer),
31084
+ [getState, menuPortalContainer, defaultContainer]
31085
+ );
31086
+ }
31087
+
31049
31088
  // src/components/InfiniteTable/hooks/useColumnMenu.ts
31050
31089
  var menuIconSelector2 = `[${MenuIconDataAttributes["data-name"]}="${MenuIconDataAttributesValues["data-name"]}"]`;
31051
31090
  function showMenuForColumn(options) {
@@ -31075,7 +31114,7 @@ function showMenuForColumn(options) {
31075
31114
  }
31076
31115
  columnMenuTargetRef.current = null;
31077
31116
  showOverlay(() => getMenuForColumn(columnId, context, onHideIntent), {
31078
- constrainTo: domRef.current,
31117
+ constrainTo: getMenuConstrainTo(getState()),
31079
31118
  id: "column-menu",
31080
31119
  alignTo: target,
31081
31120
  alignPosition: [
@@ -31099,17 +31138,12 @@ function useColumnMenu() {
31099
31138
  columnMenuVisibleKey: ctx.state.columnMenuVisibleKey
31100
31139
  };
31101
31140
  });
31102
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31103
- return {
31104
- portalDOMRef: ctx.getMasterState().portalDOMRef
31105
- };
31106
- }) || {};
31107
31141
  const {
31108
31142
  showOverlay,
31109
31143
  portal: menuPortal,
31110
31144
  clearAll
31111
31145
  } = useOverlay({
31112
- portalContainer: portalDOMRef?.current ?? false
31146
+ portalContainer: useMenuPortalContainer()
31113
31147
  });
31114
31148
  useEffect32(() => {
31115
31149
  const state = getState();
@@ -31479,11 +31513,6 @@ function getFilterOperatorMenuForColumn(columnId, context, onHideIntent) {
31479
31513
  // src/components/InfiniteTable/hooks/useColumnFilterOperatorMenu.ts
31480
31514
  var OFFSET2 = 10;
31481
31515
  function useColumnFilterOperatorMenu() {
31482
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31483
- return {
31484
- portalDOMRef: ctx.getMasterState().portalDOMRef
31485
- };
31486
- }) || {};
31487
31516
  const stableContext = useInfiniteTableStableContext();
31488
31517
  const { getState, actions } = stableContext;
31489
31518
  const {
@@ -31491,7 +31520,7 @@ function useColumnFilterOperatorMenu() {
31491
31520
  portal: menuPortal,
31492
31521
  clearAll
31493
31522
  } = useOverlay({
31494
- portalContainer: portalDOMRef?.current ?? false
31523
+ portalContainer: useMenuPortalContainer()
31495
31524
  });
31496
31525
  useEffect34(() => {
31497
31526
  const state = getState();
@@ -31517,7 +31546,7 @@ function useColumnFilterOperatorMenu() {
31517
31546
  onHideIntent
31518
31547
  ),
31519
31548
  {
31520
- constrainTo: getState().domRef.current,
31549
+ constrainTo: getMenuConstrainTo(getState()),
31521
31550
  id: "filter-operator-menu",
31522
31551
  alignTo: rect,
31523
31552
  alignPosition: [
@@ -31721,18 +31750,13 @@ var ALIGN_POSITIONS = [
31721
31750
  ];
31722
31751
  function useCellContextMenu() {
31723
31752
  const context = useInfiniteTableStableContext();
31724
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31725
- return {
31726
- portalDOMRef: ctx.getMasterState().portalDOMRef
31727
- };
31728
- }) || {};
31729
31753
  const { getState, actions } = context;
31730
31754
  const {
31731
31755
  showOverlay,
31732
31756
  portal: menuPortal,
31733
31757
  clearAll
31734
31758
  } = useOverlay({
31735
- portalContainer: portalDOMRef?.current ?? false
31759
+ portalContainer: useMenuPortalContainer()
31736
31760
  });
31737
31761
  useEffect35(() => {
31738
31762
  const { actions: actions2, getState: getState2, getDataSourceState } = context;
@@ -31758,7 +31782,7 @@ function useCellContextMenu() {
31758
31782
  rect.width += OFFSET3;
31759
31783
  rect.height += OFFSET3;
31760
31784
  showOverlay(menu, {
31761
- constrainTo: getState2().domRef.current,
31785
+ constrainTo: getMenuConstrainTo(getState2()),
31762
31786
  id: "cell-context-menu",
31763
31787
  alignTo: rect,
31764
31788
  alignPosition: ALIGN_POSITIONS
@@ -31812,18 +31836,13 @@ function useCellContextMenu() {
31812
31836
  }
31813
31837
  function useTableContextMenu() {
31814
31838
  const context = useInfiniteTableStableContext();
31815
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31816
- return {
31817
- portalDOMRef: ctx.getMasterState().portalDOMRef
31818
- };
31819
- }) || {};
31820
31839
  const { getState, actions } = context;
31821
31840
  const {
31822
31841
  showOverlay,
31823
31842
  portal: menuPortal,
31824
31843
  clearAll
31825
31844
  } = useOverlay({
31826
- portalContainer: portalDOMRef?.current ?? false
31845
+ portalContainer: useMenuPortalContainer()
31827
31846
  });
31828
31847
  useEffect35(() => {
31829
31848
  const { actions: actions2, getState: getState2 } = context;
@@ -31850,7 +31869,7 @@ function useTableContextMenu() {
31850
31869
  rect.width += OFFSET3;
31851
31870
  rect.height += OFFSET3;
31852
31871
  showOverlay(menu, {
31853
- constrainTo: getState2().domRef.current,
31872
+ constrainTo: getMenuConstrainTo(getState2()),
31854
31873
  id: "table-context-menu",
31855
31874
  alignTo: rect,
31856
31875
  alignPosition: ALIGN_POSITIONS
@@ -32828,7 +32847,7 @@ function GroupingToolbar(props) {
32828
32847
  import * as React78 from "react";
32829
32848
 
32830
32849
  // src/components/InfiniteTable/hooks/useCellRendering.tsx
32831
- import { useMemo as useMemo20 } from "react";
32850
+ import { useMemo as useMemo21 } from "react";
32832
32851
  import { useCallback as useCallback34, useEffect as useEffect39, useRef as useRef33 } from "react";
32833
32852
  import * as React75 from "react";
32834
32853
 
@@ -32873,7 +32892,7 @@ import * as React74 from "react";
32873
32892
  var RowDetailRecipe = createRuntimeFn({ defaultClassName: "evqes20", variantClassNames: {}, defaultVariants: {}, compoundVariants: [] });
32874
32893
 
32875
32894
  // src/components/InfiniteTable/components/InfiniteTableRow/useRegisterDetail.ts
32876
- import { useMemo as useMemo19 } from "react";
32895
+ import { useMemo as useMemo20 } from "react";
32877
32896
 
32878
32897
  // src/components/InfiniteTable/components/InfiniteTableRow/registerDetailShared.ts
32879
32898
  function restoreDetailStateForRowId(rowId, options) {
@@ -33001,11 +33020,11 @@ function useRegisterDetail(props) {
33001
33020
  getMasterState: ctx.getState
33002
33021
  };
33003
33022
  });
33004
- const { currentRowCache, cacheCalledByRowDetailRenderer } = useMemo19(
33023
+ const { currentRowCache, cacheCalledByRowDetailRenderer } = useMemo20(
33005
33024
  () => createCurrentRowCache(rowInfo.id, rowDetailsCache),
33006
33025
  [rowDetailsCache, rowInfo.id]
33007
33026
  );
33008
- const masterDetailContextValue = useMemo19(() => {
33027
+ const masterDetailContextValue = useMemo20(() => {
33009
33028
  return createMasterDetailContextValue({
33010
33029
  rowInfo,
33011
33030
  currentRowCache,
@@ -33149,7 +33168,7 @@ function useCellRendering(param) {
33149
33168
  toggleGroupRow,
33150
33169
  columnSize
33151
33170
  } = computed;
33152
- const visibleColumnIds = useMemo20(
33171
+ const visibleColumnIds = useMemo21(
33153
33172
  () => computedVisibleColumns.map((column) => column.id),
33154
33173
  [computedVisibleColumns]
33155
33174
  );
@@ -33251,7 +33270,7 @@ function useCellRendering(param) {
33251
33270
  onReady({ api: imperativeApi, dataSourceApi });
33252
33271
  }
33253
33272
  }, [ready]);
33254
- const dataSourceStatePartialForCell = useMemo20(() => {
33273
+ const dataSourceStatePartialForCell = useMemo21(() => {
33255
33274
  return {
33256
33275
  isNodeReadOnly: isNodeReadOnly2,
33257
33276
  selectionMode,
@@ -33377,7 +33396,7 @@ function useCellRendering(param) {
33377
33396
  dataSourceStatePartialForCell
33378
33397
  ]
33379
33398
  );
33380
- const renderDetailRow = useMemo20(() => {
33399
+ const renderDetailRow = useMemo21(() => {
33381
33400
  if (!isRowDetailsExpanded) {
33382
33401
  return void 0;
33383
33402
  }
@@ -33489,7 +33508,7 @@ function LoadMaskFn(props) {
33489
33508
  var LoadMask = React77.memo(LoadMaskFn);
33490
33509
 
33491
33510
  // src/components/InfiniteTable/components/InfiniteTableBody/index.tsx
33492
- import { useMemo as useMemo21 } from "react";
33511
+ import { useMemo as useMemo22 } from "react";
33493
33512
  var _HOVERED_CLASS_NAMES = [
33494
33513
  RowHoverCls,
33495
33514
  `${InfiniteTableColumnCellClassName}--hovered`
@@ -33606,7 +33625,7 @@ function InfiniteTableBody(props) {
33606
33625
  });
33607
33626
  const { autoFocus, tabIndex } = domProps ?? {};
33608
33627
  useToggleWrapRowsHorizontally();
33609
- const hoverClassNames = useMemo21(() => {
33628
+ const hoverClassNames = useMemo22(() => {
33610
33629
  if (!showHoverRows) {
33611
33630
  return void 0;
33612
33631
  }