Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/views/table/Table",["module","exports","require","@frontend-taglib-clay$clayui/empty-state","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/loading-indicator","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../FrontendDataSetContext","../../actions/Actions","../../utils/index","../ViewsContext","./TableCell","./TableHead","./TableInlineAddingRow","./dnd_table/index"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getVisibleFields=w,t.default=void 0;var n=b(a("@frontend-taglib-clay$clayui/empty-state")),l=a("@frontend-taglib-clay$clayui/form"),i=b(a("@frontend-taglib-clay$clayui/loading-indicator")),r=b(a("liferay!frontend-js-react-web$classnames")),s=(b(a("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=p();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var i=n?Object.getOwnPropertyDescriptor(e,l):null;i&&(i.get||i.set)?Object.defineProperty(a,l,i):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),o=b(a("../../FrontendDataSetContext")),d=b(a("../../actions/Actions")),c=a("../../utils/index"),u=b(a("../ViewsContext")),f=b(a("./TableCell")),m=b(a("./TableHead")),g=b(a("./TableInlineAddingRow")),y=b(a("./dnd_table/index"));function p(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return p=function(){return e},e}function b(e){return e&&e.__esModule?e:{default:e}}function h(e,t,a,n,l=null){return t.map((t=>{const{actionDropdownItems:i}=e,{rootPropertyName:r,value:o,valuePath:d}=t.fieldName?(0,c.getValueDetailsFromItem)(e,t.fieldName):{};return s.default.createElement(f.default,{actions:n||i,inlineEditSettings:t.inlineEditSettings,itemData:e,itemId:a,itemInlineChanges:l,key:d?d.join("_"):t.label,options:t,rootPropertyName:r,value:o,valuePath:d,view:{contentRenderer:t.contentRenderer,contentRendererModuleURL:t.contentRendererModuleURL}})}))}function w(e,t){const a=e.filter((({fieldName:e})=>t[e]));return a.length?a:e}function v({dataLoading:e,items:t,itemsActions:a,schema:c,style:f}){const{highlightedItemsValue:p,inlineAddingSettings:b,itemsChanges:v,nestedItemsKey:C,nestedItemsReferenceKey:E,selectItems:I,selectable:N,selectedItemsKey:j,selectedItemsValue:x,selectionType:P,sorting:R,updateSorting:$}=(0,s.useContext)(o.default),[{activeView:{options:D},visibleFieldNames:S}]=(0,s.useContext)(u.default),{quickActionsEnabled:T}=D||{},L=w(c.fields,S),_=(0,s.useMemo)((()=>Boolean((null==a?void 0:a.length)||(null==t?void 0:t.find((e=>e.actions||e.actionDropdownItems))))),[t,a]),k="multiple"===P?l.ClayCheckbox:l.ClayRadio;let O;O=e?s.default.createElement(i.default,{className:"mt-7"}):s.default.createElement(s.default.Fragment,null,(b||!b&&!!t.length)&&s.default.createElement(y.default.Table,{borderless:!0,className:(0,r.default)("table-style-".concat(f),{"with-quick-actions":T}),hover:!1,responsive:!0,striped:!0},s.default.createElement(m.default,{fields:L,items:t,schema:c,selectItems:I,selectable:N,selectedItemsKey:j,selectedItemsValue:x,selectionType:P,sorting:R,updateSorting:$}),s.default.createElement(y.default.Body,null,b&&s.default.createElement(g.default,{fields:L,selectable:N}),!!t.length&&t.map((e=>{const t=e[null!=j?j:"id"],n=E&&e[E];return s.default.createElement(s.default.Fragment,{key:t},s.default.createElement(y.default.Row,{className:(0,r.default)({active:p.includes(t),selected:x.includes(t)})},N&&s.default.createElement(y.default.Cell,{className:"item-selector",columnName:"item-selector"},s.default.createElement(k,{checked:!!x.find((e=>String(e)===String(t))),onChange:()=>I(t),value:t})),h(e,L,t,a,v[t]),s.default.createElement(y.default.Cell,{className:"item-actions",columnName:"item-actions"},(_||e.actions)&&s.default.createElement(d.default,{actions:a||e.actions||e.actionDropdownItems,itemData:e,itemId:t}))),n&&n.map(((e,t)=>s.default.createElement(y.default.Row,{className:(0,r.default)("nested",p.includes(e[C])&&"active",t===n.length-1&&"last"),key:e[C],paddingLeftCells:N&&1,paddingRightCells:_&&1},h(e,L,e[C],a)))))})))),!t.length&&s.default.createElement(n.default,{description:Liferay.Language.get("sorry,-no-results-were-found"),imgSrc:"".concat(themeDisplay.getPathThemeImages(),"/states/search_state.gif"),title:Liferay.Language.get("no-results-found")}));const M=[];return N&&M.push("item-selector"),M.push(...L.map((e=>String(e.fieldName))),"item-actions"),s.default.createElement(y.default.ContextProvider,{columnNames:M},O)}v.defaultProps={items:[]};var C=v;t.default=C}}));
//# sourceMappingURL=Table.js.map