adminforth 2.22.0-next.27 → 2.22.0-next.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,18 @@
1
1
  <template>
2
2
  <div
3
3
  v-if="$slots.trigger"
4
- @click="modal?.show()" class="inline-flex items-center cursor-pointer w-full"
4
+ @click="toggleModal()" class="inline-flex items-center cursor-pointer w-full"
5
5
  >
6
6
  <slot name="trigger"></slot>
7
7
  </div>
8
8
  <Teleport to="body">
9
- <div ref="modalEl" tabindex="-1" aria-hidden="true" class="[scrollbar-gutter:stable] hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-full max-h-full">
10
- <div v-bind="$attrs" class="relative p-4 max-h-full">
9
+ <div v-show="isModalOpen" v-if="!removeFromDom" @click="backdropClick" v-bind="$attrs" class="bg-black/50 overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-1rem max-h-full flex" >
11
10
  <!-- Modal content -->
12
11
  <div class="relative bg-lightDialogBackgorund rounded-lg shadow-sm dark:bg-darkDialogBackgorund">
13
12
 
14
13
  <!-- Modal body -->
15
14
  <div class="p-4 md:p-5 space-y-4 text-lightDialogBodyText dark:text-darkDialogBodyText">
16
- <slot></slot>
15
+ <slot ></slot>
17
16
  </div>
18
17
 
19
18
  <!-- Confirmation Modal -->
@@ -34,7 +33,7 @@
34
33
  <Button
35
34
  @click="
36
35
  showConfirmationOnClose = false;
37
- modal?.hide();
36
+ close();
38
37
  "
39
38
  >
40
39
  Confirm
@@ -44,97 +43,48 @@
44
43
  </div>
45
44
  </div>
46
45
  </div>
47
- </div>
48
46
  </Teleport>
49
47
  </template>
50
48
 
51
49
  <script setup lang="ts">
52
50
  import Button from "./Button.vue";
53
51
  import { ref, onMounted, nextTick, onUnmounted, computed, type Ref } from 'vue';
54
- import { Modal } from 'flowbite';
55
52
 
56
- const modalEl = ref(null);
57
- const modal: Ref<Modal|null> = ref(null);
53
+ const isModalOpen = ref(false);
58
54
 
59
- interface DialogButton {
60
- label: string
61
- onclick: (dialog: any) => void
62
- options?: Record<string, any>
63
- }
55
+ const removeFromDom = computed(() => {
56
+ return props.removeFromDomOnClose && !isModalOpen.value;
57
+ })
64
58
 
65
59
  interface DialogProps {
66
- buttons?: DialogButton[]
67
60
  clickToCloseOutside?: boolean
68
61
  beforeCloseFunction?: (() => void | Promise<void>) | null
69
62
  beforeOpenFunction?: (() => void | Promise<void>) | null
70
- closable?: boolean
71
63
  askForCloseConfirmation?: boolean
72
64
  closeConfirmationText?: string
65
+ removeFromDomOnClose?: boolean
73
66
  }
74
67
 
75
68
  const props = withDefaults(defineProps<DialogProps>(), {
76
- buttons: () => [],
77
69
  clickToCloseOutside: true,
78
70
  beforeCloseFunction: null,
79
71
  beforeOpenFunction: null,
80
- closable: true,
81
72
  askForCloseConfirmation: false,
82
73
  closeConfirmationText: 'Are you sure you want to close this dialog?',
74
+ removeFromDomOnClose: false,
83
75
  })
84
76
 
85
- const buttons = computed<DialogButton[]>(() => {
86
- if (props.buttons && props.buttons.length > 0) {
87
- return props.buttons;
88
- }
89
- return [
90
- {
91
- label: 'Close',
92
- onclick: (dialog: any) => {
93
- if (!props.askForCloseConfirmation) {
94
- dialog.hide();
95
- } else {
96
- showConfirmationOnClose.value = true;
97
- }
98
- },
99
- options: {}
100
- }
101
- ];
102
- });
103
-
104
77
  const showConfirmationOnClose = ref(false);
105
- onMounted(async () => {
106
- //await one tick when all is mounted
107
- await nextTick();
108
- modal.value = new Modal(
109
- modalEl.value,
110
- {
111
- closable: props.closable,
112
- backdrop: props.clickToCloseOutside ? 'dynamic' : 'static',
113
- onHide: async () => {
114
- if (props.beforeCloseFunction) {
115
- await props.beforeCloseFunction();
116
- }
117
- },
118
- onShow: async () => {
119
- if (props.beforeOpenFunction) {
120
- await props.beforeOpenFunction();
121
- }
122
- },
123
- }
124
- );
125
- })
126
78
 
127
- onUnmounted(() => {
128
- //destroy tooltip
129
- modal.value?.destroy();
130
- })
131
79
 
132
- function open() {
133
- modal.value?.show();
80
+ async function open() {
81
+ await props.beforeOpenFunction?.();
82
+ isModalOpen.value = true;
134
83
  }
135
84
 
136
- function close() {
137
- modal.value?.hide();
85
+ async function close() {
86
+ await props.beforeCloseFunction?.();
87
+ isModalOpen.value = false;
138
88
  }
139
89
 
140
90
  defineExpose({
@@ -145,11 +95,24 @@ defineExpose({
145
95
 
146
96
  function tryToHideModal() {
147
97
  if (!props.askForCloseConfirmation ) {
148
- modal.value?.hide();
98
+ close();
149
99
  } else {
150
100
  showConfirmationOnClose.value = true;
151
101
  }
152
102
  }
153
103
 
104
+ function toggleModal() {
105
+ if (isModalOpen.value) {
106
+ tryToHideModal();
107
+ } else {
108
+ open();
109
+ }
110
+ }
111
+
112
+ function backdropClick(e: MouseEvent) {
113
+ if (props.clickToCloseOutside && e.target === e.currentTarget) {
114
+ tryToHideModal();
115
+ }
116
+ }
154
117
 
155
118
  </script>
@@ -1,13 +1,13 @@
1
1
  <template>
2
- <div class="relative w-full max-w-[700px] bg-lightProgressBarUnfilledColor rounded-full h-2.5 dark:bg-darkProgressBarUnfilledColor" :class="props.height ? `h-${props.height}` : ''">
3
- <span class="absolute -top-6 left-0 text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ leftLabel }}</span>
4
- <span class="absolute -top-6 right-0 text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ rightLabel }}</span>
2
+ <div class="relative w-full bg-lightProgressBarUnfilledColor rounded-full h-2.5 dark:bg-darkProgressBarUnfilledColor" :class="props.height ? `h-${props.height}` : ''">
3
+ <span v-if="leftLabel" class="absolute -top-6 left-0 text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ leftLabel }}</span>
4
+ <span v-if="rightLabel" class="absolute -top-6 right-0 text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ rightLabel }}</span>
5
5
  <div
6
6
  class="bg-lightProgressBarFilledColor dark:bg-darkProgressBarFilledColor h-2.5 rounded-full transition-all duration-300 ease-in-out"
7
7
  :class="{ 'progress-bar': showAnimation, [`h-${props.height}`]: props.height }"
8
8
  :style="{ width: `${percentage}%` }"
9
9
  ></div>
10
- <div class="flex justify-between mt-2">
10
+ <div v-if="showValues || showProgress" class="flex justify-between mt-2">
11
11
  <span v-if="showValues" class="text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ formatValue(minValue) }}</span>
12
12
  <span v-if="showProgress" class="text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ progressText }}</span>
13
13
  <span v-if="showValues" class="text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ formatValue(maxValue) }}</span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.22.0-next.27",
3
+ "version": "2.22.0-next.29",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",