@den4ik92/ng2-smart-table 19.0.4 → 19.0.6
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/fesm2022/den4ik92-ng2-smart-table.mjs +248 -113
- package/fesm2022/den4ik92-ng2-smart-table.mjs.map +1 -1
- package/lib/components/table-columns-editor/column-editor.directive.d.ts +19 -0
- package/lib/components/table-columns-editor/table-columns-editor.component.d.ts +19 -0
- package/lib/lib/grid.d.ts +4 -4
- package/lib/lib/interfaces/smart-table.models.d.ts +3 -3
- package/lib/ng2-smart-table.component.d.ts +2 -2
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { output, Component, Input,
|
|
2
|
+
import { output, Component, Input, input, signal, effect, computed, inject, ElementRef, Directive, ViewContainerRef, ViewChild, ChangeDetectionStrategy } from '@angular/core';
|
|
3
|
+
import { Overlay, OverlayConfig } from '@angular/cdk/overlay';
|
|
4
|
+
import { ComponentPortal } from '@angular/cdk/portal';
|
|
3
5
|
import { Subject } from 'rxjs';
|
|
6
|
+
import { takeUntil, debounceTime, distinctUntilChanged, skip } from 'rxjs/operators';
|
|
7
|
+
import { moveItemInArray, CdkDropList, CdkDrag, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
|
|
4
8
|
import * as i1 from '@angular/forms';
|
|
5
9
|
import { FormsModule, UntypedFormControl, ReactiveFormsModule, NgControl } from '@angular/forms';
|
|
6
10
|
import { NgComponentOutlet } from '@angular/common';
|
|
7
|
-
import { debounceTime, distinctUntilChanged, skip } from 'rxjs/operators';
|
|
8
11
|
|
|
9
12
|
function prepareValue(value) { return value; }
|
|
10
13
|
class Cell {
|
|
@@ -171,6 +174,246 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
171
174
|
type: Input
|
|
172
175
|
}] } });
|
|
173
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Extending object that entered in first argument.
|
|
179
|
+
*
|
|
180
|
+
* Returns extended object or false if have no target object or incorrect type.
|
|
181
|
+
*
|
|
182
|
+
* If you wish to clone source object (without modify it), just use empty new
|
|
183
|
+
* object as first argument, like this:
|
|
184
|
+
* deepExtend({}, yourObj_1, [yourObj_N]);
|
|
185
|
+
*/
|
|
186
|
+
const deepExtend = function (...objects) {
|
|
187
|
+
if (arguments.length < 1 || typeof arguments[0] !== 'object') {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (arguments.length < 2) {
|
|
191
|
+
return arguments[0];
|
|
192
|
+
}
|
|
193
|
+
const target = arguments[0];
|
|
194
|
+
// convert arguments to array and cut off target object
|
|
195
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
|
196
|
+
let val, src;
|
|
197
|
+
args.forEach((obj) => {
|
|
198
|
+
// skip argument if it is array or isn't object
|
|
199
|
+
if (typeof obj !== 'object' || Array.isArray(obj)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
Object.keys(obj).forEach(function (key) {
|
|
203
|
+
src = target[key]; // source value
|
|
204
|
+
val = obj[key]; // new value
|
|
205
|
+
// recursion prevention
|
|
206
|
+
if (val === target) {
|
|
207
|
+
return;
|
|
208
|
+
/**
|
|
209
|
+
* if new value isn't object then just overwrite by new value
|
|
210
|
+
* instead of extending.
|
|
211
|
+
*/
|
|
212
|
+
}
|
|
213
|
+
else if (typeof val !== 'object' || val === null) {
|
|
214
|
+
target[key] = val;
|
|
215
|
+
return;
|
|
216
|
+
// just clone arrays (and recursive clone objects inside)
|
|
217
|
+
}
|
|
218
|
+
else if (Array.isArray(val)) {
|
|
219
|
+
target[key] = [...val];
|
|
220
|
+
return;
|
|
221
|
+
// overwrite by new value if source isn't object or array
|
|
222
|
+
}
|
|
223
|
+
else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
|
|
224
|
+
target[key] = deepExtend({}, val);
|
|
225
|
+
return;
|
|
226
|
+
// source value and new value is objects both, extending...
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
target[key] = deepExtend(src, val);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
return target;
|
|
235
|
+
};
|
|
236
|
+
class Deferred {
|
|
237
|
+
constructor() {
|
|
238
|
+
this.promise = new Promise((resolve, reject) => {
|
|
239
|
+
this.resolve = resolve;
|
|
240
|
+
this.reject = reject;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// getDeepFromObject({result: {data: 1}}, 'result.data', 2); // returns 1
|
|
245
|
+
function getDeepFromObject(object = {}, name, defaultValue = null) {
|
|
246
|
+
try {
|
|
247
|
+
let level = deepExtend({}, object);
|
|
248
|
+
const keys = name.split('.');
|
|
249
|
+
if (keys.length === 1) {
|
|
250
|
+
return level[keys[0]] ?? defaultValue;
|
|
251
|
+
}
|
|
252
|
+
keys.forEach((k) => {
|
|
253
|
+
if (level && typeof level[k] !== 'undefined') {
|
|
254
|
+
level = level[k];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return defaultValue;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function getPageForRowIndex(index, perPage) {
|
|
263
|
+
// we need to add 1 to convert 0-based index to 1-based page number.
|
|
264
|
+
return Math.floor(index / perPage) + 1;
|
|
265
|
+
}
|
|
266
|
+
function cloneArrayOfObject(array) {
|
|
267
|
+
return array.map((obj) => Object.assign({}, obj));
|
|
268
|
+
}
|
|
269
|
+
function setLocalStorage(key, value) {
|
|
270
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
271
|
+
}
|
|
272
|
+
function getLocalStorage(key) {
|
|
273
|
+
const valueString = localStorage.getItem(key);
|
|
274
|
+
if (!valueString) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
return JSON.parse(valueString);
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
class TableColumnsEditorComponent {
|
|
286
|
+
constructor() {
|
|
287
|
+
this.infoText = "You can drag and drop columns as you wish and also disable unnecessary ones.";
|
|
288
|
+
this.grid = input();
|
|
289
|
+
this.close = input.required();
|
|
290
|
+
this.currentState = [];
|
|
291
|
+
this.stateHasChanged = signal(false);
|
|
292
|
+
effect(() => {
|
|
293
|
+
this.currentState = cloneArrayOfObject(this.grid()?.currentColumnsSortState || []);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
resetChanges() {
|
|
297
|
+
this.currentState = cloneArrayOfObject(this.grid()?.currentColumnsSortState || []);
|
|
298
|
+
this.stateHasChanged.set(false);
|
|
299
|
+
}
|
|
300
|
+
drop(event) {
|
|
301
|
+
moveItemInArray(this.currentState, event.previousIndex, event.currentIndex);
|
|
302
|
+
this.updateChangedState();
|
|
303
|
+
}
|
|
304
|
+
setVisibility(index) {
|
|
305
|
+
this.currentState[index].hide = !this.currentState[index].hide;
|
|
306
|
+
this.updateChangedState();
|
|
307
|
+
}
|
|
308
|
+
setAndUpdate() {
|
|
309
|
+
this.grid()?.applyColumnsSortState(this.currentState);
|
|
310
|
+
this.close()();
|
|
311
|
+
this.stateHasChanged.set(false);
|
|
312
|
+
}
|
|
313
|
+
updateChangedState() {
|
|
314
|
+
this.stateHasChanged.set(JSON.stringify(this.grid()?.currentColumnsSortState) !== JSON.stringify(this.currentState));
|
|
315
|
+
}
|
|
316
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TableColumnsEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
317
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TableColumnsEditorComponent, isStandalone: true, selector: "ngx-table-columns-editor", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: false, transformFunction: null }, close: { classPropertyName: "close", publicName: "close", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<div class=\"sort-card\">\n <div class=\"sort-card-header\">\n <h6>Table columns setup</h6>\n </div>\n <div class=\"sort-card-body\">\n <div\n class=\"list\"\n cdkDropList\n [cdkDropListData]=\"currentState\"\n (cdkDropListDropped)=\"drop($event)\"\n >\n @for (column of currentState; track column.key; let i = $index) {\n\n <div\n cdkDrag\n [cdkDragLockAxis]=\"'y'\"\n [cdkDragStartDelay]=\"300\"\n [cdkDragDisabled]=\"column.moveDisabled\"\n class=\"drag-row\"\n #dragRow\n [style.--drag-row-height]=\"50\"\n >\n <div class=\"drag-placeholder\" *cdkDragPlaceholder></div>\n <div class=\"index-cell\">\n {{ i + 1 }}\n </div>\n <label class=\"sort-column-checkbox-wrap\" [for]=\"'sort-column-checkbox-' + i\">\n <span></span>\n <input\n [disabled]=\"column.moveDisabled\"\n [id]=\"'sort-column-checkbox-' + i\"\n title=\"Active state. If checked the column will be displayed\"\n type=\"checkbox\"\n class=\"sort-column-checkbox-input\"\n [checked]=\"!column.hide\"\n (change)=\"setVisibility(i)\"\n />\n <span></span>\n </label>\n {{ column.title }}\n </div>\n }\n </div>\n </div>\n @if (stateHasChanged()) {\n <div class=\"sort-card-footer\">\n <button class=\"reset-button\" (click)=\"resetChanges()\">reset</button>\n <button class=\"update-button\" (click)=\"setAndUpdate()\">Update</button>\n </div>\n }\n</div>\n", styles: [".list{overflow:auto;display:flex;flex-direction:column;gap:.3rem;max-height:100%}.drag-row{border:solid 1px var(--drag-row-border-color, #ccc);border-radius:.3rem;display:flex;align-items:center;box-sizing:border-box;cursor:grab;background:var(--drag-row-background, #ffffff);box-shadow:0 0 6px 1px #ebebeb33}.drag-row.cdk-drag-disabled{filter:opacity(.5);cursor:not-allowed}.drag-row .index-cell{min-width:2.2rem;border-right:1px solid var(--drag-row-border-color, #ccc)}.drag-row>div{padding:.3rem}.drag-row .sort-column-checkbox-wrap{margin:0 .5rem}.cdk-drag-preview{box-sizing:border-box;border-radius:.3rem;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.list.cdk-drop-list-dragging .drag-row:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.drag-placeholder{background:var(--drag-placeholder-background, #ccc);border:dotted 3px #999;min-height:var(--drag-row-heightpx, 2.5rem);transition:transform .25s cubic-bezier(0,0,.2,1)}.overlay-card nb-card-body{padding:.25rem;max-height:100%}.sort-card{box-shadow:0 0 6px 1px #0003;min-width:18rem;padding:.25rem;max-height:80dvh;background:var(--sort-card-background, #ffffff);border-radius:.5rem}.sort-card .sort-card-header{display:flex;align-items:center;gap:1rem;padding:1rem;border-bottom:1px solid var(--sort-card-header-divider-color, #edf1f7)}.sort-card .sort-card-header h6{margin:0}.sort-card .sort-card-body{padding:.5rem 0}.sort-card .sort-card-footer{border-top:1px solid var(--sort-card-header-divider-color, #edf1f7);display:flex;align-items:center;justify-content:end;gap:1rem;padding:1rem}.sort-card .sort-card-footer .update-button,.sort-card .sort-card-footer .reset-button{border-radius:.3rem;padding:.4rem 1rem;border:none;color:#fff;font-size:.875rem;font-weight:700;text-transform:uppercase}.sort-card .sort-card-footer .update-button{background-color:#36f}.sort-card .sort-card-footer .update-button:hover{background-color:#598bff}.sort-card .sort-card-footer .reset-button{background-color:#ff3d71}.sort-card .sort-card-footer .reset-button:hover{background-color:#ff708d}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }] }); }
|
|
318
|
+
}
|
|
319
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TableColumnsEditorComponent, decorators: [{
|
|
320
|
+
type: Component,
|
|
321
|
+
args: [{ selector: "ngx-table-columns-editor", imports: [CdkDropList, CdkDrag, CdkDragPlaceholder], template: "<div class=\"sort-card\">\n <div class=\"sort-card-header\">\n <h6>Table columns setup</h6>\n </div>\n <div class=\"sort-card-body\">\n <div\n class=\"list\"\n cdkDropList\n [cdkDropListData]=\"currentState\"\n (cdkDropListDropped)=\"drop($event)\"\n >\n @for (column of currentState; track column.key; let i = $index) {\n\n <div\n cdkDrag\n [cdkDragLockAxis]=\"'y'\"\n [cdkDragStartDelay]=\"300\"\n [cdkDragDisabled]=\"column.moveDisabled\"\n class=\"drag-row\"\n #dragRow\n [style.--drag-row-height]=\"50\"\n >\n <div class=\"drag-placeholder\" *cdkDragPlaceholder></div>\n <div class=\"index-cell\">\n {{ i + 1 }}\n </div>\n <label class=\"sort-column-checkbox-wrap\" [for]=\"'sort-column-checkbox-' + i\">\n <span></span>\n <input\n [disabled]=\"column.moveDisabled\"\n [id]=\"'sort-column-checkbox-' + i\"\n title=\"Active state. If checked the column will be displayed\"\n type=\"checkbox\"\n class=\"sort-column-checkbox-input\"\n [checked]=\"!column.hide\"\n (change)=\"setVisibility(i)\"\n />\n <span></span>\n </label>\n {{ column.title }}\n </div>\n }\n </div>\n </div>\n @if (stateHasChanged()) {\n <div class=\"sort-card-footer\">\n <button class=\"reset-button\" (click)=\"resetChanges()\">reset</button>\n <button class=\"update-button\" (click)=\"setAndUpdate()\">Update</button>\n </div>\n }\n</div>\n", styles: [".list{overflow:auto;display:flex;flex-direction:column;gap:.3rem;max-height:100%}.drag-row{border:solid 1px var(--drag-row-border-color, #ccc);border-radius:.3rem;display:flex;align-items:center;box-sizing:border-box;cursor:grab;background:var(--drag-row-background, #ffffff);box-shadow:0 0 6px 1px #ebebeb33}.drag-row.cdk-drag-disabled{filter:opacity(.5);cursor:not-allowed}.drag-row .index-cell{min-width:2.2rem;border-right:1px solid var(--drag-row-border-color, #ccc)}.drag-row>div{padding:.3rem}.drag-row .sort-column-checkbox-wrap{margin:0 .5rem}.cdk-drag-preview{box-sizing:border-box;border-radius:.3rem;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.list.cdk-drop-list-dragging .drag-row:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.drag-placeholder{background:var(--drag-placeholder-background, #ccc);border:dotted 3px #999;min-height:var(--drag-row-heightpx, 2.5rem);transition:transform .25s cubic-bezier(0,0,.2,1)}.overlay-card nb-card-body{padding:.25rem;max-height:100%}.sort-card{box-shadow:0 0 6px 1px #0003;min-width:18rem;padding:.25rem;max-height:80dvh;background:var(--sort-card-background, #ffffff);border-radius:.5rem}.sort-card .sort-card-header{display:flex;align-items:center;gap:1rem;padding:1rem;border-bottom:1px solid var(--sort-card-header-divider-color, #edf1f7)}.sort-card .sort-card-header h6{margin:0}.sort-card .sort-card-body{padding:.5rem 0}.sort-card .sort-card-footer{border-top:1px solid var(--sort-card-header-divider-color, #edf1f7);display:flex;align-items:center;justify-content:end;gap:1rem;padding:1rem}.sort-card .sort-card-footer .update-button,.sort-card .sort-card-footer .reset-button{border-radius:.3rem;padding:.4rem 1rem;border:none;color:#fff;font-size:.875rem;font-weight:700;text-transform:uppercase}.sort-card .sort-card-footer .update-button{background-color:#36f}.sort-card .sort-card-footer .update-button:hover{background-color:#598bff}.sort-card .sort-card-footer .reset-button{background-color:#ff3d71}.sort-card .sort-card-footer .reset-button:hover{background-color:#ff708d}\n"] }]
|
|
322
|
+
}], ctorParameters: () => [] });
|
|
323
|
+
|
|
324
|
+
class SmartTableColumnEditorDirective {
|
|
325
|
+
constructor() {
|
|
326
|
+
this.tableComponent = input();
|
|
327
|
+
this.grid = computed(() => {
|
|
328
|
+
return this.tableComponent()?.grid;
|
|
329
|
+
});
|
|
330
|
+
this.overlay = inject(Overlay);
|
|
331
|
+
this.elementRef = inject(ElementRef);
|
|
332
|
+
this.destroy$ = new Subject();
|
|
333
|
+
}
|
|
334
|
+
ngOnDestroy() {
|
|
335
|
+
this.overlayRef?.dispose();
|
|
336
|
+
this.destroy$.next();
|
|
337
|
+
this.destroy$.complete();
|
|
338
|
+
}
|
|
339
|
+
showDropdown() {
|
|
340
|
+
this.overlayRef = this.overlay.create(this.getOverlayConfig());
|
|
341
|
+
const componentPortal = new ComponentPortal(TableColumnsEditorComponent);
|
|
342
|
+
const dropdownRef = this.overlayRef.attach(componentPortal);
|
|
343
|
+
dropdownRef.setInput("grid", this.grid());
|
|
344
|
+
dropdownRef.setInput("close", this.hide.bind(this));
|
|
345
|
+
this.overlayRef?.backdropClick().pipe(takeUntil(this.destroy$)).subscribe(() => this.hide());
|
|
346
|
+
}
|
|
347
|
+
hide() {
|
|
348
|
+
this.overlayRef?.detach();
|
|
349
|
+
this.overlayRef?.dispose();
|
|
350
|
+
this.destroy$.next();
|
|
351
|
+
}
|
|
352
|
+
buttonClick() {
|
|
353
|
+
this.showDropdown();
|
|
354
|
+
}
|
|
355
|
+
getOverlayConfig() {
|
|
356
|
+
const positionStrategy = this.overlay
|
|
357
|
+
.position()
|
|
358
|
+
.flexibleConnectedTo(this.elementRef)
|
|
359
|
+
.withPush(false)
|
|
360
|
+
.withPositions([
|
|
361
|
+
{
|
|
362
|
+
originX: "center",
|
|
363
|
+
originY: "bottom",
|
|
364
|
+
overlayX: "end",
|
|
365
|
+
overlayY: "top",
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
originX: "center",
|
|
369
|
+
originY: "bottom",
|
|
370
|
+
overlayX: "center",
|
|
371
|
+
overlayY: "top",
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
originX: "center",
|
|
375
|
+
originY: "bottom",
|
|
376
|
+
overlayX: "start",
|
|
377
|
+
overlayY: "top",
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
originX: "center",
|
|
381
|
+
originY: "top",
|
|
382
|
+
overlayX: "start",
|
|
383
|
+
overlayY: "bottom",
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
originX: "center",
|
|
387
|
+
originY: "top",
|
|
388
|
+
overlayX: "center",
|
|
389
|
+
overlayY: "bottom",
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
originX: "center",
|
|
393
|
+
originY: "top",
|
|
394
|
+
overlayX: "start",
|
|
395
|
+
overlayY: "bottom",
|
|
396
|
+
},
|
|
397
|
+
]);
|
|
398
|
+
return new OverlayConfig({
|
|
399
|
+
positionStrategy: positionStrategy,
|
|
400
|
+
hasBackdrop: true,
|
|
401
|
+
backdropClass: "cdk-overlay-transparent-backdrop",
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SmartTableColumnEditorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
405
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.3", type: SmartTableColumnEditorDirective, isStandalone: true, selector: "[smartTableColumnEditor]", inputs: { tableComponent: { classPropertyName: "tableComponent", publicName: "tableComponent", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "buttonClick()" } }, ngImport: i0 }); }
|
|
406
|
+
}
|
|
407
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: SmartTableColumnEditorDirective, decorators: [{
|
|
408
|
+
type: Directive,
|
|
409
|
+
args: [{
|
|
410
|
+
selector: "[smartTableColumnEditor]",
|
|
411
|
+
host: {
|
|
412
|
+
"(click)": "buttonClick()",
|
|
413
|
+
},
|
|
414
|
+
}]
|
|
415
|
+
}] });
|
|
416
|
+
|
|
174
417
|
class Row {
|
|
175
418
|
constructor(index, data, _dataSet) {
|
|
176
419
|
this.index = index;
|
|
@@ -361,114 +604,6 @@ class LocalPager {
|
|
|
361
604
|
}
|
|
362
605
|
}
|
|
363
606
|
|
|
364
|
-
/**
|
|
365
|
-
* Extending object that entered in first argument.
|
|
366
|
-
*
|
|
367
|
-
* Returns extended object or false if have no target object or incorrect type.
|
|
368
|
-
*
|
|
369
|
-
* If you wish to clone source object (without modify it), just use empty new
|
|
370
|
-
* object as first argument, like this:
|
|
371
|
-
* deepExtend({}, yourObj_1, [yourObj_N]);
|
|
372
|
-
*/
|
|
373
|
-
const deepExtend = function (...objects) {
|
|
374
|
-
if (arguments.length < 1 || typeof arguments[0] !== 'object') {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
if (arguments.length < 2) {
|
|
378
|
-
return arguments[0];
|
|
379
|
-
}
|
|
380
|
-
const target = arguments[0];
|
|
381
|
-
// convert arguments to array and cut off target object
|
|
382
|
-
const args = Array.prototype.slice.call(arguments, 1);
|
|
383
|
-
let val, src;
|
|
384
|
-
args.forEach((obj) => {
|
|
385
|
-
// skip argument if it is array or isn't object
|
|
386
|
-
if (typeof obj !== 'object' || Array.isArray(obj)) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
Object.keys(obj).forEach(function (key) {
|
|
390
|
-
src = target[key]; // source value
|
|
391
|
-
val = obj[key]; // new value
|
|
392
|
-
// recursion prevention
|
|
393
|
-
if (val === target) {
|
|
394
|
-
return;
|
|
395
|
-
/**
|
|
396
|
-
* if new value isn't object then just overwrite by new value
|
|
397
|
-
* instead of extending.
|
|
398
|
-
*/
|
|
399
|
-
}
|
|
400
|
-
else if (typeof val !== 'object' || val === null) {
|
|
401
|
-
target[key] = val;
|
|
402
|
-
return;
|
|
403
|
-
// just clone arrays (and recursive clone objects inside)
|
|
404
|
-
}
|
|
405
|
-
else if (Array.isArray(val)) {
|
|
406
|
-
target[key] = [...val];
|
|
407
|
-
return;
|
|
408
|
-
// overwrite by new value if source isn't object or array
|
|
409
|
-
}
|
|
410
|
-
else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
|
|
411
|
-
target[key] = deepExtend({}, val);
|
|
412
|
-
return;
|
|
413
|
-
// source value and new value is objects both, extending...
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
target[key] = deepExtend(src, val);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
return target;
|
|
422
|
-
};
|
|
423
|
-
class Deferred {
|
|
424
|
-
constructor() {
|
|
425
|
-
this.promise = new Promise((resolve, reject) => {
|
|
426
|
-
this.resolve = resolve;
|
|
427
|
-
this.reject = reject;
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
// getDeepFromObject({result: {data: 1}}, 'result.data', 2); // returns 1
|
|
432
|
-
function getDeepFromObject(object = {}, name, defaultValue = null) {
|
|
433
|
-
try {
|
|
434
|
-
let level = deepExtend({}, object);
|
|
435
|
-
const keys = name.split('.');
|
|
436
|
-
if (keys.length === 1) {
|
|
437
|
-
return level[keys[0]] ?? defaultValue;
|
|
438
|
-
}
|
|
439
|
-
keys.forEach((k) => {
|
|
440
|
-
if (level && typeof level[k] !== 'undefined') {
|
|
441
|
-
level = level[k];
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
catch {
|
|
446
|
-
return defaultValue;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
function getPageForRowIndex(index, perPage) {
|
|
450
|
-
// we need to add 1 to convert 0-based index to 1-based page number.
|
|
451
|
-
return Math.floor(index / perPage) + 1;
|
|
452
|
-
}
|
|
453
|
-
function cloneArrayOfObject(array) {
|
|
454
|
-
return array.map((obj) => Object.assign({}, obj));
|
|
455
|
-
}
|
|
456
|
-
function setLocalStorage(key, value) {
|
|
457
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
458
|
-
}
|
|
459
|
-
function getLocalStorage(key) {
|
|
460
|
-
const valueString = localStorage.getItem(key);
|
|
461
|
-
if (!valueString) {
|
|
462
|
-
return null;
|
|
463
|
-
}
|
|
464
|
-
try {
|
|
465
|
-
return JSON.parse(valueString);
|
|
466
|
-
}
|
|
467
|
-
catch {
|
|
468
|
-
return null;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
607
|
class LocalDataSource extends DataSource {
|
|
473
608
|
constructor(data = []) {
|
|
474
609
|
super();
|
|
@@ -1386,7 +1521,7 @@ class Grid {
|
|
|
1386
1521
|
key: column.key,
|
|
1387
1522
|
title: column.title,
|
|
1388
1523
|
hide: !!column.hide,
|
|
1389
|
-
|
|
1524
|
+
moveDisabled: !!column.moveDisabled,
|
|
1390
1525
|
}));
|
|
1391
1526
|
}
|
|
1392
1527
|
getMergedColumnStates(newState, columnsState) {
|
|
@@ -1396,7 +1531,7 @@ class Grid {
|
|
|
1396
1531
|
newState.forEach((state) => {
|
|
1397
1532
|
const fined = columnsSettings.find((column) => column.title === state.title && column.key === state.key);
|
|
1398
1533
|
if (fined) {
|
|
1399
|
-
filtered.push({ ...fined, hide: fined.
|
|
1534
|
+
filtered.push({ ...fined, hide: fined.moveDisabled ? fined.hide : state.hide });
|
|
1400
1535
|
}
|
|
1401
1536
|
});
|
|
1402
1537
|
// find new columns witch not exist in storage state
|
|
@@ -3528,5 +3663,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
3528
3663
|
* Generated bundle index. Do not edit.
|
|
3529
3664
|
*/
|
|
3530
3665
|
|
|
3531
|
-
export { Cell, Column, DataSource, DefaultEditor, DefaultFilter, Deferred, LocalDataSource, Ng2SmartTableComponent, Row, SmartTableOnChangedEventName };
|
|
3666
|
+
export { Cell, Column, DataSource, DefaultEditor, DefaultFilter, Deferred, LocalDataSource, Ng2SmartTableComponent, Row, SmartTableColumnEditorDirective, SmartTableOnChangedEventName };
|
|
3532
3667
|
//# sourceMappingURL=den4ik92-ng2-smart-table.mjs.map
|