@sydsoft/base 1.47.0 → 1.49.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.
- package/README.md +8 -1
- package/{dist/esm → _dist}/_lib/baseFunctions.d.ts +0 -1
- package/{dist/esm → _dist}/_lib/baseFunctions.js +25 -38
- package/{dist/esm → _dist}/_lib/inputMask.js +66 -69
- package/{dist/esm → _dist}/_lib/listFunctions.js +12 -13
- package/_dist/_lib/storage/cookies.d.ts +4 -0
- package/_dist/_lib/storage/cookies.js +33 -0
- package/_dist/_lib/storage/encData.js +41 -0
- package/{dist/esm → _dist}/_lib/storage/localStorage.js +10 -10
- package/{dist/esm → _dist}/_lib/storage/sessionStorage.js +10 -10
- package/{dist/esm → _dist}/_lib/useInterval.js +5 -5
- package/{dist/esm → _dist}/alert/index.js +28 -30
- package/_dist/box/Box.js +14 -0
- package/_dist/box/BoxContent.js +5 -0
- package/_dist/box/BoxFooter.js +10 -0
- package/_dist/box/BoxHeader.js +10 -0
- package/_dist/countDown/index.js +92 -0
- package/{dist/esm → _dist}/dateTime/index.js +25 -31
- package/_dist/form/Button.js +82 -0
- package/_dist/form/Checkbox.js +22 -0
- package/_dist/form/Dialog.js +53 -0
- package/_dist/form/Form.js +10 -0
- package/_dist/form/FormOlustur.js +50 -0
- package/{dist/esm → _dist}/form/Input.js +57 -56
- package/_dist/form/Label.js +7 -0
- package/{dist/esm → _dist}/form/SearchableInput.d.ts +0 -1
- package/_dist/form/SearchableInput.js +260 -0
- package/_dist/form/UploadBase.js +84 -0
- package/_dist/grid/index.js +96 -0
- package/{dist/esm → _dist}/icon/icons.js +1 -1
- package/{dist/esm → _dist}/icon/index.d.ts +1 -1
- package/_dist/icon/index.js +34 -0
- package/_dist/menu/index.js +50 -0
- package/_dist/modal/index.js +64 -0
- package/{dist/esm → _dist}/popover/index.js +100 -100
- package/_dist/tooltip/index.js +202 -0
- package/_lib/baseFunctions.ts +94 -0
- package/_lib/inputMask.ts +257 -0
- package/_lib/listFunctions.ts +106 -0
- package/_lib/storage/cookies.ts +39 -0
- package/_lib/storage/encData.ts +41 -0
- package/_lib/storage/localStorage.ts +67 -0
- package/_lib/storage/sessionStorage.ts +67 -0
- package/_lib/useInterval.ts +30 -0
- package/alert/index.module.css +119 -0
- package/alert/index.tsx +131 -0
- package/box/Box.module.css +153 -0
- package/box/Box.tsx +33 -0
- package/box/BoxContent.tsx +18 -0
- package/box/BoxFooter.tsx +25 -0
- package/box/BoxHeader.tsx +46 -0
- package/box/index.ts +10 -0
- package/countDown/index.tsx +116 -0
- package/dateTime/index.ts +79 -0
- package/form/Button.tsx +143 -0
- package/form/Checkbox.tsx +48 -0
- package/form/Dialog.tsx +109 -0
- package/form/Form.tsx +19 -0
- package/form/FormOlustur.tsx +105 -0
- package/form/Input.tsx +364 -0
- package/form/Label.tsx +20 -0
- package/form/SearchableInput.tsx +406 -0
- package/form/UploadBase.tsx +133 -0
- package/form/index.ts +10 -0
- package/form/styles/Button.module.css +145 -0
- package/form/styles/Input.module.css +221 -0
- package/form/styles/Label.module.css +31 -0
- package/form/styles/SearchableInput.module.css +80 -0
- package/global.d.ts +9 -0
- package/grid/index.module.css +805 -0
- package/grid/index.tsx +171 -0
- package/icon/icons.tsx +33 -0
- package/icon/index.tsx +95 -0
- package/icon/mui.tsx +5932 -0
- package/index.ts +21 -0
- package/menu/index.module.css +92 -0
- package/menu/index.tsx +143 -0
- package/modal/index.module.css +77 -0
- package/modal/index.tsx +106 -0
- package/npm_recovery_codes.txt +5 -0
- package/package.json +18 -11
- package/popover/index.module.css +89 -0
- package/popover/index.tsx +392 -0
- package/tooltip/index.tsx +216 -0
- package/tsconfig.json +24 -0
- package/dist/esm/_lib/storage/cookies.d.ts +0 -4
- package/dist/esm/_lib/storage/cookies.js +0 -34
- package/dist/esm/_lib/storage/encData.js +0 -43
- package/dist/esm/box/Box.js +0 -15
- package/dist/esm/box/BoxContent.js +0 -7
- package/dist/esm/box/BoxFooter.js +0 -8
- package/dist/esm/box/BoxHeader.js +0 -9
- package/dist/esm/countDown/index.js +0 -97
- package/dist/esm/form/Button.js +0 -76
- package/dist/esm/form/Checkbox.js +0 -23
- package/dist/esm/form/Dialog.js +0 -40
- package/dist/esm/form/Form.js +0 -12
- package/dist/esm/form/FormOlustur.js +0 -52
- package/dist/esm/form/Label.js +0 -9
- package/dist/esm/form/SearchableInput.js +0 -272
- package/dist/esm/form/UploadBase.js +0 -86
- package/dist/esm/grid/index.js +0 -97
- package/dist/esm/icon/index.js +0 -26
- package/dist/esm/menu/index.js +0 -52
- package/dist/esm/modal/index.js +0 -66
- package/dist/esm/tooltip/index.js +0 -119
- /package/{dist/esm → _dist}/_lib/inputMask.d.ts +0 -0
- /package/{dist/esm → _dist}/_lib/listFunctions.d.ts +0 -0
- /package/{dist/esm → _dist}/_lib/storage/encData.d.ts +0 -0
- /package/{dist/esm → _dist}/_lib/storage/localStorage.d.ts +0 -0
- /package/{dist/esm → _dist}/_lib/storage/sessionStorage.d.ts +0 -0
- /package/{dist/esm → _dist}/_lib/useInterval.d.ts +0 -0
- /package/{dist/esm → _dist}/alert/index.d.ts +0 -0
- /package/{dist/esm → _dist}/alert/index.module.css +0 -0
- /package/{dist/esm → _dist}/box/Box.d.ts +0 -0
- /package/{dist/esm → _dist}/box/Box.module.css +0 -0
- /package/{dist/esm → _dist}/box/BoxContent.d.ts +0 -0
- /package/{dist/esm → _dist}/box/BoxFooter.d.ts +0 -0
- /package/{dist/esm → _dist}/box/BoxHeader.d.ts +0 -0
- /package/{dist/esm → _dist}/box/index.d.ts +0 -0
- /package/{dist/esm → _dist}/box/index.js +0 -0
- /package/{dist/esm → _dist}/countDown/index.d.ts +0 -0
- /package/{dist/esm → _dist}/dateTime/index.d.ts +0 -0
- /package/{dist/esm → _dist}/form/Button.d.ts +0 -0
- /package/{dist/esm → _dist}/form/Checkbox.d.ts +0 -0
- /package/{dist/esm → _dist}/form/Dialog.d.ts +0 -0
- /package/{dist/esm → _dist}/form/Form.d.ts +0 -0
- /package/{dist/esm → _dist}/form/FormOlustur.d.ts +0 -0
- /package/{dist/esm → _dist}/form/Input.d.ts +0 -0
- /package/{dist/esm → _dist}/form/Label.d.ts +0 -0
- /package/{dist/esm → _dist}/form/UploadBase.d.ts +0 -0
- /package/{dist/esm → _dist}/form/index.d.ts +0 -0
- /package/{dist/esm → _dist}/form/index.js +0 -0
- /package/{dist/esm → _dist}/form/styles/Button.module.css +0 -0
- /package/{dist/esm → _dist}/form/styles/Input.module.css +0 -0
- /package/{dist/esm → _dist}/form/styles/Label.module.css +0 -0
- /package/{dist/esm → _dist}/form/styles/SearchableInput.module.css +0 -0
- /package/{dist/esm → _dist}/grid/index.d.ts +0 -0
- /package/{dist/esm → _dist}/grid/index.module.css +0 -0
- /package/{dist/esm → _dist}/icon/icons.d.ts +0 -0
- /package/{dist/esm → _dist}/icon/mui.d.ts +0 -0
- /package/{dist/esm → _dist}/icon/mui.js +0 -0
- /package/{dist/esm → _dist}/index.d.ts +0 -0
- /package/{dist/esm → _dist}/index.js +0 -0
- /package/{dist/esm → _dist}/menu/index.d.ts +0 -0
- /package/{dist/esm → _dist}/menu/index.module.css +0 -0
- /package/{dist/esm → _dist}/modal/index.d.ts +0 -0
- /package/{dist/esm → _dist}/modal/index.module.css +0 -0
- /package/{dist/esm → _dist}/popover/index.d.ts +0 -0
- /package/{dist/esm → _dist}/popover/index.module.css +0 -0
- /package/{dist/esm → _dist}/tooltip/index.d.ts +0 -0
package/form/Input.tsx
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author : izzetseydaoglu
|
|
3
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
4
|
+
* @version : 2026-01-21 21:35:48
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { convertForSEO, inputTumuBuyukCevir, inputTumuKucukCevir } from '../_lib/baseFunctions';
|
|
9
|
+
|
|
10
|
+
import { applyInputMask } from '../_lib/inputMask';
|
|
11
|
+
import { alert_add } from '../alert';
|
|
12
|
+
import { Dialog } from './Dialog';
|
|
13
|
+
import styles from './styles/Input.module.css';
|
|
14
|
+
|
|
15
|
+
type maskSettingsTranslation = {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
pattern: any;
|
|
18
|
+
transform?: (value: string) => string;
|
|
19
|
+
optional?: boolean;
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type maskSettings = {
|
|
25
|
+
clearIfNotMatch?: boolean;
|
|
26
|
+
reverse?: boolean;
|
|
27
|
+
translation?: maskSettingsTranslation;
|
|
28
|
+
selectOnFocus?: boolean;
|
|
29
|
+
onChange?: (maskedValue: string, cleanValue: string, targetInput: React.ChangeEvent<HTMLInputElement>) => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export interface PropsInput {
|
|
33
|
+
componentRef?: any;
|
|
34
|
+
inputRef?: any;
|
|
35
|
+
className?: string;
|
|
36
|
+
id?: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
value?: any;
|
|
39
|
+
label?: string;
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
autoFocus?: boolean | undefined;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
type?: 'text' | 'number' | 'email' | 'color' | 'date' | 'time' | 'datetime-local' | 'hidden' | 'file' | 'password' | 'tel' | 'search';
|
|
46
|
+
|
|
47
|
+
// - Select
|
|
48
|
+
select?: any[];
|
|
49
|
+
ilkSec?: boolean;
|
|
50
|
+
valueKey?: string;
|
|
51
|
+
labelKey?: string;
|
|
52
|
+
|
|
53
|
+
// - Textarea
|
|
54
|
+
multiline?: boolean;
|
|
55
|
+
rows?: number | undefined;
|
|
56
|
+
|
|
57
|
+
//--Fonk Props
|
|
58
|
+
onChange?: (e: any) => void;
|
|
59
|
+
onFocus?: (e: any) => void;
|
|
60
|
+
onBlur?: (e: any) => void;
|
|
61
|
+
onClick?: (e: any) => void;
|
|
62
|
+
onKeyPress?: (e: any) => void;
|
|
63
|
+
onKeyUp?: (e: any) => void;
|
|
64
|
+
onKeyDown?: (e: any) => void;
|
|
65
|
+
|
|
66
|
+
//--Ozel Props
|
|
67
|
+
propsComponent?: object | any;
|
|
68
|
+
propsInput?: object;
|
|
69
|
+
startAdornment?: any;
|
|
70
|
+
endAdornment?: any;
|
|
71
|
+
|
|
72
|
+
//--Ozel Fonksiyonlar
|
|
73
|
+
sadeceYazi?: boolean;
|
|
74
|
+
sadeceSayi?: boolean;
|
|
75
|
+
tumuBuyuk?: boolean;
|
|
76
|
+
tumuKucuk?: boolean;
|
|
77
|
+
seoCevir?: boolean;
|
|
78
|
+
dosyaNoGiris?: boolean;
|
|
79
|
+
fileNameGiris?: boolean;
|
|
80
|
+
dateGecmisKontrol?: boolean;
|
|
81
|
+
autoSelectText?: boolean;
|
|
82
|
+
|
|
83
|
+
//--Mask
|
|
84
|
+
mask?: string;
|
|
85
|
+
maskSettings?: maskSettings;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const Input: React.FC<PropsInput> = ({
|
|
89
|
+
componentRef,
|
|
90
|
+
inputRef,
|
|
91
|
+
className,
|
|
92
|
+
propsComponent,
|
|
93
|
+
propsInput,
|
|
94
|
+
id,
|
|
95
|
+
name,
|
|
96
|
+
value = '',
|
|
97
|
+
type,
|
|
98
|
+
label,
|
|
99
|
+
startAdornment,
|
|
100
|
+
endAdornment,
|
|
101
|
+
placeholder,
|
|
102
|
+
onChange,
|
|
103
|
+
onFocus,
|
|
104
|
+
onBlur,
|
|
105
|
+
onClick,
|
|
106
|
+
onKeyPress,
|
|
107
|
+
onKeyUp,
|
|
108
|
+
onKeyDown,
|
|
109
|
+
disabled = false,
|
|
110
|
+
required = false,
|
|
111
|
+
loading = false,
|
|
112
|
+
autoFocus = false,
|
|
113
|
+
select,
|
|
114
|
+
valueKey = 'value',
|
|
115
|
+
labelKey = 'label',
|
|
116
|
+
ilkSec = false,
|
|
117
|
+
multiline = false,
|
|
118
|
+
rows = 2,
|
|
119
|
+
sadeceYazi,
|
|
120
|
+
sadeceSayi,
|
|
121
|
+
tumuBuyuk,
|
|
122
|
+
tumuKucuk,
|
|
123
|
+
seoCevir,
|
|
124
|
+
dosyaNoGiris,
|
|
125
|
+
fileNameGiris,
|
|
126
|
+
dateGecmisKontrol,
|
|
127
|
+
autoSelectText,
|
|
128
|
+
mask = '',
|
|
129
|
+
maskSettings = {
|
|
130
|
+
clearIfNotMatch: true,
|
|
131
|
+
reverse: false, //Tersten doldurmaya başla, fiyatlar için geçerli
|
|
132
|
+
selectOnFocus: false
|
|
133
|
+
}
|
|
134
|
+
}) => {
|
|
135
|
+
const refMain = useRef<any>(null);
|
|
136
|
+
const refInput = useRef<any>(null);
|
|
137
|
+
const refLabel = useRef<any>(null);
|
|
138
|
+
|
|
139
|
+
const [inputFilled, setInputFilled] = useState<boolean>(value && value.toString().length > 0);
|
|
140
|
+
const [focus, setFocus] = useState<boolean>(false);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (inputRef) inputRef.current = refInput.current;
|
|
144
|
+
if (componentRef) componentRef.current = refMain.current;
|
|
145
|
+
}, [componentRef, inputRef]);
|
|
146
|
+
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
autoSelectText && !select && refInput?.current && refInput.current.select();
|
|
149
|
+
}, [autoSelectText, select]);
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
const filled = String(value) && value.toString().length > 0 ? true : false;
|
|
153
|
+
setInputFilled(filled);
|
|
154
|
+
filled && refMain?.current?.classList?.remove(styles.error);
|
|
155
|
+
}, [value]);
|
|
156
|
+
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
// if (type === "number") sadeceSayi = true; //TODO: sadeceSayi burada değiştirelemez ki!!!
|
|
159
|
+
if (select && ilkSec && (value === '' || value === null || value === undefined)) {
|
|
160
|
+
if (select.length) {
|
|
161
|
+
const ilkItem = select[0][valueKey] ? select[0][valueKey] : '';
|
|
162
|
+
onChange && onChange({ target: { name, value: ilkItem } });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [select]);
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (typeof window !== 'undefined' && mask?.length > 0 && refInput?.current) {
|
|
169
|
+
refInput.current?.setAttribute('autocomplete', 'off');
|
|
170
|
+
}
|
|
171
|
+
if (mask?.length > 0 && refInput?.current) {
|
|
172
|
+
const maskInstance = applyInputMask(refInput.current, mask, {
|
|
173
|
+
...maskSettings,
|
|
174
|
+
onChange: (masked: string, clean: string, e: any) => {
|
|
175
|
+
if (onChange) {
|
|
176
|
+
onChange({ target: { name, value: masked } });
|
|
177
|
+
}
|
|
178
|
+
if (maskSettings && maskSettings.onChange) {
|
|
179
|
+
maskSettings.onChange(masked, clean, e);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
maskInstance?.setValue(value ? value : null);
|
|
184
|
+
return () => maskInstance?.destroy();
|
|
185
|
+
}
|
|
186
|
+
}, [mask]);
|
|
187
|
+
|
|
188
|
+
const Change = useCallback(
|
|
189
|
+
(e: any) => {
|
|
190
|
+
if (tumuBuyuk) inputTumuBuyukCevir(e);
|
|
191
|
+
if (tumuKucuk) inputTumuKucukCevir(e);
|
|
192
|
+
if (seoCevir) convertForSEO(e);
|
|
193
|
+
setInputFilled(e.target.value.length > 0);
|
|
194
|
+
onChange ? onChange(e) : null;
|
|
195
|
+
},
|
|
196
|
+
[onChange, seoCevir, tumuBuyuk, tumuKucuk]
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const Focus = useCallback(
|
|
200
|
+
(e: any) => {
|
|
201
|
+
onFocus ? onFocus(e) : null;
|
|
202
|
+
setFocus(true);
|
|
203
|
+
refMain?.current?.classList?.remove(styles.error);
|
|
204
|
+
},
|
|
205
|
+
[onFocus]
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
const Blur = useCallback(
|
|
209
|
+
(e: any) => {
|
|
210
|
+
if (fileNameGiris && e.target.value !== '' && /[/\\?%*:|"'<>]/g.test(e.target.value)) {
|
|
211
|
+
e.target.value = e.target.value.replace(/[/\\?%*:|"'<>]/g, '-');
|
|
212
|
+
if (onChange) onChange(e);
|
|
213
|
+
alert_add({ type: 'warning', message: 'Lütfen dosya adındaki özel karakter değiştirildi.' });
|
|
214
|
+
}
|
|
215
|
+
if (dosyaNoGiris && e.target.value !== '' && !/^[1-2]\d{3}\/\d/.test(e.target.value)) {
|
|
216
|
+
e.target.value = '';
|
|
217
|
+
if (onChange) onChange(e);
|
|
218
|
+
alert_add({ type: 'error', message: 'Lütfen doğru bir dosya numarası giriniz. Örn: 2022/123' });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (dateGecmisKontrol && e.target.value !== '') {
|
|
222
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
223
|
+
if (e.target.value < today) {
|
|
224
|
+
Dialog({
|
|
225
|
+
message: 'Geçmiş bir tarihi seçtiniz. Devam etmek istiyor musunuz?'
|
|
226
|
+
}).then((r) => {
|
|
227
|
+
if (!r) {
|
|
228
|
+
e.target.value = '';
|
|
229
|
+
if (onChange) onChange(e);
|
|
230
|
+
e.target.focus();
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (required) {
|
|
237
|
+
if (e.target.value === '') {
|
|
238
|
+
refMain?.current?.classList?.add(styles.error);
|
|
239
|
+
} else {
|
|
240
|
+
refMain?.current?.classList?.remove(styles.error);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (value !== e.target.value) {
|
|
245
|
+
onChange && onChange({ target: { name, value: e.target.value } });
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
onBlur ? onBlur(e) : null;
|
|
249
|
+
setFocus(false);
|
|
250
|
+
},
|
|
251
|
+
[fileNameGiris, dosyaNoGiris, dateGecmisKontrol, required, value, onBlur, onChange, name]
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
const Click = useCallback((e: any) => (onClick ? onClick(e) : null), [onClick]);
|
|
255
|
+
|
|
256
|
+
const KeyPress = useCallback(
|
|
257
|
+
(e: any) => {
|
|
258
|
+
if (sadeceYazi) {
|
|
259
|
+
const turkishLetters = /[ğüşıöçĞÜŞİÖÇ]/;
|
|
260
|
+
if (!(/[A-Za-z\s.]/.test(e.key) || turkishLetters.test(e.key))) {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if ((sadeceSayi || dosyaNoGiris) && (e.which < 48 || e.which > 57)) e.preventDefault();
|
|
266
|
+
if (dosyaNoGiris && e.which !== 8 && e.target.value.length === 4 && e.target.value.search('/') === -1) {
|
|
267
|
+
e.target.value = e.target.value + '/';
|
|
268
|
+
}
|
|
269
|
+
onKeyPress ? onKeyPress(e) : null;
|
|
270
|
+
},
|
|
271
|
+
[sadeceYazi, sadeceSayi, dosyaNoGiris, onKeyPress]
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const KeyUp = useCallback((e: any) => (onKeyUp ? onKeyUp(e) : null), [onKeyUp]);
|
|
275
|
+
|
|
276
|
+
const KeyDown = useCallback(
|
|
277
|
+
(e: any) => {
|
|
278
|
+
onKeyDown ? onKeyDown(e) : null;
|
|
279
|
+
},
|
|
280
|
+
[onKeyDown]
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const ortakProps = {
|
|
284
|
+
ref: refInput,
|
|
285
|
+
id,
|
|
286
|
+
name,
|
|
287
|
+
value,
|
|
288
|
+
autoFocus,
|
|
289
|
+
disabled,
|
|
290
|
+
required,
|
|
291
|
+
placeholder,
|
|
292
|
+
onChange: Change,
|
|
293
|
+
onFocus: Focus,
|
|
294
|
+
onBlur: Blur,
|
|
295
|
+
onClick: Click,
|
|
296
|
+
onKeyPress: KeyPress,
|
|
297
|
+
onKeyUp: KeyUp,
|
|
298
|
+
onKeyDown: KeyDown
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
let component;
|
|
302
|
+
if (select) {
|
|
303
|
+
component = (
|
|
304
|
+
<select className={`${styles.input} ${styles.select}`} {...ortakProps} {...propsInput}>
|
|
305
|
+
{ilkSec === false && <option value={''} />}
|
|
306
|
+
{select.map((item: any) => {
|
|
307
|
+
const value = item[valueKey];
|
|
308
|
+
const label = item[labelKey];
|
|
309
|
+
return (
|
|
310
|
+
<option key={value} value={value}>
|
|
311
|
+
{label ? label : value}
|
|
312
|
+
</option>
|
|
313
|
+
);
|
|
314
|
+
})}
|
|
315
|
+
</select>
|
|
316
|
+
);
|
|
317
|
+
} else if (multiline) {
|
|
318
|
+
component = <textarea className={`${styles.input} ${styles.textarea}`} rows={rows} {...ortakProps} {...propsInput} />;
|
|
319
|
+
} else {
|
|
320
|
+
component = <input className={`${styles.input}`} type={type} {...ortakProps} {...propsInput} />;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const classList = () => {
|
|
324
|
+
const list = ['sInputComponent', styles.component];
|
|
325
|
+
if (className) list.push(className);
|
|
326
|
+
if (label) {
|
|
327
|
+
list.push(styles.hidePlaceHolder);
|
|
328
|
+
}
|
|
329
|
+
// if (props.required && (value.length === 0 || !value)) list.push("error");
|
|
330
|
+
return list.join(' ');
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
if (propsComponent && propsComponent.hasOwnProperty('style')) {
|
|
335
|
+
const background = propsComponent.style.background ? propsComponent.style.background : propsComponent.style.backgroundColor ? propsComponent.style.backgroundColor : null;
|
|
336
|
+
if (background && refLabel.current) {
|
|
337
|
+
refLabel.current.style.setProperty('--label-bg', background);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}, [propsComponent]);
|
|
341
|
+
|
|
342
|
+
return (
|
|
343
|
+
<div ref={refMain} className={classList()} data-disabled={disabled} {...propsComponent}>
|
|
344
|
+
{startAdornment && <div className={`adornment_start ${styles.adornment} ${styles.start}`}>{startAdornment}</div>}
|
|
345
|
+
|
|
346
|
+
<div className={`${styles.inputBase} ${inputFilled || focus || type == 'date' ? styles.open : ''}`}>
|
|
347
|
+
{component}
|
|
348
|
+
{label && (
|
|
349
|
+
<div ref={refLabel} className={`label ${styles.label}`}>
|
|
350
|
+
{label}
|
|
351
|
+
{required && <span className={styles.required}>*</span>}
|
|
352
|
+
</div>
|
|
353
|
+
)}
|
|
354
|
+
</div>
|
|
355
|
+
|
|
356
|
+
{(endAdornment || loading) && (
|
|
357
|
+
<div className={`adornment_end ${styles.adornment} ${styles.end}`}>
|
|
358
|
+
{endAdornment}
|
|
359
|
+
{loading && <div className={styles.loading} />}
|
|
360
|
+
</div>
|
|
361
|
+
)}
|
|
362
|
+
</div>
|
|
363
|
+
);
|
|
364
|
+
};
|
package/form/Label.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Tooltip } from '../tooltip';
|
|
4
|
+
import styles from './styles/Label.module.css';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Label: React.FC<Props> = memo(function FMemo({ required = false, children, ...other }) {
|
|
12
|
+
return (
|
|
13
|
+
<label className={styles.label} {...other}>
|
|
14
|
+
{children}
|
|
15
|
+
<Tooltip title={'Zorunlu Alan'}>
|
|
16
|
+
<span className={styles.required}>{required && '*'}</span>
|
|
17
|
+
</Tooltip>
|
|
18
|
+
</label>
|
|
19
|
+
);
|
|
20
|
+
});
|