@difizen/libro-widget 0.2.0 → 0.2.2

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 (120) hide show
  1. package/es/index.d.ts +3 -4
  2. package/es/index.d.ts.map +1 -1
  3. package/es/index.js +3 -4
  4. package/es/module.d.ts +3 -0
  5. package/es/module.d.ts.map +1 -0
  6. package/es/module.js +5 -0
  7. package/es/slider/contribution.d.ts +10 -0
  8. package/es/slider/contribution.d.ts.map +1 -0
  9. package/es/{widgets/instances-progress-widget-view-contribution.js → slider/contribution.js} +15 -9
  10. package/es/slider/index.d.ts +3 -0
  11. package/es/slider/index.d.ts.map +1 -0
  12. package/es/slider/index.js +2 -0
  13. package/es/slider/index.less +3 -0
  14. package/es/slider/view.d.ts +23 -0
  15. package/es/slider/view.d.ts.map +1 -0
  16. package/es/{widgets/progress-widget-view.js → slider/view.js} +64 -70
  17. package/es/text/contribution.d.ts +10 -0
  18. package/es/text/contribution.d.ts.map +1 -0
  19. package/es/{widgets/text-widget-view-contribution.js → text/contribution.js} +3 -3
  20. package/es/text/index.d.ts +3 -0
  21. package/es/text/index.d.ts.map +1 -0
  22. package/es/text/index.js +2 -0
  23. package/es/text/view.d.ts +18 -0
  24. package/es/text/view.d.ts.map +1 -0
  25. package/es/{widgets/text-widget-view.js → text/view.js} +13 -14
  26. package/package.json +7 -6
  27. package/src/index.spec.ts +2 -3
  28. package/src/index.ts +3 -4
  29. package/src/module.ts +15 -0
  30. package/src/slider/contribution.ts +25 -0
  31. package/src/slider/index.less +3 -0
  32. package/src/slider/index.ts +2 -0
  33. package/src/slider/view.tsx +92 -0
  34. package/src/{widgets/text-widget-view-contribution.ts → text/contribution.ts} +4 -5
  35. package/src/text/index.ts +2 -0
  36. package/src/{widgets/text-widget-view.tsx → text/view.tsx} +10 -13
  37. package/es/base/comm.d.ts +0 -65
  38. package/es/base/comm.d.ts.map +0 -1
  39. package/es/base/comm.js +0 -151
  40. package/es/base/index.d.ts +0 -7
  41. package/es/base/index.d.ts.map +0 -1
  42. package/es/base/index.js +0 -6
  43. package/es/base/libro-widgets.d.ts +0 -79
  44. package/es/base/libro-widgets.d.ts.map +0 -1
  45. package/es/base/libro-widgets.js +0 -286
  46. package/es/base/protocal.d.ts +0 -171
  47. package/es/base/protocal.d.ts.map +0 -1
  48. package/es/base/protocal.js +0 -21
  49. package/es/base/utils.d.ts +0 -27
  50. package/es/base/utils.d.ts.map +0 -1
  51. package/es/base/utils.js +0 -59
  52. package/es/base/version.d.ts +0 -3
  53. package/es/base/version.d.ts.map +0 -1
  54. package/es/base/version.js +0 -2
  55. package/es/base/widget-manager.d.ts +0 -18
  56. package/es/base/widget-manager.d.ts.map +0 -1
  57. package/es/base/widget-manager.js +0 -68
  58. package/es/base/widget-view-contribution.d.ts +0 -10
  59. package/es/base/widget-view-contribution.d.ts.map +0 -1
  60. package/es/base/widget-view-contribution.js +0 -36
  61. package/es/base/widget-view.d.ts +0 -52
  62. package/es/base/widget-view.d.ts.map +0 -1
  63. package/es/base/widget-view.js +0 -137
  64. package/es/components/index.d.ts +0 -3
  65. package/es/components/index.d.ts.map +0 -1
  66. package/es/components/index.js +0 -2
  67. package/es/components/progressBar.d.ts +0 -15
  68. package/es/components/progressBar.d.ts.map +0 -1
  69. package/es/components/progressBar.js +0 -20
  70. package/es/components/progressCircle.d.ts +0 -11
  71. package/es/components/progressCircle.d.ts.map +0 -1
  72. package/es/components/progressCircle.js +0 -16
  73. package/es/widget-module.d.ts +0 -3
  74. package/es/widget-module.d.ts.map +0 -1
  75. package/es/widget-module.js +0 -39
  76. package/es/widgets/hbox-widget-view-contribution.d.ts +0 -10
  77. package/es/widgets/hbox-widget-view-contribution.d.ts.map +0 -1
  78. package/es/widgets/hbox-widget-view-contribution.js +0 -39
  79. package/es/widgets/hbox-widget-view.d.ts +0 -17
  80. package/es/widgets/hbox-widget-view.d.ts.map +0 -1
  81. package/es/widgets/hbox-widget-view.js +0 -69
  82. package/es/widgets/index.d.ts +0 -9
  83. package/es/widgets/index.d.ts.map +0 -1
  84. package/es/widgets/index.js +0 -8
  85. package/es/widgets/index.less +0 -3
  86. package/es/widgets/instances-progress-widget-view-contribution.d.ts +0 -10
  87. package/es/widgets/instances-progress-widget-view-contribution.d.ts.map +0 -1
  88. package/es/widgets/instances-progress-widget-view.d.ts +0 -31
  89. package/es/widgets/instances-progress-widget-view.d.ts.map +0 -1
  90. package/es/widgets/instances-progress-widget-view.js +0 -181
  91. package/es/widgets/progress-widget-view-contribution.d.ts +0 -10
  92. package/es/widgets/progress-widget-view-contribution.d.ts.map +0 -1
  93. package/es/widgets/progress-widget-view-contribution.js +0 -39
  94. package/es/widgets/progress-widget-view.d.ts +0 -25
  95. package/es/widgets/progress-widget-view.d.ts.map +0 -1
  96. package/es/widgets/text-widget-view-contribution.d.ts +0 -10
  97. package/es/widgets/text-widget-view-contribution.d.ts.map +0 -1
  98. package/es/widgets/text-widget-view.d.ts +0 -19
  99. package/es/widgets/text-widget-view.d.ts.map +0 -1
  100. package/src/base/comm.ts +0 -152
  101. package/src/base/index.ts +0 -6
  102. package/src/base/libro-widgets.ts +0 -207
  103. package/src/base/protocal.ts +0 -218
  104. package/src/base/utils.ts +0 -67
  105. package/src/base/version.ts +0 -2
  106. package/src/base/widget-manager.ts +0 -41
  107. package/src/base/widget-view-contribution.ts +0 -14
  108. package/src/base/widget-view.tsx +0 -146
  109. package/src/components/index.ts +0 -3
  110. package/src/components/progressBar.tsx +0 -29
  111. package/src/components/progressCircle.tsx +0 -18
  112. package/src/widget-module.ts +0 -68
  113. package/src/widgets/hbox-widget-view-contribution.ts +0 -20
  114. package/src/widgets/hbox-widget-view.tsx +0 -64
  115. package/src/widgets/index.less +0 -3
  116. package/src/widgets/index.ts +0 -8
  117. package/src/widgets/instances-progress-widget-view-contribution.ts +0 -20
  118. package/src/widgets/instances-progress-widget-view.tsx +0 -160
  119. package/src/widgets/progress-widget-view-contribution.ts +0 -24
  120. package/src/widgets/progress-widget-view.tsx +0 -85
