@epam/ai-dial-skill-editor 1.1.0-dev.294 → 1.1.0-dev.297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkillFileUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/SkillFileUploadDialog/SkillFileUploadDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SkillFileUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/SkillFileUploadDialog/SkillFileUploadDialog.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EAGlB,MAAM,iCAAiC,CAAC;AAOzC,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IACzC,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,0FAA0F;IAC1F,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sDAAsD;IACtD,WAAW,EAAE,IAAI,CAAC,sBAAsB,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC;IAC3E;;;OAGG;IACH,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC;IACtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAWD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CA0OhE,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { buildCssVars as e, formatFileSize as t, mergeClasses as n } from "@epam/ai-dial-chat-shared";
|
|
2
2
|
import { DialFileNodeType as r, DialFoldersTree as i } from "@epam/ai-dial-react-file-manager";
|
|
3
|
-
import { Accordion as a, CaptionText as
|
|
4
|
-
import { IconFileText as
|
|
5
|
-
import { Suspense as
|
|
6
|
-
import { Fragment as
|
|
3
|
+
import { Accordion as a, CaptionText as o, DIAL_ICON_SIZE as s, EditorThemes as c, ErrorText as l, FileDropzone as ee, GhostButton as u, GhostIconButton as d, Input as f, LazyMarkdownEditor as p, NeutralButton as m, Popup as h, PopupSize as te, PrimaryButton as g, Spinner as _, Textarea as v } from "@epam/ai-dial-ui-kit";
|
|
4
|
+
import { IconFileText as ne, IconPlus as re, IconTrashX as ie, IconUpload as y } from "@tabler/icons-react";
|
|
5
|
+
import { Suspense as b, lazy as x, useCallback as S, useEffect as C, useId as w, useMemo as T, useRef as E, useState as D } from "react";
|
|
6
|
+
import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
|
|
7
7
|
//#region src/hooks/useSkillFileDropZone.ts
|
|
8
|
-
var
|
|
9
|
-
let [t, n] =
|
|
8
|
+
var j = (e) => !!e.dataTransfer?.types.includes("Files"), ae = (e) => {
|
|
9
|
+
let [t, n] = D(!1), r = E(0);
|
|
10
10
|
return {
|
|
11
11
|
isDragActive: t,
|
|
12
12
|
dropZoneHandlers: {
|
|
13
|
-
onDragEnter:
|
|
14
|
-
|
|
13
|
+
onDragEnter: S((e) => {
|
|
14
|
+
j(e) && (e.preventDefault(), r.current += 1, n(!0));
|
|
15
15
|
}, []),
|
|
16
|
-
onDragLeave:
|
|
17
|
-
|
|
16
|
+
onDragLeave: S((e) => {
|
|
17
|
+
j(e) && (--r.current, r.current <= 0 && (r.current = 0, n(!1)));
|
|
18
18
|
}, []),
|
|
19
|
-
onDragOver:
|
|
20
|
-
|
|
19
|
+
onDragOver: S((e) => {
|
|
20
|
+
j(e) && e.preventDefault();
|
|
21
21
|
}, []),
|
|
22
|
-
onDrop:
|
|
23
|
-
if (!
|
|
22
|
+
onDrop: S((t) => {
|
|
23
|
+
if (!j(t)) return;
|
|
24
24
|
t.preventDefault(), r.current = 0, n(!1);
|
|
25
25
|
let i = Array.from(t.dataTransfer?.files ?? []);
|
|
26
26
|
i.length > 0 && e(i);
|
|
27
27
|
}, [e])
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
},
|
|
30
|
+
}, M = "SKILL.md", N = /* @__PURE__ */ function(e) {
|
|
31
31
|
return e.File = "file", e.Folder = "folder", e;
|
|
32
|
-
}({}),
|
|
32
|
+
}({}), P = (e) => {
|
|
33
33
|
let t = e.lastIndexOf("/");
|
|
34
34
|
return t === -1 ? null : e.slice(0, t);
|
|
35
|
-
},
|
|
35
|
+
}, F = (e) => {
|
|
36
36
|
let t = e.lastIndexOf("/");
|
|
37
37
|
return t === -1 ? e : e.slice(t + 1);
|
|
38
38
|
}, oe = (e) => {
|
|
@@ -41,16 +41,16 @@ var A = (e) => !!e.dataTransfer?.types.includes("Files"), ae = (e) => {
|
|
|
41
41
|
if (n) return n;
|
|
42
42
|
let i = {
|
|
43
43
|
path: e,
|
|
44
|
-
name:
|
|
44
|
+
name: F(e),
|
|
45
45
|
nodeType: r.FOLDER,
|
|
46
|
-
parentPath:
|
|
46
|
+
parentPath: P(e),
|
|
47
47
|
folderId: e,
|
|
48
48
|
items: []
|
|
49
49
|
};
|
|
50
50
|
return t.set(e, i), i;
|
|
51
51
|
};
|
|
52
52
|
for (let i of e) {
|
|
53
|
-
if (i.kind ===
|
|
53
|
+
if (i.kind === N.Folder) {
|
|
54
54
|
n(i.path);
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
@@ -58,13 +58,13 @@ var A = (e) => !!e.dataTransfer?.types.includes("Files"), ae = (e) => {
|
|
|
58
58
|
path: i.path,
|
|
59
59
|
name: i.name,
|
|
60
60
|
nodeType: r.ITEM,
|
|
61
|
-
parentPath:
|
|
62
|
-
folderId:
|
|
61
|
+
parentPath: P(i.path),
|
|
62
|
+
folderId: P(i.path) ?? ""
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
for (let t of [...e]) {
|
|
66
|
-
let e =
|
|
67
|
-
for (; e != null;) n(e), e =
|
|
66
|
+
let e = P(t.path);
|
|
67
|
+
for (; e != null;) n(e), e = P(e);
|
|
68
68
|
}
|
|
69
69
|
let i = [];
|
|
70
70
|
for (let e of t.values()) {
|
|
@@ -79,188 +79,167 @@ var A = (e) => !!e.dataTransfer?.types.includes("Files"), ae = (e) => {
|
|
|
79
79
|
}, se = ({ isVisible: e, labels: t }) => {
|
|
80
80
|
if (!e) return null;
|
|
81
81
|
let r = t ?? {};
|
|
82
|
-
return /* @__PURE__ */
|
|
82
|
+
return /* @__PURE__ */ k("div", {
|
|
83
83
|
role: "status",
|
|
84
84
|
"aria-live": "polite",
|
|
85
85
|
className: n("pointer-events-none absolute inset-0 z-[100] flex items-center justify-center backdrop-blur-sm"),
|
|
86
|
-
children: /* @__PURE__ */
|
|
86
|
+
children: /* @__PURE__ */ A("div", {
|
|
87
87
|
className: "flex flex-col items-center text-center",
|
|
88
88
|
children: [
|
|
89
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ k(y, {
|
|
90
90
|
size: 100,
|
|
91
91
|
className: "text-accent-primary",
|
|
92
92
|
"aria-hidden": !0
|
|
93
93
|
}),
|
|
94
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ k("span", {
|
|
95
95
|
className: "dial-h3-text mt-5",
|
|
96
96
|
children: r.dropOverlayTitle ?? "Upload files"
|
|
97
97
|
}),
|
|
98
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ k("span", {
|
|
99
99
|
className: "dial-small-text mt-4",
|
|
100
100
|
children: r.dropOverlaySubtitle ?? "Drop files here to add them to this skill"
|
|
101
101
|
})
|
|
102
102
|
]
|
|
103
103
|
})
|
|
104
104
|
});
|
|
105
|
-
},
|
|
105
|
+
}, I = /* @__PURE__ */ function(e) {
|
|
106
106
|
return e.SupportingFile = "supporting-file", e.Manifest = "manifest", e;
|
|
107
|
-
}({}),
|
|
107
|
+
}({}), L = /* @__PURE__ */ function(e) {
|
|
108
108
|
return e.Valid = "valid", e.Invalid = "invalid", e;
|
|
109
|
-
}({}),
|
|
110
|
-
let o =
|
|
109
|
+
}({}), R = (e) => (e.webkitRelativePath || e.name).replace(/\\/g, "/"), ce = 0, z = () => `skill-file-candidate-${++ce}`, le = ({ isOpen: e, onClose: n, fileActions: r, initialFiles: i, labels: a }) => {
|
|
110
|
+
let o = a ?? {}, [s, c] = D([]), [f, p] = D(/* @__PURE__ */ new Map()), [m, v] = D([]), [re, y] = D(!1), [b, x] = D(), [S, T] = D(!1), E = w(), j = (e) => {
|
|
111
111
|
let t = e.map((e) => ({
|
|
112
112
|
id: z(),
|
|
113
113
|
file: e,
|
|
114
|
-
path:
|
|
114
|
+
path: R(e)
|
|
115
115
|
}));
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
e && (
|
|
116
|
+
x(void 0), c((e) => [...e, ...t]);
|
|
117
|
+
}, ae = (e) => {
|
|
118
|
+
c((t) => t.filter((t) => t.id !== e));
|
|
119
|
+
};
|
|
120
|
+
C(() => {
|
|
121
|
+
e && (c((i ?? []).map((e) => ({
|
|
122
122
|
id: z(),
|
|
123
123
|
file: e,
|
|
124
|
-
path:
|
|
125
|
-
}))),
|
|
126
|
-
}, [e]),
|
|
124
|
+
path: R(e)
|
|
125
|
+
}))), p(/* @__PURE__ */ new Map()), v([]), x(void 0));
|
|
126
|
+
}, [e]), C(() => {
|
|
127
127
|
if (!e) return;
|
|
128
128
|
let t = !1;
|
|
129
|
-
if (
|
|
130
|
-
|
|
129
|
+
if (s.length === 0) {
|
|
130
|
+
p(/* @__PURE__ */ new Map()), v([]);
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
return
|
|
134
|
-
t || (
|
|
133
|
+
return y(!0), r.validateBatch(s).then(({ results: e, batchErrors: n }) => {
|
|
134
|
+
t || (p(new Map(e.map((e) => [e.candidateId, e]))), v(n.map((e) => e.message)));
|
|
135
135
|
}).finally(() => {
|
|
136
|
-
t ||
|
|
136
|
+
t || y(!1);
|
|
137
137
|
}), () => {
|
|
138
138
|
t = !0;
|
|
139
139
|
};
|
|
140
|
-
}, [
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
e.target.value = "", t.length > 0 && N(t);
|
|
144
|
-
}, ce = u.some((e) => f.get(e.id)?.status === I.Invalid), B = u.length > 0 && u.every((e) => f.get(e.id)?.status === I.Invalid), le = u.length > 0 && !ce && _.length === 0 && !b && !A, V = async () => {
|
|
145
|
-
j(!0), D(void 0);
|
|
140
|
+
}, [s, e]);
|
|
141
|
+
let M = s.some((e) => f.get(e.id)?.status === L.Invalid), N = s.length > 0 && s.every((e) => f.get(e.id)?.status === L.Invalid), P = s.length > 0 && !M && m.length === 0 && !re && !S, F = async () => {
|
|
142
|
+
T(!0), x(void 0);
|
|
146
143
|
try {
|
|
147
|
-
let { results: e, batchErrors: t } = await
|
|
148
|
-
if (
|
|
149
|
-
let a = await
|
|
144
|
+
let { results: e, batchErrors: t } = await r.validateBatch(s), i = new Map(e.map((e) => [e.candidateId, e]));
|
|
145
|
+
if (p(i), v(t.map((e) => e.message)), s.some((e) => i.get(e.id)?.status === L.Invalid) || t.length > 0) return;
|
|
146
|
+
let a = await r.commitBatch(s);
|
|
150
147
|
if (a.error) {
|
|
151
|
-
|
|
148
|
+
x(a.error);
|
|
152
149
|
return;
|
|
153
150
|
}
|
|
154
|
-
|
|
151
|
+
n();
|
|
155
152
|
} finally {
|
|
156
|
-
|
|
153
|
+
T(!1);
|
|
157
154
|
}
|
|
158
155
|
};
|
|
159
|
-
return /* @__PURE__ */
|
|
156
|
+
return /* @__PURE__ */ k(h, {
|
|
160
157
|
open: e,
|
|
161
158
|
header: o.uploadDialogTitle ?? "Upload files from device",
|
|
162
|
-
size:
|
|
159
|
+
size: te.Sm,
|
|
163
160
|
closeAriaLabel: o.uploadDialogCloseAriaLabel ?? "Close",
|
|
164
|
-
onClose:
|
|
165
|
-
footer: /* @__PURE__ */
|
|
161
|
+
onClose: n,
|
|
162
|
+
footer: /* @__PURE__ */ A("div", {
|
|
166
163
|
className: "flex min-h-[44px] items-center justify-end gap-2 px-6 py-4",
|
|
167
|
-
children: [/* @__PURE__ */
|
|
164
|
+
children: [/* @__PURE__ */ k(u, {
|
|
168
165
|
label: o.uploadCancelLabel ?? "Cancel",
|
|
169
|
-
onClick:
|
|
170
|
-
}), /* @__PURE__ */
|
|
166
|
+
onClick: n
|
|
167
|
+
}), /* @__PURE__ */ k(g, {
|
|
171
168
|
label: o.uploadConfirmLabel ?? "Add",
|
|
172
|
-
iconBefore:
|
|
169
|
+
iconBefore: S ? /* @__PURE__ */ k(_, {
|
|
173
170
|
size: 16,
|
|
174
171
|
ariaLabel: ""
|
|
175
172
|
}) : void 0,
|
|
176
|
-
onClick: () => void
|
|
177
|
-
disabled: !
|
|
173
|
+
onClick: () => void F(),
|
|
174
|
+
disabled: !P
|
|
178
175
|
})]
|
|
179
176
|
}),
|
|
180
|
-
children: /* @__PURE__ */
|
|
177
|
+
children: /* @__PURE__ */ A("div", {
|
|
181
178
|
className: "flex flex-col gap-4 px-6 py-4",
|
|
182
179
|
children: [
|
|
183
|
-
/* @__PURE__ */ k(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
...se,
|
|
193
|
-
children: [/* @__PURE__ */ O(v, {
|
|
194
|
-
size: 32,
|
|
195
|
-
"aria-hidden": !0
|
|
196
|
-
}), /* @__PURE__ */ k("div", {
|
|
197
|
-
className: "flex flex-col items-center gap-2 text-center",
|
|
198
|
-
children: [/* @__PURE__ */ O("span", {
|
|
199
|
-
className: "dial-small-text desktop:hidden",
|
|
200
|
-
children: o.uploadDropZoneMobileLabel ?? "Click here to upload"
|
|
201
|
-
}), /* @__PURE__ */ O("span", {
|
|
202
|
-
className: "dial-small-text hidden desktop:inline",
|
|
203
|
-
children: o.uploadDropZoneLabel ?? "Drag and drop it or click here to upload"
|
|
204
|
-
})]
|
|
205
|
-
})]
|
|
206
|
-
}),
|
|
207
|
-
/* @__PURE__ */ O("input", {
|
|
208
|
-
ref: s,
|
|
209
|
-
type: "file",
|
|
180
|
+
/* @__PURE__ */ k(ee, {
|
|
181
|
+
label: /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k("span", {
|
|
182
|
+
className: "desktop:hidden",
|
|
183
|
+
children: o.uploadDropZoneMobileLabel ?? "Click here to upload"
|
|
184
|
+
}), /* @__PURE__ */ k("span", {
|
|
185
|
+
className: "hidden desktop:inline",
|
|
186
|
+
children: o.uploadDropZoneLabel ?? "Drag and drop it or click here to upload"
|
|
187
|
+
})] }),
|
|
188
|
+
ariaLabel: o.uploadDropZoneAriaLabel ?? "Upload files",
|
|
210
189
|
multiple: !0,
|
|
211
|
-
className: "
|
|
212
|
-
onChange:
|
|
190
|
+
className: N ? "border-error hover:border-error" : void 0,
|
|
191
|
+
onChange: j
|
|
213
192
|
}),
|
|
214
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ k("span", {
|
|
215
194
|
role: "status",
|
|
216
195
|
"aria-live": "polite",
|
|
217
196
|
className: "sr-only",
|
|
218
|
-
id:
|
|
219
|
-
children:
|
|
197
|
+
id: E,
|
|
198
|
+
children: m.map((e) => `${o.uploadBatchErrorAriaPrefix ?? "Upload error: "}${e}`).join(" ")
|
|
220
199
|
}),
|
|
221
|
-
|
|
222
|
-
|
|
200
|
+
m.map((e) => /* @__PURE__ */ k(l, { text: e }, e)),
|
|
201
|
+
s.length > 0 && /* @__PURE__ */ k("ul", {
|
|
223
202
|
className: "flex flex-col gap-2",
|
|
224
|
-
children:
|
|
225
|
-
let n = f.get(e.id), r = n?.kind ===
|
|
226
|
-
return /* @__PURE__ */
|
|
203
|
+
children: s.map((e) => {
|
|
204
|
+
let n = f.get(e.id), r = n?.kind === I.Manifest, i = n?.status === L.Invalid;
|
|
205
|
+
return /* @__PURE__ */ A("li", {
|
|
227
206
|
className: "flex items-center gap-2 rounded-lg border border-tertiary p-2",
|
|
228
207
|
children: [
|
|
229
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ k(ne, {
|
|
230
209
|
size: 20,
|
|
231
210
|
"aria-hidden": !0
|
|
232
211
|
}),
|
|
233
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ A("div", {
|
|
234
213
|
className: "flex min-w-0 flex-1 flex-col",
|
|
235
214
|
children: [
|
|
236
|
-
/* @__PURE__ */
|
|
215
|
+
/* @__PURE__ */ k("span", {
|
|
237
216
|
className: "dial-small-text truncate",
|
|
238
217
|
children: e.path
|
|
239
218
|
}),
|
|
240
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ k("span", {
|
|
241
220
|
className: "dial-tiny-text text-secondary",
|
|
242
221
|
children: t(e.file.size)
|
|
243
222
|
}),
|
|
244
|
-
i && n?.error && /* @__PURE__ */
|
|
245
|
-
r && !i && /* @__PURE__ */
|
|
223
|
+
i && n?.error && /* @__PURE__ */ k(l, { text: n.error }),
|
|
224
|
+
r && !i && /* @__PURE__ */ k("span", {
|
|
246
225
|
className: "dial-tiny-text text-secondary",
|
|
247
226
|
children: o.uploadManifestRowNote ?? "Will replace this Skill's name, description, and instructions"
|
|
248
227
|
})
|
|
249
228
|
]
|
|
250
229
|
}),
|
|
251
|
-
/* @__PURE__ */
|
|
252
|
-
icon: /* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ k(d, {
|
|
231
|
+
icon: /* @__PURE__ */ k(ie, {
|
|
253
232
|
size: 16,
|
|
254
233
|
"aria-hidden": !0
|
|
255
234
|
}),
|
|
256
235
|
"aria-label": o.uploadRemoveCandidateLabel?.(e.path) ?? `Remove ${e.path}`,
|
|
257
|
-
onClick: () =>
|
|
236
|
+
onClick: () => ae(e.id)
|
|
258
237
|
})
|
|
259
238
|
]
|
|
260
239
|
}, e.id);
|
|
261
240
|
})
|
|
262
241
|
}),
|
|
263
|
-
|
|
242
|
+
b && /* @__PURE__ */ k(l, { text: b })
|
|
264
243
|
]
|
|
265
244
|
})
|
|
266
245
|
});
|
|
@@ -270,270 +249,270 @@ var A = (e) => !!e.dataTransfer?.types.includes("Files"), ae = (e) => {
|
|
|
270
249
|
headerBorder: "_headerBorder_l82ak_9",
|
|
271
250
|
sidebarBorder: "_sidebarBorder_l82ak_13",
|
|
272
251
|
actionBarBorder: "_actionBarBorder_l82ak_17"
|
|
273
|
-
},
|
|
274
|
-
let { MarkdownEditor: e } = await
|
|
252
|
+
}, ue = x(async () => {
|
|
253
|
+
let { MarkdownEditor: e } = await p();
|
|
275
254
|
return { default: e };
|
|
276
|
-
}),
|
|
277
|
-
let [
|
|
255
|
+
}), de = ({ initialValues: t, files: r, selectedPath: ee, onSelectedPathChange: d, expandedPaths: p, onExpandedPathsChange: h, isLoading: te = !1, hasLoadError: ne = !1, isSubmitting: y = !1, errors: x, submitError: j, conflict: P, onReloadLatest: F, isNameReadOnly: I = !1, onDirtyChange: L, fileActions: R, headerContent: ce, supportingFileContent: z, onSubmit: de, onCancel: fe, onRetry: pe, labels: V, styles: me, dir: he, instructionsEditorTheme: ge = c.light }) => {
|
|
256
|
+
let [H, U] = D({
|
|
278
257
|
name: t?.name ?? "",
|
|
279
258
|
description: t?.description ?? "",
|
|
280
259
|
instructions: t?.instructions ?? ""
|
|
281
|
-
}),
|
|
282
|
-
|
|
283
|
-
|
|
260
|
+
}), _e = E(t), ve = _e.current !== t, ye = E(r);
|
|
261
|
+
C(() => {
|
|
262
|
+
_e.current = t, U({
|
|
284
263
|
name: t?.name ?? "",
|
|
285
264
|
description: t?.description ?? "",
|
|
286
265
|
instructions: t?.instructions ?? ""
|
|
287
|
-
}),
|
|
266
|
+
}), ye.current = r;
|
|
288
267
|
}, [t]);
|
|
289
|
-
let
|
|
290
|
-
|
|
291
|
-
if (
|
|
268
|
+
let be = (e) => JSON.stringify([...e].sort((e, t) => e.path.localeCompare(t.path))), xe = E(!1);
|
|
269
|
+
C(() => {
|
|
270
|
+
if (ve) return;
|
|
292
271
|
let e = {
|
|
293
272
|
name: t?.name ?? "",
|
|
294
273
|
description: t?.description ?? "",
|
|
295
274
|
instructions: t?.instructions ?? ""
|
|
296
|
-
}, n = JSON.stringify(
|
|
297
|
-
n !==
|
|
275
|
+
}, n = JSON.stringify(H) !== JSON.stringify(e) || be(r) !== be(ye.current);
|
|
276
|
+
n !== xe.current && (xe.current = n, L?.(n));
|
|
298
277
|
}, [
|
|
299
|
-
|
|
278
|
+
H,
|
|
300
279
|
r,
|
|
301
280
|
t,
|
|
302
|
-
|
|
281
|
+
ve,
|
|
303
282
|
L
|
|
304
283
|
]);
|
|
305
|
-
let [
|
|
306
|
-
|
|
307
|
-
}, [d]), [
|
|
284
|
+
let [Se, Ce] = D(M), W = ee ?? Se, G = S((e) => {
|
|
285
|
+
Ce(e), d?.(e);
|
|
286
|
+
}, [d]), [we, Te] = D([]), Ee = p ?? we, De = T(() => new Set(Ee), [Ee]), Oe = S((e) => {
|
|
308
287
|
let t = [...e];
|
|
309
|
-
|
|
310
|
-
}, [
|
|
311
|
-
|
|
312
|
-
}, [
|
|
313
|
-
"--se-title-color":
|
|
314
|
-
"--se-helper-text-color":
|
|
315
|
-
"--se-border-color":
|
|
316
|
-
}), Le =
|
|
317
|
-
path:
|
|
318
|
-
name:
|
|
319
|
-
kind:
|
|
320
|
-
}, ...r]), [r]), $ =
|
|
321
|
-
|
|
322
|
-
}, [
|
|
323
|
-
R.onRemoveNode(e),
|
|
288
|
+
Te(t), h?.(t);
|
|
289
|
+
}, [h]), [K, q] = D(!1), [ke, J] = D(), [Ae, je] = D(!0), { isDragActive: Me, dropZoneHandlers: Ne } = ae(S((e) => {
|
|
290
|
+
K || (J(e), q(!0));
|
|
291
|
+
}, [K])), Y = V ?? {}, X = me?.colors, Z = me?.typography ?? {}, Pe = Z.titleClassName ?? "dial-body-semi-text", Fe = Z.helperTextClassName ?? "dial-tiny-semi-text", Q = Z.removeIconClassName ?? "text-secondary", Ie = e({
|
|
292
|
+
"--se-title-color": X?.title,
|
|
293
|
+
"--se-helper-text-color": X?.helperText,
|
|
294
|
+
"--se-border-color": X?.border
|
|
295
|
+
}), Le = T(() => oe([{
|
|
296
|
+
path: M,
|
|
297
|
+
name: M,
|
|
298
|
+
kind: N.File
|
|
299
|
+
}, ...r]), [r]), $ = T(() => r.find((e) => e.path === W), [r, W]), Re = S((e) => {
|
|
300
|
+
G(e.path);
|
|
301
|
+
}, [G]), ze = S((e) => {
|
|
302
|
+
R.onRemoveNode(e), W === e && G(M);
|
|
324
303
|
}, [
|
|
325
304
|
R,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
]), Be =
|
|
305
|
+
W,
|
|
306
|
+
G
|
|
307
|
+
]), Be = S((e) => e.path === "SKILL.md" ? [] : [{
|
|
329
308
|
key: "remove",
|
|
330
|
-
label:
|
|
331
|
-
icon: /* @__PURE__ */
|
|
332
|
-
size:
|
|
333
|
-
className:
|
|
309
|
+
label: Y.removeLabel ?? "Remove",
|
|
310
|
+
icon: /* @__PURE__ */ k(ie, {
|
|
311
|
+
size: s.SM,
|
|
312
|
+
className: Q,
|
|
334
313
|
"aria-hidden": !0
|
|
335
314
|
}),
|
|
336
315
|
onClick: () => ze(e.path)
|
|
337
316
|
}], [
|
|
338
|
-
|
|
339
|
-
|
|
317
|
+
Y.removeLabel,
|
|
318
|
+
Q,
|
|
340
319
|
ze
|
|
341
|
-
]), Ve =
|
|
320
|
+
]), Ve = w(), He = w(), Ue = /* @__PURE__ */ A("div", {
|
|
342
321
|
className: "flex flex-col gap-2 desktop:gap-5",
|
|
343
|
-
children: [/* @__PURE__ */
|
|
322
|
+
children: [/* @__PURE__ */ A("div", {
|
|
344
323
|
className: "flex items-center justify-between",
|
|
345
|
-
children: [/* @__PURE__ */
|
|
346
|
-
className: n(B.title,
|
|
347
|
-
children:
|
|
348
|
-
}), /* @__PURE__ */
|
|
349
|
-
label:
|
|
350
|
-
iconBefore: /* @__PURE__ */
|
|
324
|
+
children: [/* @__PURE__ */ k("span", {
|
|
325
|
+
className: n(B.title, Pe),
|
|
326
|
+
children: Y.filesHeading ?? "Files"
|
|
327
|
+
}), /* @__PURE__ */ k(m, {
|
|
328
|
+
label: Y.addUploadLabel ?? "Upload from device",
|
|
329
|
+
iconBefore: /* @__PURE__ */ k(re, {
|
|
351
330
|
size: 16,
|
|
352
331
|
"aria-hidden": !0
|
|
353
332
|
}),
|
|
354
333
|
onClick: () => {
|
|
355
|
-
|
|
334
|
+
J(void 0), q(!0);
|
|
356
335
|
}
|
|
357
336
|
})]
|
|
358
|
-
}), /* @__PURE__ */
|
|
337
|
+
}), /* @__PURE__ */ k("div", {
|
|
359
338
|
id: Ve,
|
|
360
339
|
role: "tree",
|
|
361
|
-
"aria-label":
|
|
362
|
-
children: /* @__PURE__ */
|
|
340
|
+
"aria-label": Y.filesTreeAriaLabel ?? "Skill files",
|
|
341
|
+
children: /* @__PURE__ */ k(i, {
|
|
363
342
|
items: Le,
|
|
364
343
|
showFiles: !0,
|
|
365
|
-
selectedPath:
|
|
366
|
-
expandedPaths:
|
|
367
|
-
onExpandedPathsChange:
|
|
344
|
+
selectedPath: W,
|
|
345
|
+
expandedPaths: De,
|
|
346
|
+
onExpandedPathsChange: Oe,
|
|
368
347
|
onItemClick: Re,
|
|
369
348
|
getContextMenuItems: Be,
|
|
370
349
|
rootItemPath: ""
|
|
371
350
|
})
|
|
372
351
|
})]
|
|
373
|
-
}), We =
|
|
374
|
-
label:
|
|
375
|
-
onClick:
|
|
376
|
-
disabled:
|
|
377
|
-
}), /* @__PURE__ */
|
|
378
|
-
label:
|
|
379
|
-
iconBefore:
|
|
352
|
+
}), We = y ? Y.savingStatusLabel ?? "Saving" : "", Ge = /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(u, {
|
|
353
|
+
label: Y.cancelLabel ?? "Cancel",
|
|
354
|
+
onClick: fe,
|
|
355
|
+
disabled: y
|
|
356
|
+
}), /* @__PURE__ */ k(g, {
|
|
357
|
+
label: Y.createLabel ?? "Create",
|
|
358
|
+
iconBefore: y ? /* @__PURE__ */ k(_, {
|
|
380
359
|
size: 16,
|
|
381
360
|
ariaLabel: ""
|
|
382
361
|
}) : void 0,
|
|
383
|
-
onClick: () =>
|
|
384
|
-
disabled:
|
|
362
|
+
onClick: () => de(H),
|
|
363
|
+
disabled: y
|
|
385
364
|
})] });
|
|
386
|
-
return
|
|
365
|
+
return te ? /* @__PURE__ */ k("div", {
|
|
387
366
|
className: "flex h-full items-center justify-center",
|
|
388
|
-
children: /* @__PURE__ */
|
|
389
|
-
}) :
|
|
367
|
+
children: /* @__PURE__ */ k(_, { ariaLabel: Y.loadingAriaLabel ?? "Loading skill" })
|
|
368
|
+
}) : ne ? /* @__PURE__ */ A("div", {
|
|
390
369
|
role: "alert",
|
|
391
370
|
className: "flex flex-col items-center gap-4 p-8",
|
|
392
|
-
children: [/* @__PURE__ */
|
|
393
|
-
label:
|
|
394
|
-
onClick:
|
|
371
|
+
children: [/* @__PURE__ */ k(l, { text: Y.loadErrorMessage ?? "Couldn't load this skill. Please try again." }), /* @__PURE__ */ k(g, {
|
|
372
|
+
label: Y.retryLabel ?? "Retry",
|
|
373
|
+
onClick: pe
|
|
395
374
|
})]
|
|
396
|
-
}) : /* @__PURE__ */
|
|
397
|
-
dir:
|
|
375
|
+
}) : /* @__PURE__ */ A("div", {
|
|
376
|
+
dir: he,
|
|
398
377
|
className: "relative flex h-full flex-col",
|
|
399
378
|
style: Ie,
|
|
400
|
-
...
|
|
379
|
+
...Ne,
|
|
401
380
|
children: [
|
|
402
|
-
/* @__PURE__ */
|
|
403
|
-
isVisible:
|
|
404
|
-
labels:
|
|
381
|
+
/* @__PURE__ */ k(se, {
|
|
382
|
+
isVisible: Me && !K,
|
|
383
|
+
labels: V
|
|
405
384
|
}),
|
|
406
|
-
/* @__PURE__ */
|
|
385
|
+
/* @__PURE__ */ k("span", {
|
|
407
386
|
role: "status",
|
|
408
387
|
"aria-live": "polite",
|
|
409
388
|
className: "sr-only",
|
|
410
389
|
id: He,
|
|
411
390
|
children: We
|
|
412
391
|
}),
|
|
413
|
-
|
|
392
|
+
j && /* @__PURE__ */ k("div", {
|
|
414
393
|
role: "alert",
|
|
415
394
|
className: "px-4 pt-2",
|
|
416
|
-
children: /* @__PURE__ */
|
|
395
|
+
children: /* @__PURE__ */ k(l, { text: j })
|
|
417
396
|
}),
|
|
418
|
-
P && /* @__PURE__ */
|
|
397
|
+
P && /* @__PURE__ */ A("div", {
|
|
419
398
|
role: "alert",
|
|
420
399
|
className: "flex items-center gap-2 px-4 pt-2",
|
|
421
|
-
children: [/* @__PURE__ */
|
|
422
|
-
label:
|
|
400
|
+
children: [/* @__PURE__ */ k(l, { text: P.message }), /* @__PURE__ */ k(u, {
|
|
401
|
+
label: Y.reloadLatestLabel ?? "Reload latest",
|
|
423
402
|
onClick: F
|
|
424
403
|
})]
|
|
425
404
|
}),
|
|
426
|
-
/* @__PURE__ */
|
|
405
|
+
/* @__PURE__ */ A("div", {
|
|
427
406
|
className: n("hidden items-center justify-between gap-2 border-b px-4 py-2 desktop:flex desktop:px-8 desktop:pb-3 desktop:pt-3", B.headerBorder),
|
|
428
|
-
children: [/* @__PURE__ */
|
|
407
|
+
children: [/* @__PURE__ */ k("div", {
|
|
429
408
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
430
|
-
children:
|
|
431
|
-
}), /* @__PURE__ */
|
|
409
|
+
children: ce
|
|
410
|
+
}), /* @__PURE__ */ k("div", {
|
|
432
411
|
className: "flex shrink-0 items-center gap-2",
|
|
433
412
|
children: Ge
|
|
434
413
|
})]
|
|
435
414
|
}),
|
|
436
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ A("div", {
|
|
437
416
|
className: "flex flex-1 flex-col gap-4 overflow-y-auto px-4 pb-20 desktop:flex-row desktop:gap-0 desktop:px-0 desktop:pb-0",
|
|
438
417
|
children: [
|
|
439
|
-
/* @__PURE__ */
|
|
418
|
+
/* @__PURE__ */ k("div", {
|
|
440
419
|
className: "desktop:hidden",
|
|
441
|
-
children: /* @__PURE__ */
|
|
442
|
-
title:
|
|
420
|
+
children: /* @__PURE__ */ k(a, {
|
|
421
|
+
title: Y.editingFileLabel ?? "Editing file",
|
|
443
422
|
description: $?.name ?? "SKILL.md",
|
|
444
|
-
expanded:
|
|
445
|
-
onToggle:
|
|
446
|
-
ariaLabel:
|
|
423
|
+
expanded: Ae,
|
|
424
|
+
onToggle: je,
|
|
425
|
+
ariaLabel: Y.editingFileLabel ?? "Editing file",
|
|
447
426
|
children: Ue
|
|
448
427
|
})
|
|
449
428
|
}),
|
|
450
|
-
/* @__PURE__ */
|
|
429
|
+
/* @__PURE__ */ k("div", {
|
|
451
430
|
className: n("hidden border-e desktop:block desktop:w-[360px] desktop:shrink-0 desktop:px-8 desktop:py-6", B.sidebarBorder),
|
|
452
431
|
children: Ue
|
|
453
432
|
}),
|
|
454
|
-
/* @__PURE__ */
|
|
433
|
+
/* @__PURE__ */ A("div", {
|
|
455
434
|
className: "flex min-w-0 flex-1 flex-col gap-4 desktop:gap-5 desktop:px-8 desktop:py-6",
|
|
456
|
-
children: [/* @__PURE__ */
|
|
457
|
-
className: n(B.title,
|
|
458
|
-
children:
|
|
459
|
-
}),
|
|
460
|
-
/* @__PURE__ */
|
|
435
|
+
children: [/* @__PURE__ */ k("h2", {
|
|
436
|
+
className: n(B.title, Pe),
|
|
437
|
+
children: W === "SKILL.md" ? M : Y.selectedFileHeading?.($?.name ?? W) ?? $?.name ?? W
|
|
438
|
+
}), W === "SKILL.md" ? /* @__PURE__ */ A(O, { children: [
|
|
439
|
+
/* @__PURE__ */ k(f, {
|
|
461
440
|
labelProps: {
|
|
462
|
-
label:
|
|
441
|
+
label: Y.nameLabel ?? "Name",
|
|
463
442
|
required: !0
|
|
464
443
|
},
|
|
465
|
-
value:
|
|
466
|
-
onChange: (e) =>
|
|
444
|
+
value: H.name,
|
|
445
|
+
onChange: (e) => U((t) => ({
|
|
467
446
|
...t,
|
|
468
447
|
name: e ?? ""
|
|
469
448
|
})),
|
|
470
|
-
placeholder:
|
|
471
|
-
caption:
|
|
472
|
-
error:
|
|
473
|
-
invalid: !!
|
|
449
|
+
placeholder: Y.namePlaceholder ?? "good-morning-breakfast",
|
|
450
|
+
caption: x?.name ? void 0 : Y.nameCaption ?? "Lowercase letters and hyphens only, no spaces. We'll reformat automatically if needed.",
|
|
451
|
+
error: x?.name,
|
|
452
|
+
invalid: !!x?.name,
|
|
474
453
|
disabled: I
|
|
475
454
|
}),
|
|
476
|
-
/* @__PURE__ */
|
|
455
|
+
/* @__PURE__ */ k(v, {
|
|
477
456
|
labelProps: {
|
|
478
|
-
label:
|
|
457
|
+
label: Y.descriptionLabel ?? "Description",
|
|
479
458
|
required: !0
|
|
480
459
|
},
|
|
481
|
-
value:
|
|
482
|
-
placeholder:
|
|
483
|
-
onChange: (e) =>
|
|
460
|
+
value: H.description,
|
|
461
|
+
placeholder: Y.descriptionPlaceholder ?? "What this skill does and when to use it",
|
|
462
|
+
onChange: (e) => U((t) => ({
|
|
484
463
|
...t,
|
|
485
464
|
description: e
|
|
486
465
|
})),
|
|
487
|
-
error:
|
|
488
|
-
invalid: !!
|
|
466
|
+
error: x?.description,
|
|
467
|
+
invalid: !!x?.description
|
|
489
468
|
}),
|
|
490
|
-
/* @__PURE__ */
|
|
469
|
+
/* @__PURE__ */ A("div", {
|
|
491
470
|
className: "flex flex-1 flex-col gap-2",
|
|
492
471
|
children: [
|
|
493
|
-
/* @__PURE__ */
|
|
472
|
+
/* @__PURE__ */ A("span", {
|
|
494
473
|
className: "flex items-center gap-0.5",
|
|
495
|
-
children: [/* @__PURE__ */
|
|
496
|
-
className: n(B.helperText,
|
|
497
|
-
children:
|
|
498
|
-
}), /* @__PURE__ */
|
|
474
|
+
children: [/* @__PURE__ */ k("span", {
|
|
475
|
+
className: n(B.helperText, Fe),
|
|
476
|
+
children: Y.instructionsLabel ?? "Instructions"
|
|
477
|
+
}), /* @__PURE__ */ k("span", {
|
|
499
478
|
className: "dial-tiny-text text-error",
|
|
500
479
|
children: "*"
|
|
501
480
|
})]
|
|
502
481
|
}),
|
|
503
|
-
/* @__PURE__ */
|
|
504
|
-
fallback: /* @__PURE__ */
|
|
505
|
-
children: /* @__PURE__ */
|
|
506
|
-
value:
|
|
507
|
-
onChange: (e) =>
|
|
482
|
+
/* @__PURE__ */ k(b, {
|
|
483
|
+
fallback: /* @__PURE__ */ k(_, { ariaLabel: Y.instructionsLoadingAriaLabel ?? "Loading" }),
|
|
484
|
+
children: /* @__PURE__ */ k(ue, {
|
|
485
|
+
value: H.instructions,
|
|
486
|
+
onChange: (e) => U((t) => ({
|
|
508
487
|
...t,
|
|
509
488
|
instructions: e
|
|
510
489
|
})),
|
|
511
|
-
theme:
|
|
512
|
-
placeholder:
|
|
490
|
+
theme: ge,
|
|
491
|
+
placeholder: Y.instructionsPlaceholder ?? "Write the skill instructions in Markdown"
|
|
513
492
|
})
|
|
514
493
|
}),
|
|
515
|
-
|
|
494
|
+
x?.instructions && /* @__PURE__ */ k(l, { text: x.instructions })
|
|
516
495
|
]
|
|
517
496
|
})
|
|
518
|
-
] }) : $?.kind ===
|
|
497
|
+
] }) : $?.kind === N.File && (z ?? /* @__PURE__ */ k(o, { text: Y.supportingFileNote ?? "This supporting file is included in the skill package as-is. Remove it from the Files panel to replace its content." }))]
|
|
519
498
|
})
|
|
520
499
|
]
|
|
521
500
|
}),
|
|
522
|
-
/* @__PURE__ */
|
|
501
|
+
/* @__PURE__ */ k("div", {
|
|
523
502
|
className: n("fixed inset-x-0 bottom-0 flex items-center gap-2 border-t p-3 desktop:hidden", B.actionBarBorder),
|
|
524
503
|
children: Ge
|
|
525
504
|
}),
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
isOpen:
|
|
505
|
+
/* @__PURE__ */ k(le, {
|
|
506
|
+
isOpen: K,
|
|
528
507
|
onClose: () => {
|
|
529
|
-
|
|
508
|
+
q(!1), J(void 0);
|
|
530
509
|
},
|
|
531
510
|
fileActions: R,
|
|
532
|
-
initialFiles:
|
|
533
|
-
labels:
|
|
511
|
+
initialFiles: ke,
|
|
512
|
+
labels: V
|
|
534
513
|
})
|
|
535
514
|
]
|
|
536
515
|
});
|
|
537
516
|
};
|
|
538
517
|
//#endregion
|
|
539
|
-
export {
|
|
518
|
+
export { de as SkillEditor, I as SkillFileCandidateKind, N as SkillFileNodeKind, L as SkillFileValidationStatus };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-skill-editor",
|
|
3
3
|
"description": "Host-agnostic form for authoring a DIAL Skill, with an inline supporting-file tree",
|
|
4
|
-
"version": "1.1.0-dev.
|
|
4
|
+
"version": "1.1.0-dev.297",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.
|
|
19
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.297",
|
|
20
20
|
"@epam/ai-dial-ui-kit": "*",
|
|
21
21
|
"@epam/ai-dial-react-file-manager": "^0.2.0-dev.7",
|
|
22
22
|
"@tabler/icons-react": "^3.0.0",
|