@tamagui/floating 3.0.0 → 3.0.1

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.
@@ -68,12 +68,14 @@ const inner = (props) => ({
68
68
  elementContext: "reference"
69
69
  });
70
70
  const diffY = Math.max(0, overflow.top);
71
- const nextY = nextArgs.y + diffY;
72
71
  const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
73
72
  const rounder = isScrollable ? (v) => v : Math.round;
74
- const maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
73
+ const fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);
74
+ const minimumHeight = item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0);
75
+ const maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));
76
+ const nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);
75
77
  scrollEl.style.maxHeight = `${maxHeight}px`;
76
- scrollEl.scrollTop = diffY;
78
+ scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);
77
79
  if (onFallbackChange) {
78
80
  const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
79
81
  ReactDOM.flushSync(() => onFallbackChange(shouldFallback));
@@ -48,7 +48,7 @@ var inner = function(props) {
48
48
  name: "inner",
49
49
  options: props,
50
50
  async fn(state) {
51
- var _listRef_current;
51
+ var _listRef_current, _listRef_current1;
52
52
  var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;
53
53
  var { rects, elements: { floating } } = state;
54
54
  var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];
@@ -72,18 +72,21 @@ var inner = function(props) {
72
72
  elementContext: "reference"
73
73
  });
74
74
  var diffY = Math.max(0, overflow.top);
75
- var nextY = nextArgs.y + diffY;
76
75
  var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
77
76
  var rounder = isScrollable ? function(v) {
78
77
  return v;
79
78
  } : Math.round;
80
- var maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
79
+ var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);
80
+ var _listRef_current_length;
81
+ var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0);
82
+ var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));
83
+ var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);
81
84
  scrollEl.style.maxHeight = `${maxHeight}px`;
82
- scrollEl.scrollTop = diffY;
85
+ scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);
83
86
  if (onFallbackChange) {
84
- var _listRef_current1;
85
- var _listRef_current_length;
86
- var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
87
+ var _listRef_current2;
88
+ var _listRef_current_length1;
89
+ var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _listRef_current_length1 !== void 0 ? _listRef_current_length1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
87
90
  ReactDOM.flushSync(function() {
88
91
  return onFallbackChange(shouldFallback);
89
92
  });
@@ -48,7 +48,7 @@ var inner = function(props) {
48
48
  name: "inner",
49
49
  options: props,
50
50
  async fn(state) {
51
- var _listRef_current;
51
+ var _listRef_current, _listRef_current1;
52
52
  var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;
53
53
  var { rects, elements: { floating } } = state;
54
54
  var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];
@@ -72,18 +72,21 @@ var inner = function(props) {
72
72
  elementContext: "reference"
73
73
  });
74
74
  var diffY = Math.max(0, overflow.top);
75
- var nextY = nextArgs.y + diffY;
76
75
  var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
77
76
  var rounder = isScrollable ? function(v) {
78
77
  return v;
79
78
  } : Math.round;
80
- var maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
79
+ var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);
80
+ var _listRef_current_length;
81
+ var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0);
82
+ var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));
83
+ var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);
81
84
  scrollEl.style.maxHeight = `${maxHeight}px`;
