@sydsoft/base 1.4.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 +7 -0
- package/dist/esm/index.js +7 -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 +3 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
checked: "0" | "1" | boolean;
|
|
4
|
+
ref?: React.Ref<any>;
|
|
5
|
+
name?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onToogle?: (e: {
|
|
10
|
+
target: {
|
|
11
|
+
name?: string;
|
|
12
|
+
value: "0" | "1";
|
|
13
|
+
};
|
|
14
|
+
}) => void;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
styleCheckbox?: React.CSSProperties;
|
|
17
|
+
styleLabel?: React.CSSProperties;
|
|
18
|
+
tabIndex?: number;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare const Checkbox: React.FC<Props>;
|
|
23
|
+
export {};
|
|
@@ -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,19 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export type propsDialog = {
|
|
3
|
+
message: any;
|
|
4
|
+
acceptButtonShow?: boolean;
|
|
5
|
+
cancelButtonShow?: boolean;
|
|
6
|
+
acceptButtonText?: string | ReactNode;
|
|
7
|
+
cancelButtonText?: string | ReactNode;
|
|
8
|
+
acceptButtonClass?: "default" | "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link";
|
|
9
|
+
cancelButtonClass?: "default" | "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link";
|
|
10
|
+
vertialAlign?: "flex-start" | "center" | "flex-end";
|
|
11
|
+
horizontalAlign?: "flex-start" | "center" | "flex-end";
|
|
12
|
+
hideBackdrop?: boolean;
|
|
13
|
+
hideEsc?: boolean;
|
|
14
|
+
styleMessage?: React.CSSProperties;
|
|
15
|
+
styleBox?: React.CSSProperties;
|
|
16
|
+
styleBoxFooter?: React.CSSProperties;
|
|
17
|
+
autoFocus?: "accept" | "cancel";
|
|
18
|
+
};
|
|
19
|
+
export declare const Dialog: (config: propsDialog) => Promise<unknown>;
|
|
@@ -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 { Button } from "./Button";
|
|
5
|
+
import { Modal } from "../modal";
|
|
6
|
+
import { createRoot } from "react-dom/client";
|
|
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.2rem",
|
|
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, 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,10 @@
|
|
|
1
|
+
import React, { FormEventHandler } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
encType?: React.FormHTMLAttributes<HTMLFormElement>["encType"];
|
|
5
|
+
onSubmit?: FormEventHandler<HTMLFormElement>;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
disableOnEnterSubmit?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const Form: React.NamedExoticComponent<Props>;
|
|
10
|
+
export {};
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { typeJustifyContent, typeSpacingValues } from "../grid";
|
|
2
|
+
import React from "react";
|
|
3
|
+
type gridValues = "auto" | "full" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
4
|
+
type grid = {
|
|
5
|
+
xs?: gridValues;
|
|
6
|
+
sm?: gridValues;
|
|
7
|
+
md?: gridValues;
|
|
8
|
+
lg?: gridValues;
|
|
9
|
+
xl?: gridValues;
|
|
10
|
+
xxl?: gridValues;
|
|
11
|
+
};
|
|
12
|
+
export type PropsFormOgeler = {
|
|
13
|
+
label?: string | null;
|
|
14
|
+
noRender?: boolean;
|
|
15
|
+
fullComponent?: any;
|
|
16
|
+
component?: any;
|
|
17
|
+
propsComponent?: object;
|
|
18
|
+
propsRow?: object;
|
|
19
|
+
propsLabel?: object;
|
|
20
|
+
gridLabel?: grid;
|
|
21
|
+
gridInput?: grid;
|
|
22
|
+
};
|
|
23
|
+
interface Props {
|
|
24
|
+
form: {
|
|
25
|
+
[key: string | number]: any;
|
|
26
|
+
};
|
|
27
|
+
formOgeler: PropsFormOgeler[];
|
|
28
|
+
onChange: Function;
|
|
29
|
+
sabitGrid: {
|
|
30
|
+
label: grid;
|
|
31
|
+
input: grid;
|
|
32
|
+
};
|
|
33
|
+
formType: "label" | "noLabel";
|
|
34
|
+
justifyContent: typeJustifyContent;
|
|
35
|
+
rowSpacing?: typeSpacingValues;
|
|
36
|
+
colSpacing?: typeSpacingValues;
|
|
37
|
+
}
|
|
38
|
+
export declare const FormOlustur: React.NamedExoticComponent<Props>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Col, Row } from "../grid";
|
|
4
|
+
import React, { memo, useEffect, useMemo } from "react";
|
|
5
|
+
import { Label } from "./Label";
|
|
6
|
+
import { isDev } from "../_lib/baseFunctions";
|
|
7
|
+
export var FormOlustur = memo(function FunctionMemo(props) {
|
|
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;
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
if (formOgeler && onChange && form) {
|
|
11
|
+
formOgeler.forEach(function (formOgeler) {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f;
|
|
13
|
+
if (formOgeler.noRender && ((_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) && form[(_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] != "") {
|
|
14
|
+
isDev && console.log("noRenderGuncelle");
|
|
15
|
+
if ((formOgeler === null || formOgeler === void 0 ? void 0 : formOgeler.component) && ((_f = (_e = formOgeler === null || formOgeler === void 0 ? void 0 : formOgeler.component) === null || _e === void 0 ? void 0 : _e.props) === null || _f === void 0 ? void 0 : _f.name)) {
|
|
16
|
+
onChange({
|
|
17
|
+
target: {
|
|
18
|
+
name: formOgeler.component.props.name,
|
|
19
|
+
value: ""
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, [JSON.stringify(form), formOgeler]);
|
|
27
|
+
var result = useMemo(function () {
|
|
28
|
+
return formOgeler.map(function (_a, i) {
|
|
29
|
+
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;
|
|
30
|
+
if (noRender) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (fullComponent)
|
|
34
|
+
return React.cloneElement(fullComponent, { key: i });
|
|
35
|
+
var newProps = __assign({}, propsComponent);
|
|
36
|
+
if (onChange && component && !component.props.onChange) {
|
|
37
|
+
newProps = __assign(__assign({}, newProps), { onChange: onChange });
|
|
38
|
+
}
|
|
39
|
+
if (onChange && form && component.props.name && !component.props.value) {
|
|
40
|
+
newProps = __assign(__assign({}, newProps), { value: form[component.props.name] && form[component.props.name].length > 0 ? String(form[component.props.name]) : "" });
|
|
41
|
+
}
|
|
42
|
+
if (formType === "label")
|
|
43
|
+
newProps = __assign(__assign({}, newProps), { label: "" });
|
|
44
|
+
var detectLabel = label || component.props.label;
|
|
45
|
+
gridLabel = __assign(__assign({}, sabitGrid.label), gridLabel);
|
|
46
|
+
gridInput = __assign(__assign({}, sabitGrid.input), gridInput);
|
|
47
|
+
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));
|
|
48
|
+
});
|
|
49
|
+
}, [form, formOgeler, onChange, formType, sabitGrid, justifyContent, rowSpacing, colSpacing]);
|
|
50
|
+
return _jsx(React.Fragment, { children: result });
|
|
51
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type maskSettingsTranslation = {
|
|
3
|
+
[key: string]: {
|
|
4
|
+
pattern: any;
|
|
5
|
+
transform?: (value: string) => string;
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
recursive?: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type maskSettings = {
|
|
11
|
+
clearIfNotMatch?: boolean;
|
|
12
|
+
reverse?: boolean;
|
|
13
|
+
translation?: maskSettingsTranslation;
|
|
14
|
+
selectOnFocus?: boolean;
|
|
15
|
+
onChange?: (maskedValue: string, cleanValue: string, targetInput: React.ChangeEvent<HTMLInputElement>) => void;
|
|
16
|
+
};
|
|
17
|
+
export interface PropsInput {
|
|
18
|
+
componentRef?: any;
|
|
19
|
+
inputRef?: any;
|
|
20
|
+
className?: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
value?: any;
|
|
24
|
+
defaultValue?: any;
|
|
25
|
+
label?: string;
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
autoFocus?: boolean | undefined;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
required?: boolean;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
type?: "text" | "number" | "email" | "color" | "date" | "time" | "datetime-local" | "hidden" | "file" | "password" | "tel" | "search";
|
|
32
|
+
select?: any[];
|
|
33
|
+
ilkSec?: boolean;
|
|
34
|
+
valueKey?: string;
|
|
35
|
+
labelKey?: string;
|
|
36
|
+
multiline?: boolean;
|
|
37
|
+
rows?: number | undefined;
|
|
38
|
+
onChange?: Function;
|
|
39
|
+
onFocus?: Function;
|
|
40
|
+
onBlur?: Function;
|
|
41
|
+
onClick?: Function;
|
|
42
|
+
onKeyPress?: Function;
|
|
43
|
+
onKeyUp?: Function;
|
|
44
|
+
onKeyDown?: Function;
|
|
45
|
+
propsComponent?: object | any;
|
|
46
|
+
propsInput?: object;
|
|
47
|
+
startAdornment?: any;
|
|
48
|
+
endAdornment?: any;
|
|
49
|
+
sadeceYazi?: boolean;
|
|
50
|
+
sadeceSayi?: boolean;
|
|
51
|
+
tumuBuyuk?: boolean;
|
|
52
|
+
tumuKucuk?: boolean;
|
|
53
|
+
seoCevir?: boolean;
|
|
54
|
+
dosyaNoGiris?: boolean;
|
|
55
|
+
fileNameGiris?: boolean;
|
|
56
|
+
dateGecmisKontrol?: boolean;
|
|
57
|
+
autoSelectText?: boolean;
|
|
58
|
+
mask?: string;
|
|
59
|
+
maskSettings?: maskSettings;
|
|
60
|
+
}
|
|
61
|
+
export declare const Input: React.FC<PropsInput>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { seoCevirFunction, tumuBuyukCevir, tumuKucukCevir } from "../_lib/baseFunctions";
|
|
5
|
+
import { Dialog } from "./Dialog";
|
|
6
|
+
import { alert_add } from "../alert";
|
|
7
|
+
import { applyInputMask } from "../_lib/inputMask";
|
|
8
|
+
import styles from "./styles/Input.module.css";
|
|
9
|
+
export var Input = function (_a) {
|
|
10
|
+
var componentRef = _a.componentRef, inputRef = _a.inputRef, className = _a.className, propsComponent = _a.propsComponent, propsInput = _a.propsInput, id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, 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, disabled = _a.disabled, required = _a.required, loading = _a.loading, autoFocus = _a.autoFocus, select = _a.select, _b = _a.valueKey, valueKey = _b === void 0 ? "value" : _b, _c = _a.labelKey, labelKey = _c === void 0 ? "label" : _c, ilkSec = _a.ilkSec, multiline = _a.multiline, rows = _a.rows, 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, _d = _a.mask, mask = _d === void 0 ? "" : _d, _e = _a.maskSettings, maskSettings = _e === void 0 ? {
|
|
11
|
+
clearIfNotMatch: true,
|
|
12
|
+
reverse: false, //Tersten doldurmaya başla, fiyatlar için geçerli
|
|
13
|
+
selectOnFocus: false
|
|
14
|
+
} : _e;
|
|
15
|
+
var refMain = useRef(null);
|
|
16
|
+
var refInput = useRef(null);
|
|
17
|
+
var refLabel = useRef(null);
|
|
18
|
+
var _f = useState(value && value.toString().length > 0), inputFilled = _f[0], setInputFilled = _f[1];
|
|
19
|
+
var _g = useState(false), focus = _g[0], setFocus = _g[1];
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
if (inputRef)
|
|
22
|
+
inputRef.current = refInput.current;
|
|
23
|
+
if (componentRef)
|
|
24
|
+
componentRef.current = refMain.current;
|
|
25
|
+
}, [componentRef, inputRef]);
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
if (autoSelectText && !select && (refInput === null || refInput === void 0 ? void 0 : refInput.current)) {
|
|
28
|
+
refInput.current.select();
|
|
29
|
+
}
|
|
30
|
+
}, [autoSelectText, select]);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
var filled = (String(value) && value.toString().length > 0) || (defaultValue && defaultValue.toString().length > 0);
|
|
34
|
+
setInputFilled(filled);
|
|
35
|
+
if (filled) {
|
|
36
|
+
(_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);
|
|
37
|
+
}
|
|
38
|
+
}, [value, defaultValue]);
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
// if (type === "number") sadeceSayi = true; //TODO: sadeceSayi burada değiştirelemez ki!!!
|
|
41
|
+
if (select && ilkSec && value.toString().length === 0) {
|
|
42
|
+
if (select.length) {
|
|
43
|
+
var ilkItem = select[0][valueKey] ? select[0][valueKey] : "";
|
|
44
|
+
onChange && onChange({ target: { name: name, value: ilkItem } });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [select]);
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
var _a;
|
|
50
|
+
if (typeof window !== "undefined" && (mask === null || mask === void 0 ? void 0 : mask.length) > 0 && (refInput === null || refInput === void 0 ? void 0 : refInput.current)) {
|
|
51
|
+
(_a = refInput.current) === null || _a === void 0 ? void 0 : _a.setAttribute("autocomplete", "off");
|
|
52
|
+
}
|
|
53
|
+
if ((mask === null || mask === void 0 ? void 0 : mask.length) > 0 && (refInput === null || refInput === void 0 ? void 0 : refInput.current)) {
|
|
54
|
+
var maskInstance_1 = applyInputMask(refInput.current, mask, __assign(__assign({}, maskSettings), { onChange: function (masked, clean, e) {
|
|
55
|
+
if (onChange) {
|
|
56
|
+
onChange({ target: { name: name, value: masked } });
|
|
57
|
+
}
|
|
58
|
+
if (maskSettings && maskSettings.onChange) {
|
|
59
|
+
maskSettings.onChange(masked, clean, e);
|
|
60
|
+
}
|
|
61
|
+
} }));
|
|
62
|
+
maskInstance_1 === null || maskInstance_1 === void 0 ? void 0 : maskInstance_1.setValue(value ? value : null);
|
|
63
|
+
return function () { return maskInstance_1 === null || maskInstance_1 === void 0 ? void 0 : maskInstance_1.destroy(); };
|
|
64
|
+
}
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, [mask]);
|
|
67
|
+
var Change = useCallback(function (e) {
|
|
68
|
+
if (tumuBuyuk)
|
|
69
|
+
tumuBuyukCevir(e);
|
|
70
|
+
if (tumuKucuk)
|
|
71
|
+
tumuKucukCevir(e);
|
|
72
|
+
if (seoCevir)
|
|
73
|
+
seoCevirFunction(e);
|
|
74
|
+
setInputFilled(e.target.value.length > 0);
|
|
75
|
+
onChange ? onChange(e) : null;
|
|
76
|
+
}, [onChange, seoCevir, tumuBuyuk, tumuKucuk]);
|
|
77
|
+
var Focus = useCallback(function (e) {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
onFocus ? onFocus(e) : null;
|
|
80
|
+
setFocus(true);
|
|
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);
|
|
82
|
+
}, [onFocus]);
|
|
83
|
+
var Blur = useCallback(function (e) {
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
|
+
if (fileNameGiris && e.target.value !== "" && /[/\\?%*:|"'<>]/g.test(e.target.value)) {
|
|
86
|
+
e.target.value = e.target.value.replace(/[/\\?%*:|"'<>]/g, "-");
|
|
87
|
+
if (onChange)
|
|
88
|
+
onChange(e);
|
|
89
|
+
alert_add({ type: "warning", message: "Lütfen dosya adındaki özel karakter değiştirildi." });
|
|
90
|
+
}
|
|
91
|
+
if (dosyaNoGiris && e.target.value !== "" && !/^[1-2]\d{3}\/\d/.test(e.target.value)) {
|
|
92
|
+
e.target.value = "";
|
|
93
|
+
if (onChange)
|
|
94
|
+
onChange(e);
|
|
95
|
+
alert_add({ type: "error", message: "Lütfen doğru bir dosya numarası giriniz. Örn: 2022/123" });
|
|
96
|
+
}
|
|
97
|
+
if (dateGecmisKontrol && e.target.value !== "") {
|
|
98
|
+
var today = new Date().toISOString().slice(0, 10);
|
|
99
|
+
if (e.target.value < today) {
|
|
100
|
+
Dialog({
|
|
101
|
+
message: "Geçmiş bir tarihi seçtiniz. Devam etmek istiyor musunuz?"
|
|
102
|
+
}).then(function (r) {
|
|
103
|
+
if (!r) {
|
|
104
|
+
e.target.value = "";
|
|
105
|
+
if (onChange)
|
|
106
|
+
onChange(e);
|
|
107
|
+
e.target.focus();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (required) {
|
|
113
|
+
if (e.target.value === "") {
|
|
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);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
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);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (value !== e.target.value) {
|
|
121
|
+
onChange && onChange({ target: { name: name, value: e.target.value } });
|
|
122
|
+
}
|
|
123
|
+
onBlur ? onBlur(e) : null;
|
|
124
|
+
setFocus(false);
|
|
125
|
+
}, [fileNameGiris, dosyaNoGiris, dateGecmisKontrol, required, value, onBlur, onChange, name]);
|
|
126
|
+
var Click = useCallback(function (e) { return (onClick ? onClick(e) : null); }, [onClick]);
|
|
127
|
+
var KeyPress = useCallback(function (e) {
|
|
128
|
+
if (sadeceYazi) {
|
|
129
|
+
var turkishLetters = /[ğüşıöçĞÜŞİÖÇ]/;
|
|
130
|
+
if (!(/[A-Za-z\s.]/.test(e.key) || turkishLetters.test(e.key))) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if ((sadeceSayi || dosyaNoGiris) && (e.which < 48 || e.which > 57))
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
if (dosyaNoGiris && e.which !== 8 && e.target.value.length === 4 && e.target.value.search("/") === -1) {
|
|
138
|
+
e.target.value = e.target.value + "/";
|
|
139
|
+
}
|
|
140
|
+
onKeyPress ? onKeyPress(e) : null;
|
|
141
|
+
}, [sadeceYazi, sadeceSayi, dosyaNoGiris, onKeyPress]);
|
|
142
|
+
var KeyUp = useCallback(function (e) { return (onKeyUp ? onKeyUp(e) : null); }, [onKeyUp]);
|
|
143
|
+
var KeyDown = useCallback(function (e) {
|
|
144
|
+
onKeyDown ? onKeyDown(e) : null;
|
|
145
|
+
}, [onKeyDown]);
|
|
146
|
+
var ortakProps = {
|
|
147
|
+
ref: refInput,
|
|
148
|
+
id: id,
|
|
149
|
+
name: name,
|
|
150
|
+
value: value,
|
|
151
|
+
defaultValue: defaultValue,
|
|
152
|
+
autoFocus: autoFocus,
|
|
153
|
+
disabled: disabled,
|
|
154
|
+
required: required,
|
|
155
|
+
placeholder: placeholder,
|
|
156
|
+
onChange: Change,
|
|
157
|
+
onFocus: Focus,
|
|
158
|
+
onBlur: Blur,
|
|
159
|
+
onClick: Click,
|
|
160
|
+
onKeyPress: KeyPress,
|
|
161
|
+
onKeyUp: KeyUp,
|
|
162
|
+
onKeyDown: KeyDown
|
|
163
|
+
};
|
|
164
|
+
var component;
|
|
165
|
+
if (select) {
|
|
166
|
+
component = (_jsxs("select", __assign({ className: "".concat(styles.input, " ").concat(styles.select) }, ortakProps, propsInput, { children: [ilkSec === false && _jsx("option", { value: "" }), select.map(function (item) {
|
|
167
|
+
var value = item[valueKey];
|
|
168
|
+
var label = item[labelKey];
|
|
169
|
+
return (_jsx("option", { value: value, children: label ? label : value }, value));
|
|
170
|
+
})] })));
|
|
171
|
+
}
|
|
172
|
+
else if (multiline) {
|
|
173
|
+
component = _jsx("textarea", __assign({ className: "".concat(styles.input, " ").concat(styles.textarea), rows: rows }, ortakProps, propsInput));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
component = _jsx("input", __assign({ className: "".concat(styles.input), type: type }, ortakProps, propsInput));
|
|
177
|
+
}
|
|
178
|
+
var classList = useCallback(function () {
|
|
179
|
+
var list = ["sInputComponent", styles.component];
|
|
180
|
+
if (className)
|
|
181
|
+
list.push(className);
|
|
182
|
+
if (label) {
|
|
183
|
+
list.push(styles.hidePlaceHolder);
|
|
184
|
+
}
|
|
185
|
+
// if (props.required && (value.length === 0 || !value)) list.push("error");
|
|
186
|
+
return list.join(" ");
|
|
187
|
+
}, [value, className]);
|
|
188
|
+
useEffect(function () {
|
|
189
|
+
if (propsComponent && propsComponent.hasOwnProperty("style")) {
|
|
190
|
+
var background = propsComponent.style.background ? propsComponent.style.background : propsComponent.style.backgroundColor ? propsComponent.style.backgroundColor : null;
|
|
191
|
+
if (background && refLabel.current) {
|
|
192
|
+
refLabel.current.style.setProperty("--label-bg", background);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}, [propsComponent]);
|
|
196
|
+
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 })] }))] })));
|
|
197
|
+
};
|
|
198
|
+
Input.defaultProps = {
|
|
199
|
+
value: "",
|
|
200
|
+
disabled: false,
|
|
201
|
+
required: false,
|
|
202
|
+
ilkSec: false,
|
|
203
|
+
multiline: false,
|
|
204
|
+
rows: 2,
|
|
205
|
+
loading: false,
|
|
206
|
+
autoFocus: false
|
|
207
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
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(props) {
|
|
7
|
+
var required = props.required, children = props.children, other = __rest(props, ["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
|
+
});
|
|
10
|
+
Label.defaultProps = {
|
|
11
|
+
required: false
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PropsInput } from "./Input";
|
|
2
|
+
import React from "react";
|
|
3
|
+
type typeList = {
|
|
4
|
+
value?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
[key: string | number]: any;
|
|
7
|
+
}[];
|
|
8
|
+
interface Props extends PropsInput {
|
|
9
|
+
autoCompleteList?: typeList | any;
|
|
10
|
+
onChange?: Function;
|
|
11
|
+
value: string | number | undefined;
|
|
12
|
+
valueKey?: string;
|
|
13
|
+
labelKey?: string;
|
|
14
|
+
itemComponent?: any;
|
|
15
|
+
api?: boolean;
|
|
16
|
+
onText?: Function;
|
|
17
|
+
onSelect?: Function;
|
|
18
|
+
onLoad?: Function;
|
|
19
|
+
newCreate?: boolean;
|
|
20
|
+
refModal?: any;
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
parentInputValue?: any;
|
|
24
|
+
listPositionRelative?: boolean;
|
|
25
|
+
}
|
|
26
|
+
type handle = {
|
|
27
|
+
open: () => void;
|
|
28
|
+
close: () => void;
|
|
29
|
+
checkByValue: (value: string, openList: boolean) => void;
|
|
30
|
+
setLoading: (loading: boolean) => void;
|
|
31
|
+
setAutoCompleteList: (list: typeList, value?: string | null) => void;
|
|
32
|
+
clear: (openList?: boolean, focusInput?: boolean) => void;
|
|
33
|
+
};
|
|
34
|
+
export declare const SearchableInput: React.ForwardRefExoticComponent<Props & React.RefAttributes<handle>>;
|
|
35
|
+
export {};
|