@difizen/libro-lab 0.0.2-alpha.0 → 0.1.1

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 (124) hide show
  1. package/es/common/icon.d.ts +14 -0
  2. package/es/common/icon.d.ts.map +1 -0
  3. package/es/common/icon.js +368 -0
  4. package/es/common/index.d.ts +2 -0
  5. package/es/common/index.d.ts.map +1 -0
  6. package/es/common/index.js +1 -0
  7. package/es/common/index.less +8 -0
  8. package/es/github-link/index.d.ts +9 -0
  9. package/es/github-link/index.d.ts.map +1 -0
  10. package/es/github-link/index.js +43 -0
  11. package/es/index.d.ts +1 -1
  12. package/es/index.d.ts.map +1 -1
  13. package/es/index.js +1 -0
  14. package/es/index.less +78 -0
  15. package/es/kernel-manager/index.d.ts +8 -0
  16. package/es/kernel-manager/index.d.ts.map +1 -0
  17. package/es/kernel-manager/index.js +40 -0
  18. package/es/lab-app.d.ts +15 -0
  19. package/es/lab-app.d.ts.map +1 -0
  20. package/es/lab-app.js +126 -0
  21. package/es/layout/brand/index.d.ts +8 -0
  22. package/es/layout/brand/index.d.ts.map +1 -0
  23. package/es/layout/brand/index.js +46 -0
  24. package/es/layout/brand/index.less +16 -0
  25. package/es/layout/container.d.ts +8 -0
  26. package/es/layout/container.d.ts.map +1 -0
  27. package/es/layout/container.js +54 -0
  28. package/es/layout/footer/current-file-footer-view.d.ts +10 -0
  29. package/es/layout/footer/current-file-footer-view.d.ts.map +1 -0
  30. package/es/layout/footer/current-file-footer-view.js +62 -0
  31. package/es/layout/footer/footer-view.d.ts +11 -0
  32. package/es/layout/footer/footer-view.d.ts.map +1 -0
  33. package/es/layout/footer/footer-view.js +60 -0
  34. package/es/layout/footer/index.less +20 -0
  35. package/es/layout/footer/status-footer-view.d.ts +10 -0
  36. package/es/layout/footer/status-footer-view.d.ts.map +1 -0
  37. package/es/layout/footer/status-footer-view.js +73 -0
  38. package/es/layout/index.d.ts +5 -0
  39. package/es/layout/index.d.ts.map +1 -0
  40. package/es/layout/index.js +4 -0
  41. package/es/layout/index.less +59 -0
  42. package/es/layout/layout-service.d.ts +15 -0
  43. package/es/layout/layout-service.d.ts.map +1 -0
  44. package/es/layout/layout-service.js +104 -0
  45. package/es/layout/layout.d.ts +12 -0
  46. package/es/layout/layout.d.ts.map +1 -0
  47. package/es/layout/layout.js +92 -0
  48. package/es/layout/main.d.ts +8 -0
  49. package/es/layout/main.d.ts.map +1 -0
  50. package/es/layout/main.js +79 -0
  51. package/es/layout/module.d.ts +3 -0
  52. package/es/layout/module.d.ts.map +1 -0
  53. package/es/layout/module.js +45 -0
  54. package/es/layout/protocol.d.ts +18 -0
  55. package/es/layout/protocol.d.ts.map +1 -0
  56. package/es/layout/protocol.js +10 -0
  57. package/es/layout/saveable-tab-view.d.ts +7 -0
  58. package/es/layout/saveable-tab-view.d.ts.map +1 -0
  59. package/es/layout/saveable-tab-view.js +77 -0
  60. package/es/menu/menu-bar-view.d.ts +9 -0
  61. package/es/menu/menu-bar-view.d.ts.map +1 -0
  62. package/es/menu/menu-bar-view.js +49 -0
  63. package/es/menu/menu-command.d.ts +139 -0
  64. package/es/menu/menu-command.d.ts.map +1 -0
  65. package/es/menu/menu-command.js +138 -0
  66. package/es/menu/menu-contribution.d.ts +18 -0
  67. package/es/menu/menu-contribution.d.ts.map +1 -0
  68. package/es/menu/menu-contribution.js +991 -0
  69. package/es/menu/module.d.ts +3 -0
  70. package/es/menu/module.d.ts.map +1 -0
  71. package/es/menu/module.js +7 -0
  72. package/es/module.d.ts +4 -0
  73. package/es/module.d.ts.map +1 -0
  74. package/es/module.js +57 -0
  75. package/es/toc/index.less +25 -0
  76. package/es/toc/libro-toc-panel-view.d.ts +18 -0
  77. package/es/toc/libro-toc-panel-view.d.ts.map +1 -0
  78. package/es/toc/libro-toc-panel-view.js +104 -0
  79. package/es/toc/module.d.ts +3 -0
  80. package/es/toc/module.d.ts.map +1 -0
  81. package/es/toc/module.js +13 -0
  82. package/es/welcome/entry-point-view.d.ts +8 -0
  83. package/es/welcome/entry-point-view.d.ts.map +1 -0
  84. package/es/welcome/entry-point-view.js +200 -0
  85. package/es/welcome/index.d.ts +13 -0
  86. package/es/welcome/index.d.ts.map +1 -0
  87. package/es/welcome/index.js +75 -0
  88. package/es/welcome/index.less +122 -0
  89. package/package.json +10 -3
  90. package/src/common/icon.tsx +300 -0
  91. package/src/common/index.less +8 -0
  92. package/src/common/index.tsx +1 -0
  93. package/src/github-link/index.tsx +27 -0
  94. package/src/index.less +78 -0
  95. package/src/index.spec.ts +10 -0
  96. package/src/index.ts +1 -0
  97. package/src/kernel-manager/index.tsx +22 -0
  98. package/src/lab-app.ts +61 -0
  99. package/src/layout/brand/index.less +16 -0
  100. package/src/layout/brand/index.tsx +22 -0
  101. package/src/layout/container.tsx +28 -0
  102. package/src/layout/footer/current-file-footer-view.tsx +40 -0
  103. package/src/layout/footer/footer-view.tsx +30 -0
  104. package/src/layout/footer/index.less +20 -0
  105. package/src/layout/footer/status-footer-view.tsx +45 -0
  106. package/src/layout/index.less +59 -0
  107. package/src/layout/index.tsx +4 -0
  108. package/src/layout/layout-service.ts +66 -0
  109. package/src/layout/layout.tsx +61 -0
  110. package/src/layout/main.tsx +67 -0
  111. package/src/layout/module.ts +68 -0
  112. package/src/layout/protocol.tsx +20 -0
  113. package/src/layout/saveable-tab-view.tsx +66 -0
  114. package/src/menu/menu-bar-view.tsx +28 -0
  115. package/src/menu/menu-command.ts +138 -0
  116. package/src/menu/menu-contribution.ts +658 -0
  117. package/src/menu/module.ts +13 -0
  118. package/src/module.tsx +92 -0
  119. package/src/toc/index.less +25 -0
  120. package/src/toc/libro-toc-panel-view.tsx +88 -0
  121. package/src/toc/module.ts +21 -0
  122. package/src/welcome/entry-point-view.tsx +169 -0
  123. package/src/welcome/index.less +122 -0
  124. package/src/welcome/index.tsx +68 -0
