@hestia-earth/ui-components 0.40.15 → 0.40.16

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.
@@ -7223,6 +7223,7 @@ const isRecalculated$1 = (key) => (value) => [...(value.added || []), ...(value.
7223
7223
  const hasRecalculatedKeys = (value) => [...(value.added || []), ...(value.updated || [])].length > 0;
7224
7224
  const hasRecalculatedValue = (values, key = 'value') => values.some(isRecalculated$1(key));
7225
7225
  const filterDeleted = (blankNodes) => (blankNodes || []).filter(value => !value.deleted);
7226
+ const filterTransformation = (blankNodes) => (blankNodes || []).filter(value => !value.transformation);
7226
7227
  const groupSubvalues = (subValues, termsGrouping) => Object.keys(termsGrouping).length
7227
7228
  ? Object.values(subValues.reduce((prev, curr) => {
7228
7229
  if (curr.id in termsGrouping) {
@@ -7647,6 +7648,12 @@ const groupLogsByTerm = (node, logs, config, allOriginalValues, allRecalculatedV
7647
7648
  const isRequired = !Object.values(termLogs)
7648
7649
  .filter(v => typeof v === 'object' && !Array.isArray(v) && !v.isKey)
7649
7650
  .every(v => v.runRequired === false);
7651
+ const ignoreTransformationValues = [
7652
+ nodeType$1 === NodeType.Cycle,
7653
+ subValues.some(v => v.key === 'transformation')
7654
+ ].every(Boolean);
7655
+ const filteredOriginalValues = ignoreTransformationValues ? filterTransformation(original) : original;
7656
+ const filteredRecalculatedValues = ignoreTransformationValues ? filterTransformation(recalculated) : recalculated;
7650
7657
  const nodeLog = dataWithConfigModelLogs(termLogs)({
7651
7658
  blankNode: true,
7652
7659
  isOpen: defaultGroupOpen,
@@ -7655,12 +7662,12 @@ const groupLogsByTerm = (node, logs, config, allOriginalValues, allRecalculatedV
7655
7662
  term,
7656
7663
  type,
7657
7664
  configModels,
7658
- original,
7659
- originalValue: reduceValues(original, termId),
7660
- recalculated,
7661
- recalculatedValue: reduceValues(recalculated, termId),
7662
- isOriginal: !!original.length,
7663
- isRecalculated: hasRecalculatedValue(recalculated),
7665
+ original: filteredOriginalValues,
7666
+ originalValue: reduceValues(filteredOriginalValues, termId),
7667
+ recalculated: filteredRecalculatedValues,
7668
+ recalculatedValue: reduceValues(filteredRecalculatedValues, termId),
7669
+ isOriginal: !!filteredOriginalValues.length,
7670
+ isRecalculated: hasRecalculatedValue(filteredRecalculatedValues),
7664
7671
  hasData,
7665
7672
  isRequired,
7666
7673
  logs: termLogs,
@@ -10207,16 +10214,15 @@ const listAsCode = (values) => (values ?? []).map(code).join(', ');
10207
10214
  const dataPathLabel = (dataPath = '') => parseDataPath(dataPath)
10208
10215
  .filter(({ label }) => allowedDataPathsLabels.includes(label))
10209
10216
  .pop()?.label;
10217
+ const guideLink = (guidePath, title) => externalLink(`${baseUrl()}/guide/${guidePath}`, title);
10210
10218
  const glossaryTypeLink = (type, text = termTypeLabel(type)) => externalLink(`${glossaryBaseUrl()}?termType=${type}`, text);
10211
10219
  const termLink = ({ id, name }) => externalLink(`${baseUrl()}/term/${id}`, name || id);
10212
10220
  const dateFormatMessage = `Should follow the ISO 8601 date format, e.g. ${code(2000)}, or ${code('2000-12')}, or ${code('2000-12-30')}, and in some cases an optional time. Please refer to the schema for more details.`;
10213
10221
  const threshold = (value) => code(`${value * 100}%`);
10214
10222
  const joinValues = (values) => (values || []).filter(Boolean).map(code).join('<span>, </span>');
10215
- const formatListLine = (values) => values
10216
- .flat()
10217
- .map(r => `<li class="is-pre-wrap">${r}</li>`)
10218
- .join('');
10219
- const formatList = (values) => `<ul class="is-pl-3 is-list-style-disc is-nowrap">${formatListLine(values)}</ul>`;
10223
+ const formatListLine = (value) => `<li class="is-pre-wrap">${value}</li>`;
10224
+ const formatListLines = (values) => values.flat().map(formatListLine).join('');
10225
+ const formatList = (values, style = 'disc') => `<ul class="is-pl-3 is-list-style-${style} is-nowrap">${formatListLines(values)}</ul>`;
10220
10226
  const noTillage = { id: 'noTillage', name: 'No tillage' };
10221
10227
  const pastureGrass = { id: 'pastureGrass', name: 'Pasture grass' };
10222
10228
  const idNotFoundDefaultMessage = `
@@ -10323,11 +10329,11 @@ const customErrorMessage = {
10323
10329
  'should have the same length as endDate': () => `The startDate must be in the same date format as ${code('endDate')}: YYYY-MM-DD, YYYY-MM, or YYYY.`,
10324
10330
  'node not found': (error, _errorCount, allErrors) => `${allErrors?.length
10325
10331
  ? `The following Nodes do not exist on the platform:
10326
- ${formatList(unique(allErrors.map(({ params }) => `<li class="is-pre-wrap">${params?.node?.['@type']} with ${code(`@id=${params?.node?.['@id']}`)}</li>`)))}`
10332
+ ${formatList(unique(allErrors.map(({ params }) => `${params?.node?.['@type']} with ${code(`@id=${params?.node?.['@id']}`)}`)))}`
10327
10333
  : `The ${error.params?.node?.['@type']} with ${code(`@id=${error.params?.node?.['@id']}`)} does not exist on the platform.`} If you are trying to link to nodes included in this upload, you must use ${code('id')} field instead. Otherwise, please check the ids are correct and try again.`,
10328
10334
  'should be linked to an existing node': (error, _errorCount, allErrors) => allErrors?.length
10329
10335
  ? `Your upload does not contain the following Nodes:
10330
- ${formatList(unique(allErrors.map(({ params }) => `<li class="is-pre-wrap">${params?.node?.type} with ${code(`id=${params?.node?.id}`)}</li>`)))}
10336
+ ${formatList(unique(allErrors.map(({ params }) => `${params?.node?.type} with ${code(`id=${params?.node?.id}`)}`)))}
10331
10337
  If you are trying to link to an existing Node on the HESTIA platform, you must use ${code('@id')} field instead.
10332
10338
  Otherwise you must include a full ${unique(allErrors.map(({ params }) => `${params?.node?.type} with id ${code(params?.node?.id)}.`)).join(', ')}`
10333
10339
  : `Your upload does not contain a ${error.params?.node?.type} with ${code(`id=${error.params?.node?.id}`)}.
@@ -10425,11 +10431,11 @@ const customErrorMessage = {
10425
10431
  ? `${code(toPrecision(params?.expected, 3))}, but the value in the upload is ${code(toPrecision(params?.current, 3))}.
10426
10432
  ${params?.threshold ? `Our threshold is ±${threshold(params?.threshold)}.` : ''}
10427
10433
  Please either:
10428
- <ul class="is-pl-3 is-list-style-decimal is-nowrap">
10429
- <li class="is-pre-wrap">Check the ${params?.term.termType} value you provided;</li>
10430
- <li class="is-pre-wrap">Check the data you provided which is the input into this model;</li>
10431
- <li class="is-pre-wrap">Carefully read the documentation to understand if we used a default property as part of the calculations.</li>
10432
- </ul>`
10434
+ ${formatList([
10435
+ 'Check the ${params?.term.termType} value you provided;',
10436
+ 'Check the data you provided which is the input into this model;',
10437
+ 'Carefully read the documentation to understand if we used a default property as part of the calculations.'
10438
+ ], 'decimal')}`
10433
10439
  : 'not consistent with the model result.'}`,
10434
10440
  'the measurement provided might be in error': ({ params }, errorCount) => `The expected value for ${code(params?.term.name)}
10435
10441
  ${params?.model?.name ? `using ${code(params.model.name)} ` : ''}
@@ -10483,11 +10489,11 @@ const customErrorMessage = {
10483
10489
  ? ` Instead use the ${termLink({ id: 'nitrogenContent', name: 'Nitrogen Content' })} Property on the ${code('kg')} term to define the nitrogen content of the ${code(params?.term?.termType)}.`
10484
10490
  : ''}`,
10485
10491
  'is missing required bibliographic information': () => `The automatic bibliography search failed for this Bibliography. Either:
10486
- <ul class="is-pl-3 is-list-style-decimal is-nowrap">
10487
- <li class="is-pre-wrap">Manually fill-in the <b>required</b> bibliographic information as per ${schemaLink(SchemaType.Bibliography, 'our schema')}.</li>
10488
- <li class="is-pre-wrap">Provide the ${code('documentDOI')} as well as the ${code('title')}.</li>
10489
- <li class="is-pre-wrap">Check the ${code('documentDOI')} and ${code('title')} for typos against the ${externalLink('https://www.mendeley.com', 'Mendeley catalogue')}.</li>
10490
- </ul>`,
10492
+ ${formatList([
10493
+ `Manually fill-in the <b>required</b> bibliographic information as per ${schemaLink(SchemaType.Bibliography, 'our schema')}.`,
10494
+ `Provide the ${code('documentDOI')} as well as the ${code('title')}.`,
10495
+ `Check the ${code('documentDOI')} and ${code('title')} for typos against the ${externalLink('https://www.mendeley.com', 'Mendeley catalogue')}.`
10496
+ ], 'decimal')}`,
10491
10497
  'should be lower than max size': ({ params }) => `The boundary or region is >${params?.expected}km2 and is too large to reliably gap fill Measurements.
10492
10498
  If you are able to use a more specific region or smaller boundary, please do.`,
10493
10499
  'an excreta input is required when using an excretaManagement practice': ({ dataPath }) => {
@@ -10573,16 +10579,16 @@ const customErrorMessage = {
10573
10579
  <br/>
10574
10580
  The fate can be added using:
10575
10581
  ${formatList([
10576
- `the ${glossaryTypeLink(TermTermType.cropResidueManagement)} practices; and`,
10577
- `the ${glossaryTypeLink(TermTermType.cropResidue)} products.`
10582
+ `The ${glossaryTypeLink(TermTermType.cropResidueManagement)} practices; and`,
10583
+ `The ${glossaryTypeLink(TermTermType.cropResidue)} products.`
10578
10584
  ])}
10579
10585
  `,
10580
10586
  'should specify the fate of cropResidue': () => `You have not specified the fate of the crop residue.
10581
10587
  Adding this information will improve emissions and soil carbon stock calculations.
10582
10588
  The fate can be added using:
10583
10589
  ${formatList([
10584
- `the ${glossaryTypeLink(TermTermType.cropResidueManagement)} practices; and/or`,
10585
- `the ${glossaryTypeLink(TermTermType.cropResidue)} products.`
10590
+ `The ${glossaryTypeLink(TermTermType.cropResidueManagement)} practices; and/or`,
10591
+ `The ${glossaryTypeLink(TermTermType.cropResidue)} products.`
10586
10592
  ])}
10587
10593
  Remember to set ${code('completeness.cropResidue')} to ${code(true)} if both the above and below ground crop residue quantities and fates are specified.`,
10588
10594
  'should have the same privacy as the related source': ({ params }) => `To link to a ${(params?.defaultSource || params?.source)?.dataPrivate ? 'private' : 'public'} Source,
@@ -10637,9 +10643,7 @@ const customErrorMessage = {
10637
10643
  We recommend adding this to the Site, including information about current and historical tillage.
10638
10644
  `}
10639
10645
  We use this information to model CO<sub>2</sub> emissions from soil organic carbon change.`,
10640
- 'can not be used on this termType': ({ params }) => `This Property can only be used on blank nodes with the following ${code('term.termType')}: ${params.expected
10641
- .map(code)
10642
- .join(', ')}.`,
10646
+ 'can not be used on this termType': ({ params }) => `This Property can only be used on blank nodes with the following ${code('term.termType')}: ${listAsCode(params.expected)}.`,
10643
10647
  'not a valid GeoJSON': ({ params }) => `
10644
10648
  ${params?.invalidCoordinates === 'true'
10645
10649
  ? `GeoJSON data should follow the WGS84 datum.
@@ -10743,9 +10747,12 @@ const customErrorMessage = {
10743
10747
  'primaryPercent not allowed on this siteType': ({ params }) => `The ${schemaLink('Practice#primaryPercent', 'primaryPercent')} can only be used on ${schemaLink('Site#siteType', 'siteType')} ${params?.expected?.map(code).join(' or ')}.`,
10744
10748
  'primaryPercent not allowed on this practice': () => `This practice is not a processing operation.
10745
10749
  You can only add the ${schemaLink('Practice#primaryPercent', 'primaryPercent')} field to terms with ${code('termType')} = ${code(TermTermType.operation)} and lookup ${code('isProcessingOperation')} = ${code(true)}.`,
10746
- 'at least one landCover practice must match an equivalent product': ({ params }) => `You have specified ${listAsCode(params?.current)} as ${code(TermTermType.landCover)} practice, but none of the recorded products match. Please add the practices for ${params?.expected
10747
- .map(code)
10748
- .join(', ')}, or remove all ${code(TermTermType.landCover)} practices.`,
10750
+ 'at least one landCover practice must match an equivalent product': ({ params }) => `To ensure there is no conflicting data between your Cycle and Products, your specified ${code(TermTermType.landCover)} Practices must match a Product.
10751
+ ${formatList([
10752
+ `Ensure at least one Practice matches a Product (e.g., ${listAsCode(params?.current)} matching ${listAsCode(params?.expected)}). Check ${code('landCoverTermId')} in the glossary for equivalents.`,
10753
+ `If specifying fallow periods, you must also include the Product's equivalent Practice with a ${code('startDate')} and ${code('endDate')}.`,
10754
+ `Alternatively, do not set these ${code(TermTermType.landCover)} practices, and they will be gap filled automatically from products.`
10755
+ ])}`,
10749
10756
  'should match the site management node value': () => `The data you have uploaded in the Management node are not consistent with the data provided in the Cycles.
10750
10757
  If the same ${code('term')} is used between the same ${code('startDate')} and ${code('endDate')}, they must have the same ${code('value')} in ${code('Management')} and in the Cycles.
10751
10758
  Please check your upload and ensure that the data is consistent throughout.`,
@@ -10755,7 +10762,7 @@ const customErrorMessage = {
10755
10762
  name: 'Saplings, depreciated amount per Cycle'
10756
10763
  })}.
10757
10764
  This input should be present in each plantation Cycle in your upload, with the ${code('value')} being the total number of ${code('Saplings')} used divided by the number of possible Cycles in the plantation's lifespan.
10758
- See the ${externalLink(`${baseUrl()}/guide/guide-file-upload-special-cases`, 'special upload case')} for more details.`,
10765
+ See the ${guideLink('guide-file-upload-special-cases', 'special upload case')} for more details.`,
10759
10766
  'must be linked to a verified country-level Impact Assessment': ({ params }) => [
10760
10767
  'This Input must be linked to a country-level verified aggregation, but none could be found.',
10761
10768
  params?.current ? 'Note: using a verified World aggregation is not valid.' : ''
@@ -10764,8 +10771,12 @@ const customErrorMessage = {
10764
10771
  .join('\n'),
10765
10772
  'must contain water inputs': () => `If ${schemaLink('Completeness#water', 'completeness.water')}=${code(true)} for irrigated Cycles, you must provide ${glossaryTypeLink(TermTermType.water)} inputs.
10766
10773
  Otherwise, set ${schemaLink('Completeness#water', 'completeness.water')}=${code(false)}.`,
10767
- 'management date must be before cycle start date': ({ params }) => `The Site Management dates must be before ${code(params.expected)} (the start date of the first linked Cycle).
10768
- Note: if the ${schemaLink('Cycle#startDate', 'Cycle startDate')} is not provided, the ${schemaLink('Cycle#cycleDuration', 'cycleDuration')} can be used to set the earliest date of overlap.`,
10774
+ 'management date must be before cycle start date': ({ params }) => `The Site Management's dates must not overlap with any of the Cycles' dates.
10775
+ The Site Management must only be used to record historical information about years preceding your first Cycle.
10776
+ If you are trying to specify land management or practices that take place during the period covered by your Cycles, please do so directly in the Cycles, using the Product or Practice nodes.
10777
+ Please refer to our Guide section on special case uploads for more information: ${guideLink('guide-file-upload-special-cases', 'special upload case')}.
10778
+ Note: if the first Cycle ${code('startDate')} is not provided, the ${code('cycleDuration')} can be used to set the earliest date of overlap.
10779
+ If the first Cycle ${code('cycleDuration')} is not provided, the lookup of the ${code('maximumCycleDuration')} primary Product can be used to set the earliest date of overlap.`,
10769
10780
  'must be in the same format as endDate': () => `The date format does not match the format of ${code('endDate')}. You must use the same date format for both fields.`,
10770
10781
  'must be at least equal to the minimum value': ({ params: { min } }) => `Must be at least equal to ${min}`,
10771
10782
  'must equal to endDate - startDate in days': ({ params: { expected } }) => `Must be equal to ${code('endDate')} - ${code('startDate')} in days (inclusive of the ${code('startDate')} and ${code('endDate')} days) (~${expected})`,
@@ -12496,12 +12507,13 @@ const restoreChildren = (node) => {
12496
12507
  const wrap = (selection, maxWidth = nodeContentWidth) => {
12497
12508
  selection.each(function (d) {
12498
12509
  const t = select(this);
12510
+ const units = ellipsis$1(d.data.units, 20);
12499
12511
  d3wrap(t, {
12500
12512
  maxWidth,
12501
12513
  maxLines: d.data.showBar ? 2 : 3,
12502
12514
  vcentre: !d.data.showBar,
12503
- words: [...d.data.label.split(/\s+/), d.data.units],
12504
- ownLineWord: d.data.units,
12515
+ words: [...d.data.label.split(/\s+/), units],
12516
+ ownLineWord: units,
12505
12517
  nHeight: nodeHeight,
12506
12518
  lHeight: lineHeight
12507
12519
  });