@nice2dev/ui-api 1.2.2 → 1.3.1

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/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsxs as n, jsx as e, Fragment as Q } from "react/jsx-runtime";
2
- import { NiceAppShell as ye, NiceButton as U, NiceTextInput as L, NiceTextArea as oe, NiceSelect as se, NiceCheckbox as fe, NiceIcon as ee } from "@nice2dev/ui";
3
- import { useNiceTranslation as $, NiceTutorialButton as ce, resolveTutorial as le, NiceIcon as B, createId as re } from "@nice2dev/ui-core";
4
- import { useState as C, useCallback as I, useRef as de, useEffect as Ne, forwardRef as Ce, useMemo as Se } from "react";
5
- const Ee = [
2
+ import { NiceAppShell as fe, NiceButton as U, NiceTextInput as L, NiceTextArea as oe, NiceSelect as se, NiceCheckbox as Ne, NiceIcon as ee } from "@nice2dev/ui";
3
+ import { useNiceTranslation as $, NiceTutorialButton as ce, resolveTutorial as le, NiceIcon as B, clickOnActivationKey as ge, createId as re } from "@nice2dev/ui-core";
4
+ import { useState as C, useCallback as I, useRef as de, useEffect as we, forwardRef as Se, useMemo as Ee } from "react";
5
+ const Pe = [
6
6
  {
7
7
  target: ".nice-api-designer",
8
8
  titleKey: "tutorial.apiDesigner.intro.title",
@@ -11,7 +11,7 @@ const Ee = [
11
11
  content: "Define endpoints, parameters, request/response schemas and security for your OpenAPI document.",
12
12
  placement: "auto"
13
13
  }
14
- ], ge = {
14
+ ], _e = {
15
15
  openapi: "3.0.3",
16
16
  info: {
17
17
  title: "Pet Store API",
@@ -113,19 +113,19 @@ const Ee = [
113
113
  }
114
114
  },
115
115
  tags: [{ name: "pets", description: "Pet operations" }]
116
- }, we = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Pe = [
116
+ }, Te = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], De = [
117
117
  "object",
118
118
  "array",
119
119
  "string",
120
120
  "number",
121
121
  "integer",
122
122
  "boolean"
123
- ], De = ["query", "path", "header", "cookie"], Ae = ["apiKey", "http", "oauth2", "openIdConnect"];
123
+ ], Ae = ["query", "path", "header", "cookie"], xe = ["apiKey", "http", "oauth2", "openIdConnect"];
124
124
  function ue(t) {
125
125
  var o, i;
126
126
  const a = [];
127
127
  return t.openapi || a.push({ path: "openapi", message: "OpenAPI version is required", severity: "error" }), (o = t.info) != null && o.title || a.push({ path: "info.title", message: "API title is required", severity: "error" }), (i = t.info) != null && i.version || a.push({ path: "info.version", message: "API version is required", severity: "error" }), Object.entries(t.paths || {}).forEach(([r, c]) => {
128
- r.startsWith("/") || a.push({ path: `paths.${r}`, message: "Path must start with /", severity: "error" }), we.forEach((l) => {
128
+ r.startsWith("/") || a.push({ path: `paths.${r}`, message: "Path must start with /", severity: "error" }), Te.forEach((l) => {
129
129
  const d = c[l.toLowerCase()];
130
130
  d && !d.responses && a.push({
131
131
  path: `paths.${r}.${l.toLowerCase()}.responses`,
@@ -135,11 +135,11 @@ function ue(t) {
135
135
  });
136
136
  }), a;
137
137
  }
138
- const _e = /* @__PURE__ */ Pe.map((t) => ({
138
+ const be = /* @__PURE__ */ De.map((t) => ({
139
139
  value: String(t),
140
140
  label: String(t)
141
141
  }));
142
- function ot({
142
+ function ct({
143
143
  schema: t,
144
144
  onChange: a,
145
145
  onSave: o,
@@ -148,8 +148,8 @@ function ot({
148
148
  tutorial: c
149
149
  }) {
150
150
  var V, G;
151
- const { t: l } = $(), [d, p] = C(t || ge), [v, u] = C("/pets"), [N, b] = C("get"), [y, T] = C("paths"), [m, S] = C(
152
- () => ue(t || ge)
151
+ const { t: l } = $(), [d, p] = C(t || _e), [v, u] = C("/pets"), [N, b] = C("get"), [y, T] = C("paths"), [m, S] = C(
152
+ () => ue(t || _e)
153
153
  ), w = I(
154
154
  (k) => {
155
155
  p((f) => {
@@ -173,17 +173,17 @@ function ot({
173
173
  }, [w]), J = I(
174
174
  (k) => {
175
175
  w((f) => {
176
- const { [k]: x, ...j } = f.paths;
177
- return { ...f, paths: j };
176
+ const { [k]: x, ...K } = f.paths;
177
+ return { ...f, paths: K };
178
178
  }), u(null), b(null);
179
179
  },
180
180
  [w]
181
181
  ), te = I(() => {
182
182
  let k = "NewSchema";
183
183
  w((f) => {
184
- var j, F, R;
184
+ var K, F, R;
185
185
  let x = 1;
186
- for (; (F = (j = f.components) == null ? void 0 : j.schemas) != null && F[k]; )
186
+ for (; (F = (K = f.components) == null ? void 0 : K.schemas) != null && F[k]; )
187
187
  k = `NewSchema${x++}`;
188
188
  return {
189
189
  ...f,
@@ -197,7 +197,7 @@ function ot({
197
197
  const k = ue(d);
198
198
  S(k), k.filter((f) => f.severity === "error").length === 0 && (o == null || o(d));
199
199
  }, [d, o]), M = Object.entries(d.paths).flatMap(
200
- ([k, f]) => we.filter((x) => f[x.toLowerCase()]).map(
200
+ ([k, f]) => Te.filter((x) => f[x.toLowerCase()]).map(
201
201
  (x) => ({
202
202
  path: k,
203
203
  method: x,
@@ -206,9 +206,9 @@ function ot({
206
206
  )
207
207
  ), O = ["info", "paths", "schemas", "security", "preview"];
208
208
  return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
209
- c && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(c, Ee) }) }),
209
+ c && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(c, Pe) }) }),
210
210
  /* @__PURE__ */ e(
211
- ye,
211
+ fe,
212
212
  {
213
213
  flush: !0,
214
214
  className: `nice-api-designer ${r}`,
@@ -252,9 +252,9 @@ function ot({
252
252
  f
253
253
  )) }) : void 0,
254
254
  children: /* @__PURE__ */ n("div", { className: "nice-api-designer__content", children: [
255
- y === "info" && /* @__PURE__ */ e(xe, { schema: d, onChange: w, readOnly: i }),
255
+ y === "info" && /* @__PURE__ */ e(Ie, { schema: d, onChange: w, readOnly: i }),
256
256
  y === "paths" && /* @__PURE__ */ e(
257
- Ie,
257
+ Re,
258
258
  {
259
259
  endpoints: M,
260
260
  schema: d,
@@ -270,7 +270,7 @@ function ot({
270
270
  }
271
271
  ),
272
272
  y === "schemas" && /* @__PURE__ */ e(
273
- Re,
273
+ qe,
274
274
  {
275
275
  schemas: ((V = d.components) == null ? void 0 : V.schemas) || {},
276
276
  onAdd: te,
@@ -282,7 +282,7 @@ function ot({
282
282
  }
283
283
  ),
284
284
  y === "security" && /* @__PURE__ */ e(
285
- qe,
285
+ $e,
286
286
  {
287
287
  schemes: ((G = d.components) == null ? void 0 : G.securitySchemes) || {},
288
288
  onChange: (k) => w((f) => ({
@@ -292,13 +292,13 @@ function ot({
292
292
  readOnly: i
293
293
  }
294
294
  ),
295
- y === "preview" && /* @__PURE__ */ e($e, { schema: d })
295
+ y === "preview" && /* @__PURE__ */ e(Be, { schema: d })
296
296
  ] })
297
297
  }
298
298
  )
299
299
  ] });
300
300
  }
301
- function xe({ schema: t, onChange: a, readOnly: o }) {
301
+ function Ie({ schema: t, onChange: a, readOnly: o }) {
302
302
  const { t: i } = $();
303
303
  return /* @__PURE__ */ n("div", { className: "nice-api-designer__info-editor", children: [
304
304
  /* @__PURE__ */ e("h3", { children: i("apiDesigner.apiInformation", "API information") }),
@@ -394,7 +394,7 @@ function xe({ schema: t, onChange: a, readOnly: o }) {
394
394
  )
395
395
  ] });
396
396
  }
397
- function Ie({
397
+ function Re({
398
398
  endpoints: t,
399
399
  schema: a,
400
400
  selectedPath: o,
@@ -431,6 +431,9 @@ function Ie({
431
431
  t.map(({ path: T, method: m }) => /* @__PURE__ */ n(
432
432
  "div",
433
433
  {
434
+ role: "button",
435
+ tabIndex: 0,
436
+ onKeyDown: ge,
434
437
  className: `nice-api-designer__endpoint ${o === T && i === m.toLowerCase() ? "nice-api-designer__endpoint--selected" : ""}`,
435
438
  onClick: () => r(T, m.toLowerCase()),
436
439
  children: [
@@ -525,7 +528,7 @@ function Ie({
525
528
  {
526
529
  size: "sm",
527
530
  value: T.in,
528
- options: De.map((S) => ({ value: String(S), label: String(S) })),
531
+ options: Ae.map((S) => ({ value: String(S), label: String(S) })),
529
532
  onChange: (S) => N({
530
533
  parameters: b.map(
531
534
  (w, A) => A === m ? { ...w, in: S } : w
@@ -534,7 +537,7 @@ function Ie({
534
537
  }
535
538
  ),
536
539
  /* @__PURE__ */ e(
537
- fe,
540
+ Ne,
538
541
  {
539
542
  checked: !!T.required,
540
543
  onChange: (S) => N({
@@ -571,7 +574,7 @@ function Ie({
571
574
  ] })
572
575
  ] });
573
576
  }
574
- function Re({
577
+ function qe({
575
578
  schemas: t,
576
579
  onAdd: a,
577
580
  onChange: o,
@@ -595,6 +598,9 @@ function Re({
595
598
  c.map((b) => /* @__PURE__ */ e(
596
599
  "div",
597
600
  {
601
+ role: "button",
602
+ tabIndex: 0,
603
+ onKeyDown: ge,
598
604
  className: `nice-api-designer__schema-item ${l === b ? "nice-api-designer__schema-item--selected" : ""}`,
599
605
  onClick: () => d(b),
600
606
  children: b
@@ -609,7 +615,7 @@ function Re({
609
615
  {
610
616
  label: r("apiDesigner.type", "Type"),
611
617
  value: p.type || "object",
612
- options: _e,
618
+ options: be,
613
619
  onChange: (b) => u({ type: b })
614
620
  }
615
621
  ),
@@ -672,12 +678,12 @@ function Re({
672
678
  {
673
679
  size: "sm",
674
680
  value: y.type || "string",
675
- options: _e,
681
+ options: be,
676
682
  onChange: (m) => N(b, { ...y, type: m })
677
683
  }
678
684
  ),
679
685
  /* @__PURE__ */ e(
680
- fe,
686
+ Ne,
681
687
  {
682
688
  checked: T,
683
689
  onChange: (m) => u({
@@ -729,7 +735,7 @@ function Re({
729
735
  ] })
730
736
  ] });
731
737
  }
732
- function qe({ schemes: t, onChange: a, readOnly: o }) {
738
+ function $e({ schemes: t, onChange: a, readOnly: o }) {
733
739
  const { t: i } = $(), r = (c, l) => a({ ...t, [c]: l });
734
740
  return /* @__PURE__ */ n("div", { className: "nice-api-designer__security-editor", children: [
735
741
  /* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
@@ -779,7 +785,7 @@ function qe({ schemes: t, onChange: a, readOnly: o }) {
779
785
  {
780
786
  size: "sm",
781
787
  value: l.type,
782
- options: Ae.map((d) => ({ value: String(d), label: String(d) })),
788
+ options: xe.map((d) => ({ value: String(d), label: String(d) })),
783
789
  onChange: (d) => r(c, { ...l, type: d })
784
790
  }
785
791
  ),
@@ -840,14 +846,14 @@ function qe({ schemes: t, onChange: a, readOnly: o }) {
840
846
  ] }, c))
841
847
  ] });
842
848
  }
843
- function $e({ schema: t }) {
849
+ function Be({ schema: t }) {
844
850
  const { t: a } = $();
845
851
  return /* @__PURE__ */ n("div", { className: "nice-api-designer__json-preview", children: [
846
852
  /* @__PURE__ */ e("h3", { children: a("apiDesigner.openapiSpecification", "OpenAPI specification") }),
847
853
  /* @__PURE__ */ e("pre", { className: "nice-api-designer__code", children: JSON.stringify(t, null, 2) })
848
854
  ] });
849
855
  }
850
- const Be = [
856
+ const ze = [
851
857
  {
852
858
  target: ".nice-api-tester",
853
859
  titleKey: "tutorial.apiTester.intro.title",
@@ -856,7 +862,7 @@ const Be = [
856
862
  content: "Build requests with collections and environment variables, send them and assert on the responses.",
857
863
  placement: "auto"
858
864
  }
859
- ], ze = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Oe = {
865
+ ], Oe = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Ke = {
860
866
  id: "",
861
867
  name: "New Request",
862
868
  method: "GET",
@@ -871,7 +877,7 @@ function je(t, a) {
871
877
  const o = Object.entries(a).filter(([, i]) => i).map(([i, r]) => `${encodeURIComponent(i)}=${encodeURIComponent(r)}`).join("&");
872
878
  return o ? `${t}?${o}` : t;
873
879
  }
874
- function ct({
880
+ function lt({
875
881
  collections: t = [],
876
882
  environments: a = [],
877
883
  onRequest: o,
@@ -882,11 +888,11 @@ function ct({
882
888
  const { t: l } = $(), [d, p] = C(t), [v, u] = C(a), [N, b] = C(
883
889
  a.find((s) => s.isActive) || null
884
890
  ), [y, T] = C({
885
- ...Oe,
891
+ ...Ke,
886
892
  id: re()
887
893
  }), [m, S] = C(null), [w, A] = C(!1), [J, te] = C("none"), [z, M] = C(
888
894
  "params"
889
- ), [O, V] = C("body"), [G, k] = C(""), [f, x] = C(""), [j, F] = C([]), [R, ie] = C([]), K = de(null), Y = I(async () => {
895
+ ), [O, V] = C("body"), [G, k] = C(""), [f, x] = C(""), [K, F] = C([]), [R, ie] = C([]), j = de(null), Y = I(async () => {
890
896
  var H;
891
897
  if (!y.url)
892
898
  return;
@@ -911,13 +917,13 @@ function ct({
911
917
  if (o)
912
918
  E = await o(g);
913
919
  else {
914
- K.current = new AbortController();
920
+ j.current = new AbortController();
915
921
  const _ = { ...g.headers };
916
- y.auth && Ke(_, y.auth);
922
+ y.auth && He(_, y.auth);
917
923
  const D = je(g.url, g.queryParams), q = {
918
924
  method: g.method,
919
925
  headers: _,
920
- signal: K.current.signal
926
+ signal: j.current.signal
921
927
  };
922
928
  ["POST", "PUT", "PATCH"].includes(g.method) && ((H = y.body) != null && H.content) && (q.body = typeof y.body.content == "string" ? y.body.content : JSON.stringify(y.body.content), y.body.type === "json" && (_["Content-Type"] = "application/json"));
923
929
  const W = await fetch(D, q), X = await W.text();
@@ -927,13 +933,13 @@ function ct({
927
933
  } catch {
928
934
  pe = X;
929
935
  }
930
- const ke = performance.now();
936
+ const Ce = performance.now();
931
937
  E = {
932
938
  status: W.status,
933
939
  statusText: W.statusText,
934
940
  headers: Object.fromEntries(W.headers.entries()),
935
941
  body: pe,
936
- time: Math.round(ke - P),
942
+ time: Math.round(Ce - P),
937
943
  size: new Blob([X]).size,
938
944
  timestamp: /* @__PURE__ */ new Date()
939
945
  };
@@ -941,7 +947,7 @@ function ct({
941
947
  if (S(E), ie(
942
948
  (_) => [..._, { request: y, response: E }].slice(-50)
943
949
  ), f) {
944
- const _ = Ue(f, E);
950
+ const _ = Me(f, E);
945
951
  F(_);
946
952
  }
947
953
  } catch (E) {
@@ -955,11 +961,11 @@ function ct({
955
961
  timestamp: /* @__PURE__ */ new Date()
956
962
  });
957
963
  } finally {
958
- A(!1), K.current = null;
964
+ A(!1), j.current = null;
959
965
  }
960
966
  }, [y, N, o, f]), ne = I(() => {
961
967
  var s;
962
- (s = K.current) == null || s.abort(), A(!1);
968
+ (s = j.current) == null || s.abort(), A(!1);
963
969
  }, []), Z = I(() => {
964
970
  T((s) => ({
965
971
  ...s,
@@ -987,7 +993,7 @@ function ct({
987
993
  }
988
994
  }, [d, y, i]);
989
995
  return /* @__PURE__ */ n("div", { className: `nice-api-tester ${r}`, style: { position: "relative" }, children: [
990
- c && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(c, Be) }) }),
996
+ c && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(c, ze) }) }),
991
997
  /* @__PURE__ */ e("div", { className: "nice-api-tester__toolbar", children: /* @__PURE__ */ e("div", { className: "nice-api-tester__env-selector", children: /* @__PURE__ */ n(
992
998
  "select",
993
999
  {
@@ -1009,7 +1015,7 @@ function ct({
1009
1015
  method: s.target.value
1010
1016
  })),
1011
1017
  className: `nice-api-tester__method nice-api-tester__method--${y.method.toLowerCase()}`,
1012
- children: ze.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
1018
+ children: Oe.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
1013
1019
  }
1014
1020
  ),
1015
1021
  /* @__PURE__ */ e(
@@ -1045,7 +1051,7 @@ function ct({
1045
1051
  )) }),
1046
1052
  /* @__PURE__ */ n("div", { className: "nice-api-tester__tab-content", children: [
1047
1053
  z === "params" && /* @__PURE__ */ e(
1048
- Me,
1054
+ Le,
1049
1055
  {
1050
1056
  params: y.queryParams,
1051
1057
  onChange: (s) => T((g) => ({ ...g, queryParams: s })),
@@ -1053,7 +1059,7 @@ function ct({
1053
1059
  }
1054
1060
  ),
1055
1061
  z === "headers" && /* @__PURE__ */ e(
1056
- Le,
1062
+ Ve,
1057
1063
  {
1058
1064
  headers: y.headers,
1059
1065
  onChange: (s) => T((g) => ({ ...g, headers: s })),
@@ -1061,7 +1067,7 @@ function ct({
1061
1067
  }
1062
1068
  ),
1063
1069
  z === "body" && /* @__PURE__ */ e(
1064
- Ve,
1070
+ Fe,
1065
1071
  {
1066
1072
  body: y.body,
1067
1073
  bodyTab: J,
@@ -1070,14 +1076,14 @@ function ct({
1070
1076
  }
1071
1077
  ),
1072
1078
  z === "auth" && /* @__PURE__ */ e(
1073
- Fe,
1079
+ Je,
1074
1080
  {
1075
1081
  auth: y.auth,
1076
1082
  onChange: (s) => T((g) => ({ ...g, auth: s }))
1077
1083
  }
1078
1084
  ),
1079
1085
  z === "tests" && /* @__PURE__ */ e(
1080
- Je,
1086
+ We,
1081
1087
  {
1082
1088
  preRequestScript: G,
1083
1089
  testScript: f,
@@ -1104,7 +1110,7 @@ function ct({
1104
1110
  m.time,
1105
1111
  "ms"
1106
1112
  ] }),
1107
- /* @__PURE__ */ e("span", { className: "nice-api-tester__size", children: He(m.size) })
1113
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__size", children: Ue(m.size) })
1108
1114
  ] }),
1109
1115
  /* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["body", "headers", "tests"].map((s) => /* @__PURE__ */ n(
1110
1116
  "button",
@@ -1113,10 +1119,10 @@ function ct({
1113
1119
  onClick: () => V(s),
1114
1120
  children: [
1115
1121
  s.charAt(0).toUpperCase() + s.slice(1),
1116
- s === "tests" && j.length > 0 && /* @__PURE__ */ n("span", { className: "nice-api-tester__test-badge", children: [
1117
- j.filter((g) => g.passed).length,
1122
+ s === "tests" && K.length > 0 && /* @__PURE__ */ n("span", { className: "nice-api-tester__test-badge", children: [
1123
+ K.filter((g) => g.passed).length,
1118
1124
  "/",
1119
- j.length
1125
+ K.length
1120
1126
  ] })
1121
1127
  ]
1122
1128
  },
@@ -1128,7 +1134,7 @@ function ct({
1128
1134
  /* @__PURE__ */ e("span", { className: "nice-api-tester__header-key", children: s }),
1129
1135
  /* @__PURE__ */ e("span", { className: "nice-api-tester__header-value", children: g })
1130
1136
  ] }, s)) }),
1131
- O === "tests" && /* @__PURE__ */ e("div", { className: "nice-api-tester__test-results", children: j.map((s, g) => /* @__PURE__ */ n(
1137
+ O === "tests" && /* @__PURE__ */ e("div", { className: "nice-api-tester__test-results", children: K.map((s, g) => /* @__PURE__ */ n(
1132
1138
  "div",
1133
1139
  {
1134
1140
  className: `nice-api-tester__test-result nice-api-tester__test-result--${s.passed ? "pass" : "fail"}`,
@@ -1148,6 +1154,9 @@ function ct({
1148
1154
  /* @__PURE__ */ e("div", { className: "nice-api-tester__history-list", children: R.slice().reverse().map(({ request: s, response: g }, P) => /* @__PURE__ */ n(
1149
1155
  "div",
1150
1156
  {
1157
+ role: "button",
1158
+ tabIndex: 0,
1159
+ onKeyDown: ge,
1151
1160
  className: "nice-api-tester__history-item",
1152
1161
  onClick: () => T(s),
1153
1162
  children: [
@@ -1175,7 +1184,7 @@ function ct({
1175
1184
  ] })
1176
1185
  ] });
1177
1186
  }
1178
- function Ke(t, a) {
1187
+ function He(t, a) {
1179
1188
  var o, i, r, c, l;
1180
1189
  switch (a.type) {
1181
1190
  case "bearer":
@@ -1189,10 +1198,10 @@ function Ke(t, a) {
1189
1198
  break;
1190
1199
  }
1191
1200
  }
1192
- function He(t) {
1201
+ function Ue(t) {
1193
1202
  return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
1194
1203
  }
1195
- function Ue(t, a) {
1204
+ function Me(t, a) {
1196
1205
  const o = [], i = {
1197
1206
  response: {
1198
1207
  code: a.status,
@@ -1248,7 +1257,7 @@ function Ue(t, a) {
1248
1257
  }
1249
1258
  return o;
1250
1259
  }
1251
- function Te({
1260
+ function ke({
1252
1261
  items: t,
1253
1262
  onChange: a,
1254
1263
  onAdd: o,
@@ -1294,13 +1303,13 @@ function Te({
1294
1303
  /* @__PURE__ */ e("button", { onClick: o, className: "nice-api-tester__add-btn", children: c("apiTester.add", "+ Add") })
1295
1304
  ] });
1296
1305
  }
1297
- function Me({
1306
+ function Le({
1298
1307
  params: t,
1299
1308
  onChange: a,
1300
1309
  onAdd: o
1301
1310
  }) {
1302
1311
  return /* @__PURE__ */ e(
1303
- Te,
1312
+ ke,
1304
1313
  {
1305
1314
  items: t,
1306
1315
  onChange: a,
@@ -1310,13 +1319,13 @@ function Me({
1310
1319
  }
1311
1320
  );
1312
1321
  }
1313
- function Le({
1322
+ function Ve({
1314
1323
  headers: t,
1315
1324
  onChange: a,
1316
1325
  onAdd: o
1317
1326
  }) {
1318
1327
  return /* @__PURE__ */ e(
1319
- Te,
1328
+ ke,
1320
1329
  {
1321
1330
  items: t,
1322
1331
  onChange: a,
@@ -1326,7 +1335,7 @@ function Le({
1326
1335
  }
1327
1336
  );
1328
1337
  }
1329
- function Ve({
1338
+ function Fe({
1330
1339
  body: t,
1331
1340
  bodyTab: a,
1332
1341
  onBodyTabChange: o,
@@ -1359,7 +1368,7 @@ function Ve({
1359
1368
  )
1360
1369
  ] });
1361
1370
  }
1362
- function Fe({
1371
+ function Je({
1363
1372
  auth: t,
1364
1373
  onChange: a
1365
1374
  }) {
@@ -1514,7 +1523,7 @@ function Fe({
1514
1523
  ] })
1515
1524
  ] });
1516
1525
  }
1517
- function Je({
1526
+ function We({
1518
1527
  preRequestScript: t,
1519
1528
  testScript: a,
1520
1529
  onPreRequestChange: o,
@@ -1550,7 +1559,7 @@ function Je({
1550
1559
  ] })
1551
1560
  ] });
1552
1561
  }
1553
- const We = [
1562
+ const Ge = [
1554
1563
  {
1555
1564
  target: ".nice-integration-builder",
1556
1565
  titleKey: "tutorial.integrationBuilder.intro.title",
@@ -1573,7 +1582,7 @@ const We = [
1573
1582
  { type: "webhook", label: "Webhook", icon: "link", category: "Actions" },
1574
1583
  { type: "function", label: "Function", icon: "code", category: "Actions" },
1575
1584
  { type: "error-handler", label: "Error Handler", icon: "warning", category: "Control" }
1576
- ], Ge = {
1585
+ ], Ye = {
1577
1586
  id: "",
1578
1587
  name: "New Flow",
1579
1588
  nodes: [],
@@ -1582,7 +1591,7 @@ const We = [
1582
1591
  triggers: [],
1583
1592
  errorHandling: { strategy: "stop" }
1584
1593
  };
1585
- function lt({
1594
+ function dt({
1586
1595
  flow: t,
1587
1596
  connectors: a = [],
1588
1597
  onChange: o,
@@ -1592,7 +1601,7 @@ function lt({
1592
1601
  tutorial: l
1593
1602
  }) {
1594
1603
  const { t: d } = $(), [p, v] = C(
1595
- t || { ...Ge, id: re() }
1604
+ t || { ...Ye, id: re() }
1596
1605
  ), [u, N] = C(null), [b, y] = C(!0), [T, m] = C("canvas"), [S, w] = C(!1), [A, J] = C(null), [te, z] = C(!1), [M, O] = C(null), [V, G] = C(!1), k = de(null), f = I(
1597
1606
  (h) => {
1598
1607
  v((s) => {
@@ -1609,7 +1618,7 @@ function lt({
1609
1618
  type: h,
1610
1619
  name: ((P = me.find((H) => H.type === h)) == null ? void 0 : P.label) || h,
1611
1620
  position: s,
1612
- config: Ye(h),
1621
+ config: Xe(h),
1613
1622
  inputs: h !== "trigger" ? ["input"] : [],
1614
1623
  outputs: ["output"]
1615
1624
  };
@@ -1619,7 +1628,7 @@ function lt({
1619
1628
  })), N(g);
1620
1629
  },
1621
1630
  [f]
1622
- ), j = I(
1631
+ ), K = I(
1623
1632
  (h) => {
1624
1633
  f((s) => ({
1625
1634
  ...s,
@@ -1665,7 +1674,7 @@ function lt({
1665
1674
  }));
1666
1675
  },
1667
1676
  [f]
1668
- ), K = I(
1677
+ ), j = I(
1669
1678
  (h) => {
1670
1679
  if (h.preventDefault(), !A || !k.current)
1671
1680
  return;
@@ -1715,7 +1724,7 @@ function lt({
1715
1724
  ] }, h.id))
1716
1725
  ] })
1717
1726
  ] }) : void 0, ae = u && T === "canvas" ? /* @__PURE__ */ e(
1718
- Qe,
1727
+ Ze,
1719
1728
  {
1720
1729
  node: u,
1721
1730
  onChange: (h) => F(u.id, h),
@@ -1723,9 +1732,9 @@ function lt({
1723
1732
  }
1724
1733
  ) : void 0;
1725
1734
  return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
1726
- l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(l, We) }) }),
1735
+ l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(l, Ge) }) }),
1727
1736
  /* @__PURE__ */ n(
1728
- ye,
1737
+ fe,
1729
1738
  {
1730
1739
  flush: !0,
1731
1740
  className: `nice-integration-builder ${c}`,
@@ -1777,10 +1786,11 @@ function lt({
1777
1786
  T === "canvas" && /* @__PURE__ */ n(
1778
1787
  "div",
1779
1788
  {
1789
+ role: "presentation",
1780
1790
  ref: k,
1781
1791
  className: `nice-integration-builder__canvas ${S ? "nice-integration-builder__canvas--dragging" : ""}`,
1782
1792
  onDragOver: (h) => h.preventDefault(),
1783
- onDrop: K,
1793
+ onDrop: j,
1784
1794
  onClick: () => N(null),
1785
1795
  children: [
1786
1796
  /* @__PURE__ */ e("svg", { className: "nice-integration-builder__connections", children: p.connections.map((h) => {
@@ -1797,12 +1807,12 @@ function lt({
1797
1807
  ) }, h.id);
1798
1808
  }) }),
1799
1809
  p.nodes.map((h) => /* @__PURE__ */ e(
1800
- Xe,
1810
+ Qe,
1801
1811
  {
1802
1812
  node: h,
1803
1813
  isSelected: (u == null ? void 0 : u.id) === h.id,
1804
1814
  onSelect: () => N(h),
1805
- onDelete: () => j(h.id),
1815
+ onDelete: () => K(h.id),
1806
1816
  onPositionChange: (s) => F(h.id, { position: s }),
1807
1817
  onStartConnection: (s) => {
1808
1818
  z(!0), O({ nodeId: h.id, output: s });
@@ -1822,14 +1832,14 @@ function lt({
1822
1832
  ),
1823
1833
  T === "code" && /* @__PURE__ */ e("div", { className: "nice-integration-builder__code-view", children: /* @__PURE__ */ e("pre", { children: JSON.stringify(p, null, 2) }) }),
1824
1834
  T === "variables" && /* @__PURE__ */ e(
1825
- Ze,
1835
+ et,
1826
1836
  {
1827
1837
  variables: p.variables,
1828
1838
  onChange: (h) => f((s) => ({ ...s, variables: h }))
1829
1839
  }
1830
1840
  ),
1831
1841
  T === "settings" && /* @__PURE__ */ e(
1832
- et,
1842
+ tt,
1833
1843
  {
1834
1844
  errorHandling: p.errorHandling,
1835
1845
  schedule: p.schedule,
@@ -1841,7 +1851,7 @@ function lt({
1841
1851
  )
1842
1852
  ] });
1843
1853
  }
1844
- function Ye(t) {
1854
+ function Xe(t) {
1845
1855
  switch (t) {
1846
1856
  case "http-request":
1847
1857
  return { method: "GET", url: "", headers: {}, body: "" };
@@ -1872,7 +1882,7 @@ return input;` };
1872
1882
  return {};
1873
1883
  }
1874
1884
  }
1875
- function Xe({
1885
+ function Qe({
1876
1886
  node: t,
1877
1887
  isSelected: a,
1878
1888
  onSelect: o,
@@ -1887,7 +1897,7 @@ function Xe({
1887
1897
  y: m.clientY - t.position.y
1888
1898
  }), o());
1889
1899
  };
1890
- return Ne(() => {
1900
+ return we(() => {
1891
1901
  if (!p)
1892
1902
  return;
1893
1903
  const m = (w) => {
@@ -1957,7 +1967,7 @@ function Xe({
1957
1967
  }
1958
1968
  );
1959
1969
  }
1960
- function Qe({
1970
+ function Ze({
1961
1971
  node: t,
1962
1972
  onChange: a,
1963
1973
  onClose: o
@@ -2090,7 +2100,7 @@ function Qe({
2090
2100
  ] })
2091
2101
  ] });
2092
2102
  }
2093
- function Ze({ variables: t, onChange: a }) {
2103
+ function et({ variables: t, onChange: a }) {
2094
2104
  const { t: o } = $(), i = () => {
2095
2105
  a({ ...t, newVariable: "" });
2096
2106
  };
@@ -2133,7 +2143,7 @@ function Ze({ variables: t, onChange: a }) {
2133
2143
  /* @__PURE__ */ e("button", { onClick: i, children: o("integrationBuilder.addVariable", "+ Add Variable") })
2134
2144
  ] });
2135
2145
  }
2136
- function et({
2146
+ function tt({
2137
2147
  errorHandling: t,
2138
2148
  schedule: a,
2139
2149
  onChange: o
@@ -2209,7 +2219,7 @@ function et({
2209
2219
  ] })
2210
2220
  ] });
2211
2221
  }
2212
- const tt = [
2222
+ const it = [
2213
2223
  {
2214
2224
  target: ".nice-webhook-tester",
2215
2225
  titleKey: "tutorial.webhookTester.intro.title",
@@ -2219,16 +2229,16 @@ const tt = [
2219
2229
  placement: "auto"
2220
2230
  }
2221
2231
  ];
2222
- function be(t) {
2232
+ function ve(t) {
2223
2233
  return t ? Object.entries(t).map(([a, o]) => ({ key: a, value: o })) : [];
2224
2234
  }
2225
- function ve(t) {
2235
+ function ye(t) {
2226
2236
  const a = {};
2227
2237
  for (const o of t)
2228
2238
  o.key.trim() !== "" && (a[o.key] = o.value);
2229
2239
  return a;
2230
2240
  }
2231
- async function it(t, a) {
2241
+ async function nt(t, a) {
2232
2242
  var l;
2233
2243
  const o = (l = globalThis.crypto) == null ? void 0 : l.subtle;
2234
2244
  if (!o)
@@ -2242,7 +2252,7 @@ async function it(t, a) {
2242
2252
  ), c = await o.sign("HMAC", r, i.encode(a));
2243
2253
  return [...new Uint8Array(c)].map((d) => d.toString(16).padStart(2, "0")).join("");
2244
2254
  }
2245
- const dt = /* @__PURE__ */ Ce(
2255
+ const pt = /* @__PURE__ */ Se(
2246
2256
  function(a, o) {
2247
2257
  const { t: i } = $(), {
2248
2258
  url: r = "",
@@ -2258,12 +2268,12 @@ const dt = /* @__PURE__ */ Ce(
2258
2268
  style: T,
2259
2269
  id: m,
2260
2270
  "data-testid": S
2261
- } = a, [w, A] = C(r), [J, te] = C(c), [z, M] = C(() => be(l)), [O, V] = C(d), [G, k] = C(""), [f, x] = C(!1), [j, F] = C(null), [R, ie] = C(null), [K, Y] = C(null), ne = de(null), Z = K !== null;
2262
- Ne(() => {
2271
+ } = a, [w, A] = C(r), [J, te] = C(c), [z, M] = C(() => ve(l)), [O, V] = C(d), [G, k] = C(""), [f, x] = C(!1), [K, F] = C(null), [R, ie] = C(null), [j, Y] = C(null), ne = de(null), Z = j !== null;
2272
+ we(() => {
2263
2273
  var _;
2264
2274
  Z && ((_ = ne.current) == null || _.focus());
2265
2275
  }, [Z]);
2266
- const ae = Se(() => {
2276
+ const ae = Ee(() => {
2267
2277
  const _ = /* @__PURE__ */ new Map();
2268
2278
  for (const D of p)
2269
2279
  _.set(D.id, D);
@@ -2271,15 +2281,15 @@ const dt = /* @__PURE__ */ Ce(
2271
2281
  }, [p]), h = (_) => {
2272
2282
  k(_);
2273
2283
  const D = ae.get(_);
2274
- D && (V(D.payload), D.headers && M(be(D.headers)));
2284
+ D && (V(D.payload), D.headers && M(ve(D.headers)));
2275
2285
  }, s = (_, D) => {
2276
2286
  M((q) => q.map((W, X) => X === _ ? { ...W, ...D } : W));
2277
2287
  }, g = async () => {
2278
2288
  x(!0), F(null), ie(null);
2279
2289
  try {
2280
- const _ = ve(z);
2290
+ const _ = ye(z);
2281
2291
  if (u && u.secret) {
2282
- const X = await it(u.secret, O);
2292
+ const X = await nt(u.secret, O);
2283
2293
  _[u.header] = `${u.prefix ?? ""}${X}`;
2284
2294
  }
2285
2295
  const D = typeof performance < "u" ? performance.now() : Date.now(), q = await v({ url: w, method: J ?? "POST", headers: _, body: O }), W = Math.round(
@@ -2292,16 +2302,16 @@ const dt = /* @__PURE__ */ Ce(
2292
2302
  x(!1);
2293
2303
  }
2294
2304
  }, P = () => {
2295
- const _ = K == null ? void 0 : K.trim();
2305
+ const _ = j == null ? void 0 : j.trim();
2296
2306
  !N || !_ || (N({
2297
2307
  id: `sample_${Date.now().toString(36)}`,
2298
2308
  name: _,
2299
2309
  payload: O,
2300
- headers: ve(z)
2310
+ headers: ye(z)
2301
2311
  }), Y(null));
2302
2312
  }, H = R == null ? "" : R.status >= 200 && R.status < 300 ? " nice-webhook-tester__status--ok" : " nice-webhook-tester__status--error", E = "nice-webhook-tester" + (y ? ` ${y}` : "");
2303
2313
  return /* @__PURE__ */ n("div", { ref: o, id: m, className: E, style: T, "data-testid": S, children: [
2304
- b && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(ce, { steps: le(b, tt) }) }),
2314
+ b && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(ce, { steps: le(b, it) }) }),
2305
2315
  /* @__PURE__ */ n("div", { className: "nice-webhook-tester__bar", children: [
2306
2316
  /* @__PURE__ */ e(
2307
2317
  "select",
@@ -2414,7 +2424,7 @@ const dt = /* @__PURE__ */ Ce(
2414
2424
  {
2415
2425
  ref: ne,
2416
2426
  type: "text",
2417
- value: K,
2427
+ value: j,
2418
2428
  placeholder: i("webhookTester.sampleNamePrompt", "Sample name"),
2419
2429
  "aria-label": i("webhookTester.sampleNamePrompt", "Sample name"),
2420
2430
  onChange: (_) => Y(_.target.value),
@@ -2423,7 +2433,7 @@ const dt = /* @__PURE__ */ Ce(
2423
2433
  }
2424
2434
  }
2425
2435
  ),
2426
- /* @__PURE__ */ e("button", { type: "button", onClick: P, disabled: !K.trim(), children: i("save", "Save") }),
2436
+ /* @__PURE__ */ e("button", { type: "button", onClick: P, disabled: !j.trim(), children: i("save", "Save") }),
2427
2437
  /* @__PURE__ */ e(
2428
2438
  "button",
2429
2439
  {
@@ -2450,7 +2460,7 @@ const dt = /* @__PURE__ */ Ce(
2450
2460
  }
2451
2461
  )
2452
2462
  ] }),
2453
- j && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__error", children: j }),
2463
+ K && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__error", children: K }),
2454
2464
  R && /* @__PURE__ */ n("div", { className: "nice-webhook-tester__response", children: [
2455
2465
  /* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
2456
2466
  i("webhookTester.response", "Response"),
@@ -2468,8 +2478,8 @@ const dt = /* @__PURE__ */ Ce(
2468
2478
  }
2469
2479
  );
2470
2480
  export {
2471
- ot as NiceAPIDesigner,
2472
- ct as NiceAPITester,
2473
- lt as NiceIntegrationBuilder,
2474
- dt as NiceWebhookTester
2481
+ ct as NiceAPIDesigner,
2482
+ lt as NiceAPITester,
2483
+ dt as NiceIntegrationBuilder,
2484
+ pt as NiceWebhookTester
2475
2485
  };