@acorex/layout 1.3.90

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/README.md +2 -0
  2. package/acorex-layout.d.ts +6 -0
  3. package/acorex-layout.metadata.json +1 -0
  4. package/bundles/acorex-layout.umd.js +1479 -0
  5. package/bundles/acorex-layout.umd.js.map +1 -0
  6. package/bundles/acorex-layout.umd.min.js +16 -0
  7. package/bundles/acorex-layout.umd.min.js.map +1 -0
  8. package/esm2015/acorex-layout.js +7 -0
  9. package/esm2015/lib/widget-board/editors/widget-size-editor/widget-size.editor.js +49 -0
  10. package/esm2015/lib/widget-board/editors/widget-size-editor/widget-size.module.js +22 -0
  11. package/esm2015/lib/widget-board/widget-board.component.js +468 -0
  12. package/esm2015/lib/widget-board/widget-board.module.js +69 -0
  13. package/esm2015/lib/widget-board/widget-config.component.js +86 -0
  14. package/esm2015/lib/widget-board/widget-host.component.js +313 -0
  15. package/esm2015/lib/widget-board/widget-save.component.js +79 -0
  16. package/esm2015/lib/widget-board/widget.class.js +123 -0
  17. package/esm2015/public-api.js +7 -0
  18. package/esm5/acorex-layout.js +7 -0
  19. package/esm5/lib/widget-board/editors/widget-size-editor/widget-size.editor.js +52 -0
  20. package/esm5/lib/widget-board/editors/widget-size-editor/widget-size.module.js +23 -0
  21. package/esm5/lib/widget-board/widget-board.component.js +494 -0
  22. package/esm5/lib/widget-board/widget-board.module.js +70 -0
  23. package/esm5/lib/widget-board/widget-config.component.js +90 -0
  24. package/esm5/lib/widget-board/widget-host.component.js +349 -0
  25. package/esm5/lib/widget-board/widget-save.component.js +83 -0
  26. package/esm5/lib/widget-board/widget.class.js +134 -0
  27. package/esm5/public-api.js +7 -0
  28. package/fesm2015/acorex-layout.js +1171 -0
  29. package/fesm2015/acorex-layout.js.map +1 -0
  30. package/fesm5/acorex-layout.js +1256 -0
  31. package/fesm5/acorex-layout.js.map +1 -0
  32. package/lib/widget-board/editors/widget-size-editor/widget-size.editor.d.ts +16 -0
  33. package/lib/widget-board/editors/widget-size-editor/widget-size.module.d.ts +3 -0
  34. package/lib/widget-board/widget-board.component.d.ts +58 -0
  35. package/lib/widget-board/widget-board.module.d.ts +6 -0
  36. package/lib/widget-board/widget-config.component.d.ts +20 -0
  37. package/lib/widget-board/widget-host.component.d.ts +48 -0
  38. package/lib/widget-board/widget-save.component.d.ts +16 -0
  39. package/lib/widget-board/widget.class.d.ts +53 -0
  40. package/package.json +21 -0
  41. package/public-api.d.ts +6 -0
