px-react-ui-components 1.0.0

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 (75) hide show
  1. package/.babelrc +3 -0
  2. package/README.md +126 -0
  3. package/dist/components/MyAlert/MyAlert.css +113 -0
  4. package/dist/components/MyAlert/MyAlert.js +109 -0
  5. package/dist/components/MyContainer/MyContainer.js +59 -0
  6. package/dist/components/MyContainer/MyContainer.module.css +110 -0
  7. package/dist/components/MyContainer/MyContainerBody.js +9 -0
  8. package/dist/components/MyContainer/MyContainerFooter.js +9 -0
  9. package/dist/components/MyContainer/MyContainerRight.js +10 -0
  10. package/dist/components/MyEditor/MyEditor.js +292 -0
  11. package/dist/components/MyEditor/MyEditor.scss +277 -0
  12. package/dist/components/MyFileUpload/MyFileUpload.js +288 -0
  13. package/dist/components/MyFileUpload/MyFileUpload.module.css +86 -0
  14. package/dist/components/MyImageCropper/MyImageCropper.js +95 -0
  15. package/dist/components/MyInput/MyInput.js +768 -0
  16. package/dist/components/MyInput/MyInput.module.css +420 -0
  17. package/dist/components/MyMaps/YandexMaps.js +162 -0
  18. package/dist/components/MyMenu/MenuItem.js +55 -0
  19. package/dist/components/MyMenu/MyMenu.module.css +102 -0
  20. package/dist/components/MyModal/MyModal.css +83 -0
  21. package/dist/components/MyModal/MyModal.js +71 -0
  22. package/dist/components/MyModal/MyModalBody.js +9 -0
  23. package/dist/components/MyModal/MyModalFooter.js +9 -0
  24. package/dist/components/MyNotFound/MyNotFound.css +22 -0
  25. package/dist/components/MyNotFound/MyNotFound.js +20 -0
  26. package/dist/components/MyScrollableCard/MyScrollableCard.js +74 -0
  27. package/dist/components/MyTable/MyTable.js +310 -0
  28. package/dist/components/MyTable/MyTable.module.css +350 -0
  29. package/dist/components/MyTable/MyTableBody.js +9 -0
  30. package/dist/components/MyTable/MyTableHead.js +9 -0
  31. package/dist/components/MyTabs/MyTabPane.js +17 -0
  32. package/dist/components/MyTabs/MyTabs.css +105 -0
  33. package/dist/components/MyTabs/MyTabs.js +66 -0
  34. package/dist/components/MyWaiting/MyWaiting.css +28 -0
  35. package/dist/components/MyWaiting/MyWaiting.js +27 -0
  36. package/dist/components/MyZoomImage/MyZoomImage.css +0 -0
  37. package/dist/components/MyZoomImage/MyZoomImage.js +108 -0
  38. package/dist/index.js +15 -0
  39. package/package.json +44 -0
  40. package/src/components/MyAlert/MyAlert.css +113 -0
  41. package/src/components/MyAlert/MyAlert.jsx +96 -0
  42. package/src/components/MyContainer/MyContainer.jsx +90 -0
  43. package/src/components/MyContainer/MyContainer.module.css +110 -0
  44. package/src/components/MyContainer/MyContainerBody.jsx +8 -0
  45. package/src/components/MyContainer/MyContainerFooter.jsx +8 -0
  46. package/src/components/MyContainer/MyContainerRight.jsx +11 -0
  47. package/src/components/MyEditor/MyEditor.jsx +252 -0
  48. package/src/components/MyEditor/MyEditor.scss +277 -0
  49. package/src/components/MyFileUpload/MyFileUpload.jsx +373 -0
  50. package/src/components/MyFileUpload/MyFileUpload.module.css +86 -0
  51. package/src/components/MyImageCropper/MyImageCropper.jsx +108 -0
  52. package/src/components/MyInput/MyInput.jsx +896 -0
  53. package/src/components/MyInput/MyInput.module.css +420 -0
  54. package/src/components/MyMaps/YandexMaps.jsx +186 -0
  55. package/src/components/MyMenu/MenuItem.jsx +62 -0
  56. package/src/components/MyMenu/MyMenu.module.css +102 -0
  57. package/src/components/MyModal/MyModal.css +83 -0
  58. package/src/components/MyModal/MyModal.jsx +78 -0
  59. package/src/components/MyModal/MyModalBody.jsx +8 -0
  60. package/src/components/MyModal/MyModalFooter.jsx +8 -0
  61. package/src/components/MyNotFound/MyNotFound.css +22 -0
  62. package/src/components/MyNotFound/MyNotFound.jsx +11 -0
  63. package/src/components/MyScrollableCard/MyScrollableCard.jsx +86 -0
  64. package/src/components/MyTable/MyTable.jsx +458 -0
  65. package/src/components/MyTable/MyTable.module.css +350 -0
  66. package/src/components/MyTable/MyTableBody.jsx +8 -0
  67. package/src/components/MyTable/MyTableHead.jsx +10 -0
  68. package/src/components/MyTabs/MyTabPane.jsx +9 -0
  69. package/src/components/MyTabs/MyTabs.css +105 -0
  70. package/src/components/MyTabs/MyTabs.jsx +63 -0
  71. package/src/components/MyWaiting/MyWaiting.css +28 -0
  72. package/src/components/MyWaiting/MyWaiting.jsx +27 -0
  73. package/src/components/MyZoomImage/MyZoomImage.css +0 -0
  74. package/src/components/MyZoomImage/MyZoomImage.jsx +139 -0
  75. package/src/index.js +15 -0
