@xsolla/xui-context-menu 0.226.0 → 0.227.0

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/native/index.mjs CHANGED
@@ -1516,6 +1516,7 @@ var filterItems = (items, query) => {
1516
1516
  return result;
1517
1517
  };
1518
1518
  var isOption = (item) => item.type === "option";
1519
+ var isSearchCellElement = (node) => isValidElement(node) && node.type === ContextMenuItem && node.props.type === "search";
1519
1520
  var ContextMenuRoot = forwardRef(
1520
1521
  ({
1521
1522
  children,
@@ -1792,7 +1793,7 @@ var ContextMenuRoot = forwardRef(
1792
1793
  );
1793
1794
  };
1794
1795
  const renderedItems = searchable ? filterItems(items, debouncedQuery) : [...items];
1795
- const searchHeader = searchable ? /* @__PURE__ */ jsx4(
1796
+ const renderStickySearch = (node, key) => /* @__PURE__ */ jsx4(
1796
1797
  "div",
1797
1798
  {
1798
1799
  "data-sticky": "top",
@@ -1802,21 +1803,34 @@ var ContextMenuRoot = forwardRef(
1802
1803
  zIndex: 1,
1803
1804
  backgroundColor: surfaceColor
1804
1805
  },
1805
- children: /* @__PURE__ */ jsx4(
1806
- ContextMenuItem,
1807
- {
1808
- type: "search",
1809
- value: query,
1810
- onValueChange: setQuery,
1811
- placeholder: "Search",
1812
- autoFocus: true,
1813
- themeMode,
1814
- themeProductContext
1815
- }
1816
- )
1806
+ children: node
1817
1807
  },
1808
+ key
1809
+ );
1810
+ const searchHeader = searchable ? renderStickySearch(
1811
+ /* @__PURE__ */ jsx4(
1812
+ ContextMenuItem,
1813
+ {
1814
+ type: "search",
1815
+ value: query,
1816
+ onValueChange: setQuery,
1817
+ placeholder: "Search",
1818
+ autoFocus: true,
1819
+ themeMode,
1820
+ themeProductContext
1821
+ }
1822
+ ),
1818
1823
  "context-menu-search"
1819
1824
  ) : null;
1825
+ const renderChildren = () => {
1826
+ if (!React3.Children.toArray(children).some(isSearchCellElement)) {
1827
+ return children;
1828
+ }
1829
+ return React3.Children.map(
1830
+ children,
1831
+ (child, index) => isSearchCellElement(child) ? renderStickySearch(child, `context-menu-search-${index}`) : child
1832
+ );
1833
+ };
1820
1834
  const renderContent = () => {
1821
1835
  if (loading || isLoading || type === "loading") {
1822
1836
  const brandColor = xuiTheme.colors.control.brand.primary.bg;
@@ -1831,7 +1845,7 @@ var ContextMenuRoot = forwardRef(
1831
1845
  }
1832
1846
  );
1833
1847
  }
1834
- if (children) return children;
1848
+ if (children) return renderChildren();
1835
1849
  if (renderedItems.length === 0) {
1836
1850
  const emptyNode = empty ?? /* @__PURE__ */ jsx4(
1837
1851
  "div",