@hestia-earth/ui-components 0.0.9 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +5 -22
  2. package/bibliographies/bibliographies-search-confirm/bibliographies-search-confirm.component.d.ts +1 -1
  3. package/bundles/hestia-earth-ui-components.umd.js +1736 -165
  4. package/bundles/hestia-earth-ui-components.umd.js.map +1 -1
  5. package/common/blank-node-state/blank-node-state.component.d.ts +2 -2
  6. package/common/delta-utils.d.ts +1 -1
  7. package/common/link-key-value/link-key-value.component.d.ts +1 -1
  8. package/common/maps-utils.d.ts +2 -2
  9. package/common/precision.pipe.d.ts +1 -1
  10. package/common/tags-input.directive.d.ts +1 -1
  11. package/common/utils.d.ts +7 -7
  12. package/cycles/cycles-emissions-chart/cycles-emissions-chart.component.d.ts +2 -2
  13. package/cycles/cycles-suggest-form/cycles-suggest-form.component.d.ts +1 -2
  14. package/cycles/cycles.model.d.ts +1 -1
  15. package/engine/aggregation-engine.service.d.ts +2 -2
  16. package/engine/engine.service.d.ts +3 -3
  17. package/esm2015/common/tags-input.directive.js +3 -3
  18. package/esm2015/files/files-error-summary.model.js +55 -0
  19. package/esm2015/files/files-error.model.js +2 -2
  20. package/esm2015/files/files-form.model.js +6 -6
  21. package/esm2015/files/index.js +2 -1
  22. package/esm2015/tags-input/defaultOptions.js +26 -0
  23. package/esm2015/tags-input/index.js +1053 -0
  24. package/esm2015/tags-input/templates/dropdown-item.js +3 -0
  25. package/esm2015/tags-input/templates/tag.js +6 -0
  26. package/esm2015/tags-input/templates/wrapper.js +10 -0
  27. package/esm2015/tags-input/utils/component.js +80 -0
  28. package/esm2015/tags-input/utils/dom.js +98 -0
  29. package/esm2015/tags-input/utils/events.js +147 -0
  30. package/esm2015/tags-input/utils/type.js +41 -0
  31. package/esm2015/tags-input/utils/uuid.js +3 -0
  32. package/fesm2015/hestia-earth-ui-components.js +1575 -75
  33. package/fesm2015/hestia-earth-ui-components.js.map +1 -1
  34. package/files/files-error-summary.model.d.ts +27 -0
  35. package/files/files-error.model.d.ts +6 -6
  36. package/files/files-form/files-form.component.d.ts +7 -7
  37. package/files/files-form.model.d.ts +11 -11
  38. package/files/index.d.ts +1 -0
  39. package/impact-assessments/impact-assessments-indicators-chart/impact-assessments-indicators-chart.component.d.ts +2 -2
  40. package/impact-assessments/impact-assessments-products/impact-assessments-products.component.d.ts +2 -2
  41. package/node/node-icon/node-icon.component.d.ts +1 -1
  42. package/node/node-link/node-link.component.d.ts +1 -1
  43. package/node/node-logs-models/node-logs-models.component.d.ts +1 -1
  44. package/node/node.service.d.ts +2 -2
  45. package/package.json +1 -2
  46. package/schema/schema.service.d.ts +1 -1
  47. package/search/search.model.d.ts +18 -17
  48. package/search/search.service.d.ts +7 -7
  49. package/sites/sites-maps/sites-maps.component.d.ts +1 -1
  50. package/sites/sites-measurements/sites-measurements.component.d.ts +1 -1
  51. package/sites/sites.model.d.ts +1 -1
  52. package/styles.scss +1 -1
  53. package/tags-input/defaultOptions.d.ts +25 -0
  54. package/tags-input/index.d.ts +277 -0
  55. package/tags-input/styles.sass +154 -0
  56. package/tags-input/templates/dropdown-item.d.ts +2 -0
  57. package/tags-input/templates/tag.d.ts +2 -0
  58. package/tags-input/templates/wrapper.d.ts +2 -0
  59. package/tags-input/utils/component.d.ts +22 -0
  60. package/tags-input/utils/dom.d.ts +38 -0
  61. package/tags-input/utils/events.d.ts +72 -0
  62. package/tags-input/utils/type.d.ts +17 -0
  63. package/tags-input/utils/uuid.d.ts +2 -0
  64. package/terms/terms.model.d.ts +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@ng-bootstrap/ng-bootstrap'), require('@angular/google-maps'), require('@fortawesome/angular-fontawesome'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-solid-svg-icons'), require('@angular/platform-browser'), require('rxjs'), require('random-material-color'), require('@hestia-earth/schema'), require('@hestia-earth/api'), require('@hestia-earth/utils'), require('pluralize'), require('rxjs/operators'), require('csvtojson'), require('@angular/common/http'), require('@hestia-earth/bulma-tagsinput'), require('json-2-csv'), require('@angular/cdk/drag-drop'), require('@hestia-earth/schema-convert'), require('@hestia-earth/json-schema/schema-utils'), require('jsondiffpatch'), require('chart.js'), require('moment'), require('moment/locale/en-gb'), require('uuid'), require('@google/markerclustererplus'), require('chartjs-plugin-datalabels')) :
3
- typeof define === 'function' && define.amd ? define('@hestia-earth/ui-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@ng-bootstrap/ng-bootstrap', '@angular/google-maps', '@fortawesome/angular-fontawesome', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-solid-svg-icons', '@angular/platform-browser', 'rxjs', 'random-material-color', '@hestia-earth/schema', '@hestia-earth/api', '@hestia-earth/utils', 'pluralize', 'rxjs/operators', 'csvtojson', '@angular/common/http', '@hestia-earth/bulma-tagsinput', 'json-2-csv', '@angular/cdk/drag-drop', '@hestia-earth/schema-convert', '@hestia-earth/json-schema/schema-utils', 'jsondiffpatch', 'chart.js', 'moment', 'moment/locale/en-gb', 'uuid', '@google/markerclustererplus', 'chartjs-plugin-datalabels'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["hestia-earth"] = global["hestia-earth"] || {}, global["hestia-earth"]["ui-components"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.i10, global.ng.googleMaps, global.i1, global.freeRegularSvgIcons, global.freeSolidSvgIcons, global.ng.platformBrowser, global.rxjs, global.randomMaterialColor, global.schema, global.api, global.utils, global.pluralize, global.rxjs.operators, global.csvtojson, global.ng.common.http, global.BulmaTagsInput, global.json2Csv, global.ng.cdk.dragDrop, global.schemaConvert, global.schemaUtils, global.jsondiffpatch, global.chart_js, global.moment, null, global.uuid, global.MarkerClusterer, global.ChartDataLabels));
5
- })(this, (function (exports, i0, i3, i1$2, i4, i10, i1$4, i1, freeRegularSvgIcons, freeSolidSvgIcons, i1$1, rxjs, randomMaterialColor, schema, api, utils, pluralize, operators, csvtojson, i1$3, BulmaTagsInput, json2Csv, i6, schemaConvert, schemaUtils, jsondiffpatch, chart_js, moment, enGb, uuid, MarkerClusterer, ChartDataLabels) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@ng-bootstrap/ng-bootstrap'), require('@angular/google-maps'), require('@fortawesome/angular-fontawesome'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-solid-svg-icons'), require('@angular/platform-browser'), require('rxjs'), require('random-material-color'), require('@hestia-earth/schema'), require('@hestia-earth/api'), require('@hestia-earth/utils'), require('pluralize'), require('rxjs/operators'), require('csvtojson'), require('@angular/common/http'), require('json-2-csv'), require('@angular/cdk/drag-drop'), require('@hestia-earth/schema-convert'), require('@hestia-earth/json-schema/schema-utils'), require('jsondiffpatch'), require('chart.js'), require('moment'), require('moment/locale/en-gb'), require('uuid'), require('@google/markerclustererplus'), require('chartjs-plugin-datalabels')) :
3
+ typeof define === 'function' && define.amd ? define('@hestia-earth/ui-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@ng-bootstrap/ng-bootstrap', '@angular/google-maps', '@fortawesome/angular-fontawesome', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-solid-svg-icons', '@angular/platform-browser', 'rxjs', 'random-material-color', '@hestia-earth/schema', '@hestia-earth/api', '@hestia-earth/utils', 'pluralize', 'rxjs/operators', 'csvtojson', '@angular/common/http', 'json-2-csv', '@angular/cdk/drag-drop', '@hestia-earth/schema-convert', '@hestia-earth/json-schema/schema-utils', 'jsondiffpatch', 'chart.js', 'moment', 'moment/locale/en-gb', 'uuid', '@google/markerclustererplus', 'chartjs-plugin-datalabels'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["hestia-earth"] = global["hestia-earth"] || {}, global["hestia-earth"]["ui-components"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.i10, global.ng.googleMaps, global.i1, global.freeRegularSvgIcons, global.freeSolidSvgIcons, global.ng.platformBrowser, global.rxjs, global.randomMaterialColor, global.schema, global.api, global.utils, global.pluralize, global.rxjs.operators, global.csvtojson, global.ng.common.http, global.json2Csv, global.ng.cdk.dragDrop, global.schemaConvert, global.schemaUtils, global.jsondiffpatch, global.chart_js, global.moment, null, global.uuid$1, global.MarkerClusterer, global.ChartDataLabels));
5
+ })(this, (function (exports, i0, i3, i1$2, i4, i10, i1$4, i1, freeRegularSvgIcons, freeSolidSvgIcons, i1$1, rxjs, randomMaterialColor, schema, api, utils, pluralize, operators, csvtojson, i1$3, json2Csv, i6, schemaConvert, schemaUtils, jsondiffpatch, chart_js, moment, enGb, uuid$1, MarkerClusterer, ChartDataLabels) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -35,7 +35,6 @@
35
35
  var pluralize__namespace = /*#__PURE__*/_interopNamespace(pluralize);
36
36
  var csvtojson__namespace = /*#__PURE__*/_interopNamespace(csvtojson);
37
37
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$3);
38
- var BulmaTagsInput__default = /*#__PURE__*/_interopDefaultLegacy(BulmaTagsInput);
39
38
  var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
40
39
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
41
40
  var MarkerClusterer__default = /*#__PURE__*/_interopDefaultLegacy(MarkerClusterer);
@@ -573,7 +572,7 @@
573
572
  }] });
574
573
 
575
574
  var _a$6;
576
- var get$4 = require('lodash.get');
575
+ var get$5 = require('lodash.get');
577
576
  var gitHome = 'https://gitlab.com/hestia-earth';
578
577
  var gitRawBaseUrl = 'https://glcdn.githack.com/hestia-earth';
579
578
  var gitBranch = function () { return ['dev', 'staging'].some(function (env) { return baseUrl().includes(env); }) ? 'develop' : 'master'; };
@@ -585,7 +584,7 @@
585
584
  'https://www.hestia.earth'; };
586
585
  var isExternal = function () { return baseUrl() !== window.location.origin; };
587
586
  var parseErrorStatus = function (error) { return ((error === null || error === void 0 ? void 0 : error.statusText) || '').toLowerCase().replace(/\s/g, '-'); };
