hanbiro-react16-sdk 1.0.12 → 1.0.14

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
@@ -15,12 +15,14 @@ npm install hanbiro-react16-sdk
15
15
  You **must** import the SDK stylesheet at the entry point of your project (or in the HTML file when using UMD).
16
16
 
17
17
  **For npm/ES module projects:**
18
+
18
19
  ```ts
19
20
  // src/index.tsx or App.tsx
20
- import 'hanbiro-react16-sdk/style.css';
21
+ import "hanbiro-react16-sdk/style.css";
21
22
  ```
22
23
 
23
24
  **For UMD (script tag):**
25
+
24
26
  ```html
25
27
  <link rel="stylesheet" href="path/to/hanbiro-react16-sdk.style.css" />
26
28
  ```
@@ -29,19 +31,20 @@ import 'hanbiro-react16-sdk/style.css';
29
31
 
30
32
  ## Exported Components
31
33
 
32
- | Component | Import path |
33
- |---|---|
34
- | `ChatAIDraft` | `hanbiro-react16-sdk/components` |
35
- | `LoadingCircular` | `hanbiro-react16-sdk/components` |
34
+ | Component | Import path |
35
+ | ------------------ | -------------------------------- |
36
+ | `ChatAIDraft` | `hanbiro-react16-sdk/components` |
37
+ | `LoadingCircular` | `hanbiro-react16-sdk/components` |
36
38
  | `LoadingContainer` | `hanbiro-react16-sdk/components` |
39
+ | `CountryFlag` | `hanbiro-react16-sdk/components` |
37
40
 
38
41
  ## Exported Utils
39
42
 
40
- | Function | Description | Import path |
41
- |---|---|---|
43
+ | Function | Description | Import path |
44
+ | --------------------- | -------------------------------- | --------------------------- |
42
45
  | `initHanbiroReactSDK` | Initialize SDK (baseUrl, signer) | `hanbiro-react16-sdk/utils` |
43
- | `getBaseUrl` | Get the configured base URL | `hanbiro-react16-sdk/utils` |
44
- | `getGroupwareUrl` | Get the groupware URL | `hanbiro-react16-sdk/utils` |
46
+ | `getBaseUrl` | Get the configured base URL | `hanbiro-react16-sdk/utils` |
47
+ | `getGroupwareUrl` | Get the groupware URL | `hanbiro-react16-sdk/utils` |
45
48
 
46
49
  ---
47
50
 
@@ -50,10 +53,10 @@ import 'hanbiro-react16-sdk/style.css';
50
53
  Call `initHanbiroReactSDK` at the entry point of your project before rendering any components.
51
54
 
52
55
  ```ts
53
- import { initHanbiroReactSDK } from 'hanbiro-react16-sdk/utils';
56
+ import { initHanbiroReactSDK } from "hanbiro-react16-sdk/utils";
54
57
 
55
58
  initHanbiroReactSDK({
56
- baseUrl: 'https://vndev.hanbiro.com',
59
+ baseUrl: "https://vndev.hanbiro.com",
57
60
  signer: null, // Pass your signer instance here if available
58
61
  });
59
62
  ```
