@sampleapp.ai/sdk 1.0.18 → 1.0.20
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/components/ChatButton.js +59 -0
- package/dist/components/ModalSearchAndChat.js +207 -0
- package/dist/index.es.js +1199 -1203
- package/dist/index.js +65 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from "react"; // Change this line
|
|
2
|
+
import * as ReactDOM from "react-dom/client"; // Change this line
|
|
3
|
+
import { ChatButton } from "./components/ChatButton";
|
|
4
|
+
import { ModalSearchAndChat } from "./components/ModalSearchAndChat";
|
|
5
|
+
// Export React components for direct JSX usage
|
|
6
|
+
export { ChatButton, ModalSearchAndChat };
|
|
7
|
+
// SDK class for loadScript programmatic usage
|
|
8
|
+
class SampleAppSDK {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.ModalSearchAndChat = (settings, container) => {
|
|
11
|
+
const targetContainer = container || document.body;
|
|
12
|
+
const modalContainer = document.createElement("div");
|
|
13
|
+
modalContainer.id = "sampleapp-modal-" + Date.now();
|
|
14
|
+
targetContainer.appendChild(modalContainer);
|
|
15
|
+
const root = ReactDOM.createRoot(modalContainer);
|
|
16
|
+
const component = React.createElement(ModalSearchAndChat, {
|
|
17
|
+
settings,
|
|
18
|
+
onClose: () => {
|
|
19
|
+
root.unmount();
|
|
20
|
+
modalContainer.remove();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
root.render(component);
|
|
24
|
+
return {
|
|
25
|
+
unmount: () => {
|
|
26
|
+
root.unmount();
|
|
27
|
+
modalContainer.remove();
|
|
28
|
+
},
|
|
29
|
+
show: () => {
|
|
30
|
+
modalContainer.style.display = "block";
|
|
31
|
+
},
|
|
32
|
+
hide: () => {
|
|
33
|
+
modalContainer.style.display = "none";
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
this.ChatButton = (settings, container) => {
|
|
38
|
+
const targetContainer = container || this.createButtonContainer();
|
|
39
|
+
const root = ReactDOM.createRoot(targetContainer);
|
|
40
|
+
const component = React.createElement(ChatButton, { settings });
|
|
41
|
+
root.render(component);
|
|
42
|
+
return {
|
|
43
|
+
unmount: () => {
|
|
44
|
+
root.unmount();
|
|
45
|
+
targetContainer.remove();
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
createButtonContainer() {
|
|
51
|
+
const container = document.createElement("div");
|
|
52
|
+
container.id = "sampleapp-button-" + Date.now();
|
|
53
|
+
document.body.appendChild(container);
|
|
54
|
+
return container;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Create singleton instance
|
|
58
|
+
const sdk = new SampleAppSDK();
|
|
59
|
+
// Default export for both usage patterns
|
|
60
|
+
export default sdk;
|
|
61
|
+
// For UMD builds, also attach individual methods to the default export
|
|
62
|
+
// This ensures they're accessible as SampleApp.ChatButton, etc.
|
|
63
|
+
if (typeof window !== "undefined") {
|
|
64
|
+
window.SampleApp = sdk;
|
|
65
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|