px-react-ui-components 1.0.1 → 1.0.3

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