@oinone/kunlun-vue-widget 6.4.9 → 7.2.0

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 (72) hide show
  1. package/dist/oinone-kunlun-vue-widget.esm.js +1 -16
  2. package/dist/types/index.d.ts +1 -1
  3. package/dist/types/src/basic/AsyncVueWidget.d.ts +7 -7
  4. package/dist/types/src/basic/VueFragment.vue.d.ts +2 -2
  5. package/dist/types/src/basic/VueWidget.d.ts +339 -331
  6. package/dist/types/src/basic/Widget.d.ts +260 -257
  7. package/dist/types/src/basic/index.d.ts +3 -3
  8. package/dist/types/src/data/ActiveRecordsWidget.d.ts +271 -261
  9. package/dist/types/src/data/PathWidget.d.ts +34 -34
  10. package/dist/types/src/data/index.d.ts +2 -2
  11. package/dist/types/src/dsl/DslDefinitionWidget.d.ts +66 -68
  12. package/dist/types/src/dsl/DslNodeWidget.d.ts +42 -42
  13. package/dist/types/src/dsl/DslRenderWidget.d.ts +47 -44
  14. package/dist/types/src/dsl/index.d.ts +3 -3
  15. package/dist/types/src/feature/index.d.ts +1 -1
  16. package/dist/types/src/feature/invisible-supported.d.ts +11 -11
  17. package/dist/types/src/hooks/all-mounted.d.ts +20 -20
  18. package/dist/types/src/hooks/index.d.ts +1 -1
  19. package/dist/types/src/index.d.ts +10 -10
  20. package/dist/types/src/state/context.d.ts +41 -41
  21. package/dist/types/src/state/global.d.ts +3 -4
  22. package/dist/types/src/state/index.d.ts +3 -3
  23. package/dist/types/src/state/method/action.d.ts +18 -18
  24. package/dist/types/src/state/method/field.d.ts +3 -3
  25. package/dist/types/src/state/method/index.d.ts +2 -2
  26. package/dist/types/src/state/typing.d.ts +112 -105
  27. package/dist/types/src/state/use-state.d.ts +15 -16
  28. package/dist/types/src/state/view.d.ts +5 -5
  29. package/dist/types/src/token/index.d.ts +2 -2
  30. package/dist/types/src/typing/WidgetTagContext.d.ts +39 -39
  31. package/dist/types/src/typing/WidgetTagProps.d.ts +23 -23
  32. package/dist/types/src/typing/index.d.ts +3 -3
  33. package/dist/types/src/typing/typing.d.ts +7 -7
  34. package/dist/types/src/util/dsl-render.d.ts +106 -106
  35. package/dist/types/src/util/index.d.ts +4 -4
  36. package/dist/types/src/util/install.d.ts +4 -4
  37. package/dist/types/src/util/render.d.ts +7 -7
  38. package/dist/types/src/util/widget-manager.d.ts +4 -4
  39. package/dist/types/src/view/index.d.ts +161 -161
  40. package/package.json +29 -18
  41. package/src/basic/AsyncVueWidget.ts +2 -2
  42. package/src/basic/VueWidget.ts +67 -31
  43. package/src/basic/Widget.ts +11 -9
  44. package/src/basic/__tests__/Widget.spec.ts +82 -0
  45. package/src/data/ActiveRecordsWidget.ts +51 -21
  46. package/src/data/PathWidget.ts +1 -1
  47. package/src/dsl/DslDefinitionWidget.ts +10 -33
  48. package/src/dsl/DslNodeWidget.ts +3 -3
  49. package/src/dsl/DslRenderWidget.ts +32 -3
  50. package/src/feature/__tests__/invisible-supported.spec.ts +31 -0
  51. package/src/hooks/__tests__/all-mounted.spec.ts +41 -0
  52. package/src/hooks/all-mounted.ts +1 -1
  53. package/src/shim-translate.d.ts +5 -2
  54. package/src/state/__tests__/state.spec.ts +114 -0
  55. package/src/state/context.ts +6 -2
  56. package/src/state/global.ts +16 -5
  57. package/src/state/method/action.ts +7 -2
  58. package/src/state/method/field.ts +1 -1
  59. package/src/state/typing.ts +10 -0
  60. package/src/state/use-state.ts +2 -2
  61. package/src/state/view.ts +3 -3
  62. package/src/token/index.ts +1 -1
  63. package/src/typing/WidgetTagContext.ts +3 -3
  64. package/src/typing/WidgetTagProps.ts +2 -2
  65. package/src/util/__tests__/dsl-render.spec.ts +112 -0
  66. package/src/util/__tests__/render.spec.ts +69 -0
  67. package/src/util/__tests__/widget-manager.spec.ts +27 -0
  68. package/src/util/dsl-render.ts +6 -7
  69. package/src/util/install.ts +1 -1
  70. package/src/util/render.ts +3 -7
  71. package/src/view/index.ts +15 -8
  72. package/rollup.config.js +0 -22
