@nucleux/attachment-tile 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 +21 -0
- package/README.md +26 -0
- package/dist/index.cjs +96 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
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/attachment-tile
|
|
2
|
+
|
|
3
|
+
AttachmentTile — removable file and image context tiles for the composer — 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/attachment-tile @nucleux/tokens
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` / `react-dom` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { AttachmentTile } from "@nucleux/attachment-tile";
|
|
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,96 @@
|
|
|
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 AttachmentTile = React__namespace.forwardRef(
|
|
31
|
+
({ name, meta, thumbnail, icon, onRemove, className, ...props }, ref) => {
|
|
32
|
+
const remove = onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
type: "button",
|
|
36
|
+
"aria-label": `Remove ${typeof name === "string" ? name : "attachment"}`,
|
|
37
|
+
onClick: onRemove,
|
|
38
|
+
className: utils.cn(
|
|
39
|
+
"inline-flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
|
|
40
|
+
thumbnail && "absolute right-1 top-1 bg-background/80 backdrop-blur"
|
|
41
|
+
),
|
|
42
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
if (thumbnail) {
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
ref,
|
|
50
|
+
className: utils.cn("relative size-16 overflow-hidden rounded-lg border border-border bg-muted", className),
|
|
51
|
+
...props,
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"img",
|
|
55
|
+
{
|
|
56
|
+
src: thumbnail,
|
|
57
|
+
alt: typeof name === "string" ? name : "",
|
|
58
|
+
className: "size-full object-cover"
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
remove
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
className: utils.cn(
|
|
71
|
+
"inline-flex max-w-64 items-center gap-2.5 rounded-lg border border-border bg-background py-2 pl-2.5 pr-2",
|
|
72
|
+
className
|
|
73
|
+
),
|
|
74
|
+
...props,
|
|
75
|
+
children: [
|
|
76
|
+
/* @__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: icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { "aria-hidden": "true" }) }),
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium text-foreground", children: name }),
|
|
79
|
+
meta && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: meta })
|
|
80
|
+
] }),
|
|
81
|
+
remove
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
AttachmentTile.displayName = "AttachmentTile";
|
|
88
|
+
var AttachmentTray = React__namespace.forwardRef(
|
|
89
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: utils.cn("flex flex-wrap items-start gap-2", className), ...props })
|
|
90
|
+
);
|
|
91
|
+
AttachmentTray.displayName = "AttachmentTray";
|
|
92
|
+
|
|
93
|
+
exports.AttachmentTile = AttachmentTile;
|
|
94
|
+
exports.AttachmentTray = AttachmentTray;
|
|
95
|
+
//# sourceMappingURL=index.cjs.map
|
|
96
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","jsx","cn","X","jsxs","FileText"],"mappings":";;;;;;;;;;;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EJ,QAAA,EAAA;AAAA,0BAAAD,cAAA,CAAC,MAAA,EAAA,EAAK,WAAU,kHAAA,EACb,QAAA,EAAA,IAAA,mCAASI,oBAAA,EAAA,EAAS,aAAA,EAAY,QAAO,CAAA,EACxC,CAAA;AAAA,0BACAD,eAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,uBAAA,EACd,QAAA,EAAA;AAAA,4BAAAH,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,8CAAA,EAAgD,QAAA,EAAA,IAAA,EAAK,CAAA;AAAA,YACpE,IAAA,oBAAQA,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,0CAA0C,QAAA,EAAA,IAAA,EAAK;AAAA,WAAA,EAC1E,CAAA;AAAA,UACC;AAAA;AAAA;AAAA,KACH;AAAA,EAEJ;AACF;AACA,cAAA,CAAe,WAAA,GAAc,gBAAA;AAKtB,IAAM,cAAA,GAAuBD,gBAAA,CAAA,UAAA;AAAA,EAClC,CAAC,EAAE,SAAA,EAAW,GAAG,KAAA,IAAS,GAAA,qBACxBC,cAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,WAAWC,QAAA,CAAG,kCAAA,EAAoC,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO;AAE5F;AACA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\nimport { FileText, X } from \"lucide-react\";\n\nexport interface AttachmentTileProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** File or attachment name. */\n name: React.ReactNode;\n /** Metadata line, e.g. `\"PDF · 240 KB\"`. */\n meta?: React.ReactNode;\n /** Image URL — renders a thumbnail tile instead of a document chip. */\n thumbnail?: string;\n /** Doctype icon for the document chip. Defaults to a document glyph. */\n icon?: React.ReactNode;\n /** Called when the remove control is used. Hidden if omitted. */\n onRemove?: () => void;\n}\n\n/**\n * A removable preview of a file or image attached as context to an agent turn —\n * document chip or image thumbnail. The multimodal-context affordance.\n * Source: Figma \"Context Expansion / File Attachment\".\n */\nexport const AttachmentTile = React.forwardRef<HTMLDivElement, AttachmentTileProps>(\n ({ name, meta, thumbnail, icon, onRemove, className, ...props }, ref) => {\n const remove = onRemove && (\n <button\n type=\"button\"\n aria-label={`Remove ${typeof name === \"string\" ? name : \"attachment\"}`}\n onClick={onRemove}\n className={cn(\n \"inline-flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5\",\n thumbnail && \"absolute right-1 top-1 bg-background/80 backdrop-blur\",\n )}\n >\n <X aria-hidden=\"true\" />\n </button>\n );\n\n if (thumbnail) {\n return (\n <div\n ref={ref}\n className={cn(\"relative size-16 overflow-hidden rounded-lg border border-border bg-muted\", className)}\n {...props}\n >\n <img\n src={thumbnail}\n alt={typeof name === \"string\" ? name : \"\"}\n className=\"size-full object-cover\"\n />\n {remove}\n </div>\n );\n }\n\n return (\n <div\n ref={ref}\n className={cn(\n \"inline-flex max-w-64 items-center gap-2.5 rounded-lg border border-border bg-background py-2 pl-2.5 pr-2\",\n className,\n )}\n {...props}\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 {icon ?? <FileText aria-hidden=\"true\" />}\n </span>\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"truncate text-sm font-medium text-foreground\">{name}</span>\n {meta && <span className=\"truncate text-xs text-muted-foreground\">{meta}</span>}\n </span>\n {remove}\n </div>\n );\n },\n);\nAttachmentTile.displayName = \"AttachmentTile\";\n\nexport interface AttachmentTrayProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/** A wrapping row of {@link AttachmentTile}s, shown above the composer. */\nexport const AttachmentTray = React.forwardRef<HTMLDivElement, AttachmentTrayProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-wrap items-start gap-2\", className)} {...props} />\n ),\n);\nAttachmentTray.displayName = \"AttachmentTray\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface AttachmentTileProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
4
|
+
/** File or attachment name. */
|
|
5
|
+
name: React.ReactNode;
|
|
6
|
+
/** Metadata line, e.g. `"PDF · 240 KB"`. */
|
|
7
|
+
meta?: React.ReactNode;
|
|
8
|
+
/** Image URL — renders a thumbnail tile instead of a document chip. */
|
|
9
|
+
thumbnail?: string;
|
|
10
|
+
/** Doctype icon for the document chip. Defaults to a document glyph. */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** Called when the remove control is used. Hidden if omitted. */
|
|
13
|
+
onRemove?: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A removable preview of a file or image attached as context to an agent turn —
|
|
17
|
+
* document chip or image thumbnail. The multimodal-context affordance.
|
|
18
|
+
* Source: Figma "Context Expansion / File Attachment".
|
|
19
|
+
*/
|
|
20
|
+
declare const AttachmentTile: React.ForwardRefExoticComponent<AttachmentTileProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
interface AttachmentTrayProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
}
|
|
23
|
+
/** A wrapping row of {@link AttachmentTile}s, shown above the composer. */
|
|
24
|
+
declare const AttachmentTray: React.ForwardRefExoticComponent<AttachmentTrayProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
|
|
26
|
+
export { AttachmentTile, type AttachmentTileProps, AttachmentTray, type AttachmentTrayProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface AttachmentTileProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
4
|
+
/** File or attachment name. */
|
|
5
|
+
name: React.ReactNode;
|
|
6
|
+
/** Metadata line, e.g. `"PDF · 240 KB"`. */
|
|
7
|
+
meta?: React.ReactNode;
|
|
8
|
+
/** Image URL — renders a thumbnail tile instead of a document chip. */
|
|
9
|
+
thumbnail?: string;
|
|
10
|
+
/** Doctype icon for the document chip. Defaults to a document glyph. */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** Called when the remove control is used. Hidden if omitted. */
|
|
13
|
+
onRemove?: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A removable preview of a file or image attached as context to an agent turn —
|
|
17
|
+
* document chip or image thumbnail. The multimodal-context affordance.
|
|
18
|
+
* Source: Figma "Context Expansion / File Attachment".
|
|
19
|
+
*/
|
|
20
|
+
declare const AttachmentTile: React.ForwardRefExoticComponent<AttachmentTileProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
interface AttachmentTrayProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
}
|
|
23
|
+
/** A wrapping row of {@link AttachmentTile}s, shown above the composer. */
|
|
24
|
+
declare const AttachmentTray: React.ForwardRefExoticComponent<AttachmentTrayProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
|
|
26
|
+
export { AttachmentTile, type AttachmentTileProps, AttachmentTray, type AttachmentTrayProps };
|
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 { X, FileText } from 'lucide-react';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/index.tsx
|
|
8
|
+
var AttachmentTile = React.forwardRef(
|
|
9
|
+
({ name, meta, thumbnail, icon, onRemove, className, ...props }, ref) => {
|
|
10
|
+
const remove = onRemove && /* @__PURE__ */ jsx(
|
|
11
|
+
"button",
|
|
12
|
+
{
|
|
13
|
+
type: "button",
|
|
14
|
+
"aria-label": `Remove ${typeof name === "string" ? name : "attachment"}`,
|
|
15
|
+
onClick: onRemove,
|
|
16
|
+
className: cn(
|
|
17
|
+
"inline-flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
|
|
18
|
+
thumbnail && "absolute right-1 top-1 bg-background/80 backdrop-blur"
|
|
19
|
+
),
|
|
20
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
if (thumbnail) {
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
ref,
|
|
28
|
+
className: cn("relative size-16 overflow-hidden rounded-lg border border-border bg-muted", className),
|
|
29
|
+
...props,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
"img",
|
|
33
|
+
{
|
|
34
|
+
src: thumbnail,
|
|
35
|
+
alt: typeof name === "string" ? name : "",
|
|
36
|
+
className: "size-full object-cover"
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
remove
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsxs(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
ref,
|
|
48
|
+
className: cn(
|
|
49
|
+
"inline-flex max-w-64 items-center gap-2.5 rounded-lg border border-border bg-background py-2 pl-2.5 pr-2",
|
|
50
|
+
className
|
|
51
|
+
),
|
|
52
|
+
...props,
|
|
53
|
+
children: [
|
|
54
|
+
/* @__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: icon ?? /* @__PURE__ */ jsx(FileText, { "aria-hidden": "true" }) }),
|
|
55
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
56
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: name }),
|
|
57
|
+
meta && /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: meta })
|
|
58
|
+
] }),
|
|
59
|
+
remove
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
AttachmentTile.displayName = "AttachmentTile";
|
|
66
|
+
var AttachmentTray = React.forwardRef(
|
|
67
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex flex-wrap items-start gap-2", className), ...props })
|
|
68
|
+
);
|
|
69
|
+
AttachmentTray.displayName = "AttachmentTray";
|
|
70
|
+
|
|
71
|
+
export { AttachmentTile, AttachmentTray };
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAuBO,IAAM,cAAA,GAAuB,KAAA,CAAA,UAAA;AAAA,EAClC,CAAC,EAAE,IAAA,EAAM,IAAA,EAAM,SAAA,EAAW,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AACvE,IAAA,MAAM,SAAS,QAAA,oBACb,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,QAAA;AAAA,QACL,cAAY,CAAA,OAAA,EAAU,OAAO,IAAA,KAAS,QAAA,GAAW,OAAO,YAAY,CAAA,CAAA;AAAA,QACpE,OAAA,EAAS,QAAA;AAAA,QACT,SAAA,EAAW,EAAA;AAAA,UACT,oOAAA;AAAA,UACA,SAAA,IAAa;AAAA,SACf;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,CAAA,EAAA,EAAE,aAAA,EAAY,MAA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CAAA,UAAA;AAAA,EAClC,CAAC,EAAE,SAAA,EAAW,GAAG,KAAA,IAAS,GAAA,qBACxB,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,WAAW,EAAA,CAAG,kCAAA,EAAoC,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO;AAE5F;AACA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\nimport { FileText, X } from \"lucide-react\";\n\nexport interface AttachmentTileProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** File or attachment name. */\n name: React.ReactNode;\n /** Metadata line, e.g. `\"PDF · 240 KB\"`. */\n meta?: React.ReactNode;\n /** Image URL — renders a thumbnail tile instead of a document chip. */\n thumbnail?: string;\n /** Doctype icon for the document chip. Defaults to a document glyph. */\n icon?: React.ReactNode;\n /** Called when the remove control is used. Hidden if omitted. */\n onRemove?: () => void;\n}\n\n/**\n * A removable preview of a file or image attached as context to an agent turn —\n * document chip or image thumbnail. The multimodal-context affordance.\n * Source: Figma \"Context Expansion / File Attachment\".\n */\nexport const AttachmentTile = React.forwardRef<HTMLDivElement, AttachmentTileProps>(\n ({ name, meta, thumbnail, icon, onRemove, className, ...props }, ref) => {\n const remove = onRemove && (\n <button\n type=\"button\"\n aria-label={`Remove ${typeof name === \"string\" ? name : \"attachment\"}`}\n onClick={onRemove}\n className={cn(\n \"inline-flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5\",\n thumbnail && \"absolute right-1 top-1 bg-background/80 backdrop-blur\",\n )}\n >\n <X aria-hidden=\"true\" />\n </button>\n );\n\n if (thumbnail) {\n return (\n <div\n ref={ref}\n className={cn(\"relative size-16 overflow-hidden rounded-lg border border-border bg-muted\", className)}\n {...props}\n >\n <img\n src={thumbnail}\n alt={typeof name === \"string\" ? name : \"\"}\n className=\"size-full object-cover\"\n />\n {remove}\n </div>\n );\n }\n\n return (\n <div\n ref={ref}\n className={cn(\n \"inline-flex max-w-64 items-center gap-2.5 rounded-lg border border-border bg-background py-2 pl-2.5 pr-2\",\n className,\n )}\n {...props}\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 {icon ?? <FileText aria-hidden=\"true\" />}\n </span>\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"truncate text-sm font-medium text-foreground\">{name}</span>\n {meta && <span className=\"truncate text-xs text-muted-foreground\">{meta}</span>}\n </span>\n {remove}\n </div>\n );\n },\n);\nAttachmentTile.displayName = \"AttachmentTile\";\n\nexport interface AttachmentTrayProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/** A wrapping row of {@link AttachmentTile}s, shown above the composer. */\nexport const AttachmentTray = React.forwardRef<HTMLDivElement, AttachmentTrayProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-wrap items-start gap-2\", className)} {...props} />\n ),\n);\nAttachmentTray.displayName = \"AttachmentTray\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nucleux/attachment-tile",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "AttachmentTile — removable file and image context tiles for the composer — Nucleux agentic UI for React.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nucleux",
|
|
9
|
+
"react",
|
|
10
|
+
"ui",
|
|
11
|
+
"components",
|
|
12
|
+
"agentic",
|
|
13
|
+
"ai",
|
|
14
|
+
"tailwind",
|
|
15
|
+
"attachment-tile"
|
|
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/attachment-tile"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|