@@ -1,29 +0,0 @@
1
- import { Progress } from 'antd';
2
-
3
- /**
4
- * Props for the ProgressBar.
5
- */
6
- export interface IProgressBarProps {
7
- /**
8
- * The current progress percentage, from 0 to 100
9
- */
10
- percent: number;
11
- /**
12
- * Width of progress bar in pixel.
13
- */
14
- width?: number;
15
- }
16
-
17
- export function ProgressBar(props: IProgressBarProps) {
18
- return (
19
- <>
20
- <Progress
21
- strokeLinecap="butt"
22
- percent={props.percent}
23
- strokeWidth={18}
24
- showInfo={false}
25
- style={{ width: '200px' }}
26
- />
27
- </>
28
- );
29
- }
@@ -1,18 +0,0 @@
1
- import { Progress } from 'antd';
2
- /**
3
- * Props for the ProgressBar.
4
- */
5
- export interface IProgressCircleProps {
6
- /**
7
- * The current progress percentage, from 0 to 100
8
- */
9
- percent: number;
10
- }
11
-
12
- export function ProgressCircle(props: IProgressCircleProps) {
13
- return (
14
- <>
15
- <Progress strokeLinecap="butt" type="circle" percent={props.percent} />;
16
- </>
17
- );
18
- }
@@ -1,68 +0,0 @@
1
- import { LibroKernelManageModule } from '@difizen/libro-kernel';
2
- import { ManaModule } from '@difizen/mana-app';
3
-
4
- import { Comm } from './base/comm.js';
5
- import {
6
- WidgetsOption,
7
- LibroWidgetCommFactory,
8
- WidgetCommOption,
9
- LibroWidgets,
10
- LibroWidgetsFactory,
11
- WidgetView,
12
- WidgetViewContribution,
13
- } from './base/index.js';
14
- import { LibroWidgetManager } from './base/widget-manager.js';
15
- import { DefaultWidgetViewContribution } from './base/widget-view-contribution.js';
16
- import { HBoxModelContribution } from './widgets/hbox-widget-view-contribution.js';
17
- import { HBoxWidget } from './widgets/hbox-widget-view.js';
18
- import { ProgressWidget } from './widgets/index.js';
19
- import { InstancesProgressWidgetViewContribution } from './widgets/instances-progress-widget-view-contribution.js';
20
- import { InstancesProgressWidget } from './widgets/instances-progress-widget-view.js';
21
- import { ProgressWidgetViewContribution } from './widgets/progress-widget-view-contribution.js';
22
- import { TextModelContribution } from './widgets/text-widget-view-contribution.js';
23
- import { LibroTextWidget } from './widgets/text-widget-view.js';
24
-
25
- export const WidgetModule = ManaModule.create()
26
- .contribution(WidgetViewContribution)
27
- .register(
28
- Comm,
29
- {
30
- token: LibroWidgetCommFactory,
31
- useFactory: (ctx) => {
32
- return (options: WidgetCommOption) => {
33
- const child = ctx.container.createChild();
34
- child.register({
35
- token: WidgetCommOption,
36
- useValue: options,
37
- });
38
- return child.get(Comm);
39
- };
40
- },
41
- },
42
- LibroWidgets,
43
- {
44
- token: LibroWidgetsFactory,
45
- useFactory: (ctx) => {
46
- return (options: WidgetsOption) => {
47
- const child = ctx.container.createChild();
48
- child.register({
49
- token: WidgetsOption,
50
- useValue: options,
51
- });
52
- return child.get(LibroWidgets);
53
- };
54
- },
55
- },
56
- LibroWidgetManager,
57
- WidgetView,
58
- ProgressWidget,
59
- DefaultWidgetViewContribution,
60
- ProgressWidgetViewContribution,
61
- InstancesProgressWidgetViewContribution,
62
- InstancesProgressWidget,
63
- HBoxModelContribution,
64
- HBoxWidget,
65
- LibroTextWidget,
66
- TextModelContribution,
67
- )
68
- .dependOn(LibroKernelManageModule);
@@ -1,20 +0,0 @@
1
- import { ViewManager, inject, singleton } from '@difizen/mana-app';
2
-
3
- import type { IWidgetViewProps } from '../base/protocal.js';
4
- import { WidgetViewContribution } from '../base/protocal.js';
5
-
6
- import { HBoxWidget } from './hbox-widget-view.js';
7
-
8
- @singleton({ contrib: WidgetViewContribution })
9
- export class HBoxModelContribution implements WidgetViewContribution {
10
- @inject(ViewManager) viewManager: ViewManager;
11
- canHandle = (attributes: any) => {
12
- if (attributes._model_name === 'HBoxModel') {
13
- return 100;
14
- }
15
- return 1;
16
- };
17
- factory(props: IWidgetViewProps) {
18
- return this.viewManager.getOrCreateView(HBoxWidget, props);
19
- }
20
- }
@@ -1,64 +0,0 @@
1
- import {
2
- view,
3
- ViewOption,
4
- ViewRender,
5
- transient,
6
- useInject,
7
- ViewInstance,
8
- inject,
9
- } from '@difizen/mana-app';
10
- import { forwardRef } from 'react';
11
-
12
- import type { IWidgetViewProps } from '../base/protocal.js';
13
- import { WidgetView } from '../base/widget-view.js';
14
- import './index.less';
15
- import { LibroWidgets } from '../base/libro-widgets.js';
16
- import { LirboContextKey } from '@difizen/libro-core';
17
-
18
- export const HBoxWidgetComponent = forwardRef<HTMLDivElement>(
19
- function HBoxWidgetComponent() {
20
- const widgetView = useInject<HBoxWidget>(ViewInstance);
21
- if (widgetView.isCommClosed) {
22
- return null;
23
- }
24
- const hboxChildrenWidget = widgetView.get_child_model();
25
- return (
26
- <div className="libro-hbox-widget">
27
- {hboxChildrenWidget.map((childrenWidgets) => (
28
- <ViewRender view={childrenWidgets} key={childrenWidgets.id} />
29
- ))}
30
- </div>
31
- );
32
- },
33
- );
34
- @transient()
35
- @view('libro-hbox-widget-view')
36
- export class HBoxWidget extends WidgetView {
37
- override view = HBoxWidgetComponent;
38
- children: string[];
39
- layout: string;
40
- box_style: string;
41
- override libroWidgets: LibroWidgets;
42
- constructor(
43
- @inject(ViewOption) props: IWidgetViewProps,
44
- @inject(LirboContextKey) lirboContextKey: LirboContextKey,
45
- @inject(LibroWidgets) libroWidgets: LibroWidgets,
46
- ) {
47
- super(props, lirboContextKey);
48
- this.box_style = props.attributes.bar_style;
49
- this.layout = props.attributes.layout;
50
- this.children = props.attributes.children;
51
- this.lirboContextKey = lirboContextKey;
52
- this.libroWidgets = libroWidgets;
53
- }
54
-
55
- get_child_model(): WidgetView[] {
56
- const childrenWidgets: WidgetView[] = [];
57
- this.children.forEach((child) => {
58
- if (this.libroWidgets.hasModel(child.substring(10))) {
59
- childrenWidgets.push(this.libroWidgets.getModel(child.substring(10)));
60
- }
61
- });
62
- return childrenWidgets;
63
- }
64
- }
@@ -1,3 +0,0 @@
1
- .libro-input-widget {
2
- display: flex;
3
- }
@@ -1,8 +0,0 @@
1
- export * from './hbox-widget-view.js';
2
- export * from './hbox-widget-view-contribution.js';
3
- export * from './instances-progress-widget-view.js';
4
- export * from './instances-progress-widget-view-contribution.js';
5
- export * from './progress-widget-view.js';
6
- export * from './progress-widget-view-contribution.js';
7
- export * from './text-widget-view.js';
8
- export * from './text-widget-view-contribution.js';
@@ -1,20 +0,0 @@
1
- import { ViewManager, inject, singleton } from '@difizen/mana-app';
2
-
3
- import type { IWidgetViewProps } from '../base/protocal.js';
4
- import { WidgetViewContribution } from '../base/protocal.js';
5
-
6
- import { InstancesProgressWidget } from './instances-progress-widget-view.js';
7
-
8
- @singleton({ contrib: WidgetViewContribution })
9
- export class InstancesProgressWidgetViewContribution implements WidgetViewContribution {
10
- @inject(ViewManager) viewManager: ViewManager;
11
- canHandle = (attributes: any) => {
12
- if (attributes._model_name === 'InstancesProgressModel') {
13
- return 100;
14
- }
15
- return 1;
16
- };
17
- factory(props: IWidgetViewProps) {
18
- return this.viewManager.getOrCreateView(InstancesProgressWidget, props);
19
- }
20
- }
@@ -1,160 +0,0 @@
1
- import { LirboContextKey } from '@difizen/libro-core';
2
- import type { KernelMessage } from '@difizen/libro-kernel';
3
- import {
4
- useInject,
5
- view,
6
- ViewInstance,
7
- ViewOption,
8
- transient,
9
- inject,
10
- prop,
11
- } from '@difizen/mana-app';
12
- import { forwardRef } from 'react';
13
-
14
- import type {
15
- InstanceRecord,
16
- InstancesRecords,
17
- ProgressItem,
18
- } from '../base/protocal.js';
19
- import type { IWidgetViewProps } from '../base/protocal.js';
20
- import { WidgetView } from '../base/widget-view.js';
21
- import './index.less';
22
-
23
- export interface ProgressOverviewProps {
24
- progressMap: Record<string, ProgressItem>;
25
- workingProgressKeys: string[];
26
- prefix: string;
27
- suffix: string;
28
- }
29
-
30
- export const LibroInstancesProgressWidgetViewComponent = forwardRef<HTMLDivElement>(
31
- function LibroInstancesProgressWidgetViewComponent(_props, ref) {
32
- const widgetView = useInject<InstancesProgressWidget>(ViewInstance);
33
- if (widgetView.isCommClosed) {
34
- return null;
35
- }
36
- return (
37
- <div ref={ref} className="libro-instances-progress-widget">
38
- <span style={{ paddingRight: 5 }}>{widgetView.prefix}</span>
39
- <span>
40
- {widgetView.workingProgressKeys.map((progressKey) => {
41
- const progressItem = widgetView.progressMap[progressKey];
42
- return (
43
- <a
44
- className="pyodps-progress-launcher"
45
- style={{ marginRight: 5 }}
46
- key={progressKey}
47
- >
48
- {progressItem && progressItem.name}
49
- </a>
50
- );
51
- })}
52
- </span>
53
- <span>{widgetView.suffix}</span>
54
- </div>
55
- );
56
- },
57
- );
58
- @transient()
59
- @view('libro-widget-instances-progress-view')
60
- export class InstancesProgressWidget extends WidgetView {
61
- override view = LibroInstancesProgressWidgetViewComponent;
62
- @prop()
63
- prefix: string;
64
- @prop()
65
- suffix: string;
66
- progressMap: Record<string, ProgressItem> = {};
67
- workingProgressKeys: string[] = []; // Order of groups by time of insertion
68
- instanceRecords: InstancesRecords = {};
69
- modalVisible = false;
70
- modalProgressItemKey = '';
71
- constructor(
72
- @inject(ViewOption) props: IWidgetViewProps,
73
- @inject(LirboContextKey) lirboContextKey: LirboContextKey,
74
- ) {
75
- super(props, lirboContextKey);
76
- this.prefix = props.attributes.prefix;
77
- this.suffix = props.attributes.suffix;
78
- }
79
- updateRecords(progressKey: string) {
80
- const progressItem = this.progressMap[progressKey];
81
- if (progressItem) {
82
- const { instances = [] } = progressItem;
83
- instances.forEach((instance) => {
84
- const { id, status } = instance;
85
- if (!this.instanceRecords[id]) {
86
- this.instanceRecords[id] = {
87
- startDate: Date.now(),
88
- } as InstanceRecord;
89
- }
90
- if (status === 'Terminated') {
91
- if (!this.instanceRecords[id].endDate) {
92
- this.instanceRecords[id].endDate = Date.now();
93
- }
94
- }
95
- });
96
- }
97
- }
98
- /**
99
- * Handle incoming comm msg.
100
- */
101
- override handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> {
102
- const data = msg.content.data as any;
103
- const method = data.method;
104
- switch (method) {
105
- case 'update':
106
- if (data.state.prefix) {
107
- this.prefix = data.state.prefix;
108
- }
109
- if (data.state.suffix) {
110
- this.suffix = data.state.suffix;
111
- }
112
- // eslint-disable-next-line no-fallthrough
113
- case 'custom':
114
- // eslint-disable-next-line no-case-declarations
115
- const customMsg = data.content;
116
- if (customMsg) {
117
- // message format: '{"action": "action", content: ["content1", "content2"]}'
118
- const msgObj: { action: 'update' | 'delete' | 'clear'; content: string[] } =
119
- JSON.parse(customMsg);
120
- const action: string = msgObj.action;
121
- const content: string[] = [];
122
- if (msgObj.content) {
123
- content.push(...msgObj.content);
124
- }
125
-
126
- switch (action) {
127
- case 'update':
128
- content.forEach((groupJson) => {
129
- const parsedProgressItem: ProgressItem = JSON.parse(groupJson);
130
- if (!this.progressMap[parsedProgressItem.key]) {
131
- this.workingProgressKeys.push(parsedProgressItem.key);
132
- }
133
- this.progressMap[parsedProgressItem.key] = parsedProgressItem;
134
- this.updateRecords(parsedProgressItem.key);
135
- });
136
- // ? TODO: 发出一个更新 modal signal 的信号,这里需要取到之前的 key
137
- break;
138
- case 'delete':
139
- content.forEach((groupKey: string) => {
140
- if (!this.progressMap[groupKey]) {
141
- return;
142
- }
143
- const i = this.workingProgressKeys.indexOf(groupKey);
144
- if (i >= 0) {
145
- this.workingProgressKeys.splice(i, 1);
146
- }
147
- });
148
- break;
149
- case 'clear':
150
- this.progressMap = {};
151
- this.workingProgressKeys = [];
152
- // ? TODO: 发出更新 overview 以及 modal 的 signal
153
- break;
154
- default:
155
- }
156
- }
157
- }
158
- return Promise.resolve();
159
- }
160
- }
@@ -1,24 +0,0 @@
1
- import { ViewManager, inject, singleton } from '@difizen/mana-app';
2
-
3
- import type { IWidgetViewProps } from '../base/protocal.js';
4
- import { WidgetViewContribution } from '../base/protocal.js';
5
-
6
- import { ProgressWidget } from './progress-widget-view.js';
7
-
8
- @singleton({ contrib: WidgetViewContribution })
9
- export class ProgressWidgetViewContribution implements WidgetViewContribution {
10
- @inject(ViewManager) viewManager: ViewManager;
11
- canHandle = (attributes: any) => {
12
- if (
13
- attributes._model_name === 'FloatProgressModel' ||
14
- attributes._model_name === 'IntProgressModel' ||
15
- attributes._model_name === 'TransientProgressModel'
16
- ) {
17
- return 100;
18
- }
19
- return 1;
20
- };
21
- factory(props: IWidgetViewProps) {
22
- return this.viewManager.getOrCreateView(ProgressWidget, props);
23
- }
24
- }
@@ -1,85 +0,0 @@
1
- import { LirboContextKey } from '@difizen/libro-core';
2
- import type { KernelMessage } from '@difizen/libro-kernel';
3
- import {
4
- view,
5
- ViewOption,
6
- transient,
7
- useInject,
8
- ViewInstance,
9
- inject,
10
- prop,
11
- } from '@difizen/mana-app';
12
- import { forwardRef } from 'react';
13
-
14
- import type { IWidgetViewProps } from '../base/protocal.js';
15
- import { WidgetView } from '../base/widget-view.js';
16
- import { ProgressBar } from '../components/index.js';
17
- import './index.less';
18
-
19
- export const LibroProgressWidgetComponent = forwardRef<HTMLDivElement>(
20
- function LibroProgressWidgetComponent() {
21
- const widgetView = useInject<ProgressWidget>(ViewInstance);
22
- const percent = widgetView.value / ((widgetView.max - widgetView.min) / 100);
23
- if (widgetView.isCommClosed) {
24
- return null;
25
- }
26
- return (
27
- <div className="libro-progress-widget">
28
- <div className="libro-progress-widget-description">
29
- {widgetView.description}
30
- </div>
31
- <ProgressBar percent={percent} />
32
- </div>
33
- );
34
- },
35
- );
36
- @transient()
37
- @view('libro-widget-progress-view')
38
- export class ProgressWidget extends WidgetView {
39
- override view = LibroProgressWidgetComponent;
40
- bar_style: string;
41
- description: string;
42
- description_tooltip: null;
43
- layout: string;
44
- @prop()
45
- max: number;
46
- @prop()
47
- min: number;
48
- orientation: string;
49
- style: string;
50
- @prop()
51
- value: number;
52
- constructor(
53
- @inject(ViewOption) props: IWidgetViewProps,
54
- @inject(LirboContextKey) lirboContextKey: LirboContextKey,
55
- ) {
56
- super(props, lirboContextKey);
57
- this.bar_style = props.attributes.bar_style;
58
- this.description = props.attributes.description;
59
- this.description_tooltip = props.attributes.description_tooltip;
60
- this.layout = props.attributes.layout;
61
- this.max = props.attributes.max;
62
- this.min = props.attributes.min;
63
- this.orientation = props.attributes.orientation;
64
- this.style = props.attributes.style;
65
- this.value = props.attributes.value;
66
- }
67
- /**
68
- * Handle incoming comm msg.
69
- */
70
- override handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> {
71
- const data = msg.content.data as any;
72
- const method = data.method;
73
- switch (method) {
74
- case 'update':
75
- case 'echo_update':
76
- if (data.state.value) {
77
- this.value = data.state.value;
78
- }
79
- if (data.state.description) {
80
- this.description = data.state.description;
81
- }
82
- }
83
- return Promise.resolve();
84
- }
85
- }