588
- var parseErrorMessage = function (error) { return get$4(error, 'error.error', get$4(error, 'error.message', get$4(error, 'error', get$4(error, 'message', error)))); };
587
+ var parseErrorMessage = function (error) { return get$5(error, 'error.error', get$5(error, 'error.message', get$5(error, 'error', get$5(error, 'message', error)))); };
589
588
  var handleAPIError = function (error) {
590
589
  try {
591
590
  error = parseErrorMessage(error);
@@ -687,7 +686,7 @@
687
686
  group[termId].values[nodeId].nodes.push(blankNode);
688
687
  group[termId].values[nodeId].value = concatBlankNodeValue(group[termId].values[nodeId].value, blankNode.value);
689
688
  grouppedValueKeys.forEach(function (arrayKey) {
690
- var newValue = get$4(blankNode, arrayKey, []);
689
+ var newValue = get$5(blankNode, arrayKey, []);
691
690
  group[termId].values[nodeId][arrayKey] = __spreadArray(__spreadArray([], __read((group[termId].values[nodeId][arrayKey] || []))), __read((Array.isArray(newValue) ? newValue : [newValue])));
692
691
  });
693
692
  return group;
@@ -697,7 +696,7 @@
697
696
  Object.keys(group.values).map(function (nodeId) {
698
697
  var index = group.values[nodeId].index;
699
698
  var termId = group.term['@id'];
700
- var originalValue = get$4(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
699
+ var originalValue = get$5(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
701
700
  if (originalValue.length > 0) {
702
701
  var value = originalValue.reduce(function (array, curr) { return concatBlankNodeValue(array, curr.value); }, []);
703
702
  group.originalValues[nodeId] = { value: propertyValue$1(value) };
@@ -2200,172 +2199,1674 @@
2200
2199
  });
2201
2200
  Object.defineProperty(SkeletonTextComponent.prototype, "hasWidth", {
2202
2201
  get: function () {
2203
- return this.width + "%";
2202
+ return this.width + "%";
2203
+ },
2204
+ enumerable: false,
2205
+ configurable: true
2206
+ });
2207
+ Object.defineProperty(SkeletonTextComponent.prototype, "hasHeight", {
2208
+ get: function () {
2209
+ return this.height;
2210
+ },
2211
+ enumerable: false,
2212
+ configurable: true
2213
+ });
2214
+ return SkeletonTextComponent;
2215
+ }());
2216
+ SkeletonTextComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkeletonTextComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2217
+ SkeletonTextComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkeletonTextComponent, selector: "he-skeleton-text", inputs: { animated: "animated", width: "width", height: "height" }, host: { properties: { "class.is-animated": "this.isAnimated", "style.width": "this.hasWidth", "style.height": "this.hasHeight" } }, ngImport: i0__namespace, template: "<span>&nbsp;</span>\n", styles: [":host{border-radius:2px;display:block;width:100%;height:inherit;margin-top:4px;margin-bottom:4px;background:rgba(0,0,0,.065);line-height:10px;-webkit-user-select:none;user-select:none;pointer-events:none}span{display:inline-block}:host(.is-animated){position:relative;background:linear-gradient(to right,rgba(0,0,0,.065) 8%,rgba(0,0,0,.135) 18%,rgba(0,0,0,.065) 33%);background-size:800px 104px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:shimmer;animation-timing-function:linear}@keyframes shimmer{0%{background-position:-468px 0}to{background-position:468px 0}}\n"] });
2218
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkeletonTextComponent, decorators: [{
2219
+ type: i0.Component,
2220
+ args: [{
2221
+ selector: 'he-skeleton-text',
2222
+ templateUrl: './skeleton-text.component.html',
2223
+ styleUrls: ['./skeleton-text.component.scss']
2224
+ }]
2225
+ }], propDecorators: { animated: [{
2226
+ type: i0.Input
2227
+ }], width: [{
2228
+ type: i0.Input
2229
+ }], height: [{
2230
+ type: i0.Input
2231
+ }], isAnimated: [{
2232
+ type: i0.HostBinding,
2233
+ args: ['class.is-animated']
2234
+ }], hasWidth: [{
2235
+ type: i0.HostBinding,
2236
+ args: ['style.width']
2237
+ }], hasHeight: [{
2238
+ type: i0.HostBinding,
2239
+ args: ['style.height']
2240
+ }] } });
2241
+
2242
+ var parsePropertyValue = function (value) { return utils.isNumber(value) ? +value : (utils.isBoolean(value) ? value.toString() === 'true' : value); };
2243
+ var parseResult = function (value) { return isNaN(value) ? '' : ("" + value).replace(',', '.'); };
2244
+ var UnitConverterComponent = /** @class */ (function () {
2245
+ function UnitConverterComponent() {
2246
+ this.value = 1;
2247
+ this.ConvertUnits = utils.ConvertUnits;
2248
+ this.result = '';
2249
+ this.arguments = [];
2250
+ }
2251
+ UnitConverterComponent.prototype.ngOnInit = function () {
2252
+ return this.updateValue();
2253
+ };
2254
+ Object.defineProperty(UnitConverterComponent.prototype, "args", {
2255
+ get: function () {
2256
+ var _a;
2257
+ return (((_a = this.term) === null || _a === void 0 ? void 0 : _a.defaultProperties) || []).reduce(function (prev, prop) {
2258
+ var _c;
2259
+ var _a, _b;
2260
+ return (Object.assign(Object.assign({}, prev), (_c = {}, _c[(_b = (_a = prop.term) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()] = parsePropertyValue(prop.value), _c)));
2261
+ }, {});
2262
+ },
2263
+ enumerable: false,
2264
+ configurable: true
2265
+ });
2266
+ Object.defineProperty(UnitConverterComponent.prototype, "units", {
2267
+ get: function () {
2268
+ var _this = this;
2269
+ return this.fromUnits ?
2270
+ Object.values(utils.ConvertUnits).filter(function (v) { return v in utils.converters[_this.fromUnits]; }) :
2271
+ [];
2272
+ },
2273
+ enumerable: false,
2274
+ configurable: true
2275
+ });
2276
+ UnitConverterComponent.prototype.requireArgs = function (keys) {
2277
+ var args = this.args;
2278
+ this.arguments = keys.map(function (key) { return ({ key: key, value: args[key] || '' }); });
2279
+ };
2280
+ UnitConverterComponent.prototype.updateUnits = function () {
2281
+ var requiredKeys = [];
2282
+ if (this.fromUnits === utils.ConvertUnits.kg || this.toUnits === utils.ConvertUnits.kg) {
2283
+ requiredKeys = ['density'];
2284
+ }
2285
+ this.requireArgs(requiredKeys);
2286
+ return this.updateValue();
2287
+ };
2288
+ UnitConverterComponent.prototype.updateValue = function () {
2289
+ if (!this.fromUnits || !this.toUnits) {
2290
+ return;
2291
+ }
2292
+ var args = Object.assign(Object.assign({}, this.args), this.arguments.reduce(function (prev, _c) {
2293
+ var _d;
2294
+ var key = _c.key, value = _c.value;
2295
+ return (Object.assign(Object.assign({}, prev), (_d = {}, _d[key] = value, _d)));
2296
+ }, {}));
2297
+ try {
2298
+ this.result = parseResult(utils.convertValue(this.value, this.fromUnits, this.toUnits, args));
2299
+ }
2300
+ catch (_) { }
2301
+ };
2302
+ return UnitConverterComponent;
2303
+ }());
2304
+ UnitConverterComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: UnitConverterComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2305
+ UnitConverterComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: UnitConverterComponent, selector: "he-unit-converter", inputs: { term: "term", value: "value", fromUnits: "fromUnits", toUnits: "toUnits" }, ngImport: i0__namespace, template: "<div class=\"columns mb-0\">\n <div class=\"column\">\n <label class=\"label has-text-white\" for=\"value\">Value</label>\n </div>\n <div class=\"column\">\n <label class=\"label has-text-white\" for=\"result\">Convert To</label>\n </div>\n</div>\n\n<div class=\"columns\">\n <div class=\"column\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <input type=\"number\" class=\"input\" [(ngModel)]=\"value\" name=\"value\" id=\"value\"\n (input)=\"updateValue()\"\n >\n </div>\n <div class=\"control is-expanded\">\n <div class=\"select is-fullwidth\">\n <select [(ngModel)]=\"fromUnits\" name=\"fromUnits\" id=\"fromUnits\"\n (change)=\"updateUnits()\"\n >\n <option [value]=\"undefined\">Unit</option>\n <option *ngFor=\"let unit of ConvertUnits | keys\" [value]=\"unit.value\">{{unit.key}}</option>\n </select>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"column\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <input type=\"string\" class=\"input\" [value]=\"result\" name=\"result\" id=\"result\" readonly>\n </div>\n <div class=\"control\">\n <div class=\"select is-fullwidth\">\n <select [(ngModel)]=\"toUnits\" name=\"toUnits\" id=\"toUnits\"\n (change)=\"updateUnits()\"\n >\n <option [value]=\"undefined\">Unit</option>\n <option *ngFor=\"let unit of units\" [value]=\"unit\">{{unit}}</option>\n </select>\n </div>\n </div>\n <div class=\"control\">\n <he-clipboard clipboardClass=\"button is-white px-2\"\n [value]=\"result\" [disabled]=\"!result\" [hideText]=\"true\"\n ></he-clipboard>\n </div>\n </div>\n </div>\n</div>\n\n<div class=\"field is-horizontal\" *ngFor=\"let arg of arguments\">\n <div class=\"field-label is-normal\">\n <label class=\"label has-text-white\" [for]=\"arg.key\">\n <span class=\"is-capitalized\">{{arg.key}}</span>\n <span class=\"has-text-danger pl-1\">*</span>\n </label>\n </div>\n <div class=\"field-body\">\n <div class=\"field\">\n <div class=\"control\">\n <input type=\"string\" class=\"input is-small\"\n [(ngModel)]=\"arg.value\" [id]=\"arg.key\"\n (input)=\"updateValue()\"\n placeholder=\"Required for conversion\"\n >\n </div>\n </div>\n </div>\n</div>\n", styles: [".select{min-width:85px}\n"], components: [{ type: ClipboardComponent, selector: "he-clipboard", inputs: ["value", "disabled", "hideText", "icon", "size", "rotate", "clipboardClass"] }], directives: [{ type: i1__namespace$4.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i1__namespace$4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1__namespace$4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1__namespace$4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1__namespace$4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i1__namespace$4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1__namespace$4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "keys": KeysPipe } });
2306
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: UnitConverterComponent, decorators: [{
2307
+ type: i0.Component,
2308
+ args: [{
2309
+ selector: 'he-unit-converter',
2310
+ templateUrl: './unit-converter.component.html',
2311
+ styleUrls: ['./unit-converter.component.scss']
2312
+ }]
2313
+ }], propDecorators: { term: [{
2314
+ type: i0.Input
2315
+ }], value: [{
2316
+ type: i0.Input
2317
+ }], fromUnits: [{
2318
+ type: i0.Input
2319
+ }], toUnits: [{
2320
+ type: i0.Input
2321
+ }] } });
2322
+
2323
+ /* eslint-disable @angular-eslint/directive-selector */
2324
+ var ClickOutsideDirective = /** @class */ (function () {
2325
+ function ClickOutsideDirective(elementRef) {
2326
+ this.elementRef = elementRef;
2327
+ this.clickOutside = new i0.EventEmitter();
2328
+ }
2329
+ ClickOutsideDirective.prototype.onClick = function (event) {
2330
+ if (!this.elementRef.nativeElement.contains(event.target)) {
2331
+ this.clickOutside.emit();
2332
+ }
2333
+ };
2334
+ return ClickOutsideDirective;
2335
+ }());
2336
+ ClickOutsideDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ClickOutsideDirective, deps: [{ token: i0__namespace.ElementRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2337
+ ClickOutsideDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: ClickOutsideDirective, selector: "[clickOutside]", outputs: { clickOutside: "clickOutside" }, host: { listeners: { "document:click": "onClick($event)" } }, ngImport: i0__namespace });
2338
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ClickOutsideDirective, decorators: [{
2339
+ type: i0.Directive,
2340
+ args: [{
2341
+ selector: '[clickOutside]'
2342
+ }]
2343
+ }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }]; }, propDecorators: { clickOutside: [{
2344
+ type: i0.Output
2345
+ }], onClick: [{
2346
+ type: i0.HostListener,
2347
+ args: ['document:click', ['$event']]
2348
+ }] } });
2349
+
2350
+ var get$4 = require('lodash.get');
2351
+ var GetPipe = /** @class */ (function () {
2352
+ function GetPipe() {
2353
+ }
2354
+ GetPipe.prototype.transform = function (value, key, defaultValue) {
2355
+ if (defaultValue === void 0) { defaultValue = ''; }
2356
+ return get$4(value, key, defaultValue);
2357
+ };
2358
+ return GetPipe;
2359
+ }());
2360
+ GetPipe.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: GetPipe, deps: [], target: i0__namespace.ɵɵFactoryTarget.Pipe });
2361
+ GetPipe.ɵpipe = i0__namespace.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: GetPipe, name: "get" });
2362
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: GetPipe, decorators: [{
2363
+ type: i0.Pipe,
2364
+ args: [{
2365
+ name: 'get'
2366
+ }]
2367
+ }] });
2368
+
2369
+ /* eslint-disable */
2370
+ /**
2371
+ * @class EventEmitter
2372
+ *
2373
+ * @property {Array} _listeners
2374
+ */
2375
+ var EventEmitter = /** @class */ (function () {
2376
+ /**
2377
+ * Construct EventEmitter
2378
+ *
2379
+ * @param listeners
2380
+ */
2381
+ function EventEmitter(listeners) {
2382
+ if (listeners === void 0) { listeners = []; }
2383
+ this._listeners = new Map(listeners);
2384
+ }
2385
+ /**
2386
+ * Destroys EventEmitter
2387
+ */
2388
+ EventEmitter.prototype.destroy = function () {
2389
+ this._listeners = {};
2390
+ };
2391
+ /**
2392
+ * Count listeners registered for the provided eventName
2393
+ *
2394
+ * @param eventName
2395
+ */
2396
+ EventEmitter.prototype.listenerCount = function (eventName) {
2397
+ if (!this._listeners.has(eventName)) {
2398
+ return 0;
2399
+ }
2400
+ return this._listeners.get(eventName).length;
2401
+ };
2402
+ /**
2403
+ * Subscribes on event eventName specified function
2404
+ *
2405
+ * @param eventName
2406
+ * @param listener
2407
+ */
2408
+ EventEmitter.prototype.on = function (eventName, listener) {
2409
+ this._addListener(eventName, listener, false);
2410
+ };
2411
+ /**
2412
+ * Subscribes on event name specified function to fire only once
2413
+ *
2414
+ * @param eventName
2415
+ * @param listener
2416
+ */
2417
+ EventEmitter.prototype.once = function (eventName, listener) {
2418
+ this._addListener(eventName, listener, true);
2419
+ };
2420
+ /**
2421
+ * Removes event with specified eventName.
2422
+ *
2423
+ * @param eventName
2424
+ */
2425
+ EventEmitter.prototype.off = function (eventName) {
2426
+ this._removeListeners(eventName);
2427
+ };
2428
+ /**
2429
+ * Emits event with specified name and params.
2430
+ *
2431
+ * @param eventName
2432
+ * @param eventArgs
2433
+ */
2434
+ EventEmitter.prototype.emit = function (eventName) {
2435
+ var eventArgs = [];
2436
+ for (var _i = 1; _i < arguments.length; _i++) {
2437
+ eventArgs[_i - 1] = arguments[_i];
2438
+ }
2439
+ return this._applyEvents(eventName, eventArgs);
2440
+ };
2441
+ /**
2442
+ * Register a new listener
2443
+ *
2444
+ * @param eventName
2445
+ * @param listener
2446
+ * @param once
2447
+ */
2448
+ EventEmitter.prototype._addListener = function (eventName, listener, once) {
2449
+ var _this = this;
2450
+ if (once === void 0) { once = false; }
2451
+ if (Array.isArray(eventName)) {
2452
+ eventName.forEach(function (e) { return _this._addListener(e, listener, once); });
2453
+ }
2454
+ else {
2455
+ eventName = eventName.toString();
2456
+ var split = eventName.split(/,|, | /);
2457
+ if (split.length > 1) {
2458
+ split.forEach(function (e) { return _this._addListener(e, listener, once); });
2459
+ }
2460
+ else {
2461
+ if (!Array.isArray(this._listeners.get(eventName))) {
2462
+ this._listeners.set(eventName, []);
2463
+ }
2464
+ (this._listeners.get(eventName)).push({
2465
+ once: once,
2466
+ fn: listener
2467
+ });
2468
+ }
2469
+ }
2470
+ };
2471
+ /**
2472
+ *
2473
+ * @param eventName
2474
+ */
2475
+ EventEmitter.prototype._removeListeners = function (eventName) {
2476
+ var _this = this;
2477
+ if (eventName === void 0) { eventName = null; }
2478
+ if (eventName !== null) {
2479
+ if (Array.isArray(eventName)) {
2480
+ eventName.forEach(function (e) { return _this._removeListeners(e); });
2481
+ }
2482
+ else {
2483
+ eventName = eventName.toString();
2484
+ var split = eventName.split(/,|, | /);
2485
+ if (split.length > 1) {
2486
+ split.forEach(function (e) { return _this._removeListeners(e); });
2487
+ }
2488
+ else {
2489
+ this._listeners.delete(eventName);
2490
+ }
2491
+ }
2492
+ }
2493
+ else {
2494
+ this._listeners = new Map();
2495
+ }
2496
+ };
2497
+ /**
2498
+ * Applies arguments to specified event
2499
+ *
2500
+ * @param eventName
2501
+ * @param eventArguments
2502
+ * @protected
2503
+ */
2504
+ EventEmitter.prototype._applyEvents = function (eventName, eventArguments) {
2505
+ var result = eventArguments;
2506
+ if (this._listeners.has(eventName)) {
2507
+ var listeners_1 = this._listeners.get(eventName);
2508
+ var removableListeners_1 = [];
2509
+ listeners_1.forEach(function (listener, index) {
2510
+ if (result = listener.fn.apply(null, eventArguments)) {
2511
+ if (listener.once) {
2512
+ removableListeners_1.unshift(index);
2513
+ }
2514
+ }
2515
+ });
2516
+ removableListeners_1.forEach(function (index) {
2517
+ listeners_1.splice(index, 1);
2518
+ });
2519
+ return result;
2520
+ }
2521
+ return result[0];
2522
+ };
2523
+ return EventEmitter;
2524
+ }());
2525
+
2526
+ var isFunction = function (unknown) { return typeof unknown === 'function'; };
2527
+ var isString = function (unknown) { return (typeof unknown === 'string' ||
2528
+ ((!!unknown && typeof unknown === 'object') && Object.prototype.toString.call(unknown) === '[object String]')); };
2529
+ var isObject = function (unknown) { return ((typeof unknown === 'function' || (typeof unknown === 'object' && !!unknown)) && !Array.isArray(unknown)); };
2530
+ // Returns true if the value has a "then" function. Adapted from
2531
+ // https://github.com/graphql/graphql-js/blob/499a75939f70c4863d44149371d6a99d57ff7c35/src/jsutils/isPromise.js
2532
+ var isPromise = function (value) { return Boolean(value && typeof value.then === 'function'); };
2533
+ var isNode = function (unknown) {
2534
+ try {
2535
+ Node.prototype.cloneNode.call(unknown, false);
2536
+ return true;
2537
+ }
2538
+ catch (err) {
2539
+ return false;
2540
+ }
2541
+ };
2542
+ /**
2543
+ * Convert String (false,False,True,true,no,yes,0,1) to real Boolean
2544
+ *
2545
+ * @param val
2546
+ */
2547
+ var BooleanParse = function (val) {
2548
+ var falsy = /^(?:f(?:alse)?|no?|0+)$/i;
2549
+ return !falsy.test(val) && !!val;
2550
+ };
2551
+ /**
2552
+ * Check if given query selector is valid
2553
+ *
2554
+ * @param selector
2555
+ */
2556
+ var isSelectorValid = function (selector) {
2557
+ var queryCheck = function (s) { return document.createDocumentFragment().querySelector(s); };
2558
+ try {
2559
+ queryCheck(selector);
2560
+ }
2561
+ catch (_a) {
2562
+ return false;
2563
+ }
2564
+ return true;
2565
+ };
2566
+
2567
+ /**
2568
+ * querySelector under steroid
2569
+ * Can use as selector:
2570
+ * - function
2571
+ * - DOM Node
2572
+ * - String
2573
+ *
2574
+ * @param selector
2575
+ * @param node
2576
+ */
2577
+ var querySelector = function (selector, node) {
2578
+ if (isFunction(selector)) {
2579
+ return selector(node);
2580
+ }
2581
+ if (isNode(selector)) {
2582
+ return selector;
2583
+ }
2584
+ if (isString(selector)) {
2585
+ if (!node || !isNode(node) || node.nodeType !== 1) {
2586
+ node = document;
2587
+ }
2588
+ return node.querySelector(selector);
2589
+ }
2590
+ if (Array.isArray(selector) || (typeof NodeList !== 'undefined' && NodeList.prototype.isPrototypeOf(selector))) {
2591
+ return selector[0];
2592
+ }
2593
+ };
2594
+ /**
2595
+ * querySelectorAll under steroid
2596
+ * Can use as selector:
2597
+ * - function
2598
+ * - DOM Node
2599
+ * - String
2600
+ *
2601
+ * @param selector
2602
+ * @param node
2603
+ */
2604
+ var querySelectorAll = function (selector, node) {
2605
+ if (isFunction(selector)) {
2606
+ return selector(node);
2607
+ }
2608
+ if (isNode(selector)) {
2609
+ return [selector];
2610
+ }
2611
+ if (isString(selector)) {
2612
+ if (!node || !isNode(node) || node.nodeType !== 1) {
2613
+ node = document;
2614
+ }
2615
+ return node.querySelectorAll(selector);
2616
+ }
2617
+ if (typeof NodeList !== 'undefined' && NodeList.prototype.isPrototypeOf(selector)) {
2618
+ return selector;
2619
+ }
2620
+ return [];
2621
+ };
2622
+ // Convert dataset into Object
2623
+ var optionsFromDataset = function (node, defaultOptions) {
2624
+ if (defaultOptions === void 0) { defaultOptions = {}; }
2625
+ if (isNode(node)) {
2626
+ return node.dataset ? Object.keys(node.dataset)
2627
+ .filter(function (key) { return Object.keys(defaultOptions).includes(key); })
2628
+ .reduce(function (obj, key) {
2629
+ var _a;
2630
+ return (Object.assign(Object.assign({}, obj), (_a = {}, _a[key] = node.dataset[key], _a)));
2631
+ }, {}) : {};
2632
+ }
2633
+ return {};
2634
+ };
2635
+ /**
2636
+ * Copy HTML attributes from a source element to a target element
2637
+ *
2638
+ * @param target
2639
+ * @param source
2640
+ * @param except list of attributes to skip (separated by space)
2641
+ */
2642
+ var cloneAttributes = function (target, source, except) {
2643
+ if (except === void 0) { except = null; }
2644
+ if (except !== null) {
2645
+ except = except.split(' ');
2646
+ }
2647
+ __spreadArray([], __read(source.attributes)).forEach(function (attr) {
2648
+ if (!except.includes(attr.nodeName)) {
2649
+ target.setAttribute(attr.nodeName === 'id' ? 'data-id' : attr.nodeName, attr.nodeValue);
2650
+ }
2651
+ });
2652
+ };
2653
+ /**
2654
+ * Escapes string for insertion into HTML, replacing special characters with HTML
2655
+ * entities.
2656
+ *
2657
+ * @param string
2658
+ */
2659
+ var escape = function (string) { return isString(string) ?
2660
+ string.replace(/(['"<>])/g, function (char) { return ({
2661
+ '<': '&lt;',
2662
+ '>': '&gt;',
2663
+ '"': '&quot;',
2664
+ '\'': '&#39;'
2665
+ }[char]); })
2666
+ : string; };
2667
+
2668
+ /* eslint-disable */
2669
+ var uuid = (function (prefix) {
2670
+ if (prefix === void 0) { prefix = ''; }
2671
+ return (prefix + (1e7 + -1e3 + -4e3 + -8e3 + -1e11)).replace(/[018]/g, function (c) { return (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16); });
2672
+ });
2673
+
2674
+ var Component = /** @class */ (function (_super) {
2675
+ __extends(Component, _super);
2676
+ function Component(element, options, defaultOptions) {
2677
+ if (options === void 0) { options = {}; }
2678
+ if (defaultOptions === void 0) { defaultOptions = {}; }
2679
+ var _this = _super.call(this) || this;
2680
+ _this.element = querySelector(element, document);
2681
+ // An invalid selector or non-DOM node has been provided.
2682
+ if (!_this.element) {
2683
+ throw new Error("An invalid selector or non-DOM node has been provided for " + _this.constructor.name + ".");
2684
+ }
2685
+ _this.id = uuid('c-');
2686
+ _this.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), options), optionsFromDataset(_this.element, defaultOptions) // Use Element dataset values to override options
2687
+ );
2688
+ return _this;
2689
+ }
2690
+ /**
2691
+ * Initiate all DOM element corresponding to selector
2692
+ *
2693
+ * @method
2694
+ * @return Array of all Plugin instances
2695
+ */
2696
+ Component.attach = function (selector, options, node) {
2697
+ var _this = this;
2698
+ if (selector === void 0) { selector = null; }
2699
+ if (options === void 0) { options = {}; }
2700
+ if (node === void 0) { node = null; }
2701
+ var instances = new Array();
2702
+ if (selector !== null) {
2703
+ querySelectorAll(selector, node).forEach(function (element) {
2704
+ // Check if plugin has already been instantiated for element
2705
+ if (typeof element[_this.name] === 'undefined') { // If no then instantiate it and register it in element
2706
+ instances.push(new _this(element, Object.assign({ selector: selector }, options)));
2707
+ }
2708
+ else { // If Yes then return the existing instance
2709
+ instances.push(element[_this.name]);
2710
+ }
2711
+ });
2712
+ if (typeof window[this.name] === 'undefined') {
2713
+ window[this.name] = {
2714
+ observers: []
2715
+ };
2716
+ }
2717
+ if (window[this.name]['observers'] && !window[this.name]['observers'].includes(selector)) {
2718
+ this.observeDom(selector, options);
2719
+ window[this.name]['observers'].push(selector);
2720
+ }
2721
+ }
2722
+ return instances;
2723
+ };
2724
+ /**
2725
+ * Observe DOM mutations to automatically initialize plugin on new elements when added to the DOM
2726
+ *
2727
+ * @param selector
2728
+ * @param options
2729
+ */
2730
+ Component.observeDom = function (selector, options) {
2731
+ var _this = this;
2732
+ var observer = new MutationObserver(function (mutations) {
2733
+ mutations.forEach(function (mutation) {
2734
+ for (var i = 0; i < mutation.addedNodes.length; i++) {
2735
+ if (typeof window[_this.name] !== 'undefined') {
2736
+ _this.attach(selector, options, mutation.addedNodes[i]);
2737
+ }
2738
+ }
2739
+ });
2740
+ });
2741
+ if (typeof document !== 'undefined') {
2742
+ observer.observe(document, {
2743
+ childList: true,
2744
+ subtree: true
2745
+ });
2746
+ }
2747
+ };
2748
+ Component._interface = function (name, options) {
2749
+ if (name === void 0) { name = null; }
2750
+ if (options === void 0) { options = {}; }
2751
+ if (typeof name === 'string') {
2752
+ if (typeof this[name] === 'undefined') {
2753
+ throw new TypeError("No method named \"" + name + "\"");
2754
+ }
2755
+ return this[name](options);
2756
+ }
2757
+ return this;
2758
+ };
2759
+ return Component;
2760
+ }(EventEmitter));
2761
+
2762
+ var defaultOptions = {
2763
+ allowDuplicates: false,
2764
+ caseSensitive: true,
2765
+ clearSelectionOnTyping: false,
2766
+ closeDropdownOnItemSelect: true,
2767
+ delimiter: ',',
2768
+ freeInput: true,
2769
+ highlightDuplicate: true,
2770
+ highlightMatchesString: true,
2771
+ itemValue: undefined,
2772
+ itemText: undefined,
2773
+ maxTags: undefined,
2774
+ maxChars: undefined,
2775
+ minChars: 1,
2776
+ noResultsLabel: 'No results found',
2777
+ placeholder: '',
2778
+ removable: true,
2779
+ searchMinChars: 1,
2780
+ searchOn: 'text',
2781
+ selectable: true,
2782
+ source: undefined,
2783
+ tagClass: 'is-rounded',
2784
+ trim: true // Should we trim value before processing them ?
2785
+ };
2786
+
2787
+ var tagTemplate = (function (data) { return "<span class=\"tag " + escape(data.style) + "\" data-value=\"" + escape(data.value) + "\">\n " + escape(data.text) + "\n " + (data.removable ? '<div class="delete is-small" data-tag="delete"></div>' : '') + "\n </span>"; });
2788
+
2789
+ var containerTemplate = (function (data) { return "<div class=\"tags-input\">\n <input class=\"input\" type=\"text\" placeholder=\"" + escape(data.placeholder) + "\">\n <div id=\"" + escape(data.uuid) + "-list\" class=\"dropdown-menu\" role=\"menu\">\n <div class=\"dropdown-content\">\n <span class=\"dropdown-item empty-title\">" + escape(data.emptyTitle) + "</span>\n </div>\n </div>\n </div>"; });
2790
+
2791
+ var dropdownItemTemplate = (function (data) { return "<a href=\"javascript:void(0);\" class=\"dropdown-item\" data-value=\"" + escape(data.value) + "\" data-text=\"" + escape(data.text) + "\">" + escape(data.text) + "</a>"; });
2792
+
2793
+ // TODO: add pattern or function to valdiate value before adding
2794
+ var BulmaTagsInput = /** @class */ (function (_super) {
2795
+ __extends(BulmaTagsInput, _super);
2796
+ function BulmaTagsInput(element, options) {
2797
+ if (options === void 0) { options = {}; }
2798
+ var _this = _super.call(this, element, options, defaultOptions) || this;
2799
+ // Convert Boolean string options to full Boolean
2800
+ _this.options.allowDuplicates = BooleanParse(_this.options.allowDuplicates);
2801
+ _this.options.caseSensitive = BooleanParse(_this.options.caseSensitive);
2802
+ _this.options.clearSelectionOnTyping = BooleanParse(_this.options.clearSelectionOnTyping);
2803
+ _this.options.closeDropdownOnItemSelect = BooleanParse(_this.options.closeDropdownOnItemSelect);
2804
+ _this.options.freeInput = BooleanParse(_this.options.freeInput);
2805
+ _this.options.highlightDuplicate = BooleanParse(_this.options.highlightDuplicate);
2806
+ _this.options.highlightMatchesString = BooleanParse(_this.options.highlightMatchesString);
2807
+ _this.options.removable = BooleanParse(_this.options.removable);
2808
+ _this.options.searchOn = _this.options.searchOn.toLowerCase();
2809
+ _this.options.selectable = BooleanParse(_this.options.selectable);
2810
+ _this.options.trim = BooleanParse(_this.options.trim);
2811
+ //Bind events to current class
2812
+ _this._onDocumentClick = _this._onDocumentClick.bind(_this);
2813
+ _this._onInputChange = _this._onInputChange.bind(_this);
2814
+ _this._onInputClick = _this._onInputClick.bind(_this);
2815
+ _this._onInputFocusOut = _this._onInputFocusOut.bind(_this);
2816
+ _this._onInputFocusIn = _this._onInputFocusIn.bind(_this);
2817
+ _this._onInputKeyDown = _this._onInputKeyDown.bind(_this);
2818
+ _this._onInputKeyPress = _this._onInputKeyPress.bind(_this);
2819
+ _this._onOriginalInputChange = _this._onOriginalInputChange.bind(_this);
2820
+ _this._onTagDeleteClick = _this._onTagDeleteClick.bind(_this);
2821
+ _this._onTagClick = _this._onTagClick.bind(_this);
2822
+ _this._onDropdownItemClick = _this._onDropdownItemClick.bind(_this);
2823
+ // Define internal variables
2824
+ _this._items = [];
2825
+ _this._selected = -1; // index of selected item
2826
+ // Initiate plugin
2827
+ _this._init();
2828
+ return _this;
2829
+ }
2830
+ /**
2831
+ * Initiate all DOM element corresponding to selector
2832
+ *
2833
+ * @method
2834
+ * @return Array of all Plugin instances
2835
+ */
2836
+ BulmaTagsInput.attach = function (selector, options, container) {
2837
+ if (selector === void 0) { selector = 'input[data-type="tags"], input[type="tags"], select[data-type="tags"], select[type="tags"]'; }
2838
+ if (options === void 0) { options = {}; }
2839
+ if (container === void 0) { container = null; }
2840
+ return _super.attach.call(this, selector, options, container);
2841
+ };
2842
+ /**
2843
+ * Initiate plugin
2844
+ *
2845
+ * @method init
2846
+ * @return
2847
+ */
2848
+ BulmaTagsInput.prototype._init = function () {
2849
+ var _this = this;
2850
+ // Detect if original input was a Select element
2851
+ this._isSelect = (this.element.tagName === 'SELECT');
2852
+ this._isMultiple = (this._isSelect && this.element.hasAttribute('multiple'));
2853
+ // Detect if we work with Object items or not
2854
+ // Object Items is forced when working with select element
2855
+ this._objectItems = (typeof this.options.itemValue !== 'undefined') || this._isSelect;
2856
+ this.options.itemValue = this.options.itemValue ? this.options.itemValue : (this._isSelect ? 'value' : undefined);
2857
+ this.options.itemText = this.options.itemText ? this.options.itemText : (this._isSelect ? 'text' : undefined);
2858
+ // If no itemText pass then use itemValue as itemText
2859
+ if (typeof this.options.itemText === 'undefined') {
2860
+ this.options.itemText = this.options.itemValue;
2861
+ }
2862
+ // Force freeInput to False if working with object items
2863
+ this.options.freeInput = this._objectItems ? false : this.options.freeInput;
2864
+ // Init search engine
2865
+ this.source = null;
2866
+ if (typeof this.options.source !== 'undefined') {
2867
+ // Fix searchOn option if wrong
2868
+ if (!['value', 'text'].includes(this.options.searchOn)) {
2869
+ this.options.searchOn = defaultOptions.searchOn;
2870
+ }
2871
+ if (isPromise(this.options.source)) {
2872
+ this.source = this.options.source;
2873
+ }
2874
+ else if (isFunction(this.options.source)) {
2875
+ this.source = function (value) { return Promise.resolve(_this.options.source(value)); };
2876
+ }
2877
+ else if (Array.isArray(this.options.source)) {
2878
+ this.source = function (value) { return Promise.resolve(_this.options.source.filter(function (i) {
2879
+ var val = (_this._objectItems ? i[_this.options.itemValue] : i);
2880
+ return _this.options.caseSensitive ? val.includes(value) : val.toLowerCase().includes(value.toLowerCase());
2881
+ })); };
2882
+ }
2883
+ }
2884
+ // Determine allowed input modes
2885
+ this._manualInputAllowed = !this._isSelect && this.options.freeInput;
2886
+ this._filterInputAllowed = this._isSelect || this.source;
2887
+ this._build();
2888
+ };
2889
+ /**
2890
+ * Build TagsInput DOM elements
2891
+ */
2892
+ BulmaTagsInput.prototype._build = function () {
2893
+ var _this = this;
2894
+ // Create TagsInput DOM
2895
+ var containerFragment = document.createRange().createContextualFragment(containerTemplate({
2896
+ emptyTitle: typeof this.options.noResultsLabel !== 'undefined' ? this.options.noResultsLabel : 'No results found',
2897
+ placeholder: this.element.placeholder ? this.element.placeholder : this.options.placeholder,
2898
+ uuid: this.id
2899
+ }));
2900
+ this.container = containerFragment.firstElementChild;
2901
+ this._input = this.container.querySelector('input');
2902
+ this.dropdown = this.container.querySelector("#" + this.id + "-list .dropdown-content");
2903
+ this.dropdownEmptyOption = this.dropdown.querySelector('.empty-title');
2904
+ // Clone attributes between original and new input
2905
+ cloneAttributes(this._input, this.element, 'data-type multiple name type value');
2906
+ if (this.element.disabled) {
2907
+ this.container.setAttribute('disabled', 'disabled');
2908
+ this.options.removable = false;
2909
+ this.options.selectable = false;
2910
+ }
2911
+ // Propagate original input disabled attribute to the container
2912
+ if (this._input.getAttribute('disabled') || this._input.classList.contains('is-disabled')) {
2913
+ this.container.setAttribute('disabled', 'disabled');
2914
+ }
2915
+ if (!this._manualInputAllowed) {
2916
+ this.container.classList.add(this._filterInputAllowed ? 'is-filter' : 'no-input');
2917
+ }
2918
+ // Remove dropdown if no source or original input is not a select element
2919
+ if (!this._isSelect && typeof this.options.source === 'undefined') {
2920
+ this.dropdown.remove();
2921
+ this.dropdown = null;
2922
+ this._input.setAttribute('list', null);
2923
+ }
2924
+ // Initialize plugin value from original input value
2925
+ if (this._isSelect) {
2926
+ Array.from(this.element.options).forEach(function (option) {
2927
+ if (option.selected) {
2928
+ // HTML Option element contains value and text properties
2929
+ // Add it silently to not propagate to the original element
2930
+ _this.add(option.value ? option : {
2931
+ value: option.text,
2932
+ text: option.text
2933
+ }, true);
2934
+ }
2935
+ _this._createDropdownItem(option);
2936
+ });
2937
+ }
2938
+ else {
2939
+ // We have on input element
2940
+ if (this.element.value.length) {
2941
+ this.add(this._objectItems ? JSON.parse(this.element.value) : this.element.value, true);
2942
+ }
2943
+ }
2944
+ this._bindEvents();
2945
+ // Insert container right before original input and make original input hidden
2946
+ this.element.parentNode.insertBefore(this.container, this.element);
2947
+ // Hide original input (type="hidden" only works on select)
2948
+ this.element.style.display = 'none';
2949
+ };
2950
+ /**
2951
+ * Bind all events listener
2952
+ */
2953
+ BulmaTagsInput.prototype._bindEvents = function () {
2954
+ // Bind document click event to close dropdown
2955
+ document.addEventListener('click', this._onDocumentClick);
2956
+ // Bind event handlers to orginal input
2957
+ this.element.addEventListener('change', this._onOriginalInputChange);
2958
+ // Bind event handlers to internal input
2959
+ this._input.addEventListener('input', this._onInputChange);
2960
+ this._input.addEventListener('click', this._onInputClick);
2961
+ this._input.addEventListener('keydown', this._onInputKeyDown);
2962
+ this._input.addEventListener('keypress', this._onInputKeyPress);
2963
+ this._input.addEventListener('focusout', this._onInputFocusOut);
2964
+ this._input.addEventListener('focusin', this._onInputFocusIn);
2965
+ };
2966
+ /**
2967
+ * Check if caret is at the beginning of the input value
2968
+ */
2969
+ BulmaTagsInput.prototype._caretAtStart = function () {
2970
+ try {
2971
+ return this._input.selectionStart === 0 && this._input.selectionEnd === 0;
2972
+ }
2973
+ catch (e) {
2974
+ return this._input.value === '';
2975
+ }
2976
+ };
2977
+ /**
2978
+ * Check value length constraint if option activated
2979
+ *
2980
+ * @param item
2981
+ */
2982
+ BulmaTagsInput.prototype._checkLength = function (item) {
2983
+ var value = this._objectItems ? item[this.options.itemValue] : item;
2984
+ if (!isString(value)) {
2985
+ return true;
2986
+ }
2987
+ return value.length >= this.options.minChars && (typeof this.options.maxChars === 'undefined' || value.length <= this.options.maxChars);
2988
+ };
2989
+ /**
2990
+ * Close dropdown
2991
+ */
2992
+ BulmaTagsInput.prototype._closeDropdown = function () {
2993
+ if (this.dropdown) {
2994
+ this.emit('before.dropdown.close', this);
2995
+ this.container.classList.remove('is-active');
2996
+ this.emit('after.dropdown.close', this);
2997
+ }
2998
+ };
2999
+ /**
3000
+ * Create a new dropdown item based on given item data
3001
+ *
3002
+ * @param item
3003
+ */
3004
+ BulmaTagsInput.prototype._createDropdownItem = function (item) {
3005
+ if (this.dropdown) {
3006
+ // TODO: add possibility to provide template through options
3007
+ var dropdownItemFragment = document.createRange().createContextualFragment(dropdownItemTemplate({
3008
+ text: item.text,
3009
+ value: item.value
3010
+ }));
3011
+ var dropdownItem = dropdownItemFragment.firstElementChild;
3012
+ // Save item data into dataset
3013
+ dropdownItem.dataset.value = item.value;
3014
+ dropdownItem.dataset.text = item.text;
3015
+ dropdownItem.addEventListener('click', this._onDropdownItemClick);
3016
+ this.dropdown.append(dropdownItem);
3017
+ }
3018
+ };
3019
+ /**
3020
+ * Create a new tag and add it to the DOM
3021
+ *
3022
+ * @param string value
3023
+ */
3024
+ BulmaTagsInput.prototype._createTag = function (item) {
3025
+ var tagFragment = document.createRange().createContextualFragment(tagTemplate({
3026
+ removable: this.options.removable,
3027
+ style: this.options.tagClass,
3028
+ text: item.text,
3029
+ value: item.value
3030
+ }));
3031
+ var tag = tagFragment.firstElementChild;
3032
+ // Attach tag click event to select it
3033
+ tag.addEventListener('click', this._onTagClick);
3034
+ if (this.options.removable) {
3035
+ // Find delete button and attach click event
3036
+ var deleteButton = tag.querySelector('.delete');
3037
+ if (deleteButton) {
3038
+ deleteButton.addEventListener('click', this._onTagDeleteClick);
3039
+ }
3040
+ }
3041
+ // insert new tag at the end (ie just before input)
3042
+ this.container.insertBefore(tag, this._input);
3043
+ };
3044
+ /**
3045
+ * Remove all dropdown items except the empty title
3046
+ */
3047
+ BulmaTagsInput.prototype._emptyDropdown = function () {
3048
+ if (this.dropdown) {
3049
+ Array.from(this.dropdown.children).filter(function (child) { return !child.classList.contains('empty-title'); }).forEach(function (child) {
3050
+ child.remove();
3051
+ });
3052
+ }
3053
+ };
3054
+ /**
3055
+ * Find needle into a string and wrap it with <mark> HTML tag
3056
+ *
3057
+ * @param string
3058
+ * @param needle
3059
+ */
3060
+ BulmaTagsInput.prototype._highlightMatchesInString = function (string, needle) {
3061
+ var reg = '(' + needle + ')(?![^<]*>|[^<>]*</)'; // explanation: http://stackoverflow.com/a/18622606/1147859
3062
+ var regex = new RegExp(reg, 'i');
3063
+ // If the regex doesn't match the string just return initial string
3064
+ if (!string.match(regex)) {
3065
+ return string;
3066
+ }
3067
+ // Otherwise, get to highlighting
3068
+ var matchStartPosition = string.match(regex).index;
3069
+ var matchEndPosition = matchStartPosition + string.match(regex)[0].toString().length;
3070
+ var originalTextFoundByRegex = string.substring(matchStartPosition, matchEndPosition);
3071
+ string = string.replace(regex, "<mark class=\"is-highlighted\">" + originalTextFoundByRegex + "</mark>");
3072
+ return string;
3073
+ };
3074
+ /**
3075
+ * Open dropdown
3076
+ */
3077
+ BulmaTagsInput.prototype._openDropdown = function () {
3078
+ if (this.dropdown) {
3079
+ this.container.classList.add('is-active');
3080
+ }
3081
+ };
3082
+ /**
3083
+ * Propagate internal input changes to the original input
3084
+ */
3085
+ BulmaTagsInput.prototype._propagateChange = function () {
3086
+ var _this = this;
3087
+ if (!this._isSelect) {
3088
+ // If original element is an input element
3089
+ this.element.value = this.value;
3090
+ }
3091
+ else {
3092
+ // If original element is a select element
3093
+ Array.from(this.element.options).forEach(function (option) {
3094
+ option.setAttribute('selected', undefined);
3095
+ option.selected = false;
3096
+ // If option has been added by TagsInput then we remove it
3097
+ // Otherwise it is an original option
3098
+ if (typeof option.dataset.source !== 'undefined') {
3099
+ option.remove();
3100
+ }
3101
+ });
3102
+ // Update original element options selected attributes
3103
+ this._items.forEach(function (item) {
3104
+ _this._updateSelectOptions({
3105
+ value: _this._objectItems ? item[_this.options.itemValue] : item,
3106
+ text: _this._objectItems ? item[_this.options.itemText] : item
3107
+ });
3108
+ });
3109
+ }
3110
+ // Trigger Change event manually (because original input is now hidden)
3111
+ // Trick: Passes current class constructor name to prevent loop with _onOriginalInputChange handler)
3112
+ var changeEvent = new CustomEvent('change', {
3113
+ detail: this.constructor.name
3114
+ });
3115
+ this.element.dispatchEvent(changeEvent);
3116
+ };
3117
+ /**
3118
+ * Trim value if option activated
3119
+ *
3120
+ * @param item
3121
+ */
3122
+ BulmaTagsInput.prototype._trim = function (item) {
3123
+ if (this.options.trim) {
3124
+ if (this._objectItems) {
3125
+ if (isString(item[this.options.itemValue])) {
3126
+ item[this.options.itemValue] = item[this.options.itemValue].trim();
3127
+ }
3128
+ if (isString(item[this.options.itemText])) {
3129
+ item[this.options.itemText] = item[this.options.itemText].trim();
3130
+ }
3131
+ }
3132
+ else {
3133
+ item = item.trim();
3134
+ }
3135
+ }
3136
+ return item;
3137
+ };
3138
+ /**
3139
+ * Filter Dropdown items to be compliant with already selected items and current input value
3140
+ * Filtering is made on Text by default (can be changed with option)
3141
+ */
3142
+ BulmaTagsInput.prototype._filterDropdownItems = function (value) {
3143
+ var _this = this;
3144
+ if (value === void 0) { value = null; }
3145
+ if (this.dropdown) {
3146
+ if (this.emit('before.dropdown.filter', this)) {
3147
+ Array.from(this.dropdown.children).filter(function (child) { return !child.classList.contains('empty-title'); }).forEach(function (child) {
3148
+ var childValue = child.dataset[_this.options.searchOn];
3149
+ // Remove highlights
3150
+ if (_this.options.highlightMatchesString) {
3151
+ child.textContent = child.textContent.replace(/<\/?(mark\s?(class="is\-highlighted")?)?>]*>?/gm, '');
3152
+ }
3153
+ // If value is found in dropdown
3154
+ if ((value && value.length)) {
3155
+ if (_this.options.caseSensitive) {
3156
+ child.style.display = childValue.includes(value) ? 'block' : 'none';
3157
+ }
3158
+ else {
3159
+ child.style.display = childValue.toLowerCase().includes(value.toLowerCase()) ? 'block' : 'none';
3160
+ }
3161
+ if (_this.options.highlightMatchesString) {
3162
+ child.innerHTML = _this._highlightMatchesInString(child.innerHTML, value);
3163
+ }
3164
+ }
3165
+ else {
3166
+ child.style.display = 'block';
3167
+ }
3168
+ if (!_this.options.allowDuplicates || (_this._isSelect && !_this._isMultiple)) {
3169
+ var hasValue = _this.options.searchOn === 'value' ? _this.hasValue(childValue) : _this.hasText(childValue);
3170
+ child.style.display = hasValue ? 'none' : child.style.display;
3171
+ }
3172
+ });
3173
+ var hasActiveItems = Array.from(this.dropdown.children).filter(function (child) { return !child.classList.contains('empty-title'); }).some(function (child) { return child.style.display !== 'none'; });
3174
+ if (hasActiveItems) {
3175
+ this.dropdownEmptyOption.style.display = 'none';
3176
+ }
3177
+ else {
3178
+ this.dropdownEmptyOption.style.display = 'block';
3179
+ }
3180
+ this.emit('after.dropdown.filter', this);
3181
+ return hasActiveItems;
3182
+ }
3183
+ }
3184
+ return true;
3185
+ };
3186
+ /**
3187
+ * Update original select option based on given item
3188
+ *
3189
+ * @param item
3190
+ */
3191
+ BulmaTagsInput.prototype._updateSelectOptions = function (item) {
3192
+ if (this._isSelect) {
3193
+ // Check to see if the tag exists in its raw or uri-encoded form
3194
+ var option = this.element.querySelector("option[value=\"" + encodeURIComponent(item.value) + "\"]") || this.element.querySelector("option[value=\"" + item.value + "\"]");
3195
+ // add <option /> if item represents a value not present in one of the <select />'s options
3196
+ if (!option) {
3197
+ var optionFragment = document.createRange().createContextualFragment("<option value=\"" + item.value + "\" data-source=\"" + this.id + "\" selected>" + item.text + "</option>");
3198
+ option = optionFragment.firstElementChild;
3199
+ this.element.add(option);
3200
+ }
3201
+ // mark option as selected
3202
+ option.setAttribute('selected', 'selected');
3203
+ option.selected = true;
3204
+ }
3205
+ };
3206
+ /**
3207
+ * Add given item
3208
+ * item = 'john'
3209
+ * item = 'john,jane'
3210
+ * item = ['john', 'jane']
3211
+ * item = [{
3212
+ * "value": "1",
3213
+ * "text": "John"
3214
+ * }, {
3215
+ * "value": "2",
3216
+ * "text": "Jane"
3217
+ * }]
3218
+ *
3219
+ * @param item
3220
+ * @param silently Should the change be propagated to the original element
3221
+ */
3222
+ BulmaTagsInput.prototype.add = function (items, silently) {
3223
+ var _this = this;
3224
+ if (silently === void 0) { silently = false; }
3225
+ // Check if number of items is limited ans reached
3226
+ if (typeof this.options.maxTags !== 'undefined' && this._items.length >= this.options.maxTags) {
3227
+ return this;
3228
+ }
3229
+ // Make sure to work with an array of items
3230
+ items = Array.isArray(items) ? items : isObject(items) ? [items] : items.split(this.options.delimiter);
3231
+ // If string items are expected then check every item is a string
3232
+ if (!this._objectItems && (items.filter(function (item) { return isString(item); }).length !== items.length)) {
3233
+ throw ('Item must be a string or an array of strings');
3234
+ }
3235
+ // If object items are expected then check every item is an object
3236
+ if (this._objectItems && (items.filter(function (item) { return isObject(item); }).length !== items.length)) {
3237
+ throw ('Item must be an object or an array of objects');
3238
+ }
3239
+ items.forEach(function (item) {
3240
+ item = _this._trim(item);
3241
+ // Check if item respects min/max chars
3242
+ if (_this._checkLength(item)) {
3243
+ // If original input is a non multiple select element
3244
+ if (_this._isSelect && !_this._isMultiple && _this._items.length > 0) {
3245
+ _this.removeAtIndex(0);
3246
+ _this.element.remove(_this.element.selectedIndex);
3247
+ }
3248
+ // check if duplicates are allowed or not
3249
+ if (item = _this.emit('before.add', item)) {
3250
+ if (_this.options.allowDuplicates || !_this.has(item)) {
3251
+ var itemData = {
3252
+ value: _this._objectItems ? item[_this.options.itemValue] : item,
3253
+ text: _this._objectItems ? item[_this.options.itemText] : item
3254
+ };
3255
+ var tag = _this._createTag(itemData);
3256
+ // save item into the internal array
3257
+ _this._items.push(item);
3258
+ if (!silently) {
3259
+ // Propagate change event to the original input
3260
+ _this._propagateChange();
3261
+ _this.emit('after.add', {
3262
+ item: item,
3263
+ tag: tag
3264
+ });
3265
+ }
3266
+ }
3267
+ else {
3268
+ if (_this.options.highlightDuplicate) {
3269
+ var duplicateTag_1 = Array.from(_this.container.children).filter(function (child) { return child.classList.contains('tag'); })[_this.indexOf(item)];
3270
+ if (duplicateTag_1) {
3271
+ duplicateTag_1.classList.add('is-duplicate');
3272
+ setTimeout(function () {
3273
+ duplicateTag_1.classList.remove('is-duplicate');
3274
+ }, 1250);
3275
+ }
3276
+ }
3277
+ _this.emit('item.duplicate', item);
3278
+ }
3279
+ }
3280
+ }
3281
+ });
3282
+ return this;
3283
+ };
3284
+ /**
3285
+ * Unselect the selected item
3286
+ */
3287
+ BulmaTagsInput.prototype.clearSelection = function () {
3288
+ if (this._selected >= 0) {
3289
+ var item = this._items[this._selected];
3290
+ var tag = Array.from(this.container.children).filter(function (child) { return child.classList.contains('tag'); })[this._selected];
3291
+ if (this.emit('before.unselect', {
3292
+ item: item,
3293
+ tag: tag
3294
+ })) {
3295
+ if (tag) {
3296
+ tag.classList.remove('is-selected');
3297
+ }
3298
+ this._selected = -1;
3299
+ this.emit('after.unselect', {
3300
+ item: item,
3301
+ tag: tag
3302
+ });
3303
+ }
3304
+ }
3305
+ return this;
3306
+ };
3307
+ /**
3308
+ * Shortcut to removeAll method
3309
+ */
3310
+ BulmaTagsInput.prototype.flush = function () {
3311
+ return this.removeAll();
3312
+ };
3313
+ /**
3314
+ * Sets focus on the input
3315
+ */
3316
+ BulmaTagsInput.prototype.focus = function () {
3317
+ this.container.classList.add('is-focused');
3318
+ this._input.focus();
3319
+ return this;
3320
+ };
3321
+ /**
3322
+ * Check if given item is present
3323
+ *
3324
+ * @param item
3325
+ */
3326
+ BulmaTagsInput.prototype.has = function (item) {
3327
+ var _this = this;
3328
+ item = this._trim(item);
3329
+ if (this._objectItems) {
3330
+ return this._items.some(function (i) { return _this.options.caseSensitive || !isString(i[_this.options.itemValue]) ? i[_this.options.itemValue] === item[_this.options.itemValue] : i[_this.options.itemValue].toLowerCase() === item[_this.options.itemValue].toLowerCase(); });
3331
+ }
3332
+ else {
3333
+ return this.hasValue(item);
3334
+ }
3335
+ };
3336
+ /**
3337
+ * Check if given text is present
3338
+ *
3339
+ * @param value
3340
+ */
3341
+ BulmaTagsInput.prototype.hasText = function (value) {
3342
+ var _this = this;
3343
+ if (this.options.trim) {
3344
+ value = value.trim();
3345
+ }
3346
+ return this._items.some(function (i) {
3347
+ var val = (_this._objectItems ? i[_this.options.itemText] : i);
3348
+ return _this.options.caseSensitive ? val === value : val.toLowerCase() === value.toLowerCase();
3349
+ });
3350
+ };
3351
+ /**
3352
+ * Check if given value is present
3353
+ *
3354
+ * @param value
3355
+ */
3356
+ BulmaTagsInput.prototype.hasValue = function (value) {
3357
+ var _this = this;
3358
+ if (this.options.trim) {
3359
+ value = value.trim();
3360
+ }
3361
+ return this._items.some(function (i) {
3362
+ var val = (_this._objectItems ? i[_this.options.itemValue] : i);
3363
+ return _this.options.caseSensitive ? val === value : val.toLowerCase() === value.toLowerCase();
3364
+ });
3365
+ };
3366
+ /**
3367
+ * Get index of given item
3368
+ *
3369
+ * @param item
3370
+ */
3371
+ BulmaTagsInput.prototype.indexOf = function (item) {
3372
+ item = this._trim(item);
3373
+ if (this._objectItems) {
3374
+ if (!isObject(item)) {
3375
+ throw ('Item must be an object');
3376
+ }
3377
+ return this._items.map(function (e) { return e.value; }).indexOf(item.value);
3378
+ }
3379
+ else {
3380
+ return this._items.indexOf(item);
3381
+ }
3382
+ };
3383
+ /**
3384
+ * Returns the internal input element
3385
+ */
3386
+ BulmaTagsInput.prototype.input = function () {
3387
+ return this._input;
3388
+ };
3389
+ /**
3390
+ * Get items
3391
+ */
3392
+ BulmaTagsInput.prototype.items = function () {
3393
+ return this._items;
3394
+ };
3395
+ /**
3396
+ * Remove given item
3397
+ * item = 'john'
3398
+ * item = 'john,jane'
3399
+ *
3400
+ * @param String item
3401
+ */
3402
+ BulmaTagsInput.prototype.remove = function (items) {
3403
+ var _this = this;
3404
+ if (this.options.removable) {
3405
+ // Make sure to work with an array of items
3406
+ items = Array.isArray(items) ? items : isObject(items) ? [items] : items.split(this.options.delimiter);
3407
+ // If string items are expected then check every item is a string
3408
+ if (!this._objectItems && (items.filter(function (item) { return isString(item); }).length !== items.length)) {
3409
+ throw ('Item must be a string or an array of strings');
3410
+ }
3411
+ // If object items are expected then check every item is an object
3412
+ if (this._objectItems && (items.filter(function (item) { return isObject(item); }).length !== items.length)) {
3413
+ throw ('Item must be an object or an array of objects');
3414
+ }
3415
+ items.forEach(function (item) {
3416
+ var index = _this.indexOf(item);
3417
+ while (index >= 0) {
3418
+ _this.removeAtIndex(index);
3419
+ index = _this.indexOf(item);
3420
+ }
3421
+ });
3422
+ }
3423
+ return this;
3424
+ };
3425
+ /**
3426
+ * Remove all tags at once
3427
+ */
3428
+ BulmaTagsInput.prototype.removeAll = function () {
3429
+ if (this.options.removable) {
3430
+ if (this.emit('before.flush', this._items)) {
3431
+ this.clearSelection();
3432
+ Array.from(this.container.children).filter(function (child) { return child.classList.contains('tag'); }).forEach(function (tag) { return tag.remove(); });
3433
+ this._items = [];
3434
+ this._filterDropdownItems();
3435
+ this._propagateChange();
3436
+ this.emit('after.flush', this._items);
3437
+ }
3438
+ }
3439
+ return this;
3440
+ };
3441
+ /**
3442
+ * Remove item at given index
3443
+ *
3444
+ * @param Integer index
3445
+ */
3446
+ BulmaTagsInput.prototype.removeAtIndex = function (index, clearSelection) {
3447
+ if (clearSelection === void 0) { clearSelection = true; }
3448
+ if (this.options.removable && !isNaN(index) && index >= 0 && index < this._items.length) {
3449
+ var tag = Array.from(this.container.children).filter(function (child) { return child.classList.contains('tag'); })[index];
3450
+ var item = this._items[index];
3451
+ if (this.emit('before.remove', item)) {
3452
+ if (clearSelection) {
3453
+ this.clearSelection();
3454
+ }
3455
+ if (tag) {
3456
+ tag.remove();
3457
+ }
3458
+ // If original input is a select element
3459
+ // then deselect related option
3460
+ if (this._isSelect) {
3461
+ this.element.options[index].selected = false;
3462
+ }
3463
+ if (this._selected == index) {
3464
+ this._selected = -1;
3465
+ }
3466
+ else if (this._selected >= 0) {
3467
+ // One item less so selected index is
3468
+ this._selected -= 1;
3469
+ }
3470
+ this._items.splice(index, 1);
3471
+ this._filterDropdownItems();
3472
+ this._propagateChange();
3473
+ this.emit('after.remove', item);
3474
+ }
3475
+ }
3476
+ return this;
3477
+ };
3478
+ /**
3479
+ * Select given item
3480
+ *
3481
+ * @param item
3482
+ */
3483
+ BulmaTagsInput.prototype.select = function (items) {
3484
+ var _this = this;
3485
+ if (this.options.selectable) {
3486
+ // Make sure to work with an array of items
3487
+ items = Array.isArray(items) ? items : isObject(items) ? [items] : items.split(this.options.delimiter);
3488
+ // If string items are expected then check every item is a string
3489
+ if (!this._objectItems && (items.filter(function (item) { return isString(item); }).length !== items.length)) {
3490
+ throw ('Item must be a string or an array of strings');
3491
+ }
3492
+ // If object items are expected then check every item is an object
3493
+ if (this._objectItems && (items.filter(function (item) { return isObject(item); }).length !== items.length)) {
3494
+ throw ('Item must be an object or an array of objects');
3495
+ }
3496
+ items.forEach(function (item) {
3497
+ _this.selectAtIndex(_this.indexOf(item));
3498
+ });
3499
+ }
3500
+ return this;
3501
+ };
3502
+ /**
3503
+ * Select tag at given index
3504
+ *
3505
+ * @param Integer index
3506
+ */
3507
+ BulmaTagsInput.prototype.selectAtIndex = function (index) {
3508
+ if (this.options.selectable) {
3509
+ // Clear selection
3510
+ this.clearSelection();
3511
+ if (!isNaN(index) && index >= 0 && index < this._items.length) {
3512
+ var tag = Array.from(this.container.children).filter(function (child) { return child.classList.contains('tag'); })[index];
3513
+ var item = this._items[index];
3514
+ if (this.emit('before.select', {
3515
+ item: item,
3516
+ tag: tag
3517
+ })) {
3518
+ if (tag) {
3519
+ tag.classList.add('is-selected');
3520
+ }
3521
+ this._selected = index;
3522
+ this.emit('after.select', {
3523
+ item: item,
3524
+ tag: tag
3525
+ });
3526
+ }
3527
+ }
3528
+ }
3529
+ return this;
3530
+ };
3531
+ Object.defineProperty(BulmaTagsInput.prototype, "selected", {
3532
+ /**
3533
+ * Get selected item
3534
+ */
3535
+ get: function () {
3536
+ if (this._selected >= 0) {
3537
+ return this._items[this._selected];
3538
+ }
3539
+ else {
3540
+ return null;
3541
+ }
2204
3542
  },
2205
3543
  enumerable: false,
2206
3544
  configurable: true
2207
3545
  });
2208
- Object.defineProperty(SkeletonTextComponent.prototype, "hasHeight", {
3546
+ Object.defineProperty(BulmaTagsInput.prototype, "selectedIndex", {
3547
+ /**
3548
+ * Get selected item index
3549
+ */
2209
3550
  get: function () {
2210
- return this.height;
3551
+ return this._selected;
2211
3552
  },
2212
3553
  enumerable: false,
2213
3554
  configurable: true
2214
3555
  });
2215
- return SkeletonTextComponent;
2216
- }());
2217
- SkeletonTextComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkeletonTextComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2218
- SkeletonTextComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkeletonTextComponent, selector: "he-skeleton-text", inputs: { animated: "animated", width: "width", height: "height" }, host: { properties: { "class.is-animated": "this.isAnimated", "style.width": "this.hasWidth", "style.height": "this.hasHeight" } }, ngImport: i0__namespace, template: "<span>&nbsp;</span>\n", styles: [":host{border-radius:2px;display:block;width:100%;height:inherit;margin-top:4px;margin-bottom:4px;background:rgba(0,0,0,.065);line-height:10px;-webkit-user-select:none;user-select:none;pointer-events:none}span{display:inline-block}:host(.is-animated){position:relative;background:linear-gradient(to right,rgba(0,0,0,.065) 8%,rgba(0,0,0,.135) 18%,rgba(0,0,0,.065) 33%);background-size:800px 104px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:shimmer;animation-timing-function:linear}@keyframes shimmer{0%{background-position:-468px 0}to{background-position:468px 0}}\n"] });
2219
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkeletonTextComponent, decorators: [{
2220
- type: i0.Component,
2221
- args: [{
2222
- selector: 'he-skeleton-text',
2223
- templateUrl: './skeleton-text.component.html',
2224
- styleUrls: ['./skeleton-text.component.scss']
2225
- }]
2226
- }], propDecorators: { animated: [{
2227
- type: i0.Input
2228
- }], width: [{
2229
- type: i0.Input
2230
- }], height: [{
2231
- type: i0.Input
2232
- }], isAnimated: [{
2233
- type: i0.HostBinding,
2234
- args: ['class.is-animated']
2235
- }], hasWidth: [{
2236
- type: i0.HostBinding,
2237
- args: ['style.width']
2238
- }], hasHeight: [{
2239
- type: i0.HostBinding,
2240
- args: ['style.height']
2241
- }] } });
2242
-
2243
- var parsePropertyValue = function (value) { return utils.isNumber(value) ? +value : (utils.isBoolean(value) ? value.toString() === 'true' : value); };
2244
- var parseResult = function (value) { return isNaN(value) ? '' : ("" + value).replace(',', '.'); };
2245
- var UnitConverterComponent = /** @class */ (function () {
2246
- function UnitConverterComponent() {
2247
- this.value = 1;
2248
- this.ConvertUnits = utils.ConvertUnits;
2249
- this.result = '';
2250
- this.arguments = [];
2251
- }
2252
- UnitConverterComponent.prototype.ngOnInit = function () {
2253
- return this.updateValue();
2254
- };
2255
- Object.defineProperty(UnitConverterComponent.prototype, "args", {
3556
+ Object.defineProperty(BulmaTagsInput.prototype, "value", {
3557
+ /**
3558
+ * Get value
3559
+ */
2256
3560
  get: function () {
2257
- var _a;
2258
- return (((_a = this.term) === null || _a === void 0 ? void 0 : _a.defaultProperties) || []).reduce(function (prev, prop) {
2259
- var _c;
2260
- var _a, _b;
2261
- return (Object.assign(Object.assign({}, prev), (_c = {}, _c[(_b = (_a = prop.term) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()] = parsePropertyValue(prop.value), _c)));
2262
- }, {});
3561
+ if (!this._isSelect) {
3562
+ if (this._objectItems) {
3563
+ return this._items.map(function (item) { return item.value; }).join(this.options.delimiter);
3564
+ }
3565
+ else {
3566
+ return this._items.join(this.options.delimiter);
3567
+ }
3568
+ }
3569
+ else {
3570
+ return Array.from(this.element.options).filter(function (option) { return option.selected; }).map(function (option) { return option.value; });
3571
+ }
2263
3572
  },
2264
- enumerable: false,
2265
- configurable: true
2266
- });
2267
- Object.defineProperty(UnitConverterComponent.prototype, "units", {
2268
- get: function () {
2269
- var _this = this;
2270
- return this.fromUnits ?
2271
- Object.values(utils.ConvertUnits).filter(function (v) { return v in utils.converters[_this.fromUnits]; }) :
2272
- [];
3573
+ /**
3574
+ * Set value
3575
+ */
3576
+ set: function (string) {
3577
+ this.removeAll();
3578
+ this.add(string);
2273
3579
  },
2274
3580
  enumerable: false,
2275
3581
  configurable: true
2276
3582
  });
2277
- UnitConverterComponent.prototype.requireArgs = function (keys) {
2278
- var args = this.args;
2279
- this.arguments = keys.map(function (key) { return ({ key: key, value: args[key] || '' }); });
3583
+ /**
3584
+ * Document click event handler
3585
+ *
3586
+ * @param e
3587
+ */
3588
+ BulmaTagsInput.prototype._onDocumentClick = function (e) {
3589
+ if (this.dropdown) {
3590
+ // If we click on element inside container then do nothing
3591
+ if (this.container.contains(e.target)) {
3592
+ return;
3593
+ }
3594
+ // Tag and delete button already deleted when event triggered
3595
+ // So we check if target is a tag delete button
3596
+ if (e.target.dataset.tag && e.target.dataset.tag === 'delete') {
3597
+ return;
3598
+ }
3599
+ // Click outside dropdown so close it
3600
+ this._closeDropdown();
3601
+ }
2280
3602
  };
2281
- UnitConverterComponent.prototype.updateUnits = function () {
2282
- var requiredKeys = [];
2283
- if (this.fromUnits === utils.ConvertUnits.kg || this.toUnits === utils.ConvertUnits.kg) {
2284
- requiredKeys = ['density'];
3603
+ /**
3604
+ * Input focus lost event handler
3605
+ *
3606
+ * @param e
3607
+ */
3608
+ BulmaTagsInput.prototype._onDropdownItemClick = function (e) {
3609
+ e.preventDefault();
3610
+ if (this.dropdown) {
3611
+ if (this._objectItems) {
3612
+ var item = {};
3613
+ item[this.options.itemText] = e.currentTarget.dataset.text;
3614
+ item[this.options.itemValue] = e.currentTarget.dataset.value;
3615
+ this.add(item);
3616
+ }
3617
+ else {
3618
+ this.add(e.currentTarget.dataset.value);
3619
+ }
3620
+ this._filterDropdownItems();
3621
+ this._input.value = '';
3622
+ this._input.focus();
3623
+ if (this.options.closeDropdownOnItemSelect) {
3624
+ this._closeDropdown();
3625
+ }
2285
3626
  }
2286
- this.requireArgs(requiredKeys);
2287
- return this.updateValue();
2288
3627
  };
2289
- UnitConverterComponent.prototype.updateValue = function () {
2290
- if (!this.fromUnits || !this.toUnits) {
2291
- return;
3628
+ /**
3629
+ * Input change event handler
3630
+ *
3631
+ * @param e
3632
+ */
3633
+ BulmaTagsInput.prototype._onInputChange = function (e) {
3634
+ this._filterDropdownItems(this._input.value);
3635
+ };
3636
+ /**
3637
+ * Input click event handler
3638
+ *
3639
+ * @param e
3640
+ */
3641
+ BulmaTagsInput.prototype._onInputClick = function (e) {
3642
+ e.preventDefault();
3643
+ if (!this.source || this._input.value.length >= this.options.searchMinChars) {
3644
+ this._openDropdown();
3645
+ this._filterDropdownItems();
2292
3646
  }
2293
- var args = Object.assign(Object.assign({}, this.args), this.arguments.reduce(function (prev, _c) {
2294
- var _d;
2295
- var key = _c.key, value = _c.value;
2296
- return (Object.assign(Object.assign({}, prev), (_d = {}, _d[key] = value, _d)));
2297
- }, {}));
2298
- try {
2299
- this.result = parseResult(utils.convertValue(this.value, this.fromUnits, this.toUnits, args));
3647
+ };
3648
+ /**
3649
+ * Input focus event handler
3650
+ *
3651
+ * @param e
3652
+ */
3653
+ BulmaTagsInput.prototype._onInputFocusIn = function (e) {
3654
+ e.preventDefault();
3655
+ if (this.container.getAttribute('disabled') !== null || this.container.classList.contains('is-disabled')) {
3656
+ this._input.blur();
3657
+ return false;
2300
3658
  }
2301
- catch (_) { }
3659
+ this.container.classList.add('is-focused');
2302
3660
  };
2303
- return UnitConverterComponent;
2304
- }());
2305
- UnitConverterComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: UnitConverterComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2306
- UnitConverterComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: UnitConverterComponent, selector: "he-unit-converter", inputs: { term: "term", value: "value", fromUnits: "fromUnits", toUnits: "toUnits" }, ngImport: i0__namespace, template: "<div class=\"columns mb-0\">\n <div class=\"column\">\n <label class=\"label has-text-white\" for=\"value\">Value</label>\n </div>\n <div class=\"column\">\n <label class=\"label has-text-white\" for=\"result\">Convert To</label>\n </div>\n</div>\n\n<div class=\"columns\">\n <div class=\"column\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <input type=\"number\" class=\"input\" [(ngModel)]=\"value\" name=\"value\" id=\"value\"\n (input)=\"updateValue()\"\n >\n </div>\n <div class=\"control is-expanded\">\n <div class=\"select is-fullwidth\">\n <select [(ngModel)]=\"fromUnits\" name=\"fromUnits\" id=\"fromUnits\"\n (change)=\"updateUnits()\"\n >\n <option [value]=\"undefined\">Unit</option>\n <option *ngFor=\"let unit of ConvertUnits | keys\" [value]=\"unit.value\">{{unit.key}}</option>\n </select>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"column\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <input type=\"string\" class=\"input\" [value]=\"result\" name=\"result\" id=\"result\" readonly>\n </div>\n <div class=\"control\">\n <div class=\"select is-fullwidth\">\n <select [(ngModel)]=\"toUnits\" name=\"toUnits\" id=\"toUnits\"\n (change)=\"updateUnits()\"\n >\n <option [value]=\"undefined\">Unit</option>\n <option *ngFor=\"let unit of units\" [value]=\"unit\">{{unit}}</option>\n </select>\n </div>\n </div>\n <div class=\"control\">\n <he-clipboard clipboardClass=\"button is-white px-2\"\n [value]=\"result\" [disabled]=\"!result\" [hideText]=\"true\"\n ></he-clipboard>\n </div>\n </div>\n </div>\n</div>\n\n<div class=\"field is-horizontal\" *ngFor=\"let arg of arguments\">\n <div class=\"field-label is-normal\">\n <label class=\"label has-text-white\" [for]=\"arg.key\">\n <span class=\"is-capitalized\">{{arg.key}}</span>\n <span class=\"has-text-danger pl-1\">*</span>\n </label>\n </div>\n <div class=\"field-body\">\n <div class=\"field\">\n <div class=\"control\">\n <input type=\"string\" class=\"input is-small\"\n [(ngModel)]=\"arg.value\" [id]=\"arg.key\"\n (input)=\"updateValue()\"\n placeholder=\"Required for conversion\"\n >\n </div>\n </div>\n </div>\n</div>\n", styles: [".select{min-width:85px}\n"], components: [{ type: ClipboardComponent, selector: "he-clipboard", inputs: ["value", "disabled", "hideText", "icon", "size", "rotate", "clipboardClass"] }], directives: [{ type: i1__namespace$4.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i1__namespace$4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1__namespace$4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1__namespace$4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1__namespace$4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i1__namespace$4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1__namespace$4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "keys": KeysPipe } });
2307
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: UnitConverterComponent, decorators: [{
2308
- type: i0.Component,
2309
- args: [{
2310
- selector: 'he-unit-converter',
2311
- templateUrl: './unit-converter.component.html',
2312
- styleUrls: ['./unit-converter.component.scss']
2313
- }]
2314
- }], propDecorators: { term: [{
2315
- type: i0.Input
2316
- }], value: [{
2317
- type: i0.Input
2318
- }], fromUnits: [{
2319
- type: i0.Input
2320
- }], toUnits: [{
2321
- type: i0.Input
2322
- }] } });
2323
-
2324
- /* eslint-disable @angular-eslint/directive-selector */
2325
- var ClickOutsideDirective = /** @class */ (function () {
2326
- function ClickOutsideDirective(elementRef) {
2327
- this.elementRef = elementRef;
2328
- this.clickOutside = new i0.EventEmitter();
2329
- }
2330
- ClickOutsideDirective.prototype.onClick = function (event) {
2331
- if (!this.elementRef.nativeElement.contains(event.target)) {
2332
- this.clickOutside.emit();
3661
+ /**
3662
+ * Input focus lost event handler
3663
+ *
3664
+ * @param e
3665
+ */
3666
+ BulmaTagsInput.prototype._onInputFocusOut = function (e) {
3667
+ e.preventDefault();
3668
+ this.container.classList.remove('is-focused');
3669
+ };
3670
+ /**
3671
+ * Input Keydown event handler
3672
+ *
3673
+ * @param e
3674
+ */
3675
+ BulmaTagsInput.prototype._onInputKeyDown = function (e) {
3676
+ var key = e.charCode || e.keyCode || e.which;
3677
+ switch (key) {
3678
+ // BACKSPACE
3679
+ case 8:
3680
+ if (this.options.removable) {
3681
+ if (this._caretAtStart() && this._selected >= 0) {
3682
+ var currentItemIndex = this._selected;
3683
+ // If tag was selected then select next (or previous if next does not exists)
3684
+ if (currentItemIndex >= 0) {
3685
+ this.selectAtIndex(currentItemIndex + 1 < this._items.length ? currentItemIndex + 1 : currentItemIndex - 1);
3686
+ }
3687
+ this.removeAtIndex(currentItemIndex, false);
3688
+ }
3689
+ }
3690
+ if (this.source && (this._input.value.length) < this.options.searchMinChars) {
3691
+ this._closeDropdown();
3692
+ }
3693
+ break;
3694
+ // ESCAPE
3695
+ case 27:
3696
+ if (this._selected >= 0) {
3697
+ this.clearSelection();
3698
+ }
3699
+ this._closeDropdown();
3700
+ break;
3701
+ // DELETE
3702
+ case 46:
3703
+ if (this.options.removable) {
3704
+ if (this._caretAtStart() && this._selected >= 0) {
3705
+ var currentItemIndex = this._selected;
3706
+ // If tag was selected then select next (or previous if next does not exists)
3707
+ if (currentItemIndex >= 0) {
3708
+ this.selectAtIndex(currentItemIndex + 1 < this._items.length ? currentItemIndex + 1 : currentItemIndex - 1);
3709
+ }
3710
+ this.removeAtIndex(currentItemIndex, false);
3711
+ }
3712
+ }
3713
+ if (this.source && (this._input.value.length) < this.options.searchMinChars) {
3714
+ this._closeDropdown();
3715
+ }
3716
+ break;
3717
+ // LEFT ARROW
3718
+ case 37:
3719
+ if (!this._input.value.length) {
3720
+ if (this._selected < 0) {
3721
+ this.selectAtIndex(this._items.length - 1);
3722
+ }
3723
+ else {
3724
+ this.selectAtIndex(this._selected - 1 >= 0 ? this._selected - 1 : this._items.length - 1);
3725
+ }
3726
+ }
3727
+ break;
3728
+ // RIGHT ARROW
3729
+ case 39:
3730
+ if (!this._input.value.length) {
3731
+ if (this._selected < 0) {
3732
+ this.selectAtIndex(0);
3733
+ }
3734
+ else {
3735
+ this.selectAtIndex(this._selected + 1 >= this._items.length ? 0 : this._selected + 1);
3736
+ }
3737
+ }
3738
+ break;
3739
+ default:
3740
+ if (this.options.clearSelectionOnTyping) {
3741
+ this.clearSelection();
3742
+ }
3743
+ // ignore
2333
3744
  }
2334
3745
  };
2335
- return ClickOutsideDirective;
2336
- }());
2337
- ClickOutsideDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ClickOutsideDirective, deps: [{ token: i0__namespace.ElementRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2338
- ClickOutsideDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: ClickOutsideDirective, selector: "[clickOutside]", outputs: { clickOutside: "clickOutside" }, host: { listeners: { "document:click": "onClick($event)" } }, ngImport: i0__namespace });
2339
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ClickOutsideDirective, decorators: [{
2340
- type: i0.Directive,
2341
- args: [{
2342
- selector: '[clickOutside]'
2343
- }]
2344
- }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }]; }, propDecorators: { clickOutside: [{
2345
- type: i0.Output
2346
- }], onClick: [{
2347
- type: i0.HostListener,
2348
- args: ['document:click', ['$event']]
2349
- }] } });
2350
-
2351
- var get$3 = require('lodash.get');
2352
- var GetPipe = /** @class */ (function () {
2353
- function GetPipe() {
2354
- }
2355
- GetPipe.prototype.transform = function (value, key, defaultValue) {
2356
- if (defaultValue === void 0) { defaultValue = ''; }
2357
- return get$3(value, key, defaultValue);
3746
+ /**
3747
+ * Input Keypress event handler
3748
+ *
3749
+ * @param e
3750
+ */
3751
+ BulmaTagsInput.prototype._onInputKeyPress = function (e) {
3752
+ var _this = this;
3753
+ var key = e.charCode || e.keyCode || e.which;
3754
+ var value = this._trim(this._input.value) + String.fromCharCode(key);
3755
+ if (!this._manualInputAllowed && !this._filterInputAllowed) {
3756
+ e.preventDefault();
3757
+ return false;
3758
+ }
3759
+ // ENTER
3760
+ if (!value.length && key !== 13) {
3761
+ return false;
3762
+ }
3763
+ if (this._filterInputAllowed) {
3764
+ this._filterDropdownItems(value);
3765
+ }
3766
+ if (this._filterInputAllowed && this.source && value.length >= this.options.searchMinChars && key !== 13) {
3767
+ this._openDropdown();
3768
+ this.dropdown.classList.add('is-loading');
3769
+ this._emptyDropdown();
3770
+ this.source(value).then(function (results) {
3771
+ results = _this.emit('on.results.received', results);
3772
+ if (results.length) {
3773
+ results.forEach(function (result) {
3774
+ var item = {
3775
+ value: null,
3776
+ text: null
3777
+ };
3778
+ if (!isObject(result)) {
3779
+ item.value = result;
3780
+ item.text = result;
3781
+ }
3782
+ else {
3783
+ item.value = result[_this.options.itemValue];
3784
+ item.text = result[_this.options.itemText];
3785
+ }
3786
+ _this._createDropdownItem(item);
3787
+ });
3788
+ }
3789
+ _this._filterDropdownItems(value);
3790
+ _this.dropdown.classList.remove('is-loading');
3791
+ });
3792
+ }
3793
+ if (this._manualInputAllowed && (value.includes(this.options.delimiter) || key == 13)) {
3794
+ // Prevent default behavior (ie: add char into input value)
3795
+ e.preventDefault();
3796
+ // Split value by delimiter in case we copy/paste multiple values
3797
+ var values = value.split(this.options.delimiter);
3798
+ values.forEach(function (value) {
3799
+ // check if empty text when delimiter is removed
3800
+ if ((value = value.replace(_this.options.delimiter, '')) != '') {
3801
+ // push to array and remove delimiter
3802
+ _this.add(value);
3803
+ }
3804
+ });
3805
+ value = '';
3806
+ // clear input
3807
+ this._input.value = '';
3808
+ this._closeDropdown();
3809
+ return false;
3810
+ }
2358
3811
  };
2359
- return GetPipe;
2360
- }());
2361
- GetPipe.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: GetPipe, deps: [], target: i0__namespace.ɵɵFactoryTarget.Pipe });
2362
- GetPipe.ɵpipe = i0__namespace.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: GetPipe, name: "get" });
2363
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: GetPipe, decorators: [{
2364
- type: i0.Pipe,
2365
- args: [{
2366
- name: 'get'
2367
- }]
2368
- }] });
3812
+ /**
3813
+ * Original input change event handler
3814
+ * CAUTION: because original input is now hidden the change event must be triggered manually on change
3815
+ * Example how to trigger change event manually
3816
+ * var changeEvent = new Event('change');
3817
+ * input.dispatchEvent(changeEvent);
3818
+ *
3819
+ * @param e
3820
+ */
3821
+ BulmaTagsInput.prototype._onOriginalInputChange = function (e) {
3822
+ if (!e.detail || isString(e.detail) && e.detail !== this.constructor.name) {
3823
+ this.value = e.currentTarget.value;
3824
+ }
3825
+ };
3826
+ /**
3827
+ * Tag click event handler
3828
+ *
3829
+ * @param e
3830
+ */
3831
+ BulmaTagsInput.prototype._onTagClick = function (e) {
3832
+ e.preventDefault();
3833
+ if (e.currentTarget.classList.contains('delete')) {
3834
+ return false;
3835
+ }
3836
+ if (this.container.getAttribute('disabled') !== null || this.container.classList.contains('is-disabled')) {
3837
+ return false;
3838
+ }
3839
+ this._input.focus();
3840
+ if (this.options.selectable) {
3841
+ var tag = e.currentTarget.closest('.tag');
3842
+ if (tag) {
3843
+ var tagIndex = Array.from(this.container.children).indexOf(tag);
3844
+ if (tagIndex === this._selected) {
3845
+ this.clearSelection();
3846
+ }
3847
+ else {
3848
+ this.selectAtIndex(tagIndex);
3849
+ }
3850
+ }
3851
+ }
3852
+ };
3853
+ /**
3854
+ * Delete tag button click event handler
3855
+ *
3856
+ * @param e
3857
+ */
3858
+ BulmaTagsInput.prototype._onTagDeleteClick = function (e) {
3859
+ e.preventDefault();
3860
+ if (this.container.getAttribute('disabled') !== null || this.container.classList.contains('is-disabled')) {
3861
+ return false;
3862
+ }
3863
+ var tag = e.currentTarget.closest('.tag');
3864
+ if (tag) {
3865
+ this.removeAtIndex(Array.from(this.container.children).indexOf(tag));
3866
+ }
3867
+ };
3868
+ return BulmaTagsInput;
3869
+ }(Component));
2369
3870
 