82
- scrollEl.scrollTop = diffY;
85
+ scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);
83
86
  if (onFallbackChange) {
84
- var _listRef_current1;
85
- var _listRef_current_length;
86
- var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
87
+ var _listRef_current2;
88
+ var _listRef_current_length1;
89
+ var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _listRef_current_length1 !== void 0 ? _listRef_current_length1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
87
90
  ReactDOM.flushSync(function() {
88
91
  return onFallbackChange(shouldFallback);
89
92
  });
@@ -1 +1 @@
1
- {"version":3,"file":"inner.native.js","names":[],"sources":["cjs/middleware/inner.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar inner_exports = {};\n__export(inner_exports, {\n inner: () => inner\n});\nmodule.exports = __toCommonJS(inner_exports);\nvar ReactDOM = __toESM(require(\"react-dom\"), 1);\nvar import_react_dom = require(\"@floating-ui/react-dom\");\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nvar inner = function(props) {\n return {\n name: \"inner\",\n options: props,\n async fn(state) {\n var _listRef_current;\n var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;\n var { rects, elements: { floating } } = state;\n var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];\n var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;\n var clientTop = floating.clientTop || scrollEl.clientTop;\n var floatingIsBordered = floating.clientTop !== 0;\n var scrollElIsBordered = scrollEl.clientTop !== 0;\n var floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);\n return {};\n }\n var nextArgs = {\n ...state,\n ...await (0, import_react_dom.offset)(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)\n };\n var detectOverflowOptions = {\n padding\n };\n var overflow = await (0, import_react_dom.detectOverflow)(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n var refOverflow = await (0, import_react_dom.detectOverflow)(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n var diffY = Math.max(0, overflow.top);\n var nextY = nextArgs.y + diffY;\n var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n var rounder = isScrollable ? function(v) {\n return v;\n } : Math.round;\n var maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = diffY;\n if (onFallbackChange) {\n var _listRef_current1;\n var _listRef_current_length;\n var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(function() {\n return onFallbackChange(shouldFallback);\n });\n }\n if (overflowRef) {\n ;\n overflowRef.current = await (0, import_react_dom.detectOverflow)(getArgsWithCustomFloatingHeight({\n ...nextArgs,\n y: nextY\n }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);\n }\n return {\n y: nextY\n };\n }\n };\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings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zB,IAAI,eAAe,SAAS,eAAe,SAAS;GACpD,IAAI,UAAU,eAAe,SAAS,GAAG;IACvC,OAAO;GACT,IAAI,KAAK;GACT,IAAI,YAAY,QAAQ,KAAK,IAAI,GAAG,SAAS,gBAAgB,sBAAsB,sBAAsB,qBAAqB,YAAY,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,SAAS,MAAM,CAAC,CAAC;GACxL,SAAS,MAAM,YAAY,GAAG,UAAU;GACxC,SAAS,YAAY;GACrB,IAAI,kBAAkB;IACpB,IAAI;IACJ,IAAI;IACJ,IAAI,iBAAiB,SAAS,eAAe,KAAK,eAAe,KAAK,IAAI,kBAAkB,2BAA2B,oBAAoB,QAAQ,aAAa,QAAQ,sBAAsB,KAAK,IAAI,KAAK,IAAI,kBAAkB,YAAY,QAAQ,4BAA4B,KAAK,IAAI,0BAA0B,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC,8BAA8B,YAAY,UAAU,CAAC;IACxY,SAAS,UAAU,WAAW;KAC5B,OAAO,iBAAiB,cAAc;IACxC,CAAC;GACH;GACA,IAAI,aAAa;IACf;IACA,YAAY,UAAU,OAAO,GAAG,iBAAiB,eAAc,CAAE,gCAAgC;KAC/F,GAAG;KACH,GAAG;IACL,GAAG,SAAS,eAAe,YAAY,SAAS,SAAS,GAAG,qBAAqB;GACnF;GACA,OAAO,EACL,GAAG,MACL;EACF;CACF;AACF"}
1
+ {"version":3,"file":"inner.native.js","names":[],"sources":["cjs/middleware/inner.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar inner_exports = {};\n__export(inner_exports, {\n inner: () => inner\n});\nmodule.exports = __toCommonJS(inner_exports);\nvar ReactDOM = __toESM(require(\"react-dom\"), 1);\nvar import_react_dom = require(\"@floating-ui/react-dom\");\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nvar inner = function(props) {\n return {\n name: \"inner\",\n options: props,\n async fn(state) {\n var _listRef_current, _listRef_current1;\n var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;\n var { rects, elements: { floating } } = state;\n var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];\n var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;\n var clientTop = floating.clientTop || scrollEl.clientTop;\n var floatingIsBordered = floating.clientTop !== 0;\n var scrollElIsBordered = scrollEl.clientTop !== 0;\n var floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);\n return {};\n }\n var nextArgs = {\n ...state,\n ...await (0, import_react_dom.offset)(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)\n };\n var detectOverflowOptions = {\n padding\n };\n var overflow = await (0, import_react_dom.detectOverflow)(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n var refOverflow = await (0, import_react_dom.detectOverflow)(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n var diffY = Math.max(0, overflow.top);\n var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n var rounder = isScrollable ? function(v) {\n return v;\n } : Math.round;\n var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);\n var _listRef_current_length;\n var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0);\n var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));\n var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);\n if (onFallbackChange) {\n var _listRef_current2;\n var _listRef_current_length1;\n var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _listRef_current_length1 !== void 0 ? _listRef_current_length1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(function() {\n return onFallbackChange(shouldFallback);\n });\n }\n if (overflowRef) {\n ;\n overflowRef.current = await (0, import_react_dom.detectOverflow)(getArgsWithCustomFloatingHeight({\n ...nextArgs,\n y: nextY\n }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);\n }\n return {\n y: nextY\n };\n }\n };\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe,EACtB,aAAa,MACf,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,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iB,cAAc;IACxC,CAAC;GACH;GACA,IAAI,aAAa;IACf;IACA,YAAY,UAAU,OAAO,GAAG,iBAAiB,eAAc,CAAE,gCAAgC;KAC/F,GAAG;KACH,GAAG;IACL,GAAG,SAAS,eAAe,YAAY,SAAS,SAAS,GAAG,qBAAqB;GACnF;GACA,OAAO,EACL,GAAG,MACL;EACF;CACF;AACF"}
@@ -40,12 +40,14 @@ const inner = (props) => ({
40
40
  elementContext: "reference"
41
41
  });
42
42
  const diffY = Math.max(0, overflow.top);
43
- const nextY = nextArgs.y + diffY;
44
43
  const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
45
44
  const rounder = isScrollable ? (v) => v : Math.round;
46
- const maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
45
+ const fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);
46
+ const minimumHeight = item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0);
47
+ const maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));
48
+ const nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);
47
49
  scrollEl.style.maxHeight = `${maxHeight}px`;
