@gobolt/genesis 0.4.14 → 0.4.18

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/dist/index.cjs CHANGED
@@ -37,7 +37,7 @@ function requireClassnames() {
37
37
  hasRequiredClassnames = 1;
38
38
  (function(module2) {
39
39
  (function() {
40
- var hasOwn2 = {}.hasOwnProperty;
40
+ var hasOwn = {}.hasOwnProperty;
41
41
  function classNames2() {
42
42
  var classes = "";
43
43
  for (var i = 0; i < arguments.length; i++) {
@@ -63,7 +63,7 @@ function requireClassnames() {
63
63
  }
64
64
  var classes = "";
65
65
  for (var key in arg) {
66
- if (hasOwn2.call(arg, key) && arg[key]) {
66
+ if (hasOwn.call(arg, key) && arg[key]) {
67
67
  classes = appendClass(classes, key);
68
68
  }
69
69
  }
@@ -3172,14 +3172,14 @@ function merge$2() {
3172
3172
  });
3173
3173
  return clone;
3174
3174
  }
3175
- function noop$5() {
3175
+ function noop$4() {
3176
3176
  }
3177
3177
  let deprecatedWarnList = null;
3178
3178
  function resetWarned() {
3179
3179
  deprecatedWarnList = null;
3180
3180
  resetWarned$1();
3181
3181
  }
3182
- let _warning = noop$5;
3182
+ let _warning = noop$4;
3183
3183
  if (process.env.NODE_ENV !== "production") {
3184
3184
  _warning = (valid2, component, message2) => {
3185
3185
  warningOnce(valid2, `[antd: ${component}] ${message2}`);
@@ -3220,7 +3220,7 @@ const devUseWarning = process.env.NODE_ENV !== "production" ? (component) => {
3220
3220
  } : () => {
3221
3221
  const noopWarning = () => {
3222
3222
  };
3223
- noopWarning.deprecated = noop$5;
3223
+ noopWarning.deprecated = noop$4;
3224
3224
  return noopWarning;
3225
3225
  };
3226
3226
  const ValidateMessagesContext = /* @__PURE__ */ React.createContext(void 0);
@@ -4928,12 +4928,12 @@ function merge$1() {
4928
4928
  return ret;
4929
4929
  }
4930
4930
  var statistic = {};
4931
- function noop$4() {
4931
+ function noop$3() {
4932
4932
  }
4933
4933
  var statisticToken = function statisticToken2(token2) {
4934
4934
  var tokenKeys2;
4935
4935
  var proxy = token2;
4936
- var flush = noop$4;
4936
+ var flush = noop$3;
4937
4937
  if (enableStatistic && typeof Proxy !== "undefined") {
4938
4938
  tokenKeys2 = /* @__PURE__ */ new Set();
4939
4939
  proxy = new Proxy(token2, {
@@ -44901,7 +44901,7 @@ if (process.env.NODE_ENV !== "production") {
44901
44901
  var defaultItemRender = function defaultItemRender2(page, type4, element2) {
44902
44902
  return element2;
44903
44903
  };
44904
- function noop$3() {
44904
+ function noop$2() {
44905
44905
  }
44906
44906
  function isInteger(v) {
44907
44907
  var value2 = Number(v);
@@ -44912,7 +44912,7 @@ function calculatePage(p, pageSize, total) {
44912
44912
  return Math.floor((total - 1) / _pageSize) + 1;
44913
44913
  }
44914
44914
  var Pagination$1 = function Pagination(props) {
44915
- var _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? "rc-pagination" : _props$prefixCls, _props$selectPrefixCl = props.selectPrefixCls, selectPrefixCls = _props$selectPrefixCl === void 0 ? "rc-select" : _props$selectPrefixCl, className = props.className, currentProp = props.current, _props$defaultCurrent = props.defaultCurrent, defaultCurrent = _props$defaultCurrent === void 0 ? 1 : _props$defaultCurrent, _props$total = props.total, total = _props$total === void 0 ? 0 : _props$total, pageSizeProp = props.pageSize, _props$defaultPageSiz = props.defaultPageSize, defaultPageSize = _props$defaultPageSiz === void 0 ? 10 : _props$defaultPageSiz, _props$onChange = props.onChange, onChange = _props$onChange === void 0 ? noop$3 : _props$onChange, hideOnSinglePage = props.hideOnSinglePage, align = props.align, _props$showPrevNextJu = props.showPrevNextJumpers, showPrevNextJumpers = _props$showPrevNextJu === void 0 ? true : _props$showPrevNextJu, showQuickJumper = props.showQuickJumper, showLessItems = props.showLessItems, _props$showTitle = props.showTitle, showTitle = _props$showTitle === void 0 ? true : _props$showTitle, _props$onShowSizeChan = props.onShowSizeChange, onShowSizeChange = _props$onShowSizeChan === void 0 ? noop$3 : _props$onShowSizeChan, _props$locale = props.locale, locale2 = _props$locale === void 0 ? locale$1 : _props$locale, style2 = props.style, _props$totalBoundaryS = props.totalBoundaryShowSizeChanger, totalBoundaryShowSizeChanger = _props$totalBoundaryS === void 0 ? 50 : _props$totalBoundaryS, disabled2 = props.disabled, simple = props.simple, showTotal = props.showTotal, _props$showSizeChange = props.showSizeChanger, showSizeChanger = _props$showSizeChange === void 0 ? total > totalBoundaryShowSizeChanger : _props$showSizeChange, sizeChangerRender = props.sizeChangerRender, pageSizeOptions = props.pageSizeOptions, _props$itemRender = props.itemRender, itemRender = _props$itemRender === void 0 ? defaultItemRender : _props$itemRender, jumpPrevIcon = props.jumpPrevIcon, jumpNextIcon = props.jumpNextIcon, prevIcon = props.prevIcon, nextIcon = props.nextIcon;
44915
+ var _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? "rc-pagination" : _props$prefixCls, _props$selectPrefixCl = props.selectPrefixCls, selectPrefixCls = _props$selectPrefixCl === void 0 ? "rc-select" : _props$selectPrefixCl, className = props.className, currentProp = props.current, _props$defaultCurrent = props.defaultCurrent, defaultCurrent = _props$defaultCurrent === void 0 ? 1 : _props$defaultCurrent, _props$total = props.total, total = _props$total === void 0 ? 0 : _props$total, pageSizeProp = props.pageSize, _props$defaultPageSiz = props.defaultPageSize, defaultPageSize = _props$defaultPageSiz === void 0 ? 10 : _props$defaultPageSiz, _props$onChange = props.onChange, onChange = _props$onChange === void 0 ? noop$2 : _props$onChange, hideOnSinglePage = props.hideOnSinglePage, align = props.align, _props$showPrevNextJu = props.showPrevNextJumpers, showPrevNextJumpers = _props$showPrevNextJu === void 0 ? true : _props$showPrevNextJu, showQuickJumper = props.showQuickJumper, showLessItems = props.showLessItems, _props$showTitle = props.showTitle, showTitle = _props$showTitle === void 0 ? true : _props$showTitle, _props$onShowSizeChan = props.onShowSizeChange, onShowSizeChange = _props$onShowSizeChan === void 0 ? noop$2 : _props$onShowSizeChan, _props$locale = props.locale, locale2 = _props$locale === void 0 ? locale$1 : _props$locale, style2 = props.style, _props$totalBoundaryS = props.totalBoundaryShowSizeChanger, totalBoundaryShowSizeChanger = _props$totalBoundaryS === void 0 ? 50 : _props$totalBoundaryS, disabled2 = props.disabled, simple = props.simple, showTotal = props.showTotal, _props$showSizeChange = props.showSizeChanger, showSizeChanger = _props$showSizeChange === void 0 ? total > totalBoundaryShowSizeChanger : _props$showSizeChange, sizeChangerRender = props.sizeChangerRender, pageSizeOptions = props.pageSizeOptions, _props$itemRender = props.itemRender, itemRender = _props$itemRender === void 0 ? defaultItemRender : _props$itemRender, jumpPrevIcon = props.jumpPrevIcon, jumpNextIcon = props.jumpNextIcon, prevIcon = props.prevIcon, nextIcon = props.nextIcon;
44916
44916
  var paginationRef = React.useRef(null);
44917
44917
  var _useMergedState = useMergedState(10, {
44918
44918
  value: pageSizeProp,
@@ -44929,7 +44929,7 @@ var Pagination$1 = function Pagination(props) {
44929
44929
  React.useEffect(function() {
44930
44930
  setInternalInputVal(current);
44931
44931
  }, [current]);
44932
- var hasOnChange = onChange !== noop$3;
44932
+ var hasOnChange = onChange !== noop$2;
44933
44933
  var hasCurrent = "current" in props;
44934
44934
  if (process.env.NODE_ENV !== "production") {
44935
44935
  warningOnce(hasCurrent ? hasOnChange : true, "You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.");
@@ -53153,7 +53153,7 @@ var HIDDEN_STYLE = {
53153
53153
  padding: 0,
53154
53154
  margin: 0
53155
53155
  };
53156
- var noop$2 = function noop() {
53156
+ var noop$1 = function noop() {
53157
53157
  };
53158
53158
  var MOTION_KEY = "RC_TREE_MOTION_".concat(Math.random());
53159
53159
  var MotionNode = {
@@ -53289,7 +53289,7 @@ var NodeList = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref)
53289
53289
  onFocus,
53290
53290
  onBlur,
53291
53291
  value: "",
53292
- onChange: noop$2,
53292
+ onChange: noop$1,
53293
53293
  "aria-label": "for screen reader"
53294
53294
  })), /* @__PURE__ */ React__namespace.createElement("div", {
53295
53295
  className: "".concat(prefixCls, "-treenode"),
@@ -72306,7 +72306,7 @@ var hasRequiredExtend;
72306
72306
  function requireExtend() {
72307
72307
  if (hasRequiredExtend) return extend$2;
72308
72308
  hasRequiredExtend = 1;
72309
- var hasOwn2 = Object.prototype.hasOwnProperty;
72309
+ var hasOwn = Object.prototype.hasOwnProperty;
72310
72310
  var toStr = Object.prototype.toString;
72311
72311
  var defineProperty = Object.defineProperty;
72312
72312
  var gOPD = Object.getOwnPropertyDescriptor;
@@ -72320,15 +72320,15 @@ function requireExtend() {
72320
72320
  if (!obj || toStr.call(obj) !== "[object Object]") {
72321
72321
  return false;
72322
72322
  }
72323
- var hasOwnConstructor = hasOwn2.call(obj, "constructor");
72324
- var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn2.call(obj.constructor.prototype, "isPrototypeOf");
72323
+ var hasOwnConstructor = hasOwn.call(obj, "constructor");
72324
+ var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
72325
72325
  if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
72326
72326
  return false;
72327
72327
  }
72328
72328
  var key;
72329
72329
  for (key in obj) {
72330
72330
  }
72331
- return typeof key === "undefined" || hasOwn2.call(obj, key);
72331
+ return typeof key === "undefined" || hasOwn.call(obj, key);
72332
72332
  };
72333
72333
  var setProperty = function setProperty2(target, options) {
72334
72334
  if (defineProperty && options.name === "__proto__") {
@@ -72344,7 +72344,7 @@ function requireExtend() {
72344
72344
  };
72345
72345
  var getProperty = function getProperty2(obj, name2) {
72346
72346
  if (name2 === "__proto__") {
72347
- if (!hasOwn2.call(obj, name2)) {
72347
+ if (!hasOwn.call(obj, name2)) {
72348
72348
  return void 0;
72349
72349
  } else if (gOPD) {
72350
72350
  return gOPD(obj, name2).value;
@@ -72394,7 +72394,7 @@ function requireExtend() {
72394
72394
  }
72395
72395
  var extendExports = requireExtend();
72396
72396
  const extend$1 = /* @__PURE__ */ getDefaultExportFromCjs(extendExports);
72397
- function isPlainObject$1(value2) {
72397
+ function isPlainObject(value2) {
72398
72398
  if (typeof value2 !== "object" || value2 === null) {
72399
72399
  return false;
72400
72400
  }
@@ -73798,7 +73798,7 @@ class Processor extends CallableInstance {
73798
73798
  } else if (parameters2.length > 0) {
73799
73799
  let [primary, ...rest] = parameters2;
73800
73800
  const currentPrimary = attachers[entryIndex][1];
73801
- if (isPlainObject$1(currentPrimary) && isPlainObject$1(primary)) {
73801
+ if (isPlainObject(currentPrimary) && isPlainObject(primary)) {
73802
73802
  primary = extend$1(true, currentPrimary, primary);
73803
73803
  }
73804
73804
  attachers[entryIndex] = [plugin, primary, ...rest];
@@ -73825,7 +73825,7 @@ function assertUnfrozen(name2, frozen) {
73825
73825
  }
73826
73826
  }
73827
73827
  function assertNode(node2) {
73828
- if (!isPlainObject$1(node2) || typeof node2.type !== "string") {
73828
+ if (!isPlainObject(node2) || typeof node2.type !== "string") {
73829
73829
  throw new TypeError("Expected node, got `" + node2 + "`");
73830
73830
  }
73831
73831
  }
@@ -74722,7 +74722,7 @@ function range2(start2, stop, step) {
74722
74722
  }
74723
74723
  return range3;
74724
74724
  }
74725
- var noop$1 = { value: () => {
74725
+ var noop2 = { value: () => {
74726
74726
  } };
74727
74727
  function dispatch() {
74728
74728
  for (var i = 0, n2 = arguments.length, _ = {}, t2; i < n2; ++i) {
@@ -74782,7 +74782,7 @@ function get$1(type4, name2) {
74782
74782
  function set$1(type4, name2, callback) {
74783
74783
  for (var i = 0, n2 = type4.length; i < n2; ++i) {
74784
74784
  if (type4[i].name === name2) {
74785
- type4[i] = noop$1, type4 = type4.slice(0, i).concat(type4.slice(i + 1));
74785
+ type4[i] = noop2, type4 = type4.slice(0, i).concat(type4.slice(i + 1));
74786
74786
  break;
74787
74787
  }
74788
74788
  }
@@ -80914,16 +80914,21 @@ const OverflowMenuContainer = styled.div`
80914
80914
  animation: ${({ $placement, $isAnimating }) => {
80915
80915
  if (!$isAnimating) return "none";
80916
80916
  switch ($placement) {
80917
- case "bottom":
80917
+ case "bottom": {
80918
80918
  return slideDown;
80919
- case "top":
80919
+ }
80920
+ case "top": {
80920
80921
  return slideUp;
80921
- case "left":
80922
+ }
80923
+ case "left": {
80922
80924
  return slideLeft;
80923
- case "right":
80925
+ }
80926
+ case "right": {
80924
80927
  return slideRight;
80925
- default:
80928
+ }
80929
+ default: {
80926
80930
  return slideDown;
80931
+ }
80927
80932
  }
80928
80933
  }}
80929
80934
  0.15s cubic-bezier(0.4, 0, 0.2, 1);
@@ -80961,112 +80966,136 @@ const OverflowMenuItem = ({ children: children2, onClick }) => {
80961
80966
  const DefaultTrigger = () => {
80962
80967
  return /* @__PURE__ */ jsxRuntime.jsx(Button$1, { isIconButton: true, themeType: "secondary", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(HiDotsHorizontal, {}) });
80963
80968
  };
80964
- const OverflowMenu = ({
80965
- items,
80966
- children: children2,
80967
- trigger = /* @__PURE__ */ jsxRuntime.jsx(DefaultTrigger, {}),
80968
- isOpen: controlledIsOpen,
80969
- onOpenChange,
80970
- placement = "bottom",
80971
- alignment = "left",
80972
- offset: offset2 = 8,
80973
- className,
80974
- style: style2,
80975
- onItemClick
80976
- }) => {
80977
- const [internalIsOpen, setInternalIsOpen] = React.useState(false);
80978
- const [isAnimating, setIsAnimating] = React.useState(false);
80979
- const triggerRef = React.useRef(null);
80980
- const menuRef = React.useRef(null);
80981
- const { theme } = useGenesis();
80982
- const isOpen = controlledIsOpen === void 0 ? internalIsOpen : controlledIsOpen;
80983
- const handleOpenChange = React.useCallback(
80984
- (open) => {
80985
- if (onOpenChange) {
80986
- onOpenChange(open);
80987
- } else {
80988
- setInternalIsOpen(open);
80989
- }
80990
- },
80991
- [onOpenChange]
80992
- );
80993
- const handleTriggerClick = () => {
80994
- handleOpenChange(!isOpen);
80995
- };
80996
- const handleClickOutside = React.useCallback(
80997
- (event) => {
80998
- if (triggerRef.current && menuRef.current && !triggerRef.current.contains(event.target) && !menuRef.current.contains(event.target)) {
80999
- handleOpenChange(false);
81000
- }
81001
- },
81002
- [handleOpenChange]
81003
- );
81004
- React.useEffect(() => {
81005
- if (isOpen) {
81006
- const timer2 = setTimeout(() => {
81007
- setIsAnimating(true);
81008
- }, 10);
81009
- document.addEventListener("mousedown", handleClickOutside);
81010
- return () => {
81011
- clearTimeout(timer2);
81012
- document.removeEventListener("mousedown", handleClickOutside);
81013
- };
81014
- } else {
81015
- setIsAnimating(false);
81016
- document.removeEventListener("mousedown", handleClickOutside);
81017
- }
81018
- }, [isOpen, handleClickOutside]);
81019
- const getMenuStyle = React.useMemo(() => {
81020
- const baseStyle = {
81021
- position: "absolute",
81022
- zIndex: 1e3,
81023
- ...style2
80969
+ const OverflowMenu = React.forwardRef(
80970
+ ({
80971
+ items,
80972
+ children: children2,
80973
+ trigger = /* @__PURE__ */ jsxRuntime.jsx(DefaultTrigger, {}),
80974
+ isOpen: controlledIsOpen,
80975
+ onOpenChange,
80976
+ placement = "bottom",
80977
+ alignment = "left",
80978
+ offset: offset2 = 8,
80979
+ className,
80980
+ style: style2,
80981
+ onItemClick
80982
+ }, ref) => {
80983
+ const [internalIsOpen, setInternalIsOpen] = React.useState(false);
80984
+ const [isAnimating, setIsAnimating] = React.useState(false);
80985
+ const triggerRef = React.useRef(null);
80986
+ const menuRef = React.useRef(null);
80987
+ const { theme } = useGenesis();
80988
+ const isOpen = controlledIsOpen === void 0 ? internalIsOpen : controlledIsOpen;
80989
+ const handleOpenChange = React.useCallback(
80990
+ (open) => {
80991
+ if (onOpenChange) {
80992
+ onOpenChange(open);
80993
+ } else {
80994
+ setInternalIsOpen(open);
80995
+ }
80996
+ },
80997
+ [onOpenChange]
80998
+ );
80999
+ const handleTriggerClick = () => {
81000
+ handleOpenChange(!isOpen);
81024
81001
  };
81025
- switch (placement) {
81026
- case "bottom": {
81027
- return {
81028
- ...baseStyle,
81029
- top: `calc(100% + ${offset2}px)`,
81030
- ...alignment === "right" ? { right: 0 } : { left: 0 }
81031
- };
81032
- }
81033
- case "top": {
81034
- return {
81035
- ...baseStyle,
81036
- bottom: `calc(100% + ${offset2}px)`,
81037
- ...alignment === "right" ? { right: 0 } : { left: 0 }
81038
- };
81039
- }
81040
- case "left": {
81041
- return {
81042
- ...baseStyle,
81043
- top: 0,
81044
- right: `calc(100% + ${offset2}px)`,
81045
- ...alignment === "right" ? { bottom: 0 } : {}
81046
- };
81047
- }
81048
- case "right": {
81049
- return {
81050
- ...baseStyle,
81051
- top: 0,
81052
- left: `calc(100% + ${offset2}px)`,
81053
- ...alignment === "right" ? { bottom: 0 } : {}
81002
+ const handleClickOutside = React.useCallback(
81003
+ (event) => {
81004
+ if (triggerRef.current && menuRef.current && !triggerRef.current.contains(event.target) && !menuRef.current.contains(event.target)) {
81005
+ handleOpenChange(false);
81006
+ }
81007
+ },
81008
+ [handleOpenChange]
81009
+ );
81010
+ React.useEffect(() => {
81011
+ if (isOpen) {
81012
+ const timer2 = setTimeout(() => {
81013
+ setIsAnimating(true);
81014
+ }, 10);
81015
+ document.addEventListener("mousedown", handleClickOutside);
81016
+ return () => {
81017
+ clearTimeout(timer2);
81018
+ document.removeEventListener("mousedown", handleClickOutside);
81054
81019
  };
81020
+ } else {
81021
+ setIsAnimating(false);
81022
+ document.removeEventListener("mousedown", handleClickOutside);
81055
81023
  }
81056
- default: {
81057
- return baseStyle;
81024
+ }, [isOpen, handleClickOutside]);
81025
+ const getMenuStyle = React.useMemo(() => {
81026
+ const baseStyle = {
81027
+ position: "absolute",
81028
+ zIndex: 1e3,
81029
+ ...style2
81030
+ };
81031
+ switch (placement) {
81032
+ case "bottom": {
81033
+ return {
81034
+ ...baseStyle,
81035
+ top: `calc(100% + ${offset2}px)`,
81036
+ ...alignment === "right" ? { right: 0 } : { left: 0 }
81037
+ };
81038
+ }
81039
+ case "top": {
81040
+ return {
81041
+ ...baseStyle,
81042
+ bottom: `calc(100% + ${offset2}px)`,
81043
+ ...alignment === "right" ? { right: 0 } : { left: 0 }
81044
+ };
81045
+ }
81046
+ case "left": {
81047
+ return {
81048
+ ...baseStyle,
81049
+ top: 0,
81050
+ right: `calc(100% + ${offset2}px)`,
81051
+ ...alignment === "right" ? { bottom: 0 } : {}
81052
+ };
81053
+ }
81054
+ case "right": {
81055
+ return {
81056
+ ...baseStyle,
81057
+ top: 0,
81058
+ left: `calc(100% + ${offset2}px)`,
81059
+ ...alignment === "right" ? { bottom: 0 } : {}
81060
+ };
81061
+ }
81062
+ default: {
81063
+ return baseStyle;
81064
+ }
81058
81065
  }
81066
+ }, [placement, alignment, offset2, style2]);
81067
+ const handleItemClick = React.useCallback(
81068
+ (item) => {
81069
+ onItemClick?.(item);
81070
+ handleOpenChange(false);
81071
+ },
81072
+ [onItemClick, handleOpenChange]
81073
+ );
81074
+ if (items && items.length > 0) {
81075
+ return /* @__PURE__ */ jsxRuntime.jsxs(OverflowMenuWrapper, { ref, children: [
81076
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: trigger }),
81077
+ isOpen && /* @__PURE__ */ jsxRuntime.jsx(
81078
+ OverflowMenuContainer,
81079
+ {
81080
+ ref: menuRef,
81081
+ theme,
81082
+ className,
81083
+ style: getMenuStyle,
81084
+ $isAnimating: isAnimating,
81085
+ $placement: placement,
81086
+ children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
81087
+ OverflowMenuItem,
81088
+ {
81089
+ ...item,
81090
+ onClick: () => handleItemClick(item)
81091
+ },
81092
+ item.id
81093
+ ))
81094
+ }
81095
+ )
81096
+ ] });
81059
81097
  }
81060
- }, [placement, alignment, offset2, style2]);
81061
- const handleItemClick = React.useCallback(
81062
- (item) => {
81063
- onItemClick?.(item);
81064
- handleOpenChange(false);
81065
- },
81066
- [onItemClick, handleOpenChange]
81067
- );
81068
- if (items && items.length > 0) {
81069
- return /* @__PURE__ */ jsxRuntime.jsxs(OverflowMenuWrapper, { children: [
81098
+ return /* @__PURE__ */ jsxRuntime.jsxs(OverflowMenuWrapper, { ref, children: [
81070
81099
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: trigger }),
81071
81100
  isOpen && /* @__PURE__ */ jsxRuntime.jsx(
81072
81101
  OverflowMenuContainer,
@@ -81077,34 +81106,13 @@ const OverflowMenu = ({
81077
81106
  style: getMenuStyle,
81078
81107
  $isAnimating: isAnimating,
81079
81108
  $placement: placement,
81080
- children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
81081
- OverflowMenuItem,
81082
- {
81083
- ...item,
81084
- onClick: () => handleItemClick(item)
81085
- },
81086
- item.id
81087
- ))
81109
+ children: children2
81088
81110
  }
81089
81111
  )
81090
81112
  ] });
81091
81113
  }
81092
- return /* @__PURE__ */ jsxRuntime.jsxs(OverflowMenuWrapper, { children: [
81093
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: trigger }),
81094
- isOpen && /* @__PURE__ */ jsxRuntime.jsx(
81095
- OverflowMenuContainer,
81096
- {
81097
- ref: menuRef,
81098
- theme,
81099
- className,
81100
- style: getMenuStyle,
81101
- $isAnimating: isAnimating,
81102
- $placement: placement,
81103
- children: children2
81104
- }
81105
- )
81106
- ] });
81107
- };
81114
+ );
81115
+ OverflowMenu.displayName = "OverflowMenu";
81108
81116
  const getGenesisClass$6 = (theme) => ``;
81109
81117
  const Popover$1 = styled(Popconfirm)`
81110
81118
  ${({ theme }) => {
@@ -84331,1231 +84339,105 @@ const CustomPagination = ({
84331
84339
  }
84332
84340
  return null;
84333
84341
  };
84334
- var Subscribable = class {
84335
- constructor() {
84336
- this.listeners = /* @__PURE__ */ new Set();
84337
- this.subscribe = this.subscribe.bind(this);
84338
- }
84339
- subscribe(listener) {
84340
- this.listeners.add(listener);
84341
- this.onSubscribe();
84342
- return () => {
84343
- this.listeners.delete(listener);
84344
- this.onUnsubscribe();
84345
- };
84346
- }
84347
- hasListeners() {
84348
- return this.listeners.size > 0;
84349
- }
84350
- onSubscribe() {
84351
- }
84352
- onUnsubscribe() {
84353
- }
84354
- };
84355
- var defaultTimeoutProvider = {
84356
- // We need the wrapper function syntax below instead of direct references to
84357
- // global setTimeout etc.
84358
- //
84359
- // BAD: `setTimeout: setTimeout`
84360
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
84361
- //
84362
- // If we use direct references here, then anything that wants to spy on or
84363
- // replace the global setTimeout (like tests) won't work since we'll already
84364
- // have a hard reference to the original implementation at the time when this
84365
- // file was imported.
84366
- setTimeout: (callback, delay) => setTimeout(callback, delay),
84367
- clearTimeout: (timeoutId) => clearTimeout(timeoutId),
84368
- setInterval: (callback, delay) => setInterval(callback, delay),
84369
- clearInterval: (intervalId) => clearInterval(intervalId)
84370
- };
84371
- var TimeoutManager = class {
84372
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
84373
- // type at app boot; and if we leave that type, then any new timer provider
84374
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
84375
- //
84376
- // We settle for type safety for the TimeoutProvider type, and accept that
84377
- // this class is unsafe internally to allow for extension.
84378
- #provider = defaultTimeoutProvider;
84379
- #providerCalled = false;
84380
- setTimeoutProvider(provider) {
84381
- if (process.env.NODE_ENV !== "production") {
84382
- if (this.#providerCalled && provider !== this.#provider) {
84383
- console.error(
84384
- `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
84385
- { previous: this.#provider, provider }
84386
- );
84387
- }
84388
- }
84389
- this.#provider = provider;
84390
- if (process.env.NODE_ENV !== "production") {
84391
- this.#providerCalled = false;
84392
- }
84393
- }
84394
- setTimeout(callback, delay) {
84395
- if (process.env.NODE_ENV !== "production") {
84396
- this.#providerCalled = true;
84397
- }
84398
- return this.#provider.setTimeout(callback, delay);
84399
- }
84400
- clearTimeout(timeoutId) {
84401
- this.#provider.clearTimeout(timeoutId);
84402
- }
84403
- setInterval(callback, delay) {
84404
- if (process.env.NODE_ENV !== "production") {
84405
- this.#providerCalled = true;
84406
- }
84407
- return this.#provider.setInterval(callback, delay);
84408
- }
84409
- clearInterval(intervalId) {
84410
- this.#provider.clearInterval(intervalId);
84411
- }
84412
- };
84413
- var timeoutManager = new TimeoutManager();
84414
- function systemSetTimeoutZero(callback) {
84415
- setTimeout(callback, 0);
84416
- }
84417
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
84418
- function noop2() {
84419
- }
84420
- function isValidTimeout(value2) {
84421
- return typeof value2 === "number" && value2 >= 0 && value2 !== Infinity;
84422
- }
84423
- function timeUntilStale(updatedAt, staleTime) {
84424
- return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
84425
- }
84426
- function resolveStaleTime(staleTime, query) {
84427
- return typeof staleTime === "function" ? staleTime(query) : staleTime;
84428
- }
84429
- function resolveEnabled(enabled, query) {
84430
- return typeof enabled === "function" ? enabled(query) : enabled;
84431
- }
84432
- var hasOwn = Object.prototype.hasOwnProperty;
84433
- function replaceEqualDeep(a, b) {
84434
- if (a === b) {
84435
- return a;
84436
- }
84437
- const array4 = isPlainArray(a) && isPlainArray(b);
84438
- if (!array4 && !(isPlainObject(a) && isPlainObject(b))) return b;
84439
- const aItems = array4 ? a : Object.keys(a);
84440
- const aSize = aItems.length;
84441
- const bItems = array4 ? b : Object.keys(b);
84442
- const bSize = bItems.length;
84443
- const copy2 = array4 ? new Array(bSize) : {};
84444
- let equalItems = 0;
84445
- for (let i = 0; i < bSize; i++) {
84446
- const key = array4 ? i : bItems[i];
84447
- const aItem = a[key];
84448
- const bItem = b[key];
84449
- if (aItem === bItem) {
84450
- copy2[key] = aItem;
84451
- if (array4 ? i < aSize : hasOwn.call(a, key)) equalItems++;
84452
- continue;
84453
- }
84454
- if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
84455
- copy2[key] = bItem;
84456
- continue;
84457
- }
84458
- const v = replaceEqualDeep(aItem, bItem);
84459
- copy2[key] = v;
84460
- if (v === aItem) equalItems++;
84461
- }
84462
- return aSize === bSize && equalItems === aSize ? a : copy2;
84463
- }
84464
- function shallowEqualObjects(a, b) {
84465
- if (!b || Object.keys(a).length !== Object.keys(b).length) {
84466
- return false;
84467
- }
84468
- for (const key in a) {
84469
- if (a[key] !== b[key]) {
84470
- return false;
84471
- }
84472
- }
84473
- return true;
84474
- }
84475
- function isPlainArray(value2) {
84476
- return Array.isArray(value2) && value2.length === Object.keys(value2).length;
84477
- }
84478
- function isPlainObject(o2) {
84479
- if (!hasObjectPrototype(o2)) {
84480
- return false;
84481
- }
84482
- const ctor = o2.constructor;
84483
- if (ctor === void 0) {
84484
- return true;
84485
- }
84486
- const prot = ctor.prototype;
84487
- if (!hasObjectPrototype(prot)) {
84488
- return false;
84489
- }
84490
- if (!prot.hasOwnProperty("isPrototypeOf")) {
84491
- return false;
84492
- }
84493
- if (Object.getPrototypeOf(o2) !== Object.prototype) {
84494
- return false;
84495
- }
84496
- return true;
84497
- }
84498
- function hasObjectPrototype(o2) {
84499
- return Object.prototype.toString.call(o2) === "[object Object]";
84500
- }
84501
- function replaceData(prevData, data, options) {
84502
- if (typeof options.structuralSharing === "function") {
84503
- return options.structuralSharing(prevData, data);
84504
- } else if (options.structuralSharing !== false) {
84505
- if (process.env.NODE_ENV !== "production") {
84506
- try {
84507
- return replaceEqualDeep(prevData, data);
84508
- } catch (error2) {
84509
- console.error(
84510
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error2}`
84511
- );
84512
- throw error2;
84513
- }
84514
- }
84515
- return replaceEqualDeep(prevData, data);
84516
- }
84517
- return data;
84518
- }
84519
- function addToEnd(items, item, max2 = 0) {
84520
- const newItems = [...items, item];
84521
- return max2 && newItems.length > max2 ? newItems.slice(1) : newItems;
84522
- }
84523
- function addToStart(items, item, max2 = 0) {
84524
- const newItems = [item, ...items];
84525
- return max2 && newItems.length > max2 ? newItems.slice(0, -1) : newItems;
84526
- }
84527
- var skipToken = Symbol();
84528
- function ensureQueryFn(options, fetchOptions) {
84529
- if (process.env.NODE_ENV !== "production") {
84530
- if (options.queryFn === skipToken) {
84531
- console.error(
84532
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
84533
- );
84534
- }
84535
- }
84536
- if (!options.queryFn && fetchOptions?.initialPromise) {
84537
- return () => fetchOptions.initialPromise;
84538
- }
84539
- if (!options.queryFn || options.queryFn === skipToken) {
84540
- return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
84541
- }
84542
- return options.queryFn;
84543
- }
84544
- function shouldThrowError(throwOnError, params) {
84545
- if (typeof throwOnError === "function") {
84546
- return throwOnError(...params);
84547
- }
84548
- return !!throwOnError;
84549
- }
84550
- var FocusManager = class extends Subscribable {
84551
- #focused;
84552
- #cleanup;
84553
- #setup;
84554
- constructor() {
84555
- super();
84556
- this.#setup = (onFocus) => {
84557
- if (!isServer && window.addEventListener) {
84558
- const listener = () => onFocus();
84559
- window.addEventListener("visibilitychange", listener, false);
84560
- return () => {
84561
- window.removeEventListener("visibilitychange", listener);
84562
- };
84563
- }
84564
- return;
84565
- };
84566
- }
84567
- onSubscribe() {
84568
- if (!this.#cleanup) {
84569
- this.setEventListener(this.#setup);
84570
- }
84571
- }
84572
- onUnsubscribe() {
84573
- if (!this.hasListeners()) {
84574
- this.#cleanup?.();
84575
- this.#cleanup = void 0;
84576
- }
84577
- }
84578
- setEventListener(setup) {
84579
- this.#setup = setup;
84580
- this.#cleanup?.();
84581
- this.#cleanup = setup((focused) => {
84582
- if (typeof focused === "boolean") {
84583
- this.setFocused(focused);
84584
- } else {
84585
- this.onFocus();
84586
- }
84587
- });
84588
- }
84589
- setFocused(focused) {
84590
- const changed = this.#focused !== focused;
84591
- if (changed) {
84592
- this.#focused = focused;
84593
- this.onFocus();
84594
- }
84595
- }
84596
- onFocus() {
84597
- const isFocused = this.isFocused();
84598
- this.listeners.forEach((listener) => {
84599
- listener(isFocused);
84600
- });
84601
- }
84602
- isFocused() {
84603
- if (typeof this.#focused === "boolean") {
84604
- return this.#focused;
84605
- }
84606
- return globalThis.document?.visibilityState !== "hidden";
84607
- }
84608
- };
84609
- var focusManager = new FocusManager();
84610
- function pendingThenable() {
84611
- let resolve;
84612
- let reject;
84613
- const thenable = new Promise((_resolve, _reject) => {
84614
- resolve = _resolve;
84615
- reject = _reject;
84616
- });
84617
- thenable.status = "pending";
84618
- thenable.catch(() => {
84619
- });
84620
- function finalize(data) {
84621
- Object.assign(thenable, data);
84622
- delete thenable.resolve;
84623
- delete thenable.reject;
84624
- }
84625
- thenable.resolve = (value2) => {
84626
- finalize({
84627
- status: "fulfilled",
84628
- value: value2
84629
- });
84630
- resolve(value2);
84631
- };
84632
- thenable.reject = (reason) => {
84633
- finalize({
84634
- status: "rejected",
84635
- reason
84636
- });
84637
- reject(reason);
84638
- };
84639
- return thenable;
84640
- }
84641
- var defaultScheduler = systemSetTimeoutZero;
84642
- function createNotifyManager() {
84643
- let queue = [];
84644
- let transactions = 0;
84645
- let notifyFn = (callback) => {
84646
- callback();
84647
- };
84648
- let batchNotifyFn = (callback) => {
84649
- callback();
84650
- };
84651
- let scheduleFn = defaultScheduler;
84652
- const schedule2 = (callback) => {
84653
- if (transactions) {
84654
- queue.push(callback);
84655
- } else {
84656
- scheduleFn(() => {
84657
- notifyFn(callback);
84658
- });
84659
- }
84660
- };
84661
- const flush = () => {
84662
- const originalQueue = queue;
84663
- queue = [];
84664
- if (originalQueue.length) {
84665
- scheduleFn(() => {
84666
- batchNotifyFn(() => {
84667
- originalQueue.forEach((callback) => {
84668
- notifyFn(callback);
84669
- });
84670
- });
84671
- });
84672
- }
84673
- };
84674
- return {
84675
- batch: (callback) => {
84676
- let result;
84677
- transactions++;
84342
+ const useInfiniteQuery = ({
84343
+ queryKey: queryKey2,
84344
+ queryFn,
84345
+ initialPageParam,
84346
+ getNextPageParam
84347
+ }) => {
84348
+ const [pages, setPages] = React.useState([]);
84349
+ const [error2, setError] = React.useState(null);
84350
+ const [isFetchingNextPage, setIsFetchingNextPage] = React.useState(false);
84351
+ const [status, setStatus] = React.useState(
84352
+ "pending"
84353
+ );
84354
+ const [hasNextPage, setHasNextPage] = React.useState(true);
84355
+ const [isInitialLoad, setIsInitialLoad] = React.useState(true);
84356
+ const abortControllerRef = React.useRef(null);
84357
+ const isFetchingRef = React.useRef(false);
84358
+ React.useEffect(() => {
84359
+ setPages([]);
84360
+ setError(null);
84361
+ setStatus("pending");
84362
+ setHasNextPage(true);
84363
+ setIsInitialLoad(true);
84364
+ isFetchingRef.current = false;
84365
+ }, [queryKey2]);
84366
+ const fetchPage = React.useCallback(
84367
+ async (pageParam) => {
84368
+ if (isFetchingRef.current) return;
84369
+ isFetchingRef.current = true;
84370
+ setError(null);
84371
+ if (abortControllerRef.current) {
84372
+ abortControllerRef.current.abort();
84373
+ }
84374
+ abortControllerRef.current = new AbortController();
84678
84375
  try {
84679
- result = callback();
84680
- } finally {
84681
- transactions--;
84682
- if (!transactions) {
84683
- flush();
84376
+ const result = await queryFn({ pageParam });
84377
+ if (abortControllerRef.current?.signal.aborted) {
84378
+ return;
84684
84379
  }
84685
- }
84686
- return result;
84687
- },
84688
- /**
84689
- * All calls to the wrapped function will be batched.
84690
- */
84691
- batchCalls: (callback) => {
84692
- return (...args) => {
84693
- schedule2(() => {
84694
- callback(...args);
84695
- });
84696
- };
84697
- },
84698
- schedule: schedule2,
84699
- /**
84700
- * Use this method to set a custom notify function.
84701
- * This can be used to for example wrap notifications with `React.act` while running tests.
84702
- */
84703
- setNotifyFunction: (fn) => {
84704
- notifyFn = fn;
84705
- },
84706
- /**
84707
- * Use this method to set a custom function to batch notifications together into a single tick.
84708
- * By default React Query will use the batch function provided by ReactDOM or React Native.
84709
- */
84710
- setBatchNotifyFunction: (fn) => {
84711
- batchNotifyFn = fn;
84712
- },
84713
- setScheduler: (fn) => {
84714
- scheduleFn = fn;
84715
- }
84716
- };
84717
- }
84718
- var notifyManager = createNotifyManager();
84719
- var OnlineManager = class extends Subscribable {
84720
- #online = true;
84721
- #cleanup;
84722
- #setup;
84723
- constructor() {
84724
- super();
84725
- this.#setup = (onOnline) => {
84726
- if (!isServer && window.addEventListener) {
84727
- const onlineListener = () => onOnline(true);
84728
- const offlineListener = () => onOnline(false);
84729
- window.addEventListener("online", onlineListener, false);
84730
- window.addEventListener("offline", offlineListener, false);
84731
- return () => {
84732
- window.removeEventListener("online", onlineListener);
84733
- window.removeEventListener("offline", offlineListener);
84734
- };
84735
- }
84736
- return;
84737
- };
84738
- }
84739
- onSubscribe() {
84740
- if (!this.#cleanup) {
84741
- this.setEventListener(this.#setup);
84742
- }
84743
- }
84744
- onUnsubscribe() {
84745
- if (!this.hasListeners()) {
84746
- this.#cleanup?.();
84747
- this.#cleanup = void 0;
84748
- }
84749
- }
84750
- setEventListener(setup) {
84751
- this.#setup = setup;
84752
- this.#cleanup?.();
84753
- this.#cleanup = setup(this.setOnline.bind(this));
84754
- }
84755
- setOnline(online) {
84756
- const changed = this.#online !== online;
84757
- if (changed) {
84758
- this.#online = online;
84759
- this.listeners.forEach((listener) => {
84760
- listener(online);
84761
- });
84762
- }
84763
- }
84764
- isOnline() {
84765
- return this.#online;
84766
- }
84767
- };
84768
- var onlineManager = new OnlineManager();
84769
- function canFetch(networkMode) {
84770
- return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
84771
- }
84772
- function fetchState(data, options) {
84773
- return {
84774
- fetchFailureCount: 0,
84775
- fetchFailureReason: null,
84776
- fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
84777
- ...data === void 0 && {
84778
- error: null,
84779
- status: "pending"
84780
- }
84781
- };
84782
- }
84783
- var QueryObserver = class extends Subscribable {
84784
- constructor(client, options) {
84785
- super();
84786
- this.options = options;
84787
- this.#client = client;
84788
- this.#selectError = null;
84789
- this.#currentThenable = pendingThenable();
84790
- this.bindMethods();
84791
- this.setOptions(options);
84792
- }
84793
- #client;
84794
- #currentQuery = void 0;
84795
- #currentQueryInitialState = void 0;
84796
- #currentResult = void 0;
84797
- #currentResultState;
84798
- #currentResultOptions;
84799
- #currentThenable;
84800
- #selectError;
84801
- #selectFn;
84802
- #selectResult;
84803
- // This property keeps track of the last query with defined data.
84804
- // It will be used to pass the previous data and query to the placeholder function between renders.
84805
- #lastQueryWithDefinedData;
84806
- #staleTimeoutId;
84807
- #refetchIntervalId;
84808
- #currentRefetchInterval;
84809
- #trackedProps = /* @__PURE__ */ new Set();
84810
- bindMethods() {
84811
- this.refetch = this.refetch.bind(this);
84812
- }
84813
- onSubscribe() {
84814
- if (this.listeners.size === 1) {
84815
- this.#currentQuery.addObserver(this);
84816
- if (shouldFetchOnMount(this.#currentQuery, this.options)) {
84817
- this.#executeFetch();
84818
- } else {
84819
- this.updateResult();
84820
- }
84821
- this.#updateTimers();
84822
- }
84823
- }
84824
- onUnsubscribe() {
84825
- if (!this.hasListeners()) {
84826
- this.destroy();
84827
- }
84828
- }
84829
- shouldFetchOnReconnect() {
84830
- return shouldFetchOn(
84831
- this.#currentQuery,
84832
- this.options,
84833
- this.options.refetchOnReconnect
84834
- );
84835
- }
84836
- shouldFetchOnWindowFocus() {
84837
- return shouldFetchOn(
84838
- this.#currentQuery,
84839
- this.options,
84840
- this.options.refetchOnWindowFocus
84841
- );
84842
- }
84843
- destroy() {
84844
- this.listeners = /* @__PURE__ */ new Set();
84845
- this.#clearStaleTimeout();
84846
- this.#clearRefetchInterval();
84847
- this.#currentQuery.removeObserver(this);
84848
- }
84849
- setOptions(options) {
84850
- const prevOptions = this.options;
84851
- const prevQuery = this.#currentQuery;
84852
- this.options = this.#client.defaultQueryOptions(options);
84853
- if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") {
84854
- throw new Error(
84855
- "Expected enabled to be a boolean or a callback that returns a boolean"
84856
- );
84857
- }
84858
- this.#updateQuery();
84859
- this.#currentQuery.setOptions(this.options);
84860
- if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
84861
- this.#client.getQueryCache().notify({
84862
- type: "observerOptionsUpdated",
84863
- query: this.#currentQuery,
84864
- observer: this
84865
- });
84866
- }
84867
- const mounted = this.hasListeners();
84868
- if (mounted && shouldFetchOptionally(
84869
- this.#currentQuery,
84870
- prevQuery,
84871
- this.options,
84872
- prevOptions
84873
- )) {
84874
- this.#executeFetch();
84875
- }
84876
- this.updateResult();
84877
- if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {
84878
- this.#updateStaleTimeout();
84879
- }
84880
- const nextRefetchInterval = this.#computeRefetchInterval();
84881
- if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {
84882
- this.#updateRefetchInterval(nextRefetchInterval);
84883
- }
84884
- }
84885
- getOptimisticResult(options) {
84886
- const query = this.#client.getQueryCache().build(this.#client, options);
84887
- const result = this.createResult(query, options);
84888
- if (shouldAssignObserverCurrentProperties(this, result)) {
84889
- this.#currentResult = result;
84890
- this.#currentResultOptions = this.options;
84891
- this.#currentResultState = this.#currentQuery.state;
84892
- }
84893
- return result;
84894
- }
84895
- getCurrentResult() {
84896
- return this.#currentResult;
84897
- }
84898
- trackResult(result, onPropTracked) {
84899
- return new Proxy(result, {
84900
- get: (target, key) => {
84901
- this.trackProp(key);
84902
- onPropTracked?.(key);
84903
- if (key === "promise" && !this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") {
84904
- this.#currentThenable.reject(
84905
- new Error(
84906
- "experimental_prefetchInRender feature flag is not enabled"
84907
- )
84380
+ setPages((prevPages) => {
84381
+ const pageExists = prevPages.some(
84382
+ (page) => page.page === result.page
84908
84383
  );
84384
+ if (pageExists) {
84385
+ return prevPages;
84386
+ }
84387
+ return [...prevPages, result];
84388
+ });
84389
+ setStatus("success");
84390
+ setHasNextPage(result.hasNextPage);
84391
+ if (isInitialLoad) {
84392
+ setIsInitialLoad(false);
84909
84393
  }
84910
- return Reflect.get(target, key);
84911
- }
84912
- });
84913
- }
84914
- trackProp(key) {
84915
- this.#trackedProps.add(key);
84916
- }
84917
- getCurrentQuery() {
84918
- return this.#currentQuery;
84919
- }
84920
- refetch({ ...options } = {}) {
84921
- return this.fetch({
84922
- ...options
84923
- });
84924
- }
84925
- fetchOptimistic(options) {
84926
- const defaultedOptions = this.#client.defaultQueryOptions(options);
84927
- const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
84928
- return query.fetch().then(() => this.createResult(query, defaultedOptions));
84929
- }
84930
- fetch(fetchOptions) {
84931
- return this.#executeFetch({
84932
- ...fetchOptions,
84933
- cancelRefetch: fetchOptions.cancelRefetch ?? true
84934
- }).then(() => {
84935
- this.updateResult();
84936
- return this.#currentResult;
84937
- });
84938
- }
84939
- #executeFetch(fetchOptions) {
84940
- this.#updateQuery();
84941
- let promise = this.#currentQuery.fetch(
84942
- this.options,
84943
- fetchOptions
84944
- );
84945
- if (!fetchOptions?.throwOnError) {
84946
- promise = promise.catch(noop2);
84947
- }
84948
- return promise;
84949
- }
84950
- #updateStaleTimeout() {
84951
- this.#clearStaleTimeout();
84952
- const staleTime = resolveStaleTime(
84953
- this.options.staleTime,
84954
- this.#currentQuery
84955
- );
84956
- if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) {
84957
- return;
84958
- }
84959
- const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime);
84960
- const timeout2 = time + 1;
84961
- this.#staleTimeoutId = timeoutManager.setTimeout(() => {
84962
- if (!this.#currentResult.isStale) {
84963
- this.updateResult();
84964
- }
84965
- }, timeout2);
84966
- }
84967
- #computeRefetchInterval() {
84968
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
84969
- }
84970
- #updateRefetchInterval(nextInterval) {
84971
- this.#clearRefetchInterval();
84972
- this.#currentRefetchInterval = nextInterval;
84973
- if (isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
84974
- return;
84975
- }
84976
- this.#refetchIntervalId = timeoutManager.setInterval(() => {
84977
- if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
84978
- this.#executeFetch();
84979
- }
84980
- }, this.#currentRefetchInterval);
84981
- }
84982
- #updateTimers() {
84983
- this.#updateStaleTimeout();
84984
- this.#updateRefetchInterval(this.#computeRefetchInterval());
84985
- }
84986
- #clearStaleTimeout() {
84987
- if (this.#staleTimeoutId) {
84988
- timeoutManager.clearTimeout(this.#staleTimeoutId);
84989
- this.#staleTimeoutId = void 0;
84990
- }
84991
- }
84992
- #clearRefetchInterval() {
84993
- if (this.#refetchIntervalId) {
84994
- timeoutManager.clearInterval(this.#refetchIntervalId);
84995
- this.#refetchIntervalId = void 0;
84996
- }
84997
- }
84998
- createResult(query, options) {
84999
- const prevQuery = this.#currentQuery;
85000
- const prevOptions = this.options;
85001
- const prevResult = this.#currentResult;
85002
- const prevResultState = this.#currentResultState;
85003
- const prevResultOptions = this.#currentResultOptions;
85004
- const queryChange = query !== prevQuery;
85005
- const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
85006
- const { state } = query;
85007
- let newState = { ...state };
85008
- let isPlaceholderData = false;
85009
- let data;
85010
- if (options._optimisticResults) {
85011
- const mounted = this.hasListeners();
85012
- const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
85013
- const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
85014
- if (fetchOnMount || fetchOptionally) {
85015
- newState = {
85016
- ...newState,
85017
- ...fetchState(state.data, query.options)
85018
- };
85019
- }
85020
- if (options._optimisticResults === "isRestoring") {
85021
- newState.fetchStatus = "idle";
85022
- }
85023
- }
85024
- let { error: error2, errorUpdatedAt, status } = newState;
85025
- data = newState.data;
85026
- let skipSelect = false;
85027
- if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
85028
- let placeholderData;
85029
- if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
85030
- placeholderData = prevResult.data;
85031
- skipSelect = true;
85032
- } else {
85033
- placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
85034
- this.#lastQueryWithDefinedData?.state.data,
85035
- this.#lastQueryWithDefinedData
85036
- ) : options.placeholderData;
85037
- }
85038
- if (placeholderData !== void 0) {
85039
- status = "success";
85040
- data = replaceData(
85041
- prevResult?.data,
85042
- placeholderData,
85043
- options
85044
- );
85045
- isPlaceholderData = true;
85046
- }
85047
- }
85048
- if (options.select && data !== void 0 && !skipSelect) {
85049
- if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) {
85050
- data = this.#selectResult;
85051
- } else {
85052
- try {
85053
- this.#selectFn = options.select;
85054
- data = options.select(data);
85055
- data = replaceData(prevResult?.data, data, options);
85056
- this.#selectResult = data;
85057
- this.#selectError = null;
85058
- } catch (selectError) {
85059
- this.#selectError = selectError;
85060
- }
85061
- }
85062
- }
85063
- if (this.#selectError) {
85064
- error2 = this.#selectError;
85065
- data = this.#selectResult;
85066
- errorUpdatedAt = Date.now();
85067
- status = "error";
85068
- }
85069
- const isFetching = newState.fetchStatus === "fetching";
85070
- const isPending = status === "pending";
85071
- const isError = status === "error";
85072
- const isLoading = isPending && isFetching;
85073
- const hasData = data !== void 0;
85074
- const result = {
85075
- status,
85076
- fetchStatus: newState.fetchStatus,
85077
- isPending,
85078
- isSuccess: status === "success",
85079
- isError,
85080
- isInitialLoading: isLoading,
85081
- isLoading,
85082
- data,
85083
- dataUpdatedAt: newState.dataUpdatedAt,
85084
- error: error2,
85085
- errorUpdatedAt,
85086
- failureCount: newState.fetchFailureCount,
85087
- failureReason: newState.fetchFailureReason,
85088
- errorUpdateCount: newState.errorUpdateCount,
85089
- isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
85090
- isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
85091
- isFetching,
85092
- isRefetching: isFetching && !isPending,
85093
- isLoadingError: isError && !hasData,
85094
- isPaused: newState.fetchStatus === "paused",
85095
- isPlaceholderData,
85096
- isRefetchError: isError && hasData,
85097
- isStale: isStale(query, options),
85098
- refetch: this.refetch,
85099
- promise: this.#currentThenable,
85100
- isEnabled: resolveEnabled(options.enabled, query) !== false
85101
- };
85102
- const nextResult = result;
85103
- if (this.options.experimental_prefetchInRender) {
85104
- const finalizeThenableIfPossible = (thenable) => {
85105
- if (nextResult.status === "error") {
85106
- thenable.reject(nextResult.error);
85107
- } else if (nextResult.data !== void 0) {
85108
- thenable.resolve(nextResult.data);
84394
+ } catch (error_) {
84395
+ if (abortControllerRef.current?.signal.aborted) {
84396
+ return;
85109
84397
  }
85110
- };
85111
- const recreateThenable = () => {
85112
- const pending = this.#currentThenable = nextResult.promise = pendingThenable();
85113
- finalizeThenableIfPossible(pending);
85114
- };
85115
- const prevThenable = this.#currentThenable;
85116
- switch (prevThenable.status) {
85117
- case "pending":
85118
- if (query.queryHash === prevQuery.queryHash) {
85119
- finalizeThenableIfPossible(prevThenable);
85120
- }
85121
- break;
85122
- case "fulfilled":
85123
- if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
85124
- recreateThenable();
85125
- }
85126
- break;
85127
- case "rejected":
85128
- if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
85129
- recreateThenable();
85130
- }
85131
- break;
85132
- }
85133
- }
85134
- return nextResult;
85135
- }
85136
- updateResult() {
85137
- const prevResult = this.#currentResult;
85138
- const nextResult = this.createResult(this.#currentQuery, this.options);
85139
- this.#currentResultState = this.#currentQuery.state;
85140
- this.#currentResultOptions = this.options;
85141
- if (this.#currentResultState.data !== void 0) {
85142
- this.#lastQueryWithDefinedData = this.#currentQuery;
85143
- }
85144
- if (shallowEqualObjects(nextResult, prevResult)) {
85145
- return;
85146
- }
85147
- this.#currentResult = nextResult;
85148
- const shouldNotifyListeners = () => {
85149
- if (!prevResult) {
85150
- return true;
85151
- }
85152
- const { notifyOnChangeProps } = this.options;
85153
- const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
85154
- if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
85155
- return true;
85156
- }
85157
- const includedProps = new Set(
85158
- notifyOnChangePropsValue ?? this.#trackedProps
85159
- );
85160
- if (this.options.throwOnError) {
85161
- includedProps.add("error");
84398
+ const error22 = error_ instanceof Error ? error_ : new Error("Unknown error occurred");
84399
+ setError(error22);
84400
+ setStatus("error");
84401
+ } finally {
84402
+ isFetchingRef.current = false;
84403
+ setIsFetchingNextPage(false);
85162
84404
  }
85163
- return Object.keys(this.#currentResult).some((key) => {
85164
- const typedKey = key;
85165
- const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
85166
- return changed && includedProps.has(typedKey);
85167
- });
85168
- };
85169
- this.#notify({ listeners: shouldNotifyListeners() });
85170
- }
85171
- #updateQuery() {
85172
- const query = this.#client.getQueryCache().build(this.#client, this.options);
85173
- if (query === this.#currentQuery) {
84405
+ },
84406
+ [queryFn, isInitialLoad]
84407
+ );
84408
+ const fetchNextPage = React.useCallback(() => {
84409
+ if (isFetchingRef.current || !hasNextPage) return;
84410
+ const lastPage = pages.at(-1);
84411
+ if (!lastPage) return;
84412
+ const nextPageParam = getNextPageParam(lastPage);
84413
+ if (nextPageParam === void 0) {
84414
+ setHasNextPage(false);
85174
84415
  return;
85175
84416
  }
85176
- const prevQuery = this.#currentQuery;
85177
- this.#currentQuery = query;
85178
- this.#currentQueryInitialState = query.state;
85179
- if (this.hasListeners()) {
85180
- prevQuery?.removeObserver(this);
85181
- query.addObserver(this);
85182
- }
85183
- }
85184
- onQueryUpdate() {
85185
- this.updateResult();
85186
- if (this.hasListeners()) {
85187
- this.#updateTimers();
85188
- }
85189
- }
85190
- #notify(notifyOptions) {
85191
- notifyManager.batch(() => {
85192
- if (notifyOptions.listeners) {
85193
- this.listeners.forEach((listener) => {
85194
- listener(this.#currentResult);
85195
- });
85196
- }
85197
- this.#client.getQueryCache().notify({
85198
- query: this.#currentQuery,
85199
- type: "observerResultsUpdated"
85200
- });
85201
- });
85202
- }
85203
- };
85204
- function shouldLoadOnMount(query, options) {
85205
- return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
85206
- }
85207
- function shouldFetchOnMount(query, options) {
85208
- return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
85209
- }
85210
- function shouldFetchOn(query, options, field) {
85211
- if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
85212
- const value2 = typeof field === "function" ? field(query) : field;
85213
- return value2 === "always" || value2 !== false && isStale(query, options);
85214
- }
85215
- return false;
85216
- }
85217
- function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
85218
- return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
85219
- }
85220
- function isStale(query, options) {
85221
- return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
85222
- }
85223
- function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
85224
- if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
85225
- return true;
85226
- }
85227
- return false;
85228
- }
85229
- function infiniteQueryBehavior(pages) {
85230
- return {
85231
- onFetch: (context, query) => {
85232
- const options = context.options;
85233
- const direction = context.fetchOptions?.meta?.fetchMore?.direction;
85234
- const oldPages = context.state.data?.pages || [];
85235
- const oldPageParams = context.state.data?.pageParams || [];
85236
- let result = { pages: [], pageParams: [] };
85237
- let currentPage = 0;
85238
- const fetchFn = async () => {
85239
- let cancelled = false;
85240
- const addSignalProperty = (object4) => {
85241
- Object.defineProperty(object4, "signal", {
85242
- enumerable: true,
85243
- get: () => {
85244
- if (context.signal.aborted) {
85245
- cancelled = true;
85246
- } else {
85247
- context.signal.addEventListener("abort", () => {
85248
- cancelled = true;
85249
- });
85250
- }
85251
- return context.signal;
85252
- }
85253
- });
85254
- };
85255
- const queryFn = ensureQueryFn(context.options, context.fetchOptions);
85256
- const fetchPage = async (data, param, previous2) => {
85257
- if (cancelled) {
85258
- return Promise.reject();
85259
- }
85260
- if (param == null && data.pages.length) {
85261
- return Promise.resolve(data);
85262
- }
85263
- const createQueryFnContext = () => {
85264
- const queryFnContext2 = {
85265
- client: context.client,
85266
- queryKey: context.queryKey,
85267
- pageParam: param,
85268
- direction: previous2 ? "backward" : "forward",
85269
- meta: context.options.meta
85270
- };
85271
- addSignalProperty(queryFnContext2);
85272
- return queryFnContext2;
85273
- };
85274
- const queryFnContext = createQueryFnContext();
85275
- const page = await queryFn(queryFnContext);
85276
- const { maxPages } = context.options;
85277
- const addTo = previous2 ? addToStart : addToEnd;
85278
- return {
85279
- pages: addTo(data.pages, page, maxPages),
85280
- pageParams: addTo(data.pageParams, param, maxPages)
85281
- };
85282
- };
85283
- if (direction && oldPages.length) {
85284
- const previous2 = direction === "backward";
85285
- const pageParamFn = previous2 ? getPreviousPageParam : getNextPageParam;
85286
- const oldData = {
85287
- pages: oldPages,
85288
- pageParams: oldPageParams
85289
- };
85290
- const param = pageParamFn(options, oldData);
85291
- result = await fetchPage(oldData, param, previous2);
85292
- } else {
85293
- const remainingPages = oldPages.length;
85294
- do {
85295
- const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
85296
- if (currentPage > 0 && param == null) {
85297
- break;
85298
- }
85299
- result = await fetchPage(result, param);
85300
- currentPage++;
85301
- } while (currentPage < remainingPages);
85302
- }
85303
- return result;
85304
- };
85305
- if (context.options.persister) {
85306
- context.fetchFn = () => {
85307
- return context.options.persister?.(
85308
- fetchFn,
85309
- {
85310
- client: context.client,
85311
- queryKey: context.queryKey,
85312
- meta: context.options.meta,
85313
- signal: context.signal
85314
- },
85315
- query
85316
- );
85317
- };
85318
- } else {
85319
- context.fetchFn = fetchFn;
85320
- }
84417
+ setIsFetchingNextPage(true);
84418
+ fetchPage(nextPageParam);
84419
+ }, [pages, hasNextPage, getNextPageParam, fetchPage]);
84420
+ React.useEffect(() => {
84421
+ if (isInitialLoad && pages.length === 0) {
84422
+ fetchPage(initialPageParam);
85321
84423
  }
85322
- };
85323
- }
85324
- function getNextPageParam(options, { pages, pageParams }) {
85325
- const lastIndex = pages.length - 1;
85326
- return pages.length > 0 ? options.getNextPageParam(
85327
- pages[lastIndex],
85328
- pages,
85329
- pageParams[lastIndex],
85330
- pageParams
85331
- ) : void 0;
85332
- }
85333
- function getPreviousPageParam(options, { pages, pageParams }) {
85334
- return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
85335
- }
85336
- function hasNextPage(options, data) {
85337
- if (!data) return false;
85338
- return getNextPageParam(options, data) != null;
85339
- }
85340
- function hasPreviousPage(options, data) {
85341
- if (!data || !options.getPreviousPageParam) return false;
85342
- return getPreviousPageParam(options, data) != null;
85343
- }
85344
- var InfiniteQueryObserver = class extends QueryObserver {
85345
- constructor(client, options) {
85346
- super(client, options);
85347
- }
85348
- bindMethods() {
85349
- super.bindMethods();
85350
- this.fetchNextPage = this.fetchNextPage.bind(this);
85351
- this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
85352
- }
85353
- setOptions(options) {
85354
- super.setOptions({
85355
- ...options,
85356
- behavior: infiniteQueryBehavior()
85357
- });
85358
- }
85359
- getOptimisticResult(options) {
85360
- options.behavior = infiniteQueryBehavior();
85361
- return super.getOptimisticResult(options);
85362
- }
85363
- fetchNextPage(options) {
85364
- return this.fetch({
85365
- ...options,
85366
- meta: {
85367
- fetchMore: { direction: "forward" }
85368
- }
85369
- });
85370
- }
85371
- fetchPreviousPage(options) {
85372
- return this.fetch({
85373
- ...options,
85374
- meta: {
85375
- fetchMore: { direction: "backward" }
84424
+ }, [isInitialLoad, pages.length, fetchPage, initialPageParam]);
84425
+ React.useEffect(() => {
84426
+ return () => {
84427
+ if (abortControllerRef.current) {
84428
+ abortControllerRef.current.abort();
85376
84429
  }
85377
- });
85378
- }
85379
- createResult(query, options) {
85380
- const { state } = query;
85381
- const parentResult = super.createResult(query, options);
85382
- const { isFetching, isRefetching, isError, isRefetchError } = parentResult;
85383
- const fetchDirection = state.fetchMeta?.fetchMore?.direction;
85384
- const isFetchNextPageError = isError && fetchDirection === "forward";
85385
- const isFetchingNextPage = isFetching && fetchDirection === "forward";
85386
- const isFetchPreviousPageError = isError && fetchDirection === "backward";
85387
- const isFetchingPreviousPage = isFetching && fetchDirection === "backward";
85388
- const result = {
85389
- ...parentResult,
85390
- fetchNextPage: this.fetchNextPage,
85391
- fetchPreviousPage: this.fetchPreviousPage,
85392
- hasNextPage: hasNextPage(options, state.data),
85393
- hasPreviousPage: hasPreviousPage(options, state.data),
85394
- isFetchNextPageError,
85395
- isFetchingNextPage,
85396
- isFetchPreviousPageError,
85397
- isFetchingPreviousPage,
85398
- isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError,
85399
- isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
85400
84430
  };
85401
- return result;
85402
- }
85403
- };
85404
- var QueryClientContext = React__namespace.createContext(
85405
- void 0
85406
- );
85407
- var useQueryClient = (queryClient) => {
85408
- const client = React__namespace.useContext(QueryClientContext);
85409
- if (!client) {
85410
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
85411
- }
85412
- return client;
85413
- };
85414
- var IsRestoringContext = React__namespace.createContext(false);
85415
- var useIsRestoring = () => React__namespace.useContext(IsRestoringContext);
85416
- IsRestoringContext.Provider;
85417
- function createValue() {
85418
- let isReset = false;
84431
+ }, []);
85419
84432
  return {
85420
- clearReset: () => {
85421
- isReset = false;
85422
- },
85423
- reset: () => {
85424
- isReset = true;
85425
- },
85426
- isReset: () => {
85427
- return isReset;
85428
- }
84433
+ data: pages.length > 0 ? { pages } : void 0,
84434
+ error: error2,
84435
+ fetchNextPage,
84436
+ hasNextPage,
84437
+ isFetchingNextPage,
84438
+ status
85429
84439
  };
85430
- }
85431
- var QueryErrorResetBoundaryContext = React__namespace.createContext(createValue());
85432
- var useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext);
85433
- var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
85434
- if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
85435
- if (!errorResetBoundary.isReset()) {
85436
- options.retryOnMount = false;
85437
- }
85438
- }
85439
84440
  };
85440
- var useClearResetErrorBoundary = (errorResetBoundary) => {
85441
- React__namespace.useEffect(() => {
85442
- errorResetBoundary.clearReset();
85443
- }, [errorResetBoundary]);
85444
- };
85445
- var getHasError = ({
85446
- result,
85447
- errorResetBoundary,
85448
- throwOnError,
85449
- query,
85450
- suspense
85451
- }) => {
85452
- return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
85453
- };
85454
- var ensureSuspenseTimers = (defaultedOptions) => {
85455
- if (defaultedOptions.suspense) {
85456
- const MIN_SUSPENSE_TIME_MS = 1e3;
85457
- const clamp = (value2) => value2 === "static" ? value2 : Math.max(value2 ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
85458
- const originalStaleTime = defaultedOptions.staleTime;
85459
- defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
85460
- if (typeof defaultedOptions.gcTime === "number") {
85461
- defaultedOptions.gcTime = Math.max(
85462
- defaultedOptions.gcTime,
85463
- MIN_SUSPENSE_TIME_MS
85464
- );
85465
- }
85466
- }
85467
- };
85468
- var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
85469
- var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
85470
- var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
85471
- errorResetBoundary.clearReset();
85472
- });
85473
- function useBaseQuery(options, Observer, queryClient) {
85474
- if (process.env.NODE_ENV !== "production") {
85475
- if (typeof options !== "object" || Array.isArray(options)) {
85476
- throw new Error(
85477
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
85478
- );
85479
- }
85480
- }
85481
- const isRestoring = useIsRestoring();
85482
- const errorResetBoundary = useQueryErrorResetBoundary();
85483
- const client = useQueryClient();
85484
- const defaultedOptions = client.defaultQueryOptions(options);
85485
- client.getDefaultOptions().queries?._experimental_beforeQuery?.(
85486
- defaultedOptions
85487
- );
85488
- if (process.env.NODE_ENV !== "production") {
85489
- if (!defaultedOptions.queryFn) {
85490
- console.error(
85491
- `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
85492
- );
85493
- }
85494
- }
85495
- defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
85496
- ensureSuspenseTimers(defaultedOptions);
85497
- ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
85498
- useClearResetErrorBoundary(errorResetBoundary);
85499
- const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
85500
- const [observer] = React__namespace.useState(
85501
- () => new Observer(
85502
- client,
85503
- defaultedOptions
85504
- )
85505
- );
85506
- const result = observer.getOptimisticResult(defaultedOptions);
85507
- const shouldSubscribe = !isRestoring && options.subscribed !== false;
85508
- React__namespace.useSyncExternalStore(
85509
- React__namespace.useCallback(
85510
- (onStoreChange) => {
85511
- const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop2;
85512
- observer.updateResult();
85513
- return unsubscribe;
85514
- },
85515
- [observer, shouldSubscribe]
85516
- ),
85517
- () => observer.getCurrentResult(),
85518
- () => observer.getCurrentResult()
85519
- );
85520
- React__namespace.useEffect(() => {
85521
- observer.setOptions(defaultedOptions);
85522
- }, [defaultedOptions, observer]);
85523
- if (shouldSuspend(defaultedOptions, result)) {
85524
- throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
85525
- }
85526
- if (getHasError({
85527
- result,
85528
- errorResetBoundary,
85529
- throwOnError: defaultedOptions.throwOnError,
85530
- query: client.getQueryCache().get(defaultedOptions.queryHash),
85531
- suspense: defaultedOptions.suspense
85532
- })) {
85533
- throw result.error;
85534
- }
85535
- client.getDefaultOptions().queries?._experimental_afterQuery?.(
85536
- defaultedOptions,
85537
- result
85538
- );
85539
- if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
85540
- const promise = isNewCacheEntry ? (
85541
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
85542
- fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
85543
- ) : (
85544
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
85545
- client.getQueryCache().get(defaultedOptions.queryHash)?.promise
85546
- );
85547
- promise?.catch(noop2).finally(() => {
85548
- observer.updateResult();
85549
- });
85550
- }
85551
- return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
85552
- }
85553
- function useInfiniteQuery(options, queryClient) {
85554
- return useBaseQuery(
85555
- options,
85556
- InfiniteQueryObserver
85557
- );
85558
- }
85559
84441
  const ResizableTitle = (props) => {
85560
84442
  const { onResize: onResize2, width, ...restProps } = props;
85561
84443
  if (!width || !onResize2) {
@@ -85599,17 +84481,41 @@ const ResizableTitle = (props) => {
85599
84481
  ] });
85600
84482
  };
85601
84483
  const InfiniteScrollTable = ({
85602
- instanceId,
85603
84484
  columns: initialColumns,
85604
84485
  fetchService,
85605
- title,
85606
84486
  scrollHeight = 600,
85607
- scrollWidth = 1300
84487
+ scrollWidth = 1300,
84488
+ onChange,
84489
+ rowSelection,
84490
+ onRowClick,
84491
+ onRowSelectionChange,
84492
+ onDataChange
85608
84493
  }) => {
85609
84494
  const observer = React.useRef();
85610
84495
  const [scrollableNode, setScrollableNode] = React.useState(
85611
84496
  null
85612
84497
  );
84498
+ const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
84499
+ const [selectedRows, setSelectedRows] = React.useState([]);
84500
+ const handleRowSelection = React.useCallback(
84501
+ (newSelectedRowKeys, newSelectedRows) => {
84502
+ setSelectedRowKeys(newSelectedRowKeys);
84503
+ setSelectedRows(newSelectedRows);
84504
+ if (rowSelection?.onChange) {
84505
+ rowSelection.onChange(newSelectedRowKeys, newSelectedRows);
84506
+ }
84507
+ },
84508
+ [rowSelection]
84509
+ );
84510
+ const defaultRowSelection2 = {
84511
+ type: "checkbox",
84512
+ selectedRowKeys,
84513
+ onChange: handleRowSelection,
84514
+ getCheckboxProps: (record) => ({
84515
+ name: record.id || record.key || String(record)
84516
+ })
84517
+ };
84518
+ const finalRowSelection = rowSelection || defaultRowSelection2;
85613
84519
  const tableContainerRef = React.useCallback((node2) => {
85614
84520
  if (node2 !== null) {
85615
84521
  const scrollNode = node2.querySelector(".ant-table-body");
@@ -85620,7 +84526,7 @@ const InfiniteScrollTable = ({
85620
84526
  data,
85621
84527
  error: error2,
85622
84528
  fetchNextPage,
85623
- hasNextPage: hasNextPage2,
84529
+ hasNextPage,
85624
84530
  isFetchingNextPage,
85625
84531
  status
85626
84532
  } = useInfiniteQuery({
@@ -85650,7 +84556,7 @@ const InfiniteScrollTable = ({
85650
84556
  if (observer.current) observer.current.disconnect();
85651
84557
  observer.current = new IntersectionObserver(
85652
84558
  (entries) => {
85653
- if (entries[0].isIntersecting && hasNextPage2) {
84559
+ if (entries[0].isIntersecting && hasNextPage) {
85654
84560
  fetchNextPage();
85655
84561
  }
85656
84562
  },
@@ -85658,10 +84564,36 @@ const InfiniteScrollTable = ({
85658
84564
  );
85659
84565
  if (node2) observer.current.observe(node2);
85660
84566
  },
85661
- [isFetchingNextPage, hasNextPage2, fetchNextPage, scrollableNode]
84567
+ [isFetchingNextPage, hasNextPage, fetchNextPage, scrollableNode]
85662
84568
  );
85663
84569
  const dataSource = data?.pages.flatMap((page) => page.docs) ?? [];
85664
- data?.pages?.[0]?.totalDocs ?? 0;
84570
+ const totalDocs = data?.pages?.[0]?.totalDocs ?? 0;
84571
+ React.useEffect(() => {
84572
+ if (onRowSelectionChange) {
84573
+ const wrappedSetSelectedRowKeys = (keys2) => {
84574
+ setSelectedRowKeys(keys2);
84575
+ };
84576
+ onRowSelectionChange(wrappedSetSelectedRowKeys);
84577
+ }
84578
+ }, [onRowSelectionChange]);
84579
+ const dataSentRef = React.useRef(false);
84580
+ React.useEffect(() => {
84581
+ if (onDataChange && dataSource.length > 0 && !dataSentRef.current) {
84582
+ onDataChange(dataSource);
84583
+ dataSentRef.current = true;
84584
+ }
84585
+ }, [dataSource, onDataChange]);
84586
+ React.useEffect(() => {
84587
+ if (onChange) {
84588
+ const dataChangeEvent = {
84589
+ totalPages: data?.pages?.length ?? 0,
84590
+ currentPage: data?.pages?.[0]?.page ?? 0,
84591
+ resultsShown: dataSource.length,
84592
+ totalResults: totalDocs
84593
+ };
84594
+ onChange(dataChangeEvent);
84595
+ }
84596
+ }, [data]);
85665
84597
  if (status === "pending") {
85666
84598
  return /* @__PURE__ */ jsxRuntime.jsx(
85667
84599
  "div",
@@ -85682,79 +84614,73 @@ const InfiniteScrollTable = ({
85682
84614
  }
85683
84615
  );
85684
84616
  }
85685
- return /* @__PURE__ */ jsxRuntime.jsxs(
85686
- "div",
85687
- {
85688
- style: {
85689
- backgroundColor: "white",
85690
- padding: "24px",
85691
- borderRadius: "8px",
85692
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
85693
- marginBottom: "24px"
85694
- },
85695
- ref: tableContainerRef,
85696
- children: [
85697
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
85698
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
84617
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: tableContainerRef, children: [
84618
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, ref: tableContainerRef, children: [
84619
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
85699
84620
  .infinite-scroll-table .ant-pagination {
85700
84621
  display: none !important;
85701
84622
  }
85702
84623
  ` }),
85703
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "infinite-scroll-table", children: /* @__PURE__ */ jsxRuntime.jsx(
85704
- ForwardTable,
85705
- {
85706
- dataSource,
85707
- columns: resizableColumns,
85708
- components: { header: { cell: ResizableTitle } },
85709
- rowKey: "id",
85710
- pagination: false,
85711
- showSorterTooltip: false,
85712
- size: "small",
85713
- scroll: { y: scrollHeight, x: scrollWidth },
85714
- onChange: () => {
85715
- },
85716
- onRow: (record, index2) => {
85717
- if (index2 === dataSource.length - 1) {
85718
- return { ref: lastRowRef };
85719
- }
85720
- return {};
85721
- }
84624
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "infinite-scroll-table", children: /* @__PURE__ */ jsxRuntime.jsx(
84625
+ ForwardTable,
84626
+ {
84627
+ dataSource,
84628
+ columns: resizableColumns,
84629
+ components: { header: { cell: ResizableTitle } },
84630
+ rowKey: "id",
84631
+ pagination: false,
84632
+ showSorterTooltip: false,
84633
+ size: "small",
84634
+ scroll: { y: scrollHeight, x: scrollWidth },
84635
+ onChange: () => {
84636
+ },
84637
+ rowSelection: finalRowSelection,
84638
+ onRow: (record, index2) => {
84639
+ const rowProps = {};
84640
+ if (index2 === dataSource.length - 1) {
84641
+ rowProps.ref = lastRowRef;
85722
84642
  }
85723
- ) }),
85724
- isFetchingNextPage && /* @__PURE__ */ jsxRuntime.jsx(
85725
- "div",
85726
- {
85727
- style: {
85728
- position: "absolute",
85729
- bottom: 0,
85730
- left: 0,
85731
- width: "100%",
85732
- padding: "16px",
85733
- display: "flex",
85734
- justifyContent: "center",
85735
- alignItems: "center",
85736
- backgroundColor: "rgba(255, 255, 255, 0.7)",
85737
- backdropFilter: "blur(2px)",
85738
- zIndex: 10
85739
- },
85740
- children: /* @__PURE__ */ jsxRuntime.jsx(Spin, {})
84643
+ if (onRowClick && index2 !== void 0) {
84644
+ rowProps.onClick = (event) => {
84645
+ onRowClick(record, index2, event);
84646
+ };
85741
84647
  }
85742
- )
85743
- ] }),
85744
- !hasNextPage2 && /* @__PURE__ */ jsxRuntime.jsx(
85745
- "div",
85746
- {
85747
- style: {
85748
- textAlign: "center",
85749
- padding: "20px",
85750
- borderTop: "1px solid #f0f0f0"
85751
- },
85752
- children: /* @__PURE__ */ jsxRuntime.jsx(Typography$1.Text, { type: "secondary", children: "No more rows to load." })
84648
+ return rowProps;
85753
84649
  }
85754
- )
85755
- ]
85756
- }
85757
- );
84650
+ }
84651
+ ) }),
84652
+ isFetchingNextPage && /* @__PURE__ */ jsxRuntime.jsx(
84653
+ "div",
84654
+ {
84655
+ style: {
84656
+ position: "absolute",
84657
+ bottom: 0,
84658
+ left: 0,
84659
+ width: "100%",
84660
+ padding: "16px",
84661
+ display: "flex",
84662
+ justifyContent: "center",
84663
+ alignItems: "center",
84664
+ backgroundColor: "rgba(255, 255, 255, 0.7)",
84665
+ backdropFilter: "blur(2px)",
84666
+ zIndex: 10
84667
+ },
84668
+ children: /* @__PURE__ */ jsxRuntime.jsx(Spin, {})
84669
+ }
84670
+ )
84671
+ ] }),
84672
+ !hasNextPage && /* @__PURE__ */ jsxRuntime.jsx(
84673
+ "div",
84674
+ {
84675
+ style: {
84676
+ textAlign: "center",
84677
+ padding: "20px",
84678
+ borderTop: "1px solid #f0f0f0"
84679
+ },
84680
+ children: /* @__PURE__ */ jsxRuntime.jsx(Typography$1.Text, { type: "secondary", children: "No more rows to load." })
84681
+ }
84682
+ )
84683
+ ] });
85758
84684
  };
