mirror of
https://github.com/Drop-OSS/drop-base.git
synced 2025-11-10 04:22:15 +10:00
Compare commits
17 Commits
1694de4e89
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 14f4e3e20b | |||
| 06bea06363 | |||
| 4c42edf5ad | |||
| 04125e89be | |||
| 893a4fe8a9 | |||
| 0c68363608 | |||
| a14d1b7081 | |||
| 26698e5b06 | |||
| e32cc36f33 | |||
| ce59647cda | |||
| 637b4e1e9b | |||
| 77b85c97d0 | |||
| 533eb483ea | |||
| b7127c645d | |||
| de0d1b4660 | |||
| 01fd41c65a | |||
| 80674ef87d |
@ -1,15 +0,0 @@
|
|||||||
import { fileURLToPath } from 'node:url'
|
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
|
||||||
extends: ['..'],
|
|
||||||
modules: ['@nuxt/eslint'],
|
|
||||||
|
|
||||||
eslint: {
|
|
||||||
config: {
|
|
||||||
// Use the generated ESLint config for lint root project as well
|
|
||||||
rootDir: fileURLToPath(new URL('..', import.meta.url))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
compatibilityDate: '2024-12-24'
|
|
||||||
})
|
|
||||||
27
app.vue
27
app.vue
@ -1,27 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ModalStack />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
onMounted(() => {
|
|
||||||
createModal(
|
|
||||||
ModalType.Confirmation,
|
|
||||||
{
|
|
||||||
title: "Are you sure?",
|
|
||||||
description:
|
|
||||||
"Are you sure you want to complete this action? It may have unintended side effects.",
|
|
||||||
},
|
|
||||||
async (event, close) => {
|
|
||||||
switch (event) {
|
|
||||||
case "confirm":
|
|
||||||
await new Promise((r) => setTimeout(r, 3000));
|
|
||||||
close();
|
|
||||||
break;
|
|
||||||
case "cancel":
|
|
||||||
close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@ -1,82 +1,52 @@
|
|||||||
<template>
|
<template>
|
||||||
<TransitionRoot
|
<div class="relative z-50" @close="emit('event', 'cancel')">
|
||||||
as="template"
|
<div class="fixed inset-0 bg-zinc-950/75" />
|
||||||
:show="true"
|
|
||||||
:style="{ 'z-index': props.zHeight }"
|
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||||
>
|
<div
|
||||||
<Dialog class="relative z-50" @close="emit('event', 'cancel')">
|
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||||
<TransitionChild
|
|
||||||
as="template"
|
|
||||||
enter="ease-out duration-300"
|
|
||||||
enter-from="opacity-0"
|
|
||||||
enter-to="opacity-100"
|
|
||||||
leave="ease-in duration-200"
|
|
||||||
leave-from="opacity-100"
|
|
||||||
leave-to="opacity-0"
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="fixed inset-0 bg-zinc-950 bg-opacity-75 transition-opacity"
|
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
||||||
/>
|
|
||||||
</TransitionChild>
|
|
||||||
|
|
||||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
|
||||||
<div
|
|
||||||
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
|
||||||
>
|
>
|
||||||
<TransitionChild
|
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||||
as="template"
|
<div class="sm:flex sm:items-start">
|
||||||
enter="ease-out duration-300"
|
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
||||||
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
<h3 class="text-base font-semibold text-zinc-100">
|
||||||
enter-to="opacity-100 translate-y-0 sm:scale-100"
|
{{ props.data.title }}
|
||||||
leave="ease-in duration-200"
|
</h3>
|
||||||
leave-from="opacity-100 translate-y-0 sm:scale-100"
|
<div class="mt-2">
|
||||||
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
<p class="text-sm text-zinc-400">
|
||||||
>
|
{{ props.data.description }}
|
||||||
<div
|
</p>
|
||||||
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
|
||||||
>
|
|
||||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
|
||||||
<div class="sm:flex sm:items-start">
|
|
||||||
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
|
||||||
<DialogTitle
|
|
||||||
as="h3"
|
|
||||||
class="text-base font-semibold text-zinc-100"
|
|
||||||
>{{ props.data.title }}
|
|
||||||
</DialogTitle>
|
|
||||||
<div class="mt-2">
|
|
||||||
<p class="text-sm text-zinc-400">
|
|
||||||
{{ props.data.description }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
|
||||||
>
|
|
||||||
<LoadingButton
|
|
||||||
:loading="props.loading"
|
|
||||||
@click="emit('event', 'confirm')"
|
|
||||||
type="submit"
|
|
||||||
class="w-full sm:w-fit"
|
|
||||||
>
|
|
||||||
{{ props.data.buttonText ?? "Confirm" }}
|
|
||||||
</LoadingButton>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
|
||||||
@click="emit('event', 'cancel')"
|
|
||||||
ref="cancelButtonRef"
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</TransitionChild>
|
</div>
|
||||||
|
<div
|
||||||
|
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
||||||
|
>
|
||||||
|
<LoadingButton
|
||||||
|
:loading="props.loading"
|
||||||
|
@click="emit('event', 'confirm')"
|
||||||
|
type="submit"
|
||||||
|
class="w-full sm:w-fit"
|
||||||
|
>
|
||||||
|
{{ props.data.buttonText ?? "Confirm" }}
|
||||||
|
</LoadingButton>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||||
|
@click="emit('event', 'cancel')"
|
||||||
|
ref="cancelButtonRef"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</div>
|
||||||
</TransitionRoot>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="inline-flex h-9 items-center justify-center rounded-md px-3 py-1.5 text-sm font-semibold leading-6 shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 text-white bg-blue-600 hover:bg-blue-500 disabled:text-zinc-400 disabled:bg-blue-600/10 disabled:hover:bg-blue-600/10"
|
:class="[
|
||||||
|
styles[style].base,
|
||||||
|
props.disabled ? styles[style].disabled : styles[style].dft,
|
||||||
|
]"
|
||||||
|
:disabled="props.disabled"
|
||||||
>
|
>
|
||||||
<div v-if="props.loading" role="status">
|
<div v-if="props.loading" role="status">
|
||||||
<svg
|
<svg
|
||||||
@ -22,12 +26,29 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span class="sr-only">Loading...</span>
|
<span class="sr-only">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<slot v-else />
|
||||||
<slot />
|
|
||||||
</span>
|
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{ loading: boolean }>();
|
type Style = "default" | "none";
|
||||||
|
const props = defineProps<{
|
||||||
|
loading: boolean;
|
||||||
|
style?: Style;
|
||||||
|
disabled?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const style = props.style ?? "default";
|
||||||
|
|
||||||
|
const styles: {
|
||||||
|
[key in Style]: { base: string; dft: string; disabled: string };
|
||||||
|
} = {
|
||||||
|
["default"]: {
|
||||||
|
base: "inline-flex min-h-9 items-center justify-center rounded-md px-3 py-1.5 text-sm font-semibold leading-6 shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600",
|
||||||
|
dft: "text-white bg-blue-600 hover:bg-blue-500",
|
||||||
|
disabled:
|
||||||
|
"text-zinc-400 bg-blue-600/10 hover:bg-blue-600/10",
|
||||||
|
},
|
||||||
|
["none"]: { base: "", dft: "", disabled: "" },
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,18 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
<component
|
<TransitionGroup name="modal">
|
||||||
v-for="(modal, modalIdx) in stack"
|
<component
|
||||||
:is="modal.component"
|
v-for="(modal, modalIdx) in stack"
|
||||||
:z-height="(modalIdx + 1) * 50"
|
:key="modal.data"
|
||||||
:loading="modal.loading"
|
:is="modal.component"
|
||||||
:data="modal.data"
|
:z-height="(modalIdx + 1) * 50"
|
||||||
@event="(event: string) => handleCallback(modalIdx, event)"
|
:loading="modal.loading"
|
||||||
/>
|
:data="modal.data"
|
||||||
|
@event="
|
||||||
|
(event: string, ...args: any[]) => handleCallback(modalIdx, event, args)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</TransitionGroup>
|
||||||
|
<div id="modalstack"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.modal-enter-active,
|
||||||
|
.modal-leave-active {
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
.modal-enter-from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.modal-enter-to {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
.modal-leave-from {
|
||||||
|
opacity: 100;
|
||||||
|
}
|
||||||
|
.modal-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const stack = useModalStack();
|
const stack = useModalStack();
|
||||||
|
|
||||||
async function handleCallback(modalIdx: number, event: string) {
|
async function handleCallback(modalIdx: number, event: string, args: any[]) {
|
||||||
const modal = stack.value[modalIdx];
|
const modal = stack.value[modalIdx];
|
||||||
console.log(modal);
|
console.log(modal);
|
||||||
const close = () => {
|
const close = () => {
|
||||||
@ -23,7 +48,7 @@ async function handleCallback(modalIdx: number, event: string) {
|
|||||||
// I kinda hate this but it's how Vue works so....
|
// I kinda hate this but it's how Vue works so....
|
||||||
(modal.loading as unknown as boolean) = true;
|
(modal.loading as unknown as boolean) = true;
|
||||||
try {
|
try {
|
||||||
await modal.callback(event, close);
|
await modal.callback(event, close, ...args);
|
||||||
} finally {
|
} finally {
|
||||||
(modal.loading as unknown as boolean) = false;
|
(modal.loading as unknown as boolean) = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
:class="['relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full', props.sizeClass ?? 'sm:max-w-lg']"
|
||||||
>
|
>
|
||||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||||
<slot />
|
<slot />
|
||||||
@ -55,7 +55,8 @@ import {
|
|||||||
TransitionRoot,
|
TransitionRoot,
|
||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
|
|
||||||
const open = defineModel<boolean>();
|
const open: Ref<boolean> = defineModel<boolean>() as any;
|
||||||
|
const props = defineProps<{sizeClass?: string}>();
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
|
|||||||
@ -1,48 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<TransitionRoot
|
<div class="relative z-50" @close="emit('event', 'close')">
|
||||||
as="template"
|
|
||||||
:show="true"
|
|
||||||
:style="{ 'z-index': props.zHeight }"
|
|
||||||
>
|
|
||||||
<Dialog class="relative z-50" @close="emit('event', 'close')">
|
|
||||||
<TransitionChild
|
|
||||||
as="template"
|
|
||||||
enter="ease-out duration-300"
|
|
||||||
enter-from="opacity-0"
|
|
||||||
enter-to="opacity-100"
|
|
||||||
leave="ease-in duration-200"
|
|
||||||
leave-from="opacity-100"
|
|
||||||
leave-to="opacity-0"
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
class="fixed inset-0 bg-zinc-950 bg-opacity-75 transition-opacity"
|
class="fixed inset-0 bg-zinc-950/75"
|
||||||
/>
|
/>
|
||||||
</TransitionChild>
|
|
||||||
|
|
||||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||||
<div
|
<div
|
||||||
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||||
>
|
>
|
||||||
<TransitionChild
|
|
||||||
as="template"
|
|
||||||
enter="ease-out duration-300"
|
|
||||||
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
||||||
enter-to="opacity-100 translate-y-0 sm:scale-100"
|
|
||||||
leave="ease-in duration-200"
|
|
||||||
leave-from="opacity-100 translate-y-0 sm:scale-100"
|
|
||||||
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
||||||
>
|
>
|
||||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
||||||
<DialogTitle
|
<h3
|
||||||
as="h3"
|
|
||||||
class="text-base font-semibold text-zinc-100"
|
class="text-base font-semibold text-zinc-100"
|
||||||
>{{ props.data.title }}
|
>{{ props.data.title }}
|
||||||
</DialogTitle>
|
</h3>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="text-sm text-zinc-400">
|
<p class="text-sm text-zinc-400">
|
||||||
{{ props.data.description }}
|
{{ props.data.description }}
|
||||||
@ -60,15 +35,13 @@
|
|||||||
type="submit"
|
type="submit"
|
||||||
class="w-full sm:w-fit"
|
class="w-full sm:w-fit"
|
||||||
>
|
>
|
||||||
{{ props.data.buttonText ?? "Confirm" }}
|
{{ props.data.buttonText ?? "Close" }}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TransitionChild>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</div>
|
||||||
</TransitionRoot>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
87
components/TextInputModal.vue
Normal file
87
components/TextInputModal.vue
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<template>
|
||||||
|
<div class="relative z-50" @close="emit('event', 'cancel')">
|
||||||
|
<div class="fixed inset-0 bg-zinc-950/75" />
|
||||||
|
|
||||||
|
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||||
|
<div
|
||||||
|
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
||||||
|
>
|
||||||
|
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||||
|
<div class="sm:flex sm:items-start">
|
||||||
|
<div class="mt-3 text-center sm:mt-0 sm:text-left w-full">
|
||||||
|
<h3 class="text-base font-semibold text-zinc-100">
|
||||||
|
{{ props.data.title }}
|
||||||
|
</h3>
|
||||||
|
<div class="mt-1">
|
||||||
|
<p class="text-sm text-zinc-400">
|
||||||
|
{{ props.data.description }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<form
|
||||||
|
class="mt-4 w-full"
|
||||||
|
@submit.prevent="() => emit('event', 'submit', v)"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="v"
|
||||||
|
type="text"
|
||||||
|
:placeholder="props.data.placeholder"
|
||||||
|
class="block w-full rounded-md border-0 bg-zinc-800 py-1.5 text-white shadow-sm ring-1 ring-inset ring-zinc-700 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||||
|
/>
|
||||||
|
<button class="hidden" type="submit" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
||||||
|
>
|
||||||
|
<LoadingButton
|
||||||
|
:loading="props.loading"
|
||||||
|
@click="emit('event', 'submit', v)"
|
||||||
|
type="submit"
|
||||||
|
class="w-full sm:w-fit"
|
||||||
|
>
|
||||||
|
{{ props.data.buttonText ?? "Submit" }}
|
||||||
|
</LoadingButton>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||||
|
@click="emit('event', 'cancel')"
|
||||||
|
ref="cancelButtonRef"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogTitle,
|
||||||
|
TransitionChild,
|
||||||
|
TransitionRoot,
|
||||||
|
} from "@headlessui/vue";
|
||||||
|
import type {
|
||||||
|
ModalDatas,
|
||||||
|
ModalEvents,
|
||||||
|
ModalType,
|
||||||
|
} from "../composables/modal-stack";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
zHeight: number;
|
||||||
|
loading: boolean;
|
||||||
|
data: ModalDatas[ModalType.TextInput];
|
||||||
|
}>();
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: "event", v: ModalEvents[ModalType.TextInput], s?: string): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const v = ref(props.data.dft || "");
|
||||||
|
</script>
|
||||||
@ -1,10 +1,12 @@
|
|||||||
import type { Component } from "vue";
|
import type { Component } from "vue";
|
||||||
import ConfirmationModal from "../components/ConfirmationModal.vue";
|
import ConfirmationModal from "../components/ConfirmationModal.vue";
|
||||||
import NotificationModal from "../components/NotificationModal.vue";
|
import NotificationModal from "../components/NotificationModal.vue";
|
||||||
|
import TextInputModal from "../components/TextInputModal.vue";
|
||||||
|
|
||||||
export type ModalCallbackType<T extends ModalType> = (
|
export type ModalCallbackType<T extends ModalType> = (
|
||||||
event: ModalEvents[T],
|
event: ModalEvents[T],
|
||||||
close: () => void
|
close: () => void,
|
||||||
|
...args: any[]
|
||||||
) => Promise<void> | void;
|
) => Promise<void> | void;
|
||||||
|
|
||||||
export interface ModalStackElement<T extends ModalType> {
|
export interface ModalStackElement<T extends ModalType> {
|
||||||
@ -18,11 +20,13 @@ export interface ModalStackElement<T extends ModalType> {
|
|||||||
export enum ModalType {
|
export enum ModalType {
|
||||||
Confirmation,
|
Confirmation,
|
||||||
Notification,
|
Notification,
|
||||||
|
TextInput
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ModalEvents = {
|
export type ModalEvents = {
|
||||||
[ModalType.Confirmation]: "confirm" | "cancel";
|
[ModalType.Confirmation]: "confirm" | "cancel";
|
||||||
[ModalType.Notification]: "close";
|
[ModalType.Notification]: "close";
|
||||||
|
[ModalType.TextInput]: "cancel" | "submit"
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModalDatas = {
|
export type ModalDatas = {
|
||||||
@ -36,11 +40,19 @@ export type ModalDatas = {
|
|||||||
description: string;
|
description: string;
|
||||||
buttonText?: string;
|
buttonText?: string;
|
||||||
};
|
};
|
||||||
|
[ModalType.TextInput]: {
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
buttonText?: string,
|
||||||
|
dft?: string,
|
||||||
|
placeholder?: string,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const modalComponents: { [key in ModalType]: Component } = {
|
const modalComponents: { [key in ModalType]: Component } = {
|
||||||
[ModalType.Confirmation]: ConfirmationModal,
|
[ModalType.Confirmation]: ConfirmationModal,
|
||||||
[ModalType.Notification]: NotificationModal,
|
[ModalType.Notification]: NotificationModal,
|
||||||
|
[ModalType.TextInput]: TextInputModal,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createModal<T extends ModalType>(
|
export function createModal<T extends ModalType>(
|
||||||
|
|||||||
@ -1,6 +1,2 @@
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({});
|
||||||
devtools: { enabled: true },
|
|
||||||
modules: ["@nuxtjs/tailwindcss"],
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/eslint": "latest",
|
"@nuxt/eslint": "latest",
|
||||||
"@nuxtjs/tailwindcss": "6.12.2",
|
|
||||||
"eslint": "^9.17.0",
|
"eslint": "^9.17.0",
|
||||||
"nuxt": "^3.14.1592",
|
"nuxt": "^3.14.1592",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
|
||||||
export default {
|
|
||||||
content: [],
|
|
||||||
theme: {
|
|
||||||
extend: {},
|
|
||||||
},
|
|
||||||
plugins: [],
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./.playground/.nuxt/tsconfig.json"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user