@pronto-tools-and-more/components 6.26.3 → 6.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/dist/main.js +108 -15
  2. package/dist/parts/CreateFakeSection/CreateFakeSection.d.ts +4 -0
  3. package/dist/parts/FakeNode/FakeNode.d.ts +5 -0
  4. package/dist/parts/HasComplexChildren/HasComplexChildren.d.ts +1 -0
  5. package/dist/parts/ISearchResult/ISearchResult.d.ts +7 -0
  6. package/dist/parts/ISearchResultComponent/ISearchResultComponent.d.ts +7 -0
  7. package/dist/parts/SearchResults/SearchResults.d.ts +4 -1
  8. package/dist/parts/UnwrapComponent/UnwrapComponent.d.ts +7 -0
  9. package/package.json +1 -1
  10. package/src/main.ts +0 -1
  11. package/src/parts/AppBar/AppBar.tsx +0 -3
  12. package/src/parts/Button/Button.tsx +0 -10
  13. package/src/parts/Components/Components.tsx +0 -12
  14. package/src/parts/EPaperLink/EPaperLink.tsx +0 -19
  15. package/src/parts/EPapers/EPapers.tsx +0 -28
  16. package/src/parts/FooterItemsList/FooterItemsList.tsx +0 -13
  17. package/src/parts/HeaderMenuItems/HeaderMenuItems.tsx +0 -12
  18. package/src/parts/Home/Home.tsx +0 -9
  19. package/src/parts/IssueList/IssueList.tsx +0 -31
  20. package/src/parts/JsonComponent/JsonComponent.tsx +0 -6
  21. package/src/parts/Link/Link.tsx +0 -17
  22. package/src/parts/Login/Login.tsx +0 -9
  23. package/src/parts/Main/Main.tsx +0 -1
  24. package/src/parts/MenuItems/MenuItems.tsx +0 -17
  25. package/src/parts/MockReact/MockReact.tsx +0 -21
  26. package/src/parts/MostRead/MostRead.tsx +0 -42
  27. package/src/parts/NoSearchResults/NoSearchResults.tsx +0 -15
  28. package/src/parts/Parts/Parts.tsx +0 -10
  29. package/src/parts/PostContentBody/PostContentBody.tsx +0 -21
  30. package/src/parts/React/React.tsx +0 -9
  31. package/src/parts/SearchField/SearchField.tsx +0 -14
  32. package/src/parts/SearchLink/SearchLink.tsx +0 -19
  33. package/src/parts/SearchResults/SearchResults.tsx +0 -114
  34. package/src/parts/SubscriptionLink/SubscriptionLink.tsx +0 -19
  35. package/src/parts/Swiper/Swiper.tsx +0 -11
package/dist/main.js CHANGED
@@ -119,23 +119,116 @@ var SearchLink = ({ message } = {}) => {
119
119
  return /* @__PURE__ */ React.createElement("div", { className: "SearchLink" }, /* @__PURE__ */ React.createElement(JsonComponent, { json }));
120
120
  };
121
121
 
