@hpcc-js/common 3.6.5 → 3.7.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 (54) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +59 -59
  3. package/dist/index.js +4 -4
  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 +2 -2
  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 +843 -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/EntityRect.ts CHANGED
@@ -1,254 +1,254 @@
1
- import { local as d3Local, select as d3Select } from "d3-selection";
2
- import { Entity } from "./Entity.ts";
3
- import { HTMLWidget } from "./HTMLWidget.ts";
4
- import * as Utility from "./Utility.ts";
5
- import { InputField } from "./Widget.ts";
6
-
7
- import "../src/EntityRect.css";
8
-
9
- export class EntityRect extends Entity {
10
- protected _element_textbox;
11
- constructor() {
12
- super();
13
- }
14
- enter(domNode, element) {
15
- super.enter(domNode, element);
16
- }
17
- update(domNode, element) {
18
- this._desc_widget.text("");
19
- super.update(domNode, element);
20
- }
21
- render(callback?: (w: EntityRect) => void) {
22
- return super.render((w: EntityRect) => {
23
- const icon_bbox = w.icon() === "" ? { width: 0, height: 0 } : this._icon_widget.getBBox(true);
24
- const title_bbox = this._title_widget.getBBox(true);
25
- const annotations_bbox = this.getAnnotationsBBox();
26
-
27
- let width = this.fixedWidth();
28
- if (!width) {
29
- width = icon_bbox.width + title_bbox.width + annotations_bbox.width + this.padding() * 4;
30
- }
31
-
32
- let height = this.fixedHeight();
33
- if (!height) {
34
- height = Math.max(icon_bbox.height, title_bbox.height, annotations_bbox.height) + this.padding() * 2;
35
- }
36
-
37
- this._background_widget
38
- .width(width)
39
- .height(height)
40
- .render()
41
- ;
42
-
43
- this._icon_widget.move({
44
- x: -(width / 2) + (icon_bbox.width),
45
- y: 0
46
- });
47
-
48
- this.moveAnnotations(width / 2, -annotations_bbox.height / 2);
49
- const iconWidth = icon_bbox.width > 0 ? icon_bbox.width + this.padding() : 0;
50
- const titleX = -(width / 2) + iconWidth + this.padding();
51
- const annoWidth = this.padding() / 2 + annotations_bbox.width + this.padding();
52
- const titleW = width - iconWidth - annoWidth;
53
-
54
- this._title_widget
55
- .move({
56
- x: titleX,
57
- y: 0
58
- })
59
- .anchor("start")
60
- .width(titleW)
61
- .render()
62
- ;
63
-
64
- if (callback) {
65
- callback(w);
66
- }
67
- });
68
- }
69
- }
70
- EntityRect.prototype._class += " common_EntityRect";
71
-
72
- export interface EntityRect {
73
- fixedWidth(): number;
74
- fixedWidth(_: number): this;
75
- fixedHeight(): number;
76
- fixedHeight(_: number): this;
77
- }
78
-
79
- EntityRect.prototype.publish("fixedWidth", null, "number", "fixedWidth");
80
- EntityRect.prototype.publish("fixedHeight", null, "number", "fixedHeight");
81
-
82
- export class EntityRectList extends HTMLWidget {
83
- static __inputs: InputField[] = [{
84
- id: "borderColor",
85
- type: "string"
86
- }, {
87
- id: "icon",
88
- type: "string"
89
- }, {
90
- id: "iconColor",
91
- type: "string"
92
- }, {
93
- id: "title",
94
- type: "string"
95
- }];
96
-
97
- private _enityRectLocal = d3Local<EntityRect>();
98
-
99
- constructor() {
100
- super();
101
- Utility.SimpleSelectionMixin.call(this, true);
102
- }
103
-
104
- entityRectData() {
105
- const columns = this.columns();
106
- const idxColumns = [
107
- "backgroundColor",
108
- "borderColor",
109
- "icon",
110
- "iconColor",
111
- "title",
112
- "titleColor",
113
- "description",
114
- "descriptionColor"
115
- ];
116
- const idxs = idxColumns.map(idxColumn => columns.indexOf(this[`${idxColumn}Column`]()));
117
- return this.data().map(row => {
118
- const retVal = {
119
- origRow: row
120
- };
121
- for (let i = 0; i < idxColumns.length; ++i) {
122
- retVal[idxColumns[i]] = idxs[i] >= 0 ? row[idxs[i]] : typeof this[`${idxColumns[i]}`] === "function" ? this[`${idxColumns[i]}`]() : "";
123
- }
124
- return retVal;
125
- }, this);
126
- }
127
-
128
- enter(domNode, element) {
129
- super.enter(domNode, element);
130
- d3Select(domNode.parentNode)
131
- .style("overflow-x", "hidden")
132
- .style("overflow-y", "scroll")
133
- ;
134
- this._selection.widgetElement(element);
135
- }
136
-
137
- update(domNode, element) {
138
- super.update(domNode, element);
139
- const context = this;
140
-
141
- const margin = { left: 8, top: 8, right: 8, bottom: 8 };
142
- const width = this.width() - margin.left - margin.right - 20; // -20 for VScroll (could do better)
143
- const height = this.fixedHeight() - margin.top - margin.bottom;
144
-
145
- const svg = element.selectAll("svg").data(this.entityRectData());
146
- svg.enter().append("svg")
147
- .attr("class", "entityRectItem")
148
- .call(this._selection.enter.bind(this._selection))
149
- .on("click", function (d) {
150
- context.click(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
151
- })
152
- .on("dblclick", function (d) {
153
- context.dblclick(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
154
- })
155
- .each(function () {
156
- const entityRect = new EntityRect()
157
- .target(this)
158
- ;
159
- context._enityRectLocal.set(this, entityRect);
160
- })
161
- .merge(svg)
162
- .style("border-color", d => d.borderColor)
163
- .each(function (d) {
164
- context._enityRectLocal.get(this)
165
- .pos({ x: width / 2, y: height / 2 })
166
- .resize({ width, height })
167
- .fixedWidth(width)
168
- .fixedHeight(height)
169
- .backgroundShape("rect")
170
- .backgroundColorFill(d.backgroundColor)
171
- .backgroundColorStroke("none")
172
- .icon(d.icon)
173
- .iconColor(d.iconColor)
174
- .iconDiameter(height / 2.6666)
175
- .iconPaddingPercent(0)
176
- .title(d.title)
177
- .titleFontSize(height / 2.6666)
178
- .titleColor(d.titleColor)
179
- .description(d.description)
180
- .descriptionColor(d.descriptionColor)
181
- .render()
182
- ;
183
- })
184
- ;
185
- svg.exit().remove();
186
- }
187
-
188
- exit(domNode, element) {
189
- super.exit(domNode, element);
190
- }
191
-
192
- // Events ---
193
- click(row, column, selected) {
194
- // console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
195
- }
196
-
197
- dblclick(row, column, selected) {
198
- // console.log("Double click: " + JSON.stringify(row) + ", " + column + "," + selected);
199
- }
200
-
201
- // SimpleSelectionMixin
202
- _selection;
203
- }
204
- EntityRectList.prototype._class += " common_EntityRectList";
205
-
206
- export interface EntityRectList {
207
- fixedHeight(): number;
208
- fixedHeight(_: number): this;
209
- backgroundColor(): string;
210
- backgroundColor(_: string): this;
211
- backgroundColorColumn(): string;
212
- backgroundColorColumn(_: string): this;
213
- borderColor(): string;
214
- borderColor(_: string): this;
215
- borderColorColumn(): string;
216
- borderColorColumn(_: string): this;
217
- icon(): string;
218
- icon(_: string): this;
219
- iconColumn(): string;
220
- iconColumn(_: string): this;
221
- iconColor(): string;
222
- iconColor(_: string): this;
223
- iconColorColumn(): string;
224
- iconColorColumn(_: string): this;
225
- titleColumn(): string;
226
- titleColumn(_: string): this;
227
- titleColor(): string;
228
- titleColor(_: string): this;
229
- titleColorColumn(): string;
230
- titleColorColumn(_: string): this;
231
- descriptionColumn(): string;
232
- descriptionColumn(_: string): this;
233
- descriptionColor(): string;
234
- descriptionColor(_: string): this;
235
- descriptionColorColumn(): string;
236
- descriptionColorColumn(_: string): this;
237
- }
238
-
239
- EntityRectList.prototype.publish("fixedHeight", 64, "number", "fixedHeight");
240
- EntityRectList.prototype.publish("backgroundColor", "#f8f8f8", "string", "Default Background Color", null, { inputType: "html-color" });
241
- EntityRectList.prototype.publish("backgroundColorColumn", null, "set", "Background Color Column", function () { return this.columns(); }, { optional: true });
242
- EntityRectList.prototype.publish("borderColor", "black", "string", "Default Border Color", null, { inputType: "html-color" });
243
- EntityRectList.prototype.publish("borderColorColumn", null, "set", "Border Color Column", function () { return this.columns(); }, { optional: true });
244
- EntityRectList.prototype.publish("icon", "", "string", "Icon");
245
- EntityRectList.prototype.publish("iconColumn", null, "set", "Icon Column", function () { return this.columns(); }, { optional: true });
246
- EntityRectList.prototype.publish("iconColor", "red", "string", "Default Icon Color", null, { inputType: "html-color" });
247
- EntityRectList.prototype.publish("iconColorColumn", null, "set", "Icon Color Column ", function () { return this.columns(); }, { optional: true });
248
- EntityRectList.prototype.publish("titleColumn", null, "set", "Title Column", function () { return this.columns(); }, { optional: true });
249
- EntityRectList.prototype.publish("titleColor", "black", "string", "Default Title Color", null, { inputType: "html-color" });
250
- EntityRectList.prototype.publish("titleColorColumn", null, "set", "Title Color Column ", function () { return this.columns(); }, { optional: true });
251
- EntityRectList.prototype.publish("descriptionColumn", null, "set", "Description Column", function () { return this.columns(); }, { optional: true });
252
- EntityRectList.prototype.publish("descriptionColor", "black", "string", "Default Description Color", null, { inputType: "html-color" });
253
- EntityRectList.prototype.publish("descriptionColorColumn", null, "set", "Description Color Column ", function () { return this.columns(); }, { optional: true });
254
-
1
+ import { local as d3Local, select as d3Select } from "d3-selection";
2
+ import { Entity } from "./Entity.ts";
3
+ import { HTMLWidget } from "./HTMLWidget.ts";
4
+ import * as Utility from "./Utility.ts";
5
+ import { InputField } from "./Widget.ts";
6
+
7
+ import "../src/EntityRect.css";
8
+
9
+ export class EntityRect extends Entity {
10
+ protected _element_textbox;
11
+ constructor() {
12
+ super();
13
+ }
14
+ enter(domNode, element) {
15
+ super.enter(domNode, element);
16
+ }
17
+ update(domNode, element) {
18
+ this._desc_widget.text("");
19
+ super.update(domNode, element);
20
+ }
21
+ render(callback?: (w: EntityRect) => void) {
22
+ return super.render((w: EntityRect) => {
23
+ const icon_bbox = w.icon() === "" ? { width: 0, height: 0 } : this._icon_widget.getBBox(true);
24
+ const title_bbox = this._title_widget.getBBox(true);
25
+ const annotations_bbox = this.getAnnotationsBBox();
26
+
27
+ let width = this.fixedWidth();
28
+ if (!width) {
29
+ width = icon_bbox.width + title_bbox.width + annotations_bbox.width + this.padding() * 4;
30
+ }
31
+
32
+ let height = this.fixedHeight();
33
+ if (!height) {
34
+ height = Math.max(icon_bbox.height, title_bbox.height, annotations_bbox.height) + this.padding() * 2;
35
+ }
36
+
37
+ this._background_widget
38
+ .width(width)
39
+ .height(height)
40
+ .render()
41
+ ;
42
+
43
+ this._icon_widget.move({
44
+ x: -(width / 2) + (icon_bbox.width),
45
+ y: 0
46
+ });
47
+
48
+ this.moveAnnotations(width / 2, -annotations_bbox.height / 2);
49
+ const iconWidth = icon_bbox.width > 0 ? icon_bbox.width + this.padding() : 0;
50
+ const titleX = -(width / 2) + iconWidth + this.padding();
51
+ const annoWidth = this.padding() / 2 + annotations_bbox.width + this.padding();
52
+ const titleW = width - iconWidth - annoWidth;
53
+
54
+ this._title_widget
55
+ .move({
56
+ x: titleX,
57
+ y: 0
58
+ })
59
+ .anchor("start")
60
+ .width(titleW)
61
+ .render()
62
+ ;
63
+
64
+ if (callback) {
65
+ callback(w);
66
+ }
67
+ });
68
+ }
69
+ }
70
+ EntityRect.prototype._class += " common_EntityRect";
71
+
72
+ export interface EntityRect {
73
+ fixedWidth(): number;
74
+ fixedWidth(_: number): this;
75
+ fixedHeight(): number;
76
+ fixedHeight(_: number): this;
77
+ }
78
+
79
+ EntityRect.prototype.publish("fixedWidth", null, "number", "fixedWidth");
80
+ EntityRect.prototype.publish("fixedHeight", null, "number", "fixedHeight");
81
+
82
+ export class EntityRectList extends HTMLWidget {
83
+ static __inputs: InputField[] = [{
84
+ id: "borderColor",
85
+ type: "string"
86
+ }, {
87
+ id: "icon",
88
+ type: "string"
89
+ }, {
90
+ id: "iconColor",
91
+ type: "string"
92
+ }, {
93
+ id: "title",
94
+ type: "string"
95
+ }];
96
+
97
+ private _enityRectLocal = d3Local<EntityRect>();
98
+
99
+ constructor() {
100
+ super();
101
+ Utility.SimpleSelectionMixin.call(this, true);
102
+ }
103
+
104
+ entityRectData() {
105
+ const columns = this.columns();
106
+ const idxColumns = [
107
+ "backgroundColor",
108
+ "borderColor",
109
+ "icon",
110
+ "iconColor",
111
+ "title",
112
+ "titleColor",
113
+ "description",
114
+ "descriptionColor"
115
+ ];
116
+ const idxs = idxColumns.map(idxColumn => columns.indexOf(this[`${idxColumn}Column`]()));
117
+ return this.data().map(row => {
118
+ const retVal = {
119
+ origRow: row
120
+ };
121
+ for (let i = 0; i < idxColumns.length; ++i) {
122
+ retVal[idxColumns[i]] = idxs[i] >= 0 ? row[idxs[i]] : typeof this[`${idxColumns[i]}`] === "function" ? this[`${idxColumns[i]}`]() : "";
123
+ }
124
+ return retVal;
125
+ }, this);
126
+ }
127
+
128
+ enter(domNode, element) {
129
+ super.enter(domNode, element);
130
+ d3Select(domNode.parentNode)
131
+ .style("overflow-x", "hidden")
132
+ .style("overflow-y", "scroll")
133
+ ;
134
+ this._selection.widgetElement(element);
135
+ }
136
+
137
+ update(domNode, element) {
138
+ super.update(domNode, element);
139
+ const context = this;
140
+
141
+ const margin = { left: 8, top: 8, right: 8, bottom: 8 };
142
+ const width = this.width() - margin.left - margin.right - 20; // -20 for VScroll (could do better)
143
+ const height = this.fixedHeight() - margin.top - margin.bottom;
144
+
145
+ const svg = element.selectAll("svg").data(this.entityRectData());
146
+ svg.enter().append("svg")
147
+ .attr("class", "entityRectItem")
148
+ .call(this._selection.enter.bind(this._selection))
149
+ .on("click", function (d) {
150
+ context.click(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
151
+ })
152
+ .on("dblclick", function (d) {
153
+ context.dblclick(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
154
+ })
155
+ .each(function () {
156
+ const entityRect = new EntityRect()
157
+ .target(this)
158
+ ;
159
+ context._enityRectLocal.set(this, entityRect);
160
+ })
161
+ .merge(svg)
162
+ .style("border-color", d => d.borderColor)
163
+ .each(function (d) {
164
+ context._enityRectLocal.get(this)
165
+ .pos({ x: width / 2, y: height / 2 })
166
+ .resize({ width, height })
167
+ .fixedWidth(width)
168
+ .fixedHeight(height)
169
+ .backgroundShape("rect")
170
+ .backgroundColorFill(d.backgroundColor)
171
+ .backgroundColorStroke("none")
172
+ .icon(d.icon)
173
+ .iconColor(d.iconColor)
174
+ .iconDiameter(height / 2.6666)
175
+ .iconPaddingPercent(0)
176
+ .title(d.title)
177
+ .titleFontSize(height / 2.6666)
178
+ .titleColor(d.titleColor)
179
+ .description(d.description)
180
+ .descriptionColor(d.descriptionColor)
181
+ .render()
182
+ ;
183
+ })
184
+ ;
185
+ svg.exit().remove();
186
+ }
187
+
188
+ exit(domNode, element) {
189
+ super.exit(domNode, element);
190
+ }
191
+
192
+ // Events ---
193
+ click(row, column, selected) {
194
+ // console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
195
+ }
196
+
197
+ dblclick(row, column, selected) {
198
+ // console.log("Double click: " + JSON.stringify(row) + ", " + column + "," + selected);
199
+ }
200
+
201
+ // SimpleSelectionMixin
202
+ _selection;
203
+ }
204
+ EntityRectList.prototype._class += " common_EntityRectList";
205
+
206
+ export interface EntityRectList {
207
+ fixedHeight(): number;
208
+ fixedHeight(_: number): this;
209
+ backgroundColor(): string;
210
+ backgroundColor(_: string): this;
211
+ backgroundColorColumn(): string;
212
+ backgroundColorColumn(_: string): this;
213
+ borderColor(): string;
214
+ borderColor(_: string): this;
215
+ borderColorColumn(): string;
216
+ borderColorColumn(_: string): this;
217
+ icon(): string;
218
+ icon(_: string): this;
219
+ iconColumn(): string;
220
+ iconColumn(_: string): this;
221
+ iconColor(): string;
222
+ iconColor(_: string): this;
223
+ iconColorColumn(): string;
224
+ iconColorColumn(_: string): this;
225
+ titleColumn(): string;
226
+ titleColumn(_: string): this;
227
+ titleColor(): string;
228
+ titleColor(_: string): this;
229
+ titleColorColumn(): string;
230
+ titleColorColumn(_: string): this;
231
+ descriptionColumn(): string;
232
+ descriptionColumn(_: string): this;
233
+ descriptionColor(): string;
234
+ descriptionColor(_: string): this;
235
+ descriptionColorColumn(): string;
236
+ descriptionColorColumn(_: string): this;
237
+ }
238
+
239
+ EntityRectList.prototype.publish("fixedHeight", 64, "number", "fixedHeight");
240
+ EntityRectList.prototype.publish("backgroundColor", "#f8f8f8", "string", "Default Background Color", null, { inputType: "html-color" });
241
+ EntityRectList.prototype.publish("backgroundColorColumn", null, "set", "Background Color Column", function () { return this.columns(); }, { optional: true });
242
+ EntityRectList.prototype.publish("borderColor", "black", "string", "Default Border Color", null, { inputType: "html-color" });
243
+ EntityRectList.prototype.publish("borderColorColumn", null, "set", "Border Color Column", function () { return this.columns(); }, { optional: true });
244
+ EntityRectList.prototype.publish("icon", "", "string", "Icon");
245
+ EntityRectList.prototype.publish("iconColumn", null, "set", "Icon Column", function () { return this.columns(); }, { optional: true });
246
+ EntityRectList.prototype.publish("iconColor", "red", "string", "Default Icon Color", null, { inputType: "html-color" });
247
+ EntityRectList.prototype.publish("iconColorColumn", null, "set", "Icon Color Column ", function () { return this.columns(); }, { optional: true });
248
+ EntityRectList.prototype.publish("titleColumn", null, "set", "Title Column", function () { return this.columns(); }, { optional: true });
249
+ EntityRectList.prototype.publish("titleColor", "black", "string", "Default Title Color", null, { inputType: "html-color" });
250
+ EntityRectList.prototype.publish("titleColorColumn", null, "set", "Title Color Column ", function () { return this.columns(); }, { optional: true });
251
+ EntityRectList.prototype.publish("descriptionColumn", null, "set", "Description Column", function () { return this.columns(); }, { optional: true });
252
+ EntityRectList.prototype.publish("descriptionColor", "black", "string", "Default Description Color", null, { inputType: "html-color" });
253
+ EntityRectList.prototype.publish("descriptionColorColumn", null, "set", "Description Color Column ", function () { return this.columns(); }, { optional: true });
254
+