@addsign/moje-agenda-shared-lib 0.0.16 → 0.0.19

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,8 +1,9 @@
1
- import { jsxs as C, jsx as n } from "react/jsx-runtime";
2
- import { useRef as B, useEffect as p, useState as m } from "react";
1
+ import { jsxs as N, jsx as n } from "react/jsx-runtime";
2
+ import { useRef as F, useEffect as p, useState as m } from "react";
3
3
  import '../../assets/tailwind.css';/* empty css */
4
- import { useFederationContext as K } from "../../contexts/FederationContext.js";
5
- import { a as _, b as ee, M as te } from "../../index-CvL09ndn.js";
4
+ import { i as K, j as _, c as ee } from "../../index-CO5g84CR.js";
5
+ import "../../contexts/FederationContext.js";
6
+ import { useFederationContext as te } from "../../contexts/useFederationContext.js";
6
7
  function re(e) {
7
8
  for (var t = [], r = 1; r < arguments.length; r++)
8
9
  t[r - 1] = arguments[r];
@@ -15,90 +16,98 @@ function ae(e) {
15
16
  }
16
17
  var le = ["mousedown", "touchstart"], se = function(e, t, r) {
17
18
  r === void 0 && (r = le);
18
- var d = B(t);
19
+ var d = F(t);
19
20
  p(function() {
20
21
  d.current = t;
21
22
  }, [t]), p(function() {
22
- for (var o = function(u) {
23
+ for (var o = function(f) {
23
24
  var c = e.current;
24
- c && !c.contains(u.target) && d.current(u);
25
- }, a = 0, f = r; a < f.length; a++) {
26
- var h = f[a];
25
+ c && !c.contains(f.target) && d.current(f);
26
+ }, a = 0, u = r; a < u.length; a++) {
27
+ var h = u[a];
27
28
  re(document, h, o);
28
29
  }
29
30
  return function() {
30
- for (var u = 0, c = r; u < c.length; u++) {
31
- var N = c[u];
32
- ae(document, N, o);
31
+ for (var f = 0, c = r; f < c.length; f++) {
32
+ var k = c[f];
33
+ ae(document, k, o);
33
34
  }
34
35
  };
35
36
  }, [r, e]);
36
37
  };
37
- const he = ({
38
+ const me = ({
38
39
  label: e,
39
40
  name: t,
40
41
  required: r,
41
42
  disabled: d,
42
43
  description: o,
43
44
  fetchUrl: a,
44
- valueKey: f,
45
+ valueKey: u,
45
46
  labelKey: h,
46
- onChange: u,
47
+ onChange: f,
47
48
  onFocus: c,
48
- onBlur: N,
49
- placeholder: A,
49
+ onBlur: k,
50
+ placeholder: D,
50
51
  serverSearch: v = !1,
51
- value: $,
52
- initOptions: F,
53
- showId: L
52
+ value: L,
53
+ initOptions: R,
54
+ showId: C
54
55
  }) => {
55
- var j, V;
56
- const [k, w] = m(""), [J, E] = m(!1), [x, R] = m([]), [M, b] = m(-1), [P, O] = m(
56
+ var T, V;
57
+ const [E, w] = m(""), [J, M] = m(!1), [x, A] = m([]), [O, b] = m(-1), [P, Q] = m(
57
58
  null
58
- ), [g, y] = m([]), X = B(null), D = B(null), q = K(), [Q, z] = m(!1), [H] = m({});
59
+ ), [g, y] = m([]), X = F(null), j = F(null), S = te(), [B, q] = m(!1), [z] = m({});
59
60
  p(() => {
60
61
  a && (async () => {
61
- E(!0), console.log(
62
+ M(!0), console.log(
62
63
  "%csrcsharedAutocompleteSearchBar.tsx:77 fetchUrl, value",
63
64
  "color: #007acc;",
64
65
  a
65
66
  );
66
- const { data: s } = await q.apiClient.get(a || "");
67
- R(
67
+ const { data: s } = await S.apiClient.get(a || "");
68
+ A(
68
69
  s.map((i) => ({
69
- value: i[f],
70
- label: i[h] + (L ? " (" + i[f] + ")" : "")
70
+ value: i[u],
71
+ label: i[h] + (C ? " (" + i[u] + ")" : "")
71
72
  }))
72
- ), E(!1);
73
+ ), M(!1);
73
74
  })();
74
- }, [a]), p(() => {
75
- F && R(F);
76
- }, [F]), p(() => {
77
- if ($ && x) {
78
- const l = x.find((s) => s.value == $);
79
- l && (w(l.label), O(l));
75
+ }, [a, u, S.apiClient, h, C]), p(() => {
76
+ R && A(R);
77
+ }, [R]), p(() => {
78
+ if (L && x) {
79
+ const l = x.find((s) => s.value == L);
80
+ l && (w(l.label), Q(l));
80
81
  }
81
- }, [$, x]), p(() => {
82
+ }, [L, x]), p(() => {
82
83
  v && (async () => {
83
- E(!0);
84
- const { data: s } = await q.apiClient.get(a + k);
85
- R(
84
+ M(!0);
85
+ const { data: s } = await S.apiClient.get(a + E);
86
+ A(
86
87
  s.map((i) => ({
87
- value: i[f],
88
- label: i[h] + (L ? " (" + i[f] + ")" : "")
88
+ value: i[u],
89
+ label: i[h] + (C ? " (" + i[u] + ")" : "")
89
90
  }))
90
91
  ), y(
91
92
  s.map((i) => ({
92
- value: i[f],
93
- label: i[h] + (L ? " (" + i[f] + ")" : "")
93
+ value: i[u],
94
+ label: i[h] + (C ? " (" + i[u] + ")" : "")
94
95
  }))
95
- ), E(!1);
96
+ ), M(!1);
96
97
  })();
97
- }, [k, v, f, h, a]), se(D, () => {
98
- y([]), P || (w(""), u(null)), S();
98
+ }, [
99
+ E,
100
+ v,
101
+ u,
102
+ h,
103
+ a,
104
+ S.apiClient,
105
+ C
106
+ ]), se(j, () => {
107
+ y([]), P || (w(""), f(null)), $();
99
108
  });
100
109
  const Y = (l) => {
101
- w(l.target.value), O(null), b(-1), y(
110
+ w(l.target.value), Q(null), b(-1), y(
102
111
  x.filter(
103
112
  (s) => {
104
113
  var i, W, G;
@@ -107,38 +116,38 @@ const he = ({
107
116
  )
108
117
  );
109
118
  }, Z = () => {
110
- console.log("handleFocus query", k), z(!0), c(), y(
119
+ console.log("handleFocus query", E), q(!0), c(), y(
111
120
  x
112
121
  /*.filter((option) =>
113
122
  option.label.toLowerCase().includes(query.toLowerCase()),
114
123
  ),*/
115
124
  );
116
- }, I = () => {
125
+ }, U = () => {
117
126
  console.log(
118
127
  "%csrcsharedAutocompleteSearchBar.tsx:95 handleClearQuery",
119
128
  "color: #007acc;"
120
- ), w(""), u(null), O(null), setTimeout(() => {
129
+ ), w(""), f(null), Q(null), setTimeout(() => {
121
130
  b(-1), y(x);
122
131
  }, 1e3);
123
- }, U = (l) => {
132
+ }, I = (l) => {
124
133
  l.key === "ArrowUp" && g.length > 0 ? b(
125
134
  (s) => s > 0 ? s - 1 : g.length - 1
126
135
  ) : l.key === "ArrowDown" && g.length > 0 ? b(
127
136
  (s) => s < g.length - 1 ? s + 1 : 0
128
- ) : l.key === "Enter" && M !== -1 ? T(g[M]) : l.key === "Escape" && M !== -1 && S();
129
- }, T = (l) => {
130
- w(l.label), O(l), b(-1), u(l.value), S();
131
- }, S = () => {
132
- y([]), N(), z(!1);
137
+ ) : l.key === "Enter" && O !== -1 ? H(g[O]) : l.key === "Escape" && O !== -1 && $();
138
+ }, H = (l) => {
139
+ w(l.label), Q(l), b(-1), f(l.value), $();
140
+ }, $ = () => {
141
+ y([]), k(), q(!1);
133
142
  };
134
- return /* @__PURE__ */ C("div", { className: "w-full min-h-20 flex-col justify-start items-start gap-1.5 inline-flex", children: [
135
- /* @__PURE__ */ C(
143
+ return /* @__PURE__ */ N("div", { className: "w-full min-h-20 flex-col justify-start items-start gap-1.5 inline-flex", children: [
144
+ /* @__PURE__ */ N(
136
145
  "div",
137
146
  {
138
147
  className: "self-stretch min-h-14 flex-col justify-start items-start gap-1.5 flex relative",
139
- ref: D,
148
+ ref: j,
140
149
  children: [
141
- /* @__PURE__ */ C(
150
+ /* @__PURE__ */ N(
142
151
  "label",
143
152
  {
144
153
  className: "text-slate-700 text-sm leading-tight font-medium",
@@ -154,22 +163,22 @@ const he = ({
154
163
  "div",
155
164
  {
156
165
  className: `self-stretch px-3 py-1.5 rounded-lg justify-start items-center gap-2 inline-flex outline-none border
157
- ${Q ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""}
158
- ${Q && ((j = H[t]) != null && j.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""}
159
- ${!Q && ((V = H[t]) != null && V.message) ? "border-red-200" : ""}
166
+ ${B ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""}
167
+ ${B && ((T = z[t]) != null && T.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""}
168
+ ${!B && ((V = z[t]) != null && V.message) ? "border-red-200" : ""}
160
169
  ${d ? "bg-gray-100" : "bg-transparent"}`,
161
170
  children: /* @__PURE__ */ n("div", { className: "Content grow shrink basis-0 min-h-5 xl:min-h-8 justify-start items-start gap-2 flex relative flex-col w-full mx-auto", children: /* @__PURE__ */ n(
162
171
  oe,
163
172
  {
164
- value: k,
173
+ value: E,
165
174
  onChange: Y,
166
- onKeyDown: U,
175
+ onKeyDown: I,
167
176
  onFocus: Z,
168
- clearQuery: I,
177
+ clearQuery: U,
169
178
  inputRef: X,
170
- placeholder: A,
171
- isFocused: Q,
172
- onBlur: S,
179
+ placeholder: D,
180
+ isFocused: B,
181
+ onBlur: $,
173
182
  isLoading: J
174
183
  }
175
184
  ) })
@@ -179,8 +188,8 @@ const he = ({
179
188
  ne,
180
189
  {
181
190
  options: g,
182
- selectedOptionIndex: M,
183
- handleOptionClick: T
191
+ selectedOptionIndex: O,
192
+ handleOptionClick: H
184
193
  }
185
194
  )
186
195
  ]
@@ -193,7 +202,7 @@ const he = ({
193
202
  selectedOptionIndex: t,
194
203
  handleOptionClick: r
195
204
  }) => {
196
- const d = B(null);
205
+ const d = F(null);
197
206
  return p(() => {
198
207
  var o;
199
208
  if (t >= 0 && t < e.length) {
@@ -226,11 +235,11 @@ const he = ({
226
235
  onFocus: d,
227
236
  onBlur: o,
228
237
  inputRef: a,
229
- placeholder: f,
238
+ placeholder: u,
230
239
  clearQuery: h,
231
- isFocused: u,
240
+ isFocused: f,
232
241
  isLoading: c
233
- }) => /* @__PURE__ */ C("div", { className: "relative flex items-center w-full sharedResource", children: [
242
+ }) => /* @__PURE__ */ N("div", { className: "relative flex items-center w-full sharedResource", children: [
234
243
  /* @__PURE__ */ n(
235
244
  "input",
236
245
  {
@@ -241,11 +250,11 @@ const he = ({
241
250
  onKeyDown: r,
242
251
  onFocus: d,
243
252
  ref: a,
244
- placeholder: f,
253
+ placeholder: u,
245
254
  disabled: c
246
255
  }
247
256
  ),
248
- c && /* @__PURE__ */ n("div", { className: "loader absolute right-0 text-gray-500", children: /* @__PURE__ */ C(
257
+ c && /* @__PURE__ */ n("div", { className: "loader absolute right-0 text-gray-500", children: /* @__PURE__ */ N(
249
258
  "svg",
250
259
  {
251
260
  className: "animate-spin h-5 w-5",
@@ -275,15 +284,15 @@ const he = ({
275
284
  ]
276
285
  }
277
286
  ) }),
278
- u && !c && /* @__PURE__ */ n(
279
- _,
287
+ f && !c && /* @__PURE__ */ n(
288
+ K,
280
289
  {
281
290
  className: "material-icons absolute right-0 cursor-pointer text-gray-500",
282
291
  onClick: o
283
292
  }
284
293
  ),
285
- !u && !c && /* @__PURE__ */ n(
286
- ee,
294
+ !f && !c && /* @__PURE__ */ n(
295
+ _,
287
296
  {
288
297
  className: "material-icons absolute right-0 cursor-pointer text-gray-500",
289
298
  onClick: () => {
@@ -293,7 +302,7 @@ const he = ({
293
302
  }
294
303
  ),
295
304
  e && !c && /* @__PURE__ */ n(
296
- te,
305
+ ee,
297
306
  {
298
307
  className: "material-icons absolute right-10 cursor-pointer text-gray-500",
299
308
  onClick: () => {
@@ -303,5 +312,5 @@ const he = ({
303
312
  )
304
313
  ] });
305
314
  export {
306
- he as default
315
+ me as default
307
316
  };
@@ -1,49 +1,50 @@
1
1
  import { jsxs as o, jsx as t, Fragment as x } from "react/jsx-runtime";
2
- import { useState as M, useRef as X, useEffect as Y } from "react";
3
- import { M as Z } from "../../index-CvL09ndn.js";
2
+ import { useState as T, useRef as Y, useEffect as Z } from "react";
3
+ import { c as _ } from "../../index-CO5g84CR.js";
4
4
  import '../../assets/tailwind.css';/* empty css */
5
- import { useFederationContext as _ } from "../../contexts/FederationContext.js";
5
+ import "../../contexts/FederationContext.js";
6
+ import { useFederationContext as K } from "../../contexts/useFederationContext.js";
6
7
  const ae = ({
7
8
  label: b,
8
9
  name: r,
9
- type: p,
10
+ type: F,
10
11
  register: y,
11
12
  disabled: n,
12
13
  errors: u = {},
13
- required: R,
14
- clearable: H,
14
+ required: E,
15
+ clearable: G,
15
16
  value: l,
16
17
  description: w,
17
18
  onInputChange: i,
18
- options: a,
19
+ options: s,
19
20
  placeholder: v,
20
21
  children: C,
21
22
  fetchUrl: N,
22
- valueKey: T,
23
- labelKey: E,
24
- maxLength: G
23
+ valueKey: B,
24
+ labelKey: O,
25
+ maxLength: q
25
26
  }) => {
26
- var j, A, S, $, L;
27
- const [k, s] = M(!1), [F, B] = M(a), O = X(null), {
28
- ref: q = O,
27
+ var $, L, R, H, M;
28
+ const [k, a] = T(!1), [p, j] = T(s), A = Y(null), {
29
+ ref: z = A,
29
30
  onBlur: d = () => {
30
31
  },
31
32
  ...f
32
- } = y ? y(r) : {}, z = (j = _()) == null ? void 0 : j.apiClient, c = q || O, D = () => {
33
+ } = y ? y(r) : {}, S = ($ = K()) == null ? void 0 : $.apiClient, c = z || A, D = () => {
33
34
  c.current && c.current.focus();
34
35
  }, J = (e) => {
35
- const g = Array.from(
36
+ const m = Array.from(
36
37
  e.target.selectedOptions,
37
- (m) => m.value
38
+ (g) => g.value
38
39
  );
39
40
  i({
40
41
  ...e,
41
42
  target: {
42
- value: g,
43
+ value: m,
43
44
  name: e.target.name
44
45
  }
45
46
  });
46
- }, K = (e) => {
47
+ }, P = (e) => {
47
48
  i({
48
49
  ...e,
49
50
  target: {
@@ -51,7 +52,7 @@ const ae = ({
51
52
  name: e.target.name
52
53
  }
53
54
  });
54
- }, P = (e) => {
55
+ }, Q = (e) => {
55
56
  i({
56
57
  ...e,
57
58
  target: {
@@ -60,21 +61,21 @@ const ae = ({
60
61
  }
61
62
  });
62
63
  };
63
- Y(() => {
64
- N && (async (g) => {
65
- const { data: m } = await z.get(g), V = typeof m[0] == "number", W = m.map((h) => V ? { value: h, label: h.toString() } : {
66
- value: h[T || "id"],
67
- label: h[E || "name"]
64
+ Z(() => {
65
+ N && (async (m) => {
66
+ const { data: g } = await S.get(m), W = typeof g[0] == "number", X = g.map((h) => W ? { value: h, label: h.toString() } : {
67
+ value: h[B || "id"],
68
+ label: h[O || "name"]
68
69
  });
69
- B([
70
+ j([
70
71
  { value: null, label: " " },
71
72
  // Add an empty option as the first item
72
- ...W
73
+ ...X
73
74
  ]);
74
- })(N), a && B(a);
75
- }, [N, a]);
76
- const Q = () => {
77
- switch (p) {
75
+ })(N), s && j(s);
76
+ }, [N, s, S, B, O]);
77
+ const V = () => {
78
+ switch (F) {
78
79
  case "select":
79
80
  return /* @__PURE__ */ t(x, { children: /* @__PURE__ */ o(
80
81
  "select",
@@ -86,13 +87,13 @@ const ae = ({
86
87
  ...f,
87
88
  ref: c,
88
89
  onChange: i,
89
- onFocus: () => s(!0),
90
+ onFocus: () => a(!0),
90
91
  onBlur: (e) => {
91
- d(e), s(!1);
92
+ d(e), a(!1);
92
93
  },
93
94
  children: [
94
95
  v && /* @__PURE__ */ t("option", { label: v }),
95
- F == null ? void 0 : F.map((e) => /* @__PURE__ */ t(
96
+ p == null ? void 0 : p.map((e) => /* @__PURE__ */ t(
96
97
  "option",
97
98
  {
98
99
  value: e.value ? e.value : void 0,
@@ -115,11 +116,11 @@ const ae = ({
115
116
  ...f,
116
117
  ref: c,
117
118
  onChange: J,
118
- onFocus: () => s(!0),
119
+ onFocus: () => a(!0),
119
120
  onBlur: (e) => {
120
- d(e), s(!1);
121
+ d(e), a(!1);
121
122
  },
122
- children: a == null ? void 0 : a.map((e) => /* @__PURE__ */ t(
123
+ children: s == null ? void 0 : s.map((e) => /* @__PURE__ */ t(
123
124
  "option",
124
125
  {
125
126
  value: e.value ? e.value : void 0,
@@ -130,7 +131,7 @@ const ae = ({
130
131
  }
131
132
  ) });
132
133
  case "radioGroup":
133
- return /* @__PURE__ */ t("div", { className: "flex flex-col", children: a == null ? void 0 : a.map((e, g) => /* @__PURE__ */ o(
134
+ return /* @__PURE__ */ t("div", { className: "flex flex-col", children: s == null ? void 0 : s.map((e, m) => /* @__PURE__ */ o(
134
135
  "label",
135
136
  {
136
137
  className: "inline-flex items-center space-x-2 my-2",
@@ -151,7 +152,7 @@ const ae = ({
151
152
  /* @__PURE__ */ t("span", { className: "text-gray-900 text-sm font-normal leading-tight", children: e.label })
152
153
  ]
153
154
  },
154
- g
155
+ m
155
156
  )) });
156
157
  case "textarea":
157
158
  return /* @__PURE__ */ t(
@@ -165,10 +166,10 @@ const ae = ({
165
166
  ...f,
166
167
  ref: c,
167
168
  onChange: i,
168
- onFocus: () => s(!0),
169
- maxLength: G || 4e3,
169
+ onFocus: () => a(!0),
170
+ maxLength: q || 4e3,
170
171
  onBlur: (e) => {
171
- d(e), s(!1);
172
+ d(e), a(!1);
172
173
  }
173
174
  }
174
175
  );
@@ -184,10 +185,10 @@ const ae = ({
184
185
  disabled: n,
185
186
  ...f,
186
187
  ref: c,
187
- onChange: K,
188
- onFocus: () => s(!0),
188
+ onChange: P,
189
+ onFocus: () => a(!0),
189
190
  onBlur: (e) => {
190
- d(e), s(!1);
191
+ d(e), a(!1);
191
192
  }
192
193
  }
193
194
  ),
@@ -201,14 +202,14 @@ const ae = ({
201
202
  id: r,
202
203
  readOnly: n,
203
204
  value: l,
204
- type: p,
205
+ type: F,
205
206
  ...f,
206
207
  ref: c,
207
208
  placeholder: v,
208
209
  onChange: i,
209
- onFocus: () => s(!0),
210
+ onFocus: () => a(!0),
210
211
  onBlur: (e) => {
211
- d(e), s(!1);
212
+ d(e), a(!1);
212
213
  }
213
214
  }
214
215
  ) });
@@ -224,24 +225,24 @@ const ae = ({
224
225
  children: [
225
226
  b,
226
227
  " ",
227
- R ? "*" : ""
228
+ E ? "*" : ""
228
229
  ]
229
230
  }
230
231
  ),
231
232
  /* @__PURE__ */ t(
232
233
  "div",
233
234
  {
234
- className: `self-stretch px-3 py-2 rounded-lg justify-start items-center gap-2 inline-flex outline-none border ${k && !((A = u[r]) != null && A.message) ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""} ${k && ((S = u[r]) != null && S.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""} ${!k && (($ = u[r]) != null && $.message) ? "border-red-200" : ""} ${n ? "bg-gray-100" : "bg-transparent"}`,
235
+ className: `self-stretch px-3 py-2 rounded-lg justify-start items-center gap-2 inline-flex outline-none border ${k && !((L = u[r]) != null && L.message) ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""} ${k && ((R = u[r]) != null && R.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""} ${!k && ((H = u[r]) != null && H.message) ? "border-red-200" : ""} ${n ? "bg-gray-100" : "bg-transparent"}`,
235
236
  children: /* @__PURE__ */ o("div", { className: "flex relative grow shrink basis-0 min-h-5 xl:min-h-[32px] justify-start items-stretch gap-2 max-w-full", children: [
236
- Q(),
237
+ V(),
237
238
  C && /* @__PURE__ */ t("div", { onClick: D, children: C }),
238
- H && l && /* @__PURE__ */ t(Z, { onClick: P })
239
+ G && l && /* @__PURE__ */ t(_, { onClick: Q })
239
240
  ] })
240
241
  }
241
242
  )
242
243
  ] }),
243
244
  w && /* @__PURE__ */ t("div", { className: "HintText self-stretch text-slate-600 text-sm font-normal leading-tight", children: w }),
244
- u[r] && /* @__PURE__ */ t("div", { className: "HintText self-stretch text-red-600 text-sm font-normal leading-tight", children: (L = u[r]) == null ? void 0 : L.message })
245
+ u[r] && /* @__PURE__ */ t("div", { className: "HintText self-stretch text-red-600 text-sm font-normal leading-tight", children: (M = u[r]) == null ? void 0 : M.message })
245
246
  ] });
246
247
  };
247
248
  export {
@@ -0,0 +1,12 @@
1
+ import { IPositionEmployee } from '../../main';
2
+
3
+ interface IPositionsSelectorSingleProps {
4
+ label: string;
5
+ name: string;
6
+ onInputChange: (e: any) => void;
7
+ initPositionEmployee?: IPositionEmployee;
8
+ disabled?: boolean;
9
+ initDepartmentId?: string;
10
+ }
11
+ declare function PositionsSelectorSingle({ label, name, onInputChange, initPositionEmployee, disabled, initDepartmentId, }: IPositionsSelectorSingleProps): import("react/jsx-runtime").JSX.Element;
12
+ export default PositionsSelectorSingle;