@hpcc-js/common 3.6.3 → 3.6.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 (54) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +59 -59
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +1 -1
  6. package/dist/index.umd.cjs.map +1 -1
  7. package/package.json +4 -4
  8. package/src/CanvasWidget.ts +31 -31
  9. package/src/Class.ts +72 -72
  10. package/src/Database.ts +860 -860
  11. package/src/Entity.ts +235 -235
  12. package/src/EntityCard.ts +66 -66
  13. package/src/EntityPin.ts +103 -103
  14. package/src/EntityRect.css +15 -15
  15. package/src/EntityRect.ts +254 -254
  16. package/src/EntityVertex.ts +86 -86
  17. package/src/FAChar.css +2 -2
  18. package/src/FAChar.ts +89 -89
  19. package/src/HTMLWidget.ts +191 -191
  20. package/src/IList.ts +4 -4
  21. package/src/IMenu.ts +5 -5
  22. package/src/Icon.css +9 -9
  23. package/src/Icon.ts +176 -176
  24. package/src/Image.ts +104 -104
  25. package/src/List.css +13 -13
  26. package/src/List.ts +102 -102
  27. package/src/Menu.css +23 -23
  28. package/src/Menu.ts +139 -139
  29. package/src/Palette.ts +341 -341
  30. package/src/Platform.ts +125 -125
  31. package/src/ProgressBar.ts +115 -115
  32. package/src/PropertyExt.ts +770 -770
  33. package/src/ResizeSurface.css +39 -39
  34. package/src/ResizeSurface.ts +225 -225
  35. package/src/SVGWidget.ts +583 -583
  36. package/src/SVGZoomWidget.css +12 -12
  37. package/src/SVGZoomWidget.ts +427 -427
  38. package/src/Shape.css +3 -3
  39. package/src/Shape.ts +186 -186
  40. package/src/Surface.css +35 -35
  41. package/src/Surface.ts +364 -364
  42. package/src/Text.css +4 -4
  43. package/src/Text.ts +131 -131
  44. package/src/TextBox.css +4 -4
  45. package/src/TextBox.ts +183 -183
  46. package/src/TitleBar.css +114 -114
  47. package/src/TitleBar.ts +407 -407
  48. package/src/Transition.ts +45 -45
  49. package/src/Utility.ts +839 -839
  50. package/src/Widget.css +8 -8
  51. package/src/Widget.ts +731 -731
  52. package/src/WidgetArray.ts +15 -15
  53. package/src/__package__.ts +3 -3
  54. package/src/index.ts +55 -55
