px-react-ui-components 1.0.0 → 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.
Files changed (41) hide show
  1. package/dist/components/MyFileUpload/MyFileUpload.js +16 -17
  2. package/dist/components/MyInput/MyInput.js +4 -7
  3. package/dist/components/MyTable/MyTable.js +9 -8
  4. package/package.json +13 -1
  5. package/.babelrc +0 -3
  6. package/src/components/MyAlert/MyAlert.css +0 -113
  7. package/src/components/MyAlert/MyAlert.jsx +0 -96
  8. package/src/components/MyContainer/MyContainer.jsx +0 -90
  9. package/src/components/MyContainer/MyContainer.module.css +0 -110
  10. package/src/components/MyContainer/MyContainerBody.jsx +0 -8
  11. package/src/components/MyContainer/MyContainerFooter.jsx +0 -8
  12. package/src/components/MyContainer/MyContainerRight.jsx +0 -11
  13. package/src/components/MyEditor/MyEditor.jsx +0 -252
  14. package/src/components/MyEditor/MyEditor.scss +0 -277
  15. package/src/components/MyFileUpload/MyFileUpload.jsx +0 -373
  16. package/src/components/MyFileUpload/MyFileUpload.module.css +0 -86
  17. package/src/components/MyImageCropper/MyImageCropper.jsx +0 -108
  18. package/src/components/MyInput/MyInput.jsx +0 -896
  19. package/src/components/MyInput/MyInput.module.css +0 -420
  20. package/src/components/MyMaps/YandexMaps.jsx +0 -186
  21. package/src/components/MyMenu/MenuItem.jsx +0 -62
  22. package/src/components/MyMenu/MyMenu.module.css +0 -102
  23. package/src/components/MyModal/MyModal.css +0 -83
  24. package/src/components/MyModal/MyModal.jsx +0 -78
  25. package/src/components/MyModal/MyModalBody.jsx +0 -8
  26. package/src/components/MyModal/MyModalFooter.jsx +0 -8
  27. package/src/components/MyNotFound/MyNotFound.css +0 -22
  28. package/src/components/MyNotFound/MyNotFound.jsx +0 -11
  29. package/src/components/MyScrollableCard/MyScrollableCard.jsx +0 -86
  30. package/src/components/MyTable/MyTable.jsx +0 -458
  31. package/src/components/MyTable/MyTable.module.css +0 -350
  32. package/src/components/MyTable/MyTableBody.jsx +0 -8
  33. package/src/components/MyTable/MyTableHead.jsx +0 -10
  34. package/src/components/MyTabs/MyTabPane.jsx +0 -9
  35. package/src/components/MyTabs/MyTabs.css +0 -105
  36. package/src/components/MyTabs/MyTabs.jsx +0 -63
  37. package/src/components/MyWaiting/MyWaiting.css +0 -28
  38. package/src/components/MyWaiting/MyWaiting.jsx +0 -27
  39. package/src/components/MyZoomImage/MyZoomImage.css +0 -0
  40. package/src/components/MyZoomImage/MyZoomImage.jsx +0 -139
  41. package/src/index.js +0 -15
