@angular-generic-table/core 5.0.0-rc.4 → 5.0.0-rc.8

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 (65) hide show
  1. package/angular-generic-table-core.d.ts +1 -3
  2. package/esm2020/angular-generic-table-core.mjs +5 -0
  3. package/esm2020/lib/core.component.mjs +122 -0
  4. package/esm2020/lib/core.module.mjs +23 -0
  5. package/esm2020/lib/core.service.mjs +14 -0
  6. package/esm2020/lib/enums/order.enum.mjs +6 -0
  7. package/esm2020/lib/models/table-column.interface.mjs +2 -0
  8. package/esm2020/lib/models/table-config.interface.mjs +2 -0
  9. package/esm2020/lib/models/table-info.interface.mjs +2 -0
  10. package/esm2020/lib/models/table-meta.interface.mjs +2 -0
  11. package/esm2020/lib/models/table-row.interface.mjs +2 -0
  12. package/esm2020/lib/models/table-sort.interface.mjs +2 -0
  13. package/esm2020/lib/pagination/pagination.component.mjs +63 -0
  14. package/esm2020/lib/pagination/pagination.module.mjs +18 -0
  15. package/esm2020/lib/pipes/capital-case.pipe.mjs +17 -0
  16. package/esm2020/lib/pipes/dash-case.pipe.mjs +17 -0
  17. package/esm2020/lib/pipes/dynamic.pipe.mjs +25 -0
  18. package/esm2020/lib/pipes/highlight.pipe.mjs +48 -0
  19. package/esm2020/lib/pipes/sort-class.pipe.mjs +16 -0
  20. package/esm2020/lib/utilities/utilities.mjs +39 -0
  21. package/esm2020/public-api.mjs +15 -0
  22. package/fesm2015/angular-generic-table-core.mjs +384 -0
  23. package/fesm2015/angular-generic-table-core.mjs.map +1 -0
  24. package/fesm2020/angular-generic-table-core.mjs +381 -0
  25. package/fesm2020/angular-generic-table-core.mjs.map +1 -0
  26. package/lib/core.component.d.ts +8 -10
  27. package/lib/core.module.d.ts +11 -0
  28. package/lib/core.service.d.ts +3 -0
  29. package/lib/models/table-column.interface.d.ts +6 -1
  30. package/lib/models/table-config.interface.d.ts +8 -3
  31. package/lib/models/table-meta.interface.d.ts +8 -0
  32. package/lib/models/table-row.interface.d.ts +1 -0
  33. package/lib/pagination/pagination.component.d.ts +14 -0
  34. package/lib/pagination/pagination.module.d.ts +8 -0
  35. package/lib/pipes/capital-case.pipe.d.ts +7 -0
  36. package/lib/pipes/dash-case.pipe.d.ts +3 -0
  37. package/lib/pipes/dynamic.pipe.d.ts +9 -0
  38. package/lib/pipes/highlight.pipe.d.ts +3 -0
  39. package/lib/pipes/sort-class.pipe.d.ts +3 -0
  40. package/lib/utilities/utilities.d.ts +1 -0
  41. package/package.json +19 -7
  42. package/public-api.d.ts +3 -0
  43. package/scss/index.scss +102 -0
  44. package/angular-generic-table-core.metadata.json +0 -1
  45. package/bundles/angular-generic-table-core.umd.js +0 -610
  46. package/bundles/angular-generic-table-core.umd.js.map +0 -1
  47. package/bundles/angular-generic-table-core.umd.min.js +0 -2
  48. package/bundles/angular-generic-table-core.umd.min.js.map +0 -1
  49. package/esm2015/angular-generic-table-core.js +0 -8
  50. package/esm2015/lib/core.component.js +0 -115
  51. package/esm2015/lib/core.module.js +0 -16
  52. package/esm2015/lib/core.service.js +0 -13
  53. package/esm2015/lib/enums/order.enum.js +0 -6
  54. package/esm2015/lib/models/table-column.interface.js +0 -2
  55. package/esm2015/lib/models/table-config.interface.js +0 -2
  56. package/esm2015/lib/models/table-info.interface.js +0 -2
  57. package/esm2015/lib/models/table-row.interface.js +0 -2
  58. package/esm2015/lib/models/table-sort.interface.js +0 -2
  59. package/esm2015/lib/pipes/dash-case.pipe.js +0 -13
  60. package/esm2015/lib/pipes/highlight.pipe.js +0 -44
  61. package/esm2015/lib/pipes/sort-class.pipe.js +0 -12
  62. package/esm2015/lib/utilities/utilities.js +0 -25
  63. package/esm2015/public-api.js +0 -12
  64. package/fesm2015/angular-generic-table-core.js +0 -242
  65. package/fesm2015/angular-generic-table-core.js.map +0 -1
