px-react-ui-components 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,86 +1,86 @@
1
- .myFileUploadContainer {
2
- display: flex;
3
- width: 100%;
4
- flex-direction: row;
5
- gap: 5px;
6
- }
7
-
8
- .myFileUploadContainer .myFileUploadContainerItem {
9
- width: 100%;
10
- padding: 5px;
11
- background-color: #f0f0f0;
12
- border-radius: 5px;
13
- border: 1px dashed #ccc;
14
- display: flex;
15
- flex-direction: row;
16
- justify-content: center;
17
- align-items: center;
18
- gap: 3px;
19
- }
20
-
21
- .myFileUploadContainer
22
- .myFileUploadContainerItem
23
- .myFileUploadContainerItemIcon {
24
- display: flex;
25
- width: 100%;
26
-
27
- flex-direction: row;
28
- justify-content: center;
29
- align-items: center;
30
- gap: 1px;
31
- }
32
-
33
- .myFileUploadContainer
34
- .myFileUploadContainerItem
35
- .myFileUploadContainerItemIcon
36
- .Icon {
37
- font-size: 35px;
38
- color: #17305b;
39
- }
40
-
41
- .myFileUploadContainer
42
- .myFileUploadContainerItem
43
- .myFileUploadContainerItemIcon
44
- .myFileUploadContainerItemIconText {
45
- width: 100%;
46
-
47
- text-align: center;
48
- font-weight: normal;
49
- color: #636363;
50
- font-size: 12px;
51
- line-height: 1.3;
52
- }
53
-
54
- .myFileUploadContainer
55
- .myFileUploadContainerItem
56
- .myFileUploadContainerItemFile {
57
- display: flex;
58
- flex-direction: row;
59
- justify-content: center;
60
- align-items: center;
61
- }
62
-
63
- .myFileUploadContainer
64
- .myFileUploadContainerItem
65
- .myFileUploadContainerItemFile
66
- .myFileUploadButton {
67
- display: flex;
68
- width: 200px;
69
- height: 35px;
70
- flex-direction: column;
71
- align-items: center;
72
- justify-content: center;
73
- gap: 10px;
74
- flex-shrink: 0;
75
- background-color: #334f7f;
76
- color: #fff;
77
- border-radius: 15px;
78
- cursor: pointer;
79
- font-size: 13px;
80
- }
81
- .myFileUploadContainer
82
- .myFileUploadContainerItem
83
- .myFileUploadContainerItemFile
84
- .myFileUploadButton:hover {
85
- background-color: #2a436a;
86
- }
1
+ .myFileUploadContainer {
2
+ display: flex;
3
+ width: 100%;
4
+ flex-direction: row;
5
+ gap: 5px;
6
+ }
7
+
8
+ .myFileUploadContainer .myFileUploadContainerItem {
9
+ width: 100%;
10
+ padding: 5px;
11
+ background-color: #f0f0f0;
12
+ border-radius: 5px;
13
+ border: 1px dashed #ccc;
14
+ display: flex;
15
+ flex-direction: row;
16
+ justify-content: center;
17
+ align-items: center;
18
+ gap: 3px;
19
+ }
20
+
21
+ .myFileUploadContainer
22
+ .myFileUploadContainerItem
23
+ .myFileUploadContainerItemIcon {
24
+ display: flex;
25
+ width: 100%;
26
+
27
+ flex-direction: row;
28
+ justify-content: center;
29
+ align-items: center;
30
+ gap: 1px;
31
+ }
32
+
33
+ .myFileUploadContainer
34
+ .myFileUploadContainerItem
35
+ .myFileUploadContainerItemIcon
36
+ .Icon {
37
+ font-size: 35px;
38
+ color: #17305b;
39
+ }
40
+
41
+ .myFileUploadContainer
42
+ .myFileUploadContainerItem
43
+ .myFileUploadContainerItemIcon
44
+ .myFileUploadContainerItemIconText {
45
+ width: 100%;
46
+
47
+ text-align: center;
48
+ font-weight: normal;
49
+ color: #636363;
50
+ font-size: 12px;
51
+ line-height: 1.3;
52
+ }
53
+
54
+ .myFileUploadContainer
55
+ .myFileUploadContainerItem
56
+ .myFileUploadContainerItemFile {
57
+ display: flex;
58
+ flex-direction: row;
59
+ justify-content: center;
60
+ align-items: center;
61
+ }
62
+
63
+ .myFileUploadContainer
64
+ .myFileUploadContainerItem
65
+ .myFileUploadContainerItemFile
66
+ .myFileUploadButton {
67
+ display: flex;
68
+ width: 200px;
69
+ height: 35px;
70
+ flex-direction: column;
71
+ align-items: center;
72
+ justify-content: center;
73
+ gap: 10px;
74
+ flex-shrink: 0;
75
+ background-color: #334f7f;
76
+ color: #fff;
77
+ border-radius: 15px;
78
+ cursor: pointer;
79
+ font-size: 13px;
80
+ }
81
+ .myFileUploadContainer
82
+ .myFileUploadContainerItem
83
+ .myFileUploadContainerItemFile
84
+ .myFileUploadButton:hover {
85
+ background-color: #2a436a;
86
+ }
@@ -7,7 +7,6 @@ exports.default = exports.MyInputType = exports.MyInputIsNumeric = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _MyInputModule = _interopRequireDefault(require("./MyInput.module.css"));
9
9
  var _pi = require("react-icons/pi");
