@ecodev/natural 38.0.0 → 40.1.0

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/localize/init'), require('@angular/core'), require('rxjs'), require('@angular/forms'), require('@angular/router'), require('lodash-es'), require('@angular/material/dialog'), require('@angular/material/snack-bar'), require('rxjs/operators'), require('@angular/material/table'), require('@angular/cdk/collections'), require('apollo-angular'), require('@apollo/client/core'), require('@angular/material/core'), require('@angular/cdk/platform'), require('@angular/common'), require('@angular/material/button'), require('@angular/material/checkbox'), require('@angular/material/menu'), require('@angular/material/icon'), require('@angular/platform-browser'), require('@angular/material/tooltip'), require('@angular/material/tabs'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/material/select'), require('@angular/material/list'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/cdk/a11y'), require('@angular/animations'), require('@angular/material/datepicker'), require('@angular/cdk/tree'), require('@angular/material/chips'), require('@angular/material/progress-spinner'), require('@angular/material/tree'), require('@angular/material/autocomplete'), require('@angular/cdk/coercion'), require('@angular/flex-layout'), require('@angular/flex-layout/core'), require('@angular/material/paginator'), require('@angular/material/sidenav'), require('ts-md5')) :
3
- typeof define === 'function' && define.amd ? define('@ecodev/natural', ['exports', '@angular/localize/init', '@angular/core', 'rxjs', '@angular/forms', '@angular/router', 'lodash-es', '@angular/material/dialog', '@angular/material/snack-bar', 'rxjs/operators', '@angular/material/table', '@angular/cdk/collections', 'apollo-angular', '@apollo/client/core', '@angular/material/core', '@angular/cdk/platform', '@angular/common', '@angular/material/button', '@angular/material/checkbox', '@angular/material/menu', '@angular/material/icon', '@angular/platform-browser', '@angular/material/tooltip', '@angular/material/tabs', '@angular/material/form-field', '@angular/material/input', '@angular/material/select', '@angular/material/list', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/cdk/a11y', '@angular/animations', '@angular/material/datepicker', '@angular/cdk/tree', '@angular/material/chips', '@angular/material/progress-spinner', '@angular/material/tree', '@angular/material/autocomplete', '@angular/cdk/coercion', '@angular/flex-layout', '@angular/flex-layout/core', '@angular/material/paginator', '@angular/material/sidenav', 'ts-md5'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ecodev = global.ecodev || {}, global.ecodev.natural = {}), global.ng.localize.init, global.ng.core, global.rxjs, global.ng.forms, global.ng.router, global["lodash-es"], global.ng.material.dialog, global.ng.material.snackBar, global.rxjs.operators, global.ng.material.table, global.ng.cdk.collections, global["apollo-angular"], global.core, global.ng.material.core, global.ng.cdk.platform, global.ng.common, global.ng.material.button, global.ng.material.checkbox, global.ng.material.menu, global.ng.material.icon, global.ng.platformBrowser, global.ng.material.tooltip, global.ng.material.tabs, global.ng.material.formField, global.ng.material.input, global.ng.material.select, global.ng.material.list, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.cdk.a11y, global.ng.animations, global.ng.material.datepicker, global.ng.cdk.tree, global.ng.material.chips, global.ng.material.progressSpinner, global.ng.material.tree, global.ng.material.autocomplete, global.ng.cdk.coercion, global.ng.flexLayout, global.ng.flexLayout.core, global.ng.material.paginator, global.ng.material.sidenav, global.tsMd5));
5
- })(this, (function (exports, init, i0, rxjs, forms, i1$1, lodashEs, i1, i2, operators, table, collections, i1$2, core, i1$3, i2$1, i1$4, button, checkbox, menu, icon, i2$2, tooltip, tabs, formField, input, select, list, i1$5, portal, a11y, animations, datepicker, tree$1, chips, progressSpinner, tree, autocomplete, coercion, flexLayout, i4, paginator, sidenav, tsMd5) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/localize/init'), require('@angular/core'), require('rxjs'), require('@angular/forms'), require('@angular/router'), require('lodash-es'), require('@angular/material/dialog'), require('@angular/material/snack-bar'), require('rxjs/operators'), require('@angular/material/table'), require('@angular/cdk/collections'), require('apollo-angular'), require('@apollo/client/core'), require('@angular/material/core'), require('@angular/cdk/platform'), require('@angular/common'), require('@angular/material/button'), require('@angular/material/checkbox'), require('@angular/material/menu'), require('@angular/material/icon'), require('@angular/platform-browser'), require('@angular/material/tooltip'), require('@angular/material/tabs'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/material/select'), require('@angular/material/list'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/cdk/a11y'), require('@angular/animations'), require('@angular/material/datepicker'), require('@angular/cdk/tree'), require('@angular/material/chips'), require('@angular/material/progress-spinner'), require('@angular/material/tree'), require('@angular/material/autocomplete'), require('@angular/cdk/coercion'), require('@angular/flex-layout'), require('@angular/flex-layout/core'), require('@angular/material/paginator'), require('@angular/material/sidenav'), require('ts-md5'), require('prosemirror-view'), require('prosemirror-state'), require('prosemirror-example-setup'), require('prosemirror-model'), require('prosemirror-schema-basic'), require('prosemirror-schema-list')) :
3
+ typeof define === 'function' && define.amd ? define('@ecodev/natural', ['exports', '@angular/localize/init', '@angular/core', 'rxjs', '@angular/forms', '@angular/router', 'lodash-es', '@angular/material/dialog', '@angular/material/snack-bar', 'rxjs/operators', '@angular/material/table', '@angular/cdk/collections', 'apollo-angular', '@apollo/client/core', '@angular/material/core', '@angular/cdk/platform', '@angular/common', '@angular/material/button', '@angular/material/checkbox', '@angular/material/menu', '@angular/material/icon', '@angular/platform-browser', '@angular/material/tooltip', '@angular/material/tabs', '@angular/material/form-field', '@angular/material/input', '@angular/material/select', '@angular/material/list', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/cdk/a11y', '@angular/animations', '@angular/material/datepicker', '@angular/cdk/tree', '@angular/material/chips', '@angular/material/progress-spinner', '@angular/material/tree', '@angular/material/autocomplete', '@angular/cdk/coercion', '@angular/flex-layout', '@angular/flex-layout/core', '@angular/material/paginator', '@angular/material/sidenav', 'ts-md5', 'prosemirror-view', 'prosemirror-state', 'prosemirror-example-setup', 'prosemirror-model', 'prosemirror-schema-basic', 'prosemirror-schema-list'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ecodev = global.ecodev || {}, global.ecodev.natural = {}), global.ng.localize.init, global.ng.core, global.rxjs, global.ng.forms, global.ng.router, global["lodash-es"], global.ng.material.dialog, global.ng.material.snackBar, global.rxjs.operators, global.ng.material.table, global.ng.cdk.collections, global["apollo-angular"], global.core, global.ng.material.core, global.ng.cdk.platform, global.ng.common, global.ng.material.button, global.ng.material.checkbox, global.ng.material.menu, global.ng.material.icon, global.ng.platformBrowser, global.ng.material.tooltip, global.ng.material.tabs, global.ng.material.formField, global.ng.material.input, global.ng.material.select, global.ng.material.list, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.cdk.a11y, global.ng.animations, global.ng.material.datepicker, global.ng.cdk.tree, global.ng.material.chips, global.ng.material.progressSpinner, global.ng.material.tree, global.ng.material.autocomplete, global.ng.cdk.coercion, global.ng.flexLayout, global.ng.flexLayout.core, global.ng.material.paginator, global.ng.material.sidenav, global.tsMd5, global.prosemirrorView, global.prosemirrorState, global.prosemirrorExampleSetup, global.prosemirrorModel, global.prosemirrorSchemaBasic, global.prosemirrorSchemaList));
5
+ })(this, (function (exports, init, i0, rxjs, forms, i1$1, lodashEs, i1, i2, operators, table, collections, i1$2, core, i1$3, i2$1, i1$4, button, checkbox, menu, icon, i2$2, tooltip, tabs, formField, input, select, list, i1$5, portal, a11y, animations, datepicker, tree$1, chips, progressSpinner, tree, autocomplete, coercion, flexLayout, i4, paginator, sidenav, tsMd5, prosemirrorView, prosemirrorState, prosemirrorExampleSetup, prosemirrorModel, prosemirrorSchemaBasic, prosemirrorSchemaList) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -2384,6 +2384,21 @@
2384
2384
  return rxjs.timer(500).pipe(operators.switchMap(function () { return modelService.count(qvm).pipe(operators.map(function (count) { return (count > 0 ? { duplicateValue: count } : null); })); }));
2385
2385
  };
2386
2386
  }
2387
+ /**
2388
+ * Returns an async validator function that checks that the form control value is available
2389
+ *
2390
+ * Similar to `unique` validator, but allows to use a custom query for when the client does
2391
+ * not have permissions for `modelService.count()`.
2392
+ */
2393
+ function available(getAvailableQuery, excludedId) {
2394
+ if (excludedId === void 0) { excludedId = null; }
2395
+ return function (control) {
2396
+ if (!control.value || !control.dirty) {
2397
+ return rxjs.of(null);
2398
+ }
2399
+ return rxjs.timer(500).pipe(operators.switchMap(function () { return getAvailableQuery(control.value, excludedId).pipe(operators.map(function (isAvailable) { return (isAvailable ? null : { available: true }); })); }));
2400
+ };
2401
+ }
2387
2402
  /**
2388
2403
  * Return all errors recursively for the given Form or control
2389
2404
  */
@@ -3357,7 +3372,7 @@
3357
3372
  * Components inheriting from this class can be used as standalone with input attributes.
3358
3373
  *
3359
3374
  * Usage :
3360
- * <natural-my-listing [forcedVariables]="{filter:...}" [initialColumns]="['col1']" [persistSearch]="false">
3375
+ * <natural-my-listing [forcedVariables]="{filter:...}" [selectedColumns]="['col1']" [persistSearch]="false">
3361
3376
  */
3362
3377
  // @dynamic
3363
3378
  var NaturalAbstractList = /** @class */ (function (_super) {
@@ -3373,7 +3388,7 @@
3373
3388
  /**
3374
3389
  * Columns list after interaction with <natural-columns-picker>
3375
3390
  */
3376
- _this._selectedColumns = [];
3391
+ _this.columnsForTable = [];
3377
3392
  /**
3378
3393
  * The default column selection that automatically happened after <natural-columns-picker> initialization
3379
3394
  */
@@ -3443,11 +3458,14 @@
3443
3458
  /**
3444
3459
  * Persist search and then launch whatever is required to refresh the list
3445
3460
  */
3446
- NaturalAbstractList.prototype.search = function (naturalSearchSelections, navigationExtras) {
3461
+ NaturalAbstractList.prototype.search = function (naturalSearchSelections, navigationExtras, resetPagination) {
3462
+ if (resetPagination === void 0) { resetPagination = true; }
3447
3463
  // Reset page index to restart the pagination (preserve pageSize)
3448
- this.variablesManager.merge('pagination', {
3449
- pagination: lodashEs.pick(this.defaultPagination, ['offset', 'pageIndex']),
3450
- });
3464
+ if (resetPagination) {
3465
+ this.variablesManager.merge('pagination', {
3466
+ pagination: lodashEs.pick(this.defaultPagination, ['offset', 'pageIndex']),
3467
+ });
3468
+ }
3451
3469
  // Persist if activated
3452
3470
  // Two parallel navigations conflict. We first persist the search, then the pagination
3453
3471
  if (this.persistSearch && !this.isPanel) {
@@ -3621,7 +3639,7 @@
3621
3639
  * Uses data provided by router such as:
3622
3640
  *
3623
3641
  * - `route.data.forcedVariables`
3624
- * - `route.data.initialColumns`
3642
+ * - `route.data.selectedColumns`
3625
3643
  */
3626
3644
  NaturalAbstractList.prototype.initFromRoute = function () {
3627
3645
  // Variables
@@ -3629,8 +3647,8 @@
3629
3647
  this.applyForcedVariables(this.route.snapshot.data.forcedVariables);
3630
3648
  }
3631
3649
  // Columns
3632
- if (this.route.snapshot.data.initialColumns) {
3633
- this.initialColumns = this.route.snapshot.data.initialColumns;
3650
+ if (this.route.snapshot.data.selectedColumns) {
3651
+ this.selectedColumns = this.route.snapshot.data.selectedColumns;
3634
3652
  }
3635
3653
  };
3636
3654
  NaturalAbstractList.prototype.getDataObservable = function () {
@@ -3656,6 +3674,11 @@
3656
3674
  if (sorting) {
3657
3675
  this.variablesManager.set('sorting', { sorting: sorting });
3658
3676
  }
3677
+ // Columns
3678
+ var persistedColumns = this.persistenceService.get('col', this.route, storageKey);
3679
+ if (typeof persistedColumns === 'string') {
3680
+ this.selectedColumns = persistedColumns.split(',');
3681
+ }
3659
3682
  // Natural search : ns
3660
3683
  this.naturalSearchSelections = fromUrl(this.persistenceService.get('ns', this.route, storageKey));
3661
3684
  this.translateSearchAndRefreshList(this.naturalSearchSelections, true);
@@ -3713,34 +3736,21 @@
3713
3736
  this.variablesManager.set('sorting', { sorting: variables.sorting });
3714
3737
  }
3715
3738
  };
3716
- Object.defineProperty(NaturalAbstractList.prototype, "selectedColumns", {
3717
- get: function () {
3718
- return this._selectedColumns;
3719
- },
3720
- set: function (columns) {
3721
- this._selectedColumns = columns;
3722
- if (!this.persistSearch || this.isPanel) {
3723
- return;
3724
- }
3725
- // The first selection we receive is the default one made by <natural-columns-picker>
3726
- if (!this.defaultSelectedColumns) {
3727
- this.defaultSelectedColumns = columns;
3728
- // Now that we know the defaults, we can try to reload from persistence
3729
- var storageKey = this.getStorageKey();
3730
- var persistedColumns = this.persistenceService.get('col', this.route, storageKey);
3731
- if (typeof persistedColumns === 'string') {
3732
- this.selectedColumns = persistedColumns.split(',');
3733
- }
3734
- }
3735
- else {
3736
- // Persist only if wanted columns are different from default selection
3737
- var value = lodashEs.isEqual(this.defaultSelectedColumns, columns) ? null : columns.join(',');
3738
- this.persistenceService.persist('col', value, this.route, this.getStorageKey());
3739
- }
3740
- },
3741
- enumerable: false,
3742
- configurable: true
3743
- });
3739
+ NaturalAbstractList.prototype.selectColumns = function (columns) {
3740
+ this.columnsForTable = columns;
3741
+ if (!this.persistSearch || this.isPanel) {
3742
+ return;
3743
+ }
3744
+ // The first selection we receive is the default one made by <natural-columns-picker>
3745
+ if (!this.defaultSelectedColumns) {
3746
+ this.defaultSelectedColumns = columns;
3747
+ }
3748
+ else {
3749
+ // Persist only if wanted columns are different from default selection
3750
+ var value = lodashEs.isEqual(this.defaultSelectedColumns, columns) ? null : columns.join(',');
3751
+ this.persistenceService.persist('col', value, this.route, this.getStorageKey());
3752
+ }
3753
+ };
3744
3754
  return NaturalAbstractList;
3745
3755
  }(NaturalAbstractPanel));
3746
3756
  NaturalAbstractList.decorators = [
@@ -3752,7 +3762,7 @@
3752
3762
  ]; };
3753
3763
  NaturalAbstractList.propDecorators = {
3754
3764
  persistSearch: [{ type: i0.Input }],
3755
- initialColumns: [{ type: i0.Input }],
3765
+ selectedColumns: [{ type: i0.Input }],
3756
3766
  forcedVariables: [{ type: i0.Input }]
3757
3767
  };
3758
3768
  var templateObject_1$6, templateObject_2$1, templateObject_3$1, templateObject_4$1;
@@ -3771,6 +3781,7 @@
3771
3781
  * Name of filter for child items to access ancestor item
3772
3782
  */
3773
3783
  _this.ancestorRelationName = 'parent';
3784
+ _this.oldAncertorId = null;
3774
3785
  _this.breadcrumbs = [];
3775
3786
  return _this;
3776
3787
  }
@@ -3781,27 +3792,30 @@
3781
3792
  // "na" is a trailing param, and should be considered only when there is no search
3782
3793
  this.route.params.subscribe(function (params) {
3783
3794
  // "ns" stands for natural-search to be shorter in url
3784
- if (!params['ns']) {
3785
- var navigationConditionValue = null;
3786
- // "na" stands for "navigation" (relation) in url
3787
- if (params['na']) {
3788
- navigationConditionValue = { have: { values: [params['na']] } };
3789
- _this.service.getOne(params['na']).subscribe(
3790
- // TODO casting should disappear and instead this class should enforce
3791
- // the service to support Tone with a new generic
3792
- function (ancestor) { return (_this.breadcrumbs = _this.getBreadcrumb(ancestor)); });
3793
- _this.clearSearch();
3794
- }
3795
- else {
3796
- navigationConditionValue = { empty: {} };
3797
- _this.breadcrumbs = [];
3798
- }
3799
- var condition = {};
3800
- condition[_this.ancestorRelationName] = navigationConditionValue;
3801
- var variables = { filter: { groups: [{ conditions: [condition] }] } };
3802
- // todo : check why without "as Vall" it errors. Vall is supposed to be QueryVariables, and filter too.
3803
- _this.variablesManager.set('navigation', variables);
3795
+ if (params['ns']) {
3796
+ return;
3797
+ }
3798
+ var navigationConditionValue = null;
3799
+ // "na" stands for "navigation" (relation) in url
3800
+ if (params['na']) {
3801
+ navigationConditionValue = { have: { values: [params['na']] } };
3802
+ _this.service.getOne(params['na']).subscribe(
3803
+ // TODO casting should disappear and instead this class should enforce
3804
+ // the service to support Tone with a new generic
3805
+ function (ancestor) { return (_this.breadcrumbs = _this.getBreadcrumb(ancestor)); });
3806
+ var hasAncestorChanged = params['na'] !== _this.oldAncertorId;
3807
+ _this.oldAncertorId = params['na'];
3808
+ _this.clearSearch(hasAncestorChanged);
3804
3809
  }
3810
+ else {
3811
+ navigationConditionValue = { empty: {} };
3812
+ _this.breadcrumbs = [];
3813
+ }
3814
+ var condition = {};
3815
+ condition[_this.ancestorRelationName] = navigationConditionValue;
3816
+ var variables = { filter: { groups: [{ conditions: [condition] }] } };
3817
+ // todo : check why without "as Vall" it errors. Vall is supposed to be QueryVariables, and filter too.
3818
+ _this.variablesManager.set('navigation', variables);
3805
3819
  });
3806
3820
  _super.prototype.ngOnInit.call(this);
3807
3821
  };
@@ -3834,11 +3848,19 @@
3834
3848
  }
3835
3849
  _super.prototype.translateSearchAndRefreshList.call(this, naturalSearchSelections);
3836
3850
  };
3837
- NaturalAbstractNavigableList.prototype.clearSearch = function () {
3851
+ NaturalAbstractNavigableList.prototype.clearSearch = function (resetPagination) {
3852
+ if (resetPagination === void 0) { resetPagination = true; }
3838
3853
  this.naturalSearchSelections = [[]];
3839
- this.search([[]]);
3854
+ _super.prototype.search.call(this, [[]], undefined, resetPagination);
3840
3855
  this.persistenceService.persistInStorage('ns', null, this.getStorageKey());
3841
3856
  };
3857
+ NaturalAbstractNavigableList.prototype.search = function (naturalSearchSelections, navigationExtras, resetPagination) {
3858
+ var _this = this;
3859
+ if (resetPagination === void 0) { resetPagination = true; }
3860
+ this.persistenceService.persistInUrl('na', null, this.route).then(function () {
3861
+ _super.prototype.search.call(_this, naturalSearchSelections, navigationExtras, resetPagination);
3862
+ });
3863
+ };
3842
3864
  /**
3843
3865
  * Return an array for router link usage
3844
3866
  */
@@ -3938,6 +3960,17 @@
3938
3960
  return;
3939
3961
  }));