@@ -0,0 +1,16 @@
1
+ .libro-lab-brand {
2
+ display: flex;
3
+ align-items: center;
4
+ height: 100%;
5
+ width: 100%;
6
+ padding: 0 22px;
7
+
8
+ &-logo {
9
+ height: 16px;
10
+ }
11
+
12
+ label {
13
+ font-size: 16px;
14
+ margin-left: 8px;
15
+ }
16
+ }
@@ -0,0 +1,22 @@
1
+ import { BaseView, view, singleton } from '@difizen/mana-app';
2
+ import * as React from 'react';
3
+ import { Logo } from '../../common/index.js';
4
+
5
+ import './index.less';
6
+
7
+ export const Brand: React.ForwardRefExoticComponent<any> = React.forwardRef(
8
+ function Brand(_props, ref: React.ForwardedRef<HTMLDivElement>) {
9
+ return (
10
+ <div className="libro-lab-brand" ref={ref}>
11
+ <Logo className="libro-lab-brand-logo" />
12
+ <label>libro lab</label>
13
+ </div>
14
+ );
15
+ },
16
+ );
17
+
18
+ @singleton()
19
+ @view('libro-brand-view')
20
+ export class BrandView extends BaseView {
21
+ override view = Brand;
22
+ }
@@ -0,0 +1,28 @@
1
+ import { singleton, Slot, view } from '@difizen/mana-app';
2
+ import { BaseView } from '@difizen/mana-app';
3
+ import { BoxPanel } from '@difizen/mana-react';
4
+ import { forwardRef } from 'react';
5
+
6
+ import './index.less';
7
+ import { LibroLabLayoutSlots } from './protocol.js';
8
+
9
+ export const LibroLabLayoutContainerComponent = forwardRef(
10
+ function LibroLabLayoutContainerComponent() {
11
+ return (
12
+ <BoxPanel direction="top-to-bottom">
13
+ <BoxPanel.Pane className="libro-lab-layout-main" flex={1}>
14
+ <Slot name={LibroLabLayoutSlots.main} />
15
+ </BoxPanel.Pane>
16
+ <BoxPanel.Pane className="libro-lab-layout-footer">
17
+ <Slot name={LibroLabLayoutSlots.footer} />
18
+ </BoxPanel.Pane>
19
+ </BoxPanel>
20
+ );
21
+ },
22
+ );
23
+
24
+ @singleton()
25
+ @view('libro-lab-layout-container')
26
+ export class LibroLabLayoutContainerView extends BaseView {
27
+ override view = LibroLabLayoutContainerComponent;
28
+ }
@@ -0,0 +1,40 @@
1
+ import {
2
+ BaseView,
3
+ inject,
4
+ singleton,
5
+ useInject,
6
+ view,
7
+ ViewInstance,
8
+ } from '@difizen/mana-app';
9
+ import * as React from 'react';
10
+
11
+ import { LayoutService } from '../layout-service.js';
12
+ import { LibroLabLayoutSlots } from '../protocol.js';
13
+ import './index.less';
14
+
15
+ const CurrentFileFooterComponent = React.forwardRef(function CurrentFileFooterComponent(
16
+ _props,
17
+ ref: React.ForwardedRef<HTMLDivElement>,
18
+ ) {
19
+ const currentFileFooterView = useInject<LibroLabCurrentFileFooterView>(ViewInstance);
20
+
21
+ return (
22
+ <div className="libro-lab-current-file-footer" ref={ref}>
23
+ <span>{`当前文件:${
24
+ currentFileFooterView.navigatableView?.title.label || ''
25
+ }`}</span>
26
+ </div>
27
+ );
28
+ });
29
+
30
+ @singleton()
31
+ @view('libro-lab-current-file-footer-view')
32
+ export class LibroLabCurrentFileFooterView extends BaseView {
33
+ override view = CurrentFileFooterComponent;
34
+ @inject(LayoutService) protected layoutService: LayoutService;
35
+
36
+ get navigatableView() {
37
+ const contentView = this.layoutService.getActiveView(LibroLabLayoutSlots.content);
38
+ return contentView;
39
+ }
40
+ }
@@ -0,0 +1,30 @@
1
+ import { DefaultSlotView, singleton, Slot, view } from '@difizen/mana-app';
2
+ import { BoxPanel } from '@difizen/mana-react';
3
+ import * as React from 'react';
4
+ import './index.less';
5
+
6
+ export enum FooterArea {
7
+ left = 'libro-lab-footer-left',
8
+ right = 'libro-lab-footer-right',
9
+ }
10
+
11
+ const FooterComponent: React.ForwardRefExoticComponent<any> = React.forwardRef(
12
+ function FooterComponent(_props, ref: React.ForwardedRef<HTMLDivElement>) {
13
+ return (
14
+ <BoxPanel direction="left-to-right" className={'libro-lab-footer'} ref={ref}>
15
+ <BoxPanel.Pane flex={1} className={'libro-lab-footer-left'}>
16
+ <Slot name={FooterArea.left} />
17
+ </BoxPanel.Pane>
18
+ <BoxPanel.Pane flex={1} className={'libro-lab-footer-right'}>
19
+ <Slot name={FooterArea.right} />
20
+ </BoxPanel.Pane>
21
+ </BoxPanel>
22
+ );
23
+ },
24
+ );
25
+
26
+ @singleton()
27
+ @view('libro-lab-footer-view')
28
+ export class LibroLabLayoutFooterView extends DefaultSlotView {
29
+ override view = FooterComponent;
30
+ }
@@ -0,0 +1,20 @@
1
+ .libro-lab-footer {
2
+ .libro-lab-footer-left,
3
+ .libro-lab-footer-right {
4
+ padding: 0 24px;
5
+ }
6
+ }
7
+
8
+ .libro-lab-current-file-footer,
9
+ .libro-lab-status-footer {
10
+ height: 100%;
11
+ display: flex;
12
+ align-items: center;
13
+ font-weight: 400;
14
+ font-size: 12px;
15
+ color: rgba(0, 10, 26, 68%);
16
+ }
17
+
18
+ .libro-lab-status-footer {
19
+ justify-content: end;
20
+ }
@@ -0,0 +1,45 @@
1
+ import { BaseView, inject, singleton, useInject, view } from '@difizen/mana-app';
2
+ import * as React from 'react';
3
+ import { Loadding, SuccIcon } from '../../common/icon.js';
4
+
5
+ import { LayoutService } from '../layout-service.js';
6
+ import { LibroLabLayoutSlots } from '../protocol.js';
7
+ import type { StatusItem, StatusType } from '../protocol.js';
8
+ import './index.less';
9
+
10
+ const Status: Record<StatusType, StatusItem> = {
11
+ loading: {
12
+ label: '启动中',
13
+ icon: <Loadding />,
14
+ },
15
+ success: {
16
+ label: '启动成功',
17
+ icon: <SuccIcon />,
18
+ },
19
+ };
20
+
21
+ const StatusFooterComponent = React.forwardRef(function CurrentFileFooterComponent(
22
+ _props,
23
+ ref: React.ForwardedRef<HTMLDivElement>,
24
+ ) {
25
+ const layoutService = useInject(LayoutService);
26
+ return (
27
+ <div className="libro-lab-status-footer" ref={ref}>
28
+ <span>服务状态:</span>
29
+ {Status[layoutService.serverSatus].icon}
30
+ {Status[layoutService.serverSatus].label}
31
+ </div>
32
+ );
33
+ });
34
+
35
+ @singleton()
36
+ @view('libro-lab-status-footer-view')
37
+ export class LibroLabStatusFooterView extends BaseView {
38
+ override view = StatusFooterComponent;
39
+ @inject(LayoutService) protected layoutService: LayoutService;
40
+
41
+ get navigatableView() {
42
+ const contentView = this.layoutService.getActiveView(LibroLabLayoutSlots.content);
43
+ return contentView;
44
+ }
45
+ }
@@ -0,0 +1,59 @@
1
+ @ant-prefix: ant;
2
+
3
+ .libro-lab-layout {
4
+ width: 100%;
5
+ height: 100%;
6
+
7
+ &-header {
8
+ height: 56px;
9
+ min-height: 56px;
10
+ }
11
+
12
+ &-container {
13
+ overflow: auto;
14
+ }
15
+
16
+ &-main {
17
+ overflow: auto;
18
+ }
19
+
20
+ &-footer {
21
+ height: 28px;
22
+ min-height: 28px;
23
+ background-image: linear-gradient(270deg, #fafafa 0%, #fff 100%);
24
+ box-shadow: 0 -1px 1px 0 rgba(0, 0, 0, 12%);
25
+ }
26
+
27
+ .mana-header {
28
+ background: var(--mana-color-bg-container);
29
+ border-bottom: none;
30
+
31
+ .mana-header-left,
32
+ .mana-header-right {
33
+ flex: unset !important;
34
+ }
35
+
36
+ .mana-menubar {
37
+ height: 100%;
38
+ padding: unset;
39
+ }
40
+
41
+ .mana-menubar-item-text {
42
+ color: rgba(0, 10, 26, 89%);
43
+ font-weight: 400;
44
+ }
45
+ }
46
+ }
47
+
48
+ .libro-lab-editor-tab-tail {
49
+ width: 16px;
50
+
51
+ .libro-lab-editor-tab-dirty {
52
+ padding: 0 4px;
53
+
54
+ .ant-badge.ant-badge-status .ant-badge-status-dot {
55
+ height: 8px;
56
+ width: 8px;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,4 @@
1
+ export * from './protocol.js';
2
+ export * from './module.js';
3
+ export * from './layout.js';
4
+ export * from './footer/footer-view.js';
@@ -0,0 +1,66 @@
1
+ import type { SlotView, View, ViewOpenHandlerOptions } from '@difizen/mana-app';
2
+ import {
3
+ DefaultSlotView,
4
+ inject,
5
+ prop,
6
+ singleton,
7
+ SlotViewManager,
8
+ } from '@difizen/mana-app';
9
+
10
+ import type { LibroLabLayoutSlotsType, StatusType } from './protocol.js';
11
+ import { LibroLabLayoutSlots } from './protocol.js';
12
+
13
+ export type VisibilityMap = Record<LibroLabLayoutSlotsType, boolean>;
14
+
15
+ @singleton()
16
+ export class LayoutService {
17
+ @inject(SlotViewManager) protected readonly slotViewManager: SlotViewManager;
18
+
19
+ @prop()
20
+ serverSatus: StatusType = 'loading';
21
+ @prop()
22
+ visibilityMap: VisibilityMap = {
23
+ [LibroLabLayoutSlots.header]: true,
24
+ [LibroLabLayoutSlots.container]: true,
25
+ [LibroLabLayoutSlots.main]: true,
26
+ [LibroLabLayoutSlots.footer]: true,
27
+ [LibroLabLayoutSlots.navigator]: false,
28
+ [LibroLabLayoutSlots.content]: true,
29
+ [LibroLabLayoutSlots.contentBottom]: false,
30
+ [LibroLabLayoutSlots.alert]: true,
31
+ };
32
+
33
+ isAreaVisible(slot: LibroLabLayoutSlotsType): boolean {
34
+ return this.visibilityMap[slot];
35
+ }
36
+
37
+ setAreaVisible(slot: LibroLabLayoutSlotsType, visible: boolean) {
38
+ this.visibilityMap[slot] = visible;
39
+ }
40
+
41
+ async addView(view: View, option?: ViewOpenHandlerOptions): Promise<void> {
42
+ const { slot = LibroLabLayoutSlots.main, ...viewOpenOption } = option || {};
43
+ const slotView = this.slotViewManager.getSlotView(slot) as SlotView;
44
+ await slotView.addView(view, viewOpenOption);
45
+ }
46
+
47
+ getActiveView(slot: LibroLabLayoutSlotsType) {
48
+ if (this.isAreaVisible(slot)) {
49
+ const slotView = this.slotViewManager.getSlotView(slot);
50
+ if (slotView instanceof DefaultSlotView) {
51
+ return slotView.active;
52
+ }
53
+ }
54
+ return undefined;
55
+ }
56
+
57
+ onSlotActiveChange(slot: LibroLabLayoutSlotsType, handler: () => void) {
58
+ if (this.isAreaVisible(slot)) {
59
+ const slotView = this.slotViewManager.getSlotView(slot);
60
+ if (slotView instanceof DefaultSlotView) {
61
+ return slotView.onActiveChange(handler);
62
+ }
63
+ }
64
+ return undefined;
65
+ }
66
+ }
@@ -0,0 +1,61 @@
1
+ import { inject, singleton, Slot, useInject, view } from '@difizen/mana-app';
2
+ import { BaseView } from '@difizen/mana-app';
3
+ import { BoxPanel } from '@difizen/mana-react';
4
+ import { Alert } from 'antd';
5
+ import { forwardRef } from 'react';
6
+
7
+ import { Loadding } from '../common/icon.js';
8
+
9
+ import './index.less';
10
+ import type { VisibilityMap } from './layout-service.js';
11
+ import { LayoutService } from './layout-service.js';
12
+ import { LibroLabLayoutSlots } from './protocol.js';
13
+
14
+ export const LibroLabLayoutContainerComponent = forwardRef(
15
+ function LibroLabLayoutContainerComponent() {
16
+ const layoutService = useInject(LayoutService);
17
+
18
+ return (
19
+ <div className="libro-lab-layout">
20
+ <BoxPanel direction="top-to-bottom">
21
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.header) && (
22
+ <BoxPanel.Pane className="libro-lab-layout-header">
23
+ <Slot name={LibroLabLayoutSlots.header} />
24
+ </BoxPanel.Pane>
25
+ )}
26
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.alert) && (
27
+ <Alert
28
+ message="服务启动中,请稍后,待容器启动完成后即可编辑文件。"
29
+ type="info"
30
+ banner
31
+ closable
32
+ icon={<Loadding className="libro-lab-loadding" />}
33
+ />
34
+ )}
35
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.container) && (
36
+ <BoxPanel.Pane className="libro-lab-layout-container" flex={1}>
37
+ <Slot name={LibroLabLayoutSlots.container} />
38
+ </BoxPanel.Pane>
39
+ )}
40
+ </BoxPanel>
41
+ </div>
42
+ );
43
+ },
44
+ );
45
+
46
+ @singleton()
47
+ @view('libro-lab-layout')
48
+ export class LibroLabLayoutView extends BaseView {
49
+ override view = LibroLabLayoutContainerComponent;
50
+
51
+ @inject(LayoutService) layoutService: LayoutService;
52
+
53
+ storeState(): object {
54
+ return { visibilityMap: this.layoutService.visibilityMap };
55
+ }
56
+
57
+ restoreState(oldState: object): void {
58
+ const state = oldState as { visibilityMap: VisibilityMap };
59
+ this.layoutService.visibilityMap = state.visibilityMap;
60
+ }
61
+ }
@@ -0,0 +1,67 @@
1
+ import { singleton, Slot, useInject, view } from '@difizen/mana-app';
2
+ import { BaseView } from '@difizen/mana-app';
3
+ import { SplitPanel } from '@difizen/mana-react';
4
+ import { forwardRef } from 'react';
5
+
6
+ import './index.less';
7
+ import { LayoutService } from './layout-service.js';
8
+ import { LibroLabLayoutSlots } from './protocol.js';
9
+
10
+ export const LibroLabLayoutMainComponent = forwardRef(
11
+ function LibroLabLayoutMainComponent() {
12
+ const layoutService = useInject(LayoutService);
13
+
14
+ return (
15
+ <SplitPanel id="libro-lab-content-layout">
16
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.navigator) && (
17
+ <SplitPanel.Pane
18
+ id="libro-lab-content-layout-left"
19
+ className="libro-lab-content-layout-left"
20
+ defaultSize={300}
21
+ >
22
+ <Slot name={LibroLabLayoutSlots.navigator} />
23
+ </SplitPanel.Pane>
24
+ )}
25
+ <SplitPanel.Pane
26
+ id="libro-lab-content-layout-main-container"
27
+ className="libro-lab-content-layout-main-container"
28
+ flex={1}
29
+ minResize={200}
30
+ >
31
+ <SplitPanel
32
+ id="libro-lab-content-layout-main-panel"
33
+ direction="top-to-bottom"
34
+ >
35
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.content) && (
36
+ <SplitPanel.Pane
37
+ id="libro-lab-content-layout-main"
38
+ className="libro-lab-content-layout-main"
39
+ flex={2}
40
+ flexGrow={1}
41
+ minResize={200}
42
+ >
43
+ <Slot name={LibroLabLayoutSlots.content} />
44
+ </SplitPanel.Pane>
45
+ )}
46
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.contentBottom) && (
47
+ <SplitPanel.Pane
48
+ id="libro-lab-content-layout-bottom"
49
+ className="libro-lab-content-layout-bottom"
50
+ flex={1}
51
+ defaultSize={200}
52
+ >
53
+ <Slot name={LibroLabLayoutSlots.contentBottom} />
54
+ </SplitPanel.Pane>
55
+ )}
56
+ </SplitPanel>
57
+ </SplitPanel.Pane>
58
+ </SplitPanel>
59
+ );
60
+ },
61
+ );
62
+
63
+ @singleton()
64
+ @view('libro-lab-layout-main')
65
+ export class LibroLabLayoutMainView extends BaseView {
66
+ override view = LibroLabLayoutMainComponent;
67
+ }
@@ -0,0 +1,68 @@
1
+ import {
2
+ createSlotPreference,
3
+ FlexSlotView,
4
+ HeaderArea,
5
+ HeaderView,
6
+ ManaModule,
7
+ } from '@difizen/mana-app';
8
+
9
+ import { BrandView } from './brand/index.js';
10
+ import { LibroLabLayoutContainerView } from './container.js';
11
+ import { LibroLabCurrentFileFooterView } from './footer/current-file-footer-view.js';
12
+ import { FooterArea, LibroLabLayoutFooterView } from './footer/footer-view.js';
13
+ import { LibroLabStatusFooterView } from './footer/status-footer-view.js';
14
+ import { LayoutService } from './layout-service.js';
15
+ import { LibroLabLayoutView } from './layout.js';
16
+ import { LibroLabLayoutMainView } from './main.js';
17
+ import { LibroLabLayoutSlots } from './protocol.js';
18
+ import { SaveableTabView } from './saveable-tab-view.js';
19
+
20
+ export const LibroLabLayoutModule = ManaModule.create('LibroLabLayoutModule').register(
21
+ LibroLabLayoutView,
22
+ LibroLabLayoutContainerView,
23
+ LibroLabLayoutMainView,
24
+ BrandView,
25
+ SaveableTabView,
26
+ LibroLabLayoutFooterView,
27
+ LibroLabCurrentFileFooterView,
28
+ LayoutService,
29
+ createSlotPreference({
30
+ slot: LibroLabLayoutSlots.header,
31
+ view: HeaderView,
32
+ }),
33
+ createSlotPreference({
34
+ slot: HeaderArea.left,
35
+ view: BrandView,
36
+ }),
37
+ createSlotPreference({
38
+ slot: LibroLabLayoutSlots.container,
39
+ view: LibroLabLayoutContainerView,
40
+ }),
41
+ createSlotPreference({
42
+ slot: LibroLabLayoutSlots.main,
43
+ view: LibroLabLayoutMainView,
44
+ }),
45
+ createSlotPreference({
46
+ slot: LibroLabLayoutSlots.footer,
47
+ view: LibroLabLayoutFooterView,
48
+ }),
49
+ createSlotPreference({
50
+ slot: FooterArea.right,
51
+ view: FlexSlotView,
52
+ options: { sort: true },
53
+ }),
54
+ createSlotPreference({
55
+ slot: FooterArea.left,
56
+ view: FlexSlotView,
57
+ options: { sort: true },
58
+ }),
59
+ createSlotPreference({
60
+ slot: FooterArea.left,
61
+ view: LibroLabCurrentFileFooterView,
62
+ }),
63
+ LibroLabStatusFooterView,
64
+ createSlotPreference({
65
+ slot: FooterArea.right,
66
+ view: LibroLabStatusFooterView,
67
+ }),
68
+ );
@@ -0,0 +1,20 @@
1
+ export const LibroLabLayoutSlots = {
2
+ header: 'libro-lab-header',
3
+ container: 'libro-lab-container',
4
+ main: 'libro-lab-main',
5
+ footer: 'libro-lab-footer',
6
+ navigator: 'libro-lab-navigator',
7
+ content: 'libro-lab-content',
8
+ contentBottom: 'libro-lab-content-bottom',
9
+ alert: 'libro-lab-alert',
10
+ };
11
+
12
+ export type StatusType = 'loading' | 'success';
13
+
14
+ export interface StatusItem {
15
+ label: string;
16
+ icon: JSX.Element;
17
+ }
18
+
19
+ export type LibroLabLayoutSlotsType =
20
+ (typeof LibroLabLayoutSlots)[keyof typeof LibroLabLayoutSlots];
@@ -0,0 +1,66 @@
1
+ import { CloseOutlined } from '@ant-design/icons';
2
+ import type { View } from '@difizen/mana-app';
3
+ import {
4
+ CardTabView,
5
+ MenuRender,
6
+ transient,
7
+ view,
8
+ ViewContext,
9
+ Saveable,
10
+ } from '@difizen/mana-app';
11
+ import { Dropdown } from '@difizen/mana-react';
12
+ import { Badge } from 'antd';
13
+ import classnames from 'classnames';
14
+
15
+ @transient()
16
+ @view('LibroLabSaveableTab')
17
+ export class SaveableTabView extends CardTabView {
18
+ protected override renderTab(item: View) {
19
+ return (
20
+ <ViewContext view={item}>
21
+ <Dropdown
22
+ trigger={['contextMenu']}
23
+ overlay={<MenuRender menuPath={['tab-bar-context-menu']} data={undefined} />}
24
+ >
25
+ <div
26
+ title={item.title.caption}
27
+ className={classnames('mana-tab-title', item.title.className)}
28
+ >
29
+ {item.title.icon && (
30
+ <span className="mana-tab-icon">
31
+ {this.renderTitleIcon(item.title.icon)}
32
+ </span>
33
+ )}
34
+ {this.renderTitleLabel(item.title.label)}
35
+ {this.renderTail(item)}
36
+ </div>
37
+ </Dropdown>
38
+ </ViewContext>
39
+ );
40
+ }
41
+ protected renderTail(item: View) {
42
+ const isDirty = Saveable.is(item) && Saveable.isDirty(item);
43
+ return (
44
+ <div className="libro-lab-editor-tab-tail">
45
+ {isDirty ? (
46
+ <div className="libro-lab-editor-tab-dirty">
47
+ <Badge status="default" />
48
+ </div>
49
+ ) : (
50
+ item.title.closable && (
51
+ <CloseOutlined
52
+ onClick={(e) => {
53
+ e.stopPropagation();
54
+ this.close(item);
55
+ if (this.children.length > 0) {
56
+ this.active = this.children[this.children.length - 1];
57
+ }
58
+ }}
59
+ className="mana-tab-close"
60
+ />
61
+ )
62
+ )}
63
+ </div>
64
+ );
65
+ }
66
+ }
@@ -0,0 +1,28 @@
1
+ import { MacCommandOutlined } from '@ant-design/icons';
2
+ import {
3
+ BaseView,
4
+ MAIN_MENU_BAR,
5
+ MenuBarRender,
6
+ prop,
7
+ singleton,
8
+ view,
9
+ } from '@difizen/mana-app';
10
+ import { forwardRef } from 'react';
11
+
12
+ export const ManaMenubarComponent = forwardRef(function GithubLinkComponent() {
13
+ return <MenuBarRender menuPath={MAIN_MENU_BAR} />;
14
+ });
15
+
16
+ @singleton()
17
+ @view('MenuBarView')
18
+ export class MenuBarView extends BaseView {
19
+ override view = ManaMenubarComponent;
20
+ @prop()
21
+ count = 0;
22
+ constructor() {
23
+ super();
24
+ this.title.icon = MacCommandOutlined;
25
+ this.title.label = '菜单';
26
+ this.id = 'menu-bar';
27
+ }
28
+ }