85759
84685
  const getRowKey = (record, rowKey, index2, enableValidation = true) => {
85760
84686
  try {
@@ -85806,6 +84732,8 @@ function Table({
85806
84732
  onChange,
85807
84733
  rowSelection,
85808
84734
  onRowClick,
84735
+ onRowSelectionChange,
84736
+ onDataChange,
85809
84737
  pagination,
85810
84738
  isMainContentCell = false,
85811
84739
  isInfiniteScroll = false,
@@ -85860,7 +84788,9 @@ function Table({
85860
84788
  fetchService: infiniteScrollConfig.fetchService,
85861
84789
  title: infiniteScrollConfig.title,
85862
84790
  scrollHeight: infiniteScrollConfig.scrollHeight,
85863
- scrollWidth: infiniteScrollConfig.scrollWidth
84791
+ scrollWidth: infiniteScrollConfig.scrollWidth,
84792
+ onRowSelectionChange,
84793
+ onDataChange
85864
84794
  }
85865
84795
  );
85866
84796
  }
@@ -86413,7 +85343,8 @@ const GroupsRow = ({ groups, onGroupItemClick }) => {
86413
85343
  const SecondaryTableControlsRow = ({
86414
85344
  groups,
86415
85345
  totalRecords,
86416
- onChange
85346
+ onChange,
85347
+ infiniteScrollData
86417
85348
  }) => {
86418
85349
  const onGroupItemClick = (title, item) => {
86419
85350
  const groupItemClickEvent = {
@@ -86433,7 +85364,8 @@ const SecondaryTableControlsRow = ({
86433
85364
  },
86434
85365
  children: [
86435
85366
  /* @__PURE__ */ jsxRuntime.jsx(GroupsRow, { groups, onGroupItemClick }),
86436
- (totalRecords ?? 0) > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` }) : null
85367
+ (totalRecords ?? 0) > 0 && !infiniteScrollData ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` }) : null,
85368
+ infiniteScrollData ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `Loaded ${infiniteScrollData.resultsShown} of ${infiniteScrollData.totalResults} Results` }) : null
86437
85369
  ]
86438
85370
  }
86439
85371
  );
@@ -86468,7 +85400,8 @@ const TableControls = ({
86468
85400
  {
86469
85401
  groups: secondaryTableRowData.groups,
86470
85402
  totalRecords: secondaryTableRowData.totalRecords,
86471
- onChange: onSecondaryChange
85403
+ onChange: onSecondaryChange,
85404
+ infiniteScrollData: secondaryTableRowData.infiniteScrollData
86472
85405
  }
86473
85406
  ) : null
86474
85407
  ] });
