hanbiro-react16-sdk 1.0.0 → 1.0.2

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 CHANGED
@@ -1 +1,89 @@
1
1
  # hanbiro-react16-sdk
2
+
3
+ React 16.2.0 compatible UI components SDK for Hanbiro projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install hanbiro-react16-sdk
9
+ ```
10
+
11
+ ## Initialization (Required)
12
+
13
+ You **must** initialize the SDK at the entry point of your main project (e.g., `index.tsx` or `App.tsx`) by calling `initHanbiroReactSDK`. This ensures that global configurations like `baseUrl` and `signer` are properly set up before any components are rendered.
14
+
15
+ ```tsx
16
+ // src/index.tsx (Entry point)
17
+ import { initHanbiroReactSDK } from 'hanbiro-react16-sdk/utils';
18
+
19
+ initHanbiroReactSDK({
20
+ baseUrl: import.meta.env.VITE_BASE_URL || "https://vndev.hanbiro.com",
21
+ signer: null, // Pass your signer instance here if available
22
+ });
23
+ ```
24
+
25
+ ## Usage Example: `ChatAIDraft` in a Class Component
26
+
27
+ Here is an example of how to import and use the `ChatAIDraft` component inside a React class component.
28
+
29
+ ```tsx
30
+ import React, { Component } from 'react';
31
+ import { ChatAIDraft } from 'hanbiro-react16-sdk/components';
32
+ import { getBaseUrl } from 'hanbiro-react16-sdk/utils';
33
+
34
+ // Optional: Import global styles if needed (depending on your build setup)
35
+ // import 'hanbiro-react16-sdk/dist/style.css';
36
+
37
+ interface AppState {
38
+ draftContent: string;
39
+ }
40
+
41
+ class ChatAIDraftApp extends Component<{}, AppState> {
42
+ constructor(props: {}) {
43
+ super(props);
44
+ this.state = {
45
+ draftContent: ''
46
+ };
47
+ }
48
+
49
+ // Handle the event when user applies AI generated content
50
+ handleApply = (result: any) => {
51
+ console.log("Applied Output:", result);
52
+ this.setState({ draftContent: result.html });
53
+ alert("Applied content: " + result.html);
54
+ };
55
+
56
+ render() {
57
+ return (
58
+ <div style={{ padding: '20px', fontFamily: 'sans-serif' }}>
59
+ <h2>Hanbiro AI Draft Component</h2>
60
+
61
+ <div style={{ border: '1px solid #ccc', padding: '16px', borderRadius: '8px' }}>
62
+ {/* Using the component */}
63
+ <ChatAIDraft
64
+ baseUrl={getBaseUrl()}
65
+ onApply={this.handleApply}
66
+ />
67
+ </div>
68
+
69
+ {/* Display the draft result */}
70
+ {this.state.draftContent && (
71
+ <div style={{ marginTop: '20px' }}>
72
+ <h3>Draft Result:</h3>
73
+ <div dangerouslySetInnerHTML={{ __html: this.state.draftContent }} />
74
+ </div>
75
+ )}
76
+ </div>
77
+ );
78
+ }
79
+ }
80
+
81
+ export default ChatAIDraftApp;
82
+ ```
83
+
84
+ ## Development Commands
85
+
86
+ - Run playground locally: `npm run dev`
87
+ - Build library for production: `npm run build`
88
+ - Build playground for production: `npm run build:playground`
89
+ - Typecheck: `npm run test:typescript`
@@ -6,5 +6,5 @@ interface ListProps {
6
6
  }) => void;
7
7
  getEditorContent?: () => string;
8
8
  }
9
- declare const List: React.SFC<ListProps>;
9
+ declare const List: React.FunctionComponent<ListProps>;
10
10
  export default List;
@@ -1,4 +1,4 @@
1
- import { C as t } from "../index-DuSzMCvF.mjs";
1
+ import { C as t } from "../index-BB9T_tBw.mjs";
2
2
  export {
3
3
  t as ChatAIDraft
4
4
  };