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