@@ -86478,14 +85411,28 @@ const TableWithControls = ({
86478
85411
  tableControlsData: tableControlsData2,
86479
85412
  onChange,
86480
85413
  onRowClick,
85414
+ onRowSelectionChange,
85415
+ onDataChange,
86481
85416
  tableType = "table",
86482
85417
  isInfiniteScroll,
86483
- // Deprecated: use tableType instead
86484
85418
  infiniteScrollConfig,
86485
85419
  paginationStyle
86486
85420
  }) => {
85421
+ const [infiniteScrollData, setInfiniteScrollData] = React.useState({
85422
+ totalPages: 0,
85423
+ currentPage: 0,
85424
+ resultsShown: 0,
85425
+ totalResults: 0
85426
+ });
86487
85427
  const { primaryTableRowData, secondaryTableRowData } = tableControlsData2;
86488
- const { dataSource, columns, rowSelection, hasSettings, hasFilter } = tableData;
85428
+ const {
85429
+ dataSource,
85430
+ columns,
85431
+ rowSelection,
85432
+ hasSettings,
85433
+ hasFilter,
85434
+ onRowClick: tableOnRowClick
85435
+ } = tableData;
86489
85436
  const actualTableType = isInfiniteScroll ? "infiniteScroll" : tableType;
86490
85437
  const onTableControlsChange = (event) => {
86491
85438
  onChange(event);
@@ -86496,6 +85443,12 @@ const TableWithControls = ({
86496
85443
  payload: { value: "tableChange", pagination, filters, sorter }
86497
85444
  });
86498
85445
  };
85446
+ const onInfiniteScrollTableChange = (event) => {
85447
+ onChange({
85448
+ event: "infiniteScrollTableChange",
85449
+ payload: { value: "infiniteScrollTableChange", event }
85450
+ });
85451
+ };
86499
85452
  const renderTable = () => {
86500
85453
  switch (actualTableType) {
86501
85454
  case "infiniteScroll": {
@@ -86518,7 +85471,12 @@ const TableWithControls = ({
86518
85471
  fetchService: infiniteScrollConfig.fetchService,
86519
85472
  title: infiniteScrollConfig.title,
86520
85473
  scrollHeight: infiniteScrollConfig.scrollHeight,
86521
- scrollWidth: infiniteScrollConfig.scrollWidth
85474
+ scrollWidth: infiniteScrollConfig.scrollWidth,
85475
+ onChange: onInfiniteScrollTableChange,
85476
+ rowSelection,
85477
+ onRowClick: tableOnRowClick || onRowClick,
85478
+ onRowSelectionChange,
85479
+ onDataChange
86522
85480
  }
86523
85481
  );
86524
85482
  }
@@ -86544,7 +85502,8 @@ const TableWithControls = ({
86544
85502
  columns,
86545
85503
  rowSelection,
86546
85504
  onChange: onTableChange,
86547
- onRowClick
85505
+ onRowClick,
85506
+ onRowSelectionChange
86548
85507
  }
86549
85508
  );
86550
85509
  }
@@ -87058,6 +86017,7 @@ const staticTableData = [
87058
86017
  state: "CA",
87059
86018
  zip: "90210"
87060
86019
  },
86020
+ job_subtype: "delivery",
87061
86021
  progress: {
87062
86022
  currentStep: 1,
87063
86023
  totalSteps: 4,
@@ -87097,6 +86057,7 @@ const staticTableData = [
87097
86057
  state: "CA",
87098
86058
  zip: "90211"
87099
86059
  },
86060
+ job_subtype: "delivery",
87100
86061
  progress: {
87101
86062
  currentStep: 4,
87102
86063
  totalSteps: 4,
@@ -87136,6 +86097,7 @@ const staticTableData = [
87136
86097
  state: "CA",
87137
86098
  zip: "90212"
87138
86099
  },
86100
+ job_subtype: "delivery",
87139
86101
  progress: {
87140
86102
  currentStep: 2,
87141
86103
  totalSteps: 4,
@@ -87175,6 +86137,7 @@ const staticTableData = [
87175
86137
  state: "CA",
87176
86138
  zip: "90213"
87177
86139
  },
86140
+ job_subtype: "pickup",
87178
86141
  progress: {
87179
86142
  currentStep: 1,
87180
86143
  totalSteps: 4,
@@ -87214,6 +86177,7 @@ const staticTableData = [
87214
86177
  state: "CA",
87215
86178
  zip: "90214"
87216
86179
  },
86180
+ job_subtype: "delivery",
87217
86181
  progress: {
87218
86182
  currentStep: 1,
87219
86183
  totalSteps: 4,
@@ -87253,6 +86217,7 @@ const staticTableData = [
87253
86217
  state: "CA",
87254
86218
  zip: "90215"
87255
86219
  },
86220
+ job_subtype: "delivery",
87256
86221
  progress: {
87257
86222
  currentStep: 3,
87258
86223
  totalSteps: 4,
@@ -87292,6 +86257,7 @@ const staticTableData = [
87292
86257
  state: "CA",
87293
86258
  zip: "90216"
87294
86259
  },
86260
+ job_subtype: "delivery",
87295
86261
  progress: {
87296
86262
  currentStep: 4,
87297
86263
  totalSteps: 4,
@@ -87331,6 +86297,7 @@ const staticTableData = [
87331
86297
  state: "CA",
87332
86298
  zip: "90217"
87333
86299
  },
86300
+ job_subtype: "delivery",
87334
86301
  progress: {
87335
86302
  currentStep: 1,
87336
86303
  totalSteps: 4,
@@ -87370,6 +86337,7 @@ const staticTableData = [
87370
86337
  state: "CA",
87371
86338
  zip: "90218"
87372
86339
  },
86340
+ job_subtype: "delivery",
87373
86341
  progress: {
87374
86342
  currentStep: 2,
87375
86343
  totalSteps: 4,
@@ -87461,9 +86429,25 @@ const mockColumns = [
87461
86429
  dataIndex: "progress",
87462
86430
  render: (progress) => {
87463
86431
  if (!progress) return null;
86432
+ let firstBarData, secondBarData;
86433
+ if ("firstBarData" in progress) {
86434
+ firstBarData = progress.firstBarData;
86435
+ secondBarData = progress.secondBarData;
86436
+ } else {
86437
+ firstBarData = {
86438
+ text: progress.steps.pickup.text,
86439
+ status: progress.steps.pickup.status,
86440
+ value: progress.steps.pickup.value
86441
+ };
86442
+ secondBarData = {
86443
+ text: progress.steps.transit.text,
86444
+ status: progress.steps.transit.status,
86445
+ value: progress.steps.transit.value
86446
+ };
86447
+ }
87464
86448
  return React.createElement(Progress, {
87465
- firstBarData: progress.firstBarData,
87466
- secondBarData: progress.secondBarData,
86449
+ firstBarData,
86450
+ secondBarData,
87467
86451
  width: 150,
87468
86452
  height: 20,
87469
86453
  isProgressCombined: true