@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.
@@ -1 +1 @@
1
- {"version":3,"file":"PromptEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromptEditor/PromptEditor.tsx"],"names":[],"mappings":"AAkCA,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,CAka9C,CAAC"}
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, useTextRefinement as f, useUnsavedChangesGuard as p } from "@epam/ai-dial-chat-shared";
3
- import { ConfirmationPopupVariant as ee, DIAL_ICON_SIZE as m, DIAL_KIT_ICON_STROKE as h, ElementSize as g, ErrorText as _, GhostIconButton as v, Input as y, Label as b, NeutralButton as x, Select as S, Spinner as C } from "@epam/ai-dial-ui-kit";
4
- import { LazyMarkdownEditor as w } from "@epam/ai-dial-ui-kit/editors";
5
- import { Suspense as te, lazy as T, useCallback as E, useEffect as D, useId as O, useMemo as k, useRef as ne, useState as A } from "react";
6
- import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
7
- import { IconFolderPlus as re, IconPencil as P, IconTrashX as F } from "@tabler/icons-react";
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 I = {
9
+ var re = {
10
10
  form: "dial-prompt-editor-form",
11
11
  folderField: "dial-prompt-editor-folder-field"
12
- }, L = {
12
+ }, ie = {
13
13
  contentError: "_contentError_1qtel_1",
14
14
  contentInvalid: "_contentInvalid_1qtel_6"
15
- }, ie = T(async () => ({ default: (await w()).MarkdownEditor })), ae = {
15
+ }, ae = D(async () => ({ default: (await E()).MarkdownEditor })), oe = {
16
16
  name: "",
17
17
  description: "",
18
18
  content: ""
19
- }, oe = [n.Name, n.Description], se = 2e3, ce = 5e4, R = 10, le = "mx-auto w-full max-w-[1180px] gap-5 px-4 py-6 desktop:px-8 desktop:py-6", ue = 24, de = 480, fe = (e, t, n) => {
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: m, isLoading: h = !1, hasLoadError: g = !1, isSaving: v = !1, errors: y, descriptionMaxLength: S = se, contentMaxLength: w = ce, counterAnnounceThreshold: T = R, onSubmit: re, onFieldChange: P, onCancel: F, onBack: z = F, onDirtyChange: B, onRetry: V, onRefineDescription: H, onRefineInstructions: U, labels: W, markdownEditorTheme: pe, styles: me }) => {
23
- let { colors: he, typography: ge } = me ?? {}, _e = ge?.contentLabelClassName ?? "dial-tiny-semi-text", ve = ge?.helperTextClassName ?? "dial-small-text", G = k(() => ({
24
- ...ae,
25
- ...m
26
- }), [m]), [K, q] = A(G), ye = O(), J = O(), be = d({
27
- bottomGap: ue,
28
- minHeight: de
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
- D(() => {
31
- q(G);
32
- }, [G]);
33
- let xe = E((e, t) => {
34
- q((n) => ({
32
+ k(() => {
33
+ xe(K);
34
+ }, [K]);
35
+ let Te = O((e, t) => {
36
+ xe((n) => ({
35
37
  ...n,
36
38
  [e]: t
37
- })), P?.(e, t);
38
- }, [P]), Se = k(() => ({
39
- name: K.name,
40
- description: K.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
- }), [K.name, K.description]), Ce = E((e) => {
46
- q((t) => ({
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 && P?.("name", e.name), e.description !== void 0 && P?.("description", e.description);
51
- }, [P]), we = k(() => ({
52
- name: y?.name,
53
- description: y?.description
54
- }), [y?.name, y?.description]), Te = k(() => ({ form: {
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: W?.nameLabel ?? "Name",
58
- placeholder: W?.namePlaceholder ?? "Prompt name"
59
+ label: G?.nameLabel ?? "Name",
60
+ placeholder: G?.namePlaceholder ?? "Prompt name"
59
61
  },
60
62
  description: {
61
- label: W?.descriptionLabel ?? "Description",
62
- placeholder: W?.descriptionPlaceholder ?? "What this prompt is for"
63
+ label: G?.descriptionLabel ?? "Description",
64
+ placeholder: G?.descriptionPlaceholder ?? "What this prompt is for"
63
65
  },
64
66
  ariaLabel: void 0
65
67
  } }), [
66
- W?.nameLabel,
67
- W?.namePlaceholder,
68
- W?.descriptionLabel,
69
- W?.descriptionPlaceholder
70
- ]), Ee = f({
71
- value: K.description,
72
- onChange: (e) => xe("description", 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: v,
81
- resetKey: m
82
- }), Y = Ee.isPending || De.isPending, Oe = H ? (e, t) => /* @__PURE__ */ M(c, {
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: W?.descriptionLabel ?? "Description",
86
- labels: W,
87
- refinement: Ee,
88
- disabled: Y || v,
87
+ label: G?.descriptionLabel ?? "Description",
88
+ labels: G,
89
+ refinement: Ae,
90
+ disabled: Y || x,
89
91
  children: e
90
- }) : void 0, ke = K.name !== G.name || K.description !== G.description || K.content !== G.content, X = p(ke && !B);
91
- D(() => {
92
- B?.(ke);
93
- }, [ke, B]);
94
- let { guard: Z } = X, { reset: Ae } = Ee, { reset: je } = De, Q = E(() => {
95
- Ae(), je();
96
- }, [Ae, je]), Me = E(() => {
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(), z();
100
+ Q(), B();
99
101
  });
100
102
  }, [
101
103
  Z,
102
104
  Q,
103
- z
104
- ]), Ne = E(() => {
105
+ B
106
+ ]), Le = O(() => {
105
107
  Z(() => {
106
- Q(), F();
108
+ Q(), z();
107
109
  });
108
110
  }, [
109
111
  Z,
110
112
  Q,
111
- F
112
- ]), Pe = E(() => {
113
- v || Y || re(K);
113
+ z
114
+ ]), Re = O(() => {
115
+ x || Y || L(q);
114
116
  }, [
115
- v,
117
+ x,
116
118
  Y,
117
- re,
118
- K
119
- ]), Fe = y?.content != null && !y?.name && !y?.description, Ie = ne(!1);
120
- D(() => {
121
- Fe && !Ie.current && document.getElementById(J)?.focus(), Ie.current = Fe;
122
- }, [Fe, J]);
123
- let Le = n ? W?.editTitle ?? "Edit prompt" : W?.createTitle ?? "Create prompt", Re = n ? W?.saveLabel ?? "Save" : W?.createLabel ?? "Create", ze = k(() => ({
124
- cancelLabel: W?.cancelLabel ?? "Cancel",
125
- backAriaLabel: W?.backButtonAriaLabel ?? "Back to prompts",
126
- savingStatusLabel: W?.savingStatusLabel ?? "Saving"
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
- W?.cancelLabel,
129
- W?.backButtonAriaLabel,
130
- W?.savingStatusLabel
131
- ]), Be = l({
132
- "--pe-content-error": he?.contentErrorText,
133
- "--pe-content-invalid-border": he?.contentInvalidBorder
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: Le,
136
- onBack: z,
137
- onCancel: F,
138
- onSubmit: Pe,
139
- submitLabel: Re,
140
- labels: ze,
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 (h) return /* @__PURE__ */ M(t, {
145
+ if (_) return /* @__PURE__ */ P(t, {
144
146
  ...$,
145
- isSubmitting: v,
146
- metadata: /* @__PURE__ */ M("div", {
147
+ isSubmitting: x,
148
+ metadata: /* @__PURE__ */ P("div", {
147
149
  role: "status",
148
- "aria-label": W?.loadingAriaLabel ?? "Loading prompt",
150
+ "aria-label": G?.loadingAriaLabel ?? "Loading prompt",
149
151
  className: "flex flex-1 items-center justify-center p-8",
150
- children: /* @__PURE__ */ M(C, {})
152
+ children: /* @__PURE__ */ P(T, {})
151
153
  })
152
154
  });
153
- if (g) return /* @__PURE__ */ M(t, {
155
+ if (b) return /* @__PURE__ */ P(t, {
154
156
  ...$,
155
- metadata: /* @__PURE__ */ N("div", {
156
- role: "alert",
157
- className: "flex flex-col items-start gap-3",
158
- children: [/* @__PURE__ */ M("p", {
159
- className: u("m-0", ve),
160
- children: W?.loadErrorMessage ?? "Couldn't load this prompt. Please try again."
161
- }), V != null && /* @__PURE__ */ M(x, {
162
- label: W?.retryLabel ?? "Retry",
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 Ve = fe(K.description, S, T), He = fe(K.content, w, T), Ue = (e) => W?.charactersRemaining?.(e) ?? `${e} characters remaining`, We = W?.contentLabel ?? "Instructions", Ge = /* @__PURE__ */ M("div", {
168
- ref: be,
169
- className: u(o, a, s, y?.content != null && L.contentInvalid),
170
- children: /* @__PURE__ */ M(te, {
171
- fallback: /* @__PURE__ */ M(C, { ariaLabel: W?.contentLoadingAriaLabel ?? "Loading prompt editor" }),
172
- children: /* @__PURE__ */ M(ie, {
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: K.content,
175
- onChange: (e) => xe("content", e),
174
+ value: q.content,
175
+ onChange: (e) => Te("content", e),
176
176
  height: 480,
177
- placeholder: W?.contentPlaceholder ?? "Write the prompt instructions",
178
- theme: pe,
177
+ placeholder: G?.contentPlaceholder ?? "Write the prompt instructions",
178
+ theme: he,
179
179
  showDragbar: !1
180
180
  })
181
181
  })
182
- }), Ke = /* @__PURE__ */ M(_, {
183
- text: y?.content,
184
- className: u(ve, L.contentError)
182
+ }), Xe = /* @__PURE__ */ P(y, {
183
+ id: Ce,
184
+ text: w?.content,
185
+ className: u(be, ie.contentError)
185
186
  });
186
- return /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(t, {
187
+ return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(t, {
187
188
  ...$,
188
- onBack: Me,
189
- onCancel: Ne,
190
- isSubmitting: v,
189
+ onBack: Ie,
190
+ onCancel: Le,
191
+ isSubmitting: x,
191
192
  isSubmitDisabled: Y,
192
- metadataSectionClassName: u(le, I.form),
193
- metadata: /* @__PURE__ */ N(j, { children: [
194
- /* @__PURE__ */ M(r, {
195
- values: Se,
196
- errors: we,
197
- onChange: Ce,
198
- fields: oe,
199
- renderDescription: Oe,
200
- labels: Te,
201
- descriptionCaption: K.description ? `${K.description.length}/${S}` : void 0
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
- U ? /* @__PURE__ */ M("div", {
204
+ W ? /* @__PURE__ */ P("div", {
204
205
  className: "flex flex-1 flex-col",
205
- style: Be,
206
- children: /* @__PURE__ */ M(c, {
206
+ style: We,
207
+ children: /* @__PURE__ */ P(c, {
207
208
  isEnabled: !0,
208
209
  fieldId: J,
209
- label: We,
210
- labelClassName: _e,
210
+ label: Je,
211
+ labelClassName: ye,
211
212
  required: !0,
212
- labels: W,
213
- refinement: De,
214
- disabled: Y || v,
215
- children: /* @__PURE__ */ N("div", {
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: [Ge, Ke]
218
+ children: [Ye, Xe]
218
219
  })
219
220
  })
220
- }) : /* @__PURE__ */ N("div", {
221
+ }) : /* @__PURE__ */ F("div", {
221
222
  role: "group",
222
- "aria-labelledby": ye,
223
+ "aria-labelledby": Se,
223
224
  className: "flex flex-1 flex-col gap-2",
224
- style: Be,
225
+ style: We,
225
226
  children: [
226
- /* @__PURE__ */ M(b, {
227
- id: ye,
227
+ /* @__PURE__ */ P(S, {
228
+ id: Se,
228
229
  htmlFor: J,
229
- label: We,
230
+ label: Je,
230
231
  required: !0,
231
- className: _e
232
+ className: ye
232
233
  }),
233
- Ge,
234
- Ke
234
+ Ye,
235
+ Xe
235
236
  ]
236
237
  }),
237
- /* @__PURE__ */ N("span", {
238
+ /* @__PURE__ */ F("span", {
238
239
  role: "status",
239
240
  "aria-live": "polite",
240
241
  className: "sr-only",
241
- children: [Ve != null && Ue(Ve), He != null && Ue(He)]
242
+ children: [Ge != null && qe(Ge), Ke != null && qe(Ke)]
242
243
  })
243
244
  ] })
244
- }), X.isConfirmOpen && /* @__PURE__ */ M(i, {
245
+ }), X.isConfirmOpen && /* @__PURE__ */ P(i, {
245
246
  open: !0,
246
- title: W?.discardTitle ?? "Discard unsaved changes?",
247
- message: W?.discardMessage ?? "You have unsaved changes. Leaving now will discard them.",
248
- confirmLabel: W?.discardConfirmLabel ?? "Discard",
249
- cancelLabel: W?.discardCancelLabel ?? "Keep editing",
250
- variant: ee.Danger,
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] = A(null), [f, p] = A(""), [ee, _] = A(), [b, C] = A(!1), w = e === V, te = o?.folderRootOption ?? "Root", T = o?.folderEmptyState ?? "No folders yet", D = k(() => [{
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: te
260
+ label: T
260
261
  }, ...t.map((e) => ({
261
262
  value: e.id,
262
263
  label: e.id
263
- }))], [t, te]), O = E(() => {
264
- d(null), p(""), _(void 0);
265
- }, []), ne = E(async () => {
266
- if (b || i == null) return;
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) _(n);
269
+ if (n != null) m(n);
269
270
  else {
270
- _(void 0), C(!0);
271
+ m(void 0), y(!0);
271
272
  try {
272
273
  if (l === B.Create) {
273
- let n = await i.onCreateFolder(t, w ? void 0 : e);
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
- O();
280
+ D();
280
281
  } catch {} finally {
281
- C(!1);
282
+ y(!1);
282
283
  }
283
284
  }
284
285
  }, [
285
- b,
286
+ v,
286
287
  i,
287
288
  f,
288
289
  l,
289
- w,
290
+ S,
290
291
  e,
291
292
  c,
292
- O
293
- ]), L = E(async () => {
294
- if (!(b || i == null)) {
295
- C(!0);
293
+ D
294
+ ]), A = O(async () => {
295
+ if (!(v || i == null)) {
296
+ y(!0);
296
297
  try {
297
- await i.onDeleteFolder(e), c(V), O();
298
+ await i.onDeleteFolder(e), c(V), D();
298
299
  } catch {} finally {
299
- C(!1);
300
+ y(!1);
300
301
  }
301
302
  }
302
303
  }, [
303
- b,
304
+ v,
304
305
  i,
305
306
  e,
306
307
  c,
307
- O
308
- ]), ie = E(() => {
309
- p(""), _(void 0), d(B.Create);
310
- }, []), ae = E(() => {
311
- p(U(e)), _(void 0), d(B.Rename);
312
- }, [e]), oe = E(() => {
313
- _(void 0), d(B.ConfirmDelete);
314
- }, []), se = E((e) => {
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]), ce = l === B.Create || l === B.Rename, R = ee ?? r;
318
- return /* @__PURE__ */ N("div", {
319
- className: u("flex flex-col gap-2", I.folderField),
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__ */ N("div", {
322
+ /* @__PURE__ */ F("div", {
322
323
  className: "flex items-end gap-2",
323
- children: [/* @__PURE__ */ M(S, {
324
+ children: [/* @__PURE__ */ P(w, {
324
325
  id: "prompt-folder",
325
326
  className: "flex-1",
326
- options: D,
327
- value: w ? H : e,
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: T,
333
- onChange: se
334
- }), i != null && !a && /* @__PURE__ */ N(j, { children: [
335
- /* @__PURE__ */ M(v, {
336
- icon: /* @__PURE__ */ M(re, {
337
- size: m.SM,
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: h
340
+ stroke: g
340
341
  }),
341
342
  "aria-label": o?.folderCreateLabel ?? "Create folder",
342
- onClick: ie
343
+ onClick: ne
343
344
  }),
344
- /* @__PURE__ */ M(v, {
345
- icon: /* @__PURE__ */ M(P, {
346
- size: m.SM,
345
+ /* @__PURE__ */ P(b, {
346
+ icon: /* @__PURE__ */ P(L, {
347
+ size: h.SM,
347
348
  "aria-hidden": !0,
348
- stroke: h
349
+ stroke: g
349
350
  }),
350
351
  "aria-label": o?.folderRenameLabel ?? "Rename folder",
351
- disabled: w,
352
- onClick: ae
352
+ disabled: S,
353
+ onClick: ie
353
354
  }),
354
- /* @__PURE__ */ M(v, {
355
- icon: /* @__PURE__ */ M(F, {
356
- size: m.SM,
355
+ /* @__PURE__ */ P(b, {
356
+ icon: /* @__PURE__ */ P(R, {
357
+ size: h.SM,
357
358
  "aria-hidden": !0,
358
- stroke: h
359
+ stroke: g
359
360
  }),
360
361
  "aria-label": o?.folderDeleteLabel ?? "Delete folder",
361
- disabled: w,
362
- onClick: oe
362
+ disabled: S,
363
+ onClick: ae
363
364
  })
364
365
  ] })]
365
366
  }),
366
- t.length === 0 && l == null && /* @__PURE__ */ M("p", {
367
+ t.length === 0 && l == null && /* @__PURE__ */ P("p", {
367
368
  className: u("m-0", s),
368
- children: T
369
+ children: E
369
370
  }),
370
- ce && /* @__PURE__ */ N("div", {
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__ */ M(y, {
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: R != null,
385
- error: R,
385
+ invalid: ce != null,
386
+ error: ce,
386
387
  onChange: (e) => p(e ?? "")
387
388
  }),
388
- /* @__PURE__ */ M(x, {
389
- size: g.Standard,
389
+ /* @__PURE__ */ P(C, {
390
+ size: _.Standard,
390
391
  label: o?.saveLabel ?? "Save",
391
- disabled: b,
392
- onClick: ne
392
+ disabled: v,
393
+ onClick: k
393
394
  }),
394
- /* @__PURE__ */ M(x, {
395
- size: g.Standard,
395
+ /* @__PURE__ */ P(C, {
396
+ size: _.Standard,
396
397
  label: o?.cancelLabel ?? "Cancel",
397
- disabled: b,
398
- onClick: O
398
+ disabled: v,
399
+ onClick: D
399
400
  })
400
401
  ]
401
402
  }),
402
- l === B.ConfirmDelete && /* @__PURE__ */ N("div", {
403
+ l === B.ConfirmDelete && /* @__PURE__ */ F("div", {
403
404
  role: "alertdialog",
404
405
  "aria-label": o?.folderDeleteConfirmTitle ?? "Delete folder",
405
- children: [/* @__PURE__ */ M("p", {
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__ */ N("div", {
409
+ }), /* @__PURE__ */ F("div", {
409
410
  className: "flex gap-2",
410
- children: [/* @__PURE__ */ M(x, {
411
- size: g.Standard,
411
+ children: [/* @__PURE__ */ P(C, {
412
+ size: _.Standard,
412
413
  label: o?.folderDeleteLabel ?? "Delete folder",
413
414
  autoFocus: !0,
414
- disabled: b,
415
- onClick: L
416
- }), /* @__PURE__ */ M(x, {
417
- size: g.Standard,
415
+ disabled: v,
416
+ onClick: A
417
+ }), /* @__PURE__ */ P(C, {
418
+ size: _.Standard,
418
419
  label: o?.cancelLabel ?? "Cancel",
419
- disabled: b,
420
- onClick: O
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, I as PROMPT_EDITOR_CLASS, z as PromptEditor, W as PromptFolderField };
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.241",
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.241"
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.241",
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
  },