@infinite-table/infinite-react 10.1.1 → 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
@@ -19044,7 +19044,7 @@ function loadData(data, componentState, actions, overrides, masterContext) {
19044
19044
  //@ts-ignore
19045
19045
  typeof data === "object" && typeof data.then === "function"
19046
19046
  );
19047
- const togglesLoading = dataIsPromise && (!componentState.lazyLoad || componentState.lazyLoad && !append);
19047
+ const togglesLoading = dataIsPromise && (!componentState.lazyLoad || !append && !dataParams.groupKeys?.length);
19048
19048
  if (togglesLoading) {
19049
19049
  actions.loading = true;
19050
19050
  }
@@ -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,
@@ -27369,7 +27371,8 @@ var LoadingIcon = (props) => {
27369
27371
  function buildColumnForGroupBy(options, toggleGroupRow, groupColumnFromProps, renderers) {
27370
27372
  const { groupByForColumn, groupIndexForColumn, groupRenderStrategy } = options;
27371
27373
  const userDefinedGroupColumn = groupByForColumn.column ? { ...groupByForColumn.column } : {};
27372
- let generatedGroupColumn = {
27374
+ const theGroupColumnFromProps = typeof groupColumnFromProps === "function" ? groupColumnFromProps(options, toggleGroupRow) : groupColumnFromProps;
27375
+ return {
27373
27376
  header: `Group by ${groupByForColumn.field || groupByForColumn.groupField}`,
27374
27377
  groupByForColumn,
27375
27378
  render: renderers.getGroupColumnRender({
@@ -27377,27 +27380,17 @@ function buildColumnForGroupBy(options, toggleGroupRow, groupColumnFromProps, re
27377
27380
  groupRenderStrategy
27378
27381
  }),
27379
27382
  ...userDefinedGroupColumn,
27383
+ ...theGroupColumnFromProps,
27384
+ // a renderGroupIcon from the groupColumn prop is wrapped too, as with a
27385
+ // single group column: it is called only where a group icon belongs, with
27386
+ // the default icon in renderBag.groupIcon
27380
27387
  renderGroupIcon: renderers.getGroupColumnRenderGroupIcon({
27381
- initialRenderGroupIcon: userDefinedGroupColumn?.renderGroupIcon,
27388
+ initialRenderGroupIcon: theGroupColumnFromProps?.renderGroupIcon ?? userDefinedGroupColumn.renderGroupIcon,
27382
27389
  groupIndexForColumn,
27383
27390
  toggleGroupRow,
27384
27391
  groupRenderStrategy
27385
27392
  })
27386
27393
  };
27387
- if (groupColumnFromProps) {
27388
- if (typeof groupColumnFromProps === "function") {
27389
- generatedGroupColumn = {
27390
- ...generatedGroupColumn,
27391
- ...groupColumnFromProps(options, toggleGroupRow)
27392
- };
27393
- } else {
27394
- generatedGroupColumn = {
27395
- ...generatedGroupColumn,
27396
- ...groupColumnFromProps
27397
- };
27398
- }
27399
- }
27400
- return generatedGroupColumn;
27401
27394
  }
27402
27395
  function buildSingleGroupColumn(options, toggleGroupRow, groupColumnFromProps, renderers) {
27403
27396
  const theGroupColumnFromProps = typeof groupColumnFromProps === "function" ? groupColumnFromProps(options, toggleGroupRow) : groupColumnFromProps;
@@ -28723,7 +28716,7 @@ var useLicense = (licenseKey = "") => {
28723
28716
  }
28724
28717
  let valid2 = isValidLicense(licenseKey, {
28725
28718
  publishedAt: 1624970570587,
28726
- version: "10.1.1"
28719
+ version: "10.1.3"
28727
28720
  });
28728
28721
  if (!licenseKey && !valid2 && isInsidePlayground) {
28729
28722
  return true;
@@ -29696,7 +29689,9 @@ function useOverlayPortal(content, portalContainer) {
29696
29689
  }
29697
29690
  getContainer();
29698
29691
  }, [portalContainer]);
29699
- 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) : (
29700
29695
  // we're probably still fetching the container
29701
29696
  /* @__PURE__ */ React57.createElement(React57.Fragment, null)
29702
29697
  ) : portalContainer === null || portalContainer === false ? content : /* @__PURE__ */ React57.createElement(DefaultOverlayPortal, null, content);
@@ -31055,6 +31050,41 @@ function getMenuForColumn(columnId, context, onHideIntent) {
31055
31050
  );
31056
31051
  }
31057
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
+
31058
31088
  // src/components/InfiniteTable/hooks/useColumnMenu.ts
31059
31089
  var menuIconSelector2 = `[${MenuIconDataAttributes["data-name"]}="${MenuIconDataAttributesValues["data-name"]}"]`;
31060
31090
  function showMenuForColumn(options) {
@@ -31084,7 +31114,7 @@ function showMenuForColumn(options) {
31084
31114
  }
31085
31115
  columnMenuTargetRef.current = null;
31086
31116
  showOverlay(() => getMenuForColumn(columnId, context, onHideIntent), {
31087
- constrainTo: domRef.current,
31117
+ constrainTo: getMenuConstrainTo(getState()),
31088
31118
  id: "column-menu",
31089
31119
  alignTo: target,
31090
31120
  alignPosition: [
@@ -31108,17 +31138,12 @@ function useColumnMenu() {
31108
31138
  columnMenuVisibleKey: ctx.state.columnMenuVisibleKey
31109
31139
  };
31110
31140
  });
31111
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31112
- return {
31113
- portalDOMRef: ctx.getMasterState().portalDOMRef
31114
- };
31115
- }) || {};
31116
31141
  const {
31117
31142
  showOverlay,
31118
31143
  portal: menuPortal,
31119
31144
  clearAll
31120
31145
  } = useOverlay({
31121
- portalContainer: portalDOMRef?.current ?? false
31146
+ portalContainer: useMenuPortalContainer()
31122
31147
  });
31123
31148
  useEffect32(() => {
31124
31149
  const state = getState();
@@ -31488,11 +31513,6 @@ function getFilterOperatorMenuForColumn(columnId, context, onHideIntent) {
31488
31513
  // src/components/InfiniteTable/hooks/useColumnFilterOperatorMenu.ts
31489
31514
  var OFFSET2 = 10;
31490
31515
  function useColumnFilterOperatorMenu() {
31491
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31492
- return {
31493
- portalDOMRef: ctx.getMasterState().portalDOMRef
31494
- };
31495
- }) || {};
31496
31516
  const stableContext = useInfiniteTableStableContext();
31497
31517
  const { getState, actions } = stableContext;
31498
31518
  const {
@@ -31500,7 +31520,7 @@ function useColumnFilterOperatorMenu() {
31500
31520
  portal: menuPortal,
31501
31521
  clearAll
31502
31522
  } = useOverlay({
31503
- portalContainer: portalDOMRef?.current ?? false
31523
+ portalContainer: useMenuPortalContainer()
31504
31524
  });
31505
31525
  useEffect34(() => {
31506
31526
  const state = getState();
@@ -31526,7 +31546,7 @@ function useColumnFilterOperatorMenu() {
31526
31546
  onHideIntent
31527
31547
  ),
31528
31548
  {
31529
- constrainTo: getState().domRef.current,
31549
+ constrainTo: getMenuConstrainTo(getState()),
31530
31550
  id: "filter-operator-menu",
31531
31551
  alignTo: rect,
31532
31552
  alignPosition: [
@@ -31730,18 +31750,13 @@ var ALIGN_POSITIONS = [
31730
31750
  ];
31731
31751
  function useCellContextMenu() {
31732
31752
  const context = useInfiniteTableStableContext();
31733
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31734
- return {
31735
- portalDOMRef: ctx.getMasterState().portalDOMRef
31736
- };
31737
- }) || {};
31738
31753
  const { getState, actions } = context;
31739
31754
  const {
31740
31755
  showOverlay,
31741
31756
  portal: menuPortal,
31742
31757
  clearAll
31743
31758
  } = useOverlay({
31744
- portalContainer: portalDOMRef?.current ?? false
31759
+ portalContainer: useMenuPortalContainer()
31745
31760
  });
31746
31761
  useEffect35(() => {
31747
31762
  const { actions: actions2, getState: getState2, getDataSourceState } = context;
@@ -31767,7 +31782,7 @@ function useCellContextMenu() {
31767
31782
  rect.width += OFFSET3;
31768
31783
  rect.height += OFFSET3;
31769
31784
  showOverlay(menu, {
31770
- constrainTo: getState2().domRef.current,
31785
+ constrainTo: getMenuConstrainTo(getState2()),
31771
31786
  id: "cell-context-menu",
31772
31787
  alignTo: rect,
31773
31788
  alignPosition: ALIGN_POSITIONS
@@ -31821,18 +31836,13 @@ function useCellContextMenu() {
31821
31836
  }
31822
31837
  function useTableContextMenu() {
31823
31838
  const context = useInfiniteTableStableContext();
31824
- const { portalDOMRef } = useDataSourceMasterDetailSelector((ctx) => {
31825
- return {
31826
- portalDOMRef: ctx.getMasterState().portalDOMRef
31827
- };
31828
- }) || {};
31829
31839
  const { getState, actions } = context;
31830
31840
  const {
31831
31841
  showOverlay,
31832
31842
  portal: menuPortal,
31833
31843
  clearAll
31834
31844
  } = useOverlay({
31835
- portalContainer: portalDOMRef?.current ?? false
31845
+ portalContainer: useMenuPortalContainer()
31836
31846
  });
31837
31847
  useEffect35(() => {
31838
31848
  const { actions: actions2, getState: getState2 } = context;
@@ -31859,7 +31869,7 @@ function useTableContextMenu() {
31859
31869
  rect.width += OFFSET3;
31860
31870
  rect.height += OFFSET3;
31861
31871
  showOverlay(menu, {
31862
- constrainTo: getState2().domRef.current,
31872
+ constrainTo: getMenuConstrainTo(getState2()),
31863
31873
  id: "table-context-menu",
31864
31874
  alignTo: rect,
31865
31875
  alignPosition: ALIGN_POSITIONS
@@ -32837,7 +32847,7 @@ function GroupingToolbar(props) {
32837
32847
  import * as React78 from "react";
32838
32848
 
32839
32849
  // src/components/InfiniteTable/hooks/useCellRendering.tsx
32840
- import { useMemo as useMemo20 } from "react";
32850
+ import { useMemo as useMemo21 } from "react";
32841
32851
  import { useCallback as useCallback34, useEffect as useEffect39, useRef as useRef33 } from "react";
32842
32852
  import * as React75 from "react";
32843
32853
 
@@ -32882,7 +32892,7 @@ import * as React74 from "react";
32882
32892
  var RowDetailRecipe = createRuntimeFn({ defaultClassName: "evqes20", variantClassNames: {}, defaultVariants: {}, compoundVariants: [] });
32883
32893
 
32884
32894
  // src/components/InfiniteTable/components/InfiniteTableRow/useRegisterDetail.ts
32885
- import { useMemo as useMemo19 } from "react";
32895
+ import { useMemo as useMemo20 } from "react";
32886
32896
 
32887
32897
  // src/components/InfiniteTable/components/InfiniteTableRow/registerDetailShared.ts
32888
32898
  function restoreDetailStateForRowId(rowId, options) {
@@ -33010,11 +33020,11 @@ function useRegisterDetail(props) {
33010
33020
  getMasterState: ctx.getState
33011
33021
  };
33012
33022
  });
33013
- const { currentRowCache, cacheCalledByRowDetailRenderer } = useMemo19(
33023
+ const { currentRowCache, cacheCalledByRowDetailRenderer } = useMemo20(
33014
33024
  () => createCurrentRowCache(rowInfo.id, rowDetailsCache),
33015
33025
  [rowDetailsCache, rowInfo.id]
33016
33026
  );
33017
- const masterDetailContextValue = useMemo19(() => {
33027
+ const masterDetailContextValue = useMemo20(() => {
33018
33028
  return createMasterDetailContextValue({
33019
33029
  rowInfo,
33020
33030
  currentRowCache,
@@ -33158,7 +33168,7 @@ function useCellRendering(param) {
33158
33168
  toggleGroupRow,
33159
33169
  columnSize
33160
33170
  } = computed;
33161
- const visibleColumnIds = useMemo20(
33171
+ const visibleColumnIds = useMemo21(
33162
33172
  () => computedVisibleColumns.map((column) => column.id),
33163
33173
  [computedVisibleColumns]
33164
33174
  );
@@ -33260,7 +33270,7 @@ function useCellRendering(param) {
33260
33270
  onReady({ api: imperativeApi, dataSourceApi });
33261
33271
  }
33262
33272
  }, [ready]);
33263
- const dataSourceStatePartialForCell = useMemo20(() => {
33273
+ const dataSourceStatePartialForCell = useMemo21(() => {
33264
33274
  return {
33265
33275
  isNodeReadOnly: isNodeReadOnly2,
33266
33276
  selectionMode,
@@ -33386,7 +33396,7 @@ function useCellRendering(param) {
33386
33396
  dataSourceStatePartialForCell
33387
33397
  ]
33388
33398
  );
33389
- const renderDetailRow = useMemo20(() => {
33399
+ const renderDetailRow = useMemo21(() => {
33390
33400
  if (!isRowDetailsExpanded) {
33391
33401
  return void 0;
33392
33402
  }
@@ -33498,7 +33508,7 @@ function LoadMaskFn(props) {
33498
33508
  var LoadMask = React77.memo(LoadMaskFn);
33499
33509
 
33500
33510
  // src/components/InfiniteTable/components/InfiniteTableBody/index.tsx
33501
- import { useMemo as useMemo21 } from "react";
33511
+ import { useMemo as useMemo22 } from "react";
33502
33512
  var _HOVERED_CLASS_NAMES = [
33503
33513
  RowHoverCls,
33504
33514
  `${InfiniteTableColumnCellClassName}--hovered`
@@ -33615,7 +33625,7 @@ function InfiniteTableBody(props) {
33615
33625
  });
33616
33626
  const { autoFocus, tabIndex } = domProps ?? {};
33617
33627
  useToggleWrapRowsHorizontally();
33618
- const hoverClassNames = useMemo21(() => {
33628
+ const hoverClassNames = useMemo22(() => {
33619
33629
  if (!showHoverRows) {
33620
33630
  return void 0;
33621
33631
  }