@truecodeio/sdk-react 0.2.6 → 0.2.8
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/index.d.ts +80 -0
- package/dist/index.js +5860 -0
- package/dist/index.js.map +1 -0
- package/package.json +15 -5
- package/CHANGELOG.md +0 -57
- package/src/index.tsx +0 -135
- package/tsconfig.json +0 -15
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truecodeio/sdk-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
7
14
|
"devDependencies": {
|
|
8
15
|
"@types/react": "^19.1.8",
|
|
9
16
|
"react": "^19.1.0",
|
|
17
|
+
"vite": "^7.0.0",
|
|
18
|
+
"vite-plugin-dts": "^4.5.4",
|
|
10
19
|
"@boko/tsconfig": "^1.0.0",
|
|
11
|
-
"@truecodeio/sdk-core": "0.2.
|
|
20
|
+
"@truecodeio/sdk-core": "0.2.7"
|
|
12
21
|
},
|
|
13
22
|
"dependencies": {
|
|
14
23
|
"@truecodeio/client-shared": "^0.1.5",
|
|
@@ -16,9 +25,10 @@
|
|
|
16
25
|
},
|
|
17
26
|
"peerDependencies": {
|
|
18
27
|
"react": "^19.1.0",
|
|
19
|
-
"@truecodeio/sdk-core": "0.2.
|
|
28
|
+
"@truecodeio/sdk-core": "0.2.7"
|
|
20
29
|
},
|
|
21
30
|
"scripts": {
|
|
31
|
+
"build": "vite build",
|
|
22
32
|
"format:prettier:fix:all": "prettier --cache --write ./src",
|
|
23
33
|
"lint:eslint:fix:all": "eslint --cache --fix ./src",
|
|
24
34
|
"lint:typescript": "tsc --noEmit"
|
package/CHANGELOG.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# @boko/sdk-react
|
|
2
|
-
|
|
3
|
-
## 0.2.6
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- @truecodeio/sdk-core@0.2.6
|
|
9
|
-
|
|
10
|
-
## 0.2.5
|
|
11
|
-
|
|
12
|
-
### Patch Changes
|
|
13
|
-
|
|
14
|
-
- Updated dependencies
|
|
15
|
-
- @truecodeio/sdk-core@0.2.5
|
|
16
|
-
|
|
17
|
-
## 0.2.4
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- Remove workspace dependencies
|
|
22
|
-
- Updated dependencies
|
|
23
|
-
- @truecodeio/sdk-core@0.2.4
|
|
24
|
-
|
|
25
|
-
## 0.2.3
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- Updated dependencies
|
|
30
|
-
- @truecodeio/sdk-core@0.2.3
|
|
31
|
-
|
|
32
|
-
## 0.2.2
|
|
33
|
-
|
|
34
|
-
### Patch Changes
|
|
35
|
-
|
|
36
|
-
- change package name
|
|
37
|
-
- Updated dependencies
|
|
38
|
-
- @truecodeio/sdk-core@0.2.2
|
|
39
|
-
|
|
40
|
-
## 0.2.1
|
|
41
|
-
|
|
42
|
-
### Patch Changes
|
|
43
|
-
|
|
44
|
-
- Override access property
|
|
45
|
-
- Updated dependencies
|
|
46
|
-
- @boko/sdk-core@0.2.1
|
|
47
|
-
|
|
48
|
-
## 0.2.0
|
|
49
|
-
|
|
50
|
-
### Minor Changes
|
|
51
|
-
|
|
52
|
-
- Init packages
|
|
53
|
-
|
|
54
|
-
### Patch Changes
|
|
55
|
-
|
|
56
|
-
- Updated dependencies
|
|
57
|
-
- @boko/sdk-core@0.2.0
|
package/src/index.tsx
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { createContext, use, useEffect, useState } from "react";
|
|
2
|
-
import type { createBokoClient, EligibleCampaign } from "@truecodeio/sdk-core";
|
|
3
|
-
import type { NodeT } from "@truecodeio/client-shared/schemas/tree-nodes/index.ts";
|
|
4
|
-
import { assertedNonNull } from "@truecodeio/common/typescript/utils/non-nullable.ts";
|
|
5
|
-
|
|
6
|
-
type ClientContextValue = {
|
|
7
|
-
client: ReturnType<typeof createBokoClient>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const ClientContext = createContext<ClientContextValue | null>(null);
|
|
11
|
-
|
|
12
|
-
export const ClientProvider = ({
|
|
13
|
-
children,
|
|
14
|
-
client,
|
|
15
|
-
}: React.PropsWithChildren<{
|
|
16
|
-
client: ReturnType<typeof createBokoClient>;
|
|
17
|
-
}>) => {
|
|
18
|
-
return <ClientContext value={{ client }}>{children}</ClientContext>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const useClient = () => {
|
|
22
|
-
return assertedNonNull(use(ClientContext)).client;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const Renderer = () => {
|
|
26
|
-
const [campaign, setCampaign] = useState<EligibleCampaign | null>(null);
|
|
27
|
-
|
|
28
|
-
const client = useClient();
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
// TODO: Replace with tanstack query
|
|
32
|
-
const fetchCampaign = async () => {
|
|
33
|
-
try {
|
|
34
|
-
const response = await client.getEligibleCampaign();
|
|
35
|
-
|
|
36
|
-
setCampaign(response);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error("Error fetching campaign:", error);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
void fetchCampaign();
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
const renderCampaign = () => {
|
|
46
|
-
if (!campaign) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const renderNode = (node: NodeT) => {
|
|
51
|
-
switch (node.type) {
|
|
52
|
-
case "root": {
|
|
53
|
-
return (
|
|
54
|
-
<div style={{ color: node.props.color }}>
|
|
55
|
-
{node.children.map(renderNode)}
|
|
56
|
-
</div>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
case "row": {
|
|
60
|
-
return (
|
|
61
|
-
<div
|
|
62
|
-
style={{
|
|
63
|
-
display: "flex",
|
|
64
|
-
backgroundColor: node.props.background.color,
|
|
65
|
-
paddingLeft: node.props.padding.left,
|
|
66
|
-
paddingRight: node.props.padding.right,
|
|
67
|
-
paddingTop: node.props.padding.top,
|
|
68
|
-
paddingBottom: node.props.padding.bottom,
|
|
69
|
-
}}
|
|
70
|
-
key={node.id}
|
|
71
|
-
>
|
|
72
|
-
{node.children.map(renderNode)}
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
case "column": {
|
|
77
|
-
return (
|
|
78
|
-
<div style={{ flex: 1 }} key={node.id}>
|
|
79
|
-
{node.children.map(renderNode)}
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
case "button": {
|
|
84
|
-
return (
|
|
85
|
-
<button type="button" key={node.id}>
|
|
86
|
-
{node.props.title}
|
|
87
|
-
</button>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
case "text": {
|
|
91
|
-
switch (node.props.type) {
|
|
92
|
-
case "paragraph": {
|
|
93
|
-
return <p key={node.id}>{node.props.content}</p>;
|
|
94
|
-
}
|
|
95
|
-
case "heading-1": {
|
|
96
|
-
return <h1 key={node.id}>{node.props.content}</h1>;
|
|
97
|
-
}
|
|
98
|
-
case "heading-2": {
|
|
99
|
-
return <h2 key={node.id}>{node.props.content}</h2>;
|
|
100
|
-
}
|
|
101
|
-
case "heading-3": {
|
|
102
|
-
return <h3 key={node.id}>{node.props.content}</h3>;
|
|
103
|
-
}
|
|
104
|
-
case "heading-4": {
|
|
105
|
-
return <h4 key={node.id}>{node.props.content}</h4>;
|
|
106
|
-
}
|
|
107
|
-
case "heading-5": {
|
|
108
|
-
return <h5 key={node.id}>{node.props.content}</h5>;
|
|
109
|
-
}
|
|
110
|
-
case "heading-6": {
|
|
111
|
-
return <h6 key={node.id}>{node.props.content}</h6>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
default: {
|
|
115
|
-
return node.props.type satisfies never;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
case "spacer": {
|
|
120
|
-
return <div style={{ height: node.props.size }} key={node.id}></div>;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
default: {
|
|
124
|
-
return node satisfies never;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
return renderNode(campaign.template.content);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
return renderCampaign();
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export { createBokoClient } from "@truecodeio/sdk-core";
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@boko/tsconfig",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"allowImportingTsExtensions": true,
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"module": "ES2022",
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"paths": {
|
|
9
|
-
"@truecodeio/sdk-react/*": ["./src/*"],
|
|
10
|
-
"@truecodeio/sdk-core": ["../sdk-core/src"],
|
|
11
|
-
"@truecodeio/sdk-core/*": ["../sdk-core/src/*"]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"include": ["src"]
|
|
15
|
-
}
|