122
+ // src/parts/HasComplexChildren/HasComplexChildren.ts
123
+ var isComplex = (child) => {
124
+ return typeof child !== "string";
125
+ };
126
+ var hasComplexChildren = (children) => {
127
+ return children.some(isComplex);
128
+ };
129
+
130
+ // src/parts/FakeNode/FakeNode.ts
131
+ var fakeNode = {
132
+ type: "html",
133
+ tag: "div",
134
+ content: '<img src="x" onerror="globalThis.fixRender(this)" />'
135
+ };
136
+
137
+ // src/parts/CreateFakeSection/CreateFakeSection.ts
138
+ var createFakeSection = (children) => {
139
+ return {
140
+ type: "section",
141
+ content: [fakeNode, ...children]
142
+ };
143
+ };
144
+
145
+ // src/parts/UnwrapComponent/UnwrapComponent.tsx
146
+ var getComponentChildren = (element, componentProps) => {
147
+ if (componentProps && componentProps.children) {
148
+ if (typeof componentProps.children === "string") {
149
+ return [componentProps.children];
150
+ }
151
+ return componentProps.children;
152
+ }
153
+ if (element && element.children) {
154
+ if (typeof element.children === "string") {
155
+ return [element.children];
156
+ }
157
+ return element.children;
158
+ }
159
+ return [];
160
+ };
161
+ var getComponentProperties = (element) => {
162
+ const componentType = element.type;
163
+ const componentProps = element.props;
164
+ const componentChildren = getComponentChildren(element, componentProps);
165
+ return {
166
+ componentType,
167
+ componentProps,
168
+ componentChildren
169
+ };
170
+ };
171
+ var unwrapComponent = (element) => {
172
+ if (!element) {
173
+ return {
174
+ type: "html",
175
+ tag: "div",
176
+ content: `Unknown component`
177
+ };
178
+ }
179
+ if (typeof element === "string" || typeof element === "number" || typeof element === "boolean") {
180
+ return {
181
+ type: "html",
182
+ tag: "div",
183
+ content: `${element}`
184
+ };
185
+ }
186
+ const { componentChildren, componentProps, componentType } = getComponentProperties(element);
187
+ if (typeof componentType === "function") {
188
+ const vnode = componentType({
189
+ ...componentProps
190
+ });
191
+ const rendered = unwrapComponent(vnode);
192
+ return rendered;
193
+ }
194
+ if (typeof componentType === "string") {
195
+ const hasComplexChildren2 = hasComplexChildren(componentChildren);
196
+ const renderedChildren = hasComplexChildren2 ? componentChildren.map(unwrapComponent) : [];
197
+ const content = hasComplexChildren2 ? "" : componentChildren[0] || "";
198
+ const props = componentProps ? componentProps : {};
199
+ return createFakeSection([
200
+ {
201
+ type: "html",
202
+ tag: componentType,
203
+ content
204
+ },
205
+ ...renderedChildren
206
+ ]);
207
+ }
208
+ if (componentType) {
209
+ return {
210
+ type: "TODO"
211
+ };
212
+ }
213
+ return {};
214
+ };
215
+
122
216
  // src/parts/SearchResults/SearchResults.tsx