@@ -1,896 +0,0 @@
1
- import React, { useEffect, useRef, useState } from "react";
2
- import styles from "./MyInput.module.css"
3
- import { PiCaretDownBold, PiEye, PiEyeSlash } from "react-icons/pi";
4
- import { useTranslation } from "../../context/TranslationContext";
5
-
6
- export const MyInputType = Object.freeze({
7
- TEXT: 'text',
8
- PASSWORD: 'password',
9
- SELECT: 'select',
10
- SELECTFILTER: 'selectfilter',
11
- FILE: 'file',
12
- IMAGE: 'image',
13
- TEXTAREA: 'textarea',
14
- COLOR: 'color',
15
- READONLY: 'readonly',
16
- DATE: 'date',
17
- DATETIME: 'datetime',
18
- TIME: 'time',
19
- MONEY: 'money',
20
- NUMBER: 'number',
21
- MAIL: 'mail',
22
- PHONE: 'phone'
23
- });
24
-
25
- export const MyInputIsNumeric = (value) => {
26
- if (value === null || value === undefined || value === '') return false;
27
- return !isNaN(value) && !isNaN(parseFloat(value));
28
- }
29
-
30
- function MyInput({
31
- id = null,
32
- ref = null,
33
- title = "",
34
- placeholder = "",
35
- placeholdersearchtext = "",
36
- description = null,
37
- type = MyInputType.TEXT,
38
- className = null,
39
- rows = 0,
40
- icon = null,
41
- options = null,
42
-
43
- options_key_value = "value",
44
- options_key_text = "text",
45
- options_key_subtext = "subtext",
46
-
47
- multiple = false,
48
- disabled = false,
49
- value = null,
50
- decimalCount = 2,
51
- buttonText = "",
52
- accept = ".jpg,.jpeg,.png",
53
- minDate = null,
54
- maxDate = null,
55
- style = null,
56
- maxlength = null,
57
- dangerouslySetInnerHTML = null,
58
-
59
- uppercase = false,
60
- lowercase = false,
61
- firstUppercase = false,
62
-
63
- onChange = null,
64
- onBlur = null,
65
- onFocus = null,
66
- onKeyDown = null,
67
- onKeyUp = null,
68
- onKeyPress = null,
69
- onMouseDown = null,
70
- onMouseUp = null,
71
- onMouseEnter = null,
72
- onMouseLeave = null,
73
- onRemoveImage = null
74
- }) {
75
- const { t } = useTranslation();
76
-
77
- const myInputId = `key${Date.now() + Math.random().toString(36).substr(2, 9)}`;
78
-
79
- const fileInputRef = useRef(null);
80
-
81
- const [loaded, setLoaded] = useState(false);
82
-
83
- const [myValue, setMyValue] = useState(value);
84
- const [myEyeView, setMyEyeView] = useState(false);
85
- const [myFileName, setMyFileName] = useState(null);
86
- const [myTitleLite, setMyTitleLite] = useState("");
87
-
88
- const [filtertext, setFiltertext] = useState("");
89
-
90
- const [isError, setIsError] = useState(false);
91
-
92
- const toBase64 = (file) =>
93
- new Promise((resolve, reject) => {
94
- const reader = new FileReader();
95
- reader.readAsDataURL(file);
96
- reader.onload = () => resolve(reader.result);
97
- reader.onerror = reject;
98
- });
99
-
100
- const calculateFileSize = (sizeInBytes) => {
101
- const units = ['B', 'KB', 'MB'];
102
- let size = sizeInBytes;
103
- let unitIndex = 0;
104
-
105
- while (size >= 1024 && unitIndex < units.length - 1) {
106
- size /= 1024;
107
- unitIndex++;
108
- }
109
-
110
- return `${size.toFixed(2)} ${units[unitIndex]}`;
111
- }
112
-
113
-
114
- const moneyFormat = (_value) => {
115
-
116
- let money = '';
117
- let inputValue = _value;
118
-
119
- if (inputValue == null || inputValue == undefined || inputValue == '') return money;
120
-
121
- try {
122
-
123
- inputValue = inputValue.toString();
124
- // Tüm virgülleri kaldır ve son girilen karakteri kontrol et
125
- money = inputValue.replace(/,/g, '');
126
- const lastChar = inputValue.slice(-1);
127
- if (lastChar === ',') {
128
- money = money + '.';
129
- }
130
-
131
- // Sadece sayılar ve tek bir nokta kalacak şekilde temizle
132
- money = money.replace(/[^0-9.]/g, '');
133
-
134
- // Birden fazla nokta varsa ilkini koru
135
- const parts = money.split('.');
136
- if (parts.length > 2) {
137
- money = parts[0] + '.' + parts[1];
138
- }
139
-
140
- // Noktadan sonra en fazla 2 basamak
141
- if (parts.length === 2 && parts[1].length > decimalCount) {
142
- money = parts[0] + '.' + parts[1].substring(0, decimalCount);
143
- }
144
-
145
- // Binlik ayracı için formatlama
146
- if (money) {
147
- const numParts = money.split('.');
148
- if (numParts[0]) {
149
- // Sayıyı önce tam sayıya çevir, sonra binlik ayracı ekle
150
- numParts[0] = parseInt(numParts[0], 10).toLocaleString('en-US');
151
- }
152
- money = numParts.join('.');
153
- }
154
-
155
- const numParts = money.split('.');
156
- if (numParts[0]) {
157
- numParts[0] = numParts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
158
- }
159
-
160
- money = numParts.join('.');
161
- } catch (error) {
162
- money = '';
163
-
164
- console.log(inputValue);
165
- console.error(error);
166
- }
167
- return money;
168
- }
169
-
170
- const onMyBlur = (e) => {
171
- setIsError(false);
172
-
173
- if (myValue != null && myValue != "") {
174
- switch (type) {
175
- case MyInputType.MAIL:
176
- if (!myValue.includes("@") || !myValue.includes(".")) {
177
- setIsError(true);
178
- }
179
- break;
180
- case MyInputType.PHONE:
181
- if (myValue.length < 10 || myValue.length > 15) {
182
- setIsError(true);
183
- }
184
- break;
185
- default:
186
- break;
187
- }
188
- }
189
-
190
- if (onBlur != null) onBlur(e);
191
- }
192
-
193
- const onMyFocus = (e) => {
194
- if (onFocus != null) onFocus(e);
195
- }
196
-
197
- const onMyKeyDown = (e) => {
198
- if (onKeyDown != null) onKeyDown(e);
199
- }
200
-
201
- const onMyKeyUp = (e) => {
202
- if (onKeyUp != null) onKeyUp(e);
203
- }
204
-
205
- const onMyKeyPress = (e) => {
206
- if (onKeyPress != null) onKeyPress(e);
207
- }
208
-
209
- const onMyMouseDown = (e) => {
210
- if (onMouseDown != null) onMouseDown(e);
211
- }
212
-
213
- const onMyMouseUp = (e) => {
214
- if (onMouseUp != null) onMouseUp(e);
215
- }
216
-
217
- const onMyMouseEnter = (e) => {
218
- if (onMouseEnter != null) onMouseEnter(e);
219
- }
220
-
221
- const onMyMouseLeave = (e) => {
222
- if (onMouseLeave != null) onMouseLeave(e);
223
- }
224
-
225
- const onRemoveImageClick = (e) => {
226
- if (onRemoveImage != null) onRemoveImage();
227
- }
228
-
229
- const onMyChange = async (e) => {
230
- switch (type) {
231
- case MyInputType.FILE:
232
- case MyInputType.IMAGE:
233
- let files = [];
234
-
235
- if (e.target.files.length > 0) {
236
- let totalSize = 0;
237
-
238
- for (let i = 0; i < e.target.files.length; i++) {
239
- const file = e.target.files[i];
240
-
241
- totalSize += parseInt(file.size);
242
-
243
- files.push({
244
- // file: file,
245
- base64: await toBase64(file),
246
- filename: file.name,
247
- size: file.size,
248
- sizeText: calculateFileSize(file.size)
249
- });
250
- }//for
251
-
252
- totalSize = calculateFileSize(totalSize);
253
-
254
- setMyFileName(`<span>${files.length == 1 ? files[0].filename : files.length + " Dosya Seçildi"}</span>
255
- <small>(${totalSize})</small>`);
256
- } else {
257
- setMyFileName("");
258
- }
259
-
260
- setMyValue(files);
261
-
262
- break;
263
- case MyInputType.NUMBER:
264
- let number = e.target.value.replace(/[^0-9.]/g, '');
265
-
266
- // Birden fazla nokta varsa ilkini koru
267
- const numberParts = number.split('.');
268
- if (numberParts.length > 2) {
269
- number = numberParts[0] + '.' + numberParts[1];
270
- }
271
-
272
- setMyValue(number);
273
- break;
274
- case MyInputType.MONEY:
275
- let money = moneyFormat(e.target.value);
276
- setMyValue(money);
277
- break;
278
- case MyInputType.DATE:
279
- case MyInputType.DATETIME:
280
- case MyInputType.TIME:
281
- const selectedDate = e.target.value;
282
- setMyValue(selectedDate);
283
- break;
284
- default:
285
- if (uppercase) setMyValue(e.target.value.toLocaleUpperCase("TR"));
286
- else if (lowercase) setMyValue(e.target.value.toLocaleLowerCase("TR"));
287
- else if (firstUppercase) setMyValue(e.target.value.split(' ').map(word => word.charAt(0).toLocaleUpperCase("TR") + word.slice(1).toLocaleLowerCase("TR")).join(' '));
288
- else setMyValue(e.target.value);
289
- break;
290
- }
291
- }
292
-
293
- const mySelectFilterListClick = (item) => {
294
- const selectElement = document.getElementById("mySelectFilterHiddenSelect" + myInputId);
295
- selectElement.value = item.value;
296
-
297
- setMyValue(item.value);
298
- setFiltertext("");
299
- }
300
-
301
- const getMyValueText = () => {
302
- if (!myValue || myValue == 0) return "";
303
-
304
- if (!MyInputIsNumeric(myValue) || options == null) return myValue;
305
-
306
- let result = options.find((e) => e.value.toString() == myValue.toString());
307
-
308
- if (result) return result.text + (result[options_key_subtext] ? ` - <span style="color: #73889d; font-style: italic; font-weight: 300;">${result[options_key_subtext]}</span>` : '');
309
-
310
- return "";
311
- }
312
-
313
- const filterSelectEvents = () => {
314
- const selectElement = document.getElementById("mySelectFilterSelected" + (id ? id : myInputId));
315
- const selectListElement = document.getElementById("mySelectFilterList" + (id ? id : myInputId));
316
- const filterInput = document.getElementById("mySelectFilterInput" + (id ? id : myInputId));
317
-
318
- if (!selectElement || !selectListElement || !filterInput) return;
319
-
320
- let isInputFocused = false;
321
-
322
- // Select'e tıklandığında seçim listesini aç
323
- selectElement.addEventListener('click', function () {
324
- if (!isInputFocused) {
325
- filterInput.style.display = 'block';
326
- selectListElement.style.display = 'block';
327
-
328
- setTimeout(() => {
329
- filterInput.focus();
330
- }, 100); // Gecikme, select listesi açılırken input'a odaklanması için
331
- }
332
- });
333
-
334
- // Input odaklandığında flag'i true yap
335
- filterInput.addEventListener('focus', function () {
336
- isInputFocused = true;
337
- });
338
-
339
- // Input odaktan çıktığında ve select'in blur olayında input'u gizle
340
- filterInput.addEventListener('blur', function () {
341
- isInputFocused = false;
342
-
343
- setTimeout(() => {
344
- setFiltertext("");
345
- filterInput.style.display = 'none';
346
- selectListElement.style.display = 'none';
347
- }, 150); // Gecikme ile select kapanmasını sağla
348
- });
349
- }
350
-
351
- const getFilterOptions = () => {
352
- let rv = options.filter(() => true);
353
-
354
- if (filtertext != "") {
355
- rv = rv.filter((e) => e.text.toLocaleLowerCase().includes(filtertext.toLocaleLowerCase()));
356
- }
357
-
358
- return rv;
359
- }
360
-
361
- const getFileImageControl = (filename) => {
362
- if (!filename) return false;
363
-
364
- if (filename.includes(";base64,")) return true;
365
-
366
- const validExtensions = ['.jpg', '.jpeg', '.png', '.webp', '.gif'];
367
-
368
- return validExtensions.some(ext => filename.toString().toLocaleLowerCase().includes(ext));
369
- }
370
-
371
- useEffect(() => {
372
- if (loaded) {
373
- let vl = value;
374
-
375
- if (value == undefined) vl = null;
376
- if (vl == null && (type == MyInputType.TEXT || type == MyInputType.MAIL || type == MyInputType.TEXTAREA || type == MyInputType.PASSWORD)) vl = "";
377
- // if (vl != myValue) setMyValue(vl);
378
- if (vl == null) setMyFileName(null);
379
- }
380
- }, [value]);
381
-
382
- useEffect(() => {
383
- if (myValue != value && onChange != null) {
384
- onChange({ value: myValue, target: { value: myValue } });
385
- }
386
- }, [myValue])
387
-
388
- useEffect(() => {
389
- if (title) {
390
- setMyTitleLite(title.replace(/<\/?[^>]+(>|$)/g, ""));
391
- }
392
- }, [title])
393
-
394
- useEffect(() => {
395
- setLoaded(true);
396
-
397
- if (type == MyInputType.SELECTFILTER)
398
- filterSelectEvents();
399
-
400
-
401
- if (type == MyInputType.DATE) {
402
- const dateInput = document.getElementById("myDate" + myInputId);
403
- dateInput.addEventListener('click', () => {
404
- // Tarih seçiciyi göstermek için odaklanma
405
- dateInput.showPicker?.(); // Eğer destekliyorsa
406
- });
407
- }
408
- if (type == MyInputType.DATETIME) {
409
- const dateTimeInput = document.getElementById("myDateTime" + myInputId);
410
- dateTimeInput.addEventListener('click', () => {
411
- // Tarih seçiciyi göstermek için odaklanma
412
- dateTimeInput.showPicker?.(); // Eğer destekliyorsa
413
- });
414
- }
415
- if (type == MyInputType.TIME) {
416
- const timeInput = document.getElementById("myTime" + myInputId);
417
- timeInput.addEventListener('click', () => {
418
- // Saat seçiciyi göstermek için odaklanma
419
- timeInput.showPicker?.(); // Eğer destekliyorsa
420
- });
421
- }
422
- }, [])
423
-
424
- const renderInput = () => {
425
- if (disabled || type === MyInputType.READONLY) {
426
- return (
427
- <span
428
- className={styles.disabledInput}
429
- dangerouslySetInnerHTML={dangerouslySetInnerHTML ? dangerouslySetInnerHTML : { __html: getMyValueText() }}
430
- style={(rows > 0 ? { ...(style ? style : {}), height: rows * 30 + 'px', alignItems: "flex-start" } : style)}
431
- />
432
- );
433
- }
434
-
435
- const inputTypes = {
436
- [MyInputType.TEXT]: () => (
437
- <div>
438
- <input
439
- ref={ref}
440
- id={id}
441
- type="text"
442
- value={myValue}
443
- onChange={onMyChange}
444
- placeholder={placeholder || myTitleLite}
445
- autoComplete="off"
446
- style={style}
447
- maxLength={maxlength}
448
- onBlur={onMyBlur}
449
- onFocus={onMyFocus}
450
- onKeyDown={onMyKeyDown}
451
- onKeyUp={onMyKeyUp}
452
- onKeyPress={onMyKeyPress}
453
- onMouseDown={onMyMouseDown}
454
- onMouseUp={onMyMouseUp}
455
- onMouseEnter={onMyMouseEnter}
456
- onMouseLeave={onMyMouseLeave}
457
- />
458
- </div>
459
- ),
460
-
461
- [MyInputType.MAIL]: () => (
462
- <div>
463
- <input
464
- ref={ref}
465
- id={id}
466
- type="text"
467
- value={myValue?.toLowerCase()}
468
- onChange={(e) => onMyChange({ ...e, target: { ...e.target, value: e.target.value.toLowerCase().replace(/\s/g, '') } })}
469
- placeholder={placeholder || myTitleLite}
470
- autoComplete="off"
471
- style={style}
472
- onBlur={onMyBlur}
473
- onFocus={onMyFocus}
474
- onKeyDown={onMyKeyDown}
475
- onKeyUp={onMyKeyUp}
476
- onKeyPress={onMyKeyPress}
477
- onMouseDown={onMyMouseDown}
478
- onMouseUp={onMyMouseUp}
479
- onMouseEnter={onMyMouseEnter}
480
- onMouseLeave={onMyMouseLeave}
481
- />
482
- </div>
483
- ),
484
-
485
- [MyInputType.PHONE]: () => (
486
- <div>
487
- <input
488
- ref={ref}
489
- id={id}
490
- type="text"
491
- value={myValue}
492
- onChange={(e) => {
493
- const value = e.target.value.replace(/[^0-9()-]/g, '');
494
-
495
- onMyChange({ ...e, target: { ...e.target, value } });
496
- }}
497
-
498
- placeholder={placeholder || myTitleLite}
499
- autoComplete="off"
500
- style={style}
501
- onBlur={onMyBlur}
502
- onFocus={onMyFocus}
503
- onKeyDown={onMyKeyDown}
504
- onKeyUp={onMyKeyUp}
505
- onKeyPress={onMyKeyPress}
506
- onMouseDown={onMyMouseDown}
507
- onMouseUp={onMyMouseUp}
508
- onMouseEnter={onMyMouseEnter}
509
- onMouseLeave={onMyMouseLeave}
510
- />
511
- </div>
512
- ),
513
-
514
- [MyInputType.MONEY]: () => (
515
- <div>
516
- <input
517
- ref={ref}
518
- id={id}
519
- type="text"
520
- value={moneyFormat(myValue)}
521
- onChange={onMyChange}
522
- placeholder={placeholder || myTitleLite}
523
- autoComplete="off"
524
- style={style}
525
- onBlur={onMyBlur}
526
- onFocus={onMyFocus}
527
- onKeyDown={onMyKeyDown}
528
- onKeyUp={onMyKeyUp}
529
- onKeyPress={onMyKeyPress}
530
- onMouseDown={onMyMouseDown}
531
- onMouseUp={onMyMouseUp}
532
- onMouseEnter={onMyMouseEnter}
533
- onMouseLeave={onMyMouseLeave}
534
- />
535
- </div>
536
- ),
537
-
538
- [MyInputType.NUMBER]: () => (
539
- <div>
540
- <input
541
- ref={ref}
542
- id={id}
543
- type="number"
544
- value={myValue}
545
- onChange={onMyChange}
546
- placeholder={placeholder || myTitleLite}
547
- autoComplete="off"
548
- style={style}
549
- onBlur={onMyBlur}
550
- onFocus={onMyFocus}
551
- onKeyDown={onMyKeyDown}
552
- onKeyUp={onMyKeyUp}
553
- onKeyPress={onMyKeyPress}
554
- onMouseDown={onMyMouseDown}
555
- onMouseUp={onMyMouseUp}
556
- onMouseEnter={onMyMouseEnter}
557
- onMouseLeave={onMyMouseLeave}
558
- />
559
- </div>
560
- ),
561
-
562
- [MyInputType.DATE]: () => (
563
- <div>
564
- <input
565
- ref={ref}
566
- type="date"
567
- id={"myDate" + myInputId}
568
- value={myValue || ''}
569
- onChange={onMyChange}
570
- placeholder={placeholder || myTitleLite}
571
- min={minDate}
572
- max={maxDate}
573
- style={style}
574
- onBlur={onMyBlur}
575
- onFocus={onMyFocus}
576
- onKeyDown={onMyKeyDown}
577
- onKeyUp={onMyKeyUp}
578
- onKeyPress={onMyKeyPress}
579
- onMouseDown={onMyMouseDown}
580
- onMouseUp={onMyMouseUp}
581
- onMouseEnter={onMyMouseEnter}
582
- onMouseLeave={onMyMouseLeave}
583
- />
584
- </div>
585
- ),
586
-
587
- [MyInputType.DATETIME]: () => (
588
- <div>
589
- <input
590
- ref={ref}
591
- type="datetime-local"
592
- id={"myDateTime" + myInputId}
593
- value={myValue || ''}
594
- onChange={onMyChange}
595
- placeholder={placeholder || myTitleLite}
596
- min={minDate}
597
- max={maxDate}
598
- style={style}
599
- onBlur={onMyBlur}
600
- onFocus={onMyFocus}
601
- onKeyDown={onMyKeyDown}
602
- onKeyUp={onMyKeyUp}
603
- onKeyPress={onMyKeyPress}
604
- onMouseDown={onMyMouseDown}
605
- onMouseUp={onMyMouseUp}
606
- onMouseEnter={onMyMouseEnter}
607
- onMouseLeave={onMyMouseLeave}
608
- />
609
- </div>
610
- ),
611
-
612
- [MyInputType.TIME]: () => (
613
- <div>
614
- <input
615
- ref={ref}
616
- type="time"
617
- id={"myTime" + myInputId}
618
- value={myValue || ''}
619
- onChange={onMyChange}
620
- placeholder={placeholder || myTitleLite}
621
- style={style}
622
- onBlur={onMyBlur}
623
- onFocus={onMyFocus}
624
- onKeyDown={onMyKeyDown}
625
- onKeyUp={onMyKeyUp}
626
- onKeyPress={onMyKeyPress}
627
- onMouseDown={onMyMouseDown}
628
- onMouseUp={onMyMouseUp}
629
- onMouseEnter={onMyMouseEnter}
630
- onMouseLeave={onMyMouseLeave}
631
- />
632
- </div>
633
- ),
634
-
635
- [MyInputType.PASSWORD]: () => (
636
- <div>
637
- <input
638
- ref={ref}
639
- id={id}
640
- type={myEyeView ? "text" : "password"}
641
- value={myValue}
642
- onChange={onMyChange}
643
- placeholder={placeholder || myTitleLite}
644
- autoComplete="new-password"
645
- style={style}
646
- maxLength={maxlength}
647
- onBlur={onMyBlur}
648
- onFocus={onMyFocus}
649
- onKeyDown={onMyKeyDown}
650
- onKeyUp={onMyKeyUp}
651
- onKeyPress={onMyKeyPress}
652
- onMouseDown={onMyMouseDown}
653
- onMouseUp={onMyMouseUp}
654
- onMouseEnter={onMyMouseEnter}
655
- onMouseLeave={onMyMouseLeave}
656
- />
657
- <button type="button" className={styles.eye} onClick={() => setMyEyeView(!myEyeView)}>
658
- {myEyeView ? <PiEyeSlash /> : <PiEye />}
659
- </button>
660
- </div>
661
- ),
662
-
663
- [MyInputType.COLOR]: () => (
664
- <div>
665
- <input
666
- ref={ref}
667
- id={id}
668
- type="color"
669
- value={myValue}
670
- onChange={onMyChange}
671
- placeholder={placeholder || myTitleLite}
672
- style={style}
673
- onBlur={onMyBlur}
674
- onFocus={onMyFocus}
675
- onKeyDown={onMyKeyDown}
676
- onKeyUp={onMyKeyUp}
677
- onKeyPress={onMyKeyPress}
678
- onMouseDown={onMyMouseDown}
679
- onMouseUp={onMyMouseUp}
680
- onMouseEnter={onMyMouseEnter}
681
- onMouseLeave={onMyMouseLeave}
682
- />
683
- </div>
684
- ),
685
-
686
- [MyInputType.TEXTAREA]: () => (
687
- <textarea
688
- ref={ref}
689
- id={id}
690
- onChange={onMyChange}
691
- rows={rows}
692
- placeholder={placeholder || myTitleLite}
693
- value={myValue}
694
- style={style}
695
- maxLength={maxlength}
696
- onBlur={onMyBlur}
697
- onFocus={onMyFocus}
698
- onKeyDown={onMyKeyDown}
699
- onKeyUp={onMyKeyUp}
700
- onKeyPress={onMyKeyPress}
701
- onMouseDown={onMyMouseDown}
702
- onMouseUp={onMyMouseUp}
703
- onMouseEnter={onMyMouseEnter}
704
- onMouseLeave={onMyMouseLeave}
705
- />
706
- ),
707
-
708
- [MyInputType.SELECT]: () => (
709
- <div>
710
- <select
711
- ref={ref}
712
- id={id}
713
- onChange={(e) => onMyChange(e)}
714
- value={myValue && !isNaN(myValue) ? (MyInputIsNumeric(myValue) ? parseInt(myValue) : myValue) : ""}
715
- style={style}
716
- onBlur={onMyBlur}
717
- onFocus={onMyFocus}
718
- onKeyDown={onMyKeyDown}
719
- onKeyUp={onMyKeyUp}
720
- onKeyPress={onMyKeyPress}
721
- onMouseDown={onMyMouseDown}
722
- onMouseUp={onMyMouseUp}
723
- onMouseEnter={onMyMouseEnter}
724
- onMouseLeave={onMyMouseLeave}
725
- >
726
- {options && options.map((e) => {
727
- return <option
728
- key={e[options_key_value]}
729
- value={MyInputIsNumeric(e[options_key_value]) ? parseInt(e[options_key_value]) : e[options_key_value]}
730
- >
731
- {e[options_key_text] || e["label"]}
732
- </option>;
733
- })}
734
- </select>
735
- {!myValue && !options && (placeholder || myTitleLite) && <span className={styles.placeholder}>{placeholder ? placeholder : myTitleLite}</span>}
736
- </div>
737
- ),
738
-
739
- [MyInputType.SELECTFILTER]: () => (
740
- <div>
741
- <input
742
- ref={ref}
743
- id={"mySelectFilterInput" + (id ? id : myInputId)}
744
- type="text"
745
- className={styles.filterInput}
746
- style={style}
747
- value={filtertext}
748
- onChange={(e) => setFiltertext(e.target.value)}
749
- placeholder={placeholdersearchtext && placeholdersearchtext != "" ? placeholdersearchtext : (placeholder ? placeholder : myTitleLite) + " " + t("Ara")}
750
- onBlur={onMyBlur}
751
- onFocus={onMyFocus}
752
- onKeyDown={onMyKeyDown}
753
- onKeyUp={onMyKeyUp}
754
- onKeyPress={onMyKeyPress}
755
- onMouseDown={onMyMouseDown}
756
- onMouseUp={onMyMouseUp}
757
- onMouseEnter={onMyMouseEnter}
758
- onMouseLeave={onMyMouseLeave}
759
- />
760
- <div className={styles.filterInputSelectedContainer + " " + (myValue ? styles.filterInputSelectedContainerSelected : '')}>
761
-
762
- <span
763
- id={"mySelectFilterSelected" + (id ? id : myInputId)}
764
- className={styles.filterInputSelected}
765
- dangerouslySetInnerHTML={{ __html: getMyValueText() }}
766
- >
767
- </span>
768
- {(myValue && <span className={styles.filterInputSelectedX} onClick={() => setMyValue(null)} title={t("Seçimi Kaldır")}>x</span>) || ""}
769
- <PiCaretDownBold className={styles.caretdown} />
770
- </div>
771
-
772
- {!myValue && (placeholder || myTitleLite) && <span className={styles.placeholder}>{placeholder ? placeholder : myTitleLite}</span>}
773
-
774
- <ul id={"mySelectFilterList" + (id ? id : myInputId)} className={styles.filterInputList}>
775
- {options && getFilterOptions().map((item) => {
776
- return <li
777
- key={item[options_key_value]}
778
- value={MyInputIsNumeric(item[options_key_value]) ? parseInt(item[options_key_value]) : item[options_key_value]}
779
- onClick={() => mySelectFilterListClick(item)}
780
- className={item[options_key_subtext] ? styles.subtextli : ''}
781
- >
782
- <span dangerouslySetInnerHTML={{ __html: item[options_key_text] || item["label"] }}></span>
783
- {item[options_key_subtext] && <span className={styles.subtext}>{item[options_key_subtext]}</span>}
784
- </li>;
785
- })}
786
- </ul>
787
- <div style={{ display: "none" }}>
788
- <select
789
- id={"mySelectFilterHiddenSelect" + myInputId}
790
- onChange={(e) => onMyChange(e)}
791
- value={myValue && !isNaN(myValue) ? (MyInputIsNumeric(myValue) ? parseInt(myValue) : myValue) : ""}
792
- >
793
- {options && options.map((item) => {
794
- return <option
795
- key={item[options_key_value]}
796
- value={MyInputIsNumeric(item[options_key_value]) ? parseInt(item[options_key_value]) : item[options_key_value]}
797
- >
798
- {item[options_key_text] || item["label"]}
799
- </option>;
800
- })}
801
- </select>
802
- </div>
803
- </div>
804
- ),
805
-
806
- [MyInputType.FILE]: () => (
807
- <div className={styles.fileinput}>
808
- {(() => {
809
- // Dosya önizleme gösterimi için kontrol
810
- if (myValue && (type === MyInputType.IMAGE || accept === '.jpg,.jpeg,.png')) {
811
- if (Array.isArray(myValue) && myValue.length === 1 && getFileImageControl(myValue[0].filename)) {
812
- return <img src={myValue[0].base64} className={styles.fileImagePreview} alt="Preview" />;
813
- } else if (getFileImageControl(myValue)) {
814
- return <img src={myValue} className={styles.fileImagePreview} alt="Preview" />;
815
- }
816
- }
817
- return null;
818
- })()}
819
-
820
- <div
821
- className={styles.filename + " " + (myFileName && styles.selected)}
822
- dangerouslySetInnerHTML={{
823
- __html: myFileName || (placeholder ? placeholder : t(type === MyInputType.IMAGE ? "Görsel Seçiniz" : "Dosya Seçiniz"))
824
- }}
825
- />
826
-
827
- {(() => {
828
- if (onRemoveImage && myValue && type === MyInputType.IMAGE &&
829
- (
830
- (Array.isArray(myValue) && myValue.length === 1 && getFileImageControl(myValue[0].filename)) ||
831
- (getFileImageControl(myValue) && !(myValue.includes("nologo") || myValue.includes("noimage")))
832
- )
833
- ) {
834
- return <button type="button" onClick={onRemoveImageClick} className={styles.filebuttonremove} title={t("Kaldır")}>x</button>;
835
- }
836
- return null;
837
- })()}
838
-
839
- <button
840
- type="button"
841
- onClick={() => fileInputRef.current.click()}
842
- className={styles.filebutton}
843
- >
844
- {type === MyInputType.IMAGE ? t("Görsel Seç") : t("Dosya Seç")}
845
- </button>
846
-
847
- <input
848
- type="file"
849
- ref={fileInputRef}
850
- onChange={(e) => onMyChange(e)}
851
- placeholder={placeholder || myTitleLite}
852
- style={{ display: "none" }}
853
- {... (multiple ? { multiple: true } : {})}
854
- accept={type === MyInputType.IMAGE ? '.jpg,.jpeg,.png' : accept}
855
- />
856
- </div>
857
- ),
858
-
859
- [MyInputType.IMAGE]: function () {
860
- return this[MyInputType.FILE]();
861
- },
862
- };
863
-
864
- return inputTypes[type]?.() || null;
865
- };
866
-
867
- return (
868
- <div id={"myinput" + myInputId}
869
- className={styles.container + " " + (className != null ? className : '') + " " + (isError ? styles.error : '')}
870
- title={title && myTitleLite || (placeholder && placeholder)}
871
- style={style && style.width && { display: 'inline-block' } || { width: '100%' }}>
872
- {title && <small dangerouslySetInnerHTML={{ __html: title }}></small>}
873
-
874
- <div className={styles.inputblock + " " + (disabled || type === MyInputType.READONLY ? styles.inputblockdisabled : '') + " " + (icon || type === MyInputType.IMAGE ? styles.inputblockicon : '')}
875
- style={style &&
876
- (
877
- {
878
- ...(style.backgroundColor && { backgroundColor: style.backgroundColor })
879
- }
880
- )
881
- }>
882
- {icon && (
883
- <div className={`${styles.icon} ${type === MyInputType.TEXTAREA || rows > 0 ? styles.icontextarea : ''}`}>
884
- {icon}
885
- </div>
886
- )}
887
-
888
- {renderInput()}
889
- </div>
890
-
891
- {description && <small className={styles.description}>{description}</small>}
892
-
893
- </div>
894
- )
895
- }
896
- export default MyInput