@vc-shell/framework 1.0.136 → 1.0.138

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 (47) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/core/types/index.ts +1 -4
  3. package/dist/core/types/index.d.ts +2 -5
  4. package/dist/core/types/index.d.ts.map +1 -1
  5. package/dist/framework.js +5121 -5114
  6. package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts.map +1 -1
  7. package/dist/shared/components/blade-navigation/plugin.d.ts.map +1 -1
  8. package/dist/shared/components/blade-navigation/types/index.d.ts +7 -0
  9. package/dist/shared/components/blade-navigation/types/index.d.ts.map +1 -1
  10. package/dist/shared/modules/dynamic/components/SchemaRender.d.ts +3 -3
  11. package/dist/shared/modules/dynamic/components/fields/Button.d.ts +1 -1
  12. package/dist/shared/modules/dynamic/components/fields/Card.d.ts +1 -1
  13. package/dist/shared/modules/dynamic/components/fields/Checkbox.d.ts +1 -1
  14. package/dist/shared/modules/dynamic/components/fields/ContentField.d.ts +1 -1
  15. package/dist/shared/modules/dynamic/components/fields/DynamicProperty.d.ts +1 -1
  16. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts +1 -1
  17. package/dist/shared/modules/dynamic/components/fields/Fieldset.d.ts +1 -1
  18. package/dist/shared/modules/dynamic/components/fields/GalleryField.d.ts +1 -1
  19. package/dist/shared/modules/dynamic/components/fields/ImageField.d.ts +1 -1
  20. package/dist/shared/modules/dynamic/components/fields/InputCurrency.d.ts +1 -1
  21. package/dist/shared/modules/dynamic/components/fields/InputField.d.ts +1 -1
  22. package/dist/shared/modules/dynamic/components/fields/MultivalueField.d.ts +1 -1
  23. package/dist/shared/modules/dynamic/components/fields/SelectField.d.ts +1 -1
  24. package/dist/shared/modules/dynamic/components/fields/StatusField.d.ts +1 -1
  25. package/dist/shared/modules/dynamic/components/fields/TextareaField.d.ts +1 -1
  26. package/dist/shared/modules/dynamic/components/fields/VideoField.d.ts +1 -1
  27. package/dist/shared/modules/dynamic/components/fields/props.d.ts +1 -1
  28. package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +1 -1
  29. package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts.map +1 -1
  30. package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/dist/ui/components/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue.d.ts +2 -2
  33. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts +2 -0
  34. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
  35. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.d.ts +0 -1
  36. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.d.ts.map +1 -1
  37. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue.d.ts +1 -1
  38. package/dist/ui/components/organisms/vc-blade/index.d.ts +7 -7
  39. package/dist/ui/components/organisms/vc-blade/vc-blade.vue.d.ts +1 -1
  40. package/package.json +5 -5
  41. package/shared/components/blade-navigation/composables/useBladeNavigation/index.ts +158 -37
  42. package/shared/components/blade-navigation/plugin.ts +5 -2
  43. package/shared/components/blade-navigation/types/index.ts +8 -0
  44. package/shared/modules/dynamic/pages/dynamic-blade-form.vue +13 -9
  45. package/ui/components/organisms/vc-app/vc-app.vue +17 -15
  46. package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue +0 -1
  47. package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue +0 -1
@@ -13,12 +13,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
13
13
  "logo:click": () => void;
14
14
  "backlink:click": () => void;
15
15
  "menubutton:click": () => void;