@@ -0,0 +1,1171 @@
1
+ import { __decorate, __metadata, __awaiter } from 'tslib';
2
+ import { EventEmitter, ChangeDetectorRef, ViewChild, Component, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, ComponentFactoryResolver, Input, Output, ViewContainerRef, HostBinding, NgZone, ViewChildren, QueryList, NgModule } from '@angular/core';
3
+ import { propertyEditor, AXBasePopupPageComponent, AXValidationFormComponent, AXPropertyDecorators, AXPopupService, AXLoadingService, AXProperyEditorComponent, AXNumberBoxModule, AXSearchBoxModule, AXLoadingModule, AXProppertyEditorModule, AXPageModule, AXToolbarModule, AXLabelModule, AXTextAreaModule, AXFieldsetModule, AXTextBoxModule, AXFormGroupModule, AXTabStripModule, AXCheckBoxModule, AXMenuModule, AXValidationModule } from '@acorex/components';
4
+ import { AXTranslator, AXHtmlUtil, AXObjectUtil, AXRenderService, AXClientRec, AXTranslatorModule } from '@acorex/core';
5
+ import { Observable } from 'rxjs';
6
+ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
7
+ import { CommonModule } from '@angular/common';
8
+ import { RouterModule } from '@angular/router';
9
+ import { FormsModule } from '@angular/forms';
10
+
11
+ const ɵ0 = () => {
12
+ return [1, 2, 3, 5, 10, 20, 30, 60].map(c => ({
13
+ id: 60000 * c,
14
+ text: AXTranslator.get('dateTime.duration.format_minute').replace('{0}', c.toString())
15
+ }));
16
+ };
17
+ // @dynamic
18
+ class AXWidgetComponent {
19
+ constructor() {
20
+ this.uid = AXHtmlUtil.getUID();
21
+ this.onBusyChanged = new EventEmitter();
22
+ this._isBusy = true;
23
+ this.refreshRate = [{
24
+ id: 60000 * 5,
25
+ text: AXTranslator.get('dateTime.duration.format_minute').replace('{0}', '5')
26
+ }];
27
+ this.onConfiguredChanged = new EventEmitter();
28
+ this.onConfiguredChanged.subscribe(() => {
29
+ if (this.isConfigured === true && this.getRefreshRate()) {
30
+ this.restartRefreshTimer();
31
+ }
32
+ else {
33
+ this.stopRefreshTimer();
34
+ }
35
+ });
36
+ }
37
+ get isBusy() {
38
+ return this._isBusy;
39
+ }
40
+ set isBusy(v) {
41
+ if (v !== this._isBusy) {
42
+ const eventData = {
43
+ component: this,
44
+ oldValue: this._isBusy,
45
+ value: v
46
+ };
47
+ this._isBusy = v;
48
+ this.onBusyChanged.emit(eventData);
49
+ }
50
+ }
51
+ // ???
52
+ getRefreshRate() {
53
+ return Array.isArray(this.refreshRate) && this.refreshRate.length ? this.refreshRate[0].id : this.refreshRate;
54
+ }
55
+ startRefreshTimer() {
56
+ this.intervalId = window.setInterval(this.refresh.bind(this), this.getRefreshRate());
57
+ }
58
+ stopRefreshTimer() {
59
+ window.clearInterval(this.intervalId);
60
+ }
61
+ restartRefreshTimer() {
62
+ this.stopRefreshTimer();
63
+ this.startRefreshTimer();
64
+ }
65
+ ngOnDestroy() {
66
+ this.stopRefreshTimer();
67
+ }
68
+ redraw() {
69
+ }
70
+ refresh() {
71
+ this.restartRefreshTimer();
72
+ }
73
+ get isConfigured() {
74
+ return true;
75
+ }
76
+ setValue(name, value) {
77
+ this[name] = value;
78
+ this.onConfiguredChanged.emit();
79
+ }
80
+ getValue(name) {
81
+ var _a;
82
+ const val = this[name];
83
+ const config = this['__meta__'].config;
84
+ const runtime = (_a = config.props[name]) === null || _a === void 0 ? void 0 : _a.runtime;
85
+ if (runtime && this.provideValue) {
86
+ const res = this.provideValue({
87
+ name,
88
+ value: val,
89
+ uniqueName: config.uniqueName,
90
+ options: config.options,
91
+ });
92
+ if (this.provideValue instanceof Promise) {
93
+ return res;
94
+ }
95
+ else {
96
+ return Promise.resolve(res);
97
+ }
98
+ }
99
+ return Promise.resolve(val);
100
+ }
101
+ }
102
+ __decorate([
103
+ propertyEditor({
104
+ editorClass: 'ax/editors/widget-size',
105
+ title: 'common.size',
106
+ visible: false,
107
+ order: -99,
108
+ }),
109
+ __metadata("design:type", Array)
110
+ ], AXWidgetComponent.prototype, "widgetSize", void 0);
111
+ __decorate([
112
+ propertyEditor({
113
+ editorClass: 'ax/editors/select',
114
+ title: 'common.refresh-rate',
115
+ visible: true,
116
+ order: -98,
117
+ editorOptions: {
118
+ items: ɵ0,
119
+ allowNull: false,
120
+ allowSearch: false,
121
+ selectionDataMode: 'value',
122
+ selectionMode: 'single',
123
+ valueField: 'id',
124
+ }
125
+ }),
126
+ __metadata("design:type", Object)
127
+ ], AXWidgetComponent.prototype, "refreshRate", void 0);
128
+
129
+ let AXWidgetConfigComponent = class AXWidgetConfigComponent extends AXBasePopupPageComponent {
130
+ constructor(cdr) {
131
+ super();
132
+ this.cdr = cdr;
133
+ this.props = [];
134
+ this.displayProps = [];
135
+ this.changes = [];
136
+ this.context = {};
137
+ }
138
+ getFooterButtons() {
139
+ return [
140
+ {
141
+ name: 'okay',
142
+ submitBehavior: true,
143
+ text: AXTranslator.get('common.confirm'),
144
+ style: 'success'
145
+ },
146
+ {
147
+ name: 'cancel',
148
+ cancelBehavior: true,
149
+ text: AXTranslator.get('common.cancel'),
150
+ style: 'danger blank'
151
+ }
152
+ ];
153
+ }
154
+ onFooterButtonClick(e) {
155
+ if (e.name === 'cancel') {
156
+ this.close();
157
+ }
158
+ if (e.name === 'okay') {
159
+ this.form.validate().then(c => {
160
+ if (c.result) {
161
+ this.close(this.changes);
162
+ }
163
+ });
164
+ }
165
+ }
166
+ handleValueChange(e) {
167
+ const prop = this.changes.find(c => c.property.name === e.property.name);
168
+ if (prop) {
169
+ prop.value = e.value;
170
+ }
171
+ else {
172
+ this.changes.push({ property: e.property, value: e.value });
173
+ }
174
+ this.updateContext();
175
+ }
176
+ ngOnInit() {
177
+ this.displayProps = this.props.filter(c => c.property.visible !== false).sort((a, b) => a.property.order - b.property.order);
178
+ this.updateContext();
179
+ }
180
+ updateContext() {
181
+ const ctx = {};
182
+ this.props.forEach(p => {
183
+ ctx[p.property.name] = p.value;
184
+ });
185
+ this.changes.forEach(p => {
186
+ ctx[p.property.name] = p.value;
187
+ });
188
+ this.context = ctx;
189
+ }
190
+ identify(index, item) {
191
+ return item.property.name;
192
+ }
193
+ };
194
+ AXWidgetConfigComponent.ctorParameters = () => [
195
+ { type: ChangeDetectorRef }
196
+ ];
197
+ __decorate([
198
+ ViewChild(AXValidationFormComponent),
199
+ __metadata("design:type", AXValidationFormComponent)
200
+ ], AXWidgetConfigComponent.prototype, "form", void 0);
201
+ AXWidgetConfigComponent = __decorate([
202
+ Component({
203
+ template: "<ax-page>\r\n <ax-page-content>\r\n <div class=\"container\">\r\n <ax-validation-form #form>\r\n <div class=\"row\" *ngFor=\"let p of displayProps; trackBy: identify\">\r\n <div class=\"col-12\">\r\n <ax-label>{{p.property.title | trans}}</ax-label>\r\n <ng-container ax-property-editor-renderer [property]=\"p\" [context]=\"context\" [host]=\"widget\" [validationForm]=\"form\"\r\n (onValueChange)=\"handleValueChange($event)\">\r\n </ng-container>\r\n </div>\r\n </div>\r\n </ax-validation-form>\r\n </div>\r\n </ax-page-content>\r\n</ax-page>",
204
+ encapsulation: ViewEncapsulation.None,
205
+ changeDetection: ChangeDetectionStrategy.OnPush
206
+ }),
207
+ __metadata("design:paramtypes", [ChangeDetectorRef])
208
+ ], AXWidgetConfigComponent);
209
+
210
+ let AXWidgetSaveComponent = class AXWidgetSaveComponent extends AXBasePopupPageComponent {
211
+ constructor() {
212
+ super(...arguments);
213
+ this.props = [];
214
+ }
215
+ getFooterButtons() {
216
+ return [
217
+ {
218
+ name: 'okay',
219
+ submitBehavior: true,
220
+ text: AXTranslator.get('common.confirm'),
221
+ style: 'ax success'
222
+ },
223
+ {
224
+ name: 'cancel',
225
+ cancelBehavior: true,
226
+ text: AXTranslator.get('common.cancel'),
227
+ style: 'ax light'
228
+ }
229
+ ];
230
+ }
231
+ ngOnInit() {
232
+ var _a, _b;
233
+ const titleProp = this.props.find(c => c.property.name === 'title' || c.property.name === 'name');
234
+ const title = ((_a = titleProp) === null || _a === void 0 ? void 0 : _a.value) || this.config.title;
235
+ const pp = {};
236
+ (_b = this.props) === null || _b === void 0 ? void 0 : _b.forEach(c => {
237
+ pp[c.property.name] = c.property;
238
+ });
239
+ this.data = {
240
+ component: this.config.component,
241
+ title,
242
+ uniqueName: `${this.config.uniqueName}-${AXHtmlUtil.getUID()}`,
243
+ options: AXObjectUtil.deepJSONClone(this.config.options),
244
+ props: AXObjectUtil.deepJSONClone(pp)
245
+ };
246
+ this.displayProps = this.props
247
+ .filter(c => c.property.visible !== false)
248
+ .sort((a, b) => a.property.order - b.property.order)
249
+ .map(c => ({
250
+ name: c.property.name,
251
+ title: c.property.title,
252
+ allow: true
253
+ }));
254
+ }
255
+ onFooterButtonClick(e) {
256
+ if (e.name === 'cancel') {
257
+ this.close();
258
+ }
259
+ if (e.name === 'okay') {
260
+ this.props.forEach(p => {
261
+ const pp = this.displayProps.find(c => c.name === p.property.name);
262
+ if (pp == null || !pp.allow) {
263
+ let ppp = this.data.props[p.property.name];
264
+ if (ppp) {
265
+ ppp.visible = false;
266
+ }
267
+ else {
268
+ ppp = { visible: false };
269
+ }
270
+ }
271
+ });
272
+ this.close(this.data);
273
+ }
274
+ }
275
+ };
276
+ AXWidgetSaveComponent = __decorate([
277
+ Component({
278
+ template: "<ax-page>\r\n <ax-page-content>\r\n <div class=\"container\">\r\n <div class=\"row\">\r\n <div class=\"col-12\">\r\n <ax-form-group>\r\n <ax-label>{{'common.title' | trans}}</ax-label>\r\n <ax-text-box [(value)]=\"data.title\"></ax-text-box>\r\n </ax-form-group>\r\n </div>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-12\">\r\n <ax-form-group>\r\n <ax-label>{{'common.description' | trans}}</ax-label>\r\n <ax-text-area [(value)]=\"data.description\"></ax-text-area>\r\n </ax-form-group>\r\n </div>\r\n </div>\r\n <!-- <div class=\"row\">\r\n <div class=\"col-12\">\r\n <ax-form-group>\r\n <ax-label>{{'common.uniquename' | trans}}</ax-label>\r\n <ax-text-box></ax-text-box>\r\n </ax-form-group>\r\n </div>\r\n </div> -->\r\n <div class=\"row\" style=\"margin-block-end: var(--ax-size-md);margin-block-start: var(--ax-size-md);\">\r\n <div class=\"col-12\">\r\n <ax-fieldset caption=\"{{'widget-board.configurable-props' | trans}}\">\r\n <div class=\"row\" *ngFor=\"let prop of displayProps\">\r\n <div class=\"col-12\" style=\"margin-block-end: var(--ax-size-sm)\">\r\n <ax-check-box [(value)]=\"prop.allow\" label=\"{{ prop.title | trans }}\">\r\n\r\n </ax-check-box>\r\n </div>\r\n </div>\r\n </ax-fieldset>\r\n </div>\r\n </div>\r\n </div>\r\n </ax-page-content>\r\n</ax-page>",
279
+ encapsulation: ViewEncapsulation.None,
280
+ changeDetection: ChangeDetectionStrategy.OnPush
281
+ })
282
+ ], AXWidgetSaveComponent);
283
+
284
+ let AXWidgetHostComponent = class AXWidgetHostComponent {
285
+ constructor(ref, componentFactoryResolver, rendererService, cdr, popup, loadingService) {
286
+ this.ref = ref;
287
+ this.componentFactoryResolver = componentFactoryResolver;
288
+ this.rendererService = rendererService;
289
+ this.cdr = cdr;
290
+ this.popup = popup;
291
+ this.loadingService = loadingService;
292
+ this._hasProps = false;
293
+ this._hasMenu = false;
294
+ this.configMenuItem = [
295
+ {
296
+ icon: 'far fa-ellipsis-h',
297
+ items: []
298
+ }
299
+ ];
300
+ this.onRemove = new EventEmitter();
301
+ this.onConfigChanged = new EventEmitter();
302
+ this.onResized = new EventEmitter();
303
+ this.onSave = new EventEmitter();
304
+ this._isLoading = false;
305
+ this.sizeX = 1;
306
+ this.sizeY = 1;
307
+ this.col = 1;
308
+ this.row = 1;
309
+ }
310
+ get widget() {
311
+ return this._widget;
312
+ }
313
+ get element() {
314
+ return this.ref.nativeElement;
315
+ }
316
+ get isLoading() {
317
+ return this._isLoading;
318
+ }
319
+ set isLoading(v) {
320
+ this._isLoading = v;
321
+ if (this._loadingId && !v) {
322
+ this.loadingService.hide(this._loadingId);
323
+ this._loadingId = null;
324
+ }
325
+ if (v) {
326
+ this._loadingId = this.loadingService.show(this.ref.nativeElement);
327
+ }
328
+ }
329
+ get isConfigured() {
330
+ var _a;
331
+ return ((_a = this._widget) === null || _a === void 0 ? void 0 : _a.isConfigured) || false;
332
+ }
333
+ ngOnInit() {
334
+ this.isLoading = true;
335
+ }
336
+ ngAfterViewInit() {
337
+ var _a;
338
+ return __awaiter(this, void 0, void 0, function* () {
339
+ let component;
340
+ if (typeof this.config.component === 'string') {
341
+ const route = yield this.rendererService.findLoadedComponentByRoute(this.config.component, 20);
342
+ component = (_a = route) === null || _a === void 0 ? void 0 : _a.component;
343
+ }
344
+ else if (typeof this.config.component === 'function') {
345
+ component = this.config.component;
346
+ }
347
+ if (component == null) {
348
+ console.error(`Invalid Widget Component!`, this.config);
349
+ this.onRemove.emit(this);
350
+ return;
351
+ }
352
+ const widgetFactory = this.componentFactoryResolver.resolveComponentFactory(component);
353
+ this.componentRef = this.vc.createComponent(widgetFactory);
354
+ this._widget = this.componentRef.instance;
355
+ this._widget.provideValue = this.provideValue;
356
+ if (this._widget.onBusyChanged) {
357
+ this._widget.onBusyChanged.subscribe((d) => {
358
+ if (!this._widget.widgetSize) {
359
+ this._widget.setValue('widgetSize', [this.sizeX, this.sizeY]);
360
+ }
361
+ else {
362
+ this.setSizeFromOptions();
363
+ }
364
+ this.isLoading = d.value;
365
+ this.cdr.detectChanges();
366
+ });
367
+ }
368
+ if (this._widget.onConfiguredChanged) {
369
+ this._widget.onConfiguredChanged.subscribe(() => {
370
+ this.setSizeFromOptions();
371
+ });
372
+ }
373
+ //
374
+ if (this.config.options) {
375
+ Object.assign(this._widget, this.config.options);
376
+ }
377
+ this._hasProps = AXPropertyDecorators.getProperties(this._widget).length > 0;
378
+ this.isLoading = false;
379
+ this.config['__meta__'].instance = this;
380
+ this._widget['__meta__'] = {};
381
+ this._widget['__meta__'].config = this.config;
382
+ //
383
+ if (this._hasProps) {
384
+ this.configMenuItem[0].items.push({
385
+ name: 'configs',
386
+ icon: 'far fa-cogs',
387
+ text: AXTranslator.get('common.configs'),
388
+ onClick: () => {
389
+ this.openConfigDialog();
390
+ }
391
+ });
392
+ }
393
+ this.configMenuItem[0].items.push({
394
+ name: 'save',
395
+ icon: 'far fa-save',
396
+ text: AXTranslator.get('common.save-as'),
397
+ onClick: () => {
398
+ this.openSaveDialog();
399
+ }
400
+ });
401
+ if (true) {
402
+ this.configMenuItem[0].items.push({
403
+ name: 'remove',
404
+ icon: 'far fa-times',
405
+ style: 'ax danger blank',
406
+ text: AXTranslator.get('common.remove'),
407
+ onClick: () => {
408
+ this.onRemove.emit(this);
409
+ }
410
+ });
411
+ }
412
+ this._hasMenu = this.configMenuItem[0].items.length > 0;
413
+ this.cdr.detectChanges();
414
+ });
415
+ }
416
+ setSizeFromOptions() {
417
+ this._widget.getValue('widgetSize').then(c => {
418
+ const oldSizeX = this.sizeX;
419
+ const oldSizeY = this.sizeY;
420
+ if (c && Array.isArray(c) && (oldSizeX !== c[0] || oldSizeY !== c[1])) {
421
+ this.config.sizeX = this.sizeX = c[0];
422
+ this.config.sizeY = this.sizeY = c[1];
423
+ this.onResized.emit({
424
+ component: this._widget,
425
+ config: this.config
426
+ });
427
+ }
428
+ this.cdr.detectChanges();
429
+ });
430
+ }
431
+ remove(e) {
432
+ e.preventDefault();
433
+ e.stopPropagation();
434
+ this.onRemove.emit(this);
435
+ return false;
436
+ }
437
+ handleConfig(e) {
438
+ e.preventDefault();
439
+ e.stopPropagation();
440
+ this.openConfigDialog();
441
+ return false;
442
+ }
443
+ openConfigDialog() {
444
+ const ppp = this.getMergedProps();
445
+ this.popup.open(AXWidgetConfigComponent, {
446
+ title: AXTranslator.get('common.configs'),
447
+ size: 'sm',
448
+ data: {
449
+ props: ppp.map(c => ({ property: c.options, value: this._widget[c.options.name] })),
450
+ widget: this.widget
451
+ }
452
+ }).then(c => {
453
+ if (c.data) {
454
+ if (!this.config.options) {
455
+ this.config.options = {};
456
+ }
457
+ c.data.forEach(p => {
458
+ this._widget.setValue(p.property.name, p.value);
459
+ this.config.options[p.property.name] = p.value;
460
+ });
461
+ this.emitConfigChanged();
462
+ this._widget.redraw();
463
+ this.cdr.detectChanges();
464
+ }
465
+ });
466
+ }
467
+ openSaveDialog() {
468
+ const ppp = this.getMergedProps();
469
+ this.popup.open(AXWidgetSaveComponent, {
470
+ title: AXTranslator.get('common.save-as'),
471
+ size: 'sm',
472
+ data: {
473
+ config: this.config,
474
+ props: ppp.map(c => ({ property: c.options, value: this._widget[c.options.name] }))
475
+ }
476
+ }).then(c => {
477
+ if (c.data) {
478
+ this.onSave.emit({
479
+ component: this._widget,
480
+ data: c.data
481
+ });
482
+ }
483
+ });
484
+ }
485
+ handleOptionClick(e) {
486
+ e.preventDefault();
487
+ e.stopPropagation();
488
+ this.openConfigDialog();
489
+ return false;
490
+ }
491
+ ngOnDestroy() {
492
+ this.vc.clear();
493
+ if (this.componentRef) {
494
+ this.componentRef.destroy();
495
+ }
496
+ }
497
+ getMergedProps() {
498
+ const ppp = AXObjectUtil.deepCopy(AXPropertyDecorators.getProperties(this._widget));
499
+ for (const key in this.config.props) {
500
+ if (Object.prototype.hasOwnProperty.call(this.config.props, key)) {
501
+ const newP = this.config.props[key];
502
+ const existPropDec = ppp.find(p => p.property === key);
503
+ if (existPropDec) {
504
+ Object.assign(existPropDec.options, newP);
505
+ }
506
+ }
507
+ }
508
+ return ppp;
509
+ }
510
+ emitConfigChanged() {
511
+ this.onConfigChanged.emit({
512
+ component: this._widget,
513
+ config: this.config
514
+ });
515
+ }
516
+ };
517
+ AXWidgetHostComponent.ctorParameters = () => [
518
+ { type: ElementRef },
519
+ { type: ComponentFactoryResolver },
520
+ { type: AXRenderService },
521
+ { type: ChangeDetectorRef },
522
+ { type: AXPopupService },
523
+ { type: AXLoadingService }
524
+ ];
525
+ __decorate([
526
+ Input(),
527
+ __metadata("design:type", Function)
528
+ ], AXWidgetHostComponent.prototype, "provideValue", void 0);
529
+ __decorate([
530
+ Output(),
531
+ __metadata("design:type", EventEmitter)
532
+ ], AXWidgetHostComponent.prototype, "onRemove", void 0);
533
+ __decorate([
534
+ Output(),
535
+ __metadata("design:type", EventEmitter)
536
+ ], AXWidgetHostComponent.prototype, "onConfigChanged", void 0);
537
+ __decorate([
538
+ Output(),
539
+ __metadata("design:type", EventEmitter)
540
+ ], AXWidgetHostComponent.prototype, "onResized", void 0);
541
+ __decorate([
542
+ Output(),
543
+ __metadata("design:type", EventEmitter)
544
+ ], AXWidgetHostComponent.prototype, "onSave", void 0);
545
+ __decorate([
546
+ Input(),
547
+ __metadata("design:type", Object)
548
+ ], AXWidgetHostComponent.prototype, "config", void 0);
549
+ __decorate([
550
+ ViewChild('vc', { read: ViewContainerRef }),
551
+ __metadata("design:type", ViewContainerRef)
552
+ ], AXWidgetHostComponent.prototype, "vc", void 0);
553
+ __decorate([
554
+ HostBinding('attr.data-size-x'),
555
+ Input(),
556
+ __metadata("design:type", Number)
557
+ ], AXWidgetHostComponent.prototype, "sizeX", void 0);
558
+ __decorate([
559
+ HostBinding('attr.data-size-y'),
560
+ Input(),
561
+ __metadata("design:type", Number)
562
+ ], AXWidgetHostComponent.prototype, "sizeY", void 0);
563
+ __decorate([
564
+ HostBinding('attr.data-col'),
565
+ Input(),
566
+ __metadata("design:type", Number)
567
+ ], AXWidgetHostComponent.prototype, "col", void 0);
568
+ __decorate([
569
+ HostBinding('attr.data-row'),
570
+ Input(),
571
+ __metadata("design:type", Number)
572
+ ], AXWidgetHostComponent.prototype, "row", void 0);
573
+ AXWidgetHostComponent = __decorate([
574
+ Component({
575
+ selector: 'ax-widget-host',
576
+ template: "<div class='widget-container'>\r\n <div class=\"widget-config-overlay\" *ngIf=\"!isConfigured\" (click)=\"handleConfig($event)\">\r\n <div class=\"widget-title\">{{config.title}}</div>\r\n <div class=\"widget-config-box\">\r\n <div class=\"config-title\">{{ 'widget-board.configure' | trans}}</div>\r\n <div class=\"config-icon\"><i class=\"fas fa-cogs fa-5x\"></i></div>\r\n </div>\r\n </div>\r\n <div class='widget-edit-overlay'>\r\n <div class='widget-edit-menu'>\r\n <button class=\"widget-edit-menu-button\" (click)=\"handleConfig($event)\"\r\n (mousedown)=\"$event.stopPropagation()\" *ngIf=\"_hasProps\" (mouseup)=\"$event.stopPropagation()\">\r\n <i class=\"far fa-cogs\"></i>\r\n </button>\r\n <button class=\"widget-edit-menu-button\" (click)=\"remove($event)\" (mousedown)=\"$event.stopPropagation()\"\r\n (mouseup)=\"$event.stopPropagation()\">\r\n <i class=\"far fa-times\"></i>\r\n </button>\r\n </div>\r\n\r\n </div>\r\n <div class=\"widget-options-menu\" *ngIf=\"_hasMenu\">\r\n <ax-menu [items]='configMenuItem' direction=\"horizontal\"></ax-menu>\r\n </div>\r\n <!-- <ax-loading-panel [visible]=\"isBusy\">\r\n </ax-loading-panel> -->\r\n <div class=\"widget-content\">\r\n <ng-container #vc></ng-container>\r\n </div>\r\n</div>",
577
+ host: { class: 'ax widget-host', tabindex: '0' },
578
+ encapsulation: ViewEncapsulation.None,
579
+ changeDetection: ChangeDetectionStrategy.OnPush
580
+ }),
581
+ __metadata("design:paramtypes", [ElementRef,
582
+ ComponentFactoryResolver,
583
+ AXRenderService,
584
+ ChangeDetectorRef,
585
+ AXPopupService,
586
+ AXLoadingService])
587
+ ], AXWidgetHostComponent);
588
+
589
+ let AXWidgetBoardComponent = class AXWidgetBoardComponent {
590
+ constructor(ref, zone, cdr) {
591
+ this.ref = ref;
592
+ this.zone = zone;
593
+ this.cdr = cdr;
594
+ this.widgets = [];
595
+ this.galleryItems = [];
596
+ this.tileSize = 80;
597
+ this.gapSize = 5;
598
+ this.newWidget = null;
599
+ this._isInEditing = false;
600
+ this.isDragging = false;
601
+ this.DATA_COL = 'data-col';
602
+ this.DATA_ROW = 'data-row';
603
+ this.DATA_SIZE_X = 'data-size-x';
604
+ this.DATA_SIZE_Y = 'data-size-y';
605
+ this.DATA_OLD_COL = 'data-old-col';
606
+ this.DATA_OLD_ROW = 'data-old-row';
607
+ this.onConfigChanged = new EventEmitter();
608
+ this.onWidgetSave = new EventEmitter();
609
+ }
610
+ isInEditing() {
611
+ return this._isInEditing;
612
+ }
613
+ ngOnInit() {
614
+ if (this.rtl == null) {
615
+ this.rtl = window.getComputedStyle(this.ref.nativeElement, null).getPropertyValue('direction') === 'rtl';
616
+ }
617
+ }
618
+ ngAfterViewInit() {
619
+ this.zone.runOutsideAngular((c) => {
620
+ const style = document.createElement('style');
621
+ style.type = 'text/css';
622
+ this.ref.nativeElement.appendChild(style);
623
+ // add css data classes
624
+ for (let i = 1; i <= 50; i++) {
625
+ style.innerHTML += `[${this.DATA_COL}="${i}"] { ${this.rtl ? 'right' : 'left'}: ${(i - 1) * (this.tileSize + this.gapSize)}px; }`;
626
+ style.innerHTML += `[${this.DATA_ROW}="${i}"] { top: ${(i - 1) * (this.tileSize + this.gapSize)}px; }`;
627
+ style.innerHTML += `[${this.DATA_SIZE_X}="${i}"] { width: ${(i * this.tileSize) + ((i - 1) * this.gapSize)}px; }`;
628
+ style.innerHTML += `[${this.DATA_SIZE_Y}="${i}"] { height: ${(i * this.tileSize) + ((i - 1) * this.gapSize)}px; }`;
629
+ }
630
+ });
631
+ }
632
+ calcGridSize() {
633
+ this.zone.runOutsideAngular(() => {
634
+ const width = (Math.max(...this.widgets.map((c) => c.col + c.sizeX - 1))) * (this.tileSize + this.gapSize);
635
+ const height = (Math.max(...this.widgets.map((c) => c.row + c.sizeY - 1))) * (this.tileSize + this.gapSize);
636
+ this.container.nativeElement.style.width = width + 'px';
637
+ this.container.nativeElement.style.height = height + 'px';
638
+ });
639
+ }
640
+ toggleEdit() {
641
+ this._isInEditing ? this.finishEdit() : this.startEdit();
642
+ }
643
+ dragStart(e) {
644
+ e.preventDefault();
645
+ e.stopPropagation();
646
+ this.zone.runOutsideAngular(() => {
647
+ if (this._isInEditing && e.which === 1) {
648
+ this.dragItem = e.currentTarget;
649
+ this.dragItem.setAttribute('data-x-offset', (this.dragItem.offsetLeft - e.clientX).toString());
650
+ //
651
+ this.dragItem.setAttribute('data-y-offset', (this.dragItem.offsetTop - e.clientY).toString());
652
+ this.dragItem.classList.add('widget-dragging');
653
+ this.dragItem.classList.remove('animate__animated', 'animate__pulse');
654
+ }
655
+ });
656
+ return false;
657
+ }
658
+ removePositionData() {
659
+ this.zone.runOutsideAngular(() => {
660
+ if (this.dragItem && this._isInEditing && this.dragItem.getAttribute(this.DATA_OLD_COL) == null) {
661
+ this.dragItem.setAttribute(this.DATA_OLD_COL, this.dragItem.getAttribute(this.DATA_COL));
662
+ this.dragItem.setAttribute(this.DATA_OLD_ROW, this.dragItem.getAttribute(this.DATA_ROW));
663
+ this.dragItem.removeAttribute(this.DATA_COL);
664
+ this.dragItem.removeAttribute(this.DATA_ROW);
665
+ }
666
+ });
667
+ }
668
+ resetPositionData() {
669
+ this.zone.runOutsideAngular(() => {
670
+ if (this.dragItem && this._isInEditing) {
671
+ this.setPosition(this.dragItem, this.dragItem.getAttribute(this.DATA_OLD_COL), this.dragItem.getAttribute(this.DATA_OLD_ROW));
672
+ }
673
+ });
674
+ }
675
+ setPosition(element, col, row) {
676
+ this.zone.runOutsideAngular(() => {
677
+ element.setAttribute(this.DATA_COL, col);
678
+ element.setAttribute(this.DATA_ROW, row);
679
+ element.removeAttribute(this.DATA_OLD_COL);
680
+ element.removeAttribute(this.DATA_OLD_ROW);
681
+ element.style.removeProperty('top');
682
+ element.style.removeProperty('left');
683
+ const widget = this.widgets.find(c => c['__meta__'].instance.element === element);
684
+ widget.col = Number(col);
685
+ widget.row = Number(row);
686
+ });
687
+ }
688
+ drag(e) {
689
+ e.preventDefault();
690
+ e.stopPropagation();
691
+ this.zone.runOutsideAngular(() => {
692
+ if (this.dragItem && this._isInEditing) {
693
+ this.isDragging = true;
694
+ this.addPlaceholder();
695
+ const xOffset = Number(this.dragItem.getAttribute('data-x-offset'));
696
+ const yOffset = Number(this.dragItem.getAttribute('data-y-offset'));
697
+ this.dragItem.style.left = e.clientX + xOffset + 'px';
698
+ this.dragItem.style.top = e.clientY + yOffset + 'px';
699
+ //
700
+ this.detectBestPlacement();
701
+ this.removePositionData();
702
+ }
703
+ });
704
+ return false;
705
+ }
706
+ dragEnd(e) {
707
+ this.zone.runOutsideAngular(() => {
708
+ if (this.dragItem && this._isInEditing && this.isDragging) {
709
+ this.dragItem.classList.remove('widget-dragging');
710
+ this.dragItem.classList.add('animate__animated', 'animate__pulse');
711
+ //
712
+ const p = this.container.nativeElement.querySelector('.widget-blank-placeholder');
713
+ if (this.newWidget) {
714
+ const w = {
715
+ uniqueName: this.newWidget.uniqueName,
716
+ component: this.newWidget.component,
717
+ title: this.newWidget.title,
718
+ options: this.newWidget.options,
719
+ sizeX: this.newWidget.sizeX,
720
+ sizeY: this.newWidget.sizeY,
721
+ col: Number(p.getAttribute(this.DATA_COL)),
722
+ row: Number(p.getAttribute(this.DATA_ROW))
723
+ };
724
+ this.widgets.push(w);
725
+ this.newWidget = null;
726
+ this.container.nativeElement.removeChild(this.dragItem);
727
+ this.zone.run(() => {
728
+ this.cdr.detectChanges();
729
+ this.calcGridSize();
730
+ setTimeout(() => {
731
+ w['__meta__'].instance.element.addEventListener('mousedown', this.dragStart.bind(this), false);
732
+ }, 1000);
733
+ });
734
+ }
735
+ else {
736
+ if (p) {
737
+ this.setPosition(this.dragItem, p.getAttribute(this.DATA_COL), p.getAttribute(this.DATA_ROW));
738
+ }
739
+ else {
740
+ this.setPosition(this.dragItem, this.dragItem.getAttribute(this.DATA_OLD_COL), this.dragItem.getAttribute(this.DATA_OLD_ROW));
741
+ }
742
+ }
743
+ //
744
+ this.removePlaceholder();
745
+ this.dragItem = null;
746
+ this.calcGridSize();
747
+ this.emitConfigChanged();
748
+ }
749
+ this.isDragging = false;
750
+ });
751
+ }
752
+ detectFirstEmptySlot(w) {
753
+ const xTile = Math.floor(this.ref.nativeElement.parentElement.offsetWidth / this.tileSize);
754
+ for (let j = 1; j <= 100; j++) {
755
+ for (let i = 1; i <= xTile - w.sizeX; i++) {
756
+ const rec = new AXClientRec({
757
+ left: i,
758
+ top: j,
759
+ width: w.sizeX,
760
+ height: w.sizeY
761
+ });
762
+ const el = this.widgets.filter(c => c !== w).find((c) => rec.intersect({
763
+ left: c.col,
764
+ top: c.row,
765
+ width: c.sizeX,
766
+ height: c.sizeY
767
+ }));
768
+ if (el == null) {
769
+ w.col = i;
770
+ w.row = j;
771
+ return;
772
+ }
773
+ }
774
+ }
775
+ }
776
+ detectBestPlacement() {
777
+ this.zone.runOutsideAngular(() => {
778
+ const p = this.container.nativeElement.querySelector('.widget-blank-placeholder');
779
+ let col = Math.ceil(this.dragItem.offsetLeft / this.tileSize);
780
+ if (this.rtl) {
781
+ col = Math.ceil((this.container.nativeElement.clientWidth - (this.dragItem.offsetLeft + this.dragItem.clientWidth)) / this.tileSize);
782
+ }
783
+ let row = Math.ceil(this.dragItem.offsetTop / this.tileSize);
784
+ if (col < 1) {
785
+ col = 1;
786
+ }
787
+ if (row < 1) {
788
+ row = 1;
789
+ }
790
+ const widgets = Array.from(this.ref.nativeElement.querySelectorAll('.widget-host')).map((c) => c);
791
+ p.setAttribute(this.DATA_COL, col.toString());
792
+ p.setAttribute(this.DATA_ROW, row.toString());
793
+ const collision = widgets.filter(c => c !== this.dragItem).some(c => AXHtmlUtil.collision(c, this.dragItem));
794
+ if (collision) {
795
+ this.removePlaceholder();
796
+ }
797
+ });
798
+ }
799
+ addPlaceholder() {
800
+ this.zone.runOutsideAngular(() => {
801
+ this.removePlaceholder();
802
+ if (this.dragItem) {
803
+ const p = document.createElement('div');
804
+ p.classList.add('widget-blank-placeholder');
805
+ p.setAttribute(this.DATA_COL, this.dragItem.getAttribute(this.DATA_COL));
806
+ p.setAttribute(this.DATA_ROW, this.dragItem.getAttribute(this.DATA_ROW));
807
+ p.setAttribute(this.DATA_SIZE_X, this.dragItem.getAttribute(this.DATA_SIZE_X));
808
+ p.setAttribute(this.DATA_SIZE_Y, this.dragItem.getAttribute(this.DATA_SIZE_Y));
809
+ this.container.nativeElement.appendChild(p);
810
+ }
811
+ });
812
+ }
813
+ removePlaceholder() {
814
+ var _a;
815
+ const p = this.container.nativeElement.querySelector('.widget-blank-placeholder');
816
+ (_a = p) === null || _a === void 0 ? void 0 : _a.remove();
817
+ }
818
+ startEdit() {
819
+ this._isInEditing = true;
820
+ this.calcGridSize();
821
+ this.ref.nativeElement.classList.add('grid-background');
822
+ const bg = this.ref.nativeElement;
823
+ bg.style.setProperty('background-position', `${this.rtl ? 'right' : 'left'} top`);
824
+ // tslint:disable-next-line: max-line-length
825
+ const pattern = `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${this.tileSize + this.gapSize}" height="${this.tileSize + this.gapSize}"> <rect style="fill: %23dadada" x="${this.rtl ? this.gapSize : 0}" width="${this.tileSize}" height="${this.tileSize}" y="0"></rect></svg>')`;
826
+ bg.style.setProperty('background-image', pattern);
827
+ //
828
+ const widgets = Array.from(this.ref.nativeElement.querySelectorAll('.widget-host'));
829
+ widgets.forEach((w) => {
830
+ w.addEventListener('mousedown', this.dragStart.bind(this), false);
831
+ });
832
+ this.ref.nativeElement.addEventListener('mousemove', this.drag.bind(this), false);
833
+ this.ref.nativeElement.addEventListener('mouseup', this.dragEnd.bind(this), false);
834
+ }
835
+ finishEdit() {
836
+ this.ref.nativeElement.classList.remove('grid-background');
837
+ const bg = this.ref.nativeElement;
838
+ bg.style.removeProperty('background-image');
839
+ //
840
+ this._isInEditing = false;
841
+ const widgets = Array.from(this.ref.nativeElement.querySelectorAll('.widget-host'));
842
+ widgets.forEach((w) => {
843
+ w.removeEventListener('mousedown', this.dragStart.bind(this), false);
844
+ });
845
+ this.ref.nativeElement.removeEventListener('mousemove', this.drag.bind(this), false);
846
+ this.ref.nativeElement.removeEventListener('mouseup', this.dragEnd.bind(this), false);
847
+ this.emitConfigChanged();
848
+ }
849
+ addWidget(widget) {
850
+ this.zone.runOutsideAngular(() => {
851
+ this.newWidget = {
852
+ uniqueName: widget.uniqueName,
853
+ component: widget.component,
854
+ title: widget.title,
855
+ col: 1,
856
+ row: 1,
857
+ sizeX: widget.sizeX,
858
+ sizeY: widget.sizeY,
859
+ options: widget.options,
860
+ props: widget.props
861
+ };
862
+ this.detectFirstEmptySlot(this.newWidget);
863
+ const w = {
864
+ uniqueName: this.newWidget.uniqueName,
865
+ component: this.newWidget.component,
866
+ title: this.newWidget.title,
867
+ options: this.newWidget.options,
868
+ props: this.newWidget.props,
869
+ sizeX: this.newWidget.sizeX,
870
+ sizeY: this.newWidget.sizeY,
871
+ col: this.newWidget.col,
872
+ row: this.newWidget.row
873
+ };
874
+ this.widgets.push(w);
875
+ this.newWidget = null;
876
+ this.zone.run(() => {
877
+ this.cdr.detectChanges();
878
+ this.calcGridSize();
879
+ this.emitConfigChanged();
880
+ setTimeout(() => {
881
+ w['__meta__'].instance.element.addEventListener('mousedown', this.dragStart.bind(this), false);
882
+ }, 1000);
883
+ });
884
+ });
885
+ }
886
+ handleOnRemove(w) {
887
+ w.element.classList.add('animate__animated', 'animate__zoomOut');
888
+ w.element.addEventListener('animationend', () => {
889
+ this.widgets = this.widgets.filter((c) => c.__meta__.id !== w.config.__meta__.id);
890
+ this.cdr.detectChanges();
891
+ this.calcGridSize();
892
+ this.emitConfigChanged();
893
+ });
894
+ }
895
+ handleOnSave(e) {
896
+ this.onWidgetSave.emit(e);
897
+ }
898
+ trackByFn(index, item) {
899
+ var _a, _b;
900
+ if (!((_a = item['__meta__']) === null || _a === void 0 ? void 0 : _a.id)) {
901
+ item['__meta__'] = {};
902
+ item['__meta__'].id = AXHtmlUtil.getUID();
903
+ }
904
+ return (_b = item['__meta__']) === null || _b === void 0 ? void 0 : _b.id;
905
+ }
906
+ load(widgets) {
907
+ this.clear();
908
+ return new Promise((resolve, reject) => {
909
+ if (widgets) {
910
+ const loadedWidgets = [];
911
+ if (typeof widgets === 'string') {
912
+ try {
913
+ loadedWidgets.push(...JSON.parse(widgets));
914
+ }
915
+ catch (error) {
916
+ reject('Invalid widget json data!');
917
+ }
918
+ }
919
+ else {
920
+ loadedWidgets.push(...widgets);
921
+ }
922
+ let intervalId = -1;
923
+ const loadFunc = () => {
924
+ if (this.galleryItems && this.galleryItems.length > 0) {
925
+ loadedWidgets.forEach(w => {
926
+ const gitem = this.galleryItems.find(c => c.uniqueName === w.uniqueName);
927
+ if (gitem) {
928
+ w.component = gitem.component;
929
+ if (gitem.props) {
930
+ w.props = JSON.parse(JSON.stringify(gitem.props));
931
+ }
932
+ }
933
+ });
934
+ this.widgets.push(...loadedWidgets);
935
+ window.clearInterval(intervalId);
936
+ this.cdr.detectChanges();
937
+ resolve();
938
+ }
939
+ };
940
+ intervalId = window.setInterval(loadFunc, 200);
941
+ }
942
+ else {
943
+ resolve();
944
+ }
945
+ });
946
+ }
947
+ clear() {
948
+ if (this.widgets.length) {
949
+ this.widgets = [];
950
+ this.cdr.detectChanges();
951
+ this.emitConfigChanged();
952
+ }
953
+ }
954
+ save() {
955
+ const obj = this.widgets.map(c => ({
956
+ uniqueName: c.uniqueName,
957
+ component: c.component,
958
+ title: c.title,
959
+ sizeX: c.sizeX,
960
+ sizeY: c.sizeY,
961
+ col: c.col,
962
+ row: c.row,
963
+ options: c.options,
964
+ props: c.props
965
+ }));
966
+ return Promise.resolve(JSON.stringify(obj));
967
+ }
968
+ refresh() {
969
+ this.widgetHosts.forEach(host => {
970
+ host.widget.refresh();
971
+ });
972
+ }
973
+ handleOnConfigChanged(e) {
974
+ this.cdr.detectChanges();
975
+ this.emitConfigChanged();
976
+ }
977
+ handleOnResizedChanged(e) {
978
+ this.detectFirstEmptySlot(e.config);
979
+ this.cdr.detectChanges();
980
+ this.emitConfigChanged();
981
+ }
982
+ emitConfigChanged() {
983
+ if (!this.resizeChangeObserver) {
984
+ this.resizeChangeObserver = new Observable();
985
+ Observable.create(observer => {
986
+ this.resizeChangeObserver = observer;
987
+ })
988
+ .pipe(debounceTime(750))
989
+ .pipe(distinctUntilChanged())
990
+ .subscribe(c => {
991
+ this.onConfigChanged.emit({
992
+ component: this
993
+ });
994
+ });
995
+ }
996
+ this.resizeChangeObserver.next(new Date());
997
+ }
998
+ };
999
+ AXWidgetBoardComponent.ctorParameters = () => [
1000
+ { type: ElementRef },
1001
+ { type: NgZone },
1002
+ { type: ChangeDetectorRef }
1003
+ ];
1004
+ __decorate([
1005
+ ViewChild('container'),
1006
+ __metadata("design:type", ElementRef)
1007
+ ], AXWidgetBoardComponent.prototype, "container", void 0);
1008
+ __decorate([
1009
+ ViewChildren(AXWidgetHostComponent),
1010
+ __metadata("design:type", QueryList)
1011
+ ], AXWidgetBoardComponent.prototype, "widgetHosts", void 0);
1012
+ __decorate([
1013
+ Input(),
1014
+ __metadata("design:type", Array)
1015
+ ], AXWidgetBoardComponent.prototype, "galleryItems", void 0);
1016
+ __decorate([
1017
+ Input(),
1018
+ __metadata("design:type", Number)
1019
+ ], AXWidgetBoardComponent.prototype, "tileSize", void 0);
1020
+ __decorate([
1021
+ Input(),
1022
+ __metadata("design:type", Number)
1023
+ ], AXWidgetBoardComponent.prototype, "gapSize", void 0);
1024
+ __decorate([
1025
+ Input(),
1026
+ __metadata("design:type", Function)
1027
+ ], AXWidgetBoardComponent.prototype, "provideValue", void 0);
1028
+ __decorate([
1029
+ Output(),
1030
+ __metadata("design:type", EventEmitter)
1031
+ ], AXWidgetBoardComponent.prototype, "onConfigChanged", void 0);
1032
+ __decorate([
1033
+ Output(),
1034
+ __metadata("design:type", EventEmitter)
1035
+ ], AXWidgetBoardComponent.prototype, "onWidgetSave", void 0);
1036
+ AXWidgetBoardComponent = __decorate([
1037
+ Component({
1038
+ selector: 'ax-widget-board',
1039
+ template: "<div class=\"widgets-container\" [class.rtl]=\"rtl\" #container>\r\n <ax-widget-host *ngFor=\"let w of widgets;trackBy: trackByFn\" [config]='w' [sizeX]=\"w.sizeX\"\r\n [sizeY]=\"w.sizeY\" [col]=\"w.col\" [row]=\"w.row\" (onRemove)=\"handleOnRemove($event)\" (onSave)=\"handleOnSave($event)\"\r\n (onConfigChanged)=\"handleOnConfigChanged($event)\" (onResized)=\"handleOnResizedChanged($event)\"\r\n [provideValue]=\"provideValue\">\r\n </ax-widget-host>\r\n</div>\r\n",
1040
+ host: { class: 'ax widget-board' },
1041
+ encapsulation: ViewEncapsulation.None,
1042
+ changeDetection: ChangeDetectionStrategy.OnPush,
1043
+ styles: [".widget-board{display:inline-block;margin:15px 20px;min-width:calc(100% - 40px);min-height:calc(100% - 34px);--animate-duration:0.5s;background-repeat:no-repeat}.widget-board.grid-background{background-repeat:repeat!important}.widget-board.grid-background .widgets-container .widget-host{touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.widget-board.grid-background .widgets-container .widget-host .widget-edit-overlay{display:block;cursor:move}.widget-board.grid-background .widgets-container .widget-host.widget-dragging{z-index:1000}.widget-board.grid-background .widgets-container .widget-host:focus{outline-width:1px;outline-style:solid;outline-color:var(--ax-primary-color)}.widget-board.grid-background .widget-blank-placeholder{background:var(--ax-primary-trans-light-color);position:absolute}.widget-board .widgets-container{position:relative;touch-action:none}.widget-board .widgets-container.rtl .widget-host .widget-options-menu{right:unset!important;left:0!important}.widget-board .widgets-container .widget-host{position:absolute;background:#fff;box-shadow:2px 2px 3px #dadada}.widget-board .widgets-container .widget-host .widget-content{width:100%;height:100%;display:flex;flex-direction:column}.widget-board .widgets-container .widget-host .widget-content .widget-title{padding:var(--ax-size-md);text-align:start;font-size:1.5em;position:absolute}.widget-board .widgets-container .widget-host .widget-edit-loading{display:none;background:rgba(255,255,255,.85);position:absolute;width:100%;height:100%;top:0;left:0;z-index:2;display:flex}.widget-board .widgets-container .widget-host .widget-config-overlay{position:absolute;background:#fff;width:100%;height:100%;top:0;left:0;z-index:1;padding:var(--ax-size-md);cursor:pointer}.widget-board .widgets-container .widget-host .widget-config-overlay:hover .widget-title{text-decoration:underline}.widget-board .widgets-container .widget-host .widget-config-overlay .widget-title{text-align:start;font-size:1.5em}.widget-board .widgets-container .widget-host .widget-config-overlay .widget-config-box{align-self:center;text-align:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--ax-gray-dark-color)}.widget-board .widgets-container .widget-host .widget-config-overlay .widget-config-box .config-title{font-size:1.2em;margin-bottom:var(--ax-size-md)}.widget-board .widgets-container .widget-host .widget-edit-overlay{display:none;background:rgba(255,255,255,.5);position:absolute;width:100%;height:100%;top:0;left:0;z-index:10}.widget-board .widgets-container .widget-host .widget-edit-overlay .widget-edit-menu{margin:6px;text-align:end;float:inline-end;opacity:1;transition:opacity 1s}.widget-board .widgets-container .widget-host .widget-edit-overlay .widget-edit-menu .widget-edit-menu-button{display:inline-block;background-color:#f0f0f0;border-radius:1px;border:2px solid #fff;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;padding:0;height:32px;width:32px;cursor:pointer;color:#666}.widget-board .widgets-container .widget-host .widget-edit-overlay .widget-edit-menu .widget-edit-menu-button:hover{border-color:#a6a6a6;background-color:#c8c8c8}.widget-board .widgets-container .widget-host .widget-options-menu{display:none;position:absolute;top:0;right:0;z-index:2;cursor:pointer;padding:2px 5px}.widget-board .widgets-container .widget-host .widget-options-menu:hover{background-color:#f0f0f0}.widget-board .widgets-container .widget-host .widget-container{padding:1px;height:100%}.widget-board .widgets-container .widget-host .widget-container:hover .widget-options-menu{display:block}"]
1044
+ }),
1045
+ __metadata("design:paramtypes", [ElementRef,
1046
+ NgZone,
1047
+ ChangeDetectorRef])
1048
+ ], AXWidgetBoardComponent);
1049
+
1050
+ let AXWidgetSizePropertyEditorComponent = class AXWidgetSizePropertyEditorComponent extends AXProperyEditorComponent {
1051
+ constructor(cdr) {
1052
+ super(cdr);
1053
+ this.cdr = cdr;
1054
+ this.minX = 1;
1055
+ this.maxX = 10;
1056
+ this.minY = 1;
1057
+ this.maxY = 10;
1058
+ }
1059
+ ngOnInit() {
1060
+ if (Array.isArray(this.value)) {
1061
+ this.sizeX = this.value[0];
1062
+ this.sizeY = this.value[1];
1063
+ }
1064
+ else {
1065
+ this.sizeX = 2;
1066
+ this.sizeY = 2;
1067
+ }
1068
+ }
1069
+ handleMinValueChange(e) {
1070
+ this.sizeX = e.value;
1071
+ if (this.sizeY > 0) {
1072
+ super.handleValueChange([this.sizeX, this.sizeY]);
1073
+ }
1074
+ }
1075
+ handleMaxValueChange(e) {
1076
+ this.sizeY = e.value;
1077
+ if (this.sizeX > 0) {
1078
+ super.handleValueChange([this.sizeX, this.sizeY]);
1079
+ }
1080
+ }
1081
+ ngAfterViewInit() {
1082
+ this.initiated = true;
1083
+ }
1084
+ };
1085
+ AXWidgetSizePropertyEditorComponent.ctorParameters = () => [
1086
+ { type: ChangeDetectorRef }
1087
+ ];
1088
+ AXWidgetSizePropertyEditorComponent = __decorate([
1089
+ Component({
1090
+ template: "<div style=\"display: flex;\">\r\n <div style=\"margin-inline-end: 0.5em;flex: calc(50% - 0.25em);\">\r\n <ax-number-box (onValueChanged)=\"handleMinValueChange($event)\" [value]=\"sizeX\" [min]=\"minX\" [max]=\"maxX\">\r\n </ax-number-box>\r\n </div>\r\n <div style=\"flex: calc(50% - 0.25em);\">\r\n <ax-number-box (onValueChanged)=\"handleMaxValueChange($event)\" [value]=\"sizeY\" [min]=\"minY\" [max]=\"maxY\">\r\n </ax-number-box>\r\n </div>\r\n</div>"
1091
+ }),
1092
+ __metadata("design:paramtypes", [ChangeDetectorRef])
1093
+ ], AXWidgetSizePropertyEditorComponent);
1094
+
1095
+ let AXWidgetSizePropertyEditorModule = class AXWidgetSizePropertyEditorModule {
1096
+ constructor() {
1097
+ }
1098
+ };
1099
+ AXWidgetSizePropertyEditorModule = __decorate([
1100
+ NgModule({
1101
+ declarations: [AXWidgetSizePropertyEditorComponent],
1102
+ imports: [CommonModule, FormsModule, AXNumberBoxModule],
1103
+ exports: [AXWidgetSizePropertyEditorComponent],
1104
+ entryComponents: [AXWidgetSizePropertyEditorComponent],
1105
+ providers: [],
1106
+ }),
1107
+ __metadata("design:paramtypes", [])
1108
+ ], AXWidgetSizePropertyEditorModule);
1109
+
1110
+ let AXWidgetBoardModule = class AXWidgetBoardModule {
1111
+ /**
1112
+ *
1113
+ */
1114
+ constructor() {
1115
+ AXTranslator.load('en', {
1116
+ 'widget-board': {
1117
+ 'configurable-props': 'Configurable Properties',
1118
+ configure: 'Configure Widget'
1119
+ }
1120
+ });
1121
+ AXTranslator.load('fa', {
1122
+ 'widget-board': {
1123
+ 'configurable-props': 'ویژگی های قابل تنظیم',
1124
+ configure: 'پیکر بندی ابزارک'
1125
+ }
1126
+ });
1127
+ }
1128
+ };
1129
+ AXWidgetBoardModule = __decorate([
1130
+ NgModule({
1131
+ imports: [
1132
+ CommonModule,
1133
+ AXSearchBoxModule,
1134
+ AXLoadingModule,
1135
+ RouterModule,
1136
+ AXProppertyEditorModule,
1137
+ AXPageModule,
1138
+ AXToolbarModule,
1139
+ AXTranslatorModule,
1140
+ AXLabelModule,
1141
+ AXTextAreaModule,
1142
+ AXFieldsetModule,
1143
+ AXTextBoxModule,
1144
+ AXFormGroupModule,
1145
+ AXTabStripModule,
1146
+ AXCheckBoxModule,
1147
+ AXMenuModule,
1148
+ AXTranslatorModule,
1149
+ AXWidgetSizePropertyEditorModule,
1150
+ AXValidationModule,
1151
+ RouterModule.forChild([
1152
+ {
1153
+ component: AXWidgetSizePropertyEditorComponent,
1154
+ path: 'ax/editors/widget-size'
1155
+ },
1156
+ ])
1157
+ ],
1158
+ exports: [AXWidgetBoardComponent, AXProppertyEditorModule],
1159
+ declarations: [AXWidgetBoardComponent, AXWidgetHostComponent, AXWidgetConfigComponent, AXWidgetSaveComponent],
1160
+ entryComponents: [AXWidgetConfigComponent, AXWidgetSaveComponent],
1161
+ providers: []
1162
+ }),
1163
+ __metadata("design:paramtypes", [])
1164
+ ], AXWidgetBoardModule);
1165
+
1166
+ /**
1167
+ * Generated bundle index. Do not edit.
1168
+ */
1169
+
1170
+ export { AXWidgetBoardComponent, AXWidgetBoardModule, AXWidgetComponent, AXWidgetHostComponent, AXWidgetSizePropertyEditorComponent, AXWidgetSizePropertyEditorModule, ɵ0, AXWidgetConfigComponent as ɵa, AXWidgetSaveComponent as ɵb };
1171
+ //# sourceMappingURL=acorex-layout.js.map