@@ -1,610 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('@angular-generic-table/core', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['angular-generic-table'] = global['angular-generic-table'] || {}, global['angular-generic-table'].core = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.common));
5
- }(this, (function (exports, i0, rxjs, operators, common) { 'use strict';
6
-
7
- var CoreService = /** @class */ (function () {
8
- function CoreService() {
9
- }
10
- return CoreService;
11
- }());
12
- CoreService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CoreService_Factory() { return new CoreService(); }, token: CoreService, providedIn: "root" });
13
- CoreService.decorators = [
14
- { type: i0.Injectable, args: [{
15
- providedIn: 'root'
16
- },] }
17
- ];
18
- CoreService.ctorParameters = function () { return []; };
19
-
20
- /*! *****************************************************************************
21
- Copyright (c) Microsoft Corporation.
22
-
23
- Permission to use, copy, modify, and/or distribute this software for any
24
- purpose with or without fee is hereby granted.
25
-
26
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
27
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
28
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
29
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
30
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
31
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
32
- PERFORMANCE OF THIS SOFTWARE.
33
- ***************************************************************************** */
34
- /* global Reflect, Promise */
35
- var extendStatics = function (d, b) {
36
- extendStatics = Object.setPrototypeOf ||
37
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
38
- function (d, b) { for (var p in b)
39
- if (Object.prototype.hasOwnProperty.call(b, p))
40
- d[p] = b[p]; };
41
- return extendStatics(d, b);
42
- };
43
- function __extends(d, b) {
44
- if (typeof b !== "function" && b !== null)
45
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
46
- extendStatics(d, b);
47
- function __() { this.constructor = d; }
48
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
49
- }
50
- var __assign = function () {
51
- __assign = Object.assign || function __assign(t) {
52
- for (var s, i = 1, n = arguments.length; i < n; i++) {
53
- s = arguments[i];
54
- for (var p in s)
55
- if (Object.prototype.hasOwnProperty.call(s, p))
56
- t[p] = s[p];
57
- }
58
- return t;
59
- };
60
- return __assign.apply(this, arguments);
61
- };
62
- function __rest(s, e) {
63
- var t = {};
64
- for (var p in s)
65
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
66
- t[p] = s[p];
67
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
68
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
69
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
70
- t[p[i]] = s[p[i]];
71
- }
72
- return t;
73
- }
74
- function __decorate(decorators, target, key, desc) {
75
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
76
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
77
- r = Reflect.decorate(decorators, target, key, desc);
78
- else
79
- for (var i = decorators.length - 1; i >= 0; i--)
80
- if (d = decorators[i])
81
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
82
- return c > 3 && r && Object.defineProperty(target, key, r), r;
83
- }
84
- function __param(paramIndex, decorator) {
85
- return function (target, key) { decorator(target, key, paramIndex); };
86
- }
87
- function __metadata(metadataKey, metadataValue) {
88
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
89
- return Reflect.metadata(metadataKey, metadataValue);
90
- }
91
- function __awaiter(thisArg, _arguments, P, generator) {
92
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
93
- return new (P || (P = Promise))(function (resolve, reject) {
94
- function fulfilled(value) { try {
95
- step(generator.next(value));
96
- }
97
- catch (e) {
98
- reject(e);
99
- } }
100
- function rejected(value) { try {
101
- step(generator["throw"](value));
102
- }
103
- catch (e) {
104
- reject(e);
105
- } }
106
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
107
- step((generator = generator.apply(thisArg, _arguments || [])).next());
108
- });
109
- }
110
- function __generator(thisArg, body) {
111
- var _ = { label: 0, sent: function () { if (t[0] & 1)
112
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
113
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
114
- function verb(n) { return function (v) { return step([n, v]); }; }
115
- function step(op) {
116
- if (f)
117
- throw new TypeError("Generator is already executing.");
118
- while (_)
119
- try {
120
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
121
- return t;
122
- if (y = 0, t)
123
- op = [op[0] & 2, t.value];
124
- switch (op[0]) {
125
- case 0:
126
- case 1:
127
- t = op;
128
- break;
129
- case 4:
130
- _.label++;
131
- return { value: op[1], done: false };
132
- case 5:
133
- _.label++;
134
- y = op[1];
135
- op = [0];
136
- continue;
137
- case 7:
138
- op = _.ops.pop();
139
- _.trys.pop();
140
- continue;
141
- default:
142
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
143
- _ = 0;
144
- continue;
145
- }
146
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
147
- _.label = op[1];
148
- break;
149
- }
150
- if (op[0] === 6 && _.label < t[1]) {
151
- _.label = t[1];
152
- t = op;
153
- break;
154
- }
155
- if (t && _.label < t[2]) {
156
- _.label = t[2];
157
- _.ops.push(op);
158
- break;
159
- }
160
- if (t[2])
161
- _.ops.pop();
162
- _.trys.pop();
163
- continue;
164
- }
165
- op = body.call(thisArg, _);
166
- }
167
- catch (e) {
168
- op = [6, e];
169
- y = 0;
170
- }
171
- finally {
172
- f = t = 0;
173
- }
174
- if (op[0] & 5)
175
- throw op[1];
176
- return { value: op[0] ? op[1] : void 0, done: true };
177
- }
178
- }
179
- var __createBinding = Object.create ? (function (o, m, k, k2) {
180
- if (k2 === undefined)
181
- k2 = k;
182
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
183
- }) : (function (o, m, k, k2) {
184
- if (k2 === undefined)
185
- k2 = k;
186
- o[k2] = m[k];
187
- });
188
- function __exportStar(m, o) {
189
- for (var p in m)
190
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
191
- __createBinding(o, m, p);
192
- }
193
- function __values(o) {
194
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
195
- if (m)
196
- return m.call(o);
197
- if (o && typeof o.length === "number")
198
- return {
199
- next: function () {
200
- if (o && i >= o.length)
201
- o = void 0;
202
- return { value: o && o[i++], done: !o };
203
- }
204
- };
205
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
206
- }
207
- function __read(o, n) {
208
- var m = typeof Symbol === "function" && o[Symbol.iterator];
209
- if (!m)
210
- return o;
211
- var i = m.call(o), r, ar = [], e;
212
- try {
213
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
214
- ar.push(r.value);
215
- }
216
- catch (error) {
217
- e = { error: error };
218
- }
219
- finally {
220
- try {
221
- if (r && !r.done && (m = i["return"]))
222
- m.call(i);
223
- }
224
- finally {
225
- if (e)
226
- throw e.error;
227
- }
228
- }
229
- return ar;
230
- }
231
- /** @deprecated */
232
- function __spread() {
233
- for (var ar = [], i = 0; i < arguments.length; i++)
234
- ar = ar.concat(__read(arguments[i]));
235
- return ar;
236
- }
237
- /** @deprecated */
238
- function __spreadArrays() {
239
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
240
- s += arguments[i].length;
241
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
242
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
243
- r[k] = a[j];
244
- return r;
245
- }
246
- function __spreadArray(to, from) {
247
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
248
- to[j] = from[i];
249
- return to;
250
- }
251
- function __await(v) {
252
- return this instanceof __await ? (this.v = v, this) : new __await(v);
253
- }
254
- function __asyncGenerator(thisArg, _arguments, generator) {
255
- if (!Symbol.asyncIterator)
256
- throw new TypeError("Symbol.asyncIterator is not defined.");
257
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
258
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
259
- function verb(n) { if (g[n])
260
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
261
- function resume(n, v) { try {
262
- step(g[n](v));
263
- }
264
- catch (e) {
265
- settle(q[0][3], e);
266
- } }
267
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
268
- function fulfill(value) { resume("next", value); }
269
- function reject(value) { resume("throw", value); }
270
- function settle(f, v) { if (f(v), q.shift(), q.length)
271
- resume(q[0][0], q[0][1]); }
272
- }
273
- function __asyncDelegator(o) {
274
- var i, p;
275
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
276
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
277
- }
278
- function __asyncValues(o) {
279
- if (!Symbol.asyncIterator)
280
- throw new TypeError("Symbol.asyncIterator is not defined.");
281
- var m = o[Symbol.asyncIterator], i;
282
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
283
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
284
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
285
- }
286
- function __makeTemplateObject(cooked, raw) {
287
- if (Object.defineProperty) {
288
- Object.defineProperty(cooked, "raw", { value: raw });
289
- }
290
- else {
291
- cooked.raw = raw;
292
- }
293
- return cooked;
294
- }
295
- ;
296
- var __setModuleDefault = Object.create ? (function (o, v) {
297
- Object.defineProperty(o, "default", { enumerable: true, value: v });
298
- }) : function (o, v) {
299
- o["default"] = v;
300
- };
301
- function __importStar(mod) {
302
- if (mod && mod.__esModule)
303
- return mod;
304
- var result = {};
305
- if (mod != null)
306
- for (var k in mod)
307
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
308
- __createBinding(result, mod, k);
309
- __setModuleDefault(result, mod);
310
- return result;
311
- }
312
- function __importDefault(mod) {
313
- return (mod && mod.__esModule) ? mod : { default: mod };
314
- }
315
- function __classPrivateFieldGet(receiver, privateMap) {
316
- if (!privateMap.has(receiver)) {
317
- throw new TypeError("attempted to get private field on non-instance");
318
- }
319
- return privateMap.get(receiver);
320
- }
321
- function __classPrivateFieldSet(receiver, privateMap, value) {
322
- if (!privateMap.has(receiver)) {
323
- throw new TypeError("attempted to set private field on non-instance");
324
- }
325
- privateMap.set(receiver, value);
326
- return value;
327
- }
328
-
329
- var Order;
330
- (function (Order) {
331
- Order["ASC"] = "asc";
332
- Order["DESC"] = "desc";
333
- })(Order || (Order = {}));
334
-
335
- var dashed;
336
- dashed = function (s) { return s.replace(/[A-Z]/g, function (m) { return '-' + m.toLowerCase(); }); };
337
- var chunk;
338
- chunk = function (array, chunkSize) {
339
- if (chunkSize < 0) {
340
- throw new Error('Invalid chunk size');
341
- }
342
- if (chunkSize === 0 && !chunkSize) {
343
- return [array];
344
- }
345
- var CHUNK = [];
346
- for (var i = 0, len = array.length; i < len; i += chunkSize) {
347
- CHUNK.push(array.slice(i, i + chunkSize));
348
- }
349
- return CHUNK;
350
- };
351
- var search;
352
- search = function (text, caseSensitive, data, config) {
353
- var searchColumns = Object.keys(config.columns).filter(function (key) { return !config.columns[key].hidden && config.columns[key].search !== false; });
354
- return data.filter(function (row) { return Object.entries(row)
355
- .filter(function (_a) {
356
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
357
- return searchColumns.indexOf(key) !== -1;
358
- })
359
- .reduce(function (prev, _a) {
360
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
361
- return prev + (prev === '' ? '' : ' & ') + (caseSensitive ? value + '' : (value + '').toLowerCase());
362
- }, '')
363
- .indexOf(text) !== -1; });
364
- };
365
-
366
- var CoreComponent = /** @class */ (function () {
367
- function CoreComponent() {
368
- var _this = this;
369
- this._loading$ = new rxjs.ReplaySubject(1);
370
- this.sortBy$ = new rxjs.Subject();
371
- // tslint:disable-next-line:variable-name
372
- this._searchBy$ = new rxjs.ReplaySubject(1);
373
- this.searchBy$ = this._searchBy$.pipe(operators.startWith(''), operators.map(function (value) { return (rxjs.isObservable(value) ? value : rxjs.of(value)); }), operators.switchMap(function (obs) { return obs; }), operators.shareReplay(1));
374
- // tslint:disable-next-line:variable-name
375
- this._tableConfig$ = new rxjs.ReplaySubject(1);
376
- this.tableConfig$ = this._tableConfig$.pipe(operators.map(function (value) { return (rxjs.isObservable(value) ? value : rxjs.of(value)); }), operators.switchMap(function (obs) { return obs; }), operators.shareReplay(1));
377
- // tslint:disable-next-line:variable-name
378
- this._data$ = new rxjs.ReplaySubject(1);
379
- this.data$ = this._data$.pipe(operators.map(function (value) { return (rxjs.isObservable(value) ? value : rxjs.of(value)); }), operators.switchMap(function (obs) { return rxjs.combineLatest([obs, _this.sortBy$.pipe(operators.startWith(rxjs.EMPTY)), _this.searchBy$]); }), operators.withLatestFrom(this.tableConfig$), operators.map(function (_c) {
380
- var _d = __read(_c, 2), _e = __read(_d[0], 3), data = _e[0], sortBy = _e[1], searchBy = _e[2], config = _d[1];
381
- return !sortBy
382
- ? searchBy
383
- ? search(searchBy, false, data, config)
384
- : data
385
- : (searchBy ? search(searchBy, false, data, config) : data).sort(function (a, b) {
386
- // TODO: improve logic
387
- var typed = sortBy;
388
- return a[typed.sortBy] > b[typed.sortBy]
389
- ? typed.sortByOrder === Order.ASC
390
- ? 1
391
- : -1
392
- : b[typed.sortBy] > a[typed.sortBy]
393
- ? typed.sortByOrder === Order.ASC
394
- ? -1
395
- : 1
396
- : 0;
397
- });
398
- }));
399
- this.table$ = rxjs.combineLatest([
400
- this.data$,
401
- this.tableConfig$,
402
- ]).pipe(operators.map(function (_c) {
403
- var _d = __read(_c, 2), sorted = _d[0], config = _d[1];
404
- // if pagination is disabled...
405
- if (!config.pagination || config.pagination.length === 0) {
406
- // ...return unaltered array
407
- return { data: [sorted], config: config, info: { records: sorted.length, pageTotal: 1 } };
408
- }
409
- // return record set
410
- return {
411
- data: chunk(sorted, +config.pagination.length),
412
- config: config,
413
- info: {
414
- records: sorted.length,
415
- pageTotal: Math.ceil(sorted.length / +config.pagination.length),
416
- },
417
- };
418
- }));
419
- // tslint:disable-next-line:variable-name
420
- this._currentPage$ = new rxjs.BehaviorSubject(0);
421
- this.currentPage$ = this._currentPage$.pipe(operators.map(function (value) { return (rxjs.isObservable(value) ? value : rxjs.of(value)); }), operators.switchMap(function (obs) { return obs; }), operators.withLatestFrom(this.table$), operators.map(function (_c) {
422
- var _d = __read(_c, 2), page = _d[0], table = _d[1];
423
- // determine last page
424
- var lastPage = Math.ceil(table.info.records / table.config.pagination.length) - 1;
425
- // determine max/min position
426
- return +page < 0 ? 0 : +page > lastPage ? lastPage : +page;
427
- }), operators.shareReplay(1));
428
- this.colspan$ = this.tableConfig$.pipe(operators.map(function (config) { return Object.values(config.columns).filter(function (value) { return value.hidden !== true; }).length; }));
429
- this.columnOrder = function (a, b) {
430
- return (a.value.order || 0) - (b.value.order || 0);
431
- };
432
- }
433
- Object.defineProperty(CoreComponent.prototype, "loading", {
434
- set: function (value) {
435
- this._loading$.next(value);
436
- },
437
- enumerable: false,
438
- configurable: true
439
- });
440
- Object.defineProperty(CoreComponent.prototype, "page", {
441
- set: function (value) {
442
- this._currentPage$.next(value);
443
- },
444
- enumerable: false,
445
- configurable: true
446
- });
447
- Object.defineProperty(CoreComponent.prototype, "search", {
448
- set: function (value) {
449
- this._searchBy$.next(value);
450
- },
451
- enumerable: false,
452
- configurable: true
453
- });
454
- Object.defineProperty(CoreComponent.prototype, "config", {
455
- set: function (value) {
456
- this._tableConfig$.next(value);
457
- },
458
- enumerable: false,
459
- configurable: true
460
- });
461
- Object.defineProperty(CoreComponent.prototype, "data", {
462
- set: function (value) {
463
- this._data$.next(value);
464
- },
465
- enumerable: false,
466
- configurable: true
467
- });
468
- Object.defineProperty(CoreComponent.prototype, "loading$", {
469
- get: function () {
470
- return this._loading$.pipe(operators.startWith(false), operators.map(function (value) { return (rxjs.isObservable(value) ? value : rxjs.of(value)); }), operators.switchMap(function (obs) { return obs; }), operators.shareReplay(1));
471
- },
472
- enumerable: false,
473
- configurable: true
474
- });
475
- CoreComponent.prototype.sort = function (property) {
476
- var _a, _b;
477
- var newSortOrder = ((_a = this._sortBy) === null || _a === void 0 ? void 0 : _a.sortBy) !== property || ((_b = this._sortBy) === null || _b === void 0 ? void 0 : _b.sortByOrder) === Order.DESC || !this._sortBy.sortByOrder
478
- ? Order.ASC
479
- : Order.DESC;
480
- var newSortBy = {
481
- sortBy: property,
482
- sortByOrder: newSortOrder,
483
- };
484
- this.sortBy$.next(newSortBy);
485
- this._sortBy = newSortBy;
486
- };
487
- return CoreComponent;
488
- }());
489
- CoreComponent.decorators = [
490
- { type: i0.Component, args: [{
491
- selector: 'angular-generic-table',
492
- template: "<table class=\"table text-nowrap mb-0\" id=\"agreementList_table\">\n <thead>\n <tr *ngIf=\"{\n config:(tableConfig$ | async)!,\n loading: loading$ | async\n } as table\">\n <ng-container *ngFor=\"let column of table.config.columns | keyvalue: columnOrder\">\n <th\n *ngIf=\"!column.value?.hidden\"\n ngClass=\"{{ column.value?.sortable ? 'sort ' : '' }} {{ sortBy$ | async | sortClass: column.key }} {{\n (column.key | dashCase) + '-column'\n }} {{column.value.class}}\"\n [class.disabled]=\"table.loading\"\n (click)=\"table.loading || !column.value.sortable || sort(column.key)\"\n >\n <span>{{ column.value?.header || column.key }}</span>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody *ngIf=\"loading$ | async; else tableContent\">\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-loading\"></ng-content>\n </td>\n </tr>\n </tbody>\n</table>\n<ng-template #tableContent>\n <ng-container\n *ngIf=\"(table$ | async)! as table\"\n >\n <tbody id=\"agreementList_tableContent\" *ngIf=\"table!.data!.length > 0; else noData\">\n <tr *ngFor=\"let row of table!.data![(currentPage$ | async) || 0]; let i = index\" [attr.id]=\"'tableRow_' + i\">\n <ng-container *ngFor=\"let column of table.config?.columns | keyvalue: columnOrder\">\n <td *ngIf=\"!column.value?.hidden\" ngClass=\"{{(column.key | dashCase) + '-column'}} {{column.value.class}}\">\n <ng-container [ngTemplateOutlet]=\"(searchBy$ | async) && !table.config.columns[column.key].templateRef ? highlighted:\n table.config.columns[column.key].templateRef ? templateRef :\n rawData\" [ngTemplateOutletContext]=\"{row: row, column: column, search: (searchBy$ | async), templateRef: table.config.columns[column.key].templateRef, index: i}\"></ng-container></td>\n </ng-container>\n </tr>\n </tbody>\n </ng-container>\n</ng-template>\n<ng-template #noData>\n <tbody>\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-no-data\"></ng-content>\n </td>\n </tr>\n </tbody>\n</ng-template>\n<ng-template #highlighted let-row=\"row\" let-column=\"column\" let-search=\"search\">\n <div [innerHTML]=\"(row[column.key] | highlight: search)\"></div>\n</ng-template>\n<ng-template #rawData let-row=\"row\" let-column=\"column\">\n {{row[column.key]}}\n</ng-template>\n<ng-template #templateRef let-row=\"row\" let-column=\"column\" let-index=\"index\" let-templateRef=\"templateRef\">\n <ng-container [ngTemplateOutlet]=\"templateRef\" [ngTemplateOutletContext]=\"{row: row, col: column, index: index}\"></ng-container>\n</ng-template>\n",
493
- changeDetection: i0.ChangeDetectionStrategy.OnPush
494
- },] }
495
- ];
496
- CoreComponent.ctorParameters = function () { return []; };
497
- CoreComponent.propDecorators = {
498
- loading: [{ type: i0.Input }],
499
- page: [{ type: i0.Input }],
500
- search: [{ type: i0.Input }],
501
- config: [{ type: i0.Input }],
502
- data: [{ type: i0.Input }]
503
- };
504
-
505
- var SortClassPipe = /** @class */ (function () {
506
- function SortClassPipe() {
507
- }
508
- SortClassPipe.prototype.transform = function (selection, property) {
509
- return (selection === null || selection === void 0 ? void 0 : selection.sortBy) === property ? 'sort-' + selection.sortByOrder : '';
510
- };
511
- return SortClassPipe;
512
- }());
513
- SortClassPipe.decorators = [
514
- { type: i0.Pipe, args: [{
515
- name: 'sortClass',
516
- },] }
517
- ];
518
-
519
- var DashCasePipe = /** @class */ (function () {
520
- function DashCasePipe() {
521
- }
522
- DashCasePipe.prototype.transform = function (s) {
523
- return dashed(s);
524
- };
525
- return DashCasePipe;
526
- }());
527
- DashCasePipe.decorators = [
528
- { type: i0.Pipe, args: [{
529
- name: 'dashCase'
530
- },] }
531
- ];
532
-
533
- var HighlightPipe = /** @class */ (function () {
534
- function HighlightPipe() {
535
- }
536
- HighlightPipe.prototype.transform = function (text, searchTerm) {
537
- if (!searchTerm) {
538
- return text;
539
- }
540
- var haystackAlwaysString = text + '';
541
- var highlightedText = haystackAlwaysString; // fallback
542
- var searchPattern;
543
- try {
544
- searchPattern = new RegExp('(' +
545
- // @ts-ignore
546
- searchTerm
547
- .toLowerCase()
548
- .match(/".*?"|[^ ]+/g) // extract words
549
- .map(function (needle) { return needle.replace(/"(.*?)"/, '$1'); } // strip away '"'
550
- )
551
- .join('|') + // combine words
552
- ')', 'ig');
553
- }
554
- catch (error) {
555
- return highlightedText;
556
- }
557
- var containsTagPattern = /(<.*?>)(.*)(<\/.*?>)/gi;
558
- var containsTagMatches = containsTagPattern.exec(haystackAlwaysString);
559
- if (containsTagMatches) {
560
- // tag exists in haystack
561
- highlightedText =
562
- containsTagMatches[1] +
563
- containsTagMatches[2].replace(searchPattern, '<span class="gt-highlight-search">$1</span>') +
564
- containsTagMatches[3];
565
- }
566
- else {
567
- highlightedText = haystackAlwaysString.replace(searchPattern, '<span class="gt-highlight-search">$1</span>');
568
- }
569
- return highlightedText;
570
- };
571
- return HighlightPipe;
572
- }());
573
- HighlightPipe.decorators = [
574
- { type: i0.Pipe, args: [{
575
- name: 'highlight'
576
- },] }
577
- ];
578
-
579
- var GenericTableCoreModule = /** @class */ (function () {
580
- function GenericTableCoreModule() {
581
- }
582
- return GenericTableCoreModule;
583
- }());
584
- GenericTableCoreModule.decorators = [
585
- { type: i0.NgModule, args: [{
586
- declarations: [CoreComponent, SortClassPipe, DashCasePipe, HighlightPipe],
587
- imports: [common.CommonModule],
588
- exports: [CoreComponent]
589
- },] }
590
- ];
591
-
592
- /*
593
- * Public API Surface of core
594
- */
595
-
596
- /**
597
- * Generated bundle index. Do not edit.
598
- */
599
-
600
- exports.CoreComponent = CoreComponent;
601
- exports.CoreService = CoreService;
602
- exports.GenericTableCoreModule = GenericTableCoreModule;
603
- exports.ɵa = SortClassPipe;
604
- exports.ɵb = DashCasePipe;
605
- exports.ɵc = HighlightPipe;
606
-
607
- Object.defineProperty(exports, '__esModule', { value: true });
608
-
609
- })));
610
- //# sourceMappingURL=angular-generic-table-core.umd.js.map