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 9.71 kB
{"version":3,"file":"index.mjs","sources":["../../src/textarea/BaseTextarea.vue","../../src/textarea/Textarea.vue","../../src/textarea/Textarea.vue?vue&type=template&id=3392f7fb&lang.js"],"sourcesContent":["<script>\nimport BaseInput from '@primevue/core/baseinput';\nimport TextareaStyle from 'primevue/textarea/style';\n\nexport default {\n name: 'BaseTextarea',\n extends: BaseInput,\n props: {\n autoResize: Boolean\n },\n style: TextareaStyle,\n provide() {\n return {\n $pcTextarea: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <textarea :class=\"cx('root')\" :value=\"d_value\" :name=\"name\" :disabled=\"disabled\" :aria-invalid=\"invalid || undefined\" :data-p=\"dataP\" @input=\"onInput\" v-bind=\"attrs\"></textarea>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport { mergeProps } from 'vue';\nimport BaseTextarea from './BaseTextarea.vue';\n\nexport default {\n name: 'Textarea',\n extends: BaseTextarea,\n inheritAttrs: false,\n observer: null,\n mounted() {\n if (this.autoResize) {\n this.observer = new ResizeObserver(() => {\n // Firefox has issues without the requestAnimationFrame - ResizeObserver loop completed with undelivered notifications.\n requestAnimationFrame(() => {\n this.resize();\n });\n });\n this.observer.observe(this.$el);\n }\n },\n updated() {\n if (this.autoResize) {\n this.resize();\n }\n },\n beforeUnmount() {\n if (this.observer) {\n this.observer.disconnect();\n }\n },\n methods: {\n resize() {\n if (!this.$el.offsetParent) return;\n\n const currentHeight = this.$el.style.height;\n const currentHeightValue = parseInt(currentHeight) || 0;\n const initialScrollHeight = this.$el.scrollHeight;\n\n const needsExpanding = !currentHeightValue || initialScrollHeight > currentHeightValue;\n const needsShrinking = currentHeightValue && initialScrollHeight < currentHeightValue;\n\n if (needsShrinking) {\n this.$el.style.height = 'auto';\n this.$el.style.height = `${this.$el.scrollHeight}px`;\n } else if (needsExpanding) {\n this.$el.style.height = `${initialScrollHeight}px`;\n }\n },\n onInput(event) {\n if (this.autoResize) {\n this.resize();\n }\n\n this.writeValue(event.target.value, event);\n }\n },\n computed: {\n attrs() {\n return mergeProps(\n this.ptmi('root', {\n context: {\n filled: this.$filled,\n disabled: this.disabled\n }\n }),\n this.formField\n );\n },\n dataP() {\n return cn({\n invalid: this.$invalid,\n fluid: this.$fluid,\n filled: this.$variant === 'filled',\n [this.size]: this.size\n });\n }\n }\n};\n</script>\n","<template>\n <textarea :class=\"cx('root')\" :value=\"d_value\" :name=\"name\" :disabled=\"disabled\" :aria-invalid=\"invalid || undefined\" :data-p=\"dataP\" @input=\"onInput\" v-bind=\"attrs\"></textarea>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport { mergeProps } from 'vue';\nimport BaseTextarea from './BaseTextarea.vue';\n\nexport default {\n name: 'Textarea',\n extends: BaseTextarea,\n inheritAttrs: false,\n observer: null,\n mounted() {\n if (this.autoResize) {\n this.observer = new ResizeObserver(() => {\n // Firefox has issues without the requestAnimationFrame - ResizeObserver loop completed with undelivered notifications.\n requestAnimationFrame(() => {\n this.resize();\n });\n });\n this.observer.observe(this.$el);\n }\n },\n updated() {\n if (this.autoResize) {\n this.resize();\n }\n },\n beforeUnmount() {\n if (this.observer) {\n this.observer.disconnect();\n }\n },\n methods: {\n resize() {\n if (!this.$el.offsetParent) return;\n\n const currentHeight = this.$el.style.height;\n const currentHeightValue = parseInt(currentHeight) || 0;\n const initialScrollHeight = this.$el.scrollHeight;\n\n const needsExpanding = !currentHeightValue || initialScrollHeight > currentHeightValue;\n const needsShrinking = currentHeightValue && initialScrollHeight < currentHeightValue;\n\n if (needsShrinking) {\n this.$el.style.height = 'auto';\n this.$el.style.height = `${this.$el.scrollHeight}px`;\n } else if (needsExpanding) {\n this.$el.style.height = `${initialScrollHeight}px`;\n }\n },\n onInput(event) {\n if (this.autoResize) {\n this.resize();\n }\n\n this.writeValue(event.target.value, event);\n }\n },\n computed: {\n attrs() {\n return mergeProps(\n this.ptmi('root', {\n context: {\n filled: this.$filled,\n disabled: this.disabled\n }\n }),\n this.formField\n );\n },\n dataP() {\n return cn({\n invalid: this.$invalid,\n fluid: this.$fluid,\n filled: this.$variant === 'filled',\n [this.size]: this.size\n });\n }\n }\n};\n</script>\n"],"names":["name","BaseInput","props","autoResize","Boolean","style","TextareaStyle","provide","$pcTextarea","$parentInstance","BaseTextarea","inheritAttrs","observer","mounted","_this","ResizeObserver","requestAnimationFrame","resize","observe","$el","updated","beforeUnmount","disconnect","methods","offsetParent","currentHeight","height","currentHeightValue","parseInt","initialScrollHeight","scrollHeight","needsExpanding","needsShrinking","concat","onInput","event","writeValue","target","value","computed","attrs","mergeProps","ptmi","context","filled","$filled","disabled","formField","dataP","cn","_defineProperty","invalid","$invalid","fluid","$fluid","$variant","size","_openBlock","_createElementBlock","_mergeProps","_ctx","cx","d_value","undefined","$options","apply","arguments","_hoisted_1"],"mappings":";;;;;AAIA,eAAe;AACXA,EAAAA,IAAI,EAAE,cAAc;AACpB,EAAA,SAAA,EAASC,SAAS;AAClBC,EAAAA,KAAK,EAAE;AACHC,IAAAA,UAAU,EAAEC;GACf;AACDC,EAAAA,KAAK,EAAEC,aAAa;EACpBC,OAAO,EAAA,SAAPA,OAAOA,GAAG;IACN,OAAO;AACHC,MAAAA,WAAW,EAAE,IAAI;AACjBC,MAAAA,eAAe,EAAE;KACpB;AACL,EAAA;AACJ,CAAC;;;;;;ACRD,aAAe;AACXT,EAAAA,IAAI,EAAE,UAAU;AAChB,EAAA,SAAA,EAASU,QAAY;AACrBC,EAAAA,YAAY,EAAE,KAAK;AACnBC,EAAAA,QAAQ,EAAE,IAAI;EACdC,OAAO,EAAA,SAAPA,OAAOA,GAAG;AAAA,IAAA,IAAAC,KAAA,GAAA,IAAA;IACN,IAAI,IAAI,CAACX,UAAU,EAAE;AACjB,MAAA,IAAI,CAACS,QAAO,GAAI,IAAI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