2370
3871
  var restrictToType = {
2371
3872
  number: function (val) { return parseFloat(val) === +val ? val : false; }
@@ -2389,7 +3890,7 @@
2389
3890
  return _this.tagsInputInput.removeEventListener(event, listener);
2390
3891
  });
2391
3892
  this.inputEvents = [];
2392
- this.tagsInput = null;
3893
+ this.tagsInput = undefined;
2393
3894
  };
2394
3895
  Object.defineProperty(TagsInputDirective.prototype, "input", {
2395
3896
  get: function () {
@@ -2430,7 +3931,7 @@
2430
3931
  var _this = this;
2431
3932
  try {
2432
3933
  var _a = this.appTagsInput, enabled = _a.enabled, items = _a.items, options = __rest(_a, ["enabled", "items"]);
2433
- this.tagsInput = new BulmaTagsInput__default["default"](this.input, options);
3934
+ this.tagsInput = new BulmaTagsInput(this.input, options);
2434
3935
  // TODO: remove when fixed, @see https://github.com/CreativeBulma/bulma-tagsinput/issues/23
2435
3936
  var classes = ['is-small', 'is-large'].filter(function (v) { return _this.input.classList.contains(v); });
2436
3937
  classes.map(function (v) { return _this.tagsInputNode.classList.add(v); });
@@ -3779,7 +5280,7 @@
3779
5280
  type: i0.Input
3780
5281
  }] } });
