@ibiz-template/vue3-util 0.4.3 → 0.4.5

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 (55) hide show
  1. package/dist/index.min.css +1 -1
  2. package/dist/index.system.min.js +1 -2
  3. package/es/index.mjs +4 -0
  4. package/es/panel-component/index.d.ts +2 -0
  5. package/es/panel-component/index.d.ts.map +1 -1
  6. package/es/panel-component/index.mjs +4 -0
  7. package/es/panel-component/nav-pos/nav-pos.controller.d.ts +10 -0
  8. package/es/panel-component/nav-pos/nav-pos.controller.d.ts.map +1 -1
  9. package/es/panel-component/nav-pos/nav-pos.controller.mjs +35 -17
  10. package/es/panel-component/panel-container-group/index.d.ts +29 -0
  11. package/es/panel-component/panel-container-group/index.d.ts.map +1 -0
  12. package/es/panel-component/panel-container-group/index.mjs +21 -0
  13. package/es/panel-component/panel-container-group/panel-container-group.controller.d.ts +32 -0
  14. package/es/panel-component/panel-container-group/panel-container-group.controller.d.ts.map +1 -0
  15. package/es/panel-component/panel-container-group/panel-container-group.controller.mjs +35 -0
  16. package/es/panel-component/panel-container-group/panel-container-group.css +1 -0
  17. package/es/panel-component/panel-container-group/panel-container-group.d.ts +29 -0
  18. package/es/panel-component/panel-container-group/panel-container-group.d.ts.map +1 -0
  19. package/es/panel-component/panel-container-group/panel-container-group.mjs +108 -0
  20. package/es/panel-component/panel-container-group/panel-container-group.provider.d.ts +16 -0
  21. package/es/panel-component/panel-container-group/panel-container-group.provider.d.ts.map +1 -0
  22. package/es/panel-component/panel-container-group/panel-container-group.provider.mjs +15 -0
  23. package/es/panel-component/panel-container-group/panel-container-group.state.d.ts +13 -0
  24. package/es/panel-component/panel-container-group/panel-container-group.state.d.ts.map +1 -0
  25. package/es/panel-component/panel-container-group/panel-container-group.state.mjs +7 -0
  26. package/es/panel-component/panel-rawitem/index.d.ts.map +1 -1
  27. package/es/panel-component/panel-rawitem/index.mjs +8 -0
  28. package/es/panel-component/panel-tab-page/index.d.ts +24 -0
  29. package/es/panel-component/panel-tab-page/index.d.ts.map +1 -0
  30. package/es/panel-component/panel-tab-page/index.mjs +13 -0
  31. package/es/panel-component/panel-tab-page/panel-tab-page.d.ts +26 -0
  32. package/es/panel-component/panel-tab-page/panel-tab-page.d.ts.map +1 -0
  33. package/es/panel-component/panel-tab-page/panel-tab-page.mjs +63 -0
  34. package/es/panel-component/panel-tab-page/panel-tab-page.provider.d.ts +14 -0
  35. package/es/panel-component/panel-tab-page/panel-tab-page.provider.d.ts.map +1 -0
  36. package/es/panel-component/panel-tab-page/panel-tab-page.provider.mjs +15 -0
  37. package/es/plugin/plugin-factory/plugin-factory.d.ts +36 -17
  38. package/es/plugin/plugin-factory/plugin-factory.d.ts.map +1 -1
  39. package/es/plugin/plugin-factory/plugin-factory.mjs +84 -53
  40. package/lib/index.cjs +21 -13
  41. package/package.json +6 -6
  42. package/src/panel-component/index.ts +2 -0
  43. package/src/panel-component/nav-pos/nav-pos.controller.ts +37 -17
  44. package/src/panel-component/panel-container-group/index.ts +22 -0
  45. package/src/panel-component/panel-container-group/panel-container-group.controller.ts +43 -0
  46. package/src/panel-component/panel-container-group/panel-container-group.provider.ts +30 -0
  47. package/src/panel-component/panel-container-group/panel-container-group.scss +91 -0
  48. package/src/panel-component/panel-container-group/panel-container-group.state.ts +12 -0
  49. package/src/panel-component/panel-container-group/panel-container-group.tsx +112 -0
  50. package/src/panel-component/panel-rawitem/index.ts +8 -0
  51. package/src/panel-component/panel-tab-page/index.ts +12 -0
  52. package/src/panel-component/panel-tab-page/panel-tab-page.provider.ts +27 -0
  53. package/src/panel-component/panel-tab-page/panel-tab-page.tsx +55 -0
  54. package/src/plugin/plugin-factory/plugin-factory.ts +87 -55
  55. package/dist/index.system.min.js.map +0 -1
