@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/web/index.mjs CHANGED
@@ -1542,6 +1542,7 @@ var filterItems = (items, query) => {
1542
1542
  return result;
1543
1543
  };
1544
1544
  var isOption = (item) => item.type === "option";
1545
+ var isSearchCellElement = (node) => isValidElement(node) && node.type === ContextMenuItem && node.props.type === "search";
1545
1546
  var ContextMenuRoot = forwardRef(
1546
1547
  ({
1547
1548
  children,
@@ -1818,7 +1819,7 @@ var ContextMenuRoot = forwardRef(
1818
1819
  );
1819
1820
  };
1820
1821
  const renderedItems = searchable ? filterItems(items, debouncedQuery) : [...items];
1821
- const searchHeader = searchable ? /* @__PURE__ */ jsx4(
1822
+ const renderStickySearch = (node, key) => /* @__PURE__ */ jsx4(
1822
1823
  "div",
1823
1824
  {
1824
1825
  "data-sticky": "top",
@@ -1828,21 +1829,34 @@ var ContextMenuRoot = forwardRef(
1828
1829
  zIndex: 1,
1829
1830
  backgroundColor: surfaceColor
1830
1831
  },
1831
- children: /* @__PURE__ */ jsx4(
1832
- ContextMenuItem,
1833
- {
1834
- type: "search",
1835
- value: query,
1836
- onValueChange: setQuery,
1837
- placeholder: "Search",
1838
- autoFocus: true,
1839
- themeMode,
1840
- themeProductContext
1841
- }
1842
- )
1832
+ children: node
1843
1833
  },
1834
+ key
1835
+ );
1836
+ const searchHeader = searchable ? renderStickySearch(
1837
+ /* @__PURE__ */ jsx4(
1838
+ ContextMenuItem,
1839
+ {
1840
+ type: "search",
1841
+ value: query,
1842
+ onValueChange: setQuery,
1843
+ placeholder: "Search",
1844
+ autoFocus: true,
1845
+ themeMode,
1846
+ themeProductContext
1847
+ }
1848
+ ),
1844
1849
  "context-menu-search"
1845
1850
  ) : null;
1851
+ const renderChildren = () => {
1852
+ if (!React5.Children.toArray(children).some(isSearchCellElement)) {
1853
+ return children;
1854
+ }
1855
+ return React5.Children.map(
1856
+ children,
1857
+ (child, index2) => isSearchCellElement(child) ? renderStickySearch(child, `context-menu-search-${index2}`) : child
1858
+ );
1859
+ };
1846
1860
  const renderContent = () => {
1847
1861
  if (loading || isLoading || type === "loading") {
1848
1862
  const brandColor = xuiTheme.colors.control.brand.primary.bg;
@@ -1857,7 +1871,7 @@ var ContextMenuRoot = forwardRef(
1857
1871
  }
1858
1872
  );
1859
1873
  }
1860
- if (children) return children;
1874
+ if (children) return renderChildren();
1861
1875
  if (renderedItems.length === 0) {
1862
1876
  const emptyNode = empty ?? /* @__PURE__ */ jsx4(
1863
1877
  "div",