@hestia-earth/ui-components 0.41.7 → 0.41.9

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.
@@ -506,6 +506,15 @@ const ignoreTermTypes = [
506
506
  TermTermType.characterisedIndicator
507
507
  ];
508
508
  const isTermTypeAllowed = (termType) => !termType || !ignoreTermTypes.includes(termType);
509
+ const transformFormula = (text) => text
510
+ .replace(/([A-Z]+[\d]+)([\d]{1}[-+])/g, '$1<sup>$2</sup>')
511
+ .replace(/([A-Z]+)([\d]{1})([-+])/g, '$1<sub>$2</sub><sup>$3</sup>')
512
+ .replace(/([A-LN-Za-ln-z])(\d+)/g, '$1<sub>$2</sub>')
513
+ .replace(/([A-L])([-+])/g, '$1<sup>$2</sup>')
514
+ .replace(/(Ox)([^A-Za-z]|$)/g, 'O<sub>x</sub>$2')
515
+ // handle m2, m3, etc.
516
+ .replace(/([m])([\d]{1})\s/g, '$1<sup>$2</sup> ')
517
+ .replace(/([m])([\d]{1})$/g, '$1<sup>$2</sup>');
509
518
  /**
510
519
  * Handles <sup> and <sub> html tags for compounds.
511
520
  *
@@ -513,18 +522,20 @@ const isTermTypeAllowed = (termType) => !termType || !ignoreTermTypes.includes(t
513
522
  * @param termType Optionally use a `TermType` to restrict the conversion further.
514
523
  * @returns HTML version with subscript and superscript tags.
515
524
  */
516
- const compoundToHtml = (value, termType) => isTermTypeAllowed(termType) && !ignoreCompounds(value)
517
- ? (value || '')
525
+ const compoundToHtml = (value, termType) => !isTermTypeAllowed(termType) || ignoreCompounds(value)
526
+ ? value
527
+ : (value || '')
518
528
  .trim()
519
- .replace(/([A-Z]+[\d]+)([\d]{1}[-+])/g, '$1<sup>$2</sup>')
520
- .replace(/([A-Z]+)([\d]{1})([-+])/g, '$1<sub>$2</sub><sup>$3</sup>')
521
- .replace(/([A-LN-Za-ln-z])(\d+)/g, '$1<sub>$2</sub>')
522
- .replace(/([A-L])([-+])/g, '$1<sup>$2</sup>')
523
- .replace(/(Ox)([^A-Za-z]|$)/g, 'O<sub>x</sub>$2')
524
- // handle m2, m3, etc.
525
- .replace(/([m])([\d]{1})\s/g, '$1<sup>$2</sup> ')
526
- .replace(/([m])([\d]{1})$/g, '$1<sup>$2</sup>')
527
- : value;
529
+ .split(/(\[[^\]]+\]\([^)]+\))/)
530
+ .map(part => {
531
+ const match = part.match(/\[([^\]]+)\]\(([^)]+)\)/);
532
+ if (match) {
533
+ const [, linkText, url] = match;
534
+ return `[${transformFormula(linkText)}](${url})`;
535
+ }
536
+ return transformFormula(part);
537
+ })
538
+ .join('');
528
539
 
