@sampleapp.ai/sdk 1.0.1 → 1.0.4

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/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@sampleapp.ai/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
+ "type": "module",
4
5
  "description": "TypeScript SDK for your components",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.es.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.es.js",
12
+ "require": "./dist/index.umd.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
7
16
  "files": [
8
17
  "dist"
9
18
  ],
@@ -11,22 +20,32 @@
11
20
  "access": "public"
12
21
  },
13
22
  "scripts": {
14
- "build": "webpack --mode=production",
15
- "dev": "webpack --mode=development --watch",
23
+ "dev": "vite",
24
+ "build": "tsc && vite build",
25
+ "preview": "vite preview",
16
26
  "type-check": "tsc --noEmit",
17
27
  "prepublishOnly": "npm run build"
18
28
  },
19
29
  "devDependencies": {
20
30
  "@types/node": "^20.0.0",
21
- "ts-loader": "^9.4.0",
31
+ "@types/react": "^18.0.0",
32
+ "@types/react-dom": "^18.0.0",
33
+ "@vitejs/plugin-react": "^4.2.0",
34
+ "react": "^18.0.0",
35
+ "react-dom": "^18.0.0",
22
36
  "typescript": "^5.0.0",
23
- "webpack": "^5.88.0",
24
- "webpack-cli": "^5.1.0"
37
+ "vite": "^5.0.0",
38
+ "vite-plugin-dts": "^3.7.0"
39
+ },
40
+ "peerDependencies": {
41
+ "react": ">=16.8.0",
42
+ "react-dom": ">=16.8.0"
25
43
  },
26
44
  "keywords": [
27
45
  "sdk",
28
46
  "typescript",
29
- "components"
47
+ "components",
48
+ "react"
30
49
  ],
31
50
  "author": "Your Name",
32
51
  "license": "MIT",
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SampleApp=t():e.SampleApp=t()}(this,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ChatButton:()=>i,ModalSearchAndChat:()=>n,default:()=>o});class n{constructor(e,t){this.element=null,this.settings=e,this.init(t)}init(e){this.validateSettings(),this.createElement(e),this.bindEvents()}validateSettings(){if(!this.settings.baseSettings.apiKey)throw new Error("API Key is required");if(!this.settings.baseSettings.primaryBrandColor)throw new Error("Primary brand color is required")}createElement(e){this.element=document.createElement("div"),this.element.className=`modal-search-chat ${(null==e?void 0:e.className)||""}`,this.element.style.cssText="\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0,0,0,0.15);\n z-index: 1000;\n display: none;\n ",this.element.innerHTML=`\n <div style="padding: 20px; border-bottom: 1px solid #eee;">\n <h3 style="margin: 0; color: ${this.settings.baseSettings.primaryBrandColor};">\n ${this.settings.baseSettings.organizationDisplayName}\n </h3>\n </div>\n <div style="padding: 20px;">\n <input type="text" placeholder="Ask a question..." style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px;" />\n ${this.renderExampleQuestions()}\n </div>\n `,document.body.appendChild(this.element)}renderExampleQuestions(){var e;return(null===(e=this.settings.aiChatSettings)||void 0===e?void 0:e.exampleQuestions)?`\n <div style="margin-top: 15px;">\n <p style="margin: 0 0 10px 0; font-weight: bold;">Example questions:</p>\n ${this.settings.aiChatSettings.exampleQuestions.map(e=>`<button style="display: block; margin: 5px 0; padding: 8px; border: 1px solid #ddd; background: white; border-radius: 4px; cursor: pointer;">${e}</button>`).join("")}\n </div>\n `:""}bindEvents(){if(this.element){const e=this.element.querySelector("input");this.element.querySelectorAll("button").forEach(t=>{t.addEventListener("click",t=>{const n=t.target;e&&(e.value=n.textContent||"")})})}}show(){this.element&&(this.element.style.display="block")}hide(){this.element&&(this.element.style.display="none")}destroy(){this.element&&(this.element.remove(),this.element=null)}}class i{constructor(e,t){this.element=null,this.settings=e,this.init(t)}init(e){this.validateSettings(),this.createElement(e),this.bindEvents()}validateSettings(){if(!this.settings.baseSettings.apiKey)throw new Error("API Key is required")}createElement(e){var t;if(this.element=document.createElement("button"),this.element.className=`chat-button ${(null==e?void 0:e.className)||""}`,this.element.textContent="Ask AI",this.element.style.cssText=`\n position: fixed;\n bottom: 20px;\n right: 20px;\n background: ${this.settings.baseSettings.primaryBrandColor};\n color: white;\n border: none;\n border-radius: 50px;\n padding: 15px 20px;\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n z-index: 1000;\n transition: transform 0.2s, box-shadow 0.2s;\n `,null===(t=this.settings.aiChatSettings)||void 0===t?void 0:t.aiAssistantAvatar){const e=document.createElement("img");e.src=this.settings.aiChatSettings.aiAssistantAvatar,e.style.cssText="width: 20px; height: 20px; border-radius: 50%; margin-right: 8px; vertical-align: middle;",this.element.insertBefore(e,this.element.firstChild)}document.body.appendChild(this.element)}bindEvents(){this.element&&(this.element.addEventListener("mouseenter",()=>{this.element&&(this.element.style.transform="scale(1.05)",this.element.style.boxShadow="0 6px 20px rgba(0,0,0,0.2)")}),this.element.addEventListener("mouseleave",()=>{this.element&&(this.element.style.transform="scale(1)",this.element.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)")}),this.element.addEventListener("click",()=>{this.handleClick()}))}handleClick(){const e=new CustomEvent("chatButtonClick",{detail:{settings:this.settings}});document.dispatchEvent(e),console.log("Chat button clicked!",this.settings)}destroy(){this.element&&(this.element.remove(),this.element=null)}}const s=new class{constructor(){this.ModalSearchAndChat=(e,t)=>new n(e,t),this.ChatButton=(e,t)=>new i(e,t),this.version="1.0.0"}},o=s;return"undefined"!=typeof window&&(window.SampleApp=s),t})());