@seekora-ai/docsearch-js 0.1.1

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.
@@ -0,0 +1,65 @@
1
+ import { DocSearchHit, DocSearchSuggestion, DocSearchProps } from '@seekora-ai/docsearch-react';
2
+ export { DocSearchHit, DocSearchProps, DocSearchSuggestion } from '@seekora-ai/docsearch-react';
3
+
4
+ interface DocSearchOptions {
5
+ /** Container element or CSS selector */
6
+ container: string | HTMLElement;
7
+ /** API endpoint for search (e.g., "https://api.example.com/v1/docs") */
8
+ apiEndpoint: string;
9
+ /** Optional API key for authentication */
10
+ apiKey?: string;
11
+ /** Index name (optional) */
12
+ indexName?: string;
13
+ /** Placeholder text for the search input */
14
+ placeholder?: string;
15
+ /** Maximum number of results to show */
16
+ maxResults?: number;
17
+ /** Debounce delay in milliseconds */
18
+ debounceMs?: number;
19
+ /** Callback when a result is selected */
20
+ onSelect?: (hit: DocSearchHit | DocSearchSuggestion) => void;
21
+ /** Callback when the modal is closed */
22
+ onClose?: () => void;
23
+ /** Custom translations */
24
+ translations?: DocSearchProps['translations'];
25
+ /** Whether to render the button trigger (default: true) */
26
+ renderButton?: boolean;
27
+ /** Initial open state */
28
+ initialOpen?: boolean;
29
+ /** Disable keyboard shortcut (Cmd/Ctrl+K) */
30
+ disableShortcut?: boolean;
31
+ /** Custom keyboard shortcut key (default: 'k') */
32
+ shortcutKey?: string;
33
+ }
34
+ interface DocSearchInstance {
35
+ /** Destroy the DocSearch instance and cleanup */
36
+ destroy: () => void;
37
+ /** Open the search modal programmatically */
38
+ open: () => void;
39
+ /** Close the search modal programmatically */
40
+ close: () => void;
41
+ /** Update options */
42
+ update: (options: Partial<DocSearchOptions>) => void;
43
+ }
44
+ /**
45
+ * Initialize DocSearch on a container element.
46
+ *
47
+ * @example
48
+ * ```js
49
+ * import docsearch from '@seekora-ai/docsearch-js';
50
+ * import '@seekora-ai/docsearch-css';
51
+ *
52
+ * const search = docsearch({
53
+ * container: '#docsearch',
54
+ * apiEndpoint: 'https://api.example.com/v1/docs',
55
+ * });
56
+ *
57
+ * // Later, if needed:
58
+ * search.open();
59
+ * search.destroy();
60
+ * ```
61
+ */
62
+ declare function docsearch(options: DocSearchOptions): DocSearchInstance;
63
+
64
+ export { docsearch as default, docsearch };
65
+ export type { DocSearchInstance, DocSearchOptions };
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import require$$0 from 'react-dom';
3
+ import { DocSearch } from '@seekora-ai/docsearch-react';
4
+
5
+ var createRoot;
6
+
7
+ var m = require$$0;
8
+ {
9
+ createRoot = m.createRoot;
10
+ m.hydrateRoot;
11
+ }
12
+
13
+ /**
14
+ * Initialize DocSearch on a container element.
15
+ *
16
+ * @example
17
+ * ```js
18
+ * import docsearch from '@seekora-ai/docsearch-js';
19
+ * import '@seekora-ai/docsearch-css';
20
+ *
21
+ * const search = docsearch({
22
+ * container: '#docsearch',
23
+ * apiEndpoint: 'https://api.example.com/v1/docs',
24
+ * });
25
+ *
26
+ * // Later, if needed:
27
+ * search.open();
28
+ * search.destroy();
29
+ * ```
30
+ */
31
+ function docsearch(options) {
32
+ const { container, ...props } = options;
33
+ // Get or validate container element
34
+ const containerElement = typeof container === 'string'
35
+ ? document.querySelector(container)
36
+ : container;
37
+ if (!containerElement) {
38
+ throw new Error(`DocSearch: Container element not found. ` +
39
+ `Provided: ${typeof container === 'string' ? container : 'HTMLElement'}`);
40
+ }
41
+ // State for programmatic control
42
+ let isOpen = props.initialOpen ?? false;
43
+ let currentProps = { ...props };
44
+ let root = null;
45
+ // Render function
46
+ const render = () => {
47
+ if (!root) {
48
+ root = createRoot(containerElement);
49
+ }
50
+ const element = React.createElement(DocSearch, {
51
+ ...currentProps,
52
+ initialOpen: isOpen,
53
+ onClose: () => {
54
+ isOpen = false;
55
+ currentProps.onClose?.();
56
+ render(); // Re-render to sync state
57
+ },
58
+ });
59
+ root.render(element);
60
+ };
61
+ // Initial render
62
+ render();
63
+ // Return instance API
64
+ return {
65
+ destroy: () => {
66
+ if (root) {
67
+ root.unmount();
68
+ root = null;
69
+ }
70
+ },
71
+ open: () => {
72
+ isOpen = true;
73
+ render();
74
+ },
75
+ close: () => {
76
+ isOpen = false;
77
+ render();
78
+ },
79
+ update: (newOptions) => {
80
+ currentProps = { ...currentProps, ...newOptions };
81
+ render();
82
+ },
83
+ };
84
+ }
85
+
86
+ export { docsearch as default, docsearch };
87
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","../src/index.ts"],"sourcesContent":["'use strict';\n\nvar m = require('react-dom');\nif (process.env.NODE_ENV === 'production') {\n exports.createRoot = m.createRoot;\n exports.hydrateRoot = m.hydrateRoot;\n} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n",null],"names":[],"mappings":";;;;;;AAEA,IAAI,CAAC,GAAG,UAAoB;AACe;AAC3C,EAAE,UAAA,GAAqB,CAAC,CAAC,UAAU;AACnC,EAAwB,CAAC,CAAC,WAAW;AACrC;;AC6CA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,SAAS,CAAC,OAAyB,EAAA;IACjD,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO;;AAGvC,IAAA,MAAM,gBAAgB,GACpB,OAAO,SAAS,KAAK;AACnB,UAAE,QAAQ,CAAC,aAAa,CAAc,SAAS;UAC7C,SAAS;IAEf,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAA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 +1,92 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var require$$0 = require('react-dom');
7
+ var docsearchReact = require('@seekora-ai/docsearch-react');
8
+
9
+ var createRoot;
10
+
11
+ var m = require$$0;
12
+ {
13
+ createRoot = m.createRoot;
14
+ m.hydrateRoot;
15
+ }
16
+
17
+ /**
18
+ * Initialize DocSearch on a container element.
19
+ *
20
+ * @example
21
+ * ```js
22
+ * import docsearch from '@seekora-ai/docsearch-js';
23
+ * import '@seekora-ai/docsearch-css';
24
+ *
25
+ * const search = docsearch({
26
+ * container: '#docsearch',
27
+ * apiEndpoint: 'https://api.example.com/v1/docs',
28
+ * });
29
+ *
30
+ * // Later, if needed:
31
+ * search.open();
32
+ * search.destroy();
33
+ * ```
34
+ */
35
+ function docsearch(options) {
36
+ const { container, ...props } = options;
37
+ // Get or validate container element
38
+ const containerElement = typeof container === 'string'
39
+ ? document.querySelector(container)
40
+ : container;
41
+ if (!containerElement) {
42
+ throw new Error(`DocSearch: Container element not found. ` +
43
+ `Provided: ${typeof container === 'string' ? container : 'HTMLElement'}`);
44
+ }
45
+ // State for programmatic control
46
+ let isOpen = props.initialOpen ?? false;
47
+ let currentProps = { ...props };
48
+ let root = null;
49
+ // Render function
50
+ const render = () => {
51
+ if (!root) {
52
+ root = createRoot(containerElement);
53
+ }
54
+ const element = React.createElement(docsearchReact.DocSearch, {
55
+ ...currentProps,
56
+ initialOpen: isOpen,
57
+ onClose: () => {
58
+ isOpen = false;
59
+ currentProps.onClose?.();
60
+ render(); // Re-render to sync state
61
+ },
62
+ });
63
+ root.render(element);
64
+ };
65
+ // Initial render
66
+ render();
67
+ // Return instance API
68
+ return {
69
+ destroy: () => {
70
+ if (root) {
71
+ root.unmount();
72
+ root = null;
73
+ }
74
+ },
75
+ open: () => {
76
+ isOpen = true;
77
+ render();
78
+ },
79
+ close: () => {
80
+ isOpen = false;
81
+ render();
82
+ },
83
+ update: (newOptions) => {
84
+ currentProps = { ...currentProps, ...newOptions };
85
+ render();
86
+ },
87
+ };
88
+ }
89
+
90
+ exports.default = docsearch;
91
+ exports.docsearch = docsearch;
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","../src/index.ts"],"sourcesContent":["'use strict';\n\nvar m = require('react-dom');\nif (process.env.NODE_ENV === 'production') {\n exports.createRoot = m.createRoot;\n exports.hydrateRoot = m.hydrateRoot;\n} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n",null],"names":["DocSearch"],"mappings":";;;;;;;;;;AAEA,IAAI,CAAC,GAAG,UAAoB;AACe;AAC3C,EAAE,UAAA,GAAqB,CAAC,CAAC,UAAU;AACnC,EAAwB,CAAC,CAAC,WAAW;AACrC;;AC6CA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,SAAS,CAAC,OAAyB,EAAA;IACjD,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO;;AAGvC,IAAA,MAAM,gBAAgB,GACpB,OAAO,SAAS,KAAK;AACnB,UAAE,QAAQ,CAAC,aAAa,CAAc,SAAS;UAC7C,SAAS;IAEf,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,CAAA,wCAAA,CAA0C;AACxC,YAAA,CAAA,UAAA,EAAa,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,aAAa,CAAA,CAAE,CAC3E;IACH;;AAGA,IAAA,IAAI,MAAM,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK;AACvC,IAAA,IAAI,YAAY,GAAG,EAAE,GAAG,KAAK,EAAE;IAC/B,IAAI,IAAI,GAAgB,IAAI;;IAG5B,MAAM,MAAM,GAAG,MAAK;QAClB,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,IAAI,GAAG,UAAU,CAAC,gBAAgB,CAAC;QACrC;AAEA,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAACA,wBAAS,EAAE;AAC7C,YAAA,GAAG,YAAY;AACf,YAAA,WAAW,EAAE,MAAM;YACnB,OAAO,EAAE,MAAK;gBACZ,MAAM,GAAG,KAAK;AACd,gBAAA,YAAY,CAAC,OAAO,IAAI;gBACxB,MAAM,EAAE,CAAC;YACX,CAAC;AACgB,SAAA,CAAC;AAEpB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;AACtB,IAAA,CAAC;;AAGD,IAAA,MAAM,EAAE;;IAGR,OAAO;QACL,OAAO,EAAE,MAAK;YACZ,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,OAAO,EAAE;gBACd,IAAI,GAAG,IAAI;YACb;QACF,CAAC;QAED,IAAI,EAAE,MAAK;YACT,MAAM,GAAG,IAAI;AACb,YAAA,MAAM,EAAE;QACV,CAAC;QAED,KAAK,EAAE,MAAK;YACV,MAAM,GAAG,KAAK;AACd,YAAA,MAAM,EAAE;QACV,CAAC;AAED,QAAA,MAAM,EAAE,CAAC,UAAqC,KAAI;YAChD,YAAY,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,EAAE;AACjD,YAAA,MAAM,EAAE;QACV,CAAC;KACF;AACH;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,2 @@
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("react"),require("react-dom"),require("@seekora-ai/docsearch-react")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","@seekora-ai/docsearch-react"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).docsearch={},e.React,e.require$$0,e.docsearchReact)}(this,function(e,o,t,r){"use strict";var n,c=t;function a(e){const{container:t,...c}=e,a="string"==typeof t?document.querySelector(t):t;if(!a)throw Error("DocSearch: Container element not found. Provided: "+("string"==typeof t?t:"HTMLElement"));let i=c.initialOpen??!1,d={...c},s=null;const u=()=>{s||(s=n(a));const e=o.createElement(r.DocSearch,{...d,initialOpen:i,onClose:()=>{i=!1,d.onClose?.(),u()}});s.render(e)};return u(),{destroy:()=>{s&&(s.unmount(),s=null)},open:()=>{i=!0,u()},close:()=>{i=!1,u()},update:e=>{d={...d,...e},u()}}}n=c.createRoot,e.default=a,e.docsearch=a,Object.defineProperty(e,"__esModule",{value:!0})});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../../../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","../src/index.ts"],"sourcesContent":["'use strict';\n\nvar m = require('react-dom');\nif (process.env.NODE_ENV === 'production') {\n exports.createRoot = m.createRoot;\n exports.hydrateRoot = m.hydrateRoot;\n} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n",null],"names":["m","require$$0","docsearch","options","container","props","containerElement","document","querySelector","Error","isOpen","initialOpen","currentProps","root","render","createRoot","element","React","createElement","DocSearch","onClose","destroy","unmount","open","close","update","newOptions"],"mappings":"iaAEIA,EAAIC,ECmEF,SAAUC,EAAUC,GACxB,MAAMC,UAAEA,KAAcC,GAAUF,EAG1BG,EACiB,iBAAdF,EACHG,SAASC,cAA2BJ,GACpCA,EAEN,IAAKE,EACH,MAAUG,MACR,sDACoC,iBAAdL,EAAyBA,EAAY,gBAK/D,IAAIM,EAASL,EAAMM,cAAe,EAC9BC,EAAe,IAAKP,GACpBQ,EAAoB,KAGxB,MAAMC,EAAS,KACRD,IACHA,EAAOE,EAAWT,IAGpB,MAAMU,EAAUC,EAAMC,cAAcC,YAAW,IAC1CP,EACHD,YAAaD,EACbU,QAAS,KACPV,GAAS,EACTE,EAAaQ,YACbN,OAIJD,EAAKC,OAAOE,IAOd,OAHAF,IAGO,CACLO,QAAS,KACHR,IACFA,EAAKS,UACLT,EAAO,OAIXU,KAAM,KACJb,GAAS,EACTI,KAGFU,MAAO,KACLd,GAAS,EACTI,KAGFW,OAASC,IACPd,EAAe,IAAKA,KAAiBc,GACrCZ,KAGN,CDpIEC,EAAqBf,EAAEe","x_google_ignoreList":[0]}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@seekora-ai/docsearch-js",
3
+ "version": "0.1.1",
4
+ "description": "Seekora DocSearch JavaScript - Vanilla JS wrapper for documentation search",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/index.esm.js",
8
+ "unpkg": "dist/index.umd.js",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.esm.js",
12
+ "require": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "rollup -c",
23
+ "dev": "rollup -c -w",
24
+ "clean": "rm -rf dist",
25
+ "test": "echo \"Tests pending\" && exit 0",
26
+ "lint": "tsc --noEmit"
27
+ },
28
+ "keywords": [
29
+ "seekora",
30
+ "docsearch",
31
+ "javascript",
32
+ "vanilla",
33
+ "search",
34
+ "documentation"
35
+ ],
36
+ "author": "Seekora",
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/seekora/seekora-docsearch.git",
41
+ "directory": "packages/js"
42
+ },
43
+ "dependencies": {
44
+ "@seekora-ai/docsearch-react": "^0.1.1",
45
+ "react": "^18.2.0",
46
+ "react-dom": "^18.2.0"
47
+ },
48
+ "devDependencies": {
49
+ "@rollup/plugin-commonjs": "^25.0.7",
50
+ "@rollup/plugin-node-resolve": "^15.2.3",
51
+ "@rollup/plugin-replace": "^5.0.5",
52
+ "@rollup/plugin-terser": "^0.4.4",
53
+ "@rollup/plugin-typescript": "^11.1.5",
54
+ "@types/react": "^18.2.0",
55
+ "@types/react-dom": "^18.2.0",
56
+ "rollup": "^4.9.0",
57
+ "rollup-plugin-dts": "^6.1.0",
58
+ "tslib": "^2.8.1",
59
+ "typescript": "^5.3.0"
60
+ }
61
+ }