@nucleux/knowledge-base-picker 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nucleux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @nucleux/knowledge-base-picker
2
+
3
+ KnowledgeBasePicker — select the context files an agent may use — Nucleux agentic UI for React.
4
+
5
+ Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @nucleux/knowledge-base-picker @nucleux/tokens
11
+ ```
12
+
13
+ `react` / `react-dom` are peer dependencies.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { KnowledgeBasePicker } from "@nucleux/knowledge-base-picker";
19
+ ```
20
+
21
+ Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
22
+ and the Tailwind preset from `@nucleux/tokens/preset`.
23
+
24
+ ## License
25
+
26
+ MIT © Nucleux
package/dist/index.cjs ADDED
@@ -0,0 +1,95 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var utils = require('@nucleux/utils');
6
+ var lucideReact = require('lucide-react');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+
29
+ // src/index.tsx
30
+ var KnowledgeBasePicker = React__namespace.forwardRef(
31
+ ({ sources, value, defaultValue = [], onValueChange, heading = "Knowledge sources", className, ...props }, ref) => {
32
+ const [internal, setInternal] = React__namespace.useState(defaultValue);
33
+ const selected = value !== void 0 ? value : internal;
34
+ const toggle = (id) => {
35
+ const next = selected.includes(id) ? selected.filter((v) => v !== id) : [...selected, id];
36
+ if (value === void 0) setInternal(next);
37
+ onValueChange?.(next);
38
+ };
39
+ return /* @__PURE__ */ jsxRuntime.jsxs(
40
+ "div",
41
+ {
42
+ ref,
43
+ className: utils.cn("flex flex-col gap-2 rounded-xl border border-border bg-background p-3", className),
44
+ ...props,
45
+ children: [
46
+ heading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-1", children: [
47
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: heading }),
48
+ selected.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
49
+ selected.length,
50
+ " selected"
51
+ ] })
52
+ ] }),
53
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-1", children: sources.map((source) => {
54
+ const active = selected.includes(source.id);
55
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
56
+ "button",
57
+ {
58
+ type: "button",
59
+ role: "checkbox",
60
+ "aria-checked": active,
61
+ onClick: () => toggle(source.id),
62
+ className: utils.cn(
63
+ "flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
64
+ active ? "border-brand bg-brand-muted/40" : "border-transparent hover:bg-accent"
65
+ ),
66
+ children: [
67
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground [&_svg]:size-4", children: source.icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { "aria-hidden": "true" }) }),
68
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
69
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium text-foreground", children: source.name }),
70
+ source.meta && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: source.meta })
71
+ ] }),
72
+ /* @__PURE__ */ jsxRuntime.jsx(
73
+ "span",
74
+ {
75
+ className: utils.cn(
76
+ "inline-flex size-5 shrink-0 items-center justify-center rounded-md border transition-colors [&_svg]:size-3.5",
77
+ active ? "border-brand bg-brand text-brand-foreground" : "border-border"
78
+ ),
79
+ children: active && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { "aria-hidden": "true" })
80
+ }
81
+ )
82
+ ]
83
+ }
84
+ ) }, source.id);
85
+ }) })
86
+ ]
87
+ }
88
+ );
89
+ }
90
+ );
91
+ KnowledgeBasePicker.displayName = "KnowledgeBasePicker";
92
+
93
+ exports.KnowledgeBasePicker = KnowledgeBasePicker;
94
+ //# sourceMappingURL=index.cjs.map
95
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","jsxs","cn","jsx","FileText","Check"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,IAAM,mBAAA,GAA4BA,gBAAA,CAAA,UAAA;AAAA,EACvC,CAAC,EAAE,OAAA,EAAS,KAAA,EAAO,eAAe,EAAC,EAAG,aAAA,EAAe,OAAA,GAAU,mBAAA,EAAqB,SAAA,EAAW,GAAG,KAAA,IAAS,GAAA,KAAQ;AACjH,IAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAUA,0BAAmB,YAAY,CAAA;AACrE,IAAA,MAAM,QAAA,GAAW,KAAA,KAAU,MAAA,GAAY,KAAA,GAAQ,QAAA;AAC/C,IAAA,MAAM,MAAA,GAAS,CAAC,EAAA,KAAe;AAC7B,MAAA,MAAM,IAAA,GAAO,QAAA,CAAS,QAAA,CAAS,EAAE,IAAI,QAAA,CAAS,MAAA,CAAO,CAAC,CAAA,KAAM,MAAM,EAAE,CAAA,GAAI,CAAC,GAAG,UAAU,EAAE,CAAA;AACxF,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,WAAA,CAAY,IAAI,CAAA;AACzC,MAAA,aAAA,GAAgB,IAAI,CAAA;AAAA,IACtB,CAAA;AACA,IAAA,uBACEC,eAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAA,EAAWC,QAAA,CAAG,uEAAA,EAAyE,SAAS,CAAA;AAAA,QAC/F,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,OAAA,oBACCD,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,wCAAA,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AC3E,OAAO,IAAA,oBAAQA,cAAA,CAAC,UAAK,SAAA,EAAU,wCAAA,EAA0C,iBAAO,IAAA,EAAK;AAAA,mBAAA,EACxF,CAAA;AAAA,kCACAA,cAAA;AAAA,oBAAC,MAAA;AAAA,oBAAA;AAAA,sBACC,SAAA,EAAWD,QAAA;AAAA,wBACT,8GAAA;AAAA,wBACA,SAAS,6CAAA,GAAgD;AAAA,uBAC3D;AAAA,sBAEC,QAAA,EAAA,MAAA,oBAAUC,cAAA,CAACE,iBAAA,EAAA,EAAM,aAAA,EAAY,MAAA,EAAO;AAAA;AAAA;AACvC;AAAA;AAAA,aACF,EAAA,EA1BO,OAAO,EA2BhB,CAAA;AAAA,UAEJ,CAAC,CAAA,EACH;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,mBAAA,CAAoB,WAAA,GAAc,qBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\nimport { FileText, Check } from \"lucide-react\";\n\nexport interface KnowledgeSource {\n /** Stable id. */\n id: string;\n /** Source name, e.g. a filename. */\n name: React.ReactNode;\n /** Metadata line, e.g. `\"PDF · 12 pages\"`. */\n meta?: React.ReactNode;\n /** Leading icon. Defaults to a document glyph. */\n icon?: React.ReactNode;\n}\n\nexport interface KnowledgeBasePickerProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n /** The available knowledge sources. */\n sources: KnowledgeSource[];\n /** Selected source ids (controlled). */\n value?: string[];\n /** Initial selection (uncontrolled). */\n defaultValue?: string[];\n /** Called when the selection changes. */\n onValueChange?: (ids: string[]) => void;\n /** Heading above the list. Defaults to `\"Knowledge sources\"`. */\n heading?: React.ReactNode;\n}\n\n/**\n * A selectable list of context files/knowledge sources an agent may draw on —\n * curates the retrieval context for a turn.\n * Source: Figma \"Context Expansion / Knowledge Bases\".\n */\nexport const KnowledgeBasePicker = React.forwardRef<HTMLDivElement, KnowledgeBasePickerProps>(\n ({ sources, value, defaultValue = [], onValueChange, heading = \"Knowledge sources\", className, ...props }, ref) => {\n const [internal, setInternal] = React.useState<string[]>(defaultValue);\n const selected = value !== undefined ? value : internal;\n const toggle = (id: string) => {\n const next = selected.includes(id) ? selected.filter((v) => v !== id) : [...selected, id];\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n return (\n <div\n ref={ref}\n className={cn(\"flex flex-col gap-2 rounded-xl border border-border bg-background p-3\", className)}\n {...props}\n >\n {heading && (\n <div className=\"flex items-center justify-between px-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-muted-foreground\">{heading}</p>\n {selected.length > 0 && (\n <span className=\"text-xs text-muted-foreground\">{selected.length} selected</span>\n )}\n </div>\n )}\n <ul className=\"flex flex-col gap-1\">\n {sources.map((source) => {\n const active = selected.includes(source.id);\n return (\n <li key={source.id}>\n <button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={active}\n onClick={() => toggle(source.id)}\n className={cn(\n \"flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n active ? \"border-brand bg-brand-muted/40\" : \"border-transparent hover:bg-accent\",\n )}\n >\n <span className=\"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground [&_svg]:size-4\">\n {source.icon ?? <FileText aria-hidden=\"true\" />}\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate text-sm font-medium text-foreground\">{source.name}</span>\n {source.meta && <span className=\"truncate text-xs text-muted-foreground\">{source.meta}</span>}\n </span>\n <span\n className={cn(\n \"inline-flex size-5 shrink-0 items-center justify-center rounded-md border transition-colors [&_svg]:size-3.5\",\n active ? \"border-brand bg-brand text-brand-foreground\" : \"border-border\",\n )}\n >\n {active && <Check aria-hidden=\"true\" />}\n </span>\n </button>\n </li>\n );\n })}\n </ul>\n </div>\n );\n },\n);\nKnowledgeBasePicker.displayName = \"KnowledgeBasePicker\";\n"]}
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+
3
+ interface KnowledgeSource {
4
+ /** Stable id. */
5
+ id: string;
6
+ /** Source name, e.g. a filename. */
7
+ name: React.ReactNode;
8
+ /** Metadata line, e.g. `"PDF · 12 pages"`. */
9
+ meta?: React.ReactNode;
10
+ /** Leading icon. Defaults to a document glyph. */
11
+ icon?: React.ReactNode;
12
+ }
13
+ interface KnowledgeBasePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
14
+ /** The available knowledge sources. */
15
+ sources: KnowledgeSource[];
16
+ /** Selected source ids (controlled). */
17
+ value?: string[];
18
+ /** Initial selection (uncontrolled). */
19
+ defaultValue?: string[];
20
+ /** Called when the selection changes. */
21
+ onValueChange?: (ids: string[]) => void;
22
+ /** Heading above the list. Defaults to `"Knowledge sources"`. */
23
+ heading?: React.ReactNode;
24
+ }
25
+ /**
26
+ * A selectable list of context files/knowledge sources an agent may draw on —
27
+ * curates the retrieval context for a turn.
28
+ * Source: Figma "Context Expansion / Knowledge Bases".
29
+ */
30
+ declare const KnowledgeBasePicker: React.ForwardRefExoticComponent<KnowledgeBasePickerProps & React.RefAttributes<HTMLDivElement>>;
31
+
32
+ export { KnowledgeBasePicker, type KnowledgeBasePickerProps, type KnowledgeSource };
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+
3
+ interface KnowledgeSource {
4
+ /** Stable id. */
5
+ id: string;
6
+ /** Source name, e.g. a filename. */
7
+ name: React.ReactNode;
8
+ /** Metadata line, e.g. `"PDF · 12 pages"`. */
9
+ meta?: React.ReactNode;
10
+ /** Leading icon. Defaults to a document glyph. */
11
+ icon?: React.ReactNode;
12
+ }
13
+ interface KnowledgeBasePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
14
+ /** The available knowledge sources. */
15
+ sources: KnowledgeSource[];
16
+ /** Selected source ids (controlled). */
17
+ value?: string[];
18
+ /** Initial selection (uncontrolled). */
19
+ defaultValue?: string[];
20
+ /** Called when the selection changes. */
21
+ onValueChange?: (ids: string[]) => void;
22
+ /** Heading above the list. Defaults to `"Knowledge sources"`. */
23
+ heading?: React.ReactNode;
24
+ }
25
+ /**
26
+ * A selectable list of context files/knowledge sources an agent may draw on —
27
+ * curates the retrieval context for a turn.
28
+ * Source: Figma "Context Expansion / Knowledge Bases".
29
+ */
30
+ declare const KnowledgeBasePicker: React.ForwardRefExoticComponent<KnowledgeBasePickerProps & React.RefAttributes<HTMLDivElement>>;
31
+
32
+ export { KnowledgeBasePicker, type KnowledgeBasePickerProps, type KnowledgeSource };
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cn } from '@nucleux/utils';
4
+ import { FileText, Check } from 'lucide-react';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ // src/index.tsx
8
+ var KnowledgeBasePicker = React.forwardRef(
9
+ ({ sources, value, defaultValue = [], onValueChange, heading = "Knowledge sources", className, ...props }, ref) => {
10
+ const [internal, setInternal] = React.useState(defaultValue);
11
+ const selected = value !== void 0 ? value : internal;
12
+ const toggle = (id) => {
13
+ const next = selected.includes(id) ? selected.filter((v) => v !== id) : [...selected, id];
14
+ if (value === void 0) setInternal(next);
15
+ onValueChange?.(next);
16
+ };
17
+ return /* @__PURE__ */ jsxs(
18
+ "div",
19
+ {
20
+ ref,
21
+ className: cn("flex flex-col gap-2 rounded-xl border border-border bg-background p-3", className),
22
+ ...props,
23
+ children: [
24
+ heading && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-1", children: [
25
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: heading }),
26
+ selected.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
27
+ selected.length,
28
+ " selected"
29
+ ] })
30
+ ] }),
31
+ /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", children: sources.map((source) => {
32
+ const active = selected.includes(source.id);
33
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ role: "checkbox",
38
+ "aria-checked": active,
39
+ onClick: () => toggle(source.id),
40
+ className: cn(
41
+ "flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
42
+ active ? "border-brand bg-brand-muted/40" : "border-transparent hover:bg-accent"
43
+ ),
44
+ children: [
45
+ /* @__PURE__ */ jsx("span", { className: "inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground [&_svg]:size-4", children: source.icon ?? /* @__PURE__ */ jsx(FileText, { "aria-hidden": "true" }) }),
46
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
47
+ /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: source.name }),
48
+ source.meta && /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: source.meta })
49
+ ] }),
50
+ /* @__PURE__ */ jsx(
51
+ "span",
52
+ {
53
+ className: cn(
54
+ "inline-flex size-5 shrink-0 items-center justify-center rounded-md border transition-colors [&_svg]:size-3.5",
55
+ active ? "border-brand bg-brand text-brand-foreground" : "border-border"
56
+ ),
57
+ children: active && /* @__PURE__ */ jsx(Check, { "aria-hidden": "true" })
58
+ }
59
+ )
60
+ ]
61
+ }
62
+ ) }, source.id);
63
+ }) })
64
+ ]
65
+ }
66
+ );
67
+ }
68
+ );
69
+ KnowledgeBasePicker.displayName = "KnowledgeBasePicker";
70
+
71
+ export { KnowledgeBasePicker };
72
+ //# sourceMappingURL=index.js.map
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAkCO,IAAM,mBAAA,GAA4B,KAAA,CAAA,UAAA;AAAA,EACvC,CAAC,EAAE,OAAA,EAAS,KAAA,EAAO,eAAe,EAA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,CAAA;AAAA,UAEJ,CAAC,CAAA,EACH;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,mBAAA,CAAoB,WAAA,GAAc,qBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\nimport { FileText, Check } from \"lucide-react\";\n\nexport interface KnowledgeSource {\n /** Stable id. */\n id: string;\n /** Source name, e.g. a filename. */\n name: React.ReactNode;\n /** Metadata line, e.g. `\"PDF · 12 pages\"`. */\n meta?: React.ReactNode;\n /** Leading icon. Defaults to a document glyph. */\n icon?: React.ReactNode;\n}\n\nexport interface KnowledgeBasePickerProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n /** The available knowledge sources. */\n sources: KnowledgeSource[];\n /** Selected source ids (controlled). */\n value?: string[];\n /** Initial selection (uncontrolled). */\n defaultValue?: string[];\n /** Called when the selection changes. */\n onValueChange?: (ids: string[]) => void;\n /** Heading above the list. Defaults to `\"Knowledge sources\"`. */\n heading?: React.ReactNode;\n}\n\n/**\n * A selectable list of context files/knowledge sources an agent may draw on —\n * curates the retrieval context for a turn.\n * Source: Figma \"Context Expansion / Knowledge Bases\".\n */\nexport const KnowledgeBasePicker = React.forwardRef<HTMLDivElement, KnowledgeBasePickerProps>(\n ({ sources, value, defaultValue = [], onValueChange, heading = \"Knowledge sources\", className, ...props }, ref) => {\n const [internal, setInternal] = React.useState<string[]>(defaultValue);\n const selected = value !== undefined ? value : internal;\n const toggle = (id: string) => {\n const next = selected.includes(id) ? selected.filter((v) => v !== id) : [...selected, id];\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n return (\n <div\n ref={ref}\n className={cn(\"flex flex-col gap-2 rounded-xl border border-border bg-background p-3\", className)}\n {...props}\n >\n {heading && (\n <div className=\"flex items-center justify-between px-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-muted-foreground\">{heading}</p>\n {selected.length > 0 && (\n <span className=\"text-xs text-muted-foreground\">{selected.length} selected</span>\n )}\n </div>\n )}\n <ul className=\"flex flex-col gap-1\">\n {sources.map((source) => {\n const active = selected.includes(source.id);\n return (\n <li key={source.id}>\n <button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={active}\n onClick={() => toggle(source.id)}\n className={cn(\n \"flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n active ? \"border-brand bg-brand-muted/40\" : \"border-transparent hover:bg-accent\",\n )}\n >\n <span className=\"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground [&_svg]:size-4\">\n {source.icon ?? <FileText aria-hidden=\"true\" />}\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate text-sm font-medium text-foreground\">{source.name}</span>\n {source.meta && <span className=\"truncate text-xs text-muted-foreground\">{source.meta}</span>}\n </span>\n <span\n className={cn(\n \"inline-flex size-5 shrink-0 items-center justify-center rounded-md border transition-colors [&_svg]:size-3.5\",\n active ? \"border-brand bg-brand text-brand-foreground\" : \"border-border\",\n )}\n >\n {active && <Check aria-hidden=\"true\" />}\n </span>\n </button>\n </li>\n );\n })}\n </ul>\n </div>\n );\n },\n);\nKnowledgeBasePicker.displayName = \"KnowledgeBasePicker\";\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nucleux/knowledge-base-picker",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "KnowledgeBasePicker — select the context files an agent may use — Nucleux agentic UI for React.",
7
+ "keywords": [
8
+ "nucleux",
9
+ "react",
10
+ "ui",
11
+ "components",
12
+ "agentic",
13
+ "ai",
14
+ "tailwind",
15
+ "knowledge-base-picker"
16
+ ],
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "peerDependencies": {
32
+ "react": ">=18",
33
+ "react-dom": ">=18"
34
+ },
35
+ "dependencies": {
36
+ "lucide-react": "^0.469.0",
37
+ "@nucleux/utils": "0.1.1"
38
+ },
39
+ "devDependencies": {
40
+ "tsup": "^8.3.5",
41
+ "typescript": "^5.7.2",
42
+ "@types/react": "^18.3.18",
43
+ "react": "^18.3.1"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
52
+ "directory": "packages/knowledge-base-picker"
53
+ },
54
+ "homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
55
+ "scripts": {
56
+ "build": "tsup"
57
+ }
58
+ }