@aerogel/core 0.1.1-next.7fce7b4ce55cfb9c329a7746f571015aedc8e3bd → 0.1.1-next.97f5cf5c97f16ab8a0ef63b82aaab049a0f9e15b
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.
- package/dist/aerogel-core.d.ts +42 -10
- package/dist/aerogel-core.js +701 -688
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AppOverlays.vue +1 -1
- package/src/components/headless/HeadlessModal.vue +3 -12
- package/src/components/headless/HeadlessModalContent.vue +1 -1
- package/src/components/ui/Modal.vue +2 -2
- package/src/ui/UI.ts +2 -2
- package/src/ui/index.ts +1 -1
- package/src/ui/modals.ts +36 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DialogRoot :ref="forwardRef" open @update:open="persistent || close()">
|
|
2
|
+
<DialogRoot :ref="forwardRef" open @update:open="persistent || $event || close()">
|
|
3
3
|
<DialogPortal>
|
|
4
4
|
<slot :close />
|
|
5
5
|
</DialogPortal>
|
|
@@ -7,18 +7,17 @@
|
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script setup lang="ts" generic="T = void">
|
|
10
|
-
import { after } from '@noeldemartin/utils';
|
|
11
10
|
import { DialogPortal, DialogRoot, useForwardExpose } from 'reka-ui';
|
|
12
11
|
import { provide, ref } from 'vue';
|
|
13
|
-
import { useModal } from '@noeldemartin/vue-modals';
|
|
14
12
|
import type { DialogContent } from 'reka-ui';
|
|
15
13
|
import type { Nullable } from '@noeldemartin/utils';
|
|
16
14
|
|
|
15
|
+
import { useModal } from '@aerogel/core/ui/modals';
|
|
17
16
|
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
18
17
|
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
19
18
|
|
|
20
19
|
const $content = ref<Nullable<InstanceType<typeof DialogContent>>>(null);
|
|
21
|
-
const
|
|
20
|
+
const { close } = useModal<T>();
|
|
22
21
|
|
|
23
22
|
defineProps<ModalProps>();
|
|
24
23
|
defineSlots<ModalSlots<T>>();
|
|
@@ -27,12 +26,4 @@ defineExpose<AcceptRefs<ModalExpose>>({ $content });
|
|
|
27
26
|
const { forwardRef } = useForwardExpose();
|
|
28
27
|
|
|
29
28
|
provide('$modalContentRef', $content);
|
|
30
|
-
|
|
31
|
-
async function close(result?: T) {
|
|
32
|
-
modal.close(result);
|
|
33
|
-
|
|
34
|
-
await after(1000);
|
|
35
|
-
|
|
36
|
-
modal.remove();
|
|
37
|
-
}
|
|
38
29
|
</script>
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
<script setup lang="ts">
|
|
10
10
|
import { useTemplateRef, watchEffect } from 'vue';
|
|
11
11
|
import { DialogContent } from 'reka-ui';
|
|
12
|
-
import { ModalComponent, useModal } from '@noeldemartin/vue-modals';
|
|
13
12
|
import type { Ref } from 'vue';
|
|
14
13
|
|
|
14
|
+
import { ModalComponent, useModal } from '@aerogel/core/ui/modals';
|
|
15
15
|
import { injectOrFail } from '@aerogel/core/utils/vue';
|
|
16
16
|
import type { ModalContentInstance } from '@aerogel/core/components/contracts/Modal';
|
|
17
17
|
|
|
@@ -58,8 +58,6 @@ import IconClose from '~icons/zondicons/close';
|
|
|
58
58
|
|
|
59
59
|
import { useForwardExpose } from 'reka-ui';
|
|
60
60
|
import { computed, onMounted } from 'vue';
|
|
61
|
-
import { injectModal, modals, useModal } from '@noeldemartin/vue-modals';
|
|
62
|
-
import type { ModalController } from '@noeldemartin/vue-modals';
|
|
63
61
|
import type { ComponentPublicInstance, HTMLAttributes, Ref } from 'vue';
|
|
64
62
|
import { type Nullable, after } from '@noeldemartin/utils';
|
|
65
63
|
|
|
@@ -71,6 +69,8 @@ import HeadlessModalOverlay from '@aerogel/core/components/headless/HeadlessModa
|
|
|
71
69
|
import HeadlessModalTitle from '@aerogel/core/components/headless/HeadlessModalTitle.vue';
|
|
72
70
|
import { classes } from '@aerogel/core/utils/classes';
|
|
73
71
|
import { reactiveSet } from '@aerogel/core/utils';
|
|
72
|
+
import { injectModal, modals, useModal } from '@aerogel/core/ui/modals';
|
|
73
|
+
import type { ModalController } from '@aerogel/core/ui/modals';
|
|
74
74
|
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
75
75
|
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
76
76
|
|
package/src/ui/UI.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { after, facade, fail, isDevelopment, uuid } from '@noeldemartin/utils';
|
|
2
2
|
import { markRaw, unref } from 'vue';
|
|
3
|
-
import { closeModal, createModal, modals, showModal } from '@noeldemartin/vue-modals';
|
|
4
3
|
import type { Constructor } from '@noeldemartin/utils';
|
|
5
4
|
import type { Component, ComputedOptions, MethodOptions } from 'vue';
|
|
6
|
-
import type { GetModalProps, GetModalResponse } from '@noeldemartin/vue-modals';
|
|
7
5
|
|
|
8
6
|
import Events from '@aerogel/core/services/Events';
|
|
7
|
+
import { closeModal, createModal, modals, showModal } from '@aerogel/core/ui/modals';
|
|
8
|
+
import type { GetModalProps, GetModalResponse } from '@aerogel/core/ui/modals';
|
|
9
9
|
import type { AcceptRefs } from '@aerogel/core/utils';
|
|
10
10
|
import type { AlertModalExpose, AlertModalProps } from '@aerogel/core/components/contracts/AlertModal';
|
|
11
11
|
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
package/src/ui/index.ts
CHANGED
|
@@ -14,10 +14,10 @@ import type { Component } from 'vue';
|
|
|
14
14
|
|
|
15
15
|
const services = { $ui: UI };
|
|
16
16
|
|
|
17
|
+
export * from './modals';
|
|
17
18
|
export * from './UI';
|
|
18
19
|
export * from './utils';
|
|
19
20
|
export { default as UI } from './UI';
|
|
20
|
-
export { useModal } from '@noeldemartin/vue-modals';
|
|
21
21
|
|
|
22
22
|
export type UIServices = typeof services;
|
|
23
23
|
|
package/src/ui/modals.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { after } from '@noeldemartin/utils';
|
|
2
|
+
import { injectModal, useModal as useModalBase } from '@noeldemartin/vue-modals';
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
createModal,
|
|
6
|
+
showModal,
|
|
7
|
+
injectModal,
|
|
8
|
+
closeModal,
|
|
9
|
+
modals,
|
|
10
|
+
ModalComponent,
|
|
11
|
+
ModalsPortal,
|
|
12
|
+
type GetModalProps,
|
|
13
|
+
type GetModalResponse,
|
|
14
|
+
type ModalController,
|
|
15
|
+
} from '@noeldemartin/vue-modals';
|
|
16
|
+
|
|
17
|
+
const instances = new WeakSet();
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
20
|
+
export function useModal<T = never>() {
|
|
21
|
+
const instance = injectModal<T>();
|
|
22
|
+
const { close, remove, ...modal } = useModalBase<T>(instances.has(instance) ? {} : { removeOnClose: false });
|
|
23
|
+
|
|
24
|
+
instances.add(instance);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
...modal,
|
|
28
|
+
async close(result?: T) {
|
|
29
|
+
close(result);
|
|
30
|
+
|
|
31
|
+
await after(1000);
|
|
32
|
+
|
|
33
|
+
remove();
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|