529
540
  class ControlValueAccessor {
530
541
  constructor() {
@@ -1808,9 +1819,11 @@ class ClipboardComponent {
1808
1819
  }
1809
1820
  }
1810
1821
  onClick($event) {
1811
- $event.stopPropagation();
1812
- $event.preventDefault();
1813
- this.clipboard();
1822
+ if (!this.disabled()) {
1823
+ $event?.stopPropagation();
1824
+ $event?.preventDefault();
1825
+ this.clipboard();
1826
+ }
1814
1827
  }
1815
1828
  copy(value) {
1816
1829
  if (navigator?.clipboard?.writeText) {
@@ -1840,11 +1853,11 @@ class ClipboardComponent {
1840
1853
  }
1841
1854
  }
1842
1855
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ClipboardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1843
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ClipboardComponent, isStandalone: true, selector: "he-clipboard", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, hideText: { classPropertyName: "hideText", publicName: "hideText", isSignal: true, isRequired: false, transformFunction: null }, hideIcon: { classPropertyName: "hideIcon", publicName: "hideIcon", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, clipboardClass: { classPropertyName: "clipboardClass", publicName: "clipboardClass", isSignal: true, isRequired: false, transformFunction: null }, tooltipPlacement: { classPropertyName: "tooltipPlacement", publicName: "tooltipPlacement", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "window:copy": "onCopy($event)" } }, viewQueries: [{ propertyName: "valueNode", first: true, predicate: ["valueNode"], descendants: true, isSignal: true }, { propertyName: "tooltip", first: true, predicate: ["t"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n [class.is-clickable]=\"!disabled()\"\n (click)=\"onClick($event)\"\n ngbTooltip=\"Copied!\"\n triggers=\"manual\"\n [placement]=\"tooltipPlacement()\"\n container=\"body\"\n #t=\"ngbTooltip\">\n <span #valueNode [class.is-hidden]=\"hideText()\">{{ value() }}</span>\n\n @if (!hideIcon()) {\n <he-svg-icon [name]=\"icon()\" [size]=\"size()\" [class]=\"clipboardClass()\" />\n }\n</div>\n", styles: [".is-small he-svg-icon{height:16px!important;width:16px!important}\n"], dependencies: [{ kind: "directive", type: NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "popperOptions", "triggers", "positionTarget", "container", "disableTooltip", "tooltipClass", "tooltipContext", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { kind: "component", type: HESvgIconComponent, selector: "he-svg-icon", inputs: ["name", "size", "animation"] }] }); }
1856
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ClipboardComponent, isStandalone: true, selector: "he-clipboard", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, hideText: { classPropertyName: "hideText", publicName: "hideText", isSignal: true, isRequired: false, transformFunction: null }, hideIcon: { classPropertyName: "hideIcon", publicName: "hideIcon", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, clipboardClass: { classPropertyName: "clipboardClass", publicName: "clipboardClass", isSignal: true, isRequired: false, transformFunction: null }, tooltipPlacement: { classPropertyName: "tooltipPlacement", publicName: "tooltipPlacement", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "window:copy": "onCopy($event)" } }, viewQueries: [{ propertyName: "valueNode", first: true, predicate: ["valueNode"], descendants: true, isSignal: true }, { propertyName: "tooltip", first: true, predicate: ["t"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n class=\"is-inline-block\"\n [class.is-clickable]=\"!disabled()\"\n (click)=\"onClick($event)\"\n ngbTooltip=\"Copied!\"\n triggers=\"manual\"\n [placement]=\"tooltipPlacement()\"\n container=\"body\"\n #t=\"ngbTooltip\">\n <span #valueNode [class.is-hidden]=\"hideText()\">{{ value() }}</span>\n\n @if (!hideIcon()) {\n <span [class]=\"clipboardClass()\">\n <he-svg-icon [name]=\"icon()\" [size]=\"size()\" />\n </span>\n }\n</div>\n", styles: [":host{display:inline-block}.is-small he-svg-icon{height:16px!important;width:16px!important}\n"], dependencies: [{ kind: "directive", type: NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "popperOptions", "triggers", "positionTarget", "container", "disableTooltip", "tooltipClass", "tooltipContext", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { kind: "component", type: HESvgIconComponent, selector: "he-svg-icon", inputs: ["name", "size", "animation"] }] }); }
1844
1857
  }
1845
1858
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ClipboardComponent, decorators: [{
1846
1859
  type: Component$1,
1847
- args: [{ selector: 'he-clipboard', imports: [NgbTooltip, HESvgIconComponent], template: "<div\n [class.is-clickable]=\"!disabled()\"\n (click)=\"onClick($event)\"\n ngbTooltip=\"Copied!\"\n triggers=\"manual\"\n [placement]=\"tooltipPlacement()\"\n container=\"body\"\n #t=\"ngbTooltip\">\n <span #valueNode [class.is-hidden]=\"hideText()\">{{ value() }}</span>\n\n @if (!hideIcon()) {\n <he-svg-icon [name]=\"icon()\" [size]=\"size()\" [class]=\"clipboardClass()\" />\n }\n</div>\n", styles: [".is-small he-svg-icon{height:16px!important;width:16px!important}\n"] }]
1860
+ args: [{ selector: 'he-clipboard', imports: [NgbTooltip, HESvgIconComponent], template: "<div\n class=\"is-inline-block\"\n [class.is-clickable]=\"!disabled()\"\n (click)=\"onClick($event)\"\n ngbTooltip=\"Copied!\"\n triggers=\"manual\"\n [placement]=\"tooltipPlacement()\"\n container=\"body\"\n #t=\"ngbTooltip\">\n <span #valueNode [class.is-hidden]=\"hideText()\">{{ value() }}</span>\n\n @if (!hideIcon()) {\n <span [class]=\"clipboardClass()\">\n <he-svg-icon [name]=\"icon()\" [size]=\"size()\" />\n </span>\n }\n</div>\n", styles: [":host{display:inline-block}.is-small he-svg-icon{height:16px!important;width:16px!important}\n"] }]
1848
1861
  }], propDecorators: { valueNode: [{ type: i0.ViewChild, args: ['valueNode', { isSignal: true }] }], tooltip: [{ type: i0.ViewChild, args: ['t', { isSignal: true }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], hideText: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideText", required: false }] }], hideIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideIcon", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], clipboardClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "clipboardClass", required: false }] }], tooltipPlacement: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPlacement", required: false }] }], onCopy: [{
1849
1862
  type: HostListener,
1850
1863
  args: ['window:copy', ['$event']]
@@ -8133,14 +8146,13 @@ class NodeLogsModelsComponent {
8133
8146
  params: () => ({
8134
8147
  ids: unique(this.cycle()
8135
8148
  ?.inputs?.filter((value) => inputGroupsTermTypes.includes(value?.term?.termType))
8136
- ?.map(v => v.term['@id'])
8137
- ?.filter(Boolean) ?? [])
8149
+ ?.map(v => v.term['@id']) ?? []).filter(Boolean)
8138
8150
  }),
8139
8151
  stream: ({ params: { ids } }) => from(ids).pipe(mergeMap((id) => this.nodeService.get$({ '@type': NodeType.Term, '@id': id })), mergeMap(term => term.defaultProperties?.map(v => ({ id: v.key?.['@id'], group: term['@id'] }))), filter(v => !!v.id), reduce((prev, curr) => {
8140
8152
  prev[curr.id] = prev[curr.id] || [];
8141
8153
  prev[curr.id].push(curr.group);
8142
8154
  return prev;
8143
- }, {}))
8155
+ }, {}), catchError(() => of({})))
8144
8156
  });
