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

2 lines
9.4 KiB
JavaScript

import t,{Component as e}from"react";import{classNames as o,ObjectUtils as n}from"primereact/utils";import{Ripple as r}from"primereact/ripple";import{tip as i}from"primereact/tooltip";function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=new Array(e);o<e;o++)n[o]=t[o];return n}function s(t){if(Array.isArray(t))return l(t)}function a(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function p(t,e){if(t){if("string"==typeof t)return l(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?l(t,e):void 0}}function u(){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 c(t){return s(t)||a(t)||p(t)||u()}function f(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function y(t,e,o){return e&&h(t.prototype,e),o&&h(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function b(t,e){return b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},b(t,e)}function v(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&&b(t,e)}function m(t){return m="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},m(t)}function O(t,e){if(e&&("object"===m(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return d(t)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}function k(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function w(){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 j=function(n){v(a,e);var i,l,s=(i=a,l=w(),function(){var t,e=g(i);if(l){var o=g(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return O(this,t)});function a(t){var e;return f(this,a),(e=s.call(this,t)).state={focused:!1},e.onClick=e.onClick.bind(d(e)),e.onFocus=e.onFocus.bind(d(e)),e.onBlur=e.onBlur.bind(d(e)),e.onKeyDown=e.onKeyDown.bind(d(e)),e}return y(a,[{key:"onClick",value:function(t){this.props.onClick&&this.props.onClick({originalEvent:t,option:this.props.option})}},{key:"onFocus",value:function(){this.setState({focused:!0})}},{key:"onBlur",value:function(){this.setState({focused:!1})}},{key:"onKeyDown",value:function(t){var e=t.which;32!==e&&13!==e||(this.onClick(t),t.preventDefault())}},{key:"renderContent",value:function(){return this.props.template?this.props.template(this.props.option):t.createElement("span",{className:"p-button-label p-c"},this.props.label)}},{key:"render",value:function(){var e=o("p-button p-component",{"p-highlight":this.props.selected,"p-disabled":this.props.disabled,"p-focus":this.state.focused},this.props.className),n=this.renderContent();return t.createElement("div",{className:e,role:"button","aria-label":this.props.label,"aria-pressed":this.props.selected,"aria-labelledby":this.props.ariaLabelledBy,onClick:this.onClick,onKeyDown:this.onKeyDown,tabIndex:this.props.tabIndex,onFocus:this.onFocus,onBlur:this.onBlur},n,!this.props.disabled&&t.createElement(r,null))}}]),a}();function D(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function S(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?D(Object(o),!0).forEach((function(e){k(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):D(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function C(t,e){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=P(t))||e&&t&&"number"==typeof t.length){o&&(t=o);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,s=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return l=t.done,t},e:function(t){s=!0,i=t},f:function(){try{l||null==o.return||o.return()}finally{if(s)throw i}}}}function P(t,e){if(t){if("string"==typeof t)return E(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?E(t,e):void 0}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=new Array(e);o<e;o++)n[o]=t[o];return n}function B(){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}}k(j,"defaultProps",{option:null,label:null,className:null,selected:null,tabIndex:null,ariaLabelledBy:null,template:null,onClick:null});var A=function(r){v(p,e);var l,s,a=(l=p,s=B(),function(){var t,e=g(l);if(s){var o=g(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return O(this,t)});function p(t){var e;return f(this,p),(e=a.call(this,t)).onOptionClick=e.onOptionClick.bind(d(e)),e}return y(p,[{key:"onOptionClick",value:function(t){var e=this;if(!this.props.disabled&&!this.isOptionDisabled(t.option)){var o=this.isSelected(t.option);if(!o||this.props.unselectable){var r,i=this.getOptionValue(t.option);if(this.props.multiple){var l=this.props.value?c(this.props.value):[];r=o?l.filter((function(t){return!n.equals(t,i,e.props.dataKey)})):[].concat(c(l),[i])}else r=o?null:i;this.props.onChange&&this.props.onChange({originalEvent:t.originalEvent,value:r,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:r}})}}}},{key:"getOptionLabel",value:function(t){return this.props.optionLabel?n.resolveFieldData(t,this.props.optionLabel):t&&void 0!==t.label?t.label:t}},{key:"getOptionValue",value:function(t){return this.props.optionValue?n.resolveFieldData(t,this.props.optionValue):t&&void 0!==t.value?t.value:t}},{key:"isOptionDisabled",value:function(t){return this.props.optionDisabled?n.isFunction(this.props.optionDisabled)?this.props.optionDisabled(t):n.resolveFieldData(t,this.props.optionDisabled):!(!t||void 0===t.disabled)&&t.disabled}},{key:"isSelected",value:function(t){var e=!1,o=this.getOptionValue(t);if(this.props.multiple){if(this.props.value&&this.props.value.length){var r,i=C(this.props.value);try{for(i.s();!(r=i.n()).done;){if(n.equals(r.value,o,this.props.dataKey)){e=!0;break}}}catch(t){i.e(t)}finally{i.f()}}}else e=n.equals(this.props.value,o,this.props.dataKey);return e}},{key:"componentDidMount",value:function(){this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(t){t.tooltip===this.props.tooltip&&t.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(S({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=i({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderItems",value:function(){var e=this;return this.props.options&&this.props.options.length?this.props.options.map((function(o,n){var r=e.props.disabled||e.isOptionDisabled(o),i=e.getOptionLabel(o),l=r?null:0;return t.createElement(j,{key:"".concat(i,"_").concat(n),label:i,className:o.className,option:o,onClick:e.onOptionClick,template:e.props.itemTemplate,selected:e.isSelected(o),tabIndex:l,disabled:r,ariaLabelledBy:e.props.ariaLabelledBy})})):null}},{key:"render",value:function(){var e=this,n=o("p-selectbutton p-buttonset p-component",this.props.className),r=this.renderItems();return t.createElement("div",{id:this.props.id,ref:function(t){return e.element=t},className:n,style:this.props.style,role:"group"},r)}}]),p}();k(A,"defaultProps",{id:null,value:null,options:null,optionLabel:null,optionValue:null,optionDisabled:null,tabIndex:null,multiple:!1,unselectable:!0,disabled:!1,style:null,className:null,dataKey:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,itemTemplate:null,onChange:null});export{A as SelectButton};