@epam/ai-dial-prompt-editor 1.3.0-dev.241 → 1.3.0-dev.244
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/PromptEditor/PromptEditor.d.ts.map +1 -1
- package/index.js +246 -245
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromptEditor/PromptEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PromptEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromptEditor/PromptEditor.tsx"],"names":[],"mappings":"AAqCA,OAAO,0CAA0C,CAAC;AAClD,OAAO,0CAA0C,CAAC;AAClD,OAAO,EAGL,KAAK,EAAE,EAQR,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,kCAAkC,CAAC;AA2C1C,uDAAuD;AACvD,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA8a9C,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,378 +1,379 @@
|
|
|
1
1
|
import { DEFAULT_METADATA_FORM_LABELS as e, EntityEditor as t, MetadataField as n, MetadataForm as r } from "@epam/ai-dial-builder-form";
|
|
2
|
-
import { ConfirmationDialog as i, MARKDOWN_EDITOR_FILL_HEIGHT_CLASS_NAME as a, MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME as o, MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME as s, TextRefinementField as c, buildCssVars as l, mergeClasses as u, useAvailableHeightCap as d,
|
|
3
|
-
import { ConfirmationPopupVariant as
|
|
4
|
-
import { LazyMarkdownEditor as
|
|
5
|
-
import { Suspense as te, lazy as
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { IconFolderPlus as
|
|
2
|
+
import { ConfirmationDialog as i, MARKDOWN_EDITOR_FILL_HEIGHT_CLASS_NAME as a, MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME as o, MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME as s, TextRefinementField as c, buildCssVars as l, mergeClasses as u, useAvailableHeightCap as d, useControlErrorAssociation as f, useTextRefinement as p, useUnsavedChangesGuard as ee } from "@epam/ai-dial-chat-shared";
|
|
3
|
+
import { ConfirmationPopupVariant as m, DIAL_ICON_SIZE as h, DIAL_KIT_ICON_STROKE as g, ElementSize as _, ErrorMessageNotification as v, ErrorText as y, GhostIconButton as b, Input as x, Label as S, NeutralButton as C, Select as w, Spinner as T } from "@epam/ai-dial-ui-kit";
|
|
4
|
+
import { LazyMarkdownEditor as E } from "@epam/ai-dial-ui-kit/editors";
|
|
5
|
+
import { Suspense as te, lazy as D, useCallback as O, useEffect as k, useId as A, useMemo as j, useRef as ne, useState as M } from "react";
|
|
6
|
+
import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
7
|
+
import { IconFolderPlus as I, IconPencil as L, IconTrashX as R } from "@tabler/icons-react";
|
|
8
8
|
//#region src/constants/public-class-names.ts
|
|
9
|
-
var
|
|
9
|
+
var re = {
|
|
10
10
|
form: "dial-prompt-editor-form",
|
|
11
11
|
folderField: "dial-prompt-editor-folder-field"
|
|
12
|
-
},
|
|
12
|
+
}, ie = {
|
|
13
13
|
contentError: "_contentError_1qtel_1",
|
|
14
14
|
contentInvalid: "_contentInvalid_1qtel_6"
|
|
15
|
-
},
|
|
15
|
+
}, ae = D(async () => ({ default: (await E()).MarkdownEditor })), oe = {
|
|
16
16
|
name: "",
|
|
17
17
|
description: "",
|
|
18
18
|
content: ""
|
|
19
|
-
},
|
|
19
|
+
}, se = [n.Name, n.Description], ce = 2e3, le = 5e4, ue = 10, de = "mx-auto w-full max-w-[1180px] gap-5 px-4 py-6 desktop:px-8 desktop:py-6", fe = 24, pe = 480, me = (e, t, n) => {
|
|
20
20
|
let r = t - e.length;
|
|
21
21
|
return r <= n ? Math.max(r, 0) : null;
|
|
22
|
-
}, z = ({ isEditMode: n = !1, initialValues:
|
|
23
|
-
let { colors:
|
|
24
|
-
...
|
|
25
|
-
...
|
|
26
|
-
}), [
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
}, z = ({ isEditMode: n = !1, initialValues: h, isLoading: _ = !1, hasLoadError: b = !1, isSaving: x = !1, errors: w, descriptionMaxLength: E = ce, contentMaxLength: D = le, counterAnnounceThreshold: I = ue, onSubmit: L, onFieldChange: R, onCancel: z, onBack: B = z, onDirtyChange: V, onRetry: H, onRefineDescription: U, onRefineInstructions: W, labels: G, markdownEditorTheme: he, styles: ge }) => {
|
|
23
|
+
let { colors: _e, typography: ve } = ge ?? {}, ye = ve?.contentLabelClassName ?? "dial-tiny-semi-text", be = ve?.helperTextClassName ?? "dial-small-text", K = j(() => ({
|
|
24
|
+
...oe,
|
|
25
|
+
...h
|
|
26
|
+
}), [h]), [q, xe] = M(K), Se = A(), J = A(), Ce = A();
|
|
27
|
+
f(() => document.getElementById(J), Ce, !!w?.content);
|
|
28
|
+
let we = d({
|
|
29
|
+
bottomGap: fe,
|
|
30
|
+
minHeight: pe
|
|
29
31
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
let
|
|
34
|
-
|
|
32
|
+
k(() => {
|
|
33
|
+
xe(K);
|
|
34
|
+
}, [K]);
|
|
35
|
+
let Te = O((e, t) => {
|
|
36
|
+
xe((n) => ({
|
|
35
37
|
...n,
|
|
36
38
|
[e]: t
|
|
37
|
-
})),
|
|
38
|
-
}, [
|
|
39
|
-
name:
|
|
40
|
-
description:
|
|
39
|
+
})), R?.(e, t);
|
|
40
|
+
}, [R]), Ee = j(() => ({
|
|
41
|
+
name: q.name,
|
|
42
|
+
description: q.description,
|
|
41
43
|
iconUrl: "",
|
|
42
44
|
version: "",
|
|
43
45
|
topics: [],
|
|
44
46
|
otherLocales: []
|
|
45
|
-
}), [
|
|
46
|
-
|
|
47
|
+
}), [q.name, q.description]), De = O((e) => {
|
|
48
|
+
xe((t) => ({
|
|
47
49
|
...t,
|
|
48
50
|
...e.name !== void 0 && { name: e.name },
|
|
49
51
|
...e.description !== void 0 && { description: e.description }
|
|
50
|
-
})), e.name !== void 0 &&
|
|
51
|
-
}, [
|
|
52
|
-
name:
|
|
53
|
-
description:
|
|
54
|
-
}), [
|
|
52
|
+
})), e.name !== void 0 && R?.("name", e.name), e.description !== void 0 && R?.("description", e.description);
|
|
53
|
+
}, [R]), Oe = j(() => ({
|
|
54
|
+
name: w?.name,
|
|
55
|
+
description: w?.description
|
|
56
|
+
}), [w?.name, w?.description]), ke = j(() => ({ form: {
|
|
55
57
|
...e,
|
|
56
58
|
name: {
|
|
57
|
-
label:
|
|
58
|
-
placeholder:
|
|
59
|
+
label: G?.nameLabel ?? "Name",
|
|
60
|
+
placeholder: G?.namePlaceholder ?? "Prompt name"
|
|
59
61
|
},
|
|
60
62
|
description: {
|
|
61
|
-
label:
|
|
62
|
-
placeholder:
|
|
63
|
+
label: G?.descriptionLabel ?? "Description",
|
|
64
|
+
placeholder: G?.descriptionPlaceholder ?? "What this prompt is for"
|
|
63
65
|
},
|
|
64
66
|
ariaLabel: void 0
|
|
65
67
|
} }), [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
]),
|
|
71
|
-
value:
|
|
72
|
-
onChange: (e) =>
|
|
73
|
-
onRefine: H,
|
|
74
|
-
disabled: v,
|
|
75
|
-
resetKey: m
|
|
76
|
-
}), De = f({
|
|
77
|
-
value: K.content,
|
|
78
|
-
onChange: (e) => xe("content", e),
|
|
68
|
+
G?.nameLabel,
|
|
69
|
+
G?.namePlaceholder,
|
|
70
|
+
G?.descriptionLabel,
|
|
71
|
+
G?.descriptionPlaceholder
|
|
72
|
+
]), Ae = p({
|
|
73
|
+
value: q.description,
|
|
74
|
+
onChange: (e) => Te("description", e),
|
|
79
75
|
onRefine: U,
|
|
80
|
-
disabled:
|
|
81
|
-
resetKey:
|
|
82
|
-
}),
|
|
76
|
+
disabled: x,
|
|
77
|
+
resetKey: h
|
|
78
|
+
}), je = p({
|
|
79
|
+
value: q.content,
|
|
80
|
+
onChange: (e) => Te("content", e),
|
|
81
|
+
onRefine: W,
|
|
82
|
+
disabled: x,
|
|
83
|
+
resetKey: h
|
|
84
|
+
}), Y = Ae.isPending || je.isPending, Me = U ? (e, t) => /* @__PURE__ */ P(c, {
|
|
83
85
|
isEnabled: !0,
|
|
84
86
|
fieldId: t,
|
|
85
|
-
label:
|
|
86
|
-
labels:
|
|
87
|
-
refinement:
|
|
88
|
-
disabled: Y ||
|
|
87
|
+
label: G?.descriptionLabel ?? "Description",
|
|
88
|
+
labels: G,
|
|
89
|
+
refinement: Ae,
|
|
90
|
+
disabled: Y || x,
|
|
89
91
|
children: e
|
|
90
|
-
}) : void 0,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, [
|
|
94
|
-
let { guard: Z } = X, { reset:
|
|
95
|
-
|
|
96
|
-
}, [
|
|
92
|
+
}) : void 0, Ne = q.name !== K.name || q.description !== K.description || q.content !== K.content, X = ee(Ne && !V);
|
|
93
|
+
k(() => {
|
|
94
|
+
V?.(Ne);
|
|
95
|
+
}, [Ne, V]);
|
|
96
|
+
let { guard: Z } = X, { reset: Pe } = Ae, { reset: Fe } = je, Q = O(() => {
|
|
97
|
+
Pe(), Fe();
|
|
98
|
+
}, [Pe, Fe]), Ie = O(() => {
|
|
97
99
|
Z(() => {
|
|
98
|
-
Q(),
|
|
100
|
+
Q(), B();
|
|
99
101
|
});
|
|
100
102
|
}, [
|
|
101
103
|
Z,
|
|
102
104
|
Q,
|
|
103
|
-
|
|
104
|
-
]),
|
|
105
|
+
B
|
|
106
|
+
]), Le = O(() => {
|
|
105
107
|
Z(() => {
|
|
106
|
-
Q(),
|
|
108
|
+
Q(), z();
|
|
107
109
|
});
|
|
108
110
|
}, [
|
|
109
111
|
Z,
|
|
110
112
|
Q,
|
|
111
|
-
|
|
112
|
-
]),
|
|
113
|
-
|
|
113
|
+
z
|
|
114
|
+
]), Re = O(() => {
|
|
115
|
+
x || Y || L(q);
|
|
114
116
|
}, [
|
|
115
|
-
|
|
117
|
+
x,
|
|
116
118
|
Y,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
]),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}, [
|
|
123
|
-
let
|
|
124
|
-
cancelLabel:
|
|
125
|
-
backAriaLabel:
|
|
126
|
-
savingStatusLabel:
|
|
119
|
+
L,
|
|
120
|
+
q
|
|
121
|
+
]), ze = w?.content != null && !w?.name && !w?.description, Be = ne(!1);
|
|
122
|
+
k(() => {
|
|
123
|
+
ze && !Be.current && document.getElementById(J)?.focus(), Be.current = ze;
|
|
124
|
+
}, [ze, J]);
|
|
125
|
+
let Ve = n ? G?.editTitle ?? "Edit prompt" : G?.createTitle ?? "Create prompt", He = n ? G?.saveLabel ?? "Save" : G?.createLabel ?? "Create", Ue = j(() => ({
|
|
126
|
+
cancelLabel: G?.cancelLabel ?? "Cancel",
|
|
127
|
+
backAriaLabel: G?.backButtonAriaLabel ?? "Back to prompts",
|
|
128
|
+
savingStatusLabel: G?.savingStatusLabel ?? "Saving"
|
|
127
129
|
}), [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
]),
|
|
132
|
-
"--pe-content-error":
|
|
133
|
-
"--pe-content-invalid-border":
|
|
130
|
+
G?.cancelLabel,
|
|
131
|
+
G?.backButtonAriaLabel,
|
|
132
|
+
G?.savingStatusLabel
|
|
133
|
+
]), We = l({
|
|
134
|
+
"--pe-content-error": _e?.contentErrorText,
|
|
135
|
+
"--pe-content-invalid-border": _e?.contentInvalidBorder
|
|
134
136
|
}), $ = {
|
|
135
|
-
title:
|
|
136
|
-
onBack:
|
|
137
|
-
onCancel:
|
|
138
|
-
onSubmit:
|
|
139
|
-
submitLabel:
|
|
140
|
-
labels:
|
|
137
|
+
title: Ve,
|
|
138
|
+
onBack: B,
|
|
139
|
+
onCancel: z,
|
|
140
|
+
onSubmit: Re,
|
|
141
|
+
submitLabel: He,
|
|
142
|
+
labels: Ue,
|
|
141
143
|
metadataTitle: null
|
|
142
144
|
};
|
|
143
|
-
if (
|
|
145
|
+
if (_) return /* @__PURE__ */ P(t, {
|
|
144
146
|
...$,
|
|
145
|
-
isSubmitting:
|
|
146
|
-
metadata: /* @__PURE__ */
|
|
147
|
+
isSubmitting: x,
|
|
148
|
+
metadata: /* @__PURE__ */ P("div", {
|
|
147
149
|
role: "status",
|
|
148
|
-
"aria-label":
|
|
150
|
+
"aria-label": G?.loadingAriaLabel ?? "Loading prompt",
|
|
149
151
|
className: "flex flex-1 items-center justify-center p-8",
|
|
150
|
-
children: /* @__PURE__ */
|
|
152
|
+
children: /* @__PURE__ */ P(T, {})
|
|
151
153
|
})
|
|
152
154
|
});
|
|
153
|
-
if (
|
|
155
|
+
if (b) return /* @__PURE__ */ P(t, {
|
|
154
156
|
...$,
|
|
155
|
-
metadata: /* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
onClick: V
|
|
164
|
-
})]
|
|
157
|
+
metadata: /* @__PURE__ */ P(v, {
|
|
158
|
+
message: G?.loadErrorMessage ?? "Couldn't load this prompt. Please try again.",
|
|
159
|
+
textClassName: be,
|
|
160
|
+
iconStroke: g,
|
|
161
|
+
action: H != null && /* @__PURE__ */ P(C, {
|
|
162
|
+
label: G?.retryLabel ?? "Retry",
|
|
163
|
+
onClick: H
|
|
164
|
+
})
|
|
165
165
|
})
|
|
166
166
|
});
|
|
167
|
-
let
|
|
168
|
-
ref:
|
|
169
|
-
className: u(o, a, s,
|
|
170
|
-
children: /* @__PURE__ */
|
|
171
|
-
fallback: /* @__PURE__ */
|
|
172
|
-
children: /* @__PURE__ */
|
|
167
|
+
let Ge = me(q.description, E, I), Ke = me(q.content, D, I), qe = (e) => G?.charactersRemaining?.(e) ?? `${e} characters remaining`, Je = G?.contentLabel ?? "Instructions", Ye = /* @__PURE__ */ P("div", {
|
|
168
|
+
ref: we,
|
|
169
|
+
className: u(o, a, s, w?.content != null && ie.contentInvalid),
|
|
170
|
+
children: /* @__PURE__ */ P(te, {
|
|
171
|
+
fallback: /* @__PURE__ */ P(T, { ariaLabel: G?.contentLoadingAriaLabel ?? "Loading prompt editor" }),
|
|
172
|
+
children: /* @__PURE__ */ P(ae, {
|
|
173
173
|
id: J,
|
|
174
|
-
value:
|
|
175
|
-
onChange: (e) =>
|
|
174
|
+
value: q.content,
|
|
175
|
+
onChange: (e) => Te("content", e),
|
|
176
176
|
height: 480,
|
|
177
|
-
placeholder:
|
|
178
|
-
theme:
|
|
177
|
+
placeholder: G?.contentPlaceholder ?? "Write the prompt instructions",
|
|
178
|
+
theme: he,
|
|
179
179
|
showDragbar: !1
|
|
180
180
|
})
|
|
181
181
|
})
|
|
182
|
-
}),
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
}), Xe = /* @__PURE__ */ P(y, {
|
|
183
|
+
id: Ce,
|
|
184
|
+
text: w?.content,
|
|
185
|
+
className: u(be, ie.contentError)
|
|
185
186
|
});
|
|
186
|
-
return /* @__PURE__ */ N
|
|
187
|
+
return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(t, {
|
|
187
188
|
...$,
|
|
188
|
-
onBack:
|
|
189
|
-
onCancel:
|
|
190
|
-
isSubmitting:
|
|
189
|
+
onBack: Ie,
|
|
190
|
+
onCancel: Le,
|
|
191
|
+
isSubmitting: x,
|
|
191
192
|
isSubmitDisabled: Y,
|
|
192
|
-
metadataSectionClassName: u(
|
|
193
|
-
metadata: /* @__PURE__ */ N
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
values:
|
|
196
|
-
errors:
|
|
197
|
-
onChange:
|
|
198
|
-
fields:
|
|
199
|
-
renderDescription:
|
|
200
|
-
labels:
|
|
201
|
-
descriptionCaption:
|
|
193
|
+
metadataSectionClassName: u(de, re.form),
|
|
194
|
+
metadata: /* @__PURE__ */ F(N, { children: [
|
|
195
|
+
/* @__PURE__ */ P(r, {
|
|
196
|
+
values: Ee,
|
|
197
|
+
errors: Oe,
|
|
198
|
+
onChange: De,
|
|
199
|
+
fields: se,
|
|
200
|
+
renderDescription: Me,
|
|
201
|
+
labels: ke,
|
|
202
|
+
descriptionCaption: q.description ? `${q.description.length}/${E}` : void 0
|
|
202
203
|
}),
|
|
203
|
-
|
|
204
|
+
W ? /* @__PURE__ */ P("div", {
|
|
204
205
|
className: "flex flex-1 flex-col",
|
|
205
|
-
style:
|
|
206
|
-
children: /* @__PURE__ */
|
|
206
|
+
style: We,
|
|
207
|
+
children: /* @__PURE__ */ P(c, {
|
|
207
208
|
isEnabled: !0,
|
|
208
209
|
fieldId: J,
|
|
209
|
-
label:
|
|
210
|
-
labelClassName:
|
|
210
|
+
label: Je,
|
|
211
|
+
labelClassName: ye,
|
|
211
212
|
required: !0,
|
|
212
|
-
labels:
|
|
213
|
-
refinement:
|
|
214
|
-
disabled: Y ||
|
|
215
|
-
children: /* @__PURE__ */
|
|
213
|
+
labels: G,
|
|
214
|
+
refinement: je,
|
|
215
|
+
disabled: Y || x,
|
|
216
|
+
children: /* @__PURE__ */ F("div", {
|
|
216
217
|
className: "flex flex-col gap-2",
|
|
217
|
-
children: [
|
|
218
|
+
children: [Ye, Xe]
|
|
218
219
|
})
|
|
219
220
|
})
|
|
220
|
-
}) : /* @__PURE__ */
|
|
221
|
+
}) : /* @__PURE__ */ F("div", {
|
|
221
222
|
role: "group",
|
|
222
|
-
"aria-labelledby":
|
|
223
|
+
"aria-labelledby": Se,
|
|
223
224
|
className: "flex flex-1 flex-col gap-2",
|
|
224
|
-
style:
|
|
225
|
+
style: We,
|
|
225
226
|
children: [
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
id:
|
|
227
|
+
/* @__PURE__ */ P(S, {
|
|
228
|
+
id: Se,
|
|
228
229
|
htmlFor: J,
|
|
229
|
-
label:
|
|
230
|
+
label: Je,
|
|
230
231
|
required: !0,
|
|
231
|
-
className:
|
|
232
|
+
className: ye
|
|
232
233
|
}),
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
Ye,
|
|
235
|
+
Xe
|
|
235
236
|
]
|
|
236
237
|
}),
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ F("span", {
|
|
238
239
|
role: "status",
|
|
239
240
|
"aria-live": "polite",
|
|
240
241
|
className: "sr-only",
|
|
241
|
-
children: [
|
|
242
|
+
children: [Ge != null && qe(Ge), Ke != null && qe(Ke)]
|
|
242
243
|
})
|
|
243
244
|
] })
|
|
244
|
-
}), X.isConfirmOpen && /* @__PURE__ */
|
|
245
|
+
}), X.isConfirmOpen && /* @__PURE__ */ P(i, {
|
|
245
246
|
open: !0,
|
|
246
|
-
title:
|
|
247
|
-
message:
|
|
248
|
-
confirmLabel:
|
|
249
|
-
cancelLabel:
|
|
250
|
-
variant:
|
|
247
|
+
title: G?.discardTitle ?? "Discard unsaved changes?",
|
|
248
|
+
message: G?.discardMessage ?? "You have unsaved changes. Leaving now will discard them.",
|
|
249
|
+
confirmLabel: G?.discardConfirmLabel ?? "Discard",
|
|
250
|
+
cancelLabel: G?.discardCancelLabel ?? "Keep editing",
|
|
251
|
+
variant: m.Danger,
|
|
251
252
|
onConfirm: X.confirm,
|
|
252
253
|
onClose: X.dismiss
|
|
253
254
|
})] });
|
|
254
255
|
}, B = /* @__PURE__ */ function(e) {
|
|
255
256
|
return e.Create = "create", e.Rename = "rename", e.ConfirmDelete = "confirmDelete", e;
|
|
256
257
|
}({}), V = "", H = "__root__", U = (e) => e.split("/").pop() ?? "", W = ({ value: e, folders: t, error: n, nameError: r, actions: i, disabled: a = !1, labels: o, helperTextClassName: s = "dial-small-text", onChange: c }) => {
|
|
257
|
-
let [l, d] =
|
|
258
|
+
let [l, d] = M(null), [f, p] = M(""), [ee, m] = M(), [v, y] = M(!1), S = e === V, T = o?.folderRootOption ?? "Root", E = o?.folderEmptyState ?? "No folders yet", te = j(() => [{
|
|
258
259
|
value: H,
|
|
259
|
-
label:
|
|
260
|
+
label: T
|
|
260
261
|
}, ...t.map((e) => ({
|
|
261
262
|
value: e.id,
|
|
262
263
|
label: e.id
|
|
263
|
-
}))], [t,
|
|
264
|
-
d(null), p(""),
|
|
265
|
-
}, []),
|
|
266
|
-
if (
|
|
264
|
+
}))], [t, T]), D = O(() => {
|
|
265
|
+
d(null), p(""), m(void 0);
|
|
266
|
+
}, []), k = O(async () => {
|
|
267
|
+
if (v || i == null) return;
|
|
267
268
|
let t = f.trim(), n = i.onValidateFolderName?.(t);
|
|
268
|
-
if (n != null)
|
|
269
|
+
if (n != null) m(n);
|
|
269
270
|
else {
|
|
270
|
-
|
|
271
|
+
m(void 0), y(!0);
|
|
271
272
|
try {
|
|
272
273
|
if (l === B.Create) {
|
|
273
|
-
let n = await i.onCreateFolder(t,
|
|
274
|
+
let n = await i.onCreateFolder(t, S ? void 0 : e);
|
|
274
275
|
typeof n == "string" && c(n);
|
|
275
276
|
} else {
|
|
276
277
|
let n = await i.onRenameFolder(e, t);
|
|
277
278
|
typeof n == "string" && c(n);
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
+
D();
|
|
280
281
|
} catch {} finally {
|
|
281
|
-
|
|
282
|
+
y(!1);
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
285
|
}, [
|
|
285
|
-
|
|
286
|
+
v,
|
|
286
287
|
i,
|
|
287
288
|
f,
|
|
288
289
|
l,
|
|
289
|
-
|
|
290
|
+
S,
|
|
290
291
|
e,
|
|
291
292
|
c,
|
|
292
|
-
|
|
293
|
-
]),
|
|
294
|
-
if (!(
|
|
295
|
-
|
|
293
|
+
D
|
|
294
|
+
]), A = O(async () => {
|
|
295
|
+
if (!(v || i == null)) {
|
|
296
|
+
y(!0);
|
|
296
297
|
try {
|
|
297
|
-
await i.onDeleteFolder(e), c(V),
|
|
298
|
+
await i.onDeleteFolder(e), c(V), D();
|
|
298
299
|
} catch {} finally {
|
|
299
|
-
|
|
300
|
+
y(!1);
|
|
300
301
|
}
|
|
301
302
|
}
|
|
302
303
|
}, [
|
|
303
|
-
|
|
304
|
+
v,
|
|
304
305
|
i,
|
|
305
306
|
e,
|
|
306
307
|
c,
|
|
307
|
-
|
|
308
|
-
]),
|
|
309
|
-
p(""),
|
|
310
|
-
}, []),
|
|
311
|
-
p(U(e)),
|
|
312
|
-
}, [e]),
|
|
313
|
-
|
|
314
|
-
}, []),
|
|
308
|
+
D
|
|
309
|
+
]), ne = O(() => {
|
|
310
|
+
p(""), m(void 0), d(B.Create);
|
|
311
|
+
}, []), ie = O(() => {
|
|
312
|
+
p(U(e)), m(void 0), d(B.Rename);
|
|
313
|
+
}, [e]), ae = O(() => {
|
|
314
|
+
m(void 0), d(B.ConfirmDelete);
|
|
315
|
+
}, []), oe = O((e) => {
|
|
315
316
|
let t = Array.isArray(e) ? e[0] : e;
|
|
316
317
|
t != null && c(t === H ? V : t);
|
|
317
|
-
}, [c]),
|
|
318
|
-
return /* @__PURE__ */
|
|
319
|
-
className: u("flex flex-col gap-2",
|
|
318
|
+
}, [c]), se = l === B.Create || l === B.Rename, ce = ee ?? r;
|
|
319
|
+
return /* @__PURE__ */ F("div", {
|
|
320
|
+
className: u("flex flex-col gap-2", re.folderField),
|
|
320
321
|
children: [
|
|
321
|
-
/* @__PURE__ */
|
|
322
|
+
/* @__PURE__ */ F("div", {
|
|
322
323
|
className: "flex items-end gap-2",
|
|
323
|
-
children: [/* @__PURE__ */
|
|
324
|
+
children: [/* @__PURE__ */ P(w, {
|
|
324
325
|
id: "prompt-folder",
|
|
325
326
|
className: "flex-1",
|
|
326
|
-
options:
|
|
327
|
-
value:
|
|
327
|
+
options: te,
|
|
328
|
+
value: S ? H : e,
|
|
328
329
|
labelProps: { label: o?.folderLabel ?? "Folder" },
|
|
329
330
|
invalid: n != null,
|
|
330
331
|
disabled: a,
|
|
331
332
|
error: n,
|
|
332
|
-
emptyStateTitle:
|
|
333
|
-
onChange:
|
|
334
|
-
}), i != null && !a && /* @__PURE__ */ N
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
icon: /* @__PURE__ */
|
|
337
|
-
size:
|
|
333
|
+
emptyStateTitle: E,
|
|
334
|
+
onChange: oe
|
|
335
|
+
}), i != null && !a && /* @__PURE__ */ F(N, { children: [
|
|
336
|
+
/* @__PURE__ */ P(b, {
|
|
337
|
+
icon: /* @__PURE__ */ P(I, {
|
|
338
|
+
size: h.SM,
|
|
338
339
|
"aria-hidden": !0,
|
|
339
|
-
stroke:
|
|
340
|
+
stroke: g
|
|
340
341
|
}),
|
|
341
342
|
"aria-label": o?.folderCreateLabel ?? "Create folder",
|
|
342
|
-
onClick:
|
|
343
|
+
onClick: ne
|
|
343
344
|
}),
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
icon: /* @__PURE__ */
|
|
346
|
-
size:
|
|
345
|
+
/* @__PURE__ */ P(b, {
|
|
346
|
+
icon: /* @__PURE__ */ P(L, {
|
|
347
|
+
size: h.SM,
|
|
347
348
|
"aria-hidden": !0,
|
|
348
|
-
stroke:
|
|
349
|
+
stroke: g
|
|
349
350
|
}),
|
|
350
351
|
"aria-label": o?.folderRenameLabel ?? "Rename folder",
|
|
351
|
-
disabled:
|
|
352
|
-
onClick:
|
|
352
|
+
disabled: S,
|
|
353
|
+
onClick: ie
|
|
353
354
|
}),
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
icon: /* @__PURE__ */
|
|
356
|
-
size:
|
|
355
|
+
/* @__PURE__ */ P(b, {
|
|
356
|
+
icon: /* @__PURE__ */ P(R, {
|
|
357
|
+
size: h.SM,
|
|
357
358
|
"aria-hidden": !0,
|
|
358
|
-
stroke:
|
|
359
|
+
stroke: g
|
|
359
360
|
}),
|
|
360
361
|
"aria-label": o?.folderDeleteLabel ?? "Delete folder",
|
|
361
|
-
disabled:
|
|
362
|
-
onClick:
|
|
362
|
+
disabled: S,
|
|
363
|
+
onClick: ae
|
|
363
364
|
})
|
|
364
365
|
] })]
|
|
365
366
|
}),
|
|
366
|
-
t.length === 0 && l == null && /* @__PURE__ */
|
|
367
|
+
t.length === 0 && l == null && /* @__PURE__ */ P("p", {
|
|
367
368
|
className: u("m-0", s),
|
|
368
|
-
children:
|
|
369
|
+
children: E
|
|
369
370
|
}),
|
|
370
|
-
|
|
371
|
+
se && /* @__PURE__ */ F("div", {
|
|
371
372
|
role: "group",
|
|
372
373
|
"aria-label": l === B.Create ? o?.folderCreateLabel ?? "Create folder" : o?.folderRenameLabel ?? "Rename folder",
|
|
373
374
|
className: "flex items-end gap-2",
|
|
374
375
|
children: [
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ P(x, {
|
|
376
377
|
id: "prompt-folder-name",
|
|
377
378
|
className: "flex-1",
|
|
378
379
|
value: f,
|
|
@@ -381,43 +382,43 @@ var I = {
|
|
|
381
382
|
label: o?.folderNameLabel ?? "Folder name",
|
|
382
383
|
required: !0
|
|
383
384
|
},
|
|
384
|
-
invalid:
|
|
385
|
-
error:
|
|
385
|
+
invalid: ce != null,
|
|
386
|
+
error: ce,
|
|
386
387
|
onChange: (e) => p(e ?? "")
|
|
387
388
|
}),
|
|
388
|
-
/* @__PURE__ */
|
|
389
|
-
size:
|
|
389
|
+
/* @__PURE__ */ P(C, {
|
|
390
|
+
size: _.Standard,
|
|
390
391
|
label: o?.saveLabel ?? "Save",
|
|
391
|
-
disabled:
|
|
392
|
-
onClick:
|
|
392
|
+
disabled: v,
|
|
393
|
+
onClick: k
|
|
393
394
|
}),
|
|
394
|
-
/* @__PURE__ */
|
|
395
|
-
size:
|
|
395
|
+
/* @__PURE__ */ P(C, {
|
|
396
|
+
size: _.Standard,
|
|
396
397
|
label: o?.cancelLabel ?? "Cancel",
|
|
397
|
-
disabled:
|
|
398
|
-
onClick:
|
|
398
|
+
disabled: v,
|
|
399
|
+
onClick: D
|
|
399
400
|
})
|
|
400
401
|
]
|
|
401
402
|
}),
|
|
402
|
-
l === B.ConfirmDelete && /* @__PURE__ */
|
|
403
|
+
l === B.ConfirmDelete && /* @__PURE__ */ F("div", {
|
|
403
404
|
role: "alertdialog",
|
|
404
405
|
"aria-label": o?.folderDeleteConfirmTitle ?? "Delete folder",
|
|
405
|
-
children: [/* @__PURE__ */
|
|
406
|
+
children: [/* @__PURE__ */ P("p", {
|
|
406
407
|
className: u("m-0 mb-2", s),
|
|
407
408
|
children: o?.folderDeleteConfirmMessage?.(e) ?? `Delete "${e}" and every prompt inside it?`
|
|
408
|
-
}), /* @__PURE__ */
|
|
409
|
+
}), /* @__PURE__ */ F("div", {
|
|
409
410
|
className: "flex gap-2",
|
|
410
|
-
children: [/* @__PURE__ */
|
|
411
|
-
size:
|
|
411
|
+
children: [/* @__PURE__ */ P(C, {
|
|
412
|
+
size: _.Standard,
|
|
412
413
|
label: o?.folderDeleteLabel ?? "Delete folder",
|
|
413
414
|
autoFocus: !0,
|
|
414
|
-
disabled:
|
|
415
|
-
onClick:
|
|
416
|
-
}), /* @__PURE__ */
|
|
417
|
-
size:
|
|
415
|
+
disabled: v,
|
|
416
|
+
onClick: A
|
|
417
|
+
}), /* @__PURE__ */ P(C, {
|
|
418
|
+
size: _.Standard,
|
|
418
419
|
label: o?.cancelLabel ?? "Cancel",
|
|
419
|
-
disabled:
|
|
420
|
-
onClick:
|
|
420
|
+
disabled: v,
|
|
421
|
+
onClick: D
|
|
421
422
|
})]
|
|
422
423
|
})]
|
|
423
424
|
})
|
|
@@ -425,4 +426,4 @@ var I = {
|
|
|
425
426
|
});
|
|
426
427
|
};
|
|
427
428
|
//#endregion
|
|
428
|
-
export { B as FolderFormMode,
|
|
429
|
+
export { B as FolderFormMode, re as PROMPT_EDITOR_CLASS, z as PromptEditor, W as PromptFolderField };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-prompt-editor",
|
|
3
3
|
"description": "Host-agnostic form for authoring a reusable prompt, with an inline folder picker",
|
|
4
|
-
"version": "1.3.0-dev.
|
|
4
|
+
"version": "1.3.0-dev.244",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"@tabler/icons-react": "^3.44.0",
|
|
21
21
|
"@uiw/react-markdown-preview": "^5.2.1",
|
|
22
22
|
"@uiw/react-md-editor": "^4.1.1",
|
|
23
|
-
"@epam/ai-dial-builder-form": "1.3.0-dev.
|
|
23
|
+
"@epam/ai-dial-builder-form": "1.3.0-dev.244"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@epam/ai-dial-chat-shared": "1.3.0-dev.
|
|
26
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.244",
|
|
27
27
|
"@epam/ai-dial-ui-kit": "^0.16.0-dev.45",
|
|
28
28
|
"react": "^19.2.8"
|
|
29
29
|
},
|