@sydsoft/base 1.44.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/esm/_lib/baseFunctions.js +25 -38
- package/dist/esm/_lib/inputMask.js +66 -68
- package/dist/esm/_lib/listFunctions.js +12 -13
- package/dist/esm/_lib/storage/cookies.js +20 -21
- package/dist/esm/_lib/storage/encData.js +19 -21
- package/dist/esm/_lib/storage/localStorage.js +10 -10
- package/dist/esm/_lib/storage/sessionStorage.js +10 -10
- package/dist/esm/_lib/useInterval.js +5 -5
- package/dist/esm/alert/index.js +28 -30
- package/dist/esm/box/Box.js +6 -7
- package/dist/esm/box/BoxContent.js +2 -4
- package/dist/esm/box/BoxFooter.js +6 -4
- package/dist/esm/box/BoxHeader.js +6 -5
- package/dist/esm/countDown/index.js +28 -33
- package/dist/esm/dateTime/index.js +25 -31
- package/dist/esm/form/Button.js +28 -22
- package/dist/esm/form/Checkbox.js +7 -8
- package/dist/esm/form/Dialog.d.ts +7 -6
- package/dist/esm/form/Dialog.js +51 -38
- package/dist/esm/form/Form.js +3 -5
- package/dist/esm/form/FormOlustur.js +15 -17
- package/dist/esm/form/Input.d.ts +12 -7
- package/dist/esm/form/Input.js +68 -77
- package/dist/esm/form/Label.d.ts +1 -1
- package/dist/esm/form/Label.js +5 -10
- package/dist/esm/form/SearchableInput.js +77 -89
- package/dist/esm/form/UploadBase.js +30 -32
- package/dist/esm/grid/index.js +40 -41
- package/dist/esm/icon/icons.js +1 -1
- package/dist/esm/icon/index.js +21 -10
- package/dist/esm/index.module.css +89 -0
- package/dist/esm/menu/index.d.ts +30 -4
- package/dist/esm/menu/index.js +32 -14
- package/dist/esm/modal/index.js +14 -16
- package/dist/esm/popover/index.d.ts +21 -7
- package/dist/esm/popover/index.js +320 -119
- package/dist/esm/tooltip/index.js +117 -34
- package/package.json +12 -6
- package/dist/esm/alert/index.module.css +0 -119
- package/dist/esm/grid/index.module.css +0 -805
- package/dist/esm/menu/index.module.css +0 -67
- package/dist/esm/modal/index.module.css +0 -76
- /package/dist/esm/{box/Box.module.css → Box.module.css} +0 -0
- /package/dist/esm/{form/styles → styles}/Button.module.css +0 -0
- /package/dist/esm/{form/styles → styles}/Input.module.css +0 -0
- /package/dist/esm/{form/styles → styles}/Label.module.css +0 -0
- /package/dist/esm/{form/styles → styles}/SearchableInput.module.css +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { decData, encData } from "./encData";
|
|
2
2
|
import { isDev } from "../baseFunctions";
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
const storageAvailable = typeof Storage === "undefined" || !window.sessionStorage ? false : true;
|
|
4
|
+
export const setSessionStorage = (key, value) => {
|
|
5
5
|
if (!storageAvailable)
|
|
6
6
|
return false;
|
|
7
7
|
try {
|
|
@@ -13,11 +13,11 @@ export var setSessionStorage = function (key, value) {
|
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export const getSessionStorage = (key) => {
|
|
17
17
|
if (!storageAvailable)
|
|
18
18
|
return false;
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
const saved = sessionStorage.getItem(key);
|
|
21
21
|
return saved ? decData(saved) : null;
|
|
22
22
|
}
|
|
23
23
|
catch (e) {
|
|
@@ -25,7 +25,7 @@ export var getSessionStorage = function (key) {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
export
|
|
28
|
+
export const removeSessionStorage = (key) => {
|
|
29
29
|
if (!storageAvailable)
|
|
30
30
|
return false;
|
|
31
31
|
try {
|
|
@@ -37,7 +37,7 @@ export var removeSessionStorage = function (key) {
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export const clearSessionStorage = () => {
|
|
41
41
|
if (!storageAvailable)
|
|
42
42
|
return false;
|
|
43
43
|
try {
|
|
@@ -50,17 +50,17 @@ export var clearSessionStorage = function () {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
// Tüm SessionStorage anahtarlarını getir
|
|
53
|
-
export
|
|
53
|
+
export const getSessionStorageAllKeys = () => {
|
|
54
54
|
if (!storageAvailable)
|
|
55
55
|
return [];
|
|
56
56
|
return Object.keys(sessionStorage);
|
|
57
57
|
};
|
|
58
58
|
// Tüm SessionStorage boyutunu getir
|
|
59
|
-
export
|
|
59
|
+
export const getSessionStorageSize = () => {
|
|
60
60
|
if (!storageAvailable)
|
|
61
61
|
return 0;
|
|
62
|
-
|
|
63
|
-
for (
|
|
62
|
+
let total = 0;
|
|
63
|
+
for (const key in sessionStorage) {
|
|
64
64
|
if (sessionStorage.hasOwnProperty(key)) {
|
|
65
65
|
total += sessionStorage[key].length + key.length;
|
|
66
66
|
}
|
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
// source: https://overreacted.io/making-setinterval-declarative-with-react-hooks/
|
|
7
7
|
import { useEffect, useRef } from "react";
|
|
8
8
|
export function useInterval(callback, delay) {
|
|
9
|
-
|
|
9
|
+
const savedCallback = useRef(null);
|
|
10
10
|
// Remember the latest callback.
|
|
11
|
-
useEffect(
|
|
11
|
+
useEffect(() => {
|
|
12
12
|
savedCallback.current = callback;
|
|
13
13
|
}, [callback]);
|
|
14
14
|
// Set up the interval.
|
|
15
|
-
useEffect(
|
|
15
|
+
useEffect(() => {
|
|
16
16
|
function tick() {
|
|
17
17
|
savedCallback && savedCallback.current && savedCallback.current();
|
|
18
18
|
}
|
|
19
19
|
if (delay !== null) {
|
|
20
|
-
|
|
21
|
-
return
|
|
20
|
+
const id = setInterval(tick, delay);
|
|
21
|
+
return () => clearInterval(id);
|
|
22
22
|
}
|
|
23
23
|
}, [delay]);
|
|
24
24
|
}
|
package/dist/esm/alert/index.js
CHANGED
|
@@ -2,21 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { createRoot } from "react-dom/client";
|
|
4
4
|
import styles from "./index.module.css";
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
useEffect(function () {
|
|
5
|
+
const sAlertTimeout = [];
|
|
6
|
+
export const Alert = ({ defaultTimer = "5000", defaultErrorTimer = "10000", defaultSuccessTimer = "5000" }) => {
|
|
7
|
+
useEffect(() => {
|
|
9
8
|
if (typeof window === "undefined")
|
|
10
9
|
return;
|
|
11
|
-
|
|
10
|
+
const divCheck = document.getElementById("salert");
|
|
12
11
|
if (!divCheck) {
|
|
13
12
|
// let div = document.createElement('div') as HTMLDivElement
|
|
14
|
-
|
|
13
|
+
const div = document.createElement("div");
|
|
15
14
|
div.setAttribute("id", "salert");
|
|
16
15
|
div.setAttribute("defaultTimer", defaultTimer);
|
|
17
16
|
div.setAttribute("defaultErrorTimer", defaultErrorTimer);
|
|
18
17
|
div.setAttribute("defaultSuccessTimer", defaultSuccessTimer);
|
|
19
|
-
|
|
18
|
+
const alertStyle = [
|
|
20
19
|
"position: fixed",
|
|
21
20
|
"bottom: 0",
|
|
22
21
|
"right: 0",
|
|
@@ -34,27 +33,26 @@ export var Alert = function (_a) {
|
|
|
34
33
|
}, []);
|
|
35
34
|
return null;
|
|
36
35
|
};
|
|
37
|
-
export
|
|
38
|
-
var _b, _c
|
|
39
|
-
var type = _a.type, message = _a.message, style = _a.style, timer = _a.timer;
|
|
36
|
+
export const alert_add = ({ type, message, style, timer }) => {
|
|
37
|
+
var _a, _b, _c;
|
|
40
38
|
if (typeof window === "undefined")
|
|
41
39
|
return false;
|
|
42
|
-
|
|
40
|
+
const mainDiv = document.getElementById("salert");
|
|
43
41
|
if (mainDiv) {
|
|
44
|
-
|
|
45
|
-
mainDiv.prepend(
|
|
46
|
-
|
|
47
|
-
if (mainDiv &&
|
|
48
|
-
mainDiv.removeChild(
|
|
42
|
+
const alert = document.createElement("div");
|
|
43
|
+
mainDiv.prepend(alert);
|
|
44
|
+
const onClose = () => {
|
|
45
|
+
if (mainDiv && alert && mainDiv.contains(alert))
|
|
46
|
+
mainDiv.removeChild(alert);
|
|
49
47
|
};
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const root = createRoot(alert);
|
|
49
|
+
const Component = (_jsxs("div", { className: `${styles.salert} ${styles[type]}`, style: style, children: [_jsx("div", { className: styles.message, dangerouslySetInnerHTML: { __html: message } }), _jsx("div", { className: styles.close, onClick: onClose, children: "\u2715" })] }));
|
|
52
50
|
root.render(Component);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const defaultTimer = (_a = mainDiv.getAttribute("defaulttimer")) !== null && _a !== void 0 ? _a : "5000";
|
|
52
|
+
const defaultErrorTimer = (_b = mainDiv.getAttribute("defaulterrortimer")) !== null && _b !== void 0 ? _b : "10000";
|
|
53
|
+
const defaultSuccessTimer = (_c = mainDiv.getAttribute("defaultsuccesstimer")) !== null && _c !== void 0 ? _c : "5000";
|
|
54
|
+
const timerFilled = typeof timer === "number" && timer > 0;
|
|
55
|
+
let newTimer = timerFilled ? timer : defaultTimer;
|
|
58
56
|
switch (type) {
|
|
59
57
|
case "error":
|
|
60
58
|
newTimer = timerFilled ? timer : defaultErrorTimer;
|
|
@@ -69,27 +67,27 @@ export var alert_add = function (_a) {
|
|
|
69
67
|
if (typeof timer !== "boolean") {
|
|
70
68
|
// False gelmişse sabit kalsın
|
|
71
69
|
if (newTimer > 0) {
|
|
72
|
-
|
|
70
|
+
const timeout = setTimeout(() => onClose(), newTimer);
|
|
73
71
|
sAlertTimeout.push(timeout);
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
|
-
return
|
|
74
|
+
return alert;
|
|
77
75
|
}
|
|
78
76
|
return null;
|
|
79
77
|
};
|
|
80
|
-
export
|
|
78
|
+
export const alert_remove = (alert) => {
|
|
81
79
|
if (typeof window === "undefined" || !alert)
|
|
82
80
|
return;
|
|
83
|
-
|
|
81
|
+
const mainDiv = document.getElementById("salert");
|
|
84
82
|
if (mainDiv && alert && mainDiv.contains(alert))
|
|
85
83
|
mainDiv.removeChild(alert);
|
|
86
84
|
return;
|
|
87
85
|
};
|
|
88
|
-
export
|
|
86
|
+
export const alert_clear = () => {
|
|
89
87
|
if (typeof window === "undefined")
|
|
90
88
|
return false;
|
|
91
|
-
sAlertTimeout.map(
|
|
92
|
-
|
|
89
|
+
sAlertTimeout.map((id) => clearTimeout(id));
|
|
90
|
+
const mainDiv = document.getElementById("salert");
|
|
93
91
|
if (mainDiv)
|
|
94
92
|
mainDiv.innerHTML = "";
|
|
95
93
|
return true;
|
package/dist/esm/box/Box.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useEffect, useRef, useState } from "react";
|
|
3
3
|
import styles from "./Box.module.css";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
useEffect(function () {
|
|
4
|
+
export const Box = memo(function MemoFunction({ children, className, style, loading = false }) {
|
|
5
|
+
const boxRef = useRef(null);
|
|
6
|
+
const [hasContent, setHasContent] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
9
8
|
if (!boxRef.current)
|
|
10
9
|
return;
|
|
11
|
-
|
|
10
|
+
const found = boxRef.current.querySelector(".sbox_content");
|
|
12
11
|
setHasContent(!!found);
|
|
13
12
|
}, [children]);
|
|
14
|
-
return (_jsxs("div", { ref: boxRef, className:
|
|
13
|
+
return (_jsxs("div", { ref: boxRef, className: `sbox ${styles.sbox} ${className || ""}`, style: style, children: [(hasContent && children) || _jsx("div", { className: styles.content, children: children }), loading && (_jsx("div", { className: styles.loading, children: _jsx("div", { className: styles.loading_spinner }) }))] }));
|
|
15
14
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import styles from "./Box.module.css";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
return (_jsx("div", { className: "".concat(styles.content, " sbox_content ").concat(className || ""), style: __assign(__assign({}, style), { padding: padding }), children: children }));
|
|
3
|
+
export const BoxContent = ({ className, style, padding, children }) => {
|
|
4
|
+
return (_jsx("div", { className: `${styles.content} sbox_content ${className || ""}`, style: { ...style, padding }, children: children }));
|
|
7
5
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { memo } from "react";
|
|
4
3
|
import styles from "./Box.module.css";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const BoxFooter = memo(function FunctionMemo({ children, className, style, align, marginTop }) {
|
|
5
|
+
return (_jsx("div", { className: `sbox_footer ${styles.footer} ${className || ""}`, style: {
|
|
6
|
+
marginTop,
|
|
7
|
+
justifyContent: align,
|
|
8
|
+
...style
|
|
9
|
+
}, children: children }));
|
|
8
10
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { memo } from 'react';
|
|
4
3
|
import styles from './Box.module.css';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export const BoxHeader = memo(function FunctionMemo({ children, className, title, icon, menu, mainStyle, iconStyle, titleStyle, menuStyle, marginBottom, component = 'div' }) {
|
|
5
|
+
const Comp = component;
|
|
6
|
+
return (_jsxs("div", { className: `sbox_header ${styles.header} ${className || ''}`, style: {
|
|
7
|
+
marginBottom,
|
|
8
|
+
...mainStyle
|
|
9
|
+
}, children: [icon && (_jsx("div", { className: styles.icon, style: iconStyle, children: icon })), _jsx(Comp, { className: `sbox_title ${styles.title}`, style: titleStyle, children: children || title }), menu && (_jsx("div", { className: styles.menu, style: menuStyle, children: menu }))] }));
|
|
9
10
|
});
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useInterval } from '../_lib/useInterval';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
useEffect(
|
|
11
|
-
useEffect(function () {
|
|
4
|
+
export const useCountDown = ({ autoStart = false, onComplete, getStatus, targetTime, timerType = 'countdown', countType = 'seconds', speed = 1000, hide }) => {
|
|
5
|
+
const refCountDownRender = useRef(null);
|
|
6
|
+
const [enabled, setEnabled] = useState(timerType === 'datetime' || autoStart);
|
|
7
|
+
const [timer, setTimer] = useState(0);
|
|
8
|
+
const [timerSpeed, setTimerSpeed] = useState(typeof speed === 'number' && speed > 0 ? speed : 1000);
|
|
9
|
+
useEffect(() => prepareTimer(targetTime), [targetTime]);
|
|
10
|
+
useEffect(() => {
|
|
12
11
|
if (!hide)
|
|
13
12
|
render();
|
|
14
13
|
}, [timer]);
|
|
15
|
-
useInterval(
|
|
14
|
+
useInterval(() => {
|
|
16
15
|
if (enabled) {
|
|
17
16
|
if (timer <= 1) {
|
|
18
17
|
stopCountDown();
|
|
@@ -22,7 +21,7 @@ export var useCountDown = function (_a) {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
}, enabled ? timerSpeed : null);
|
|
25
|
-
|
|
24
|
+
const prepareTimer = (timeORstring) => {
|
|
26
25
|
if (timerType === 'datetime') {
|
|
27
26
|
setTimer(Math.floor((new Date(timeORstring).getTime() - new Date().getTime()) / 1000));
|
|
28
27
|
setEnabled(true);
|
|
@@ -31,20 +30,16 @@ export var useCountDown = function (_a) {
|
|
|
31
30
|
setTimer(timeORstring);
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
|
-
|
|
33
|
+
const stopCountDown = () => {
|
|
35
34
|
setTimer(0);
|
|
36
35
|
setEnabled(false);
|
|
37
36
|
if ((enabled && onComplete) || (timerType === 'datetime' && onComplete)) {
|
|
38
37
|
onComplete();
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return (typeof targetTime === 'number' && targetTime < 10 ? num : String(num).padStart(padLength, padString));
|
|
45
|
-
};
|
|
46
|
-
var render = function () {
|
|
47
|
-
var days = 0, hours = 0, minutes = 0, seconds = timer;
|
|
40
|
+
const padNumber = (num, padLength = 2, padString = '0') => (typeof targetTime === 'number' && targetTime < 10 ? num : String(num).padStart(padLength, padString));
|
|
41
|
+
const render = () => {
|
|
42
|
+
let days = 0, hours = 0, minutes = 0, seconds = timer;
|
|
48
43
|
if (countType === 'minutes:seconds') {
|
|
49
44
|
minutes = Math.floor(seconds / 60);
|
|
50
45
|
seconds -= minutes * 60;
|
|
@@ -65,33 +60,33 @@ export var useCountDown = function (_a) {
|
|
|
65
60
|
}
|
|
66
61
|
seconds = Math.floor(seconds);
|
|
67
62
|
if (getStatus && timer > 0)
|
|
68
|
-
getStatus({ days
|
|
63
|
+
getStatus({ days, hours, minutes, seconds, timer });
|
|
69
64
|
if (refCountDownRender.current) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return { length
|
|
65
|
+
const getPadValues = (div) => {
|
|
66
|
+
const length = div.dataset.padlength || 2;
|
|
67
|
+
const string = div.dataset.padstring || '0';
|
|
68
|
+
return { length, string };
|
|
74
69
|
};
|
|
75
|
-
|
|
70
|
+
const divGun = refCountDownRender.current.querySelector("[data-name='days']");
|
|
76
71
|
if (divGun)
|
|
77
72
|
divGun.innerHTML = padNumber(days, getPadValues(divGun).length, getPadValues(divGun).string).toString();
|
|
78
|
-
|
|
73
|
+
const divSaat = refCountDownRender.current.querySelector("[data-name='hours']");
|
|
79
74
|
if (divSaat)
|
|
80
75
|
divSaat.innerHTML = padNumber(hours, getPadValues(divSaat).length, getPadValues(divSaat).string).toString();
|
|
81
|
-
|
|
76
|
+
const divDakika = refCountDownRender.current.querySelector("[data-name='minutes']");
|
|
82
77
|
if (divDakika)
|
|
83
78
|
divDakika.innerHTML = padNumber(minutes, getPadValues(divDakika).length, getPadValues(divDakika).string).toString();
|
|
84
|
-
|
|
79
|
+
const divSaniye = refCountDownRender.current.querySelector("[data-name='seconds']");
|
|
85
80
|
if (divSaniye)
|
|
86
81
|
divSaniye.innerHTML = padNumber(seconds, getPadValues(divSaniye).length, getPadValues(divSaniye).string).toString();
|
|
87
82
|
}
|
|
88
83
|
};
|
|
89
84
|
return {
|
|
90
|
-
ComponentCountDown:
|
|
91
|
-
startCountDown:
|
|
92
|
-
stopCountDown:
|
|
93
|
-
setTargetTime:
|
|
94
|
-
setTimerSpeed:
|
|
95
|
-
getChildrenRef:
|
|
85
|
+
ComponentCountDown: (children) => (hide ? null : React.cloneElement(children, { ref: refCountDownRender })),
|
|
86
|
+
startCountDown: () => setEnabled(true),
|
|
87
|
+
stopCountDown: () => setEnabled(false),
|
|
88
|
+
setTargetTime: (targetTime) => prepareTimer(targetTime),
|
|
89
|
+
setTimerSpeed: (timerSpeed) => setTimerSpeed(timerSpeed),
|
|
90
|
+
getChildrenRef: () => refCountDownRender.current || null
|
|
96
91
|
};
|
|
97
92
|
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (datetime === void 0) { datetime = null; }
|
|
4
|
-
if (format === void 0) { format = "y-m-d h:i:s"; }
|
|
1
|
+
export default class dateTime {
|
|
2
|
+
constructor(datetime = null, format = "y-m-d h:i:s") {
|
|
5
3
|
this.resut_format = "y-m-d h:i:s";
|
|
6
4
|
this.format(format);
|
|
7
5
|
this.datetime = datetime !== "0000-00-00 00:00:00" && datetime !== "0000-00-00" && datetime ? datetime : new Date().toISOString(); // GMT ekli halde
|
|
8
6
|
return this;
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
addDays(days) {
|
|
9
|
+
const datetime = new Date(this.datetime);
|
|
12
10
|
datetime.setDate(datetime.getDate() + days);
|
|
13
11
|
this.datetime = datetime.toISOString();
|
|
14
12
|
return this;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
}
|
|
14
|
+
parse() {
|
|
15
|
+
const datetime = new Date(this.datetime);
|
|
16
|
+
const monthNames = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
|
|
17
|
+
const dayNames = ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"];
|
|
20
18
|
return {
|
|
21
19
|
y: datetime.getFullYear().toString(),
|
|
22
20
|
m: (datetime.getMonth() + 1).toString().padStart(2, "0"),
|
|
@@ -30,10 +28,10 @@ var dateTime = /** @class */ (function () {
|
|
|
30
28
|
TAMAY: monthNames[datetime.getMonth()],
|
|
31
29
|
TAMGUN: dayNames[datetime.getDay()]
|
|
32
30
|
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
}
|
|
32
|
+
getResult() {
|
|
33
|
+
const parse = this.parse();
|
|
34
|
+
let result = this.resut_format;
|
|
37
35
|
result = result.replace(new RegExp("y", "g"), parse.y.toString());
|
|
38
36
|
result = result.replace(new RegExp("m", "g"), parse.m.toString());
|
|
39
37
|
result = result.replace(new RegExp("d", "g"), parse.d.toString());
|
|
@@ -45,24 +43,22 @@ var dateTime = /** @class */ (function () {
|
|
|
45
43
|
result = result.replace(new RegExp("TAMAY", "g"), parse.TAMAY.toString());
|
|
46
44
|
result = result.replace(new RegExp("TAMGUN", "g"), parse.TAMGUN.toString());
|
|
47
45
|
return result;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (format === void 0) { format = "y-m-d h:i:s"; }
|
|
46
|
+
}
|
|
47
|
+
format(format = "y-m-d h:i:s") {
|
|
51
48
|
this.resut_format = format;
|
|
52
49
|
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
50
|
+
}
|
|
51
|
+
today() {
|
|
55
52
|
this.datetime = new Date().toISOString();
|
|
56
53
|
this.format("y-m-d");
|
|
57
54
|
return this.getResult();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
}
|
|
56
|
+
getTime() {
|
|
57
|
+
const convertDateTime = new dateTime(this.datetime).format("y-m-d h:i:s").getResult();
|
|
58
|
+
const datetime = new Date(convertDateTime);
|
|
62
59
|
return datetime.getTime();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (format === void 0) { format = "y-m-d"; }
|
|
60
|
+
}
|
|
61
|
+
nextMonthFirstDay(format = "y-m-d") {
|
|
66
62
|
// Verilen tarihin bir sonraki ayının ilk gününü bul
|
|
67
63
|
this.datetime = new Date(this.datetime);
|
|
68
64
|
this.datetime.setMonth(this.datetime.getMonth() + 1);
|
|
@@ -70,7 +66,5 @@ var dateTime = /** @class */ (function () {
|
|
|
70
66
|
this.datetime = this.datetime.toISOString();
|
|
71
67
|
this.format(format);
|
|
72
68
|
return this.getResult();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}());
|
|
76
|
-
export default dateTime;
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/esm/form/Button.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { __assign, __rest } from "tslib";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { Dialog } from "./Dialog";
|
|
4
3
|
import { memo, useCallback, useEffect, useState } from "react";
|
|
5
4
|
import { Tooltip } from "../tooltip";
|
|
6
5
|
import Link from "next/link";
|
|
7
6
|
import styles from "./styles/Button.module.css";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
circle.style.width = circle.style.height = "".concat(diameter, "px");
|
|
7
|
+
export const Button = memo(function MemoFunction({ children, component = "button", className, buttonClass = "default", buttonSize = "medium", style, type = "button", fullWidth = false, onlyIcon, onClick, href, target, tabIndex, title, titlePosition, titleArrow, dialog, autoFocus, ...other }) {
|
|
8
|
+
const Comp = component;
|
|
9
|
+
const ripple = (e) => {
|
|
10
|
+
const el = e.currentTarget;
|
|
11
|
+
const circle = document.createElement("span");
|
|
12
|
+
const diameter = Math.max(el.clientWidth, el.clientHeight);
|
|
13
|
+
circle.style.width = circle.style.height = `${diameter}px`;
|
|
16
14
|
circle.classList.add(styles.ripple);
|
|
17
|
-
|
|
15
|
+
const ripple = el.getElementsByClassName(styles.ripple)[0];
|
|
18
16
|
if (ripple)
|
|
19
17
|
ripple.remove();
|
|
20
18
|
el.appendChild(circle);
|
|
21
19
|
};
|
|
22
|
-
|
|
20
|
+
const handleClick = (e) => {
|
|
23
21
|
ripple(e);
|
|
24
22
|
if (dialog) {
|
|
25
|
-
Dialog(dialog).then(
|
|
23
|
+
Dialog(dialog).then((result) => {
|
|
26
24
|
if (result && onClick) {
|
|
27
25
|
onClick(e);
|
|
28
26
|
}
|
|
@@ -33,8 +31,8 @@ export var Button = memo(function MemoFunction(_a) {
|
|
|
33
31
|
onClick(e);
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const createClassList = useCallback(() => {
|
|
35
|
+
const list = ["sbutton", styles.button];
|
|
38
36
|
if (buttonClass)
|
|
39
37
|
list.push(styles[buttonClass]);
|
|
40
38
|
if (className)
|
|
@@ -45,27 +43,35 @@ export var Button = memo(function MemoFunction(_a) {
|
|
|
45
43
|
list.push(styles.fullwidth);
|
|
46
44
|
return list.join(" ");
|
|
47
45
|
}, [buttonClass, className, onlyIcon, fullWidth]);
|
|
48
|
-
|
|
49
|
-
useEffect(
|
|
50
|
-
|
|
46
|
+
const [classList, setClassList] = useState(() => createClassList());
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const newClassList = createClassList().split(" ").filter(Boolean);
|
|
51
49
|
if (href && typeof window !== "undefined" && window.location.pathname === href) {
|
|
52
50
|
newClassList.push("active");
|
|
53
51
|
}
|
|
54
52
|
setClassList(newClassList.join(" "));
|
|
55
53
|
}, [href, createClassList]);
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
let ortakProps = {
|
|
55
|
+
className: classList,
|
|
56
|
+
style,
|
|
57
|
+
onClick: handleClick,
|
|
58
|
+
tabIndex,
|
|
59
|
+
autoFocus,
|
|
60
|
+
"data-button-size": (!onlyIcon) ? buttonSize : null,
|
|
61
|
+
...other
|
|
62
|
+
};
|
|
63
|
+
let renderComponent;
|
|
58
64
|
if (href !== undefined) {
|
|
59
65
|
if (other === null || other === void 0 ? void 0 : other.hidden) {
|
|
60
66
|
renderComponent = null;
|
|
61
67
|
}
|
|
62
68
|
else {
|
|
63
|
-
|
|
64
|
-
renderComponent = (_jsx(Link, { href: checkHref, target: (other === null || other === void 0 ? void 0 : other.disabled) ? "_self" : target, children: _jsx(Comp,
|
|
69
|
+
let checkHref = (other === null || other === void 0 ? void 0 : other.disabled) ? "#" : href;
|
|
70
|
+
renderComponent = (_jsx(Link, { href: checkHref, target: (other === null || other === void 0 ? void 0 : other.disabled) ? "_self" : target, children: _jsx(Comp, { ...ortakProps, children: onlyIcon ? onlyIcon : children }) }));
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
73
|
else {
|
|
68
|
-
renderComponent = (_jsx(Comp,
|
|
74
|
+
renderComponent = (_jsx(Comp, { type: type, ...ortakProps, children: onlyIcon ? onlyIcon : children }));
|
|
69
75
|
}
|
|
70
76
|
if (title && renderComponent) {
|
|
71
77
|
return (_jsx(Tooltip, { title: title, position: titlePosition, arrow: titleArrow, children: renderComponent }));
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import styles from "./styles/Input.module.css";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
var refMain = useRef(null);
|
|
4
|
+
export const Checkbox = ({ ref, children, name, label, checked, className, style, styleCheckbox, styleLabel, onToogle, disabled, tabIndex, required = false }) => {
|
|
5
|
+
const refMain = useRef(null);
|
|
7
6
|
// checked değerini boolean hâline getiriyoruz
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const isChecked = checked === "1" || checked === true;
|
|
8
|
+
const handleChange = (newChecked) => {
|
|
10
9
|
if (disabled)
|
|
11
10
|
return;
|
|
12
11
|
onToogle === null || onToogle === void 0 ? void 0 : onToogle({
|
|
13
12
|
target: {
|
|
14
|
-
name
|
|
13
|
+
name,
|
|
15
14
|
value: newChecked ? "1" : "0"
|
|
16
15
|
}
|
|
17
16
|
});
|
|
18
17
|
};
|
|
19
|
-
|
|
18
|
+
const toggleCheck = () => {
|
|
20
19
|
handleChange(!isChecked);
|
|
21
20
|
};
|
|
22
|
-
return (_jsxs("div", { ref: refMain, className:
|
|
21
|
+
return (_jsxs("div", { ref: refMain, className: `${styles.checkbox} ${className || ""}`, style: style, tabIndex: tabIndex, onClick: toggleCheck, children: [_jsx("input", { ref: ref, type: "checkbox", name: name, onChange: (e) => 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
22
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
export type propsDialog = {
|
|
3
3
|
message: any;
|
|
4
4
|
acceptButtonShow?: boolean;
|
|
5
5
|
cancelButtonShow?: boolean;
|
|
6
6
|
acceptButtonText?: string | ReactNode;
|
|
7
7
|
cancelButtonText?: string | ReactNode;
|
|
8
|
-
acceptButtonClass?:
|
|
9
|
-
cancelButtonClass?:
|
|
10
|
-
vertialAlign?:
|
|
11
|
-
horizontalAlign?:
|
|
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
12
|
hideBackdrop?: boolean;
|
|
13
13
|
hideEsc?: boolean;
|
|
14
14
|
styleMessage?: React.CSSProperties;
|
|
15
15
|
styleBox?: React.CSSProperties;
|
|
16
16
|
styleBoxFooter?: React.CSSProperties;
|
|
17
|
-
autoFocus?:
|
|
17
|
+
autoFocus?: 'accept' | 'cancel';
|
|
18
|
+
backdropStyle?: React.CSSProperties;
|
|
18
19
|
};
|
|
19
20
|
export declare const Dialog: (config: propsDialog) => Promise<unknown>;
|