@aiconomy/aico-components 0.0.158 → 0.0.164
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/README.md +14 -12
- 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-076c2ca2.entry.js → p-43d0546f.entry.js} +3 -3
- package/dist/aico-components/p-43d0546f.entry.js.map +1 -0
- package/dist/cjs/aico-album-content_27.cjs.entry.js +15 -7
- package/dist/cjs/aico-album-content_27.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-news-list/aico-news-list.js +40 -2
- package/dist/collection/components/aico-news-list/aico-news-list.js.map +1 -1
- package/dist/collection/components/aico-special-news-carousel/aico-special-news-carousel.js +2 -2
- package/dist/collection/components/aico-special-news-carousel/aico-special-news-carousel.js.map +1 -1
- package/dist/collection/components/aico-top-news-carousel/aico-top-news-carousel.js +2 -2
- package/dist/collection/components/aico-top-news-carousel/aico-top-news-carousel.js.map +1 -1
- package/dist/collection/utils/utils.js +7 -1
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/aico-news-list.js +6 -2
- package/dist/components/aico-news-list.js.map +1 -1
- package/dist/components/aico-special-news-carousel.js +2 -2
- package/dist/components/aico-special-news-carousel.js.map +1 -1
- package/dist/components/aico-top-news-carousel.js +2 -2
- package/dist/components/aico-top-news-carousel.js.map +1 -1
- package/dist/components/utils.js +7 -1
- package/dist/components/utils.js.map +1 -1
- package/dist/esm/aico-album-content_27.entry.js +15 -7
- package/dist/esm/aico-album-content_27.entry.js.map +1 -1
- package/dist/esm/aico-components.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/aico-news-list/aico-news-list.d.ts +8 -0
- package/dist/types/components.d.ts +16 -0
- package/dist/types/utils/utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/aico-components/p-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oBACnB,MAAA,IAAI,CAAC,cAAc,0CAAE,IAAI,CAAC,OAAO,CAAC,CAAC;iBACpC,IAEA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,mCAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAC3C,CACD,EACL,SAAG,KAAK,EAAC,uBAAuB,IAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,mCAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAK,CACrF,EACN,WAAK,KAAK,EAAC,0BAA0B,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,IACjE,WACE,KAAK,EAAC,kCAAkC,EACxC,KAAK,EAAE,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,EAC1E,GAAG,EAAC,cAAc,eAEhB,MAAA,MAAA,MAAA,MAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,mCAClB,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,mCAC/B,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,mCAC3B,OAAO,CAAC,UAAU,CAAC,KAAK,mCACxB,OAAO,CAAC,UAAU,CAAC,kBAAkB,mCACrC,OAAO,CAAC,UAAU,CAAC,cAAc,GAEnC,CACE,CACF,EACN;SACH,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["AicoSpecialNewsCarousel","$"],"sources":["src/components/aico-special-news-carousel/aico-special-news-carousel.css?tag=aico-special-news-carousel&encapsulation=scoped","src/components/aico-special-news-carousel/aico-special-news-carousel.tsx"],"sourcesContent":["@import '../../../node_modules/bootstrap/dist/css/bootstrap.css';\n\n:host,\n:host::before,\n:host::after {\n box-sizing: border-box;\n}\n\n:host {\n font-family: var(--bs-body-font-family);\n font-size: var(--bs-body-font-size);\n font-weight: var(--bs-body-font-weight);\n line-height: var(--bs-body-line-height);\n color: var(--bs-body-color);\n text-align: var(--bs-body-text-align);\n -webkit-text-size-adjust: 100%;\n}\n\n.slick-slide > div {\n height: 100% !important;\n}\n","import { Component, Event, EventEmitter, Prop, State, h } from '@stencil/core';\nimport type { NewsResponse } from '../../model/NewsResponse';\nimport type { AicoApiRequestInfo } from '../../model/AicoApiRequestInfo';\nimport type { Article } from '../../model/Article';\nimport { fetchSpecialNewsArticles, splitByComma } from '../../utils/utils';\n\nimport $ from 'jquery';\nimport 'slick-carousel';\n\n@Component({\n tag: 'aico-special-news-carousel',\n styleUrl: 'aico-special-news-carousel.css',\n scoped: true,\n})\nexport class AicoSpecialNewsCarousel {\n @State() newsResponse!: NewsResponse;\n\n @State() newsChannelsArr: string[] = [];\n\n @State() newsSellerIdsArr: string[] = [];\n\n @State() newsBrandIdsArr: string[] = [];\n\n @State() newsLanguageLocalesArr: string[] = [];\n\n /**\n * The url of the Aico Api that will be used to retrieve the article.\n */\n @Prop() aicoUrl!: string;\n\n /**\n * The token used to authenticate against he Aico Api.\n */\n @Prop() aicoBearerToken!: string;\n\n /**\n * Channel names as a comma separated list used to filter the results.\n */\n @Prop() newsChannels: string = '';\n\n /**\n * Seller ids as a comma separated list used to filter the results.\n */\n @Prop() newsSellerIds: string = '';\n\n /**\n * Brand ids as a comma separated list used to filter the results.\n */\n @Prop() newsBrandIds: string = '';\n\n /**\n * Language locales as a comma separated list used to filter the results.\n */\n @Prop() newsLanguageLocales: string = '';\n\n /**\n * The number of articles shown in the carousel. Prefer this number to be small.\n */\n @Prop() numberOfArticles: number = 6;\n\n /**\n * The article translation that will be used to render the content.\n *\n * If the locale specified is not present in the article's translations, most content will not be shown.\n */\n @Prop() locale: string = 'de';\n\n /**\n * Event emitted when a user clicks an article title.\n *\n * The handler receives the entire Article entity.\n */\n @Event() articleClicked?: EventEmitter<Article>;\n\n private api?: AicoApiRequestInfo;\n private newsListFetchController?: AbortController;\n\n connectedCallback() {\n this.newsListFetchController = new AbortController();\n this.api = { baseApi: this.aicoUrl, bearerToken: this.aicoBearerToken };\n\n this.newsChannelsArr = splitByComma(this.newsChannels);\n this.newsSellerIdsArr = splitByComma(this.newsSellerIds);\n this.newsBrandIdsArr = splitByComma(this.newsBrandIds);\n this.newsLanguageLocalesArr = splitByComma(this.newsLanguageLocales);\n }\n\n disconnectedCallback() {\n this.newsListFetchController!.abort('disconnected');\n }\n\n async componentWillLoad(): Promise<void> {\n this.newsResponse = await fetchSpecialNewsArticles(\n this.api!,\n 1,\n this.numberOfArticles,\n this.newsListFetchController!.signal,\n this.newsChannelsArr,\n this.newsSellerIdsArr,\n this.newsBrandIdsArr,\n this.newsLanguageLocalesArr,\n );\n }\n\n async componentWillUpdate(): Promise<void> {\n this.newsListFetchController = new AbortController();\n this.newsResponse = await fetchSpecialNewsArticles(\n this.api!,\n 1,\n this.numberOfArticles,\n this.newsListFetchController.signal,\n this.newsChannelsArr,\n this.newsSellerIdsArr,\n this.newsBrandIdsArr,\n this.newsLanguageLocalesArr,\n );\n }\n\n componentDidLoad() {\n $('.carousel').slick({\n autoplay: true,\n autoplaySpeed: 6000,\n dots: true,\n arrows: false,\n pauseOnDotsHover: true,\n });\n }\n\n render() {\n return (\n <div class=\"carousel\">\n {this.newsResponse.data.map(article => {\n const focusX = article.attributes.focusXPercentage ? `${article.attributes.focusXPercentage}%` : 'center';\n const focusY = article.attributes.focusYPercentage ? `${article.attributes.focusYPercentage}%` : 'center';\n const translation = article.attributes.translations.find(t => t.locale === this.locale);\n return (\n <div class=\"carousel-item card border-0\">\n <div class=\"card-body\">\n <h5 class=\"card-title text-center text-uppercase\">\n <a\n class=\"text-reset text-decoration-none\"\n href=\"#\"\n onClick={e => {\n e.preventDefault();\n this.articleClicked?.emit(article);\n }}\n >\n {translation?.name ?? article.attributes.name}\n </a>\n </h5>\n <p class=\"card-text text-center\">{translation?.excerpt ?? article.attributes.excerpt}</p>\n </div>\n <div class=\"ratio ratio-16x9 mx-auto\" style={{ 'max-width': '50%' }}>\n <img\n class=\"card-img-bottom object-fit-cover\"\n style={{ 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }}\n alt=\"News Picture\"\n data-lazy={\n translation?.image ??\n translation?.optimizedListImage ??\n translation?.optimizedImage ??\n article.attributes.image ??\n article.attributes.optimizedListImage ??\n article.attributes.optimizedImage\n }\n />\n </div>\n </div>\n );\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -52,7 +52,7 @@ const AicoTopNewsCarousel$1 = /*@__PURE__*/ proxyCustomElement(class AicoTopNews
|
|
|
52
52
|
}
|
|
53
53
|
render() {
|
|
54
54
|
return (h("div", { class: "carousel" }, this.newsResponse.data.map(article => {
|
|
55
|
-
var _a, _b, _c, _d, _e, _f;
|
|
55
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
56
56
|
const focusX = article.attributes.focusXPercentage ? `${article.attributes.focusXPercentage}%` : 'center';
|
|
57
57
|
const focusY = article.attributes.focusYPercentage ? `${article.attributes.focusYPercentage}%` : 'center';
|
|
58
58
|
const translation = article.attributes.translations.find(t => t.locale === this.locale);
|
|
@@ -60,7 +60,7 @@ const AicoTopNewsCarousel$1 = /*@__PURE__*/ proxyCustomElement(class AicoTopNews
|
|
|
60
60
|
var _a;
|
|
61
61
|
e.preventDefault();
|
|
62
62
|
(_a = this.articleClicked) === null || _a === void 0 ? void 0 : _a.emit(article);
|
|
63
|
-
} }, (_a = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _a !== void 0 ? _a : article.attributes.name))), h("div", { class: "ratio ratio-16x9 mx-auto", style: { 'max-width': '50%' } }, h("img", { class: "card-img-bottom object-fit-cover", style: { 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }, alt: "News Picture", "data-lazy": (_f = (_e = (_d = (_c =
|
|
63
|
+
} }, (_a = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _a !== void 0 ? _a : article.attributes.name)), h("p", { class: "card-text text-center" }, (_b = translation === null || translation === void 0 ? void 0 : translation.excerpt) !== null && _b !== void 0 ? _b : article.attributes.excerpt)), h("div", { class: "ratio ratio-16x9 mx-auto", style: { 'max-width': '50%' } }, h("img", { class: "card-img-bottom object-fit-cover", style: { 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }, alt: "News Picture", "data-lazy": (_g = (_f = (_e = (_d = (_c = translation === null || translation === void 0 ? void 0 : translation.image) !== null && _c !== void 0 ? _c : translation === null || translation === void 0 ? void 0 : translation.optimizedListImage) !== null && _d !== void 0 ? _d : translation === null || translation === void 0 ? void 0 : translation.optimizedImage) !== null && _e !== void 0 ? _e : article.attributes.image) !== null && _f !== void 0 ? _f : article.attributes.optimizedListImage) !== null && _g !== void 0 ? _g : article.attributes.optimizedImage }))));
|
|
64
64
|
})));
|
|
65
65
|
}
|
|
66
66
|
static get style() { return aicoTopNewsCarouselCss; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"aico-top-news-carousel.js","mappings":";;;;AAAA,MAAM,sBAAsB,GAAG,klmUAAklmU;;MCcpmmUA,qBAAmB;;;;;;+BAGO,EAAE;gCAED,EAAE;+BAEH,EAAE;sCAEK,EAAE;;;4BAef,EAAE;6BAKD,EAAE;4BAKH,EAAE;mCAKK,EAAE;gCAKL,CAAC;sBAOX,IAAI;;IAY7B,iBAAiB;QACf,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAe,EAAE,CAAC;QACrD,IAAI,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC;QAExE,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,CAAC,sBAAsB,GAAG,Y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X,WAAW,CAAE,cAAc,mCAC3B,OAAO,CAAC,UAAU,CAAC,KAAK,mCACxB,OAAO,CAAC,UAAU,CAAC,kBAAkB,mCACrC,OAAO,CAAC,UAAU,CAAC,cAAc,GAEnC,CACE,CACF,EACN;SACH,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["AicoTopNewsCarousel","$"],"sources":["src/components/aico-top-news-carousel/aico-top-news-carousel.css?tag=aico-top-news-carousel&encapsulation=scoped","src/components/aico-top-news-carousel/aico-top-news-carousel.tsx"],"sourcesContent":["@import '../../../node_modules/bootstrap/dist/css/bootstrap.css';\n\n:host,\n:host::before,\n:host::after {\n box-sizing: border-box;\n}\n\n:host {\n font-family: var(--bs-body-font-family);\n font-size: var(--bs-body-font-size);\n font-weight: var(--bs-body-font-weight);\n line-height: var(--bs-body-line-height);\n color: var(--bs-body-color);\n text-align: var(--bs-body-text-align);\n -webkit-text-size-adjust: 100%;\n}\n\n.slick-slide > div {\n height: 100% !important;\n}\n","import { Component, Event, EventEmitter, Prop, State, h } from '@stencil/core';\nimport type { NewsResponse } from '../../model/NewsResponse';\nimport type { AicoApiRequestInfo } from '../../model/AicoApiRequestInfo';\nimport type { Article } from '../../model/Article';\nimport { fetchTopNewsArticles, splitByComma } from '../../utils/utils';\n\nimport $ from 'jquery';\nimport 'slick-carousel';\n\n@Component({\n tag: 'aico-top-news-carousel',\n styleUrl: 'aico-top-news-carousel.css',\n scoped: true,\n})\nexport class AicoTopNewsCarousel {\n @State() newsResponse!: NewsResponse;\n\n @State() newsChannelsArr: string[] = [];\n\n @State() newsSellerIdsArr: string[] = [];\n\n @State() newsBrandIdsArr: string[] = [];\n\n @State() newsLanguageLocalesArr: string[] = [];\n\n /**\n * The url of the Aico Api that will be used to retrieve the article.\n */\n @Prop() aicoUrl!: string;\n\n /**\n * The token used to authenticate against he Aico Api.\n */\n @Prop() aicoBearerToken!: string;\n\n /**\n * Channel names as a comma separated list used to filter the results.\n */\n @Prop() newsChannels: string = '';\n\n /**\n * Seller ids as a comma separated list used to filter the results.\n */\n @Prop() newsSellerIds: string = '';\n\n /**\n * Brand ids as a comma separated list used to filter the results.\n */\n @Prop() newsBrandIds: string = '';\n\n /**\n * Language locales as a comma separated list used to filter the results.\n */\n @Prop() newsLanguageLocales: string = '';\n\n /**\n * The number of articles shown in the carousel. Prefer this number to be small.\n */\n @Prop() numberOfArticles: number = 6;\n\n /**\n * The article translation that will be used to render the content.\n *\n * If the locale specified is not present in the article's translations, most content will not be shown.\n */\n @Prop() locale: string = 'de';\n\n /**\n * Event emitted when a user clicks an article title.\n *\n * The handler receives the entire Article entity.\n */\n @Event() articleClicked?: EventEmitter<Article>;\n\n private api?: AicoApiRequestInfo;\n private newsListFetchController?: AbortController;\n\n connectedCallback() {\n this.newsListFetchController = new AbortController();\n this.api = { baseApi: this.aicoUrl, bearerToken: this.aicoBearerToken };\n\n this.newsChannelsArr = splitByComma(this.newsChannels);\n this.newsSellerIdsArr = splitByComma(this.newsSellerIds);\n this.newsBrandIdsArr = splitByComma(this.newsBrandIds);\n this.newsLanguageLocalesArr = splitByComma(this.newsLanguageLocales);\n }\n\n disconnectedCallback() {\n this.newsListFetchController!.abort('disconnected');\n }\n\n async componentWillLoad(): Promise<void> {\n this.newsResponse = await fetchTopNewsArticles(\n this.api!,\n 1,\n this.numberOfArticles,\n this.newsListFetchController!.signal,\n this.newsChannelsArr,\n this.newsSellerIdsArr,\n this.newsBrandIdsArr,\n this.newsLanguageLocalesArr,\n );\n }\n\n async componentWillUpdate(): Promise<void> {\n this.newsListFetchController = new AbortController();\n this.newsResponse = await fetchTopNewsArticles(\n this.api!,\n 1,\n this.numberOfArticles,\n this.newsListFetchController.signal,\n this.newsChannelsArr,\n this.newsSellerIdsArr,\n this.newsBrandIdsArr,\n this.newsLanguageLocalesArr,\n );\n }\n\n componentDidLoad() {\n $('.carousel').slick({\n autoplay: true,\n autoplaySpeed: 6000,\n dots: true,\n arrows: false,\n pauseOnDotsHover: true,\n });\n }\n\n render() {\n return (\n <div class=\"carousel\">\n {this.newsResponse.data.map(article => {\n const focusX = article.attributes.focusXPercentage ? `${article.attributes.focusXPercentage}%` : 'center';\n const focusY = article.attributes.focusYPercentage ? `${article.attributes.focusYPercentage}%` : 'center';\n const translation = article.attributes.translations.find(t => t.locale === this.locale);\n return (\n <div class=\"carousel-item card border-0\">\n <div class=\"card-body\">\n <h5 class=\"card-title text-center text-uppercase\">\n <a\n class=\"text-reset text-decoration-none\"\n href=\"#\"\n onClick={e => {\n e.preventDefault();\n this.articleClicked?.emit(article);\n }}\n >\n {translation?.name ?? article.attributes.name}\n </a>\n </h5>\n <p class=\"card-text text-center\">{translation?.excerpt ?? article.attributes.excerpt}</p>\n </div>\n <div class=\"ratio ratio-16x9 mx-auto\" style={{ 'max-width': '50%' }}>\n <img\n class=\"card-img-bottom object-fit-cover\"\n style={{ 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }}\n alt=\"News Picture\"\n data-lazy={\n translation?.image ??\n translation?.optimizedListImage ??\n translation?.optimizedImage ??\n article.attributes.image ??\n article.attributes.optimizedListImage ??\n article.attributes.optimizedImage\n }\n />\n </div>\n </div>\n );\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
package/dist/components/utils.js
CHANGED
|
@@ -16,7 +16,7 @@ function setArrayFilter(queryParams, key, values) {
|
|
|
16
16
|
queryParams.append(key, value);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
async function fetchNewsArticles(api, page, size, signal, newsChannels = [], newsSellerIds = [], newsBrandIds = [], newsLanguageLocales = []) {
|
|
19
|
+
async function fetchNewsArticles(api, page, size, signal, newsChannels = [], newsSellerIds = [], newsBrandIds = [], newsLanguageLocales = [], hideTopArticles = false, hideSpecialArticles = false) {
|
|
20
20
|
const queryParams = new URLSearchParams();
|
|
21
21
|
queryParams.set('page[number]', String(page));
|
|
22
22
|
queryParams.set('page[size]', String(size));
|
|
@@ -27,6 +27,12 @@ async function fetchNewsArticles(api, page, size, signal, newsChannels = [], new
|
|
|
27
27
|
setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);
|
|
28
28
|
setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);
|
|
29
29
|
setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);
|
|
30
|
+
if (hideTopArticles) {
|
|
31
|
+
queryParams.set('filter[isTopNews]', '0');
|
|
32
|
+
}
|
|
33
|
+
if (hideSpecialArticles) {
|
|
34
|
+
queryParams.set('filter[isSpecialArticle]', '0');
|
|
35
|
+
}
|
|
30
36
|
const request = getAuthenticatedRequest(api, 'news', queryParams, signal);
|
|
31
37
|
const response = await fetch(request);
|
|
32
38
|
return await response.json();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"utils.js","mappings":"AAKO,MAAM,uBAAuB,GAAG,CAAC,WAAmB;IACzD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEK,MAAM,uBAAuB,GAAG,CAAC,GAAuB,EAAE,KAAa,EAAE,KAAsB,EAAE,MAAoB;IAC1H,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE;QACvE,OAAO,EAAE,uBAAuB,CAAC,GAAG,CAAC,WAAW,CAAC;QACjD,MAAM;KACP,CAAC,CAAC;AACL,CAAC;;ACbD,SAAS,cAAc,CAAC,WAA4B,EAAE,GAAW,EAAE,MAAgB;IACjF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,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AAQ,CAAC,UAAsC;IAC7D,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC5C,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACtB;KACF;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;SAEe,YAAY,CAAC,GAAmB;IAC9C,IAAI,4BAA4B,CAAC,GAAG,CAAC,EAAE;QACrC,OAAO,EAAE,CAAC;KACX;IAED,GAAG,GAAG,GAAI,CAAC;IACX,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1D;;;;","names":[],"sources":["src/model/AicoApiRequestInfo.ts","src/utils/utils.ts"],"sourcesContent":["export type AicoApiRequestInfo = {\n baseApi: string;\n bearerToken: string;\n};\n\nexport const getAuthenticatedHeaders = (bearerToken: string): Headers => {\n const headers = new Headers();\n headers.append('Accept', 'application/vnd.api+json');\n headers.append('Authorization', `Bearer ${bearerToken}`);\n return headers;\n};\n\nexport const getAuthenticatedRequest = (api: AicoApiRequestInfo, route: string, query: URLSearchParams, signal?: AbortSignal): Request => {\n return new Request(new URL(`${route}?${query.toString()}`, api.baseApi), {\n headers: getAuthenticatedHeaders(api.bearerToken),\n signal,\n });\n};\n","import { Article } from '../components';\nimport { AicoApiRequestInfo, getAuthenticatedHeaders, getAuthenticatedRequest } from '../model/AicoApiRequestInfo';\nimport { NewsResponse } from '../model/NewsResponse';\n\nfunction setArrayFilter(queryParams: URLSearchParams, key: string, values: string[]) {\n for (const value of values) {\n queryParams.append(key, value);\n }\n}\n\nexport async function fetchNewsArticles(\n api: AicoApiRequestInfo,\n page: number,\n size: number,\n signal: AbortSignal,\n newsChannels: string[] = [],\n newsSellerIds: string[] = [],\n newsBrandIds: string[] = [],\n newsLanguageLocales: string[] = [],\n): Promise<NewsResponse> {\n const queryParams = new URLSearchParams();\n queryParams.set('page[number]', String(page));\n queryParams.set('page[size]', String(size));\n queryParams.set('sort', '-publishDate');\n queryParams.set('filter[isActive]', '1');\n queryParams.set('filter[excludeTag][]', 'Eisnull');\n setArrayFilter(queryParams, 'filter[channel][]', newsChannels);\n setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);\n setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);\n setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n return await response.json();\n}\n\nexport async function fetchSpecialNewsArticles(\n api: AicoApiRequestInfo,\n page: number,\n size: number,\n signal: AbortSignal,\n newsChannels: string[] = [],\n newsSellerIds: string[] = [],\n newsBrandIds: string[] = [],\n newsLanguageLocales: string[] = [],\n): Promise<NewsResponse> {\n const queryParams = new URLSearchParams();\n queryParams.set('page[number]', String(page));\n queryParams.set('page[size]', String(size));\n queryParams.set('sort', '-publishDate');\n queryParams.set('filter[isActive]', '1');\n queryParams.set('filter[isSpecialArticle]', '1');\n queryParams.set('filter[isLightVersion]', 'true');\n queryParams.set('filter[excludeTag][]', 'Eisnull');\n setArrayFilter(queryParams, 'filter[channel][]', newsChannels);\n setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);\n setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);\n setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n return await response.json();\n}\n\nexport async function fetchTopNewsArticles(\n api: AicoApiRequestInfo,\n page: number,\n size: number,\n signal: AbortSignal,\n newsChannels: string[] = [],\n newsSellerIds: string[] = [],\n newsBrandIds: string[] = [],\n newsLanguageLocales: string[] = [],\n): Promise<NewsResponse> {\n const queryParams = new URLSearchParams();\n queryParams.set('page[number]', String(page));\n queryParams.set('page[size]', String(size));\n queryParams.set('sort', '-publishDate');\n queryParams.set('filter[isActive]', '1');\n queryParams.set('filter[isTopNews]', '1');\n queryParams.set('filter[isLightVersion]', 'true');\n queryParams.set('filter[excludeTag][]', 'Eisnull');\n setArrayFilter(queryParams, 'filter[channel][]', newsChannels);\n setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);\n setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);\n setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n return await response.json();\n}\n\nexport async function fetchNewsArticle(api: AicoApiRequestInfo, articleId: string, signal: AbortSignal): Promise<Article> {\n const request = getAuthenticatedRequest(api, `news/${articleId}`, new URLSearchParams(), signal);\n const response = await fetch(request);\n const article = await response.json();\n return article.data;\n}\n\nexport async function fetchNewsArticleByHandle(api: AicoApiRequestInfo, urlHandle: string, signal: AbortSignal): Promise<Article | undefined> {\n const queryParams = new URLSearchParams();\n queryParams.set('filter[urlHandle]', urlHandle);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n const articles = await response.json();\n return articles.data.length === 1 ? articles.data[0] : undefined;\n}\n\nexport async function fetchArticle(url: string, bearerToken: string, signal: AbortSignal): Promise<Article> {\n const request = new Request(new URL(url), {\n headers: getAuthenticatedHeaders(bearerToken),\n signal,\n });\n const response = await fetch(request);\n return await response.json();\n}\n\nexport function getImageWidthPrc(pictureSize?: string): string {\n switch (pictureSize) {\n case 'extra-small':\n return '28%';\n case 'small':\n return '40%';\n case 'large':\n return '80%';\n case 'extra large': // TODO: has - or not?\n return '100%';\n default:\n return '60%';\n }\n}\n\nexport function getYoutubeURL(url: string): string | null {\n const regExp = /.*(?:youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=)([^#&?]*).*/;\n const match = url.match(regExp);\n if (match && match[1].length == 11) {\n return `https://www.youtube.com/embed/${match[1]}`;\n }\n\n return null;\n}\n\nexport function strIsNullOrEmptyOrWhitespace(str?: string | null): boolean {\n if (!str || str === ' ') {\n return true;\n }\n\n return false;\n}\n\nexport function getClass(conditions: { [key: string]: boolean }): string {\n const classes: string[] = [];\n for (const kvp of Object.entries(conditions)) {\n if (kvp[1]) {\n classes.push(kvp[0]);\n }\n }\n\n return classes.join(' ');\n}\n\nexport function splitByComma(str?: string | null): string[] {\n if (strIsNullOrEmptyOrWhitespace(str)) {\n return [];\n }\n\n str = str!;\n return str.indexOf(',') === -1 ? [str] : str.split(',');\n}\n"],"version":3}
|
|
1
|
+
{"file":"utils.js","mappings":"AAKO,MAAM,uBAAuB,GAAG,CAAC,WAAmB;IACzD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEK,MAAM,uBAAuB,GAAG,CAAC,GAAuB,EAAE,KAAa,EAAE,KAAsB,EAAE,MAAoB;IAC1H,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE;QACvE,OAAO,EAAE,uBAAuB,CAAC,GAAG,CAAC,WAAW,CAAC;QACjD,MAAM;KACP,CAAC,CAAC;AACL,CAAC;;ACbD,SAAS,cAAc,CAAC,WAA4B,EAAE,GAAW,EAAE,MAAgB;IACjF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KAChC;AACH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C,EAAE,CAAC;KACpD;IAED,OAAO,IAAI,CAAC;AACd,CAAC;SAEe,4BAA4B,CAAC,GAAmB;IAC9D,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,GAAG,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;SAEe,QAAQ,CAAC,UAAsC;IAC7D,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC5C,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACtB;KACF;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;SAEe,YAAY,CAAC,GAAmB;IAC9C,IAAI,4BAA4B,CAAC,GAAG,CAAC,EAAE;QACrC,OAAO,EAAE,CAAC;KACX;IAED,GAAG,GAAG,GAAI,CAAC;IACX,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1D;;;;","names":[],"sources":["src/model/AicoApiRequestInfo.ts","src/utils/utils.ts"],"sourcesContent":["export type AicoApiRequestInfo = {\n baseApi: string;\n bearerToken: string;\n};\n\nexport const getAuthenticatedHeaders = (bearerToken: string): Headers => {\n const headers = new Headers();\n headers.append('Accept', 'application/vnd.api+json');\n headers.append('Authorization', `Bearer ${bearerToken}`);\n return headers;\n};\n\nexport const getAuthenticatedRequest = (api: AicoApiRequestInfo, route: string, query: URLSearchParams, signal?: AbortSignal): Request => {\n return new Request(new URL(`${route}?${query.toString()}`, api.baseApi), {\n headers: getAuthenticatedHeaders(api.bearerToken),\n signal,\n });\n};\n","import { Article } from '../components';\nimport { AicoApiRequestInfo, getAuthenticatedHeaders, getAuthenticatedRequest } from '../model/AicoApiRequestInfo';\nimport { NewsResponse } from '../model/NewsResponse';\n\nfunction setArrayFilter(queryParams: URLSearchParams, key: string, values: string[]) {\n for (const value of values) {\n queryParams.append(key, value);\n }\n}\n\nexport async function fetchNewsArticles(\n api: AicoApiRequestInfo,\n page: number,\n size: number,\n signal: AbortSignal,\n newsChannels: string[] = [],\n newsSellerIds: string[] = [],\n newsBrandIds: string[] = [],\n newsLanguageLocales: string[] = [],\n hideTopArticles: boolean = false,\n hideSpecialArticles: boolean = false,\n): Promise<NewsResponse> {\n const queryParams = new URLSearchParams();\n queryParams.set('page[number]', String(page));\n queryParams.set('page[size]', String(size));\n queryParams.set('sort', '-publishDate');\n queryParams.set('filter[isActive]', '1');\n queryParams.set('filter[excludeTag][]', 'Eisnull');\n setArrayFilter(queryParams, 'filter[channel][]', newsChannels);\n setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);\n setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);\n setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);\n if (hideTopArticles) {\n queryParams.set('filter[isTopNews]', '0');\n }\n\n if (hideSpecialArticles) {\n queryParams.set('filter[isSpecialArticle]', '0');\n }\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n return await response.json();\n}\n\nexport async function fetchSpecialNewsArticles(\n api: AicoApiRequestInfo,\n page: number,\n size: number,\n signal: AbortSignal,\n newsChannels: string[] = [],\n newsSellerIds: string[] = [],\n newsBrandIds: string[] = [],\n newsLanguageLocales: string[] = [],\n): Promise<NewsResponse> {\n const queryParams = new URLSearchParams();\n queryParams.set('page[number]', String(page));\n queryParams.set('page[size]', String(size));\n queryParams.set('sort', '-publishDate');\n queryParams.set('filter[isActive]', '1');\n queryParams.set('filter[isSpecialArticle]', '1');\n queryParams.set('filter[isLightVersion]', 'true');\n queryParams.set('filter[excludeTag][]', 'Eisnull');\n setArrayFilter(queryParams, 'filter[channel][]', newsChannels);\n setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);\n setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);\n setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n return await response.json();\n}\n\nexport async function fetchTopNewsArticles(\n api: AicoApiRequestInfo,\n page: number,\n size: number,\n signal: AbortSignal,\n newsChannels: string[] = [],\n newsSellerIds: string[] = [],\n newsBrandIds: string[] = [],\n newsLanguageLocales: string[] = [],\n): Promise<NewsResponse> {\n const queryParams = new URLSearchParams();\n queryParams.set('page[number]', String(page));\n queryParams.set('page[size]', String(size));\n queryParams.set('sort', '-publishDate');\n queryParams.set('filter[isActive]', '1');\n queryParams.set('filter[isTopNews]', '1');\n queryParams.set('filter[isLightVersion]', 'true');\n queryParams.set('filter[excludeTag][]', 'Eisnull');\n setArrayFilter(queryParams, 'filter[channel][]', newsChannels);\n setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);\n setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);\n setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n return await response.json();\n}\n\nexport async function fetchNewsArticle(api: AicoApiRequestInfo, articleId: string, signal: AbortSignal): Promise<Article> {\n const request = getAuthenticatedRequest(api, `news/${articleId}`, new URLSearchParams(), signal);\n const response = await fetch(request);\n const article = await response.json();\n return article.data;\n}\n\nexport async function fetchNewsArticleByHandle(api: AicoApiRequestInfo, urlHandle: string, signal: AbortSignal): Promise<Article | undefined> {\n const queryParams = new URLSearchParams();\n queryParams.set('filter[urlHandle]', urlHandle);\n\n const request = getAuthenticatedRequest(api, 'news', queryParams, signal);\n const response = await fetch(request);\n const articles = await response.json();\n return articles.data.length === 1 ? articles.data[0] : undefined;\n}\n\nexport async function fetchArticle(url: string, bearerToken: string, signal: AbortSignal): Promise<Article> {\n const request = new Request(new URL(url), {\n headers: getAuthenticatedHeaders(bearerToken),\n signal,\n });\n const response = await fetch(request);\n return await response.json();\n}\n\nexport function getImageWidthPrc(pictureSize?: string): string {\n switch (pictureSize) {\n case 'extra-small':\n return '28%';\n case 'small':\n return '40%';\n case 'large':\n return '80%';\n case 'extra large': // TODO: has - or not?\n return '100%';\n default:\n return '60%';\n }\n}\n\nexport function getYoutubeURL(url: string): string | null {\n const regExp = /.*(?:youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=)([^#&?]*).*/;\n const match = url.match(regExp);\n if (match && match[1].length == 11) {\n return `https://www.youtube.com/embed/${match[1]}`;\n }\n\n return null;\n}\n\nexport function strIsNullOrEmptyOrWhitespace(str?: string | null): boolean {\n if (!str || str === ' ') {\n return true;\n }\n\n return false;\n}\n\nexport function getClass(conditions: { [key: string]: boolean }): string {\n const classes: string[] = [];\n for (const kvp of Object.entries(conditions)) {\n if (kvp[1]) {\n classes.push(kvp[0]);\n }\n }\n\n return classes.join(' ');\n}\n\nexport function splitByComma(str?: string | null): string[] {\n if (strIsNullOrEmptyOrWhitespace(str)) {\n return [];\n }\n\n str = str!;\n return str.indexOf(',') === -1 ? [str] : str.split(',');\n}\n"],"version":3}
|
|
@@ -13780,7 +13780,7 @@ function setArrayFilter(queryParams, key, values) {
|
|
|
13780
13780
|
queryParams.append(key, value);
|
|
13781
13781
|
}
|
|
13782
13782
|
}
|
|
13783
|
-
async function fetchNewsArticles(api, page, size, signal, newsChannels = [], newsSellerIds = [], newsBrandIds = [], newsLanguageLocales = []) {
|
|
13783
|
+
async function fetchNewsArticles(api, page, size, signal, newsChannels = [], newsSellerIds = [], newsBrandIds = [], newsLanguageLocales = [], hideTopArticles = false, hideSpecialArticles = false) {
|
|
13784
13784
|
const queryParams = new URLSearchParams();
|
|
13785
13785
|
queryParams.set('page[number]', String(page));
|
|
13786
13786
|
queryParams.set('page[size]', String(size));
|
|
@@ -13791,6 +13791,12 @@ async function fetchNewsArticles(api, page, size, signal, newsChannels = [], new
|
|
|
13791
13791
|
setArrayFilter(queryParams, 'filter[sellerIds][]', newsSellerIds);
|
|
13792
13792
|
setArrayFilter(queryParams, 'filter[brandId][]', newsBrandIds);
|
|
13793
13793
|
setArrayFilter(queryParams, 'filter[newsLanguage][]', newsLanguageLocales);
|
|
13794
|
+
if (hideTopArticles) {
|
|
13795
|
+
queryParams.set('filter[isTopNews]', '0');
|
|
13796
|
+
}
|
|
13797
|
+
if (hideSpecialArticles) {
|
|
13798
|
+
queryParams.set('filter[isSpecialArticle]', '0');
|
|
13799
|
+
}
|
|
13794
13800
|
const request = getAuthenticatedRequest(api, 'news', queryParams, signal);
|
|
13795
13801
|
const response = await fetch(request);
|
|
13796
13802
|
return await response.json();
|
|
@@ -20643,6 +20649,8 @@ const AicoNewsList = class {
|
|
|
20643
20649
|
this.newsSellerIds = '';
|
|
20644
20650
|
this.newsBrandIds = '';
|
|
20645
20651
|
this.newsLanguageLocales = '';
|
|
20652
|
+
this.hideTopArticles = true;
|
|
20653
|
+
this.hideSpecialArticles = false;
|
|
20646
20654
|
this.pageSize = 16;
|
|
20647
20655
|
this.nextButtonText = 'Next';
|
|
20648
20656
|
this.previousButtonText = 'Previous';
|
|
@@ -20661,11 +20669,11 @@ const AicoNewsList = class {
|
|
|
20661
20669
|
this.newsListFetchController.abort('disconnected');
|
|
20662
20670
|
}
|
|
20663
20671
|
async componentWillLoad() {
|
|
20664
|
-
this.newsResponse = await fetchNewsArticles(this.api, this.pageNumber, this.pageSize, this.newsListFetchController.signal, this.newsChannelsArr, this.newsSellerIdsArr, this.newsBrandIdsArr, this.newsLanguageLocalesArr);
|
|
20672
|
+
this.newsResponse = await fetchNewsArticles(this.api, this.pageNumber, this.pageSize, this.newsListFetchController.signal, this.newsChannelsArr, this.newsSellerIdsArr, this.newsBrandIdsArr, this.newsLanguageLocalesArr, this.hideTopArticles, this.hideSpecialArticles);
|
|
20665
20673
|
}
|
|
20666
20674
|
async componentWillUpdate() {
|
|
20667
20675
|
this.newsListFetchController = new AbortController();
|
|
20668
|
-
this.newsResponse = await fetchNewsArticles(this.api, this.pageNumber, this.pageSize, this.newsListFetchController.signal, this.newsChannelsArr, this.newsSellerIdsArr, this.newsBrandIdsArr, this.newsLanguageLocalesArr);
|
|
20676
|
+
this.newsResponse = await fetchNewsArticles(this.api, this.pageNumber, this.pageSize, this.newsListFetchController.signal, this.newsChannelsArr, this.newsSellerIdsArr, this.newsBrandIdsArr, this.newsLanguageLocalesArr, this.hideTopArticles, this.hideSpecialArticles);
|
|
20669
20677
|
}
|
|
20670
20678
|
render() {
|
|
20671
20679
|
var _a, _b, _c;
|
|
@@ -20826,7 +20834,7 @@ const AicoSpecialNewsCarousel = class {
|
|
|
20826
20834
|
}
|
|
20827
20835
|
render() {
|
|
20828
20836
|
return (h("div", { class: "carousel" }, this.newsResponse.data.map(article => {
|
|
20829
|
-
var _a, _b, _c, _d, _e, _f;
|
|
20837
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
20830
20838
|
const focusX = article.attributes.focusXPercentage ? `${article.attributes.focusXPercentage}%` : 'center';
|
|
20831
20839
|
const focusY = article.attributes.focusYPercentage ? `${article.attributes.focusYPercentage}%` : 'center';
|
|
20832
20840
|
const translation = article.attributes.translations.find(t => t.locale === this.locale);
|
|
@@ -20834,7 +20842,7 @@ const AicoSpecialNewsCarousel = class {
|
|
|
20834
20842
|
var _a;
|
|
20835
20843
|
e.preventDefault();
|
|
20836
20844
|
(_a = this.articleClicked) === null || _a === void 0 ? void 0 : _a.emit(article);
|
|
20837
|
-
} }, (_a = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _a !== void 0 ? _a : article.attributes.name))), h("div", { class: "ratio ratio-16x9 mx-auto", style: { 'max-width': '50%' } }, h("img", { class: "card-img-bottom object-fit-cover", style: { 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }, alt: "News Picture", "data-lazy": (_f = (_e = (_d = (_c =
|
|
20845
|
+
} }, (_a = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _a !== void 0 ? _a : article.attributes.name)), h("p", { class: "card-text text-center" }, (_b = translation === null || translation === void 0 ? void 0 : translation.excerpt) !== null && _b !== void 0 ? _b : article.attributes.excerpt)), h("div", { class: "ratio ratio-16x9 mx-auto", style: { 'max-width': '50%' } }, h("img", { class: "card-img-bottom object-fit-cover", style: { 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }, alt: "News Picture", "data-lazy": (_g = (_f = (_e = (_d = (_c = translation === null || translation === void 0 ? void 0 : translation.image) !== null && _c !== void 0 ? _c : translation === null || translation === void 0 ? void 0 : translation.optimizedListImage) !== null && _d !== void 0 ? _d : translation === null || translation === void 0 ? void 0 : translation.optimizedImage) !== null && _e !== void 0 ? _e : article.attributes.image) !== null && _f !== void 0 ? _f : article.attributes.optimizedListImage) !== null && _g !== void 0 ? _g : article.attributes.optimizedImage }))));
|
|
20838
20846
|
})));
|
|
20839
20847
|
}
|
|
20840
20848
|
};
|
|
@@ -21060,7 +21068,7 @@ const AicoTopNewsCarousel = class {
|
|
|
21060
21068
|
}
|
|
21061
21069
|
render() {
|
|
21062
21070
|
return (h("div", { class: "carousel" }, this.newsResponse.data.map(article => {
|
|
21063
|
-
var _a, _b, _c, _d, _e, _f;
|
|
21071
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
21064
21072
|
const focusX = article.attributes.focusXPercentage ? `${article.attributes.focusXPercentage}%` : 'center';
|
|
21065
21073
|
const focusY = article.attributes.focusYPercentage ? `${article.attributes.focusYPercentage}%` : 'center';
|
|
21066
21074
|
const translation = article.attributes.translations.find(t => t.locale === this.locale);
|
|
@@ -21068,7 +21076,7 @@ const AicoTopNewsCarousel = class {
|
|
|
21068
21076
|
var _a;
|
|
21069
21077
|
e.preventDefault();
|
|
21070
21078
|
(_a = this.articleClicked) === null || _a === void 0 ? void 0 : _a.emit(article);
|
|
21071
|
-
} }, (_a = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _a !== void 0 ? _a : article.attributes.name))), h("div", { class: "ratio ratio-16x9 mx-auto", style: { 'max-width': '50%' } }, h("img", { class: "card-img-bottom object-fit-cover", style: { 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }, alt: "News Picture", "data-lazy": (_f = (_e = (_d = (_c =
|
|
21079
|
+
} }, (_a = translation === null || translation === void 0 ? void 0 : translation.name) !== null && _a !== void 0 ? _a : article.attributes.name)), h("p", { class: "card-text text-center" }, (_b = translation === null || translation === void 0 ? void 0 : translation.excerpt) !== null && _b !== void 0 ? _b : article.attributes.excerpt)), h("div", { class: "ratio ratio-16x9 mx-auto", style: { 'max-width': '50%' } }, h("img", { class: "card-img-bottom object-fit-cover", style: { 'object-position': `${focusX} ${focusY}`, 'min-height': '15rem' }, alt: "News Picture", "data-lazy": (_g = (_f = (_e = (_d = (_c = translation === null || translation === void 0 ? void 0 : translation.image) !== null && _c !== void 0 ? _c : translation === null || translation === void 0 ? void 0 : translation.optimizedListImage) !== null && _d !== void 0 ? _d : translation === null || translation === void 0 ? void 0 : translation.optimizedImage) !== null && _e !== void 0 ? _e : article.attributes.image) !== null && _f !== void 0 ? _f : article.attributes.optimizedListImage) !== null && _g !== void 0 ? _g : article.attributes.optimizedImage }))));
|
|
21072
21080
|
})));
|
|
21073
21081
|
}
|
|
21074
21082
|
};
|