primereact 7.2.0 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendar/calendar.cjs.js +1 -1
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +1 -1
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +1 -1
- package/calendar/calendar.min.js +1 -1
- package/carousel/carousel.cjs.js +212 -5
- package/carousel/carousel.cjs.min.js +1 -1
- package/carousel/carousel.esm.js +212 -5
- package/carousel/carousel.esm.min.js +1 -1
- package/carousel/carousel.js +212 -5
- package/carousel/carousel.min.js +1 -1
- package/core/core.js +34 -3
- package/core/core.min.js +4 -4
- package/datatable/datatable.cjs.js +21 -16
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.d.ts +1 -0
- package/datatable/datatable.esm.js +21 -16
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +21 -16
- package/datatable/datatable.min.js +1 -1
- package/dataview/dataview.cjs.js +1 -5
- package/dataview/dataview.cjs.min.js +1 -1
- package/dataview/dataview.esm.js +1 -5
- package/dataview/dataview.esm.min.js +1 -1
- package/dataview/dataview.js +1 -5
- package/dataview/dataview.min.js +1 -1
- package/dropdown/dropdown.cjs.js +1 -1
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +1 -1
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +1 -1
- package/dropdown/dropdown.min.js +1 -1
- package/galleria/galleria.cjs.js +212 -5
- package/galleria/galleria.cjs.min.js +1 -1
- package/galleria/galleria.esm.js +212 -5
- package/galleria/galleria.esm.min.js +1 -1
- package/galleria/galleria.js +212 -5
- package/galleria/galleria.min.js +1 -1
- package/inputnumber/inputnumber.cjs.js +5 -1
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +5 -1
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +5 -1
- package/inputnumber/inputnumber.min.js +1 -1
- package/knob/knob.cjs.js +1 -1
- package/knob/knob.cjs.min.js +1 -1
- package/knob/knob.esm.js +1 -1
- package/knob/knob.esm.min.js +1 -1
- package/knob/knob.js +1 -1
- package/knob/knob.min.js +1 -1
- package/multiselect/multiselect.cjs.js +1 -1
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +1 -1
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +1 -1
- package/multiselect/multiselect.min.js +1 -1
- package/package.json +1 -1
- package/primereact.all.cjs.js +142 -122
- package/primereact.all.cjs.min.js +1 -1
- package/primereact.all.esm.js +142 -122
- package/primereact.all.esm.min.js +1 -1
- package/primereact.all.js +142 -122
- package/primereact.all.min.js +1 -1
- package/resources/primereact.css +7 -2
- package/resources/primereact.min.css +1 -1
- package/resources/themes/arya-blue/theme.css +254 -2
- package/resources/themes/arya-green/theme.css +254 -2
- package/resources/themes/arya-orange/theme.css +254 -2
- package/resources/themes/arya-purple/theme.css +254 -2
- package/resources/themes/bootstrap4-dark-blue/theme.css +254 -2
- package/resources/themes/bootstrap4-dark-purple/theme.css +254 -2
- package/resources/themes/bootstrap4-light-blue/theme.css +252 -0
- package/resources/themes/bootstrap4-light-purple/theme.css +252 -0
- package/resources/themes/fluent-light/theme.css +252 -0
- package/resources/themes/lara-dark-blue/theme.css +261 -44
- package/resources/themes/lara-dark-indigo/theme.css +261 -44
- package/resources/themes/lara-dark-purple/theme.css +261 -44
- package/resources/themes/lara-dark-teal/theme.css +261 -44
- package/resources/themes/lara-light-blue/theme.css +259 -42
- package/resources/themes/lara-light-indigo/theme.css +259 -42
- package/resources/themes/lara-light-purple/theme.css +259 -42
- package/resources/themes/lara-light-teal/theme.css +259 -42
- package/resources/themes/luna-amber/theme.css +252 -0
- package/resources/themes/luna-blue/theme.css +252 -0
- package/resources/themes/luna-green/theme.css +252 -0
- package/resources/themes/luna-pink/theme.css +252 -0
- package/resources/themes/md-dark-deeppurple/theme.css +328 -2
- package/resources/themes/md-dark-indigo/theme.css +328 -2
- package/resources/themes/md-light-deeppurple/theme.css +326 -0
- package/resources/themes/md-light-indigo/theme.css +326 -0
- package/resources/themes/mdc-dark-deeppurple/theme.css +328 -2
- package/resources/themes/mdc-dark-indigo/theme.css +328 -2
- package/resources/themes/mdc-light-deeppurple/theme.css +326 -0
- package/resources/themes/mdc-light-indigo/theme.css +326 -0
- package/resources/themes/nova/theme.css +252 -0
- package/resources/themes/nova-accent/theme.css +252 -0
- package/resources/themes/nova-alt/theme.css +252 -0
- package/resources/themes/rhea/theme.css +252 -0
- package/resources/themes/saga-blue/theme.css +252 -0
- package/resources/themes/saga-green/theme.css +252 -0
- package/resources/themes/saga-orange/theme.css +252 -0
- package/resources/themes/saga-purple/theme.css +252 -0
- package/resources/themes/tailwind-light/theme.css +252 -0
- package/resources/themes/vela-blue/theme.css +254 -2
- package/resources/themes/vela-green/theme.css +254 -2
- package/resources/themes/vela-orange/theme.css +254 -2
- package/resources/themes/vela-purple/theme.css +254 -2
- package/splitbutton/splitbutton.d.ts +4 -1
- package/splitbutton/splitbutton.min.css +1 -1
- package/tabmenu/tabmenu.cjs.js +1 -1
- package/tabmenu/tabmenu.cjs.min.js +1 -1
- package/tabmenu/tabmenu.esm.js +1 -1
- package/tabmenu/tabmenu.esm.min.js +1 -1
- package/tabmenu/tabmenu.js +1 -1
- package/tabmenu/tabmenu.min.js +1 -1
- package/tabview/tabview.cjs.js +1 -1
- package/tabview/tabview.cjs.min.js +1 -1
- package/tabview/tabview.esm.js +1 -1
- package/tabview/tabview.esm.min.js +1 -1
- package/tabview/tabview.js +1 -1
- package/tabview/tabview.min.js +1 -1
- package/toolbar/toolbar.min.css +1 -1
- package/tree/tree.cjs.js +2 -1
- package/tree/tree.cjs.min.js +1 -1
- package/tree/tree.esm.js +2 -1
- package/tree/tree.esm.min.js +1 -1
- package/tree/tree.js +2 -1
- package/tree/tree.min.js +1 -1
- package/treeselect/treeselect.cjs.js +3 -3
- package/treeselect/treeselect.cjs.min.js +1 -1
- package/treeselect/treeselect.esm.js +3 -3
- package/treeselect/treeselect.esm.min.js +1 -1
- package/treeselect/treeselect.js +3 -3
- package/treeselect/treeselect.min.js +1 -1
- package/treetable/treetable.cjs.js +12 -10
- package/treetable/treetable.cjs.min.js +1 -1
- package/treetable/treetable.esm.js +8 -7
- package/treetable/treetable.esm.min.js +1 -1
- package/treetable/treetable.js +12 -10
- package/treetable/treetable.min.js +1 -1
- package/utils/utils.cjs.js +26 -0
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.d.ts +1 -0
- package/utils/utils.esm.js +26 -0
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +26 -0
- package/utils/utils.min.js +1 -1
- package/web-types.json +15 -3
- package/resources/themes/lara-dark-blue/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-dark-blue/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-dark-indigo/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-dark-purple/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-dark-teal/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-light-blue/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-light-indigo/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-light-purple/fonts/Inter-SemiBold.woff2 +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Bold.woff +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Bold.woff2 +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Light.woff +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Light.woff2 +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Medium.woff +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Medium.woff2 +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Regular.woff +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-Regular.woff2 +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-SemiBold.woff +0 -0
- package/resources/themes/lara-light-teal/fonts/Inter-SemiBold.woff2 +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),i=require("primereact/ripple"),n=require("primereact/api");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=s(t),r=s(n);function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function l(t){if(Array.isArray(t))return o(t)}function u(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function c(t,e){if(t){if("string"==typeof t)return o(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?o(t,e):void 0}}function p(){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){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,i){return e&&d(t.prototype,e),i&&d(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t,e){return v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},v(t,e)}function y(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&&v(t,e)}function g(t){return g="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},g(t)}function b(t,e){if(e&&("object"===g(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},S(t)}function I(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function k(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function w(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?k(Object(i),!0).forEach((function(e){I(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):k(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function P(t){var e=O();return function(){var i,n=S(t);if(e){var s=S(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return b(this,i)}}function O(){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 C=function(i){y(s,t.Component);var n=P(s);function s(){return m(this,s),n.apply(this,arguments)}return f(s,[{key:"render",value:function(){var t=this.props.template(this.props.item),i=e.classNames(this.props.className,"p-carousel-item",{"p-carousel-item-active":this.props.active,"p-carousel-item-start":this.props.start,"p-carousel-item-end":this.props.end});return a.default.createElement("div",{className:i},t)}}]),s}();I(C,"defaultProps",{template:null,item:null,active:!1,start:!1,end:!1,className:null});var V=function(n){y(o,t.Component);var s=P(o);function o(t){var i;return m(this,o),(i=s.call(this,t)).state={numVisible:t.numVisible,numScroll:t.numScroll,totalShiftedItems:t.page*t.numScroll*-1},i.props.onPageChange||(i.state=w(w({},i.state),{},{page:t.page})),i.navBackward=i.navBackward.bind(h(i)),i.navForward=i.navForward.bind(h(i)),i.onTransitionEnd=i.onTransitionEnd.bind(h(i)),i.onTouchStart=i.onTouchStart.bind(h(i)),i.onTouchMove=i.onTouchMove.bind(h(i)),i.onTouchEnd=i.onTouchEnd.bind(h(i)),i.totalIndicators=0,i.remainingItems=0,i.allowAutoplay=!!i.props.autoplayInterval,i.circular=i.props.circular||i.allowAutoplay,i.attributeSelector=e.UniqueComponentId(),i.swipeThreshold=20,i}return f(o,[{key:"step",value:function(t,i){var n=this.state.totalShiftedItems,s=this.isCircular();null!=i?(n=this.state.numScroll*i*-1,s&&(n-=this.state.numVisible),this.isRemainingItemsAdded=!1):(n+=this.state.numScroll*t,this.isRemainingItemsAdded&&(n+=this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!1),i=Math.abs(Math.floor((s?n+this.state.numVisible:n)/this.state.numScroll)));s&&this.state.page===this.totalIndicators-1&&-1===t?(n=-1*(this.props.value.length+this.state.numVisible),i=0):s&&0===this.state.page&&1===t?(n=0,i=this.totalIndicators-1):i===this.totalIndicators-1&&this.remainingItems>0&&(n+=-1*this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!0),this.itemsContainer&&(e.DomHandler.removeClass(this.itemsContainer,"p-items-hidden"),this.changePosition(n),this.itemsContainer.style.transition="transform 500ms ease 0s"),this.props.onPageChange?(this.setState({totalShiftedItems:n}),this.props.onPageChange({page:i})):this.setState({page:i,totalShiftedItems:n})}},{key:"calculatePosition",value:function(){if(this.itemsContainer&&this.responsiveOptions){for(var t=window.innerWidth,e={numVisible:this.props.numVisible,numScroll:this.props.numScroll},i=0;i<this.responsiveOptions.length;i++){var n=this.responsiveOptions[i];parseInt(n.breakpoint,10)>=t&&(e=n)}var s={};if(this.state.numScroll!==e.numScroll){var a=this.getPage();a=Math.floor(a*this.state.numScroll/e.numScroll);var r=e.numScroll*a*-1;this.isCircular()&&(r-=e.numVisible),s={totalShiftedItems:r,numScroll:e.numScroll},this.props.onPageChange?this.props.onPageChange({page:a}):s=w(w({},s),{},{page:a})}this.state.numVisible!==e.numVisible&&(s=w(w({},s),{},{numVisible:e.numVisible})),Object.keys(s).length&&this.setState(s)}}},{key:"navBackward",value:function(t,e){(this.circular||0!==this.getPage())&&this.step(1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"navForward",value:function(t,e){(this.circular||this.getPage()<this.totalIndicators-1)&&this.step(-1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"onDotClick",value:function(t,e){var i=this.getPage();e>i?this.navForward(t,e):e<i&&this.navBackward(t,e)}},{key:"onTransitionEnd",value:function(t){this.itemsContainer&&"transform"===t.propertyName&&(e.DomHandler.addClass(this.itemsContainer,"p-items-hidden"),this.itemsContainer.style.transition="",0!==this.state.page&&this.state.page!==this.totalIndicators-1||!this.isCircular()||this.changePosition(this.state.totalShiftedItems))}},{key:"onTouchStart",value:function(t){var e=t.changedTouches[0];this.startPos={x:e.pageX,y:e.pageY}}},{key:"onTouchMove",value:function(t){t.cancelable&&t.preventDefault()}},{key:"onTouchEnd",value:function(t){var e=t.changedTouches[0];this.isVertical()?this.changePageOnTouch(t,e.pageY-this.startPos.y):this.changePageOnTouch(t,e.pageX-this.startPos.x)}},{key:"changePageOnTouch",value:function(t,e){Math.abs(e)>this.swipeThreshold&&(e<0?this.navForward(t):this.navBackward(t))}},{key:"bindDocumentListeners",value:function(){var t=this;this.documentResizeListener||(this.documentResizeListener=function(){t.calculatePosition()},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"isVertical",value:function(){return"vertical"===this.props.orientation}},{key:"isCircular",value:function(){return this.circular&&this.props.value.length>=this.state.numVisible}},{key:"getPage",value:function(){return this.props.onPageChange?this.props.page:this.state.page}},{key:"getTotalIndicators",value:function(){return this.props.value?Math.ceil((this.props.value.length-this.state.numVisible)/this.state.numScroll)+1:0}},{key:"isAutoplay",value:function(){return this.props.autoplayInterval&&this.allowAutoplay}},{key:"startAutoplay",value:function(){var t=this;this.interval=setInterval((function(){t.step(-1,t.state.page===t.totalIndicators-1?0:t.state.page+1)}),this.props.autoplayInterval)}},{key:"stopAutoplay",value:function(){this.interval&&clearInterval(this.interval)}},{key:"createStyle",value:function(){this.carouselStyle||(this.carouselStyle=e.DomHandler.createInlineStyle(r.default.nonce));var t,i="\n .p-carousel[".concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/this.state.numVisible,"%\n }\n ");if(this.props.responsiveOptions){this.responsiveOptions=l(t=this.props.responsiveOptions)||u(t)||c(t)||p(),this.responsiveOptions.sort((function(t,e){var i=t.breakpoint,n=e.breakpoint;return-1*(null==i&&null!=n?-1:null!=i&&null==n?1:null==i&&null==n?0:"string"==typeof i&&"string"==typeof n?i.localeCompare(n,void 0,{numeric:!0}):i<n?-1:i>n?1:0)}));for(var n=0;n<this.responsiveOptions.length;n++){var s=this.responsiveOptions[n];i+="\n @media screen and (max-width: ".concat(s.breakpoint,") {\n .p-carousel[").concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/s.numVisible,"%\n }\n }\n ")}}this.carouselStyle.innerHTML=i}},{key:"changePosition",value:function(t){this.itemsContainer&&(this.itemsContainer.style.transform=this.isVertical()?"translate3d(0, ".concat(t*(100/this.state.numVisible),"%, 0)"):"translate3d(".concat(t*(100/this.state.numVisible),"%, 0, 0)"))}},{key:"componentDidMount",value:function(){this.container&&this.container.setAttribute(this.attributeSelector,""),this.createStyle(),this.calculatePosition(),this.changePosition(this.state.totalShiftedItems),this.props.responsiveOptions&&this.bindDocumentListeners()}},{key:"componentDidUpdate",value:function(t,e){var i=this.isCircular(),n=!1,s=this.state.totalShiftedItems;if(this.props.autoplayInterval&&this.stopAutoplay(),e.numScroll!==this.state.numScroll||e.numVisible!==this.state.numVisible||this.props.value&&t.value&&t.value.length!==this.props.value.length){this.remainingItems=(this.props.value.length-this.state.numVisible)%this.state.numScroll;var a=this.getPage();0!==this.totalIndicators&&a>=this.totalIndicators&&(a=this.totalIndicators-1,this.props.onPageChange?this.props.onPageChange({page:a}):this.setState({page:a}),n=!0),s=a*this.state.numScroll*-1,i&&(s-=this.state.numVisible),a===this.totalIndicators-1&&this.remainingItems>0?(s+=-1*this.remainingItems+this.state.numScroll,this.isRemainingItemsAdded=!0):this.isRemainingItemsAdded=!1,s!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:s}),n=!0),this.changePosition(s)}i&&(0===this.state.page?s=-1*this.state.numVisible:0===s&&(s=-1*this.props.value.length,this.remainingItems>0&&(this.isRemainingItemsAdded=!0)),s!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:s}),n=!0)),t.page!==this.props.page&&(this.props.page>t.page&&this.props.page<=this.totalIndicators-1?this.step(-1,this.props.page):this.props.page<t.page&&this.step(1,this.props.page)),!n&&this.isAutoplay()&&this.startAutoplay()}},{key:"componentWillUnmount",value:function(){this.props.responsiveOptions&&this.unbindDocumentListeners(),this.props.autoplayInterval&&this.stopAutoplay()}},{key:"renderItems",value:function(){var t=this;if(this.props.value&&this.props.value.length){var e=this.isCircular(),i=null,n=null;if(e){var s=null;i=(s=this.props.value.slice(-1*this.state.numVisible)).map((function(e,i){return a.default.createElement(C,{key:i+"_scloned",className:"p-carousel-item-cloned",template:t.props.itemTemplate,item:e,active:-1*t.state.totalShiftedItems===t.props.value.length+t.state.numVisible,start:0===i,end:i===s.length-1})})),n=(s=this.props.value.slice(0,this.state.numVisible)).map((function(e,i){return a.default.createElement(C,{key:i+"_fcloned",className:"p-carousel-item-cloned",template:t.props.itemTemplate,item:e,active:0===t.state.totalShiftedItems,start:0===i,end:i===s.length-1})}))}var r=this.props.value.map((function(i,n){var s=e?-1*(t.state.totalShiftedItems+t.state.numVisible):-1*t.state.totalShiftedItems,r=s+t.state.numVisible-1;return a.default.createElement(C,{key:n,template:t.props.itemTemplate,item:i,active:s<=n&&r>=n,start:s===n,end:r===n})}));return a.default.createElement(a.default.Fragment,null,i,r,n)}}},{key:"renderHeader",value:function(){return this.props.header?a.default.createElement("div",{className:"p-carousel-header"},this.props.header):null}},{key:"renderFooter",value:function(){return this.props.footer?a.default.createElement("div",{className:"p-carousel-footer"},this.props.footer):null}},{key:"renderContent",value:function(){var t=this,i=this.renderItems(),n=this.isVertical()?this.props.verticalViewPortHeight:"auto",s=this.renderBackwardNavigator(),r=this.renderForwardNavigator(),o=e.classNames("p-carousel-container",this.props.containerClassName);return a.default.createElement("div",{className:o},s,a.default.createElement("div",{className:"p-carousel-items-content",style:{height:n},onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd},a.default.createElement("div",{ref:function(e){return t.itemsContainer=e},className:"p-carousel-items-container",onTransitionEnd:this.onTransitionEnd},i)),r)}},{key:"renderBackwardNavigator",value:function(){var t=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&0===this.getPage(),n=e.classNames("p-carousel-prev p-link",{"p-disabled":t}),s=e.classNames("p-carousel-prev-icon pi",{"pi-chevron-left":!this.isVertical(),"pi-chevron-up":this.isVertical()});return a.default.createElement("button",{type:"button",className:n,onClick:this.navBackward,disabled:t},a.default.createElement("span",{className:s}),a.default.createElement(i.Ripple,null))}},{key:"renderForwardNavigator",value:function(){var t=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&(this.getPage()===this.totalIndicators-1||0===this.totalIndicators),n=e.classNames("p-carousel-next p-link",{"p-disabled":t}),s=e.classNames("p-carousel-next-icon pi",{"pi-chevron-right":!this.isVertical(),"pi-chevron-down":this.isVertical()});return a.default.createElement("button",{type:"button",className:n,onClick:this.navForward,disabled:t},a.default.createElement("span",{className:s}),a.default.createElement(i.Ripple,null))}},{key:"renderIndicator",value:function(t){var n=this,s=this.getPage()===t,r=e.classNames("p-carousel-indicator",{"p-highlight":s});return a.default.createElement("li",{className:r,key:"p-carousel-indicator-"+t},a.default.createElement("button",{type:"button",className:"p-link",onClick:function(e){return n.onDotClick(e,t)}},a.default.createElement(i.Ripple,null)))}},{key:"renderIndicators",value:function(){for(var t=e.classNames("p-carousel-indicators p-reset",this.props.indicatorsContentClassName),i=[],n=0;n<this.totalIndicators;n++)i.push(this.renderIndicator(n));return a.default.createElement("ul",{className:t},i)}},{key:"render",value:function(){var t=this,i=e.classNames("p-carousel p-component",{"p-carousel-vertical":this.isVertical(),"p-carousel-horizontal":!this.isVertical()},this.props.className),n=e.classNames("p-carousel-content",this.props.contentClassName);this.totalIndicators=this.getTotalIndicators();var s=this.renderContent(),r=this.renderIndicators(),o=this.renderHeader(),l=this.renderFooter();return a.default.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:i,style:this.props.style},o,a.default.createElement("div",{className:n},s,r),l)}}]),o}();I(V,"defaultProps",{id:null,value:null,page:0,header:null,footer:null,style:null,className:null,itemTemplate:null,circular:!1,autoplayInterval:0,numVisible:1,numScroll:1,responsiveOptions:null,orientation:"horizontal",verticalViewPortHeight:"300px",contentClassName:null,containerClassName:null,indicatorsContentClassName:null,onPageChange:null}),exports.Carousel=V;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),n=require("primereact/ripple"),i=require("primereact/api");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=r(t),s=r(i);function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function l(t){if(Array.isArray(t))return o(t)}function u(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function c(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function p(){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){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function f(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function d(t,e,n){return e&&f(t.prototype,e),n&&f(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t,e){return v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},v(t,e)}function g(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&&v(t,e)}function y(t){return y="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},y(t)}function b(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function S(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var I=function(){function t(){m(this,t)}return d(t,null,[{key:"equals",value:function(t,e,n){return n&&t&&"object"===y(t)&&e&&"object"===y(e)?this.resolveFieldData(t,n)===this.resolveFieldData(e,n):this.deepEquals(t,e)}},{key:"deepEquals",value:function(t,e){if(t===e)return!0;if(t&&e&&"object"==y(t)&&"object"==y(e)){var n,i,r,a=Array.isArray(t),s=Array.isArray(e);if(a&&s){if((i=t.length)!==e.length)return!1;for(n=i;0!=n--;)if(!this.deepEquals(t[n],e[n]))return!1;return!0}if(a!==s)return!1;var o=t instanceof Date,l=e instanceof Date;if(o!==l)return!1;if(o&&l)return t.getTime()===e.getTime();var u=t instanceof RegExp,c=e instanceof RegExp;if(u!==c)return!1;if(u&&c)return t.toString()===e.toString();var p=Object.keys(t);if((i=p.length)!==Object.keys(e).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,p[n]))return!1;for(n=i;0!=n--;)if(!this.deepEquals(t[r=p[n]],e[r]))return!1;return!0}return t!=t&&e!=e}},{key:"resolveFieldData",value:function(t,e){if(t&&Object.keys(t).length&&e){if(this.isFunction(e))return e(t);if(-1===e.indexOf("."))return t[e];for(var n=e.split("."),i=t,r=0,a=n.length;r<a;++r){if(null==i)return null;i=i[n[r]]}return i}return null}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{key:"findDiffKeys",value:function(t,e){return t&&e?Object.keys(t).filter((function(t){return!e.hasOwnProperty(t)})).reduce((function(e,n){return e[n]=t[n],e}),{}):{}}},{key:"reorderArray",value:function(t,e,n){var i;if(t&&e!==n){if(n>=t.length)for(i=n-t.length;1+i--;)t.push(void 0);t.splice(n,0,t.splice(e,1)[0])}}},{key:"findIndexInList",value:function(t,e,n){var i=this;return e?e.findIndex(n?function(e){return i.equals(e,t,n)}:function(e){return e===t}):-1}},{key:"getJSXElement",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.isFunction(t)?t.apply(void 0,n):t}},{key:"getPropValue",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.isFunction(t)?t.apply(void 0,n):t}},{key:"getRefElement",value:function(t){return t?"object"===y(t)&&t.hasOwnProperty("current")?t.current:t:null}},{key:"removeAccents",value:function(t){return t&&t.search(/[\xC0-\xFF]/g)>-1&&(t=t.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),t}},{key:"isEmpty",value:function(t){return null==t||""===t||Array.isArray(t)&&0===t.length||!(t instanceof Date)&&"object"===y(t)&&0===Object.keys(t).length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"sort",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0;return n*(null==t&&null!=e?-1:null!=t&&null==e?1:null==t&&null==e?0:"string"==typeof t&&"string"==typeof e?t.localeCompare(e,i,{numeric:!0}):t<e?-1:t>e?1:0)}}]),t}();function E(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function C(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?E(Object(n),!0).forEach((function(e){S(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(t){var e=w();return function(){var n,i=k(t);if(e){var r=k(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return b(this,n)}}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 P=function(n){g(r,t.Component);var i=O(r);function r(){return m(this,r),i.apply(this,arguments)}return d(r,[{key:"render",value:function(){var t=this.props.template(this.props.item),n=e.classNames(this.props.className,"p-carousel-item",{"p-carousel-item-active":this.props.active,"p-carousel-item-start":this.props.start,"p-carousel-item-end":this.props.end});return a.default.createElement("div",{className:n},t)}}]),r}();S(P,"defaultProps",{template:null,item:null,active:!1,start:!1,end:!1,className:null});var x=function(i){g(o,t.Component);var r=O(o);function o(t){var n;return m(this,o),(n=r.call(this,t)).state={numVisible:t.numVisible,numScroll:t.numScroll,totalShiftedItems:t.page*t.numScroll*-1},n.props.onPageChange||(n.state=C(C({},n.state),{},{page:t.page})),n.navBackward=n.navBackward.bind(h(n)),n.navForward=n.navForward.bind(h(n)),n.onTransitionEnd=n.onTransitionEnd.bind(h(n)),n.onTouchStart=n.onTouchStart.bind(h(n)),n.onTouchMove=n.onTouchMove.bind(h(n)),n.onTouchEnd=n.onTouchEnd.bind(h(n)),n.totalIndicators=0,n.remainingItems=0,n.allowAutoplay=!!n.props.autoplayInterval,n.circular=n.props.circular||n.allowAutoplay,n.attributeSelector=e.UniqueComponentId(),n.swipeThreshold=20,n}return d(o,[{key:"step",value:function(t,n){var i=this.state.totalShiftedItems,r=this.isCircular();null!=n?(i=this.state.numScroll*n*-1,r&&(i-=this.state.numVisible),this.isRemainingItemsAdded=!1):(i+=this.state.numScroll*t,this.isRemainingItemsAdded&&(i+=this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!1),n=Math.abs(Math.floor((r?i+this.state.numVisible:i)/this.state.numScroll)));r&&this.state.page===this.totalIndicators-1&&-1===t?(i=-1*(this.props.value.length+this.state.numVisible),n=0):r&&0===this.state.page&&1===t?(i=0,n=this.totalIndicators-1):n===this.totalIndicators-1&&this.remainingItems>0&&(i+=-1*this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!0),this.itemsContainer&&(e.DomHandler.removeClass(this.itemsContainer,"p-items-hidden"),this.changePosition(i),this.itemsContainer.style.transition="transform 500ms ease 0s"),this.props.onPageChange?(this.setState({totalShiftedItems:i}),this.props.onPageChange({page:n})):this.setState({page:n,totalShiftedItems:i})}},{key:"calculatePosition",value:function(){if(this.itemsContainer&&this.responsiveOptions){for(var t=window.innerWidth,e={numVisible:this.props.numVisible,numScroll:this.props.numScroll},n=0;n<this.responsiveOptions.length;n++){var i=this.responsiveOptions[n];parseInt(i.breakpoint,10)>=t&&(e=i)}var r={};if(this.state.numScroll!==e.numScroll){var a=this.getPage();a=Math.floor(a*this.state.numScroll/e.numScroll);var s=e.numScroll*a*-1;this.isCircular()&&(s-=e.numVisible),r={totalShiftedItems:s,numScroll:e.numScroll},this.props.onPageChange?this.props.onPageChange({page:a}):r=C(C({},r),{},{page:a})}this.state.numVisible!==e.numVisible&&(r=C(C({},r),{},{numVisible:e.numVisible})),Object.keys(r).length&&this.setState(r)}}},{key:"navBackward",value:function(t,e){(this.circular||0!==this.getPage())&&this.step(1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"navForward",value:function(t,e){(this.circular||this.getPage()<this.totalIndicators-1)&&this.step(-1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"onDotClick",value:function(t,e){var n=this.getPage();e>n?this.navForward(t,e):e<n&&this.navBackward(t,e)}},{key:"onTransitionEnd",value:function(t){this.itemsContainer&&"transform"===t.propertyName&&(e.DomHandler.addClass(this.itemsContainer,"p-items-hidden"),this.itemsContainer.style.transition="",0!==this.state.page&&this.state.page!==this.totalIndicators-1||!this.isCircular()||this.changePosition(this.state.totalShiftedItems))}},{key:"onTouchStart",value:function(t){var e=t.changedTouches[0];this.startPos={x:e.pageX,y:e.pageY}}},{key:"onTouchMove",value:function(t){t.cancelable&&t.preventDefault()}},{key:"onTouchEnd",value:function(t){var e=t.changedTouches[0];this.isVertical()?this.changePageOnTouch(t,e.pageY-this.startPos.y):this.changePageOnTouch(t,e.pageX-this.startPos.x)}},{key:"changePageOnTouch",value:function(t,e){Math.abs(e)>this.swipeThreshold&&(e<0?this.navForward(t):this.navBackward(t))}},{key:"bindDocumentListeners",value:function(){var t=this;this.documentResizeListener||(this.documentResizeListener=function(){t.calculatePosition()},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"isVertical",value:function(){return"vertical"===this.props.orientation}},{key:"isCircular",value:function(){return this.circular&&this.props.value.length>=this.state.numVisible}},{key:"getPage",value:function(){return this.props.onPageChange?this.props.page:this.state.page}},{key:"getTotalIndicators",value:function(){return this.props.value?Math.ceil((this.props.value.length-this.state.numVisible)/this.state.numScroll)+1:0}},{key:"isAutoplay",value:function(){return this.props.autoplayInterval&&this.allowAutoplay}},{key:"startAutoplay",value:function(){var t=this;this.interval=setInterval((function(){t.step(-1,t.state.page===t.totalIndicators-1?0:t.state.page+1)}),this.props.autoplayInterval)}},{key:"stopAutoplay",value:function(){this.interval&&clearInterval(this.interval)}},{key:"createStyle",value:function(){this.carouselStyle||(this.carouselStyle=e.DomHandler.createInlineStyle(s.default.nonce));var t,n="\n .p-carousel[".concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/this.state.numVisible,"%\n }\n ");if(this.props.responsiveOptions){this.responsiveOptions=l(t=this.props.responsiveOptions)||u(t)||c(t)||p(),this.responsiveOptions.sort((function(t,e){return I.sort(t.breakpoint,e.breakpoint,-1,s.default.locale)}));for(var i=0;i<this.responsiveOptions.length;i++){var r=this.responsiveOptions[i];n+="\n @media screen and (max-width: ".concat(r.breakpoint,") {\n .p-carousel[").concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/r.numVisible,"%\n }\n }\n ")}}this.carouselStyle.innerHTML=n}},{key:"changePosition",value:function(t){this.itemsContainer&&(this.itemsContainer.style.transform=this.isVertical()?"translate3d(0, ".concat(t*(100/this.state.numVisible),"%, 0)"):"translate3d(".concat(t*(100/this.state.numVisible),"%, 0, 0)"))}},{key:"componentDidMount",value:function(){this.container&&this.container.setAttribute(this.attributeSelector,""),this.createStyle(),this.calculatePosition(),this.changePosition(this.state.totalShiftedItems),this.props.responsiveOptions&&this.bindDocumentListeners()}},{key:"componentDidUpdate",value:function(t,e){var n=this.isCircular(),i=!1,r=this.state.totalShiftedItems;if(this.props.autoplayInterval&&this.stopAutoplay(),e.numScroll!==this.state.numScroll||e.numVisible!==this.state.numVisible||this.props.value&&t.value&&t.value.length!==this.props.value.length){this.remainingItems=(this.props.value.length-this.state.numVisible)%this.state.numScroll;var a=this.getPage();0!==this.totalIndicators&&a>=this.totalIndicators&&(a=this.totalIndicators-1,this.props.onPageChange?this.props.onPageChange({page:a}):this.setState({page:a}),i=!0),r=a*this.state.numScroll*-1,n&&(r-=this.state.numVisible),a===this.totalIndicators-1&&this.remainingItems>0?(r+=-1*this.remainingItems+this.state.numScroll,this.isRemainingItemsAdded=!0):this.isRemainingItemsAdded=!1,r!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:r}),i=!0),this.changePosition(r)}n&&(0===this.state.page?r=-1*this.state.numVisible:0===r&&(r=-1*this.props.value.length,this.remainingItems>0&&(this.isRemainingItemsAdded=!0)),r!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:r}),i=!0)),t.page!==this.props.page&&(this.props.page>t.page&&this.props.page<=this.totalIndicators-1?this.step(-1,this.props.page):this.props.page<t.page&&this.step(1,this.props.page)),!i&&this.isAutoplay()&&this.startAutoplay()}},{key:"componentWillUnmount",value:function(){this.props.responsiveOptions&&this.unbindDocumentListeners(),this.props.autoplayInterval&&this.stopAutoplay()}},{key:"renderItems",value:function(){var t=this;if(this.props.value&&this.props.value.length){var e=this.isCircular(),n=null,i=null;if(e){var r=null;n=(r=this.props.value.slice(-1*this.state.numVisible)).map((function(e,n){return a.default.createElement(P,{key:n+"_scloned",className:"p-carousel-item-cloned",template:t.props.itemTemplate,item:e,active:-1*t.state.totalShiftedItems===t.props.value.length+t.state.numVisible,start:0===n,end:n===r.length-1})})),i=(r=this.props.value.slice(0,this.state.numVisible)).map((function(e,n){return a.default.createElement(P,{key:n+"_fcloned",className:"p-carousel-item-cloned",template:t.props.itemTemplate,item:e,active:0===t.state.totalShiftedItems,start:0===n,end:n===r.length-1})}))}var s=this.props.value.map((function(n,i){var r=e?-1*(t.state.totalShiftedItems+t.state.numVisible):-1*t.state.totalShiftedItems,s=r+t.state.numVisible-1;return a.default.createElement(P,{key:i,template:t.props.itemTemplate,item:n,active:r<=i&&s>=i,start:r===i,end:s===i})}));return a.default.createElement(a.default.Fragment,null,n,s,i)}}},{key:"renderHeader",value:function(){return this.props.header?a.default.createElement("div",{className:"p-carousel-header"},this.props.header):null}},{key:"renderFooter",value:function(){return this.props.footer?a.default.createElement("div",{className:"p-carousel-footer"},this.props.footer):null}},{key:"renderContent",value:function(){var t=this,n=this.renderItems(),i=this.isVertical()?this.props.verticalViewPortHeight:"auto",r=this.renderBackwardNavigator(),s=this.renderForwardNavigator(),o=e.classNames("p-carousel-container",this.props.containerClassName);return a.default.createElement("div",{className:o},r,a.default.createElement("div",{className:"p-carousel-items-content",style:{height:i},onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd},a.default.createElement("div",{ref:function(e){return t.itemsContainer=e},className:"p-carousel-items-container",onTransitionEnd:this.onTransitionEnd},n)),s)}},{key:"renderBackwardNavigator",value:function(){var t=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&0===this.getPage(),i=e.classNames("p-carousel-prev p-link",{"p-disabled":t}),r=e.classNames("p-carousel-prev-icon pi",{"pi-chevron-left":!this.isVertical(),"pi-chevron-up":this.isVertical()});return a.default.createElement("button",{type:"button",className:i,onClick:this.navBackward,disabled:t},a.default.createElement("span",{className:r}),a.default.createElement(n.Ripple,null))}},{key:"renderForwardNavigator",value:function(){var t=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&(this.getPage()===this.totalIndicators-1||0===this.totalIndicators),i=e.classNames("p-carousel-next p-link",{"p-disabled":t}),r=e.classNames("p-carousel-next-icon pi",{"pi-chevron-right":!this.isVertical(),"pi-chevron-down":this.isVertical()});return a.default.createElement("button",{type:"button",className:i,onClick:this.navForward,disabled:t},a.default.createElement("span",{className:r}),a.default.createElement(n.Ripple,null))}},{key:"renderIndicator",value:function(t){var i=this,r=this.getPage()===t,s=e.classNames("p-carousel-indicator",{"p-highlight":r});return a.default.createElement("li",{className:s,key:"p-carousel-indicator-"+t},a.default.createElement("button",{type:"button",className:"p-link",onClick:function(e){return i.onDotClick(e,t)}},a.default.createElement(n.Ripple,null)))}},{key:"renderIndicators",value:function(){for(var t=e.classNames("p-carousel-indicators p-reset",this.props.indicatorsContentClassName),n=[],i=0;i<this.totalIndicators;i++)n.push(this.renderIndicator(i));return a.default.createElement("ul",{className:t},n)}},{key:"render",value:function(){var t=this,n=e.classNames("p-carousel p-component",{"p-carousel-vertical":this.isVertical(),"p-carousel-horizontal":!this.isVertical()},this.props.className),i=e.classNames("p-carousel-content",this.props.contentClassName);this.totalIndicators=this.getTotalIndicators();var r=this.renderContent(),s=this.renderIndicators(),o=this.renderHeader(),l=this.renderFooter();return a.default.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:n,style:this.props.style},o,a.default.createElement("div",{className:i},r,s),l)}}]),o}();S(x,"defaultProps",{id:null,value:null,page:0,header:null,footer:null,style:null,className:null,itemTemplate:null,circular:!1,autoplayInterval:0,numVisible:1,numScroll:1,responsiveOptions:null,orientation:"horizontal",verticalViewPortHeight:"300px",contentClassName:null,containerClassName:null,indicatorsContentClassName:null,onPageChange:null}),exports.Carousel=x;
|
package/carousel/carousel.esm.js
CHANGED
|
@@ -140,6 +140,217 @@ function _defineProperty(obj, key, value) {
|
|
|
140
140
|
return obj;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
var ObjectUtils = /*#__PURE__*/function () {
|
|
144
|
+
function ObjectUtils() {
|
|
145
|
+
_classCallCheck(this, ObjectUtils);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_createClass(ObjectUtils, null, [{
|
|
149
|
+
key: "equals",
|
|
150
|
+
value: function equals(obj1, obj2, field) {
|
|
151
|
+
if (field && obj1 && _typeof(obj1) === 'object' && obj2 && _typeof(obj2) === 'object') return this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field);else return this.deepEquals(obj1, obj2);
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "deepEquals",
|
|
155
|
+
value: function deepEquals(a, b) {
|
|
156
|
+
if (a === b) return true;
|
|
157
|
+
|
|
158
|
+
if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {
|
|
159
|
+
var arrA = Array.isArray(a),
|
|
160
|
+
arrB = Array.isArray(b),
|
|
161
|
+
i,
|
|
162
|
+
length,
|
|
163
|
+
key;
|
|
164
|
+
|
|
165
|
+
if (arrA && arrB) {
|
|
166
|
+
length = a.length;
|
|
167
|
+
if (length !== b.length) return false;
|
|
168
|
+
|
|
169
|
+
for (i = length; i-- !== 0;) {
|
|
170
|
+
if (!this.deepEquals(a[i], b[i])) return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (arrA !== arrB) return false;
|
|
177
|
+
var dateA = a instanceof Date,
|
|
178
|
+
dateB = b instanceof Date;
|
|
179
|
+
if (dateA !== dateB) return false;
|
|
180
|
+
if (dateA && dateB) return a.getTime() === b.getTime();
|
|
181
|
+
var regexpA = a instanceof RegExp,
|
|
182
|
+
regexpB = b instanceof RegExp;
|
|
183
|
+
if (regexpA !== regexpB) return false;
|
|
184
|
+
if (regexpA && regexpB) return a.toString() === b.toString();
|
|
185
|
+
var keys = Object.keys(a);
|
|
186
|
+
length = keys.length;
|
|
187
|
+
if (length !== Object.keys(b).length) return false;
|
|
188
|
+
|
|
189
|
+
for (i = length; i-- !== 0;) {
|
|
190
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
for (i = length; i-- !== 0;) {
|
|
194
|
+
key = keys[i];
|
|
195
|
+
if (!this.deepEquals(a[key], b[key])) return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
/*eslint no-self-compare: "off"*/
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
return a !== a && b !== b;
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "resolveFieldData",
|
|
207
|
+
value: function resolveFieldData(data, field) {
|
|
208
|
+
if (data && Object.keys(data).length && field) {
|
|
209
|
+
if (this.isFunction(field)) {
|
|
210
|
+
return field(data);
|
|
211
|
+
} else if (field.indexOf('.') === -1) {
|
|
212
|
+
return data[field];
|
|
213
|
+
} else {
|
|
214
|
+
var fields = field.split('.');
|
|
215
|
+
var value = data;
|
|
216
|
+
|
|
217
|
+
for (var i = 0, len = fields.length; i < len; ++i) {
|
|
218
|
+
if (value == null) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
value = value[fields[i]];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "isFunction",
|
|
233
|
+
value: function isFunction(obj) {
|
|
234
|
+
return !!(obj && obj.constructor && obj.call && obj.apply);
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
key: "findDiffKeys",
|
|
238
|
+
value: function findDiffKeys(obj1, obj2) {
|
|
239
|
+
if (!obj1 || !obj2) {
|
|
240
|
+
return {};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return Object.keys(obj1).filter(function (key) {
|
|
244
|
+
return !obj2.hasOwnProperty(key);
|
|
245
|
+
}).reduce(function (result, current) {
|
|
246
|
+
result[current] = obj1[current];
|
|
247
|
+
return result;
|
|
248
|
+
}, {});
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "reorderArray",
|
|
252
|
+
value: function reorderArray(value, from, to) {
|
|
253
|
+
var target;
|
|
254
|
+
|
|
255
|
+
if (value && from !== to) {
|
|
256
|
+
if (to >= value.length) {
|
|
257
|
+
target = to - value.length;
|
|
258
|
+
|
|
259
|
+
while (target-- + 1) {
|
|
260
|
+
value.push(undefined);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
value.splice(to, 0, value.splice(from, 1)[0]);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "findIndexInList",
|
|
269
|
+
value: function findIndexInList(value, list, dataKey) {
|
|
270
|
+
var _this = this;
|
|
271
|
+
|
|
272
|
+
if (list) {
|
|
273
|
+
return dataKey ? list.findIndex(function (item) {
|
|
274
|
+
return _this.equals(item, value, dataKey);
|
|
275
|
+
}) : list.findIndex(function (item) {
|
|
276
|
+
return item === value;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return -1;
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "getJSXElement",
|
|
284
|
+
value: function getJSXElement(obj) {
|
|
285
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
286
|
+
params[_key - 1] = arguments[_key];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return this.isFunction(obj) ? obj.apply(void 0, params) : obj;
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
key: "getPropValue",
|
|
293
|
+
value: function getPropValue(obj) {
|
|
294
|
+
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
295
|
+
params[_key2 - 1] = arguments[_key2];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return this.isFunction(obj) ? obj.apply(void 0, params) : obj;
|
|
299
|
+
}
|
|
300
|
+
}, {
|
|
301
|
+
key: "getRefElement",
|
|
302
|
+
value: function getRefElement(ref) {
|
|
303
|
+
if (ref) {
|
|
304
|
+
return _typeof(ref) === 'object' && ref.hasOwnProperty('current') ? ref.current : ref;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
key: "removeAccents",
|
|
311
|
+
value: function removeAccents(str) {
|
|
312
|
+
if (str && str.search(/[\xC0-\xFF]/g) > -1) {
|
|
313
|
+
str = str.replace(/[\xC0-\xC5]/g, "A").replace(/[\xC6]/g, "AE").replace(/[\xC7]/g, "C").replace(/[\xC8-\xCB]/g, "E").replace(/[\xCC-\xCF]/g, "I").replace(/[\xD0]/g, "D").replace(/[\xD1]/g, "N").replace(/[\xD2-\xD6\xD8]/g, "O").replace(/[\xD9-\xDC]/g, "U").replace(/[\xDD]/g, "Y").replace(/[\xDE]/g, "P").replace(/[\xE0-\xE5]/g, "a").replace(/[\xE6]/g, "ae").replace(/[\xE7]/g, "c").replace(/[\xE8-\xEB]/g, "e").replace(/[\xEC-\xEF]/g, "i").replace(/[\xF1]/g, "n").replace(/[\xF2-\xF6\xF8]/g, "o").replace(/[\xF9-\xFC]/g, "u").replace(/[\xFE]/g, "p").replace(/[\xFD\xFF]/g, "y");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return str;
|
|
317
|
+
}
|
|
318
|
+
}, {
|
|
319
|
+
key: "isEmpty",
|
|
320
|
+
value: function isEmpty(value) {
|
|
321
|
+
return value === null || value === undefined || value === '' || Array.isArray(value) && value.length === 0 || !(value instanceof Date) && _typeof(value) === 'object' && Object.keys(value).length === 0;
|
|
322
|
+
}
|
|
323
|
+
}, {
|
|
324
|
+
key: "isNotEmpty",
|
|
325
|
+
value: function isNotEmpty(value) {
|
|
326
|
+
return !this.isEmpty(value);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Compare value1 and value2 ascending by default (1) or pass in order as -1 for descending.
|
|
330
|
+
*
|
|
331
|
+
* @param {any} value1 the first value
|
|
332
|
+
* @param {any} value2 the second value
|
|
333
|
+
* @param {number | undefined} order by default ascending (1) set to descending (-1)
|
|
334
|
+
* @param {string | undefined} locale the locale to use (default to browser locale if null)
|
|
335
|
+
* @returns either 0, 1 or -1 for comparing the two values
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
}, {
|
|
339
|
+
key: "sort",
|
|
340
|
+
value: function sort(value1, value2) {
|
|
341
|
+
var order = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
342
|
+
var locale = arguments.length > 3 ? arguments[3] : undefined;
|
|
343
|
+
var result = null;
|
|
344
|
+
if (value1 == null && value2 != null) result = -1;else if (value1 != null && value2 == null) result = 1;else if (value1 == null && value2 == null) result = 0;else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, locale, {
|
|
345
|
+
numeric: true
|
|
346
|
+
});else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
347
|
+
return order * result;
|
|
348
|
+
}
|
|
349
|
+
}]);
|
|
350
|
+
|
|
351
|
+
return ObjectUtils;
|
|
352
|
+
}();
|
|
353
|
+
|
|
143
354
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
144
355
|
|
|
145
356
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -506,11 +717,7 @@ var Carousel = /*#__PURE__*/function (_Component2) {
|
|
|
506
717
|
this.responsiveOptions.sort(function (data1, data2) {
|
|
507
718
|
var value1 = data1.breakpoint;
|
|
508
719
|
var value2 = data2.breakpoint;
|
|
509
|
-
|
|
510
|
-
if (value1 == null && value2 != null) result = -1;else if (value1 != null && value2 == null) result = 1;else if (value1 == null && value2 == null) result = 0;else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, {
|
|
511
|
-
numeric: true
|
|
512
|
-
});else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
513
|
-
return -1 * result;
|
|
720
|
+
return ObjectUtils.sort(value1, value2, -1, PrimeReact.locale);
|
|
514
721
|
});
|
|
515
722
|
|
|
516
723
|
for (var i = 0; i < this.responsiveOptions.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t,{Component as e}from"react";import{classNames as i,UniqueComponentId as n,DomHandler as s}from"primereact/utils";import{Ripple as r}from"primereact/ripple";import a from"primereact/api";function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function l(t){if(Array.isArray(t))return o(t)}function c(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 o(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?o(t,e):void 0}}function p(){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){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,i){return e&&d(t.prototype,e),i&&d(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t,e){return v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},v(t,e)}function g(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&&v(t,e)}function y(t){return y="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},y(t)}function b(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},S(t)}function I(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function k(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function w(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?k(Object(i),!0).forEach((function(e){I(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):k(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function P(t){var e=O();return function(){var i,n=S(t);if(e){var s=S(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return b(this,i)}}function O(){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 C=function(n){g(r,e);var s=P(r);function r(){return m(this,r),s.apply(this,arguments)}return f(r,[{key:"render",value:function(){var e=this.props.template(this.props.item),n=i(this.props.className,"p-carousel-item",{"p-carousel-item-active":this.props.active,"p-carousel-item-start":this.props.start,"p-carousel-item-end":this.props.end});return t.createElement("div",{className:n},e)}}]),r}();I(C,"defaultProps",{template:null,item:null,active:!1,start:!1,end:!1,className:null});var V=function(o){g(v,e);var d=P(v);function v(t){var e;return m(this,v),(e=d.call(this,t)).state={numVisible:t.numVisible,numScroll:t.numScroll,totalShiftedItems:t.page*t.numScroll*-1},e.props.onPageChange||(e.state=w(w({},e.state),{},{page:t.page})),e.navBackward=e.navBackward.bind(h(e)),e.navForward=e.navForward.bind(h(e)),e.onTransitionEnd=e.onTransitionEnd.bind(h(e)),e.onTouchStart=e.onTouchStart.bind(h(e)),e.onTouchMove=e.onTouchMove.bind(h(e)),e.onTouchEnd=e.onTouchEnd.bind(h(e)),e.totalIndicators=0,e.remainingItems=0,e.allowAutoplay=!!e.props.autoplayInterval,e.circular=e.props.circular||e.allowAutoplay,e.attributeSelector=n(),e.swipeThreshold=20,e}return f(v,[{key:"step",value:function(t,e){var i=this.state.totalShiftedItems,n=this.isCircular();null!=e?(i=this.state.numScroll*e*-1,n&&(i-=this.state.numVisible),this.isRemainingItemsAdded=!1):(i+=this.state.numScroll*t,this.isRemainingItemsAdded&&(i+=this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!1),e=Math.abs(Math.floor((n?i+this.state.numVisible:i)/this.state.numScroll)));n&&this.state.page===this.totalIndicators-1&&-1===t?(i=-1*(this.props.value.length+this.state.numVisible),e=0):n&&0===this.state.page&&1===t?(i=0,e=this.totalIndicators-1):e===this.totalIndicators-1&&this.remainingItems>0&&(i+=-1*this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!0),this.itemsContainer&&(s.removeClass(this.itemsContainer,"p-items-hidden"),this.changePosition(i),this.itemsContainer.style.transition="transform 500ms ease 0s"),this.props.onPageChange?(this.setState({totalShiftedItems:i}),this.props.onPageChange({page:e})):this.setState({page:e,totalShiftedItems:i})}},{key:"calculatePosition",value:function(){if(this.itemsContainer&&this.responsiveOptions){for(var t=window.innerWidth,e={numVisible:this.props.numVisible,numScroll:this.props.numScroll},i=0;i<this.responsiveOptions.length;i++){var n=this.responsiveOptions[i];parseInt(n.breakpoint,10)>=t&&(e=n)}var s={};if(this.state.numScroll!==e.numScroll){var r=this.getPage();r=Math.floor(r*this.state.numScroll/e.numScroll);var a=e.numScroll*r*-1;this.isCircular()&&(a-=e.numVisible),s={totalShiftedItems:a,numScroll:e.numScroll},this.props.onPageChange?this.props.onPageChange({page:r}):s=w(w({},s),{},{page:r})}this.state.numVisible!==e.numVisible&&(s=w(w({},s),{},{numVisible:e.numVisible})),Object.keys(s).length&&this.setState(s)}}},{key:"navBackward",value:function(t,e){(this.circular||0!==this.getPage())&&this.step(1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"navForward",value:function(t,e){(this.circular||this.getPage()<this.totalIndicators-1)&&this.step(-1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"onDotClick",value:function(t,e){var i=this.getPage();e>i?this.navForward(t,e):e<i&&this.navBackward(t,e)}},{key:"onTransitionEnd",value:function(t){this.itemsContainer&&"transform"===t.propertyName&&(s.addClass(this.itemsContainer,"p-items-hidden"),this.itemsContainer.style.transition="",0!==this.state.page&&this.state.page!==this.totalIndicators-1||!this.isCircular()||this.changePosition(this.state.totalShiftedItems))}},{key:"onTouchStart",value:function(t){var e=t.changedTouches[0];this.startPos={x:e.pageX,y:e.pageY}}},{key:"onTouchMove",value:function(t){t.cancelable&&t.preventDefault()}},{key:"onTouchEnd",value:function(t){var e=t.changedTouches[0];this.isVertical()?this.changePageOnTouch(t,e.pageY-this.startPos.y):this.changePageOnTouch(t,e.pageX-this.startPos.x)}},{key:"changePageOnTouch",value:function(t,e){Math.abs(e)>this.swipeThreshold&&(e<0?this.navForward(t):this.navBackward(t))}},{key:"bindDocumentListeners",value:function(){var t=this;this.documentResizeListener||(this.documentResizeListener=function(){t.calculatePosition()},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"isVertical",value:function(){return"vertical"===this.props.orientation}},{key:"isCircular",value:function(){return this.circular&&this.props.value.length>=this.state.numVisible}},{key:"getPage",value:function(){return this.props.onPageChange?this.props.page:this.state.page}},{key:"getTotalIndicators",value:function(){return this.props.value?Math.ceil((this.props.value.length-this.state.numVisible)/this.state.numScroll)+1:0}},{key:"isAutoplay",value:function(){return this.props.autoplayInterval&&this.allowAutoplay}},{key:"startAutoplay",value:function(){var t=this;this.interval=setInterval((function(){t.step(-1,t.state.page===t.totalIndicators-1?0:t.state.page+1)}),this.props.autoplayInterval)}},{key:"stopAutoplay",value:function(){this.interval&&clearInterval(this.interval)}},{key:"createStyle",value:function(){this.carouselStyle||(this.carouselStyle=s.createInlineStyle(a.nonce));var t,e="\n .p-carousel[".concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/this.state.numVisible,"%\n }\n ");if(this.props.responsiveOptions){this.responsiveOptions=l(t=this.props.responsiveOptions)||c(t)||u(t)||p(),this.responsiveOptions.sort((function(t,e){var i=t.breakpoint,n=e.breakpoint;return-1*(null==i&&null!=n?-1:null!=i&&null==n?1:null==i&&null==n?0:"string"==typeof i&&"string"==typeof n?i.localeCompare(n,void 0,{numeric:!0}):i<n?-1:i>n?1:0)}));for(var i=0;i<this.responsiveOptions.length;i++){var n=this.responsiveOptions[i];e+="\n @media screen and (max-width: ".concat(n.breakpoint,") {\n .p-carousel[").concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/n.numVisible,"%\n }\n }\n ")}}this.carouselStyle.innerHTML=e}},{key:"changePosition",value:function(t){this.itemsContainer&&(this.itemsContainer.style.transform=this.isVertical()?"translate3d(0, ".concat(t*(100/this.state.numVisible),"%, 0)"):"translate3d(".concat(t*(100/this.state.numVisible),"%, 0, 0)"))}},{key:"componentDidMount",value:function(){this.container&&this.container.setAttribute(this.attributeSelector,""),this.createStyle(),this.calculatePosition(),this.changePosition(this.state.totalShiftedItems),this.props.responsiveOptions&&this.bindDocumentListeners()}},{key:"componentDidUpdate",value:function(t,e){var i=this.isCircular(),n=!1,s=this.state.totalShiftedItems;if(this.props.autoplayInterval&&this.stopAutoplay(),e.numScroll!==this.state.numScroll||e.numVisible!==this.state.numVisible||this.props.value&&t.value&&t.value.length!==this.props.value.length){this.remainingItems=(this.props.value.length-this.state.numVisible)%this.state.numScroll;var r=this.getPage();0!==this.totalIndicators&&r>=this.totalIndicators&&(r=this.totalIndicators-1,this.props.onPageChange?this.props.onPageChange({page:r}):this.setState({page:r}),n=!0),s=r*this.state.numScroll*-1,i&&(s-=this.state.numVisible),r===this.totalIndicators-1&&this.remainingItems>0?(s+=-1*this.remainingItems+this.state.numScroll,this.isRemainingItemsAdded=!0):this.isRemainingItemsAdded=!1,s!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:s}),n=!0),this.changePosition(s)}i&&(0===this.state.page?s=-1*this.state.numVisible:0===s&&(s=-1*this.props.value.length,this.remainingItems>0&&(this.isRemainingItemsAdded=!0)),s!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:s}),n=!0)),t.page!==this.props.page&&(this.props.page>t.page&&this.props.page<=this.totalIndicators-1?this.step(-1,this.props.page):this.props.page<t.page&&this.step(1,this.props.page)),!n&&this.isAutoplay()&&this.startAutoplay()}},{key:"componentWillUnmount",value:function(){this.props.responsiveOptions&&this.unbindDocumentListeners(),this.props.autoplayInterval&&this.stopAutoplay()}},{key:"renderItems",value:function(){var e=this;if(this.props.value&&this.props.value.length){var i=this.isCircular(),n=null,s=null;if(i){var r=null;n=(r=this.props.value.slice(-1*this.state.numVisible)).map((function(i,n){return t.createElement(C,{key:n+"_scloned",className:"p-carousel-item-cloned",template:e.props.itemTemplate,item:i,active:-1*e.state.totalShiftedItems===e.props.value.length+e.state.numVisible,start:0===n,end:n===r.length-1})})),s=(r=this.props.value.slice(0,this.state.numVisible)).map((function(i,n){return t.createElement(C,{key:n+"_fcloned",className:"p-carousel-item-cloned",template:e.props.itemTemplate,item:i,active:0===e.state.totalShiftedItems,start:0===n,end:n===r.length-1})}))}var a=this.props.value.map((function(n,s){var r=i?-1*(e.state.totalShiftedItems+e.state.numVisible):-1*e.state.totalShiftedItems,a=r+e.state.numVisible-1;return t.createElement(C,{key:s,template:e.props.itemTemplate,item:n,active:r<=s&&a>=s,start:r===s,end:a===s})}));return t.createElement(t.Fragment,null,n,a,s)}}},{key:"renderHeader",value:function(){return this.props.header?t.createElement("div",{className:"p-carousel-header"},this.props.header):null}},{key:"renderFooter",value:function(){return this.props.footer?t.createElement("div",{className:"p-carousel-footer"},this.props.footer):null}},{key:"renderContent",value:function(){var e=this,n=this.renderItems(),s=this.isVertical()?this.props.verticalViewPortHeight:"auto",r=this.renderBackwardNavigator(),a=this.renderForwardNavigator(),o=i("p-carousel-container",this.props.containerClassName);return t.createElement("div",{className:o},r,t.createElement("div",{className:"p-carousel-items-content",style:{height:s},onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd},t.createElement("div",{ref:function(t){return e.itemsContainer=t},className:"p-carousel-items-container",onTransitionEnd:this.onTransitionEnd},n)),a)}},{key:"renderBackwardNavigator",value:function(){var e=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&0===this.getPage(),n=i("p-carousel-prev p-link",{"p-disabled":e}),s=i("p-carousel-prev-icon pi",{"pi-chevron-left":!this.isVertical(),"pi-chevron-up":this.isVertical()});return t.createElement("button",{type:"button",className:n,onClick:this.navBackward,disabled:e},t.createElement("span",{className:s}),t.createElement(r,null))}},{key:"renderForwardNavigator",value:function(){var e=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&(this.getPage()===this.totalIndicators-1||0===this.totalIndicators),n=i("p-carousel-next p-link",{"p-disabled":e}),s=i("p-carousel-next-icon pi",{"pi-chevron-right":!this.isVertical(),"pi-chevron-down":this.isVertical()});return t.createElement("button",{type:"button",className:n,onClick:this.navForward,disabled:e},t.createElement("span",{className:s}),t.createElement(r,null))}},{key:"renderIndicator",value:function(e){var n=this,s=this.getPage()===e,a=i("p-carousel-indicator",{"p-highlight":s});return t.createElement("li",{className:a,key:"p-carousel-indicator-"+e},t.createElement("button",{type:"button",className:"p-link",onClick:function(t){return n.onDotClick(t,e)}},t.createElement(r,null)))}},{key:"renderIndicators",value:function(){for(var e=i("p-carousel-indicators p-reset",this.props.indicatorsContentClassName),n=[],s=0;s<this.totalIndicators;s++)n.push(this.renderIndicator(s));return t.createElement("ul",{className:e},n)}},{key:"render",value:function(){var e=this,n=i("p-carousel p-component",{"p-carousel-vertical":this.isVertical(),"p-carousel-horizontal":!this.isVertical()},this.props.className),s=i("p-carousel-content",this.props.contentClassName);this.totalIndicators=this.getTotalIndicators();var r=this.renderContent(),a=this.renderIndicators(),o=this.renderHeader(),l=this.renderFooter();return t.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:n,style:this.props.style},o,t.createElement("div",{className:s},r,a),l)}}]),v}();I(V,"defaultProps",{id:null,value:null,page:0,header:null,footer:null,style:null,className:null,itemTemplate:null,circular:!1,autoplayInterval:0,numVisible:1,numScroll:1,responsiveOptions:null,orientation:"horizontal",verticalViewPortHeight:"300px",contentClassName:null,containerClassName:null,indicatorsContentClassName:null,onPageChange:null});export{V as Carousel};
|
|
1
|
+
import t,{Component as e}from"react";import{classNames as n,UniqueComponentId as i,DomHandler as r}from"primereact/utils";import{Ripple as s}from"primereact/ripple";import a from"primereact/api";function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function l(t){if(Array.isArray(t))return o(t)}function u(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function c(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function p(){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){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function f(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function d(t,e,n){return e&&f(t.prototype,e),n&&f(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t,e){return v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},v(t,e)}function g(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&&v(t,e)}function y(t){return y="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},y(t)}function b(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function S(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var I=function(){function t(){m(this,t)}return d(t,null,[{key:"equals",value:function(t,e,n){return n&&t&&"object"===y(t)&&e&&"object"===y(e)?this.resolveFieldData(t,n)===this.resolveFieldData(e,n):this.deepEquals(t,e)}},{key:"deepEquals",value:function(t,e){if(t===e)return!0;if(t&&e&&"object"==y(t)&&"object"==y(e)){var n,i,r,s=Array.isArray(t),a=Array.isArray(e);if(s&&a){if((i=t.length)!==e.length)return!1;for(n=i;0!=n--;)if(!this.deepEquals(t[n],e[n]))return!1;return!0}if(s!==a)return!1;var o=t instanceof Date,l=e instanceof Date;if(o!==l)return!1;if(o&&l)return t.getTime()===e.getTime();var u=t instanceof RegExp,c=e instanceof RegExp;if(u!==c)return!1;if(u&&c)return t.toString()===e.toString();var p=Object.keys(t);if((i=p.length)!==Object.keys(e).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,p[n]))return!1;for(n=i;0!=n--;)if(!this.deepEquals(t[r=p[n]],e[r]))return!1;return!0}return t!=t&&e!=e}},{key:"resolveFieldData",value:function(t,e){if(t&&Object.keys(t).length&&e){if(this.isFunction(e))return e(t);if(-1===e.indexOf("."))return t[e];for(var n=e.split("."),i=t,r=0,s=n.length;r<s;++r){if(null==i)return null;i=i[n[r]]}return i}return null}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{key:"findDiffKeys",value:function(t,e){return t&&e?Object.keys(t).filter((function(t){return!e.hasOwnProperty(t)})).reduce((function(e,n){return e[n]=t[n],e}),{}):{}}},{key:"reorderArray",value:function(t,e,n){var i;if(t&&e!==n){if(n>=t.length)for(i=n-t.length;1+i--;)t.push(void 0);t.splice(n,0,t.splice(e,1)[0])}}},{key:"findIndexInList",value:function(t,e,n){var i=this;return e?e.findIndex(n?function(e){return i.equals(e,t,n)}:function(e){return e===t}):-1}},{key:"getJSXElement",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.isFunction(t)?t.apply(void 0,n):t}},{key:"getPropValue",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.isFunction(t)?t.apply(void 0,n):t}},{key:"getRefElement",value:function(t){return t?"object"===y(t)&&t.hasOwnProperty("current")?t.current:t:null}},{key:"removeAccents",value:function(t){return t&&t.search(/[\xC0-\xFF]/g)>-1&&(t=t.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),t}},{key:"isEmpty",value:function(t){return null==t||""===t||Array.isArray(t)&&0===t.length||!(t instanceof Date)&&"object"===y(t)&&0===Object.keys(t).length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"sort",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0;return n*(null==t&&null!=e?-1:null!=t&&null==e?1:null==t&&null==e?0:"string"==typeof t&&"string"==typeof e?t.localeCompare(e,i,{numeric:!0}):t<e?-1:t>e?1:0)}}]),t}();function E(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function w(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?E(Object(n),!0).forEach((function(e){S(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(t){var e=C();return function(){var n,i=k(t);if(e){var r=k(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return b(this,n)}}function C(){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 P=function(i){g(s,e);var r=O(s);function s(){return m(this,s),r.apply(this,arguments)}return d(s,[{key:"render",value:function(){var e=this.props.template(this.props.item),i=n(this.props.className,"p-carousel-item",{"p-carousel-item-active":this.props.active,"p-carousel-item-start":this.props.start,"p-carousel-item-end":this.props.end});return t.createElement("div",{className:i},e)}}]),s}();S(P,"defaultProps",{template:null,item:null,active:!1,start:!1,end:!1,className:null});var x=function(o){g(v,e);var f=O(v);function v(t){var e;return m(this,v),(e=f.call(this,t)).state={numVisible:t.numVisible,numScroll:t.numScroll,totalShiftedItems:t.page*t.numScroll*-1},e.props.onPageChange||(e.state=w(w({},e.state),{},{page:t.page})),e.navBackward=e.navBackward.bind(h(e)),e.navForward=e.navForward.bind(h(e)),e.onTransitionEnd=e.onTransitionEnd.bind(h(e)),e.onTouchStart=e.onTouchStart.bind(h(e)),e.onTouchMove=e.onTouchMove.bind(h(e)),e.onTouchEnd=e.onTouchEnd.bind(h(e)),e.totalIndicators=0,e.remainingItems=0,e.allowAutoplay=!!e.props.autoplayInterval,e.circular=e.props.circular||e.allowAutoplay,e.attributeSelector=i(),e.swipeThreshold=20,e}return d(v,[{key:"step",value:function(t,e){var n=this.state.totalShiftedItems,i=this.isCircular();null!=e?(n=this.state.numScroll*e*-1,i&&(n-=this.state.numVisible),this.isRemainingItemsAdded=!1):(n+=this.state.numScroll*t,this.isRemainingItemsAdded&&(n+=this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!1),e=Math.abs(Math.floor((i?n+this.state.numVisible:n)/this.state.numScroll)));i&&this.state.page===this.totalIndicators-1&&-1===t?(n=-1*(this.props.value.length+this.state.numVisible),e=0):i&&0===this.state.page&&1===t?(n=0,e=this.totalIndicators-1):e===this.totalIndicators-1&&this.remainingItems>0&&(n+=-1*this.remainingItems-this.state.numScroll*t,this.isRemainingItemsAdded=!0),this.itemsContainer&&(r.removeClass(this.itemsContainer,"p-items-hidden"),this.changePosition(n),this.itemsContainer.style.transition="transform 500ms ease 0s"),this.props.onPageChange?(this.setState({totalShiftedItems:n}),this.props.onPageChange({page:e})):this.setState({page:e,totalShiftedItems:n})}},{key:"calculatePosition",value:function(){if(this.itemsContainer&&this.responsiveOptions){for(var t=window.innerWidth,e={numVisible:this.props.numVisible,numScroll:this.props.numScroll},n=0;n<this.responsiveOptions.length;n++){var i=this.responsiveOptions[n];parseInt(i.breakpoint,10)>=t&&(e=i)}var r={};if(this.state.numScroll!==e.numScroll){var s=this.getPage();s=Math.floor(s*this.state.numScroll/e.numScroll);var a=e.numScroll*s*-1;this.isCircular()&&(a-=e.numVisible),r={totalShiftedItems:a,numScroll:e.numScroll},this.props.onPageChange?this.props.onPageChange({page:s}):r=w(w({},r),{},{page:s})}this.state.numVisible!==e.numVisible&&(r=w(w({},r),{},{numVisible:e.numVisible})),Object.keys(r).length&&this.setState(r)}}},{key:"navBackward",value:function(t,e){(this.circular||0!==this.getPage())&&this.step(1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"navForward",value:function(t,e){(this.circular||this.getPage()<this.totalIndicators-1)&&this.step(-1,e),this.allowAutoplay=!1,t.cancelable&&t.preventDefault()}},{key:"onDotClick",value:function(t,e){var n=this.getPage();e>n?this.navForward(t,e):e<n&&this.navBackward(t,e)}},{key:"onTransitionEnd",value:function(t){this.itemsContainer&&"transform"===t.propertyName&&(r.addClass(this.itemsContainer,"p-items-hidden"),this.itemsContainer.style.transition="",0!==this.state.page&&this.state.page!==this.totalIndicators-1||!this.isCircular()||this.changePosition(this.state.totalShiftedItems))}},{key:"onTouchStart",value:function(t){var e=t.changedTouches[0];this.startPos={x:e.pageX,y:e.pageY}}},{key:"onTouchMove",value:function(t){t.cancelable&&t.preventDefault()}},{key:"onTouchEnd",value:function(t){var e=t.changedTouches[0];this.isVertical()?this.changePageOnTouch(t,e.pageY-this.startPos.y):this.changePageOnTouch(t,e.pageX-this.startPos.x)}},{key:"changePageOnTouch",value:function(t,e){Math.abs(e)>this.swipeThreshold&&(e<0?this.navForward(t):this.navBackward(t))}},{key:"bindDocumentListeners",value:function(){var t=this;this.documentResizeListener||(this.documentResizeListener=function(){t.calculatePosition()},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"isVertical",value:function(){return"vertical"===this.props.orientation}},{key:"isCircular",value:function(){return this.circular&&this.props.value.length>=this.state.numVisible}},{key:"getPage",value:function(){return this.props.onPageChange?this.props.page:this.state.page}},{key:"getTotalIndicators",value:function(){return this.props.value?Math.ceil((this.props.value.length-this.state.numVisible)/this.state.numScroll)+1:0}},{key:"isAutoplay",value:function(){return this.props.autoplayInterval&&this.allowAutoplay}},{key:"startAutoplay",value:function(){var t=this;this.interval=setInterval((function(){t.step(-1,t.state.page===t.totalIndicators-1?0:t.state.page+1)}),this.props.autoplayInterval)}},{key:"stopAutoplay",value:function(){this.interval&&clearInterval(this.interval)}},{key:"createStyle",value:function(){this.carouselStyle||(this.carouselStyle=r.createInlineStyle(a.nonce));var t,e="\n .p-carousel[".concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/this.state.numVisible,"%\n }\n ");if(this.props.responsiveOptions){this.responsiveOptions=l(t=this.props.responsiveOptions)||u(t)||c(t)||p(),this.responsiveOptions.sort((function(t,e){return I.sort(t.breakpoint,e.breakpoint,-1,a.locale)}));for(var n=0;n<this.responsiveOptions.length;n++){var i=this.responsiveOptions[n];e+="\n @media screen and (max-width: ".concat(i.breakpoint,") {\n .p-carousel[").concat(this.attributeSelector,"] .p-carousel-item {\n flex: 1 0 ").concat(100/i.numVisible,"%\n }\n }\n ")}}this.carouselStyle.innerHTML=e}},{key:"changePosition",value:function(t){this.itemsContainer&&(this.itemsContainer.style.transform=this.isVertical()?"translate3d(0, ".concat(t*(100/this.state.numVisible),"%, 0)"):"translate3d(".concat(t*(100/this.state.numVisible),"%, 0, 0)"))}},{key:"componentDidMount",value:function(){this.container&&this.container.setAttribute(this.attributeSelector,""),this.createStyle(),this.calculatePosition(),this.changePosition(this.state.totalShiftedItems),this.props.responsiveOptions&&this.bindDocumentListeners()}},{key:"componentDidUpdate",value:function(t,e){var n=this.isCircular(),i=!1,r=this.state.totalShiftedItems;if(this.props.autoplayInterval&&this.stopAutoplay(),e.numScroll!==this.state.numScroll||e.numVisible!==this.state.numVisible||this.props.value&&t.value&&t.value.length!==this.props.value.length){this.remainingItems=(this.props.value.length-this.state.numVisible)%this.state.numScroll;var s=this.getPage();0!==this.totalIndicators&&s>=this.totalIndicators&&(s=this.totalIndicators-1,this.props.onPageChange?this.props.onPageChange({page:s}):this.setState({page:s}),i=!0),r=s*this.state.numScroll*-1,n&&(r-=this.state.numVisible),s===this.totalIndicators-1&&this.remainingItems>0?(r+=-1*this.remainingItems+this.state.numScroll,this.isRemainingItemsAdded=!0):this.isRemainingItemsAdded=!1,r!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:r}),i=!0),this.changePosition(r)}n&&(0===this.state.page?r=-1*this.state.numVisible:0===r&&(r=-1*this.props.value.length,this.remainingItems>0&&(this.isRemainingItemsAdded=!0)),r!==this.state.totalShiftedItems&&(this.setState({totalShiftedItems:r}),i=!0)),t.page!==this.props.page&&(this.props.page>t.page&&this.props.page<=this.totalIndicators-1?this.step(-1,this.props.page):this.props.page<t.page&&this.step(1,this.props.page)),!i&&this.isAutoplay()&&this.startAutoplay()}},{key:"componentWillUnmount",value:function(){this.props.responsiveOptions&&this.unbindDocumentListeners(),this.props.autoplayInterval&&this.stopAutoplay()}},{key:"renderItems",value:function(){var e=this;if(this.props.value&&this.props.value.length){var n=this.isCircular(),i=null,r=null;if(n){var s=null;i=(s=this.props.value.slice(-1*this.state.numVisible)).map((function(n,i){return t.createElement(P,{key:i+"_scloned",className:"p-carousel-item-cloned",template:e.props.itemTemplate,item:n,active:-1*e.state.totalShiftedItems===e.props.value.length+e.state.numVisible,start:0===i,end:i===s.length-1})})),r=(s=this.props.value.slice(0,this.state.numVisible)).map((function(n,i){return t.createElement(P,{key:i+"_fcloned",className:"p-carousel-item-cloned",template:e.props.itemTemplate,item:n,active:0===e.state.totalShiftedItems,start:0===i,end:i===s.length-1})}))}var a=this.props.value.map((function(i,r){var s=n?-1*(e.state.totalShiftedItems+e.state.numVisible):-1*e.state.totalShiftedItems,a=s+e.state.numVisible-1;return t.createElement(P,{key:r,template:e.props.itemTemplate,item:i,active:s<=r&&a>=r,start:s===r,end:a===r})}));return t.createElement(t.Fragment,null,i,a,r)}}},{key:"renderHeader",value:function(){return this.props.header?t.createElement("div",{className:"p-carousel-header"},this.props.header):null}},{key:"renderFooter",value:function(){return this.props.footer?t.createElement("div",{className:"p-carousel-footer"},this.props.footer):null}},{key:"renderContent",value:function(){var e=this,i=this.renderItems(),r=this.isVertical()?this.props.verticalViewPortHeight:"auto",s=this.renderBackwardNavigator(),a=this.renderForwardNavigator(),o=n("p-carousel-container",this.props.containerClassName);return t.createElement("div",{className:o},s,t.createElement("div",{className:"p-carousel-items-content",style:{height:r},onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd},t.createElement("div",{ref:function(t){return e.itemsContainer=t},className:"p-carousel-items-container",onTransitionEnd:this.onTransitionEnd},i)),a)}},{key:"renderBackwardNavigator",value:function(){var e=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&0===this.getPage(),i=n("p-carousel-prev p-link",{"p-disabled":e}),r=n("p-carousel-prev-icon pi",{"pi-chevron-left":!this.isVertical(),"pi-chevron-up":this.isVertical()});return t.createElement("button",{type:"button",className:i,onClick:this.navBackward,disabled:e},t.createElement("span",{className:r}),t.createElement(s,null))}},{key:"renderForwardNavigator",value:function(){var e=(!this.circular||this.props.value&&this.props.value.length<this.state.numVisible)&&(this.getPage()===this.totalIndicators-1||0===this.totalIndicators),i=n("p-carousel-next p-link",{"p-disabled":e}),r=n("p-carousel-next-icon pi",{"pi-chevron-right":!this.isVertical(),"pi-chevron-down":this.isVertical()});return t.createElement("button",{type:"button",className:i,onClick:this.navForward,disabled:e},t.createElement("span",{className:r}),t.createElement(s,null))}},{key:"renderIndicator",value:function(e){var i=this,r=this.getPage()===e,a=n("p-carousel-indicator",{"p-highlight":r});return t.createElement("li",{className:a,key:"p-carousel-indicator-"+e},t.createElement("button",{type:"button",className:"p-link",onClick:function(t){return i.onDotClick(t,e)}},t.createElement(s,null)))}},{key:"renderIndicators",value:function(){for(var e=n("p-carousel-indicators p-reset",this.props.indicatorsContentClassName),i=[],r=0;r<this.totalIndicators;r++)i.push(this.renderIndicator(r));return t.createElement("ul",{className:e},i)}},{key:"render",value:function(){var e=this,i=n("p-carousel p-component",{"p-carousel-vertical":this.isVertical(),"p-carousel-horizontal":!this.isVertical()},this.props.className),r=n("p-carousel-content",this.props.contentClassName);this.totalIndicators=this.getTotalIndicators();var s=this.renderContent(),a=this.renderIndicators(),o=this.renderHeader(),l=this.renderFooter();return t.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:i,style:this.props.style},o,t.createElement("div",{className:r},s,a),l)}}]),v}();S(x,"defaultProps",{id:null,value:null,page:0,header:null,footer:null,style:null,className:null,itemTemplate:null,circular:!1,autoplayInterval:0,numVisible:1,numScroll:1,responsiveOptions:null,orientation:"horizontal",verticalViewPortHeight:"300px",contentClassName:null,containerClassName:null,indicatorsContentClassName:null,onPageChange:null});export{x as Carousel};
|
package/carousel/carousel.js
CHANGED
|
@@ -144,6 +144,217 @@ this.primereact.carousel = (function (exports, React, utils, ripple, PrimeReact)
|
|
|
144
144
|
return obj;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
var ObjectUtils = /*#__PURE__*/function () {
|
|
148
|
+
function ObjectUtils() {
|
|
149
|
+
_classCallCheck(this, ObjectUtils);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_createClass(ObjectUtils, null, [{
|
|
153
|
+
key: "equals",
|
|
154
|
+
value: function equals(obj1, obj2, field) {
|
|
155
|
+
if (field && obj1 && _typeof(obj1) === 'object' && obj2 && _typeof(obj2) === 'object') return this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field);else return this.deepEquals(obj1, obj2);
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "deepEquals",
|
|
159
|
+
value: function deepEquals(a, b) {
|
|
160
|
+
if (a === b) return true;
|
|
161
|
+
|
|
162
|
+
if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {
|
|
163
|
+
var arrA = Array.isArray(a),
|
|
164
|
+
arrB = Array.isArray(b),
|
|
165
|
+
i,
|
|
166
|
+
length,
|
|
167
|
+
key;
|
|
168
|
+
|
|
169
|
+
if (arrA && arrB) {
|
|
170
|
+
length = a.length;
|
|
171
|
+
if (length !== b.length) return false;
|
|
172
|
+
|
|
173
|
+
for (i = length; i-- !== 0;) {
|
|
174
|
+
if (!this.deepEquals(a[i], b[i])) return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (arrA !== arrB) return false;
|
|
181
|
+
var dateA = a instanceof Date,
|
|
182
|
+
dateB = b instanceof Date;
|
|
183
|
+
if (dateA !== dateB) return false;
|
|
184
|
+
if (dateA && dateB) return a.getTime() === b.getTime();
|
|
185
|
+
var regexpA = a instanceof RegExp,
|
|
186
|
+
regexpB = b instanceof RegExp;
|
|
187
|
+
if (regexpA !== regexpB) return false;
|
|
188
|
+
if (regexpA && regexpB) return a.toString() === b.toString();
|
|
189
|
+
var keys = Object.keys(a);
|
|
190
|
+
length = keys.length;
|
|
191
|
+
if (length !== Object.keys(b).length) return false;
|
|
192
|
+
|
|
193
|
+
for (i = length; i-- !== 0;) {
|
|
194
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
for (i = length; i-- !== 0;) {
|
|
198
|
+
key = keys[i];
|
|
199
|
+
if (!this.deepEquals(a[key], b[key])) return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
/*eslint no-self-compare: "off"*/
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
return a !== a && b !== b;
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "resolveFieldData",
|
|
211
|
+
value: function resolveFieldData(data, field) {
|
|
212
|
+
if (data && Object.keys(data).length && field) {
|
|
213
|
+
if (this.isFunction(field)) {
|
|
214
|
+
return field(data);
|
|
215
|
+
} else if (field.indexOf('.') === -1) {
|
|
216
|
+
return data[field];
|
|
217
|
+
} else {
|
|
218
|
+
var fields = field.split('.');
|
|
219
|
+
var value = data;
|
|
220
|
+
|
|
221
|
+
for (var i = 0, len = fields.length; i < len; ++i) {
|
|
222
|
+
if (value == null) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
value = value[fields[i]];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}, {
|
|
236
|
+
key: "isFunction",
|
|
237
|
+
value: function isFunction(obj) {
|
|
238
|
+
return !!(obj && obj.constructor && obj.call && obj.apply);
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
key: "findDiffKeys",
|
|
242
|
+
value: function findDiffKeys(obj1, obj2) {
|
|
243
|
+
if (!obj1 || !obj2) {
|
|
244
|
+
return {};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return Object.keys(obj1).filter(function (key) {
|
|
248
|
+
return !obj2.hasOwnProperty(key);
|
|
249
|
+
}).reduce(function (result, current) {
|
|
250
|
+
result[current] = obj1[current];
|
|
251
|
+
return result;
|
|
252
|
+
}, {});
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "reorderArray",
|
|
256
|
+
value: function reorderArray(value, from, to) {
|
|
257
|
+
var target;
|
|
258
|
+
|
|
259
|
+
if (value && from !== to) {
|
|
260
|
+
if (to >= value.length) {
|
|
261
|
+
target = to - value.length;
|
|
262
|
+
|
|
263
|
+
while (target-- + 1) {
|
|
264
|
+
value.push(undefined);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
value.splice(to, 0, value.splice(from, 1)[0]);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "findIndexInList",
|
|
273
|
+
value: function findIndexInList(value, list, dataKey) {
|
|
274
|
+
var _this = this;
|
|
275
|
+
|
|
276
|
+
if (list) {
|
|
277
|
+
return dataKey ? list.findIndex(function (item) {
|
|
278
|
+
return _this.equals(item, value, dataKey);
|
|
279
|
+
}) : list.findIndex(function (item) {
|
|
280
|
+
return item === value;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return -1;
|
|
285
|
+
}
|
|
286
|
+
}, {
|
|
287
|
+
key: "getJSXElement",
|
|
288
|
+
value: function getJSXElement(obj) {
|
|
289
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
290
|
+
params[_key - 1] = arguments[_key];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return this.isFunction(obj) ? obj.apply(void 0, params) : obj;
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "getPropValue",
|
|
297
|
+
value: function getPropValue(obj) {
|
|
298
|
+
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
299
|
+
params[_key2 - 1] = arguments[_key2];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return this.isFunction(obj) ? obj.apply(void 0, params) : obj;
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "getRefElement",
|
|
306
|
+
value: function getRefElement(ref) {
|
|
307
|
+
if (ref) {
|
|
308
|
+
return _typeof(ref) === 'object' && ref.hasOwnProperty('current') ? ref.current : ref;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}, {
|
|
314
|
+
key: "removeAccents",
|
|
315
|
+
value: function removeAccents(str) {
|
|
316
|
+
if (str && str.search(/[\xC0-\xFF]/g) > -1) {
|
|
317
|
+
str = str.replace(/[\xC0-\xC5]/g, "A").replace(/[\xC6]/g, "AE").replace(/[\xC7]/g, "C").replace(/[\xC8-\xCB]/g, "E").replace(/[\xCC-\xCF]/g, "I").replace(/[\xD0]/g, "D").replace(/[\xD1]/g, "N").replace(/[\xD2-\xD6\xD8]/g, "O").replace(/[\xD9-\xDC]/g, "U").replace(/[\xDD]/g, "Y").replace(/[\xDE]/g, "P").replace(/[\xE0-\xE5]/g, "a").replace(/[\xE6]/g, "ae").replace(/[\xE7]/g, "c").replace(/[\xE8-\xEB]/g, "e").replace(/[\xEC-\xEF]/g, "i").replace(/[\xF1]/g, "n").replace(/[\xF2-\xF6\xF8]/g, "o").replace(/[\xF9-\xFC]/g, "u").replace(/[\xFE]/g, "p").replace(/[\xFD\xFF]/g, "y");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return str;
|
|
321
|
+
}
|
|
322
|
+
}, {
|
|
323
|
+
key: "isEmpty",
|
|
324
|
+
value: function isEmpty(value) {
|
|
325
|
+
return value === null || value === undefined || value === '' || Array.isArray(value) && value.length === 0 || !(value instanceof Date) && _typeof(value) === 'object' && Object.keys(value).length === 0;
|
|
326
|
+
}
|
|
327
|
+
}, {
|
|
328
|
+
key: "isNotEmpty",
|
|
329
|
+
value: function isNotEmpty(value) {
|
|
330
|
+
return !this.isEmpty(value);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Compare value1 and value2 ascending by default (1) or pass in order as -1 for descending.
|
|
334
|
+
*
|
|
335
|
+
* @param {any} value1 the first value
|
|
336
|
+
* @param {any} value2 the second value
|
|
337
|
+
* @param {number | undefined} order by default ascending (1) set to descending (-1)
|
|
338
|
+
* @param {string | undefined} locale the locale to use (default to browser locale if null)
|
|
339
|
+
* @returns either 0, 1 or -1 for comparing the two values
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
}, {
|
|
343
|
+
key: "sort",
|
|
344
|
+
value: function sort(value1, value2) {
|
|
345
|
+
var order = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
346
|
+
var locale = arguments.length > 3 ? arguments[3] : undefined;
|
|
347
|
+
var result = null;
|
|
348
|
+
if (value1 == null && value2 != null) result = -1;else if (value1 != null && value2 == null) result = 1;else if (value1 == null && value2 == null) result = 0;else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, locale, {
|
|
349
|
+
numeric: true
|
|
350
|
+
});else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
351
|
+
return order * result;
|
|
352
|
+
}
|
|
353
|
+
}]);
|
|
354
|
+
|
|
355
|
+
return ObjectUtils;
|
|
356
|
+
}();
|
|
357
|
+
|
|
147
358
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
148
359
|
|
|
149
360
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -510,11 +721,7 @@ this.primereact.carousel = (function (exports, React, utils, ripple, PrimeReact)
|
|
|
510
721
|
this.responsiveOptions.sort(function (data1, data2) {
|
|
511
722
|
var value1 = data1.breakpoint;
|
|
512
723
|
var value2 = data2.breakpoint;
|
|
513
|
-
|
|
514
|
-
if (value1 == null && value2 != null) result = -1;else if (value1 != null && value2 == null) result = 1;else if (value1 == null && value2 == null) result = 0;else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, {
|
|
515
|
-
numeric: true
|
|
516
|
-
});else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
517
|
-
return -1 * result;
|
|
724
|
+
return ObjectUtils.sort(value1, value2, -1, PrimeReact__default["default"].locale);
|
|
518
725
|
});
|
|
519
726
|
|
|
520
727
|
for (var i = 0; i < this.responsiveOptions.length; i++) {
|