@epam/ai-dial-deployment-creation-form 1.0.1 → 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":"DeploymentCreationForm.d.ts","sourceRoot":"","sources":["../../../src/components/DeploymentCreationForm/DeploymentCreationForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeploymentCreationForm.d.ts","sourceRoot":"","sources":["../../../src/components/DeploymentCreationForm/DeploymentCreationForm.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AAGzF,sGAAsG;AACtG,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAqGlE,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ButtonAppearance as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { IconPencil as
|
|
5
|
-
import { Fragment as
|
|
1
|
+
import { TAG_INPUT_TAG_CLASS_NAME as e, mergeClasses as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { ButtonAppearance as n, ButtonVariant as r, DIAL_ICON_SIZE as i, DIAL_KIT_ICON_STROKE as a, DangerIconButton as o, ElementSize as s, Input as c, LinkButton as l, Popup as u, Select as d, TagInput as f, Textarea as p } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
import { useEffect as m, useRef as h, useState as g } from "react";
|
|
4
|
+
import { IconPencil as _, IconPlus as v, IconTrashX as y } from "@tabler/icons-react";
|
|
5
|
+
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/DeploymentLocalesField/DeploymentLocalesField.tsx
|
|
7
|
-
var
|
|
7
|
+
var C = (e, t, n) => ({
|
|
8
8
|
id: e,
|
|
9
9
|
language: n.find((e) => !t.has(e.code))?.code ?? "",
|
|
10
10
|
name: "",
|
|
11
11
|
description: ""
|
|
12
|
-
}),
|
|
13
|
-
let { summaryLabel: A, editLabel: j, popupTitle: M, addLocaleLabel: N, localeRowLabel: P = "Locale", languageLabel: F, nameLabel: I, namePlaceholder: L, descriptionLabel: R, descriptionPlaceholder: z, deleteAriaLabel: B, cancelLabel: V = "Cancel", saveLabel: H = "Save" } = T, [U, W] =
|
|
14
|
-
|
|
15
|
-
U && K(
|
|
12
|
+
}), w = ({ value: e, onChange: f, availableLocaleOptions: w = [], labels: T, className: E, summaryClassName: D = "dial-body-text text-secondary", rowLabelClassName: O = "dial-tiny-lead-text text-secondary", requiredMarkClassName: k = "text-error" }) => {
|
|
13
|
+
let { summaryLabel: A, editLabel: j, popupTitle: M, addLocaleLabel: N, localeRowLabel: P = "Locale", languageLabel: F, nameLabel: I, namePlaceholder: L, descriptionLabel: R, descriptionPlaceholder: z, deleteAriaLabel: B, cancelLabel: V = "Cancel", saveLabel: H = "Save" } = T, [U, W] = g(!1), [G, K] = g([]), q = h(0);
|
|
14
|
+
m(() => {
|
|
15
|
+
U && K(e.length > 0 ? e : [C(`locale-row-${++q.current}`, /* @__PURE__ */ new Set(), w)]);
|
|
16
16
|
}, [
|
|
17
17
|
U,
|
|
18
|
-
|
|
18
|
+
e,
|
|
19
19
|
w
|
|
20
20
|
]);
|
|
21
21
|
let J = () => W(!0), Y = () => W(!1), X = () => {
|
|
22
|
-
|
|
22
|
+
f(G.filter((e) => e.language && e.name)), W(!1);
|
|
23
23
|
}, Z = () => {
|
|
24
24
|
let e = new Set(G.map((e) => e.language).filter(Boolean));
|
|
25
|
-
K((t) => [...t,
|
|
25
|
+
K((t) => [...t, C(`locale-row-${++q.current}`, e, w)]);
|
|
26
26
|
}, Q = (e, t) => {
|
|
27
27
|
K((n) => n.map((n) => n.id === e ? {
|
|
28
28
|
...n,
|
|
@@ -31,24 +31,24 @@ var S = (e, t, n) => ({
|
|
|
31
31
|
}, $ = (e) => {
|
|
32
32
|
K((t) => t.filter((t) => t.id !== e));
|
|
33
33
|
}, ee = (e) => w.find((t) => t.code === e)?.label ?? e.toUpperCase(), te = G.some((e) => !e.language || !e.name);
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
className:
|
|
34
|
+
return /* @__PURE__ */ S("div", {
|
|
35
|
+
className: t("flex items-center gap-2", E),
|
|
36
36
|
children: [
|
|
37
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ x("span", {
|
|
38
38
|
className: D,
|
|
39
|
-
children: `${A}: ${
|
|
39
|
+
children: `${A}: ${e.length > 0 ? e.map((e) => `[${ee(e.language)}]`).join(", ") : "—"}`
|
|
40
40
|
}),
|
|
41
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ x(l, {
|
|
42
42
|
label: j,
|
|
43
|
-
iconBefore: /* @__PURE__ */
|
|
44
|
-
size:
|
|
43
|
+
iconBefore: /* @__PURE__ */ x(_, {
|
|
44
|
+
size: i.SM,
|
|
45
45
|
"aria-hidden": !0,
|
|
46
|
-
stroke:
|
|
46
|
+
stroke: a
|
|
47
47
|
}),
|
|
48
48
|
className: "!px-0",
|
|
49
49
|
onClick: J
|
|
50
50
|
}),
|
|
51
|
-
/* @__PURE__ */
|
|
51
|
+
/* @__PURE__ */ x(u, {
|
|
52
52
|
open: U,
|
|
53
53
|
header: M,
|
|
54
54
|
onClose: Y,
|
|
@@ -57,67 +57,67 @@ var S = (e, t, n) => ({
|
|
|
57
57
|
onClick: Y
|
|
58
58
|
}, {
|
|
59
59
|
label: H,
|
|
60
|
-
variant:
|
|
60
|
+
variant: r.Primary,
|
|
61
61
|
disabled: te,
|
|
62
62
|
onClick: X
|
|
63
63
|
}],
|
|
64
|
-
children: /* @__PURE__ */
|
|
64
|
+
children: /* @__PURE__ */ S("div", {
|
|
65
65
|
className: "flex flex-col gap-8 px-6 py-3",
|
|
66
|
-
children: [G.map((e,
|
|
67
|
-
let
|
|
68
|
-
return /* @__PURE__ */
|
|
66
|
+
children: [G.map((e, t) => {
|
|
67
|
+
let r = new Set(G.filter((t) => t.id !== e.id).map((e) => e.language).filter(Boolean));
|
|
68
|
+
return /* @__PURE__ */ S("div", {
|
|
69
69
|
className: "flex flex-col gap-2",
|
|
70
|
-
children: [/* @__PURE__ */
|
|
70
|
+
children: [/* @__PURE__ */ S("div", {
|
|
71
71
|
className: "flex items-center justify-between",
|
|
72
|
-
children: [/* @__PURE__ */
|
|
72
|
+
children: [/* @__PURE__ */ S("span", {
|
|
73
73
|
className: O,
|
|
74
74
|
children: [
|
|
75
75
|
P,
|
|
76
76
|
" ",
|
|
77
|
-
|
|
77
|
+
t + 1
|
|
78
78
|
]
|
|
79
|
-
}), /* @__PURE__ */
|
|
80
|
-
appearance:
|
|
81
|
-
size:
|
|
82
|
-
icon: /* @__PURE__ */
|
|
83
|
-
size:
|
|
79
|
+
}), /* @__PURE__ */ x(o, {
|
|
80
|
+
appearance: n.Ghost,
|
|
81
|
+
size: s.Small,
|
|
82
|
+
icon: /* @__PURE__ */ x(y, {
|
|
83
|
+
size: i.SM,
|
|
84
84
|
"aria-hidden": !0,
|
|
85
|
-
stroke:
|
|
85
|
+
stroke: a
|
|
86
86
|
}),
|
|
87
|
-
"aria-label": `${B} ${
|
|
87
|
+
"aria-label": `${B} ${t + 1}`,
|
|
88
88
|
onClick: () => $(e.id)
|
|
89
89
|
})]
|
|
90
|
-
}), /* @__PURE__ */
|
|
90
|
+
}), /* @__PURE__ */ S("div", {
|
|
91
91
|
role: "group",
|
|
92
|
-
"aria-label": `${P} ${
|
|
92
|
+
"aria-label": `${P} ${t + 1}`,
|
|
93
93
|
className: "flex flex-col gap-5",
|
|
94
|
-
children: [/* @__PURE__ */
|
|
94
|
+
children: [/* @__PURE__ */ S("div", {
|
|
95
95
|
className: "flex items-start gap-5",
|
|
96
|
-
children: [/* @__PURE__ */
|
|
96
|
+
children: [/* @__PURE__ */ x(d, {
|
|
97
97
|
id: `${e.id}-language`,
|
|
98
98
|
labelProps: { label: F },
|
|
99
99
|
className: "shrink-0 basis-20",
|
|
100
100
|
options: w.map((e) => ({
|
|
101
101
|
value: e.code,
|
|
102
102
|
label: e.label,
|
|
103
|
-
disabled:
|
|
103
|
+
disabled: r.has(e.code)
|
|
104
104
|
})),
|
|
105
105
|
value: e.language,
|
|
106
106
|
onChange: (t) => Q(e.id, { language: t })
|
|
107
|
-
}), /* @__PURE__ */
|
|
107
|
+
}), /* @__PURE__ */ x(c, {
|
|
108
108
|
id: `${e.id}-name`,
|
|
109
109
|
containerClassName: "min-w-0 flex-1",
|
|
110
110
|
required: !0,
|
|
111
111
|
value: e.name,
|
|
112
112
|
onChange: (t) => Q(e.id, { name: t ?? "" }),
|
|
113
|
-
labelProps: { label: /* @__PURE__ */
|
|
113
|
+
labelProps: { label: /* @__PURE__ */ S(b, { children: [I, /* @__PURE__ */ x("span", {
|
|
114
114
|
"aria-hidden": !0,
|
|
115
115
|
className: k,
|
|
116
116
|
children: "*"
|
|
117
117
|
})] }) },
|
|
118
118
|
placeholder: L
|
|
119
119
|
})]
|
|
120
|
-
}), /* @__PURE__ */
|
|
120
|
+
}), /* @__PURE__ */ x(p, {
|
|
121
121
|
id: `${e.id}-description`,
|
|
122
122
|
resize: !0,
|
|
123
123
|
value: e.description,
|
|
@@ -127,12 +127,12 @@ var S = (e, t, n) => ({
|
|
|
127
127
|
})]
|
|
128
128
|
})]
|
|
129
129
|
}, e.id);
|
|
130
|
-
}), /* @__PURE__ */
|
|
130
|
+
}), /* @__PURE__ */ x(l, {
|
|
131
131
|
label: N,
|
|
132
|
-
iconBefore: /* @__PURE__ */
|
|
133
|
-
size:
|
|
132
|
+
iconBefore: /* @__PURE__ */ x(v, {
|
|
133
|
+
size: i.SM,
|
|
134
134
|
"aria-hidden": !0,
|
|
135
|
-
stroke:
|
|
135
|
+
stroke: a
|
|
136
136
|
}),
|
|
137
137
|
className: "self-start",
|
|
138
138
|
onClick: Z,
|
|
@@ -142,88 +142,89 @@ var S = (e, t, n) => ({
|
|
|
142
142
|
})
|
|
143
143
|
]
|
|
144
144
|
});
|
|
145
|
-
},
|
|
146
|
-
let
|
|
147
|
-
return
|
|
148
|
-
|
|
145
|
+
}, T = ({ values: n, errors: r, onChange: i, onNameBlur: a, onVersionBlur: o, labels: s, styles: l, availableLocaleOptions: u = [] }) => {
|
|
146
|
+
let d = h(null), g = h(null), _ = h(!1), v = !!(r.name || r.version);
|
|
147
|
+
return m(() => {
|
|
148
|
+
v && !_.current && (r.name ? d : g).current?.focus(), _.current = v;
|
|
149
149
|
}, [
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
]), /* @__PURE__ */
|
|
154
|
-
role:
|
|
155
|
-
"aria-label":
|
|
156
|
-
className:
|
|
150
|
+
v,
|
|
151
|
+
r.name,
|
|
152
|
+
r.version
|
|
153
|
+
]), /* @__PURE__ */ S("div", {
|
|
154
|
+
role: s.ariaLabel ? "group" : void 0,
|
|
155
|
+
"aria-label": s.ariaLabel,
|
|
156
|
+
className: t("flex flex-col gap-4", l?.root),
|
|
157
157
|
children: [
|
|
158
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ x(c, {
|
|
159
159
|
id: "deployment-creation-form-name",
|
|
160
|
-
inputRef:
|
|
161
|
-
value:
|
|
162
|
-
onChange: (e) =>
|
|
163
|
-
onBlur:
|
|
160
|
+
inputRef: d,
|
|
161
|
+
value: n.name,
|
|
162
|
+
onChange: (e) => i({ name: e ?? "" }),
|
|
163
|
+
onBlur: a,
|
|
164
164
|
labelProps: {
|
|
165
|
-
label:
|
|
165
|
+
label: s.name.label,
|
|
166
166
|
required: !0
|
|
167
167
|
},
|
|
168
|
-
placeholder:
|
|
169
|
-
error:
|
|
170
|
-
invalid: !!
|
|
171
|
-
containerClassName:
|
|
168
|
+
placeholder: s.name.placeholder,
|
|
169
|
+
error: r.name || void 0,
|
|
170
|
+
invalid: !!r.name,
|
|
171
|
+
containerClassName: l?.field
|
|
172
172
|
}),
|
|
173
|
-
/* @__PURE__ */
|
|
173
|
+
/* @__PURE__ */ x(p, {
|
|
174
174
|
id: "deployment-creation-form-description",
|
|
175
|
-
value:
|
|
176
|
-
onChange: (e) =>
|
|
177
|
-
labelProps: { label:
|
|
178
|
-
placeholder:
|
|
179
|
-
containerClassName:
|
|
175
|
+
value: n.description,
|
|
176
|
+
onChange: (e) => i({ description: e }),
|
|
177
|
+
labelProps: { label: s.description.label },
|
|
178
|
+
placeholder: s.description.placeholder,
|
|
179
|
+
containerClassName: l?.field
|
|
180
180
|
}),
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
value:
|
|
183
|
-
onChange: (e) =>
|
|
184
|
-
availableLocaleOptions:
|
|
185
|
-
labels:
|
|
186
|
-
className:
|
|
181
|
+
/* @__PURE__ */ x(w, {
|
|
182
|
+
value: n.otherLocales,
|
|
183
|
+
onChange: (e) => i({ otherLocales: e }),
|
|
184
|
+
availableLocaleOptions: u,
|
|
185
|
+
labels: s.otherLocales,
|
|
186
|
+
className: l?.field
|
|
187
187
|
}),
|
|
188
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ x(c, {
|
|
189
189
|
id: "deployment-creation-form-icon-url",
|
|
190
|
-
value:
|
|
191
|
-
onChange: (e) =>
|
|
192
|
-
labelProps: { label:
|
|
193
|
-
placeholder:
|
|
194
|
-
containerClassName:
|
|
190
|
+
value: n.iconUrl,
|
|
191
|
+
onChange: (e) => i({ iconUrl: e ?? "" }),
|
|
192
|
+
labelProps: { label: s.iconUrl.label },
|
|
193
|
+
placeholder: s.iconUrl.placeholder,
|
|
194
|
+
containerClassName: l?.field
|
|
195
195
|
}),
|
|
196
|
-
/* @__PURE__ */
|
|
196
|
+
/* @__PURE__ */ x(c, {
|
|
197
197
|
id: "deployment-creation-form-version",
|
|
198
|
-
inputRef:
|
|
199
|
-
value:
|
|
200
|
-
onChange: (e) =>
|
|
201
|
-
onBlur:
|
|
202
|
-
labelProps: { label:
|
|
203
|
-
placeholder:
|
|
204
|
-
error:
|
|
205
|
-
invalid: !!
|
|
206
|
-
containerClassName:
|
|
198
|
+
inputRef: g,
|
|
199
|
+
value: n.version,
|
|
200
|
+
onChange: (e) => i({ version: e ?? "" }),
|
|
201
|
+
onBlur: o,
|
|
202
|
+
labelProps: { label: s.version.label },
|
|
203
|
+
placeholder: s.version.placeholder,
|
|
204
|
+
error: r.version || void 0,
|
|
205
|
+
invalid: !!r.version,
|
|
206
|
+
containerClassName: l?.field
|
|
207
207
|
}),
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
className:
|
|
210
|
-
children: /* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ x("div", {
|
|
209
|
+
className: l?.field,
|
|
210
|
+
children: /* @__PURE__ */ x(f, {
|
|
211
211
|
id: "deployment-creation-form-topics",
|
|
212
|
-
labelProps: { label:
|
|
213
|
-
placeholder:
|
|
214
|
-
value:
|
|
215
|
-
onChange: (e) =>
|
|
212
|
+
labelProps: { label: s.topics.label },
|
|
213
|
+
placeholder: s.topics.placeholder,
|
|
214
|
+
value: n.topics,
|
|
215
|
+
onChange: (e) => i({ topics: e }),
|
|
216
|
+
tagClassName: e
|
|
216
217
|
})
|
|
217
218
|
})
|
|
218
219
|
]
|
|
219
220
|
});
|
|
220
|
-
},
|
|
221
|
+
}, E = /* @__PURE__ */ function(e) {
|
|
221
222
|
return e.Required = "required", e.InvalidFormat = "invalid-format", e.TooLong = "too-long", e;
|
|
222
|
-
}({}),
|
|
223
|
+
}({}), D = /^[a-zA-Z0-9 _.-]+$/, O = /^[a-zA-Z0-9._-]+$/, k = (e, t = {}) => {
|
|
223
224
|
let n = {}, r = e.name.trim();
|
|
224
|
-
r ? t.validateNamePattern && !
|
|
225
|
+
r ? t.validateNamePattern && !D.test(r) && (n.name = E.InvalidFormat) : n.name = E.Required;
|
|
225
226
|
let i = e.version.trim();
|
|
226
|
-
return t.validateVersionPattern && i && !
|
|
227
|
+
return t.validateVersionPattern && i && !O.test(i) && (n.version = E.InvalidFormat), n;
|
|
227
228
|
};
|
|
228
229
|
//#endregion
|
|
229
|
-
export {
|
|
230
|
+
export { E as DeploymentCreationFieldErrorCode, T as DeploymentCreationForm, w as DeploymentLocalesField, D as NAME_PATTERN, O as VERSION_PATTERN, k as validateDeploymentCreationFields };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-deployment-creation-form",
|
|
3
3
|
"description": "Shared General-step field set for creating and editing a DIAL deployment",
|
|
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,7 +16,7 @@
|
|
|
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
21
|
"@tabler/icons-react": "*",
|
|
22
22
|
"react": "^19.0.0"
|