@addsign/moje-agenda-shared-lib 0.0.28 → 0.0.30

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.
Files changed (39) hide show
  1. package/dist/assets/tailwind.css +1484 -1
  2. package/dist/components/Button.js +24 -21
  3. package/dist/components/Button.js.map +1 -0
  4. package/dist/components/Calendar.js +89 -57
  5. package/dist/components/Calendar.js.map +1 -0
  6. package/dist/components/ConfirmationModalDialog.js +52 -47
  7. package/dist/components/ConfirmationModalDialog.js.map +1 -0
  8. package/dist/components/DataTable.js +211 -145
  9. package/dist/components/DataTable.js.map +1 -0
  10. package/dist/components/Spinner.js +9 -8
  11. package/dist/components/Spinner.js.map +1 -0
  12. package/dist/components/form/AutocompleteSearchBar.js +323 -239
  13. package/dist/components/form/AutocompleteSearchBar.js.map +1 -0
  14. package/dist/components/form/FormField.js +171 -142
  15. package/dist/components/form/FormField.js.map +1 -0
  16. package/dist/components/form/PositionsSelectorSingle.js +143 -113
  17. package/dist/components/form/PositionsSelectorSingle.js.map +1 -0
  18. package/dist/components/layout/PageTitle.js +9 -8
  19. package/dist/components/layout/PageTitle.js.map +1 -0
  20. package/dist/components/layout/SectionTitle.js +9 -8
  21. package/dist/components/layout/SectionTitle.js.map +1 -0
  22. package/dist/contexts/FederationContext.js +12 -8
  23. package/dist/contexts/FederationContext.js.map +1 -0
  24. package/dist/contexts/useFederationContext.js +5 -4
  25. package/dist/contexts/useFederationContext.js.map +1 -0
  26. package/dist/iconBase-BY_L6Cb_.js +144 -0
  27. package/dist/iconBase-BY_L6Cb_.js.map +1 -0
  28. package/dist/index-C0yNf1cc.js +48 -0
  29. package/dist/index-C0yNf1cc.js.map +1 -0
  30. package/dist/main.js +29 -28
  31. package/dist/main.js.map +1 -0
  32. package/dist/types.d.ts +7 -3
  33. package/dist/types.js +1 -0
  34. package/dist/types.js.map +1 -0
  35. package/dist/utils/getFullName.js +9 -3
  36. package/dist/utils/getFullName.js.map +1 -0
  37. package/package.json +1 -1
  38. package/dist/iconBase-DkR9t2l_.js +0 -117
  39. package/dist/index-CO5g84CR.js +0 -47
@@ -1,204 +1,233 @@
1
- import { jsxs as r, Fragment as z, jsx as t } from "react/jsx-runtime";
2
- import { useState as s, useEffect as h } from "react";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
3
  import '../../assets/tailwind.css';/* empty css */
4
- import m from "../Button.js";
5
- import F from "./AutocompleteSearchBar.js";
6
- import C from "./FormField.js";
7
- import M from "../layout/SectionTitle.js";
8
- import { h as B } from "../../index-CO5g84CR.js";
4
+ import Button from "../Button.js";
5
+ import AutocompleteSearchBar from "./AutocompleteSearchBar.js";
6
+ import FormField from "./FormField.js";
7
+ import SectionTitle from "../layout/SectionTitle.js";
8
+ import { h as MdCheck } from "../../index-C0yNf1cc.js";
9
9
  import "../../contexts/FederationContext.js";
