UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

1 lines 13.9 kB
{"version":3,"file":"index.mjs","sources":["../../src/scrolltop/BaseScrollTop.vue","../../src/scrolltop/ScrollTop.vue","../../src/scrolltop/ScrollTop.vue?vue&type=template&id=13ee561a&lang.js"],"sourcesContent":["<script>\nimport BaseComponent from '@primevue/core/basecomponent';\nimport ScrollTopStyle from 'primevue/scrolltop/style';\n\nexport default {\n name: 'BaseScrollTop',\n extends: BaseComponent,\n props: {\n target: {\n type: String,\n default: 'window'\n },\n threshold: {\n type: Number,\n default: 400\n },\n icon: {\n type: String,\n default: undefined\n },\n behavior: {\n type: String,\n default: 'smooth'\n },\n buttonProps: {\n type: Object,\n default: () => {\n return { rounded: true };\n }\n }\n },\n style: ScrollTopStyle,\n provide() {\n return {\n $pcScrollTop: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <transition name=\"p-scrolltop\" appear @enter=\"onEnter\" @after-leave=\"onAfterLeave\" v-bind=\"ptm('transition')\">\n <Button v-if=\"visible\" :ref=\"containerRef\" :class=\"cx('root')\" @click=\"onClick\" :aria-label=\"scrollTopAriaLabel\" :unstyled=\"unstyled\" v-bind=\"buttonProps\" :pt=\"ptm('root')\">\n <template #icon=\"slotProps\">\n <slot name=\"icon\" :class=\"cx('icon')\">\n <component :is=\"icon ? 'span' : 'ChevronUpIcon'\" :class=\"[cx('icon'), icon, slotProps.class]\" v-bind=\"ptm('root')['icon']\" data-pc-section=\"icon\" />\n </slot>\n </template>\n </Button>\n </transition>\n</template>\n\n<script>\nimport { getWindowScrollTop } from '@primeuix/utils/dom';\nimport { ZIndex } from '@primeuix/utils/zindex';\nimport ChevronUpIcon from '@primevue/icons/chevronup';\nimport Button from 'primevue/button';\nimport BaseScrollTop from './BaseScrollTop.vue';\n\nexport default {\n name: 'ScrollTop',\n extends: BaseScrollTop,\n inheritAttrs: false,\n scrollListener: null,\n container: null,\n data() {\n return {\n visible: false\n };\n },\n mounted() {\n if (this.target === 'window') this.bindDocumentScrollListener();\n else if (this.target === 'parent') this.bindParentScrollListener();\n },\n beforeUnmount() {\n if (this.target === 'window') this.unbindDocumentScrollListener();\n else if (this.target === 'parent') this.unbindParentScrollListener();\n\n if (this.container) {\n ZIndex.clear(this.container);\n this.overlay = null;\n }\n },\n methods: {\n onClick() {\n let scrollElement = this.target === 'window' ? window : this.$el.parentElement;\n\n scrollElement.scroll({\n top: 0,\n behavior: this.behavior\n });\n },\n checkVisibility(scrollY) {\n if (scrollY > this.threshold) this.visible = true;\n else this.visible = false;\n },\n bindParentScrollListener() {\n this.scrollListener = () => {\n this.checkVisibility(this.$el.parentElement.scrollTop);\n };\n\n this.$el.parentElement.addEventListener('scroll', this.scrollListener);\n },\n bindDocumentScrollListener() {\n this.scrollListener = () => {\n this.checkVisibility(getWindowScrollTop());\n };\n\n window.addEventListener('scroll', this.scrollListener);\n },\n unbindParentScrollListener() {\n if (this.scrollListener) {\n this.$el.parentElement.removeEventListener('scroll', this.scrollListener);\n this.scrollListener = null;\n }\n },\n unbindDocumentScrollListener() {\n if (this.scrollListener) {\n window.removeEventListener('scroll', this.scrollListener);\n this.scrollListener = null;\n }\n },\n onEnter(el) {\n ZIndex.set('overlay', el, this.$primevue.config.zIndex.overlay);\n },\n onAfterLeave(el) {\n ZIndex.clear(el);\n },\n containerRef(el) {\n this.container = el ? el.$el : undefined;\n }\n },\n computed: {\n scrollTopAriaLabel() {\n return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.scrollTop : undefined;\n }\n },\n components: {\n ChevronUpIcon,\n Button\n }\n};\n</script>\n","<template>\n <transition name=\"p-scrolltop\" appear @enter=\"onEnter\" @after-leave=\"onAfterLeave\" v-bind=\"ptm('transition')\">\n <Button v-if=\"visible\" :ref=\"containerRef\" :class=\"cx('root')\" @click=\"onClick\" :aria-label=\"scrollTopAriaLabel\" :unstyled=\"unstyled\" v-bind=\"buttonProps\" :pt=\"ptm('root')\">\n <template #icon=\"slotProps\">\n <slot name=\"icon\" :class=\"cx('icon')\">\n <component :is=\"icon ? 'span' : 'ChevronUpIcon'\" :class=\"[cx('icon'), icon, slotProps.class]\" v-bind=\"ptm('root')['icon']\" data-pc-section=\"icon\" />\n </slot>\n </template>\n </Button>\n </transition>\n</template>\n\n<script>\nimport { getWindowScrollTop } from '@primeuix/utils/dom';\nimport { ZIndex } from '@primeuix/utils/zindex';\nimport ChevronUpIcon from '@primevue/icons/chevronup';\nimport Button from 'primevue/button';\nimport BaseScrollTop from './BaseScrollTop.vue';\n\nexport default {\n name: 'ScrollTop',\n extends: BaseScrollTop,\n inheritAttrs: false,\n scrollListener: null,\n container: null,\n data() {\n return {\n visible: false\n };\n },\n mounted() {\n if (this.target === 'window') this.bindDocumentScrollListener();\n else if (this.target === 'parent') this.bindParentScrollListener();\n },\n beforeUnmount() {\n if (this.target === 'window') this.unbindDocumentScrollListener();\n else if (this.target === 'parent') this.unbindParentScrollListener();\n\n if (this.container) {\n ZIndex.clear(this.container);\n this.overlay = null;\n }\n },\n methods: {\n onClick() {\n let scrollElement = this.target === 'window' ? window : this.$el.parentElement;\n\n scrollElement.scroll({\n top: 0,\n behavior: this.behavior\n });\n },\n checkVisibility(scrollY) {\n if (scrollY > this.threshold) this.visible = true;\n else this.visible = false;\n },\n bindParentScrollListener() {\n this.scrollListener = () => {\n this.checkVisibility(this.$el.parentElement.scrollTop);\n };\n\n this.$el.parentElement.addEventListener('scroll', this.scrollListener);\n },\n bindDocumentScrollListener() {\n this.scrollListener = () => {\n this.checkVisibility(getWindowScrollTop());\n };\n\n window.addEventListener('scroll', this.scrollListener);\n },\n unbindParentScrollListener() {\n if (this.scrollListener) {\n this.$el.parentElement.removeEventListener('scroll', this.scrollListener);\n this.scrollListener = null;\n }\n },\n unbindDocumentScrollListener() {\n if (this.scrollListener) {\n window.removeEventListener('scroll', this.scrollListener);\n this.scrollListener = null;\n }\n },\n onEnter(el) {\n ZIndex.set('overlay', el, this.$primevue.config.zIndex.overlay);\n },\n onAfterLeave(el) {\n ZIndex.clear(el);\n },\n containerRef(el) {\n this.container = el ? el.$el : undefined;\n }\n },\n computed: {\n scrollTopAriaLabel() {\n return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.scrollTop : undefined;\n }\n },\n components: {\n ChevronUpIcon,\n Button\n }\n};\n</script>\n"],"names":["name","BaseComponent","props","target","type","String","threshold","Number","icon","undefined","behavior","buttonProps","Object","default","rounded","style","ScrollTopStyle","provide","$pcScrollTop","$parentInstance","BaseScrollTop","inheritAttrs","scrollListener","container","data","visible","mounted","bindDocumentScrollListener","bindParentScrollListener","beforeUnmount","unbindDocumentScrollListener","unbindParentScrollListener","ZIndex","clear","overlay","methods","onClick","scrollElement","window","$el","parentElement","scroll","top","checkVisibility","scrollY","_this","scrollTop","addEventListener","_this2","getWindowScrollTop","removeEventListener","onEnter","el","set","$primevue","config","zIndex","onAfterLeave","containerRef","computed","scrollTopAriaLabel","locale","aria","components","ChevronUpIcon","Button","_openBlock","_createBlock","_Transition","_mergeProps","appear","$options","_ctx","ptm","$data","_component_Button","ref","cx","unstyled","pt","_withCtx","slotProps","_renderSlot","$slots","_resolveDynamicComponent"],"mappings":";;;;;;;;AAIA,eAAe;AACXA,EAAAA,IAAI,EAAE,eAAe;AACrB,EAAA,SAAA,EAASC,aAAa;AACtBC,EAAAA,KAAK,EAAE;AACHC,IAAAA,MAAM,EAAE;AACJC,MAAAA,IAAI,EAAEC,MAAM;MACZ,SAAS,EAAA;KACZ;AACDC,IAAAA,SAAS,EAAE;AACPF,MAAAA,IAAI,EAAEG,MAAM;MACZ,SAAS,EAAA;KACZ;AACDC,IAAAA,IAAI,EAAE;AACFJ,MAAAA,IAAI,EAAEC,MAAM;MACZ,SAASI,EAAAA;KACZ;AACDC,IAAAA,QAAQ,EAAE;AACNN,MAAAA,IAAI,EAAEC,MAAM;MACZ,SAAS,EAAA;KAC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