Fixed #3802 - Improve folder structure for nuxt configurations

This commit is contained in:
mertsincan 2023-03-26 06:22:57 +01:00
parent 851950270b
commit f5fe822afb
563 changed files with 1703 additions and 1095 deletions

65
components/lib/textarea/Textarea.d.ts vendored Executable file
View file

@ -0,0 +1,65 @@
/**
*
* Textarea is a multi-line text input element.
*
* [Live Demo](https://www.primevue.org/textarea/)
*
* @module textarea
*
*/
import { TextareaHTMLAttributes } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
/**
* Defines valid properties in Textarea component. In addition to these, all properties of TextareaHTMLAttributes can be used in this component.
* @extends TextareaHTMLAttributes
*/
export interface TextareaProps extends TextareaHTMLAttributes {
/**
* Value of the component.
*/
modelValue?: string | undefined;
/**
* When present, height of textarea changes as being typed.
* @defaultValue false
*/
autoResize?: boolean | undefined;
}
/**
* Defines valid slots in Textarea component.
*/
export interface TextareaSlots {}
/**
* Defines valid emits in Textarea component.
*/
export interface TextareaEmits {
/**
* Emitted when the value changes.
* @param {string} value - New value.
*/
'update:modelValue': (value: string) => void;
}
/**
* **PrimeVue - Textarea**
*
* _Textarea is a multi-line text input element._
*
* [Live Demo](https://www.primevue.org/textarea/)
* --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
*
* @group Component
*
*/
declare class Textarea extends ClassComponent<TextareaProps, TextareaSlots, TextareaEmits> {}
declare module '@vue/runtime-core' {
interface GlobalComponents {
Textarea: GlobalComponentConstructor<Textarea>;
}
}
export default Textarea;

View file

@ -0,0 +1,44 @@
import { mount } from '@vue/test-utils';
import Textarea from './Textarea.vue';
describe('Textarea.vue', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(Textarea, {
props: {
modelValue: '',
rows: 1,
cols: 1
}
});
});
it('should exist', () => {
expect(wrapper.find('.p-inputtextarea.p-component').exists()).toBe(true);
expect(wrapper.attributes().rows).toBe('1');
expect(wrapper.attributes().cols).toBe('1');
});
it('should be autoresized', async () => {
await wrapper.setProps({ autoResize: true });
expect(wrapper.find('.p-inputtextarea-resizable').exists()).toBe(true);
});
it('should input', async () => {
await wrapper.vm.onInput({ target: { value: 'primevue' } });
expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['primevue']);
});
it('should resize', async () => {
const firstHeight = wrapper.attributes().style;
await wrapper.setProps({ autoResize: true });
await wrapper.vm.onInput({ target: { value: 'primevue' } });
expect(wrapper.attributes().style).not.toEqual(firstHeight);
});
});

View file

@ -0,0 +1,62 @@
<template>
<textarea :class="['p-inputtextarea p-inputtext p-component', { 'p-filled': filled, 'p-inputtextarea-resizable ': autoResize }]" :value="modelValue" @input="onInput"></textarea>
</template>
<script>
export default {
name: 'Textarea',
emits: ['update:modelValue'],
props: {
modelValue: null,
autoResize: Boolean
},
mounted() {
if (this.$el.offsetParent && this.autoResize) {
this.resize();
}
},
updated() {
if (this.$el.offsetParent && this.autoResize) {
this.resize();
}
},
methods: {
resize() {
const style = window.getComputedStyle(this.$el);
this.$el.style.height = 'auto';
this.$el.style.height = `calc(${style.borderTopWidth} + ${style.borderBottomWidth} + ${this.$el.scrollHeight}px)`;
if (parseFloat(this.$el.style.height) >= parseFloat(this.$el.style.maxHeight)) {
this.$el.style.overflowY = 'scroll';
this.$el.style.height = this.$el.style.maxHeight;
} else {
this.$el.style.overflow = 'hidden';
}
},
onInput(event) {
if (this.autoResize) {
this.resize();
}
this.$emit('update:modelValue', event.target.value);
}
},
computed: {
filled() {
return this.modelValue != null && this.modelValue.toString().length > 0;
}
}
};
</script>
<style>
.p-inputtextarea-resizable {
overflow: hidden;
resize: none;
}
.p-fluid .p-inputtextarea {
width: 100%;
}
</style>

View file

@ -0,0 +1,9 @@
{
"main": "./textarea.cjs.js",
"module": "./textarea.esm.js",
"unpkg": "./textarea.min.js",
"types": "./Textarea.d.ts",
"browser": {
"./sfc": "./Textarea.vue"
}
}