3781
5282
 
3782
- var get$2 = require('lodash.get');
5283
+ var get$3 = require('lodash.get');
3783
5284
  var orderBy$4 = require('lodash.orderby');
3784
5285
  var reduceValues = function (values) { return values.length ? values.reduce(function (p, v) { return p + propertyValue$1(v.value); }, 0) : null; };
3785
5286
  var logSubValue = function (logs, key, prop) { return logs[key][prop] ? {
@@ -3850,7 +5351,7 @@
3850
5351
  case 4:
3851
5352
  _e.allTerms = _f.sent();
3852
5353
  this.allBlankNodes = this.allTerms.flatMap(function (term) {
3853
- var emissionLogs = get$2(_this.logs, term['@id'], {});
5354
+ var emissionLogs = get$3(_this.logs, term['@id'], {});
3854
5355
  var original = originalValues.filter(function (v) { return term['@id'] === v.term['@id']; });
3855
5356
  var recalculated = recalculatedValues.filter(function (v) { return term['@id'] === v.term['@id']; });
3856
5357
  var hasData = !!original.length || !!recalculated.length || Object.keys(emissionLogs).length > 0;
@@ -3910,7 +5411,7 @@
3910
5411
  };
3911
5412
  NodeLogsModelsComponent.prototype.validSubValue = function (node, index, subValue) {
3912
5413
  var methodId = this.getMethodIdAt(node, index, subValue);
3913
- return !(subValue === null || subValue === void 0 ? void 0 : subValue.value) || get$2(node.logs[methodId], subValue === null || subValue === void 0 ? void 0 : subValue.key, null) === (subValue === null || subValue === void 0 ? void 0 : subValue.value);
5414
+ return !(subValue === null || subValue === void 0 ? void 0 : subValue.value) || get$3(node.logs[methodId], subValue === null || subValue === void 0 ? void 0 : subValue.key, null) === (subValue === null || subValue === void 0 ? void 0 : subValue.value);
3914
5415
  };
3915
5416
  NodeLogsModelsComponent.prototype.getMethodIdAt = function (node, index, subValue) {
3916
5417
  var configModels = (subValue || node).configModels;
@@ -4815,6 +6316,7 @@
4815
6316
  var _f;
4816
6317
  var mapErrorMessage = 'does not contain latitude and longitude';
4817
6318
  var parseDataPath = function (dataPath) {
6319
+ if (dataPath === void 0) { dataPath = ''; }
4818
6320
  var _f = __read(dataPath.split('.')), _ = _f[0], paths = _f.slice(1);
4819
6321
  return paths.map(function (path) { return ({ path: path, label: keyToLabel(path.replace(/\[\d+\]/g, '')) }); });
4820
6322
  };
@@ -5009,7 +6511,7 @@
5009
6511
 
5010
6512
  var _d;
5011
6513
  /* eslint-disable complexity */
5012
- var get$1 = require('lodash.get');
6514
+ var get$2 = require('lodash.get');
5013
6515
  var ARRAY_DELIMITER = ';';
5014
6516
  var privateKeys = [
5015
6517
  'filepath'
@@ -5019,6 +6521,7 @@
5019
6521
  var nonExpandableArrayDataPath = function (key) { return key.replace(/\[\d+\]$/, ''); };
5020
6522
  var keyToDataPath = function (key) { return (key === null || key === void 0 ? void 0 : key.length) ? "." + key : ''; };
5021
6523
  var dataPathToKey = function (dataPath, trimArray) {
6524
+ if (dataPath === void 0) { dataPath = ''; }
5022
6525
  if (trimArray === void 0) { trimArray = false; }
5023
6526
  return trimArray ? nonExpandableArrayDataPath(dataPath.substring(1)) : dataPath.substring(1);
5024
6527
  };
@@ -5146,7 +6649,7 @@
5146
6649
  return ['title', 'documentDOI', 'scopus'].includes(key) && parent === 'bibliography' && keys.length >= 1 ? {
5147
6650
  type: schema.NodeType.Source,
5148
6651
  parentLevel: 1
5149
- } : null;
6652
+ } : undefined;
5150
6653
  },
5151
6654
  _d.number = function (_a, _b, schema) {
5152
6655
  var values = schema.const ? [schema.const] : [];
@@ -5181,10 +6684,10 @@
5181
6684
  }); },
5182
6685
  _d);
