@inkeep/cxkit-primitives 0.5.103 → 0.5.105
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),B=require("../../atoms/cmdk/index.cjs"),F=require("../../providers/search-events-provider.cjs"),L=require("../../providers/config-provider.cjs"),P=require("../../utils/graphql-client.cjs"),H=require("./search-query.graphql.cjs"),O=require("./search-provider.cjs"),j=250,x=()=>{const{setResultsList:o,setLoading:u,showSearchResults:a,setShowSearchResults:i}=O.useSearch(),{baseSettings:_,searchSettings:A}=L.useInkeepConfig(),{apiKey:y,aiApiBaseUrl:k,userAuthToken:l,filters:R}=_,{maxResults:m,searchApiBaseUrl:M,debounceTimeMs:S,onQueryChange:U,filters:b}=A,{logEvent:g}=F.useSearchEvents(),t=r.useRef({}),h=r.useRef(null),f=r.useRef(null),T=`${M||k}/graphql`,q=r.useMemo(()=>({Authorization:`Bearer ${y}`,"Content-Type":"application/json",...l?{"User-Token":l}:{}}),[y,l]),w=r.useCallback(async e=>{const s=new AbortController;h.current=s;try{const E=(await P.graphqlRequest(T,H.default,{searchInput:e},q,s.signal))?.search.searchHits;t.current[e.searchQuery]=E,o(E)}catch(C){if(C.name==="AbortError")return}finally{u(!1)}},[T,q]),Q=r.useCallback(e=>{const s=t.current[e.searchQuery];g({eventName:"search_query_response_received",properties:{searchQuery:e.searchQuery,totalResults:s?.length}})},[]),p=()=>{h.current&&(h.current.abort(),u(!1))},v=r.useCallback(e=>{if(f.current&&window.clearTimeout(f.current),!e.searchQuery){p(),o([]);return}f.current=window.setTimeout(()=>{p(),g({eventName:"search_query_submitted",properties:{searchQuery:e.searchQuery}}),t.current[e.searchQuery]?(o(t.current[e.searchQuery]),Q(e)):(u(!0),w(e).then(()=>{Q(e)}))},S)},[S,w]),c=B.useCommandState(e=>e.search),d=r.useMemo(()=>({searchQuery:c,filters:{...R,...b,limit:m}}),[c,m,R,b]),n=r.useRef(null);r.useEffect(()=>{const e=()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},s=!!c;return s&&!a?(e(),n.current=window.setTimeout(()=>{i(!0)},j)):!s&&a&&(e(),i(!1)),e},[c,a,i]),r.useEffect(()=>{U?.(d.searchQuery),v(d)},[v,d])};exports.useSearchFetch=x;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as n, useMemo as
|
|
3
|
-
import { useCommandState as
|
|
4
|
-
import { useSearchEvents as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { graphqlRequest as
|
|
7
|
-
import
|
|
8
|
-
import { useSearch as
|
|
9
|
-
const
|
|
10
|
-
const { setResultsList: c, setLoading:
|
|
2
|
+
import { useRef as n, useMemo as v, useCallback as y, useEffect as k } from "react";
|
|
3
|
+
import { useCommandState as M } from "../../atoms/cmdk/index.js";
|
|
4
|
+
import { useSearchEvents as x } from "../../providers/search-events-provider.js";
|
|
5
|
+
import { useInkeepConfig as N } from "../../providers/config-provider.js";
|
|
6
|
+
import { graphqlRequest as O } from "../../utils/graphql-client.js";
|
|
7
|
+
import $ from "./search-query.graphql.js";
|
|
8
|
+
import { useSearch as j } from "./search-provider.js";
|
|
9
|
+
const z = 250, X = () => {
|
|
10
|
+
const { setResultsList: c, setLoading: a, showSearchResults: u, setShowSearchResults: i } = j(), { baseSettings: U, searchSettings: B } = N(), { apiKey: p, aiApiBaseUrl: L, userAuthToken: l, filters: R } = U, { maxResults: d, searchApiBaseUrl: F, debounceTimeMs: S, onQueryChange: H, filters: w } = B, { logEvent: T } = x(), t = n({}), h = n(null), m = n(null), Q = `${F || L}/graphql`, b = v(
|
|
11
11
|
() => ({
|
|
12
|
-
Authorization: `Bearer ${
|
|
12
|
+
Authorization: `Bearer ${p}`,
|
|
13
13
|
"Content-Type": "application/json",
|
|
14
14
|
...l ? { "User-Token": l } : {}
|
|
15
15
|
}),
|
|
16
|
-
[
|
|
16
|
+
[p, l]
|
|
17
17
|
), g = y(
|
|
18
18
|
async (e) => {
|
|
19
19
|
const r = new AbortController();
|
|
20
20
|
h.current = r;
|
|
21
21
|
try {
|
|
22
|
-
const
|
|
22
|
+
const q = (await O(
|
|
23
23
|
Q,
|
|
24
|
-
|
|
24
|
+
$,
|
|
25
25
|
{ searchInput: e },
|
|
26
26
|
b,
|
|
27
27
|
r.signal
|
|
28
28
|
))?.search.searchHits;
|
|
29
|
-
t.current[e.searchQuery] =
|
|
30
|
-
} catch (
|
|
31
|
-
if (
|
|
29
|
+
t.current[e.searchQuery] = q, c(q);
|
|
30
|
+
} catch (E) {
|
|
31
|
+
if (E.name === "AbortError")
|
|
32
32
|
return;
|
|
33
33
|
} finally {
|
|
34
|
-
|
|
34
|
+
a(!1);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
[Q, b]
|
|
@@ -45,8 +45,8 @@ const j = 250, V = () => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
}, []), _ = () => {
|
|
48
|
-
h.current && (h.current.abort(),
|
|
49
|
-
},
|
|
48
|
+
h.current && (h.current.abort(), a(!1));
|
|
49
|
+
}, A = y(
|
|
50
50
|
(e) => {
|
|
51
51
|
if (m.current && window.clearTimeout(m.current), !e.searchQuery) {
|
|
52
52
|
_(), c([]);
|
|
@@ -58,34 +58,34 @@ const j = 250, V = () => {
|
|
|
58
58
|
properties: {
|
|
59
59
|
searchQuery: e.searchQuery
|
|
60
60
|
}
|
|
61
|
-
}), t.current[e.searchQuery] ? (c(t.current[e.searchQuery]), C(e)) : (
|
|
61
|
+
}), t.current[e.searchQuery] ? (c(t.current[e.searchQuery]), C(e)) : (a(!0), g(e).then(() => {
|
|
62
62
|
C(e);
|
|
63
63
|
}));
|
|
64
64
|
}, S);
|
|
65
65
|
},
|
|
66
66
|
[S, g]
|
|
67
|
-
), s =
|
|
67
|
+
), s = M((e) => e.search), f = v(
|
|
68
68
|
() => ({
|
|
69
69
|
searchQuery: s,
|
|
70
70
|
filters: {
|
|
71
|
-
...
|
|
71
|
+
...R,
|
|
72
72
|
...w,
|
|
73
|
-
limit:
|
|
73
|
+
limit: d
|
|
74
74
|
}
|
|
75
75
|
}),
|
|
76
|
-
[s,
|
|
76
|
+
[s, d, R, w]
|
|
77
77
|
), o = n(null);
|
|
78
78
|
k(() => {
|
|
79
79
|
const e = () => {
|
|
80
80
|
o.current !== null && (window.clearTimeout(o.current), o.current = null);
|
|
81
81
|
}, r = !!s;
|
|
82
|
-
return r && !
|
|
82
|
+
return r && !u ? (e(), o.current = window.setTimeout(() => {
|
|
83
83
|
i(!0);
|
|
84
|
-
},
|
|
85
|
-
}, [s,
|
|
86
|
-
|
|
87
|
-
}, [
|
|
84
|
+
}, z)) : !r && u && (e(), i(!1)), e;
|
|
85
|
+
}, [s, u, i]), k(() => {
|
|
86
|
+
H?.(f.searchQuery), A(f);
|
|
87
|
+
}, [A, f]);
|
|
88
88
|
};
|
|
89
89
|
export {
|
|
90
|
-
|
|
90
|
+
X as useSearchFetch
|
|
91
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.105",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
|
|
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
|
|
|
7
7
|
const u = B(void 0), $ = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.105",
|
|
11
11
|
componentType: s,
|
|
12
12
|
tags: a
|
|
13
13
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.105",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"remark-gfm": "^4.0.1",
|
|
68
68
|
"unist-util-visit": "^5.0.0",
|
|
69
69
|
"use-sync-external-store": "^1.4.0",
|
|
70
|
-
"@inkeep/cxkit-color-mode": "^0.5.
|
|
71
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
72
|
-
"@inkeep/cxkit-types": "0.5.
|
|
70
|
+
"@inkeep/cxkit-color-mode": "^0.5.105",
|
|
71
|
+
"@inkeep/cxkit-theme": "0.5.105",
|
|
72
|
+
"@inkeep/cxkit-types": "0.5.105"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@biomejs/biome": "1.9.4",
|