@@ -0,0 +1,112 @@
1
+ import { IPanelContainer } from '@ibiz/model-core';
2
+ import { computed, defineComponent, PropType, ref, VNode } from 'vue';
3
+ import { PanelContainerGroupController } from './panel-container-group.controller';
4
+ import './panel-container-group.scss';
5
+ import { useNamespace } from '../../use';
6
+
7
+ export const PanelContainerGroup = defineComponent({
8
+ name: 'IBizPanelContainerGroup',
9
+ props: {
10
+ modelData: {
11
+ type: Object as PropType<IPanelContainer>,
12
+ required: true,
13
+ },
14
+ controller: {
15
+ type: PanelContainerGroupController,
16
+ required: true,
17
+ },
18
+ },
19
+ setup(props) {
20
+ const ns = useNamespace('panel-container-group');
21
+
22
+ const isCollapse = ref(!props.controller.defaultExpansion);
23
+
24
+ const changeCollapse = (): void => {
25
+ if (!props.controller.disableClose) {
26
+ isCollapse.value = !isCollapse.value;
27
+ }
28
+ };
29
+
30
+ const captionText = computed(() => {
31
+ const { captionItemName, caption, capLanguageRes } = props.modelData;
32
+ if (captionItemName) {
33
+ return props.controller.data[captionItemName];
34
+ }
35
+ let text = caption;
36
+ if (capLanguageRes) {
37
+ text = ibiz.i18n.t(capLanguageRes.lanResTag!, caption);
38
+ }
39
+ return text;
40
+ });
41
+
42
+ return { ns, captionText, changeCollapse, isCollapse };
43
+ },
44
+ render() {
45
+ const classArr: string[] = [
46
+ this.ns.b(),
47
+ this.ns.m(this.modelData.id),
48
+ ...this.controller.containerClass,
49
+ this.ns.is('hidden', !this.controller.state.visible),
50
+ ];
51
+ if (this.modelData.showCaption === true) {
52
+ classArr.push(this.ns.m('show-header'));
53
+ classArr.push(this.ns.b('collapse'));
54
+ classArr.push(this.ns.is('collapse', this.isCollapse));
55
+ if (this.controller.disableClose) {
56
+ classArr.push(this.ns.bm('collapse', 'disable-close'));
57
+ }
58
+ }
59
+
60
+ // 内容区默认插槽处理,封装app-col
61
+ const defaultSlots: VNode[] = this.$slots.default?.() || [];
62
+ const content = (
63
+ <iBizRow slot='content' layout={this.modelData.layout}>
64
+ {defaultSlots.map(slot => {
65
+ const props = slot.props as IData;
66
+ if (!props || !props.controller) {
67
+ return slot;
68
+ }
69
+
70
+ return (
71
+ <iBizCol
72
+ layoutPos={props.modelData.layoutPos}
73
+ state={props.controller.state}
74
+ >
75
+ {slot}
76
+ </iBizCol>
77
+ );
78
+ })}
79
+ </iBizRow>
80
+ );
81
+
82
+ // 头部绘制
83
+ let header: unknown = null;
84
+ if (this.modelData.showCaption) {
85
+ header = (
86
+ <div class={[this.ns.b('header')]} onClick={this.changeCollapse}>
87
+ <div class={[this.ns.be('header', 'left')]}>
88
+ <div class={[this.ns.e('caption'), ...this.controller.labelClass]}>
89
+ {this.captionText}
90
+ </div>
91
+ </div>
92
+ <div class={[this.ns.be('header', 'right')]}>
93
+ {this.modelData.titleBarCloseMode !== undefined &&
94
+ this.modelData.titleBarCloseMode !== 0 &&
95
+ (this.isCollapse ? (
96
+ <ion-icon name='caret-forward-sharp' />
97
+ ) : (
98
+ <ion-icon name='caret-down-sharp' />
99
+ ))}
100
+ </div>
101
+ </div>
102
+ );
103
+ }
104
+
105
+ return (
106
+ <div class={classArr}>
107
+ {header}
108
+ <div class={[this.ns.b('content')]}>{content}</div>
109
+ </div>
110
+ );
111
+ },
112
+ });
@@ -13,6 +13,14 @@ export const IBizPanelRawItem = withInstall(PanelRawItem, function (v: App) {
13
13
  'RAWITEM_STATIC_IMAGE',
14
14
  () => new PanelRawItemProvider(),
15
15
  );
16
+ registerPanelItemProvider(
17
+ 'RAWITEM_STATIC_LABEL',
18
+ () => new PanelRawItemProvider(),
19
+ );
20
+ registerPanelItemProvider(
21
+ 'RAWITEM_STATIC_TEXT',
22
+ () => new PanelRawItemProvider(),
23
+ );
16
24
  });