5183
6686
  var enableSuggestions = function (parentSchema, type, fullKey, schema) {
5184
- var suggestion = type in typeToSuggestion ? typeToSuggestion[type](fullKey, parentSchema) : null;
5185
- return suggestion !== null ? suggestion : (schema && schema.type in typeToSuggestion ?
6687
+ var suggestion = type in typeToSuggestion ? typeToSuggestion[type](fullKey, parentSchema) : undefined;
6688
+ return suggestion || (schema && schema.type in typeToSuggestion ?
5186
6689
  typeToSuggestion[schema.type](fullKey, parentSchema, schema) :
5187
- null);
6690
+ undefined);
5188
6691
  };
5189
6692
  var formatProperty = function (prop) { return (Object.assign(Object.assign({ '@type': schema.SchemaType.Property }, prop), { term: Object.assign({ '@type': schema.NodeType.Term }, prop.term) })); };
5190
6693
  var formatSuggestion = function (_c) {
@@ -5193,7 +6696,7 @@
5193
6696
  };
5194
6697
  var nodeAvailableProperties = function (node, _d) {
5195
6698
  var fullKey = _d.fullKey, schema = _d.schema, schemaType = _d.schemaType;
5196
- return availableProperties(schema, schemaType, fullKey ? get$1(node, fullKey, {}) : node, fullKey.length > 0);
6699
+ return availableProperties(schema, schemaType, fullKey ? get$2(node, fullKey, {}) : node, fullKey.length > 0);
5197
6700
  };
