@wayke-se/components-react 3.3.2 → 3.4.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-node/index.js +63 -16
- package/dist-node/index.js.map +1 -1
- package/dist-src/components/DocumentList/index.js +23 -0
- package/dist-src/components/{Pdf → DocumentList}/wrapper.js +1 -1
- package/dist-src/components/Heading/index.js +3 -5
- package/dist-src/layouts/searchItem/Documents.js +44 -0
- package/dist-src/layouts/searchItem/index.js +2 -9
- package/dist-types/@types/codegen/types.d.ts +2 -0
- package/dist-types/components/{Pdf → DocumentList}/index.d.ts +3 -3
- package/dist-types/components/{Pdf → DocumentList}/wrapper.d.ts +1 -1
- package/dist-types/components/Heading/index.d.ts +5 -0
- package/dist-types/layouts/searchItem/Documents.d.ts +7 -0
- package/dist-web/index.js +64 -22
- package/dist-web/index.js.map +1 -1
- package/package.json +1 -1
- package/dist-src/components/Pdf/index.js +0 -11
package/dist-node/index.js
CHANGED
|
@@ -993,13 +993,11 @@ const H2 = styled__default(HeadingBase).attrs(props => ({
|
|
|
993
993
|
}))`
|
|
994
994
|
font-size: 1.5rem;
|
|
995
995
|
`;
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
as: props.as || 'h3',
|
|
996
|
+
const H3 = styled__default(HeadingBase).attrs(props => ({
|
|
997
|
+
as: props.as || 'h3'
|
|
999
998
|
}))`
|
|
1000
999
|
font-size: 1.125rem;
|
|
1001
1000
|
`;
|
|
1002
|
-
*/
|
|
1003
1001
|
const H4 = styled__default(HeadingBase).attrs(props => ({
|
|
1004
1002
|
as: props.as || 'h4'
|
|
1005
1003
|
}))`
|
|
@@ -8069,7 +8067,7 @@ const PdfListItem = styled__default.li.attrs(() => ({
|
|
|
8069
8067
|
flex: 0 0 100%;
|
|
8070
8068
|
}
|
|
8071
8069
|
`;
|
|
8072
|
-
const
|
|
8070
|
+
const List$a = styled__default.ul`
|
|
8073
8071
|
list-style: none;
|
|
8074
8072
|
padding: 0;
|
|
8075
8073
|
display: flex;
|
|
@@ -8113,20 +8111,71 @@ const PdfListInner = styled__default.div`
|
|
|
8113
8111
|
}
|
|
8114
8112
|
`;
|
|
8115
8113
|
|
|
8114
|
+
const translateContentType = document => {
|
|
8115
|
+
switch (document.contentType) {
|
|
8116
|
+
case 'application/pdf':
|
|
8117
|
+
return 'PDF';
|
|
8118
|
+
default:
|
|
8119
|
+
const formattedContentType = document.url && document.url.includes('.') ? document.url.split('.').pop() : '';
|
|
8120
|
+
return formattedContentType;
|
|
8121
|
+
}
|
|
8122
|
+
};
|
|
8116
8123
|
const PdfDownloadItem = ({
|
|
8117
8124
|
document
|
|
8118
|
-
}) =>
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8125
|
+
}) => {
|
|
8126
|
+
const contentType = React.useMemo(() => translateContentType(document), [document]);
|
|
8127
|
+
return React__default.createElement(PdfListItem, null, React__default.createElement(PdfListInner, null, React__default.createElement(PdfColumn, null, React__default.createElement(PdfTitle, null, document.name), React__default.createElement(PdfSubtitle, null, contentType)), React__default.createElement(PdfColumn, null, React__default.createElement(PdfLink, {
|
|
8128
|
+
href: document.url,
|
|
8129
|
+
rel: "noopener noreferrer nofollow",
|
|
8130
|
+
target: "_blank"
|
|
8131
|
+
}, "\u00D6ppna"))));
|
|
8132
|
+
};
|
|
8133
|
+
const DocumentList = ({
|
|
8124
8134
|
documents
|
|
8125
|
-
}) => React__default.createElement(
|
|
8135
|
+
}) => React__default.createElement(List$a, null, documents.map((document, i) => React__default.createElement(PdfDownloadItem, {
|
|
8126
8136
|
key: `${document.url}-${i}`,
|
|
8127
8137
|
document: document
|
|
8128
8138
|
})));
|
|
8129
8139
|
|
|
8140
|
+
const Translation = {
|
|
8141
|
+
'tyre-label': 'Energideklaration för däck',
|
|
8142
|
+
'content declaration': 'Varudeklaration',
|
|
8143
|
+
other: 'Övriga dokument'
|
|
8144
|
+
};
|
|
8145
|
+
const SortOrder = {
|
|
8146
|
+
'tyre-label': 2,
|
|
8147
|
+
'content declaration': 1,
|
|
8148
|
+
other: 3
|
|
8149
|
+
};
|
|
8150
|
+
const Documents = ({
|
|
8151
|
+
documents
|
|
8152
|
+
}) => {
|
|
8153
|
+
const categorised = documents.reduce((prev, curr) => {
|
|
8154
|
+
const index = prev.findIndex(x => x.category === (curr.category || 'others'));
|
|
8155
|
+
if (index > -1) {
|
|
8156
|
+
prev[index].documents.push(curr);
|
|
8157
|
+
} else {
|
|
8158
|
+
var _SortOrder$category;
|
|
8159
|
+
const category = curr.category || 'others';
|
|
8160
|
+
prev.push({
|
|
8161
|
+
category,
|
|
8162
|
+
documents: [curr],
|
|
8163
|
+
sortOrder: (_SortOrder$category = SortOrder === null || SortOrder === void 0 ? void 0 : SortOrder[category]) !== null && _SortOrder$category !== void 0 ? _SortOrder$category : 99
|
|
8164
|
+
});
|
|
8165
|
+
}
|
|
8166
|
+
return prev;
|
|
8167
|
+
}, []).sort((a, b) => a.sortOrder - b.sortOrder);
|
|
8168
|
+
if (!documents.length) return null;
|
|
8169
|
+
const manyCategories = categorised.length > 1;
|
|
8170
|
+
return React__default.createElement(ProductPageMainSection, null, React__default.createElement(Repeat, null, React__default.createElement(H2, {
|
|
8171
|
+
noMargin: true
|
|
8172
|
+
}, "Dokument")), categorised.map(group => React__default.createElement(Repeat, {
|
|
8173
|
+
key: group.category
|
|
8174
|
+
}, manyCategories && React__default.createElement(H3, null, (Translation === null || Translation === void 0 ? void 0 : Translation[group.category]) || Translation.other), React__default.createElement(DocumentList, {
|
|
8175
|
+
documents: group.documents
|
|
8176
|
+
}))));
|
|
8177
|
+
};
|
|
8178
|
+
|
|
8130
8179
|
const WaykeSearchItem = ({
|
|
8131
8180
|
id,
|
|
8132
8181
|
hashRoute,
|
|
@@ -8322,11 +8371,9 @@ const WaykeSearchItem = ({
|
|
|
8322
8371
|
onClick: onShowMoreOptionsClick
|
|
8323
8372
|
}, React__default.createElement(UspList, {
|
|
8324
8373
|
items: options
|
|
8325
|
-
})))),
|
|
8326
|
-
noMargin: true
|
|
8327
|
-
}, "Dokument")), React__default.createElement(Repeat, null, React__default.createElement(Content$2, null, React__default.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))), React__default.createElement(Repeat, null, React__default.createElement(PdfDownloadContainer, {
|
|
8374
|
+
})))), React__default.createElement(Documents, {
|
|
8328
8375
|
documents: documents
|
|
8329
|
-
})
|
|
8376
|
+
}), React__default.createElement(ProductPageMainSection, null, React__default.createElement(Branch, {
|
|
8330
8377
|
branch: branch,
|
|
8331
8378
|
loading: loadingCentralStorageVehicle
|
|
8332
8379
|
}), ecommerce && ecommerce.enabled && React__default.createElement(Repeat, null, React__default.createElement(ButtonPrimary, {
|