@sydsoft/base 1.49.0 → 1.50.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/package.json +2 -2
- package/_lib/baseFunctions.ts +0 -94
- package/_lib/inputMask.ts +0 -257
- package/_lib/listFunctions.ts +0 -106
- package/_lib/storage/cookies.ts +0 -39
- package/_lib/storage/encData.ts +0 -41
- package/_lib/storage/localStorage.ts +0 -67
- package/_lib/storage/sessionStorage.ts +0 -67
- package/_lib/useInterval.ts +0 -30
- package/alert/index.module.css +0 -119
- package/alert/index.tsx +0 -131
- package/box/Box.module.css +0 -153
- package/box/Box.tsx +0 -33
- package/box/BoxContent.tsx +0 -18
- package/box/BoxFooter.tsx +0 -25
- package/box/BoxHeader.tsx +0 -46
- package/box/index.ts +0 -10
- package/countDown/index.tsx +0 -116
- package/dateTime/index.ts +0 -79
- package/form/Button.tsx +0 -143
- package/form/Checkbox.tsx +0 -48
- package/form/Dialog.tsx +0 -109
- package/form/Form.tsx +0 -19
- package/form/FormOlustur.tsx +0 -105
- package/form/Input.tsx +0 -364
- package/form/Label.tsx +0 -20
- package/form/SearchableInput.tsx +0 -406
- package/form/UploadBase.tsx +0 -133
- package/form/index.ts +0 -10
- package/form/styles/Button.module.css +0 -145
- package/form/styles/Input.module.css +0 -221
- package/form/styles/Label.module.css +0 -31
- package/form/styles/SearchableInput.module.css +0 -80
- package/global.d.ts +0 -9
- package/grid/index.module.css +0 -805
- package/grid/index.tsx +0 -171
- package/icon/icons.tsx +0 -33
- package/icon/index.tsx +0 -95
- package/icon/mui.tsx +0 -5932
- package/index.ts +0 -21
- package/menu/index.module.css +0 -92
- package/menu/index.tsx +0 -143
- package/modal/index.module.css +0 -77
- package/modal/index.tsx +0 -106
- package/npm_recovery_codes.txt +0 -5
- package/popover/index.module.css +0 -89
- package/popover/index.tsx +0 -392
- package/tooltip/index.tsx +0 -216
- package/tsconfig.json +0 -24
package/_lib/useInterval.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023
|
|
3
|
-
* @author: izzetseydaoglu
|
|
4
|
-
* @last-modified: 29.01.2024 04:09
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// source: https://overreacted.io/making-setinterval-declarative-with-react-hooks/
|
|
8
|
-
|
|
9
|
-
import { useEffect, useRef } from "react";
|
|
10
|
-
|
|
11
|
-
export function useInterval(callback: any, delay: any) {
|
|
12
|
-
const savedCallback = useRef<any>(null);
|
|
13
|
-
|
|
14
|
-
// Remember the latest callback.
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
savedCallback.current = callback;
|
|
17
|
-
}, [callback]);
|
|
18
|
-
|
|
19
|
-
// Set up the interval.
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
function tick() {
|
|
22
|
-
savedCallback && savedCallback.current && savedCallback.current();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (delay !== null) {
|
|
26
|
-
const id = setInterval(tick, delay);
|
|
27
|
-
return () => clearInterval(id);
|
|
28
|
-
}
|
|
29
|
-
}, [delay]);
|
|
30
|
-
}
|
package/alert/index.module.css
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
.message {
|
|
2
|
-
flex: 1;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.close {
|
|
6
|
-
position: absolute;
|
|
7
|
-
top: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
width: 17px;
|
|
10
|
-
height: 17px;
|
|
11
|
-
border-radius: 50%;
|
|
12
|
-
padding: 3px;
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
font-size: 9px;
|
|
17
|
-
letter-spacing: 0;
|
|
18
|
-
transform: translate(-50%, -50%) scale(0);
|
|
19
|
-
transition: ease-in-out 0.2s;
|
|
20
|
-
border: 1px #97979740 solid;
|
|
21
|
-
box-shadow: 1px 1px 4px 0 #000000a6;
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
background: inherit;
|
|
24
|
-
}
|
|
25
|
-
.close:hover {
|
|
26
|
-
zoom: 1.1;
|
|
27
|
-
}
|
|
28
|
-
.salert:hover .close {
|
|
29
|
-
transform: translate(-50%, -50%) scale(1);
|
|
30
|
-
}
|
|
31
|
-
.salert {
|
|
32
|
-
position: relative;
|
|
33
|
-
min-width: 50px;
|
|
34
|
-
width: fit-content;
|
|
35
|
-
margin: 6px 0 6px auto;
|
|
36
|
-
padding: 10px 15px;
|
|
37
|
-
border-radius: 5px;
|
|
38
|
-
cursor: default;
|
|
39
|
-
background: #1f1f1f;
|
|
40
|
-
color: rgba(255, 255, 255, 0.93);
|
|
41
|
-
border: 1px #97979740 solid;
|
|
42
|
-
box-shadow: 1px 1px 4px 0 #000000a6;
|
|
43
|
-
display: flex;
|
|
44
|
-
flex-direction: row;
|
|
45
|
-
align-items: center;
|
|
46
|
-
transition: transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms;
|
|
47
|
-
animation: show 0.3s;
|
|
48
|
-
font-family: inherit;
|
|
49
|
-
font-size: 1rem;
|
|
50
|
-
line-height: 1.5;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.error {
|
|
54
|
-
background: rgb(211, 47, 47);
|
|
55
|
-
background: linear-gradient(
|
|
56
|
-
135deg,
|
|
57
|
-
rgba(211, 47, 47, 1) 0%,
|
|
58
|
-
rgba(211, 47, 47, 0.8) 70%
|
|
59
|
-
);
|
|
60
|
-
color: rgba(255, 255, 255, 0.93);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.success {
|
|
64
|
-
background: rgb(67, 160, 71);
|
|
65
|
-
background: linear-gradient(
|
|
66
|
-
135deg,
|
|
67
|
-
rgba(67, 160, 71, 1) 0%,
|
|
68
|
-
rgba(67, 160, 71, 0.8) 70%
|
|
69
|
-
);
|
|
70
|
-
color: rgba(255, 255, 255, 0.93);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.info {
|
|
74
|
-
background: rgb(13, 141, 189);
|
|
75
|
-
background: linear-gradient(
|
|
76
|
-
135deg,
|
|
77
|
-
rgba(13, 141, 189, 1) 0%,
|
|
78
|
-
rgba(13, 141, 189, 0.8) 70%
|
|
79
|
-
);
|
|
80
|
-
color: rgba(255, 255, 255, 0.93);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.warning {
|
|
84
|
-
background: rgb(217, 142, 4);
|
|
85
|
-
background: linear-gradient(
|
|
86
|
-
135deg,
|
|
87
|
-
rgba(217, 142, 4, 1) 0%,
|
|
88
|
-
rgba(217, 142, 4, 0.8) 70%
|
|
89
|
-
);
|
|
90
|
-
color: rgba(255, 255, 255, 0.93);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.loading {
|
|
94
|
-
background: linear-gradient(
|
|
95
|
-
60deg,
|
|
96
|
-
rgb(15 33 34) 0%,
|
|
97
|
-
rgba(0, 172, 193, 1) 100%
|
|
98
|
-
);
|
|
99
|
-
color: rgba(255, 255, 255, 0.93);
|
|
100
|
-
animation: waves 50s infinite linear;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@keyframes show {
|
|
104
|
-
from {
|
|
105
|
-
transform: translateX(200%);
|
|
106
|
-
}
|
|
107
|
-
to {
|
|
108
|
-
transform: translateX(0);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@keyframes waves {
|
|
113
|
-
from {
|
|
114
|
-
background-position: 0;
|
|
115
|
-
}
|
|
116
|
-
to {
|
|
117
|
-
background-position: 100vw 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
package/alert/index.tsx
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
import { createRoot } from "react-dom/client";
|
|
4
|
-
import styles from "./index.module.css";
|
|
5
|
-
|
|
6
|
-
const sAlertTimeout: any[] = [];
|
|
7
|
-
|
|
8
|
-
export type typeAlert = {
|
|
9
|
-
defaultTimer?: string;
|
|
10
|
-
defaultErrorTimer?: string;
|
|
11
|
-
defaultSuccessTimer?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const Alert = ({ defaultTimer = "5000", defaultErrorTimer = "10000", defaultSuccessTimer = "5000" }: typeAlert) => {
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (typeof window === "undefined") return;
|
|
17
|
-
const divCheck = document.getElementById("salert");
|
|
18
|
-
if (!divCheck) {
|
|
19
|
-
// let div = document.createElement('div') as HTMLDivElement
|
|
20
|
-
const div = document.createElement("div");
|
|
21
|
-
div.setAttribute("id", "salert");
|
|
22
|
-
div.setAttribute("defaultTimer", defaultTimer);
|
|
23
|
-
div.setAttribute("defaultErrorTimer", defaultErrorTimer);
|
|
24
|
-
div.setAttribute("defaultSuccessTimer", defaultSuccessTimer);
|
|
25
|
-
const alertStyle = [
|
|
26
|
-
"position: fixed",
|
|
27
|
-
"bottom: 0",
|
|
28
|
-
"right: 0",
|
|
29
|
-
"max-width: 300px",
|
|
30
|
-
"max-height: 600px",
|
|
31
|
-
"overflow-x: hidden",
|
|
32
|
-
"padding: 15px",
|
|
33
|
-
"display: flex",
|
|
34
|
-
"flex-direction: column",
|
|
35
|
-
"z-index: 9999999"
|
|
36
|
-
];
|
|
37
|
-
div.setAttribute("style", alertStyle.join(";"));
|
|
38
|
-
document.body.appendChild(div);
|
|
39
|
-
}
|
|
40
|
-
}, []);
|
|
41
|
-
|
|
42
|
-
return null;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
type typeAddAlert = {
|
|
46
|
-
type: "error" | "success" | "warning" | "info" | "loading";
|
|
47
|
-
message: string;
|
|
48
|
-
timer?: number | boolean;
|
|
49
|
-
style?: React.CSSProperties;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const alert_add = ({ type, message, style, timer }: typeAddAlert) => {
|
|
53
|
-
if (typeof window === "undefined") return false;
|
|
54
|
-
const mainDiv = document.getElementById("salert");
|
|
55
|
-
if (mainDiv) {
|
|
56
|
-
const alert = document.createElement("div");
|
|
57
|
-
mainDiv.prepend(alert);
|
|
58
|
-
|
|
59
|
-
const onClose = () => {
|
|
60
|
-
if (mainDiv && alert && mainDiv.contains(alert)) mainDiv.removeChild(alert);
|
|
61
|
-
};
|
|
62
|
-
const root = createRoot(alert!);
|
|
63
|
-
const Component = (
|
|
64
|
-
<div className={`${styles.salert} ${styles[type]}`} style={style}>
|
|
65
|
-
<div className={styles.message} dangerouslySetInnerHTML={{ __html: message }} />
|
|
66
|
-
<div className={styles.close} onClick={onClose}>
|
|
67
|
-
✕
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
root.render(Component);
|
|
72
|
-
|
|
73
|
-
const defaultTimer = mainDiv.getAttribute("defaulttimer") ?? "5000";
|
|
74
|
-
const defaultErrorTimer = mainDiv.getAttribute("defaulterrortimer") ?? "10000";
|
|
75
|
-
const defaultSuccessTimer = mainDiv.getAttribute("defaultsuccesstimer") ?? "5000";
|
|
76
|
-
|
|
77
|
-
const timerFilled = typeof timer === "number" && timer > 0;
|
|
78
|
-
|
|
79
|
-
let newTimer = timerFilled ? timer : defaultTimer;
|
|
80
|
-
|
|
81
|
-
switch (type) {
|
|
82
|
-
case "error":
|
|
83
|
-
newTimer = timerFilled ? timer : defaultErrorTimer;
|
|
84
|
-
break;
|
|
85
|
-
case "success":
|
|
86
|
-
newTimer = timerFilled ? timer : defaultSuccessTimer;
|
|
87
|
-
break;
|
|
88
|
-
default:
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
newTimer = newTimer as number;
|
|
92
|
-
|
|
93
|
-
if (typeof timer !== "boolean") {
|
|
94
|
-
// False gelmişse sabit kalsın
|
|
95
|
-
if (newTimer > 0) {
|
|
96
|
-
const timeout = setTimeout(() => onClose(), newTimer);
|
|
97
|
-
sAlertTimeout.push(timeout);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return alert;
|
|
102
|
-
}
|
|
103
|
-
return null;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const alert_remove = (alert: any): void => {
|
|
107
|
-
if (typeof window === "undefined" || !alert) return;
|
|
108
|
-
const mainDiv = document.getElementById("salert");
|
|
109
|
-
if (mainDiv && alert && mainDiv.contains(alert)) mainDiv.removeChild(alert);
|
|
110
|
-
return;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const alert_clear = () => {
|
|
114
|
-
if (typeof window === "undefined") return false;
|
|
115
|
-
sAlertTimeout.map((id) => clearTimeout(id));
|
|
116
|
-
const mainDiv = document.getElementById("salert");
|
|
117
|
-
if (mainDiv) mainDiv.innerHTML = "";
|
|
118
|
-
return true;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export function alertCheck(response: any) {
|
|
122
|
-
if (response.data && response.data["alert"]) {
|
|
123
|
-
response.data["alert"].map(function (alert: any) {
|
|
124
|
-
alert_add({
|
|
125
|
-
type: alert.type,
|
|
126
|
-
message: alert.message,
|
|
127
|
-
timer: alert.timer
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
package/box/Box.module.css
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
.sbox {
|
|
2
|
-
position: relative;
|
|
3
|
-
max-width: 100%;
|
|
4
|
-
background-color: #fff;
|
|
5
|
-
box-shadow: 0 2px 4px rgb(0 0 0 / 10%), 0 8px 16px rgb(0 0 0 / 10%);
|
|
6
|
-
border-radius: 8px;
|
|
7
|
-
overflow-y: auto;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.sbox h1,
|
|
11
|
-
.sbox h2,
|
|
12
|
-
.sbox h3,
|
|
13
|
-
.sbox h4,
|
|
14
|
-
.sbox h5,
|
|
15
|
-
.sbox h6 {
|
|
16
|
-
margin: 0;
|
|
17
|
-
padding: 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.content {
|
|
21
|
-
padding: 20px;
|
|
22
|
-
box-sizing: border-box;
|
|
23
|
-
overflow: auto;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.header,
|
|
27
|
-
.footer {
|
|
28
|
-
z-index: 1;
|
|
29
|
-
position: sticky;
|
|
30
|
-
padding: 12px 16px;
|
|
31
|
-
background: inherit;
|
|
32
|
-
}
|
|
33
|
-
.header {
|
|
34
|
-
top: 0;
|
|
35
|
-
border-bottom: 1px solid #00000020;
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: row;
|
|
38
|
-
justify-content: flex-start;
|
|
39
|
-
align-items: center;
|
|
40
|
-
gap: 10px;
|
|
41
|
-
/* margin: 10px 0 5px 0; */
|
|
42
|
-
}
|
|
43
|
-
.footer {
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: row;
|
|
46
|
-
flex-wrap: wrap;
|
|
47
|
-
align-items: center;
|
|
48
|
-
justify-content: flex-end;
|
|
49
|
-
gap: 10px;
|
|
50
|
-
bottom: 0;
|
|
51
|
-
border-top: 1px solid #00000020;
|
|
52
|
-
background-color: #f7f7f7;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.icon {
|
|
56
|
-
display: inline-flex;
|
|
57
|
-
align-items: center;
|
|
58
|
-
flex: 0 0 auto;
|
|
59
|
-
text-align: center;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.title {
|
|
64
|
-
flex: 1;
|
|
65
|
-
font-size: 1.1rem;
|
|
66
|
-
font-weight: 500;
|
|
67
|
-
line-height: 1.5;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.menu {
|
|
71
|
-
display: inline-flex;
|
|
72
|
-
flex: 0 0 auto;
|
|
73
|
-
align-items: center;
|
|
74
|
-
justify-content: center;
|
|
75
|
-
}
|
|
76
|
-
.menu > * {
|
|
77
|
-
margin: 0 3px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.loading {
|
|
81
|
-
position: absolute;
|
|
82
|
-
top: 0;
|
|
83
|
-
left: 0;
|
|
84
|
-
width: 100%;
|
|
85
|
-
height: 100%;
|
|
86
|
-
background-color: #f4f7faa6;
|
|
87
|
-
overflow: hidden;
|
|
88
|
-
border-radius: inherit;
|
|
89
|
-
display: flex;
|
|
90
|
-
justify-content: center;
|
|
91
|
-
align-items: center;
|
|
92
|
-
z-index: 9999;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.loading::after {
|
|
96
|
-
position: absolute;
|
|
97
|
-
top: 0;
|
|
98
|
-
right: 0;
|
|
99
|
-
bottom: 0;
|
|
100
|
-
left: 0;
|
|
101
|
-
transform: translateX(-100%);
|
|
102
|
-
background: linear-gradient(90deg, rgb(183 190 199 / 2%) 0, rgb(182 190 198 / 19%) 20%, rgb(183 190 199 / 2%) 60%, rgb(184 192 200 / 1%));
|
|
103
|
-
animation: shimmer 2s infinite;
|
|
104
|
-
content: "";
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.loading_spinner {
|
|
108
|
-
position: relative;
|
|
109
|
-
margin: 6px;
|
|
110
|
-
width: 24px;
|
|
111
|
-
height: 24px;
|
|
112
|
-
}
|
|
113
|
-
.loading_spinner:before {
|
|
114
|
-
position: absolute;
|
|
115
|
-
display: block;
|
|
116
|
-
content: "";
|
|
117
|
-
z-index: 12;
|
|
118
|
-
top: 3px;
|
|
119
|
-
left: 3px;
|
|
120
|
-
width: 30px;
|
|
121
|
-
height: 30px;
|
|
122
|
-
border-radius: 50%;
|
|
123
|
-
background-color: #fff;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.loading_spinner:after {
|
|
127
|
-
position: absolute;
|
|
128
|
-
display: block;
|
|
129
|
-
content: "";
|
|
130
|
-
z-index: 11;
|
|
131
|
-
width: 18px;
|
|
132
|
-
height: 18px;
|
|
133
|
-
border-radius: 200px 0 0;
|
|
134
|
-
background: linear-gradient(45deg, rgba(0, 0, 0, 0) 0, rgba(69, 154, 215, 1) 50%, rgba(69, 154, 215, 1) 100%);
|
|
135
|
-
animation: loading_spinner 0.5s linear infinite;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@keyframes shimmer {
|
|
139
|
-
100% {
|
|
140
|
-
transform: translateX(100%);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
@keyframes loading_spinner {
|
|
144
|
-
0% {
|
|
145
|
-
transform-origin: 100% 100%;
|
|
146
|
-
transform: rotate(0deg);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
100% {
|
|
150
|
-
transform-origin: 100% 100%;
|
|
151
|
-
transform: rotate(360deg);
|
|
152
|
-
}
|
|
153
|
-
}
|
package/box/Box.tsx
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { memo, useEffect, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import styles from "./Box.module.css";
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
className?: string;
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
loading?: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const Box = memo(function MemoFunction({ children, className, style, loading = false }: Props) {
|
|
13
|
-
const boxRef = useRef<HTMLDivElement>(null);
|
|
14
|
-
|
|
15
|
-
const [hasContent, setHasContent] = useState(false);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (!boxRef.current) return;
|
|
18
|
-
const found = boxRef.current.querySelector(".sbox_content");
|
|
19
|
-
setHasContent(!!found);
|
|
20
|
-
}, [children]);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div ref={boxRef} className={`sbox ${styles.sbox} ${className || ""}`} style={style}>
|
|
24
|
-
{(hasContent && children) || <div className={styles.content}>{children}</div>}
|
|
25
|
-
|
|
26
|
-
{loading && (
|
|
27
|
-
<div className={styles.loading}>
|
|
28
|
-
<div className={styles.loading_spinner} />
|
|
29
|
-
</div>
|
|
30
|
-
)}
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
});
|
package/box/BoxContent.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
import styles from "./Box.module.css";
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: React.CSSProperties;
|
|
8
|
-
padding?: number;
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const BoxContent = ({ className, style, padding, children }: Props) => {
|
|
13
|
-
return (
|
|
14
|
-
<div className={`${styles.content} sbox_content ${className || ""}`} style={{ ...style, padding }}>
|
|
15
|
-
{children}
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
};
|
package/box/BoxFooter.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { memo } from "react";
|
|
2
|
-
|
|
3
|
-
import styles from "./Box.module.css";
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
className?: string;
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
marginTop?: number;
|
|
10
|
-
align?: "flex-start" | "center" | "flex-end" | "stretch";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const BoxFooter = memo(function FunctionMemo({ children, className, style, align, marginTop }: Props) {
|
|
14
|
-
return (
|
|
15
|
-
<div
|
|
16
|
-
className={`sbox_footer ${styles.footer} ${className || ""}`}
|
|
17
|
-
style={{
|
|
18
|
-
marginTop,
|
|
19
|
-
justifyContent: align,
|
|
20
|
-
...style
|
|
21
|
-
}}>
|
|
22
|
-
{children}
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
});
|
package/box/BoxHeader.tsx
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, memo } from 'react';
|
|
2
|
-
|
|
3
|
-
import styles from './Box.module.css';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
className?: string;
|
|
8
|
-
title?: string | ReactNode;
|
|
9
|
-
icon?: ReactNode;
|
|
10
|
-
menu?: ReactNode;
|
|
11
|
-
mainStyle?: React.CSSProperties;
|
|
12
|
-
iconStyle?: React.CSSProperties;
|
|
13
|
-
titleStyle?: React.CSSProperties;
|
|
14
|
-
menuStyle?: React.CSSProperties;
|
|
15
|
-
component?: any;
|
|
16
|
-
marginBottom?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const BoxHeader = memo(function FunctionMemo({ children, className, title, icon, menu, mainStyle, iconStyle, titleStyle, menuStyle, marginBottom, component = 'div' }: Props) {
|
|
20
|
-
const Comp = component;
|
|
21
|
-
return (
|
|
22
|
-
<div
|
|
23
|
-
className={`sbox_header ${styles.header} ${className || ''}`}
|
|
24
|
-
style={{
|
|
25
|
-
marginBottom,
|
|
26
|
-
...mainStyle
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
{icon && (
|
|
30
|
-
<div className={styles.icon} style={iconStyle}>
|
|
31
|
-
{icon}
|
|
32
|
-
</div>
|
|
33
|
-
)}
|
|
34
|
-
|
|
35
|
-
<Comp className={`sbox_title ${styles.title}`} style={titleStyle}>
|
|
36
|
-
{children || title}
|
|
37
|
-
</Comp>
|
|
38
|
-
|
|
39
|
-
{menu && (
|
|
40
|
-
<div className={styles.menu} style={menuStyle}>
|
|
41
|
-
{menu}
|
|
42
|
-
</div>
|
|
43
|
-
)}
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
});
|
package/box/index.ts
DELETED
package/countDown/index.tsx
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { useInterval } from '../_lib/useInterval';
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
targetTime: number | string; // 30 | "2022-01-20 22:35" | veya direkt microtime ;
|
|
8
|
-
timerType?: 'countdown' | 'datetime';
|
|
9
|
-
speed?: number;
|
|
10
|
-
countType?: 'seconds' | 'minutes:seconds' | 'hours:minutes:seconds' | 'days:hours:minutes:seconds';
|
|
11
|
-
hide?: boolean;
|
|
12
|
-
onComplete?: () => void;
|
|
13
|
-
getStatus?: ({ days, hours, minutes, seconds, timer }: any) => void;
|
|
14
|
-
autoStart?: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const useCountDown = ({ autoStart = false, onComplete, getStatus, targetTime, timerType = 'countdown', countType = 'seconds', speed = 1000, hide }: Props) => {
|
|
18
|
-
const refCountDownRender = useRef<any>(null);
|
|
19
|
-
const [enabled, setEnabled] = useState(timerType === 'datetime' || autoStart);
|
|
20
|
-
const [timer, setTimer] = useState<any>(0);
|
|
21
|
-
const [timerSpeed, setTimerSpeed] = useState<number>(typeof speed === 'number' && speed > 0 ? speed : 1000);
|
|
22
|
-
|
|
23
|
-
useEffect(() => prepareTimer(targetTime), [targetTime]);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (!hide) render();
|
|
27
|
-
}, [timer]);
|
|
28
|
-
|
|
29
|
-
useInterval(
|
|
30
|
-
() => {
|
|
31
|
-
if (enabled) {
|
|
32
|
-
if (timer <= 1) {
|
|
33
|
-
stopCountDown();
|
|
34
|
-
} else {
|
|
35
|
-
setTimer(timer - 1);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
enabled ? timerSpeed : null
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const prepareTimer = (timeORstring: string | number) => {
|
|
43
|
-
if (timerType === 'datetime') {
|
|
44
|
-
setTimer(Math.floor((new Date(timeORstring).getTime() - new Date().getTime()) / 1000));
|
|
45
|
-
setEnabled(true);
|
|
46
|
-
} else {
|
|
47
|
-
setTimer(timeORstring);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const stopCountDown = () => {
|
|
52
|
-
setTimer(0);
|
|
53
|
-
setEnabled(false);
|
|
54
|
-
if ((enabled && onComplete) || (timerType === 'datetime' && onComplete)) {
|
|
55
|
-
onComplete();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const padNumber = (num: number, padLength = 2, padString = '0') => (typeof targetTime === 'number' && targetTime < 10 ? num : String(num).padStart(padLength, padString));
|
|
60
|
-
|
|
61
|
-
const render = () => {
|
|
62
|
-
let days = 0,
|
|
63
|
-
hours = 0,
|
|
64
|
-
minutes = 0,
|
|
65
|
-
seconds = timer;
|
|
66
|
-
if (countType === 'minutes:seconds') {
|
|
67
|
-
minutes = Math.floor(seconds / 60);
|
|
68
|
-
seconds -= minutes * 60;
|
|
69
|
-
} else if (countType === 'hours:minutes:seconds') {
|
|
70
|
-
hours = Math.floor(seconds / (60 * 60));
|
|
71
|
-
seconds -= hours * 60 * 60;
|
|
72
|
-
minutes = Math.floor(seconds / 60);
|
|
73
|
-
seconds -= minutes * 60;
|
|
74
|
-
} else if (countType === 'days:hours:minutes:seconds') {
|
|
75
|
-
days = Math.floor(seconds / (60 * 60 * 24));
|
|
76
|
-
seconds -= days * 60 * 60 * 24;
|
|
77
|
-
hours = Math.floor(seconds / (60 * 60));
|
|
78
|
-
seconds -= hours * 60 * 60;
|
|
79
|
-
minutes = Math.floor(seconds / 60);
|
|
80
|
-
seconds -= minutes * 60;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
seconds = Math.floor(seconds);
|
|
84
|
-
|
|
85
|
-
if (getStatus && timer > 0) getStatus({ days, hours, minutes, seconds, timer });
|
|
86
|
-
|
|
87
|
-
if (refCountDownRender.current) {
|
|
88
|
-
const getPadValues = (div: any) => {
|
|
89
|
-
const length = div.dataset.padlength || 2;
|
|
90
|
-
const string = div.dataset.padstring || '0';
|
|
91
|
-
return { length, string };
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const divGun = refCountDownRender.current.querySelector("[data-name='days']");
|
|
95
|
-
if (divGun) divGun.innerHTML = padNumber(days, getPadValues(divGun).length, getPadValues(divGun).string).toString();
|
|
96
|
-
|
|
97
|
-
const divSaat = refCountDownRender.current.querySelector("[data-name='hours']");
|
|
98
|
-
if (divSaat) divSaat.innerHTML = padNumber(hours, getPadValues(divSaat).length, getPadValues(divSaat).string).toString();
|
|
99
|
-
|
|
100
|
-
const divDakika = refCountDownRender.current.querySelector("[data-name='minutes']");
|
|
101
|
-
if (divDakika) divDakika.innerHTML = padNumber(minutes, getPadValues(divDakika).length, getPadValues(divDakika).string).toString();
|
|
102
|
-
|
|
103
|
-
const divSaniye = refCountDownRender.current.querySelector("[data-name='seconds']");
|
|
104
|
-
if (divSaniye) divSaniye.innerHTML = padNumber(seconds, getPadValues(divSaniye).length, getPadValues(divSaniye).string).toString();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
ComponentCountDown: (children: any) => (hide ? null : React.cloneElement(children, { ref: refCountDownRender })),
|
|
110
|
-
startCountDown: () => setEnabled(true),
|
|
111
|
-
stopCountDown: () => setEnabled(false),
|
|
112
|
-
setTargetTime: (targetTime: number | string) => prepareTimer(targetTime),
|
|
113
|
-
setTimerSpeed: (timerSpeed: number) => setTimerSpeed(timerSpeed),
|
|
114
|
-
getChildrenRef: () => refCountDownRender.current || null
|
|
115
|
-
};
|
|
116
|
-
};
|