|
1 | 1 | <template>
|
2 | 2 | <slot v-if="$slots.toggle" name="toggle" v-bind="{ toggleModal, model }"></slot>
|
3 |
| - <Teleport v-if="!disabled" :id="modalId" :key="modalId" :to="target || 'body'"> |
4 |
| - <dialog 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> |
| 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> |
25 | 23 | </div>
|
26 |
| - </slot> |
27 |
| - <div class="scroll --vertical"> |
28 |
| - <!-- Main modal content --> |
29 |
| - <slot v-bind="{ toggleModal, model, invertedTheme }"></slot> |
| 24 | + <ActionLink |
| 25 | + :theme="invertedTheme" |
| 26 | + :aria-label="cancelButtonOptions.title" |
| 27 | + @click.stop="closeModal()" |
| 28 | + > |
| 29 | + <IconFa name="xmark" size="20" /> |
| 30 | + </ActionLink> |
30 | 31 | </div>
|
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> |
| 32 | + </slot> |
| 33 | + <div class="scroll --vertical"> |
| 34 | + <!-- Main modal content --> |
| 35 | + <slot v-bind="{ toggleModal, model, invertedTheme }"></slot> |
59 | 36 | </div>
|
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" |
| 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)" |
65 | 45 | >
|
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 |
| - </Teleport> |
| 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> |
81 | 86 | <slot v-else v-bind="{ toggleModal, model, invertedTheme }"></slot>
|
82 | 87 | </template>
|
83 | 88 |
|
84 | 89 | <script setup lang="ts">
|
85 |
| - import { type RendererElement, computed, onMounted, onUnmounted, ref, watch } from "vue"; |
| 90 | + import { computed, onMounted, onUnmounted, ref, watch } from "vue"; |
86 | 91 | import _ from "lodash";
|
87 | 92 |
|
88 | 93 | import { useI18n, useSwal } from "@open-xamu-co/ui-common-helpers";
|
|
146 | 151 | * @private
|
147 | 152 | */
|
148 | 153 | modelValue?: boolean;
|
149 |
| - target?: string | RendererElement; |
150 | 154 | }
|
151 | 155 |
|
152 | 156 | /**
|
|
0 commit comments