@snf/access-qa-bot 0.2.0 → 0.3.0

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.
Files changed (43) hide show
  1. package/README.md +5 -4
  2. package/build/static/css/main.css +1 -1
  3. package/build/static/css/main.css.map +1 -1
  4. package/build/static/js/main.js +1 -1
  5. package/build/static/js/main.js.LICENSE.txt +0 -10
  6. package/build/static/js/main.js.map +1 -1
  7. package/dist/access-qa-bot.js +1 -55
  8. package/dist/access-qa-bot.js.map +1 -1
  9. package/dist/access-qa-bot.standalone.js +4 -22
  10. package/dist/access-qa-bot.standalone.js.map +1 -1
  11. package/dist/access-qa-bot.umd.cjs +1 -55
  12. package/dist/access-qa-bot.umd.cjs.map +1 -1
  13. package/package.json +2 -2
  14. package/dist/access-qa-bot.umd.js +0 -56
  15. package/dist/access-qa-bot.umd.js.map +0 -1
  16. package/dist/index.esm.js +0 -56
  17. package/dist/index.esm.js.map +0 -1
  18. package/dist/index.js +0 -56
  19. package/dist/index.js.map +0 -1
  20. package/dist/index.umd.js +0 -56
  21. package/dist/index.umd.js.map +0 -1
  22. package/dist/preact.esm.js +0 -2
  23. package/dist/preact.esm.js.map +0 -1
  24. package/dist/preact.js +0 -2
  25. package/dist/preact.js.map +0 -1
  26. package/dist/preact.umd.js +0 -2
  27. package/dist/preact.umd.js.map +0 -1
  28. package/dist/qa-bot-element.js +0 -241
  29. package/dist/qa-bot-element.js.map +0 -1
  30. package/dist/qa-bot-element.min.js +0 -2
  31. package/dist/qa-bot-element.min.js.map +0 -1
  32. package/dist/qa-bot-standalone.js +0 -34372
  33. package/dist/qa-bot-standalone.js.map +0 -1
  34. package/dist/qa-bot-standalone.min.js +0 -105
  35. package/dist/qa-bot-standalone.min.js.map +0 -1
  36. package/dist/web-component.js +0 -56
  37. package/dist/web-component.js.map +0 -1
  38. package/dist/web-components.js +0 -228
  39. package/dist/web-components.js.map +0 -1
  40. package/dist/web-components.min.js +0 -2
  41. package/dist/web-components.min.js.map +0 -1
  42. package/dist/web-components.umd.js +0 -239
  43. package/dist/web-components.umd.js.map +0 -1
