@hpcc-js/common 3.6.2 → 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.
- package/LICENSE +43 -43
- package/README.md +59 -59
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/CanvasWidget.ts +31 -31
- package/src/Class.ts +72 -72
- package/src/Database.ts +860 -860
- package/src/Entity.ts +235 -235
- package/src/EntityCard.ts +66 -66
- package/src/EntityPin.ts +103 -103
- package/src/EntityRect.css +15 -15
- package/src/EntityRect.ts +254 -254
- package/src/EntityVertex.ts +86 -86
- package/src/FAChar.css +2 -2
- package/src/FAChar.ts +89 -89
- package/src/HTMLWidget.ts +191 -191
- package/src/IList.ts +4 -4
- package/src/IMenu.ts +5 -5
- package/src/Icon.css +9 -9
- package/src/Icon.ts +176 -176
- package/src/Image.ts +104 -104
- package/src/List.css +13 -13
- package/src/List.ts +102 -102
- package/src/Menu.css +23 -23
- package/src/Menu.ts +139 -139
- package/src/Palette.ts +341 -341
- package/src/Platform.ts +125 -125
- package/src/ProgressBar.ts +115 -115
- package/src/PropertyExt.ts +770 -770
- package/src/ResizeSurface.css +39 -39
- package/src/ResizeSurface.ts +225 -225
- package/src/SVGWidget.ts +583 -583
- package/src/SVGZoomWidget.css +12 -12
- package/src/SVGZoomWidget.ts +427 -427
- package/src/Shape.css +3 -3
- package/src/Shape.ts +186 -186
- package/src/Surface.css +35 -35
- package/src/Surface.ts +364 -364
- package/src/Text.css +4 -4
- package/src/Text.ts +131 -131
- package/src/TextBox.css +4 -4
- package/src/TextBox.ts +183 -183
- package/src/TitleBar.css +114 -114
- package/src/TitleBar.ts +407 -407
- package/src/Transition.ts +45 -45
- package/src/Utility.ts +839 -839
- package/src/Widget.css +8 -8
- package/src/Widget.ts +731 -731
- package/src/WidgetArray.ts +15 -15
- package/src/__package__.ts +3 -3
- package/src/index.ts +55 -55
package/src/TitleBar.ts
CHANGED
|
@@ -1,407 +1,407 @@
|
|
|
1
|
-
import { event as d3Event } from "d3-selection";
|
|
2
|
-
import { HTMLWidget } from "./HTMLWidget.ts";
|
|
3
|
-
import { fa5Class } from "./Utility.ts";
|
|
4
|
-
import { Widget } from "./Widget.ts";
|
|
5
|
-
|
|
6
|
-
import "../src/TitleBar.css";
|
|
7
|
-
|
|
8
|
-
// Lite button for titlebar ---
|
|
9
|
-
export class Button extends HTMLWidget {
|
|
10
|
-
private _enabled = true;
|
|
11
|
-
private _i;
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this._tag = "a";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
enter(domNode: HTMLElement, element) {
|
|
19
|
-
super.enter(domNode, element);
|
|
20
|
-
const context = this;
|
|
21
|
-
this._i = this._element
|
|
22
|
-
.attr("href", "#")
|
|
23
|
-
.on("click", function () {
|
|
24
|
-
context.click();
|
|
25
|
-
d3Event.preventDefault();
|
|
26
|
-
})
|
|
27
|
-
.on("keydown", function (this: HTMLElement) {
|
|
28
|
-
if (d3Event.key === " " || d3Event.key === "Spacebar" || d3Event.code === "Space" || d3Event.key === "Enter") {
|
|
29
|
-
this.click();
|
|
30
|
-
d3Event.preventDefault();
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.on("mousemove", this.mouseMove)
|
|
34
|
-
.on("mouseout", this.mouseOut)
|
|
35
|
-
.append("i")
|
|
36
|
-
;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
update(domNode: HTMLElement, element) {
|
|
40
|
-
super.update(domNode, element);
|
|
41
|
-
element
|
|
42
|
-
.classed("disabled", !this.enabled())
|
|
43
|
-
.attr("title", this.tooltip())
|
|
44
|
-
;
|
|
45
|
-
this._i.attr("class", `fa ${fa5Class(this.faChar())} fa-lg fa-fw`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Events ---
|
|
49
|
-
click() {
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
mouseMove(d, idx, groups) {
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
mouseOut(d, idx, groups) {
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
enabled(): boolean;
|
|
59
|
-
enabled(_: boolean): this;
|
|
60
|
-
enabled(_?: boolean): boolean | this {
|
|
61
|
-
if (!arguments.length) return this._enabled;
|
|
62
|
-
this._enabled = _;
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
Button.prototype._class += " common_Button";
|
|
67
|
-
export interface Button {
|
|
68
|
-
faChar(): string;
|
|
69
|
-
faChar(_: string): this;
|
|
70
|
-
tooltip(): string;
|
|
71
|
-
tooltip(_: string): this;
|
|
72
|
-
}
|
|
73
|
-
Button.prototype.publish("faChar", "", "string", "FontAwesome class");
|
|
74
|
-
Button.prototype.publish("tooltip", "", "string", "Displays as the button alt text attribute");
|
|
75
|
-
|
|
76
|
-
// Sticky button ---
|
|
77
|
-
export class StickyButton extends Button {
|
|
78
|
-
|
|
79
|
-
enter(domNode: HTMLElement, element) {
|
|
80
|
-
super.enter(domNode, element);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
update(domNode: HTMLElement, element) {
|
|
84
|
-
super.update(domNode, element);
|
|
85
|
-
element.classed("selected", this.selected());
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
StickyButton.prototype._class += " common_StickyButton";
|
|
89
|
-
export interface StickyButton {
|
|
90
|
-
selected(): boolean;
|
|
91
|
-
selected(_: boolean): this;
|
|
92
|
-
}
|
|
93
|
-
StickyButton.prototype.publish("selected", false, "boolean");
|
|
94
|
-
|
|
95
|
-
// Toggle button ---
|
|
96
|
-
export class ToggleButton extends StickyButton {
|
|
97
|
-
|
|
98
|
-
enter(domNode: HTMLElement, element) {
|
|
99
|
-
element.on("click.sel", (d, idx, groups) => {
|
|
100
|
-
this
|
|
101
|
-
.selected(!this.selected())
|
|
102
|
-
.render()
|
|
103
|
-
;
|
|
104
|
-
d3Event.preventDefault();
|
|
105
|
-
});
|
|
106
|
-
super.enter(domNode, element);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
ToggleButton.prototype._class += " common_ToggleButton";
|
|
110
|
-
|
|
111
|
-
// Spacer ---
|
|
112
|
-
export class Spacer extends HTMLWidget {
|
|
113
|
-
|
|
114
|
-
enter(domNode: HTMLElement, element) {
|
|
115
|
-
super.enter(domNode, element);
|
|
116
|
-
element
|
|
117
|
-
.attr("class", this.vline() ? "spacer vline" : "spacer")
|
|
118
|
-
.attr("href", "#")
|
|
119
|
-
.append("i")
|
|
120
|
-
;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
Spacer.prototype._class += " common_Spacer";
|
|
124
|
-
|
|
125
|
-
export interface Spacer {
|
|
126
|
-
vline(): boolean;
|
|
127
|
-
vline(_: boolean): this;
|
|
128
|
-
}
|
|
129
|
-
Spacer.prototype.publish("vline", true, "boolean");
|
|
130
|
-
|
|
131
|
-
export class SelectDropDown extends HTMLWidget {
|
|
132
|
-
private _enabled = true;
|
|
133
|
-
|
|
134
|
-
constructor() {
|
|
135
|
-
super();
|
|
136
|
-
this._tag = "select";
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
enabled(): boolean;
|
|
140
|
-
enabled(_: boolean): this;
|
|
141
|
-
enabled(_?: boolean): boolean | this {
|
|
142
|
-
if (!arguments.length) return this._enabled;
|
|
143
|
-
this._enabled = _;
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
enter(domNode: HTMLSelectElement, element) {
|
|
148
|
-
super.enter(domNode, element);
|
|
149
|
-
const context = this;
|
|
150
|
-
element.on("change", function (d) {
|
|
151
|
-
const values = context.values();
|
|
152
|
-
for (const key in context.values()) {
|
|
153
|
-
if (this.value === values[key]) {
|
|
154
|
-
context.selected(key);
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
context.click(this.value);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
update(domNode: HTMLElement, element) {
|
|
163
|
-
super.update(domNode, element);
|
|
164
|
-
element
|
|
165
|
-
.classed("disabled", !this.enabled())
|
|
166
|
-
.attr("title", this.tooltip())
|
|
167
|
-
;
|
|
168
|
-
|
|
169
|
-
const values = this.values();
|
|
170
|
-
|
|
171
|
-
const options = element.selectAll(".icon-bar-select-option").data(Object.keys(values));
|
|
172
|
-
const optionUpdate = options.enter().append("option")
|
|
173
|
-
.attr("class", "icon-bar-select-option")
|
|
174
|
-
.merge(options)
|
|
175
|
-
.attr("value", r => values[r])
|
|
176
|
-
.attr("selected", r => r === this.selected() ? "selected" : null)
|
|
177
|
-
.text(r => r)
|
|
178
|
-
;
|
|
179
|
-
options.exit().remove();
|
|
180
|
-
optionUpdate.order();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Events ---
|
|
184
|
-
click(value) {
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
mouseMove(d, idx, groups) {
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
mouseOut(d, idx, groups) {
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
SelectDropDown.prototype._class += " common_SelectDropDown";
|
|
194
|
-
export interface SelectDropDown {
|
|
195
|
-
values(): { [key: string]: string };
|
|
196
|
-
values(_: { [key: string]: string }): this;
|
|
197
|
-
selected(): string;
|
|
198
|
-
selected(_: string): this;
|
|
199
|
-
tooltip(): string;
|
|
200
|
-
tooltip(_: string): this;
|
|
201
|
-
}
|
|
202
|
-
SelectDropDown.prototype.publish("values", {}, "object", "Label, Values");
|
|
203
|
-
SelectDropDown.prototype.publish("selected", "", "string", "Selected Item");
|
|
204
|
-
SelectDropDown.prototype.publish("tooltip", "", "string", "Displays as the button alt text attribute");
|
|
205
|
-
|
|
206
|
-
// IconBar ---
|
|
207
|
-
export class IconBar extends HTMLWidget {
|
|
208
|
-
_divIconBar;
|
|
209
|
-
_buttons: Widget[] = [];
|
|
210
|
-
|
|
211
|
-
constructor() {
|
|
212
|
-
super();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
enter(domNode, element) {
|
|
216
|
-
super.enter(domNode, element);
|
|
217
|
-
this._divIconBar = element.append("div")
|
|
218
|
-
.attr("class", "icon-bar")
|
|
219
|
-
;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
update(domNode, element) {
|
|
223
|
-
super.update(domNode, element);
|
|
224
|
-
|
|
225
|
-
let buttons = this.buttons().filter(button => this.hiddenButtons().indexOf(button) < 0);
|
|
226
|
-
buttons = buttons.reduce((prev, item, idx) => {
|
|
227
|
-
if (item instanceof Spacer) {
|
|
228
|
-
if ((prev.length === 0 || idx === buttons.length - 1)) {
|
|
229
|
-
return prev;
|
|
230
|
-
} else if (buttons[idx + 1] instanceof Spacer) {
|
|
231
|
-
return prev;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
prev.push(item);
|
|
235
|
-
return prev;
|
|
236
|
-
}, []);
|
|
237
|
-
const icons = this._divIconBar.selectAll(".icon-bar-item").data(buttons, (d: Widget) => d.id());
|
|
238
|
-
icons.enter().append("div")
|
|
239
|
-
.attr("class", "icon-bar-item")
|
|
240
|
-
.each(function (this: HTMLElement, d: Widget) {
|
|
241
|
-
d.target(this);
|
|
242
|
-
})
|
|
243
|
-
.merge(icons)
|
|
244
|
-
.each(function (d: Widget) {
|
|
245
|
-
d.render();
|
|
246
|
-
})
|
|
247
|
-
;
|
|
248
|
-
icons.exit()
|
|
249
|
-
.each(function (d: Widget) {
|
|
250
|
-
d.target(null);
|
|
251
|
-
})
|
|
252
|
-
.remove()
|
|
253
|
-
;
|
|
254
|
-
icons.order();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
exit(domNode, element) {
|
|
258
|
-
this.buttons().forEach(b => b.target(null));
|
|
259
|
-
super.exit(domNode, element);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
IconBar.prototype._class += " common_IconBar";
|
|
263
|
-
|
|
264
|
-
export interface IconBar {
|
|
265
|
-
buttons(): Widget[];
|
|
266
|
-
buttons(_: Widget[]): this;
|
|
267
|
-
hiddenButtons(): Widget[];
|
|
268
|
-
hiddenButtons(_: Widget[]): this;
|
|
269
|
-
}
|
|
270
|
-
IconBar.prototype.publish("buttons", [], "widgetArray", null, { internal: true });
|
|
271
|
-
IconBar.prototype.publish("hiddenButtons", [], "widgetArray", null, { internal: true });
|
|
272
|
-
|
|
273
|
-
// SelectionBar ---
|
|
274
|
-
export class SelectionButton extends StickyButton {
|
|
275
|
-
_owner: SelectionBar;
|
|
276
|
-
|
|
277
|
-
enter(domNode: HTMLElement, element) {
|
|
278
|
-
element.on("click.sel", (d, idx, groups) => {
|
|
279
|
-
this.selected(true).render();
|
|
280
|
-
d3Event.preventDefault();
|
|
281
|
-
});
|
|
282
|
-
super.enter(domNode, element);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
selected(): boolean;
|
|
286
|
-
selected(_: boolean): this;
|
|
287
|
-
selected(_?: boolean): boolean | this {
|
|
288
|
-
const retVal = super.selected.apply(this, arguments);
|
|
289
|
-
if (_ && this._owner) {
|
|
290
|
-
this._owner.buttons().filter(sb => sb !== this && sb instanceof SelectionButton).forEach((sb: SelectionButton) => sb.selected(false).render());
|
|
291
|
-
this._owner.selected(this);
|
|
292
|
-
}
|
|
293
|
-
return retVal;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
SelectionButton.prototype._class += " common_SelectionButton";
|
|
297
|
-
|
|
298
|
-
export class SelectionBar extends IconBar {
|
|
299
|
-
|
|
300
|
-
buttons(): Array<SelectionButton | Spacer>;
|
|
301
|
-
buttons(_: Array<SelectionButton | Spacer>): this;
|
|
302
|
-
buttons(_?: Array<SelectionButton | Spacer>): Array<SelectionButton | Spacer> | this {
|
|
303
|
-
const retVal = super.buttons.apply(this, arguments);
|
|
304
|
-
if (arguments.length) {
|
|
305
|
-
_.filter(b => b instanceof SelectionButton).forEach((sb: SelectionButton) => {
|
|
306
|
-
sb._owner = this;
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
return retVal;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Events ---
|
|
313
|
-
selected(row: SelectionButton) {
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
SelectionBar.prototype._class += " common_SelectionBar";
|
|
317
|
-
|
|
318
|
-
// Titlebar ---
|
|
319
|
-
export class TitleBar extends IconBar {
|
|
320
|
-
|
|
321
|
-
_divTitle;
|
|
322
|
-
_divTitleIcon;
|
|
323
|
-
_divTitleText;
|
|
324
|
-
_divDescriptionText;
|
|
325
|
-
|
|
326
|
-
constructor() {
|
|
327
|
-
super();
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
enter(domNode, element) {
|
|
331
|
-
this._divTitle = element.append("div")
|
|
332
|
-
.attr("class", "title-title")
|
|
333
|
-
.style("min-width", "0px")
|
|
334
|
-
;
|
|
335
|
-
this._divTitleIcon = this._divTitle.append("div")
|
|
336
|
-
.attr("class", "title-icon")
|
|
337
|
-
.style("font-family", this.titleIconFont())
|
|
338
|
-
.style("font-size", `${this.titleIconFontSize()}px`)
|
|
339
|
-
.style("width", `${this.titleIconFontSize()}px`)
|
|
340
|
-
;
|
|
341
|
-
this._divTitle.append("div")
|
|
342
|
-
.attr("class", "data-count")
|
|
343
|
-
;
|
|
344
|
-
this._divTitleText = this._divTitle.append("div")
|
|
345
|
-
.attr("class", "title-text")
|
|
346
|
-
.style("font-family", this.titleFont())
|
|
347
|
-
.style("font-size", `${this.titleFontSize()}px`)
|
|
348
|
-
;
|
|
349
|
-
this._divDescriptionText = this._divTitle.append("div")
|
|
350
|
-
.attr("class", "description-text")
|
|
351
|
-
.style("font-family", this.descriptionFont())
|
|
352
|
-
;
|
|
353
|
-
|
|
354
|
-
super.enter(domNode, element);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
update(domNode, element) {
|
|
358
|
-
this._divTitleIcon
|
|
359
|
-
.text(this.titleIcon())
|
|
360
|
-
.style("display", this.titleIcon() !== "" ? "inline-block" : "none")
|
|
361
|
-
;
|
|
362
|
-
this._divTitleText
|
|
363
|
-
.text(this.title())
|
|
364
|
-
.attr("title", this.title())
|
|
365
|
-
;
|
|
366
|
-
this._divDescriptionText
|
|
367
|
-
.style("display", this.description_exists() ? "block" : "none")
|
|
368
|
-
.style("font-size", this.description_exists() ? `${this.descriptionFontSize()}px` : null)
|
|
369
|
-
.style("line-height", this.description_exists() ? `${this.descriptionFontSize()}px` : null)
|
|
370
|
-
.text(this.description())
|
|
371
|
-
;
|
|
372
|
-
|
|
373
|
-
super.update(domNode, element);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
TitleBar.prototype._class += " common_TitleBar";
|
|
377
|
-
|
|
378
|
-
export interface TitleBar {
|
|
379
|
-
title(): string;
|
|
380
|
-
title(_: string): this;
|
|
381
|
-
titleIcon(): string;
|
|
382
|
-
titleIcon(_: string): this;
|
|
383
|
-
titleIconFont(): string;
|
|
384
|
-
titleIconFont(_: string): this;
|
|
385
|
-
titleFont(): string;
|
|
386
|
-
titleFont(_: string): this;
|
|
387
|
-
titleIconFontSize(): number;
|
|
388
|
-
titleIconFontSize(_: number): this;
|
|
389
|
-
titleFontSize(): number;
|
|
390
|
-
titleFontSize(_: number): this;
|
|
391
|
-
description(): string;
|
|
392
|
-
description(_: string): this;
|
|
393
|
-
description_exists(): boolean;
|
|
394
|
-
descriptionFont(): string;
|
|
395
|
-
descriptionFont(_: string): this;
|
|
396
|
-
descriptionFontSize(): number;
|
|
397
|
-
descriptionFontSize(_: number): this;
|
|
398
|
-
}
|
|
399
|
-
TitleBar.prototype.publish("titleIcon", "", "string", "Icon text");
|
|
400
|
-
TitleBar.prototype.publish("titleIconFont", "", "string", "Icon font-family");
|
|
401
|
-
TitleBar.prototype.publish("titleIconFontSize", 28, "number", "Icon font-size (pixels)");
|
|
402
|
-
TitleBar.prototype.publish("title", "", "string", "Title text");
|
|
403
|
-
TitleBar.prototype.publish("titleFont", "", "string", "Title font-family");
|
|
404
|
-
TitleBar.prototype.publish("titleFontSize", 20, "number", "Title font-size (pixels)");
|
|
405
|
-
TitleBar.prototype.publish("description", null, "string", "Description text", null, { optional: true });
|
|
406
|
-
TitleBar.prototype.publish("descriptionFont", "", "string", "Description font-family");
|
|
407
|
-
TitleBar.prototype.publish("descriptionFontSize", 10, "number", "Description font-size (pixels)");
|
|
1
|
+
import { event as d3Event } from "d3-selection";
|
|
2
|
+
import { HTMLWidget } from "./HTMLWidget.ts";
|
|
3
|
+
import { fa5Class } from "./Utility.ts";
|
|
4
|
+
import { Widget } from "./Widget.ts";
|
|
5
|
+
|
|
6
|
+
import "../src/TitleBar.css";
|
|
7
|
+
|
|
8
|
+
// Lite button for titlebar ---
|
|
9
|
+
export class Button extends HTMLWidget {
|
|
10
|
+
private _enabled = true;
|
|
11
|
+
private _i;
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this._tag = "a";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
enter(domNode: HTMLElement, element) {
|
|
19
|
+
super.enter(domNode, element);
|
|
20
|
+
const context = this;
|
|
21
|
+
this._i = this._element
|
|
22
|
+
.attr("href", "#")
|
|
23
|
+
.on("click", function () {
|
|
24
|
+
context.click();
|
|
25
|
+
d3Event.preventDefault();
|
|
26
|
+
})
|
|
27
|
+
.on("keydown", function (this: HTMLElement) {
|
|
28
|
+
if (d3Event.key === " " || d3Event.key === "Spacebar" || d3Event.code === "Space" || d3Event.key === "Enter") {
|
|
29
|
+
this.click();
|
|
30
|
+
d3Event.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.on("mousemove", this.mouseMove)
|
|
34
|
+
.on("mouseout", this.mouseOut)
|
|
35
|
+
.append("i")
|
|
36
|
+
;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
update(domNode: HTMLElement, element) {
|
|
40
|
+
super.update(domNode, element);
|
|
41
|
+
element
|
|
42
|
+
.classed("disabled", !this.enabled())
|
|
43
|
+
.attr("title", this.tooltip())
|
|
44
|
+
;
|
|
45
|
+
this._i.attr("class", `fa ${fa5Class(this.faChar())} fa-lg fa-fw`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Events ---
|
|
49
|
+
click() {
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
mouseMove(d, idx, groups) {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
mouseOut(d, idx, groups) {
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
enabled(): boolean;
|
|
59
|
+
enabled(_: boolean): this;
|
|
60
|
+
enabled(_?: boolean): boolean | this {
|
|
61
|
+
if (!arguments.length) return this._enabled;
|
|
62
|
+
this._enabled = _;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
Button.prototype._class += " common_Button";
|
|
67
|
+
export interface Button {
|
|
68
|
+
faChar(): string;
|
|
69
|
+
faChar(_: string): this;
|
|
70
|
+
tooltip(): string;
|
|
71
|
+
tooltip(_: string): this;
|
|
72
|
+
}
|
|
73
|
+
Button.prototype.publish("faChar", "", "string", "FontAwesome class");
|
|
74
|
+
Button.prototype.publish("tooltip", "", "string", "Displays as the button alt text attribute");
|
|
75
|
+
|
|
76
|
+
// Sticky button ---
|
|
77
|
+
export class StickyButton extends Button {
|
|
78
|
+
|
|
79
|
+
enter(domNode: HTMLElement, element) {
|
|
80
|
+
super.enter(domNode, element);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
update(domNode: HTMLElement, element) {
|
|
84
|
+
super.update(domNode, element);
|
|
85
|
+
element.classed("selected", this.selected());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
StickyButton.prototype._class += " common_StickyButton";
|
|
89
|
+
export interface StickyButton {
|
|
90
|
+
selected(): boolean;
|
|
91
|
+
selected(_: boolean): this;
|
|
92
|
+
}
|
|
93
|
+
StickyButton.prototype.publish("selected", false, "boolean");
|
|
94
|
+
|
|
95
|
+
// Toggle button ---
|
|
96
|
+
export class ToggleButton extends StickyButton {
|
|
97
|
+
|
|
98
|
+
enter(domNode: HTMLElement, element) {
|
|
99
|
+
element.on("click.sel", (d, idx, groups) => {
|
|
100
|
+
this
|
|
101
|
+
.selected(!this.selected())
|
|
102
|
+
.render()
|
|
103
|
+
;
|
|
104
|
+
d3Event.preventDefault();
|
|
105
|
+
});
|
|
106
|
+
super.enter(domNode, element);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
ToggleButton.prototype._class += " common_ToggleButton";
|
|
110
|
+
|
|
111
|
+
// Spacer ---
|
|
112
|
+
export class Spacer extends HTMLWidget {
|
|
113
|
+
|
|
114
|
+
enter(domNode: HTMLElement, element) {
|
|
115
|
+
super.enter(domNode, element);
|
|
116
|
+
element
|
|
117
|
+
.attr("class", this.vline() ? "spacer vline" : "spacer")
|
|
118
|
+
.attr("href", "#")
|
|
119
|
+
.append("i")
|
|
120
|
+
;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
Spacer.prototype._class += " common_Spacer";
|
|
124
|
+
|
|
125
|
+
export interface Spacer {
|
|
126
|
+
vline(): boolean;
|
|
127
|
+
vline(_: boolean): this;
|
|
128
|
+
}
|
|
129
|
+
Spacer.prototype.publish("vline", true, "boolean");
|
|
130
|
+
|
|
131
|
+
export class SelectDropDown extends HTMLWidget {
|
|
132
|
+
private _enabled = true;
|
|
133
|
+
|
|
134
|
+
constructor() {
|
|
135
|
+
super();
|
|
136
|
+
this._tag = "select";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
enabled(): boolean;
|
|
140
|
+
enabled(_: boolean): this;
|
|
141
|
+
enabled(_?: boolean): boolean | this {
|
|
142
|
+
if (!arguments.length) return this._enabled;
|
|
143
|
+
this._enabled = _;
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
enter(domNode: HTMLSelectElement, element) {
|
|
148
|
+
super.enter(domNode, element);
|
|
149
|
+
const context = this;
|
|
150
|
+
element.on("change", function (d) {
|
|
151
|
+
const values = context.values();
|
|
152
|
+
for (const key in context.values()) {
|
|
153
|
+
if (this.value === values[key]) {
|
|
154
|
+
context.selected(key);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
context.click(this.value);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
update(domNode: HTMLElement, element) {
|
|
163
|
+
super.update(domNode, element);
|
|
164
|
+
element
|
|
165
|
+
.classed("disabled", !this.enabled())
|
|
166
|
+
.attr("title", this.tooltip())
|
|
167
|
+
;
|
|
168
|
+
|
|
169
|
+
const values = this.values();
|
|
170
|
+
|
|
171
|
+
const options = element.selectAll(".icon-bar-select-option").data(Object.keys(values));
|
|
172
|
+
const optionUpdate = options.enter().append("option")
|
|
173
|
+
.attr("class", "icon-bar-select-option")
|
|
174
|
+
.merge(options)
|
|
175
|
+
.attr("value", r => values[r])
|
|
176
|
+
.attr("selected", r => r === this.selected() ? "selected" : null)
|
|
177
|
+
.text(r => r)
|
|
178
|
+
;
|
|
179
|
+
options.exit().remove();
|
|
180
|
+
optionUpdate.order();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Events ---
|
|
184
|
+
click(value) {
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
mouseMove(d, idx, groups) {
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
mouseOut(d, idx, groups) {
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
SelectDropDown.prototype._class += " common_SelectDropDown";
|
|
194
|
+
export interface SelectDropDown {
|
|
195
|
+
values(): { [key: string]: string };
|
|
196
|
+
values(_: { [key: string]: string }): this;
|
|
197
|
+
selected(): string;
|
|
198
|
+
selected(_: string): this;
|
|
199
|
+
tooltip(): string;
|
|
200
|
+
tooltip(_: string): this;
|
|
201
|
+
}
|
|
202
|
+
SelectDropDown.prototype.publish("values", {}, "object", "Label, Values");
|
|
203
|
+
SelectDropDown.prototype.publish("selected", "", "string", "Selected Item");
|
|
204
|
+
SelectDropDown.prototype.publish("tooltip", "", "string", "Displays as the button alt text attribute");
|
|
205
|
+
|
|
206
|
+
// IconBar ---
|
|
207
|
+
export class IconBar extends HTMLWidget {
|
|
208
|
+
_divIconBar;
|
|
209
|
+
_buttons: Widget[] = [];
|
|
210
|
+
|
|
211
|
+
constructor() {
|
|
212
|
+
super();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
enter(domNode, element) {
|
|
216
|
+
super.enter(domNode, element);
|
|
217
|
+
this._divIconBar = element.append("div")
|
|
218
|
+
.attr("class", "icon-bar")
|
|
219
|
+
;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
update(domNode, element) {
|
|
223
|
+
super.update(domNode, element);
|
|
224
|
+
|
|
225
|
+
let buttons = this.buttons().filter(button => this.hiddenButtons().indexOf(button) < 0);
|
|
226
|
+
buttons = buttons.reduce((prev, item, idx) => {
|
|
227
|
+
if (item instanceof Spacer) {
|
|
228
|
+
if ((prev.length === 0 || idx === buttons.length - 1)) {
|
|
229
|
+
return prev;
|
|
230
|
+
} else if (buttons[idx + 1] instanceof Spacer) {
|
|
231
|
+
return prev;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
prev.push(item);
|
|
235
|
+
return prev;
|
|
236
|
+
}, []);
|
|
237
|
+
const icons = this._divIconBar.selectAll(".icon-bar-item").data(buttons, (d: Widget) => d.id());
|
|
238
|
+
icons.enter().append("div")
|
|
239
|
+
.attr("class", "icon-bar-item")
|
|
240
|
+
.each(function (this: HTMLElement, d: Widget) {
|
|
241
|
+
d.target(this);
|
|
242
|
+
})
|
|
243
|
+
.merge(icons)
|
|
244
|
+
.each(function (d: Widget) {
|
|
245
|
+
d.render();
|
|
246
|
+
})
|
|
247
|
+
;
|
|
248
|
+
icons.exit()
|
|
249
|
+
.each(function (d: Widget) {
|
|
250
|
+
d.target(null);
|
|
251
|
+
})
|
|
252
|
+
.remove()
|
|
253
|
+
;
|
|
254
|
+
icons.order();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
exit(domNode, element) {
|
|
258
|
+
this.buttons().forEach(b => b.target(null));
|
|
259
|
+
super.exit(domNode, element);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
IconBar.prototype._class += " common_IconBar";
|
|
263
|
+
|
|
264
|
+
export interface IconBar {
|
|
265
|
+
buttons(): Widget[];
|
|
266
|
+
buttons(_: Widget[]): this;
|
|
267
|
+
hiddenButtons(): Widget[];
|
|
268
|
+
hiddenButtons(_: Widget[]): this;
|
|
269
|
+
}
|
|
270
|
+
IconBar.prototype.publish("buttons", [], "widgetArray", null, { internal: true });
|
|
271
|
+
IconBar.prototype.publish("hiddenButtons", [], "widgetArray", null, { internal: true });
|
|
272
|
+
|
|
273
|
+
// SelectionBar ---
|
|
274
|
+
export class SelectionButton extends StickyButton {
|
|
275
|
+
_owner: SelectionBar;
|
|
276
|
+
|
|
277
|
+
enter(domNode: HTMLElement, element) {
|
|
278
|
+
element.on("click.sel", (d, idx, groups) => {
|
|
279
|
+
this.selected(true).render();
|
|
280
|
+
d3Event.preventDefault();
|
|
281
|
+
});
|
|
282
|
+
super.enter(domNode, element);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
selected(): boolean;
|
|
286
|
+
selected(_: boolean): this;
|
|
287
|
+
selected(_?: boolean): boolean | this {
|
|
288
|
+
const retVal = super.selected.apply(this, arguments);
|
|
289
|
+
if (_ && this._owner) {
|
|
290
|
+
this._owner.buttons().filter(sb => sb !== this && sb instanceof SelectionButton).forEach((sb: SelectionButton) => sb.selected(false).render());
|
|
291
|
+
this._owner.selected(this);
|
|
292
|
+
}
|
|
293
|
+
return retVal;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
SelectionButton.prototype._class += " common_SelectionButton";
|
|
297
|
+
|
|
298
|
+
export class SelectionBar extends IconBar {
|
|
299
|
+
|
|
300
|
+
buttons(): Array<SelectionButton | Spacer>;
|
|
301
|
+
buttons(_: Array<SelectionButton | Spacer>): this;
|
|
302
|
+
buttons(_?: Array<SelectionButton | Spacer>): Array<SelectionButton | Spacer> | this {
|
|
303
|
+
const retVal = super.buttons.apply(this, arguments);
|
|
304
|
+
if (arguments.length) {
|
|
305
|
+
_.filter(b => b instanceof SelectionButton).forEach((sb: SelectionButton) => {
|
|
306
|
+
sb._owner = this;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return retVal;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Events ---
|
|
313
|
+
selected(row: SelectionButton) {
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
SelectionBar.prototype._class += " common_SelectionBar";
|
|
317
|
+
|
|
318
|
+
// Titlebar ---
|
|
319
|
+
export class TitleBar extends IconBar {
|
|
320
|
+
|
|
321
|
+
_divTitle;
|
|
322
|
+
_divTitleIcon;
|
|
323
|
+
_divTitleText;
|
|
324
|
+
_divDescriptionText;
|
|
325
|
+
|
|
326
|
+
constructor() {
|
|
327
|
+
super();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
enter(domNode, element) {
|
|
331
|
+
this._divTitle = element.append("div")
|
|
332
|
+
.attr("class", "title-title")
|
|
333
|
+
.style("min-width", "0px")
|
|
334
|
+
;
|
|
335
|
+
this._divTitleIcon = this._divTitle.append("div")
|
|
336
|
+
.attr("class", "title-icon")
|
|
337
|
+
.style("font-family", this.titleIconFont())
|
|
338
|
+
.style("font-size", `${this.titleIconFontSize()}px`)
|
|
339
|
+
.style("width", `${this.titleIconFontSize()}px`)
|
|
340
|
+
;
|
|
341
|
+
this._divTitle.append("div")
|
|
342
|
+
.attr("class", "data-count")
|
|
343
|
+
;
|
|
344
|
+
this._divTitleText = this._divTitle.append("div")
|
|
345
|
+
.attr("class", "title-text")
|
|
346
|
+
.style("font-family", this.titleFont())
|
|
347
|
+
.style("font-size", `${this.titleFontSize()}px`)
|
|
348
|
+
;
|
|
349
|
+
this._divDescriptionText = this._divTitle.append("div")
|
|
350
|
+
.attr("class", "description-text")
|
|
351
|
+
.style("font-family", this.descriptionFont())
|
|
352
|
+
;
|
|
353
|
+
|
|
354
|
+
super.enter(domNode, element);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
update(domNode, element) {
|
|
358
|
+
this._divTitleIcon
|
|
359
|
+
.text(this.titleIcon())
|
|
360
|
+
.style("display", this.titleIcon() !== "" ? "inline-block" : "none")
|
|
361
|
+
;
|
|
362
|
+
this._divTitleText
|
|
363
|
+
.text(this.title())
|
|
364
|
+
.attr("title", this.title())
|
|
365
|
+
;
|
|
366
|
+
this._divDescriptionText
|
|
367
|
+
.style("display", this.description_exists() ? "block" : "none")
|
|
368
|
+
.style("font-size", this.description_exists() ? `${this.descriptionFontSize()}px` : null)
|
|
369
|
+
.style("line-height", this.description_exists() ? `${this.descriptionFontSize()}px` : null)
|
|
370
|
+
.text(this.description())
|
|
371
|
+
;
|
|
372
|
+
|
|
373
|
+
super.update(domNode, element);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
TitleBar.prototype._class += " common_TitleBar";
|
|
377
|
+
|
|
378
|
+
export interface TitleBar {
|
|
379
|
+
title(): string;
|
|
380
|
+
title(_: string): this;
|
|
381
|
+
titleIcon(): string;
|
|
382
|
+
titleIcon(_: string): this;
|
|
383
|
+
titleIconFont(): string;
|
|
384
|
+
titleIconFont(_: string): this;
|
|
385
|
+
titleFont(): string;
|
|
386
|
+
titleFont(_: string): this;
|
|
387
|
+
titleIconFontSize(): number;
|
|
388
|
+
titleIconFontSize(_: number): this;
|
|
389
|
+
titleFontSize(): number;
|
|
390
|
+
titleFontSize(_: number): this;
|
|
391
|
+
description(): string;
|
|
392
|
+
description(_: string): this;
|
|
393
|
+
description_exists(): boolean;
|
|
394
|
+
descriptionFont(): string;
|
|
395
|
+
descriptionFont(_: string): this;
|
|
396
|
+
descriptionFontSize(): number;
|
|
397
|
+
descriptionFontSize(_: number): this;
|
|
398
|
+
}
|
|
399
|
+
TitleBar.prototype.publish("titleIcon", "", "string", "Icon text");
|
|
400
|
+
TitleBar.prototype.publish("titleIconFont", "", "string", "Icon font-family");
|
|
401
|
+
TitleBar.prototype.publish("titleIconFontSize", 28, "number", "Icon font-size (pixels)");
|
|
402
|
+
TitleBar.prototype.publish("title", "", "string", "Title text");
|
|
403
|
+
TitleBar.prototype.publish("titleFont", "", "string", "Title font-family");
|
|
404
|
+
TitleBar.prototype.publish("titleFontSize", 20, "number", "Title font-size (pixels)");
|
|
405
|
+
TitleBar.prototype.publish("description", null, "string", "Description text", null, { optional: true });
|
|
406
|
+
TitleBar.prototype.publish("descriptionFont", "", "string", "Description font-family");
|
|
407
|
+
TitleBar.prototype.publish("descriptionFontSize", 10, "number", "Description font-size (pixels)");
|