@@ -0,0 +1,420 @@
1
+ .container {
2
+ display: block;
3
+ /* width: 100%; */
4
+ width: auto;
5
+ font-size: 15px;
6
+ }
7
+
8
+ .container small {
9
+ padding-left: 5px;
10
+ font-size: 11px;
11
+ }
12
+
13
+ .inputblock {
14
+ display: block;
15
+ position: relative;
16
+ /* width: 100%; */
17
+ width: auto;
18
+ background-color: #fff;
19
+ border: 1px solid #e5e7eb;
20
+ padding-right: 8px;
21
+ padding-left: 15px;
22
+ border-radius: 8px;
23
+ }
24
+
25
+ .inputblockdisabled{
26
+ background-color: #f8fafd;
27
+ border-color: #e5e7eb;
28
+ }
29
+
30
+ .disabledInput {
31
+ width: 100%;
32
+ min-height: 40px;
33
+ display: flex;
34
+ align-items: center;
35
+ padding: 8px;
36
+ overflow: auto;
37
+ scrollbar-width: thin;
38
+ }
39
+
40
+ .caretdown {
41
+ position: absolute;
42
+ right: 10px;
43
+ top: 50%;
44
+ transform: translateY(-50%);
45
+ font-size: 15px;
46
+ }
47
+
48
+ .fileinput,
49
+ .css13cymwtControl,
50
+ .inputblock select,
51
+ .inputblock textarea,
52
+ .inputblock input {
53
+ display: block;
54
+ width: 100%;
55
+ min-height: 41px;
56
+ background: rgba(243, 242, 247, 0.1);
57
+ border: none;
58
+ padding: 10px 0px;
59
+ color: #0a0b0f;
60
+ font-weight: normal;
61
+ font-size: 14px;
62
+ outline: none;
63
+ z-index: 9;
64
+ }
65
+
66
+ .inputblock:focus-within {
67
+ background-color: #ecf8ff;
68
+ }
69
+
70
+ .inputblock select {
71
+ padding: 10px 0px 11px 0;
72
+ }
73
+
74
+ .fileinput::placeholder,
75
+ .css13cymwtControl::placeholder,
76
+ .inputblock select::placeholder,
77
+ .inputblock textarea::placeholder,
78
+ .inputblock input::placeholder {
79
+ color: #73889d;
80
+ opacity: 0.8;
81
+ }
82
+
83
+ .fileinput:-internal-autofill-selected,
84
+ .css13cymwtControl:-internal-autofill-selected,
85
+ .inputblock select:-internal-autofill-selected,
86
+ .inputblock textarea:-internal-autofill-selected,
87
+ .inputblock input:-internal-autofill-selected {
88
+ background-color: rgba(243, 242, 247, 0.1) !important;
89
+ }
90
+
91
+ .inputblock input[type="color"] {
92
+ height: 45px;
93
+ padding: 5px 0;
94
+ }
95
+
96
+ .inputblock textarea {
97
+ line-height: unset;
98
+ }
99
+
100
+ .placeholder {
101
+ position: absolute;
102
+ top: 50%;
103
+ transform: translateY(-50%);
104
+ color: #75899e;
105
+ opacity: 0.8;
106
+ z-index: 0;
107
+ pointer-events: none;
108
+ font-weight: 300;
109
+ font-size: 14px;
110
+ }
111
+
112
+ .inputblock input.filterInput {
113
+ position: absolute;
114
+ display: none;
115
+ left: 10px;
116
+ top: 0px;
117
+ width: calc(100% - 75px) !important;
118
+ padding-left: 5px !important;
119
+ z-index: 2 !important;
120
+ background-color: #f3f2f7 !important;
121
+ }
122
+
123
+ .inputblockicon input.filterInput {
124
+ left: 40px;
125
+ }
126
+
127
+ .filterInputSelected {
128
+ display: block;
129
+ width: 100%;
130
+ height: 41px;
131
+ padding: 10px 0;
132
+ font-size: 14px;
133
+ font-weight: 300;
134
+ }
135
+
136
+ .filterInputSelectedSelected {
137
+ position: relative;
138
+ padding-left: 30px;
139
+ }
140
+
141
+ .filterInputSelectedContainer {
142
+ display: flex;
143
+ align-items: center;
144
+ justify-content: space-between;
145
+ padding-left: 10px;
146
+ }
147
+
148
+ .filterInputSelectedContainerSelected {
149
+ position: relative;
150
+ }
151
+
152
+ .filterInputSelectedX {
153
+ position: absolute;
154
+ right: 35px;
155
+ top: 50%;
156
+ transform: translateY(-50%);
157
+ font-size: 15px;
158
+ cursor: pointer;
159
+ font-family: monospace;
160
+ border-radius: 50%;
161
+ width: 18px;
162
+ height: 18px;
163
+ background: #e4e4e4;
164
+ text-align: center;
165
+ padding: 0px;
166
+ line-height: 15px;
167
+ color: #000000;
168
+ }
169
+
170
+ .filterInputSelectedX:hover {
171
+ background: #f0cdcd;
172
+ color: #a34444;
173
+ }
174
+
175
+ .filterInputList {
176
+ display: none;
177
+ position: absolute;
178
+ left: 5px;
179
+ top: 41px;
180
+ max-height: 300px;
181
+ width: calc(100% - 10px);
182
+ z-index: 99;
183
+ background-color: #fff;
184
+ padding: 0;
185
+ border-radius: 8px;
186
+ overflow: auto;
187
+ scrollbar-width: thin;
188
+ box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.5);
189
+ font-size: 13px;
190
+ font-weight: 300;
191
+ }
192
+
193
+ .filterInputList.opened {
194
+ display: block;
195
+ }
196
+
197
+ .filterInputList li {
198
+ cursor: default;
199
+ padding: 6px 15px;
200
+ display: flex;
201
+ flex-direction: column;
202
+ gap: 0px;
203
+ }
204
+
205
+ .filterInputList .subtextli {
206
+ padding: 4px 15px;
207
+ }
208
+ .filterInputList li .subtext {
209
+ font-size: 11px;
210
+ font-style: italic;
211
+ color: #73889d;
212
+ opacity: 0.8;
213
+ font-weight: 300;
214
+ }
215
+
216
+ .filterInputList li:hover {
217
+ background-color: #1c61c9;
218
+ color: #fff;
219
+ }
220
+
221
+ .filterInputList li:hover .subtext,
222
+ .filterInputList li:hover i,
223
+ .filterInputList li:hover span,
224
+ .filterInputList li:hover small {
225
+ color: #fff !important;
226
+ }
227
+
228
+ .inputblockicon {
229
+ padding-left: 40px;
230
+ }
231
+
232
+ .inputblockicon .eye,
233
+ .inputblockicon .icon {
234
+ position: absolute;
235
+ left: 5px;
236
+ top: 50%;
237
+ width: 30px;
238
+ transform: translateY(-50%);
239
+ color: #73889d;
240
+ padding: 0px;
241
+ font-size: 22px;
242
+ display: flex;
243
+ align-items: center;
244
+ justify-content: center;
245
+ }
246
+
247
+ .inputblockicon .icontextarea {
248
+ top: 13px;
249
+ transform: unset;
250
+ }
251
+
252
+ .inputblockicon .icon {
253
+ z-index: 0;
254
+ pointer-events: none;
255
+ }
256
+
257
+ .inputblockicon .eye {
258
+ left: unset;
259
+ right: 10px;
260
+ background: unset;
261
+ border: none;
262
+ }
263
+
264
+ .inputblockicon .eye:hover {
265
+ color: #a3a7ac;
266
+ }
267
+
268
+ .inputblockicon .placeholder {
269
+ left: 45px;
270
+ }
271
+
272
+ .error .inputblock{
273
+ border-color: #ff0000 !important;
274
+ }
275
+
276
+ .fileinput {
277
+ position: relative;
278
+ display: flex;
279
+ flex-direction: row;
280
+ align-items: center;
281
+ justify-content: space-between;
282
+ gap: 5px;
283
+ width: 100%;
284
+ padding: 0px;
285
+ }
286
+
287
+ .fileImagePreview {
288
+ position: absolute;
289
+ height: 35px;
290
+ width: 35px;
291
+ object-fit: cover;
292
+ border-radius: 5px;
293
+ left: -40px;
294
+ top: 50%;
295
+ transform: translateY(-50%);
296
+ padding: 2px;
297
+ background: #f3f3f3;
298
+ }
299
+
300
+ .fileImagePreview:hover {
301
+ height: 180px;
302
+ width: 180px;
303
+ z-index: 9999;
304
+ padding: 8px;
305
+ cursor: pointer;
306
+ -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.35);
307
+ -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.35);
308
+ box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.35);
309
+ }
310
+
311
+ .filename {
312
+ display: block;
313
+ position: relative;
314
+ width: calc(100% - 110px);
315
+ color: #b9bbbd;
316
+ padding: 0 0 0 5px;
317
+ }
318
+
319
+ .filename small {
320
+ position: absolute;
321
+ right: 0px;
322
+ top: 0px;
323
+ height: 100%;
324
+ font-weight: normal;
325
+ background: #cdcdcd;
326
+ padding: 5px;
327
+ border-radius: 8px;
328
+ line-height: 1;
329
+ }
330
+
331
+ .filename.selected {
332
+ color: #000;
333
+ }
334
+
335
+ .filebutton {
336
+ margin-left: auto;
337
+ /* position: absolute;
338
+ right: -2px;
339
+ top: 5px; */
340
+ min-width: 80px;
341
+ /* height: calc(100% - 10px); */
342
+ padding: 8px;
343
+ border: none;
344
+ background: #d0d6de;
345
+ color: #464255;
346
+ border-radius: 8px;
347
+ flex-shrink: 0;
348
+
349
+ }
350
+
351
+ .filebutton:hover {
352
+ background: #c7ced6;
353
+ }
354
+
355
+ .filebuttonremove {
356
+ width: 20px;
357
+ height: 20px;
358
+ background: #c7ced6;
359
+ color: #fff;
360
+ border: none;
361
+ padding: 0px;
362
+ border-radius: 50%;
363
+ font-size: 12px;
364
+ cursor: pointer;
365
+ margin-left: auto;
366
+ flex-shrink: 0;
367
+
368
+ /* position: absolute; */
369
+ /* right: 10px;
370
+ top: 50%;
371
+ transform: translateY(-50%); */
372
+ }
373
+
374
+ .description {
375
+ display: block;
376
+ width: 100%;
377
+ font-size: 10px;
378
+ padding-top: 2px;
379
+ color: #737a83;
380
+ }
381
+
382
+ @media screen and (max-width: 768px) {
383
+ .container {
384
+ font-size: 14px;
385
+ }
386
+
387
+ .inputblock {
388
+ padding-right: 6px;
389
+ }
390
+
391
+ .filebutton {
392
+ min-width: 70px;
393
+ padding: 6px;
394
+ }
395
+
396
+ .inputblockicon .icon,
397
+ .inputblockicon .eye {
398
+ font-size: 22px;
399
+ }
400
+ }
401
+
402
+ @media screen and (max-width: 480px) {
403
+ .container {
404
+ font-size: 11px;
405
+ }
406
+
407
+ .inputblock {
408
+ padding-right: 4px;
409
+ }
410
+
411
+ .filebutton {
412
+ min-width: 60px;
413
+ padding: 4px;
414
+ }
415
+
416
+ .inputblockicon .icon,
417
+ .inputblockicon .eye {
418
+ font-size: 20px;
419
+ }
420
+ }
@@ -0,0 +1,186 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+
3
+ // Global olarak ymaps yükleyicisi
4
+ let ymapsLoader;
5
+
6
+ const loadYandexMapsAPI = (APIKEY) => {
7
+ if (ymapsLoader) {
8
+ return ymapsLoader;
9
+ }
10
+
11
+ ymapsLoader = new Promise((resolve, reject) => {
12
+ if (window.ymaps) {
13
+ resolve(window.ymaps);
14
+ } else {
15
+ const script = document.getElementById("yandexmapapi");
16
+
17
+ if (!script) {
18
+ const newScript = document.createElement('script');
19
+ newScript.id = "yandexmapapi";
20
+ newScript.src = `https://api-maps.yandex.com/2.1/?apikey=${APIKEY}&lang=tr_TR`;
21
+ newScript.async = true;
22
+ document.head.appendChild(newScript);
23
+
24
+ newScript.onload = () => {
25
+ window.ymaps.ready(() => resolve(window.ymaps));
26
+ };
27
+
28
+ newScript.onerror = reject;
29
+ } else {
30
+ script.onload = () => {
31
+ window.ymaps.ready(() => resolve(window.ymaps));
32
+ };
33
+ }
34
+ }
35
+ });
36
+
37
+ return ymapsLoader;
38
+ };
39
+
40
+ const YandexMap = ({ className = "", value = null, address = null, addressSearch = false, onChange = null, onAddress = null, style = null, APIKEY = null }) => {
41
+ const [loaded, setLoaded] = useState(false);
42
+ const [position, setPosition] = useState(null);
43
+ const [error, setError] = useState(null);
44
+ const [componentKey] = useState(Date.now() + '' + (Math.floor(Math.random() * (10 - 1)) + 1));
45
+ const markerRef = useRef(null); // Marker için referans
46
+
47
+ const currentLocation = () => {
48
+ if (value) {
49
+ maps_load(parseFloat(value.coords[0]), parseFloat(value.coords[1]), parseInt(value.zoom));
50
+ return;
51
+ }
52
+
53
+ if (navigator.geolocation) {
54
+ navigator.geolocation.getCurrentPosition(
55
+ (position) => {
56
+ maps_load(position.coords.latitude, position.coords.longitude, 12);
57
+ },
58
+ (error) => {
59
+ console.error(error.message);
60
+ maps_load(40.32110315567054, 32.199745873178124, 8);
61
+ }
62
+ );
63
+ } else {
64
+ maps_load(40.32110315567054, 32.199745873178124, 8);
65
+ setError("Geolocation is not supported by this browser.");
66
+ }
67
+ };
68
+
69
+ const maps_load = (coorX, coorY, zoom = 10) => {
70
+ document.getElementById("map" + componentKey).innerHTML = "";
71
+
72
+ const myMap = new ymaps.Map("map" + componentKey, {
73
+ center: [coorX, coorY],
74
+ zoom: zoom,
75
+ });
76
+
77
+ createMarker(myMap, [coorX, coorY], zoom);
78
+
79
+ myMap.events.add('click', (e) => {
80
+ const coords = e.get('coords');
81
+ let curzoom = myMap.getZoom();
82
+ // if (curzoom < 17) {
83
+ // curzoom = 17;
84
+ // myMap.setZoom(curzoom);
85
+ // }
86
+
87
+ setPosition({ coords: coords, zoom: curzoom });
88
+ getAddress(coords);
89
+ createMarker(myMap, coords, curzoom);
90
+ });
91
+
92
+ };
93
+
94
+ const createMarker = (myMap, coords, curzoom) => {
95
+ if (markerRef.current) {
96
+ myMap.geoObjects.remove(markerRef.current); // Önceki marker'ı kaldır
97
+ }
98
+ const newMarker = new ymaps.Placemark(coords, {
99
+ balloonContent: `Yeni Koordinatlar: ${coords[0]}, ${coords[1]}`,
100
+ });
101
+
102
+ myMap.geoObjects.add(newMarker);
103
+ markerRef.current = newMarker;
104
+ // myMap.setCenter(coords, curzoom);
105
+ };
106
+
107
+ const getAddress = (coords) => {
108
+ if (!onAddress) return;
109
+
110
+ ymaps.geocode(coords).then((res) => {
111
+ const firstGeoObject = res.geoObjects.get(0);
112
+
113
+ if (firstGeoObject) {
114
+ const address = firstGeoObject.getAddressLine();
115
+ onAddress(address);
116
+ }
117
+ });
118
+ };
119
+
120
+ const getAddressCoor = () => {
121
+ const geocodeUrl = `https://geocode-maps.yandex.ru/1.x/?geocode=${encodeURIComponent(address)}&format=json&apikey=${APIKEY}`;
122
+
123
+ fetch(geocodeUrl)
124
+ .then(response => response.json())
125
+ .then(data => {
126
+ if (data.response.GeoObjectCollection.featureMember.length > 0) {
127
+ const firstResult = data.response.GeoObjectCollection.featureMember[0].GeoObject;
128
+ const pos = firstResult.Point.pos.split(' ');
129
+
130
+ maps_load(parseFloat(pos[1]), parseFloat(pos[0]), 17)
131
+ }
132
+ })
133
+ .catch(err => {
134
+ setError(`Hata: ${err.message}`);
135
+ });
136
+ }
137
+
138
+ useEffect(() => {
139
+ if (addressSearch && !markerRef.current && address && address != "") {
140
+ getAddressCoor();
141
+ }
142
+ }, [addressSearch])
143
+
144
+ useEffect(() => {
145
+ if (onChange && loaded) {
146
+ onChange(position);
147
+ }
148
+ }, [position]);
149
+
150
+ const opened = () => {
151
+ currentLocation();
152
+
153
+ setTimeout(() => {
154
+ setLoaded(true);
155
+ }, 1000);
156
+ };
157
+
158
+ useEffect(() => {
159
+ if (loaded && value) {
160
+ maps_load(parseFloat(value.coords[0]), parseFloat(value.coords[1]), parseInt(value.zoom));
161
+ }
162
+ }, [value]);
163
+
164
+ useEffect(() => {
165
+ // if (loaded && value) {
166
+ // maps_load(parseFloat(value.coords[0]), parseFloat(value.coords[1]), parseInt(value.zoom));
167
+ // }
168
+ }, [loaded]);
169
+
170
+ useEffect(() => {
171
+ if (!APIKEY) {
172
+ APIKEY = "0d21dc94-68eb-4245-871f-a56081b703b3";
173
+ }
174
+
175
+ loadYandexMapsAPI(APIKEY)
176
+ .then(() => {
177
+ opened(); // Harita işlevselliğinizi başlatın
178
+ })
179
+ .catch((err) => console.error("Yandex Maps API yüklenemedi", err));
180
+ }, []);
181
+
182
+
183
+ return <div id={"map" + componentKey} className={"w-full h-72 " + className} style={style}></div>;
184
+ };
185
+
186
+ export default YandexMap;
@@ -0,0 +1,62 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import styles from "./MyMenu.module.css"
4
+ import { PiCaretDown, PiCaretUp } from 'react-icons/pi';
5
+ import { GoDotFill } from 'react-icons/go';
6
+
7
+ function MenuItem({ children = null, to = "", text = "", className = null, badge = null, icon = null, title = "", defaultOpen=false, defaultRoute = "", isShortMenu = false }) {
8
+ // let selected = window.location.pathname == to || (window.location.pathname == defaultRoute);
9
+
10
+
11
+ const [open, setOpen] = useState(defaultOpen);
12
+ const [selected, setSelected] = useState(false);
13
+
14
+ useEffect(() => {
15
+ setSelected(children ? false : (window.location.pathname == to || (window.location.pathname == defaultRoute || window.location.pathname.includes(to))));
16
+ }, [window.location.pathname]);
17
+
18
+
19
+ return (
20
+ <>
21
+ {children &&
22
+
23
+ <div className={styles.menuItemOwner}>
24
+ <div
25
+ className={
26
+ styles.menuItem + " " +
27
+ (className != null ? className : "") + " " +
28
+ (selected ? styles.selected : '') + " " +
29
+ (open ? styles.menuItemOpen : '') + " " +
30
+ (isShortMenu ? styles.menuItemShortMenu : '')
31
+ } title={title == "" ? text : title}
32
+ onClick={() => setOpen(!open)}
33
+ >
34
+ {icon && <div className={styles.menuItemIcon}>{icon}</div>}
35
+ <span className={styles.menuItemText + " " + (badge != null ? styles.menuItemTextBadge : '')}>
36
+ {text}
37
+ {badge != null && typeof badge !== 'object' ? <span className={styles.menuItemBadge}>{badge.toString()}</span> : badge}
38
+ </span>
39
+
40
+ {open &&
41
+ <PiCaretUp className={`font-bold text-2xl ${styles.menuItemIconSubMenu} ${open ? styles.menuItemIconSubMenuOpen : ''}`} />
42
+ ||
43
+ <PiCaretDown className={`font-bold text-2xl ${styles.menuItemIconSubMenu} ${open ? styles.menuItemIconSubMenuOpen : ''}`} />}
44
+ </div>
45
+
46
+ <div className={styles.menuItemChildren + " " + (open ? styles.menuItemChildrenOpen : '')}>
47
+ {children}
48
+ </div>
49
+ </div> ||
50
+ <Link to={to} className={styles.menuItem + " " + (className != null ? className : "") + " " + (selected ? styles.selected : '') + " " + (isShortMenu ? styles.menuItemShortMenu : '')} title={title == "" ? text : title}>
51
+ {icon && <div className={styles.menuItemIcon}>{icon}</div> || <GoDotFill />}
52
+ <span className={styles.menuItemText + " " + (badge != null ? styles.menuItemTextBadge : '')}>
53
+ {text}
54
+ {badge != null && typeof badge !== 'object' ? <span className={styles.menuItemBadge}>{badge.toString()}</span> : badge}
55
+ </span>
56
+ </Link>
57
+ }
58
+ </>
59
+ )
60
+ }
61
+
62
+ export default MenuItem