Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/views/table/FieldsSelectorDropdown",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../FrontendDataSetContext","../../thunks/persistVisibleFieldNames","../ViewsContext"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=d(r("@frontend-taglib-clay$clayui/button")),n=d(r("@frontend-taglib-clay$clayui/drop-down")),l=d(r("@frontend-taglib-clay$clayui/icon")),o=(d(r("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=a?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(r,n,l):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),i=d(r("../../FrontendDataSetContext")),u=d(r("../../thunks/persistVisibleFieldNames")),c=d(r("../ViewsContext"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function d(e){return e&&e.__esModule?e:{default:e}}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var b=({fields:e})=>{const{appURL:t,id:r,portletId:f}=(0,o.useContext)(i.default),[{visibleFieldNames:d},s]=(0,o.useContext)(c.default),[y,b]=(0,o.useState)(!1),[m,g]=(0,o.useState)(e),[w,O]=(0,o.useState)(""),j=Object.keys(d).length?d:e.reduce(((e,t)=>p(p({},e),{},{[t.fieldName]:!0})),{});return(0,o.useEffect)((()=>{g(e.filter((e=>e.label.toLowerCase().includes(w.toLowerCase()))))}),[e,w]),o.default.createElement(n.default,{active:y,className:"ml-auto",onActiveChange:b,trigger:o.default.createElement(a.default,{borderless:!0,displayType:"secondary"},o.default.createElement(l.default,{symbol:y?"caret-top":"caret-bottom"}),o.default.createElement("span",{className:"sr-only"},y?Liferay.Language.get("close-fields-menu"):Liferay.Language.get("open-fields-menu")))},o.default.createElement(n.default.Search,{formProps:{onSubmit:e=>e.preventDefault()},onChange:e=>O(e.target.value),value:w}),m.length?o.default.createElement(n.default.ItemList,null,m.map((({fieldName:e,label:a})=>o.default.createElement(n.default.Item,{key:e,onClick:()=>{s((0,u.default)({appURL:t,id:r,portletId:f,visibleFieldNames:p(p({},j),{},{[e]:!j[e]})}))}},j[e]&&o.default.createElement(l.default,{className:"mr-2",symbol:"check"}),a)))):o.default.createElement("div",{className:"dropdown-section text-muted"},Liferay.Language.get("no-fields-were-found")))};t.default=b}}));
//# sourceMappingURL=FieldsSelectorDropdown.js.map