@@ -1,4 +1,4 @@
1
- import { Component, Directive, Plugin } from 'vue';
2
- export declare function componentInstall(component: Component, name?: string | string[]): void;
3
- export declare function directiveInstall(directive: Directive, name: string): void;
4
- export declare function pluginInstall(plugin: Plugin, ...options: unknown[]): void;
1
+ import type { Component, Directive, Plugin } from 'vue';
2
+ export declare function componentInstall(component: Component, name?: string | string[]): void;
3
+ export declare function directiveInstall(directive: Directive, name: string): void;
4
+ export declare function pluginInstall(plugin: Plugin, ...options: unknown[]): void;
@@ -1,7 +1,7 @@
1
- import { Slots, VNode } from 'vue';
2
- import { VueWidget } from '../basic';
3
- export declare function renderWidgets(widgets: VueWidget[], ctx: Record<string, unknown>, slots?: Slots): VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
- [key: string]: any;
5
- }> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
6
- [key: string]: any;
7
- }>[] | undefined;
1
+ import type { Slots, VNode } from 'vue';
2
+ import { VueWidget } from '../basic';
3
+ export declare function renderWidgets(widgets: VueWidget[], ctx: Record<string, unknown>, slots?: Slots): VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
+ [key: string]: any;
5
+ }> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
6
+ [key: string]: any;
7
+ }>[] | undefined;
@@ -1,4 +1,4 @@
1
- import { VueWidget } from '../basic';
2
- export declare function newVueWidget(): VueWidget;
3
- export declare function getWidget(handler: string): VueWidget | undefined;
4
- export declare function getWidgetNotNull(handle: string): VueWidget;
1
+ import { VueWidget } from '../basic';
2
+ export declare function newVueWidget(): VueWidget;
3
+ export declare function getWidget(handler: string): VueWidget | undefined;
4
+ export declare function getWidgetNotNull(handle: string): VueWidget;
@@ -1,161 +1,161 @@
1
- import { EntityBody, IViewProps, ListVM, ObjectVM, RuntimeModel } from '@oinone/kunlun-engine';
2
- import { LifeCycleTypes, ViewEventName } from '@oinone/kunlun-event';
3
- import { Entity, IDslNode, IModel, IView, ViewElement, ViewId, ViewType } from '@oinone/kunlun-meta';
4
- import { Matched } from '@oinone/kunlun-router';
5
- import { Constructor } from '@oinone/kunlun-shared';
6
- import { SPIOptions, SPISingleSelector, SPITokenFactory } from '@oinone/kunlun-spi';
7
- import { DslNodeWidget } from '../dsl/DslNodeWidget';
8
- export interface IViewFilterOptions extends SPIOptions {
9
- id?: ViewId[] | ViewId;
10
- name?: string[] | string;
11
- type?: ViewType[] | ViewType;
12
- model?: string[] | string;
13
- widget?: string[] | string;
14
- tagName?: string[] | string;
15
- }
16
- declare type WatchCb<T> = (value: T, oldValue: T) => void;
17
- export declare abstract class ViewWidget<ViewData = any, VP extends IViewProps = any, VM extends ListVM | ObjectVM = any> extends DslNodeWidget<VP> {
18
- static Token: SPITokenFactory<IViewFilterOptions>;
19
- static Selector: SPISingleSelector<IViewFilterOptions, Constructor<ViewWidget>>;
20
- protected loading: boolean;
21
- protected currentRoute: Matched;
22
- rootData: EntityBody;
23
- private subjectRoute$;
24
- private $$vm;
25
- getVM(): VM;
26
- setVM($$vm: VM): void;
27
- /**
28
- * 设置loading
29
- */
30
- setBusy(busy: boolean): void;
31
- /**
32
- * 获取url参数
33
- *
34
- * @returns {Record<string, string>}
35
- */
36
- getUrlParams(): any;
37
- /**
38
- * 获取当前是否处于loading状态
39
- */
40
- getBusy(): boolean;
41
- initialize(props: VP): this;
42
- protected domain: string;
43
- private filter;
44
- private parentRootHandlerStr;
45
- private currentRootHandlerStr;
46
- private get rootHandleStr();
47
- isRootView: boolean;
48
- /**
49
- * 监听视图的事件
50
- * @param event 事件名 / 事件对象
51
- * @param handler? 回调函数
52
- *
53
- * @example
54
- *
55
- * 单个事件监听
56
- * viewWidget.on('change', (fieldInstance) => {})
57
- * viewWidget.on('blur', (fieldInstance) => {})
58
- */
59
- on<V = ViewWidget>(event: {
60
- [key in ViewEventName]?: (view: V) => void;
61
- }): void;
62
- /**
63
- * 多个事件监听
64
- *
65
- * @example
66
- *
67
- * viewWidget.on({
68
- * change(fieldInstance) => {},
69
- * blur(fieldInstance) => {},
70
- * })
71
- */
72
- on<V = ViewWidget>(event: ViewEventName, handler: (view: V) => void): void;
73
- /**
74
- * 用来监听视图数据的的变化
75
- *
76
- * @param {(value, oldValue):void} cb 监听数据发生变化的回调函数
77
- * @param {object} options 可配置选项
78
- * watchKey -> 当key对应的value发生变化后,才会触发回调用函数
79
- * "如果要监听的数据是对象,那么该参数不会生效"
80
- * distinct -> 是否去重(当上一个值跟当前的值相当的时候,就不会处理)
81
- *
82
- * @example
83
- * const widget = this.createWidget(FormWidget, undefined, {....})
84
- * widget.watch((value) => {....})
85
- *
86
- */
87
- watch(cb: WatchCb<ViewData>): any;
88
- watch(cb: WatchCb<ViewData>, options: {
89
- watchKey?: string;
90
- distinct?: boolean;
91
- }): any;
92
- watch(cb: WatchCb<ViewData>, options: {
93
- watchKey?: string[];
94
- distinct?: boolean;
95
- }): any;
96
- /**
97
- * 如果没有key,就不做任何处理
98
- * 如果key不是字符串类型,也不是数组类型,那么不做任何处理
99
- */
100
- protected filterWatchData(pre: ViewData, next: ViewData, key: string | string[]): boolean;
101
- isDialogView: boolean;
102
- /**
103
- * 当前的widget是不是更节点
104
- */
105
- get isRoot(): boolean;
106
- get useConstruct(): boolean;
107
- private selfHandleStr;
108
- view: IView;
109
- protected model: RuntimeModel | null;
110
- protected type: 'FORM' | 'TABLE' | 'UNKNOWN';
111
- /**
112
- * 页面默认的参数, A页面跳转到B页面,期望能带入参数过去
113
- */
114
- protected initQueryParams: Record<string, string> | null;
115
- get viewElement(): ViewElement | any;
116
- protected resolveTemplate(): void;
117
- fetchData(data?: Entity[], options?: any, variables?: Record<string, unknown>): unknown;
118
- onRowsChange(data: any[]): void;
119
- loadData(data: ViewData, reset?: boolean): unknown;
120
- /**
121
- * 加载`rootData` 数据
122
- */
123
- loadRootData(content: any): void;
124
- setRootDataByKey(key: string, value: any): void;
125
- submit(): unknown;
126
- getData(): ViewData;
127
- setData(content: ViewData): void;
128
- validator(): Promise<any[]>;
129
- /**
130
- * 加载元数据,允许被重写
131
- *
132
- * @param {IModel} model 模型
133
- * @param {IDslNode} dslNode? dslNode,如果不传入,会自动创建
134
- * @param {IView} view? 视图,如果不传入,会自动创建
135
- * @param {ViewType} viewType? 指定视图类型
136
- */
137
- loadMetadata(model: IModel, dslNode?: IDslNode, view?: IView, viewType?: ViewType): void;
138
- getActiveRecords(): Entity[];
139
- setDomain(domain: string): void;
140
- getDomain(): string;
141
- setFilter(f: string): void;
142
- getFilter(): string;
143
- getModel(): IModel;
144
- getView(): IView;
145
- path: string;
146
- getPath(): string;
147
- notify(type: LifeCycleTypes): void;
148
- $$beforeCreated(): void;
149
- $$created(): void;
150
- $$beforeMount(): void;
151
- $$mounted(): void;
152
- $$beforeUpdate(): void;
153
- $$updated(): void;
154
- $$beforeUnmount(): void;
155
- $$unmounted(): void;
156
- }
157
- /**
158
- * @deprecated 移动端未修改,必须移除该定义
159
- */
160
- export declare const ViewSubSymbol: unique symbol;
161
- export {};
1
+ import { type EntityBody, type IViewProps, ListVM, ObjectVM, type RuntimeModel } from '@oinone/kunlun-engine';
2
+ import { LifeCycleTypes, type ViewEventName } from '@oinone/kunlun-event';
3
+ import { type Entity, type IDslNode, type IModel, type IView, ViewElement, type ViewId, ViewType } from '@oinone/kunlun-meta';
4
+ import { type Matched } from '@oinone/kunlun-router';
5
+ import type { Constructor } from '@oinone/kunlun-shared';
6
+ import { type SPIOptions, type SPISingleSelector, type SPITokenFactory } from '@oinone/kunlun-spi';
7
+ import { DslNodeWidget } from '../dsl/DslNodeWidget';
8
+ export interface IViewFilterOptions extends SPIOptions {
9
+ id?: ViewId[] | ViewId;
10
+ name?: string[] | string;
11
+ type?: ViewType[] | ViewType;
12
+ model?: string[] | string;
13
+ widget?: string[] | string;
14
+ tagName?: string[] | string;
15
+ }
16
+ type WatchCb<T> = (value: T, oldValue: T) => void;
17
+ export declare abstract class ViewWidget<ViewData = any, VP extends IViewProps = any, VM extends ListVM | ObjectVM = any> extends DslNodeWidget<VP> {
18
+ static Token: SPITokenFactory<IViewFilterOptions>;
19
+ static Selector: SPISingleSelector<IViewFilterOptions, Constructor<ViewWidget>>;
20
+ protected loading: boolean;
21
+ protected currentRoute: Matched;
22
+ rootData: EntityBody;
23
+ private subjectRoute$;
24
+ private $$vm;
25
+ getVM(): VM;
26
+ setVM($$vm: VM): void;
27
+ /**
28
+ * 设置loading
29
+ */
30
+ setBusy(busy: boolean): void;
31
+ /**
32
+ * 获取url参数
33
+ *
34
+ * @returns {Record<string, string>}
35
+ */
36
+ getUrlParams(): any;
37
+ /**
38
+ * 获取当前是否处于loading状态
39
+ */
40
+ getBusy(): boolean;
41
+ initialize(props: VP): this;
42
+ protected domain: string;
43
+ private filter;
44
+ private parentRootHandlerStr;
45
+ private currentRootHandlerStr;
46
+ private get rootHandleStr();
47
+ isRootView: boolean;
48
+ /**
49
+ * 监听视图的事件
50
+ * @param event 事件名 / 事件对象
51
+ * @param handler? 回调函数
52
+ *
53
+ * @example
54
+ *
55
+ * 单个事件监听
56
+ * viewWidget.on('change', (fieldInstance) => {})
57
+ * viewWidget.on('blur', (fieldInstance) => {})
58
+ */
59
+ on<V = ViewWidget>(event: {
60
+ [key in ViewEventName]?: (view: V) => void;
61
+ }): void;
62
+ /**
63
+ * 多个事件监听
64
+ *
65
+ * @example
66
+ *
67
+ * viewWidget.on({
68
+ * change(fieldInstance) => {},
69
+ * blur(fieldInstance) => {},
70
+ * })
71
+ */
72
+ on<V = ViewWidget>(event: ViewEventName, handler: (view: V) => void): void;
73
+ /**
74
+ * 用来监听视图数据的的变化
75
+ *
76
+ * @param {(value, oldValue):void} cb 监听数据发生变化的回调函数
77
+ * @param {object} options 可配置选项
78
+ * watchKey -> 当key对应的value发生变化后,才会触发回调用函数
79
+ * "如果要监听的数据是对象,那么该参数不会生效"
80
+ * distinct -> 是否去重(当上一个值跟当前的值相当的时候,就不会处理)
81
+ *
82
+ * @example
83
+ * const widget = this.createWidget(FormWidget, undefined, {....})
84
+ * widget.watch((value) => {....})
85
+ *
86
+ */
87
+ watch(cb: WatchCb<ViewData>): any;
88
+ watch(cb: WatchCb<ViewData>, options: {
89
+ watchKey?: string;
90
+ distinct?: boolean;
91
+ }): any;
92
+ watch(cb: WatchCb<ViewData>, options: {
93
+ watchKey?: string[];
94
+ distinct?: boolean;
95
+ }): any;
96
+ /**
97
+ * 如果没有key,就不做任何处理
98
+ * 如果key不是字符串类型,也不是数组类型,那么不做任何处理
99
+ */
100
+ protected filterWatchData(pre: ViewData, next: ViewData, key: string | string[]): boolean;
101
+ isDialogView: boolean;
102
+ /**
103
+ * 当前的widget是不是更节点
104
+ */
105
+ get isRoot(): boolean;
106
+ get useConstruct(): boolean;
107
+ private selfHandleStr;
108
+ view: IView;
109
+ protected model: RuntimeModel | null;
110
+ protected type: 'FORM' | 'TABLE' | 'UNKNOWN';
111
+ /**
112
+ * 页面默认的参数, A页面跳转到B页面,期望能带入参数过去
113
+ */
114
+ protected initQueryParams: Record<string, string> | null;
115
+ get viewElement(): ViewElement | any;
116
+ protected resolveTemplate(): void;
117
+ fetchData(data?: Entity[], options?: any, variables?: Record<string, unknown>): unknown;
118
+ onRowsChange(data: any[]): void;
119
+ loadData(data: ViewData, reset?: boolean): unknown;
120
+ /**
121
+ * 加载`rootData` 数据
122
+ */
123
+ loadRootData(content: any): void;
124
+ setRootDataByKey(key: string, value: any): void;
125
+ submit(): unknown;
126
+ getData(): ViewData;
127
+ setData(content: ViewData): void;
128
+ validator(): Promise<any[]>;
129
+ /**
130
+ * 加载元数据,允许被重写
131
+ *
132
+ * @param {IModel} model 模型
133
+ * @param {IDslNode} dslNode? dslNode,如果不传入,会自动创建
134
+ * @param {IView} view? 视图,如果不传入,会自动创建
135
+ * @param {ViewType} viewType? 指定视图类型
136
+ */
137
+ loadMetadata(model: IModel, dslNode?: IDslNode, view?: IView, viewType?: ViewType): void;
138
+ getActiveRecords(): Entity[];
139
+ setDomain(domain: string): void;
140
+ getDomain(): string;
141
+ setFilter(f: string): void;
142
+ getFilter(): string;
143
+ getModel(): IModel;
144
+ getView(): IView;
145
+ path: string;
146
+ getPath(): string;
147
+ notify(type: LifeCycleTypes): void;
148
+ $$beforeCreated(): void;
149
+ $$created(): void;
150
+ $$beforeMount(): void;
151
+ $$mounted(): void;
152
+ $$beforeUpdate(): void;
153
+ $$updated(): void;
154
+ $$beforeUnmount(): void;
155
+ $$unmounted(): void;
156
+ }
157
+ /**
158
+ * @deprecated 移动端未修改,必须移除该定义
159
+ */
160
+ export declare const ViewSubSymbol: unique symbol;
161
+ export {};
package/package.json CHANGED
@@ -1,35 +1,46 @@
1
1
  {
2
2
  "name": "@oinone/kunlun-vue-widget",
3
- "version": "6.4.9",
4
- "main": "index.ts",
3
+ "version": "7.2.0",
4
+ "type": "module",
5
+ "main": "dist/oinone-kunlun-vue-widget.esm.js",
5
6
  "scripts": {
6
7
  "prebuild": "rimraf dist",
7
8
  "build": "rollup -c",
8
9
  "dist": "npm run prepublishOnly",
9
10
  "index": "npm run postpublish",
10
- "x-prepublishOnly": "node ../../scripts/prepublish-only.js",
11
- "x-postpublish": "node ../../scripts/postpublish.js"
11
+ "format": "prettier --write --experimental-cli src/",
12
+ "test": "jest",
13
+ "prepublishOnly": "node ../../../../scripts/prepublish-only.cjs",
14
+ "deploy": "npm publish --exact",
15
+ "postpublish": "node ../../../../scripts/postpublish.cjs"
12
16
  },
13
17
  "dependencies": {
14
- "@oinone/kunlun-vue-ui-common": "6.4.9"
18
+ "@oinone/kunlun-vue-ui-common": "7.2.0"
15
19
  },
16
20
  "devDependencies": {
17
- "@oinone/kunlun-config": "~6.4.0",
18
- "@oinone/kunlun-dsl": "~6.4.0",
19
- "@oinone/kunlun-engine": "~6.4.0",
20
- "@oinone/kunlun-event": "~6.4.0",
21
- "@oinone/kunlun-meta": "~6.4.0",
22
- "@oinone/kunlun-router": "~6.4.0",
23
- "@oinone/kunlun-shared": "~6.4.0",
24
- "@oinone/kunlun-spi": "~6.4.0",
25
- "@oinone/kunlun-state": "~6.4.0",
26
- "@types/lodash": "4.14.182",
21
+ "@oinone/kunlun-config": "~7.2.0",
22
+ "@oinone/kunlun-dsl": "~7.2.0",
23
+ "@oinone/kunlun-engine": "~7.2.0",
24
+ "@oinone/kunlun-event": "~7.2.0",
25
+ "@oinone/kunlun-meta": "~7.2.0",
26
+ "@oinone/kunlun-router": "~7.2.0",
27
+ "@oinone/kunlun-shared": "~7.2.0",
28
+ "@oinone/kunlun-spi": "~7.2.0",
29
+ "@oinone/kunlun-state": "~7.2.0",
30
+ "@types/lodash": "4.17.21",
27
31
  "@types/lodash-es": "4.17.6",
28
32
  "lodash": "4.17.21",
29
33
  "lodash-es": "4.17.21"
30
34
  },
31
35
  "peerDependencies": {
32
- "vue": ">=3.2.40"
36
+ "vue": ">=3.5.26"
33
37
  },
34
- "gitHead": "2b4c0c7911626c105ca71c2d41e54af470e2e079"
35
- }
38
+ "gitHead": "2b4c0c7911626c105ca71c2d41e54af470e2e079",
39
+ "module": "dist/oinone-kunlun-vue-widget.esm.js",
40
+ "typings": "dist/types/index.d.ts",
41
+ "files": [
42
+ "dist",
43
+ "index.ts",
44
+ "src"
45
+ ]
46
+ }
@@ -1,5 +1,5 @@
1
- import { h, Suspense, VNode, SetupContext } from 'vue';
2
- import { SetupHook, VueWidget } from './VueWidget';
1
+ import { h, Suspense, type VNode, type SetupContext } from 'vue';
2
+ import { type SetupHook, VueWidget } from './VueWidget';
3
3
 
