@openlettermarketing/olc-react-sdk 0.0.39 → 0.0.40
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/README.md +117 -20
- package/build/index.js +99 -78
- package/build/index.js.map +1 -1
- package/build/types/App.d.ts +1 -0
- package/build/types/components/SidePanel/index.d.ts +1 -0
- package/build/types/components/TemplateBuilder/index.d.ts +1 -0
- package/build/types/index.d.ts +3 -1
- package/build/types/utils/constants.d.ts +2 -1
- package/build/types/utils/customStyles.d.ts +1 -0
- package/build/types/utils/helper.d.ts +3 -0
- package/package.json +2 -1
- /package/build/types/components/SidePanel/{customFields → CustomFields}/customFieldSection.d.ts +0 -0
- /package/build/types/components/SidePanel/{templates → Templates}/customTemplateSection.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,30 +1,127 @@
|
|
|
1
|
-
# React
|
|
1
|
+
# OLC React SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `OLC React SDK` SDK allows developers to integrate a customizable template builder into their applications. This SDK provides a range of options to manage templates, handle authentication, and customize the look and feel of the template builder.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
7
|
+
To install the SDK, use npm:
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @openlettermarketing/olc-react-sdk
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import TemplateBuilder from '@openlettermarketing/olc-react-sdk';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const templateBuilderProps: TemplateBuilderProps = {
|
|
15
|
+
container: document.getElementById('template-builder-container'),
|
|
16
|
+
secretKey: 'your-secret-key',
|
|
17
|
+
basicAuthUsername: 'your-username',
|
|
18
|
+
basicAuthPassword: 'your-password',
|
|
19
|
+
platformName: 'Your Platform Name',
|
|
20
|
+
createTemplateRoute: '/create-template',
|
|
21
|
+
templateBuilderRoute: '/edit-template',
|
|
22
|
+
olcTemplate: yourTemplateObject,
|
|
23
|
+
onReturnAndNavigate: () => {
|
|
24
|
+
// Define what happens when the user returns and navigates.
|
|
25
|
+
},
|
|
26
|
+
onGetOneTemplate: async (payload) => {
|
|
27
|
+
// Fetch a specific template.
|
|
28
|
+
},
|
|
29
|
+
onGetTemplates: async (payload) => {
|
|
30
|
+
// Fetch all templates.
|
|
31
|
+
},
|
|
32
|
+
onGetCustomFields: async () => {
|
|
33
|
+
// Fetch custom fields for the templates.
|
|
24
34
|
},
|
|
35
|
+
onSubmit: async (payload) => {
|
|
36
|
+
// Handle the submission of a template.
|
|
37
|
+
},
|
|
38
|
+
styles: {
|
|
39
|
+
root: {
|
|
40
|
+
// Custom CSS properties for the root element.
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
TemplateBuilder(templateBuilderProps);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## TemplateBuilderProps Interface
|
|
49
|
+
This interface defines the structure for the properties that you can pass to the TemplateBuilder SDK.
|
|
50
|
+
|
|
51
|
+
## Properties
|
|
52
|
+
|
|
53
|
+
#### container (HTMLElement | null):
|
|
54
|
+
The container element where the template builder will be rendered. This must be an HTML element in your DOM.
|
|
55
|
+
|
|
56
|
+
#### secretKey (string):
|
|
57
|
+
The secret key used for authenticating requests.
|
|
58
|
+
|
|
59
|
+
#### basicAuthUsername (string):
|
|
60
|
+
The username for basic authentication.
|
|
61
|
+
|
|
62
|
+
#### basicAuthPassword (string):
|
|
63
|
+
The password for basic authentication.
|
|
64
|
+
|
|
65
|
+
#### platformName (string | null, optional):
|
|
66
|
+
The name of the platform where the template builder is integrated.
|
|
67
|
+
|
|
68
|
+
#### createTemplateRoute (string | null, optional):
|
|
69
|
+
The route used for creating new templates.
|
|
70
|
+
|
|
71
|
+
#### templateBuilderRoute (string | null, optional):
|
|
72
|
+
The route used for editing existing templates.
|
|
73
|
+
|
|
74
|
+
#### olcTemplate (Record<string, any>, optional):
|
|
75
|
+
An object representing the template to be edited or used as a base.
|
|
76
|
+
|
|
77
|
+
#### onReturnAndNavigate (() => void, optional):
|
|
78
|
+
A callback function triggered when the user returns and navigates away from the template builder.
|
|
79
|
+
|
|
80
|
+
#### onGetOneTemplate ((payload: any) => Promise<any>, optional):
|
|
81
|
+
A function to fetch a specific template. It receives a payload and returns a promise.
|
|
82
|
+
|
|
83
|
+
#### onGetTemplates ((payload: any) => Promise<any>, optional):
|
|
84
|
+
A function to fetch all templates. It receives a payload and returns a promise.
|
|
85
|
+
|
|
86
|
+
#### onGetCustomFields (() => Promise<any>, optional):
|
|
87
|
+
A function to fetch custom fields associated with the templates.
|
|
88
|
+
|
|
89
|
+
#### onSubmit ((payload: any) => Promise<any>, optional):
|
|
90
|
+
A function triggered upon submitting a template. It receives a payload and returns a promise.
|
|
91
|
+
|
|
92
|
+
#### styles (object, optional):
|
|
93
|
+
An object for custom CSS properties to style the template builder's root element.
|
|
94
|
+
|
|
95
|
+
## Example Usage
|
|
96
|
+
```bash
|
|
97
|
+
import { useEffect } from "react";
|
|
98
|
+
|
|
99
|
+
import TemplateBuilder from "@openlettermarketing/olc-react-sdk";
|
|
100
|
+
import '@blueprintjs/core/lib/css/blueprint.css';
|
|
101
|
+
|
|
102
|
+
function App() {
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
TemplateBuilder({
|
|
105
|
+
container: document.getElementById('template-builder-container'),
|
|
106
|
+
secretKey: 'your-secret-key',
|
|
107
|
+
basicAuthUsername: 'your-username',
|
|
108
|
+
basicAuthPassword: 'your-password',
|
|
109
|
+
onSubmit: async (payload) => {
|
|
110
|
+
console.log('Template submitted:', payload);
|
|
111
|
+
// Add your submission logic here
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}, []);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<>
|
|
118
|
+
<div id="template-builder-container"></div>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
25
121
|
}
|
|
122
|
+
|
|
123
|
+
export default App;
|
|
26
124
|
```
|
|
27
125
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
|
126
|
+
## License
|
|
127
|
+
This SDK is licensed under the MIT License
|