From 754e2ee938720b9eea051819eacbf1b7a68e561b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 14 Jan 2021 16:36:42 +0300 Subject: [PATCH] add usetoast and useconfirm --- src/components/useconfirm/useconfirm.d.ts | 19 +++++++++++++++++++ src/components/useconfirm/useconfirm.js | 12 ++++++++++++ src/components/usetoast/usetoast.d.ts | 1 + src/components/usetoast/usetoast.js | 12 ++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 src/components/useconfirm/useconfirm.d.ts create mode 100644 src/components/useconfirm/useconfirm.js create mode 100644 src/components/usetoast/usetoast.d.ts create mode 100644 src/components/usetoast/usetoast.js diff --git a/src/components/useconfirm/useconfirm.d.ts b/src/components/useconfirm/useconfirm.d.ts new file mode 100644 index 000000000..44df8c048 --- /dev/null +++ b/src/components/useconfirm/useconfirm.d.ts @@ -0,0 +1,19 @@ +export declare function useConfirm(): { + require(args:{ + message?: string; + group?: string; + icon?: string; + header?: string; + accept?: Function; + reject?: Function; + acceptLabel?: string; + rejectLabel?: string; + acceptIcon?: string; + rejectIcon?: string; + blockScroll?: boolean; + acceptClass?: string; + rejectClass?: string; + }): void + + close(): void +} \ No newline at end of file diff --git a/src/components/useconfirm/useconfirm.js b/src/components/useconfirm/useconfirm.js new file mode 100644 index 000000000..c0a588441 --- /dev/null +++ b/src/components/useconfirm/useconfirm.js @@ -0,0 +1,12 @@ +import { inject } from 'vue'; + +export const PrimeVueConfirmSymbol = Symbol(); + +export function useConfirm() { + const PrimeVueConfirm = inject(PrimeVueConfirmSymbol); + if (!PrimeVueConfirm) { + throw new Error('No PrimeVue Confirmation provided!'); + } + + return PrimeVueConfirm; +} \ No newline at end of file diff --git a/src/components/usetoast/usetoast.d.ts b/src/components/usetoast/usetoast.d.ts new file mode 100644 index 000000000..eca896906 --- /dev/null +++ b/src/components/usetoast/usetoast.d.ts @@ -0,0 +1 @@ +export declare function useToast(): { add(args:{ severity?: string, summary?: string, detail?: string, life?: number, closable?: boolean, group?: string }): void } \ No newline at end of file diff --git a/src/components/usetoast/usetoast.js b/src/components/usetoast/usetoast.js new file mode 100644 index 000000000..24713327c --- /dev/null +++ b/src/components/usetoast/usetoast.js @@ -0,0 +1,12 @@ +import { inject } from 'vue'; + +export const PrimeVueToastSymbol = Symbol(); + +export function useToast() { + const PrimeVueToast = inject(PrimeVueToastSymbol); + if (!PrimeVueToast) { + throw new Error('No PrimeVue Toast provided!'); + } + + return PrimeVueToast; +} \ No newline at end of file