@inkeep/cxkit-primitives 0.0.0-dev-20250301022441 → 0.0.0-dev-20250301024154
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/components/embedded-search/transform-results.cjs +1 -1
- package/dist/components/embedded-search/transform-results.js +1 -1
- package/dist/utils/transform-source/index.cjs +1 -1
- package/dist/utils/transform-source/index.js +11 -11
- package/dist/utils/transform-source/tabs.cjs +1 -1
- package/dist/utils/transform-source/tabs.js +5 -5
- package/package.json +4 -4
|
@@ -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"),k=(e,o)=>{const{baseSettings:{transformSource:r,organizationDisplayName:s},searchSettings:{tabs:u,searchQueryParamKey:p,shouldOpenLinksInNewTab:g}}=S.useInkeepConfig();return w.useMemo(()=>{const R=u.length>0?u:["All"],n={},y=new Set,i=R.map(t=>typeof t=="string"?t:t[0]);for(const t of i)n[t]=[];for(const t of e){const c=t.url||"";if(y.has(c))continue;y.add(c);const d=v(c,o,p),a=T.transformInkeepSource({title:t.title,url:d,description:I(t),type:_(t.rootRecord.__typename),tag:D(t),breadcrumbs:t.rootRecord.pathBreadcrumbs,contentType:t.rootRecord.contentType},"searchResultItem",{organizationDisplayName:s,tabs:u,transformSource:r}),l={...a,id:t.id,isExternal:g||!!a.shouldOpenInNewTab},h=l.tabs||[];for(const f of h){const b=typeof f=="string"?f:f[0];if(!i.includes(b)){console.warn(`Tab "${b}" found in item but not configured in tabs`);continue}n[b].push(l)}i.includes("All")&&n.All.push(l)}for(const t of Object.keys(n)){const c=R.find(a=>typeof a=="string"?a===t:a[0]===t),d=typeof c=="object"?c[1]?.isAlwaysVisible===!0:!1;n[t].length===0&&!d&&delete n[t]}return n},[e,r,s,u,o,p,g])};function v(e,o,r){try{const s=new URL(e);return s.searchParams.set(r,o),s.toString()}catch{return e}}const I=e=>{switch(e.rootRecord.__typename){case"DocumentationRecord":{const o=m(e.pathHeadings?.at(-1)?.content||""),r=m(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}},m=e=>{const o=/(https?:\/\/\S+)/g;return e.replace(o,r=>{const s=r.split("/");return s.length>3?`...${s.slice(-2).join("/")}`:r})},_=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=k;
|
|
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"),k=(e,o)=>{const{baseSettings:{transformSource:r,organizationDisplayName:s},searchSettings:{tabs:u,searchQueryParamKey:p,shouldOpenLinksInNewTab:g}}=S.useInkeepConfig();return w.useMemo(()=>{const R=u.length>0?u:["All"],n={},y=new Set,i=R.map(t=>typeof t=="string"?t:t[0]);for(const t of i)n[t]=[];for(const t of e){const c=t.url||"";if(y.has(c))continue;y.add(c);const d=v(c,o,p),a=T.transformInkeepSource({title:t.title,url:d,description:I(t),type:_(t.rootRecord.__typename),tag:D(t),breadcrumbs:t.rootRecord.pathBreadcrumbs??[],contentType:t.rootRecord.contentType},"searchResultItem",{organizationDisplayName:s,tabs:u,transformSource:r}),l={...a,id:t.id,isExternal:g||!!a.shouldOpenInNewTab},h=l.tabs||[];for(const f of h){const b=typeof f=="string"?f:f[0];if(!i.includes(b)){console.warn(`Tab "${b}" found in item but not configured in tabs`);continue}n[b].push(l)}i.includes("All")&&n.All.push(l)}for(const t of Object.keys(n)){const c=R.find(a=>typeof a=="string"?a===t:a[0]===t),d=typeof c=="object"?c[1]?.isAlwaysVisible===!0:!1;n[t].length===0&&!d&&delete n[t]}return n},[e,r,s,u,o,p,g])};function v(e,o,r){try{const s=new URL(e);return s.searchParams.set(r,o),s.toString()}catch{return e}}const I=e=>{switch(e.rootRecord.__typename){case"DocumentationRecord":{const o=m(e.pathHeadings?.at(-1)?.content||""),r=m(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}},m=e=>{const o=/(https?:\/\/\S+)/g;return e.replace(o,r=>{const s=r.split("/");return s.length>3?`...${s.slice(-2).join("/")}`:r})},_=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=k;
|
|
@@ -22,7 +22,7 @@ const C = (e, o) => {
|
|
|
22
22
|
description: T(t),
|
|
23
23
|
type: D(t.rootRecord.__typename),
|
|
24
24
|
tag: v(t),
|
|
25
|
-
breadcrumbs: t.rootRecord.pathBreadcrumbs,
|
|
25
|
+
breadcrumbs: t.rootRecord.pathBreadcrumbs ?? [],
|
|
26
26
|
contentType: t.rootRecord.contentType
|
|
27
27
|
},
|
|
28
28
|
"searchResultItem",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./breadcrumbs.cjs"),c=require("./description.cjs"),d=require("./icon.cjs"),l=require("./tabs.cjs"),u=require("./title.cjs"),p=(e,n,r)=>{const{transformSource:a,...o}=r,i=b.getBreadcrumbs(e,r),s=l.getTabs(e,r),t=a?.({...e,breadcrumbs:i,tabs:s},n,o)??{};return{id:t?.id??e.id,title:t?.title??u.getTitle(e,r),description:t?.description??c.getDescription(e,n),breadcrumbs:t?.breadcrumbs??i,icon:t?.icon??d.getIcon(e),tabs:t?.tabs??s,url:t?.url??e.url,tag:t?.tag??e.tag,type:t?.type??e.type,shouldOpenInNewTab:t?.shouldOpenInNewTab??void 0,appendToUrl:t?.appendToUrl??void 0}};exports.transformInkeepSource=p;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { getBreadcrumbs as
|
|
2
|
-
import { getDescription as
|
|
3
|
-
import { getIcon as
|
|
4
|
-
import { getTabs as
|
|
1
|
+
import { getBreadcrumbs as d } from "./breadcrumbs.js";
|
|
2
|
+
import { getDescription as p } from "./description.js";
|
|
3
|
+
import { getIcon as b } from "./icon.js";
|
|
4
|
+
import { getTabs as s } from "./tabs.js";
|
|
5
5
|
import { getTitle as l } from "./title.js";
|
|
6
|
-
const
|
|
7
|
-
const { transformSource:
|
|
6
|
+
const h = (r, n, e) => {
|
|
7
|
+
const { transformSource: a, ...m } = e, i = d(r, e), o = s(r, e), t = a?.({ ...r, breadcrumbs: i, tabs: o }, n, m) ?? {};
|
|
8
8
|
return {
|
|
9
9
|
id: t?.id ?? r.id,
|
|
10
10
|
title: t?.title ?? l(r, e),
|
|
11
|
-
description: t?.description ??
|
|
12
|
-
breadcrumbs: t?.breadcrumbs ??
|
|
13
|
-
icon: t?.icon ??
|
|
14
|
-
tabs: t?.tabs ??
|
|
11
|
+
description: t?.description ?? p(r, n),
|
|
12
|
+
breadcrumbs: t?.breadcrumbs ?? i,
|
|
13
|
+
icon: t?.icon ?? b(r),
|
|
14
|
+
tabs: t?.tabs ?? o,
|
|
15
15
|
url: t?.url ?? r.url,
|
|
16
16
|
tag: t?.tag ?? r.tag,
|
|
17
17
|
type: t?.type ?? r.type,
|
|
@@ -20,5 +20,5 @@ const I = (r, i, e) => {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
h as transformInkeepSource
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./utils/misc.cjs"),o=(t,n)=>{const s=[];t.type==="documentation"&&t.contentType==="book"?s.push("Publications"):t.type==="documentation"&&t.contentType==="pdf"&&s.push("PDFs"),(t.type==="github_issue"||b.isGitHubUrl(t.url))&&s.push("GitHub"),t.type==="discourse"&&s.push("Forums"),t.type==="discord"&&s.push("Discord"),t.type==="slack_message"&&s.push("Slack"),t.type==="stackoverflow"&&s.push("StackOverflow");const i=[],a=n?.tabs?.map(e=>typeof e=="string"?e:e[0]);for(const e of s)a?.includes(e)&&(e===t.breadcrumbs?.[0]?i.push([e,{breadcrumbs:t.breadcrumbs?.slice(1)}]):i.push(e));return console.log("tabsWithBreadcrumbs",s,a),i};exports.getTabs=o;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isGitHubUrl as n } from "./utils/misc.js";
|
|
3
|
-
const
|
|
3
|
+
const b = (t, a) => {
|
|
4
4
|
const s = [];
|
|
5
5
|
t.type === "documentation" && t.contentType === "book" ? s.push("Publications") : t.type === "documentation" && t.contentType === "pdf" && s.push("PDFs"), (t.type === "github_issue" || n(t.url)) && s.push("GitHub"), t.type === "discourse" && s.push("Forums"), t.type === "discord" && s.push("Discord"), t.type === "slack_message" && s.push("Slack"), t.type === "stackoverflow" && s.push("StackOverflow");
|
|
6
|
-
const e = [],
|
|
6
|
+
const e = [], p = a?.tabs?.map((i) => typeof i == "string" ? i : i[0]);
|
|
7
7
|
for (const i of s)
|
|
8
|
-
|
|
9
|
-
return e;
|
|
8
|
+
p?.includes(i) && (i === t.breadcrumbs?.[0] ? e.push([i, { breadcrumbs: t.breadcrumbs?.slice(1) }]) : e.push(i));
|
|
9
|
+
return console.log("tabsWithBreadcrumbs", s, p), e;
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
b as getTabs
|
|
13
13
|
};
|
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-20250301024154",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"react-textarea-autosize": "8.5.7",
|
|
55
55
|
"rehype-raw": "7.0.0",
|
|
56
56
|
"unist-util-visit": "^5.0.0",
|
|
57
|
-
"@inkeep/cxkit-color-mode": "0.0.0-dev-
|
|
58
|
-
"@inkeep/cxkit-theme": "0.0.0-dev-
|
|
59
|
-
"@inkeep/cxkit-types": "0.0.0-dev-
|
|
57
|
+
"@inkeep/cxkit-color-mode": "0.0.0-dev-20250301024154",
|
|
58
|
+
"@inkeep/cxkit-theme": "0.0.0-dev-20250301024154",
|
|
59
|
+
"@inkeep/cxkit-types": "0.0.0-dev-20250301024154"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@biomejs/biome": "1.9.4",
|