5198
6701
  var isAddPropertyEnabled = function (node, schemaType, schema, fullKey) {
5199
6702
  if (fullKey === void 0) { fullKey = ''; }
@@ -5202,7 +6705,7 @@
5202
6705
  (!fullKey || nestingTypeEnabled(schemaType));
5203
6706
  };
5204
6707
  var editableKey = function (key) { return !['type', '@type', 'termType'].includes(key); };
5205
- var propertyId = function () { return uuid.v4(); };
6708
+ var propertyId = function () { return uuid$1.v4(); };
5206
6709
  var propertyUrl = function (node, key) { return ['@id', 'name'].includes(key) && linkTypeEnabled(node['@type']) ?
5207
6710
  {
5208
6711
  url: baseUrl() + "/" + node['@type'].toLowerCase() + "/" + node['@id'],
@@ -5234,7 +6737,7 @@
5234
6737
  var _d = __read(fullKey.split('.')), parent = _d[0], keys = _d.slice(1);
5235
6738
  var properties = schema.properties || {};
5236
6739
  var examples = (parent in properties ? properties[parent] : { examples: [] }).examples;
5237
- return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$1(examples[0], keys.join('.'), null) : null;
6740
+ return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$2(examples[0], keys.join('.'), null) : null;
5238
6741
  };
5239
6742
  var propertyPlaceholder = function (schema, valueType, fullKey, parentSchema) {
5240
6743
  if (fullKey === void 0) { fullKey = ''; }
@@ -5399,7 +6902,7 @@
5399
6902
  var _d = __read(fullKey.split('.')), _t = _d[0], keys = _d.slice(1);
5400
6903
  var key = keys.pop();
5401
6904
  var parent = keys.join('.');
5402
- var parentNode = parent.length ? get$1(node, parent) : node;
6905
+ var parentNode = parent.length ? get$2(node, parent) : node;
5403
6906
  var schemaType = schema.typeToSchemaType(parentNode.type || parentNode['@type']);
5404
6907
  var parentSchema = schemas[schemaType];
5405
6908
  return propertyFromNode(schemas, errors, parentSchema, true, parent, parentNode)(key);
@@ -5611,6 +7114,73 @@
5611
7114
  return moment__namespace(endDate.value).locale('en-gb').subtract(cycleDuration.value, 'days').format('YYYY-MM-DD');
5612
7115
  };
5613
7116
 
7117
+ var get$1 = require('lodash.get');
7118
+ var nodeTerm = function (node, key) {
7119
+ var termType = get$1(node, key + ".type", get$1(node, key + ".@type", null));
7120
+ return termType === schema.SchemaType.Term ? get$1(node, key, null) : null;
7121
+ };
7122
+ var findNodeTerm = function (node, _b) {
7123
+ var dataPath = _b.dataPath;
7124
+ return nodeTerm(node, dataPathToKey(dataPath)) ||
7125
+ nodeTerm(node, dataPathToKey(dataPath) + ".term") ||
7126
+ nodeTerm(node, dataPathToKey(dataPath, true)) ||
7127
+ nodeTerm(node, dataPathToKey(dataPath, true) + ".term");
7128
+ };
7129
+ var uniqueTerms = function (errors) { return utils.unique(errors
7130
+ .map(function (_b) {
7131
+ var term = _b.term;
7132
+ return term ? nodeLink(term) || code(term.name || term['@id'] || term.id) : null;
7133
+ })
7134
+ .filter(Boolean)); };
7135
+ var summaryShowErrors = function (summaryData, _b) {
7136
+ var path = _b.path, level = _b.level, message = _b.message;
7137
+ var _a;
7138
+ return ((_a = summaryData.find(function (summary) { return summary.path === path && summary.level === level && summary.message === message; })) === null || _a === void 0 ? void 0 : _a.showErrors) || true;
7139
+ };
7140
+ /**
7141
+ * Build the summary objects.
7142
+ *
7143
+ * @param nodes The list of nodes.
7144
+ * @param errors The list of errors per node.
7145
+ * @param summaryData The previously computed summary objects.
7146
+ * @returns
7147
+ */
7148
+ var buildSummary = function (nodes, errors, summaryData) {
7149
+ if (nodes === void 0) { nodes = []; }
7150
+ if (errors === void 0) { errors = []; }
7151
+ if (summaryData === void 0) { summaryData = []; }
7152
+ return rxjs.from(errors).pipe(operators.mergeMap(function (error) { return 'error' in error ? error.error : error; }), operators.filter(filterError), operators.reduce(function (prev, error) {
7153
+ var _a;
7154
+ var message = error.message;
7155
+ var _b = __read(parseDataPath(error.dataPath), 1), dataPath = _b[0];
7156
+ var node = get$1(nodes, error.nodeIndex, null);
7157
+ var label = dataPath ? dataPath.label : node === null || node === void 0 ? void 0 : node.type;
7158
+ var term = ((_a = error.params) === null || _a === void 0 ? void 0 : _a.term) || findNodeTerm(node, error);
7159
+ prev[message] = prev[message] || { level: error.level, paths: {} };
7160
+ prev[message].paths[label] = prev[message].paths[label] || [];
7161
+ prev[message].paths[label].push({ node: node, error: error, term: term });
7162
+ return prev;
7163
+ }, {}), operators.mergeMap(function (data) { return rxjs.from(Object.keys(data)).pipe(operators.filter(function (message) { return !!message; }), operators.mergeMap(function (message) { return Object.keys(data[message].paths).map(function (path) {
7164
+ var _a;
7165
+ return ({
7166
+ level: data[message].level,
7167
+ path: path,
7168
+ message: message,
7169
+ formattedMessage: (_a = formatError(data[message].paths[path][0].error, data[message].paths[path].length)) === null || _a === void 0 ? void 0 : _a.message,
7170
+ terms: uniqueTerms(data[message].paths[path]).join(' ; '),
7171
+ errors: data[message].paths[path],
7172
+ count: data[message].paths[path].length,
7173
+ showErrors: summaryShowErrors(summaryData, { level: data[message].level, path: path, message: message })
7174
+ });
7175
+ }); }), operators.filter(function (_b) {
7176
+ var formattedMessage = _b.formattedMessage;
7177
+ return !!formattedMessage;
7178
+ })); }), operators.toArray(), operators.map(function (values) { return values.sort(function (_b) {
7179
+ var level = _b.level;
7180
+ return level === 'error' ? -1 : 1;
7181
+ }); }));
7182
+ };
7183
+
5614
7184
  var isSite = function (_a) {
5615
7185
  var type = _a["@type"], id = _a["@id"];
5616
7186
  return type === schema.NodeType.Site && !!id;
@@ -7423,6 +8993,7 @@
7423
8993
  exports.availableProperties = availableProperties;
7424
8994
  exports.baseUrl = baseUrl;
7425
8995
  exports.bottom = bottom;
8996
+ exports.buildSummary = buildSummary;
7426
8997
  exports.calculateCycleDuration = calculateCycleDuration;
7427
8998
  exports.calculateCycleDurationEnabled = calculateCycleDurationEnabled;
7428
8999
  exports.calculateCycleStartDate = calculateCycleStartDate;