@inkeep/cxkit-primitives 0.0.0-dev-20250312234650 → 0.0.0-dev-20250313232451
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/atoms/markdown/index.cjs +1 -1
- package/dist/atoms/markdown/index.js +33 -32
- package/dist/components/embedded-search/transform-results.cjs +1 -1
- package/dist/components/embedded-search/transform-results.js +21 -21
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
- package/dist/components/embedded-search/use-inkeep-search.js +81 -73
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/utils/default-settings.cjs +1 -1
- package/dist/utils/default-settings.js +2 -3
- package/dist/utils/graphql-client.cjs +1 -1
- package/dist/utils/graphql-client.js +3 -2
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),m=require("react-markdown"),M=require("rehype-raw"),y=require("../../providers/markdown-provider.cjs"),g=require("../codeblock/index.cjs"),n=require("./components.cjs"),b=require("./rehype-inline-code-property.cjs");const f=({children:c,componentStyles:a,shouldOpenLinksInNewTab:h,onLinkClick:u,onCodeCopy:k,...p})=>{if(!c)return null;const w={h1:({children:r})=>e.jsx(n.MarkdownH1,{children:r}),h2:({children:r})=>e.jsx(n.MarkdownH2,{children:r}),p:({children:r})=>e.jsx(n.MarkdownP,{children:r}),li:({children:r})=>e.jsx(n.MarkdownLi,{children:r}),ul:({children:r})=>e.jsx(n.MarkdownUl,{children:r}),ol:({children:r,node:o})=>{const t=o?.properties?.start,i=typeof t=="number"?t:void 0;return e.jsx(n.MarkdownOl,{style:{"--start":t?.toString()??"0"},start:i,children:r})},a:({children:r,href:o})=>{const t=x.Children.toArray(r),i=t[0],d=typeof i=="string"&&/^\(\d+\)$/.test(i)&&t.length===1,s=d?i.match(/\d+/):r,l=e.jsx(n.MarkdownLink,{isExternal:h,href:o,onClick:()=>{u?.(o,s?.toString())},children:s});return d?e.jsx(n.MarkdownSourceLink,{children:l}):l},img:({src:r,alt:o})=>``,table:({children:r})=>e.jsx(n.MarkdownTable,{children:r}),th:({children:r,isHeader:o})=>o?e.jsx(n.MarkdownTh,{children:r}):e.jsx(n.MarkdownTd,{children:r}),pre:({children:r})=>e.jsx("pre",{children:r}),code:({children:r,inline:o,className:t})=>o?e.jsx(n.MarkdownCode,{children:r}):e.jsx(g.CodeBlock,{className:t,onCopy:k,children:r})},j=e.jsx(m,{rehypePlugins:[M,b.rehypeInlineCodeProperty],components:w,disallowedElements:C,children:c.toString(),...p});return e.jsx(y.ChatMarkdownProvider,{componentStyles:a,children:j})},C=["script","iframe","frame","embed","meta","base","form","style","object"];exports.Markdown=f;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import w from "react";
|
|
3
|
+
import f from "react-markdown";
|
|
4
4
|
import M from "rehype-raw";
|
|
5
5
|
import { ChatMarkdownProvider as y } from "../../providers/markdown-provider.js";
|
|
6
6
|
import { CodeBlock as g } from "../codeblock/index.js";
|
|
7
|
-
import { MarkdownCode as C, MarkdownTh as b, MarkdownTd as S, MarkdownTable as P, MarkdownSourceLink as x, MarkdownOl as L, MarkdownUl as R, MarkdownLi as T, MarkdownP as $, MarkdownH2 as j, MarkdownH1 as
|
|
8
|
-
import { rehypeInlineCodeProperty as
|
|
9
|
-
const
|
|
7
|
+
import { MarkdownCode as C, MarkdownTh as b, MarkdownTd as S, MarkdownTable as P, MarkdownSourceLink as x, MarkdownOl as L, MarkdownUl as R, MarkdownLi as T, MarkdownP as $, MarkdownH2 as j, MarkdownH1 as v, MarkdownLink as A } from "./components.js";
|
|
8
|
+
import { rehypeInlineCodeProperty as E } from "./rehype-inline-code-property.js";
|
|
9
|
+
const D = ({
|
|
10
10
|
children: i,
|
|
11
11
|
componentStyles: a,
|
|
12
12
|
shouldOpenLinksInNewTab: h,
|
|
@@ -16,54 +16,55 @@ const F = ({
|
|
|
16
16
|
}) => {
|
|
17
17
|
if (!i) return null;
|
|
18
18
|
const k = {
|
|
19
|
-
h1: ({ children: r }) => /* @__PURE__ */
|
|
20
|
-
h2: ({ children: r }) => /* @__PURE__ */
|
|
21
|
-
p: ({ children: r }) => /* @__PURE__ */
|
|
22
|
-
li: ({ children: r }) => /* @__PURE__ */
|
|
23
|
-
ul: ({ children: r }) => /* @__PURE__ */
|
|
24
|
-
ol: ({ children: r, node:
|
|
25
|
-
const o =
|
|
26
|
-
return /* @__PURE__ */
|
|
19
|
+
h1: ({ children: r }) => /* @__PURE__ */ e(v, { children: r }),
|
|
20
|
+
h2: ({ children: r }) => /* @__PURE__ */ e(j, { children: r }),
|
|
21
|
+
p: ({ children: r }) => /* @__PURE__ */ e($, { children: r }),
|
|
22
|
+
li: ({ children: r }) => /* @__PURE__ */ e(T, { children: r }),
|
|
23
|
+
ul: ({ children: r }) => /* @__PURE__ */ e(R, { children: r }),
|
|
24
|
+
ol: ({ children: r, node: n }) => {
|
|
25
|
+
const o = n?.properties?.start, t = typeof o == "number" ? o : void 0;
|
|
26
|
+
return /* @__PURE__ */ e(
|
|
27
27
|
L,
|
|
28
28
|
{
|
|
29
29
|
style: {
|
|
30
30
|
"--start": o?.toString() ?? "0"
|
|
31
31
|
},
|
|
32
|
+
start: t,
|
|
32
33
|
children: r
|
|
33
34
|
}
|
|
34
35
|
);
|
|
35
36
|
},
|
|
36
|
-
a: ({ children: r, href:
|
|
37
|
-
const o =
|
|
38
|
-
|
|
37
|
+
a: ({ children: r, href: n }) => {
|
|
38
|
+
const o = w.Children.toArray(r), t = o[0], d = typeof t == "string" && /^\(\d+\)$/.test(t) && o.length === 1, c = d ? t.match(/\d+/) : r, l = /* @__PURE__ */ e(
|
|
39
|
+
A,
|
|
39
40
|
{
|
|
40
41
|
isExternal: h,
|
|
41
|
-
href:
|
|
42
|
+
href: n,
|
|
42
43
|
onClick: () => {
|
|
43
|
-
s?.(
|
|
44
|
+
s?.(n, c?.toString());
|
|
44
45
|
},
|
|
45
46
|
children: c
|
|
46
47
|
}
|
|
47
48
|
);
|
|
48
|
-
return d ? /* @__PURE__ */
|
|
49
|
+
return d ? /* @__PURE__ */ e(x, { children: l }) : l;
|
|
49
50
|
},
|
|
50
|
-
img: ({ src: r, alt:
|
|
51
|
-
table: ({ children: r }) => /* @__PURE__ */
|
|
52
|
-
th: ({ children: r, isHeader:
|
|
53
|
-
pre: ({ children: r }) => /* @__PURE__ */
|
|
54
|
-
code: ({ children: r, inline:
|
|
55
|
-
},
|
|
56
|
-
|
|
51
|
+
img: ({ src: r, alt: n }) => ``,
|
|
52
|
+
table: ({ children: r }) => /* @__PURE__ */ e(P, { children: r }),
|
|
53
|
+
th: ({ children: r, isHeader: n }) => n ? /* @__PURE__ */ e(b, { children: r }) : /* @__PURE__ */ e(S, { children: r }),
|
|
54
|
+
pre: ({ children: r }) => /* @__PURE__ */ e("pre", { children: r }),
|
|
55
|
+
code: ({ children: r, inline: n, className: o }) => n ? /* @__PURE__ */ e(C, { children: r }) : /* @__PURE__ */ e(g, { className: o, onCopy: m, children: r })
|
|
56
|
+
}, u = /* @__PURE__ */ e(
|
|
57
|
+
f,
|
|
57
58
|
{
|
|
58
|
-
rehypePlugins: [M,
|
|
59
|
+
rehypePlugins: [M, E],
|
|
59
60
|
components: k,
|
|
60
|
-
disallowedElements:
|
|
61
|
+
disallowedElements: H,
|
|
61
62
|
children: i.toString(),
|
|
62
63
|
...p
|
|
63
64
|
}
|
|
64
65
|
);
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
},
|
|
66
|
+
return /* @__PURE__ */ e(y, { componentStyles: a, children: u });
|
|
67
|
+
}, H = [
|
|
67
68
|
"script",
|
|
68
69
|
"iframe",
|
|
69
70
|
"frame",
|
|
@@ -75,5 +76,5 @@ const F = ({
|
|
|
75
76
|
"object"
|
|
76
77
|
];
|
|
77
78
|
export {
|
|
78
|
-
|
|
79
|
+
D as Markdown
|
|
79
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),S=require("../../providers/config-provider.cjs"),T=require("../../utils/transform-source/index.cjs"),v=(e,o)=>{const{baseSettings:{transformSource:r,organizationDisplayName:s},searchSettings:{tabs:u,searchQueryParamKey:
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),S=require("../../providers/config-provider.cjs"),T=require("../../utils/transform-source/index.cjs"),v=(e,o)=>{const{baseSettings:{transformSource:r,organizationDisplayName:s},searchSettings:{tabs:u,searchQueryParamKey:i,shouldOpenLinksInNewTab:g}}=S.useInkeepConfig();return w.useMemo(()=>{const R=u.length>0?u:["All"],n={},y=new Set,d=R.map(t=>typeof t=="string"?t:t[0]);for(const t of d)n[t]=[];for(const t of e){const c=t.url||"";if(y.has(c))continue;y.add(c);const l=i?I(c,o,i):c,a=T.transformInkeepSource({title:t.title,url:l,description:k(t),type:O(t.rootRecord.__typename),tag:D(t),breadcrumbs:t.rootRecord.pathBreadcrumbs??[],contentType:t.rootRecord.contentType},"searchResultItem",{organizationDisplayName:s,tabs:u,transformSource:r}),f={...a,id:t.id,isExternal:a.shouldOpenInNewTab!==void 0?a.shouldOpenInNewTab:g},m=f.tabs||[];for(const b of m){const p=typeof b=="string"?b:b[0];if(!d.includes(p)){console.warn(`Tab "${p}" found in item but not configured in tabs`);continue}n[p].push(f)}d.includes("All")&&n.All.push(f)}for(const t of Object.keys(n)){const c=R.find(a=>typeof a=="string"?a===t:a[0]===t),l=typeof c=="object"?c[1]?.isAlwaysVisible===!0:!1;n[t].length===0&&!l&&delete n[t]}return n},[e,r,s,u,o,i,g])};function I(e,o,r){try{const s=new URL(e);return s.searchParams.set(r,o),s.toString()}catch{return e}}const k=e=>{switch(e.rootRecord.__typename){case"DocumentationRecord":{const o=h(e.pathHeadings?.at(-1)?.content||""),r=h(e.content?.content||"");return e.preview||r||o}case"GitHubIssueRecord":case"StackOverflowRecord":case"DiscourseRecord":return e.rootRecord.body;default:return e.preview}},D=e=>{switch(e.rootRecord.__typename){case"StackOverflowRecord":return e.rootRecord.markedAsCorrectAnswer?"Resolved":void 0;case"GitHubIssueRecord":return e.rootRecord.state==="CLOSED"?"Closed":void 0}},h=e=>{const o=/(https?:\/\/\S+)/g;return e.replace(o,r=>{const s=r.split("/");return s.length>3?`...${s.slice(-2).join("/")}`:r})},O=e=>{switch(e){case"DocumentationRecord":return"documentation";case"GitHubIssueRecord":return"github_issue";case"DiscourseRecord":return"discourse";case"DiscordRecord":return"discord";case"StackOverflowRecord":return"stackoverflow";case"SlackEntry":return"slack_message";default:return"site"}};exports.useTransformResults=v;
|
|
@@ -5,20 +5,20 @@ import { transformInkeepSource as I } from "../../utils/transform-source/index.j
|
|
|
5
5
|
const N = (e, r) => {
|
|
6
6
|
const {
|
|
7
7
|
baseSettings: { transformSource: o, organizationDisplayName: s },
|
|
8
|
-
searchSettings: { tabs: u, searchQueryParamKey:
|
|
8
|
+
searchSettings: { tabs: u, searchQueryParamKey: i, shouldOpenLinksInNewTab: g }
|
|
9
9
|
} = S();
|
|
10
10
|
return w(() => {
|
|
11
|
-
const m = u.length > 0 ? u : ["All"], n = {}, R = /* @__PURE__ */ new Set(),
|
|
12
|
-
for (const t of
|
|
11
|
+
const m = u.length > 0 ? u : ["All"], n = {}, R = /* @__PURE__ */ new Set(), d = m.map((t) => typeof t == "string" ? t : t[0]);
|
|
12
|
+
for (const t of d)
|
|
13
13
|
n[t] = [];
|
|
14
14
|
for (const t of e) {
|
|
15
|
-
const
|
|
16
|
-
if (R.has(
|
|
17
|
-
R.add(
|
|
18
|
-
const
|
|
15
|
+
const c = t.url || "";
|
|
16
|
+
if (R.has(c)) continue;
|
|
17
|
+
R.add(c);
|
|
18
|
+
const l = i ? T(c, r, i) : c, a = I(
|
|
19
19
|
{
|
|
20
20
|
title: t.title,
|
|
21
|
-
url:
|
|
21
|
+
url: l,
|
|
22
22
|
description: k(t),
|
|
23
23
|
type: D(t.rootRecord.__typename),
|
|
24
24
|
tag: v(t),
|
|
@@ -27,24 +27,24 @@ const N = (e, r) => {
|
|
|
27
27
|
},
|
|
28
28
|
"searchResultItem",
|
|
29
29
|
{ organizationDisplayName: s, tabs: u, transformSource: o }
|
|
30
|
-
),
|
|
31
|
-
...
|
|
30
|
+
), f = {
|
|
31
|
+
...a,
|
|
32
32
|
id: t.id,
|
|
33
|
-
isExternal:
|
|
34
|
-
}, y =
|
|
35
|
-
for (const
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
console.warn(`Tab "${
|
|
33
|
+
isExternal: a.shouldOpenInNewTab !== void 0 ? a.shouldOpenInNewTab : g
|
|
34
|
+
}, y = f.tabs || [];
|
|
35
|
+
for (const p of y) {
|
|
36
|
+
const b = typeof p == "string" ? p : p[0];
|
|
37
|
+
if (!d.includes(b)) {
|
|
38
|
+
console.warn(`Tab "${b}" found in item but not configured in tabs`);
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
|
-
n[
|
|
41
|
+
n[b].push(f);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
d.includes("All") && n.All.push(f);
|
|
44
44
|
}
|
|
45
45
|
for (const t of Object.keys(n)) {
|
|
46
|
-
const
|
|
47
|
-
n[t].length === 0 && !
|
|
46
|
+
const c = m.find((a) => typeof a == "string" ? a === t : a[0] === t), l = typeof c == "object" ? c[1]?.isAlwaysVisible === !0 : !1;
|
|
47
|
+
n[t].length === 0 && !l && delete n[t];
|
|
48
48
|
}
|
|
49
49
|
return n;
|
|
50
50
|
}, [
|
|
@@ -53,7 +53,7 @@ const N = (e, r) => {
|
|
|
53
53
|
s,
|
|
54
54
|
u,
|
|
55
55
|
r,
|
|
56
|
-
|
|
56
|
+
i,
|
|
57
57
|
g
|
|
58
58
|
]);
|
|
59
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),Y=require("../../providers/config-provider.cjs"),Z=require("../../hooks/use-media-query.cjs"),ee=require("./search-query.graphql.cjs"),te=require("./transform-results.cjs"),se=require("../../providers/search-events-provider.cjs"),re=require("../../hooks/use-instant-update.cjs"),ne=require("../../utils/graphql-client.cjs"),ae=()=>{const{baseSettings:O,searchSettings:x}=Y.useInkeepConfig(),{apiKey:R,aiApiBaseUrl:B,userAuthToken:l,filters:Q}=O,{maxResults:q,placeholder:C,defaultQuery:H,debounceTimeMs:T,onQueryChange:$,searchFunctionsRef:z,tabs:i,filters:k}=x,{logEvent:v}=se.useSearchEvents(),[a,E]=t.useState(H),M=t.useRef(null),[w,h]=t.useState(!1),[D,f]=t.useState(null),[K,c]=t.useState("NONE"),W=t.useCallback(e=>{c(e)},[]),[d,y]=t.useState([]),s=te.useTransformResults(d,a),I=typeof i?.[0]=="string"?i[0]:i[0][0],[b,A]=t.useState(I),{disableTransition:P,disabled:G}=re.useInstantUpdate(),J=t.useCallback(e=>{P(),A(e);const r=s[e][0].id;c(r)},[s,P]);t.useEffect(()=>{let e=b in s?b:Object.keys(s)[0];if(!s[e]?.length){const n=Object.keys(s).find(u=>s[u]?.length);n?e=n:e=I}if(!e)return;A(e);const r=s[e]?.[0];r&&c(r.id)},[s]);const g=Z.useMediaQuery("(max-width: 768px)"),o=t.useRef({}),m=t.useRef(null),p=t.useRef(null);t.useImperativeHandle(z,()=>({updateQuery(e){E(e)},focusInput:()=>{M.current?.focus()}}));const U=`${B}/graphql`,_=t.useMemo(()=>({Authorization:`Bearer ${R}`,"Content-Type":"application/json",...l?{"User-Token":l}:{}}),[R,l]),j=t.useCallback(async e=>{const r=new AbortController;m.current=r;try{f(null);const u=(await ne.graphqlRequest(U,ee.default,{searchInput:e},_,r.signal))?.search.searchHits;o.current[e.searchQuery]=u,y(u)}catch(n){if(n.name==="AbortError")return;f("Failed to fetch search results. Please try again.")}finally{h(!1)}},[U,_]),F=t.useCallback(e=>{const r=o.current[e.searchQuery];v({eventName:"search_query_response_received",properties:{searchQuery:e.searchQuery,totalResults:r?.length}})},[]),L=()=>{m.current&&(m.current.abort(),h(!1))},N=t.useCallback(e=>{if(p.current&&window.clearTimeout(p.current),!e.searchQuery){L(),y([]),f(null);return}p.current=window.setTimeout(()=>{L(),v({eventName:"search_query_submitted",properties:{searchQuery:e.searchQuery}}),o.current[e.searchQuery]?(y(o.current[e.searchQuery]),F(e)):(h(!0),j(e).then(()=>{F(e)}))},T)},[T,j]),S=t.useMemo(()=>({searchQuery:a,filters:{...Q,...k,limit:q}}),[a,q,Q,k]);t.useEffect(()=>{$?.(S.searchQuery),N(S)},[N,S]);const V=t.useCallback(e=>E(e.target.value),[]),X=t.useMemo(()=>C||(g?"Search...":"Search for anything..."),[C,g]);return{results:s,resultsList:d,hasContent:d.length>0||w,loading:w,error:D,query:a,onInput:V,placeholder:X,tab:b,onTabChange:J,selectedItem:K,setSelectedItem:c,onSelectedItemChange:W,transitionsDisabled:G,inputRef:M,isMobile:g}};exports.useInkeepSearch=ae;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as s, useRef as
|
|
3
|
-
import { useInkeepConfig as
|
|
4
|
-
import { useMediaQuery as
|
|
5
|
-
import
|
|
6
|
-
import { useTransformResults as
|
|
7
|
-
import { useSearchEvents as
|
|
8
|
-
import { useInstantUpdate as
|
|
9
|
-
import { graphqlRequest as
|
|
10
|
-
const
|
|
11
|
-
const { baseSettings:
|
|
12
|
-
maxResults:
|
|
13
|
-
placeholder:
|
|
14
|
-
defaultQuery:
|
|
15
|
-
debounceTimeMs:
|
|
16
|
-
onQueryChange:
|
|
17
|
-
searchFunctionsRef:
|
|
2
|
+
import { useState as s, useRef as u, useCallback as n, useEffect as P, useImperativeHandle as re, useMemo as S } from "react";
|
|
3
|
+
import { useInkeepConfig as se } from "../../providers/config-provider.js";
|
|
4
|
+
import { useMediaQuery as ne } from "../../hooks/use-media-query.js";
|
|
5
|
+
import oe from "./search-query.graphql.js";
|
|
6
|
+
import { useTransformResults as ce } from "./transform-results.js";
|
|
7
|
+
import { useSearchEvents as ae } from "../../providers/search-events-provider.js";
|
|
8
|
+
import { useInstantUpdate as ie } from "../../hooks/use-instant-update.js";
|
|
9
|
+
import { graphqlRequest as le } from "../../utils/graphql-client.js";
|
|
10
|
+
const ge = () => {
|
|
11
|
+
const { baseSettings: $, searchSettings: z } = se(), { apiKey: C, aiApiBaseUrl: D, userAuthToken: h, filters: v } = $, {
|
|
12
|
+
maxResults: k,
|
|
13
|
+
placeholder: w,
|
|
14
|
+
defaultQuery: K,
|
|
15
|
+
debounceTimeMs: q,
|
|
16
|
+
onQueryChange: W,
|
|
17
|
+
searchFunctionsRef: G,
|
|
18
18
|
tabs: f,
|
|
19
|
-
filters:
|
|
20
|
-
} =
|
|
19
|
+
filters: E
|
|
20
|
+
} = z, { logEvent: A } = ae(), [c, I] = s(K), _ = u(null), [x, m] = s(!1), [J, d] = s(null), [V, a] = s("NONE"), X = n((e) => {
|
|
21
21
|
a(e);
|
|
22
|
-
}, []), [
|
|
22
|
+
}, []), [y, p] = s([]), t = ce(y, c), F = typeof f?.[0] == "string" ? f[0] : f[0][0], [b, L] = s(F), { disableTransition: M, disabled: Y } = ie(), Z = n(
|
|
23
23
|
(e) => {
|
|
24
24
|
M(), L(e);
|
|
25
25
|
const r = t[e][0].id;
|
|
@@ -27,10 +27,10 @@ const be = () => {
|
|
|
27
27
|
},
|
|
28
28
|
[t, M]
|
|
29
29
|
);
|
|
30
|
-
|
|
31
|
-
let e =
|
|
30
|
+
P(() => {
|
|
31
|
+
let e = b in t ? b : Object.keys(t)[0];
|
|
32
32
|
if (!t[e]?.length) {
|
|
33
|
-
const o = Object.keys(t).find((
|
|
33
|
+
const o = Object.keys(t).find((l) => t[l]?.length);
|
|
34
34
|
o ? e = o : e = F;
|
|
35
35
|
}
|
|
36
36
|
if (!e) return;
|
|
@@ -38,106 +38,114 @@ const be = () => {
|
|
|
38
38
|
const r = t[e]?.[0];
|
|
39
39
|
r && a(r.id);
|
|
40
40
|
}, [t]);
|
|
41
|
-
const
|
|
42
|
-
|
|
41
|
+
const g = ne("(max-width: 768px)"), i = u({}), Q = u(null), R = u(null);
|
|
42
|
+
re(G, () => ({
|
|
43
43
|
updateQuery(e) {
|
|
44
|
-
|
|
44
|
+
I(e);
|
|
45
45
|
},
|
|
46
46
|
focusInput: () => {
|
|
47
|
-
|
|
47
|
+
_.current?.focus();
|
|
48
48
|
}
|
|
49
49
|
}));
|
|
50
|
-
const N = `${
|
|
50
|
+
const N = `${D}/graphql`, U = S(
|
|
51
51
|
() => ({
|
|
52
|
-
Authorization: `Bearer ${
|
|
52
|
+
Authorization: `Bearer ${C}`,
|
|
53
53
|
"Content-Type": "application/json",
|
|
54
54
|
...h ? { "User-Token": h } : {}
|
|
55
55
|
}),
|
|
56
|
-
[
|
|
56
|
+
[C, h]
|
|
57
57
|
), j = n(
|
|
58
58
|
async (e) => {
|
|
59
|
-
g.current && g.current.abort();
|
|
60
59
|
const r = new AbortController();
|
|
61
|
-
|
|
60
|
+
Q.current = r;
|
|
62
61
|
try {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
62
|
+
d(null);
|
|
63
|
+
const l = (await le(
|
|
64
|
+
N,
|
|
65
|
+
oe,
|
|
66
|
+
{ searchInput: e },
|
|
67
|
+
U,
|
|
68
|
+
r.signal
|
|
69
|
+
))?.search.searchHits;
|
|
70
|
+
i.current[e.searchQuery] = l, p(l);
|
|
66
71
|
} catch (o) {
|
|
67
72
|
if (o.name === "AbortError")
|
|
68
73
|
return;
|
|
69
|
-
|
|
74
|
+
d("Failed to fetch search results. Please try again.");
|
|
75
|
+
} finally {
|
|
76
|
+
m(!1);
|
|
70
77
|
}
|
|
71
|
-
x(!1);
|
|
72
78
|
},
|
|
73
79
|
[N, U]
|
|
74
80
|
), O = n((e) => {
|
|
75
81
|
const r = i.current[e.searchQuery];
|
|
76
|
-
|
|
82
|
+
A({
|
|
77
83
|
eventName: "search_query_response_received",
|
|
78
84
|
properties: {
|
|
79
85
|
searchQuery: e.searchQuery,
|
|
80
86
|
totalResults: r?.length
|
|
81
87
|
}
|
|
82
88
|
});
|
|
83
|
-
}, []), B =
|
|
89
|
+
}, []), B = () => {
|
|
90
|
+
Q.current && (Q.current.abort(), m(!1));
|
|
91
|
+
}, H = n(
|
|
84
92
|
(e) => {
|
|
85
|
-
if (
|
|
86
|
-
p([]),
|
|
93
|
+
if (R.current && window.clearTimeout(R.current), !e.searchQuery) {
|
|
94
|
+
B(), p([]), d(null);
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
R.current = window.setTimeout(() => {
|
|
98
|
+
B(), A({
|
|
91
99
|
eventName: "search_query_submitted",
|
|
92
100
|
properties: {
|
|
93
101
|
searchQuery: e.searchQuery
|
|
94
102
|
}
|
|
95
|
-
}), i.current[e.searchQuery] ? (p(i.current[e.searchQuery]), O(e)) : j(e).then(() => {
|
|
103
|
+
}), i.current[e.searchQuery] ? (p(i.current[e.searchQuery]), O(e)) : (m(!0), j(e).then(() => {
|
|
96
104
|
O(e);
|
|
97
|
-
});
|
|
98
|
-
},
|
|
105
|
+
}));
|
|
106
|
+
}, q);
|
|
99
107
|
},
|
|
100
|
-
[
|
|
101
|
-
),
|
|
108
|
+
[q, j]
|
|
109
|
+
), T = S(
|
|
102
110
|
() => ({
|
|
103
111
|
searchQuery: c,
|
|
104
112
|
filters: {
|
|
105
|
-
...
|
|
106
|
-
...
|
|
107
|
-
limit:
|
|
113
|
+
...v,
|
|
114
|
+
...E,
|
|
115
|
+
limit: k
|
|
108
116
|
}
|
|
109
117
|
}),
|
|
110
|
-
[c,
|
|
118
|
+
[c, k, v, E]
|
|
111
119
|
);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, [
|
|
115
|
-
const
|
|
116
|
-
(e) =>
|
|
120
|
+
P(() => {
|
|
121
|
+
W?.(T.searchQuery), H(T);
|
|
122
|
+
}, [H, T]);
|
|
123
|
+
const ee = n(
|
|
124
|
+
(e) => I(e.target.value),
|
|
117
125
|
[]
|
|
118
|
-
),
|
|
119
|
-
() =>
|
|
120
|
-
[
|
|
126
|
+
), te = S(
|
|
127
|
+
() => w || (g ? "Search..." : "Search for anything..."),
|
|
128
|
+
[w, g]
|
|
121
129
|
);
|
|
122
130
|
return {
|
|
123
131
|
results: t,
|
|
124
|
-
resultsList:
|
|
125
|
-
hasContent:
|
|
126
|
-
loading:
|
|
127
|
-
error:
|
|
132
|
+
resultsList: y,
|
|
133
|
+
hasContent: y.length > 0 || x,
|
|
134
|
+
loading: x,
|
|
135
|
+
error: J,
|
|
128
136
|
query: c,
|
|
129
|
-
onInput:
|
|
130
|
-
placeholder:
|
|
131
|
-
tab:
|
|
132
|
-
onTabChange:
|
|
133
|
-
selectedItem:
|
|
137
|
+
onInput: ee,
|
|
138
|
+
placeholder: te,
|
|
139
|
+
tab: b,
|
|
140
|
+
onTabChange: Z,
|
|
141
|
+
selectedItem: V,
|
|
134
142
|
setSelectedItem: a,
|
|
135
|
-
onSelectedItemChange:
|
|
136
|
-
transitionsDisabled:
|
|
137
|
-
inputRef:
|
|
138
|
-
isMobile:
|
|
143
|
+
onSelectedItemChange: X,
|
|
144
|
+
transitionsDisabled: Y,
|
|
145
|
+
inputRef: _,
|
|
146
|
+
isMobile: g
|
|
139
147
|
};
|
|
140
148
|
};
|
|
141
149
|
export {
|
|
142
|
-
|
|
150
|
+
ge as useInkeepSearch
|
|
143
151
|
};
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),y=require("../atoms/api/analytics/events.cjs"),B=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),f=({children:e})=>{const{baseSettings:s,componentType:n}=B.useInkeepConfig(),{apiKey:o,analyticsApiBaseUrl:r,tags:i,privacyPreferences:d,env:E}=s,{userProperties:c}=b.useUser(),a=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),y=require("../atoms/api/analytics/events.cjs"),B=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),f=({children:e})=>{const{baseSettings:s,componentType:n}=B.useInkeepConfig(),{apiKey:o,analyticsApiBaseUrl:r,tags:i,privacyPreferences:d,env:E}=s,{userProperties:c}=b.useUser(),a=t.useMemo(()=>({widgetLibraryVersion:"0.5.26",componentType:n,tags:i}),[n,i]),u=!d.optOutAllAnalytics&&E!=="development",g={logEvent:t.useCallback(async v=>{const m={...a,...v.properties},l={eventName:v.eventName,properties:m,userProperties:c};u&&y.logEvent(l,o,r),s.onEvent?.(l)},[u,s,o,r,c,a])};return P.jsx(p.Provider,{value:g,children:e})},x=()=>{const e=t.useContext(p);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=f;exports.useBaseEvents=x;
|
|
@@ -7,7 +7,7 @@ import { useUser as b } from "./user-provider.js";
|
|
|
7
7
|
const m = x(void 0), U = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: o } = C(), { apiKey: n, analyticsApiBaseUrl: s, tags: r, privacyPreferences: u, env: l } = t, { userProperties: i } = b(), a = d(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.26",
|
|
11
11
|
componentType: o,
|
|
12
12
|
tags: r
|
|
13
13
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@inkeep/cxkit-theme"),t=require("./tools/links-schema.cjs"),s={model:"inkeep-qa-expert",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],workflowsHeader:"Workflows",workflows:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},prompts:[],tools:[{type:"function",function:{name:"provideLinks",description:"Provides links",parameters:t.linksSchema}}],onToolCall:l=>{}},a={env:"production",apiKey:"",aiApiBaseUrl:"https://api.inkeep.com",analyticsApiBaseUrl:"https://api.io.inkeep.com",shouldBypassCaptcha:!1,privacyPreferences:{optOutAnalyticalCookies:!1,optOutAllAnalytics:!1,optOutFunctionalCookies:!1},tags:[],userProperties:{},primaryBrandColor:e.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},i={shouldOpenLinksInNewTab:!1,maxResults:40,defaultQuery:"",debounceTimeMs:0,tabs:["All","Publications","PDFs","GitHub","Forums","Discord","Slack","StackOverflow"],
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@inkeep/cxkit-theme"),t=require("./tools/links-schema.cjs"),s={model:"inkeep-qa-expert",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],workflowsHeader:"Workflows",workflows:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},prompts:[],tools:[{type:"function",function:{name:"provideLinks",description:"Provides links",parameters:t.linksSchema}}],onToolCall:l=>{}},a={env:"production",apiKey:"",aiApiBaseUrl:"https://api.inkeep.com",analyticsApiBaseUrl:"https://api.io.inkeep.com",shouldBypassCaptcha:!1,privacyPreferences:{optOutAnalyticalCookies:!1,optOutAllAnalytics:!1,optOutFunctionalCookies:!1},tags:[],userProperties:{},primaryBrandColor:e.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},i={shouldOpenLinksInNewTab:!1,maxResults:40,defaultQuery:"",debounceTimeMs:0,tabs:["All","Publications","PDFs","GitHub","Forums","Discord","Slack","StackOverflow"],placeholder:"Search for anything..."};exports.defaultInkeepAIChatSettings=s;exports.defaultInkeepBaseSettings=a;exports.defaultInkeepSearchSettings=i;
|
|
@@ -61,17 +61,16 @@ const i = {
|
|
|
61
61
|
varsClassName: "inkeep-widget-vars",
|
|
62
62
|
...e
|
|
63
63
|
}
|
|
64
|
-
},
|
|
64
|
+
}, p = {
|
|
65
65
|
shouldOpenLinksInNewTab: !1,
|
|
66
66
|
maxResults: 40,
|
|
67
67
|
defaultQuery: "",
|
|
68
68
|
debounceTimeMs: 0,
|
|
69
69
|
tabs: ["All", "Publications", "PDFs", "GitHub", "Forums", "Discord", "Slack", "StackOverflow"],
|
|
70
|
-
searchQueryParamKey: "q",
|
|
71
70
|
placeholder: "Search for anything..."
|
|
72
71
|
};
|
|
73
72
|
export {
|
|
74
73
|
i as defaultInkeepAIChatSettings,
|
|
75
74
|
n as defaultInkeepBaseSettings,
|
|
76
|
-
|
|
75
|
+
p as defaultInkeepSearchSettings
|
|
77
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(r,s,o,n,a){const e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...n},signal:a,body:JSON.stringify({query:s,variables:o})});if(!e.ok)throw new Error(`Network response was not OK (status: ${e.status})`);const t=await e.json();if(t.errors?.length)throw new Error(t.errors[0].message);return t.data}exports.graphqlRequest=i;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
async function
|
|
2
|
+
async function i(r, s, o, n, a) {
|
|
3
3
|
const t = await fetch(r, {
|
|
4
4
|
method: "POST",
|
|
5
5
|
headers: {
|
|
6
6
|
"Content-Type": "application/json",
|
|
7
7
|
...n
|
|
8
8
|
},
|
|
9
|
+
signal: a,
|
|
9
10
|
body: JSON.stringify({
|
|
10
11
|
query: s,
|
|
11
12
|
variables: o
|
|
@@ -19,5 +20,5 @@ async function a(r, s, o, n) {
|
|
|
19
20
|
return e.data;
|
|
20
21
|
}
|
|
21
22
|
export {
|
|
22
|
-
|
|
23
|
+
i as graphqlRequest
|
|
23
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20250313232451",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"rehype-raw": "7.0.0",
|
|
59
59
|
"unist-util-visit": "^5.0.0",
|
|
60
60
|
"use-sync-external-store": "^1.4.0",
|
|
61
|
-
"@inkeep/cxkit-color-mode": "0.0.0-dev-
|
|
62
|
-
"@inkeep/cxkit-theme": "0.0.0-dev-
|
|
63
|
-
"@inkeep/cxkit-types": "0.0.0-dev-
|
|
61
|
+
"@inkeep/cxkit-color-mode": "0.0.0-dev-20250313232451",
|
|
62
|
+
"@inkeep/cxkit-theme": "0.0.0-dev-20250313232451",
|
|
63
|
+
"@inkeep/cxkit-types": "0.0.0-dev-20250313232451"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@biomejs/biome": "1.9.4",
|