4
4
  export class AsyncVueWidget extends VueWidget {
5
5
  public setup(setupHook?: SetupHook) {
@@ -1,25 +1,27 @@
1
- import { genStaticPath, translateValueByKey, WidgetConstructor, WidgetProps } from '@oinone/kunlun-engine';
1
+ import { genStaticPath, translateValueByKey, type WidgetConstructor, type WidgetProps } from '@oinone/kunlun-engine';
2
2
  import { uniqueKeyGenerator } from '@oinone/kunlun-shared';
3
- import { ComponentPublicInstance } from '@vue/runtime-core';
4
3
  import {
5
- Component,
6
- ComponentOptions,
4
+ type Component,
5
+ type ComponentOptions,
6
+ type ComponentPublicInstance,
7
7
  computed,
8
8
  createVNode,
9
9
  defineComponent,
10
- DefineComponent,
11
- EffectScope,
10
+ type DefineComponent,
11
+ type EffectScope,
12
12
  effectScope,
13
13
  isRef,
14
14
  nextTick,
15
15
  ref,
16
- Ref,
17
- Slot,
18
- Slots,
16
+ type Ref,
17
+ type Slot,
18
+ type Slots,
19
19
  toRaw,
20
- VNode,
21
- watch
20
+ type VNode,
21
+ watch,
22
+ withCtx
22
23
  } from 'vue';
24
+ import { useInjectMetaContext, useProviderMetaContext } from '../state';
23
25
  import VueFragment from './VueFragment.vue';
24
26
  import { Widget } from './Widget';
25
27
 
@@ -70,7 +72,7 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
70
72
  /**
71
73
  * vue实例内属性(props、computed、data)的集合
72
74
  */
73
- private res?: {};
75
+ private res?: object;
74
76
 
75
77
  public revolveNodeCode() {
76
78
  return uniqueKeyGenerator();
@@ -100,14 +102,14 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
100
102
  if (compute) {
101
103
  if (compute.get) {
102
104
  if (!compute.set) {
103
- Reflect.set(result, displayName, computed(compute.get!.bind(opt)));
105
+ Reflect.set(result, displayName, computed(compute.get.bind(opt)));
104
106
  } else {
105
107
  Reflect.set(
106
108
  result,
107
109
  displayName,
108
110
  computed({
109
- get: compute.get!.bind(opt),
110
- set: compute.set!.bind(opt)
111
+ get: compute.get.bind(opt),
112
+ set: compute.set.bind(opt)
111
113
  })
112
114
  );
113
115
  }
@@ -290,7 +292,7 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
290
292
  ) => {
291
293
  const afterHosts = VueWidget.afterHooks.get(target.constructor.name) || new Map();
292
294
  const afterHooks = afterHosts.get(host) || [];
293
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
295
+
294
296
  afterHooks.push(description.value!);
295
297
  afterHosts.set(host, afterHooks);
296
298
  VueWidget.afterHooks.set(target.constructor.name, afterHosts);
@@ -464,7 +466,7 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
464
466
 
465
467
  const hosts = VueWidget.getHookHosts(this);
466
468
  hosts.forEach((hookName) => {
467
- const host = Reflect.get(this, hookName);
469
+ const host = Reflect.get(this, hookName) as Function;
468
470
  Reflect.set(this, hookName, (...args: unknown[]) => {
469
471
  if (hookName === 'render') {
470
472
  return host.apply(operator, args);
@@ -587,6 +589,7 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
587
589
  this.behaviorGroup[BehaviorName.mounted]?.();
588
590
  this.$$mounted.call(opt);
589
591
  this.mounted.call(opt);
592
+ this.$$mountedAfterProperties.call(opt);
590
593
  },
591
594
  beforeUpdate: () => {
592
595
  this.behaviorGroup[BehaviorName.beforeUpdate]?.();
@@ -624,7 +627,10 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
624
627
  const { $slots } = ctx;
625
628
  const componentProps = this.resolveProps(component, props);
626
629
 
627
- const children = $slots && Object.keys($slots).length ? $slots : this.resolveChildren();
630
+ const children = {
631
+ ...this.resolveChildren(),
632
+ ...$slots
633
+ };
628
634
 
629
635
  const expandCom = this.renderExpandComponent() as VNode;
630
636
  const expandSlot = {} as Record<string, any>;
@@ -721,20 +727,33 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
721
727
  * @protected
722
728
  */
723
729
  protected resolveChildren(): Record<string, Slot> {
724
- const result = {};
725
- const slots: string[] = [];
726
- const children = this.getChildren();
727
- children.forEach((c) => {
728
- if (!slots.includes(c.getName())) {
729
- slots.push(c.getName());
730
+ const slotWidgets: Record<string, Widget[]> = {};
731
+ const children: Widget[] = this.getChildren();
732
+ for (const child of children) {
733
+ const slotName = child.getName();
734
+ let widgets: Widget[] | undefined = slotWidgets[slotName];
735
+ if (!widgets) {
736
+ widgets = [];
737
+ slotWidgets[slotName] = widgets;
730
738
  }
731
- });
732
- slots.forEach((s) => {
733
- Reflect.set(result, s, (...args: unknown[]) =>
734
- children.filter((c) => c.getName() === s).map((c) => c.render(...args))
735
- );
736
- });
737
- return result;
739
+ widgets.push(child);
740
+ }
741
+ const slots: Record<string, Slot> = {};
742
+ for (const [slotName, widgets] of Object.entries(slotWidgets)) {
743
+ slots[slotName] = withCtx((context: Record<string, unknown>) => {
744
+ const vNodes: VNode[] = [];
745
+ for (const widget of widgets) {
746
+ const result = widget.render(context) as VNode | VNode[];
747
+ if (Array.isArray(result)) {
748
+ vNodes.push(...result);
749
+ } else {
750
+ vNodes.push(result);
751
+ }
752
+ }
753
+ return vNodes;
754
+ }) as Slot;
755
+ }
756
+ return slots;
738
757
  }
739
758
 
740
759
  /**
@@ -749,6 +768,7 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
749
768
  this.$$beforeCreated();
750
769
  this.beforeCreated();
751
770
  this.behaviorGroup[BehaviorName.created]?.();
771
+ this.$$metaContextProvide();
752
772
  this.$$created();
753
773
  this.created();
754
774
  return {};
@@ -857,6 +877,17 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
857
877
  */
858
878
  protected created() {}
859
879
 
880
+ /**
881
+ * @internal
882
+ */
883
+ protected $$metaContextProvide() {
884
+ const metaContext = useInjectMetaContext();
885
+ useProviderMetaContext({
886
+ ...metaContext,
887
+ parentHandle: computed(() => this.getHandle())
888
+ });
889
+ }
890
+
860
891
  /**
861
892
  * @internal
862
893
  */
@@ -884,6 +915,11 @@ export class VueWidget<Props extends WidgetProps = WidgetProps> extends Widget<P
884
915
  */
885
916
  protected $$mounted() {}
886
917
 
918
+ /**
919
+ * @internal
920
+ */
921
+ protected $$mountedAfterProperties() {}
922
+
887
923
  /**
888
924
  * Vue钩子
889
925
  * @protected