katoikia-app/web-ui/web-react/node_modules/primereact/dataview/dataview.esm.min.js

2 lines
9.1 KiB
JavaScript

import t,{Component as e}from"react";import{Paginator as r}from"primereact/paginator";import{classNames as o,ObjectUtils as n}from"primereact/utils";import{Ripple as a}from"primereact/ripple";import{localeOption as i}from"primereact/api";function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}function p(t){if(Array.isArray(t))return s(t)}function l(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function u(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function f(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function g(t,e,r){return e&&f(t.prototype,e),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function m(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function b(t,e){if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return y(t)}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}function w(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function k(t){var e=E();return function(){var r,o=P(t);if(e){var n=P(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return b(this,r)}}function E(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var R=function(r){m(i,e);var n=k(i);function i(t){var e;return h(this,i),(e=n.call(this,t)).changeLayout=e.changeLayout.bind(y(e)),e}return g(i,[{key:"changeLayout",value:function(t,e){this.props.onChange({originalEvent:t,value:e}),t.preventDefault()}},{key:"render",value:function(){var e=this,r=o("p-dataview-layout-options p-selectbutton p-buttonset",this.props.className),n=o("p-button p-button-icon-only",{"p-highlight":"list"===this.props.layout}),i=o("p-button p-button-icon-only",{"p-highlight":"grid"===this.props.layout});return t.createElement("div",{id:this.props.id,style:this.props.style,className:r},t.createElement("button",{type:"button",className:n,onClick:function(t){return e.changeLayout(t,"list")}},t.createElement("i",{className:"pi pi-bars"}),t.createElement(a,null)),t.createElement("button",{type:"button",className:i,onClick:function(t){return e.changeLayout(t,"grid")}},t.createElement("i",{className:"pi pi-th-large"}),t.createElement(a,null)))}}]),i}();w(R,"defaultProps",{id:null,style:null,className:null,layout:null,onChange:null});var N=function(t){m(o,e);var r=k(o);function o(){return h(this,o),r.apply(this,arguments)}return g(o,[{key:"render",value:function(){return this.props.template(this.props.item,this.props.layout)}}]),o}();w(N,"defaultProps",{template:null,item:null,layout:null});var O=function(a){m(f,e);var s=k(f);function f(t){var e;return h(this,f),(e=s.call(this,t)).props.onPage||(e.state={first:e.props.first,rows:e.props.rows}),e.sortChange=!1,e.onPageChange=e.onPageChange.bind(y(e)),e}return g(f,[{key:"getItemRenderKey",value:function(t){return this.props.dataKey?n.resolveFieldData(t,this.props.dataKey):null}},{key:"getTotalRecords",value:function(){return this.props.totalRecords?this.props.totalRecords:this.props.value?this.props.value.length:0}},{key:"createPaginator",value:function(e){var n=o("p-paginator-"+e,this.props.paginatorClassName),a=this.props.onPage?this.props.first:this.state.first,i=this.props.onPage?this.props.rows:this.state.rows,s=this.getTotalRecords();return t.createElement(r,{first:a,rows:i,pageLinkSize:this.props.pageLinkSize,className:n,onPageChange:this.onPageChange,template:this.props.paginatorTemplate,totalRecords:s,rowsPerPageOptions:this.props.rowsPerPageOptions,currentPageReportTemplate:this.props.currentPageReportTemplate,leftContent:this.props.paginatorLeft,rightContent:this.props.paginatorRight,alwaysShow:this.props.alwaysShowPaginator,dropdownAppendTo:this.props.paginatorDropdownAppendTo})}},{key:"onPageChange",value:function(t){this.props.onPage?this.props.onPage(t):this.setState({first:t.first,rows:t.rows})}},{key:"isEmpty",value:function(){return!this.props.value||0===this.props.value.length}},{key:"sort",value:function(){var t,e=this;if(this.props.value){var r=p(t=this.props.value)||l(t)||u(t)||c();return r.sort((function(t,r){var o=n.resolveFieldData(t,e.props.sortField),a=n.resolveFieldData(r,e.props.sortField),i=null;return i=null==o&&null!=a?-1:null!=o&&null==a?1:null==o&&null==a?0:"string"==typeof o&&"string"==typeof a?o.localeCompare(a,void 0,{numeric:!0}):o<a?-1:o>a?1:0,e.props.sortOrder*i})),r}return null}},{key:"renderLoader",value:function(){if(this.props.loading){var e=o("p-dataview-loading-icon pi-spin",this.props.loadingIcon);return t.createElement("div",{className:"p-dataview-loading-overlay p-component-overlay"},t.createElement("i",{className:e}))}return null}},{key:"renderTopPaginator",value:function(){return!this.props.paginator||"bottom"===this.props.paginatorPosition&&"both"!==this.props.paginatorPosition?null:this.createPaginator("top")}},{key:"renderBottomPaginator",value:function(){return!this.props.paginator||"top"===this.props.paginatorPosition&&"both"!==this.props.paginatorPosition?null:this.createPaginator("bottom")}},{key:"renderEmptyMessage",value:function(){if(!this.props.loading){var e=this.props.emptyMessage||i("emptyMessage");return t.createElement("div",{className:"p-col-12 col-12 p-dataview-emptymessage"},e)}return null}},{key:"renderHeader",value:function(){return this.props.header?t.createElement("div",{className:"p-dataview-header"},this.props.header):null}},{key:"renderFooter",value:function(){return this.props.footer?t.createElement("div",{className:"p-dataview-footer"}," ",this.props.footer):null}},{key:"renderItems",value:function(e){var r=this;if(e&&e.length){if(this.props.paginator){for(var o=this.props.onPage?this.props.rows:this.state.rows,n=this.props.lazy?0:this.props.onPage?this.props.first:this.state.first,a=this.getTotalRecords(),i=Math.min(o+n,a),s=[],p=n;p<i;p++){var l=e[p];l&&s.push(t.createElement(N,{key:this.getItemRenderKey(e)||p,template:this.props.itemTemplate,layout:this.props.layout,item:l}))}return s}return e.map((function(e,o){return t.createElement(N,{key:r.getItemRenderKey(e)||o,template:r.props.itemTemplate,layout:r.props.layout,item:e})}))}return this.renderEmptyMessage()}},{key:"renderContent",value:function(e){var r=this.renderItems(e);return t.createElement("div",{className:"p-dataview-content"},t.createElement("div",{className:"p-grid p-nogutter grid grid-nogutter"},r))}},{key:"processData",value:function(){var t=this.props.value;return t&&t.length&&this.props.sortField&&(t=this.sort()),t}},{key:"render",value:function(){var e=this.processData(),r=o("p-dataview p-component",{"p-dataview-list":"list"===this.props.layout,"p-dataview-grid":"grid"===this.props.layout,"p-dataview-loading":this.props.loading},this.props.className),n=this.renderLoader(),a=this.renderTopPaginator(),i=this.renderBottomPaginator(),s=this.renderHeader(),p=this.renderFooter(),l=this.renderContent(e);return t.createElement("div",{id:this.props.id,style:this.props.style,className:r},n,s,a,l,i,p)}}]),f}();w(O,"defaultProps",{id:null,header:null,footer:null,value:null,layout:"list",dataKey:null,rows:null,first:0,totalRecords:null,paginator:!1,paginatorPosition:"bottom",alwaysShowPaginator:!0,paginatorClassName:null,paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown",paginatorLeft:null,paginatorRight:null,paginatorDropdownAppendTo:null,pageLinkSize:5,rowsPerPageOptions:null,currentPageReportTemplate:"({currentPage} of {totalPages})",emptyMessage:null,sortField:null,sortOrder:null,style:null,className:null,lazy:!1,loading:!1,loadingIcon:"pi pi-spinner",itemTemplate:null,onPage:null});export{O as DataView,R as DataViewLayoutOptions};