@vc-shell/framework 1.1.39 → 1.1.41

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/framework.js +1 -1
  3. package/dist/{index-Cy1TZEcM.js → index-1JJQveyB.js} +1 -1
  4. package/dist/{index-kCPa67RI.js → index-B44cWItv.js} +1 -1
  5. package/dist/{index-D6UGtozM.js → index-BE4Tk28_.js} +1 -1
  6. package/dist/{index-CBD6Yh8s.js → index-BTgH6s3D.js} +1 -1
  7. package/dist/{index-Ct4swSYd.js → index-Bi-8Kqqp.js} +1 -1
  8. package/dist/{index-DfRPeXpk.js → index-BykyKXxV.js} +1 -1
  9. package/dist/{index-CG1o0S3d.js → index-C8JpDUy_.js} +1 -1
  10. package/dist/{index-5ZS3JrDU.js → index-CAR4cutK.js} +14568 -14541
  11. package/dist/{index-DV2VMX_-.js → index-CB3EUnU6.js} +1 -1
  12. package/dist/{index-Duy_QA-o.js → index-CGdhIFOS.js} +1 -1
  13. package/dist/{index-C1SnCxF_.js → index-Cedihxe6.js} +1 -1
  14. package/dist/{index-Dh0KD5hP.js → index-Cgs4IS8B.js} +1 -1
  15. package/dist/{index-nCEw48yM.js → index-DU2lNPGJ.js} +1 -1
  16. package/dist/{index-B9cIr1zZ.js → index-DVhOKCWa.js} +1 -1
  17. package/dist/{index-Cal7ggzV.js → index-DriR0C3C.js} +1 -1
  18. package/dist/{index-DawL8TtG.js → index-jBU41-9Y.js} +1 -1
  19. package/dist/{index-aVtGNj6A.js → index-x1P3MADA.js} +1 -1
  20. package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts +1 -1
  21. package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts.map +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue.d.ts.map +1 -1
  24. package/package.json +4 -4
  25. package/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue +3 -3
  26. package/shared/components/blade-navigation/composables/useBladeNavigation/index.ts +97 -42
  27. package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"vc-widget-container.vue.d.ts","sourceRoot":"","sources":["../../../../../../../ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue"],"names":[],"mappings":"AAwIA,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;;AAsFD,wBAMG"}
