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