@kapaai/support-form-deflector 0.1.9 → 0.2.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 (33) hide show
  1. package/dist/answer/answer-renderer.d.ts +6 -0
  2. package/dist/answer/answer-renderer.d.ts.map +1 -0
  3. package/dist/answer/error-indicator.d.ts +3 -0
  4. package/dist/answer/error-indicator.d.ts.map +1 -0
  5. package/dist/answer/index.d.ts +3 -0
  6. package/dist/answer/index.d.ts.map +1 -0
  7. package/dist/answer/info-texts.d.ts +4 -0
  8. package/dist/answer/info-texts.d.ts.map +1 -0
  9. package/dist/answer/loading-indicator.d.ts +3 -0
  10. package/dist/answer/loading-indicator.d.ts.map +1 -0
  11. package/dist/answer/use-submit-button-text-override.d.ts +8 -0
  12. package/dist/answer/use-submit-button-text-override.d.ts.map +1 -0
  13. package/dist/config-provider.d.ts +33 -0
  14. package/dist/config-provider.d.ts.map +1 -0
  15. package/dist/icons/sparkles.d.ts +3 -0
  16. package/dist/icons/sparkles.d.ts.map +1 -0
  17. package/dist/icons/types.d.ts +9 -0
  18. package/dist/icons/types.d.ts.map +1 -0
  19. package/dist/index.d.ts +6 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.html +1 -1
  22. package/dist/kapa-support-form-deflector.bundle.js +2 -0
  23. package/dist/kapa-support-form-deflector.bundle.js.LICENSE.txt +61 -0
  24. package/dist/state.d.ts +19 -0
  25. package/dist/state.d.ts.map +1 -0
  26. package/dist/utils/errors.d.ts +7 -0
  27. package/dist/utils/errors.d.ts.map +1 -0
  28. package/dist/utils/wait-for-elements.d.ts +24 -0
  29. package/dist/utils/wait-for-elements.d.ts.map +1 -0
  30. package/package.json +2 -3
  31. package/dist/__tests__/example.test.d.ts +0 -2
  32. package/dist/__tests__/example.test.d.ts.map +0 -1
  33. package/dist/kapa-deflector.bundle.js +0 -1