@@ -1,228 +0,0 @@
1
- // Define the AccessQABot web component that uses the React QABot component
2
- class AccessQABot extends HTMLElement {
3
- constructor() {
4
- super();
5
- this.attachShadow({
6
- mode: 'open'
7
- });
8
-
9
- // Reference to cleanup function
10
- this.cleanup = null;
11
-
12
- // Observe attribute changes
13
- this.observedAttributes = ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];
14
- }
15
-
16
- // Properties that reflect to attributes
17
- get isLoggedIn() {
18
- return this.hasAttribute('is-logged-in');
19
- }
20
- set isLoggedIn(value) {
21
- if (value) {
22
- this.setAttribute('is-logged-in', '');
23
- } else {
24
- this.removeAttribute('is-logged-in');
25
- }
26
- }
27
- get isOpen() {
28
- return this.hasAttribute('is-open');
29
- }
30
- set isOpen(value) {
31
- if (value) {
32
- this.setAttribute('is-open', '');
33
- } else {
34
- this.removeAttribute('is-open');
35
- }
36
- }
37
- get embedded() {
38
- return this.hasAttribute('embedded');
39
- }
40
- set embedded(value) {
41
- if (value) {
42
- this.setAttribute('embedded', '');
43
- } else {
44
- this.removeAttribute('embedded');
45
- }
46
- }
47
- get welcome() {
48
- return this.getAttribute('welcome');
49
- }
50
- set welcome(value) {
51
- this.setAttribute('welcome', value);
52
- }
53
- get prompt() {
54
- return this.getAttribute('prompt');
55
- }
56
- set prompt(value) {
57
- this.setAttribute('prompt', value);
58
- }
59
- get apiKey() {
60
- return this.getAttribute('api-key');
61
- }
62
- set apiKey(value) {
63
- this.setAttribute('api-key', value);
64
- }
65
-
66
- // Lifecycle: component added to DOM
67
- connectedCallback() {
68
- console.log('AccessQABot component added to the DOM');
69
- this.render();
70
- this.loadQABot();
71
- }
72
-
73
- // Lifecycle: component removed from DOM
74
- disconnectedCallback() {
75
- console.log('AccessQABot component removed from the DOM');
76
- if (this.cleanup) {
77
- this.cleanup();
78
- this.cleanup = null;
79
- }
80
- }
81
-
82
- // Lifecycle: attributes changed
83
- attributeChangedCallback(name, oldValue, newValue) {
84
- if (oldValue !== newValue) {
85
- this.render();
86
- // Need to reload QA Bot when attributes change
87
- this.loadQABot();
88
- }
89
- }
90
-
91
- // Static list of observed attributes
92
- static get observedAttributes() {
93
- return ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];
94
- }
95
-
96
- // Render the component's HTML and CSS
97
- render() {
98
- // Set up container for React component
99
- this.shadowRoot.innerHTML = `
100
- <style>
101
- :host {
102
- display: block;
103
- min-height: 50px;
104
- }
105
- .react-container {
106
- width: 100%;
107
- height: 100%;
108
- }
109
- /* CSS for loading state */
110
- .loading {
111
- display: flex;
112
- align-items: center;
113
- justify-content: center;
114
- padding: 20px;
115
- color: #666;
116
- font-style: italic;
117
- }
118
- </style>
119
- <div class="react-container">
120
- <div class="loading">Loading ACCESS QA Bot...</div>
121
- </div>
122
- `;
123
- }
124
-
125
- // Load the React QA Bot into the shadow DOM
126
- loadQABot() {
127
- // If we have an existing instance, clean it up first
128
- if (this.cleanup) {
129
- this.cleanup();
130
- this.cleanup = null;
131
- }
132
-
133
- // Get the container for the React component
134
- const container = this.shadowRoot.querySelector('.react-container');
135
- if (!container) return;
136
-
137
- // Check if the qAndATool function is available
138
- if (typeof window.accessQABot === 'undefined') {
139
- // Load the UMD script
140
- this.loadScript('./dist/index.umd.js', () => {
141
- this.initializeQABot(container);
142
- }, error => {
143
- this.showError(container, error);
144
- });
145
- } else {
146
- // Initialize immediately if already loaded
147
- this.initializeQABot(container);
148
- }
149
- }
150
-
151
- // Helper method to load a script
152
- loadScript(src, onLoad, onError) {
153
- const script = document.createElement('script');
154
- script.src = src;
155
- script.onload = onLoad;
156
- script.onerror = () => onError(new Error(`Failed to load script: ${src}`));
157
- document.head.appendChild(script);
158
- }
159
-
160
- // Initialize the QA Bot using the global UMD export
161
- initializeQABot(container) {
162
- try {
163
- // Get the qAndATool function from the global variable
164
- // Note: UMD exports can be structured in multiple ways, so we need to check all possibilities
165
- let qAndATool;
166
- if (typeof window.accessQABot === 'function') {
167
- // Direct function export
168
- qAndATool = window.accessQABot;
169
- } else if (window.accessQABot && typeof window.accessQABot.default === 'function') {
170
- // Default export in an object
171
- qAndATool = window.accessQABot.default;
172
- } else if (window.accessQABot && typeof window.accessQABot.qAndATool === 'function') {
173
- // Named export in an object
174
- qAndATool = window.accessQABot.qAndATool;
175
- } else {
176
- throw new Error('QA Bot library loaded but function not found in the expected format');
177
- }
178
-
179
- // Configure the QA Bot
180
- const config = {
181
- target: container,
182
- isLoggedIn: this.isLoggedIn,
183
- isOpen: this.isOpen,
184
- embedded: this.embedded,
185
- apiKey: this.apiKey
186
- };
187
-
188
- // Add optional props if they exist
189
- if (this.welcome) config.welcome = this.welcome;
190
- if (this.prompt) config.prompt = this.prompt;
191
-
192
- // Create the QA Bot instance
193
- this.cleanup = qAndATool(config);
194
- } catch (error) {
195
- this.showError(container, error);
196
- }
197
- }
198
-
199
- // Show an error message in the container
200
- showError(container, error) {
201
- console.error('Failed to load QA Bot component:', error);
202
- container.innerHTML = `
203
- <div style="color: red; padding: 10px; border: 1px solid #ddd; border-radius: 4px;">
204
- <strong>Error loading ACCESS QA Bot</strong>
205
- <p>Make sure you've built the React component with: npm run build:lib</p>
206
- <p style="font-size: 12px; margin-top: 10px;">Error: ${error.message}</p>
207
- </div>
208
- `;
209
- }
210
- }
211
-
212
- // Register the component if it hasn't been registered yet
213
- if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {
214
- window.customElements.define('access-qa-bot', AccessQABot);
215
- }
216
-
217
- // Default export for simpler importing
218
- var index = {
219
- register() {
220
- // This method ensures components are registered
221
- if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {
222
- window.customElements.define('access-qa-bot', AccessQABot);
223
- }
224
- }
225
- };
226
-
227
- export { AccessQABot, index as default };
228
- //# sourceMappingURL=web-components.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-components.js","sources":["../src/web-components/AccessQABot.js","../src/web-components/index.js"],"sourcesContent":["// Define the AccessQABot web component that uses the React QABot component\nclass AccessQABot extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n\n // Reference to cleanup function\n this.cleanup = null;\n\n // Observe attribute changes\n this.observedAttributes = ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];\n }\n\n // Properties that reflect to attributes\n get isLoggedIn() {\n return this.hasAttribute('is-logged-in');\n }\n\n set isLoggedIn(value) {\n if (value) {\n this.setAttribute('is-logged-in', '');\n } else {\n this.removeAttribute('is-logged-in');\n }\n }\n\n get isOpen() {\n return this.hasAttribute('is-open');\n }\n\n set isOpen(value) {\n if (value) {\n this.setAttribute('is-open', '');\n } else {\n this.removeAttribute('is-open');\n }\n }\n\n get embedded() {\n return this.hasAttribute('embedded');\n }\n\n set embedded(value) {\n if (value) {\n this.setAttribute('embedded', '');\n } else {\n this.removeAttribute('embedded');\n }\n }\n\n get welcome() {\n return this.getAttribute('welcome');\n }\n\n set welcome(value) {\n this.setAttribute('welcome', value);\n }\n\n get prompt() {\n return this.getAttribute('prompt');\n }\n\n set prompt(value) {\n this.setAttribute('prompt', value);\n }\n\n get apiKey() {\n return this.getAttribute('api-key');\n }\n\n set apiKey(value) {\n this.setAttribute('api-key', value);\n }\n\n // Lifecycle: component added to DOM\n connectedCallback() {\n console.log('AccessQABot component added to the DOM');\n this.render();\n this.loadQABot();\n }\n\n // Lifecycle: component removed from DOM\n disconnectedCallback() {\n console.log('AccessQABot component removed from the DOM');\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n }\n\n // Lifecycle: attributes changed\n attributeChangedCallback(name, oldValue, newValue) {\n if (oldValue !== newValue) {\n this.render();\n // Need to reload QA Bot when attributes change\n this.loadQABot();\n }\n }\n\n // Static list of observed attributes\n static get observedAttributes() {\n return ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];\n }\n\n // Render the component's HTML and CSS\n render() {\n // Set up container for React component\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n display: block;\n min-height: 50px;\n }\n .react-container {\n width: 100%;\n height: 100%;\n }\n /* CSS for loading state */\n .loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: #666;\n font-style: italic;\n }\n </style>\n <div class=\"react-container\">\n <div class=\"loading\">Loading ACCESS QA Bot...</div>\n </div>\n `;\n }\n\n // Load the React QA Bot into the shadow DOM\n loadQABot() {\n // If we have an existing instance, clean it up first\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n\n // Get the container for the React component\n const container = this.shadowRoot.querySelector('.react-container');\n if (!container) return;\n\n // Check if the qAndATool function is available\n if (typeof window.accessQABot === 'undefined') {\n // Load the UMD script\n this.loadScript('./dist/index.umd.js', () => {\n this.initializeQABot(container);\n }, (error) => {\n this.showError(container, error);\n });\n } else {\n // Initialize immediately if already loaded\n this.initializeQABot(container);\n }\n }\n\n // Helper method to load a script\n loadScript(src, onLoad, onError) {\n const script = document.createElement('script');\n script.src = src;\n script.onload = onLoad;\n script.onerror = () => onError(new Error(`Failed to load script: ${src}`));\n document.head.appendChild(script);\n }\n\n // Initialize the QA Bot using the global UMD export\n initializeQABot(container) {\n try {\n // Get the qAndATool function from the global variable\n // Note: UMD exports can be structured in multiple ways, so we need to check all possibilities\n let qAndATool;\n\n if (typeof window.accessQABot === 'function') {\n // Direct function export\n qAndATool = window.accessQABot;\n } else if (window.accessQABot && typeof window.accessQABot.default === 'function') {\n // Default export in an object\n qAndATool = window.accessQABot.default;\n } else if (window.accessQABot && typeof window.accessQABot.qAndATool === 'function') {\n // Named export in an object\n qAndATool = window.accessQABot.qAndATool;\n } else {\n throw new Error('QA Bot library loaded but function not found in the expected format');\n }\n\n // Configure the QA Bot\n const config = {\n target: container,\n isLoggedIn: this.isLoggedIn,\n isOpen: this.isOpen,\n embedded: this.embedded,\n apiKey: this.apiKey\n };\n\n // Add optional props if they exist\n if (this.welcome) config.welcome = this.welcome;\n if (this.prompt) config.prompt = this.prompt;\n\n // Create the QA Bot instance\n this.cleanup = qAndATool(config);\n } catch (error) {\n this.showError(container, error);\n }\n }\n\n // Show an error message in the container\n showError(container, error) {\n console.error('Failed to load QA Bot component:', error);\n container.innerHTML = `\n <div style=\"color: red; padding: 10px; border: 1px solid #ddd; border-radius: 4px;\">\n <strong>Error loading ACCESS QA Bot</strong>\n <p>Make sure you've built the React component with: npm run build:lib</p>\n <p style=\"font-size: 12px; margin-top: 10px;\">Error: ${error.message}</p>\n </div>\n `;\n }\n}\n\n// Export the class\nexport default AccessQABot;","import AccessQABot from './AccessQABot';\n\n// Register the component if it hasn't been registered yet\nif (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {\n window.customElements.define('access-qa-bot', AccessQABot);\n}\n\n// Export the component class for users who want to extend it\nexport { AccessQABot };\n\n// Default export for simpler importing\nexport default {\n register() {\n // This method ensures components are registered\n if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {\n window.customElements.define('access-qa-bot', AccessQABot);\n }\n }\n};"],"names":["AccessQABot","HTMLElement","constructor","attachShadow","mode","cleanup","observedAttributes","isLoggedIn","hasAttribute","value","setAttribute","removeAttribute","isOpen","embedded","welcome","getAttribute","prompt","apiKey","connectedCallback","console","log","render","loadQABot","disconnectedCallback","attributeChangedCallback","name","oldValue","newValue","shadowRoot","innerHTML","container","querySelector","window","accessQABot","loadScript","initializeQABot","error","showError","src","onLoad","onError","script","document","createElement","onload","onerror","Error","head","appendChild","qAndATool","default","config","target","message","customElements","get","define","register"],"mappings":"AAAA;AACA,MAAMA,WAAW,SAASC,WAAW,CAAC;AAClCC,EAAAA,WAAWA,GAAG;AACV,IAAA,KAAK,EAAE;IACP,IAAI,CAACC,YAAY,CAAC;AAAEC,MAAAA,IAAI,EAAE;AAAO,KAAC,CAAC;;AAEnC;IACA,IAAI,CAACC,OAAO,GAAG,IAAI;;AAEnB;AACA,IAAA,IAAI,CAACC,kBAAkB,GAAG,CAAC,cAA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,OAAOrB,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACsB,cAAc,CAACC,GAAG,CAAC,eAAe,CAAC,EAAE;EAC9EvB,MAAM,CAACsB,cAAc,CAACE,MAAM,CAAC,eAAe,EAAExD,WAAW,CAAC;AAC9D;;AAKA;AACA,YAAe;AACXyD,EAAAA,QAAQA,GAAG;AACP;AACA,IAAA,IAAI,OAAOzB,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACsB,cAAc,CAACC,GAAG,CAAC,eAAe,CAAC,EAAE;MAC9EvB,MAAM,CAACsB,cAAc,CAACE,MAAM,CAAC,eAAe,EAAExD,WAAW,CAAC;AAC9D;AACJ;AACJ,CAAC;;;;"}
@@ -1,2 +0,0 @@
1
- var AccessWebComponents=function(e){"use strict";class t extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.cleanup=null,this.observedAttributes=["is-logged-in","is-open","embedded","welcome","prompt","api-key"]}get isLoggedIn(){return this.hasAttribute("is-logged-in")}set isLoggedIn(e){e?this.setAttribute("is-logged-in",""):this.removeAttribute("is-logged-in")}get isOpen(){return this.hasAttribute("is-open")}set isOpen(e){e?this.setAttribute("is-open",""):this.removeAttribute("is-open")}get embedded(){return this.hasAttribute("embedded")}set embedded(e){e?this.setAttribute("embedded",""):this.removeAttribute("embedded")}get welcome(){return this.getAttribute("welcome")}set welcome(e){this.setAttribute("welcome",e)}get prompt(){return this.getAttribute("prompt")}set prompt(e){this.setAttribute("prompt",e)}get apiKey(){return this.getAttribute("api-key")}set apiKey(e){this.setAttribute("api-key",e)}connectedCallback(){console.log("AccessQABot component added to the DOM"),this.render(),this.loadQABot()}disconnectedCallback(){console.log("AccessQABot component removed from the DOM"),this.cleanup&&(this.cleanup(),this.cleanup=null)}attributeChangedCallback(e,t,o){t!==o&&(this.render(),this.loadQABot())}static get observedAttributes(){return["is-logged-in","is-open","embedded","welcome","prompt","api-key"]}render(){this.shadowRoot.innerHTML='\n <style>\n :host {\n display: block;\n min-height: 50px;\n }\n .react-container {\n width: 100%;\n height: 100%;\n }\n /* CSS for loading state */\n .loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: #666;\n font-style: italic;\n }\n </style>\n <div class="react-container">\n <div class="loading">Loading ACCESS QA Bot...</div>\n </div>\n '}loadQABot(){this.cleanup&&(this.cleanup(),this.cleanup=null);const e=this.shadowRoot.querySelector(".react-container");e&&(void 0===window.accessQABot?this.loadScript("./dist/index.umd.js",(()=>{this.initializeQABot(e)}),(t=>{this.showError(e,t)})):this.initializeQABot(e))}loadScript(e,t,o){const i=document.createElement("script");i.src=e,i.onload=t,i.onerror=()=>o(new Error(`Failed to load script: ${e}`)),document.head.appendChild(i)}initializeQABot(e){try{let t;if("function"==typeof window.accessQABot)t=window.accessQABot;else if(window.accessQABot&&"function"==typeof window.accessQABot.default)t=window.accessQABot.default;else{if(!window.accessQABot||"function"!=typeof window.accessQABot.qAndATool)throw new Error("QA Bot library loaded but function not found in the expected format");t=window.accessQABot.qAndATool}const o={target:e,isLoggedIn:this.isLoggedIn,isOpen:this.isOpen,embedded:this.embedded,apiKey:this.apiKey};this.welcome&&(o.welcome=this.welcome),this.prompt&&(o.prompt=this.prompt),this.cleanup=t(o)}catch(t){this.showError(e,t)}}showError(e,t){console.error("Failed to load QA Bot component:",t),e.innerHTML=`\n <div style="color: red; padding: 10px; border: 1px solid #ddd; border-radius: 4px;">\n <strong>Error loading ACCESS QA Bot</strong>\n <p>Make sure you've built the React component with: npm run build:lib</p>\n <p style="font-size: 12px; margin-top: 10px;">Error: ${t.message}</p>\n </div>\n `}}"undefined"==typeof window||window.customElements.get("access-qa-bot")||window.customElements.define("access-qa-bot",t);var o={register(){"undefined"==typeof window||window.customElements.get("access-qa-bot")||window.customElements.define("access-qa-bot",t)}};return e.AccessQABot=t,e.default=o,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
2
- //# sourceMappingURL=web-components.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-components.min.js","sources":["../src/web-components/AccessQABot.js","../src/web-components/index.js"],"sourcesContent":["// Define the AccessQABot web component that uses the React QABot component\nclass AccessQABot extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n\n // Reference to cleanup function\n this.cleanup = null;\n\n // Observe attribute changes\n this.observedAttributes = ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];\n }\n\n // Properties that reflect to attributes\n get isLoggedIn() {\n return this.hasAttribute('is-logged-in');\n }\n\n set isLoggedIn(value) {\n if (value) {\n this.setAttribute('is-logged-in', '');\n } else {\n this.removeAttribute('is-logged-in');\n }\n }\n\n get isOpen() {\n return this.hasAttribute('is-open');\n }\n\n set isOpen(value) {\n if (value) {\n this.setAttribute('is-open', '');\n } else {\n this.removeAttribute('is-open');\n }\n }\n\n get embedded() {\n return this.hasAttribute('embedded');\n }\n\n set embedded(value) {\n if (value) {\n this.setAttribute('embedded', '');\n } else {\n this.removeAttribute('embedded');\n }\n }\n\n get welcome() {\n return this.getAttribute('welcome');\n }\n\n set welcome(value) {\n this.setAttribute('welcome', value);\n }\n\n get prompt() {\n return this.getAttribute('prompt');\n }\n\n set prompt(value) {\n this.setAttribute('prompt', value);\n }\n\n get apiKey() {\n return this.getAttribute('api-key');\n }\n\n set apiKey(value) {\n this.setAttribute('api-key', value);\n }\n\n // Lifecycle: component added to DOM\n connectedCallback() {\n console.log('AccessQABot component added to the DOM');\n this.render();\n this.loadQABot();\n }\n\n // Lifecycle: component removed from DOM\n disconnectedCallback() {\n console.log('AccessQABot component removed from the DOM');\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n }\n\n // Lifecycle: attributes changed\n attributeChangedCallback(name, oldValue, newValue) {\n if (oldValue !== newValue) {\n this.render();\n // Need to reload QA Bot when attributes change\n this.loadQABot();\n }\n }\n\n // Static list of observed attributes\n static get observedAttributes() {\n return ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];\n }\n\n // Render the component's HTML and CSS\n render() {\n // Set up container for React component\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n display: block;\n min-height: 50px;\n }\n .react-container {\n width: 100%;\n height: 100%;\n }\n /* CSS for loading state */\n .loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: #666;\n font-style: italic;\n }\n </style>\n <div class=\"react-container\">\n <div class=\"loading\">Loading ACCESS QA Bot...</div>\n </div>\n `;\n }\n\n // Load the React QA Bot into the shadow DOM\n loadQABot() {\n // If we have an existing instance, clean it up first\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n\n // Get the container for the React component\n const container = this.shadowRoot.querySelector('.react-container');\n if (!container) return;\n\n // Check if the qAndATool function is available\n if (typeof window.accessQABot === 'undefined') {\n // Load the UMD script\n this.loadScript('./dist/index.umd.js', () => {\n this.initializeQABot(container);\n }, (error) => {\n this.showError(container, error);\n });\n } else {\n // Initialize immediately if already loaded\n this.initializeQABot(container);\n }\n }\n\n // Helper method to load a script\n loadScript(src, onLoad, onError) {\n const script = document.createElement('script');\n script.src = src;\n script.onload = onLoad;\n script.onerror = () => onError(new Error(`Failed to load script: ${src}`));\n document.head.appendChild(script);\n }\n\n // Initialize the QA Bot using the global UMD export\n initializeQABot(container) {\n try {\n // Get the qAndATool function from the global variable\n // Note: UMD exports can be structured in multiple ways, so we need to check all possibilities\n let qAndATool;\n\n if (typeof window.accessQABot === 'function') {\n // Direct function export\n qAndATool = window.accessQABot;\n } else if (window.accessQABot && typeof window.accessQABot.default === 'function') {\n // Default export in an object\n qAndATool = window.accessQABot.default;\n } else if (window.accessQABot && typeof window.accessQABot.qAndATool === 'function') {\n // Named export in an object\n qAndATool = window.accessQABot.qAndATool;\n } else {\n throw new Error('QA Bot library loaded but function not found in the expected format');\n }\n\n // Configure the QA Bot\n const config = {\n target: container,\n isLoggedIn: this.isLoggedIn,\n isOpen: this.isOpen,\n embedded: this.embedded,\n apiKey: this.apiKey\n };\n\n // Add optional props if they exist\n if (this.welcome) config.welcome = this.welcome;\n if (this.prompt) config.prompt = this.prompt;\n\n // Create the QA Bot instance\n this.cleanup = qAndATool(config);\n } catch (error) {\n this.showError(container, error);\n }\n }\n\n // Show an error message in the container\n showError(container, error) {\n console.error('Failed to load QA Bot component:', error);\n container.innerHTML = `\n <div style=\"color: red; padding: 10px; border: 1px solid #ddd; border-radius: 4px;\">\n <strong>Error loading ACCESS QA Bot</strong>\n <p>Make sure you've built the React component with: npm run build:lib</p>\n <p style=\"font-size: 12px; margin-top: 10px;\">Error: ${error.message}</p>\n </div>\n `;\n }\n}\n\n// Export the class\nexport default AccessQABot;","import AccessQABot from './AccessQABot';\n\n// Register the component if it hasn't been registered yet\nif (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {\n window.customElements.define('access-qa-bot', AccessQABot);\n}\n\n// Export the component class for users who want to extend it\nexport { AccessQABot };\n\n// Default export for simpler importing\nexport default {\n register() {\n // This method ensures components are registered\n if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {\n window.customElements.define('access-qa-bot', AccessQABot);\n }\n }\n};"],"names":["AccessQABot","HTMLElement","constructor","super","this","attachShadow","mode","cleanup","observedAttributes","isLoggedIn","hasAttribute","value","setAttribute","removeAttribute","isOpen","embedded","welcome","getAttribute","prompt","apiKey","connectedCallback","console","log","render","loadQABot","disconnectedCallback","attributeChangedCallback","name","oldValue","newValue","shadowRoot","innerHTML","container","querySelector","window","accessQABot","loadScript","initializeQABot","error","showError","src","onLoad","onError","script","document","createElement","onload","onerror","Error","head","appendChild","qAndATool","default","config","target","message","customElements","get","define","index","register"],"mappings":"iDACA,MAAMA,UAAoBC,YACtBC,WAAAA,GACIC,QACAC,KAAKC,aAAa,CAAEC,KAAM,SAG1BF,KAAKG,QAAU,KAGfH,KAAKI,mBAAqB,CAAC,eAAgB,UAAW,WAAY,UAAW,SAAU,UAC3F,CAGA,cAAIC,GACA,OAAOL,KAAKM,aAAa,eAC7B,CAEA,cAAID,CAAWE,GACPA,EACAP,KA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eof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AccessWebComponents = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- // Define the AccessQABot web component that uses the React QABot component
8
- class AccessQABot extends HTMLElement {
9
- constructor() {
10
- super();
11
- this.attachShadow({
12
- mode: 'open'
13
- });
14
-
15
- // Reference to cleanup function
16
- this.cleanup = null;
17
-
18
- // Observe attribute changes
19
- this.observedAttributes = ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];
20
- }
21
-
22
- // Properties that reflect to attributes
23
- get isLoggedIn() {
24
- return this.hasAttribute('is-logged-in');
25
- }
26
- set isLoggedIn(value) {
27
- if (value) {
28
- this.setAttribute('is-logged-in', '');
29
- } else {
30
- this.removeAttribute('is-logged-in');
31
- }
32
- }
33
- get isOpen() {
34
- return this.hasAttribute('is-open');
35
- }
36
- set isOpen(value) {
37
- if (value) {
38
- this.setAttribute('is-open', '');
39
- } else {
40
- this.removeAttribute('is-open');
41
- }
42
- }
43
- get embedded() {
44
- return this.hasAttribute('embedded');
45
- }
46
- set embedded(value) {
47
- if (value) {
48
- this.setAttribute('embedded', '');
49
- } else {
50
- this.removeAttribute('embedded');
51
- }
52
- }
53
- get welcome() {
54
- return this.getAttribute('welcome');
55
- }
56
- set welcome(value) {
57
- this.setAttribute('welcome', value);
58
- }
59
- get prompt() {
60
- return this.getAttribute('prompt');
61
- }
62
- set prompt(value) {
63
- this.setAttribute('prompt', value);
64
- }
65
- get apiKey() {
66
- return this.getAttribute('api-key');
67
- }
68
- set apiKey(value) {
69
- this.setAttribute('api-key', value);
70
- }
71
-
72
- // Lifecycle: component added to DOM
73
- connectedCallback() {
74
- console.log('AccessQABot component added to the DOM');
75
- this.render();
76
- this.loadQABot();
77
- }
78
-
79
- // Lifecycle: component removed from DOM
80
- disconnectedCallback() {
81
- console.log('AccessQABot component removed from the DOM');
82
- if (this.cleanup) {
83
- this.cleanup();
84
- this.cleanup = null;
85
- }
86
- }
87
-
88
- // Lifecycle: attributes changed
89
- attributeChangedCallback(name, oldValue, newValue) {
90
- if (oldValue !== newValue) {
91
- this.render();
92
- // Need to reload QA Bot when attributes change
93
- this.loadQABot();
94
- }
95
- }
96
-
97
- // Static list of observed attributes
98
- static get observedAttributes() {
99
- return ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];
100
- }
101
-
102
- // Render the component's HTML and CSS
103
- render() {
104
- // Set up container for React component
105
- this.shadowRoot.innerHTML = `
106
- <style>
107
- :host {
108
- display: block;
109
- min-height: 50px;
110
- }
111
- .react-container {
112
- width: 100%;
113
- height: 100%;
114
- }
115
- /* CSS for loading state */
116
- .loading {
117
- display: flex;
118
- align-items: center;
119
- justify-content: center;
120
- padding: 20px;
121
- color: #666;
122
- font-style: italic;
123
- }
124
- </style>
125
- <div class="react-container">
126
- <div class="loading">Loading ACCESS QA Bot...</div>
127
- </div>
128
- `;
129
- }
130
-
131
- // Load the React QA Bot into the shadow DOM
132
- loadQABot() {
133
- // If we have an existing instance, clean it up first
134
- if (this.cleanup) {
135
- this.cleanup();
136
- this.cleanup = null;
137
- }
138
-
139
- // Get the container for the React component
140
- const container = this.shadowRoot.querySelector('.react-container');
141
- if (!container) return;
142
-
143
- // Check if the qAndATool function is available
144
- if (typeof window.accessQABot === 'undefined') {
145
- // Load the UMD script
146
- this.loadScript('./dist/index.umd.js', () => {
147
- this.initializeQABot(container);
148
- }, error => {
149
- this.showError(container, error);
150
- });
151
- } else {
152
- // Initialize immediately if already loaded
153
- this.initializeQABot(container);
154
- }
155
- }
156
-
157
- // Helper method to load a script
158
- loadScript(src, onLoad, onError) {
159
- const script = document.createElement('script');
160
- script.src = src;
161
- script.onload = onLoad;
162
- script.onerror = () => onError(new Error(`Failed to load script: ${src}`));
163
- document.head.appendChild(script);
164
- }
165
-
166
- // Initialize the QA Bot using the global UMD export
167
- initializeQABot(container) {
168
- try {
169
- // Get the qAndATool function from the global variable
170
- // Note: UMD exports can be structured in multiple ways, so we need to check all possibilities
171
- let qAndATool;
172
- if (typeof window.accessQABot === 'function') {
173
- // Direct function export
174
- qAndATool = window.accessQABot;
175
- } else if (window.accessQABot && typeof window.accessQABot.default === 'function') {
176
- // Default export in an object
177
- qAndATool = window.accessQABot.default;
178
- } else if (window.accessQABot && typeof window.accessQABot.qAndATool === 'function') {
179
- // Named export in an object
180
- qAndATool = window.accessQABot.qAndATool;
181
- } else {
182
- throw new Error('QA Bot library loaded but function not found in the expected format');
183
- }
184
-
185
- // Configure the QA Bot
186
- const config = {
187
- target: container,
188
- isLoggedIn: this.isLoggedIn,
189
- isOpen: this.isOpen,
190
- embedded: this.embedded,
191
- apiKey: this.apiKey
192
- };
193
-
194
- // Add optional props if they exist
195
- if (this.welcome) config.welcome = this.welcome;
196
- if (this.prompt) config.prompt = this.prompt;
197
-
198
- // Create the QA Bot instance
199
- this.cleanup = qAndATool(config);
200
- } catch (error) {
201
- this.showError(container, error);
202
- }
203
- }
204
-
205
- // Show an error message in the container
206
- showError(container, error) {
207
- console.error('Failed to load QA Bot component:', error);
208
- container.innerHTML = `
209
- <div style="color: red; padding: 10px; border: 1px solid #ddd; border-radius: 4px;">
210
- <strong>Error loading ACCESS QA Bot</strong>
211
- <p>Make sure you've built the React component with: npm run build:lib</p>
212
- <p style="font-size: 12px; margin-top: 10px;">Error: ${error.message}</p>
213
- </div>
214
- `;
215
- }
216
- }
217
-
218
- // Register the component if it hasn't been registered yet
219
- if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {
220
- window.customElements.define('access-qa-bot', AccessQABot);
221
- }
222
-
223
- // Default export for simpler importing
224
- var index = {
225
- register() {
226
- // This method ensures components are registered
227
- if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {
228
- window.customElements.define('access-qa-bot', AccessQABot);
229
- }
230
- }
231
- };
232
-
233
- exports.AccessQABot = AccessQABot;
234
- exports.default = index;
235
-
236
- Object.defineProperty(exports, '__esModule', { value: true });
237
-
238
- }));
239
- //# sourceMappingURL=web-components.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-components.umd.js","sources":["../src/web-components/AccessQABot.js","../src/web-components/index.js"],"sourcesContent":["// Define the AccessQABot web component that uses the React QABot component\nclass AccessQABot extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n\n // Reference to cleanup function\n this.cleanup = null;\n\n // Observe attribute changes\n this.observedAttributes = ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];\n }\n\n // Properties that reflect to attributes\n get isLoggedIn() {\n return this.hasAttribute('is-logged-in');\n }\n\n set isLoggedIn(value) {\n if (value) {\n this.setAttribute('is-logged-in', '');\n } else {\n this.removeAttribute('is-logged-in');\n }\n }\n\n get isOpen() {\n return this.hasAttribute('is-open');\n }\n\n set isOpen(value) {\n if (value) {\n this.setAttribute('is-open', '');\n } else {\n this.removeAttribute('is-open');\n }\n }\n\n get embedded() {\n return this.hasAttribute('embedded');\n }\n\n set embedded(value) {\n if (value) {\n this.setAttribute('embedded', '');\n } else {\n this.removeAttribute('embedded');\n }\n }\n\n get welcome() {\n return this.getAttribute('welcome');\n }\n\n set welcome(value) {\n this.setAttribute('welcome', value);\n }\n\n get prompt() {\n return this.getAttribute('prompt');\n }\n\n set prompt(value) {\n this.setAttribute('prompt', value);\n }\n\n get apiKey() {\n return this.getAttribute('api-key');\n }\n\n set apiKey(value) {\n this.setAttribute('api-key', value);\n }\n\n // Lifecycle: component added to DOM\n connectedCallback() {\n console.log('AccessQABot component added to the DOM');\n this.render();\n this.loadQABot();\n }\n\n // Lifecycle: component removed from DOM\n disconnectedCallback() {\n console.log('AccessQABot component removed from the DOM');\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n }\n\n // Lifecycle: attributes changed\n attributeChangedCallback(name, oldValue, newValue) {\n if (oldValue !== newValue) {\n this.render();\n // Need to reload QA Bot when attributes change\n this.loadQABot();\n }\n }\n\n // Static list of observed attributes\n static get observedAttributes() {\n return ['is-logged-in', 'is-open', 'embedded', 'welcome', 'prompt', 'api-key'];\n }\n\n // Render the component's HTML and CSS\n render() {\n // Set up container for React component\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n display: block;\n min-height: 50px;\n }\n .react-container {\n width: 100%;\n height: 100%;\n }\n /* CSS for loading state */\n .loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n color: #666;\n font-style: italic;\n }\n </style>\n <div class=\"react-container\">\n <div class=\"loading\">Loading ACCESS QA Bot...</div>\n </div>\n `;\n }\n\n // Load the React QA Bot into the shadow DOM\n loadQABot() {\n // If we have an existing instance, clean it up first\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n\n // Get the container for the React component\n const container = this.shadowRoot.querySelector('.react-container');\n if (!container) return;\n\n // Check if the qAndATool function is available\n if (typeof window.accessQABot === 'undefined') {\n // Load the UMD script\n this.loadScript('./dist/index.umd.js', () => {\n this.initializeQABot(container);\n }, (error) => {\n this.showError(container, error);\n });\n } else {\n // Initialize immediately if already loaded\n this.initializeQABot(container);\n }\n }\n\n // Helper method to load a script\n loadScript(src, onLoad, onError) {\n const script = document.createElement('script');\n script.src = src;\n script.onload = onLoad;\n script.onerror = () => onError(new Error(`Failed to load script: ${src}`));\n document.head.appendChild(script);\n }\n\n // Initialize the QA Bot using the global UMD export\n initializeQABot(container) {\n try {\n // Get the qAndATool function from the global variable\n // Note: UMD exports can be structured in multiple ways, so we need to check all possibilities\n let qAndATool;\n\n if (typeof window.accessQABot === 'function') {\n // Direct function export\n qAndATool = window.accessQABot;\n } else if (window.accessQABot && typeof window.accessQABot.default === 'function') {\n // Default export in an object\n qAndATool = window.accessQABot.default;\n } else if (window.accessQABot && typeof window.accessQABot.qAndATool === 'function') {\n // Named export in an object\n qAndATool = window.accessQABot.qAndATool;\n } else {\n throw new Error('QA Bot library loaded but function not found in the expected format');\n }\n\n // Configure the QA Bot\n const config = {\n target: container,\n isLoggedIn: this.isLoggedIn,\n isOpen: this.isOpen,\n embedded: this.embedded,\n apiKey: this.apiKey\n };\n\n // Add optional props if they exist\n if (this.welcome) config.welcome = this.welcome;\n if (this.prompt) config.prompt = this.prompt;\n\n // Create the QA Bot instance\n this.cleanup = qAndATool(config);\n } catch (error) {\n this.showError(container, error);\n }\n }\n\n // Show an error message in the container\n showError(container, error) {\n console.error('Failed to load QA Bot component:', error);\n container.innerHTML = `\n <div style=\"color: red; padding: 10px; border: 1px solid #ddd; border-radius: 4px;\">\n <strong>Error loading ACCESS QA Bot</strong>\n <p>Make sure you've built the React component with: npm run build:lib</p>\n <p style=\"font-size: 12px; margin-top: 10px;\">Error: ${error.message}</p>\n </div>\n `;\n }\n}\n\n// Export the class\nexport default AccessQABot;","import AccessQABot from './AccessQABot';\n\n// Register the component if it hasn't been registered yet\nif (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {\n window.customElements.define('access-qa-bot', AccessQABot);\n}\n\n// Export the component class for users who want to extend it\nexport { AccessQABot };\n\n// Default export for simpler importing\nexport default {\n register() {\n // This method ensures components are registered\n if (typeof window !== 'undefined' && !window.customElements.get('access-qa-bot')) {\n window.customElements.define('access-qa-bot', AccessQABot);\n }\n }\n};"],"names":["AccessQABot","HTMLElement","constructor","attachShadow","mode","cleanup","observedAttributes","isLoggedIn","hasAttribute","value","setAttribute","removeAttribute","isOpen","embedded","welcome","getAttribute","prompt","apiKey","connectedCallback","console","log","render","loadQABot","disconnectedCallback","attributeChangedCallback","name","oldValue","newValue","shadowRoot","innerHTML","container","querySelector","window","accessQABot","loadScript","initializeQABot","error","showError","src","onLoad","onError","script","document","createElement","onload","onerror","Error","head","appendChild","qAndATool","default","config","target","message","customElements","get","define","register"],"mappings":";;;;;;IAAA;IACA,MAAMA,WAAW,SAASC,WAAW,CAAC;IAClCC,EAAAA,WAAWA,GAAG;IACV,IAAA,KAAK,EAAE;QACP,IAAI,CAACC,YAAY,CAAC;IAAEC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