@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { PdfListItem, PdfSubtitle, PdfTitle, List, PdfListInner, PdfLink, PdfColumn, } from './wrapper';
|
|
3
|
+
const translateContentType = (document) => {
|
|
4
|
+
switch (document.contentType) {
|
|
5
|
+
case 'application/pdf':
|
|
6
|
+
return 'PDF';
|
|
7
|
+
default:
|
|
8
|
+
const formattedContentType = document.url && document.url.includes('.') ? document.url.split('.').pop() : '';
|
|
9
|
+
return formattedContentType;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const PdfDownloadItem = ({ document }) => {
|
|
13
|
+
const contentType = useMemo(() => translateContentType(document), [document]);
|
|
14
|
+
return (React.createElement(PdfListItem, null,
|
|
15
|
+
React.createElement(PdfListInner, null,
|
|
16
|
+
React.createElement(PdfColumn, null,
|
|
17
|
+
React.createElement(PdfTitle, null, document.name),
|
|
18
|
+
React.createElement(PdfSubtitle, null, contentType)),
|
|
19
|
+
React.createElement(PdfColumn, null,
|
|
20
|
+
React.createElement(PdfLink, { href: document.url, rel: "noopener noreferrer nofollow", target: "_blank" }, "\u00D6ppna")))));
|
|
21
|
+
};
|
|
22
|
+
export const DocumentList = ({ documents }) => (React.createElement(List, null, documents.map((document, i) => (React.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
|
|
23
|
+
export default DocumentList;
|
|
@@ -23,13 +23,11 @@ export const H2 = styled(HeadingBase).attrs((props) => ({
|
|
|
23
23
|
})) `
|
|
24
24
|
font-size: 1.5rem;
|
|
25
25
|
`;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}))`
|
|
26
|
+
export const H3 = styled(HeadingBase).attrs((props) => ({
|
|
27
|
+
as: props.as || 'h3',
|
|
28
|
+
})) `
|
|
30
29
|
font-size: 1.125rem;
|
|
31
30
|
`;
|
|
32
|
-
*/
|
|
33
31
|
export const H4 = styled(HeadingBase).attrs((props) => ({
|
|
34
32
|
as: props.as || 'h4',
|
|
35
33
|
})) `
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { H2, H3 } from '../../components/Heading/index';
|
|
3
|
+
import { ProductPageMainSection } from '../../components/ProductPage/index';
|
|
4
|
+
import DocumentList from '../../components/DocumentList/index';
|
|
5
|
+
import { Repeat } from '../../components/Repeat/index';
|
|
6
|
+
const Translation = {
|
|
7
|
+
'tyre-label': 'Energideklaration för däck',
|
|
8
|
+
'content declaration': 'Varudeklaration',
|
|
9
|
+
other: 'Övriga dokument',
|
|
10
|
+
};
|
|
11
|
+
const SortOrder = {
|
|
12
|
+
'tyre-label': 2,
|
|
13
|
+
'content declaration': 1,
|
|
14
|
+
other: 3,
|
|
15
|
+
};
|
|
16
|
+
const Documents = ({ documents }) => {
|
|
17
|
+
const categorised = documents
|
|
18
|
+
.reduce((prev, curr) => {
|
|
19
|
+
const index = prev.findIndex((x) => x.category === (curr.category || 'others'));
|
|
20
|
+
if (index > -1) {
|
|
21
|
+
prev[index].documents.push(curr);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const category = curr.category || 'others';
|
|
25
|
+
prev.push({
|
|
26
|
+
category,
|
|
27
|
+
documents: [curr],
|
|
28
|
+
sortOrder: SortOrder?.[category] ?? 99,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return prev;
|
|
32
|
+
}, [])
|
|
33
|
+
.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
34
|
+
if (!documents.length)
|
|
35
|
+
return null;
|
|
36
|
+
const manyCategories = categorised.length > 1;
|
|
37
|
+
return (React.createElement(ProductPageMainSection, null,
|
|
38
|
+
React.createElement(Repeat, null,
|
|
39
|
+
React.createElement(H2, { noMargin: true }, "Dokument")),
|
|
40
|
+
categorised.map((group) => (React.createElement(Repeat, { key: group.category },
|
|
41
|
+
manyCategories && (React.createElement(H3, null, Translation?.[group.category] || Translation.other)),
|
|
42
|
+
React.createElement(DocumentList, { documents: group.documents }))))));
|
|
43
|
+
};
|
|
44
|
+
export default Documents;
|
|
@@ -32,8 +32,8 @@ import PageLoading from './PageLoading';
|
|
|
32
32
|
import PubSub from '../../utils/pubsub/pubsub';
|
|
33
33
|
import Property from './Property';
|
|
34
34
|
import DemoCarModal from './DemoCarModal';
|
|
35
|
-
import PdfDownloadContainer from '../../components/Pdf/index';
|
|
36
35
|
import useSettings from '../../State/Settings/useSettings';
|
|
36
|
+
import Documents from './Documents';
|
|
37
37
|
const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
|
|
38
38
|
const { ecomSettings } = useSettings();
|
|
39
39
|
const ecomContext = useRef();
|
|
@@ -165,14 +165,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
165
165
|
React.createElement(Repeat, null,
|
|
166
166
|
React.createElement(ExtendContent, { actionTitle: "Visa mer", onClick: onShowMoreOptionsClick },
|
|
167
167
|
React.createElement(UspList, { items: options }))))),
|
|
168
|
-
|
|
169
|
-
React.createElement(Repeat, null,
|
|
170
|
-
React.createElement(H2, { noMargin: true }, "Dokument")),
|
|
171
|
-
React.createElement(Repeat, null,
|
|
172
|
-
React.createElement(Content, null,
|
|
173
|
-
React.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))),
|
|
174
|
-
React.createElement(Repeat, null,
|
|
175
|
-
React.createElement(PdfDownloadContainer, { documents: documents })))),
|
|
168
|
+
React.createElement(Documents, { documents: documents }),
|
|
176
169
|
React.createElement(ProductPageMainSection, null,
|
|
177
170
|
React.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
|
|
178
171
|
ecommerce && ecommerce.enabled && (React.createElement(Repeat, null,
|
|
@@ -4,8 +4,8 @@ interface PdfDownloadItemProps {
|
|
|
4
4
|
document: Scalars['FileDocument'];
|
|
5
5
|
}
|
|
6
6
|
export declare const PdfDownloadItem: ({ document }: PdfDownloadItemProps) => JSX.Element;
|
|
7
|
-
interface
|
|
7
|
+
interface IDocumentList {
|
|
8
8
|
documents: Scalars['FileDocument'][];
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
11
|
-
export default
|
|
10
|
+
export declare const DocumentList: ({ documents }: IDocumentList) => JSX.Element;
|
|
11
|
+
export default DocumentList;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const PdfListItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {
|
|
2
2
|
className: "wayke__theme wayke__color--primary-text";
|
|
3
3
|
}, "className">;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const List: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
|
|
5
5
|
export declare const PdfLink: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, {
|
|
6
6
|
className: "wayke__theme wayke__color--primary-text wayke__font--bold";
|
|
7
7
|
}, "className">;
|
|
@@ -9,6 +9,11 @@ export declare const H2: import("styled-components").StyledComponent<"div", impo
|
|
|
9
9
|
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
10
10
|
noMargin?: boolean | undefined;
|
|
11
11
|
}, "className">;
|
|
12
|
+
export declare const H3: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
13
|
+
className: "wayke__theme wayke__font--bold";
|
|
14
|
+
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
15
|
+
noMargin?: boolean | undefined;
|
|
16
|
+
}, "className">;
|
|
12
17
|
export declare const H4: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
13
18
|
className: "wayke__theme wayke__font--bold";
|
|
14
19
|
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Scalars } from '../../@types/codegen/types';
|
|
3
|
+
interface DocumentsProps {
|
|
4
|
+
documents: Scalars['FileDocument'][];
|
|
5
|
+
}
|
|
6
|
+
declare const Documents: ({ documents }: DocumentsProps) => JSX.Element | null;
|
|
7
|
+
export default Documents;
|
package/dist-web/index.js
CHANGED
|
@@ -806,13 +806,11 @@ const H2 = styled(HeadingBase).attrs((props) => ({
|
|
|
806
806
|
})) `
|
|
807
807
|
font-size: 1.5rem;
|
|
808
808
|
`;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
}))`
|
|
809
|
+
const H3 = styled(HeadingBase).attrs((props) => ({
|
|
810
|
+
as: props.as || 'h3',
|
|
811
|
+
})) `
|
|
813
812
|
font-size: 1.125rem;
|
|
814
813
|
`;
|
|
815
|
-
*/
|
|
816
814
|
const H4 = styled(HeadingBase).attrs((props) => ({
|
|
817
815
|
as: props.as || 'h4',
|
|
818
816
|
})) `
|
|
@@ -7108,7 +7106,7 @@ const PdfListItem = styled.li.attrs(() => ({
|
|
|
7108
7106
|
flex: 0 0 100%;
|
|
7109
7107
|
}
|
|
7110
7108
|
`;
|
|
7111
|
-
const
|
|
7109
|
+
const List$a = styled.ul `
|
|
7112
7110
|
list-style: none;
|
|
7113
7111
|
padding: 0;
|
|
7114
7112
|
display: flex;
|
|
@@ -7152,14 +7150,65 @@ const PdfListInner = styled.div `
|
|
|
7152
7150
|
}
|
|
7153
7151
|
`;
|
|
7154
7152
|
|
|
7155
|
-
const
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7153
|
+
const translateContentType = (document) => {
|
|
7154
|
+
switch (document.contentType) {
|
|
7155
|
+
case 'application/pdf':
|
|
7156
|
+
return 'PDF';
|
|
7157
|
+
default:
|
|
7158
|
+
const formattedContentType = document.url && document.url.includes('.') ? document.url.split('.').pop() : '';
|
|
7159
|
+
return formattedContentType;
|
|
7160
|
+
}
|
|
7161
|
+
};
|
|
7162
|
+
const PdfDownloadItem = ({ document }) => {
|
|
7163
|
+
const contentType = useMemo(() => translateContentType(document), [document]);
|
|
7164
|
+
return (React__default.createElement(PdfListItem, null,
|
|
7165
|
+
React__default.createElement(PdfListInner, null,
|
|
7166
|
+
React__default.createElement(PdfColumn, null,
|
|
7167
|
+
React__default.createElement(PdfTitle, null, document.name),
|
|
7168
|
+
React__default.createElement(PdfSubtitle, null, contentType)),
|
|
7169
|
+
React__default.createElement(PdfColumn, null,
|
|
7170
|
+
React__default.createElement(PdfLink, { href: document.url, rel: "noopener noreferrer nofollow", target: "_blank" }, "\u00D6ppna")))));
|
|
7171
|
+
};
|
|
7172
|
+
const DocumentList = ({ documents }) => (React__default.createElement(List$a, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
|
|
7173
|
+
|
|
7174
|
+
const Translation = {
|
|
7175
|
+
'tyre-label': 'Energideklaration för däck',
|
|
7176
|
+
'content declaration': 'Varudeklaration',
|
|
7177
|
+
other: 'Övriga dokument',
|
|
7178
|
+
};
|
|
7179
|
+
const SortOrder = {
|
|
7180
|
+
'tyre-label': 2,
|
|
7181
|
+
'content declaration': 1,
|
|
7182
|
+
other: 3,
|
|
7183
|
+
};
|
|
7184
|
+
const Documents = ({ documents }) => {
|
|
7185
|
+
const categorised = documents
|
|
7186
|
+
.reduce((prev, curr) => {
|
|
7187
|
+
const index = prev.findIndex((x) => x.category === (curr.category || 'others'));
|
|
7188
|
+
if (index > -1) {
|
|
7189
|
+
prev[index].documents.push(curr);
|
|
7190
|
+
}
|
|
7191
|
+
else {
|
|
7192
|
+
const category = curr.category || 'others';
|
|
7193
|
+
prev.push({
|
|
7194
|
+
category,
|
|
7195
|
+
documents: [curr],
|
|
7196
|
+
sortOrder: SortOrder?.[category] ?? 99,
|
|
7197
|
+
});
|
|
7198
|
+
}
|
|
7199
|
+
return prev;
|
|
7200
|
+
}, [])
|
|
7201
|
+
.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
7202
|
+
if (!documents.length)
|
|
7203
|
+
return null;
|
|
7204
|
+
const manyCategories = categorised.length > 1;
|
|
7205
|
+
return (React__default.createElement(ProductPageMainSection, null,
|
|
7206
|
+
React__default.createElement(Repeat, null,
|
|
7207
|
+
React__default.createElement(H2, { noMargin: true }, "Dokument")),
|
|
7208
|
+
categorised.map((group) => (React__default.createElement(Repeat, { key: group.category },
|
|
7209
|
+
manyCategories && (React__default.createElement(H3, null, Translation?.[group.category] || Translation.other)),
|
|
7210
|
+
React__default.createElement(DocumentList, { documents: group.documents }))))));
|
|
7211
|
+
};
|
|
7163
7212
|
|
|
7164
7213
|
const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
|
|
7165
7214
|
const { ecomSettings } = useSettings();
|
|
@@ -7292,14 +7341,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7292
7341
|
React__default.createElement(Repeat, null,
|
|
7293
7342
|
React__default.createElement(ExtendContent, { actionTitle: "Visa mer", onClick: onShowMoreOptionsClick },
|
|
7294
7343
|
React__default.createElement(UspList, { items: options }))))),
|
|
7295
|
-
|
|
7296
|
-
React__default.createElement(Repeat, null,
|
|
7297
|
-
React__default.createElement(H2, { noMargin: true }, "Dokument")),
|
|
7298
|
-
React__default.createElement(Repeat, null,
|
|
7299
|
-
React__default.createElement(Content$2, null,
|
|
7300
|
-
React__default.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))),
|
|
7301
|
-
React__default.createElement(Repeat, null,
|
|
7302
|
-
React__default.createElement(PdfDownloadContainer, { documents: documents })))),
|
|
7344
|
+
React__default.createElement(Documents, { documents: documents }),
|
|
7303
7345
|
React__default.createElement(ProductPageMainSection, null,
|
|
7304
7346
|
React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
|
|
7305
7347
|
ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,
|