10
- import { useFederationContext as K } from "../../contexts/useFederationContext.js";
11
- import { getFullName as v } from "../../utils/getFullName.js";
12
- import { G as O } from "../../iconBase-DkR9t2l_.js";
13
- function T(d) {
14
- return O({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "g", attr: { id: "Edit" }, child: [{ tag: "g", attr: {}, child: [{ tag: "path", attr: { d: "M3.548,20.938h16.9a.5.5,0,0,0,0-1H3.548a.5.5,0,0,0,0,1Z" }, child: [] }, { tag: "path", attr: { d: "M9.71,17.18a2.587,2.587,0,0,0,1.12-.65l9.54-9.54a1.75,1.75,0,0,0,0-2.47l-.94-.93a1.788,1.788,0,0,0-2.47,0L7.42,13.12a2.473,2.473,0,0,0-.64,1.12L6.04,17a.737.737,0,0,0,.19.72.767.767,0,0,0,.53.22Zm.41-1.36a1.468,1.468,0,0,1-.67.39l-.97.26-1-1,.26-.97a1.521,1.521,0,0,1,.39-.67l.38-.37,1.99,1.99Zm1.09-1.08L9.22,12.75l6.73-6.73,1.99,1.99Zm8.45-8.45L18.65,7.3,16.66,5.31l1.01-1.02a.748.748,0,0,1,1.06,0l.93.94A.754.754,0,0,1,19.66,6.29Z" }, child: [] }] }] }] })(d);
10
+ import { useFederationContext } from "../../contexts/useFederationContext.js";
11
+ import { getFullName } from "../../utils/getFullName.js";
12
+ import { G as GenIcon } from "../../iconBase-BY_L6Cb_.js";
13
+ function CiEdit(props) {
14
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "g", "attr": { "id": "Edit" }, "child": [{ "tag": "g", "attr": {}, "child": [{ "tag": "path", "attr": { "d": "M3.548,20.938h16.9a.5.5,0,0,0,0-1H3.548a.5.5,0,0,0,0,1Z" }, "child": [] }, { "tag": "path", "attr": { "d": "M9.71,17.18a2.587,2.587,0,0,0,1.12-.65l9.54-9.54a1.75,1.75,0,0,0,0-2.47l-.94-.93a1.788,1.788,0,0,0-2.47,0L7.42,13.12a2.473,2.473,0,0,0-.64,1.12L6.04,17a.737.737,0,0,0,.19.72.767.767,0,0,0,.53.22Zm.41-1.36a1.468,1.468,0,0,1-.67.39l-.97.26-1-1,.26-.97a1.521,1.521,0,0,1,.39-.67l.38-.37,1.99,1.99Zm1.09-1.08L9.22,12.75l6.73-6.73,1.99,1.99Zm8.45-8.45L18.65,7.3,16.66,5.31l1.01-1.02a.748.748,0,0,1,1.06,0l.93.94A.754.754,0,0,1,19.66,6.29Z" }, "child": [] }] }] }] })(props);
15
15
  }
