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

101
components/lib/inplace/Inplace.d.ts vendored Executable file
View file

@ -0,0 +1,101 @@
/**
*
* Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
*
* [Live Demo](https://www.primevue.org/inplace)
*
* @module inplace
*
*/
import { ButtonHTMLAttributes, HTMLAttributes, VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
/**
* Defines valid properties in Inplace component.
*/
export interface InplaceProps {
/**
* Displays a button to switch back to display mode.
* @defaultValue false
*/
closable?: boolean | undefined;
/**
* Whether the content is displayed or not.
* @defaultValue false
*/
active?: boolean | undefined;
/**
* When present, it specifies that the element should be disabled.
* @defaultValue false
*/
disabled?: boolean | undefined;
/**
* Icon to display in the close button.
* @defaultValue pi pi-times
*/
closeIcon?: string | undefined;
/**
* Uses to pass all properties of the HTMLDivElement to display container.
*/
displayProps?: HTMLAttributes | undefined;
/**
* Uses to pass all properties of the HTMLButtonElement to the close button.
*/
closeButtonProps?: ButtonHTMLAttributes | undefined;
}
/**
* Defines valid slots in Inplace component.
*/
export interface InplaceSlots {
/**
* Custom display template.
*/
display(): VNode[];
/**
* Custom content template.
*/
content(): VNode[];
}
/**
* Defines valid emits in Inplace component.
*/
export interface InplaceEmits {
/**
* Emitted when the active changes.
* @param {boolean} value - New value.
*/
'update:active'(value: boolean): void;
/**
* Callback to invoke when inplace is opened.
* @param {Event} event - Browser event.
*/
open(event: Event): void;
/**
* Callback to invoke when inplace is closed.
* @param {Event} event - Browser event.
*/
close(event: Event): void;
}
/**
* **PrimeVue - Inplace**
*
* _Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content._
*
* [Live Demo](https://www.primevue.org/inplace/)
* --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
*
* @group Component
*/
declare class Inplace extends ClassComponent<InplaceProps, InplaceSlots, InplaceEmits> {}
declare module '@vue/runtime-core' {
interface GlobalComponents {
Inplace: GlobalComponentConstructor<Inplace>;
}
}
export default Inplace;

View file

@ -0,0 +1,101 @@
import { config, mount } from '@vue/test-utils';
import InputText from 'primevue/inputtext';
import Inplace from './Inplace.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
close: 'Close'
}
}
}
}
};
describe('Inplace.vue', () => {
it('should exist', () => {
const wrapper = mount(Inplace);
expect(wrapper.find('.p-inplace.p-component').exists()).toBe(true);
});
it('should slots display', () => {
const wrapper = mount(Inplace, {
global: {
components: {
InputText
}
},
slots: {
display: `
<span class="pi pi-search" style="vertical-align: middle"></span>
<span style="margin-left:.5rem; vertical-align: middle">View Picture</span>
`,
content: `<img src="/images/nature/nature1.jpg" />`
}
});
expect(wrapper.find('.p-inplace-display').exists()).toBe(true);
wrapper.vm.open({});
expect(wrapper.emitted()['update:active'][0]).toEqual([true]);
wrapper.vm.close({});
expect(wrapper.emitted()['update:active'][1]).toEqual([false]);
});
it('closable inplace', async () => {
const wrapper = mount(Inplace, {
global: {
components: {
InputText
}
},
props: {
closable: true
},
slots: {
display: `{{'Click to Edit'}}`,
content: `<InputText autofocus />`
}
});
expect(wrapper.find('.p-inplace-closable').exists()).toBe(true);
expect(wrapper.find('.p-inplace-display').text()).toBe('Click to Edit');
await wrapper.vm.open({});
expect(wrapper.find('.p-inputtext').exists()).toBe(true);
expect(wrapper.find('.pi.pi-times').exists()).toBe(true);
await wrapper.vm.close({});
expect(wrapper.find('.pi.pi-times').exists()).toBe(false);
});
it('should have custom close icon', async () => {
const wrapper = mount(Inplace, {
global: {
components: {
InputText
}
},
props: {
closable: true,
closeIcon: 'pi pi-discord'
},
slots: {
display: `{{'Click to Edit'}}`,
content: `<InputText autofocus />`
}
});
await wrapper.vm.open({});
expect(wrapper.find('.pi.pi-discord').exists()).toBe(true);
});
});

View file

@ -0,0 +1,113 @@
<template>
<div v-focustrap :class="containerClass" aria-live="polite">
<div v-if="!d_active" ref="display" :class="displayClass" :tabindex="$attrs.tabindex || '0'" role="button" @click="open" @keydown.enter="open" v-bind="displayProps">
<slot name="display"></slot>
</div>
<div v-else class="p-inplace-content">
<slot name="content"></slot>
<IPButton v-if="closable" :icon="closeIcon" :aria-label="closeAriaLabel" @click="close" v-bind="closeButtonProps" />
</div>
</div>
</template>
<script>
import Button from 'primevue/button';
import FocusTrap from 'primevue/focustrap';
export default {
name: 'Inplace',
emits: ['open', 'close', 'update:active'],
props: {
closable: {
type: Boolean,
default: false
},
active: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
closeIcon: {
type: String,
default: 'pi pi-times'
},
displayProps: {
type: null,
default: null
},
closeButtonProps: {
type: null,
default: null
}
},
data() {
return {
d_active: this.active
};
},
watch: {
active(newValue) {
this.d_active = newValue;
}
},
methods: {
open(event) {
if (this.disabled) {
return;
}
this.$emit('open', event);
this.d_active = true;
this.$emit('update:active', true);
},
close(event) {
this.$emit('close', event);
this.d_active = false;
this.$emit('update:active', false);
setTimeout(() => {
this.$refs.display.focus();
}, 0);
}
},
computed: {
containerClass() {
return ['p-inplace p-component', { 'p-inplace-closable': this.closable }];
},
displayClass() {
return ['p-inplace-display', { 'p-disabled': this.disabled }];
},
closeAriaLabel() {
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
}
},
components: {
IPButton: Button
},
directives: {
focustrap: FocusTrap
}
};
</script>
<style>
.p-inplace .p-inplace-display {
display: inline;
cursor: pointer;
}
.p-inplace .p-inplace-content {
display: inline;
}
.p-fluid .p-inplace.p-inplace-closable .p-inplace-content {
display: flex;
}
.p-fluid .p-inplace.p-inplace-closable .p-inplace-content > .p-inputtext {
flex: 1 1 auto;
width: 1%;
}
</style>

View file

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