package/src/Entity.ts CHANGED
@@ -1,235 +1,235 @@
1
- import { local as d3Local } from "d3-selection";
2
- import { Icon } from "./Icon.ts";
3
- import { Shape } from "./Shape.ts";
4
- import { SVGWidget } from "./SVGWidget.ts";
5
- import { Text } from "./Text.ts";
6
- import { BBox, Widget } from "./Widget.ts";
7
-
8
- export interface IAnnotation {
9
- faChar: string;
10
- tooltip?: string;
11
- shape_colorFill?: string;
12
- shape_colorStroke?: string;
13
- image_colorFill?: string;
14
- shape?: string;
15
- }
16
-
17
- export class Entity extends SVGWidget {
18
- protected _icon_widget: Icon;
19
- protected _background_widget: Shape;
20
- protected _title_widget: Text;
21
- protected _desc_widget: Text;
22
- protected _annotation_widgets: { [idx: number]: { widget: SVGWidget, bbox: BBox } };
23
- protected _element_anno;
24
- protected _element_background;
25
- protected _element_desc;
26
- protected _element_icon;
27
- protected _element_title;
28
-
29
- private _annotationLocal = d3Local<Icon>();
30
-
31
- constructor() {
32
- super();
33
-
34
- this._background_widget = new Shape();
35
- this._icon_widget = new Icon();
36
- this._title_widget = new Text();
37
- this._desc_widget = new Text();
38
- this._annotation_widgets = {};
39
- }
40
- getAnnotationsBBox(): BBox {
41
- let retVal: BBox;
42
- for (const key in this._annotation_widgets) {
43
- const bbox = this._annotation_widgets[key].bbox;
44
- if (!retVal) {
45
- retVal = bbox;
46
- } else {
47
- retVal.x = Math.min(retVal.x, bbox.x);
48
- retVal.y = Math.min(retVal.y, bbox.y);
49
- retVal.width = Math.max(retVal.width, bbox.width);
50
- retVal.height = Math.max(retVal.height, bbox.height);
51
- }
52
- }
53
- return retVal || { x: 0, y: 0, width: 0, height: 0 };
54
- }
55
- enter(domNode, element) {
56
- super.enter(domNode, element);
57
- element
58
- .on("mouseover", () => {
59
- element.classed("hovering", true);
60
- this.render();
61
- })
62
- .on("mouseout", () => {
63
- element.classed("hovering", false);
64
- this.render();
65
- })
66
- ;
67
-
68
- this._element_background = element.append("g").attr("class", "entity_shape");
69
- this._element_icon = element.append("g").attr("class", "entity_icon");
70
- this._element_title = element.append("g").attr("class", "entity_title");
71
- this._element_desc = element.append("g").attr("class", "entity_desc");
72
- this._element_anno = element.append("g").attr("class", "entity_anno");
73
-
74
- this._background_widget
75
- .target(this._element_background.node());
76
- this._icon_widget
77
- .shape_colorFill("none")
78
- .shape_colorStroke("none")
79
- .target(this._element_icon.node());
80
- this._title_widget
81
- .target(this._element_title.node());
82
- this._desc_widget
83
- .target(this._element_desc.node());
84
- }
85
- update(domNode, element) {
86
- super.update(domNode, element);
87
- this._desc_widget
88
- .fontSize(this.descriptionFontSize());
89
- const context = this;
90
- this._annotation_widgets = {};
91
- let annoXPos = 0;
92
- const annotations = this._element_anno.selectAll(".annotation").data([...this.annotationIcons()].reverse());
93
- annotations.enter().append("g")
94
- .attr("class", "annotation")
95
- .each(function (this: SVGGElement, d, idx) {
96
- const anno = new Icon()
97
- .diameter(context.annotationDiameter())
98
- .paddingPercent(context.annotationPaddingPercent())
99
- .target(this)
100
- .shape("square")
101
- ;
102
- context._annotationLocal.set(this, anno);
103
- })
104
- .merge(annotations)
105
- .each(function (this: SVGGElement, d, idx) {
106
- const anno = context._annotationLocal.get(this);
107
- if (typeof d.faChar !== "undefined") anno.faChar(d.faChar);
108
- if (typeof d.shape !== "undefined") anno.shape(d.shape);
109
- if (typeof d.image_colorFill !== "undefined") anno.image_colorFill(d.image_colorFill);
110
- if (typeof d.shape_colorFill !== "undefined") anno.shape_colorFill(d.shape_colorFill);
111
- if (typeof d.shape_colorStroke !== "undefined") anno.shape_colorStroke(d.shape_colorStroke);
112
- const annoDiam = anno.diameter();
113
- anno
114
- .x(annoXPos - annoDiam)
115
- .y(annoDiam / 2)
116
- .render()
117
- ;
118
- annoXPos -= annoDiam + context.annotationSpacing();
119
- context._annotation_widgets[idx] = {
120
- widget: anno,
121
- bbox: anno.getBBox(true)
122
- };
123
- });
124
- annotations.exit()
125
- .each(function (this: HTMLElement, d, idx) {
126
- const anno = context._annotationLocal.get(this);
127
- anno.target(null);
128
- })
129
- .remove();
130
- }
131
- exit(domNode, element) {
132
- this._desc_widget.target(null);
133
- this._title_widget.target(null);
134
- this._icon_widget.target(null);
135
- this._background_widget.target(null);
136
- super.exit(domNode, element);
137
- }
138
- moveAnnotations(x_offset: number, y_offset: number) {
139
- this._element_anno.attr("transform", `translate(${x_offset}, ${y_offset})`);
140
- }
141
- render(callback?: (w: Widget) => void) {
142
- return super.render(w => {
143
- this._background_widget.render();
144
- this._icon_widget.render();
145
- this._title_widget.render();
146
- this._desc_widget.render();
147
- if (callback) {
148
- callback(w);
149
- }
150
- });
151
- }
152
- }
153
- Entity.prototype._class += " common_Entity";
154
-
155
- export interface Entity {
156
- arrowHeight(): number;
157
- arrowHeight(_: number): this;
158
- arrowWidth(): number;
159
- arrowWidth(_: number): this;
160
- cornerRadius(): number;
161
- cornerRadius(_: number): this;
162
- padding(): number;
163
- padding(_: number): this;
164
- paddingPercent(): number;
165
- paddingPercent(_: number): this;
166
-
167
- annotationIcons(): IAnnotation[];
168
- annotationIcons(_: IAnnotation[]): this;
169
- annotationDiameter(): number;
170
- annotationDiameter(_: number): this;
171
- annotationSpacing(): number;
172
- annotationSpacing(_: number): this;
173
- annotationPaddingPercent(): number;
174
- annotationPaddingPercent(_: number): this;
175
- icon(): string;
176
- icon(_: string): this;
177
- iconColor(): string;
178
- iconColor(_: string): this;
179
- iconDiameter(): number;
180
- iconDiameter(_: number): this;
181
- iconPaddingPercent(): number;
182
- iconPaddingPercent(_: number): this;
183
- description(): string;
184
- description(_: string): this;
185
- descriptionColor(): string;
186
- descriptionColor(_: string): this;
187
- descriptionFontFamily(): string;
188
- descriptionFontFamily(_: string): this;
189
- descriptionFontSize(): number;
190
- descriptionFontSize(_: number): this;
191
- title(): string;
192
- title(_: string): this;
193
- titleColor(): string;
194
- titleColor(_: string): this;
195
- titleFontFamily(): string;
196
- titleFontFamily(_: string): this;
197
- titleFontSize(): number;
198
- titleFontSize(_: number): this;
199
- backgroundShape(): string;
200
- backgroundShape(_: string): this;
201
- backgroundColorFill(): string;
202
- backgroundColorFill(_: string): this;
203
- backgroundColorStroke(): string;
204
- backgroundColorStroke(_: string): this;
205
- }
206
-
207
- Entity.prototype.publish("padding", 8, "number", "padding");
208
-
209
- Entity.prototype.publish("annotationPaddingPercent", 38, "number", "annotationPaddingPercent");
210
- Entity.prototype.publish("annotationDiameter", 14, "number", "Annotation Diameter");
211
- Entity.prototype.publish("annotationIcons", [], "array", "annotationIcons"); // TODO: is this really used?
212
- Entity.prototype.publish("annotationSpacing", 3, "number", "annotationSpacing");
213
-
214
- Entity.prototype.publishProxy("icon", "_icon_widget", "faChar");
215
- Entity.prototype.publishProxy("iconColor", "_icon_widget", "image_colorFill");
216
- Entity.prototype.publishProxy("iconDiameter", "_icon_widget", "diameter");
217
- Entity.prototype.publishProxy("iconPaddingPercent", "_icon_widget", "paddingPercent");
218
-
219
- Entity.prototype.publishProxy("title", "_title_widget", "text");
220
- Entity.prototype.publishProxy("titleColor", "_title_widget", "colorFill");
221
- Entity.prototype.publishProxy("titleFontFamily", "_title_widget", "fontFamily");
222
- Entity.prototype.publishProxy("titleFontSize", "_title_widget", "fontSize");
223
-
224
- Entity.prototype.publishProxy("description", "_desc_widget", "text");
225
- Entity.prototype.publishProxy("descriptionColor", "_desc_widget", "colorFill");
226
- Entity.prototype.publishProxy("descriptionFontFamily", "_desc_widget", "fontFamily");
227
- Entity.prototype.publishProxy("descriptionFontSize", "_desc_widget", "fontSize");
228
-
229
- Entity.prototype.publishProxy("backgroundShape", "_background_widget", "shape");
230
- Entity.prototype.publishProxy("backgroundColorFill", "_background_widget", "colorFill");
231
- Entity.prototype.publishProxy("backgroundColorStroke", "_background_widget", "colorStroke");
232
-
233
- Entity.prototype.publishProxy("cornerRadius", "_background_widget");
234
- Entity.prototype.publishProxy("arrowHeight", "_background_widget");
235
- Entity.prototype.publishProxy("arrowWidth", "_background_widget");
1
+ import { local as d3Local } from "d3-selection";
2
+ import { Icon } from "./Icon.ts";
3
+ import { Shape } from "./Shape.ts";
4
+ import { SVGWidget } from "./SVGWidget.ts";
5
+ import { Text } from "./Text.ts";
6
+ import { BBox, Widget } from "./Widget.ts";
7
+
8
+ export interface IAnnotation {
9
+ faChar: string;
10
+ tooltip?: string;
11
+ shape_colorFill?: string;
12
+ shape_colorStroke?: string;
13
+ image_colorFill?: string;
14
+ shape?: string;
15
+ }
16
+
17
+ export class Entity extends SVGWidget {
18
+ protected _icon_widget: Icon;
19
+ protected _background_widget: Shape;
20
+ protected _title_widget: Text;
21
+ protected _desc_widget: Text;
22
+ protected _annotation_widgets: { [idx: number]: { widget: SVGWidget, bbox: BBox } };
23
+ protected _element_anno;
24
+ protected _element_background;
25
+ protected _element_desc;
26
+ protected _element_icon;
27
+ protected _element_title;
28
+
29
+ private _annotationLocal = d3Local<Icon>();
30
+
31
+ constructor() {
32
+ super();
33
+
34
+ this._background_widget = new Shape();
35
+ this._icon_widget = new Icon();
36
+ this._title_widget = new Text();
37
+ this._desc_widget = new Text();
38
+ this._annotation_widgets = {};
39
+ }
40
+ getAnnotationsBBox(): BBox {
41
+ let retVal: BBox;
42
+ for (const key in this._annotation_widgets) {
43
+ const bbox = this._annotation_widgets[key].bbox;
44
+ if (!retVal) {
45
+ retVal = bbox;
46
+ } else {
47
+ retVal.x = Math.min(retVal.x, bbox.x);
48
+ retVal.y = Math.min(retVal.y, bbox.y);
49
+ retVal.width = Math.max(retVal.width, bbox.width);
50
+ retVal.height = Math.max(retVal.height, bbox.height);
51
+ }
52
+ }
53
+ return retVal || { x: 0, y: 0, width: 0, height: 0 };
54
+ }
55
+ enter(domNode, element) {
56
+ super.enter(domNode, element);
57
+ element
58
+ .on("mouseover", () => {
59
+ element.classed("hovering", true);
60
+ this.render();
61
+ })
62
+ .on("mouseout", () => {
63
+ element.classed("hovering", false);
64
+ this.render();
65
+ })
66
+ ;
67
+
68
+ this._element_background = element.append("g").attr("class", "entity_shape");
69
+ this._element_icon = element.append("g").attr("class", "entity_icon");
70
+ this._element_title = element.append("g").attr("class", "entity_title");
71
+ this._element_desc = element.append("g").attr("class", "entity_desc");
72
+ this._element_anno = element.append("g").attr("class", "entity_anno");
73
+
74
+ this._background_widget
75
+ .target(this._element_background.node());
76
+ this._icon_widget
77
+ .shape_colorFill("none")
78
+ .shape_colorStroke("none")
79
+ .target(this._element_icon.node());
80
+ this._title_widget
81
+ .target(this._element_title.node());
82
+ this._desc_widget
83
+ .target(this._element_desc.node());
84
+ }
85
+ update(domNode, element) {
86
+ super.update(domNode, element);
87
+ this._desc_widget
88
+ .fontSize(this.descriptionFontSize());
89
+ const context = this;
90
+ this._annotation_widgets = {};
91
+ let annoXPos = 0;
92
+ const annotations = this._element_anno.selectAll(".annotation").data([...this.annotationIcons()].reverse());
93
+ annotations.enter().append("g")
94
+ .attr("class", "annotation")
95
+ .each(function (this: SVGGElement, d, idx) {
96
+ const anno = new Icon()
97
+ .diameter(context.annotationDiameter())
98
+ .paddingPercent(context.annotationPaddingPercent())
99
+ .target(this)
100
+ .shape("square")
101
+ ;
102
+ context._annotationLocal.set(this, anno);
103
+ })
104
+ .merge(annotations)
105
+ .each(function (this: SVGGElement, d, idx) {
106
+ const anno = context._annotationLocal.get(this);
107
+ if (typeof d.faChar !== "undefined") anno.faChar(d.faChar);
108
+ if (typeof d.shape !== "undefined") anno.shape(d.shape);
109
+ if (typeof d.image_colorFill !== "undefined") anno.image_colorFill(d.image_colorFill);
110
+ if (typeof d.shape_colorFill !== "undefined") anno.shape_colorFill(d.shape_colorFill);
111
+ if (typeof d.shape_colorStroke !== "undefined") anno.shape_colorStroke(d.shape_colorStroke);
112
+ const annoDiam = anno.diameter();
113
+ anno
114
+ .x(annoXPos - annoDiam)
115
+ .y(annoDiam / 2)
116
+ .render()
117
+ ;
118
+ annoXPos -= annoDiam + context.annotationSpacing();
119
+ context._annotation_widgets[idx] = {
120
+ widget: anno,
121
+ bbox: anno.getBBox(true)
122
+ };
123
+ });
124
+ annotations.exit()
125
+ .each(function (this: HTMLElement, d, idx) {
126
+ const anno = context._annotationLocal.get(this);
127
+ anno.target(null);
128
+ })
129
+ .remove();
130
+ }
131
+ exit(domNode, element) {
132
+ this._desc_widget.target(null);
133
+ this._title_widget.target(null);
134
+ this._icon_widget.target(null);
135
+ this._background_widget.target(null);
136
+ super.exit(domNode, element);
137
+ }
138
+ moveAnnotations(x_offset: number, y_offset: number) {
139
+ this._element_anno.attr("transform", `translate(${x_offset}, ${y_offset})`);
140
+ }
141
+ render(callback?: (w: Widget) => void) {
142
+ return super.render(w => {
143
+ this._background_widget.render();
144
+ this._icon_widget.render();
145
+ this._title_widget.render();
146
+ this._desc_widget.render();
147
+ if (callback) {
148
+ callback(w);
149
+ }
150
+ });
151
+ }
152
+ }
153
+ Entity.prototype._class += " common_Entity";
154
+
155
+ export interface Entity {
156
+ arrowHeight(): number;
157
+ arrowHeight(_: number): this;
158
+ arrowWidth(): number;
159
+ arrowWidth(_: number): this;
160
+ cornerRadius(): number;
161
+ cornerRadius(_: number): this;
162
+ padding(): number;
163
+ padding(_: number): this;
164
+ paddingPercent(): number;
165
+ paddingPercent(_: number): this;
166
+
167
+ annotationIcons(): IAnnotation[];
168
+ annotationIcons(_: IAnnotation[]): this;
169
+ annotationDiameter(): number;
170
+ annotationDiameter(_: number): this;
171
+ annotationSpacing(): number;
172
+ annotationSpacing(_: number): this;
173
+ annotationPaddingPercent(): number;
174
+ annotationPaddingPercent(_: number): this;
175
+ icon(): string;
176
+ icon(_: string): this;
177
+ iconColor(): string;
178
+ iconColor(_: string): this;
179
+ iconDiameter(): number;
180
+ iconDiameter(_: number): this;
181
+ iconPaddingPercent(): number;
182
+ iconPaddingPercent(_: number): this;
183
+ description(): string;
184
+ description(_: string): this;
185
+ descriptionColor(): string;
186
+ descriptionColor(_: string): this;
187
+ descriptionFontFamily(): string;
188
+ descriptionFontFamily(_: string): this;
189
+ descriptionFontSize(): number;
190
+ descriptionFontSize(_: number): this;
191
+ title(): string;
192
+ title(_: string): this;
193
+ titleColor(): string;
194
+ titleColor(_: string): this;
195
+ titleFontFamily(): string;
196
+ titleFontFamily(_: string): this;
197
+ titleFontSize(): number;
198
+ titleFontSize(_: number): this;
199
+ backgroundShape(): string;
200
+ backgroundShape(_: string): this;
201
+ backgroundColorFill(): string;
202
+ backgroundColorFill(_: string): this;
203
+ backgroundColorStroke(): string;
204
+ backgroundColorStroke(_: string): this;
205
+ }
206
+
207
+ Entity.prototype.publish("padding", 8, "number", "padding");
208
+
209
+ Entity.prototype.publish("annotationPaddingPercent", 38, "number", "annotationPaddingPercent");
210
+ Entity.prototype.publish("annotationDiameter", 14, "number", "Annotation Diameter");
211
+ Entity.prototype.publish("annotationIcons", [], "array", "annotationIcons"); // TODO: is this really used?
212
+ Entity.prototype.publish("annotationSpacing", 3, "number", "annotationSpacing");
213
+
214
+ Entity.prototype.publishProxy("icon", "_icon_widget", "faChar");
215
+ Entity.prototype.publishProxy("iconColor", "_icon_widget", "image_colorFill");
216
+ Entity.prototype.publishProxy("iconDiameter", "_icon_widget", "diameter");
217
+ Entity.prototype.publishProxy("iconPaddingPercent", "_icon_widget", "paddingPercent");
218
+
219
+ Entity.prototype.publishProxy("title", "_title_widget", "text");
220
+ Entity.prototype.publishProxy("titleColor", "_title_widget", "colorFill");
221
+ Entity.prototype.publishProxy("titleFontFamily", "_title_widget", "fontFamily");
222
+ Entity.prototype.publishProxy("titleFontSize", "_title_widget", "fontSize");
223
+
224
+ Entity.prototype.publishProxy("description", "_desc_widget", "text");
225
+ Entity.prototype.publishProxy("descriptionColor", "_desc_widget", "colorFill");
226
+ Entity.prototype.publishProxy("descriptionFontFamily", "_desc_widget", "fontFamily");
227
+ Entity.prototype.publishProxy("descriptionFontSize", "_desc_widget", "fontSize");
228
+
229
+ Entity.prototype.publishProxy("backgroundShape", "_background_widget", "shape");
230
+ Entity.prototype.publishProxy("backgroundColorFill", "_background_widget", "colorFill");
231
+ Entity.prototype.publishProxy("backgroundColorStroke", "_background_widget", "colorStroke");
232
+
233
+ Entity.prototype.publishProxy("cornerRadius", "_background_widget");
234
+ Entity.prototype.publishProxy("arrowHeight", "_background_widget");
235
+ Entity.prototype.publishProxy("arrowWidth", "_background_widget");
package/src/EntityCard.ts CHANGED
@@ -1,66 +1,66 @@
1
- import { Entity } from "./Entity.ts";
2
-
3
- export class EntityCard extends Entity {
4
- protected _element_textbox;
5
- constructor() {
6
- super();
7
- }
8
- enter(domNode, element) {
9
- super.enter(domNode, element);
10
- }
11
- update() {
12
- super.update.apply(this, arguments);
13
-
14
- this._icon_widget.render();
15
- this._title_widget.render();
16
- this._desc_widget.render();
17
- const icon_bbox = this._icon_widget.getBBox(true);
18
- const title_bbox = this._title_widget.getBBox(true);
19
- const desc_bbox = this._desc_widget.getBBox(true);
20
-
21
- let anno_w = 0;
22
- let anno_h = 0;
23
- const anno_gap = this.annotationSpacing();
24
- for (const i of Object.keys(this._annotation_widgets)) {
25
- anno_w += this._annotation_widgets[i].bbox.width + anno_gap;
26
- anno_h = anno_h > this._annotation_widgets[i].bbox.height ? anno_h : this._annotation_widgets[i].bbox.height;
27
- }
28
-
29
- const _background_h = this.fixedHeight() !== null ? this.fixedHeight() : Math.max(
30
- title_bbox.height + desc_bbox.height + (this.padding() * 3),
31
- anno_h + icon_bbox.height + (this.padding() * 3)
32
- );
33
- const _background_w = this.fixedWidth() !== null ? this.fixedWidth() : Math.max(
34
- title_bbox.width + icon_bbox.width + (this.padding() * 3),
35
- anno_w + desc_bbox.width + (this.padding() * 3)
36
- );
37
- this._background_widget
38
- .height(_background_h)
39
- .width(_background_w);
40
-
41
- this._title_widget.move({
42
- x: -(_background_w / 2) + (title_bbox.width / 2) + this.padding(),
43
- y: -(_background_h / 2) + (title_bbox.height / 2) + this.padding()
44
- });
45
- this._icon_widget.move({
46
- x: (_background_w / 2) - (icon_bbox.width / 2) - this.padding(),
47
- y: -(_background_h / 2) + (icon_bbox.height / 2) + this.padding()
48
- });
49
- this._desc_widget.move({
50
- x: -(_background_w / 2) + (desc_bbox.width / 2) + this.padding(),
51
- y: (_background_h / 2) - (desc_bbox.height / 2) - this.padding()
52
- });
53
- this.moveAnnotations((_background_w / 2), (_background_h / 2) - anno_h - this.padding());
54
- }
55
- }
56
- EntityCard.prototype._class += " common_EntityCard";
57
-
58
- export interface EntityCard {
59
- fixedWidth(): number;
60
- fixedWidth(_: number): this;
61
- fixedHeight(): number;
62
- fixedHeight(_: number): this;
63
- }
64
-
65
- EntityCard.prototype.publish("fixedWidth", null, "number", "fixedWidth");
66
- EntityCard.prototype.publish("fixedHeight", null, "number", "fixedHeight");
1
+ import { Entity } from "./Entity.ts";
2
+
3
+ export class EntityCard extends Entity {
4
+ protected _element_textbox;
5
+ constructor() {
6
+ super();
7
+ }
8
+ enter(domNode, element) {
9
+ super.enter(domNode, element);
10
+ }
11
+ update() {
12
+ super.update.apply(this, arguments);
13
+
14
+ this._icon_widget.render();
15
+ this._title_widget.render();
16
+ this._desc_widget.render();
17
+ const icon_bbox = this._icon_widget.getBBox(true);
18
+ const title_bbox = this._title_widget.getBBox(true);
19
+ const desc_bbox = this._desc_widget.getBBox(true);
20
+
21
+ let anno_w = 0;
22
+ let anno_h = 0;
23
+ const anno_gap = this.annotationSpacing();
24
+ for (const i of Object.keys(this._annotation_widgets)) {
25
+ anno_w += this._annotation_widgets[i].bbox.width + anno_gap;
26
+ anno_h = anno_h > this._annotation_widgets[i].bbox.height ? anno_h : this._annotation_widgets[i].bbox.height;
27
+ }
28
+
29
+ const _background_h = this.fixedHeight() !== null ? this.fixedHeight() : Math.max(
30
+ title_bbox.height + desc_bbox.height + (this.padding() * 3),
31
+ anno_h + icon_bbox.height + (this.padding() * 3)
32
+ );
33
+ const _background_w = this.fixedWidth() !== null ? this.fixedWidth() : Math.max(
34
+ title_bbox.width + icon_bbox.width + (this.padding() * 3),
35
+ anno_w + desc_bbox.width + (this.padding() * 3)
36
+ );
37
+ this._background_widget
38
+ .height(_background_h)
39
+ .width(_background_w);
40
+
41
+ this._title_widget.move({
42
+ x: -(_background_w / 2) + (title_bbox.width / 2) + this.padding(),
43
+ y: -(_background_h / 2) + (title_bbox.height / 2) + this.padding()
44
+ });
45
+ this._icon_widget.move({
46
+ x: (_background_w / 2) - (icon_bbox.width / 2) - this.padding(),
47
+ y: -(_background_h / 2) + (icon_bbox.height / 2) + this.padding()
48
+ });
49
+ this._desc_widget.move({
50
+ x: -(_background_w / 2) + (desc_bbox.width / 2) + this.padding(),
51
+ y: (_background_h / 2) - (desc_bbox.height / 2) - this.padding()
52
+ });
53
+ this.moveAnnotations((_background_w / 2), (_background_h / 2) - anno_h - this.padding());
54
+ }
55
+ }
56
+ EntityCard.prototype._class += " common_EntityCard";
57
+
58
+ export interface EntityCard {
59
+ fixedWidth(): number;
60
+ fixedWidth(_: number): this;
61
+ fixedHeight(): number;
62
+ fixedHeight(_: number): this;
63
+ }
64
+
65
+ EntityCard.prototype.publish("fixedWidth", null, "number", "fixedWidth");
66
+ EntityCard.prototype.publish("fixedHeight", null, "number", "fixedHeight");