@hpcc-js/dgrid 3.5.6 → 3.5.9

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/src/Table.ts CHANGED
@@ -1,246 +1,246 @@
1
- import { Palette, PropertyExt, Field } from "@hpcc-js/common";
2
- import { hashSum } from "@hpcc-js/util";
3
- import { format as d3Format } from "d3-format";
4
- import { select as d3Select } from "d3-selection";
5
- import { Common } from "./Common.ts";
6
- import { CellFormatter, CellRenderer, ColumnType, RowType } from "./RowFormatter.ts";
7
-
8
- // ColumnPalette ---
9
- export class ColumnFormat extends PropertyExt {
10
- _owner: Table;
11
-
12
- constructor() {
13
- super();
14
- }
15
-
16
- owner(): Table;
17
- owner(_: Table): this;
18
- owner(_?: Table): Table | this {
19
- if (!arguments.length) return this._owner;
20
- this._owner = _;
21
- return this;
22
- }
23
-
24
- valid(): boolean {
25
- return !!this.column();
26
- }
27
-
28
- formatterFunc(): CellFormatter | undefined {
29
- const defaultFormatter = this._owner.formatterFunc();
30
- if (this.valid() && this.format()) {
31
- const numberFormatter = d3Format(this.format());
32
-
33
- return function (this: ColumnType, cell: any, row: RowType): string {
34
- if (typeof cell === "number")
35
- return numberFormatter(cell);
36
- return defaultFormatter.call(this, cell, row);
37
- };
38
- }
39
- return defaultFormatter;
40
- }
41
-
42
- renderCellFunc(): CellRenderer | undefined {
43
- const defaultRenderCell = this._owner.renderCellFunc();
44
- const defaultFormatter = this.formatterFunc();
45
- if (this.valid() && this.paletteID()) {
46
- const columns = this._owner.columns();
47
- const palette = Palette.rainbow(this.paletteID());
48
- const min = this.min();
49
- const max = this.max();
50
- const valueColIdx = this.valueColumn() ? columns.indexOf(this.valueColumn()) : undefined;
51
- return function (this: ColumnType, row: RowType, cell: any, cellElement: HTMLElement): HTMLElement | void {
52
- if (defaultRenderCell) {
53
- defaultRenderCell.call(this, row, cell, cellElement);
54
- }
55
- const value = valueColIdx ? row.__origRow[valueColIdx] : cell;
56
- const background = palette(value, min, max);
57
- const cellText: any = defaultFormatter.call(this, cell, row);
58
- d3Select(cellElement)
59
- .style("background", background)
60
- .style("color", background && Palette.textColor(background))
61
- .text(cellText?.html ?? cellText ?? cell)
62
- ;
63
- };
64
- }
65
- return defaultRenderCell;
66
- }
67
- }
68
- ColumnFormat.prototype._class += " dgrid_Table.ColumnFormat";
69
-
70
- export interface ColumnFormat {
71
- column(): string;
72
- column(_: string): this;
73
- width(): number;
74
- width(_: number): this;
75
- format(): string;
76
- format(_: string): this;
77
- paletteID(): string;
78
- paletteID(_: string): this;
79
- min(): number;
80
- min(_: number): this;
81
- max(): number;
82
- max(_: number): this;
83
- valueColumn(): string;
84
- valueColumn(_: string): this;
85
- }
86
- ColumnFormat.prototype.publish("column", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true });
87
- ColumnFormat.prototype.publish("width", null, "number", "Width", null, { optional: true });
88
- ColumnFormat.prototype.publish("format", null, "string", "Format (d3-format)", null, { optional: true });
89
- ColumnFormat.prototype.publish("paletteID", null, "set", "Color palette for this widget", ["", ...Palette.rainbow("default").switch()], { optional: true });
90
- ColumnFormat.prototype.publish("min", 0, "number", "Min Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
91
- ColumnFormat.prototype.publish("max", 100, "number", "Max Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
92
- ColumnFormat.prototype.publish("valueColumn", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true, disable: (cf: ColumnFormat) => !cf.paletteID() });
93
-
94
- // Table ---
95
- export class Table extends Common {
96
- private _prevColsHash;
97
- private _prevFieldsHash;
98
- _colsRefresh = false;
99
- _dataRefresh = false;
100
-
101
- constructor() {
102
- super();
103
- }
104
-
105
- fields(): Field[];
106
- fields(_: Field[]): this;
107
- fields(_?: Field[]): Field[] | this {
108
- const retVal = super.fields.apply(this, arguments as any);
109
- if (arguments.length) {
110
- const hash = hashSum({ _ });
111
- if (this._prevFieldsHash !== hash) {
112
- this._prevFieldsHash = hash;
113
- this._colsRefresh = true;
114
- }
115
- }
116
- return retVal;
117
- }
118
-
119
- columns(): string[];
120
- columns(_: string[], asDefault?: boolean): this;
121
- columns(_?: string[], asDefault?: boolean): string[] | this {
122
- const retVal = super.columns.apply(this, arguments as any);
123
- if (arguments.length) {
124
- const hash = hashSum({ _ });
125
- if (this._prevColsHash !== hash) {
126
- this._prevColsHash = hash;
127
- this._colsRefresh = true;
128
- }
129
- }
130
- return retVal;
131
- }
132
-
133
- data(): any;
134
- data(_: any): this;
135
- data(_?: any): any | this {
136
- const retVal = super.data.apply(this, arguments as any);
137
- if (arguments.length) {
138
- this._dataRefresh = true;
139
- }
140
- return retVal;
141
- }
142
-
143
- enter(domNode, element) {
144
- super.enter(domNode, element);
145
- }
146
-
147
- guessWidth(columns, data) {
148
- const sortablePadding = this.sortable() ? 12 : 0;
149
- for (const column of columns) {
150
- if (column.children) {
151
- let sampleData = [];
152
- for (let i = 0; i < Math.min(3, data.length); ++i) {
153
- sampleData = sampleData.concat(data[i][column.idx]);
154
- }
155
- this.guessWidth(column.children, sampleData);
156
- } else {
157
- column.width = data.reduce((prevVal: number, row) => {
158
- const cell = ("" + row[column.idx]).trim();
159
- return Math.max(prevVal, this.textSize(cell).width);
160
- }, this.textSize("" + column.label, undefined, undefined, true).width + sortablePadding) + 8; // +12 for the sort icon, +8 for the cell padding.
161
- }
162
- }
163
- }
164
-
165
- _prevHash;
166
- update(domNode, element) {
167
- super.update(domNode, element);
168
- const hash = this.hashSum();
169
- if (this._prevHash !== hash) {
170
- this._prevHash = hash;
171
- this._colsRefresh = true;
172
- }
173
- if (this._colsRefresh) {
174
- this._columns = this._store.columns(this.sortable(), this.formatterFunc(), this.renderCellFunc());
175
- switch (this.columnWidth()) {
176
- case "auto":
177
- const tenRows = this.data().filter((row, idx) => idx < 10);
178
- this.guessWidth(this._columns, tenRows);
179
- break;
180
- }
181
- const columns = this.columns();
182
- for (const columnFormat of this.columnFormats()) {
183
- if (columnFormat.valid()) {
184
- const colIdx = columns.indexOf(columnFormat.column());
185
- if (this._columns[colIdx]) {
186
- this._columns[colIdx].hidden = columnFormat.width() === 0;
187
- this._columns[colIdx].width = columnFormat.width() || this._columns[colIdx].width;
188
- this._columns[colIdx].formatter = columnFormat.formatterFunc();
189
- this._columns[colIdx].renderCell = columnFormat.renderCellFunc();
190
- }
191
- }
192
- }
193
- this._dgrid.set("columns", this._columns.filter(col => !col.hidden));
194
- this._colsRefresh = false;
195
- }
196
- if (this._colsRefresh || this._dataRefresh) {
197
- if (this._colsRefresh) {
198
- this._dgrid.refresh({});
199
- } else {
200
- this._dgrid.refresh();
201
- }
202
- this._colsRefresh = false;
203
- this._dataRefresh = false;
204
- }
205
- }
206
-
207
- exit(domNode, element) {
208
- delete this._prevColsHash;
209
- delete this._prevFieldsHash;
210
- super.exit(domNode, element);
211
- }
212
-
213
- // Cell ---
214
- formatterFunc(): CellFormatter | undefined {
215
- return function (this: ColumnType, cell: any, row: RowType): string | any {
216
- switch (typeof cell) {
217
- case "string":
218
- return {
219
- html: cell.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").trim()
220
- };
221
- case "undefined":
222
- return "";
223
- }
224
- return cell;
225
- };
226
- }
227
-
228
- renderCellFunc(): CellRenderer | undefined {
229
- return undefined; // Undefined will defualt to formatter ---
230
- }
231
-
232
- // Events ---
233
- click(row, col, sel) {
234
- }
235
- }
236
- Table.prototype._class += " dgrid_Table";
237
-
238
- export interface Table {
239
- columnWidth(): "auto" | "none";
240
- columnWidth(_: "auto" | "none"): this;
241
- columnFormats(): ColumnFormat[];
242
- columnFormats(_: ColumnFormat[]): this;
243
- }
244
-
245
- Table.prototype.publish("columnWidth", "auto", "set", "Default column width", ["auto", "none"]);
246
- Table.prototype.publish("columnFormats", [], "propertyArray", "Source Columns", null, { autoExpand: ColumnFormat });
1
+ import { Palette, PropertyExt, Field } from "@hpcc-js/common";
2
+ import { hashSum } from "@hpcc-js/util";
3
+ import { format as d3Format } from "d3-format";
4
+ import { select as d3Select } from "d3-selection";
5
+ import { Common } from "./Common.ts";
6
+ import { CellFormatter, CellRenderer, ColumnType, RowType } from "./RowFormatter.ts";
7
+
8
+ // ColumnPalette ---
9
+ export class ColumnFormat extends PropertyExt {
10
+ _owner: Table;
11
+
12
+ constructor() {
13
+ super();
14
+ }
15
+
16
+ owner(): Table;
17
+ owner(_: Table): this;
18
+ owner(_?: Table): Table | this {
19
+ if (!arguments.length) return this._owner;
20
+ this._owner = _;
21
+ return this;
22
+ }
23
+
24
+ valid(): boolean {
25
+ return !!this.column();
26
+ }
27
+
28
+ formatterFunc(): CellFormatter | undefined {
29
+ const defaultFormatter = this._owner.formatterFunc();
30
+ if (this.valid() && this.format()) {
31
+ const numberFormatter = d3Format(this.format());
32
+
33
+ return function (this: ColumnType, cell: any, row: RowType): string {
34
+ if (typeof cell === "number")
35
+ return numberFormatter(cell);
36
+ return defaultFormatter.call(this, cell, row);
37
+ };
38
+ }
39
+ return defaultFormatter;
40
+ }
41
+
42
+ renderCellFunc(): CellRenderer | undefined {
43
+ const defaultRenderCell = this._owner.renderCellFunc();
44
+ const defaultFormatter = this.formatterFunc();
45
+ if (this.valid() && this.paletteID()) {
46
+ const columns = this._owner.columns();
47
+ const palette = Palette.rainbow(this.paletteID());
48
+ const min = this.min();
49
+ const max = this.max();
50
+ const valueColIdx = this.valueColumn() ? columns.indexOf(this.valueColumn()) : undefined;
51
+ return function (this: ColumnType, row: RowType, cell: any, cellElement: HTMLElement): HTMLElement | void {
52
+ if (defaultRenderCell) {
53
+ defaultRenderCell.call(this, row, cell, cellElement);
54
+ }
55
+ const value = valueColIdx ? row.__origRow[valueColIdx] : cell;
56
+ const background = palette(value, min, max);
57
+ const cellText: any = defaultFormatter.call(this, cell, row);
58
+ d3Select(cellElement)
59
+ .style("background", background)
60
+ .style("color", background && Palette.textColor(background))
61
+ .text(cellText?.html ?? cellText ?? cell)
62
+ ;
63
+ };
64
+ }
65
+ return defaultRenderCell;
66
+ }
67
+ }
68
+ ColumnFormat.prototype._class += " dgrid_Table.ColumnFormat";
69
+
70
+ export interface ColumnFormat {
71
+ column(): string;
72
+ column(_: string): this;
73
+ width(): number;
74
+ width(_: number): this;
75
+ format(): string;
76
+ format(_: string): this;
77
+ paletteID(): string;
78
+ paletteID(_: string): this;
79
+ min(): number;
80
+ min(_: number): this;
81
+ max(): number;
82
+ max(_: number): this;
83
+ valueColumn(): string;
84
+ valueColumn(_: string): this;
85
+ }
86
+ ColumnFormat.prototype.publish("column", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true });
87
+ ColumnFormat.prototype.publish("width", null, "number", "Width", null, { optional: true });
88
+ ColumnFormat.prototype.publish("format", null, "string", "Format (d3-format)", null, { optional: true });
89
+ ColumnFormat.prototype.publish("paletteID", null, "set", "Color palette for this widget", ["", ...Palette.rainbow("default").switch()], { optional: true });
90
+ ColumnFormat.prototype.publish("min", 0, "number", "Min Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
91
+ ColumnFormat.prototype.publish("max", 100, "number", "Max Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
92
+ ColumnFormat.prototype.publish("valueColumn", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true, disable: (cf: ColumnFormat) => !cf.paletteID() });
93
+
94
+ // Table ---
95
+ export class Table extends Common {
96
+ private _prevColsHash;
97
+ private _prevFieldsHash;
98
+ _colsRefresh = false;
99
+ _dataRefresh = false;
100
+
101
+ constructor() {
102
+ super();
103
+ }
104
+
105
+ fields(): Field[];
106
+ fields(_: Field[]): this;
107
+ fields(_?: Field[]): Field[] | this {
108
+ const retVal = super.fields.apply(this, arguments as any);
109
+ if (arguments.length) {
110
+ const hash = hashSum({ _ });
111
+ if (this._prevFieldsHash !== hash) {
112
+ this._prevFieldsHash = hash;
113
+ this._colsRefresh = true;
114
+ }
115
+ }
116
+ return retVal;
117
+ }
118
+
119
+ columns(): string[];
120
+ columns(_: string[], asDefault?: boolean): this;
121
+ columns(_?: string[], asDefault?: boolean): string[] | this {
122
+ const retVal = super.columns.apply(this, arguments as any);
123
+ if (arguments.length) {
124
+ const hash = hashSum({ _ });
125
+ if (this._prevColsHash !== hash) {
126
+ this._prevColsHash = hash;
127
+ this._colsRefresh = true;
128
+ }
129
+ }
130
+ return retVal;
131
+ }
132
+
133
+ data(): any;
134
+ data(_: any): this;
135
+ data(_?: any): any | this {
136
+ const retVal = super.data.apply(this, arguments as any);
137
+ if (arguments.length) {
138
+ this._dataRefresh = true;
139
+ }
140
+ return retVal;
141
+ }
142
+
143
+ enter(domNode, element) {
144
+ super.enter(domNode, element);
145
+ }
146
+
147
+ guessWidth(columns, data) {
148
+ const sortablePadding = this.sortable() ? 12 : 0;
149
+ for (const column of columns) {
150
+ if (column.children) {
151
+ let sampleData = [];
152
+ for (let i = 0; i < Math.min(3, data.length); ++i) {
153
+ sampleData = sampleData.concat(data[i][column.idx]);
154
+ }
155
+ this.guessWidth(column.children, sampleData);
156
+ } else {
157
+ column.width = data.reduce((prevVal: number, row) => {
158
+ const cell = ("" + row[column.idx]).trim();
159
+ return Math.max(prevVal, this.textSize(cell).width);
160
+ }, this.textSize("" + column.label, undefined, undefined, true).width + sortablePadding) + 8; // +12 for the sort icon, +8 for the cell padding.
161
+ }
162
+ }
163
+ }
164
+
165
+ _prevHash;
166
+ update(domNode, element) {
167
+ super.update(domNode, element);
168
+ const hash = this.hashSum();
169
+ if (this._prevHash !== hash) {
170
+ this._prevHash = hash;
171
+ this._colsRefresh = true;
172
+ }
173
+ if (this._colsRefresh) {
174
+ this._columns = this._store.columns(this.sortable(), this.formatterFunc(), this.renderCellFunc());
175
+ switch (this.columnWidth()) {
176
+ case "auto":
177
+ const tenRows = this.data().filter((row, idx) => idx < 10);
178
+ this.guessWidth(this._columns, tenRows);
179
+ break;
180
+ }
181
+ const columns = this.columns();
182
+ for (const columnFormat of this.columnFormats()) {
183
+ if (columnFormat.valid()) {
184
+ const colIdx = columns.indexOf(columnFormat.column());
185
+ if (this._columns[colIdx]) {
186
+ this._columns[colIdx].hidden = columnFormat.width() === 0;
187
+ this._columns[colIdx].width = columnFormat.width() || this._columns[colIdx].width;
188
+ this._columns[colIdx].formatter = columnFormat.formatterFunc();
189
+ this._columns[colIdx].renderCell = columnFormat.renderCellFunc();
190
+ }
191
+ }
192
+ }
193
+ this._dgrid.set("columns", this._columns.filter(col => !col.hidden));
194
+ this._colsRefresh = false;
195
+ }
196
+ if (this._colsRefresh || this._dataRefresh) {
197
+ if (this._colsRefresh) {
198
+ this._dgrid.refresh({});
199
+ } else {
200
+ this._dgrid.refresh();
201
+ }
202
+ this._colsRefresh = false;
203
+ this._dataRefresh = false;
204
+ }
205
+ }
206
+
207
+ exit(domNode, element) {
208
+ delete this._prevColsHash;
209
+ delete this._prevFieldsHash;
210
+ super.exit(domNode, element);
211
+ }
212
+
213
+ // Cell ---
214
+ formatterFunc(): CellFormatter | undefined {
215
+ return function (this: ColumnType, cell: any, row: RowType): string | any {
216
+ switch (typeof cell) {
217
+ case "string":
218
+ return {
219
+ html: cell.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").trim()
220
+ };
221
+ case "undefined":
222
+ return "";
223
+ }
224
+ return cell;
225
+ };
226
+ }
227
+
228
+ renderCellFunc(): CellRenderer | undefined {
229
+ return undefined; // Undefined will defualt to formatter ---
230
+ }
231
+
232
+ // Events ---
233
+ click(row, col, sel) {
234
+ }
235
+ }
236
+ Table.prototype._class += " dgrid_Table";
237
+
238
+ export interface Table {
239
+ columnWidth(): "auto" | "none";
240
+ columnWidth(_: "auto" | "none"): this;
241
+ columnFormats(): ColumnFormat[];
242
+ columnFormats(_: ColumnFormat[]): this;
243
+ }
244
+
245
+ Table.prototype.publish("columnWidth", "auto", "set", "Default column width", ["auto", "none"]);
246
+ Table.prototype.publish("columnFormats", [], "propertyArray", "Source Columns", null, { autoExpand: ColumnFormat });
@@ -1,3 +1,3 @@
1
- export const PKG_NAME = "__PACKAGE_NAME__";
2
- export const PKG_VERSION = "__PACKAGE_VERSION__";
3
- export const BUILD_VERSION = "__BUILD_VERSION__";
1
+ export const PKG_NAME = "__PACKAGE_NAME__";
2
+ export const PKG_VERSION = "__PACKAGE_VERSION__";
3
+ export const BUILD_VERSION = "__BUILD_VERSION__";
@@ -1 +1 @@
1
- export { Test } from "./test1";
1
+ export { Test } from "./test1";
@@ -1,50 +1,50 @@
1
- import { Table } from "../Table";
2
-
3
- export class Test extends Table {
4
-
5
- constructor() {
6
- super();
7
- this
8
- .columns(["Category", "Series-1", "Series-2", "Series-3", "Series-4"])
9
- .data([
10
- ["A", -25, -23, -25, -22],
11
- ["B", -20, -21, -25, -21],
12
- ["C", -18, -20, -25, -19],
13
- ["D", -17, -17, -25, -18],
14
- ["E", -16, -15, -19, -18],
15
- ["F", -15, -14, -16, -16],
16
- ["G", -12, -10, -14, -15],
17
- ["H", -12, -8, -13, -15],
18
- ["I", -11, -6, -12, -12],
19
- ["J", -11, -6, -8, -12],
20
- ["K", -9, 0, -5, -10],
21
- ["L", -5, 1, -5, -9],
22
- ["M", -5, 2, -4, -8],
23
- ["N", -1, 4, -2, -7],
24
- ["O", 3, 7, 0, -5],
25
- ["P", 3, 8, 0, -3],
26
- ["Q", 4, 8, 7, 0],
27
- ["R", 6, 9, 11, 1],
28
- ["S", 9, 11, 11, 5],
29
- ["T", 10, 20, 12, 6],
30
- ["U", 12, 20, 16, 8],
31
- ["V", 12, 21, 18, 14],
32
- ["W", 14, 21, 18, 18],
33
- ["X", 15, 23, 21, 18],
34
- ["Y", 21, 23, 23, 21],
35
- ["Z", 23, 24, 24, 24]
36
- ])
37
- .on("click", (row, column, selected) => {
38
- console.info("click", row, column, selected);
39
- })
40
- ;
41
- // setTimeout(() => {
42
- // this.data([
43
- // // ["J", -11, -6, -8, -12],
44
- // // ["K", -9, 0, -5, -10],
45
- // // ["L", -5, 1, -5, -9],
46
- // ]).lazyRender();
47
- // }, 3000);
48
- }
49
- }
50
-
1
+ import { Table } from "../Table";
2
+
3
+ export class Test extends Table {
4
+
5
+ constructor() {
6
+ super();
7
+ this
8
+ .columns(["Category", "Series-1", "Series-2", "Series-3", "Series-4"])
9
+ .data([
10
+ ["A", -25, -23, -25, -22],
11
+ ["B", -20, -21, -25, -21],
12
+ ["C", -18, -20, -25, -19],
13
+ ["D", -17, -17, -25, -18],
14
+ ["E", -16, -15, -19, -18],
15
+ ["F", -15, -14, -16, -16],
16
+ ["G", -12, -10, -14, -15],
17
+ ["H", -12, -8, -13, -15],
18
+ ["I", -11, -6, -12, -12],
19
+ ["J", -11, -6, -8, -12],
20
+ ["K", -9, 0, -5, -10],
21
+ ["L", -5, 1, -5, -9],
22
+ ["M", -5, 2, -4, -8],
23
+ ["N", -1, 4, -2, -7],
24
+ ["O", 3, 7, 0, -5],
25
+ ["P", 3, 8, 0, -3],
26
+ ["Q", 4, 8, 7, 0],
27
+ ["R", 6, 9, 11, 1],
28
+ ["S", 9, 11, 11, 5],
29
+ ["T", 10, 20, 12, 6],
30
+ ["U", 12, 20, 16, 8],
31
+ ["V", 12, 21, 18, 14],
32
+ ["W", 14, 21, 18, 18],
33
+ ["X", 15, 23, 21, 18],
34
+ ["Y", 21, 23, 23, 21],
35
+ ["Z", 23, 24, 24, 24]
36
+ ])
37
+ .on("click", (row, column, selected) => {
38
+ console.info("click", row, column, selected);
39
+ })
40
+ ;
41
+ // setTimeout(() => {
42
+ // this.data([
43
+ // // ["J", -11, -6, -8, -12],
44
+ // // ["K", -9, 0, -5, -10],
45
+ // // ["L", -5, 1, -5, -9],
46
+ // ]).lazyRender();
47
+ // }, 3000);
48
+ }
49
+ }
50
+
package/src/dgrid-shim.ts CHANGED
@@ -1,12 +1,12 @@
1
- import * as dgrid_shim from "@hpcc-js/dgrid-shim";
2
-
3
- if (!globalThis["@hpcc-js/dgrid-shim"]) {
4
- console.error("dgrid-shim not loaded, please add `<script src=\"https://cdn.jsdelivr.net/npm/@hpcc-js/dgrid-shim/dist/index.min.js\"></script>` or similar to your HTML file");
5
- }
6
-
7
- export const Deferred = globalThis["@hpcc-js/dgrid-shim"].Deferred as typeof dgrid_shim.Deferred;
8
- export const Memory = globalThis["@hpcc-js/dgrid-shim"].Memory as typeof dgrid_shim.Memory;
9
- export const QueryResults = globalThis["@hpcc-js/dgrid-shim"].QueryResults as typeof dgrid_shim.QueryResults;
10
- export const Grid = globalThis["@hpcc-js/dgrid-shim"].Grid as typeof dgrid_shim.Grid;
11
- export const PagingGrid = globalThis["@hpcc-js/dgrid-shim"].PagingGrid as typeof dgrid_shim.PagingGrid;
12
- export const domConstruct = globalThis["@hpcc-js/dgrid-shim"].domConstruct as typeof dgrid_shim.domConstruct;
1
+ import * as dgrid_shim from "@hpcc-js/dgrid-shim";
2
+
3
+ if (!globalThis["@hpcc-js/dgrid-shim"]) {
4
+ console.error("dgrid-shim not loaded, please add `<script src=\"https://cdn.jsdelivr.net/npm/@hpcc-js/dgrid-shim/dist/index.min.js\"></script>` or similar to your HTML file");
5
+ }
6
+
7
+ export const Deferred = globalThis["@hpcc-js/dgrid-shim"].Deferred as typeof dgrid_shim.Deferred;
8
+ export const Memory = globalThis["@hpcc-js/dgrid-shim"].Memory as typeof dgrid_shim.Memory;
9
+ export const QueryResults = globalThis["@hpcc-js/dgrid-shim"].QueryResults as typeof dgrid_shim.QueryResults;
10
+ export const Grid = globalThis["@hpcc-js/dgrid-shim"].Grid as typeof dgrid_shim.Grid;
11
+ export const PagingGrid = globalThis["@hpcc-js/dgrid-shim"].PagingGrid as typeof dgrid_shim.PagingGrid;
12
+ export const domConstruct = globalThis["@hpcc-js/dgrid-shim"].domConstruct as typeof dgrid_shim.domConstruct;
package/src/i18n.js CHANGED
@@ -1,12 +1,12 @@
1
- // eslint-disable-next-line no-undef
2
- define({
3
- load: function (name, req, onload, config) {
4
- if (config.isBuild) {
5
- onload();
6
- } else {
7
- req([name], function (value) {
8
- onload(value.root);
9
- });
10
- }
11
- }
1
+ // eslint-disable-next-line no-undef
2
+ define({
3
+ load: function (name, req, onload, config) {
4
+ if (config.isBuild) {
5
+ onload();
6
+ } else {
7
+ req([name], function (value) {
8
+ onload(value.root);
9
+ });
10
+ }
11
+ }
12
12
  });