@aiconomy/aico-components 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aico-components/aico-components.esm.js +1 -1
- package/dist/aico-components/aico-components.esm.js.map +1 -1
- package/dist/aico-components/{p-17b7115a.entry.js → p-cf9b69ea.entry.js} +3 -3
- package/dist/aico-components/p-cf9b69ea.entry.js.map +1 -0
- package/dist/cjs/aico-album-content_28.cjs.entry.js +131 -10
- package/dist/cjs/aico-album-content_28.cjs.entry.js.map +1 -1
- package/dist/cjs/aico-components.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/aico-article-detail/aico-article-detail.js +11 -7
- package/dist/collection/components/aico-article-detail/aico-article-detail.js.map +1 -1
- package/dist/collection/components/aico-neo-content/aico-neo-content.js +53 -2
- package/dist/collection/components/aico-neo-content/aico-neo-content.js.map +1 -1
- package/dist/collection/utils/neo/neo-lead-trim.js +106 -0
- package/dist/collection/utils/neo/neo-lead-trim.js.map +1 -0
- package/dist/components/aico-article-detail2.js +11 -7
- package/dist/components/aico-article-detail2.js.map +1 -1
- package/dist/components/aico-neo-content2.js +126 -5
- package/dist/components/aico-neo-content2.js.map +1 -1
- package/dist/esm/aico-album-content_28.entry.js +131 -10
- package/dist/esm/aico-album-content_28.entry.js.map +1 -1
- package/dist/esm/aico-components.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ssr/index.js +134 -11
- package/dist/ssr/index.mjs +134 -11
- package/dist/types/components/aico-article-detail/aico-article-detail.d.ts +3 -1
- package/dist/types/components/aico-neo-content/aico-neo-content.d.ts +10 -0
- package/dist/types/components.d.ts +16 -0
- package/dist/types/utils/neo/neo-lead-trim.d.ts +33 -0
- package/package.json +1 -1
- package/dist/aico-components/p-17b7115a.entry.js.map +0 -1
|
@@ -13961,11 +13961,11 @@ const AicoArticleDetail = class {
|
|
|
13961
13961
|
const translation = (_a = this.article.attributes.translations.find(translation => translation.locale === this.locale)) !== null && _a !== void 0 ? _a : null;
|
|
13962
13962
|
const category = (_c = (_b = this.article.attributes.newsCategory) === null || _b === void 0 ? void 0 : _b.translations.find(translation => translation.locale === this.locale)) !== null && _c !== void 0 ? _c : null;
|
|
13963
13963
|
const articleDate = new Date(this.article.attributes.publishDate);
|
|
13964
|
-
const content = this.mapBodyContent();
|
|
13964
|
+
const content = this.mapBodyContent(translation);
|
|
13965
13965
|
const headlineFocusX = this.article.attributes.headlineImageFocusXPercentage ? `${this.article.attributes.headlineImageFocusXPercentage}%` : 'center';
|
|
13966
13966
|
const headlineFocusY = this.article.attributes.headlineImageFocusYPercentage ? `${this.article.attributes.headlineImageFocusYPercentage}%` : 'center';
|
|
13967
13967
|
const headlineImage = (_d = translation === null || translation === void 0 ? void 0 : translation.headlineImage) !== null && _d !== void 0 ? _d : this.article.attributes.headlineImage;
|
|
13968
|
-
return (index.h(index.Host, { key: '
|
|
13968
|
+
return (index.h(index.Host, { key: '4973f50c2a561ff5f68ff16b29285dde0ef75f87' }, index.h("figure", { key: '363fdcf4f12d61022d5153216ad574f590dc3e82', class: "figure" }, index.h("blockquote", { key: '357d1a947423d3bb99748ebfe65c0ce6f95647cb', class: "blockquote" }, index.h("h2", { key: 'd1037e2b0b71bab77fc37b36f7533d6d141ac406', class: "text-uppercase" }, (_e = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _e !== void 0 ? _e : this.article.attributes.name)), headlineImage && index.h("img", { key: '265565ff90b7b243555fb1c2aa5441e20826b43a', class: "figure-img img-fluid rounded object-fit-cover", style: { 'object-position': `${headlineFocusX} ${headlineFocusY}` }, alt: "Headline image", src: headlineImage }), index.h(ConditionalRender, { key: '3f94832f01549a5511a4927c53286c114953228d', condition: !this.hideDateAndAuthor }, index.h("figcaption", { key: '7afe217a895b0f9546a2beda40c9f143acdcc358', class: "figure-caption mb-1" }, articleDate.toLocaleDateString('en-US', this.dateOptions), " by ", index.h("cite", { key: '7a0c93292b1ed0bc39e8e94f68de9ba18ac99a36', title: "Author" }, this.article.attributes.author))), index.h(ConditionalRender, { key: 'a89fb90d8e7f6ba6048b43a119d127c7a6c6879b', condition: !this.hideCategoryAndTags && !strIsNullOrEmptyOrWhitespace(category === null || category === void 0 ? void 0 : category.webName) }, index.h("span", { key: '87aa1fe763f281238ed12d2b1dddbe043f58c8e6', class: "badge bg-info text-dark" }, category === null || category === void 0 ? void 0 : category.webName))), index.h("div", { key: 'e0bb9d8ebbedc684e4cb848042998874e3c7520b', class: "content-wrapper" }, content), index.h(ConditionalRender, { key: '81c6c20f4f8274a01ff8b65f1bf2c319e1811998', condition: !this.hideCategoryAndTags }, this.article.attributes.newsTags.map(tag => {
|
|
13969
13969
|
var _a;
|
|
13970
13970
|
const translation = (_a = tag.translations.find(translation => translation.locale === this.locale)) !== null && _a !== void 0 ? _a : null;
|
|
13971
13971
|
return (index.h(ConditionalRender, { condition: !strIsNullOrEmptyOrWhitespace(translation === null || translation === void 0 ? void 0 : translation.webName) }, index.h("span", { class: "badge bg-light text-dark" }, translation.webName)));
|
|
@@ -13977,15 +13977,19 @@ const AicoArticleDetail = class {
|
|
|
13977
13977
|
* then empty, null, or a stale copy) — when the Neo document has sections it
|
|
13978
13978
|
* wins, mirroring the b2b storefront's precedence. Otherwise the legacy
|
|
13979
13979
|
* rows render; a null/absent legacy builder renders an empty body instead
|
|
13980
|
-
* of throwing.
|
|
13980
|
+
* of throwing. When this page already shows its own headline image/title
|
|
13981
|
+
* above the body, the Neo renderer is asked to trim a duplicate leading
|
|
13982
|
+
* hero image/heading from the document (see neo-lead-trim.ts).
|
|
13981
13983
|
*/
|
|
13982
|
-
mapBodyContent() {
|
|
13983
|
-
var _a, _b;
|
|
13984
|
+
mapBodyContent(translation) {
|
|
13985
|
+
var _a, _b, _c, _d;
|
|
13984
13986
|
const neoDocument = this.article.attributes.contentBuilderNeoJson;
|
|
13985
13987
|
if (neoDocumentHasContent(neoDocument)) {
|
|
13986
|
-
|
|
13988
|
+
const headlineImage = (_a = translation === null || translation === void 0 ? void 0 : translation.headlineImage) !== null && _a !== void 0 ? _a : this.article.attributes.headlineImage;
|
|
13989
|
+
const title = (_b = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _b !== void 0 ? _b : this.article.attributes.name;
|
|
13990
|
+
return index.h("aico-neo-content", { neoDocument: neoDocument, locale: this.locale, trimLeadImage: !!headlineImage, dedupeTitle: title });
|
|
13987
13991
|
}
|
|
13988
|
-
const rows = (
|
|
13992
|
+
const rows = (_d = (_c = this.article.attributes.contentBuilder) === null || _c === void 0 ? void 0 : _c.rows) !== null && _d !== void 0 ? _d : [];
|
|
13989
13993
|
return [...rows].sort((a, b) => a.order - b.order).map((row, index) => this.mapRowContent(row, index));
|
|
13990
13994
|
}
|
|
13991
13995
|
mapRowContent(row, index$1) {
|
|
@@ -20845,6 +20849,112 @@ function resolveLocale(document, locale, defaultLocale = null) {
|
|
|
20845
20849
|
return resolved;
|
|
20846
20850
|
}
|
|
20847
20851
|
|
|
20852
|
+
const ENTITIES = {
|
|
20853
|
+
'&': '&',
|
|
20854
|
+
'<': '<',
|
|
20855
|
+
'>': '>',
|
|
20856
|
+
'"': '"',
|
|
20857
|
+
''': "'",
|
|
20858
|
+
' ': ' ',
|
|
20859
|
+
};
|
|
20860
|
+
/** Plain text of an HTML fragment, whitespace-collapsed and lowercased (mirrors NeoNewsContentRenderer::normalizeText). */
|
|
20861
|
+
function normalizeText(html) {
|
|
20862
|
+
const stripped = html.replace(/<[^>]*>/g, '');
|
|
20863
|
+
const decoded = stripped.replace(/&|<|>|"|'| /g, entity => ENTITIES[entity]);
|
|
20864
|
+
return decoded.replace(/\s+/g, ' ').trim().toLowerCase();
|
|
20865
|
+
}
|
|
20866
|
+
function headingText(element) {
|
|
20867
|
+
var _a;
|
|
20868
|
+
const text = (_a = element.content) === null || _a === void 0 ? void 0 : _a.text;
|
|
20869
|
+
return typeof text === 'string' ? text : '';
|
|
20870
|
+
}
|
|
20871
|
+
/** Filters one elements array, recursing into `columns` children. Returns the input array by reference when nothing changed. */
|
|
20872
|
+
function trimElements(elements, state) {
|
|
20873
|
+
const result = [];
|
|
20874
|
+
let changed = false;
|
|
20875
|
+
for (const element of elements) {
|
|
20876
|
+
if (element.type === 'columns') {
|
|
20877
|
+
const children = Array.isArray(element.children) ? element.children : [];
|
|
20878
|
+
const newChildren = trimElements(children, state);
|
|
20879
|
+
if (newChildren.length === 0) {
|
|
20880
|
+
changed = true;
|
|
20881
|
+
continue;
|
|
20882
|
+
}
|
|
20883
|
+
if (newChildren !== children) {
|
|
20884
|
+
changed = true;
|
|
20885
|
+
result.push(Object.assign(Object.assign({}, element), { children: newChildren }));
|
|
20886
|
+
}
|
|
20887
|
+
else {
|
|
20888
|
+
result.push(element);
|
|
20889
|
+
}
|
|
20890
|
+
continue;
|
|
20891
|
+
}
|
|
20892
|
+
if (element.type === 'image') {
|
|
20893
|
+
// Images never end the lead: kept or dropped, either way the next
|
|
20894
|
+
// element is still evaluated as leading.
|
|
20895
|
+
if (state.atLeadingEdge && state.dropLeadingImage) {
|
|
20896
|
+
changed = true;
|
|
20897
|
+
continue;
|
|
20898
|
+
}
|
|
20899
|
+
result.push(element);
|
|
20900
|
+
continue;
|
|
20901
|
+
}
|
|
20902
|
+
if (element.type === 'divider') {
|
|
20903
|
+
// Dividers don't end the lead either.
|
|
20904
|
+
result.push(element);
|
|
20905
|
+
continue;
|
|
20906
|
+
}
|
|
20907
|
+
if (element.type === 'heading') {
|
|
20908
|
+
if (state.atLeadingEdge && state.normalizedTitle !== null && normalizeText(headingText(element)) === state.normalizedTitle) {
|
|
20909
|
+
changed = true;
|
|
20910
|
+
continue;
|
|
20911
|
+
}
|
|
20912
|
+
result.push(element);
|
|
20913
|
+
state.atLeadingEdge = false;
|
|
20914
|
+
continue;
|
|
20915
|
+
}
|
|
20916
|
+
// Any other element type (text, html, button, video, gallery, slideshow, …) is kept and ends the lead.
|
|
20917
|
+
result.push(element);
|
|
20918
|
+
state.atLeadingEdge = false;
|
|
20919
|
+
}
|
|
20920
|
+
return changed ? result : elements;
|
|
20921
|
+
}
|
|
20922
|
+
/**
|
|
20923
|
+
* Preprocesses a locale-resolved Neo document, dropping lead content that
|
|
20924
|
+
* duplicates the host page's own header. Non-mutating: returns the input
|
|
20925
|
+
* unchanged (same reference) when there is nothing to do, otherwise a new
|
|
20926
|
+
* document with a new `sections` array (untouched sections/elements may be
|
|
20927
|
+
* reused by reference).
|
|
20928
|
+
*/
|
|
20929
|
+
function trimNeoLead(document, options) {
|
|
20930
|
+
const sections = Array.isArray(document.sections) ? document.sections : [];
|
|
20931
|
+
if (sections.length === 0) {
|
|
20932
|
+
return document;
|
|
20933
|
+
}
|
|
20934
|
+
const dedupeTitle = options.dedupeTitle;
|
|
20935
|
+
const hasDedupeTitle = typeof dedupeTitle === 'string' && dedupeTitle.trim() !== '';
|
|
20936
|
+
if (!options.trimLeadImage && !hasDedupeTitle) {
|
|
20937
|
+
return document;
|
|
20938
|
+
}
|
|
20939
|
+
const state = {
|
|
20940
|
+
atLeadingEdge: true,
|
|
20941
|
+
dropLeadingImage: options.trimLeadImage,
|
|
20942
|
+
normalizedTitle: hasDedupeTitle ? normalizeText(dedupeTitle) : null,
|
|
20943
|
+
};
|
|
20944
|
+
const newSections = [];
|
|
20945
|
+
for (const section of sections) {
|
|
20946
|
+
const elements = Array.isArray(section.elements) ? section.elements : [];
|
|
20947
|
+
const newElements = trimElements(elements, state);
|
|
20948
|
+
if (newElements.length === 0) {
|
|
20949
|
+
// An empty section must not survive — this is what removes a
|
|
20950
|
+
// background-only hero section once its sole image is trimmed.
|
|
20951
|
+
continue;
|
|
20952
|
+
}
|
|
20953
|
+
newSections.push(newElements === elements ? section : Object.assign(Object.assign({}, section), { elements: newElements }));
|
|
20954
|
+
}
|
|
20955
|
+
return Object.assign(Object.assign({}, document), { sections: newSections });
|
|
20956
|
+
}
|
|
20957
|
+
|
|
20848
20958
|
/**
|
|
20849
20959
|
* news-neo-renderer.ts
|
|
20850
20960
|
*
|
|
@@ -21983,12 +22093,14 @@ const AicoNeoContent = class {
|
|
|
21983
22093
|
this.neoDocument = undefined;
|
|
21984
22094
|
this.locale = 'de';
|
|
21985
22095
|
this.defaultLocale = undefined;
|
|
22096
|
+
this.trimLeadImage = false;
|
|
22097
|
+
this.dedupeTitle = undefined;
|
|
21986
22098
|
}
|
|
21987
22099
|
componentWillLoad() {
|
|
21988
22100
|
this.prepareHtml();
|
|
21989
22101
|
}
|
|
21990
22102
|
prepareHtml() {
|
|
21991
|
-
var _a;
|
|
22103
|
+
var _a, _b;
|
|
21992
22104
|
if (!neoDocumentHasContent(this.neoDocument)) {
|
|
21993
22105
|
this.renderedHtml = '';
|
|
21994
22106
|
return;
|
|
@@ -21997,6 +22109,13 @@ const AicoNeoContent = class {
|
|
|
21997
22109
|
if (hasLocaleStructure(resolvedDocument)) {
|
|
21998
22110
|
resolvedDocument = resolveLocale(resolvedDocument, this.locale, (_a = this.defaultLocale) !== null && _a !== void 0 ? _a : null);
|
|
21999
22111
|
}
|
|
22112
|
+
if (this.trimLeadImage || this.dedupeTitle) {
|
|
22113
|
+
resolvedDocument = trimNeoLead(resolvedDocument, { trimLeadImage: this.trimLeadImage, dedupeTitle: (_b = this.dedupeTitle) !== null && _b !== void 0 ? _b : null });
|
|
22114
|
+
if (resolvedDocument.sections.length === 0) {
|
|
22115
|
+
this.renderedHtml = '';
|
|
22116
|
+
return;
|
|
22117
|
+
}
|
|
22118
|
+
}
|
|
22000
22119
|
setActiveLocale(this.locale);
|
|
22001
22120
|
this.renderedHtml = NewsNeo.render({ contentBuilderNeoJson: resolvedDocument });
|
|
22002
22121
|
}
|
|
@@ -22008,13 +22127,15 @@ const AicoNeoContent = class {
|
|
|
22008
22127
|
}
|
|
22009
22128
|
}
|
|
22010
22129
|
render() {
|
|
22011
|
-
return (index.h(index.Host, { key: '
|
|
22130
|
+
return (index.h(index.Host, { key: '663be625008bd9444656dfedd24cfe9fa97e7d43' }, index.h("div", { key: 'f0827191bf2ccc6d8cb35644103aa558d338382f', class: "aico-neo-content-mount", innerHTML: this.renderedHtml })));
|
|
22012
22131
|
}
|
|
22013
22132
|
get host() { return index.getElement(this); }
|
|
22014
22133
|
static get watchers() { return {
|
|
22015
22134
|
"neoDocument": ["prepareHtml"],
|
|
22016
22135
|
"locale": ["prepareHtml"],
|
|
22017
|
-
"defaultLocale": ["prepareHtml"]
|
|
22136
|
+
"defaultLocale": ["prepareHtml"],
|
|
22137
|
+
"trimLeadImage": ["prepareHtml"],
|
|
22138
|
+
"dedupeTitle": ["prepareHtml"]
|
|
22018
22139
|
}; }
|
|
22019
22140
|
};
|
|
22020
22141
|
AicoNeoContent.style = AicoNeoContentStyle0;
|