@sydsoft/base 1.3.0 → 1.5.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 +9 -0
- package/dist/esm/_lib/baseFunctions.d.ts +5 -0
- package/dist/esm/_lib/baseFunctions.js +38 -0
- package/dist/esm/_lib/inputMask.d.ts +7 -0
- package/dist/esm/_lib/inputMask.js +228 -0
- package/dist/esm/box/Box.d.ts +9 -0
- package/dist/esm/box/Box.js +15 -0
- package/dist/esm/box/Box.module.css +152 -0
- package/dist/esm/box/BoxContent.d.ts +9 -0
- package/dist/esm/box/BoxContent.js +7 -0
- package/dist/esm/box/BoxFooter.d.ts +10 -0
- package/dist/esm/box/BoxFooter.js +8 -0
- package/dist/esm/box/BoxHeader.d.ts +16 -0
- package/dist/esm/box/BoxHeader.js +9 -0
- package/dist/esm/box/index.d.ts +9 -0
- package/dist/esm/box/index.js +9 -0
- package/dist/esm/form/Button.d.ts +27 -0
- package/dist/esm/form/Button.js +76 -0
- package/dist/esm/form/Checkbox.d.ts +23 -0
- package/dist/esm/form/Checkbox.js +23 -0
- package/dist/esm/form/Dialog.d.ts +19 -0
- package/dist/esm/form/Dialog.js +40 -0
- package/dist/esm/form/Form.d.ts +10 -0
- package/dist/esm/form/Form.js +12 -0
- package/dist/esm/form/FormOlustur.d.ts +39 -0
- package/dist/esm/form/FormOlustur.js +51 -0
- package/dist/esm/form/Input.d.ts +62 -0
- package/dist/esm/form/Input.js +207 -0
- package/dist/esm/form/Label.d.ts +7 -0
- package/dist/esm/form/Label.js +12 -0
- package/dist/esm/form/SearchableInput.d.ts +35 -0
- package/dist/esm/form/SearchableInput.js +313 -0
- package/dist/esm/form/UploadBase.d.ts +25 -0
- package/dist/esm/form/UploadBase.js +86 -0
- package/dist/esm/form/index.d.ts +9 -0
- package/dist/esm/form/index.js +9 -0
- package/dist/esm/form/styles/Button.module.css +144 -0
- package/dist/esm/form/styles/Input.module.css +220 -0
- package/dist/esm/form/styles/Label.module.css +31 -0
- package/dist/esm/form/styles/SearchableInput.module.css +79 -0
- package/dist/esm/grid/index.d.ts +37 -0
- package/dist/esm/grid/index.js +63 -0
- package/dist/esm/grid/index.module.css +805 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/modal/index.d.ts +23 -0
- package/dist/esm/modal/index.js +66 -0
- package/dist/esm/modal/index.module.css +74 -0
- package/dist/esm/popover/index.d.ts +12 -0
- package/dist/esm/popover/index.js +142 -0
- package/dist/esm/tooltip/index.d.ts +11 -0
- package/dist/esm/tooltip/index.js +119 -0
- package/package.json +10 -6
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/global.d.ts +0 -2
- package/tsconfig.json +0 -22
- /package/dist/{alert → esm/alert}/index.d.ts +0 -0
- /package/dist/{alert → esm/alert}/index.js +0 -0
- /package/dist/{alert → esm/alert}/index.module.css +0 -0
- /package/dist/{datetime → esm/datetime}/index.d.ts +0 -0
- /package/dist/{datetime → esm/datetime}/index.js +0 -0
- /package/dist/{icon → esm/icon}/index.d.ts +0 -0
- /package/dist/{icon → esm/icon}/index.js +0 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { __assign, __rest, __spreadArray } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Input } from "./Input";
|
|
4
|
+
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Button } from "./Button";
|
|
6
|
+
import { Icon } from "../icon";
|
|
7
|
+
import { isDev } from "../_lib/baseFunctions";
|
|
8
|
+
import styles from "./styles/SearchableInput.module.css";
|
|
9
|
+
var Component = function (_a, forwardedRef) {
|
|
10
|
+
var _b = _a.api, api = _b === void 0 ? false : _b, onText = _a.onText, onSelect = _a.onSelect, onLoad = _a.onLoad, _c = _a.newCreate, newCreate = _c === void 0 ? false : _c, name = _a.name, value = _a.value, _d = _a.autoCompleteList, autoCompleteList = _d === void 0 ? [] : _d, itemComponent = _a.itemComponent, onChange = _a.onChange, inputRef = _a.inputRef, _e = _a.valueKey, valueKey = _e === void 0 ? "value" : _e, _f = _a.labelKey, labelKey = _f === void 0 ? "label" : _f, placeholder = _a.placeholder, endAdornment = _a.endAdornment, refModal = _a.refModal, style = _a.style, disabled = _a.disabled, parentInputValue = _a.parentInputValue, listPositionRelative = _a.listPositionRelative, other = __rest(_a, ["api", "onText", "onSelect", "onLoad", "newCreate", "name", "value", "autoCompleteList", "itemComponent", "onChange", "inputRef", "valueKey", "labelKey", "placeholder", "endAdornment", "refModal", "style", "disabled", "parentInputValue", "listPositionRelative"]);
|
|
11
|
+
var refMain = useRef(null);
|
|
12
|
+
var refInput = useRef(null);
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
if (inputRef)
|
|
15
|
+
inputRef.current = refInput.current;
|
|
16
|
+
}, [refInput.current]);
|
|
17
|
+
var refComponentInput = useRef();
|
|
18
|
+
var refList = useRef();
|
|
19
|
+
var _g = useState(autoCompleteList), data = _g[0], setData = _g[1];
|
|
20
|
+
var _h = useState(""), text = _h[0], setText = _h[1]; //Inputta görünen
|
|
21
|
+
var _j = useState(""), filter = _j[0], setFilter = _j[1]; // Filtrelemeye tabi tutulan
|
|
22
|
+
var _k = useState(false), open = _k[0], setOpen = _k[1];
|
|
23
|
+
var _l = useState(api), loading = _l[0], setLoading = _l[1];
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
if (onLoad)
|
|
26
|
+
onLoad(value !== null && value !== void 0 ? value : "");
|
|
27
|
+
}, []);
|
|
28
|
+
useImperativeHandle(forwardedRef, function () { return ({
|
|
29
|
+
open: function () { return setOpen(true); },
|
|
30
|
+
close: function () { return setOpen(false); },
|
|
31
|
+
checkByValue: function (value, openList) {
|
|
32
|
+
if (openList === void 0) { openList = false; }
|
|
33
|
+
return checkByValue(value, openList);
|
|
34
|
+
},
|
|
35
|
+
setLoading: function (value) { return setLoading(value); },
|
|
36
|
+
setAutoCompleteList: function (list, value) {
|
|
37
|
+
if (value === void 0) { value = null; }
|
|
38
|
+
setData(list);
|
|
39
|
+
if (value)
|
|
40
|
+
checkByValue(value, false, list);
|
|
41
|
+
setLoading(false);
|
|
42
|
+
},
|
|
43
|
+
clear: function (openList, focusInput) {
|
|
44
|
+
if (openList === void 0) { openList = false; }
|
|
45
|
+
if (focusInput === void 0) { focusInput = false; }
|
|
46
|
+
return clear(openList, focusInput);
|
|
47
|
+
}
|
|
48
|
+
}); });
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
if (parentInputValue) {
|
|
51
|
+
clear(false);
|
|
52
|
+
}
|
|
53
|
+
}, [parentInputValue]);
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (!api && Object.keys(data).length > 0)
|
|
56
|
+
checkByValue(value, open);
|
|
57
|
+
// if (Object.keys(data).length > 0) checkByValue(value, open);
|
|
58
|
+
isDev && console.log("useDeepCompareEffect =>", name, "data");
|
|
59
|
+
}, [data]);
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
if (Object.keys(data).length > 0) {
|
|
62
|
+
if (value && value.toString().length > 0) {
|
|
63
|
+
checkByValue(value, open);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
if (!api)
|
|
67
|
+
clear(false);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
isDev && console.log("useEffect-value =>", name, value);
|
|
71
|
+
}, [value]);
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
var checkHideBackDrop = function (e) {
|
|
74
|
+
if (open && refMain.current && !refMain.current.contains(e.target)) {
|
|
75
|
+
checkByInput();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var checkESC = function (e) {
|
|
79
|
+
if (e.keyCode === 27 || e.key === "Escape" || e.code === "Escape")
|
|
80
|
+
checkByInput();
|
|
81
|
+
};
|
|
82
|
+
window.addEventListener("mousedown", checkHideBackDrop);
|
|
83
|
+
if (refMain.current)
|
|
84
|
+
refMain.current.addEventListener("keydown", checkESC);
|
|
85
|
+
return function () {
|
|
86
|
+
window.removeEventListener("mousedown", checkHideBackDrop);
|
|
87
|
+
if (refMain.current)
|
|
88
|
+
refMain.current.removeEventListener("keydown", checkESC);
|
|
89
|
+
};
|
|
90
|
+
}, [data, open]);
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
if (refModal && refModal.current) {
|
|
93
|
+
if (open) {
|
|
94
|
+
refModal.current.style.overflow = "visible";
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
refModal.current.style.overflow = "auto overlay";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (open) {
|
|
101
|
+
setScrollPosition();
|
|
102
|
+
if (refModal && refModal.current && refMain && refMain.current) {
|
|
103
|
+
refModal.current.scrollTop = refMain.current.offsetTop + 300;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, [open]);
|
|
107
|
+
var cevirTumuKucuk = function (text) {
|
|
108
|
+
if (text === void 0) { text = ""; }
|
|
109
|
+
return text.toString().toLocaleLowerCase("tr-TR");
|
|
110
|
+
};
|
|
111
|
+
var convertForSearch = function (value) {
|
|
112
|
+
var data = cevirTumuKucuk(value);
|
|
113
|
+
data = data.replace(/ö/g, "o");
|
|
114
|
+
data = data.replace(/ç/g, "c");
|
|
115
|
+
data = data.replace(/ş/g, "s");
|
|
116
|
+
data = data.replace(/ı/g, "i");
|
|
117
|
+
data = data.replace(/ğ/g, "g");
|
|
118
|
+
data = data.replace(/ü/g, "u");
|
|
119
|
+
data = data.replace(/[^a-z\d]/g, ""); // %_- are allowed
|
|
120
|
+
data = data.replace(/^\s+|\s+$/g, "");
|
|
121
|
+
return data;
|
|
122
|
+
};
|
|
123
|
+
var filteredData = useMemo(function () {
|
|
124
|
+
var _a;
|
|
125
|
+
var list;
|
|
126
|
+
if (filter.length > 0) {
|
|
127
|
+
list = Object.values(data).filter(function (item) {
|
|
128
|
+
return convertForSearch(item[labelKey]).includes(convertForSearch(filter)) || item[labelKey] == filter;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
list = data;
|
|
133
|
+
}
|
|
134
|
+
if (newCreate && text.length > 0) {
|
|
135
|
+
var filterText = Object.values(data).find(function (item) { return item[labelKey].toString().toLowerCase() === text.toString().toLowerCase(); });
|
|
136
|
+
if (!filterText) {
|
|
137
|
+
list = __spreadArray([(_a = {}, _a[labelKey] = text, _a[valueKey] = text, _a.create = true, _a)], list, true);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return list;
|
|
141
|
+
}, [data, filter]);
|
|
142
|
+
var Change = function (e) {
|
|
143
|
+
setValue(false, true);
|
|
144
|
+
setText(e.target.value);
|
|
145
|
+
setFilter(e.target.value);
|
|
146
|
+
setOpen(true);
|
|
147
|
+
if (onText)
|
|
148
|
+
onText(e.target.value);
|
|
149
|
+
};
|
|
150
|
+
var setValue = function (result, openList) {
|
|
151
|
+
setOpen(openList);
|
|
152
|
+
var newValue = result && result[valueKey] ? result[valueKey] : "";
|
|
153
|
+
if (result) {
|
|
154
|
+
var newLabel = result && result[labelKey] ? result[labelKey] : "";
|
|
155
|
+
setText(newLabel);
|
|
156
|
+
}
|
|
157
|
+
setFilter("");
|
|
158
|
+
if (onChange && newValue != value) {
|
|
159
|
+
isDev && console.log("onChange =>", name, "yeni:" + newValue, "eski:" + value);
|
|
160
|
+
onChange({
|
|
161
|
+
target: {
|
|
162
|
+
name: name,
|
|
163
|
+
value: newValue
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (onSelect)
|
|
168
|
+
onSelect(result);
|
|
169
|
+
};
|
|
170
|
+
var checkByValue = function (value, openList, list) {
|
|
171
|
+
if (openList === void 0) { openList = false; }
|
|
172
|
+
if (list === void 0) { list = []; }
|
|
173
|
+
var targetList = list.length > 0 ? list : data;
|
|
174
|
+
var find = Object.values(targetList).find(function (item) { return cevirTumuKucuk(item[valueKey]) === cevirTumuKucuk(value); });
|
|
175
|
+
setValue(find, openList);
|
|
176
|
+
};
|
|
177
|
+
var checkByInput = function () {
|
|
178
|
+
isDev && console.log("checkByInput =>", name, refInput.current.value, data);
|
|
179
|
+
var findByLabel = Object.values(data).find(function (item) { return cevirTumuKucuk(item[labelKey]) === cevirTumuKucuk(refInput.current.value); });
|
|
180
|
+
if (findByLabel && value == findByLabel[valueKey]) {
|
|
181
|
+
setOpen(false);
|
|
182
|
+
isDev && console.log("findByLabel - Zaten Aynı =>", name, findByLabel);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
setValue(findByLabel, false);
|
|
186
|
+
if (!findByLabel)
|
|
187
|
+
setText("");
|
|
188
|
+
if (api && !findByLabel && Object.keys(data).length === 0) {
|
|
189
|
+
if (onText)
|
|
190
|
+
onText("");
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var clear = function (openList, focusInput) {
|
|
194
|
+
var _a;
|
|
195
|
+
if (openList === void 0) { openList = true; }
|
|
196
|
+
if (focusInput === void 0) { focusInput = false; }
|
|
197
|
+
setFilter("");
|
|
198
|
+
setText("");
|
|
199
|
+
setValue(false, openList);
|
|
200
|
+
if (onText)
|
|
201
|
+
onText("");
|
|
202
|
+
if (focusInput)
|
|
203
|
+
(_a = refInput === null || refInput === void 0 ? void 0 : refInput.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
204
|
+
isDev && console.log("clear");
|
|
205
|
+
};
|
|
206
|
+
function setScrollPosition() {
|
|
207
|
+
if (refList.current) {
|
|
208
|
+
var position = 0;
|
|
209
|
+
var text_1 = refList.current.querySelector("li.item.selected");
|
|
210
|
+
if (text_1) {
|
|
211
|
+
position = text_1.offsetTop - 35;
|
|
212
|
+
}
|
|
213
|
+
else if (refList.current.querySelector("li.item.active")) {
|
|
214
|
+
position = refList.current.querySelector("li.item.active").offsetTop - 35;
|
|
215
|
+
}
|
|
216
|
+
refList.current.scrollTop = position;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
var onKeyDown = function (e) {
|
|
220
|
+
if (!open)
|
|
221
|
+
return null;
|
|
222
|
+
function selectEnter() {
|
|
223
|
+
var text = refList.current.querySelector("li.item.selected");
|
|
224
|
+
if (text) {
|
|
225
|
+
checkByValue(text.dataset.value);
|
|
226
|
+
}
|
|
227
|
+
else if (refList.current.querySelectorAll("li.item").length > 0) {
|
|
228
|
+
checkByValue(refList.current.querySelectorAll("li.item")[0].dataset.value);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
clear(true, true);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function selectFirst() {
|
|
235
|
+
var showList = refList.current.querySelectorAll("li.item");
|
|
236
|
+
if (showList.length > 0) {
|
|
237
|
+
showList[0].classList.add("selected");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function selectLast() {
|
|
241
|
+
var showList = refList.current.querySelectorAll("li.item");
|
|
242
|
+
if (showList.length > 0) {
|
|
243
|
+
showList[showList.length - 1].classList.add("selected");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function selectNext(element) {
|
|
247
|
+
element.classList.remove("selected");
|
|
248
|
+
var next = element.nextElementSibling;
|
|
249
|
+
if (next && next.nodeType !== -1) {
|
|
250
|
+
if (next.classList.contains("item")) {
|
|
251
|
+
next.classList.add("selected");
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
selectNext(next);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
selectFirst();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function selectPrev(element) {
|
|
262
|
+
element.classList.remove("selected");
|
|
263
|
+
var next = element.previousElementSibling;
|
|
264
|
+
if (next && next.nodeType !== -1) {
|
|
265
|
+
if (next.classList.contains("item")) {
|
|
266
|
+
next.classList.add("selected");
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
selectPrev(next);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
selectLast();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
var selected = refList.current.querySelector("li.item.selected");
|
|
277
|
+
if (e.which == 40) {
|
|
278
|
+
if (selected) {
|
|
279
|
+
selectNext(selected);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
selectFirst();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (e.which == 38) {
|
|
286
|
+
if (selected) {
|
|
287
|
+
selectPrev(selected);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
selectLast();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else if (e.which == 35) {
|
|
294
|
+
selectLast();
|
|
295
|
+
}
|
|
296
|
+
else if (e.which == 36) {
|
|
297
|
+
selectFirst();
|
|
298
|
+
}
|
|
299
|
+
else if (e.which == 13) {
|
|
300
|
+
selectEnter();
|
|
301
|
+
}
|
|
302
|
+
else if (e.which == 9) {
|
|
303
|
+
checkByInput();
|
|
304
|
+
}
|
|
305
|
+
setScrollPosition();
|
|
306
|
+
};
|
|
307
|
+
return (_jsxs("div", { ref: refMain, className: styles.component, onKeyDown: onKeyDown, style: style, children: [_jsx(Input, __assign({}, other, { name: name, value: text, inputRef: refInput, componentRef: refComponentInput, onFocus: function () { return setOpen(true); }, onChange: Change, endAdornment: !disabled && (_jsxs("div", { style: { marginRight: 5 }, tabIndex: -1, children: [_jsx(Button, { title: "Temizle", tabIndex: -1, hidden: !(text && text.length > 0), onClick: function () { return clear(true, true); }, onlyIcon: _jsx(Icon, { iconMui: "clear", style: { color: "#444" } }) }), endAdornment, _jsx(Button, { tabIndex: -1, hidden: !(Object.keys(data).length > 0), onClick: function () { return setOpen(!open); }, onlyIcon: _jsx(Icon, { iconMui: open ? "keyboard_arrow_up" : "keyboard_arrow_down", style: { color: "#444" } }) })] })), placeholder: loading ? "Lütfen bekleyiniz..." : placeholder, loading: loading, disabled: disabled, propsInput: __assign(__assign({}, other === null || other === void 0 ? void 0 : other.propsInput), { autoComplete: "off" }) })), _jsx("div", { className: styles.listDiv, "data-relative": listPositionRelative, children: _jsxs("ul", { ref: refList, className: "".concat(styles.list, " ").concat(open ? styles.open : ""), children: [(Object.keys(filteredData).length === 0 || loading) && (_jsx("div", { className: "".concat(styles.message, " ").concat(loading ? styles.loading : ""), children: loading ? "Lütfen bekleyiniz..." : "Kayıt bulunamadı..." })), Object.values(filteredData).map(function (item, key) {
|
|
308
|
+
var itemValue = item[valueKey];
|
|
309
|
+
var itemLabel = item[labelKey];
|
|
310
|
+
return (_jsxs("li", { className: "".concat(styles.listItem, " ").concat(itemValue === value ? styles.active : ""), "data-value": itemValue, "data-label": itemLabel, onClick: function () { return setValue(item, false); }, children: [item.create && _jsx("span", { className: styles.newCreate, children: "Yeni Olu\u015Ftur: " }), itemComponent ? itemComponent(item) : itemLabel] }, key));
|
|
311
|
+
})] }) })] }));
|
|
312
|
+
};
|
|
313
|
+
export var SearchableInput = React.forwardRef(Component);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024
|
|
3
|
+
* @author: izzetseydaoglu
|
|
4
|
+
* @last-modified: 11.06.2024 02:39
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
interface Props {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
refUploadInput?: any;
|
|
10
|
+
className?: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
multiple?: boolean;
|
|
13
|
+
ext_ok?: string[];
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
maxFile?: number;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
onChange?: Function;
|
|
18
|
+
targetForm?: Function;
|
|
19
|
+
name?: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
component?: any;
|
|
22
|
+
}
|
|
23
|
+
export declare const UploadBase: ({ component, children, targetForm, onChange, name, required, multiple, maxSize, maxFile, ext_ok, style, className, refUploadInput, label }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare const uploadBase_CreateForm: (formData: any) => any;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2024
|
|
5
|
+
* @author: izzetseydaoglu
|
|
6
|
+
* @last-modified: 11.06.2024 02:39
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useRef } from "react";
|
|
9
|
+
import { alert_add } from "../alert";
|
|
10
|
+
var upload_ext_ok = ["pdf", "doc", "docx", "xls", "xlsx", "jpg", "jpeg", "png", "bmp", "tiff", "tif", "udf", "txt", "rtf", "csv", "xml", "zip", "rar"];
|
|
11
|
+
var upload_maxsize = 30;
|
|
12
|
+
var upload_maxfile = 50;
|
|
13
|
+
export var UploadBase = function (_a) {
|
|
14
|
+
var _b = _a.component, component = _b === void 0 ? "div" : _b, children = _a.children, targetForm = _a.targetForm, onChange = _a.onChange, _c = _a.name, name = _c === void 0 ? "file__" : _c, _d = _a.required, required = _d === void 0 ? true : _d, _e = _a.multiple, multiple = _e === void 0 ? false : _e, _f = _a.maxSize, maxSize = _f === void 0 ? upload_maxsize : _f, _g = _a.maxFile, maxFile = _g === void 0 ? upload_maxfile : _g, _h = _a.ext_ok, ext_ok = _h === void 0 ? upload_ext_ok : _h, style = _a.style, className = _a.className, _j = _a.refUploadInput, refUploadInput = _j === void 0 ? null : _j, label = _a.label;
|
|
15
|
+
var ref = useRef(null);
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
if (refUploadInput)
|
|
18
|
+
refUploadInput.current = ref.current;
|
|
19
|
+
}, [ref.current]);
|
|
20
|
+
var fileSelected = function (e) {
|
|
21
|
+
if (!(e.target.files.length > 0)) {
|
|
22
|
+
e.target.value = null;
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (e.target.files.length > maxFile) {
|
|
26
|
+
alert_add({ type: "error", message: "En fazla " + maxFile + " dosya seçebilirsiniz." });
|
|
27
|
+
e.target.value = null;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
var fileList = [];
|
|
31
|
+
Object.values(e.target.files).map(function (file) {
|
|
32
|
+
var size = file.size;
|
|
33
|
+
var ext = file.name.replace(/^.*\./, "").toLowerCase();
|
|
34
|
+
if (ext_ok.indexOf(ext) === -1) {
|
|
35
|
+
alert_add({ type: "error", message: "Yüklemeye çalıştığınız dosya türü desteklenmiyor. Desteklenen dosya türleri: " + ext_ok.join(", ") });
|
|
36
|
+
}
|
|
37
|
+
else if (size > maxSize * 1000000) {
|
|
38
|
+
alert_add({ type: "error", message: "En fazla " + maxSize + "MB büyüklüğündeki dosyaları seçebilirsiniz." });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
fileList.push(file);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (onChange)
|
|
45
|
+
onChange(fileList);
|
|
46
|
+
if (targetForm) {
|
|
47
|
+
var nameList_1 = [];
|
|
48
|
+
var newform_1 = {};
|
|
49
|
+
var uniqueID_1 = new Date().getTime();
|
|
50
|
+
fileList.map(function (file) {
|
|
51
|
+
var _a;
|
|
52
|
+
uniqueID_1 = uniqueID_1 + 1;
|
|
53
|
+
newform_1 = __assign(__assign({}, newform_1), (_a = {}, _a[name + uniqueID_1] = file, _a));
|
|
54
|
+
nameList_1.push(file.name);
|
|
55
|
+
});
|
|
56
|
+
targetForm(function (prev) { return (__assign(__assign({}, prev), { uploadBaseList: __assign({}, newform_1), uploadBaseListName: nameList_1.join(", ") })); });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var defaultStyle = {
|
|
60
|
+
position: "relative",
|
|
61
|
+
cursor: "pointer"
|
|
62
|
+
};
|
|
63
|
+
var Component = component.toLowerCase();
|
|
64
|
+
return (_jsxs(Component, { className: className, style: __assign(__assign({}, defaultStyle), style), "data-label": label !== null && label !== void 0 ? label : "", children: [children, _jsx("input", { ref: ref, type: "file", required: required, onChange: fileSelected, multiple: multiple, accept: ext_ok.map(function (i) { return "." + i; }).join(","), style: {
|
|
65
|
+
position: "absolute",
|
|
66
|
+
top: 0,
|
|
67
|
+
left: 0,
|
|
68
|
+
opacity: 0,
|
|
69
|
+
width: "100%",
|
|
70
|
+
height: "100%",
|
|
71
|
+
cursor: "pointer",
|
|
72
|
+
zIndex: 1
|
|
73
|
+
} })] }));
|
|
74
|
+
};
|
|
75
|
+
export var uploadBase_CreateForm = function (formData) {
|
|
76
|
+
var _a;
|
|
77
|
+
var newform = __assign({}, formData);
|
|
78
|
+
var list = (_a = formData["uploadBaseList"]) !== null && _a !== void 0 ? _a : {};
|
|
79
|
+
Object.keys(list).map(function (fileKey) {
|
|
80
|
+
var _a;
|
|
81
|
+
return (newform = __assign(__assign({}, newform), (_a = {}, _a[fileKey] = list[fileKey], _a)));
|
|
82
|
+
});
|
|
83
|
+
delete newform["uploadBaseList"];
|
|
84
|
+
delete newform["uploadBaseListName"];
|
|
85
|
+
return newform;
|
|
86
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./Button";
|
|
2
|
+
export * from "./Checkbox";
|
|
3
|
+
export * from "./Dialog";
|
|
4
|
+
export * from "./Form";
|
|
5
|
+
export * from "./FormOlustur";
|
|
6
|
+
export * from "./Input";
|
|
7
|
+
export * from "./Label";
|
|
8
|
+
export * from "./SearchableInput";
|
|
9
|
+
export * from "./UploadBase";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./Button";
|
|
2
|
+
export * from "./Checkbox";
|
|
3
|
+
export * from "./Dialog";
|
|
4
|
+
export * from "./Form";
|
|
5
|
+
export * from "./FormOlustur";
|
|
6
|
+
export * from "./Input";
|
|
7
|
+
export * from "./Label";
|
|
8
|
+
export * from "./SearchableInput";
|
|
9
|
+
export * from "./UploadBase";
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
appearance: none;
|
|
7
|
+
user-select: none;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
text-decoration: none;
|
|
11
|
+
letter-spacing: 0.03em;
|
|
12
|
+
text-transform: none;
|
|
13
|
+
border-radius: 6px;
|
|
14
|
+
color: rgba(0, 0, 0, 0.87);
|
|
15
|
+
font-family: inherit;
|
|
16
|
+
font-size: inherit;
|
|
17
|
+
line-height: inherit;
|
|
18
|
+
box-shadow: 0 3px 1px -2px rgb(0 0 0 / 20%), 0 2px 2px 0 rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
|
|
19
|
+
background-color: #e0e0e0;
|
|
20
|
+
padding: 4px 10px;
|
|
21
|
+
outline: 0;
|
|
22
|
+
border: 0;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
}
|
|
26
|
+
.button.fullwidth {
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
.button[data-button-size="small"] {
|
|
30
|
+
font-size: 0.8125rem;
|
|
31
|
+
padding: 4px 10px;
|
|
32
|
+
min-width: 64px;
|
|
33
|
+
height: 32px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.button[data-button-size="medium"] {
|
|
37
|
+
font-size: 0.875rem;
|
|
38
|
+
padding: 6px 12px;
|
|
39
|
+
min-width: 72px;
|
|
40
|
+
height: 36px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.button[data-button-size="large"] {
|
|
44
|
+
font-size: 1rem;
|
|
45
|
+
padding: 8px 16px;
|
|
46
|
+
min-width: 80px;
|
|
47
|
+
height: 40px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.button[hidden] {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.button[disabled] {
|
|
55
|
+
opacity: 0.7;
|
|
56
|
+
box-shadow: inset 0 0 20px #000000ad;
|
|
57
|
+
cursor: not-allowed;
|
|
58
|
+
}
|
|
59
|
+
.button:focus,
|
|
60
|
+
.button:hover {
|
|
61
|
+
opacity: 0.9;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.button.primary {
|
|
65
|
+
color: #fff;
|
|
66
|
+
background-color: #3772c4;
|
|
67
|
+
border-color: #1877f2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.button.secondary {
|
|
71
|
+
color: #fff;
|
|
72
|
+
background-color: #6c7573;
|
|
73
|
+
border-color: #6c757d;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.button.success {
|
|
77
|
+
color: #fff;
|
|
78
|
+
background-color: #198754;
|
|
79
|
+
border-color: #198754;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.button.danger {
|
|
83
|
+
color: #fff;
|
|
84
|
+
background-color: #dc3545;
|
|
85
|
+
border-color: #dc3545;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.button.warning {
|
|
89
|
+
color: #000;
|
|
90
|
+
background-color: #ffc107;
|
|
91
|
+
border-color: #ffc107;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.button.info {
|
|
95
|
+
color: #000;
|
|
96
|
+
background-color: #0dcaf0;
|
|
97
|
+
border-color: #0dcaf0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.button.light {
|
|
101
|
+
color: #000;
|
|
102
|
+
background-color: #f8f9fa;
|
|
103
|
+
border-color: #f8f9fa;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.button.dark {
|
|
107
|
+
color: #fff;
|
|
108
|
+
background-color: #212529;
|
|
109
|
+
border-color: #212529;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.button.link {
|
|
113
|
+
box-shadow: none;
|
|
114
|
+
background-color: transparent;
|
|
115
|
+
color: inherit;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.iconbutton {
|
|
119
|
+
padding: 8px;
|
|
120
|
+
border-radius: 50%;
|
|
121
|
+
background-color: transparent;
|
|
122
|
+
box-shadow: none;
|
|
123
|
+
color: #707274;
|
|
124
|
+
/* overflow: unset; */
|
|
125
|
+
}
|
|
126
|
+
.iconbutton:focus,
|
|
127
|
+
.iconbutton:hover {
|
|
128
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ripple {
|
|
132
|
+
content: "";
|
|
133
|
+
position: absolute;
|
|
134
|
+
border-radius: 50%;
|
|
135
|
+
transform: scale(0);
|
|
136
|
+
animation: ripple 900ms linear;
|
|
137
|
+
background-color: rgba(255, 255, 255, 0.7);
|
|
138
|
+
}
|
|
139
|
+
@keyframes ripple {
|
|
140
|
+
to {
|
|
141
|
+
transform: scale(4);
|
|
142
|
+
opacity: 0;
|
|
143
|
+
}
|
|
144
|
+
}
|