48
- scrollEl.scrollTop = diffY;
50
+ scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);
49
51
  if (onFallbackChange) {
50
52
  const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
51
53
  ReactDOM.flushSync(() => onFallbackChange(shouldFallback));
@@ -1 +1 @@
1
- {"version":3,"file":"inner.js","names":[],"sources":["esm/middleware/inner.js"],"sourcesContent":["import * as ReactDOM from \"react-dom\";\nimport { detectOverflow, offset } from \"@floating-ui/react-dom\";\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nconst inner = (props) => ({\n name: \"inner\",\n options: props,\n async fn(state) {\n const {\n listRef,\n overflowRef,\n onFallbackChange,\n offset: innerOffset = 0,\n index = 0,\n minItemsVisible = 4,\n referenceOverflowThreshold = 0,\n scrollRef,\n padding = 0\n } = props;\n const {\n rects,\n elements: { floating }\n } = state;\n const item = listRef.current?.[index ?? 0];\n const scrollEl = scrollRef?.current || floating;\n const clientTop = floating.clientTop || scrollEl.clientTop;\n const floatingIsBordered = floating.clientTop !== 0;\n const scrollElIsBordered = scrollEl.clientTop !== 0;\n const floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange?.(true);\n return {};\n }\n const nextArgs = {\n ...state,\n ...await offset(\n -item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset\n ).fn(state)\n };\n const detectOverflowOptions = { padding };\n const overflow = await detectOverflow(\n getArgsWithCustomFloatingHeight(\n nextArgs,\n scrollEl.scrollHeight + clientTop + floating.clientTop\n ),\n detectOverflowOptions\n );\n const refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n const diffY = Math.max(0, overflow.top);\n const nextY = nextArgs.y + diffY;\n const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n const rounder = isScrollable ? (v) => v : Math.round;\n const maxHeight = rounder(\n Math.max(\n 0,\n scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)\n )\n );\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = diffY;\n if (onFallbackChange) {\n const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(() => onFallbackChange(shouldFallback));\n }\n if (overflowRef) {\n ;\n overflowRef.current = await detectOverflow(\n getArgsWithCustomFloatingHeight(\n { ...nextArgs, y: nextY },\n scrollEl.offsetHeight + clientTop + floating.clientTop\n ),\n detectOverflowOptions\n );\n }\n return {\n y: nextY\n };\n }\n});\nexport {\n inner\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings":";;;;AAEA,SAAS,gCAAgC,OAAO,QAAQ;CACtD,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,MAAM;GACT,UAAU;IACR,GAAG,MAAM,MAAM;IACf;GACF;EACF;CACF;AACF;AACA,MAAM,SAAS,WAAW;CACxB,MAAM;CACN,SAAS;CACT,MAAM,GAAG,OAAO;EACd,MAAM,EACJ,SACA,aACA,kBACA,QAAQ,cAAc,GACtB,QAAQ,GACR,kBAAkB,GAClB,6BAA6B,GAC7B,WACA,UAAU,MACR;EACJ,MAAM,EACJ,OACA,UAAU,EAAE,eACV;EACJ,MAAM,OAAO,QAAQ,UAAU,SAAS;EACxC,MAAM,WAAW,WAAW,WAAW;EACvC,MAAM,YAAY,SAAS,aAAa,SAAS;EACjD,MAAM,qBAAqB,SAAS,cAAc;EAClD,MAAM,qBAAqB,SAAS,cAAc;EAClD,MAAM,qBAAqB,aAAa;EACxC,IAAI,CAAC,QAAQ,SAAS,MAAM;GAC1B,mBAAmB,IAAI;GACvB,OAAO,CAAC;EACV;EACA,MAAM,WAAW;GACf,GAAG;GACH,GAAG,MAAM,OACP,CAAC,KAAK,YAAY,SAAS,YAAY,MAAM,UAAU,SAAS,IAAI,KAAK,eAAe,IAAI,WAC9F,CAAC,CAAC,GAAG,KAAK;EACZ;EACA,MAAM,wBAAwB,EAAE,QAAQ;EACxC,MAAM,WAAW,MAAM,eACrB,gCACE,UACA,SAAS,eAAe,YAAY,SAAS,SAC/C,GACA,qBACF;EACA,MAAM,cAAc,MAAM,eAAe,UAAU;GACjD,GAAG;GACH,gBAAgB;EAClB,CAAC;EACD,MAAM,QAAQ,KAAK,IAAI,GAAG,SAAS,GAAG;EACtC,MAAM,QAAQ,SAAS,IAAI;EAC3B,MAAM,eAAe,SAAS,eAAe,SAAS;EACtD,MAAM,UAAU,gBAAgB,MAAM,IAAI,KAAK;EAC/C,MAAM,YAAY,QAChB,KAAK,IACH,GACA,SAAS,gBAAgB,sBAAsB,sBAAsB,qBAAqB,YAAY,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,SAAS,MAAM,CACpJ,CACF;EACA,SAAS,MAAM,YAAY,GAAG,UAAU;EACxC,SAAS,YAAY;EACrB,IAAI,kBAAkB;GACpB,MAAM,iBAAiB,SAAS,eAAe,KAAK,eAAe,KAAK,IAAI,iBAAiB,QAAQ,SAAS,UAAU,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC,8BAA8B,YAAY,UAAU,CAAC;GAC3M,SAAS,gBAAgB,iBAAiB,cAAc,CAAC;EAC3D;EACA,IAAI,aAAa;GACf;GACA,YAAY,UAAU,MAAM,eAC1B,gCACE;IAAE,GAAG;IAAU,GAAG;GAAM,GACxB,SAAS,eAAe,YAAY,SAAS,SAC/C,GACA,qBACF;EACF;EACA,OAAO,EACL,GAAG,MACL;CACF;AACF"}
1
+ {"version":3,"file":"inner.js","names":[],"sources":["esm/middleware/inner.js"],"sourcesContent":["import * as ReactDOM from \"react-dom\";\nimport { detectOverflow, offset } from \"@floating-ui/react-dom\";\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nconst inner = (props) => ({\n name: \"inner\",\n options: props,\n async fn(state) {\n const {\n listRef,\n overflowRef,\n onFallbackChange,\n offset: innerOffset = 0,\n index = 0,\n minItemsVisible = 4,\n referenceOverflowThreshold = 0,\n scrollRef,\n padding = 0\n } = props;\n const {\n rects,\n elements: { floating }\n } = state;\n const item = listRef.current?.[index ?? 0];\n const scrollEl = scrollRef?.current || floating;\n const clientTop = floating.clientTop || scrollEl.clientTop;\n const floatingIsBordered = floating.clientTop !== 0;\n const scrollElIsBordered = scrollEl.clientTop !== 0;\n const floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange?.(true);\n return {};\n }\n const nextArgs = {\n ...state,\n ...await offset(\n -item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset\n ).fn(state)\n };\n const detectOverflowOptions = { padding };\n const overflow = await detectOverflow(\n getArgsWithCustomFloatingHeight(\n nextArgs,\n scrollEl.scrollHeight + clientTop + floating.clientTop\n ),\n detectOverflowOptions\n );\n const refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n const diffY = Math.max(0, overflow.top);\n const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n const rounder = isScrollable ? (v) => v : Math.round;\n const fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);\n const minimumHeight = item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0);\n const maxHeight = rounder(\n Math.max(\n 0,\n Math.min(\n fullHeight,\n fullHeight - overflow.top - overflow.bottom,\n Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom))\n )\n )\n );\n const nextY = Math.min(\n nextArgs.y + diffY,\n nextArgs.y + fullHeight - overflow.bottom - maxHeight\n );\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);\n if (onFallbackChange) {\n const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(() => onFallbackChange(shouldFallback));\n }\n if (overflowRef) {\n ;\n overflowRef.current = await detectOverflow(\n getArgsWithCustomFloatingHeight(\n { ...nextArgs, y: nextY },\n scrollEl.offsetHeight + clientTop + floating.clientTop\n ),\n detectOverflowOptions\n );\n }\n return {\n y: nextY\n };\n }\n});\nexport {\n inner\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings":";;;;AAEA,SAAS,gCAAgC,OAAO,QAAQ;CACtD,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,MAAM;GACT,UAAU;IACR,GAAG,MAAM,MAAM;IACf;GACF;EACF;CACF;AACF;AACA,MAAM,SAAS,WAAW;CACxB,MAAM;CACN,SAAS;CACT,MAAM,GAAG,OAAO;EACd,MAAM,EACJ,SACA,aACA,kBACA,QAAQ,cAAc,GACtB,QAAQ,GACR,kBAAkB,GAClB,6BAA6B,GAC7B,WACA,UAAU,MACR;EACJ,MAAM,EACJ,OACA,UAAU,EAAE,eACV;EACJ,MAAM,OAAO,QAAQ,UAAU,SAAS;EACxC,MAAM,WAAW,WAAW,WAAW;EACvC,MAAM,YAAY,SAAS,aAAa,SAAS;EACjD,MAAM,qBAAqB,SAAS,cAAc;EAClD,MAAM,qBAAqB,SAAS,cAAc;EAClD,MAAM,qBAAqB,aAAa;EACxC,IAAI,CAAC,QAAQ,SAAS,MAAM;GAC1B,mBAAmB,IAAI;GACvB,OAAO,CAAC;EACV;EACA,MAAM,WAAW;GACf,GAAG;GACH,GAAG,MAAM,OACP,CAAC,KAAK,YAAY,SAAS,YAAY,MAAM,UAAU,SAAS,IAAI,KAAK,eAAe,IAAI,WAC9F,CAAC,CAAC,GAAG,KAAK;EACZ;EACA,MAAM,wBAAwB,EAAE,QAAQ;EACxC,MAAM,WAAW,MAAM,eACrB,gCACE,UACA,SAAS,eAAe,YAAY,SAAS,SAC/C,GACA,qBACF;EACA,MAAM,cAAc,MAAM,eAAe,UAAU;GACjD,GAAG;GACH,gBAAgB;EAClB,CAAC;EACD,MAAM,QAAQ,KAAK,IAAI,GAAG,SAAS,GAAG;EACtC,MAAM,eAAe,SAAS,eAAe,SAAS;EACtD,MAAM,UAAU,gBAAgB,MAAM,IAAI,KAAK;EAC/C,MAAM,aAAa,SAAS,gBAAgB,sBAAsB,sBAAsB,qBAAqB,YAAY,IAAI;EAC7H,MAAM,gBAAgB,KAAK,eAAe,KAAK,IAAI,iBAAiB,QAAQ,SAAS,UAAU,CAAC;EAChG,MAAM,YAAY,QAChB,KAAK,IACH,GACA,KAAK,IACH,YACA,aAAa,SAAS,MAAM,SAAS,QACrC,KAAK,IAAI,eAAe,aAAa,QAAQ,KAAK,IAAI,GAAG,SAAS,MAAM,CAAC,CAC3E,CACF,CACF;EACA,MAAM,QAAQ,KAAK,IACjB,SAAS,IAAI,OACb,SAAS,IAAI,aAAa,SAAS,SAAS,SAC9C;EACA,SAAS,MAAM,YAAY,GAAG,UAAU;EACxC,SAAS,YAAY,KAAK,IAAI,GAAG,QAAQ,SAAS,CAAC;EACnD,IAAI,kBAAkB;GACpB,MAAM,iBAAiB,SAAS,eAAe,KAAK,eAAe,KAAK,IAAI,iBAAiB,QAAQ,SAAS,UAAU,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC,8BAA8B,YAAY,UAAU,CAAC;GAC3M,SAAS,gBAAgB,iBAAiB,cAAc,CAAC;EAC3D;EACA,IAAI,aAAa;GACf;GACA,YAAY,UAAU,MAAM,eAC1B,gCACE;IAAE,GAAG;IAAU,GAAG;GAAM,GACxB,SAAS,eAAe,YAAY,SAAS,SAC/C,GACA,qBACF;EACF;EACA,OAAO,EACL,GAAG,MACL;CACF;AACF"}
@@ -18,7 +18,7 @@ var inner = function(props) {
18
18
  name: "inner",
19
19
  options: props,
20
20
  async fn(state) {
21
- var _listRef_current;
21
+ var _listRef_current, _listRef_current1;
22
22
  var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;
23
23
  var { rects, elements: { floating } } = state;
24
24
  var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];
@@ -42,18 +42,21 @@ var inner = function(props) {
42
42
  elementContext: "reference"
43
43
  });
44
44
  var diffY = Math.max(0, overflow.top);
45
- var nextY = nextArgs.y + diffY;
46
45
  var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
47
46
  var rounder = isScrollable ? function(v) {
48
47
  return v;
49
48
  } : Math.round;
50
- var maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
49
+ var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);
50
+ var _listRef_current_length;
51
+ var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0);
52
+ var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));
53
+ var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);
51
54
  scrollEl.style.maxHeight = `${maxHeight}px`;
