@shwfed/nuxt 0.11.18 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.11.18",
4
+ "version": "0.11.19",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -9,34 +9,36 @@ declare function close(): void;
9
9
  declare var __VLS_14: {
10
10
  close: typeof close;
11
11
  isDesktop: boolean;
12
- }, __VLS_34: {
12
+ }, __VLS_36: {
13
13
  close: typeof close;
14
14
  isDesktop: boolean;
15
- }, __VLS_42: {
15
+ }, __VLS_44: {
16
16
  close: typeof close;
17
17
  isDesktop: boolean;
18
- }, __VLS_44: {
18
+ }, __VLS_46: {
19
19
  close: typeof close;
20
20
  isDesktop: boolean;
21
- }, __VLS_52: {
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 __VLS_34) => any;
28
+ title?: (props: typeof __VLS_36) => any;
29
29
  } & {
30
- description?: (props: typeof __VLS_42) => any;
30
+ description?: (props: typeof __VLS_44) => any;
31
31
  } & {
32
- default?: (props: typeof __VLS_44) => any;
32
+ default?: (props: typeof __VLS_46) => any;
33
33
  } & {
34
- footer?: (props: typeof __VLS_52) => any;
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
- }, __VLS_34: {
12
+ }, __VLS_36: {
13
13
  close: typeof close;
14
14
  isDesktop: boolean;
15
- }, __VLS_42: {
15
+ }, __VLS_44: {
16
16
  close: typeof close;
17
17
  isDesktop: boolean;
18
- }, __VLS_44: {
18
+ }, __VLS_46: {
19
19
  close: typeof close;
20
20
  isDesktop: boolean;
21
- }, __VLS_52: {
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 __VLS_34) => any;
28
+ title?: (props: typeof __VLS_36) => any;
29
29
  } & {
30
- description?: (props: typeof __VLS_42) => any;
30
+ description?: (props: typeof __VLS_44) => any;
31
31
  } & {
32
- default?: (props: typeof __VLS_44) => any;
32
+ default?: (props: typeof __VLS_46) => any;
33
33
  } & {
34
- footer?: (props: typeof __VLS_52) => any;
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="true"
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"
@@ -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 closeInternal(sessionId, result) {
54
- return Effect.gen(function* () {
55
- const session = removeSession(sessionId);
56
- if (!session) {
57
- return;
58
- }
59
- yield* Deferred.succeed(session.deferred, result);
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
- void Effect.runPromise(closeInternal(sessionId, Option.none()));
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
- void Effect.runPromise(closeInternal(sessionId, createResult(...args)));
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
- void Effect.runPromise(closeInternal(topSession.sessionId, Option.none()));
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
- void Effect.runPromise(closeInternal(sessionId, Option.none()));
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) => closeInternal(session.sessionId, createResult(...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) => closeInternal(handle.sessionId, Option.none())
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) => findSessionIndex(sessionId) >= 0,
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) => closeInternal(sessionId, createResult(...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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.11.18",
3
+ "version": "0.11.19",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",