|
1 | 1 | <template>
|
2 | 2 | <slot v-if="$slots.toggle" name="toggle" v-bind="{ toggleModal, model }"></slot>
|
3 |
| - <dialog |
4 |
| - v-if="!disabled" |
5 |
| - :id="modalId" |
6 |
| - :key="modalId" |
7 |
| - ref="modalRef" |
8 |
| - @close="closeModal" |
9 |
| - @mousedown="clickOutside" |
10 |
| - > |
11 |
| - <div |
12 |
| - v-show="!loading && !hide" |
13 |
| - class="modal" |
14 |
| - role="document" |
15 |
| - :class="[modalClass ?? 'flx --flxColumn --flx-start-stretch --width', themeClasses]" |
16 |
| - v-bind="$attrs" |
17 |
| - > |
18 |
| - <slot name="modal-header" v-bind="{ toggleModal, model, invertedTheme }"> |
19 |
| - <div v-if="title" class="flx --flxRow --flx-between-center"> |
20 |
| - <div class="txt --gaping-none"> |
21 |
| - <h5>{{ title }}</h5> |
22 |
| - <p v-if="subtitle" class="--txtSize-xs">{{ subtitle }}</p> |
| 3 | + <BaseWrapper v-if="!disabled" :key="modalId" :el="Teleport" :wrap="!!target" :to="target"> |
| 4 | + <dialog :id="modalId" ref="modalRef" @close="closeModal" @mousedown="clickOutside"> |
| 5 | + <div |
| 6 | + v-show="!loading && !hide" |
| 7 | + class="modal" |
| 8 | + role="document" |
| 9 | + :class="[modalClass ?? 'flx --flxColumn --flx-start-stretch --width', themeClasses]" |
| 10 | + v-bind="$attrs" |
| 11 | + > |
| 12 | + <slot name="modal-header" v-bind="{ toggleModal, model, invertedTheme }"> |
| 13 | + <div v-if="title" class="flx --flxRow --flx-between-center"> |
| 14 | + <div class="txt --gaping-none"> |
| 15 | + <h5>{{ title }}</h5> |
| 16 | + <p v-if="subtitle" class="--txtSize-xs">{{ subtitle }}</p> |
| 17 | + </div> |
| 18 | + <ActionLink |
| 19 | + :theme="invertedTheme" |
| 20 | + :aria-label="cancelButtonOptions.title" |
| 21 | + @click.stop="closeModal()" |
| 22 | + > |
| 23 | + <IconFa name="xmark" size="20" /> |
| 24 | + </ActionLink> |
23 | 25 | </div>
|
24 |
| - <ActionLink |
25 |
| - :theme="invertedTheme" |
26 |
| - :aria-label="cancelButtonOptions.title" |
27 |
| - @click.stop="closeModal()" |
28 |
| - > |
29 |
| - <IconFa name="xmark" size="20" /> |
30 |
| - </ActionLink> |
| 26 | + </slot> |
| 27 | + <div class="scroll --vertical"> |
| 28 | + <!-- Main modal content --> |
| 29 | + <slot v-bind="{ toggleModal, model, invertedTheme }"></slot> |
31 | 30 | </div>
|
32 |
| - </slot> |
33 |
| - <div class="scroll --vertical"> |
34 |
| - <!-- Main modal content --> |
35 |
| - <slot v-bind="{ toggleModal, model, invertedTheme }"></slot> |
| 31 | + <slot name="modal-footer" v-bind="{ toggleModal, model, invertedTheme }"> |
| 32 | + <div v-if="!hideFooter" class="flx --flxRow --flx-end-center"> |
| 33 | + <ActionButton |
| 34 | + v-if="saveButtonOptions.visible" |
| 35 | + :theme="invertedTheme" |
| 36 | + :aria-label="saveButtonOptions.title" |
| 37 | + :class="saveButtonOptions.btnClass" |
| 38 | + @click="emit('save', closeModal, $event)" |
| 39 | + > |
| 40 | + {{ saveButtonOptions.title }} |
| 41 | + </ActionButton> |
| 42 | + <ActionButtonToggle |
| 43 | + v-if="cancelButtonOptions.visible" |
| 44 | + :theme="invertedTheme" |
| 45 | + :aria-label="cancelButtonOptions.title" |
| 46 | + :class="cancelButtonOptions.btnClass" |
| 47 | + data-dismiss="modal" |
| 48 | + round=":sm-inv" |
| 49 | + @click.stop="closeModal()" |
| 50 | + > |
| 51 | + <IconFa name="xmark" hidden="-full:sm" /> |
| 52 | + <IconFa name="xmark" regular hidden="-full:sm" /> |
| 53 | + <span class="--hidden-full:sm-inv"> |
| 54 | + {{ cancelButtonOptions.title }} |
| 55 | + </span> |
| 56 | + </ActionButtonToggle> |
| 57 | + </div> |
| 58 | + </slot> |
36 | 59 | </div>
|
37 |
| - <slot name="modal-footer" v-bind="{ toggleModal, model, invertedTheme }"> |
38 |
| - <div v-if="!hideFooter" class="flx --flxRow --flx-end-center"> |
39 |
| - <ActionButton |
40 |
| - v-if="saveButtonOptions.visible" |
41 |
| - :theme="invertedTheme" |
42 |
| - :aria-label="saveButtonOptions.title" |
43 |
| - :class="saveButtonOptions.btnClass" |
44 |
| - @click="emit('save', closeModal, $event)" |
| 60 | + <LoaderSimple v-if="loading || hide" :theme="invertedTheme"> |
| 61 | + <transition name="fade"> |
| 62 | + <div |
| 63 | + v-if="loadingTooLong || (props.hide && props.hideMessage)" |
| 64 | + class="txt --txtAlignFlx-center --gaping-5" |
45 | 65 | >
|
46 |
| - {{ saveButtonOptions.title }} |
47 |
| - </ActionButton> |
48 |
| - <ActionButtonToggle |
49 |
| - v-if="cancelButtonOptions.visible" |
50 |
| - :theme="invertedTheme" |
51 |
| - :aria-label="cancelButtonOptions.title" |
52 |
| - :class="cancelButtonOptions.btnClass" |
53 |
| - data-dismiss="modal" |
54 |
| - round=":sm-inv" |
55 |
| - @click.stop="closeModal()" |
56 |
| - > |
57 |
| - <IconFa name="xmark" hidden="-full:sm" /> |
58 |
| - <IconFa name="xmark" regular hidden="-full:sm" /> |
59 |
| - <span class="--hidden-full:sm-inv"> |
60 |
| - {{ cancelButtonOptions.title }} |
61 |
| - </span> |
62 |
| - </ActionButtonToggle> |
63 |
| - </div> |
64 |
| - </slot> |
65 |
| - </div> |
66 |
| - <LoaderSimple v-if="loading || hide" :theme="invertedTheme"> |
67 |
| - <transition name="fade"> |
68 |
| - <div |
69 |
| - v-if="loadingTooLong || (props.hide && props.hideMessage)" |
70 |
| - class="txt --txtAlignFlx-center --gaping-5" |
71 |
| - > |
72 |
| - <p class="--txtColor-light --txtShadow --txtSize-sm"> |
73 |
| - {{ props.hideMessage ? props.hideMessage : t("modal_taking_too_long") }} |
74 |
| - </p> |
75 |
| - <ActionButton |
76 |
| - :theme="invertedTheme" |
77 |
| - :aria-label="t('close')" |
78 |
| - @click="closeModal()" |
79 |
| - > |
80 |
| - {{ t("close") }} |
81 |
| - </ActionButton> |
82 |
| - </div> |
83 |
| - </transition> |
84 |
| - </LoaderSimple> |
85 |
| - </dialog> |
| 66 | + <p class="--txtColor-light --txtShadow --txtSize-sm"> |
| 67 | + {{ props.hideMessage ? props.hideMessage : t("modal_taking_too_long") }} |
| 68 | + </p> |
| 69 | + <ActionButton |
| 70 | + :theme="invertedTheme" |
| 71 | + :aria-label="t('close')" |
| 72 | + @click="closeModal()" |
| 73 | + > |
| 74 | + {{ t("close") }} |
| 75 | + </ActionButton> |
| 76 | + </div> |
| 77 | + </transition> |
| 78 | + </LoaderSimple> |
| 79 | + </dialog> |
| 80 | + </BaseWrapper> |
86 | 81 | <slot v-else v-bind="{ toggleModal, model, invertedTheme }"></slot>
|
87 | 82 | </template>
|
88 | 83 |
|
89 | 84 | <script setup lang="ts">
|
90 |
| - import { computed, onMounted, onUnmounted, ref, watch } from "vue"; |
| 85 | + import { |
| 86 | + computed, |
| 87 | + onMounted, |
| 88 | + onUnmounted, |
| 89 | + ref, |
| 90 | + watch, |
| 91 | + Teleport, |
| 92 | + type RendererElement, |
| 93 | + } from "vue"; |
91 | 94 | import _ from "lodash";
|
92 | 95 |
|
93 | 96 | import { useI18n, useSwal } from "@open-xamu-co/ui-common-helpers";
|
94 | 97 |
|
| 98 | + import BaseWrapper from "./base/Wrapper.vue"; |
95 | 99 | import IconFa from "./icon/Fa.vue";
|
96 | 100 | import ActionLink from "./action/Link.vue";
|
97 | 101 | import ActionButton from "./action/Button.vue";
|
|
151 | 155 | * @private
|
152 | 156 | */
|
153 | 157 | modelValue?: boolean;
|
| 158 | + target?: string | RendererElement; |
154 | 159 | }
|
155 | 160 |
|
156 | 161 | /**
|
|
0 commit comments