Liferay.Loader.define("knowledge-base-web@5.0.98/admin/js/components/SearchField",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/empty-state","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/link","@frontend-taglib-clay$clayui/list","frontend-js-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function SearchField({handleSearchChange:e,items:t}){const a={filteredItems:[],query:""},[l,u]=(0,f.useState)(a),[i,c]=(0,f.useState)(!1);(0,f.useEffect)((()=>{e({isSearchActive:i})}),[e,i]);const o=l.query?Liferay.Language.get("clear"):Liferay.Language.get("search");return f.default.createElement(f.default.Fragment,null,f.default.createElement(n.ClayInput.Group,{small:!0},f.default.createElement(n.ClayInput.GroupItem,null,f.default.createElement(n.ClayInput,{"aria-label":Liferay.Language.get("search-for"),className:"form-control input-group-inset input-group-inset-after",onChange:e=>{const a=e.target.value;let r=[];a.length>d&&(r=t.filter((e=>e.name.toLowerCase().includes(a.toLowerCase())))),c(a.length>d),u({filteredItems:r,query:a})},placeholder:Liferay.Language.get("search-for"),type:"text",value:l.query}),f.default.createElement(n.ClayInput.GroupInsetItem,{after:!0,tag:"span"},f.default.createElement(r.ClayButtonWithIcon,{"aria-label":o,displayType:"unstyled",onClick:()=>{l.query&&(u(a),c(!1))},small:!0,symbol:l.query?"times":"search",title:o})))),f.default.createElement("hr",{className:"separator"}),i&&f.default.createElement(SearchResult,{filteredItems:l.filteredItems,keyword:l.query}))};var r=a("@frontend-taglib-clay$clayui/button"),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/empty-state")),n=a("@frontend-taglib-clay$clayui/form"),u=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/link")),c=_interopRequireDefault(a("@frontend-taglib-clay$clayui/list")),o=a("frontend-js-web"),f=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=r?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(a,l,n):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={article:"document-text",folder:"folder"},d=2,highlithKeywordInText=(e,t)=>{const a=e.split(new RegExp("(".concat(t,")"),"gi"));return f.default.createElement("span",null,a.map((e=>e.toLowerCase()===t.toLowerCase()?f.default.createElement("b",null,e):e)))},SearchResult=({filteredItems:t,keyword:a})=>t.length?f.default.createElement(c.default,{role:"list"},t.map((t=>f.default.createElement(c.default.ItemField,{expand:!0,key:t.id},f.default.createElement(i.default,{className:"p-1",displayType:"secondary",href:t.href},f.default.createElement(u.default,{className:"mr-2",symbol:e[t.type]}),highlithKeywordInText(t.name,a)))))):f.default.createElement(l.default,{description:(0,o.sub)(Liferay.Language.get("no-content-was-found-that-matched-keyword-x"),[a]),imgSrc:"".concat(themeDisplay.getPathThemeImages(),"/states/search_state.gif"),small:!0,title:Liferay.Language.get("no-results-found")})}}));
//# sourceMappingURL=SearchField.js.map