16
- function X({
17
- label: d,
18
- name: u,
19
- onInputChange: k,
20
- initPositionEmployee: l,
21
- disabled: x,
22
- initDepartmentId: p
16
+ function PositionsSelectorSingle({
17
+ label,
18
+ name,
19
+ onInputChange,
20
+ initPositionEmployee,
21
+ disabled,
22
+ initDepartmentId
23
23
  }) {
24
- var b;
25
- const [S, c] = s(!1), [i, f] = s(""), [j, Z] = s([]), [a, g] = s(), [n, w] = s(), N = (b = K()) == null ? void 0 : b.apiClient;
26
- h(() => {
27
- const e = (o) => {
28
- o.key === "Escape" && c(!1);
24
+ var _a;
25
+ const [isModalOpen, setModalOpen] = useState(false);
26
+ const [department, setDepartment] = useState("");
27
+ const [positions, setPositions] = useState([]);
28
+ const [selectedPositionEmployee, setSelectedPositionEmployee] = useState();
29
+ const [storedPositionEmployee, setStoredPositionEmployee] = useState();
30
+ const apiClient = (_a = useFederationContext()) == null ? void 0 : _a.apiClient;
31
+ useEffect(() => {
32
+ const handleKeyDown = (event) => {
33
+ if (event.key === "Escape") {
34
+ setModalOpen(false);
35
+ }
29
36
  };
30
- return window.addEventListener("keydown", e), () => {
31
- window.removeEventListener("keydown", e);
37
+ window.addEventListener("keydown", handleKeyDown);
38
+ return () => {
39
+ window.removeEventListener("keydown", handleKeyDown);
32
40
  };
33
- }, []), h(() => {
34
- l && (g(l), w(l), f(l.departmentId));
35
- }, [l]), h(() => {
36
- p && !l && f(p);
37
- }, [p, l]);
38
- const I = (e) => {
39
- k({
40
- target: { name: u, value: e || null }
41
- }), w(e), c(!1);
42
- }, y = (e) => {
41
+ }, []);
42
+ useEffect(() => {
43
+ if (initPositionEmployee) {
44
+ setSelectedPositionEmployee(initPositionEmployee);
45
+ setStoredPositionEmployee(initPositionEmployee);
46
+ setDepartment(initPositionEmployee.departmentId);
47
+ }
48
+ }, [initPositionEmployee]);
49
+ useEffect(() => {
50
+ if (initDepartmentId && !initPositionEmployee) {
51
+ setDepartment(initDepartmentId);
52
+ }
53
+ }, [initDepartmentId, initPositionEmployee]);
54
+ const handleSave = (selectedPositionEmployee2) => {
55
+ onInputChange({
56
+ target: { name, value: selectedPositionEmployee2 || null }
57
+ });
58
+ setStoredPositionEmployee(selectedPositionEmployee2);
59
+ setModalOpen(false);
60
+ };
61
+ const handleSelectedPositionEmployee = (position) => {
43
62
  console.log(
44
63
  "%csrcsharedPositionsSelectorSingle.tsx:54 position",
45
64
  "color: #007acc;",
46
- e,
47
- a,
48
- e.id == (a == null ? void 0 : a.id)
49
- ), !a || e.id !== (a == null ? void 0 : a.id) ? g(e) : g(void 0);
50
- }, L = (e) => {
51
- console.log("%csrcsharedTransferListModal.tsx:109 e", "color: #007acc;", e), f(e);
65
+ position,
66
+ selectedPositionEmployee,
67
+ position.id == (selectedPositionEmployee == null ? void 0 : selectedPositionEmployee.id)
68
+ );
69
+ if (!selectedPositionEmployee || position.id !== (selectedPositionEmployee == null ? void 0 : selectedPositionEmployee.id)) {
70
+ setSelectedPositionEmployee(position);
71
+ } else {
72
+ setSelectedPositionEmployee(void 0);
73
+ }
52
74
  };
53
- return h(() => {
54
- i && N.get(
55
- "os/positions/employees?maxResults=1000&departmentId=" + i
56
- ).then((e) => {
57
- var o;
58
- Z((o = e.data) == null ? void 0 : o.content);
59
- }).catch((e) => {
60
- console.error(
61
- "There was an error fetching positions/employees",
62
- e
63
- );
64
- });
65
- }, [N, i]), /* @__PURE__ */ r(z, { children: [
66
- /* @__PURE__ */ r("div", { className: "", children: [
67
- /* @__PURE__ */ r("p", { className: "text-slate-700 text-sm leading-tight font-medium mb-2", children: [
68
- d,
75
+ const handleDepartmentChange = (e) => {
76
+ console.log("%csrcsharedTransferListModal.tsx:109 e", "color: #007acc;", e);
77
+ setDepartment(e);
78
+ };
79
+ useEffect(() => {
80
+ if (department && isModalOpen) {
81
+ apiClient.get(
82
+ "os/positions/employees?maxResults=1000&departmentId=" + department
83
+ ).then((response) => {
84
+ var _a2;
85
+ setPositions((_a2 = response.data) == null ? void 0 : _a2.content);
86
+ }).catch((error) => {
87
+ console.error(
88
+ "There was an error fetching positions/employees",
89
+ error
90
+ );
91
+ });
92
+ }
93
+ }, [apiClient, department, isModalOpen]);
94
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
95
+ /* @__PURE__ */ jsxs("div", { className: "", children: [
96
+ /* @__PURE__ */ jsxs("p", { className: "text-slate-700 text-sm leading-tight font-medium mb-2", children: [
97
+ label,
69
98
  ":"
70
99
  ] }),
71
- /* @__PURE__ */ r("div", { className: "w-full flex gap-5 ", children: [
72
- /* @__PURE__ */ t(
73
- C,
100
+ /* @__PURE__ */ jsxs("div", { className: "w-full flex gap-5 ", children: [
101
+ /* @__PURE__ */ jsx(
102
+ FormField,
74
103
  {
75
104
  placeholder: "Zatím není určen",
76
- name: u,
105
+ name,
77
106
  onInputChange: () => {
78
107
  },
79
108
  type: "text",
80
- disabled: !0,
81
- value: n != null && n.employee ? v(n == null ? void 0 : n.employee, !0) : ""
109
+ disabled: true,
110
+ value: (storedPositionEmployee == null ? void 0 : storedPositionEmployee.employee) ? getFullName(storedPositionEmployee == null ? void 0 : storedPositionEmployee.employee, true) : ""
82
111
  }
83
112
  ),
84
- /* @__PURE__ */ t(
85
- m,
113
+ /* @__PURE__ */ jsx(
114
+ Button,
86
115
  {
87
- className: "text-xl " + (x ? "hidden" : ""),
116
+ className: "text-xl " + (disabled ? "hidden" : ""),
88
117
  variant: "primary",
89
- onClick: () => c(!0),
90
- disabled: x,
91
- children: /* @__PURE__ */ t(T, {})
118
+ onClick: () => setModalOpen(true),
119
+ disabled,
120
+ children: /* @__PURE__ */ jsx(CiEdit, {})
92
121
  }
93
122
  )
94
123
  ] })
95
124
  ] }),
96
- S && /* @__PURE__ */ t(
125
+ isModalOpen && /* @__PURE__ */ jsx(
97
126
  "div",
98
127
  {
99
128
  className: "fixed inset-0 bg-black bg-opacity-25 flex items-center justify-center p-5",
100
129
  style: { zIndex: 50 },
101
- children: /* @__PURE__ */ t(
130
+ children: /* @__PURE__ */ jsx(
102
131
  "div",
103
132
  {
104
133
  className: "bg-white rounded-lg shadow-xl m-4 overflow-auto max-h-full pointer-events-auto ",
105
134
  style: { width: "50vw" },
106
- children: /* @__PURE__ */ r("div", { className: "grid grid-cols-13 gap-4 p-5", children: [
107
- /* @__PURE__ */ r("div", { className: "col-span-12", children: [
108
- /* @__PURE__ */ r(M, { children: [
109
- d,
135
+ children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-13 gap-4 p-5", children: [
136
+ /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
137
+ /* @__PURE__ */ jsxs(SectionTitle, { children: [
138
+ label,
110
139
  " - Výběr pozice"
111
140
  ] }),
112
141
  " "
113
142
  ] }),
114
- /* @__PURE__ */ t("div", { className: "col-span-12", children: /* @__PURE__ */ t(
115
- F,
143
+ /* @__PURE__ */ jsx("div", { className: "col-span-12", children: /* @__PURE__ */ jsx(
144
+ AutocompleteSearchBar,
116
145
  {
117
146
  name: "departmentId",
118
147
  placeholder: "Vyhledejte útvar",
119
- fetchUrl: "os/departments?maxResults=5000",
148
+ fetchUrl: "os/departments?pageSize=5000",
120
149
  valueKey: "departmentId",
121
150
  labelKey: "nameLong",
122
151
  label: "Útvar",
123
- onChange: L,
152
+ onChange: handleDepartmentChange,
124
153
  onBlur: () => {
125
154
  },
126
155
  onFocus: () => {
127
156
  },
128
- value: i,
129
- showId: !0
157
+ value: department,
158
+ showId: true
130
159
  }
131
160
  ) }),
132
- /* @__PURE__ */ t("div", { className: "col-span-12 h-[400px]", children: /* @__PURE__ */ r("div", { className: "pt-4 w-full ", children: [
133
- /* @__PURE__ */ t("div", { className: "text-slate-700 text-sm leading-tight font-medium my-4", children: "Nalezené pozice:" }),
134
- j.map((e) => /* @__PURE__ */ t(
161
+ /* @__PURE__ */ jsx("div", { className: "col-span-12 h-[400px]", children: /* @__PURE__ */ jsxs("div", { className: "pt-4 w-full ", children: [
162
+ /* @__PURE__ */ jsx("div", { className: "text-slate-700 text-sm leading-tight font-medium my-4", children: "Nalezené pozice:" }),
163
+ positions.map((position) => /* @__PURE__ */ jsx(
135
164
  "div",
136
165
  {
137
166
  className: "w-1/2 group h-11 px-1.5 py-px justify-start items-center inline-flex cursor-pointer",
138
- onClick: () => y(e),
139
- children: /* @__PURE__ */ r(
167
+ onClick: () => handleSelectedPositionEmployee(position),
168
+ children: /* @__PURE__ */ jsxs(
140
169
  "div",
141
170
  {
142
- className: `grow shrink basis-0 h-11 pl-2 pr-2.5 py-2.5 rounded-md justify-start items-center gap-2 flex ${e.id == (a == null ? void 0 : a.id) ? " bg-gray-100 hover:bg-gray-200 " : "hover:bg-gray-50"} `,
171
+ className: `grow shrink basis-0 h-11 pl-2 pr-2.5 py-2.5 rounded-md justify-start items-center gap-2 flex ${position.id == (selectedPositionEmployee == null ? void 0 : selectedPositionEmployee.id) ? " bg-gray-100 hover:bg-gray-200 " : "hover:bg-gray-50"} `,
143
172
  children: [
144
- /* @__PURE__ */ t("div", { className: "grow shrink basis-0 h-6 justify-start items-center gap-2 flex", children: /* @__PURE__ */ t("div", { className: "text-gray-900 text-base font-medium font-['Inter'] leading-normal", children: v(e.employee, !0) }) }),
145
- /* @__PURE__ */ t(
173
+ /* @__PURE__ */ jsx("div", { className: "grow shrink basis-0 h-6 justify-start items-center gap-2 flex", children: /* @__PURE__ */ jsx("div", { className: "text-gray-900 text-base font-medium font-['Inter'] leading-normal", children: getFullName(position.employee, true) }) }),
174
+ /* @__PURE__ */ jsx(
146
175
  "div",
147
176
  {
148
- className: `w-5 h-5 relative group-hover:text-gray-300 ${e.id == (a == null ? void 0 : a.id) ? " text-blue-500 group-hover:text-black " : "text-transparent"}`,
149
- children: /* @__PURE__ */ t(B, {})
177
+ className: `w-5 h-5 relative group-hover:text-gray-300 ${position.id == (selectedPositionEmployee == null ? void 0 : selectedPositionEmployee.id) ? " text-blue-500 group-hover:text-black " : "text-transparent"}`,
178
+ children: /* @__PURE__ */ jsx(MdCheck, {})
150
179
  }
151
180
  )
152
181
  ]
153
182
  }
154
183
  )
155
184
  },
156
- e.id
185
+ position.id
157
186
  ))
158
187
  ] }) }),
159
- /* @__PURE__ */ r("div", { className: "col-span-12 flex justify-between gap-4", children: [
160
- /* @__PURE__ */ r("div", { className: " w-1/2 group flex ", children: [
161
- /* @__PURE__ */ t(
162
- C,
188
+ /* @__PURE__ */ jsxs("div", { className: "col-span-12 flex justify-between gap-4", children: [
189
+ /* @__PURE__ */ jsxs("div", { className: " w-1/2 group flex ", children: [
190
+ /* @__PURE__ */ jsx(
191
+ FormField,
163
192
  {
164
193
  placeholder: "Zatím není určen",
165
- name: u,
194
+ name,
166
195
  label: "Zvolená pozice ",
167
196
  onInputChange: () => {
168
197
  },
169
198
  type: "text",
170
- disabled: !0,
171
- value: a ? v(a == null ? void 0 : a.employee, !0) : ""
199
+ disabled: true,
200
+ value: selectedPositionEmployee ? getFullName(selectedPositionEmployee == null ? void 0 : selectedPositionEmployee.employee, true) : ""
172
201
  }
173
202
  ),
174
- a && /* @__PURE__ */ r("div", { className: "flex justify-end space-x-5 mt-auto ml-5", children: [
203
+ selectedPositionEmployee && /* @__PURE__ */ jsxs("div", { className: "flex justify-end space-x-5 mt-auto ml-5", children: [
175
204
  " ",
176
- /* @__PURE__ */ t(
177
- m,
205
+ /* @__PURE__ */ jsx(
206
+ Button,
178
207
  {
179
208
  variant: "secondary",
180
- onClick: () => y(
181
- a
209
+ onClick: () => handleSelectedPositionEmployee(
210
+ selectedPositionEmployee
182
211
  ),
183
212
  children: "Odebrat přiřazení"
184
213
  }
185
214
  )
186
215
  ] })
187
216
  ] }),
188
- /* @__PURE__ */ r("div", { className: "flex justify-end space-x-5 mt-auto ", children: [
189
- /* @__PURE__ */ t(
190
- m,
217
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end space-x-5 mt-auto ", children: [
218
+ /* @__PURE__ */ jsx(
219
+ Button,
191
220
  {
192
221
  variant: "secondary",
193
- onClick: () => c(!1),
222
+ onClick: () => setModalOpen(false),
194
223
  children: "Zrušit"
195
224
  }
196
225
  ),
197
- /* @__PURE__ */ t(
198
- m,
226
+ /* @__PURE__ */ jsx(
227
+ Button,
199
228
  {
200
229
  variant: "primary",
201
- onClick: () => I(a),
230
+ onClick: () => handleSave(selectedPositionEmployee),
202
231
  children: "Uložit"
203
232
  }
204
233
  )
@@ -212,5 +241,6 @@ function X({
212
241
  ] });
213
242
  }
214
243
  export {
215
- X as default
244
+ PositionsSelectorSingle as default
216
245
  };
246
+ //# sourceMappingURL=PositionsSelectorSingle.js.map