@shwfed/nuxt 0.11.2 → 0.11.3

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.2",
4
+ "version": "0.11.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -28,6 +28,17 @@ function handleOpenUpdate(sessionId, open) {
28
28
  reason: "dismiss"
29
29
  });
30
30
  }
31
+ function patchFooter(sessionId, definitionId, nextProps) {
32
+ if (!definitionId) {
33
+ return;
34
+ }
35
+ overlay.patchSync(sessionId, {
36
+ footer: {
37
+ id: definitionId,
38
+ props: nextProps
39
+ }
40
+ });
41
+ }
31
42
  const renderedSessions = computed(() => {
32
43
  const nextSessions = [];
33
44
  for (const session of overlay.sessions) {
@@ -35,6 +46,7 @@ const renderedSessions = computed(() => {
35
46
  if (!definition) {
36
47
  continue;
37
48
  }
49
+ const footerDefinition = session.footer ? overlay.definitions[session.footer.id] : void 0;
38
50
  nextSessions.push({
39
51
  sessionId: session.sessionId,
40
52
  definitionId: session.definitionId,
@@ -47,6 +59,11 @@ const renderedSessions = computed(() => {
47
59
  },
48
60
  descriptionSrOnly: session.shell.descriptionSrOnly,
49
61
  props: session.props,
62
+ footer: session.footer && footerDefinition ? {
63
+ definitionId: session.footer.id,
64
+ props: session.footer.props,
65
+ definition: footerDefinition
66
+ } : void 0,
50
67
  definition
51
68
  });
52
69
  }
@@ -98,6 +115,23 @@ const renderedSessions = computed(() => {
98
115
  close: (value) => overlay.closeSync(session.sessionId, value),
99
116
  patch: (nextProps) => overlay.patchSync(session.sessionId, { props: nextProps }),
100
117
  isDesktop: modalSlotProps.isDesktop
118
+ }"
119
+ />
120
+ </template>
121
+
122
+ <template
123
+ v-if="session.footer"
124
+ #footer="modalSlotProps"
125
+ >
126
+ <OverlayBody
127
+ :render="session.footer.definition.render"
128
+ :slot-props="{
129
+ props: session.footer.props,
130
+ shell: session.shell,
131
+ sessionId: session.sessionId,
132
+ close: (value) => overlay.closeSync(session.sessionId, value),
133
+ patch: (nextProps) => patchFooter(session.sessionId, session.footer?.definitionId, nextProps),
134
+ isDesktop: modalSlotProps.isDesktop
101
135
  }"
102
136
  />
103
137
  </template>
@@ -54,32 +54,16 @@ watch(currentConfig, (value) => {
54
54
  }, { immediate: true });
55
55
  const modalDefinitions = computed(() => {
56
56
  const nextDefinitions = [];
57
- for (const group of displayConfig.value.groups) {
58
- for (const item of group.items) {
59
- if (isDropdownItem(item)) {
60
- for (const child of item.items) {
61
- const render2 = slots[child.id];
62
- if (render2) {
63
- nextDefinitions.push({
64
- definitionId: child.id,
65
- ownerId: overlayOwnerId,
66
- render: render2,
67
- shell: getModalShell(child.modal)
68
- });
69
- }
70
- }
71
- continue;
72
- }
73
- const render = slots[item.id];
74
- if (render) {
75
- nextDefinitions.push({
76
- definitionId: item.id,
77
- ownerId: overlayOwnerId,
78
- render,
79
- shell: getModalShell(item.modal)
80
- });
81
- }
57
+ for (const [slotName, render] of Object.entries(slots)) {
58
+ if (!uuidPattern.test(slotName) || typeof render !== "function") {
59
+ continue;
82
60
  }
61
+ nextDefinitions.push({
62
+ definitionId: slotName,
63
+ ownerId: overlayOwnerId,
64
+ render,
65
+ shell: getModalShell(findButtonAction(slotName)?.modal)
66
+ });
83
67
  }
84
68
  return nextDefinitions;
85
69
  });
@@ -14,13 +14,19 @@ export type OverlayShellProps = Readonly<{
14
14
  dismissible?: boolean;
15
15
  }>;
16
16
  export type OverlayBodyProps = Readonly<Record<string, unknown>>;
17
+ export type OverlaySectionReferenceInput = Readonly<{
18
+ id: string;
19
+ props?: Record<string, unknown>;
20
+ }>;
17
21
  export type OverlaySessionInput = Readonly<{
18
22
  shell?: Partial<OverlayShellProps>;
19
23
  props?: Record<string, unknown>;
24
+ footer?: OverlaySectionReferenceInput;
20
25
  }>;
21
26
  export type OverlaySessionPatch = Readonly<{
22
27
  shell?: Partial<OverlayShellProps>;
23
28
  props?: Record<string, unknown>;
29
+ footer?: OverlaySectionReferenceInput | null;
24
30
  }>;
25
31
  export type OverlaySlotProps = Readonly<{
26
32
  props: OverlayBodyProps;
@@ -45,6 +51,10 @@ type OverlaySession = {
45
51
  definitionId: string;
46
52
  shell: OverlayShellState;
47
53
  props: Record<string, unknown>;
54
+ footer?: {
55
+ id: string;
56
+ props: Record<string, unknown>;
57
+ };
48
58
  deferred: Deferred.Deferred<OverlayResult, never>;
49
59
  };
50
60
  export type OverlayHandle = Readonly<{
@@ -112,6 +112,18 @@ function createOverlayRuntime() {
112
112
  ...patch.props
113
113
  };
114
114
  }
115
+ if (Reflect.has(patch, "footer")) {
116
+ if (patch.footer === null || patch.footer === void 0) {
117
+ session.footer = void 0;
118
+ return;
119
+ }
120
+ session.footer = {
121
+ id: patch.footer.id,
122
+ props: {
123
+ ...patch.footer.props
124
+ }
125
+ };
126
+ }
115
127
  }
116
128
  function closeSync(sessionId, value) {
117
129
  void Effect.runPromise(closeInternal(sessionId, value));
@@ -163,6 +175,9 @@ function createOverlayRuntime() {
163
175
  if (!definition) {
164
176
  return yield* Effect.fail(createDefinitionNotFoundError(definitionId));
165
177
  }
178
+ if (options?.footer && !getDefinition(options.footer.id)) {
179
+ return yield* Effect.fail(createDefinitionNotFoundError(options.footer.id));
180
+ }
166
181
  const buttonActionOption = yield* Effect.serviceOption(ButtonActionService);
167
182
  const buttonAction = Option.match(buttonActionOption, {
168
183
  onNone: () => void 0,
@@ -191,6 +206,12 @@ function createOverlayRuntime() {
191
206
  props: {
192
207
  ...options?.props
193
208
  },
209
+ footer: options?.footer ? {
210
+ id: options.footer.id,
211
+ props: {
212
+ ...options.footer.props
213
+ }
214
+ } : void 0,
194
215
  deferred
195
216
  };
196
217
  sessions.value.push(session);
@@ -10,6 +10,7 @@ declare const _default: import("#app").Plugin<{
10
10
  id?: number | string | undefined;
11
11
  icon?: import("vue").Component | undefined;
12
12
  dismissible?: boolean | undefined;
13
+ duration?: number | undefined;
13
14
  class?: string | undefined;
14
15
  style?: import("vue").CSSProperties | undefined;
15
16
  cancel?: (import("vue-sonner").Action | import("vue").Component) | undefined;
@@ -19,7 +20,6 @@ declare const _default: import("#app").Plugin<{
19
20
  richColors?: boolean | undefined;
20
21
  invert?: boolean | undefined;
21
22
  closeButton?: boolean | undefined;
22
- duration?: number | undefined;
23
23
  important?: boolean | undefined;
24
24
  action?: (import("vue-sonner").Action | import("vue").Component) | undefined;
25
25
  onDismiss?: ((toast: import("vue-sonner").ToastT) => void) | undefined;
@@ -63,6 +63,7 @@ declare const _default: import("#app").Plugin<{
63
63
  id?: number | string | undefined;
64
64
  icon?: import("vue").Component | undefined;
65
65
  dismissible?: boolean | undefined;
66
+ duration?: number | undefined;
66
67
  class?: string | undefined;
67
68
  style?: import("vue").CSSProperties | undefined;
68
69
  cancel?: (import("vue-sonner").Action | import("vue").Component) | undefined;
@@ -72,7 +73,6 @@ declare const _default: import("#app").Plugin<{
72
73
  richColors?: boolean | undefined;
73
74
  invert?: boolean | undefined;
74
75
  closeButton?: boolean | undefined;
75
- duration?: number | undefined;
76
76
  important?: boolean | undefined;
77
77
  action?: (import("vue-sonner").Action | import("vue").Component) | undefined;
78
78
  onDismiss?: ((toast: import("vue-sonner").ToastT) => void) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",