52
- scrollEl.scrollTop = diffY;
55
+ scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);
53
56
  if (onFallbackChange) {
54
- var _listRef_current1;
55
- var _listRef_current_length;
56
- var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
57
+ var _listRef_current2;
58
+ var _listRef_current_length1;
59
+ var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _listRef_current_length1 !== void 0 ? _listRef_current_length1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
57
60
  ReactDOM.flushSync(function() {
58
61
  return onFallbackChange(shouldFallback);
59
62
  });
@@ -1 +1 @@
1
- {"version":3,"file":"inner.native.js","names":[],"sources":["esm/middleware/inner.native.js"],"sourcesContent":["import * as ReactDOM from \"react-dom\";\nimport { detectOverflow, offset } from \"@floating-ui/react-dom\";\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nvar inner = function(props) {\n return {\n name: \"inner\",\n options: props,\n async fn(state) {\n var _listRef_current;\n var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;\n var { rects, elements: { floating } } = state;\n var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];\n var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;\n var clientTop = floating.clientTop || scrollEl.clientTop;\n var floatingIsBordered = floating.clientTop !== 0;\n var scrollElIsBordered = scrollEl.clientTop !== 0;\n var floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);\n return {};\n }\n var nextArgs = {\n ...state,\n ...await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)\n };\n var detectOverflowOptions = {\n padding\n };\n var overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n var refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n var diffY = Math.max(0, overflow.top);\n var nextY = nextArgs.y + diffY;\n var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n var rounder = isScrollable ? function(v) {\n return v;\n } : Math.round;\n var maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = diffY;\n if (onFallbackChange) {\n var _listRef_current1;\n var _listRef_current_length;\n var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(function() {\n return onFallbackChange(shouldFallback);\n });\n }\n if (overflowRef) {\n ;\n overflowRef.current = await detectOverflow(getArgsWithCustomFloatingHeight({\n ...nextArgs,\n y: nextY\n }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);\n }\n return {\n y: nextY\n };\n }\n };\n};\nexport {\n inner\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings":";;;;AAEA,SAAS,gCAAgC,OAAO,QAAQ;CACtD,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,MAAM;GACT,UAAU;IACR,GAAG,MAAM,MAAM;IACf;GACF;EACF;CACF;AACF;AACA,IAAI,QAAQ,SAAS,OAAO;CAC1B,OAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,GAAG,OAAO;GACd,IAAI;GACJ,IAAI,EAAE,SAA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,QAAQ,KAAK,IAAI,GAAG,SAAS,MAAM,CAAC,CAAC;GACxL,SAAS,MAAM,YAAY,GAAG,UAAU;GACxC,SAAS,YAAY;GACrB,IAAI,kBAAkB;IACpB,IAAI;IACJ,IAAI;IACJ,IAAI,iBAAiB,SAAS,eAAe,KAAK,eAAe,KAAK,IAAI,kBAAkB,2BAA2B,oBAAoB,QAAQ,aAAa,QAAQ,sBAAsB,KAAK,IAAI,KAAK,IAAI,kBAAkB,YAAY,QAAQ,4BAA4B,KAAK,IAAI,0BAA0B,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC,8BAA8B,YAAY,UAAU,CAAC;IACxY,SAAS,UAAU,WAAW;KAC5B,OAAO,iBAAiB,cAAc;IACxC,CAAC;GACH;GACA,IAAI,aAAa;IACf;IACA,YAAY,UAAU,MAAM,eAAe,gCAAgC;KACzE,GAAG;KACH,GAAG;IACL,GAAG,SAAS,eAAe,YAAY,SAAS,SAAS,GAAG,qBAAqB;GACnF;GACA,OAAO,EACL,GAAG,MACL;EACF;CACF;AACF"}
1
+ {"version":3,"file":"inner.native.js","names":[],"sources":["esm/middleware/inner.native.js"],"sourcesContent":["import * as ReactDOM from \"react-dom\";\nimport { detectOverflow, offset } from \"@floating-ui/react-dom\";\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nvar inner = function(props) {\n return {\n name: \"inner\",\n options: props,\n async fn(state) {\n var _listRef_current, _listRef_current1;\n var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;\n var { rects, elements: { floating } } = state;\n var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];\n var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;\n var clientTop = floating.clientTop || scrollEl.clientTop;\n var floatingIsBordered = floating.clientTop !== 0;\n var scrollElIsBordered = scrollEl.clientTop !== 0;\n var floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);\n return {};\n }\n var nextArgs = {\n ...state,\n ...await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)\n };\n var detectOverflowOptions = {\n padding\n };\n var overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n var refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n var diffY = Math.max(0, overflow.top);\n var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n var rounder = isScrollable ? function(v) {\n return v;\n } : Math.round;\n var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);\n var _listRef_current_length;\n var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0);\n var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));\n var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);\n if (onFallbackChange) {\n var _listRef_current2;\n var _listRef_current_length1;\n var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _listRef_current_length1 !== void 0 ? _listRef_current_length1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(function() {\n return onFallbackChange(shouldFallback);\n });\n }\n if (overflowRef) {\n ;\n overflowRef.current = await detectOverflow(getArgsWithCustomFloatingHeight({\n ...nextArgs,\n y: nextY\n }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);\n }\n return {\n y: nextY\n };\n }\n };\n};\nexport {\n inner\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings":";;;;AAEA,SAAS,gCAAgC,OAAO,QAAQ;CACtD,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,MAAM;GACT,UAAU;IACR,GAAG,MAAM,MAAM;IACf;GACF;EACF;CACF;AACF;AACA,IAAI,QAAQ,SAAS,OAAO;CAC1B,OAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,GAAG,OAAO;GACd,IAAI,kBAAkB;GACtB,IAAI,EAAE,SAAS,aAAa,kBAAkB,QAAQ,cAAc,GAAG,QAAQ,GAAG,kBAAkB,GAAG,6BAA6B,GAAG,WAAW,UAAU,MAAM;GAClK,IAAI,EAAE,OAAO,UAAU,EAAE,eAAe;GACxC,IAAI,QAAQ,mBAAmB,QAAQ,aAAa,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB,UAAU,QAAQ,UAAU,KAAK,IAAI,QAAQ;GACjK,IAAI,YAAY,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU,YAAY;GAC5F,IAAI,YAAY,SAAS,aAAa,SAAS;GAC/C,IAAI,qBAAqB,SAAS,cAAc;GAChD,IAAI,qBAAqB,SAAS,cAAc;GAChD,IAAI,qBAAqB,aAAa;GACtC,IAAI,CAAC,QAAQ,SAAS,MAAM;IAC1B,qBAAqB,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB,IAAI;IACzF,OAAO,CAAC;GACV;GACA,IAAI,WAAW;IACb,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,aAAa,QAAQ,sBAAsB,KAAK,IAAI,KAAK,IAAI,kBAAkB,YAAY,QAAQ,6BAA6B,KAAK,IAAI,2BAA2B,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC,8BAA8B,YAAY,UAAU,CAAC;IAC3Y,SAAS,UAAU,WAAW;KAC5B,OAAO,iBAAiB,cAAc;IACxC,CAAC;GACH;GACA,IAAI,aAAa;IACf;IACA,YAAY,UAAU,MAAM,eAAe,gCAAgC;KACzE,GAAG;KACH,GAAG;IACL,GAAG,SAAS,eAAe,YAAY,SAAS,SAAS,GAAG,qBAAqB;GACnF;GACA,OAAO,EACL,GAAG,MACL;EACF;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/floating",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "files": [
@@ -37,10 +37,10 @@
37
37
  "dependencies": {
38
38
  "@floating-ui/react-dom": "^2.1.6",
39
39
  "@floating-ui/react-native": "^0.10.7",
40
- "@tamagui/use-event": "3.0.0"
40
+ "@tamagui/use-event": "3.0.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@tamagui/build": "3.0.0",
43
+ "@tamagui/build": "3.0.1",
44
44
  "react": "19.2.3",
45
45
  "react-native": "0.87.1"
46
46
  },
@@ -53,5 +53,5 @@
53
53
  "url": "git+https://github.com/tamagui/tamagui.git",
54
54
  "directory": "code/core/floating"
55
55
  },
56
- "releaseSourceCommit": "15fbca480b143f876f6975601e23a17d3f90d2ee"
56
+ "releaseSourceCommit": "c156b7cc55e5a6cc5883ebc8189720850ac32dbd"
57
57
  }
@@ -93,24 +93,35 @@ export const inner = (props: InnerProps): Middleware => ({
93
93
  })
94
94
 
95
95
  const diffY = Math.max(0, overflow.top)
96
- const nextY = nextArgs.y + diffY
97
96
  const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight
98
97
  const rounder = isScrollable ? (v: number) => v : Math.round
99
-
98
+ const fullHeight =
99
+ scrollEl.scrollHeight +
100
+ ((floatingIsBordered && floatingIsScrollEl) || scrollElIsBordered
101
+ ? clientTop * 2
102
+ : 0)
103
+ const minimumHeight =
104
+ item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0)
105
+
106
+ // keep the promised rows visible near a screen edge, moving the list when
107
+ // necessary instead of cropping a list that has room to show them
100
108
  const maxHeight = rounder(
101
109
  Math.max(
102
110
  0,
103
- scrollEl.scrollHeight +
104
- ((floatingIsBordered && floatingIsScrollEl) || scrollElIsBordered
105
- ? clientTop * 2
106
- : 0) -
107
- diffY -
108
- Math.max(0, overflow.bottom)
111
+ Math.min(
112
+ fullHeight,
113
+ fullHeight - overflow.top - overflow.bottom,
114
+ Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom))
115
+ )
109
116
  )
110
117
  )
118
+ const nextY = Math.min(
119
+ nextArgs.y + diffY,
120
+ nextArgs.y + fullHeight - overflow.bottom - maxHeight
121
+ )
111
122
 
112
123
  scrollEl.style.maxHeight = `${maxHeight}px`
113
- scrollEl.scrollTop = diffY
124
+ scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y)
114
125
 
115
126
  // check if we should fall back to standard positioning
116
127
  if (onFallbackChange) {
@@ -1 +1 @@
1
- {"version":3,"file":"inner.d.ts","sourceRoot":"","sources":["../../src/middleware/inner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,wBAAwB,CAAA;AAKzE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAA;IACnD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IACjC,gBAAgB,CAAC,EAAE,IAAI,GAAG,CAAC,C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