@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/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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sampleapp.ai/sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for your components",
6
6
  "main": "./dist/index.umd.js",