1
+ {"version":3,"file":"vc-widget-container.vue.d.ts","sourceRoot":"","sources":["../../../../../../../ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue"],"names":[],"mappings":"AA0IA,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;;AAwFD,wBAMG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vc-shell/framework",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "type": "module",
5
5
  "main": "./dist/framework.js",
6
6
  "types": "./dist/index.d.ts",
@@ -70,9 +70,9 @@
70
70
  "devDependencies": {
71
71
  "@fullhuman/postcss-purgecss": "^7.0.2",
72
72
  "@types/dompurify": "^3.0.5",
73
- "@vc-shell/api-client-generator": "^1.1.39",
74
- "@vc-shell/config-generator": "^1.1.39",
75
- "@vc-shell/ts-config": "^1.1.39",
73
+ "@vc-shell/api-client-generator": "^1.1.41",
74
+ "@vc-shell/config-generator": "^1.1.41",
75
+ "@vc-shell/ts-config": "^1.1.41",
76
76
  "@vitejs/plugin-vue": "^5.2.3",
77
77
  "@vue/test-utils": "^2.4.5",
78
78
  "cypress-signalr-mock": "^1.5.0",
@@ -121,9 +121,9 @@ const render = () => {
121
121
  closeBlade(index);
122
122
  },
123
123
  "onParent:call": async (args: IParentCallArgs) => {
124
- await nextTick(() => {
125
- const instance = blades.value?.[index - 1]?.props?.navigation?.instance;
126
- if (instance) onParentCall(instance, args);
124
+ await nextTick(async () => {
125
+ // Use the centralized onParentCall with the current blade index
126
+ await onParentCall(args, index);
127
127
  });
128
128
  },
129
129
  onVnodeUnmounted: resetInterceptor,
@@ -1,4 +1,4 @@
1
- import { computed, getCurrentInstance, inject, warn, Component, ComputedRef, Ref, shallowRef } from "vue";
1
+ import { computed, getCurrentInstance, inject, warn, Component, ComputedRef, Ref, shallowRef, unref } from "vue";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  import { createSharedComposable } from "@vueuse/core";
4
4
  import * as _ from "lodash-es";
@@ -38,7 +38,7 @@ interface IUseBladeNavigation {
38
38
  ) => Promise<void | NavigationFailure>;
39
39
  closeBlade: (index: number) => Promise<boolean>;
40
40
  goToRoot: () => RouteLocationRaw;
41
- onParentCall: (parentExposedMethods: Record<string, any>, args: IParentCallArgs) => void;
41
+ onParentCall: (args: IParentCallArgs, currentBladeIndex?: number) => void;
42
42
  onBeforeClose: (cb: () => Promise<boolean | undefined>) => void;
43
43
  resolveBladeByName: (name: string) => BladeInstanceConstructor | undefined;
44
44
  routeResolver: (to: RouteLocationNormalized) => Promise<RouteLocationRaw | undefined> | RouteLocationRaw | undefined;
@@ -125,17 +125,6 @@ const useBladeNavigationSingleton = createSharedComposable(() => {
125
125
  routeResolver: routeResolverInstance,
126
126
  setBladeError: bladeState.setBladeError,
127
127
  clearBladeError: bladeState.clearBladeError,
128
- onParentCall: async (parentExposedMethods: Record<string, any>, args: IParentCallArgs) => {
129
- if (args.method && parentExposedMethods && typeof parentExposedMethods[args.method] === "function") {
130
- const method = parentExposedMethods[args.method];
131
- const result = await method(args.args);
132
- if (typeof args.callback === "function") args.callback(result);
133
- } else {
134
- console.error(
135
- `No such method: ${args.method}. Please, add method with name ${args.method} and use defineExpose to expose it in parent blade`,
136
- );
137
- }
138
- },
139
128
  onBeforeClose: (cb: () => Promise<boolean | undefined>) => {
140
129
  const targetBlade = bladeState.activeWorkspace.value;
141
130
  if (targetBlade && targetBlade.props.navigation) {
@@ -198,24 +187,43 @@ export function useBladeNavigation(): IUseBladeNavigation {
198
187
  const singleton = useBladeNavigationSingleton() as typeof useBladeNavigationSingleton extends () => infer R
199
188
  ? R
200
189
  : never;
201
- console.log("useBladeNavigation singleton", singleton);
202
190
  const currentCallingInstance = getCurrentInstance() as BladeComponentInternalInstance | null;
203
- console.log("useBladeNavigation currentCallingInstance", currentCallingInstance);
204
191
  const bladeRegistry = useBladeRegistry();
205
- console.log("useBladeNavigation bladeRegistry", bladeRegistry);
206
192
 
207
- const currentBladeNavigationData = computed(() => {
208
- if (!currentCallingInstance) return undefined;
209
- const viewNode = (currentCallingInstance as any).provides[navigationViewLocation as any] as BladeVNode | undefined;
193
+ // Find the closest parent blade in the component hierarchy
194
+ const findParentBlade = (instance: BladeComponentInternalInstance | null): BladeVNode | undefined => {
195
+ if (!instance) return undefined;
196
+
197
+ // Check if current instance provides navigationViewLocation
198
+ const viewNode = (instance as any).provides[navigationViewLocation as any] as BladeVNode | undefined;
199
+ if (viewNode) {
200
+ return viewNode;
201
+ }
202
+
203
+ // Check if current instance is a blade itself
210
204
  if (
211
- !viewNode &&
205
+ instance.vnode &&
212
206
  singleton.activeWorkspace.value &&
213
- currentCallingInstance.vnode &&
214
- _.isEqual(currentCallingInstance.vnode.type, singleton.activeWorkspace.value.type)
207
+ _.isEqual(instance.vnode.type, singleton.activeWorkspace.value.type)
215
208
  ) {
216
- return singleton.activeWorkspace.value.props?.navigation;
209
+ return singleton.activeWorkspace.value;
210
+ }
211
+
212
+ // Check if current instance is in the blades list
213
+ const matchingBlade = singleton.blades.value.find(
214
+ (blade) => blade && instance.vnode && _.isEqual(blade.type, instance.vnode.type),
215
+ );
216
+ if (matchingBlade) {
217
+ return matchingBlade;
217
218
  }
218
- return viewNode?.props?.navigation;
219
+
220
+ // Recursively check parent instance
221
+ return findParentBlade(instance.parent as BladeComponentInternalInstance | null);
222
+ };
223
+
224
+ const currentBladeNavigationData = computed(() => {
225
+ const parentBlade = findParentBlade(currentCallingInstance);
226
+ return parentBlade?.props?.navigation;
219
227
  });
220
228
 
221
229
  const onBeforeClose = (cb: () => Promise<boolean | undefined>) => {
@@ -223,22 +231,73 @@ export function useBladeNavigation(): IUseBladeNavigation {
223
231
  warn("onBeforeClose called outside of a component setup context.");
224
232
  return;
225
233
  }
226
- const viewNode = (currentCallingInstance as any).provides[navigationViewLocation as any] as BladeVNode | undefined;
227
- const targetBlade = singleton.blades.value.find(
228
- (b) =>
229
- (b && viewNode && _.isEqual(b, viewNode)) ||
230
- (b &&
231
- b.props?.navigation?.idx === 0 &&
232
- currentCallingInstance.vnode &&
233
- _.isEqual(b.type, currentCallingInstance.vnode.type)),
234
- );
235
- if (targetBlade && targetBlade.props.navigation) {
236
- targetBlade.props.navigation.onBeforeClose = cb;
234
+ const parentBlade = findParentBlade(currentCallingInstance);
235
+ if (parentBlade && parentBlade.props.navigation) {
236
+ parentBlade.props.navigation.onBeforeClose = cb;
237
237
  } else {
238
238
  warn("Context-specific onBeforeClose: Could not identify the target blade in the global list.");
239
239
  }
240
240
  };
241
241
 
242
+ const onParentCall = async (args: IParentCallArgs, currentBladeIndex?: number) => {
243
+ let bladeIndex = currentBladeIndex;
244
+
245
+ // If currentBladeIndex is not provided, try to find it from the component hierarchy
246
+ if (bladeIndex === undefined) {
247
+ if (!currentCallingInstance) {
248
+ warn("onParentCall called outside of a component setup context and without currentBladeIndex.");
249
+ return;
250
+ }
251
+
252
+ // Find current blade in the blades list
253
+ const currentBlade = findParentBlade(currentCallingInstance);
254
+ if (!currentBlade) {
255
+ console.error("onParentCall: Could not identify current blade in the global list.");
256
+ return;
257
+ }
258
+
259
+ bladeIndex = currentBlade.props.navigation?.idx ?? -1;
260
+ }
261
+
262
+ if (bladeIndex <= 0) {
263
+ console.error("onParentCall: Current blade is workspace (index 0) or invalid, no parent blade available.");
264
+ return;
265
+ }
266
+
267
+ // Find parent blade (blade with index bladeIndex - 1)
268
+ const parentBlade = singleton.blades.value.find((blade) => blade && blade.props.navigation?.idx === bladeIndex - 1);
269
+
270
+ if (!parentBlade) {
271
+ console.error(`onParentCall: Parent blade with index ${bladeIndex - 1} not found.`);
272
+ return;
273
+ }
274
+
275
+ const parentExposedMethods = parentBlade.props.navigation?.instance;
276
+
277
+ if (!parentExposedMethods) {
278
+ console.error("onParentCall: Parent blade has no exposed methods (navigation.instance is undefined).");
279
+ return;
280
+ }
281
+
282
+ // Try to get the method from exposed methods with Vue refs handling
283
+ const targetMethod = parentExposedMethods[args.method];
284
+
285
+ if (args.method && typeof targetMethod === "function") {
286
+ const result = await targetMethod(args.args);
287
+ if (typeof args.callback === "function") args.callback(result);
288
+ } else {
289
+ console.error(
290
+ `onParentCall: Method '${args.method}' is not available or not a function in parent blade '${parentBlade.type?.name}'.`,
291
+ );
292
+ console.error("Available properties:", Object.keys(parentExposedMethods));
293
+ console.error(`Requested method '${args.method}' type:`, typeof targetMethod);
294
+ console.error(`Requested method '${args.method}' value:`, targetMethod);
295
+ console.error(
296
+ `Please ensure that the method '${args.method}' is defined and exposed using defineExpose() in the parent blade component.`,
297
+ );
298
+ }
299
+ };
300
+
242
301
  return {
243
302
  blades: singleton.blades,
244
303
  activeWorkspace: singleton.activeWorkspace,
@@ -246,12 +305,8 @@ export function useBladeNavigation(): IUseBladeNavigation {
246
305
  args: IBladeEvent<Blade>,
247
306
  isWorkspace?: boolean,
248
307
  ): Promise<void | NavigationFailure> => {
249
- let sourceBladeInstanceForOpening: BladeVNode | undefined = undefined;
250
- if (currentCallingInstance) {
251
- sourceBladeInstanceForOpening = (currentCallingInstance as any).provides[navigationViewLocation as any] as
252
- | BladeVNode
253
- | undefined;
254
- }
308
+ // Find the closest parent blade in the component hierarchy
309
+ let sourceBladeInstanceForOpening: BladeVNode | undefined = findParentBlade(currentCallingInstance);
255
310
 
256
311
  if (!sourceBladeInstanceForOpening) {
257
312
  sourceBladeInstanceForOpening = singleton.activeWorkspace.value;
@@ -266,7 +321,7 @@ export function useBladeNavigation(): IUseBladeNavigation {
266
321
  },
267
322
  closeBlade: singleton.closeBlade,
268
323
  goToRoot: singleton.goToRoot,
269
- onParentCall: singleton.onParentCall,
324
+ onParentCall,
270
325
  resolveBladeByName: (name: string) => bladeRegistry.getBladeComponent(name),
271
326
  routeResolver: singleton.routeResolver,
272
327
  currentBladeNavigationData,
@@ -36,6 +36,8 @@ const visibleWidgets = computed(() =>
36
36
  return widget.isVisible(bladeInstance);
37
37
  } else if (typeof widget.isVisible === "boolean") {
38
38
  return widget.isVisible;
39
+ } else if (widget.isVisible === undefined) {
40
+ return true; // Show widget by default if isVisible is not specified
39
41
  }
40
42
  return toValue(widget.isVisible);
41
43
  }),