@sydsoft/base 1.53.0 → 1.56.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/{_dist → dist/esm}/_lib/baseFunctions.js +11 -24
- package/{_dist → dist/esm}/_lib/inputMask.js +3 -7
- package/{_dist → dist/esm}/_lib/listFunctions.js +2 -7
- package/dist/esm/_lib/storage/cookies.js +34 -0
- package/{_dist → dist/esm}/_lib/storage/encData.js +5 -10
- package/dist/esm/_lib/storage/localStorage.js +69 -0
- package/dist/esm/_lib/storage/sessionStorage.js +69 -0
- package/{_dist → dist/esm}/_lib/useInterval.js +5 -8
- package/{_dist → dist/esm}/alert/index.js +13 -22
- package/dist/esm/box/Box.js +15 -0
- package/dist/esm/box/BoxContent.js +7 -0
- package/dist/esm/box/BoxFooter.js +8 -0
- package/dist/esm/box/BoxHeader.js +9 -0
- package/dist/esm/box/index.js +9 -0
- package/{_dist → dist/esm}/countDown/index.js +12 -17
- package/{_dist → dist/esm}/dateTime/index.js +1 -3
- package/dist/esm/form/Button.js +76 -0
- package/dist/esm/form/Checkbox.js +23 -0
- package/dist/esm/form/Dialog.js +40 -0
- package/dist/esm/form/Form.js +12 -0
- package/{_dist → dist/esm}/form/FormOlustur.js +19 -22
- package/{_dist → dist/esm}/form/Input.js +45 -49
- package/dist/esm/form/Label.js +9 -0
- package/{_dist → dist/esm}/form/SearchableInput.js +45 -48
- package/{_dist → dist/esm}/form/UploadBase.js +16 -21
- package/dist/esm/form/index.js +9 -0
- package/dist/esm/grid/index.js +97 -0
- package/dist/esm/icon/icons.js +23 -0
- package/dist/esm/icon/index.js +26 -0
- package/dist/esm/icon/mui.js +1 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/menu/index.js +52 -0
- package/{_dist → dist/esm}/modal/index.js +13 -16
- package/{_dist → dist/esm}/popover/index.js +36 -39
- package/{_dist → dist/esm}/tooltip/index.js +6 -9
- package/package.json +8 -13
- package/_dist/_lib/storage/cookies.js +0 -41
- package/_dist/_lib/storage/localStorage.js +0 -78
- package/_dist/_lib/storage/sessionStorage.js +0 -78
- package/_dist/box/Box.js +0 -19
- package/_dist/box/BoxContent.js +0 -11
- package/_dist/box/BoxFooter.js +0 -11
- package/_dist/box/BoxHeader.js +0 -12
- package/_dist/box/index.js +0 -12
- package/_dist/form/Button.js +0 -79
- package/_dist/form/Checkbox.js +0 -28
- package/_dist/form/Dialog.js +0 -44
- package/_dist/form/Form.js +0 -15
- package/_dist/form/Label.js +0 -12
- package/_dist/form/index.js +0 -12
- package/_dist/grid/index.js +0 -104
- package/_dist/icon/icons.js +0 -26
- package/_dist/icon/index.js +0 -30
- package/_dist/icon/mui.js +0 -2
- package/_dist/index.js +0 -22
- package/_dist/menu/index.js +0 -55
- /package/{_dist → dist/esm}/_lib/baseFunctions.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/inputMask.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/listFunctions.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/storage/cookies.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/storage/encData.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/storage/localStorage.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/storage/sessionStorage.d.ts +0 -0
- /package/{_dist → dist/esm}/_lib/useInterval.d.ts +0 -0
- /package/{_dist → dist/esm}/alert/index.d.ts +0 -0
- /package/{_dist → dist/esm}/alert/index.module.css +0 -0
- /package/{_dist → dist/esm}/box/Box.d.ts +0 -0
- /package/{_dist → dist/esm}/box/Box.module.css +0 -0
- /package/{_dist → dist/esm}/box/BoxContent.d.ts +0 -0
- /package/{_dist → dist/esm}/box/BoxFooter.d.ts +0 -0
- /package/{_dist → dist/esm}/box/BoxHeader.d.ts +0 -0
- /package/{_dist → dist/esm}/box/index.d.ts +0 -0
- /package/{_dist → dist/esm}/countDown/index.d.ts +0 -0
- /package/{_dist → dist/esm}/dateTime/index.d.ts +0 -0
- /package/{_dist → dist/esm}/form/Button.d.ts +0 -0
- /package/{_dist → dist/esm}/form/Checkbox.d.ts +0 -0
- /package/{_dist → dist/esm}/form/Dialog.d.ts +0 -0
- /package/{_dist → dist/esm}/form/Form.d.ts +0 -0
- /package/{_dist → dist/esm}/form/FormOlustur.d.ts +0 -0
- /package/{_dist → dist/esm}/form/Input.d.ts +0 -0
- /package/{_dist → dist/esm}/form/Label.d.ts +0 -0
- /package/{_dist → dist/esm}/form/SearchableInput.d.ts +0 -0
- /package/{_dist → dist/esm}/form/UploadBase.d.ts +0 -0
- /package/{_dist → dist/esm}/form/index.d.ts +0 -0
- /package/{_dist → dist/esm}/form/styles/Button.module.css +0 -0
- /package/{_dist → dist/esm}/form/styles/Input.module.css +0 -0
- /package/{_dist → dist/esm}/form/styles/Label.module.css +0 -0
- /package/{_dist → dist/esm}/form/styles/SearchableInput.module.css +0 -0
- /package/{_dist → dist/esm}/grid/index.d.ts +0 -0
- /package/{_dist → dist/esm}/grid/index.module.css +0 -0
- /package/{_dist → dist/esm}/icon/icons.d.ts +0 -0
- /package/{_dist → dist/esm}/icon/index.d.ts +0 -0
- /package/{_dist → dist/esm}/icon/mui.d.ts +0 -0
- /package/{_dist → dist/esm}/index.d.ts +0 -0
- /package/{_dist → dist/esm}/menu/index.d.ts +0 -0
- /package/{_dist → dist/esm}/menu/index.module.css +0 -0
- /package/{_dist → dist/esm}/modal/index.d.ts +0 -0
- /package/{_dist → dist/esm}/modal/index.module.css +0 -0
- /package/{_dist → dist/esm}/popover/index.d.ts +0 -0
- /package/{_dist → dist/esm}/popover/index.module.css +0 -0
- /package/{_dist → dist/esm}/tooltip/index.d.ts +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import styles from "./styles/Input.module.css";
|
|
4
|
+
export var Checkbox = function (_a) {
|
|
5
|
+
var ref = _a.ref, children = _a.children, name = _a.name, label = _a.label, checked = _a.checked, className = _a.className, style = _a.style, styleCheckbox = _a.styleCheckbox, styleLabel = _a.styleLabel, onToogle = _a.onToogle, disabled = _a.disabled, tabIndex = _a.tabIndex, _b = _a.required, required = _b === void 0 ? false : _b;
|
|
6
|
+
var refMain = useRef(null);
|
|
7
|
+
// checked değerini boolean hâline getiriyoruz
|
|
8
|
+
var isChecked = checked === "1" || checked === true;
|
|
9
|
+
var handleChange = function (newChecked) {
|
|
10
|
+
if (disabled)
|
|
11
|
+
return;
|
|
12
|
+
onToogle === null || onToogle === void 0 ? void 0 : onToogle({
|
|
13
|
+
target: {
|
|
14
|
+
name: name,
|
|
15
|
+
value: newChecked ? "1" : "0"
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var toggleCheck = function () {
|
|
20
|
+
handleChange(!isChecked);
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs("div", { ref: refMain, className: "".concat(styles.checkbox, " ").concat(className || ""), style: style, tabIndex: tabIndex, onClick: toggleCheck, children: [_jsx("input", { ref: ref, type: "checkbox", name: name, onChange: function (e) { return handleChange(e.target.checked); }, checked: isChecked, required: required, style: styleCheckbox, disabled: disabled }), label && _jsx("label", { style: styleLabel, children: label }), children && _jsx("div", { children: children })] }));
|
|
23
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Box, BoxFooter } from '../box';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { Modal } from '../modal';
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
export var Dialog = function (config) {
|
|
8
|
+
return new Promise(function (resolve) {
|
|
9
|
+
if (typeof window === 'undefined')
|
|
10
|
+
return false;
|
|
11
|
+
var mainDiv = document.getElementById('sdialog');
|
|
12
|
+
if (!mainDiv) {
|
|
13
|
+
var createDiv = document.createElement('div');
|
|
14
|
+
createDiv.setAttribute('id', 'sdialog');
|
|
15
|
+
document.body.appendChild(createDiv);
|
|
16
|
+
mainDiv = createDiv;
|
|
17
|
+
}
|
|
18
|
+
var root = createRoot(mainDiv);
|
|
19
|
+
var settings = __assign({ acceptButtonShow: true, cancelButtonShow: true, acceptButtonText: 'EVET', cancelButtonText: 'HAYIR', acceptButtonClass: 'danger', cancelButtonClass: 'secondary', vertialAlign: 'center', horizontalAlign: 'center', hideBackdrop: true, hideEsc: true, styleMessage: {
|
|
20
|
+
fontSize: '1.1rem',
|
|
21
|
+
padding: '10px 20px'
|
|
22
|
+
}, styleBox: { padding: 0, margin: 0, minWidth: 250 }, styleBoxFooter: { padding: '8px 5px' }, autoFocus: 'accept' }, config);
|
|
23
|
+
var close = function () {
|
|
24
|
+
if (mainDiv) {
|
|
25
|
+
root.unmount();
|
|
26
|
+
mainDiv.remove();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var onCancel = function () {
|
|
30
|
+
resolve(false);
|
|
31
|
+
close();
|
|
32
|
+
};
|
|
33
|
+
var onAccept = function () {
|
|
34
|
+
resolve(true);
|
|
35
|
+
close();
|
|
36
|
+
};
|
|
37
|
+
var Component = (_jsx(Modal, { open: true, keepMounted: false, close: onCancel, hideBackdrop: settings.hideBackdrop, hideEsc: settings.hideEsc, hideCloseButton: true, vertialAlign: settings.vertialAlign, horizontalAlign: settings.horizontalAlign, backdropStyle: settings.backdropStyle, children: _jsxs(Box, { style: settings.styleBox, children: [_jsx("div", { className: "sbox_content", style: settings.styleMessage, dangerouslySetInnerHTML: { __html: settings.message } }), (settings.acceptButtonShow || settings.cancelButtonShow) && (_jsxs(BoxFooter, { style: settings.styleBoxFooter, children: [settings.cancelButtonShow && (_jsx(Button, { autoFocus: settings.autoFocus === 'cancel', buttonClass: settings.cancelButtonClass, onClick: onCancel, children: settings.cancelButtonText })), settings.acceptButtonShow && (_jsx(Button, { autoFocus: settings.autoFocus === 'accept', buttonClass: settings.acceptButtonClass, onClick: onAccept, children: settings.acceptButtonText }))] }))] }) }));
|
|
38
|
+
root.render(Component);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
export var Form = memo(function FunctionMemo(_a) {
|
|
5
|
+
var _b = _a.encType, encType = _b === void 0 ? "multipart/form-data" : _b, onSubmit = _a.onSubmit, style = _a.style, _c = _a.disableOnEnterSubmit, disableOnEnterSubmit = _c === void 0 ? false : _c, other = __rest(_a, ["encType", "onSubmit", "style", "disableOnEnterSubmit"]);
|
|
6
|
+
var onKeyDown = function (e) {
|
|
7
|
+
if (e.key === "Enter" && disableOnEnterSubmit) {
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
return _jsx("form", __assign({ style: style, encType: encType, onSubmit: onSubmit, onKeyDown: onKeyDown }, other));
|
|
12
|
+
});
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var baseFunctions_1 = require("../_lib/baseFunctions");
|
|
9
|
-
var Label_1 = require("./Label");
|
|
10
|
-
exports.FormOlustur = (0, react_1.memo)(function FunctionMemo(props) {
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { memo, useEffect, useMemo } from 'react';
|
|
4
|
+
import { Col, Row } from '../grid';
|
|
5
|
+
import { isDev } from '../_lib/baseFunctions';
|
|
6
|
+
import { Label } from './Label';
|
|
7
|
+
export var FormOlustur = memo(function FunctionMemo(props) {
|
|
11
8
|
var form = props.form, formOgeler = props.formOgeler, onChange = props.onChange, formType = props.formType, sabitGrid = props.sabitGrid, justifyContent = props.justifyContent, rowSpacing = props.rowSpacing, colSpacing = props.colSpacing;
|
|
12
|
-
|
|
9
|
+
useEffect(function () {
|
|
13
10
|
if (formOgeler && onChange && form) {
|
|
14
11
|
formOgeler.forEach(function (formOgeler) {
|
|
15
12
|
var _a, _b, _c, _d;
|
|
16
13
|
var fieldName = (_b = (_a = formOgeler === null || formOgeler === void 0 ? void 0 : formOgeler.component) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.name;
|
|
17
14
|
if (formOgeler.noRender && fieldName && form[fieldName] && form[fieldName] != '') {
|
|
18
|
-
|
|
15
|
+
isDev && console.log('noRenderGuncelle');
|
|
19
16
|
if ((formOgeler === null || formOgeler === void 0 ? void 0 : formOgeler.component) && ((_d = (_c = formOgeler === null || formOgeler === void 0 ? void 0 : formOgeler.component) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.name)) {
|
|
20
17
|
onChange({
|
|
21
18
|
target: {
|
|
@@ -28,28 +25,28 @@ exports.FormOlustur = (0, react_1.memo)(function FunctionMemo(props) {
|
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
27
|
}, [JSON.stringify(form), formOgeler]);
|
|
31
|
-
var result =
|
|
28
|
+
var result = useMemo(function () {
|
|
32
29
|
return formOgeler.map(function (_a, i) {
|
|
33
30
|
var noRender = _a.noRender, fullComponent = _a.fullComponent, component = _a.component, propsComponent = _a.propsComponent, propsRow = _a.propsRow, label = _a.label, propsLabel = _a.propsLabel, gridLabel = _a.gridLabel, gridInput = _a.gridInput;
|
|
34
31
|
if (noRender) {
|
|
35
32
|
return null;
|
|
36
33
|
}
|
|
37
34
|
if (fullComponent)
|
|
38
|
-
return
|
|
39
|
-
var newProps =
|
|
35
|
+
return React.cloneElement(fullComponent, { key: i });
|
|
36
|
+
var newProps = __assign({}, propsComponent);
|
|
40
37
|
if (onChange && component && !component.props.onChange) {
|
|
41
|
-
newProps =
|
|
38
|
+
newProps = __assign(__assign({}, newProps), { onChange: onChange });
|
|
42
39
|
}
|
|
43
40
|
if (onChange && form && component.props.name && !component.props.value) {
|
|
44
|
-
newProps =
|
|
41
|
+
newProps = __assign(__assign({}, newProps), { value: form[component.props.name] && form[component.props.name].length > 0 ? String(form[component.props.name]) : '' });
|
|
45
42
|
}
|
|
46
43
|
if (formType === 'label')
|
|
47
|
-
newProps =
|
|
44
|
+
newProps = __assign(__assign({}, newProps), { label: '' });
|
|
48
45
|
var detectLabel = label || component.props.label;
|
|
49
|
-
gridLabel =
|
|
50
|
-
gridInput =
|
|
51
|
-
return ((
|
|
46
|
+
gridLabel = __assign(__assign({}, sabitGrid.label), gridLabel);
|
|
47
|
+
gridInput = __assign(__assign({}, sabitGrid.input), gridInput);
|
|
48
|
+
return (_jsxs(Row, __assign({ justifyContent: justifyContent, rowSpacing: rowSpacing, colSpacing: colSpacing }, propsRow, { children: [formType === 'label' && detectLabel && (_jsx(Col, __assign({}, gridLabel, { children: _jsx(Label, __assign({ required: component.props.required }, propsLabel, { children: detectLabel })) }))), _jsx(Col, __assign({}, gridInput, { children: React.cloneElement(component, newProps) }))] }), i));
|
|
52
49
|
});
|
|
53
50
|
}, [form, formOgeler, onChange, formType, sabitGrid, justifyContent, rowSpacing, colSpacing]);
|
|
54
|
-
return (
|
|
51
|
+
return _jsx(React.Fragment, { children: result });
|
|
55
52
|
});
|
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Input = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
3
|
/**
|
|
7
4
|
* @author : izzetseydaoglu
|
|
8
5
|
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
9
6
|
* @version : 2026-01-21 21:35:48
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var Input = function (_a) {
|
|
8
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { convertForSEO, inputTumuBuyukCevir, inputTumuKucukCevir } from '../_lib/baseFunctions';
|
|
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
|
+
export var Input = function (_a) {
|
|
18
15
|
var componentRef = _a.componentRef, inputRef = _a.inputRef, className = _a.className, propsComponent = _a.propsComponent, propsInput = _a.propsInput, id = _a.id, name = _a.name, _b = _a.value, value = _b === void 0 ? '' : _b, type = _a.type, label = _a.label, startAdornment = _a.startAdornment, endAdornment = _a.endAdornment, placeholder = _a.placeholder, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, onClick = _a.onClick, onKeyPress = _a.onKeyPress, onKeyUp = _a.onKeyUp, onKeyDown = _a.onKeyDown, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.required, required = _d === void 0 ? false : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, select = _a.select, _g = _a.valueKey, valueKey = _g === void 0 ? 'value' : _g, _h = _a.labelKey, labelKey = _h === void 0 ? 'label' : _h, _j = _a.ilkSec, ilkSec = _j === void 0 ? false : _j, _k = _a.multiline, multiline = _k === void 0 ? false : _k, _l = _a.rows, rows = _l === void 0 ? 2 : _l, sadeceYazi = _a.sadeceYazi, sadeceSayi = _a.sadeceSayi, tumuBuyuk = _a.tumuBuyuk, tumuKucuk = _a.tumuKucuk, seoCevir = _a.seoCevir, dosyaNoGiris = _a.dosyaNoGiris, fileNameGiris = _a.fileNameGiris, dateGecmisKontrol = _a.dateGecmisKontrol, autoSelectText = _a.autoSelectText, _m = _a.mask, mask = _m === void 0 ? '' : _m, _o = _a.maskSettings, maskSettings = _o === void 0 ? {
|
|
19
16
|
clearIfNotMatch: true,
|
|
20
17
|
reverse: false, //Tersten doldurmaya başla, fiyatlar için geçerli
|
|
21
18
|
selectOnFocus: false
|
|
22
19
|
} : _o;
|
|
23
|
-
var refMain =
|
|
24
|
-
var refInput =
|
|
25
|
-
var refLabel =
|
|
26
|
-
var _p =
|
|
27
|
-
var _q =
|
|
28
|
-
|
|
20
|
+
var refMain = useRef(null);
|
|
21
|
+
var refInput = useRef(null);
|
|
22
|
+
var refLabel = useRef(null);
|
|
23
|
+
var _p = useState(value && value.toString().length > 0), inputFilled = _p[0], setInputFilled = _p[1];
|
|
24
|
+
var _q = useState(false), focus = _q[0], setFocus = _q[1];
|
|
25
|
+
useEffect(function () {
|
|
29
26
|
if (inputRef)
|
|
30
27
|
inputRef.current = refInput.current;
|
|
31
28
|
if (componentRef)
|
|
32
29
|
componentRef.current = refMain.current;
|
|
33
30
|
}, [componentRef, inputRef]);
|
|
34
|
-
|
|
31
|
+
useEffect(function () {
|
|
35
32
|
autoSelectText && !select && (refInput === null || refInput === void 0 ? void 0 : refInput.current) && refInput.current.select();
|
|
36
33
|
}, [autoSelectText, select]);
|
|
37
|
-
|
|
34
|
+
useEffect(function () {
|
|
38
35
|
var _a, _b;
|
|
39
36
|
var filled = String(value) && value.toString().length > 0 ? true : false;
|
|
40
37
|
setInputFilled(filled);
|
|
41
|
-
filled && ((_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(
|
|
38
|
+
filled && ((_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(styles.error));
|
|
42
39
|
}, [value]);
|
|
43
|
-
|
|
40
|
+
useEffect(function () {
|
|
44
41
|
// if (type === "number") sadeceSayi = true; //TODO: sadeceSayi burada değiştirelemez ki!!!
|
|
45
42
|
if (select && ilkSec && (value === '' || value === null || value === undefined)) {
|
|
46
43
|
if (select.length) {
|
|
@@ -49,13 +46,13 @@ var Input = function (_a) {
|
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
}, [select]);
|
|
52
|
-
|
|
49
|
+
useEffect(function () {
|
|
53
50
|
var _a;
|
|
54
51
|
if (typeof window !== 'undefined' && (mask === null || mask === void 0 ? void 0 : mask.length) > 0 && (refInput === null || refInput === void 0 ? void 0 : refInput.current)) {
|
|
55
52
|
(_a = refInput.current) === null || _a === void 0 ? void 0 : _a.setAttribute('autocomplete', 'off');
|
|
56
53
|
}
|
|
57
54
|
if ((mask === null || mask === void 0 ? void 0 : mask.length) > 0 && (refInput === null || refInput === void 0 ? void 0 : refInput.current)) {
|
|
58
|
-
var maskInstance_1 =
|
|
55
|
+
var maskInstance_1 = applyInputMask(refInput.current, mask, __assign(__assign({}, maskSettings), { onChange: function (masked, clean, e) {
|
|
59
56
|
if (onChange) {
|
|
60
57
|
onChange({ target: { name: name, value: masked } });
|
|
61
58
|
}
|
|
@@ -67,40 +64,40 @@ var Input = function (_a) {
|
|
|
67
64
|
return function () { return maskInstance_1 === null || maskInstance_1 === void 0 ? void 0 : maskInstance_1.destroy(); };
|
|
68
65
|
}
|
|
69
66
|
}, [mask]);
|
|
70
|
-
var Change =
|
|
67
|
+
var Change = useCallback(function (e) {
|
|
71
68
|
if (tumuBuyuk)
|
|
72
|
-
|
|
69
|
+
inputTumuBuyukCevir(e);
|
|
73
70
|
if (tumuKucuk)
|
|
74
|
-
|
|
71
|
+
inputTumuKucukCevir(e);
|
|
75
72
|
if (seoCevir)
|
|
76
|
-
|
|
73
|
+
convertForSEO(e);
|
|
77
74
|
setInputFilled(e.target.value.length > 0);
|
|
78
75
|
onChange ? onChange(e) : null;
|
|
79
76
|
}, [onChange, seoCevir, tumuBuyuk, tumuKucuk]);
|
|
80
|
-
var Focus =
|
|
77
|
+
var Focus = useCallback(function (e) {
|
|
81
78
|
var _a, _b;
|
|
82
79
|
onFocus ? onFocus(e) : null;
|
|
83
80
|
setFocus(true);
|
|
84
|
-
(_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(
|
|
81
|
+
(_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(styles.error);
|
|
85
82
|
}, [onFocus]);
|
|
86
|
-
var Blur =
|
|
83
|
+
var Blur = useCallback(function (e) {
|
|
87
84
|
var _a, _b, _c, _d;
|
|
88
85
|
if (fileNameGiris && e.target.value !== '' && /[/\\?%*:|"'<>]/g.test(e.target.value)) {
|
|
89
86
|
e.target.value = e.target.value.replace(/[/\\?%*:|"'<>]/g, '-');
|
|
90
87
|
if (onChange)
|
|
91
88
|
onChange(e);
|
|
92
|
-
|
|
89
|
+
alert_add({ type: 'warning', message: 'Lütfen dosya adındaki özel karakter değiştirildi.' });
|
|
93
90
|
}
|
|
94
91
|
if (dosyaNoGiris && e.target.value !== '' && !/^[1-2]\d{3}\/\d/.test(e.target.value)) {
|
|
95
92
|
e.target.value = '';
|
|
96
93
|
if (onChange)
|
|
97
94
|
onChange(e);
|
|
98
|
-
|
|
95
|
+
alert_add({ type: 'error', message: 'Lütfen doğru bir dosya numarası giriniz. Örn: 2022/123' });
|
|
99
96
|
}
|
|
100
97
|
if (dateGecmisKontrol && e.target.value !== '') {
|
|
101
98
|
var today = new Date().toISOString().slice(0, 10);
|
|
102
99
|
if (e.target.value < today) {
|
|
103
|
-
|
|
100
|
+
Dialog({
|
|
104
101
|
message: 'Geçmiş bir tarihi seçtiniz. Devam etmek istiyor musunuz?'
|
|
105
102
|
}).then(function (r) {
|
|
106
103
|
if (!r) {
|
|
@@ -114,10 +111,10 @@ var Input = function (_a) {
|
|
|
114
111
|
}
|
|
115
112
|
if (required) {
|
|
116
113
|
if (e.target.value === '') {
|
|
117
|
-
(_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add(
|
|
114
|
+
(_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add(styles.error);
|
|
118
115
|
}
|
|
119
116
|
else {
|
|
120
|
-
(_d = (_c = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _c === void 0 ? void 0 : _c.classList) === null || _d === void 0 ? void 0 : _d.remove(
|
|
117
|
+
(_d = (_c = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _c === void 0 ? void 0 : _c.classList) === null || _d === void 0 ? void 0 : _d.remove(styles.error);
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
if (value !== e.target.value) {
|
|
@@ -126,8 +123,8 @@ var Input = function (_a) {
|
|
|
126
123
|
onBlur ? onBlur(e) : null;
|
|
127
124
|
setFocus(false);
|
|
128
125
|
}, [fileNameGiris, dosyaNoGiris, dateGecmisKontrol, required, value, onBlur, onChange, name]);
|
|
129
|
-
var Click =
|
|
130
|
-
var KeyPress =
|
|
126
|
+
var Click = useCallback(function (e) { return (onClick ? onClick(e) : null); }, [onClick]);
|
|
127
|
+
var KeyPress = useCallback(function (e) {
|
|
131
128
|
if (sadeceYazi) {
|
|
132
129
|
var turkishLetters = /[ğüşıöçĞÜŞİÖÇ]/;
|
|
133
130
|
if (!(/[A-Za-z\s.]/.test(e.key) || turkishLetters.test(e.key))) {
|
|
@@ -142,8 +139,8 @@ var Input = function (_a) {
|
|
|
142
139
|
}
|
|
143
140
|
onKeyPress ? onKeyPress(e) : null;
|
|
144
141
|
}, [sadeceYazi, sadeceSayi, dosyaNoGiris, onKeyPress]);
|
|
145
|
-
var KeyUp =
|
|
146
|
-
var KeyDown =
|
|
142
|
+
var KeyUp = useCallback(function (e) { return (onKeyUp ? onKeyUp(e) : null); }, [onKeyUp]);
|
|
143
|
+
var KeyDown = useCallback(function (e) {
|
|
147
144
|
onKeyDown ? onKeyDown(e) : null;
|
|
148
145
|
}, [onKeyDown]);
|
|
149
146
|
var ortakProps = {
|
|
@@ -165,29 +162,29 @@ var Input = function (_a) {
|
|
|
165
162
|
};
|
|
166
163
|
var component;
|
|
167
164
|
if (select) {
|
|
168
|
-
component = ((
|
|
165
|
+
component = (_jsxs("select", __assign({ className: "".concat(styles.input, " ").concat(styles.select) }, ortakProps, propsInput, { children: [ilkSec === false && _jsx("option", { value: '' }), select.map(function (item) {
|
|
169
166
|
var value = item[valueKey];
|
|
170
167
|
var label = item[labelKey];
|
|
171
|
-
return ((
|
|
168
|
+
return (_jsx("option", { value: value, children: label ? label : value }, value));
|
|
172
169
|
})] })));
|
|
173
170
|
}
|
|
174
171
|
else if (multiline) {
|
|
175
|
-
component = (
|
|
172
|
+
component = _jsx("textarea", __assign({ className: "".concat(styles.input, " ").concat(styles.textarea), rows: rows }, ortakProps, propsInput));
|
|
176
173
|
}
|
|
177
174
|
else {
|
|
178
|
-
component = (
|
|
175
|
+
component = _jsx("input", __assign({ className: "".concat(styles.input), type: type }, ortakProps, propsInput));
|
|
179
176
|
}
|
|
180
177
|
var classList = function () {
|
|
181
|
-
var list = ['sInputComponent',
|
|
178
|
+
var list = ['sInputComponent', styles.component];
|
|
182
179
|
if (className)
|
|
183
180
|
list.push(className);
|
|
184
181
|
if (label) {
|
|
185
|
-
list.push(
|
|
182
|
+
list.push(styles.hidePlaceHolder);
|
|
186
183
|
}
|
|
187
184
|
// if (props.required && (value.length === 0 || !value)) list.push("error");
|
|
188
185
|
return list.join(' ');
|
|
189
186
|
};
|
|
190
|
-
|
|
187
|
+
useEffect(function () {
|
|
191
188
|
if (propsComponent && propsComponent.hasOwnProperty('style')) {
|
|
192
189
|
var background = propsComponent.style.background ? propsComponent.style.background : propsComponent.style.backgroundColor ? propsComponent.style.backgroundColor : null;
|
|
193
190
|
if (background && refLabel.current) {
|
|
@@ -195,6 +192,5 @@ var Input = function (_a) {
|
|
|
195
192
|
}
|
|
196
193
|
}
|
|
197
194
|
}, [propsComponent]);
|
|
198
|
-
return ((
|
|
195
|
+
return (_jsxs("div", __assign({ ref: refMain, className: classList(), "data-disabled": disabled }, propsComponent, { children: [startAdornment && _jsx("div", { className: "adornment_start ".concat(styles.adornment, " ").concat(styles.start), children: startAdornment }), _jsxs("div", { className: "".concat(styles.inputBase, " ").concat(inputFilled || focus || type == 'date' ? styles.open : ''), children: [component, label && (_jsxs("div", { ref: refLabel, className: "label ".concat(styles.label), children: [label, required && _jsx("span", { className: styles.required, children: "*" })] }))] }), (endAdornment || loading) && (_jsxs("div", { className: "adornment_end ".concat(styles.adornment, " ").concat(styles.end), children: [endAdornment, loading && _jsx("div", { className: styles.loading })] }))] })));
|
|
199
196
|
};
|
|
200
|
-
exports.Input = Input;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { Tooltip } from '../tooltip';
|
|
5
|
+
import styles from './styles/Label.module.css';
|
|
6
|
+
export var Label = memo(function FMemo(_a) {
|
|
7
|
+
var _b = _a.required, required = _b === void 0 ? false : _b, children = _a.children, other = __rest(_a, ["required", "children"]);
|
|
8
|
+
return (_jsxs("label", __assign({ className: styles.label }, other, { children: [children, _jsx(Tooltip, { title: 'Zorunlu Alan', children: _jsx("span", { className: styles.required, children: required && '*' }) })] })));
|
|
9
|
+
});
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
var _r = (0, react_1.useState)(false), open = _r[0], setOpen = _r[1];
|
|
24
|
-
var _s = (0, react_1.useState)(isDataFromApi && (!autoCompleteList || (autoCompleteList === null || autoCompleteList === void 0 ? void 0 : autoCompleteList.length) == 0)), loading = _s[0], setLoading = _s[1];
|
|
25
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
1
|
+
import { __assign, __rest, __spreadArray } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Input } from './index';
|
|
4
|
+
import { convertForSearch, convertLowerCase } from '../_lib/baseFunctions';
|
|
5
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { onKeyboardSelection, setScrollListPosition } from '../_lib/listFunctions';
|
|
7
|
+
import { Icon } from '../icon';
|
|
8
|
+
import styles from './styles/SearchableInput.module.css';
|
|
9
|
+
export var SearchableInput = forwardRef(function (_a, ref) {
|
|
10
|
+
var _b = _a.autoCompleteList, autoCompleteList = _b === void 0 ? [] : _b, isDataFromApi = _a.isDataFromApi, name = _a.name, value = _a.value, parentInputValue = _a.parentInputValue, disabled = _a.disabled, itemComponent = _a.itemComponent, _c = _a.valueKey, valueKey = _c === void 0 ? 'value' : _c, _d = _a.labelKey, labelKey = _d === void 0 ? 'label' : _d, onSelect = _a.onSelect, onChange = _a.onChange, onText = _a.onText, onLoad = _a.onLoad, style = _a.style, _e = _a.listPositionRelative, listPositionRelative = _e === void 0 ? false : _e, _f = _a.loadingMessage, loadingMessage = _f === void 0 ? 'Lütfen bekleyiniz...' : _f, _g = _a.notFoundMessage, notFoundMessage = _g === void 0 ? 'Kayıt bulunamadı...' : _g, placeholder = _a.placeholder, endAdornment = _a.endAdornment, _h = _a.ilkSec, ilkSec = _h === void 0 ? false : _h, _j = _a.newCreate, newCreate = _j === void 0 ? false : _j, inputRef = _a.inputRef, other = __rest(_a, ["autoCompleteList", "isDataFromApi", "name", "value", "parentInputValue", "disabled", "itemComponent", "valueKey", "labelKey", "onSelect", "onChange", "onText", "onLoad", "style", "listPositionRelative", "loadingMessage", "notFoundMessage", "placeholder", "endAdornment", "ilkSec", "newCreate", "inputRef"]);
|
|
11
|
+
var refMain = useRef(null);
|
|
12
|
+
var refInput = useRef(null);
|
|
13
|
+
var refList = useRef(null);
|
|
14
|
+
var _k = useState(autoCompleteList !== null && autoCompleteList !== void 0 ? autoCompleteList : []), data = _k[0], setData = _k[1];
|
|
15
|
+
var _l = useState(value !== null && value !== void 0 ? value : undefined), selectedValue = _l[0], setSelectedValue = _l[1];
|
|
16
|
+
var _m = useState(parentInputValue !== null && parentInputValue !== void 0 ? parentInputValue : undefined), parentValue = _m[0], setParentValue = _m[1];
|
|
17
|
+
var _o = useState(''), text = _o[0], setText = _o[1]; //Inputta görünen
|
|
18
|
+
var _p = useState(''), filter = _p[0], setFilter = _p[1]; // Filtrelemeye tabi tutulan
|
|
19
|
+
var _q = useState({ created: false }), newItemCreate = _q[0], setNewItemCreate = _q[1];
|
|
20
|
+
var _r = useState(false), open = _r[0], setOpen = _r[1];
|
|
21
|
+
var _s = useState(isDataFromApi && (!autoCompleteList || (autoCompleteList === null || autoCompleteList === void 0 ? void 0 : autoCompleteList.length) == 0)), loading = _s[0], setLoading = _s[1];
|
|
22
|
+
useImperativeHandle(ref, function () { return ({
|
|
26
23
|
setAutoCompleteList: function (list, value, callback) {
|
|
27
24
|
if (value === void 0) { value = undefined; }
|
|
28
25
|
if (autoCompleteList && (autoCompleteList === null || autoCompleteList === void 0 ? void 0 : autoCompleteList.length) > 0) {
|
|
@@ -54,12 +51,12 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
54
51
|
},
|
|
55
52
|
setLoading: function (value) { return setLoading(value); }
|
|
56
53
|
}); }, [autoCompleteList, data, value]);
|
|
57
|
-
|
|
54
|
+
useEffect(function () {
|
|
58
55
|
if (inputRef)
|
|
59
56
|
inputRef.current = refInput.current;
|
|
60
57
|
}, [refInput.current]);
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
useEffect(function () { return onLoad && onLoad(value); }, []);
|
|
59
|
+
useEffect(function () {
|
|
63
60
|
if (autoCompleteList && Array.isArray(autoCompleteList)) {
|
|
64
61
|
if (autoCompleteList.length > 0) {
|
|
65
62
|
// Sadece gerçekten farklıysa set et
|
|
@@ -77,7 +74,7 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
}, [autoCompleteList]);
|
|
80
|
-
|
|
77
|
+
useEffect(function () {
|
|
81
78
|
// isDev && console.log('data =>', name, data, 'selectedValue =>', selectedValue, 'value =>', value);
|
|
82
79
|
if (!Array.isArray(data)) {
|
|
83
80
|
setData([]);
|
|
@@ -94,21 +91,21 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
94
91
|
}
|
|
95
92
|
}, [data]);
|
|
96
93
|
// Seçim değişikliğinde parent'ı bilgilendir
|
|
97
|
-
|
|
94
|
+
useEffect(function () {
|
|
98
95
|
// isDev && console.log('selectedValue =>', name, selectedValue, 'value =>', value);
|
|
99
96
|
if ((value === null || value === void 0 ? void 0 : value.toString()) != (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.toString())) {
|
|
100
97
|
checkByValue(value, open);
|
|
101
98
|
// isDev && console.log('value Kontrol ediliyor', value, selectedValue);
|
|
102
99
|
}
|
|
103
100
|
}, [value]);
|
|
104
|
-
|
|
101
|
+
useEffect(function () {
|
|
105
102
|
if (parentInputValue !== parentValue) {
|
|
106
103
|
setParentValue(parentInputValue);
|
|
107
104
|
clear(false);
|
|
108
105
|
// isDev && console.log(name, "parentInputValueDeğişti =>", parentInputValue);
|
|
109
106
|
}
|
|
110
107
|
}, [parentInputValue]);
|
|
111
|
-
|
|
108
|
+
useEffect(function () {
|
|
112
109
|
var checkHideBackDrop = function (e) {
|
|
113
110
|
if (open && refMain.current && !refMain.current.contains(e.target)) {
|
|
114
111
|
checkByInput();
|
|
@@ -122,7 +119,7 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
122
119
|
if (refMain.current)
|
|
123
120
|
refMain.current.addEventListener('keydown', checkESC);
|
|
124
121
|
if (open) {
|
|
125
|
-
|
|
122
|
+
setScrollListPosition(refList);
|
|
126
123
|
if (!listPositionRelative) {
|
|
127
124
|
window.addEventListener('scroll', handleUpdatePosition, true);
|
|
128
125
|
window.addEventListener('resize', handleUpdatePosition);
|
|
@@ -136,8 +133,8 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
136
133
|
window.removeEventListener('resize', handleUpdatePosition);
|
|
137
134
|
};
|
|
138
135
|
}, [open]);
|
|
139
|
-
|
|
140
|
-
var setValue =
|
|
136
|
+
useLayoutEffect(function () { return handleUpdatePosition(); }, [open]);
|
|
137
|
+
var setValue = useCallback(function (item, openList) {
|
|
141
138
|
var _a, _b;
|
|
142
139
|
var newValue = (_a = item === null || item === void 0 ? void 0 : item[valueKey]) !== null && _a !== void 0 ? _a : '';
|
|
143
140
|
var newLabel = (_b = item === null || item === void 0 ? void 0 : item[labelKey]) !== null && _b !== void 0 ? _b : '';
|
|
@@ -151,26 +148,26 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
151
148
|
onChange && sendChange(newValue);
|
|
152
149
|
onSelect && onSelect(item);
|
|
153
150
|
}, [onChange, onSelect, name, selectedValue, valueKey, labelKey]);
|
|
154
|
-
var textInputOnChange =
|
|
151
|
+
var textInputOnChange = useCallback(function (e) {
|
|
155
152
|
setSelectedValue(undefined);
|
|
156
153
|
setText(e.target.value);
|
|
157
154
|
setFilter(e.target.value.trim());
|
|
158
155
|
setOpen(true);
|
|
159
156
|
onText && onText(e.target.value);
|
|
160
157
|
}, [setValue, onText]);
|
|
161
|
-
var checkByValue =
|
|
158
|
+
var checkByValue = useCallback(function (value, openList, list) {
|
|
162
159
|
if (openList === void 0) { openList = false; }
|
|
163
160
|
if (list === void 0) { list = []; }
|
|
164
161
|
var targetList = list.length > 0 ? list : data;
|
|
165
|
-
var find = Object.values(targetList).find(function (item) { return
|
|
162
|
+
var find = Object.values(targetList).find(function (item) { return convertLowerCase(item[valueKey]) === convertLowerCase(value); });
|
|
166
163
|
if (!find && newCreate && newItemCreate.create) {
|
|
167
164
|
find = newItemCreate;
|
|
168
165
|
}
|
|
169
166
|
// isDev && console.log('find', find, 'value', value, data);
|
|
170
167
|
setValue(find, openList);
|
|
171
168
|
}, [data, valueKey, newCreate, newItemCreate, setValue]);
|
|
172
|
-
var checkByInput =
|
|
173
|
-
var findByLabel = data.find(function (item) { var _a; return
|
|
169
|
+
var checkByInput = useCallback(function () {
|
|
170
|
+
var findByLabel = data.find(function (item) { var _a; return convertLowerCase(item[labelKey]) === convertLowerCase((_a = refInput.current) === null || _a === void 0 ? void 0 : _a.value); });
|
|
174
171
|
if (findByLabel && value == findByLabel[valueKey]) {
|
|
175
172
|
setOpen(false);
|
|
176
173
|
return;
|
|
@@ -183,7 +180,7 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
183
180
|
onText('');
|
|
184
181
|
}
|
|
185
182
|
}, [data, labelKey, value, valueKey, isDataFromApi, onText, setValue, refInput.current]);
|
|
186
|
-
var clear =
|
|
183
|
+
var clear = useCallback(function (openList, focusInput) {
|
|
187
184
|
var _a;
|
|
188
185
|
if (openList === void 0) { openList = true; }
|
|
189
186
|
if (focusInput === void 0) { focusInput = false; }
|
|
@@ -193,17 +190,17 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
193
190
|
onText && onText('');
|
|
194
191
|
focusInput && ((_a = refInput === null || refInput === void 0 ? void 0 : refInput.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
195
192
|
}, [setValue, onText]);
|
|
196
|
-
var sendChange =
|
|
193
|
+
var sendChange = useCallback(function (value) {
|
|
197
194
|
// isDev && console.log(name, "sendChange", value, "selectedValue", selectedValue);
|
|
198
195
|
if (onChange && value !== selectedValue) {
|
|
199
196
|
onChange({ target: { name: name, value: value } });
|
|
200
197
|
}
|
|
201
198
|
}, [onChange, name]);
|
|
202
|
-
var filteredData =
|
|
199
|
+
var filteredData = useMemo(function () {
|
|
203
200
|
var _a;
|
|
204
201
|
var list;
|
|
205
202
|
if (filter.length > 0) {
|
|
206
|
-
list = data.filter(function (item) { return
|
|
203
|
+
list = data.filter(function (item) { return convertForSearch(item[labelKey]).includes(convertForSearch(filter)) || item[labelKey] == filter; });
|
|
207
204
|
}
|
|
208
205
|
else {
|
|
209
206
|
list = data;
|
|
@@ -212,7 +209,7 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
212
209
|
var filterText = data.find(function (item) { return item[labelKey].toString().toLowerCase() === text.toString().toLowerCase(); });
|
|
213
210
|
if (!filterText) {
|
|
214
211
|
var newItem = (_a = {}, _a[labelKey] = text, _a[valueKey] = text, _a.create = true, _a);
|
|
215
|
-
list =
|
|
212
|
+
list = __spreadArray([newItem], list, true);
|
|
216
213
|
setNewItemCreate(newItem);
|
|
217
214
|
}
|
|
218
215
|
else {
|
|
@@ -230,7 +227,7 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
230
227
|
var onKeyDown = function (e) {
|
|
231
228
|
if (!open || !refList.current)
|
|
232
229
|
return null;
|
|
233
|
-
|
|
230
|
+
onKeyboardSelection({
|
|
234
231
|
e: e,
|
|
235
232
|
targetElement: refList,
|
|
236
233
|
checkByInput: checkByInput,
|
|
@@ -240,10 +237,10 @@ exports.SearchableInput = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
240
237
|
selectedClass: 'selected'
|
|
241
238
|
});
|
|
242
239
|
};
|
|
243
|
-
return ((
|
|
240
|
+
return (_jsxs("div", { ref: refMain, className: styles.searchableInputComponent, onKeyDown: onKeyDown, style: style, children: [_jsx(Input, __assign({}, other, { inputRef: refInput, name: name, value: text, onFocus: function () { return !disabled && setOpen(true); }, onChange: textInputOnChange, 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, { name: 'close', style: { color: '#444' } }) }), endAdornment, _jsx(Button, { tabIndex: -1, hidden: !data || !(data.length > 0), onClick: function () { return !disabled && setOpen(!open); }, onlyIcon: _jsx(Icon, { name: 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' }) })), open && (_jsx("div", { className: 'listDiv', "data-relative": listPositionRelative, children: _jsxs("ul", { ref: refList, className: "list ".concat(open ? 'open' : ''), children: [(filteredData.length === 0 || loading) && _jsx("div", { className: "message ".concat(loading ? 'loading' : ''), children: loading ? loadingMessage : notFoundMessage }), filteredData.map(function (item, key) {
|
|
244
241
|
var itemValue = item[valueKey];
|
|
245
242
|
var itemLabel = item[labelKey];
|
|
246
|
-
return ((
|
|
243
|
+
return (_jsxs("li", { className: "item ".concat(itemValue === selectedValue ? 'active' : ''), "data-value": itemValue, "data-label": itemLabel, onClick: function () { return setValue(item, false); }, children: [item.create && _jsx("span", { className: 'newCreate', children: "Yeni Olu\u015Ftur: " }), itemComponent ? itemComponent(item) : itemLabel] }, key));
|
|
247
244
|
})] }) }))] }));
|
|
248
245
|
});
|
|
249
246
|
var setFixedPosition = function (refMain) {
|