@epam/ai-dial-attachment-input 1.0.0-dev.486 → 1.0.0-dev.489
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/components/AttachmentCard/AttachmentCard.d.ts.map +1 -1
- package/components/AttachmentFileRow/AttachmentFileRow.d.ts.map +1 -1
- package/components/AttachmentGroup/AttachmentGroup.d.ts.map +1 -1
- package/components/FileDndOverlay/FileDndOverlay.d.ts.map +1 -1
- package/hooks/useClipboardPaste.d.ts +9 -1
- package/hooks/useClipboardPaste.d.ts.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +297 -265
- package/models/attachment-card.d.ts +17 -0
- package/models/attachment-card.d.ts.map +1 -1
- package/models/attachment-file-row.d.ts +10 -1
- package/models/attachment-file-row.d.ts.map +1 -1
- package/models/attachment-group.d.ts +9 -0
- package/models/attachment-group.d.ts.map +1 -1
- package/package.json +2 -2
- package/utils/attachment.d.ts +7 -3
- package/utils/attachment.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentCard.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentCard/AttachmentCard.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,EAAE,EAAgD,MAAM,OAAO,CAAC;AAK9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAOxE,8GAA8G;AAC9G,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"AttachmentCard.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentCard/AttachmentCard.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,EAAE,EAAgD,MAAM,OAAO,CAAC;AAK9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAOxE,8GAA8G;AAC9G,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAsXlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentFileRow.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentFileRow/AttachmentFileRow.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"AttachmentFileRow.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentFileRow/AttachmentFileRow.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,EAAE,EAA8C,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAU/E;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAkNxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentGroup.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentGroup/AttachmentGroup.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,EAAqB,MAAM,OAAO,CAAC;AAEnD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAUvC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"AttachmentGroup.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentGroup/AttachmentGroup.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,EAAqB,MAAM,OAAO,CAAC;AAEnD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAUvC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAkKpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDndOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/FileDndOverlay/FileDndOverlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,uGAAuG;AACvG,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"FileDndOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/FileDndOverlay/FileDndOverlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,uGAAuG;AACvG,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAgElD,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { Attachment } from '@epam/ai-dial-chat-shared';
|
|
2
2
|
import { ClipboardEventHandler } from 'react';
|
|
3
|
+
/** Localised default file names used by `useClipboardPaste` for pasted content. */
|
|
4
|
+
export interface UseClipboardPasteLabels {
|
|
5
|
+
/** Default file name given to a pasted image. Defaults to `'Screenshot.png'`. */
|
|
6
|
+
screenshotName?: string;
|
|
7
|
+
/** Default file name given to pasted plain text when it has no usable preview. Defaults to `'Pasted text'`. */
|
|
8
|
+
pastedTextName?: string;
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* Returns a `handlePaste` handler for a textarea that intercepts clipboard
|
|
5
12
|
* events and converts image items or long plain-text strings into
|
|
@@ -9,8 +16,9 @@ import { ClipboardEventHandler } from 'react';
|
|
|
9
16
|
* intercepted.
|
|
10
17
|
* @param threshold - Plain-text pastes longer than this many characters are
|
|
11
18
|
* converted to a file attachment instead of being inserted inline.
|
|
19
|
+
* @param labels - Localised default file names for pasted content.
|
|
12
20
|
*/
|
|
13
|
-
export declare const useClipboardPaste: (onAttachments: (attachments: Attachment[]) => void, threshold: number) => {
|
|
21
|
+
export declare const useClipboardPaste: (onAttachments: (attachments: Attachment[]) => void, threshold: number, labels?: UseClipboardPasteLabels) => {
|
|
14
22
|
handlePaste: ClipboardEventHandler<HTMLTextAreaElement>;
|
|
15
23
|
};
|
|
16
24
|
//# sourceMappingURL=useClipboardPaste.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClipboardPaste.d.ts","sourceRoot":"","sources":["../../src/hooks/useClipboardPaste.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAe,MAAM,OAAO,CAAC;AAG3D
|
|
1
|
+
{"version":3,"file":"useClipboardPaste.d.ts","sourceRoot":"","sources":["../../src/hooks/useClipboardPaste.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAe,MAAM,OAAO,CAAC;AAG3D,mFAAmF;AACnF,MAAM,WAAW,uBAAuB;IACtC,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+GAA+G;IAC/G,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,eAAe,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,EAClD,WAAW,MAAM,EACjB,SAAQ,uBAA4B,KACnC;IAAE,WAAW,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAA;CAkE3D,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ export { AttachmentGroup } from './components/AttachmentGroup/AttachmentGroup';
|
|
|
4
4
|
export { AttachmentFileRow } from './components/AttachmentFileRow/AttachmentFileRow';
|
|
5
5
|
export { AttachmentMoreTile } from './components/AttachmentMoreTile/AttachmentMoreTile';
|
|
6
6
|
export { FileDndOverlay } from './components/FileDndOverlay/FileDndOverlay';
|
|
7
|
-
export type { AttachmentCardProps, AttachmentCardColors, AttachmentCardTypography, AttachmentCardStyles, AttachmentCardLabels, AttachmentCardState, } from './models/attachment-card';
|
|
7
|
+
export type { AttachmentCardProps, AttachmentCardColors, AttachmentCardTypography, AttachmentCardStyles, AttachmentCardLabels, AttachmentCardState, AttachmentTypeLabels, } from './models/attachment-card';
|
|
8
8
|
export type { AttachmentTrayProps, AttachmentTrayLabels, } from './models/attachment-tray';
|
|
9
9
|
export { AttachmentTilesLayout, type AttachmentGroupProps, type AttachmentGroupLabels, type AttachmentGroupStyles, type AttachmentTilesPlan, } from './models/attachment-group';
|
|
10
10
|
export type { AttachmentFileRowProps, AttachmentFileRowLabels, AttachmentFileRowStyles, } from './models/attachment-file-row';
|
|
11
11
|
export type { AttachmentMoreTileProps } from './models/attachment-more-tile';
|
|
12
12
|
export type { FileDndOverlayProps, FileDndOverlayStyles, } from './models/file-dnd-overlay';
|
|
13
|
-
export { useClipboardPaste } from './hooks/useClipboardPaste';
|
|
13
|
+
export { useClipboardPaste, type UseClipboardPasteLabels, } from './hooks/useClipboardPaste';
|
|
14
14
|
export { useLazyImageLoad, LazyImageLoadStatus, } from './hooks/useLazyImageLoad';
|
|
15
15
|
export { generateAttachmentId, getAttachmentCardState, getExtFromContentType, getAttachmentIcon, getAttachmentTilesPlan, getNameWithoutExtension, mimeTypesToExtensionLabels, isMimeTypeAllowed, } from './utils/attachment';
|
|
16
16
|
export { ATTACHMENT_COLLAPSE_THRESHOLD, ATTACHMENT_COLLAPSED_VISIBLE_COUNT, } from './constants/attachment-group';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,YAAY,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,EACjB,KAAK,uBAAuB,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,GACnC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AttachmentErrorReason as e, AttachmentType as t, CodeBlockTheme as n, Highlight as r, MIME_TYPE_EXT_MAP as i, RequestStatus as a, buildCssVars as o, mergeClasses as s } from "@epam/ai-dial-chat-shared";
|
|
2
2
|
import { DIAL_ICON_SIZE as c, DialGhostIconButton as l, DialSkeleton as u, DialSkeletonVariant as d, DialSpinner as f, ElementSize as p } from "@epam/ai-dial-ui-kit";
|
|
3
|
-
import { IconChevronUp as m, IconClipboard as h, IconDownload as g, IconFile as _, IconFileDescription as v, IconFileTypeBmp as y, IconFileTypeCss as b, IconFileTypeCsv as x, IconFileTypeDoc as S, IconFileTypeDocx as C, IconFileTypeHtml as w, IconFileTypeJpg as T, IconFileTypeJs as E, IconFileTypeJsx as D, IconFileTypePdf as O, IconFileTypePhp as k, IconFileTypePng as A, IconFileTypePpt as j, IconFileTypeRs as M, IconFileTypeSql as N, IconFileTypeSvg as P, IconFileTypeTs as F, IconFileTypeTsx as I, IconFileTypeTxt as L, IconFileTypeVue as R, IconFileTypeXls as z, IconFileTypeXml as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { Fragment as
|
|
3
|
+
import { IconChevronUp as m, IconClipboard as h, IconDownload as g, IconFile as _, IconFileDescription as v, IconFileTypeBmp as y, IconFileTypeCss as b, IconFileTypeCsv as x, IconFileTypeDoc as S, IconFileTypeDocx as C, IconFileTypeHtml as w, IconFileTypeJpg as T, IconFileTypeJs as E, IconFileTypeJsx as D, IconFileTypePdf as O, IconFileTypePhp as k, IconFileTypePng as A, IconFileTypePpt as j, IconFileTypeRs as M, IconFileTypeSql as N, IconFileTypeSvg as P, IconFileTypeTs as F, IconFileTypeTsx as I, IconFileTypeTxt as L, IconFileTypeVue as R, IconFileTypeXls as z, IconFileTypeXml as B, IconFileTypeZip as V, IconFileX as H, IconMusic as U, IconPaperclip as ee, IconPhoto as W, IconReload as te, IconTerminal2 as ne, IconVideo as re, IconX as ie } from "@tabler/icons-react";
|
|
4
|
+
import { useCallback as G, useEffect as K, useId as ae, useMemo as oe, useRef as se, useState as ce } from "react";
|
|
5
|
+
import { Fragment as q, jsx as J, jsxs as Y } from "react/jsx-runtime";
|
|
6
6
|
//#region src/hooks/useLazyImageLoad.ts
|
|
7
|
-
var
|
|
7
|
+
var le = /* @__PURE__ */ function(e) {
|
|
8
8
|
return e.Idle = "idle", e.Loading = "loading", e.Loaded = "loaded", e.Error = "error", e;
|
|
9
|
-
}({}),
|
|
10
|
-
let n =
|
|
11
|
-
return
|
|
9
|
+
}({}), ue = ({ enabled: e, src: t }) => {
|
|
10
|
+
let n = se(null), [r, i] = ce("idle");
|
|
11
|
+
return K(() => {
|
|
12
12
|
i(e && t ? "loading" : "idle");
|
|
13
|
-
}, [e, t]),
|
|
13
|
+
}, [e, t]), K(() => {
|
|
14
14
|
let r = n.current;
|
|
15
15
|
if (!r || !e || !t) return;
|
|
16
16
|
let a = () => i("loaded"), o = () => i("error");
|
|
@@ -33,31 +33,31 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
33
33
|
actionBtn: "_actionBtn_ywrb5_32",
|
|
34
34
|
removeBtnImage: "_removeBtnImage_ywrb5_43",
|
|
35
35
|
hoverDownloadIcon: "_hoverDownloadIcon_ywrb5_51"
|
|
36
|
-
},
|
|
36
|
+
}, de = 5, fe = 4, Z = /* @__PURE__ */ function(e) {
|
|
37
37
|
return e.None = "none", e.AllVisible = "all-visible", e.Collapsed = "collapsed", e;
|
|
38
|
-
}({}),
|
|
38
|
+
}({}), pe = () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, me = (e) => {
|
|
39
39
|
let t = e.lastIndexOf(".");
|
|
40
40
|
return t > 0 ? e.slice(0, t) : e;
|
|
41
|
-
},
|
|
41
|
+
}, he = {
|
|
42
42
|
image: "Image files",
|
|
43
43
|
audio: "Audio files",
|
|
44
44
|
video: "Video files",
|
|
45
45
|
text: "Text files"
|
|
46
|
-
},
|
|
46
|
+
}, ge = (e, t = he) => e.map((e) => {
|
|
47
47
|
if (e.endsWith("/*")) {
|
|
48
|
-
let
|
|
49
|
-
return
|
|
48
|
+
let n = e.slice(0, -2);
|
|
49
|
+
return t[n] ?? `${n} files`;
|
|
50
50
|
}
|
|
51
|
-
let
|
|
52
|
-
return
|
|
53
|
-
}).join(", "),
|
|
51
|
+
let n = e.split("/")[1];
|
|
52
|
+
return n == null ? e.toUpperCase() : n.toUpperCase();
|
|
53
|
+
}).join(", "), _e = (e, t) => t.length === 0 ? !1 : t.some((t) => {
|
|
54
54
|
if (t === "*" || t === "*/*") return !0;
|
|
55
55
|
if (t.endsWith("/*")) {
|
|
56
56
|
let n = t.slice(0, -2);
|
|
57
57
|
return e.startsWith(`${n}/`);
|
|
58
58
|
}
|
|
59
59
|
return e === t;
|
|
60
|
-
}),
|
|
60
|
+
}), ve = (e) => {
|
|
61
61
|
if (!e) return _;
|
|
62
62
|
if (e.startsWith("image/")) switch (e) {
|
|
63
63
|
case "image/jpeg":
|
|
@@ -65,10 +65,10 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
65
65
|
case "image/png": return A;
|
|
66
66
|
case "image/svg+xml": return P;
|
|
67
67
|
case "image/bmp": return y;
|
|
68
|
-
default: return
|
|
68
|
+
default: return W;
|
|
69
69
|
}
|
|
70
|
-
if (e.startsWith("video/")) return
|
|
71
|
-
if (e.startsWith("audio/")) return
|
|
70
|
+
if (e.startsWith("video/")) return re;
|
|
71
|
+
if (e.startsWith("audio/")) return U;
|
|
72
72
|
switch (e) {
|
|
73
73
|
case "application/pdf": return O;
|
|
74
74
|
case "application/msword":
|
|
@@ -83,13 +83,13 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
83
83
|
case "application/x-rar-compressed":
|
|
84
84
|
case "application/x-7z-compressed":
|
|
85
85
|
case "application/gzip":
|
|
86
|
-
case "application/x-tar": return
|
|
86
|
+
case "application/x-tar": return V;
|
|
87
87
|
case "text/csv": return x;
|
|
88
88
|
case "text/plain": return L;
|
|
89
89
|
case "text/html":
|
|
90
90
|
case "application/xhtml+xml": return w;
|
|
91
91
|
case "text/xml":
|
|
92
|
-
case "application/xml": return
|
|
92
|
+
case "application/xml": return B;
|
|
93
93
|
case "application/sql":
|
|
94
94
|
case "text/x-sql": return N;
|
|
95
95
|
case "text/javascript":
|
|
@@ -106,39 +106,39 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
106
106
|
case "text/x-vue": return R;
|
|
107
107
|
default: return _;
|
|
108
108
|
}
|
|
109
|
-
}, ve = (e) => {
|
|
110
|
-
let { type: n, contentType: r } = e;
|
|
111
|
-
return n === t.Prompt ? H : n === t.Pasted ? h : n === t.Image ? V : _e(r ?? "");
|
|
112
109
|
}, ye = (e) => {
|
|
110
|
+
let { type: n, contentType: r } = e;
|
|
111
|
+
return n === t.Prompt ? ne : n === t.Pasted ? h : n === t.Image ? W : ve(r ?? "");
|
|
112
|
+
}, be = (e) => {
|
|
113
113
|
let t = e.toLowerCase().split(";")[0].trim(), n = i[t];
|
|
114
114
|
if (n) return n;
|
|
115
115
|
let r = t.split("/")[1];
|
|
116
116
|
if (r && !r.startsWith("vnd.") && !r.includes("+")) return r;
|
|
117
|
-
},
|
|
118
|
-
let { type:
|
|
119
|
-
if (
|
|
120
|
-
if (
|
|
121
|
-
if (
|
|
122
|
-
if (
|
|
123
|
-
let e =
|
|
117
|
+
}, xe = (e, n) => {
|
|
118
|
+
let { type: r, name: i, contentType: a } = e;
|
|
119
|
+
if (r === t.Prompt) return n.promptLabel ?? "Prompt";
|
|
120
|
+
if (r === t.Pasted) return n.pastedLabel ?? "Pasted";
|
|
121
|
+
if (r === t.Image) return n.imageLabel ?? "Image";
|
|
122
|
+
if (a) {
|
|
123
|
+
let e = be(a);
|
|
124
124
|
if (e) return `.${e}`;
|
|
125
125
|
}
|
|
126
|
-
let
|
|
127
|
-
return
|
|
128
|
-
},
|
|
129
|
-
let { type:
|
|
126
|
+
let o = i.lastIndexOf(".");
|
|
127
|
+
return o > 0 && o < i.length - 1 ? `.${i.slice(o + 1).toLowerCase()}` : i;
|
|
128
|
+
}, Se = (e, n, r, i = {}) => {
|
|
129
|
+
let { type: o, status: c, previewUrl: l, url: u } = e, d = c === a.Loading, f = c === a.Error, p = o === t.Image && !!(l ?? u) && !f, m = o === t.Audio && !f, h = s(X.card, f && X.cardError, n && X.cardSelected, !f && !n && o === t.Prompt && X.cardPrompt, !f && !n && o === t.Pasted && X.cardPasted);
|
|
130
130
|
return {
|
|
131
|
-
isLoading:
|
|
132
|
-
isError:
|
|
133
|
-
isImage:
|
|
134
|
-
isAudio:
|
|
135
|
-
areActionsVisible:
|
|
136
|
-
BottomIcon:
|
|
137
|
-
typeLabel:
|
|
138
|
-
cardColorClass:
|
|
139
|
-
removeBtnClass:
|
|
131
|
+
isLoading: d,
|
|
132
|
+
isError: f,
|
|
133
|
+
isImage: p,
|
|
134
|
+
isAudio: m,
|
|
135
|
+
areActionsVisible: f || r,
|
|
136
|
+
BottomIcon: ye(e),
|
|
137
|
+
typeLabel: xe(e, i),
|
|
138
|
+
cardColorClass: h,
|
|
139
|
+
removeBtnClass: p ? X.removeBtnImage : X.actionBtn
|
|
140
140
|
};
|
|
141
|
-
},
|
|
141
|
+
}, Ce = (e, t) => e <= 0 ? {
|
|
142
142
|
layout: Z.None,
|
|
143
143
|
visibleCount: 0,
|
|
144
144
|
hiddenCount: 0
|
|
@@ -150,159 +150,167 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
150
150
|
layout: Z.Collapsed,
|
|
151
151
|
visibleCount: 4,
|
|
152
152
|
hiddenCount: e - 4
|
|
153
|
-
},
|
|
154
|
-
let { removeLabel:
|
|
155
|
-
"--ci-card-border":
|
|
156
|
-
"--ci-card-bg":
|
|
157
|
-
"--ci-card-name":
|
|
158
|
-
"--ci-card-meta":
|
|
159
|
-
}), { isLoading:
|
|
153
|
+
}, we = ({ attachment: n, searchQuery: i = "", onRemove: a, onRetry: m, onExpand: h, onClick: _, isSelected: v, shouldAlwaysShowActions: y, labels: b, typeLabels: x, styles: S, showHoverDownloadIcon: C = !1, className: w }) => {
|
|
154
|
+
let { removeLabel: T = "Remove attachment", retryLabel: E = "Retry upload", clickLabel: D = "Open attachment", expandLabel: O = "Expand pasted text", loadingLabel: k = "Loading attachment", uploadFailedStatusLabel: A = "Upload failed" } = b ?? {}, { colors: j, typography: M, roundedClassName: N = "rounded-xl" } = S ?? {}, { id: P, name: F } = n, I = n.previewUrl ?? n.url, L = n.type === t.Pasted, R = L && h !== void 0, z = oe(() => L ? F : me(F), [L, F]), B = o({
|
|
155
|
+
"--ci-card-border": j?.border,
|
|
156
|
+
"--ci-card-bg": j?.background,
|
|
157
|
+
"--ci-card-name": j?.nameText,
|
|
158
|
+
"--ci-card-meta": j?.metaText
|
|
159
|
+
}), { isLoading: V, isError: H, isImage: U, isAudio: ee, areActionsVisible: ne, BottomIcon: re, typeLabel: G, cardColorClass: K, removeBtnClass: ae } = oe(() => Se(n, v ?? !1, y ?? !1, x), [
|
|
160
160
|
n,
|
|
161
161
|
v,
|
|
162
|
-
y
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
162
|
+
y,
|
|
163
|
+
x
|
|
164
|
+
]), se = _ !== void 0 && !R && !V && !H, ce = R || se, { imageRef: de, imageLoadStatus: fe } = ue({
|
|
165
|
+
enabled: U,
|
|
166
|
+
src: I
|
|
167
|
+
}), Z = () => {
|
|
168
|
+
R && h ? h(P) : se && _ && _(P);
|
|
169
|
+
}, pe = (e) => {
|
|
170
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), Z());
|
|
170
171
|
};
|
|
171
|
-
if (ee) return /* @__PURE__ */
|
|
172
|
-
style:
|
|
173
|
-
className: s("group flex w-full min-w-[280px] max-w-[300px] flex-col gap-2 border p-3",
|
|
174
|
-
children: [/* @__PURE__ */
|
|
172
|
+
if (ee) return /* @__PURE__ */ Y("div", {
|
|
173
|
+
style: B,
|
|
174
|
+
className: s("group flex w-full min-w-[280px] max-w-[300px] flex-col gap-2 border p-3", N, K, w),
|
|
175
|
+
children: [/* @__PURE__ */ Y("div", {
|
|
175
176
|
className: "flex items-center justify-between gap-2",
|
|
176
|
-
children: [/* @__PURE__ */
|
|
177
|
+
children: [/* @__PURE__ */ J("span", {
|
|
177
178
|
title: n.name,
|
|
178
|
-
className: s(
|
|
179
|
-
children: i ? /* @__PURE__ */
|
|
179
|
+
className: s(M?.fontClassName ?? "dial-tiny-text", "min-w-0 truncate", X.name),
|
|
180
|
+
children: i ? /* @__PURE__ */ J(r, {
|
|
180
181
|
text: n.name,
|
|
181
182
|
query: i,
|
|
182
183
|
maxLines: 1
|
|
183
184
|
}) : n.name
|
|
184
|
-
}), _ && /* @__PURE__ */
|
|
185
|
-
icon: /* @__PURE__ */
|
|
185
|
+
}), _ && /* @__PURE__ */ J(l, {
|
|
186
|
+
icon: /* @__PURE__ */ J(g, {
|
|
186
187
|
size: c.SM,
|
|
187
188
|
"aria-hidden": !0
|
|
188
189
|
}),
|
|
189
190
|
size: p.Small,
|
|
190
|
-
className: s("h-6 w-6 shrink-0 rounded",
|
|
191
|
-
"aria-label":
|
|
191
|
+
className: s("h-6 w-6 shrink-0 rounded", ae),
|
|
192
|
+
"aria-label": D,
|
|
192
193
|
onClick: (e) => {
|
|
193
|
-
e.stopPropagation(), _(
|
|
194
|
+
e.stopPropagation(), _(P);
|
|
194
195
|
}
|
|
195
196
|
})]
|
|
196
|
-
}), n.playUrl && /* @__PURE__ */
|
|
197
|
+
}), n.playUrl && /* @__PURE__ */ J("audio", {
|
|
197
198
|
controls: !0,
|
|
198
199
|
src: n.playUrl,
|
|
200
|
+
"aria-label": n.name,
|
|
199
201
|
className: "w-full",
|
|
200
202
|
preload: "metadata"
|
|
201
203
|
})]
|
|
202
204
|
});
|
|
203
|
-
let
|
|
204
|
-
|
|
205
|
+
let he = s("group relative flex h-[100px] w-[100px] flex-shrink-0 border focus-within:outline focus-within:outline-1 focus-within:outline-offset-1", N, K, !U && "flex-col gap-3 p-3", ce && "cursor-pointer", w), ge = /* @__PURE__ */ Y(q, { children: [
|
|
206
|
+
U ? /* @__PURE__ */ Y("div", {
|
|
205
207
|
className: "relative h-full w-full overflow-hidden",
|
|
206
|
-
children: [
|
|
208
|
+
children: [fe !== le.Loaded && /* @__PURE__ */ J(u, {
|
|
207
209
|
variant: d.Rectangular,
|
|
208
210
|
width: "100%",
|
|
209
211
|
height: "100%",
|
|
210
|
-
active:
|
|
211
|
-
overlay: /* @__PURE__ */
|
|
212
|
+
active: fe === le.Loading,
|
|
213
|
+
overlay: /* @__PURE__ */ J(W, {
|
|
212
214
|
size: c.LG,
|
|
213
|
-
className:
|
|
215
|
+
className: M?.placeholderIconClassName ?? "text-secondary",
|
|
214
216
|
"aria-hidden": !0
|
|
215
217
|
}),
|
|
216
|
-
className: s("absolute inset-0",
|
|
217
|
-
}), /* @__PURE__ */
|
|
218
|
-
ref:
|
|
219
|
-
src:
|
|
220
|
-
alt:
|
|
218
|
+
className: s("absolute inset-0", N)
|
|
219
|
+
}), /* @__PURE__ */ J("img", {
|
|
220
|
+
ref: de,
|
|
221
|
+
src: I,
|
|
222
|
+
alt: F,
|
|
221
223
|
loading: "lazy",
|
|
222
224
|
decoding: "async",
|
|
223
|
-
className: s("h-full w-full object-cover transition-opacity duration-200",
|
|
225
|
+
className: s("h-full w-full object-cover transition-opacity duration-200", fe === le.Loaded ? "opacity-100" : "opacity-0", N)
|
|
224
226
|
})]
|
|
225
|
-
}) :
|
|
227
|
+
}) : H ? /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ Y("div", {
|
|
226
228
|
className: "flex flex-row items-center gap-1 overflow-hidden",
|
|
227
|
-
children: [/* @__PURE__ */
|
|
229
|
+
children: [/* @__PURE__ */ J(re, {
|
|
228
230
|
size: c.SM,
|
|
229
231
|
className: s("shrink-0", X.meta),
|
|
230
232
|
"aria-hidden": !0
|
|
231
|
-
}), /* @__PURE__ */
|
|
232
|
-
title:
|
|
233
|
-
className: s(
|
|
234
|
-
children:
|
|
233
|
+
}), /* @__PURE__ */ J("span", {
|
|
234
|
+
title: G,
|
|
235
|
+
className: s(M?.metaClassName ?? "dial-tiny-text", "min-w-0 truncate", X.meta),
|
|
236
|
+
children: G
|
|
235
237
|
})]
|
|
236
|
-
}), /* @__PURE__ */
|
|
238
|
+
}), /* @__PURE__ */ J("div", {
|
|
237
239
|
className: "min-w-0 flex-1",
|
|
238
|
-
children: /* @__PURE__ */
|
|
239
|
-
title:
|
|
240
|
-
className: s(
|
|
241
|
-
children: i ? /* @__PURE__ */
|
|
242
|
-
text:
|
|
240
|
+
children: /* @__PURE__ */ J("div", {
|
|
241
|
+
title: z,
|
|
242
|
+
className: s(M?.fontClassName ?? "dial-tiny-text", "line-clamp-3 break-words", X.name),
|
|
243
|
+
children: i ? /* @__PURE__ */ J(r, {
|
|
244
|
+
text: z,
|
|
243
245
|
query: i,
|
|
244
246
|
maxLines: 3
|
|
245
|
-
}) :
|
|
247
|
+
}) : z
|
|
246
248
|
})
|
|
247
|
-
})] }) : /* @__PURE__ */
|
|
249
|
+
})] }) : /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J("div", {
|
|
248
250
|
className: "min-w-0 flex-1",
|
|
249
|
-
children: /* @__PURE__ */
|
|
250
|
-
title:
|
|
251
|
-
className: s(
|
|
252
|
-
children: i ? /* @__PURE__ */
|
|
253
|
-
text:
|
|
251
|
+
children: /* @__PURE__ */ J("div", {
|
|
252
|
+
title: z,
|
|
253
|
+
className: s(M?.fontClassName ?? "dial-tiny-text", "line-clamp-3 break-words", X.name),
|
|
254
|
+
children: i ? /* @__PURE__ */ J(r, {
|
|
255
|
+
text: z,
|
|
254
256
|
query: i,
|
|
255
257
|
maxLines: 3
|
|
256
|
-
}) :
|
|
258
|
+
}) : z
|
|
257
259
|
})
|
|
258
|
-
}), /* @__PURE__ */
|
|
260
|
+
}), /* @__PURE__ */ Y("div", {
|
|
259
261
|
className: "flex flex-row items-center gap-1 overflow-hidden",
|
|
260
|
-
children: [/* @__PURE__ */
|
|
262
|
+
children: [/* @__PURE__ */ J(re, {
|
|
261
263
|
size: c.SM,
|
|
262
264
|
className: s("shrink-0", X.meta),
|
|
263
265
|
"aria-hidden": !0
|
|
264
|
-
}), /* @__PURE__ */
|
|
265
|
-
title:
|
|
266
|
-
className: s(
|
|
267
|
-
children:
|
|
266
|
+
}), /* @__PURE__ */ J("span", {
|
|
267
|
+
title: G,
|
|
268
|
+
className: s(M?.metaClassName ?? "dial-tiny-text", "min-w-0 truncate", X.meta),
|
|
269
|
+
children: G
|
|
268
270
|
})]
|
|
269
271
|
})] }),
|
|
270
|
-
|
|
271
|
-
className: s("absolute inset-0 flex items-center justify-center",
|
|
272
|
-
children: /* @__PURE__ */
|
|
272
|
+
V && /* @__PURE__ */ J("span", {
|
|
273
|
+
className: s("absolute inset-0 flex items-center justify-center", N, X.loadingOverlay),
|
|
274
|
+
children: /* @__PURE__ */ J(f, {
|
|
273
275
|
size: 40,
|
|
274
|
-
ariaLabel:
|
|
276
|
+
ariaLabel: k,
|
|
275
277
|
className: "z-50"
|
|
276
278
|
})
|
|
277
279
|
}),
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
/* @__PURE__ */ J("span", {
|
|
281
|
+
role: "status",
|
|
282
|
+
"aria-live": "polite",
|
|
283
|
+
className: "sr-only",
|
|
284
|
+
children: H ? A : ""
|
|
285
|
+
}),
|
|
286
|
+
!V && /* @__PURE__ */ Y("div", {
|
|
287
|
+
className: s("absolute end-1 top-1 flex gap-1 transition-opacity", ne ? "opacity-100" : "opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 mobile:opacity-100"),
|
|
280
288
|
children: [
|
|
281
|
-
|
|
282
|
-
icon: /* @__PURE__ */
|
|
289
|
+
H && m && n.errorReason !== e.UnsupportedType && /* @__PURE__ */ J(l, {
|
|
290
|
+
icon: /* @__PURE__ */ J(te, {
|
|
283
291
|
size: c.SM,
|
|
284
292
|
"aria-hidden": !0
|
|
285
293
|
}),
|
|
286
294
|
size: p.Small,
|
|
287
|
-
className: s("h-6 w-6 rounded",
|
|
288
|
-
"aria-label":
|
|
295
|
+
className: s("h-6 w-6 rounded", ae),
|
|
296
|
+
"aria-label": E,
|
|
289
297
|
onClick: (e) => {
|
|
290
|
-
e.stopPropagation(), m(
|
|
298
|
+
e.stopPropagation(), m(P);
|
|
291
299
|
}
|
|
292
300
|
}),
|
|
293
|
-
a && /* @__PURE__ */
|
|
294
|
-
icon: /* @__PURE__ */
|
|
301
|
+
a && /* @__PURE__ */ J(l, {
|
|
302
|
+
icon: /* @__PURE__ */ J(ie, {
|
|
295
303
|
size: c.SM,
|
|
296
304
|
"aria-hidden": !0
|
|
297
305
|
}),
|
|
298
306
|
size: p.Small,
|
|
299
|
-
className: s("h-6 w-6 rounded",
|
|
300
|
-
"aria-label":
|
|
307
|
+
className: s("h-6 w-6 rounded", ae),
|
|
308
|
+
"aria-label": T,
|
|
301
309
|
onClick: (e) => {
|
|
302
|
-
e.stopPropagation(), a?.(
|
|
310
|
+
e.stopPropagation(), a?.(P);
|
|
303
311
|
}
|
|
304
312
|
}),
|
|
305
|
-
|
|
313
|
+
C && !a && !H && /* @__PURE__ */ J(g, {
|
|
306
314
|
size: c.SM,
|
|
307
315
|
"aria-hidden": !0,
|
|
308
316
|
className: s("h-6 w-6 rounded-lg p-1", X.hoverDownloadIcon)
|
|
@@ -310,29 +318,29 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
310
318
|
]
|
|
311
319
|
})
|
|
312
320
|
] });
|
|
313
|
-
return
|
|
314
|
-
style:
|
|
315
|
-
className:
|
|
316
|
-
onClick:
|
|
317
|
-
onKeyDown:
|
|
321
|
+
return ce ? /* @__PURE__ */ J("div", {
|
|
322
|
+
style: B,
|
|
323
|
+
className: he,
|
|
324
|
+
onClick: Z,
|
|
325
|
+
onKeyDown: pe,
|
|
318
326
|
tabIndex: 0,
|
|
319
327
|
role: "button",
|
|
320
|
-
"aria-label":
|
|
321
|
-
children:
|
|
322
|
-
}) : /* @__PURE__ */
|
|
323
|
-
style:
|
|
324
|
-
className:
|
|
325
|
-
children:
|
|
328
|
+
"aria-label": se ? D : R ? O : void 0,
|
|
329
|
+
children: ge
|
|
330
|
+
}) : /* @__PURE__ */ J("div", {
|
|
331
|
+
style: B,
|
|
332
|
+
className: he,
|
|
333
|
+
children: ge
|
|
326
334
|
});
|
|
327
|
-
},
|
|
335
|
+
}, Te = ({ attachments: e, onRemove: t, onRetry: n, onExpand: r, onAttachmentClick: i, labels: a, className: o }) => {
|
|
328
336
|
let { ariaLabel: c = "Attached files", removeLabel: l, retryLabel: u, clickLabel: d } = a ?? {};
|
|
329
|
-
return e.length === 0 ? null : /* @__PURE__ */
|
|
337
|
+
return e.length === 0 ? null : /* @__PURE__ */ J("div", {
|
|
330
338
|
role: "list",
|
|
331
339
|
"aria-label": c,
|
|
332
340
|
className: s("flex w-full min-w-0 gap-2 overflow-x-auto", o),
|
|
333
|
-
children: e.map((e) => /* @__PURE__ */
|
|
341
|
+
children: e.map((e) => /* @__PURE__ */ J("div", {
|
|
334
342
|
role: "listitem",
|
|
335
|
-
children: /* @__PURE__ */
|
|
343
|
+
children: /* @__PURE__ */ J(we, {
|
|
336
344
|
attachment: e,
|
|
337
345
|
onRemove: t,
|
|
338
346
|
onRetry: n,
|
|
@@ -357,76 +365,87 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
357
365
|
track: "_track_488nu_45",
|
|
358
366
|
indeterminateFill: "_indeterminateFill_488nu_49",
|
|
359
367
|
"attachment-tile-indeterminate": "_attachment-tile-indeterminate_488nu_1"
|
|
360
|
-
},
|
|
368
|
+
}, Ee = {
|
|
361
369
|
[e.Network]: "Upload failed · network error",
|
|
362
370
|
[e.UnsupportedType]: "Upload failed · unsupported file type"
|
|
363
|
-
},
|
|
364
|
-
let { clickLabel:
|
|
365
|
-
|
|
366
|
-
},
|
|
367
|
-
(e.key === "Enter" || e.key === " ") &&
|
|
368
|
-
},
|
|
369
|
-
title:
|
|
370
|
-
className: s(
|
|
371
|
-
children:
|
|
372
|
-
}),
|
|
373
|
-
className: s("flex items-center gap-1 overflow-hidden",
|
|
374
|
-
children: [/* @__PURE__ */
|
|
371
|
+
}, De = ({ attachment: t, onClick: r, onRetry: i, labels: o, typeLabels: u, styles: d, theme: f = n.Dark, className: m }) => {
|
|
372
|
+
let { clickLabel: h = "Download attachment", retryLabel: _ = "Retry upload", sizeLabel: v, uploadingLabel: y = "Uploading", errorReasonLabels: b, genericErrorLabel: x = "Upload failed" } = o ?? {}, { nameClassName: S = "dial-caption-text", metaClassName: C = "dial-caption-text" } = d ?? {}, { id: w, name: T, status: E, errorReason: D } = t, O = E === a.Loading, k = E === a.Error, A = ae(), j = k && (D && (b?.[D] ?? Ee[D]) || x), { BottomIcon: M, typeLabel: N } = Se(t, !1, !1, u), P = !k && !O && r !== void 0, F = k && !!i && D !== e.UnsupportedType, I = P || F ? "pe-5" : void 0, L = () => {
|
|
373
|
+
P && r?.(t);
|
|
374
|
+
}, R = (e) => {
|
|
375
|
+
(e.key === "Enter" || e.key === " ") && P && (e.preventDefault(), L());
|
|
376
|
+
}, z = s("group relative flex size-[84px] flex-col justify-between gap-1 overflow-hidden rounded-xl border p-1.5", Q.tile, !k && f === n.Light && Q.tileLight, k && Q.tileError), B = /* @__PURE__ */ J("div", {
|
|
377
|
+
title: T,
|
|
378
|
+
className: s(S, "line-clamp-2 min-w-0 break-words", Q.nameText, !k && I),
|
|
379
|
+
children: T
|
|
380
|
+
}), V = /* @__PURE__ */ Y("div", {
|
|
381
|
+
className: s("flex items-center gap-1 overflow-hidden", k && I),
|
|
382
|
+
children: [/* @__PURE__ */ J(M, {
|
|
375
383
|
size: 16,
|
|
376
384
|
className: Q.typeText,
|
|
377
385
|
"aria-hidden": !0
|
|
378
|
-
}), /* @__PURE__ */
|
|
379
|
-
className: s(
|
|
380
|
-
children:
|
|
386
|
+
}), /* @__PURE__ */ J("span", {
|
|
387
|
+
className: s(C, "truncate", Q.typeText),
|
|
388
|
+
children: v ? `${N} · ${v}` : N
|
|
381
389
|
})]
|
|
382
|
-
}),
|
|
383
|
-
|
|
384
|
-
|
|
390
|
+
}), H = /* @__PURE__ */ Y(q, { children: [
|
|
391
|
+
k ? /* @__PURE__ */ Y(q, { children: [V, B] }) : /* @__PURE__ */ Y(q, { children: [B, V] }),
|
|
392
|
+
O && /* @__PURE__ */ J("div", {
|
|
385
393
|
role: "progressbar",
|
|
386
|
-
"aria-label":
|
|
394
|
+
"aria-label": y,
|
|
387
395
|
className: s("absolute inset-x-2 bottom-2 h-[3px] overflow-hidden rounded-full", Q.track),
|
|
388
|
-
children: /* @__PURE__ */
|
|
396
|
+
children: /* @__PURE__ */ J("div", { className: s("h-full w-1/3 rounded-full", Q.indeterminateFill) })
|
|
389
397
|
}),
|
|
390
|
-
|
|
398
|
+
P && /* @__PURE__ */ J(g, {
|
|
391
399
|
size: c.SM,
|
|
392
400
|
"aria-hidden": !0,
|
|
393
401
|
className: s("absolute end-1 top-1 h-6 w-6 rounded-lg p-1 opacity-0 transition-opacity group-hover:opacity-100 mobile:opacity-100", Q.hoverIcon)
|
|
394
402
|
}),
|
|
395
|
-
|
|
396
|
-
icon: /* @__PURE__ */
|
|
403
|
+
F && /* @__PURE__ */ J(l, {
|
|
404
|
+
icon: /* @__PURE__ */ J(te, {
|
|
397
405
|
size: c.SM,
|
|
398
406
|
"aria-hidden": !0
|
|
399
407
|
}),
|
|
400
408
|
size: p.Small,
|
|
401
409
|
className: s("absolute end-1 top-1 h-6 w-6 rounded-lg", Q.retryIcon),
|
|
402
|
-
"aria-label":
|
|
410
|
+
"aria-label": _,
|
|
411
|
+
"aria-describedby": j ? A : void 0,
|
|
403
412
|
onClick: (e) => {
|
|
404
|
-
e.stopPropagation(), i(
|
|
413
|
+
e.stopPropagation(), i(w);
|
|
405
414
|
}
|
|
415
|
+
}),
|
|
416
|
+
k && /* @__PURE__ */ J("span", {
|
|
417
|
+
id: A,
|
|
418
|
+
role: "status",
|
|
419
|
+
"aria-live": "polite",
|
|
420
|
+
className: "sr-only",
|
|
421
|
+
children: j
|
|
406
422
|
})
|
|
407
423
|
] });
|
|
408
|
-
return /* @__PURE__ */
|
|
409
|
-
className: s("inline-flex",
|
|
410
|
-
children:
|
|
424
|
+
return /* @__PURE__ */ J("div", {
|
|
425
|
+
className: s("inline-flex", m),
|
|
426
|
+
children: P ? /* @__PURE__ */ J("div", {
|
|
411
427
|
role: "button",
|
|
412
428
|
tabIndex: 0,
|
|
413
|
-
"aria-label":
|
|
414
|
-
onClick:
|
|
415
|
-
onKeyDown:
|
|
416
|
-
className: s(
|
|
417
|
-
children:
|
|
418
|
-
}) : /* @__PURE__ */
|
|
419
|
-
className:
|
|
420
|
-
title:
|
|
421
|
-
|
|
429
|
+
"aria-label": h,
|
|
430
|
+
onClick: L,
|
|
431
|
+
onKeyDown: R,
|
|
432
|
+
className: s(z, "cursor-pointer focus-within:outline focus-within:outline-1 focus-within:outline-offset-1"),
|
|
433
|
+
children: H
|
|
434
|
+
}) : /* @__PURE__ */ J("div", {
|
|
435
|
+
className: z,
|
|
436
|
+
title: j || void 0,
|
|
437
|
+
role: k ? "group" : void 0,
|
|
438
|
+
"aria-describedby": k ? A : void 0,
|
|
439
|
+
tabIndex: k ? 0 : void 0,
|
|
440
|
+
children: H
|
|
422
441
|
})
|
|
423
442
|
});
|
|
424
|
-
},
|
|
443
|
+
}, Oe = { tile: "_tile_1s4d7_1" }, ke = ({ count: e, onClick: t, ariaLabel: n, children: r, fontClassName: i = "dial-small-semi-text", className: a }) => /* @__PURE__ */ J("button", {
|
|
425
444
|
type: "button",
|
|
426
445
|
onClick: t,
|
|
427
446
|
"aria-label": n ?? `Show ${e} more attachments`,
|
|
428
|
-
className: s("flex size-[84px] items-center justify-center rounded-xl border", i,
|
|
429
|
-
children: r ?? /* @__PURE__ */
|
|
447
|
+
className: s("flex size-[84px] items-center justify-center rounded-xl border", i, Oe.tile, a),
|
|
448
|
+
children: r ?? /* @__PURE__ */ J("bdi", {
|
|
430
449
|
dir: "ltr",
|
|
431
450
|
children: `+${e}`
|
|
432
451
|
})
|
|
@@ -436,83 +455,85 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
436
455
|
headerLabel: "_headerLabel_7fktb_7",
|
|
437
456
|
downloadAllButton: "_downloadAllButton_7fktb_8",
|
|
438
457
|
imageTile: "_imageTile_7fktb_12"
|
|
439
|
-
},
|
|
440
|
-
let { ariaLabel:
|
|
458
|
+
}, Ae = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, je = ({ attachments: e, onAttachmentClick: n, onDownloadAll: r, onRetry: i, getSizeLabel: o, labels: u, typeLabels: d, styles: f, theme: p, className: h }) => {
|
|
459
|
+
let { ariaLabel: v = "Attachments", clickLabel: y = "Download attachment", retryLabel: b = "Retry upload", showLessLabel: x = "Show less", downloadAllLabel: S = "Download all", getHeaderLabel: C = (e) => Ae(e, "attachment") } = u ?? {}, { headerLabelClassName: w = "dial-tiny-semi-text" } = f ?? {}, [T, E] = ce(!1), D = oe(() => Ce(e.length, T), [e.length, T]);
|
|
441
460
|
if (e.length === 0) return null;
|
|
442
|
-
let
|
|
443
|
-
return /* @__PURE__ */
|
|
461
|
+
let O = e.some((e) => e.type === t.Image), k = e.some((e) => e.type !== t.Image), A = O && k, j = e.length >= 5, M = A ? ee : O ? W : _, N = C(e.length), P = e.slice(0, D.visibleCount);
|
|
462
|
+
return /* @__PURE__ */ Y("div", {
|
|
444
463
|
role: "group",
|
|
445
|
-
"aria-label":
|
|
446
|
-
className: s("rounded-2xl border p-3",
|
|
447
|
-
children: [/* @__PURE__ */
|
|
464
|
+
"aria-label": v,
|
|
465
|
+
className: s("rounded-2xl border p-3", j ? "w-full min-w-0 max-w-[492px]" : "max-w-[420px]", $.container, h),
|
|
466
|
+
children: [/* @__PURE__ */ Y("div", {
|
|
448
467
|
className: "mb-3 flex min-h-6 items-center gap-2",
|
|
449
468
|
children: [
|
|
450
|
-
/* @__PURE__ */
|
|
469
|
+
/* @__PURE__ */ J(M, {
|
|
451
470
|
size: c.SM,
|
|
452
471
|
className: s("shrink-0", $.headerIcon),
|
|
453
472
|
"aria-hidden": !0
|
|
454
473
|
}),
|
|
455
|
-
/* @__PURE__ */
|
|
456
|
-
className: s(
|
|
457
|
-
children:
|
|
474
|
+
/* @__PURE__ */ J("span", {
|
|
475
|
+
className: s(w, $.headerLabel),
|
|
476
|
+
children: N
|
|
458
477
|
}),
|
|
459
|
-
e.length >= 2 && (r || n) && /* @__PURE__ */
|
|
460
|
-
icon: /* @__PURE__ */
|
|
478
|
+
e.length >= 2 && (r || n) && /* @__PURE__ */ J(l, {
|
|
479
|
+
icon: /* @__PURE__ */ J(g, {
|
|
461
480
|
size: c.SM,
|
|
462
481
|
"aria-hidden": !0
|
|
463
482
|
}),
|
|
464
483
|
className: s("ms-auto h-6 w-6 rounded-lg", $.downloadAllButton),
|
|
465
|
-
"aria-label":
|
|
484
|
+
"aria-label": S,
|
|
466
485
|
onClick: () => {
|
|
467
486
|
let t = e.filter((e) => e.status === a.Idle);
|
|
468
487
|
r ? r(t) : t.forEach((e) => n?.(e));
|
|
469
488
|
}
|
|
470
489
|
})
|
|
471
490
|
]
|
|
472
|
-
}), /* @__PURE__ */
|
|
491
|
+
}), /* @__PURE__ */ Y("div", {
|
|
473
492
|
role: "list",
|
|
474
|
-
"aria-label":
|
|
475
|
-
className: s("gap-3",
|
|
493
|
+
"aria-label": N,
|
|
494
|
+
className: s("gap-3", j ? "grid grid-cols-[repeat(5,84px)] overflow-x-auto" : "flex flex-wrap"),
|
|
476
495
|
children: [
|
|
477
|
-
|
|
496
|
+
P.map((e) => /* @__PURE__ */ J("div", {
|
|
478
497
|
role: "listitem",
|
|
479
|
-
children: e.type === t.Image ? /* @__PURE__ */
|
|
498
|
+
children: e.type === t.Image ? /* @__PURE__ */ J(we, {
|
|
480
499
|
attachment: e,
|
|
481
500
|
onClick: n ? () => n(e) : void 0,
|
|
482
501
|
onRetry: i,
|
|
483
502
|
labels: {
|
|
484
|
-
clickLabel:
|
|
485
|
-
retryLabel:
|
|
503
|
+
clickLabel: y,
|
|
504
|
+
retryLabel: b
|
|
486
505
|
},
|
|
506
|
+
typeLabels: d,
|
|
487
507
|
styles: { roundedClassName: "rounded-xl" },
|
|
488
508
|
showHoverDownloadIcon: !0,
|
|
489
509
|
className: s("size-[84px]", $.imageTile)
|
|
490
|
-
}) : /* @__PURE__ */
|
|
510
|
+
}) : /* @__PURE__ */ J(De, {
|
|
491
511
|
attachment: e,
|
|
492
512
|
onClick: n,
|
|
493
513
|
onRetry: i,
|
|
494
514
|
labels: {
|
|
495
|
-
clickLabel:
|
|
496
|
-
retryLabel:
|
|
515
|
+
clickLabel: y,
|
|
516
|
+
retryLabel: b,
|
|
497
517
|
sizeLabel: o?.(e)
|
|
498
518
|
},
|
|
499
|
-
|
|
519
|
+
typeLabels: d,
|
|
520
|
+
theme: p
|
|
500
521
|
})
|
|
501
522
|
}, e.id)),
|
|
502
|
-
|
|
523
|
+
D.layout === Z.Collapsed && /* @__PURE__ */ J("div", {
|
|
503
524
|
role: "listitem",
|
|
504
|
-
children: /* @__PURE__ */
|
|
505
|
-
count:
|
|
506
|
-
onClick: () =>
|
|
525
|
+
children: /* @__PURE__ */ J(ke, {
|
|
526
|
+
count: D.hiddenCount,
|
|
527
|
+
onClick: () => E(!0)
|
|
507
528
|
})
|
|
508
529
|
}),
|
|
509
|
-
|
|
530
|
+
j && T && /* @__PURE__ */ J("div", {
|
|
510
531
|
role: "listitem",
|
|
511
|
-
children: /* @__PURE__ */
|
|
532
|
+
children: /* @__PURE__ */ J(ke, {
|
|
512
533
|
count: 0,
|
|
513
|
-
onClick: () =>
|
|
514
|
-
ariaLabel:
|
|
515
|
-
children: /* @__PURE__ */
|
|
534
|
+
onClick: () => E(!1),
|
|
535
|
+
ariaLabel: x,
|
|
536
|
+
children: /* @__PURE__ */ J(m, {
|
|
516
537
|
size: c.MD,
|
|
517
538
|
"aria-hidden": !0
|
|
518
539
|
})
|
|
@@ -521,77 +542,88 @@ var Y = /* @__PURE__ */ function(e) {
|
|
|
521
542
|
]
|
|
522
543
|
})]
|
|
523
544
|
});
|
|
524
|
-
},
|
|
545
|
+
}, Me = {
|
|
525
546
|
overlay: "_overlay_wr7ez_1",
|
|
526
547
|
icon: "_icon_wr7ez_5",
|
|
527
548
|
deniedIcon: "_deniedIcon_wr7ez_9"
|
|
528
|
-
},
|
|
549
|
+
}, Ne = ({ isVisible: e, isAttachmentsAllowed: t = !0, title: n, subtitle: r, styles: i }) => {
|
|
529
550
|
let { colors: a, typography: c } = i ?? {}, { titleClassName: l = "heading-3 font-semibold", subtitleClassName: u = "dial-small-text" } = c ?? {};
|
|
530
551
|
if (!e) return null;
|
|
531
552
|
let d = o({
|
|
532
553
|
"--fd-bg": a?.background,
|
|
533
554
|
"--fd-icon": a?.icon,
|
|
534
555
|
"--fd-denied-icon": a?.deniedIcon
|
|
535
|
-
}), f = n ?? (t ? "Attach files" : "No attachments allowed"), p = r ?? (t ? "Drop files here to attach them to message" : "Attachments can't be added to message"), m = t ?
|
|
556
|
+
}), f = n ?? (t ? "Attach files" : "No attachments allowed"), p = r ?? (t ? "Drop files here to attach them to message" : "Attachments can't be added to message"), m = t ? Me.icon : Me.deniedIcon, h = (e) => {
|
|
536
557
|
e.preventDefault();
|
|
537
|
-
}, g = t ? v :
|
|
538
|
-
return /* @__PURE__ */
|
|
539
|
-
|
|
558
|
+
}, g = t ? v : H;
|
|
559
|
+
return /* @__PURE__ */ J("div", {
|
|
560
|
+
role: "status",
|
|
561
|
+
"aria-live": "polite",
|
|
562
|
+
className: s("fixed inset-0 z-[9999] flex items-center justify-center backdrop-blur-sm", Me.overlay, t ? "pointer-events-none" : "pointer-events-auto cursor-not-allowed"),
|
|
540
563
|
onDragOver: t ? void 0 : h,
|
|
541
564
|
onDrop: t ? void 0 : h,
|
|
542
565
|
style: d,
|
|
543
|
-
children: /* @__PURE__ */
|
|
566
|
+
children: /* @__PURE__ */ Y("div", {
|
|
544
567
|
className: "flex flex-col items-center text-center",
|
|
545
568
|
children: [
|
|
546
|
-
/* @__PURE__ */
|
|
569
|
+
/* @__PURE__ */ J(g, {
|
|
547
570
|
size: 100,
|
|
548
|
-
className: m
|
|
571
|
+
className: m,
|
|
572
|
+
"aria-hidden": !0
|
|
549
573
|
}),
|
|
550
|
-
/* @__PURE__ */
|
|
574
|
+
/* @__PURE__ */ J("span", {
|
|
551
575
|
className: s("mt-5", l),
|
|
552
576
|
children: f
|
|
553
577
|
}),
|
|
554
|
-
/* @__PURE__ */
|
|
578
|
+
/* @__PURE__ */ J("span", {
|
|
555
579
|
className: s("mt-4", u),
|
|
556
580
|
children: p
|
|
557
581
|
})
|
|
558
582
|
]
|
|
559
583
|
})
|
|
560
584
|
});
|
|
561
|
-
},
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
let
|
|
566
|
-
|
|
567
|
-
let
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
585
|
+
}, Pe = (e, n, r = {}) => {
|
|
586
|
+
let { screenshotName: i = "Screenshot.png", pastedTextName: o = "Pasted text" } = r;
|
|
587
|
+
return { handlePaste: G((r) => {
|
|
588
|
+
if (!r.clipboardData) return;
|
|
589
|
+
let s = Array.from(r.clipboardData.items).filter((e) => e.kind === "file" && e.type.startsWith("image/")), c = r.clipboardData.getData("text/plain").length > 0;
|
|
590
|
+
if (s.length > 0 && !c) {
|
|
591
|
+
let n = [];
|
|
592
|
+
for (let e of s) {
|
|
593
|
+
let r = e.getAsFile();
|
|
594
|
+
if (!r) continue;
|
|
595
|
+
let o = new File([r], i, { type: r.type }), s = {
|
|
596
|
+
id: pe(),
|
|
597
|
+
name: i,
|
|
598
|
+
contentType: r.type,
|
|
599
|
+
file: o,
|
|
600
|
+
type: t.Image,
|
|
601
|
+
status: a.Idle,
|
|
602
|
+
previewUrl: URL.createObjectURL(o)
|
|
603
|
+
};
|
|
604
|
+
n.push(s);
|
|
605
|
+
}
|
|
606
|
+
r.preventDefault(), e(n);
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
let l = r.clipboardData.getData("text/plain");
|
|
610
|
+
if (l.length > n) {
|
|
611
|
+
let n = l.trim(), i = (n.length > 80 ? `${n.slice(0, 80).trimEnd()}…` : n) || o, s = new File([l], i, { type: "text/plain" }), c = {
|
|
612
|
+
id: pe(),
|
|
613
|
+
name: i,
|
|
614
|
+
contentType: "text/plain",
|
|
615
|
+
file: s,
|
|
616
|
+
type: t.Pasted,
|
|
617
|
+
status: a.Idle
|
|
577
618
|
};
|
|
578
|
-
|
|
619
|
+
r.preventDefault(), e([c]);
|
|
579
620
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
name: i,
|
|
588
|
-
contentType: "text/plain",
|
|
589
|
-
file: o,
|
|
590
|
-
type: t.Pasted,
|
|
591
|
-
status: a.Idle
|
|
592
|
-
};
|
|
593
|
-
r.preventDefault(), e([c]);
|
|
594
|
-
}
|
|
595
|
-
}, [e, n]) }), Pe = 100;
|
|
621
|
+
}, [
|
|
622
|
+
e,
|
|
623
|
+
n,
|
|
624
|
+
i,
|
|
625
|
+
o
|
|
626
|
+
]) };
|
|
627
|
+
}, Fe = 100;
|
|
596
628
|
//#endregion
|
|
597
|
-
export {
|
|
629
|
+
export { fe as ATTACHMENT_COLLAPSED_VISIBLE_COUNT, de as ATTACHMENT_COLLAPSE_THRESHOLD, we as AttachmentCard, De as AttachmentFileRow, je as AttachmentGroup, ke as AttachmentMoreTile, Z as AttachmentTilesLayout, Te as AttachmentTray, Ne as FileDndOverlay, le as LazyImageLoadStatus, Fe as MAX_UPLOADS_PER_MINUTE, pe as generateAttachmentId, Se as getAttachmentCardState, ve as getAttachmentIcon, Ce as getAttachmentTilesPlan, be as getExtFromContentType, me as getNameWithoutExtension, _e as isMimeTypeAllowed, ge as mimeTypesToExtensionLabels, Pe as useClipboardPaste, ue as useLazyImageLoad };
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
2
2
|
import { Icon } from '@tabler/icons-react';
|
|
3
|
+
/** Localised labels for the non-extension attachment type names derived by `getAttachmentCardState`. */
|
|
4
|
+
export interface AttachmentTypeLabels {
|
|
5
|
+
/** Label shown for a prompt-type attachment. Defaults to `'Prompt'`. */
|
|
6
|
+
promptLabel?: string;
|
|
7
|
+
/** Label shown for a pasted-text attachment. Defaults to `'Pasted'`. */
|
|
8
|
+
pastedLabel?: string;
|
|
9
|
+
/** Label shown for an image attachment. Defaults to `'Image'`. */
|
|
10
|
+
imageLabel?: string;
|
|
11
|
+
}
|
|
3
12
|
/** Derived display state an AttachmentCard/AttachmentFileRow needs to render a given attachment. */
|
|
4
13
|
export interface AttachmentCardState {
|
|
5
14
|
/** Whether the attachment is currently uploading. */
|
|
@@ -58,6 +67,12 @@ export interface AttachmentCardLabels {
|
|
|
58
67
|
retryLabel?: string;
|
|
59
68
|
/** Accessible label applied to the card root when it is interactive via `onClick`. Defaults to `'Open attachment'`. */
|
|
60
69
|
clickLabel?: string;
|
|
70
|
+
/** Accessible label applied to the card root when it is interactive via `onExpand` (pasted-text cards). Defaults to `'Expand pasted text'`. */
|
|
71
|
+
expandLabel?: string;
|
|
72
|
+
/** Accessible label for the loading spinner shown while the attachment is uploading. Defaults to `'Loading attachment'`. */
|
|
73
|
+
loadingLabel?: string;
|
|
74
|
+
/** Status message announced to assistive tech when the upload fails. Defaults to `'Upload failed'`. */
|
|
75
|
+
uploadFailedStatusLabel?: string;
|
|
61
76
|
}
|
|
62
77
|
/** Props accepted by the `AttachmentCard` component. */
|
|
63
78
|
export interface AttachmentCardProps {
|
|
@@ -79,6 +94,8 @@ export interface AttachmentCardProps {
|
|
|
79
94
|
onClick?: (id: string) => void;
|
|
80
95
|
/** Localised accessible labels for the remove/retry actions and the interactive card root. */
|
|
81
96
|
labels?: AttachmentCardLabels;
|
|
97
|
+
/** Localised labels for the non-extension attachment type names (prompt/pasted/image). */
|
|
98
|
+
typeLabels?: AttachmentTypeLabels;
|
|
82
99
|
/** Color, typography, and shape overrides for the card. */
|
|
83
100
|
styles?: AttachmentCardStyles;
|
|
84
101
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-card.d.ts","sourceRoot":"","sources":["../../src/models/attachment-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,oGAAoG;AACpG,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,6FAA6F;IAC7F,iBAAiB,EAAE,OAAO,CAAC;IAC3B,yDAAyD;IACzD,UAAU,EAAE,IAAI,CAAC;IACjB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,cAAc,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,wBAAwB;IACvC,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sHAAsH;IACtH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,mGAAmG;AACnG,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,oJAAoJ;IACpJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uHAAuH;IACvH,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment-card.d.ts","sourceRoot":"","sources":["../../src/models/attachment-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wGAAwG;AACxG,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,oGAAoG;AACpG,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,6FAA6F;IAC7F,iBAAiB,EAAE,OAAO,CAAC;IAC3B,yDAAyD;IACzD,UAAU,EAAE,IAAI,CAAC;IACjB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,cAAc,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,wBAAwB;IACvC,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sHAAsH;IACtH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,mGAAmG;AACnG,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,oJAAoJ;IACpJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uHAAuH;IACvH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+IAA+I;IAC/I,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4HAA4H;IAC5H,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uGAAuG;IACvG,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,wDAAwD;AACxD,MAAM,WAAW,mBAAmB;IAClC,sCAAsC;IACtC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,mGAAmG;IACnG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,gGAAgG;IAChG,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,8FAA8F;IAC9F,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,0FAA0F;IAC1F,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CodeBlockTheme, DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
1
|
+
import { AttachmentErrorReason, CodeBlockTheme, DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { AttachmentTypeLabels } from './attachment-card';
|
|
2
3
|
/** Localised labels for the `AttachmentFileRow` component. */
|
|
3
4
|
export interface AttachmentFileRowLabels {
|
|
4
5
|
/** Accessible label for the download action. Defaults to `'Download attachment'`. */
|
|
@@ -7,6 +8,12 @@ export interface AttachmentFileRowLabels {
|
|
|
7
8
|
retryLabel?: string;
|
|
8
9
|
/** Human-readable size text (e.g. `'2.4 MB'`), appended after the type label in the meta line (`'.pdf · 2.4 MB'`) when derivable; omitted from the meta line if absent. */
|
|
9
10
|
sizeLabel?: string;
|
|
11
|
+
/** Accessible label for the in-progress upload progress bar. Defaults to `'Uploading'`. */
|
|
12
|
+
uploadingLabel?: string;
|
|
13
|
+
/** Per-`AttachmentErrorReason` error title text, shown as the tile's tooltip/title in error state. Defaults to built-in English reason text. */
|
|
14
|
+
errorReasonLabels?: Partial<Record<AttachmentErrorReason, string>>;
|
|
15
|
+
/** Fallback error title used when `errorReason` is absent or has no entry in `errorReasonLabels`. Defaults to `'Upload failed'`. */
|
|
16
|
+
genericErrorLabel?: string;
|
|
10
17
|
}
|
|
11
18
|
/** Style overrides for the `AttachmentFileRow` component. */
|
|
12
19
|
export interface AttachmentFileRowStyles {
|
|
@@ -25,6 +32,8 @@ export interface AttachmentFileRowProps {
|
|
|
25
32
|
onRetry?: (id: string) => void;
|
|
26
33
|
/** Localised labels for the download/retry actions and size text. */
|
|
27
34
|
labels?: AttachmentFileRowLabels;
|
|
35
|
+
/** Localised labels for the non-extension attachment type names (prompt/pasted/image). */
|
|
36
|
+
typeLabels?: AttachmentTypeLabels;
|
|
28
37
|
/** Style overrides for the file name and meta label text. */
|
|
29
38
|
styles?: AttachmentFileRowStyles;
|
|
30
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-file-row.d.ts","sourceRoot":"","sources":["../../src/models/attachment-file-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment-file-row.d.ts","sourceRoot":"","sources":["../../src/models/attachment-file-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2KAA2K;IAC3K,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gJAAgJ;IAChJ,iBAAiB,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC;IACnE,oIAAoI;IACpI,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,6DAA6D;AAC7D,MAAM,WAAW,uBAAuB;IACtC,yFAAyF;IACzF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iHAAiH;IACjH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2DAA2D;AAC3D,MAAM,WAAW,sBAAsB;IACrC,0DAA0D;IAC1D,UAAU,EAAE,iBAAiB,CAAC;IAC9B,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,qEAAqE;IACrE,MAAM,CAAC,EAAE,uBAAuB,CAAC;IACjC,0FAA0F;IAC1F,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,uBAAuB,CAAC;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CodeBlockTheme, DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { AttachmentTypeLabels } from './attachment-card';
|
|
2
3
|
/** How the unified attachment tile grid should render for a given total attachment count. */
|
|
3
4
|
export declare enum AttachmentTilesLayout {
|
|
4
5
|
/** No attachments. */
|
|
@@ -29,6 +30,12 @@ export interface AttachmentGroupLabels {
|
|
|
29
30
|
showLessLabel?: string;
|
|
30
31
|
/** Label for the "download all" header action, shown whenever the group has 2+ attachments. Defaults to `'Download all'`. */
|
|
31
32
|
downloadAllLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the header count label (e.g. `'3 attachments'`) for a given
|
|
35
|
+
* attachment count. Defaults to English `'{count} attachment'` /
|
|
36
|
+
* `'{count} attachments'` pluralization.
|
|
37
|
+
*/
|
|
38
|
+
getHeaderLabel?: (count: number) => string;
|
|
32
39
|
}
|
|
33
40
|
/** Style overrides for the `AttachmentGroup` component. */
|
|
34
41
|
export interface AttachmentGroupStyles {
|
|
@@ -53,6 +60,8 @@ export interface AttachmentGroupProps {
|
|
|
53
60
|
getSizeLabel?: (attachment: DisplayAttachment) => string | undefined;
|
|
54
61
|
/** Localised accessible labels for the group region and its actions. */
|
|
55
62
|
labels?: AttachmentGroupLabels;
|
|
63
|
+
/** Localised labels for the non-extension attachment type names (prompt/pasted/image), forwarded to each tile. */
|
|
64
|
+
typeLabels?: AttachmentTypeLabels;
|
|
56
65
|
/** Style overrides for the header label. */
|
|
57
66
|
styles?: AttachmentGroupStyles;
|
|
58
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-group.d.ts","sourceRoot":"","sources":["../../src/models/attachment-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment-group.d.ts","sourceRoot":"","sources":["../../src/models/attachment-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,6FAA6F;AAC7F,oBAAY,qBAAqB;IAC/B,sBAAsB;IACtB,IAAI,SAAS;IACb,mEAAmE;IACnE,UAAU,gBAAgB;IAC1B,oFAAoF;IACpF,SAAS,cAAc;CACxB;AAED,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,MAAM,EAAE,qBAAqB,CAAC;IAC9B,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,uEAAuE;AACvE,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oIAAoI;IACpI,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6HAA6H;IAC7H,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AAED,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IACpC,4GAA4G;IAC5G,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,mGAAmG;IACnG,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5D;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,IAAI,CAAC;IAC3D,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,kHAAkH;IAClH,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,MAAM,GAAG,SAAS,CAAC;IACrE,wEAAwE;IACxE,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,kHAAkH;IAClH,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,4CAA4C;IAC5C,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-attachment-input",
|
|
3
3
|
"description": "File attachment input components with upload validation, drag-and-drop, and progress tracking",
|
|
4
|
-
"version": "1.0.0-dev.
|
|
4
|
+
"version": "1.0.0-dev.489",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@epam/ai-dial-chat-shared": "1.0.0-dev.
|
|
20
|
+
"@epam/ai-dial-chat-shared": "1.0.0-dev.489",
|
|
21
21
|
"@epam/ai-dial-ui-kit": "0.12.0-dev.28",
|
|
22
22
|
"@tabler/icons-react": "^3.44.0",
|
|
23
23
|
"react": "^19.0.0"
|
package/utils/attachment.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
2
2
|
import { Icon } from '@tabler/icons-react';
|
|
3
|
-
import { AttachmentCardState } from '../models/attachment-card';
|
|
3
|
+
import { AttachmentCardState, AttachmentTypeLabels } from '../models/attachment-card';
|
|
4
4
|
import { AttachmentTilesPlan } from '../models/attachment-group';
|
|
5
5
|
/**
|
|
6
6
|
* Generates a unique identifier for an attachment, combining the current
|
|
@@ -18,8 +18,12 @@ export declare const getNameWithoutExtension: (name: string) => string;
|
|
|
18
18
|
* Examples:
|
|
19
19
|
* `['application/pdf', 'image/jpeg']` → `'PDF, JPEG'`
|
|
20
20
|
* `['image/*', 'text/csv']` → `'Image files, CSV'`
|
|
21
|
+
*
|
|
22
|
+
* @param wildcardLabels - Optional overrides for the wildcard category labels
|
|
23
|
+
* (`image`, `audio`, `video`, `text`), keyed by MIME major type. Defaults
|
|
24
|
+
* to the built-in English labels.
|
|
21
25
|
*/
|
|
22
|
-
export declare const mimeTypesToExtensionLabels: (types: string[]) => string;
|
|
26
|
+
export declare const mimeTypesToExtensionLabels: (types: string[], wildcardLabels?: Record<string, string>) => string;
|
|
23
27
|
/**
|
|
24
28
|
* Returns `true` when `mimeType` matches at least one entry in `allowedTypes`.
|
|
25
29
|
*
|
|
@@ -39,7 +43,7 @@ export declare const getAttachmentIcon: (contentType: string) => Icon;
|
|
|
39
43
|
/** Derives a bare file extension (no leading dot) from a MIME type, e.g. `'application/pdf'` -> `'pdf'`. */
|
|
40
44
|
export declare const getExtFromContentType: (contentType: string) => string | undefined;
|
|
41
45
|
/** Derives the display state (icons, labels, color classes) an AttachmentCard/AttachmentFileRow needs to render a given attachment. */
|
|
42
|
-
export declare const getAttachmentCardState: (attachment: DisplayAttachment, isSelected: boolean, shouldAlwaysShowActions: boolean) => AttachmentCardState;
|
|
46
|
+
export declare const getAttachmentCardState: (attachment: DisplayAttachment, isSelected: boolean, shouldAlwaysShowActions: boolean, typeLabels?: AttachmentTypeLabels) => AttachmentCardState;
|
|
43
47
|
/** Decides how the unified tile grid should render for `totalCount` attachments, given whether the group is expanded. */
|
|
44
48
|
export declare const getAttachmentTilesPlan: (totalCount: number, isExpanded: boolean) => AttachmentTilesPlan;
|
|
45
49
|
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../src/utils/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAqChD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../src/utils/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAqChD,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,4BAA4B,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAO,MACgB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,MAGtD,CAAC;AASF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GACrC,OAAO,MAAM,EAAE,EACf,iBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAwB,KAC5D,MAUF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,MAAM,EAChB,cAAc,MAAM,EAAE,KACrB,OAUF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,IA0FvD,CAAC;AAUF,4GAA4G;AAC5G,eAAO,MAAM,qBAAqB,GAChC,aAAa,MAAM,KAClB,MAAM,GAAG,SAUX,CAAC;AA0BF,uIAAuI;AACvI,eAAO,MAAM,sBAAsB,GACjC,YAAY,iBAAiB,EAC7B,YAAY,OAAO,EACnB,yBAAyB,OAAO,EAChC,aAAY,oBAAyB,KACpC,mBAkCF,CAAC;AAEF,yHAAyH;AACzH,eAAO,MAAM,sBAAsB,GACjC,YAAY,MAAM,EAClB,YAAY,OAAO,KAClB,mBAoBF,CAAC"}
|