Export locale config and typescript support

pull/800/head
Cagatay Civici 2020-12-10 11:03:08 +03:00
parent e35f1d5927
commit 80b1be89f5
5 changed files with 53 additions and 13 deletions

1
exports/config.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export * from './components/config/PrimeVue';

2
exports/config.js Normal file
View File

@ -0,0 +1,2 @@
'use strict';
module.exports = require('./components/config/PrimeVue.js');

38
src/components/config/PrimeVue.d.ts vendored Normal file
View File

@ -0,0 +1,38 @@
import Vue, { PluginFunction } from 'vue';
interface PrimeVueConfiguration {
ripple?: boolean;
locale?: PrimeVueLocaleOptions;
}
interface PrimeVueLocaleOptions {
accept?: string;
reject?: string;
choose?: string;
upload?: string;
cancel?: string;
dayNames: string[];
dayNamesShort: string[];
dayNamesMin: string[];
monthNames: string[];
monthNamesShort: string[];
today?: string;
clear?: string;
weekHeader?: string;
firstDayOfWeek?: number;
dateFormat?: string;
weak?: string;
medium?: string;
strong?: string;
passwordPrompt?: string;
}
export declare function usePrimeVue(): PrimeVueConfiguration;
export const install: PluginFunction<{}>;
declare module 'vue/types/vue' {
interface Vue {
$primevue: PrimeVueConfiguration;
}
}

View File

@ -1,5 +1,5 @@
import {PrimeVueSymbol} from './usePrimeVue';
import {reactive} from 'vue';
import {reactive,inject} from 'vue';
const defaultOptions = {
ripple: false,
@ -26,6 +26,17 @@ const defaultOptions = {
}
};
const PrimeVueSymbol = Symbol();
export function usePrimeVue() {
const PrimeVue = inject(PrimeVueSymbol);
if (!PrimeVue) {
throw new Error('PrimeVue is not installed!');
}
return PrimeVue;
}
export default {
install: (app, options) => {
let configOptions = options ? {...defaultOptions, ...options} : {...defaultOptions};

View File

@ -1,12 +0,0 @@
import { inject } from 'vue';
export const PrimeVueSymbol = Symbol();
export function usePrimeVue() {
const PrimeVue = inject(PrimeVueSymbol);
if (!PrimeVue) {
throw new Error('PrimeVue is not installed!');
}
return PrimeVue;
}