8145
8157
  this.animalGroups = computed(() => (this.cycle()?.animals?.flatMap(animal => animal.inputs?.map(input => ({ id: input.term['@id'], group: animal.animalId }))) ?? [])
8146
8158
  .filter(Boolean)
@@ -8164,7 +8176,7 @@ class NodeLogsModelsComponent {
8164
8176
  ? this.searchTerms({
8165
8177
  bool: {
8166
8178
  must: [matchType(NodeType.Term)],
8167
- should: values.map(matchId),
8179
+ should: values.filter(Boolean).map(matchId),
8168
8180
  minimum_should_match: 1
8169
8181
  }
8170
8182
  })
@@ -8224,7 +8236,7 @@ class NodeLogsModelsComponent {
8224
8236
  ? this.searchTerms({
8225
8237
  bool: {
8226
8238
  must: [matchType(NodeType.Term)],
8227
- should: ids.map(id => matchExactQuery('@id', id)),
8239
+ should: ids.filter(Boolean).map(matchId),
8228
8240
  minimum_should_match: 1
8229
8241
  }
8230
8242
  }).pipe(map(groupTerms))
@@ -10081,7 +10093,7 @@ class EngineOrchestratorEditComponent {
10081
10093
  query: {
10082
10094
  bool: {
10083
10095
  must: [matchType(NodeType.Term)],
10084
- should: ids.map(matchId),
10096
+ should: ids.filter(Boolean).map(matchId),
10085
10097
  minimum_should_match: 1
10086
10098
  }
10087
10099
  }
@@ -10721,6 +10733,11 @@ const customErrorMessage = {
10721
10733
  If it is more than 7305 days, consider using the term ${code('Other natural vegetation')} instead.`,
10722
10734
  'must not add the feed input to the Cycle as well': ({ params: { term } = {} }) => `You have added the animal feed Input ${code(term['@id'])} to the Cycle inputs as well, which might lead to double counting.
10723
10735
  If you do not know the amount of ${code(term['@id'])} given to each Animal, please add the Input to the Cycle only.`,
10736
+ 'must provide value or min and max': ({ params }) => `You have provided only a ${code('max')} without a ${code('min')} or a ${code('value')}${params.term ? ` for ${termLink(params.term)}` : ''}.
10737
+ ${params?.term?.termType === TermTermType.measurement
10738
+ ? `This Measurement has additional restrictions and needs either a ${code('value')} or both a ${code('min')} and ${code('max')} specified.
10739
+ Please consider adding both the ${code('min')} and the ${code('max')}, or delete the Measurement.`
10740
+ : ''}`,
10724
10741
  'must specify water type for ponds': ({ params }) => `For Sites with ${schemaLink('Site#siteType', 'siteType')} = ${code('pond')}, you must specify the ${externalNodeLink({
10725
10742
  '@type': NodeType.Term,
10726
10743
  '@id': 'waterSalinity',