@@ -0,0 +1,61 @@
1
+ /*! Bundled license information:
2
+
3
+ prismjs/prism.js:
4
+ (**
5
+ * Prism: Lightweight, robust, elegant syntax highlighting
6
+ *
7
+ * @license MIT <https://opensource.org/licenses/MIT>
8
+ * @author Lea Verou <https://lea.verou.me>
9
+ * @namespace
10
+ * @public
11
+ *)
12
+ */
13
+
14
+ /**
15
+ * @license React
16
+ * react-dom.production.min.js
17
+ *
18
+ * Copyright (c) Facebook, Inc. and its affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ */
23
+
24
+ /**
25
+ * @license React
26
+ * react-jsx-runtime.production.min.js
27
+ *
28
+ * Copyright (c) Facebook, Inc. and its affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ */
33
+
34
+ /**
35
+ * @license React
36
+ * react.production.min.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */
43
+
44
+ /**
45
+ * @license React
46
+ * scheduler.production.min.js
47
+ *
48
+ * Copyright (c) Facebook, Inc. and its affiliates.
49
+ *
50
+ * This source code is licensed under the MIT license found in the
51
+ * LICENSE file in the root directory of this source tree.
52
+ */
53
+
54
+ /** @license React v16.13.1
55
+ * react-is.production.min.js
56
+ *
57
+ * Copyright (c) Facebook, Inc. and its affiliates.
58
+ *
59
+ * This source code is licensed under the MIT license found in the
60
+ * LICENSE file in the root directory of this source tree.
61
+ */
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ type DeflectorState = "loading" | "error" | "not_triggered" | "success";
3
+ type GlobalState = {
4
+ state: DeflectorState;
5
+ answer?: string;
6
+ };
7
+ type GlobalAction = {
8
+ type: "LOADING" | "SUCCESS" | "ERROR";
9
+ data: any;
10
+ };
11
+ export declare const DeflectorProvider: React.FC<{
12
+ children: React.ReactNode;
13
+ }>;
14
+ export declare const useDeflector: () => {
15
+ state: GlobalState;
16
+ dispatch: React.Dispatch<GlobalAction>;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,KAAK,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,eAAe,GAAG,SAAS,CAAC;AACxE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAOF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACtC,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAuCF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAuRA,CAAC;AAEF,eAAO,MAAM,YAAY;WApSZ,WAAW;cACR,MAAM,QAAQ,CAAC,YAAY,CAAC;CAyS3C,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare class ReCAPTCHAError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class ReCAPTCHATimeoutError extends ReCAPTCHAError {
5
+ constructor(message: string);
6
+ }
7
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAO5B;AAED,qBAAa,qBAAsB,SAAQ,cAAc;gBAC3C,OAAO,EAAE,MAAM;CAO5B"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Asynchronously waits for DOM elements matching the provided selectors to appear in the document.
3
+ * Uses MutationObserver to efficiently detect DOM changes and includes timeout protection.
4
+ *
5
+ * @param selectors - Array of CSS selector strings to watch for
6
+ * @param timeout - Maximum time to wait in milliseconds before rejecting (default: 10000ms)
7
+ * @returns Promise<Element[]> - Resolves with array of found elements in same order as selectors
8
+ * @throws Error if timeout is reached before all elements are found
9
+ *
10
+ * @example
11
+ * // Wait for single element
12
+ * const [mainContent] = await waitForElements(['form[name=contact-form]']);
13
+ *
14
+ * @example
15
+ * // Handle timeout error
16
+ * try {
17
+ * const elements = await waitForElements(['form[name=contact-form]']);
18
+ * } catch (error) {
19
+ * console.error('Elements did not appear in time:', error);
20
+ * }
21
+ */
22
+ declare const waitForElements: (selectors: string[], timeout?: number) => Promise<Element[]>;
23
+ export default waitForElements;
24
+ //# sourceMappingURL=wait-for-elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-for-elements.d.ts","sourceRoot":"","sources":["../../src/utils/wait-for-elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,eAAe,cACR,MAAM,EAAE,uBAElB,QAAQ,OAAO,EAAE,CAgDnB,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapaai/support-form-deflector",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -35,7 +35,6 @@
35
35
  "prismjs": "^1.29.0",
36
36
  "react": "^18.2.0",
37
37
  "react-dom": "^18.2.0",
38
- "react-google-recaptcha": "^2.1.0",
39
38
  "react-markdown": "^8.0.7",
40
39
  "react-scripts": "5.0.1",
41
40
  "remark-gfm": "^3.0.1",
@@ -45,7 +44,7 @@
45
44
  "scripts": {
46
45
  "dev": "webpack serve --mode development",
47
46
  "build": "webpack --mode production",
48
- "test": "jest",
47
+ "test": "jest --passWithNoTests",
49
48
  "eject": "react-scripts eject",
50
49
  "postpublish": "node scripts/post-publish-gcs.js"
51
50
  },
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=example.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/example.test.tsx"],"names":[],"mappings":""}
@@ -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.KapaDeflector=t():e.KapaDeflector=t()}(self,(()=>(()=>{"use strict";var e={151:(e,t,o)=>{o.r(t),o.d(t,{TimeoutError:()=>c,executeWithTimeout:()=>p,getButtonPosition:()=>i,getFaviconUrl:()=>n,makeBgColorImportant:()=>a,parseJsonField:()=>u,strip:()=>s});var r=(e,t,o)=>new Promise(((r,n)=>{var i=e=>{try{s(o.next(e))}catch(e){n(e)}},u=e=>{try{s(o.throw(e))}catch(e){n(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,u);s((o=o.apply(e,t)).next())})),n=e=>`https://www.google.com/s2/favicons?sz=128&domain=${new URL(e).hostname}`,i=e=>{const{buttonPositionTop:t,buttonPositionRight:o,buttonPositionBottom:r,buttonPositionLeft:n}=e,i={top:t,right:o,bottom:r,left:n};return Object.entries(i).reduce(((e,[t,o])=>(void 0!==o&&(e[t]=o),e)),{bottom:"20px",right:"20px"})};function u(e){if(e)return JSON.parse(e)}function s(e,t){const o=new RegExp(`^[${t}]+|[${t}]+$`,"g");return e.replace(o,"")}function a(e){return e?`${e} !important`:void 0}var c=class e extends Error{constructor(t){super(t),this.name="TimeoutError",Object.setPrototypeOf(this,e.prototype)}};function p(e,t){return r(this,null,(function*(){return new Promise(((o,r)=>{const n=setTimeout((()=>{r(new c("Promise timed out."))}),t);e.then((e=>{clearTimeout(n),o(e)})).catch((e=>{clearTimeout(n),r(e)}))}))}))}}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.getFaviconUrlExample=e.dummy=void 0,e.dummy=1;const t=o(151);e.getFaviconUrlExample=e=>(0,t.getFaviconUrl)(e)})(),r})()));