3940
3962
  }
3963
+ /**
3964
+ * For debugging purpose only, will dump in console everything that happen to
3965
+ * the observable
3966
+ */
3967
+ function debug(debugName) {
3968
+ return operators.tap({
3969
+ next: function (value) { return console.log('NEXT', debugName, value); },
3970
+ error: function (error) { return console.log('ERROR', debugName, error); },
3971
+ complete: function () { return console.log('COMPLETE', debugName); },
3972
+ });
3973
+ }
3941
3974
 
3942
3975
  var NaturalAbstractModelService = /** @class */ (function () {
3943
3976
  function NaturalAbstractModelService(apollo, name, oneQuery, allQuery, createMutation, updateMutation, deleteMutation) {
@@ -4829,20 +4862,38 @@
4829
4862
  function NaturalColumnsPickerComponent(changeDetectorRef) {
4830
4863
  this.changeDetectorRef = changeDetectorRef;
4831
4864
  /**
4832
- * Emit a list of column keys whenever the selection changes
4865
+ * Emit a list of valid and selected column keys whenever the selection changes
4833
4866
  */
4834
4867
  this.selectionChange = new i0.EventEmitter();
4835
- this.defaultSelectionChange = new i0.EventEmitter();
4868
+ /**
4869
+ * Available columns are defined by options in the template
4870
+ */
4836
4871
  this.availableColumns = null;
4872
+ /**
4873
+ * Displayed options in the dropdown menu
4874
+ */
4837
4875
  this.displayedColumns = [];
4838
4876
  this.ngUnsubscribe = new rxjs.Subject();
4839
4877
  }
4840
- Object.defineProperty(NaturalColumnsPickerComponent.prototype, "selection", {
4878
+ Object.defineProperty(NaturalColumnsPickerComponent.prototype, "selections", {
4879
+ /**
4880
+ * Set the columns that are wanted but might be unavailable.
4881
+ *
4882
+ * If a column is unavailable it will be ignored silently. To know what columns were actually applied
4883
+ * you should use `selectionChange`.
4884
+ *
4885
+ * It is often set once on component initialization, but it can also be set again later in the lifespan of the component.
4886
+ */
4841
4887
  set: function (columns) {
4842
4888
  var _a;
4889
+ this._selections = columns;
4890
+ if (!columns || !this.availableColumns) {
4891
+ return;
4892
+ }
4843
4893
  (_a = this.availableColumns) === null || _a === void 0 ? void 0 : _a.forEach(function (col) {
4844
4894
  col.checked = columns.includes(col.key);
4845
4895
  });
4896
+ this.updateColumns();
4846
4897
  },
4847
4898
  enumerable: false,
4848
4899
  configurable: true
@@ -4859,8 +4910,10 @@
4859
4910
  var _this = this;
4860
4911
  var _a, _b, _c;
4861
4912
  (_a = this.availableColumns) === null || _a === void 0 ? void 0 : _a.forEach(function (col) {
4862
- col.checked = _this.initialSelection ? _this.initialSelection.includes(col.key) : col.checked;
4913
+ var _a;
4914
+ col.checked = ((_a = _this._selections) === null || _a === void 0 ? void 0 : _a.length) ? _this._selections.includes(col.key) : col.checked;
4863
4915
  });
4916
+ // Show options only for columns that are not hidden
4864
4917
  this.displayedColumns = (_c = (_b = this.availableColumns) === null || _b === void 0 ? void 0 : _b.filter(function (col) { return !col.hidden; })) !== null && _c !== void 0 ? _c : [];
4865
4918
  };
4866
4919
  NaturalColumnsPickerComponent.prototype.updateColumns = function () {
@@ -4885,10 +4938,8 @@
4885
4938
  { type: i0.ChangeDetectorRef }
4886
4939
  ]; };
4887
4940
  NaturalColumnsPickerComponent.propDecorators = {
4888
- selection: [{ type: i0.Input }],
4941
+ selections: [{ type: i0.Input }],
4889
4942
  selectionChange: [{ type: i0.Output }],
4890
- defaultSelectionChange: [{ type: i0.Output }],
4891
- initialSelection: [{ type: i0.Input }],
4892
4943
  availableColumns: [{ type: i0.ContentChildren, args: [NaturalColumnsPickerColumnDirective,] }]
4893
4944
  };
4894
4945
 
@@ -11080,6 +11131,142 @@
11080
11131
  { type: i2$2.Title }
11081
11132
  ]; };
11082
11133
 
11134
+ /*
11135
+ * Public API Surface of natural
11136
+ */
11137
+
11138
+ var myNodes = {
11139
+ heading: prosemirrorSchemaBasic.nodes.heading,
11140
+ doc: prosemirrorSchemaBasic.nodes.doc,
11141
+ paragraph: prosemirrorSchemaBasic.nodes.paragraph,
11142
+ text: prosemirrorSchemaBasic.nodes.text,
11143
+ hard_break: prosemirrorSchemaBasic.nodes.hard_break,
11144
+ };
11145
+ var myMarks = {
11146
+ link: prosemirrorSchemaBasic.marks.link,
11147
+ em: prosemirrorSchemaBasic.marks.em,
11148
+ strong: prosemirrorSchemaBasic.marks.strong,
11149
+ };
11150
+ var basicSchema = new prosemirrorModel.Schema({ nodes: myNodes, marks: myMarks });
11151
+ var schema = new prosemirrorModel.Schema({
11152
+ nodes: prosemirrorSchemaList.addListNodes(basicSchema.spec.nodes, 'paragraph block*', 'block'),
11153
+ marks: basicSchema.spec.marks,
11154
+ });
11155
+
11156
+ /**
11157
+ * Prosemirror component
11158
+ * Usage :
11159
+ * <natural-editor [(ngModel)]="htmlString"></natural-editor>
11160
+ */
11161
+ // @dynamic
11162
+ var NaturalEditorComponent = /** @class */ (function () {
11163
+ function NaturalEditorComponent(ngControl, document) {
11164
+ this.ngControl = ngControl;
11165
+ this.document = document;
11166
+ this.view = null;
11167
+ this.contentChange = new i0.EventEmitter();
11168
+ /**
11169
+ * HTML string
11170
+ */
11171
+ this.content = '';
11172
+ if (this.ngControl !== null) {
11173
+ this.ngControl.valueAccessor = this;
11174
+ }
11175
+ }
11176
+ NaturalEditorComponent.prototype.ngOnInit = function () {
11177
+ var _this = this;
11178
+ var serializer = prosemirrorModel.DOMSerializer.fromSchema(schema);
11179
+ var state = this.createState();
11180
+ this.view = new prosemirrorView.EditorView(this.editor.nativeElement, {
11181
+ state: state,
11182
+ dispatchTransaction: function (transaction) {
11183
+ if (!_this.view) {
11184
+ return;
11185
+ }
11186
+ var newState = _this.view.state.apply(transaction);
11187
+ _this.view.updateState(newState);
11188
+ // Transform doc into HTML string
11189
+ var dom = serializer.serializeFragment(_this.view.state.doc);
11190
+ var el = _this.document.createElement('_');
11191
+ el.appendChild(dom);
11192
+ var newContent = el.innerHTML;
11193
+ if (_this.content === newContent) {
11194
+ return;
11195
+ }
11196
+ _this.content = el.innerHTML;
11197
+ if (_this.onChange) {
11198
+ _this.onChange(_this.content);
11199
+ }
11200
+ _this.contentChange.emit(_this.content);
11201
+ },
11202
+ });
11203
+ };
11204
+ NaturalEditorComponent.prototype.writeValue = function (val) {
11205
+ if (typeof val === 'string' && val !== this.content) {
11206
+ this.content = val;
11207
+ }
11208
+ if (this.view !== null) {
11209
+ var state = this.createState();
11210
+ this.view.updateState(state);
11211
+ }
11212
+ };
11213
+ NaturalEditorComponent.prototype.createState = function () {
11214
+ var template = this.document.createElement('_');
11215
+ template.innerHTML = '<div>' + this.content + '</div>';
11216
+ if (!template.firstChild) {
11217
+ throw new Error('child of template element could not be created');
11218
+ }
11219
+ var parser = prosemirrorModel.DOMParser.fromSchema(schema);
11220
+ var doc = parser.parse(template.firstChild);
11221
+ return prosemirrorState.EditorState.create({
11222
+ doc: doc,
11223
+ plugins: prosemirrorExampleSetup.exampleSetup({ schema: schema }),
11224
+ });
11225
+ };
11226
+ NaturalEditorComponent.prototype.registerOnChange = function (fn) {
11227
+ this.onChange = fn;
11228
+ };
11229
+ NaturalEditorComponent.prototype.registerOnTouched = function (fn) { };
11230
+ NaturalEditorComponent.prototype.setDisabledState = function (isDisabled) {
11231
+ // TODO disable editor ?
11232
+ };
11233
+ NaturalEditorComponent.prototype.ngOnDestroy = function () {
11234
+ if (this.view) {
11235
+ this.view.destroy();
11236
+ this.view = null;
11237
+ }
11238
+ };
11239
+ return NaturalEditorComponent;
11240
+ }());
11241
+ NaturalEditorComponent.decorators = [
11242
+ { type: i0.Component, args: [{
11243
+ selector: 'natural-editor',
11244
+ template: " <div #editor></div>",
11245
+ styles: ["@charset \"UTF-8\";::ng-deep .ProseMirror{position:relative;background:rgba(0,0,0,.1)}::ng-deep .ProseMirror{word-wrap:break-word;white-space:pre-wrap;-webkit-font-variant-ligatures:none;font-feature-settings:none;font-variant-ligatures:none}::ng-deep .ProseMirror pre{white-space:pre-wrap}::ng-deep .ProseMirror li{position:relative}::ng-deep .ProseMirror-hideselection *::selection{background:transparent}::ng-deep .ProseMirror-hideselection *::-moz-selection{background:transparent}::ng-deep .ProseMirror-hideselection{caret-color:transparent}::ng-deep .ProseMirror-selectednode{outline:2px solid #8cf}::ng-deep li.ProseMirror-selectednode{outline:none}::ng-deep li.ProseMirror-selectednode:after{content:\"\";position:absolute;left:-32px;right:-2px;top:-2px;bottom:-2px;border:2px solid #8cf;pointer-events:none}::ng-deep .ProseMirror-textblock-dropdown{min-width:3em}::ng-deep .ProseMirror-menu{margin:20px;line-height:1}::ng-deep .ProseMirror-tooltip .ProseMirror-menu{width:-moz-fit-content;width:fit-content;white-space:pre}::ng-deep .ProseMirror-menuitem{margin-right:8px;display:inline-block}::ng-deep .ProseMirror-menuseparator{border-right:1px solid rgba(255,255,255,.3);margin-right:12px}::ng-deep .ProseMirror-menu-dropdown,::ng-deep .ProseMirror-menu-dropdown-menu{white-space:nowrap}::ng-deep .ProseMirror-menu-dropdown{vertical-align:1px;cursor:pointer;position:relative;padding-right:15px}::ng-deep .ProseMirror-menu-dropdown-wrap{padding:1px 0 1px 4px;display:inline-block;position:relative}::ng-deep .ProseMirror-menu-dropdown:after{content:\"\";border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 2px)}::ng-deep .ProseMirror-menu-dropdown-menu,::ng-deep .ProseMirror-menu-submenu{position:absolute;background:white;color:#666;padding:2px;border-radius:4px;box-shadow:0 5px 5px #00000080}::ng-deep .ProseMirror-menu-dropdown-menu{z-index:15;min-width:6em;padding:6px;top:40px}::ng-deep .ProseMirror-menu-dropdown-item{cursor:pointer;padding:12px}::ng-deep .ProseMirror-menu-dropdown-item:hover{background:#f2f2f2}::ng-deep .ProseMirror-menu-submenu{padding:6px}::ng-deep .ProseMirror-menu-submenu-wrap{position:relative;margin-right:-4px}::ng-deep .ProseMirror-menu-submenu-label:after{content:\"\";border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 4px)}::ng-deep .ProseMirror-menu-submenu{display:none;min-width:6em;left:100%;top:-17px}::ng-deep .ProseMirror-menu-active{background:white;color:#000}::ng-deep .ProseMirror-menu-disabled{opacity:.3}::ng-deep .ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu,::ng-deep .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu{display:block}::ng-deep .ProseMirror-menubar{border-top-left-radius:inherit;border-top-right-radius:inherit;position:relative;min-height:1em;color:#fffc;padding:10px 18px;top:0;left:0;right:0;background:rgba(0,0,0,.8);z-index:10;box-sizing:border-box;overflow:visible;font-size:18px}::ng-deep .ProseMirror-icon{display:inline-block;line-height:.8;vertical-align:-2px;padding:8px;cursor:pointer;border-radius:4px}::ng-deep .ProseMirror-menu-disabled.ProseMirror-icon{cursor:default}::ng-deep .ProseMirror-icon svg{fill:currentColor;height:1em}::ng-deep .ProseMirror-icon span{vertical-align:text-top}::ng-deep .ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}::ng-deep .ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}::ng-deep .ProseMirror-focused .ProseMirror-gapcursor{display:block}::ng-deep .ProseMirror-example-setup-style hr{padding:2px 10px;border:none;margin:1em 0}::ng-deep .ProseMirror-example-setup-style hr:after{content:\"\";display:block;height:1px;background-color:silver;line-height:2px}::ng-deep .ProseMirror ul,::ng-deep .ProseMirror ol{padding-left:30px}::ng-deep .ProseMirror blockquote{padding-left:1em;border-left:3px solid #eee;margin-left:0;margin-right:0}::ng-deep .ProseMirror-example-setup-style img{cursor:default}::ng-deep .ProseMirror-prompt{background:white;padding:20px;position:fixed;border-radius:4px;z-index:11;box-shadow:-.5px 2px 15px #000c;font-size:16px;color:#000}::ng-deep .ProseMirror-prompt h5{margin:0;font-weight:normal;font-size:24px}::ng-deep .ProseMirror-prompt input[type=text],::ng-deep .ProseMirror-prompt textarea{background:rgba(0,0,0,.1);border:none;border-bottom:1px solid rgba(0,0,0,.8);outline:none;padding:10px 20px;margin:.4em 0;width:20em;border-top-left-radius:4px;border-top-right-radius:4px;font-size:16px;color:#000}::ng-deep .ProseMirror-prompt-close{position:absolute;left:2px;top:1px;color:#000;border:none;background:transparent;padding:0}::ng-deep .ProseMirror-prompt-close:after{content:\"\\e2\\153\\2022\";font-size:12px}::ng-deep .ProseMirror-invalid{background:#ffc;border:1px solid #cc7;border-radius:4px;padding:5px 10px;position:absolute;min-width:10em}::ng-deep .ProseMirror-prompt-buttons{margin-top:5px;display:none}::ng-deep #editor,::ng-deep .editor{background:white;color:#000;background-clip:padding-box;border-radius:4px;border:2px solid rgba(0,0,0,.2);padding:5px 0;margin-bottom:23px}::ng-deep .ProseMirror p:first-child,::ng-deep .ProseMirror h1:first-child,::ng-deep .ProseMirror h2:first-child,::ng-deep .ProseMirror h3:first-child,::ng-deep .ProseMirror h4:first-child,::ng-deep .ProseMirror h5:first-child,::ng-deep .ProseMirror h6:first-child{margin-top:10px}::ng-deep .ProseMirror{padding:4px 8px 4px 14px;line-height:1.2;outline:none}::ng-deep .ProseMirror p{margin-bottom:1em}\n"]
11246
+ },] }
11247
+ ];
11248
+ NaturalEditorComponent.ctorParameters = function () { return [
11249
+ { type: forms.NgControl, decorators: [{ type: i0.Optional }, { type: i0.Self }] },
11250
+ { type: Document, decorators: [{ type: i0.Inject, args: [i1$4.DOCUMENT,] }] }
11251
+ ]; };
11252
+ NaturalEditorComponent.propDecorators = {
11253
+ editor: [{ type: i0.ViewChild, args: ['editor', { read: i0.ElementRef, static: true },] }],
11254
+ contentChange: [{ type: i0.Output }]
11255
+ };
11256
+
11257
+ var NaturalEditorModule = /** @class */ (function () {
11258
+ function NaturalEditorModule() {
11259
+ }
11260
+ return NaturalEditorModule;
11261
+ }());
11262
+ NaturalEditorModule.decorators = [
11263
+ { type: i0.NgModule, args: [{
11264
+ declarations: [NaturalEditorComponent],
11265
+ imports: [i1$4.CommonModule],
11266
+ exports: [NaturalEditorComponent],
11267
+ },] }
11268
+ ];
11269
+
11083
11270
  /*
11084
11271
  * Public API Surface of natural
11085
11272
  */
@@ -11120,6 +11307,8 @@
11120
11307
  exports.NaturalDialogTriggerModule = NaturalDialogTriggerModule;
11121
11308
  exports.NaturalDropdownComponentsModule = NaturalDropdownComponentsModule;
11122
11309
  exports.NaturalDropdownRef = NaturalDropdownRef;
11310
+ exports.NaturalEditorComponent = NaturalEditorComponent;
11311
+ exports.NaturalEditorModule = NaturalEditorModule;
11123
11312
  exports.NaturalEllipsisPipe = NaturalEllipsisPipe;
11124
11313
  exports.NaturalEnumPipe = NaturalEnumPipe;
11125
11314
  exports.NaturalEnumService = NaturalEnumService;
@@ -11181,9 +11370,11 @@
11181
11370
  exports.TypeNumberComponent = TypeNumberComponent;
11182
11371
  exports.TypeSelectComponent = TypeSelectComponent;
11183
11372
  exports.TypeTextComponent = TypeTextComponent;
11373
+ exports.available = available;
11184
11374
  exports.cancellableTimeout = cancellableTimeout;
11185
11375
  exports.cleanSameValues = cleanSameValues;
11186
11376
  exports.collectErrors = collectErrors;
11377
+ exports.debug = debug;
11187
11378
  exports.decimal = decimal;
11188
11379
  exports.deliverableEmail = deliverableEmail;
11189
11380
  exports.ensureHttpPrefix = ensureHttpPrefix;