@truecodeio/sdk-react 0.2.7 → 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/package.json CHANGED
@@ -1,12 +1,21 @@
1
1
  {
2
2
  "name": "@truecodeio/sdk-react",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
- "main": "src/index.tsx",
6
- "access": "public",
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
20
  "@truecodeio/sdk-core": "0.2.7"
12
21
  },
@@ -19,6 +28,7 @@
19
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,64 +0,0 @@
1
- # @boko/sdk-react
2
-
3
- ## 0.2.7
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies
8
- - @truecodeio/sdk-core@0.2.7
9
-
10
- ## 0.2.6
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies
15
- - @truecodeio/sdk-core@0.2.6
16
-
17
- ## 0.2.5
18
-
19
- ### Patch Changes
20
-
21
- - Updated dependencies
22
- - @truecodeio/sdk-core@0.2.5
23
-
24
- ## 0.2.4
25
-
26
- ### Patch Changes
27
-
28
- - Remove workspace dependencies
29
- - Updated dependencies
30
- - @truecodeio/sdk-core@0.2.4
31
-
32
- ## 0.2.3
33
-
34
- ### Patch Changes
35
-
36
- - Updated dependencies
37
- - @truecodeio/sdk-core@0.2.3
38
-
39
- ## 0.2.2
40
-
41
- ### Patch Changes
42
-
43
- - change package name
44
- - Updated dependencies
45
- - @truecodeio/sdk-core@0.2.2
46
-
47
- ## 0.2.1
48
-
49
- ### Patch Changes
50
-
51
- - Override access property
52
- - Updated dependencies
53
- - @boko/sdk-core@0.2.1
54
-
55
- ## 0.2.0
56
-
57
- ### Minor Changes
58
-
59
- - Init packages
60
-
61
- ### Patch Changes
62
-
63
- - Updated dependencies
64
- - @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,13 +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
- }
11
- },
12
- "include": ["src"]
13
- }