ar-design 0.1.59 → 0.1.60
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/assets/css/components/feedback/loading/loading.css +54 -0
- package/dist/assets/css/components/feedback/progress/animations.css +10 -0
- package/dist/assets/css/components/feedback/progress/progress.css +49 -0
- package/dist/assets/css/components/form/date-picker/calendar/header.css +78 -7
- package/dist/components/data-display/dnd/index.js +1 -1
- package/dist/components/feedback/confirm/index.js +0 -5
- package/dist/components/feedback/loading/index.d.ts +4 -0
- package/dist/components/feedback/loading/index.js +7 -0
- package/dist/components/feedback/modal/index.js +0 -5
- package/dist/components/feedback/progress/IProps.d.ts +5 -0
- package/dist/components/feedback/progress/IProps.js +1 -0
- package/dist/components/feedback/progress/index.d.ts +5 -0
- package/dist/components/feedback/progress/index.js +26 -0
- package/dist/components/form/button-action/index.js +0 -7
- package/dist/components/form/date-picker/DATE.d.ts +12 -0
- package/dist/components/form/date-picker/DATE.js +23 -0
- package/dist/components/form/date-picker/index.js +111 -165
- package/dist/components/form/input/index.js +7 -4
- package/dist/components/form/select/index.js +11 -31
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/libs/core/application/contexts/Loading.d.ts +11 -0
- package/dist/libs/core/application/contexts/Loading.js +13 -0
- package/dist/libs/core/application/contexts/index.d.ts +2 -1
- package/dist/libs/core/application/contexts/index.js +2 -1
- package/dist/libs/core/application/hooks/index.d.ts +5 -1
- package/dist/libs/core/application/hooks/index.js +11 -3
- package/dist/libs/core/service/Api.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.ar-loading {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: center;
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset: 0;
|
|
7
|
+
background-color: rgba(var(--black-rgb), 0.5);
|
|
8
|
+
animation: background 250ms linear 0s 1 normal both;
|
|
9
|
+
z-index: 1051;
|
|
10
|
+
}
|
|
11
|
+
.ar-loading::before {
|
|
12
|
+
content: "";
|
|
13
|
+
width: 1rem;
|
|
14
|
+
height: 1rem;
|
|
15
|
+
border-radius: var(--border-radius-pill);
|
|
16
|
+
transform: rotate(-135deg);
|
|
17
|
+
animation: spin 1s linear 0s infinite normal both;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@keyframes background {
|
|
21
|
+
0% {
|
|
22
|
+
opacity: 0;
|
|
23
|
+
visibility: hidden;
|
|
24
|
+
}
|
|
25
|
+
100% {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
visibility: visible;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@keyframes spin {
|
|
32
|
+
0% {
|
|
33
|
+
background-color: var(--white);
|
|
34
|
+
}
|
|
35
|
+
20% {
|
|
36
|
+
box-shadow: -1.25rem -1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem -1.25rem 0 0 rgba(var(--white-rgb), 0.75),
|
|
37
|
+
-1.25rem 1.25rem 0 0 rgba(var(--white-rgb), 0.75), 1.25rem 1.25rem 0 0 rgba(var(--white-rgb), 0.75);
|
|
38
|
+
}
|
|
39
|
+
40% {
|
|
40
|
+
box-shadow: -1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem -1.25rem 0 0 rgba(var(--white-rgb), 0.75),
|
|
41
|
+
-1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem 1.25rem 0 0 rgba(var(--white-rgb), 0.75);
|
|
42
|
+
}
|
|
43
|
+
60% {
|
|
44
|
+
box-shadow: -1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem -1.25rem 0 0 rgba(var(--white-rgb), 0.75),
|
|
45
|
+
1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75);
|
|
46
|
+
}
|
|
47
|
+
80% {
|
|
48
|
+
box-shadow: -1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem -1.25rem 0 0 rgba(var(--warning-rgb), 0.75),
|
|
49
|
+
1.25rem 1.25rem 0 0 rgba(var(--warning-rgb), 0.75), 1.25rem -1.25rem 0 0 rgba(var(--warning-rgb), 0.75);
|
|
50
|
+
}
|
|
51
|
+
100% {
|
|
52
|
+
background-color: var(--warning);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.ar-progress {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 0.75rem;
|
|
6
|
+
}
|
|
7
|
+
.ar-progress > .ar-progress-bar {
|
|
8
|
+
position: absolute;
|
|
9
|
+
inset: 0;
|
|
10
|
+
opacity: 0.1;
|
|
11
|
+
}
|
|
12
|
+
.ar-progress > .ar-progress-value {
|
|
13
|
+
position: absolute;
|
|
14
|
+
inset: 0;
|
|
15
|
+
}
|
|
16
|
+
.ar-progress > .ar-progress-value::before {
|
|
17
|
+
content: "";
|
|
18
|
+
position: absolute;
|
|
19
|
+
inset: 0;
|
|
20
|
+
border-radius: var(--border-radius-pill);
|
|
21
|
+
/* Sırasıyla; Ad, Süre, Hız, Gecikme Süresi, Tekrar Sayısı, Yön, Bitiş Süreci */
|
|
22
|
+
animation: progress cubic-bezier(0.23, 1, 0.32, 1) 2.5s 0s infinite normal both;
|
|
23
|
+
}
|
|
24
|
+
.ar-progress > .ar-progress-value > span {
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: -20px;
|
|
27
|
+
right: 0;
|
|
28
|
+
background-color: var(--black);
|
|
29
|
+
width: auto;
|
|
30
|
+
height: 1rem;
|
|
31
|
+
padding: 0 0.25rem;
|
|
32
|
+
border-radius: var(--border-radius-pill);
|
|
33
|
+
color: var(--white);
|
|
34
|
+
font-size: 0.75rem;
|
|
35
|
+
line-height: 1rem;
|
|
36
|
+
-webkit-text-stroke: 0.75px var(--white);
|
|
37
|
+
z-index: 1;
|
|
38
|
+
}
|
|
39
|
+
.ar-progress > .ar-progress-value > span::before {
|
|
40
|
+
content: "";
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 100%;
|
|
43
|
+
left: 50%;
|
|
44
|
+
transform: translateX(-50%);
|
|
45
|
+
border: solid 2.5px transparent;
|
|
46
|
+
border-top-color: var(--black);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@import url("./animations.css");
|
|
@@ -2,32 +2,103 @@
|
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
min-height: 3.75rem;
|
|
5
|
+
padding: 0 1rem;
|
|
5
6
|
border-bottom: solid 1px var(--gray-200);
|
|
6
7
|
}
|
|
7
8
|
.ar-date-calendar > .header > .select-field {
|
|
9
|
+
position: relative;
|
|
8
10
|
display: flex;
|
|
9
11
|
flex-direction: row;
|
|
10
|
-
justify-content:
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
align-items: center;
|
|
11
14
|
gap: 0 0.75rem;
|
|
15
|
+
width: 100%;
|
|
12
16
|
padding: 0 0.5rem;
|
|
13
17
|
}
|
|
18
|
+
|
|
14
19
|
.ar-date-calendar > .header > .select-field > .selects {
|
|
15
20
|
display: flex;
|
|
16
21
|
flex-direction: row;
|
|
17
22
|
justify-content: stretch;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 0 1rem;
|
|
18
25
|
height: var(--input-height);
|
|
19
26
|
}
|
|
27
|
+
.ar-date-calendar > .header > .select-field > .selects > div > span {
|
|
28
|
+
color: var(--black);
|
|
29
|
+
user-select: none;
|
|
30
|
+
}
|
|
20
31
|
|
|
21
32
|
/* #region Prev and Next Buttons */
|
|
22
33
|
.ar-date-calendar > .header > .select-field > .prev,
|
|
23
34
|
.ar-date-calendar > .header > .select-field > .next {
|
|
24
|
-
display: flex;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
align-items: center;
|
|
27
|
-
gap: 0 0.5rem;
|
|
28
|
-
color: var(--gray-600);
|
|
29
|
-
cursor: pointer;
|
|
30
35
|
user-select: none;
|
|
31
36
|
}
|
|
37
|
+
.ar-date-calendar > .header > .select-field > .prev > span,
|
|
38
|
+
.ar-date-calendar > .header > .select-field > .next > span {
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 50%;
|
|
41
|
+
transform: translateY(-50%);
|
|
42
|
+
left: 0;
|
|
43
|
+
width: 1rem;
|
|
44
|
+
height: 1rem;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
.ar-date-calendar > .header > .select-field > .next > span {
|
|
48
|
+
left: auto;
|
|
49
|
+
right: 0;
|
|
50
|
+
}
|
|
51
|
+
.ar-date-calendar > .header > .select-field > .prev > span:last-child {
|
|
52
|
+
left: 1.5rem;
|
|
53
|
+
}
|
|
54
|
+
.ar-date-calendar > .header > .select-field > .next > span:first-child {
|
|
55
|
+
right: 1.5rem;
|
|
56
|
+
}
|
|
57
|
+
.ar-date-calendar > .header > .select-field > .prev > span:first-child::before,
|
|
58
|
+
.ar-date-calendar > .header > .select-field > .prev > span:first-child::after {
|
|
59
|
+
position: absolute;
|
|
60
|
+
content: "";
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: 100%;
|
|
63
|
+
border-top: solid 2px var(--gray-600);
|
|
64
|
+
border-left: solid 2px var(--gray-600);
|
|
65
|
+
transform: rotate(-45deg);
|
|
66
|
+
}
|
|
67
|
+
.ar-date-calendar > .header > .select-field > .next > span:last-child::before,
|
|
68
|
+
.ar-date-calendar > .header > .select-field > .next > span:last-child::after {
|
|
69
|
+
position: absolute;
|
|
70
|
+
content: "";
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
border-top: solid 2px var(--gray-600);
|
|
74
|
+
border-left: solid 2px var(--gray-600);
|
|
75
|
+
transform: rotate(135deg);
|
|
76
|
+
}
|
|
77
|
+
.ar-date-calendar > .header > .select-field > .prev > span:first-child::after {
|
|
78
|
+
left: 0.35rem;
|
|
79
|
+
opacity: 0.25;
|
|
80
|
+
}
|
|
81
|
+
.ar-date-calendar > .header > .select-field > .next > span:last-child::after {
|
|
82
|
+
left: 0.35rem;
|
|
83
|
+
opacity: 0.25;
|
|
84
|
+
}
|
|
85
|
+
.ar-date-calendar > .header > .select-field > .prev > span:last-child::before {
|
|
86
|
+
position: absolute;
|
|
87
|
+
content: "";
|
|
88
|
+
width: 100%;
|
|
89
|
+
height: 100%;
|
|
90
|
+
border-top: solid 2px var(--gray-600);
|
|
91
|
+
border-left: solid 2px var(--gray-600);
|
|
92
|
+
transform: rotate(-45deg);
|
|
93
|
+
}
|
|
94
|
+
.ar-date-calendar > .header > .select-field > .next > span:first-child::before {
|
|
95
|
+
position: absolute;
|
|
96
|
+
content: "";
|
|
97
|
+
width: 100%;
|
|
98
|
+
height: 100%;
|
|
99
|
+
border-top: solid 2px var(--gray-600);
|
|
100
|
+
border-left: solid 2px var(--gray-600);
|
|
101
|
+
transform: rotate(135deg);
|
|
102
|
+
}
|
|
32
103
|
/* #endregion Prev and Next Buttons */
|
|
33
104
|
/* Prev and Next Buttons */
|
|
@@ -71,7 +71,7 @@ const DnD = function ({ data, renderItem, onChange }) {
|
|
|
71
71
|
});
|
|
72
72
|
_arDnD.current.ondragover = (event) => event.preventDefault();
|
|
73
73
|
}, [data]);
|
|
74
|
-
return (React.createElement("div", { ref: _arDnD, className: "ar-dnd" }, data.map((item, index) => (React.createElement("div", { draggable: true },
|
|
74
|
+
return (React.createElement("div", { ref: _arDnD, className: "ar-dnd" }, data.map((item, index) => (React.createElement("div", { key: index, draggable: true },
|
|
75
75
|
React.createElement("div", { className: "move" },
|
|
76
76
|
React.createElement("span", null),
|
|
77
77
|
React.createElement("span", null),
|
|
@@ -47,11 +47,6 @@ const Confirm = ({ children, title, message, content, onConfirm }) => {
|
|
|
47
47
|
document.addEventListener("click", handleClickOutSide);
|
|
48
48
|
document.addEventListener("keydown", handleKeys);
|
|
49
49
|
}
|
|
50
|
-
else {
|
|
51
|
-
window.removeEventListener("blur", () => setOpen(false));
|
|
52
|
-
document.removeEventListener("click", handleClickOutSide);
|
|
53
|
-
document.removeEventListener("keydown", handleKeys);
|
|
54
|
-
}
|
|
55
50
|
return () => {
|
|
56
51
|
window.removeEventListener("blur", () => setOpen(false));
|
|
57
52
|
document.removeEventListener("click", handleClickOutSide);
|
|
@@ -29,11 +29,6 @@ const Modal = ({ children, open, title, size = "normal", footer }) => {
|
|
|
29
29
|
// document.addEventListener("click", handleClickOutSide);
|
|
30
30
|
document.addEventListener("keydown", handleKeys);
|
|
31
31
|
}
|
|
32
|
-
else {
|
|
33
|
-
document.body.style.removeProperty("overflow");
|
|
34
|
-
// document.removeEventListener("click", handleClickOutSide);
|
|
35
|
-
document.removeEventListener("keydown", handleKeys);
|
|
36
|
-
}
|
|
37
32
|
return () => {
|
|
38
33
|
document.body.style.removeProperty("overflow");
|
|
39
34
|
// document.removeEventListener("click", handleClickOutSide);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
3
|
+
import "../../../assets/css/components/feedback/progress/progress.css";
|
|
4
|
+
const Progress = ({ value, reverse }) => {
|
|
5
|
+
// variable/s
|
|
6
|
+
let _status = undefined;
|
|
7
|
+
const _arProgressClassName = [];
|
|
8
|
+
if (value >= 0 && value <= 25)
|
|
9
|
+
_status = !reverse ? "danger" : "success";
|
|
10
|
+
else if (value >= 26 && value <= 50)
|
|
11
|
+
_status = !reverse ? "warning" : "primary";
|
|
12
|
+
else if (value >= 51 && value <= 75)
|
|
13
|
+
_status = !reverse ? "primary" : "warning";
|
|
14
|
+
else if (value >= 76 && value <= 100)
|
|
15
|
+
_status = !reverse ? "success" : "danger";
|
|
16
|
+
_arProgressClassName.push(...Utils.GetClassName("filled", _status, { radius: "pill" }, undefined, undefined, undefined));
|
|
17
|
+
return (React.createElement("div", { className: "ar-progress" },
|
|
18
|
+
React.createElement("div", { className: `ar-progress-bar ${_arProgressClassName.map((c) => c).join(" ")}` }),
|
|
19
|
+
React.createElement("div", { className: `ar-progress-value ${_arProgressClassName.map((c) => c).join(" ")}`, style: {
|
|
20
|
+
width: `${value}%`,
|
|
21
|
+
} },
|
|
22
|
+
React.createElement("span", null,
|
|
23
|
+
"%",
|
|
24
|
+
value))));
|
|
25
|
+
};
|
|
26
|
+
export default Progress;
|
|
@@ -29,14 +29,7 @@ const ButtonAction = ({ buttons }) => {
|
|
|
29
29
|
document.addEventListener("keydown", handleKeys);
|
|
30
30
|
window.addEventListener("resize", handleResizeEvent);
|
|
31
31
|
}
|
|
32
|
-
else {
|
|
33
|
-
// Dinleyicileri kaldır.
|
|
34
|
-
document.removeEventListener("click", handleClickOutSide);
|
|
35
|
-
document.removeEventListener("keydown", handleKeys);
|
|
36
|
-
window.removeEventListener("resize", handleResizeEvent);
|
|
37
|
-
}
|
|
38
32
|
return () => {
|
|
39
|
-
// Dinleyicileri kaldır.
|
|
40
33
|
document.removeEventListener("click", handleClickOutSide);
|
|
41
34
|
document.removeEventListener("keydown", handleKeys);
|
|
42
35
|
window.removeEventListener("resize", handleResizeEvent);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare class DATE {
|
|
2
|
+
Parse: (value: string, isCloack?: boolean) => {
|
|
3
|
+
year: number;
|
|
4
|
+
month: number;
|
|
5
|
+
day: number;
|
|
6
|
+
hours: number;
|
|
7
|
+
minutes: number;
|
|
8
|
+
};
|
|
9
|
+
ParseValue: (value: string, isCloack?: boolean) => string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: DATE;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class DATE {
|
|
2
|
+
Parse = (value, isCloack = false) => {
|
|
3
|
+
// Seçilmiş Tarih ve Zaman
|
|
4
|
+
const [sd, st] = value.split("T");
|
|
5
|
+
const [y, m, d] = sd.split("-").map(Number);
|
|
6
|
+
// Zaman Bilgileri
|
|
7
|
+
const [c, _] = isCloack ? st.split(".") : "00:00";
|
|
8
|
+
const [hh, mm] = isCloack ? c.split(":").map(Number) : [0, 0];
|
|
9
|
+
return {
|
|
10
|
+
year: y,
|
|
11
|
+
month: m,
|
|
12
|
+
day: d,
|
|
13
|
+
hours: hh,
|
|
14
|
+
minutes: mm,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
ParseValue = (value, isCloack = false) => {
|
|
18
|
+
const [date, time] = value.split("T");
|
|
19
|
+
const [clock, _] = isCloack && time ? time.split(".") : "00:00";
|
|
20
|
+
return !isCloack ? date : `${date}T${clock}`;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export default new DATE();
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import "../../../assets/css/components/form/date-picker/date-picker.css";
|
|
4
4
|
import Input from "../input";
|
|
5
|
-
import Select from "../select";
|
|
6
5
|
import Button from "../button";
|
|
7
6
|
import Alert from "../../feedback/alert";
|
|
8
7
|
import ReactDOM from "react-dom";
|
|
8
|
+
import DATE from "./DATE";
|
|
9
9
|
const weekdays = ["Pzt", "Sal", "Çar", "Per", "Cum", "Cmt", "Paz"];
|
|
10
10
|
const months = [
|
|
11
11
|
{ value: 0, text: "Ocak" },
|
|
@@ -26,8 +26,7 @@ const DatePicker = ({ onChange, isClock, ...attributes }) => {
|
|
|
26
26
|
const _arCalendar = useRef(null);
|
|
27
27
|
const _currentDate = useRef(new Date()).current;
|
|
28
28
|
const _beginDate = useRef(null);
|
|
29
|
-
|
|
30
|
-
// refs
|
|
29
|
+
// refs -> Geçerli Tarih ve Saat Bilgileri.
|
|
31
30
|
const _year = useRef(_currentDate.getFullYear());
|
|
32
31
|
const _month = useRef(_currentDate.getMonth());
|
|
33
32
|
const _day = useRef(_currentDate.getDate());
|
|
@@ -39,205 +38,141 @@ const DatePicker = ({ onChange, isClock, ...attributes }) => {
|
|
|
39
38
|
const _minutesListElement = useRef(null);
|
|
40
39
|
const _minutesLiElements = useRef([]);
|
|
41
40
|
// states
|
|
42
|
-
const [
|
|
43
|
-
const [
|
|
41
|
+
const [calendarIsOpen, setCalendarIsOpen] = useState(false);
|
|
42
|
+
const [calendarDays, setCalendarDays] = useState([]);
|
|
44
43
|
const [years, setYears] = useState([]);
|
|
45
44
|
const [hours, setHours] = useState();
|
|
46
45
|
const [minutes, setMinutes] = useState();
|
|
47
|
-
const [
|
|
48
|
-
const [
|
|
49
|
-
// states =>
|
|
50
|
-
const [
|
|
51
|
-
const [
|
|
52
|
-
const [
|
|
53
|
-
const [
|
|
54
|
-
const [
|
|
46
|
+
const [dateChanged, setDateChanged] = useState(false);
|
|
47
|
+
const [timeChanged, setTimeChanged] = useState(false);
|
|
48
|
+
// states => Seçilmiş Tarihler
|
|
49
|
+
const [selectedYear, setSelectedYear] = useState(_currentDate.getFullYear());
|
|
50
|
+
const [selectedMonth, setSelectedMonth] = useState(_currentDate.getMonth());
|
|
51
|
+
const [selectedDay, setSelectedDay] = useState(_currentDate.getDate());
|
|
52
|
+
const [selectedHours, setSelectedHours] = useState(_currentDate.getHours());
|
|
53
|
+
const [selectedMinutes, setSelectedMinutes] = useState(_currentDate.getMinutes());
|
|
55
54
|
// methods
|
|
56
55
|
const handleClickOutSide = (event) => {
|
|
57
56
|
const target = event.target;
|
|
58
57
|
if (_arCalendar.current && !_arCalendar.current.contains(target))
|
|
59
|
-
|
|
58
|
+
closeCalendar();
|
|
60
59
|
};
|
|
61
60
|
const handleKeys = (event) => {
|
|
62
61
|
const key = event.key;
|
|
63
62
|
if (key === "Escape")
|
|
64
|
-
|
|
63
|
+
closeCalendar();
|
|
65
64
|
};
|
|
66
65
|
const handlePosition = () => {
|
|
67
66
|
if (_arCalendar.current && _beginDate.current) {
|
|
68
67
|
const arCalendarRect = _arCalendar.current.getBoundingClientRect();
|
|
69
68
|
const InpuRect = _beginDate.current?.getBoundingClientRect();
|
|
70
69
|
if (InpuRect) {
|
|
71
|
-
const
|
|
70
|
+
const screenCenterX = window.innerWidth / 2;
|
|
71
|
+
const screenCenterY = window.innerHeight / 2;
|
|
72
72
|
const sx = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
73
73
|
const sy = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
|
74
|
-
_arCalendar.current.style.top = `${(InpuRect.top >
|
|
75
|
-
_arCalendar.current.style.left = `${InpuRect.left + sx}px`;
|
|
74
|
+
_arCalendar.current.style.top = `${(InpuRect.top > screenCenterY ? InpuRect.top - arCalendarRect.height : InpuRect.top + InpuRect.height) + sy}px`;
|
|
75
|
+
_arCalendar.current.style.left = `${(InpuRect.left > screenCenterX ? InpuRect.right - arCalendarRect.width : InpuRect.left) + sx}px`;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const [year, month, day] = date.split("-").map(Number);
|
|
82
|
-
const hours = time ? time.split(".")[0].split(":").map(Number)[0] : 0;
|
|
83
|
-
const minutes = time ? time.split(".")[0].split(":").map(Number)[1] : 0;
|
|
84
|
-
return {
|
|
85
|
-
date: date,
|
|
86
|
-
time: time,
|
|
87
|
-
year: year,
|
|
88
|
-
month: month,
|
|
89
|
-
day: day,
|
|
90
|
-
hours: hours,
|
|
91
|
-
minutes: minutes,
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
const setNow = () => {
|
|
79
|
+
// Şimdi Butonu
|
|
80
|
+
const setNowButton = () => {
|
|
95
81
|
const now = new Date();
|
|
96
82
|
// Stateler güncelleniyor...
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
setSelectedYear(now.getFullYear());
|
|
84
|
+
setSelectedMonth(now.getMonth());
|
|
85
|
+
setSelectedDay(now.getDate());
|
|
86
|
+
setSelectedHours(now.getHours());
|
|
87
|
+
setSelectedMinutes(now.getMinutes());
|
|
102
88
|
_year.current = now.getFullYear();
|
|
103
89
|
_month.current = now.getMonth();
|
|
104
90
|
_day.current = now.getDate();
|
|
105
91
|
_hours.current = now.getHours();
|
|
106
92
|
_minutes.current = now.getMinutes();
|
|
107
|
-
// Input güncelleniyor...
|
|
108
|
-
updateDateInput(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes());
|
|
109
93
|
// Takvim kapatılıyor...
|
|
110
|
-
|
|
94
|
+
setCalendarIsOpen(false);
|
|
111
95
|
// Değer gönderiliyor...
|
|
112
96
|
const inputDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), !isClock ? 0 : now.getHours(), !isClock ? 0 : now.getMinutes(), 0));
|
|
113
97
|
onChange(inputDate.toISOString());
|
|
114
98
|
};
|
|
115
|
-
|
|
116
|
-
if (_beginDate.current) {
|
|
117
|
-
const inputDate = new Date(Date.UTC(year, month, day, hours, minutes, 0));
|
|
118
|
-
if (isNaN(inputDate.getTime()))
|
|
119
|
-
return;
|
|
120
|
-
const [date, time] = inputDate.toISOString().split("T");
|
|
121
|
-
const [clock, _] = time.split(".");
|
|
122
|
-
_beginDate.current.value = !_clockOpen.current ? date : `${date}T${clock}`;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
99
|
+
// Tamam Butonu
|
|
125
100
|
const okayButton = () => {
|
|
126
101
|
return (React.createElement(Button, { variant: "borderless", status: "success", onClick: () => {
|
|
127
|
-
// Input güncelleniyor...
|
|
128
|
-
updateDateInput(_year.current, _month.current, _day.current, _hours.current, _minutes.current);
|
|
129
102
|
// Stateler güncelleniyor...
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
103
|
+
setSelectedYear(_year.current);
|
|
104
|
+
setSelectedMonth(_month.current);
|
|
105
|
+
setSelectedDay(_day.current);
|
|
106
|
+
setSelectedHours(_hours.current);
|
|
107
|
+
setSelectedMinutes(_minutes.current);
|
|
135
108
|
const inputDate = new Date(Date.UTC(_year.current, _month.current, _day.current, !isClock ? 0 : _hours.current, !isClock ? 0 : _minutes.current, 0));
|
|
136
109
|
onChange(inputDate.toISOString());
|
|
137
|
-
|
|
110
|
+
setCalendarIsOpen(false);
|
|
138
111
|
} }, "Tamam"));
|
|
139
112
|
};
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
_year.current = attributes.value ?
|
|
143
|
-
_month.current = attributes.value ?
|
|
144
|
-
_day.current = attributes.value ?
|
|
145
|
-
_hours.current = attributes.value ?
|
|
146
|
-
_minutes.current = attributes.value ?
|
|
147
|
-
|
|
113
|
+
const closeCalendar = () => {
|
|
114
|
+
const { year, month, day, hours, minutes } = DATE.Parse(String(attributes.value), isClock);
|
|
115
|
+
_year.current = attributes.value ? year : selectedYear;
|
|
116
|
+
_month.current = attributes.value ? month - 1 : selectedMonth;
|
|
117
|
+
_day.current = attributes.value ? day : selectedDay;
|
|
118
|
+
_hours.current = attributes.value ? hours : selectedHours;
|
|
119
|
+
_minutes.current = attributes.value ? minutes : selectedMinutes;
|
|
120
|
+
setCalendarIsOpen(false);
|
|
148
121
|
};
|
|
149
122
|
// useEffects
|
|
150
123
|
useEffect(() => {
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// Önümüzdeki 20 yıl
|
|
159
|
-
for (let i = _year.current + 1; i <= _year.current + 20; i++) {
|
|
160
|
-
years.push({ value: i, text: `${i}` });
|
|
161
|
-
}
|
|
162
|
-
setYears(years);
|
|
163
|
-
}, []);
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
if (attributes.value && _beginDate.current) {
|
|
166
|
-
const dateParse = handleParse(String(attributes.value));
|
|
167
|
-
_year.current = dateParse.year;
|
|
168
|
-
_month.current = dateParse.month - 1;
|
|
169
|
-
_day.current = dateParse.day;
|
|
170
|
-
if (hours || minutes) {
|
|
171
|
-
_hours.current = dateParse.hours;
|
|
172
|
-
_minutes.current = dateParse.minutes;
|
|
173
|
-
}
|
|
174
|
-
updateDateInput(dateParse.year, dateParse.month - 1, dateParse.day, dateParse.hours, dateParse.minutes);
|
|
175
|
-
}
|
|
176
|
-
}, [attributes.value]);
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
if (calendarOpen) {
|
|
179
|
-
const calendar = [];
|
|
180
|
-
const beginDateValue = _beginDate.current?.value || "";
|
|
181
|
-
const date = {
|
|
182
|
-
input: {
|
|
183
|
-
begin: new Date(beginDateValue),
|
|
184
|
-
},
|
|
185
|
-
current: {
|
|
186
|
-
firstDay: new Date(_year.current, _month.current, 1), // Geçerli ayın ilk günü
|
|
187
|
-
lastDay: new Date(_year.current, _month.current + 1, 0), // Geçerli ayın son günü
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
const startingDay = date.current.firstDay.getDay() === 0 ? 7 : date.current.firstDay.getDay();
|
|
191
|
-
const endDay = date.current.lastDay.getDay() === 0 ? 7 : date.current.lastDay.getDay();
|
|
124
|
+
if (calendarIsOpen) {
|
|
125
|
+
handlePosition();
|
|
126
|
+
const days = [];
|
|
127
|
+
const firstDayOfMonth = new Date(_year.current, _month.current, 1);
|
|
128
|
+
const lastDayOfMonth = new Date(_year.current, _month.current + 1, 0);
|
|
129
|
+
const startingDay = firstDayOfMonth.getDay() === 0 ? 7 : firstDayOfMonth.getDay();
|
|
130
|
+
const endingDay = lastDayOfMonth.getDay() === 0 ? 7 : lastDayOfMonth.getDay();
|
|
192
131
|
for (let i = 1; i < startingDay; i++) {
|
|
193
|
-
|
|
132
|
+
days.push(React.createElement("span", { key: `prev-${i}`, className: "empty-day" }));
|
|
194
133
|
}
|
|
195
|
-
for (let i =
|
|
196
|
-
const isSelected = !isNaN(
|
|
197
|
-
?
|
|
198
|
-
|
|
199
|
-
i
|
|
200
|
-
: _currentDate.getFullYear()
|
|
201
|
-
_currentDate.getMonth()
|
|
202
|
-
i
|
|
203
|
-
|
|
134
|
+
for (let i = firstDayOfMonth.getDate(); i <= lastDayOfMonth.getDate(); i++) {
|
|
135
|
+
const isSelected = !isNaN(firstDayOfMonth.getTime())
|
|
136
|
+
? firstDayOfMonth.getFullYear() === _year.current &&
|
|
137
|
+
firstDayOfMonth.getMonth() === _month.current &&
|
|
138
|
+
i === _day.current
|
|
139
|
+
: _currentDate.getFullYear() === _year.current &&
|
|
140
|
+
_currentDate.getMonth() === _month.current &&
|
|
141
|
+
i === _day.current;
|
|
142
|
+
days.push(React.createElement("span", { key: `current-${i}`, className: isSelected ? "selection-day" : "", onClick: (event) => {
|
|
143
|
+
event.preventDefault();
|
|
204
144
|
_day.current = i;
|
|
205
|
-
|
|
145
|
+
setSelectedDay(i);
|
|
146
|
+
setDateChanged(!dateChanged);
|
|
206
147
|
} },
|
|
207
148
|
React.createElement("span", null, i)));
|
|
208
149
|
}
|
|
209
|
-
for (let i =
|
|
210
|
-
|
|
150
|
+
for (let i = endingDay; i < 7; i++) {
|
|
151
|
+
days.push(React.createElement("span", { key: `next-${i}`, className: "empty-day" }));
|
|
211
152
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
// Konumu Ayarlanıyor.
|
|
215
|
-
setTimeout(handlePosition, 0);
|
|
216
|
-
window.addEventListener("blur", () => setCalendarOpen(false));
|
|
153
|
+
setCalendarDays(days);
|
|
154
|
+
window.addEventListener("blur", () => closeCalendar());
|
|
217
155
|
document.addEventListener("click", handleClickOutSide);
|
|
218
156
|
document.addEventListener("keydown", handleKeys);
|
|
219
157
|
}
|
|
220
|
-
else {
|
|
221
|
-
window.removeEventListener("blur", () => setCalendarOpen(false));
|
|
222
|
-
document.removeEventListener("click", handleClickOutSide);
|
|
223
|
-
document.removeEventListener("keydown", handleKeys);
|
|
224
|
-
}
|
|
225
158
|
return () => {
|
|
226
|
-
window.removeEventListener("blur", () =>
|
|
159
|
+
window.removeEventListener("blur", () => closeCalendar());
|
|
227
160
|
document.removeEventListener("click", handleClickOutSide);
|
|
228
161
|
document.removeEventListener("keydown", handleKeys);
|
|
229
162
|
};
|
|
230
|
-
}, [
|
|
163
|
+
}, [dateChanged, calendarIsOpen]);
|
|
231
164
|
useEffect(() => {
|
|
232
165
|
const generateList = (count, current, setFunc) => {
|
|
233
166
|
const items = Array.from({ length: count }, (_, i) => (React.createElement("li", { ref: (element) => count === 24 ? (_hoursLiElements.current[i] = element) : (_minutesLiElements.current[i] = element), key: i, ...(current === i ? { className: "selection-time" } : {}), onClick: () => {
|
|
234
167
|
if (count === 24) {
|
|
235
|
-
|
|
168
|
+
setTimeChanged((prev) => !prev);
|
|
236
169
|
_hours.current = i;
|
|
170
|
+
setSelectedHours(i);
|
|
237
171
|
}
|
|
238
172
|
else {
|
|
239
|
-
|
|
173
|
+
setTimeChanged((prev) => !prev);
|
|
240
174
|
_minutes.current = i;
|
|
175
|
+
setSelectedMinutes(i);
|
|
241
176
|
}
|
|
242
177
|
} },
|
|
243
178
|
React.createElement("span", null,
|
|
@@ -264,10 +199,24 @@ const DatePicker = ({ onChange, isClock, ...attributes }) => {
|
|
|
264
199
|
behavior: "smooth",
|
|
265
200
|
});
|
|
266
201
|
}
|
|
267
|
-
}, [
|
|
202
|
+
}, [timeChanged, calendarIsOpen, isClock]);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (isNaN(_year.current))
|
|
205
|
+
return;
|
|
206
|
+
const years = [];
|
|
207
|
+
// Son 20 yıl
|
|
208
|
+
for (let i = _year.current - 20; i <= _year.current; i++) {
|
|
209
|
+
years.push({ value: i, text: `${i}` });
|
|
210
|
+
}
|
|
211
|
+
// Önümüzdeki 20 yıl
|
|
212
|
+
for (let i = _year.current + 1; i <= _year.current + 20; i++) {
|
|
213
|
+
years.push({ value: i, text: `${i}` });
|
|
214
|
+
}
|
|
215
|
+
setYears(years);
|
|
216
|
+
}, []);
|
|
268
217
|
return (React.createElement("div", { className: "ar-date-picker" },
|
|
269
218
|
attributes.placeholder && attributes.placeholder.length > 0 && React.createElement("label", null, attributes.placeholder),
|
|
270
|
-
React.createElement(Input, { ref: _beginDate, type: isClock ? "datetime-local" : "date", onKeyDown: (event) => event.code == "Space" && event.preventDefault(), onChange: (event) => {
|
|
219
|
+
React.createElement(Input, { ref: _beginDate, value: DATE.ParseValue(String(attributes.value), isClock), type: isClock ? "datetime-local" : "date", onKeyDown: (event) => event.code == "Space" && event.preventDefault(), onChange: (event) => {
|
|
271
220
|
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
272
221
|
if (attributes.disabled)
|
|
273
222
|
return;
|
|
@@ -284,42 +233,38 @@ const DatePicker = ({ onChange, isClock, ...attributes }) => {
|
|
|
284
233
|
_hours.current = hours;
|
|
285
234
|
_minutes.current = minutes;
|
|
286
235
|
}
|
|
287
|
-
|
|
288
|
-
|
|
236
|
+
setDateChanged((prev) => !prev);
|
|
237
|
+
setTimeChanged((prev) => !prev);
|
|
289
238
|
})();
|
|
290
239
|
}, onClick: (event) => {
|
|
291
240
|
event.preventDefault();
|
|
292
|
-
|
|
241
|
+
setCalendarIsOpen(true);
|
|
293
242
|
}, autoComplete: "off" }),
|
|
294
|
-
|
|
243
|
+
calendarIsOpen &&
|
|
295
244
|
ReactDOM.createPortal(React.createElement("div", { ref: _arCalendar, className: "ar-date-calendar" },
|
|
296
245
|
React.createElement("div", { className: "header" },
|
|
297
246
|
React.createElement("div", { className: "select-field" },
|
|
298
247
|
React.createElement("div", { className: "prev" },
|
|
299
248
|
React.createElement("span", { onClick: () => {
|
|
300
249
|
_year.current -= 1;
|
|
301
|
-
|
|
302
|
-
|
|
250
|
+
setSelectedYear(_year.current);
|
|
251
|
+
setDateChanged((prev) => !prev);
|
|
252
|
+
} }),
|
|
303
253
|
React.createElement("span", { onClick: () => {
|
|
304
254
|
if (_month.current <= 0) {
|
|
305
255
|
_year.current -= 1;
|
|
306
256
|
_month.current = 12;
|
|
307
257
|
}
|
|
308
258
|
_month.current -= 1;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
259
|
+
setSelectedYear(_year.current);
|
|
260
|
+
setSelectedMonth(_month.current);
|
|
261
|
+
setDateChanged((prev) => !prev);
|
|
262
|
+
} })),
|
|
312
263
|
React.createElement("div", { className: "selects" },
|
|
313
|
-
React.createElement(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}, placeholder: "Ay" }),
|
|
318
|
-
React.createElement(Select, { variant: "borderless", value: years.find((years) => years.value === _year.current), options: years, onChange: (option) => {
|
|
319
|
-
_year.current = option?.value;
|
|
320
|
-
updateDateInput(_year.current, _month.current, _day.current);
|
|
321
|
-
setDateTrigger((prev) => !prev);
|
|
322
|
-
}, placeholder: "Y\u0131l" })),
|
|
264
|
+
React.createElement("div", null,
|
|
265
|
+
React.createElement("span", null, months.find((month) => month.value === selectedMonth)?.text)),
|
|
266
|
+
React.createElement("div", null,
|
|
267
|
+
React.createElement("span", null, years.find((year) => year.value === selectedYear)?.text))),
|
|
323
268
|
React.createElement("div", { className: "next" },
|
|
324
269
|
React.createElement("span", { onClick: () => {
|
|
325
270
|
if (_month.current >= 11) {
|
|
@@ -327,20 +272,21 @@ const DatePicker = ({ onChange, isClock, ...attributes }) => {
|
|
|
327
272
|
_month.current = -1;
|
|
328
273
|
}
|
|
329
274
|
_month.current += 1;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
275
|
+
setSelectedYear(_year.current);
|
|
276
|
+
setSelectedMonth(_month.current);
|
|
277
|
+
setDateChanged((prev) => !prev);
|
|
278
|
+
} }),
|
|
333
279
|
React.createElement("span", { onClick: () => {
|
|
334
280
|
_year.current += 1;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
} }
|
|
281
|
+
setSelectedYear(_year.current);
|
|
282
|
+
setDateChanged((prev) => !prev);
|
|
283
|
+
} })))),
|
|
338
284
|
React.createElement("div", { className: "content" }, !isNaN(_month.current) && !isNaN(_year.current) ? (React.createElement("div", { className: "calendar" },
|
|
339
285
|
React.createElement("div", { className: "weekdays" }, weekdays.map((weekday, index) => (React.createElement("span", { key: index }, weekday)))),
|
|
340
|
-
React.createElement("div", { className: "days" },
|
|
286
|
+
React.createElement("div", { className: "days" }, calendarDays))) : (React.createElement(Alert, { status: "warning" }, "Ay veya y\u0131l se\u00E7imi yapman\u0131z gerekmektedir."))),
|
|
341
287
|
React.createElement("div", { className: "footer" },
|
|
342
288
|
React.createElement("div", null,
|
|
343
|
-
React.createElement(Button, { variant: "borderless", onClick: () =>
|
|
289
|
+
React.createElement(Button, { variant: "borderless", onClick: () => setNowButton() }, "\u015Eimdi")),
|
|
344
290
|
React.createElement("div", null, !isClock && okayButton())),
|
|
345
291
|
React.createElement("div", { className: `clock ${isClock ? "active" : "passive"}` },
|
|
346
292
|
React.createElement("div", { className: "header" },
|
|
@@ -5,8 +5,8 @@ import Button from "../button";
|
|
|
5
5
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
6
6
|
const Input = forwardRef(({ variant = "outlined", status = "light", size = "normal", icon, border = { radius: "sm" }, button, addon, validation, ...attributes }, ref) => {
|
|
7
7
|
// states
|
|
8
|
-
const [value, setValue] = useState(
|
|
9
|
-
//
|
|
8
|
+
const [value, setValue] = useState("");
|
|
9
|
+
// variable/s
|
|
10
10
|
const _wrapperClassName = ["ar-input-wrapper"];
|
|
11
11
|
const _addonBeforeClassName = ["addon-before"];
|
|
12
12
|
const _addonAfterClassName = ["addon-after"];
|
|
@@ -23,13 +23,16 @@ const Input = forwardRef(({ variant = "outlined", status = "light", size = "norm
|
|
|
23
23
|
_addonAfterClassName.push(`border-radius-${border.radius}`);
|
|
24
24
|
}
|
|
25
25
|
// useEffects
|
|
26
|
-
useEffect(() =>
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (attributes.value !== undefined)
|
|
28
|
+
setValue(value);
|
|
29
|
+
}, [attributes.value]);
|
|
27
30
|
return (React.createElement("div", { className: _wrapperClassName.map((c) => c).join(" ") },
|
|
28
31
|
addon?.before && React.createElement("span", { className: _addonBeforeClassName.map((c) => c).join(" ") }, addon?.before),
|
|
29
32
|
React.createElement("div", { className: "ar-input" },
|
|
30
33
|
icon?.element && React.createElement("span", { className: "icon-element" }, icon.element),
|
|
31
34
|
attributes.placeholder && React.createElement("label", { className: value ? "visible" : "hidden" }, attributes.placeholder),
|
|
32
|
-
React.createElement("input", { ref: ref, ...attributes, size: 20, className: _inputClassName.map((c) => c).join(" "), onChange: (event) => {
|
|
35
|
+
React.createElement("input", { ref: ref, ...attributes, value: attributes.value !== undefined ? attributes.value : value, size: 20, className: _inputClassName.map((c) => c).join(" "), onChange: (event) => {
|
|
33
36
|
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
34
37
|
if (attributes.disabled)
|
|
35
38
|
return;
|
|
@@ -28,9 +28,8 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
28
28
|
// methods
|
|
29
29
|
const handleClickOutSide = (event) => {
|
|
30
30
|
const target = event.target;
|
|
31
|
-
if (_arSelect.current && !_arSelect.current.contains(target))
|
|
31
|
+
if (_arSelect.current && !_arSelect.current.contains(target))
|
|
32
32
|
setOptionsOpen(false);
|
|
33
|
-
}
|
|
34
33
|
};
|
|
35
34
|
const handleKeys = (event) => {
|
|
36
35
|
const key = event.key;
|
|
@@ -62,10 +61,8 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
62
61
|
return;
|
|
63
62
|
optionItems[_navigationIndex.current]?.click();
|
|
64
63
|
}
|
|
65
|
-
else if (key === "Escape")
|
|
64
|
+
else if (key === "Escape")
|
|
66
65
|
setOptionsOpen(false);
|
|
67
|
-
setSingleInputText("");
|
|
68
|
-
}
|
|
69
66
|
};
|
|
70
67
|
const handlePosition = () => {
|
|
71
68
|
if (_options.current) {
|
|
@@ -99,12 +96,12 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
99
96
|
const handleCleanSelection = () => {
|
|
100
97
|
if (multiple) {
|
|
101
98
|
if (_searchField.current)
|
|
102
|
-
|
|
99
|
+
setSearchText("");
|
|
103
100
|
onChange([]);
|
|
104
101
|
}
|
|
105
102
|
else {
|
|
106
103
|
if (_singleInput.current) {
|
|
107
|
-
|
|
104
|
+
setSingleInputText("");
|
|
108
105
|
_singleInput.current.placeholder = placeholder ?? "";
|
|
109
106
|
}
|
|
110
107
|
onChange(undefined);
|
|
@@ -112,19 +109,10 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
112
109
|
};
|
|
113
110
|
// useEffects
|
|
114
111
|
useEffect(() => {
|
|
115
|
-
if (multiple)
|
|
112
|
+
if (multiple)
|
|
116
113
|
setSearchText("");
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
if (!_singleInput.current)
|
|
122
|
-
return;
|
|
123
|
-
if (value)
|
|
124
|
-
_singleInput.current.value = value.text;
|
|
125
|
-
else
|
|
126
|
-
_singleInput.current.value = "";
|
|
127
|
-
}
|
|
114
|
+
else
|
|
115
|
+
setSingleInputText(value?.text ?? "");
|
|
128
116
|
}, [value]);
|
|
129
117
|
useEffect(() => setFilteredOptions(options), [options]);
|
|
130
118
|
useEffect(() => {
|
|
@@ -141,7 +129,7 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
141
129
|
// });
|
|
142
130
|
// }
|
|
143
131
|
if (_singleInput.current) {
|
|
144
|
-
|
|
132
|
+
setSingleInputText("");
|
|
145
133
|
_singleInput.current.placeholder = value?.text || placeholder || "";
|
|
146
134
|
}
|
|
147
135
|
}
|
|
@@ -156,11 +144,6 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
156
144
|
document.addEventListener("keydown", handleKeys);
|
|
157
145
|
}
|
|
158
146
|
else {
|
|
159
|
-
// Dinleyicileri kaldır ve zamanlayıcıyı temizle.
|
|
160
|
-
clearTimeout(_otoFocus);
|
|
161
|
-
window.removeEventListener("blur", () => setOptionsOpen(false));
|
|
162
|
-
document.removeEventListener("click", handleClickOutSide);
|
|
163
|
-
document.removeEventListener("keydown", handleKeys);
|
|
164
147
|
// Options paneli kapanma süresi 250ms.
|
|
165
148
|
// 300ms sonra temizlenmesinin sebebi kapanırken birder veriler gerliyor ve panel yüksekliği artıyor.
|
|
166
149
|
setTimeout(() => setSearchText(""), 300);
|
|
@@ -170,7 +153,7 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
170
153
|
}
|
|
171
154
|
else {
|
|
172
155
|
if (_singleInput.current) {
|
|
173
|
-
|
|
156
|
+
setSingleInputText(value?.text ?? "");
|
|
174
157
|
_singleInput.current.placeholder = placeholder ?? "";
|
|
175
158
|
}
|
|
176
159
|
}
|
|
@@ -216,10 +199,7 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
216
199
|
return (React.createElement("div", { ref: _arSelect, className: "ar-select-wrapper" },
|
|
217
200
|
React.createElement("div", { ref: _multipleInput, className: "ar-select" },
|
|
218
201
|
multiple ? (React.createElement("div", { className: _selectionClassName.map((c) => c).join(" "), onClick: () => setOptionsOpen((x) => !x) },
|
|
219
|
-
React.createElement("div", { className: "items" }, value.length > 0 ? (value.map((_value, index) => (React.createElement(Chip, { key: index, variant: status?.selected?.variant || "filled", status: status?.selected?.color || status?.color, text: _value.text })))) : (React.createElement("span", { className: "placeholder" }, placeholder))))) : (React.createElement(Input, { ref: _singleInput, variant: variant, status: !Utils.IsNullOrEmpty(validation?.text) ? "danger" : status, border: { radius: border.radius }, value:
|
|
220
|
-
setOptionsOpen((prev) => !prev);
|
|
221
|
-
setSingleInputText("");
|
|
222
|
-
}, onChange: (event) => {
|
|
202
|
+
React.createElement("div", { className: "items" }, value.length > 0 ? (value.map((_value, index) => (React.createElement(Chip, { key: index, variant: status?.selected?.variant || "filled", status: status?.selected?.color || status?.color, text: _value.text })))) : (React.createElement("span", { className: "placeholder" }, placeholder))))) : (React.createElement(Input, { ref: _singleInput, variant: variant, status: !Utils.IsNullOrEmpty(validation?.text) ? "danger" : status, border: { radius: border.radius }, value: singleInputText, onClick: () => setOptionsOpen((prev) => !prev), onChange: (event) => {
|
|
223
203
|
!optionsOpen && setOptionsOpen(true);
|
|
224
204
|
setSingleInputText(event.target.value);
|
|
225
205
|
}, onKeyUp: (event) => {
|
|
@@ -241,7 +221,7 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
241
221
|
optionsOpen &&
|
|
242
222
|
ReactDOM.createPortal(React.createElement("div", { ref: _options, className: "ar-select-options" },
|
|
243
223
|
multiple && (React.createElement("div", { className: "search-field" },
|
|
244
|
-
React.createElement(Input, { ref: _searchField, variant: "outlined", status: "light", placeholder: "Search...",
|
|
224
|
+
React.createElement(Input, { ref: _searchField, variant: "outlined", status: "light", placeholder: "Search...", value: searchText, onChange: (event) => setSearchText(event.currentTarget.value) }))),
|
|
245
225
|
filteredOptions.length > 0 ? (React.createElement("ul", null, filteredOptions.map((option, index) => {
|
|
246
226
|
const isItem = multiple && value.some((_value) => _value.value === option.value);
|
|
247
227
|
return (React.createElement("li", { key: index, ref: (element) => (_optionItems.current[index] = element), className: option === value ? "selectedItem" : "", onClick: () => handleItemSelected(option) },
|
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,9 @@ import Typography from "./components/data-display/typography";
|
|
|
20
20
|
import Alert from "./components/feedback/alert";
|
|
21
21
|
import Confirm from "./components/feedback/confirm";
|
|
22
22
|
import Modal from "./components/feedback/modal";
|
|
23
|
+
import Progress from "./components/feedback/progress";
|
|
23
24
|
import Menu from "./components/navigation/menu";
|
|
24
25
|
import Steps from "./components/navigation/steps";
|
|
25
26
|
import Grid from "./components/layout/grid-system";
|
|
26
27
|
import Layout from "./components/layout";
|
|
27
|
-
export { Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Confirm, Modal, Menu, Steps, Grid, Layout, };
|
|
28
|
+
export { Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Confirm, Modal, Progress, Menu, Steps, Grid, Layout, };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import Typography from "./components/data-display/typography";
|
|
|
23
23
|
import Alert from "./components/feedback/alert";
|
|
24
24
|
import Confirm from "./components/feedback/confirm";
|
|
25
25
|
import Modal from "./components/feedback/modal";
|
|
26
|
+
import Progress from "./components/feedback/progress";
|
|
26
27
|
// Navigation
|
|
27
28
|
import Menu from "./components/navigation/menu";
|
|
28
29
|
import Steps from "./components/navigation/steps";
|
|
@@ -35,7 +36,7 @@ Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox,
|
|
|
35
36
|
// Data Display
|
|
36
37
|
Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography,
|
|
37
38
|
// Feedback
|
|
38
|
-
Alert, Confirm, Modal,
|
|
39
|
+
Alert, Confirm, Modal, Progress,
|
|
39
40
|
// Navigation
|
|
40
41
|
Menu, Steps,
|
|
41
42
|
// Layout
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type LoadingContextProps = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
5
|
+
};
|
|
6
|
+
type LoadingProviderProps = {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare const LoadingContext: React.Context<LoadingContextProps>;
|
|
10
|
+
declare const LoadingProvider: ({ children }: LoadingProviderProps) => React.JSX.Element;
|
|
11
|
+
export { LoadingContext, LoadingProvider };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { createContext, useState } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import Loading from "../../../../components/feedback/loading";
|
|
5
|
+
const LoadingContext = createContext({ isLoading: false, setIsLoading: () => { } });
|
|
6
|
+
const LoadingProvider = ({ children }) => {
|
|
7
|
+
// states
|
|
8
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
+
return (React.createElement(LoadingContext.Provider, { value: { isLoading, setIsLoading } },
|
|
10
|
+
children,
|
|
11
|
+
isLoading && ReactDOM.createPortal(React.createElement(Loading, null), document.body)));
|
|
12
|
+
};
|
|
13
|
+
export { LoadingContext, LoadingProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigProvider } from "./Config";
|
|
2
2
|
import { NotificationProvider } from "./Notification";
|
|
3
3
|
import { LanguageProvider } from "./Language";
|
|
4
|
-
|
|
4
|
+
import { LoadingProvider } from "./Loading";
|
|
5
|
+
export { ConfigProvider, LanguageProvider, NotificationProvider, LoadingProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigProvider } from "./Config";
|
|
2
2
|
import { NotificationProvider } from "./Notification";
|
|
3
3
|
import { LanguageProvider } from "./Language";
|
|
4
|
-
|
|
4
|
+
import { LoadingProvider } from "./Loading";
|
|
5
|
+
export { ConfigProvider, LanguageProvider, NotificationProvider, LoadingProvider };
|
|
@@ -32,7 +32,7 @@ export declare const useLayout: () => {
|
|
|
32
32
|
perPage: number;
|
|
33
33
|
}>>;
|
|
34
34
|
};
|
|
35
|
-
export declare const useLanguage: () => string;
|
|
35
|
+
export declare const useLanguage: () => string | undefined;
|
|
36
36
|
export declare const useNotification: () => {
|
|
37
37
|
notification: ({ title, message, status }: {
|
|
38
38
|
title: string;
|
|
@@ -51,3 +51,7 @@ export declare const useTranslation: <TBaseLocale>(currentLanguage: string | und
|
|
|
51
51
|
t: (key: keyof TBaseLocale, ...args: any[]) => string;
|
|
52
52
|
currentLanguage: string | undefined;
|
|
53
53
|
};
|
|
54
|
+
export declare const useLoading: () => {
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
setIsLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
57
|
+
};
|
|
@@ -3,6 +3,7 @@ import { ConfigContext } from "../contexts/Config";
|
|
|
3
3
|
import { NotificationContext } from "../contexts/Notification";
|
|
4
4
|
import Utils from "../../../infrastructure/shared/Utils";
|
|
5
5
|
import { LanguageContext } from "../contexts/Language";
|
|
6
|
+
import { LoadingContext } from "../contexts/Loading";
|
|
6
7
|
export const useLayout = () => {
|
|
7
8
|
const context = useContext(ConfigContext);
|
|
8
9
|
if (!context) {
|
|
@@ -12,9 +13,9 @@ export const useLayout = () => {
|
|
|
12
13
|
};
|
|
13
14
|
export const useLanguage = () => {
|
|
14
15
|
const context = useContext(LanguageContext);
|
|
15
|
-
if (!context) {
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
// if (!context) {
|
|
17
|
+
// throw new Error("useLayout must be used within a LayoutProvider");
|
|
18
|
+
// }
|
|
18
19
|
return context;
|
|
19
20
|
};
|
|
20
21
|
export const useNotification = () => {
|
|
@@ -99,3 +100,10 @@ export const useTranslation = function (currentLanguage, translations) {
|
|
|
99
100
|
};
|
|
100
101
|
return { t, currentLanguage };
|
|
101
102
|
};
|
|
103
|
+
export const useLoading = () => {
|
|
104
|
+
const context = useContext(LoadingContext);
|
|
105
|
+
// if (!context) {
|
|
106
|
+
// throw new Error("useLayout must be used within a LayoutProvider");
|
|
107
|
+
// }
|
|
108
|
+
return context;
|
|
109
|
+
};
|