@shwfed/nuxt 0.11.17 → 0.11.19
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/module.json +1 -1
- package/dist/runtime/components/modal.d.vue.ts +10 -8
- package/dist/runtime/components/modal.vue +11 -1
- package/dist/runtime/components/modal.vue.d.ts +10 -8
- package/dist/runtime/components/ui/app/OverlayHost.vue +9 -1
- package/dist/runtime/components/ui/buttons/button-action.types.d.ts +6 -0
- package/dist/runtime/components/ui/buttons/button-action.types.js +26 -0
- package/dist/runtime/composables/useButtonAction.d.ts +2 -1
- package/dist/runtime/composables/useOverlay.d.ts +2 -0
- package/dist/runtime/composables/useOverlay.js +31 -17
- package/dist/runtime/plugins/toast/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -9,34 +9,36 @@ declare function close(): void;
|
|
|
9
9
|
declare var __VLS_14: {
|
|
10
10
|
close: typeof close;
|
|
11
11
|
isDesktop: boolean;
|
|
12
|
-
},
|
|
12
|
+
}, __VLS_36: {
|
|
13
13
|
close: typeof close;
|
|
14
14
|
isDesktop: boolean;
|
|
15
|
-
},
|
|
15
|
+
}, __VLS_44: {
|
|
16
16
|
close: typeof close;
|
|
17
17
|
isDesktop: boolean;
|
|
18
|
-
},
|
|
18
|
+
}, __VLS_46: {
|
|
19
19
|
close: typeof close;
|
|
20
20
|
isDesktop: boolean;
|
|
21
|
-
},
|
|
21
|
+
}, __VLS_54: {
|
|
22
22
|
close: typeof close;
|
|
23
23
|
isDesktop: boolean;
|
|
24
24
|
};
|
|
25
25
|
type __VLS_Slots = {} & {
|
|
26
26
|
trigger?: (props: typeof __VLS_14) => any;
|
|
27
27
|
} & {
|
|
28
|
-
title?: (props: typeof
|
|
28
|
+
title?: (props: typeof __VLS_36) => any;
|
|
29
29
|
} & {
|
|
30
|
-
description?: (props: typeof
|
|
30
|
+
description?: (props: typeof __VLS_44) => any;
|
|
31
31
|
} & {
|
|
32
|
-
default?: (props: typeof
|
|
32
|
+
default?: (props: typeof __VLS_46) => any;
|
|
33
33
|
} & {
|
|
34
|
-
footer?: (props: typeof
|
|
34
|
+
footer?: (props: typeof __VLS_54) => any;
|
|
35
35
|
};
|
|
36
36
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
37
37
|
"update:open": (open: boolean) => any;
|
|
38
|
+
"after-close": () => any;
|
|
38
39
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
39
40
|
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
41
|
+
"onAfter-close"?: (() => any) | undefined;
|
|
40
42
|
}>, {
|
|
41
43
|
showCloseButton: boolean;
|
|
42
44
|
breakpoint: string;
|
|
@@ -31,7 +31,7 @@ const props = defineProps({
|
|
|
31
31
|
showCloseButton: { type: Boolean, required: false, default: true },
|
|
32
32
|
dismissible: { type: Boolean, required: false, default: true }
|
|
33
33
|
});
|
|
34
|
-
const emit = defineEmits(["update:open"]);
|
|
34
|
+
const emit = defineEmits(["update:open", "after-close"]);
|
|
35
35
|
const attrs = useAttrs();
|
|
36
36
|
const slots = useSlots();
|
|
37
37
|
const uncontrolledOpen = ref(props.defaultOpen);
|
|
@@ -76,6 +76,15 @@ const open = computed({
|
|
|
76
76
|
function close() {
|
|
77
77
|
open.value = false;
|
|
78
78
|
}
|
|
79
|
+
function isClosedContentTarget(target) {
|
|
80
|
+
return target instanceof HTMLElement && target.dataset.state === "closed";
|
|
81
|
+
}
|
|
82
|
+
function handleContentAnimationEnd(event) {
|
|
83
|
+
if (open.value || event.target !== event.currentTarget || !isClosedContentTarget(event.currentTarget)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
emit("after-close");
|
|
87
|
+
}
|
|
79
88
|
</script>
|
|
80
89
|
|
|
81
90
|
<template>
|
|
@@ -99,6 +108,7 @@ function close() {
|
|
|
99
108
|
:is="modalComponents.Content"
|
|
100
109
|
v-bind="attrs"
|
|
101
110
|
:show-close-button="props.showCloseButton"
|
|
111
|
+
@animationend="handleContentAnimationEnd"
|
|
102
112
|
>
|
|
103
113
|
<component
|
|
104
114
|
:is="modalComponents.Header"
|
|
@@ -9,34 +9,36 @@ declare function close(): void;
|
|
|
9
9
|
declare var __VLS_14: {
|
|
10
10
|
close: typeof close;
|
|
11
11
|
isDesktop: boolean;
|
|
12
|
-
},
|
|
12
|
+
}, __VLS_36: {
|
|
13
13
|
close: typeof close;
|
|
14
14
|
isDesktop: boolean;
|
|
15
|
-
},
|
|
15
|
+
}, __VLS_44: {
|
|
16
16
|
close: typeof close;
|
|
17
17
|
isDesktop: boolean;
|
|
18
|
-
},
|
|
18
|
+
}, __VLS_46: {
|
|
19
19
|
close: typeof close;
|
|
20
20
|
isDesktop: boolean;
|
|
21
|
-
},
|
|
21
|
+
}, __VLS_54: {
|
|
22
22
|
close: typeof close;
|
|
23
23
|
isDesktop: boolean;
|
|
24
24
|
};
|
|
25
25
|
type __VLS_Slots = {} & {
|
|
26
26
|
trigger?: (props: typeof __VLS_14) => any;
|
|
27
27
|
} & {
|
|
28
|
-
title?: (props: typeof
|
|
28
|
+
title?: (props: typeof __VLS_36) => any;
|
|
29
29
|
} & {
|
|
30
|
-
description?: (props: typeof
|
|
30
|
+
description?: (props: typeof __VLS_44) => any;
|
|
31
31
|
} & {
|
|
32
|
-
default?: (props: typeof
|
|
32
|
+
default?: (props: typeof __VLS_46) => any;
|
|
33
33
|
} & {
|
|
34
|
-
footer?: (props: typeof
|
|
34
|
+
footer?: (props: typeof __VLS_54) => any;
|
|
35
35
|
};
|
|
36
36
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
37
37
|
"update:open": (open: boolean) => any;
|
|
38
|
+
"after-close": () => any;
|
|
38
39
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
39
40
|
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
41
|
+
"onAfter-close"?: (() => any) | undefined;
|
|
40
42
|
}>, {
|
|
41
43
|
showCloseButton: boolean;
|
|
42
44
|
breakpoint: string;
|
|
@@ -25,6 +25,12 @@ function handleOpenUpdate(sessionId, open) {
|
|
|
25
25
|
}
|
|
26
26
|
overlay.closeSync(sessionId);
|
|
27
27
|
}
|
|
28
|
+
function handleAfterClose(sessionId) {
|
|
29
|
+
const finalizeCloseSync = Reflect.get(overlay, "finalizeCloseSync");
|
|
30
|
+
if (typeof finalizeCloseSync === "function") {
|
|
31
|
+
finalizeCloseSync(sessionId);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
28
34
|
const renderedSessions = computed(() => {
|
|
29
35
|
const nextSessions = [];
|
|
30
36
|
for (const session of overlay.sessions) {
|
|
@@ -35,6 +41,7 @@ const renderedSessions = computed(() => {
|
|
|
35
41
|
nextSessions.push({
|
|
36
42
|
sessionId: session.sessionId,
|
|
37
43
|
definitionId: session.definitionId,
|
|
44
|
+
open: session.open,
|
|
38
45
|
shell: {
|
|
39
46
|
title: session.shell.title,
|
|
40
47
|
description: session.shell.description,
|
|
@@ -57,11 +64,12 @@ const renderedSessions = computed(() => {
|
|
|
57
64
|
:key="session.sessionId"
|
|
58
65
|
>
|
|
59
66
|
<ShwfedModal
|
|
60
|
-
:open="
|
|
67
|
+
:open="session.open"
|
|
61
68
|
:breakpoint="session.shell.breakpoint"
|
|
62
69
|
:show-close-button="session.shell.showCloseButton"
|
|
63
70
|
:dismissible="session.shell.dismissible"
|
|
64
71
|
@update:open="handleOpenUpdate(session.sessionId, $event)"
|
|
72
|
+
@after-close="handleAfterClose(session.sessionId)"
|
|
65
73
|
>
|
|
66
74
|
<template
|
|
67
75
|
v-if="session.shell.title"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ButtonActionEffect, type ButtonActionEffectFactory } from '../../../composables/useButtonAction.js';
|
|
2
|
+
export declare const overlayFactoryEffect: ButtonActionEffectFactory;
|
|
3
|
+
export declare const submitFactoryEffect: ButtonActionEffectFactory;
|
|
4
|
+
export declare const promiseEffect: ButtonActionEffect;
|
|
5
|
+
export declare const syncEffect: ButtonActionEffect;
|
|
6
|
+
export declare const overlayContextEffect: ButtonActionEffectFactory;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
2
|
+
import { openOverlay } from "../../../composables/useOverlay.js";
|
|
3
|
+
import { currentButtonAction } from "../../../composables/useButtonAction.js";
|
|
4
|
+
export const overlayFactoryEffect = ({ id }) => Effect.gen(function* () {
|
|
5
|
+
const handle = yield* openOverlay(id);
|
|
6
|
+
return handle;
|
|
7
|
+
});
|
|
8
|
+
export const submitFactoryEffect = ({ title }) => Effect.gen(function* () {
|
|
9
|
+
if (title.length === 0) {
|
|
10
|
+
return yield* Effect.fail(new Error("missing title"));
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
submitted: true,
|
|
14
|
+
title
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
export const promiseEffect = Effect.promise(async () => ({
|
|
18
|
+
status: "ok"
|
|
19
|
+
}));
|
|
20
|
+
export const syncEffect = Effect.sync(() => 1);
|
|
21
|
+
export const overlayContextEffect = () => Effect.gen(function* () {
|
|
22
|
+
const action = yield* currentButtonAction();
|
|
23
|
+
const handle = yield* openOverlay(action.id);
|
|
24
|
+
const result = yield* handle.result;
|
|
25
|
+
return Option.isSome(result);
|
|
26
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context, Effect, type Scope } from 'effect';
|
|
2
|
+
import type { OverlayService } from './useOverlay.js';
|
|
2
3
|
export type ButtonActionRuntime = Readonly<{
|
|
3
4
|
id: string;
|
|
4
5
|
locale: string;
|
|
@@ -15,7 +16,7 @@ declare const ButtonActionService_base: Context.TagClass<ButtonActionService, "s
|
|
|
15
16
|
}>>;
|
|
16
17
|
export declare class ButtonActionService extends ButtonActionService_base {
|
|
17
18
|
}
|
|
18
|
-
export type ButtonActionEffect = Effect.Effect<
|
|
19
|
+
export type ButtonActionEffect = Effect.Effect<unknown, unknown, ButtonActionService | OverlayService | Scope.Scope> | Effect.Effect<unknown, unknown, ButtonActionService | OverlayService> | Effect.Effect<unknown, unknown, ButtonActionService | Scope.Scope> | Effect.Effect<unknown, unknown, OverlayService | Scope.Scope> | Effect.Effect<unknown, unknown, ButtonActionService> | Effect.Effect<unknown, unknown, OverlayService> | Effect.Effect<unknown, unknown, Scope.Scope> | Effect.Effect<unknown, unknown, never>;
|
|
19
20
|
export type ButtonActionEffectFactory = (context: ButtonActionRuntime) => ButtonActionEffect;
|
|
20
21
|
export declare function currentButtonAction(): Effect.Effect<ButtonActionRuntime, never, ButtonActionService>;
|
|
21
22
|
export {};
|
|
@@ -38,9 +38,11 @@ type OverlayShellState = OverlayShellProps & {
|
|
|
38
38
|
type OverlaySession = {
|
|
39
39
|
sessionId: string;
|
|
40
40
|
definitionId: string;
|
|
41
|
+
open: boolean;
|
|
41
42
|
shell: OverlayShellState;
|
|
42
43
|
props: Record<string, unknown>;
|
|
43
44
|
deferred: Deferred.Deferred<OverlayResult, never>;
|
|
45
|
+
pendingResult?: OverlayResult;
|
|
44
46
|
};
|
|
45
47
|
export type OverlayHandle<T = Record<string, unknown>> = Readonly<{
|
|
46
48
|
sessionId: string;
|
|
@@ -50,19 +50,25 @@ function createOverlayRuntime() {
|
|
|
50
50
|
const [session] = sessions.value.splice(index, 1);
|
|
51
51
|
return session;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
function finalizeCloseSync(sessionId, result) {
|
|
54
|
+
const session = removeSession(sessionId);
|
|
55
|
+
if (!session) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
Effect.runSync(Deferred.succeed(session.deferred, session.pendingResult ?? result ?? Option.none()));
|
|
59
|
+
}
|
|
60
|
+
function requestCloseSync(sessionId, result) {
|
|
61
|
+
const session = getSession(sessionId);
|
|
62
|
+
if (!session || !session.open) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
session.open = false;
|
|
66
|
+
session.pendingResult = result;
|
|
61
67
|
}
|
|
62
68
|
function closeDefinitionSessions(definitionId) {
|
|
63
69
|
const targetSessions = sessions.value.filter((session) => session.definitionId === definitionId).map((session) => session.sessionId);
|
|
64
70
|
for (const sessionId of targetSessions) {
|
|
65
|
-
|
|
71
|
+
finalizeCloseSync(sessionId, Option.none());
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
function registerDefinition(definition) {
|
|
@@ -111,19 +117,19 @@ function createOverlayRuntime() {
|
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
function closeSync(sessionId, ...args) {
|
|
114
|
-
|
|
120
|
+
requestCloseSync(sessionId, createResult(...args));
|
|
115
121
|
}
|
|
116
122
|
function closeTopSync() {
|
|
117
123
|
const topSession = sessions.value.at(-1);
|
|
118
124
|
if (!topSession) {
|
|
119
125
|
return;
|
|
120
126
|
}
|
|
121
|
-
|
|
127
|
+
requestCloseSync(topSession.sessionId, Option.none());
|
|
122
128
|
}
|
|
123
129
|
function closeAllSync() {
|
|
124
130
|
const sessionIds = sessions.value.map((session) => session.sessionId);
|
|
125
131
|
for (const sessionId of sessionIds) {
|
|
126
|
-
|
|
132
|
+
requestCloseSync(sessionId, Option.none());
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
function createHandle(session) {
|
|
@@ -132,7 +138,9 @@ function createOverlayRuntime() {
|
|
|
132
138
|
patch: (patch) => Effect.sync(() => {
|
|
133
139
|
patchSync(session.sessionId, patch);
|
|
134
140
|
}),
|
|
135
|
-
close: (...args) =>
|
|
141
|
+
close: (...args) => Effect.sync(() => {
|
|
142
|
+
requestCloseSync(session.sessionId, createResult(...args));
|
|
143
|
+
}),
|
|
136
144
|
result: Deferred.await(session.deferred)
|
|
137
145
|
};
|
|
138
146
|
}
|
|
@@ -160,6 +168,7 @@ function createOverlayRuntime() {
|
|
|
160
168
|
const session = {
|
|
161
169
|
sessionId: crypto.randomUUID(),
|
|
162
170
|
definitionId,
|
|
171
|
+
open: true,
|
|
163
172
|
shell: {
|
|
164
173
|
title: explicitTitle ?? buttonTitle ?? definitionTitle,
|
|
165
174
|
description: explicitDescription ?? buttonDescription ?? definitionDescription ?? getDefaultOverlayDescription(buttonAction?.locale ?? "zh"),
|
|
@@ -176,7 +185,9 @@ function createOverlayRuntime() {
|
|
|
176
185
|
sessions.value.push(session);
|
|
177
186
|
return createHandle(session);
|
|
178
187
|
}),
|
|
179
|
-
(handle) =>
|
|
188
|
+
(handle) => Effect.sync(() => {
|
|
189
|
+
finalizeCloseSync(handle.sessionId, Option.none());
|
|
190
|
+
})
|
|
180
191
|
);
|
|
181
192
|
}
|
|
182
193
|
const runtime = {
|
|
@@ -192,7 +203,7 @@ function createOverlayRuntime() {
|
|
|
192
203
|
registerDefinition,
|
|
193
204
|
unregisterDefinition,
|
|
194
205
|
syncDefinitions,
|
|
195
|
-
isOpen: (sessionId) =>
|
|
206
|
+
isOpen: (sessionId) => getSession(sessionId)?.open === true,
|
|
196
207
|
patchSync,
|
|
197
208
|
closeSync,
|
|
198
209
|
closeTopSync,
|
|
@@ -201,13 +212,16 @@ function createOverlayRuntime() {
|
|
|
201
212
|
patch: (sessionId, patch) => Effect.sync(() => {
|
|
202
213
|
patchSync(sessionId, patch);
|
|
203
214
|
}),
|
|
204
|
-
close: (sessionId, ...args) =>
|
|
215
|
+
close: (sessionId, ...args) => Effect.sync(() => {
|
|
216
|
+
requestCloseSync(sessionId, createResult(...args));
|
|
217
|
+
}),
|
|
205
218
|
closeTop: () => Effect.sync(() => {
|
|
206
219
|
closeTopSync();
|
|
207
220
|
}),
|
|
208
221
|
closeAll: () => Effect.sync(() => {
|
|
209
222
|
closeAllSync();
|
|
210
|
-
})
|
|
223
|
+
}),
|
|
224
|
+
finalizeCloseSync
|
|
211
225
|
};
|
|
212
226
|
return runtime;
|
|
213
227
|
}
|
|
@@ -7,9 +7,9 @@ declare const _default: import("#app").Plugin<{
|
|
|
7
7
|
custom: (component: import("vue").Component, data?: import("vue-sonner").ExternalToast) => string | number;
|
|
8
8
|
message: (message: string | (() => string | import("vue").Component) | import("vue").Component, data?: import("vue-sonner").ExternalToast) => string | number;
|
|
9
9
|
promise: <ToastData>(promise: Promise<ToastData> | (() => Promise<ToastData>), data?: ({
|
|
10
|
+
dismissible?: boolean | undefined;
|
|
10
11
|
id?: number | string | undefined;
|
|
11
12
|
icon?: import("vue").Component | undefined;
|
|
12
|
-
dismissible?: boolean | undefined;
|
|
13
13
|
duration?: number | undefined;
|
|
14
14
|
class?: string | undefined;
|
|
15
15
|
style?: import("vue").CSSProperties | undefined;
|
|
@@ -60,9 +60,9 @@ declare const _default: import("#app").Plugin<{
|
|
|
60
60
|
custom: (component: import("vue").Component, data?: import("vue-sonner").ExternalToast) => string | number;
|
|
61
61
|
message: (message: string | (() => string | import("vue").Component) | import("vue").Component, data?: import("vue-sonner").ExternalToast) => string | number;
|
|
62
62
|
promise: <ToastData>(promise: Promise<ToastData> | (() => Promise<ToastData>), data?: ({
|
|
63
|
+
dismissible?: boolean | undefined;
|
|
63
64
|
id?: number | string | undefined;
|
|
64
65
|
icon?: import("vue").Component | undefined;
|
|
65
|
-
dismissible?: boolean | undefined;
|
|
66
66
|
duration?: number | undefined;
|
|
67
67
|
class?: string | undefined;
|
|
68
68
|
style?: import("vue").CSSProperties | undefined;
|