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