10
- var _md = require("react-icons/md");
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -85,6 +84,8 @@ function MyInput({
85
84
  const [myTitleLite, setMyTitleLite] = (0, _react.useState)("");
86
85
  const [filtertext, setFiltertext] = (0, _react.useState)("");
87
86
  const [isError, setIsError] = (0, _react.useState)(false);
87
+ const [isTyping, setIsTyping] = (0, _react.useState)(false);
88
+ const typingTimeoutRef = (0, _react.useRef)(null);
88
89
  const toBase64 = file => new Promise((resolve, reject) => {
89
90
  const reader = new FileReader();
90
91
  reader.readAsDataURL(file);
@@ -196,56 +197,68 @@ function MyInput({
196
197
  const onRemoveImageClick = e => {
197
198
  if (onRemoveImage != null) onRemoveImage();
198
199
  };
199
- const onMyChange = async e => {
200
- switch (type) {
201
- case MyInputType.FILE:
202
- case MyInputType.IMAGE:
203
- let files = [];
204
- if (e.target.files.length > 0) {
205
- let totalSize = 0;
206
- for (let i = 0; i < e.target.files.length; i++) {
207
- const file = e.target.files[i];
208
- totalSize += parseInt(file.size);
209
- files.push({
210
- // file: file,
211
- base64: await toBase64(file),
212
- filename: file.name,
213
- size: file.size,
214
- sizeText: calculateFileSize(file.size)
215
- });
216
- } //for
200
+ const handleChange = (0, _react.useCallback)(e => {
201
+ const newValue = e.target.value;
217
202
 
218
- totalSize = calculateFileSize(totalSize);
219
- setMyFileName(`<span>${files.length == 1 ? files[0].filename : files.length + " Dosya Seçildi"}</span>
220
- <small>(${totalSize})</small>`);
221
- } else {
222
- setMyFileName("");
223
- }
224
- setMyValue(files);
225
- break;
226
- case MyInputType.NUMBER:
227
- let number = e.target.value.replace(/[^0-9.]/g, '');
203
+ // Eğer değer değişmediyse güncelleme yapma
204
+ if (newValue === myValue) return;
205
+
206
+ // Typing durumunu güncelle
207
+ setIsTyping(true);
208
+
209
+ // Önceki timeout'u temizle
210
+ if (typingTimeoutRef.current) {
211
+ clearTimeout(typingTimeoutRef.current);
212
+ }
228
213
 
229
- // Birden fazla nokta varsa ilkini koru
230
- const numberParts = number.split('.');
231
- if (numberParts.length > 2) {
232
- number = numberParts[0] + '.' + numberParts[1];
214
+ // Yeni timeout ayarla
215
+ typingTimeoutRef.current = setTimeout(() => {
216
+ setIsTyping(false);
217
+ if (onChange) {
218
+ onChange({
219
+ value: newValue,
220
+ target: {
221
+ value: newValue
222
+ }
223
+ });
224
+ }
225
+ }, 300); // 300ms gecikme
226
+
227
+ // State'i güncelle
228
+ setMyValue(newValue);
229
+ }, [myValue, onChange]);
230
+ const onMyChange = async e => {
231
+ if (type === MyInputType.FILE || type === MyInputType.IMAGE) {
232
+ let files = [];
233
+ if (e.target.files.length > 0) {
234
+ let totalSize = 0;
235
+ for (let i = 0; i < e.target.files.length; i++) {
236
+ const file = e.target.files[i];
237
+ totalSize += parseInt(file.size);
238
+ files.push({
239
+ base64: await toBase64(file),
240
+ filename: file.name,
241
+ size: file.size,
242
+ sizeText: calculateFileSize(file.size)
243
+ });
233
244
  }
234
- setMyValue(number);
235
- break;
236
- case MyInputType.MONEY:
237
- let money = moneyFormat(e.target.value);
238
- setMyValue(money);
239
- break;
240
- case MyInputType.DATE:
241
- case MyInputType.DATETIME:
242
- case MyInputType.TIME:
243
- const selectedDate = e.target.value;
244
- setMyValue(selectedDate);
245
- break;
246
- default:
247
- if (uppercase) setMyValue(e.target.value.toLocaleUpperCase("TR"));else if (lowercase) setMyValue(e.target.value.toLocaleLowerCase("TR"));else if (firstUppercase) setMyValue(e.target.value.split(' ').map(word => word.charAt(0).toLocaleUpperCase("TR") + word.slice(1).toLocaleLowerCase("TR")).join(' '));else setMyValue(e.target.value);
248
- break;
245
+ totalSize = calculateFileSize(totalSize);
246
+ setMyFileName(`<span>${files.length == 1 ? files[0].filename : files.length + " Dosya Seçildi"}</span>
247
+ <small>(${totalSize})</small>`);
248
+ } else {
249
+ setMyFileName("");
250
+ }
251
+ setMyValue(files);
252
+ if (onChange) {
253
+ onChange({
254
+ value: files,
255
+ target: {
256
+ value: files
257
+ }
258
+ });
259
+ }
260
+ } else {
261
+ handleChange(e);
249
262
  }
250
263
  };
251
264
  const mySelectFilterListClick = item => {
@@ -312,20 +325,15 @@ function MyInput({
312
325
  let vl = value;
313
326
  if (value == undefined) vl = null;
314
327
  if (vl == null && (type == MyInputType.TEXT || type == MyInputType.MAIL || type == MyInputType.TEXTAREA || type == MyInputType.PASSWORD)) vl = "";
315
- // if (vl != myValue) setMyValue(vl);
328
+ if (vl != myValue) setMyValue(vl);
316
329
  if (vl == null) setMyFileName(null);
317
330
  }
318
- }, [value]);
331
+ }, [value, loaded, type]);
319
332
  (0, _react.useEffect)(() => {
320
- if (myValue != value && onChange != null) {
321
- onChange({
322
- value: myValue,
323
- target: {
324
- value: myValue
325
- }
326
- });
333
+ if (!isTyping && value !== myValue) {
334
+ setMyValue(value);
327
335
  }
328
- }, [myValue]);
336
+ }, [value, isTyping]);
329
337
  (0, _react.useEffect)(() => {
330
338
  if (title) {
331
339
  setMyTitleLite(title.replace(/<\/?[^>]+(>|$)/g, ""));
@@ -356,6 +364,13 @@ function MyInput({
356
364
  });
357
365
  }
358
366
  }, []);
367
+ (0, _react.useEffect)(() => {
368
+ return () => {
369
+ if (typingTimeoutRef.current) {
370
+ clearTimeout(typingTimeoutRef.current);
371
+ }
372
+ };
373
+ }, []);
359
374
  const renderInput = () => {
360
375
  if (disabled || type === MyInputType.READONLY) {
361
376
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -376,8 +391,8 @@ function MyInput({
376
391
  ref: ref,
377
392
  id: id,
378
393
  type: "text",
379
- value: myValue,
380
- onChange: onMyChange,
394
+ value: myValue || '',
395
+ onChange: handleChange,
381
396
  placeholder: placeholder || myTitleLite,
382
397
  autoComplete: "off",
383
398
  style: style,
@@ -456,7 +471,7 @@ function MyInput({
456
471
  id: id,
457
472
  type: "text",
458
473
  value: moneyFormat(myValue),
459
- onChange: onMyChange,
474
+ onChange: handleChange,
460
475
  placeholder: placeholder || myTitleLite,
461
476
  autoComplete: "off",
462
477
  style: style,
@@ -477,7 +492,7 @@ function MyInput({
477
492
  id: id,
478
493
  type: "number",
479
494
  value: myValue,
480
- onChange: onMyChange,
495
+ onChange: handleChange,
481
496
  placeholder: placeholder || myTitleLite,
482
497
  autoComplete: "off",
483
498
  style: style,
@@ -498,7 +513,7 @@ function MyInput({
498
513
  type: "date",
499
514
  id: "myDate" + myInputId,
500
515
  value: myValue || '',
501
- onChange: onMyChange,
516
+ onChange: handleChange,
502
517
  placeholder: placeholder || myTitleLite,
503
518
  min: minDate,
504
519
  max: maxDate,
@@ -520,7 +535,7 @@ function MyInput({
520
535
  type: "datetime-local",
521
536
  id: "myDateTime" + myInputId,
522
537
  value: myValue || '',
523
- onChange: onMyChange,
538
+ onChange: handleChange,
524
539
  placeholder: placeholder || myTitleLite,
525
540
  min: minDate,
526
541
  max: maxDate,
@@ -542,7 +557,7 @@ function MyInput({
542
557
  type: "time",
543
558
  id: "myTime" + myInputId,
544
559
  value: myValue || '',
545
- onChange: onMyChange,
560
+ onChange: handleChange,
546
561
  placeholder: placeholder || myTitleLite,
547
562
  style: style,
548
563
  onBlur: onMyBlur,
@@ -562,7 +577,7 @@ function MyInput({
562
577
  id: id,
563
578
  type: myEyeView ? "text" : "password",
564
579
  value: myValue,
565
- onChange: onMyChange,
580
+ onChange: handleChange,
566
581
  placeholder: placeholder || myTitleLite,
567
582
  autoComplete: "new-password",
568
583
  style: style,
@@ -589,7 +604,7 @@ function MyInput({
589
604
  id: id,
590
605
  type: "color",
591
606
  value: myValue,
592
- onChange: onMyChange,
607
+ onChange: handleChange,
593
608
  placeholder: placeholder || myTitleLite,
594
609
  style: style,
595
610
  onBlur: onMyBlur,
@@ -606,7 +621,7 @@ function MyInput({
606
621
  [MyInputType.TEXTAREA]: () => /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
607
622
  ref: ref,
608
623
  id: id,
609
- onChange: onMyChange,
624
+ onChange: handleChange,
610
625
  rows: rows,
611
626
  placeholder: placeholder || myTitleLite,
612
627
  value: myValue,
@@ -626,7 +641,7 @@ function MyInput({
626
641
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("select", {
627
642
  ref: ref,
628
643
  id: id,
629
- onChange: e => onMyChange(e),
644
+ onChange: handleChange,
630
645
  value: myValue && !isNaN(myValue) ? MyInputIsNumeric(myValue) ? parseInt(myValue) : myValue : "",
631
646
  style: style,
632
647
  onBlur: onMyBlur,
@@ -658,7 +673,7 @@ function MyInput({
658
673
  style: style,
659
674
  value: filtertext,
660
675
  onChange: e => setFiltertext(e.target.value),
661
- placeholder: placeholdersearchtext && placeholdersearchtext != "" ? placeholdersearchtext : (placeholder ? placeholder : myTitleLite) + " ...",
676
+ placeholder: placeholdersearchtext && placeholdersearchtext != "" ? placeholdersearchtext : (placeholder ? placeholder : myTitleLite) + " Ara",
662
677
  onBlur: onMyBlur,
663
678
  onFocus: onMyFocus,
664
679
  onKeyDown: onMyKeyDown,
@@ -679,7 +694,7 @@ function MyInput({
679
694
  }), myValue && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
680
695
  className: _MyInputModule.default.filterInputSelectedX,
681
696
  onClick: () => setMyValue(null),
682
- title: t("Seçimi Kaldır"),
697
+ title: "Se\xE7imi Kald\u0131r",
683
698
  children: "x"
684
699
  }) || "", /*#__PURE__*/(0, _jsxRuntime.jsx)(_pi.PiCaretDownBold, {
685
700
  className: _MyInputModule.default.caretdown
@@ -711,7 +726,7 @@ function MyInput({
711
726
  },
712
727
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("select", {
713
728
  id: "mySelectFilterHiddenSelect" + myInputId,
714
- onChange: e => onMyChange(e),
729
+ onChange: handleChange,
715
730
  value: myValue && !isNaN(myValue) ? MyInputIsNumeric(myValue) ? parseInt(myValue) : myValue : "",
716
731
  children: options && options.map(item => {
717
732
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
@@ -745,7 +760,7 @@ function MyInput({
745
760
  })(), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
746
761
  className: _MyInputModule.default.filename + " " + (myFileName && _MyInputModule.default.selected),
747
762
  dangerouslySetInnerHTML: {
748
- __html: myFileName || (placeholder ? placeholder : t(type === MyInputType.IMAGE ? "Görsel Seçiniz" : "Dosya Seçiniz"))
763
+ __html: myFileName || (placeholder ? placeholder : type === MyInputType.IMAGE ? "Görsel Seçiniz" : "Dosya Seçiniz")
749
764
  }
750
765
  }), (() => {
751
766
  if (onRemoveImage && myValue && type === MyInputType.IMAGE && (Array.isArray(myValue) && myValue.length === 1 && getFileImageControl(myValue[0].filename) || getFileImageControl(myValue) && !(myValue.includes("nologo") || myValue.includes("noimage")))) {
@@ -753,7 +768,7 @@ function MyInput({
753
768
  type: "button",
754
769
  onClick: onRemoveImageClick,
755
770
  className: _MyInputModule.default.filebuttonremove,
756
- title: t("Kaldır"),
771
+ title: "Kald\u0131r",
757
772
  children: "x"
758
773
  });
759
774
  }
@@ -762,11 +777,11 @@ function MyInput({
762
777
  type: "button",
763
778
  onClick: () => fileInputRef.current.click(),
764
779
  className: _MyInputModule.default.filebutton,
765
- children: type === MyInputType.IMAGE ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_pi.PiImage, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdOutlineAttachFile, {})
780
+ children: type === MyInputType.IMAGE ? "Görsel Seç" : "Dosya Seç"
766
781
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
767
782
  type: "file",
768
783
  ref: fileInputRef,
769
- onChange: e => onMyChange(e),
784
+ onChange: handleChange,
770
785
  placeholder: placeholder || myTitleLite,
771
786
  style: {
772
787
  display: "none"