17
25
 
18
26
  export default IBizPanelRawItem;
@@ -0,0 +1,12 @@
1
+ import { registerPanelItemProvider } from '@ibiz-template/runtime';
2
+ import { App } from 'vue';
3
+ import { PanelTabPage } from './panel-tab-page';
4
+ import { PanelTabPageProvider } from './panel-tab-page.provider';
5
+ import { withInstall } from '../../util';
6
+
7
+ export const IBizPanelTabPage = withInstall(PanelTabPage, function (v: App) {
8
+ v.component(PanelTabPage.name, PanelTabPage);
9
+ registerPanelItemProvider('TABPAGE', () => new PanelTabPageProvider());
10
+ });
11
+
12
+ export default IBizPanelTabPage;
@@ -0,0 +1,27 @@
1
+ import {
2
+ IPanelItemProvider,
3
+ PanelController,
4
+ PanelItemController,
5
+ } from '@ibiz-template/runtime';
6
+ import { IPanelItem } from '@ibiz/model-core';
7
+
8
+ /**
9
+ * 面板分页适配器
10
+ *
11
+ * @export
12
+ * @class PanelTabPageController
13
+ * @implements {IPanelItemProvider}
14
+ */
15
+ export class PanelTabPageProvider implements IPanelItemProvider {
16
+ component: string = 'IBizPanelTabPage';
17
+
18
+ async createController(
19
+ panelItem: IPanelItem,
20
+ panel: PanelController,
21
+ parent: PanelItemController | undefined,
22
+ ): Promise<PanelItemController> {
23
+ const c = new PanelItemController(panelItem, panel, parent);
24
+ await c.init();
25
+ return c;
26
+ }
27
+ }
@@ -0,0 +1,55 @@
1
+ import { computed, defineComponent, PropType, VNode } from 'vue';
2
+ import { IPanelContainer } from '@ibiz/model-core';
3
+ import { PanelItemController } from '@ibiz-template/runtime';
4
+ import { useNamespace } from '../../use';
5
+
6
+ export const PanelTabPage = defineComponent({
7
+ name: 'IBizPanelTabPage',
8
+ props: {
9
+ modelData: {
10
+ // IPanelTabPage 不能使用 IPanelTabPage模型 否则会类型报错
11
+ type: Object as PropType<IPanelContainer>,
12
+ required: true,
13
+ },
14
+ controller: {
15
+ type: PanelItemController,
16
+ required: true,
17
+ },
18
+ },
19
+ setup(props) {
20
+ const ns = useNamespace('panel-tab-page');
21
+ // 类名控制
22
+ const classArr = computed(() => {
23
+ const { id } = props.modelData;
24
+ const result: Array<string | false> = [ns.b(), ns.m(id)];
25
+ result.push(...props.controller.containerClass);
26
+ return result;
27
+ });
28
+ return {
29
+ ns,
30
+ classArr,
31
+ };
32
+ },
33
+ render() {
34
+ const defaultSlots: VNode[] = this.$slots.default?.() || [];
35
+ return (
36
+ <iBizRow
37
+ class={[this.ns.b(), this.ns.m(this.modelData.codeName), this.classArr]}
38
+ layout={this.modelData.layout}
39
+ >
40
+ {defaultSlots.map(slot => {
41
+ const props = slot.props as IData;
42
+ if (!props || !props.controller) {
43
+ return slot;
44
+ }
45
+ const c = props.controller;
46
+ return (
47
+ <iBizCol layoutPos={c.model.layoutPos} state={c.state}>
48
+ {slot}
49
+ </iBizCol>
50
+ );
51
+ })}
52
+ </iBizRow>
53
+ );
54
+ },
55
+ });
@@ -37,15 +37,6 @@ export class PluginFactory implements IPluginFactory {
37
37
  */
38
38
  protected cache: Map<string, boolean> = new Map();
39
39
 
40
- /**
41
- * 本地开发测试包,只在本地开发生效
42
- *
43
- * @author chitanda
44
- * @date 2022-11-02 21:11:41
45
- * @protected
46
- */
47
- protected devPackages: Map<string, () => Promise<unknown>> = new Map();
48
-
49
40
  /**
50
41
  * 插件缓存
51
42
  *
@@ -76,6 +67,55 @@ export class PluginFactory implements IPluginFactory {
76
67
  */
77
68
  protected predefinedPlugins: Map<string, IPluginItem> = new Map();
78
69
 
70
+ /**
71
+ * 忽略加载的插件规则,支持正则。配配规则为插件包地址,如:@ibiz-template-vue/vue3-plugin-*
72
+ *
73
+ * @author chitanda
74
+ * @date 2023-12-04 15:12:58
75
+ * @protected
76
+ * @type {((string | RegExp)[])}
77
+ */
78
+ protected ignoreRules: (string | RegExp)[] = [];
79
+
80
+ /**
81
+ * 插件加载队列
82
+ *
83
+ * @author chitanda
84
+ * @date 2023-12-05 16:12:04
85
+ * @protected
86
+ * @type {Map<string, Promise<boolean>>}
87
+ */
88
+ protected loadQueue: Map<string, Promise<boolean>> = new Map();
89
+
90
+ /**
91
+ * 是否忽略插件加载
92
+ *
93
+ * @author chitanda
94
+ * @date 2023-12-04 16:12:48
95
+ * @protected
96
+ * @param {string} pluginPath
97
+ * @return {*} {boolean}
98
+ */
99
+ protected isIgnore(pluginPath: string): boolean {
100
+ return this.ignoreRules.some(rule => {
101
+ if (typeof rule === 'string') {
102
+ return pluginPath === rule;
103
+ }
104
+ return rule.test(pluginPath);
105
+ });
106
+ }
107
+
108
+ /**
109
+ * 设置本地开发忽略远程加载的插件
110
+ *
111
+ * @author chitanda
112
+ * @date 2023-12-04 17:12:49
113
+ * @param {(string | RegExp)} rule
114
+ */
115
+ setDevIgnore(rule: string | RegExp): void {
116
+ this.ignoreRules.push(rule);
117
+ }
118
+
79
119
  /**
80
120
  * 注册视图默认插件
81
121
  *
@@ -132,18 +172,6 @@ export class PluginFactory implements IPluginFactory {
132
172
  });
133
173
  }
134
174
 
135
- /**
136
- * 设置开发插件,用于本地调试
137
- *
138
- * @author chitanda
139
- * @date 2022-11-02 21:11:56
140
- * @param {string} name
141
- * @param {() => Promise<unknown>} fn
142
- */
143
- setDevPlugin(name: string, fn: () => Promise<unknown>): void {
144
- this.devPackages.set(name, fn);
145
- }
146
-
147
175
  /**
148
176
  * 加载插件
149
177
  *
@@ -156,13 +184,35 @@ export class PluginFactory implements IPluginFactory {
156
184
  if (plugin.runtimeObject === true) {
157
185
  const pluginRef = plugin as unknown as IAppPFPluginRef;
158
186
  if (pluginRef) {
187
+ const rtObjectName = pluginRef.rtobjectName!;
188
+ const rtObjectRepo = pluginRef.rtobjectRepo!;
189
+ if (this.isIgnore(rtObjectRepo)) {
190
+ return true;
191
+ }
192
+ if (this.pluginCache.has(rtObjectName)) {
193
+ return true;
194
+ }
195
+ if (this.loadQueue.has(rtObjectRepo)) {
196
+ const p = await this.loadQueue.get(rtObjectRepo)!;
197
+ try {
198
+ const result = await p;
199
+ return result;
200
+ } catch (error) {
201
+ return false;
202
+ }
203
+ }
159
204
  try {
160
- await this.loadPluginRef(
205
+ const p = this.loadPluginRef(
161
206
  pluginRef.rtobjectName!,
162
207
  pluginRef.rtobjectRepo!,
163
208
  );
209
+ this.loadQueue.set(rtObjectRepo, p);
210
+ const result = await p;
211
+ return result;
164
212
  } catch (error) {
165
213
  throw new RuntimeModelError(pluginRef, `配置加载失败`);
214
+ } finally {
215
+ this.loadQueue.delete(rtObjectRepo);
166
216
  }
167
217
  }
168
218
  }
@@ -181,14 +231,14 @@ export class PluginFactory implements IPluginFactory {
181
231
  rtObjectName: string,
182
232
  rtObjectRepo: string,
183
233
  ): Promise<boolean> {
234
+ if (this.isIgnore(rtObjectRepo)) {
235
+ return true;
236
+ }
184
237
  if (this.pluginCache.has(rtObjectName)) {
185
238
  return true;
186
239
  }
187
240
  let configData: unknown = null;
188
- const fn = this.devPackages.get(rtObjectName);
189
- if (fn) {
190
- configData = await fn();
191
- } else {
241
+ {
192
242
  const pluginPath: string = rtObjectRepo;
193
243
  const configUrl = this.urlReg.test(pluginPath)
194
244
  ? `${pluginPath}/package.json`
@@ -231,17 +281,9 @@ export class PluginFactory implements IPluginFactory {
231
281
  */
232
282
  protected async loadScript(remotePlugin: RemotePluginItem): Promise<void> {
233
283
  const pluginPath: string = remotePlugin.repo;
234
- const { name, version, system, module, styles } = remotePlugin.config;
284
+ const { name, system, styles = [] } = remotePlugin.config;
235
285
  let scriptUrl = '';
236
- if (this.devPackages.has(name)) {
237
- scriptUrl = join(`${name}@${version}`, module);
238
- } else if (ibiz.env.dev) {
239
- scriptUrl = this.urlReg.test(pluginPath)
240
- ? `${pluginPath}/${join(module)}`
241
- : `${ibiz.env.pluginBaseUrl}/${pluginPath}/${join(module)}`;
242
- } else {
243
- scriptUrl = join(pluginPath, system);
244
- }
286
+ scriptUrl = join(pluginPath, system);
245
287
  if (scriptUrl) {
246
288
  if (this.cache.has(scriptUrl)) {
247
289
  return;
@@ -251,26 +293,16 @@ export class PluginFactory implements IPluginFactory {
251
293
  const styleUrls = (typeof styles === 'string' ? [styles] : styles).map(
252
294
  styleUrl => this.parseUrl(path.join(pluginPath, styleUrl)),
253
295
  );
254
- // 本地开发模式下的包引用加载
255
- if (this.devPackages.has(name)) {
256
- const fn = this.devPackages.get(name)!;
296
+ System.addImportMap({
297
+ imports: {
298
+ [name]: url,
299
+ },
300
+ styles: {
301
+ [name]: styleUrls,
302
+ },
257
303
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
258
- data = (await fn()) as any;
259
- this.cache.set(scriptUrl, true);
260
- } else if (ibiz.env.dev) {
261
- data = await import(/* @vite-ignore */ scriptUrl);
262
- } else {
263
- System.addImportMap({
264
- imports: {
265
- [name]: url,
266
- },
267
- styles: {
268
- [name]: styleUrls,
269
- },
270
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
271
- } as any);
272
- data = await System.import(name);
273
- }
304
+ } as any);
305
+ data = await System.import(name);
274
306
  if (data) {
275
307
  if (data.default) {
276
308
  this.setPluginCode(data.default);