import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { useRecordBoardContext } from "../../hooks/useRecordBoardContext.js";
import { PisellFind } from "../../../pisellFind/index.js";
import React, { useCallback } from "react";
//#region src/components/pisellRecordBoard/shellFrame/Search/index.tsx
/** 与 context.searchParams 对应的默认搜索参数字段名 */
const DEFAULT_SEARCH_FIELD = "keyword";
/**
* RecordBoard 下的独立搜索槽：使用 PisellFind，绑定 context.searchParams.keyword 与 onSearch。
* 可通过 childComponentProps.search 透传 PisellFind 的 props。
*/
const RecordBoardSearch = (props) => {
	var _searchParams$DEFAULT;
	const ctx = useRecordBoardContext({ displayName: "search" });
	const { searchParams, onSearch } = ctx;
	const searchProps = ctx;
	const keyword = (_searchParams$DEFAULT = searchParams === null || searchParams === void 0 ? void 0 : searchParams[DEFAULT_SEARCH_FIELD]) !== null && _searchParams$DEFAULT !== void 0 ? _searchParams$DEFAULT : "";
	const handleSearch = useCallback((value) => {
		onSearch(_objectSpread2(_objectSpread2({}, searchParams), {}, { [DEFAULT_SEARCH_FIELD]: value || void 0 }));
	}, [onSearch, searchParams]);
	return /* @__PURE__ */ React.createElement("div", {
		"data-layout-slot": "search",
		style: { marginBottom: 8 }
	}, /* @__PURE__ */ React.createElement(PisellFind, _objectSpread2({
		value: keyword,
		onSearch: handleSearch
	}, searchProps)));
};
RecordBoardSearch.displayName = "RecordBoard.Search";
//#endregion
export { RecordBoardSearch as default };