@@ -63,23 +66,18 @@ initHanbiroReactSDK({
63
66
  ## Usage: ES Module (npm)
64
67
 
65
68
  ```tsx
66
- import React, { Component } from 'react';
67
- import { ChatAIDraft } from 'hanbiro-react16-sdk/components';
68
- import { getBaseUrl } from 'hanbiro-react16-sdk/utils';
69
- import 'hanbiro-react16-sdk/style.css';
69
+ import React, { Component } from "react";
70
+ import { ChatAIDraft } from "hanbiro-react16-sdk/components";
71
+ import { getBaseUrl } from "hanbiro-react16-sdk/utils";
72
+ import "hanbiro-react16-sdk/style.css";
70
73
 
71
74
  class ChatAIDraftApp extends Component {
72
75
  handleApply = (result) => {
73
- console.log('Applied Output:', result);
76
+ console.log("Applied Output:", result);
74
77
  };
75
78
 
76
79
  render() {
77
- return (
78
- <ChatAIDraft
79
- baseUrl={getBaseUrl()}
80
- onApply={this.handleApply}
81
- />
82
- );
80
+ return <ChatAIDraft baseUrl={getBaseUrl()} onApply={this.handleApply} />;
83
81
  }
84
82
  }
85
83
 
@@ -109,7 +107,7 @@ The SDK is exposed as a global variable `HanbiroReact16SDK`.
109
107
  ```js
110
108
  // Initialize
111
109
  HanbiroReact16SDK.initHanbiroReactSDK({
112
- baseUrl: 'https://vndev.hanbiro.com',
110
+ baseUrl: "https://vndev.hanbiro.com",
113
111
  signer: null,
114
112
  });
115
113
 
@@ -117,44 +115,44 @@ HanbiroReact16SDK.initHanbiroReactSDK({
117
115
  ReactDOM.render(
118
116
  React.createElement(HanbiroReact16SDK.ChatAIDraft, {
119
117
  baseUrl: HanbiroReact16SDK.getBaseUrl(),
120
- onApply: function(result) {
121
- console.log('Applied:', result);
118
+ onApply: function (result) {
119
+ console.log("Applied:", result);
122
120
  },
123
121
  }),
124
- document.getElementById('chat-ai-container')
122
+ document.getElementById("chat-ai-container"),
125
123
  );
126
124
  ```
127
125
 
128
126
  ### Example: AngularJS Directive
129
127
 
130
128
  ```js
131
- angular.module('myApp').directive('chatAiDraft', function() {
129
+ angular.module("myApp").directive("chatAiDraft", function () {
132
130
  return {
133
- restrict: 'E',
134
- link: function(scope, element) {
131
+ restrict: "E",
132
+ link: function (scope, element) {
135
133
  var container = element[0];
136
134
 
137
135
  HanbiroReact16SDK.initHanbiroReactSDK({
138
- baseUrl: 'https://vndev.hanbiro.com',
136
+ baseUrl: "https://vndev.hanbiro.com",
139
137
  signer: null,
140
138
  });
141
139
 
142
140
  ReactDOM.render(
143
141
  React.createElement(HanbiroReact16SDK.ChatAIDraft, {
144
142
  baseUrl: HanbiroReact16SDK.getBaseUrl(),
145
- onApply: function(result) {
146
- scope.$apply(function() {
143
+ onApply: function (result) {
144
+ scope.$apply(function () {
147
145
  scope.draftContent = result.html;
148
146
  });
149
147
  },
150
148
  }),
151
- container
149
+ container,
152
150
  );
153
151
 
154
- scope.$on('$destroy', function() {
152
+ scope.$on("$destroy", function () {
155
153
  ReactDOM.unmountComponentAtNode(container);
156
154
  });
157
- }
155
+ },
158
156
  };
159
157
  });
160
158
  ```
@@ -179,14 +177,14 @@ interface ChatAIDraftRef {
179
177
  ### React 18 / React 16.8+ (useRef)
180
178
 
181
179
  ```tsx
182
- import React, { useRef } from 'react';
183
- import { ChatAIDraft } from 'hanbiro-react16-sdk/components';
180
+ import React, { useRef } from "react";
181
+ import { ChatAIDraft } from "hanbiro-react16-sdk/components";
184
182
 
185
183
  function MailComposer() {
186
184
  const chatRef = useRef<ChatAIDraft>(null);
187
185
 
188
186
  const handleOpenAI = () => {
189
- chatRef.current?.setAIContext('<p>Original email content...</p>');
187
+ chatRef.current?.setAIContext("<p>Original email content...</p>");
190
188
  };
191
189
 
192
190
  return (
@@ -208,10 +206,14 @@ let chatAIInstance = null;
208
206
 
209
207
  ReactDOM.render(
210
208
  React.createElement(HanbiroReact16SDK.ChatAIDraft, {
211
- ref: function(instance) { chatAIInstance = instance; },
212
- onApply: function(result) { /* ... */ },
209
+ ref: function (instance) {
210
+ chatAIInstance = instance;
211
+ },
212
+ onApply: function (result) {
213
+ /* ... */
214
+ },
213
215
  }),
214
- document.getElementById('chat-ai-container')
216
+ document.getElementById("chat-ai-container"),
215
217
  );
216
218
 
217
219
  // Call anytime — e.g. when opening the AI panel
@@ -226,8 +228,30 @@ function setEmailContext(html) {
226
228
 
227
229
  ## Development Commands
228
230
 
229
-
230
231
  - Run playground locally: `npm run dev`
231
232
  - Build library for production: `npm run build`
232
233
  - Build playground for production: `npm run build:playground`
233
234
  - Typecheck: `npm run test:typescript`
235
+
236
+ ## Development Workflow
237
+
238
+ Follow these steps when updating the library:
239
+
240
+ 1. **Finish coding**: Make your changes in the `src` directory.
241
+ 2. **Build**: Run the build command and ensure there are no errors.
242
+ ```bash
243
+ npm run build
244
+ ```
245
+ 3. **Commit**: Commit your changes to git.
246
+ 4. **Patch version**: Increment the version number.
247
+ ```bash
248
+ npm version patch
249
+ ```
250
+ 5. **Push**: Push the changes and tags to GitHub.
251
+ ```bash
252
+ git push origin main --follow-tags
253
+ ```
254
+ 6. **Publish**: Publish the new version to npm.
255
+ ```bash
256
+ npm publish
257
+ ```
@@ -9,6 +9,7 @@ interface SettingPopperProps {
9
9
  parentRef?: React.RefObject<HTMLDivElement>;
10
10
  }
11
11
  interface SettingPopperState {
12
+ languageOptions: LabelValue[];
12
13
  open: boolean;
13
14
  }
14
15
  declare class SettingPopper extends React.Component<SettingPopperProps, SettingPopperState> {
@@ -17,6 +18,7 @@ declare class SettingPopper extends React.Component<SettingPopperProps, SettingP
17
18
  constructor(props: SettingPopperProps);
18
19
  componentDidMount(): void;
19
20
  componentWillUnmount(): void;
21
+ getLanguageOptions: () => Promise<void>;
20
22
  handleClickOutside: (event: MouseEvent) => void;
21
23
  togglePopper: () => void;
22
24
  handleLangChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
@@ -1,6 +1,7 @@
1
1
  import { LabelValue } from '../../types';
2
2
  import * as React from "react";
3
- export interface AIPaneProps {
3
+ export interface ChatAIDraftProps {
4
+ defaultLang?: string;
4
5
  getEditorContent?: () => string;
5
6
  onApply: (params: {
6
7
  html: string;
@@ -26,9 +27,9 @@ interface AIPaneState {
26
27
  conversationId: string;
27
28
  originalEmail: string;
28
29
  }
29
- declare class ChatAIDraft extends React.Component<AIPaneProps, AIPaneState> implements ChatAIDraftRef {
30
+ declare class ChatAIDraft extends React.Component<ChatAIDraftProps, AIPaneState> implements ChatAIDraftRef {
30
31
  private rootRef;
31
- constructor(props: AIPaneProps);
32
+ constructor(props: ChatAIDraftProps);
32
33
  setAIContext: (html: string) => void;
33
34
  handleMessageChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
34
35
  handleSubmit: () => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const CNFlag: (props: React.SVGAttributes<SVGSVGElement>) => React.JSX.Element;
3
+ export default CNFlag;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const IDFlag: (props: React.SVGAttributes<SVGSVGElement>) => React.JSX.Element;
3
+ export default IDFlag;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const KRFlag: (props: React.SVGAttributes<SVGSVGElement>) => React.JSX.Element;
3
+ export default KRFlag;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const USFlag: (props: React.SVGAttributes<SVGSVGElement>) => React.JSX.Element;
3
+ export default USFlag;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const VNFlag: (props: React.SVGAttributes<SVGSVGElement>) => React.JSX.Element;
3
+ export default VNFlag;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ export type FlagCode = "cn" | "id" | "kr" | "us" | "vn";
3
+ export interface FlagProps extends React.SVGAttributes<SVGSVGElement> {
4
+ flagCode?: FlagCode;
5
+ }
6
+ declare const CountryFlag: (props: FlagProps) => React.JSX.Element | null;
7
+ export default CountryFlag;
@@ -1,5 +1,7 @@
1
- export { default as ChatAIDraft } from './ChatAIDraft';
1
+ export { default as ChatAIDraft, type ChatAIDraftRef } from './ChatAIDraft';
2
2
  export { default as LoadingCircular } from './LoadingCircular';
3
3
  export { default as LoadingContainer } from './LoadingContainer';
4
4
  export { default as Tooltip } from './Tooltip';
5
5
  export type { TooltipProps, TooltipPlacement } from './Tooltip';
6
+ export { default as CountryFlag } from './CountryFlag';
7
+ export type { FlagCode } from './CountryFlag';
@@ -0,0 +1,8 @@
1
+ import { FlagCode } from '../components/CountryFlag';
2
+ import { LabelValue } from '../types';
3
+
4
+ interface AILang extends LabelValue {
5
+ flagCode: FlagCode;
6
+ }
7
+ export declare const AI_LANG_FLAGS: AILang[];
8
+ export {};