123
- var SearchResults = () => {
217
+ var SearchResults = ({
218
+ SearchResult
219
+ }) => {
220
+ const searchResult = {
221
+ description: "abc",
222
+ label: "abc",
223
+ readtime: "",
224
+ title: "$context.title",
225
+ imageSrc: ""
226
+ };
227
+ const unwrapped = unwrapComponent(
228
+ /* @__PURE__ */ React.createElement(SearchResult, { item: searchResult })
229
+ );
124
230
  const json = {
125
- content: {
126
- type: "search-result",
127
- pageHitExcerptMessage: "test",
128
- coverHeight: "FIXED",
129
- tapPageHit: {
130
- type: "openContent"
131
- },
132
- tapCover: {
133
- type: "openContent"
134
- },
135
- class: "issue-card issue-card--overline-in-page-hit-excerpt-message",
136
- template: "feed",
137
- renderProperties: ["authors"]
138
- },
231
+ content: unwrapped,
139
232
  dataSource: {
140
233
  phrase: "$context.phrase",
141
234
  type: "search-result",
@@ -0,0 +1,4 @@
1
+ export declare const createFakeSection: (children: any) => {
2
+ type: string;
3
+ content: any[];
4
+ };
@@ -0,0 +1,5 @@
1
+ export declare const fakeNode: {
2
+ type: string;
3
+ tag: string;
4
+ content: string;
5
+ };
@@ -0,0 +1 @@
1
+ export declare const hasComplexChildren: (children: any) => any;
@@ -0,0 +1,7 @@
1
+ export interface ISearchResult {
2
+ readonly label: string;
3
+ readonly readtime: string;
4
+ readonly title: string;
5
+ readonly description: string;
6
+ readonly imageSrc: string;
7
+ }
@@ -0,0 +1,7 @@
1
+ import type React from "react";
2
+ import type { ISearchResult } from "../ISearchResult/ISearchResult.tsx";
3
+ export interface ISearchResultComponent {
4
+ ({ item }: {
5
+ item: ISearchResult;
6
+ }): React.ReactNode;
7
+ }
@@ -1 +1,4 @@
1
- export declare const SearchResults: () => import("react").JSX.Element;
1
+ import type { ISearchResultComponent } from "../ISearchResultComponent/ISearchResultComponent.tsx";
2
+ export declare const SearchResults: ({ SearchResult, }: {
3
+ SearchResult: ISearchResultComponent;
4
+ }) => import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type React from "react";
2
+ export declare const createElement: (tag: any, props: any, ...children: any[]) => {
3
+ tag: any;
4
+ props: any;
5
+ children: any[];
6
+ };
7
+ export declare const unwrapComponent: (element: React.ReactNode) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/components",
3
- "version": "6.26.3",
3
+ "version": "6.28.0",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
package/src/main.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./parts/Components/Components.tsx";
@@ -1,3 +0,0 @@
1
- export const AppBar = () => {
2
- return <div className="AppBar">hello from appbar</div>;
3
- };
@@ -1,10 +0,0 @@
1
- export const Button = ({ message }: { message: string }) => {
2
- return {
3
- type: "button",
4
- message,
5
- tap: {
6
- type: "navigate",
7
- path: "epaper",
8
- },
9
- };
10
- };
@@ -1,12 +0,0 @@
1
- export * from "../EPaperLink/EPaperLink.tsx";
2
- export * from "../FooterItemsList/FooterItemsList.tsx";
3
- export * from "../HeaderMenuItems/HeaderMenuItems.tsx";
4
- export * from "../JsonComponent/JsonComponent.tsx";
5
- export * from "../Link/Link.tsx";
6
- export * from "../Login/Login.tsx";
7
- export * from "../MenuItems/MenuItems.tsx";
8
- export * from "../PostContentBody/PostContentBody.tsx";
9
- export * from "../SearchField/SearchField.tsx";
10
- export * from "../SearchLink/SearchLink.tsx";
11
- export * from "../SearchResults/SearchResults.tsx";
12
- export * from "../SubscriptionLink/SubscriptionLink.tsx";
@@ -1,19 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const EPaperLink = ({ message }: { message?: string } = {}) => {
4
- const json = {
5
- type: "button",
6
- tap: {
7
- type: "navigate",
8
- path: "e-paper",
9
- },
10
- message,
11
- buttonClass: "e-paper",
12
- id: "button-epaper",
13
- };
14
- return (
15
- <div className="EPaperLink">
16
- <JsonComponent json={json} />
17
- </div>
18
- );
19
- };
@@ -1,28 +0,0 @@
1
- export const EPapers = () => {
2
- return {
3
- content: {
4
- type: "issue",
5
- descriptionMessage: "",
6
- customMessages: [],
7
- tapCover: {
8
- type: "openContent",
9
- mode: "MODAL",
10
- titleBar: true,
11
- },
12
- },
13
- dataSource: {
14
- type: "issue",
15
- sort: [
16
- {
17
- publicationDate: {
18
- direction: "ASC",
19
- },
20
- },
21
- ],
22
- batchSize: 12,
23
- },
24
- type: "list",
25
- class: "epaper-issues",
26
- template: "grid",
27
- };
28
- };
@@ -1,13 +0,0 @@
1
- import { MenuItems } from "../MenuItems/MenuItems.tsx";
2
-
3
- export const FooterItemsList = ({
4
- className,
5
- menuName = "",
6
- }: { className?: string; menuName?: string } = {}) => {
7
- const fullClassName = `FooterItemsList ${className}`;
8
- return (
9
- <div className={fullClassName}>
10
- <MenuItems menuName={menuName} />
11
- </div>
12
- );
13
- };
@@ -1,12 +0,0 @@
1
- import { MenuItems } from "../MenuItems/MenuItems.tsx";
2
-
3
- export const HeaderMenuItems = ({
4
- menuName = "",
5
- }: { menuName?: string } = {}) => {
6
- const fullClassName = `HeaderMenuItems`;
7
- return (
8
- <div className={fullClassName}>
9
- <MenuItems menuName={menuName} />
10
- </div>
11
- );
12
- };
@@ -1,9 +0,0 @@
1
- import { AppBar } from "../AppBar/AppBar.tsx";
2
-
3
- export const Home = () => {
4
- return (
5
- <div>
6
- <AppBar />
7
- </div>
8
- );
9
- };
@@ -1,31 +0,0 @@
1
- export const IssueList = () => {
2
- return {
3
- content: {
4
- type: "issue",
5
- template: "cover",
6
- downloadOptions: {
7
- buttonType: "SINGLE",
8
- progressType: "RADIAL",
9
- },
10
- openContent: {},
11
- tapCover: {
12
- type: "openContent",
13
- mode: "MODAL",
14
- titleBar: true,
15
- },
16
- },
17
- dataSource: {
18
- type: "issue",
19
- sort: [
20
- {
21
- publicationDate: {
22
- direction: "DESC",
23
- },
24
- },
25
- ],
26
- limit: 3,
27
- },
28
- type: "list",
29
- template: "horizontal",
30
- };
31
- };
@@ -1,6 +0,0 @@
1
- import type React from "react";
2
-
3
- export const JsonComponent = ({ json }): React.ReactElement => {
4
- const node = json as React.ReactElement;
5
- return node;
6
- };
@@ -1,17 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const Link = ({ to, message }: { to: string; message: string }) => {
4
- const json = {
5
- type: "button",
6
- tap: {
7
- type: "navigate",
8
- path: to,
9
- },
10
- message,
11
- };
12
- return (
13
- <div className="Link">
14
- <JsonComponent json={json} />
15
- </div>
16
- );
17
- };
@@ -1,9 +0,0 @@
1
- import type React from "react";
2
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
3
-
4
- export const Login = (): React.ReactNode => {
5
- const json = {
6
- type: "login",
7
- };
8
- return <JsonComponent json={json} />;
9
- };
@@ -1 +0,0 @@
1
- export * from "../Components/Components.tsx";
@@ -1,17 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const MenuItems = ({ menuName }: { menuName: string }) => {
4
- const json = {
5
- dataSource: {
6
- type: "menu",
7
- filter: {
8
- name: {
9
- value: menuName,
10
- },
11
- },
12
- },
13
- type: "menu",
14
- template: "STATIC",
15
- };
16
- return <JsonComponent json={json} />;
17
- };
@@ -1,21 +0,0 @@
1
- import { jest } from "@jest/globals";
2
-
3
- // jest.unstable_mockModule("react", () => {
4
- // return {
5
- // createElement(key, props, children) {
6
- // return {
7
- // key,
8
- // props,
9
- // children,
10
- // };
11
- // },
12
- // };
13
- // });
14
-
15
- // jest.unstable_mockModule("react/jsx-runtime", () => {
16
- // return {
17
- // jsx(fn, props) {
18
- // return fn(props);
19
- // },
20
- // };
21
- // });
@@ -1,42 +0,0 @@
1
- export const MostRead = ({ limit = 3 }) => {
2
- return {
3
- content: {
4
- type: "issue",
5
- issueContextKey: "content",
6
- template: "details",
7
- descriptionMessage: "",
8
- class: "issue-card",
9
- hideComponents: {
10
- publication: true,
11
- tags: true,
12
- categories: true,
13
- publicationDate: true,
14
- cover: true,
15
- properties: true,
16
- description: false,
17
- },
18
- },
19
- dataSource: {
20
- type: "content",
21
- filter: {
22
- AND: [
23
- {
24
- contentType: {
25
- value: "POST",
26
- },
27
- },
28
- {
29
- postType: {
30
- value: "post",
31
- },
32
- },
33
- ],
34
- },
35
- limit,
36
- },
37
- type: "list",
38
- tapEntry: {
39
- type: "openContent",
40
- },
41
- };
42
- };
@@ -1,15 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const NoSearchResults = () => {
4
- const json = {
5
- tag: "p",
6
- type: "html",
7
- content: "SEARCH_RESULT_NO_SEARCH",
8
- class: "no-search",
9
- condition: {
10
- value: "$context.phrase",
11
- operation: "NOT_SET",
12
- },
13
- };
14
- return <JsonComponent json={json} />;
15
- };
@@ -1,10 +0,0 @@
1
- export * from "../AppBar/AppBar.tsx";
2
- export * from "../Button/Button.tsx";
3
- export * from "../EPapers/EPapers.tsx";
4
- export * from "../Home/Home.tsx";
5
- export * from "../IssueList/IssueList.tsx";
6
- export * from "../Login/Login.tsx";
7
- export * from "../MostRead/MostRead.tsx";
8
- export * from "../NoSearchResults/NoSearchResults.tsx";
9
- export * from "../SearchField/SearchField.tsx";
10
- export * from "../Swiper/Swiper.tsx";
@@ -1,21 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const PostContentBody = () => {
4
- const json = {
5
- type: "content-body",
6
- id: "post-content-body",
7
- customBlocks: [],
8
- class: ["post-content-service"],
9
- dataSource: {
10
- type: "content",
11
- preventSSRCache: true,
12
- filter: {
13
- id: {
14
- value: "$context.content.id",
15
- },
16
- },
17
- },
18
- isLazy: false,
19
- };
20
- return <JsonComponent json={json} />;
21
- };
@@ -1,9 +0,0 @@
1
- export const React = {
2
- createElement(tag, props, children) {
3
- return {
4
- tag,
5
- props,
6
- children,
7
- };
8
- },
9
- };
@@ -1,14 +0,0 @@
1
- import type React from "react";
2
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
3
-
4
- export const SearchField = (): React.ReactElement => {
5
- const json = {
6
- type: "search-field",
7
- className: "searchfield",
8
- };
9
- return (
10
- <div className="SearchField">
11
- <JsonComponent json={json} />
12
- </div>
13
- );
14
- };
@@ -1,19 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const SearchLink = ({ message }: { message?: string } = {}) => {
4
- const json = {
5
- type: "button",
6
- tap: {
7
- type: "navigate",
8
- path: "suche",
9
- },
10
- message,
11
- buttonClass: "search",
12
- id: "button-search",
13
- };
14
- return (
15
- <div className="SearchLink">
16
- <JsonComponent json={json} />
17
- </div>
18
- );
19
- };
@@ -1,114 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const SearchResults = () => {
4
- const json = {
5
- content: {
6
- type: "search-result",
7
- pageHitExcerptMessage: "test",
8
- coverHeight: "FIXED",
9
- tapPageHit: {
10
- type: "openContent",
11
- },
12
- tapCover: {
13
- type: "openContent",
14
- },
15
- class: "issue-card issue-card--overline-in-page-hit-excerpt-message",
16
- template: "feed",
17
- renderProperties: ["authors"],
18
- },
19
- dataSource: {
20
- phrase: "$context.phrase",
21
- type: "search-result",
22
- filter: {
23
- AND: [
24
- {
25
- OR: [
26
- {
27
- contentType: {
28
- value: "POST",
29
- },
30
- },
31
- {
32
- contentType: {
33
- value: "BUNDLE",
34
- },
35
- },
36
- ],
37
- },
38
- {
39
- postType: {
40
- value: "post",
41
- },
42
- },
43
- {
44
- condition: {
45
- value: "$context.issue-age",
46
- compareValue: "day",
47
- },
48
- age: {
49
- count: 1,
50
- unit: "DAY",
51
- },
52
- },
53
- {
54
- condition: {
55
- value: "$context.issue-age",
56
- compareValue: "week",
57
- },
58
- age: {
59
- count: 1,
60
- unit: "WEEK",
61
- },
62
- },
63
- {
64
- condition: {
65
- value: "$context.issue-age",
66
- compareValue: "month",
67
- },
68
- age: {
69
- count: 1,
70
- unit: "MONTH",
71
- },
72
- },
73
- {
74
- condition: {
75
- value: "$context.issue-age",
76
- compareValue: "year",
77
- },
78
- age: {
79
- count: 1,
80
- unit: "YEAR",
81
- },
82
- },
83
- ],
84
- },
85
- contextKey: "searchResults",
86
- searchOptions: {
87
- sortBy: "PUB_DATE_DESC",
88
- findAll: true,
89
- },
90
- limitCharactersBeforeHit: 70,
91
- legacyMode: {
92
- mapPostToIssue: true,
93
- unwrapBundles: true,
94
- },
95
- },
96
- type: "list",
97
- class: "schlauch-section",
98
- emptyMessage: {
99
- message: "SEARCH_RESULT_NO_RESULT",
100
- variables: ["$context.phrase"],
101
- },
102
- errorMessage: "SEARCH_ERROR",
103
- errorButtonLabel: "SEARCH_ERROR_RETRY",
104
- template: "grid",
105
- tapEntry: {
106
- type: "openContent",
107
- },
108
- };
109
- return (
110
- <div className="SearchResults">
111
- <JsonComponent json={json} />
112
- </div>
113
- );
114
- };
@@ -1,19 +0,0 @@
1
- import { JsonComponent } from "../JsonComponent/JsonComponent.tsx";
2
-
3
- export const SubscriptionLink = ({ message }: { message?: string } = {}) => {
4
- const json = {
5
- type: "button",
6
- tap: {
7
- type: "navigate",
8
- path: "subscriptions",
9
- },
10
- message,
11
- buttonClass: "subscriptions",
12
- id: "button-subscriptions",
13
- };
14
- return (
15
- <div className="SubscriptionLink">
16
- <JsonComponent json={json} />
17
- </div>
18
- );
19
- };
@@ -1,11 +0,0 @@
1
- export const Swiper = () => {
2
- return {
3
- type: "swiper",
4
- effect: "slide",
5
- loop: false,
6
- pagination: false,
7
- centeredSlides: false,
8
- param: "$context.embeddedParams.swiperIndex",
9
- paramScope: "USER_ATTRIBUTE",
10
- };
11
- };