16
- "button:click": (item: IBladeToolbar<import("vue").ComponentPublicInstance>) => void;
16
+ "button:click": (item: IBladeToolbar) => void;
17
17
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<Props>>> & {
18
18
  "onLogo:click"?: (() => any) | undefined;
19
19
  "onBacklink:click"?: (() => any) | undefined;
20
20
  "onMenubutton:click"?: (() => any) | undefined;
21
- "onButton:click"?: ((item: IBladeToolbar<import("vue").ComponentPublicInstance>) => any) | undefined;
21
+ "onButton:click"?: ((item: IBladeToolbar) => any) | undefined;
22
22
  }, {}, {}>, {
23
23
  "app-switcher"?(_: {}): any;
24
24
  toolbar?(_: {}): any;
@@ -8,6 +8,7 @@ export interface Props {
8
8
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<Props>>>, {}, {}>, Readonly<{
9
9
  "app-switcher": void;
10
10
  toolbar: void;
11
+ "navigation-menu": void;
11
12
  "toolbar:prepend": void;
12
13
  "toolbar:language-selector": void;
13
14
  "toolbar:notifications-dropdown": void;
@@ -48,6 +49,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
48
49
  }> & {
49
50
  "app-switcher": void;
50
51
  toolbar: void;
52
+ "navigation-menu": void;
51
53
  "toolbar:prepend": void;
52
54
  "toolbar:language-selector": void;
53
55
  "toolbar:notifications-dropdown": void;
@@ -1 +1 @@
1
- {"version":3,"file":"vc-app.vue.d.ts","sourceRoot":"","sources":["../../../../../ui/components/organisms/vc-app/vc-app.vue.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAibD,wBAAwG;AACxG,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAClD,MAAM,EAAE,CAAC,CAAC;KACT,CAAA;CAAE,CAAC"}
@@ -3,7 +3,6 @@ export interface Props {
3
3
  isExpanded: boolean;
4
4
  icon?: string | (() => string);
5
5
  title?: string;
6
- options?: Record<string, unknown>;
7
6
  disabled?: boolean;
8
7
  dropdownItems?: IBladeDropdownItem[];
9
8
  clickHandler?(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"vc-blade-toolbar-button.vue.d.ts","sourceRoot":"","sources":["../../../../../../../../../ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,MAAM,WAAW,KAAK;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,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ar-button.vue.d.ts","sourceRoot":"","sources":["../../../../../../../../../ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,MAAM,WAAW,KAAK;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACrC,YAAY,CAAC,IAAI,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmPD,wBAOG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -7,7 +7,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
7
7
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
8
8
  items: () => never[];
9
9
  }>>>, {
10
- items: IBladeToolbar<import("vue").ComponentPublicInstance>[];
10
+ items: IBladeToolbar[];
11
11
  }, {}>;
12
12
  export default _default;
13
13
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -26,7 +26,7 @@ export declare const VcBlade: {
26
26
  default: boolean;
27
27
  };
28
28
  toolbarItems: {
29
- type: import("vue").PropType<import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[]>;
29
+ type: import("vue").PropType<import("../../../..").IBladeToolbar[]>;
30
30
  default: () => never[];
31
31
  };
32
32
  }>> & {
@@ -63,7 +63,7 @@ export declare const VcBlade: {
63
63
  default: boolean;
64
64
  };
65
65
  toolbarItems: {
66
- type: import("vue").PropType<import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[]>;
66
+ type: import("vue").PropType<import("../../../..").IBladeToolbar[]>;
67
67
  default: () => never[];
68
68
  };
69
69
  }>> & {
@@ -74,7 +74,7 @@ export declare const VcBlade: {
74
74
  width: string | number;
75
75
  closable: boolean;
76
76
  expandable: boolean;
77
- toolbarItems: import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[];
77
+ toolbarItems: import("../../../..").IBladeToolbar[];
78
78
  }, true, {}, {}, {
79
79
  P: {};
80
80
  B: {};
@@ -108,7 +108,7 @@ export declare const VcBlade: {
108
108
  default: boolean;
109
109
  };
110
110
  toolbarItems: {
111
- type: import("vue").PropType<import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[]>;
111
+ type: import("vue").PropType<import("../../../..").IBladeToolbar[]>;
112
112
  default: () => never[];
113
113
  };
114
114
  }>> & {
@@ -119,7 +119,7 @@ export declare const VcBlade: {
119
119
  width: string | number;
120
120
  closable: boolean;
121
121
  expandable: boolean;
122
- toolbarItems: import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[];
122
+ toolbarItems: import("../../../..").IBladeToolbar[];
123
123
  }>;
124
124
  __isFragment?: undefined;
125
125
  __isTeleport?: undefined;
@@ -150,7 +150,7 @@ export declare const VcBlade: {
150
150
  default: boolean;
151
151
  };
152
152
  toolbarItems: {
153
- type: import("vue").PropType<import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[]>;
153
+ type: import("vue").PropType<import("../../../..").IBladeToolbar[]>;
154
154
  default: () => never[];
155
155
  };
156
156
  }>> & {
@@ -165,7 +165,7 @@ export declare const VcBlade: {
165
165
  width: string | number;
166
166
  closable: boolean;
167
167
  expandable: boolean;
168
- toolbarItems: import("../../../..").IBladeToolbar<import("vue").ComponentPublicInstance>[];
168
+ toolbarItems: import("../../../..").IBladeToolbar[];
169
169
  }, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
170
170
  $slots: {
171
171
  actions?(_: {}): any;
@@ -36,7 +36,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
36
36
  width: string | number;
37
37
  closable: boolean;
38
38
  expandable: boolean;
39
- toolbarItems: IBladeToolbar<import("vue").ComponentPublicInstance>[];
39
+ toolbarItems: IBladeToolbar[];
40
40
  }, {}>, {
41
41
  actions?(_: {}): any;
42
42
  default?(_: {}): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vc-shell/framework",
3
- "version": "1.0.136",
3
+ "version": "1.0.138",
4
4
  "type": "module",
5
5
  "main": "./dist/framework.js",
6
6
  "types": "./dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "quill-image-uploader": "^1.3.0",
45
45
  "swiper": "^6.8.4",
46
46
  "vee-validate": "^4.12.4",
47
- "vue": "3.4.0",
47
+ "vue": "3.4.5",
48
48
  "vue-currency-input": "^3.0.5",
49
49
  "vue-i18n": "^9.8.0",
50
50
  "vue-router": "^4.2.5",
@@ -52,9 +52,9 @@
52
52
  "whatwg-fetch": "^3.6.19"
53
53
  },
54
54
  "devDependencies": {
55
- "@vc-shell/api-client-generator": "^1.0.136",
56
- "@vc-shell/config-generator": "^1.0.136",
57
- "@vc-shell/ts-config": "^1.0.136",
55
+ "@vc-shell/api-client-generator": "^1.0.138",
56
+ "@vc-shell/config-generator": "^1.0.138",
57
+ "@vc-shell/ts-config": "^1.0.138",
58
58
  "@vitejs/plugin-vue": "^5.0.0",
59
59
  "sass": "^1.69.6",
60
60
  "typescript": "5.3.3",
@@ -1,8 +1,15 @@
1
+ import { resolve } from "node:path";
1
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  import { reactiveComputed } from "@vueuse/core";
3
4
  import { computed, getCurrentInstance, inject, warn, Component, watch, isVNode, h, shallowRef, ComputedRef } from "vue";
4
5
  import * as _ from "lodash-es";
5
- import { RouteLocationNormalized, useRoute, RouteRecordNormalized, NavigationFailure } from "vue-router";
6
+ import {
7
+ RouteLocationNormalized,
8
+ useRoute,
9
+ RouteRecordNormalized,
10
+ NavigationFailure,
11
+ createRouterMatcher,
12
+ } from "vue-router";
6
13
  import { bladeNavigationInstance } from "../../plugin";
7
14
  import {
8
15
  BladeComponentInternalInstance,
@@ -12,6 +19,7 @@ import {
12
19
  IParentCallArgs,
13
20
  BladeInstanceConstructor,
14
21
  BladeRouteRecordLocationNormalized,
22
+ BladeRoutesRecord,
15
23
  } from "../../types";
16
24
  import { navigationViewLocation } from "../../injectionKeys";
17
25
  import { generateId } from "../../../../../core/utilities";
@@ -37,7 +45,7 @@ interface IUseBladeNavigation {
37
45
  }
38
46
 
39
47
  const activeWorkspace = shallowRef<BladeVNode>();
40
-
48
+ const baseUrl = shallowRef<string>();
41
49
  export function useBladeNavigation(): IUseBladeNavigation {
42
50
  const navigationView = inject(navigationViewLocation, undefined) as BladeVNode;
43
51
 
@@ -49,9 +57,7 @@ export function useBladeNavigation(): IUseBladeNavigation {
49
57
 
50
58
  const router = navigationInstance?.router;
51
59
 
52
- const routes = router.getRoutes();
53
-
54
- const mainRouteName = router.getRoutes().find((r) => r.meta?.root)?.name as string;
60
+ const mainRoute = router.getRoutes().find((r) => r.meta?.root)!;
55
61
 
56
62
  const blades = computed(() => {
57
63
  return router.getRoutes().find((routeItem) => {
@@ -59,12 +65,23 @@ export function useBladeNavigation(): IUseBladeNavigation {
59
65
  });
60
66
  }) as ComputedRef<BladeRouteRecordLocationNormalized>;
61
67
 
68
+ function parseWorkspaceUrl(path: string): string {
69
+ // Object.values(route.params)[0] will always be base path of the app
70
+ if (!baseUrl.value) {
71
+ baseUrl.value = "/" + (Object.values(route.params)?.[0] ?? "");
72
+ }
73
+ const pathWithoutBase = path.startsWith(baseUrl.value) ? path.slice(baseUrl.value.length) : path;
74
+ const segments = pathWithoutBase.split("/").filter(Boolean);
75
+ const workspaceUrl = segments.slice(0, 1).join("/");
76
+ return "/" + workspaceUrl;
77
+ }
78
+
62
79
  watch(
63
80
  () => route.path,
64
81
  (newVal) => {
65
- const workspaceUrl = newVal.split("/").slice(0, 2).join("/");
82
+ const workspaceUrl = parseWorkspaceUrl(newVal);
66
83
 
67
- const wsRouteComponent = routes.find((x) => x.path === workspaceUrl)?.components?.default as BladeVNode;
84
+ const wsRouteComponent = router.resolve({ path: workspaceUrl })?.matched?.[1]?.components?.default as BladeVNode;
68
85
 
69
86
  if (wsRouteComponent && wsRouteComponent.type?.isWorkspace) {
70
87
  activeWorkspace.value = wsRouteComponent;
@@ -73,12 +90,18 @@ export function useBladeNavigation(): IUseBladeNavigation {
73
90
  { immediate: true },
74
91
  );
75
92
 
93
+ /**
94
+ * The function `openWorkspace` adds a route to the router and pushes the route to navigate to a
95
+ * specific workspace component.
96
+ * @param - - `blade`: The component to be rendered in the workspace.
97
+ * @returns the result of the `router.push()` method, which is a Promise.
98
+ */
76
99
  async function openWorkspace<Blade extends Component>({ blade, param, options }: IBladeEvent<Blade>) {
77
100
  const createdComponent = h(blade, { param, options }) as BladeVNode;
78
101
 
79
102
  try {
80
103
  if (createdComponent.type?.url) {
81
- router.addRoute(mainRouteName, {
104
+ router.addRoute(mainRoute.name as string, {
82
105
  name: createdComponent.type?.name,
83
106
  path: createdComponent.type?.url,
84
107
  components: {
@@ -97,6 +120,13 @@ export function useBladeNavigation(): IUseBladeNavigation {
97
120
  }
98
121
  }
99
122
 
123
+ /**
124
+ * The `openBlade` function is used to open a blade component in a workspace or navigation view.
125
+ * @param - - `blade`: The component that represents the blade to be opened.
126
+ * @param [isWorkspace=false] - A boolean value indicating whether the blade is being opened as a
127
+ * workspace or not.
128
+ * @returns a Promise that resolves to the result of the `router.push()` method.
129
+ */
100
130
  async function openBlade<Blade extends Component>(
101
131
  { blade, param, options, onOpen, onClose }: IBladeEvent<Blade>,
102
132
  isWorkspace = false,
@@ -110,21 +140,20 @@ export function useBladeNavigation(): IUseBladeNavigation {
110
140
  return await openWorkspace({ blade, param, options });
111
141
  }
112
142
 
113
- const allRoutes = router.getRoutes();
114
-
115
143
  try {
116
144
  const instanceComponent = navigationView || activeWorkspace.value;
117
145
 
118
- if (instanceComponent) {
119
- const initialBlade = allRoutes.find(
120
- (x) =>
121
- x?.path ===
122
- (instanceComponent.props?.navigation?.fullPath
123
- ? instanceComponent.props?.navigation?.fullPath
124
- : activeWorkspace.value?.type.url),
125
- );
146
+ if (instanceComponent && activeWorkspace.value) {
147
+ const initialBlade = router.resolve({
148
+ path: instanceComponent.props?.navigation?.fullPath ?? instanceComponent.type.url,
149
+ })?.matched[1];
126
150
 
127
- const url = initialBlade?.path + (blade.url ? blade.url + (param ? "/" + param : "") : "");
151
+ const base =
152
+ router.resolve({ name: initialBlade?.name }).path + (blade.url ? blade.url + (param ? "/" + param : "") : "");
153
+
154
+ const url = (baseUrl.value === "/" ? "" : baseUrl.value) + base;
155
+
156
+ const rawRouterUrl = mainRoute.path + base;
128
157
 
129
158
  /**
130
159
  * Removes routes without paths and default route from next route.
@@ -160,9 +189,9 @@ export function useBladeNavigation(): IUseBladeNavigation {
160
189
  ),
161
190
  );
162
191
 
163
- router.addRoute(mainRouteName, {
192
+ router.addRoute(mainRoute.name as string, {
164
193
  name: isInitialBlade ? activeWorkspace.value?.type.name : url,
165
- path: url,
194
+ path: rawRouterUrl,
166
195
  components: Object.assign(
167
196
  {},
168
197
  { default: activeWorkspace.value },
@@ -184,12 +213,22 @@ export function useBladeNavigation(): IUseBladeNavigation {
184
213
  path: url,
185
214
  replace: !blade.url,
186
215
  });
216
+ } else {
217
+ throw new Error("No workspace found");
187
218
  }
188
219
  } catch (e) {
189
220
  console.error(e);
190
221
  }
191
222
  }
192
223
 
224
+ /**
225
+ * The function merges the permissions of a workspace blade and a child blade.
226
+ * @param {BladeVNode} workspaceBlade - The `workspaceBlade` parameter is a BladeVNode object
227
+ * representing the workspace blade.
228
+ * @param {BladeVNode | BladeInstanceConstructor} childBlade - The `childBlade` parameter is either a
229
+ * `BladeVNode` or a `BladeInstanceConstructor`.
230
+ * @returns an array of permissions.
231
+ */
193
232
  function mergePermissions(workspaceBlade: BladeVNode, childBlade: BladeVNode | BladeInstanceConstructor) {
194
233
  const child = (isVNode(childBlade) ? childBlade : h(childBlade)) as BladeVNode;
195
234
  if (child && child.type?.permissions) {
@@ -207,11 +246,27 @@ export function useBladeNavigation(): IUseBladeNavigation {
207
246
  } else return workspaceBlade.type.permissions;
208
247
  }
209
248
 
249
+ /**
250
+ * The function removes a specified substring from a given input string.
251
+ * @param {string} inputString - The input string from which the substring will be removed.
252
+ * @param {string} substringToRemove - The `substringToRemove` parameter is a string that represents
253
+ * the substring that you want to remove from the `inputString`.
254
+ * @returns the input string with the specified substring removed.
255
+ */
210
256
  function removeSubstring(inputString: string, substringToRemove: string) {
211
257
  const regex = new RegExp(`${substringToRemove}+$`);
212
258
  return inputString.replace(regex, "");
213
259
  }
214
260
 
261
+ /**
262
+ * The `closeBlade` function is used to close a blade and update the router location if necessary.
263
+ * @param {number} index - The `index` parameter is a number that represents the index of the blade
264
+ * to be closed.
265
+ * @param [changeLocation=true] - A boolean value indicating whether the location should be changed
266
+ * when closing the blade. The default value is `true`.
267
+ * @returns a Promise that resolves to a boolean value if `changeLocation` is true and the router
268
+ * successfully replaces the path, otherwise it returns undefined.
269
+ */
215
270
  async function closeBlade(index: number, changeLocation = true) {
216
271
  console.debug(`[@vc-shell/framework#useBladeNavigation] - closeBlade called.`);
217
272
 
@@ -230,7 +285,7 @@ export function useBladeNavigation(): IUseBladeNavigation {
230
285
  if (routeWithNamedBlade) {
231
286
  const isInitialBlade = activeWorkspace.value?.type.name === routeWithNamedBlade.name;
232
287
 
233
- router.addRoute(mainRouteName, {
288
+ router.addRoute(mainRoute.name as string, {
234
289
  name: isInitialBlade ? routeWithNamedBlade?.name : routeWithNamedBlade?.path,
235
290
  path: routeWithNamedBlade?.path,
236
291
  components: _.omitBy(routeWithNamedBlade?.components, (value: BladeVNode) => {
@@ -244,6 +299,15 @@ export function useBladeNavigation(): IUseBladeNavigation {
244
299
  }
245
300
  }
246
301
 
302
+ /**
303
+ * The function `onParentCall` handles method calls from a parent component and executes the
304
+ * corresponding method if it exists, otherwise it logs an error message.
305
+ * @param parentExposedMethods - parentExposedMethods is an object that contains the methods exposed
306
+ * by the parent blade. Each method is represented as a key-value pair, where the key is the method
307
+ * name and the value is the method itself.
308
+ * @param {IParentCallArgs} args - The `args` parameter is an object that contains the following
309
+ * properties:
310
+ */
247
311
  async function onParentCall(parentExposedMethods: Record<string, any>, args: IParentCallArgs) {
248
312
  console.debug(`vc-app#onParentCall({ method: ${args.method} }) called.`);
249
313
 
@@ -260,6 +324,13 @@ export function useBladeNavigation(): IUseBladeNavigation {
260
324
  }
261
325
  }
262
326
 
327
+ /**
328
+ * The function `resolveBladeByName` resolves a Blade component by its name and returns its
329
+ * constructor.
330
+ * @param {string} name - The `name` parameter is a string that represents the name of a Blade
331
+ * component.
332
+ * @returns a BladeInstanceConstructor, which is the constructor function for a Blade instance.
333
+ */
263
334
  function resolveBladeByName(name: string): BladeInstanceConstructor {
264
335
  if (!instance) {
265
336
  warn("resolveComponentByName can only be used in setup().");
@@ -279,22 +350,49 @@ export function useBladeNavigation(): IUseBladeNavigation {
279
350
  }
280
351
  }
281
352
 
353
+ /**
354
+ * The function `routeResolver` checks if a necessary route exists and generates a route if it
355
+ * doesn't.
356
+ * @param {RouteLocationNormalized} to - The `to` parameter is of type `RouteLocationNormalized`,
357
+ * which represents the target route that needs to be resolved. It contains information about the
358
+ * target route, such as the path, query parameters, and hash.
359
+ * @returns the result of the `generateRoute` function if the `hasNecessaryRoute` function returns
360
+ * false.
361
+ */
282
362
  function routeResolver(to: RouteLocationNormalized) {
283
363
  if (!hasNecessaryRoute(to)) {
284
- return generateRoute(to, router.getRoutes());
364
+ return generateRoute(to, navigationInstance.internalRoutes);
285
365
  }
286
366
  }
287
367
 
368
+ /**
369
+ * The function checks if a given route exists in a list of routes.
370
+ * @param {RouteLocationNormalized} to - The "to" parameter is of type RouteLocationNormalized, which
371
+ * represents the destination route location.
372
+ * @returns a route object from the `routes` array that has a matching `path` property with the
373
+ * `to.path` value.
374
+ */
288
375
  function hasNecessaryRoute(to: RouteLocationNormalized) {
289
- return routes.find((route) => route.path === to.path);
376
+ return router.getRoutes().find((route) => route.path === to.path);
290
377
  }
291
378
 
292
- async function generateRoute(to: RouteLocationNormalized, routes: RouteRecordNormalized[]) {
379
+ /**
380
+ * The function generates a route based on the provided destination and routes, and then pushes the
381
+ * generated route to the router.
382
+ * @param {RouteLocationNormalized} to - The `to` parameter is of type `RouteLocationNormalized` and
383
+ * represents the destination route that we want to generate. It contains information about the path,
384
+ * query parameters, and other route-related data.
385
+ * @param {RouteRecordNormalized[]} routes - The `routes` parameter is an array of
386
+ * `RouteRecordNormalized` objects. Each object represents a route in the application and contains
387
+ * information such as the route path, components to render, and any meta information associated with
388
+ * the route.
389
+ * @returns the result of the `router.push()` method.
390
+ */
391
+ async function generateRoute(to: RouteLocationNormalized, routes: BladeRoutesRecord[]) {
293
392
  const parsedRoutes: TParsedRoute[] = parseRoutes(to.path, routes);
294
393
 
295
394
  const workspace = parsedRoutes[0];
296
- const workspaceComponent = routes.find((route) => route.path === workspace.blade)?.components
297
- ?.default as BladeVNode;
395
+ const workspaceComponent = routes.find((route) => route.route === workspace.blade)?.component;
298
396
 
299
397
  if (workspaceComponent) {
300
398
  const children: Record<string, BladeVNode> = {};
@@ -302,11 +400,10 @@ export function useBladeNavigation(): IUseBladeNavigation {
302
400
  parsedRoutes
303
401
  .filter((r) => r !== workspace)
304
402
  .forEach((parsedRoute, index) => {
305
- const registeredRouteComponent = routes.find((route) => route.path === parsedRoute.blade)?.components
306
- ?.default;
403
+ const registeredRouteComponent = routes.find((route) => route.route === parsedRoute.blade)?.component;
307
404
 
308
405
  if (registeredRouteComponent && parsedRoute.name) {
309
- children[parsedRoute.name] = _.merge(registeredRouteComponent, {
406
+ children[parsedRoute.name] = _.merge({}, registeredRouteComponent, {
310
407
  props: {
311
408
  param: parsedRoute.param,
312
409
  navigation: {
@@ -319,11 +416,11 @@ export function useBladeNavigation(): IUseBladeNavigation {
319
416
  }) as BladeVNode;
320
417
 
321
418
  // Add routes one by one
322
- router.addRoute(mainRouteName, {
419
+ router.addRoute(mainRoute.name as string, {
323
420
  name: parsedRoute.name,
324
421
  path: parsedRoute.name,
325
422
  components: {
326
- default: workspaceComponent,
423
+ default: workspaceComponent, // { param: Object.values(children)[0].props?.param }),
327
424
  ...children,
328
425
  },
329
426
  meta: {
@@ -338,11 +435,11 @@ export function useBladeNavigation(): IUseBladeNavigation {
338
435
  .flatMap((comp) => mergePermissions(workspaceComponent, comp));
339
436
 
340
437
  // Add summary route
341
- router.addRoute(mainRouteName, {
438
+ router.addRoute(mainRoute.name as string, {
342
439
  name: to.path,
343
440
  path: to.path,
344
441
  components: {
345
- default: _.merge(workspaceComponent, { props: { param: Object.values(children)[0].props?.param } }),
442
+ default: workspaceComponent,
346
443
  ...children,
347
444
  },
348
445
  meta: {
@@ -351,10 +448,21 @@ export function useBladeNavigation(): IUseBladeNavigation {
351
448
  });
352
449
 
353
450
  return router.push(to.path);
354
- } else return router.push({ name: mainRouteName });
451
+ } else return router.push({ name: mainRoute.name as string });
355
452
  }
356
453
 
357
- function parseRoutes(route: string, commonRoutes: RouteRecordNormalized[]) {
454
+ /**
455
+ * The function `parseRoutes` takes a route string and an array of common routes, and returns an
456
+ * array of route objects with blade, param, and name properties.
457
+ * @param {string} route - The `route` parameter is a string representing a route path. It is the
458
+ * route that needs to be parsed into its individual parts.
459
+ * @param {RouteRecordNormalized[]} commonRoutes - commonRoutes is an array of RouteRecordNormalized
460
+ * objects. Each object represents a common route in the application and has properties like "path"
461
+ * which represents the route path.
462
+ * @returns The function `parseRoutes` returns an array of objects. Each object in the array
463
+ * represents a part of the route and contains the following properties: blade, param, and name.
464
+ */
465
+ function parseRoutes(route: string, commonRoutes: BladeRoutesRecord[]) {
358
466
  const parts: string[] = route.split("/").filter((part) => part !== "");
359
467
  const result = [];
360
468
  let currentBlade = "";
@@ -362,13 +470,22 @@ export function useBladeNavigation(): IUseBladeNavigation {
362
470
 
363
471
  for (let i = 0; i < parts.length; i++) {
364
472
  currentBlade = "/" + parts[i];
473
+
474
+ /**
475
+ * If current blade is not registered in routes, then it's a param
476
+ */
477
+ if (!navigationInstance.internalRoutes.some((x) => currentBlade === x?.route)) {
478
+ baseUrl.value = currentBlade;
479
+ continue;
480
+ }
481
+
365
482
  let currentParam = null;
366
483
 
367
484
  if (i + 1 < parts.length) {
368
485
  const nextPart = "/" + parts.slice(i + 1, i + 2).join("/");
369
486
  currentName += currentBlade;
370
487
 
371
- if (!commonRoutes.some((route) => nextPart === route.path)) {
488
+ if (!commonRoutes.some((route) => nextPart === route.route)) {
372
489
  currentParam = parts[i + 1];
373
490
  currentName += "/" + currentParam;
374
491
  i++; // Skip the next part as it's a param
@@ -388,6 +505,10 @@ export function useBladeNavigation(): IUseBladeNavigation {
388
505
  return result;
389
506
  }
390
507
 
508
+ /**
509
+ * The function getCurrentBlade returns the current BladeVNode instance's vnode.
510
+ * @returns the `vnode` property of the `instance` object, which is of type `BladeVNode`.
511
+ */
391
512
  function getCurrentBlade(): BladeVNode {
392
513
  return instance.vnode;
393
514
  }
@@ -1,7 +1,7 @@
1
1
  import { Router } from "vue-router";
2
- import { App } from "vue";
2
+ import { App, inject } from "vue";
3
3
  import * as components from "./components";
4
- import { BladeNavigationPlugin } from "./types";
4
+ import { BladeNavigationPlugin, BladeRoutesRecord } from "./types";
5
5
 
6
6
  // Declare globally
7
7
  declare module "@vue/runtime-core" {
@@ -19,9 +19,12 @@ export const VcBladeNavigationComponent = {
19
19
  app.component(componentName, component);
20
20
  });
21
21
 
22
+ const internalRoutes = app.runWithContext(() => inject("bladeRoutes")) as BladeRoutesRecord[];
23
+
22
24
  // Plugin
23
25
  const bladeNavigationPlugin: BladeNavigationPlugin = {
24
26
  router: args.router,
27
+ internalRoutes,
25
28
  };
26
29
 
27
30
  app.config.globalProperties.$bladeNavigationPlugin = bladeNavigationPlugin;
@@ -74,6 +74,14 @@ export interface IBladeEvent<T extends Component = Component> {
74
74
 
75
75
  export interface BladeNavigationPlugin {
76
76
  router: Router;
77
+ internalRoutes: BladeRoutesRecord[];
78
+ }
79
+
80
+ export interface BladeRoutesRecord {
81
+ component: BladeVNode;
82
+ name: string;
83
+ isWorkspace: boolean;
84
+ route: string;
77
85
  }
78
86
 
79
87
  type VNodeMountHook = (vnode: BladeVNode | VNode) => void;
@@ -156,12 +156,15 @@ const unwatchTitle = watch(
156
156
  { immediate: true },
157
157
  );
158
158
 
159
- useBeforeUnload(
160
- computed(() => {
161
- const toolBarSave = _.get(toValue(scope)?.toolbarOverrides, "saveChanges") as unknown as IBladeToolbar;
162
- return !unref(toolBarSave && "disabled" in toolBarSave && toolBarSave.disabled) || validationState.value.validated;
163
- }),
164
- );
159
+ /**
160
+ * Validated state. Uses 'disabled' property from toolbarOverrides.saveChanges OR validationState.validated
161
+ */
162
+ const validated = computed(() => {
163
+ const toolBarSave = _.get(toValue(scope)?.toolbarOverrides, "saveChanges") as unknown as IBladeToolbar;
164
+ return !unref(toolBarSave && "disabled" in toolBarSave && toolBarSave.disabled) || validationState.value.validated;
165
+ });
166
+
167
+ useBeforeUnload(validated);
165
168
 
166
169
  const settings = computed(() => props.model?.settings);
167
170
 
@@ -280,9 +283,10 @@ onBeforeMount(async () => {
280
283
 
281
284
  onBeforeRouteLeave(async (to) => {
282
285
  if (
283
- currentBladeNavigationData.value?.fullPath &&
284
- !to.path.includes(currentBladeNavigationData.value?.fullPath) &&
285
- validationState.value.modified
286
+ (settings.value?.url
287
+ ? currentBladeNavigationData.value?.fullPath && !to.path.includes(currentBladeNavigationData.value?.fullPath)
288
+ : true) &&
289
+ unref(validated)
286
290
  ) {
287
291
  return await showConfirmation(
288
292
  unref(