2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
this.primereact=this.primereact||{},this.primereact.organizationchart=function(e,t,n){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(t);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function l(e){if(Array.isArray(e))return i(e)}function a(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function s(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):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 d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function f(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t){return h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},h(e,t)}function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function g(e,t){if(t&&("object"===y(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e){var t=S();return function(){var n,o=v(e);if(t){var r=v(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return g(this,n)}}function S(){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(e){return!1}}var E=function(e){m(o,e);var t=N(o);function o(e){var n;return p(this,o),(n=t.call(this,e)).node=n.props.node,n.state={expanded:n.node.expanded},n}return f(o,[{key:"getLeaf",value:function(){return!1!==this.node.leaf&&!(this.node.children&&this.node.children.length)}},{key:"getColspan",value:function(){return this.node.children&&this.node.children.length?2*this.node.children.length:null}},{key:"onNodeClick",value:function(e,t){this.props.onNodeClick(e,t)}},{key:"toggleNode",value:function(e,t){this.setState((function(e){return{expanded:!e.expanded}})),e.preventDefault()}},{key:"isSelected",value:function(){return this.props.isSelected(this.node)}},{key:"render",value:function(){var e=this;this.node=this.props.node;var t=this.getColspan(),i=n.classNames("p-organizationchart-node-content",this.node.className,{"p-organizationchart-selectable-node":this.props.selectionMode&&!1!==this.node.selectable,"p-highlight":this.isSelected()}),l=this.props.nodeTemplate&&this.props.nodeTemplate(this.node)?r.default.createElement("div",null,this.props.nodeTemplate(this.node)):r.default.createElement("div",null,this.node.label),a=n.classNames("p-node-toggler-icon",{"pi pi-chevron-down":this.state.expanded,"pi pi-chevron-up":!this.state.expanded}),s=r.default.createElement("tr",null,r.default.createElement("td",{colSpan:t},r.default.createElement("div",{className:i,onClick:function(t){return e.onNodeClick(t,e.node)}},l,!this.getLeaf()&&r.default.createElement("a",{href:"#",className:"p-node-toggler",onClick:function(t){return e.toggleNode(t,e.node)}},r.default.createElement("i",{className:a}))))),c=!this.getLeaf()&&this.state.expanded?"inherit":"hidden",d=r.default.createElement("tr",{style:{visibility:c},className:"p-organizationchart-lines"},r.default.createElement("td",{colSpan:t},r.default.createElement("div",{className:"p-organizationchart-line-down"}))),p=this.node.children&&this.node.children.length,u=r.default.createElement("tr",{style:{visibility:c},className:"p-organizationchart-lines"},this.node.children&&1===this.node.children.length&&r.default.createElement("td",{colSpan:this.getColspan()},r.default.createElement("div",{className:"p-organizationchart-line-down"})),this.node.children&&this.node.children.length>1&&this.node.children.map((function(e,t){var o=n.classNames("p-organizationchart-line-left",{"p-organizationchart-line-top":0!==t}),i=n.classNames("p-organizationchart-line-right",{"p-organizationchart-line-top":t!==p-1});return[r.default.createElement("td",{key:t+"_lineleft",className:o}," "),r.default.createElement("td",{key:t+"_lineright",className:i}," ")]}))),f=r.default.createElement("tr",{style:{visibility:c},className:"p-organizationchart-nodes"},this.node.children&&this.node.children.map((function(t,n){return r.default.createElement("td",{key:n,colSpan:"2"},r.default.createElement(o,{node:t,nodeTemplate:e.props.nodeTemplate,selectionMode:e.props.selectionMode,onNodeClick:e.props.onNodeClick,isSelected:e.props.isSelected}))})));return r.default.createElement("table",{className:"p-organizationchart-table"},r.default.createElement("tbody",null,s,d,u,f))}}]),o}(t.Component);b(E,"defaultProps",{node:null,nodeTemplate:null,root:!1,first:!1,last:!1,selectionMode:null,onNodeClick:null,isSelected:null});var k=function(e){m(o,e);var t=N(o);function o(e){var n;return p(this,o),(n=t.call(this,e)).root=n.props.value&&n.props.value.length?n.props.value[0]:null,n.onNodeClick=n.onNodeClick.bind(d(n)),n.isSelected=n.isSelected.bind(d(n)),n}return f(o,[{key:"onNodeClick",value:function(e,t){if(this.props.selectionMode){var n=e.target;if(n.className&&(-1!==n.className.indexOf("p-node-toggler")||-1!==n.className.indexOf("p-node-toggler-icon")))return;if(!1===t.selectable)return;var o,r=this.findIndexInSelection(t),i=r>=0;"single"===this.props.selectionMode?i?(o=null,this.props.onNodeUnselect&&this.props.onNodeUnselect({originalEvent:e,node:t})):(o=t,this.props.onNodeSelect&&this.props.onNodeSelect({originalEvent:e,node:t})):"multiple"===this.props.selectionMode&&(i?(o=this.props.selection.filter((function(e,t){return t!==r})),this.props.onNodeUnselect&&this.props.onNodeUnselect({originalEvent:e,node:t})):(o=[].concat(l(d=this.props.selection||[])||a(d)||s(d)||c(),[t]),this.props.onNodeSelect&&this.props.onNodeSelect({originalEvent:e,node:t}))),this.props.onSelectionChange&&this.props.onSelectionChange({originalEvent:e,data:o})}var d}},{key:"findIndexInSelection",value:function(e){var t=-1;if(this.props.selectionMode&&this.props.selection)if("single"===this.props.selectionMode)t=this.props.selection===e?0:-1;else if("multiple"===this.props.selectionMode)for(var n=0;n<this.props.selection.length;n++)if(this.props.selection[n]===e){t=n;break}return t}},{key:"isSelected",value:function(e){return-1!==this.findIndexInSelection(e)}},{key:"render",value:function(){this.root=this.props.value&&this.props.value.length?this.props.value[0]:null;var e=n.classNames("p-organizationchart p-component",this.props.className);return r.default.createElement("div",{id:this.props.id,style:this.props.style,className:e},r.default.createElement(E,{node:this.root,nodeTemplate:this.props.nodeTemplate,selectionMode:this.props.selectionMode,onNodeClick:this.onNodeClick,isSelected:this.isSelected}))}}]),o}(t.Component);return b(k,"defaultProps",{id:null,value:null,style:null,className:null,selectionMode:null,selection:null,nodeTemplate:null,onSelectionChange:null,onNodeSelect:null,onNodeUnselect:null}),e.OrganizationChart=k,e.OrganizationChartNode=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils);
|