ar-design 0.1.21 → 0.1.22
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/data-display/divider/divider.css +4 -1
- package/dist/assets/css/components/data-display/paper/paper.css +20 -0
- package/dist/assets/css/components/data-display/table/scroll.css +61 -0
- package/dist/assets/css/components/data-display/table/table.css +89 -0
- package/dist/assets/css/components/data-display/typography/title/core.css +1 -2
- package/dist/assets/css/components/feedback/alert/alert.css +0 -1
- package/dist/assets/css/components/feedback/modal/content.css +6 -0
- package/dist/assets/css/components/feedback/modal/footer.css +9 -0
- package/dist/assets/css/components/feedback/modal/header.css +56 -0
- package/dist/assets/css/components/feedback/modal/modal.css +54 -0
- package/dist/assets/css/components/form/button/button.css +7 -0
- package/dist/assets/css/components/form/button/core/icon.css +15 -15
- package/dist/assets/css/components/form/button-group/button-group.css +6 -0
- package/dist/assets/css/components/form/checkbox/core/border.css +1 -2
- package/dist/assets/css/components/form/date-picker/calendar/content.css +68 -0
- package/dist/assets/css/components/form/date-picker/calendar/footer.css +10 -0
- package/dist/assets/css/components/form/date-picker/calendar/header.css +33 -0
- package/dist/assets/css/components/form/date-picker/clock/clock.css +30 -0
- package/dist/assets/css/components/form/date-picker/clock/content.css +56 -0
- package/dist/assets/css/components/form/date-picker/clock/footer.css +7 -0
- package/dist/assets/css/components/form/date-picker/clock/header.css +6 -0
- package/dist/assets/css/components/form/date-picker/date-picker.css +51 -0
- package/dist/assets/css/components/form/input/core/border.css +1 -2
- package/dist/assets/css/components/form/input/core/button.css +1 -2
- package/dist/assets/css/components/form/select/options.css +2 -1
- package/dist/assets/css/components/form/switch/core/border.css +1 -2
- package/dist/assets/css/components/layout/header.css +1 -0
- package/dist/assets/css/components/layout/layout.css +0 -2
- package/dist/assets/css/components/navigation/menu/menu.css +1 -0
- package/dist/assets/css/components/navigation/pagination/pagination.css +60 -0
- package/dist/assets/css/core/ar-core.css +19 -4
- package/dist/assets/css/core/variants/animation.css +1 -2
- package/dist/assets/css/core/variants/borderless/borderless.css +25 -50
- package/dist/assets/css/core/variants/dashed/dashed.css +9 -10
- package/dist/assets/css/core/variants/filled/filled.css +65 -34
- package/dist/assets/css/core/variants/outlined/outlined.css +10 -11
- package/dist/components/data-display/paper/index.d.ts +8 -0
- package/dist/components/data-display/paper/index.js +12 -0
- package/dist/components/data-display/table/Actions.d.ts +8 -0
- package/dist/components/data-display/table/Actions.js +2 -0
- package/dist/components/data-display/table/IProps.d.ts +14 -0
- package/dist/components/data-display/table/IProps.js +1 -0
- package/dist/components/data-display/table/index.d.ts +12 -0
- package/dist/components/data-display/table/index.js +194 -0
- package/dist/components/feedback/modal/IProps.d.ts +20 -0
- package/dist/components/feedback/modal/IProps.js +1 -0
- package/dist/components/feedback/modal/index.d.ts +5 -0
- package/dist/components/feedback/modal/index.js +45 -0
- package/dist/components/form/button/IProps.d.ts +1 -1
- package/dist/components/form/button/index.js +12 -26
- package/dist/components/form/checkbox/IProps.d.ts +1 -1
- package/dist/components/form/checkbox/index.d.ts +1 -1
- package/dist/components/form/checkbox/index.js +11 -18
- package/dist/components/form/date-picker/Props.d.ts +7 -0
- package/dist/components/form/date-picker/Props.js +1 -0
- package/dist/components/form/date-picker/index.d.ts +5 -0
- package/dist/components/form/date-picker/index.js +328 -0
- package/dist/components/form/input/IProps.d.ts +1 -1
- package/dist/components/form/input/index.js +19 -35
- package/dist/components/form/select/Props.d.ts +1 -1
- package/dist/components/form/select/index.js +43 -42
- package/dist/components/form/switch/index.js +4 -3
- package/dist/components/layout/Header.js +1 -1
- package/dist/components/layout/LSider.js +2 -2
- package/dist/components/layout/RSider.js +3 -3
- package/dist/components/layout/index.js +5 -8
- package/dist/components/navigation/menu/Types.d.ts +1 -1
- package/dist/components/navigation/menu/index.js +12 -10
- package/dist/components/navigation/pagination/IProps.d.ts +7 -0
- package/dist/components/navigation/pagination/IProps.js +1 -0
- package/dist/components/navigation/pagination/index.d.ts +5 -0
- package/dist/components/navigation/pagination/index.js +77 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +11 -10
- package/dist/libs/core/application/contexts/Config.d.ts +26 -0
- package/dist/libs/core/application/contexts/Config.js +20 -0
- package/dist/libs/core/application/hooks/index.d.ts +24 -18
- package/dist/libs/core/application/hooks/index.js +2 -2
- package/dist/libs/core/service/Api.d.ts +35 -0
- package/dist/libs/core/service/Api.js +86 -0
- package/dist/libs/core/service/index.d.ts +28 -0
- package/dist/libs/core/service/index.js +48 -0
- package/dist/libs/infrastructure/shared/Utils.d.ts +6 -0
- package/dist/libs/infrastructure/shared/Utils.js +15 -0
- package/dist/libs/types/IGlobalProps.d.ts +46 -13
- package/dist/libs/types/index.d.ts +19 -2
- package/package.json +3 -1
- package/dist/libs/core/application/contexts/Layout.d.ts +0 -23
- package/dist/libs/core/application/contexts/Layout.js +0 -17
- package/dist/libs/index.d.ts +0 -0
- package/dist/libs/index.js +0 -3
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import "../../../assets/css/components/form/date-picker/date-picker.css";
|
|
4
|
+
import Input from "../input";
|
|
5
|
+
import Select from "../select";
|
|
6
|
+
import Button from "../button";
|
|
7
|
+
import Alert from "../../feedback/alert";
|
|
8
|
+
const weekdays = ["Pzt", "Sal", "Çar", "Per", "Cum", "Cmt", "Paz"];
|
|
9
|
+
const months = [
|
|
10
|
+
{ value: 0, text: "Ocak" },
|
|
11
|
+
{ value: 1, text: "Şubat" },
|
|
12
|
+
{ value: 2, text: "Mart" },
|
|
13
|
+
{ value: 3, text: "Nisan" },
|
|
14
|
+
{ value: 4, text: "Mayıs" },
|
|
15
|
+
{ value: 5, text: "Haziran" },
|
|
16
|
+
{ value: 6, text: "Temmuz" },
|
|
17
|
+
{ value: 7, text: "Ağustos" },
|
|
18
|
+
{ value: 8, text: "Eylül" },
|
|
19
|
+
{ value: 9, text: "Ekim" },
|
|
20
|
+
{ value: 10, text: "Kasım" },
|
|
21
|
+
{ value: 11, text: "Aralık" },
|
|
22
|
+
];
|
|
23
|
+
const DatePicker = ({ onChange, ...attributes }) => {
|
|
24
|
+
// refs
|
|
25
|
+
const _arCalendar = useRef(null);
|
|
26
|
+
const _currentDate = useRef(new Date()).current;
|
|
27
|
+
const _beginDate = useRef(null);
|
|
28
|
+
const _clockOpen = useRef(false);
|
|
29
|
+
// refs
|
|
30
|
+
const _year = useRef(_currentDate.getFullYear());
|
|
31
|
+
const _month = useRef(_currentDate.getMonth());
|
|
32
|
+
const _day = useRef(_currentDate.getDate());
|
|
33
|
+
const _hours = useRef(_currentDate.getHours());
|
|
34
|
+
const _minutes = useRef(_currentDate.getMinutes());
|
|
35
|
+
// refs -> List Elements
|
|
36
|
+
const _hoursListElement = useRef(null);
|
|
37
|
+
const _hoursLiElements = useRef([]);
|
|
38
|
+
const _minutesListElement = useRef(null);
|
|
39
|
+
const _minutesLiElements = useRef([]);
|
|
40
|
+
// states
|
|
41
|
+
const [calendarOpen, setCalendarOpen] = useState(false);
|
|
42
|
+
const [clockOpen, setClockOpen] = useState(false);
|
|
43
|
+
const [calendar, setCalendar] = useState([]);
|
|
44
|
+
const [years, setYears] = useState([]);
|
|
45
|
+
const [hours, setHours] = useState();
|
|
46
|
+
const [minutes, setMinutes] = useState();
|
|
47
|
+
const [dateTrigger, setDateTrigger] = useState(false);
|
|
48
|
+
const [timeTrigger, setTimeTrigger] = useState(false);
|
|
49
|
+
let [calendarClassName, setCalendarClassName] = useState([
|
|
50
|
+
"calendar-wrapper",
|
|
51
|
+
"closed",
|
|
52
|
+
]);
|
|
53
|
+
// states => Selected Date
|
|
54
|
+
const [currentYear, setCurrentYear] = useState(_currentDate.getFullYear());
|
|
55
|
+
const [currentMonth, setCurrentMonth] = useState(_currentDate.getMonth());
|
|
56
|
+
const [currentDay, setCurrentDay] = useState(_currentDate.getDate());
|
|
57
|
+
const [currentHours, setCurrentHours] = useState(_currentDate.getHours());
|
|
58
|
+
const [currentMinutes, setCurrentMinutes] = useState(_currentDate.getMinutes());
|
|
59
|
+
// methods
|
|
60
|
+
const handleClickOutSide = (event) => {
|
|
61
|
+
const target = event.target;
|
|
62
|
+
if (_arCalendar.current && !_arCalendar.current.contains(target))
|
|
63
|
+
cancelProgress();
|
|
64
|
+
};
|
|
65
|
+
const handleKeys = (event) => {
|
|
66
|
+
const key = event.key;
|
|
67
|
+
if (key === "Escape")
|
|
68
|
+
cancelProgress();
|
|
69
|
+
};
|
|
70
|
+
const setNow = () => {
|
|
71
|
+
const now = new Date();
|
|
72
|
+
// Stateler güncelleniyor...
|
|
73
|
+
setCurrentYear(now.getFullYear());
|
|
74
|
+
setCurrentMonth(now.getMonth());
|
|
75
|
+
setCurrentDay(now.getDate());
|
|
76
|
+
setCurrentHours(now.getHours());
|
|
77
|
+
setCurrentMinutes(now.getMinutes());
|
|
78
|
+
_year.current = now.getFullYear();
|
|
79
|
+
_month.current = now.getMonth();
|
|
80
|
+
_day.current = now.getDate();
|
|
81
|
+
_hours.current = now.getHours();
|
|
82
|
+
_minutes.current = now.getMinutes();
|
|
83
|
+
// Input güncelleniyor...
|
|
84
|
+
updateDateInput(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes());
|
|
85
|
+
// Takvim kapatılıyor...
|
|
86
|
+
setCalendarOpen(false);
|
|
87
|
+
// Değer gönderiliyor...
|
|
88
|
+
const inputDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), !clockOpen ? 0 : now.getHours(), !clockOpen ? 0 : now.getMinutes(), 0));
|
|
89
|
+
onChange(inputDate.toISOString());
|
|
90
|
+
};
|
|
91
|
+
const updateDateInput = (year = _year.current, month = _month.current, day = _day.current, hours = _hours.current, minutes = _minutes.current) => {
|
|
92
|
+
if (_beginDate.current) {
|
|
93
|
+
const inputDate = new Date(Date.UTC(year, month, day, hours, minutes, 0));
|
|
94
|
+
if (isNaN(inputDate.getTime()))
|
|
95
|
+
return;
|
|
96
|
+
const [date, time] = inputDate.toISOString().split("T");
|
|
97
|
+
const [clock, ms] = time.split(".");
|
|
98
|
+
_beginDate.current.value = !_clockOpen.current ? date : `${date}T${clock}`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const okayButton = () => {
|
|
102
|
+
return (React.createElement(Button, { variant: "borderless", status: "success", onClick: () => {
|
|
103
|
+
// Input güncelleniyor...
|
|
104
|
+
updateDateInput(_year.current, _month.current, _day.current, _hours.current, _minutes.current);
|
|
105
|
+
// Stateler güncelleniyor...
|
|
106
|
+
setCurrentYear(_year.current);
|
|
107
|
+
setCurrentMonth(_month.current);
|
|
108
|
+
setCurrentDay(_day.current);
|
|
109
|
+
setCurrentHours(_hours.current);
|
|
110
|
+
setCurrentMinutes(_minutes.current);
|
|
111
|
+
const inputDate = new Date(Date.UTC(_year.current, _month.current, _day.current, !clockOpen ? 0 : _hours.current, !clockOpen ? 0 : _minutes.current, 0));
|
|
112
|
+
onChange(inputDate.toISOString());
|
|
113
|
+
setCalendarOpen(false);
|
|
114
|
+
} }, "Tamam"));
|
|
115
|
+
};
|
|
116
|
+
const cancelProgress = () => {
|
|
117
|
+
updateDateInput(currentYear, currentMonth, currentDay, currentHours, currentMinutes);
|
|
118
|
+
_year.current = currentYear;
|
|
119
|
+
_month.current = currentMonth;
|
|
120
|
+
_day.current = currentDay;
|
|
121
|
+
_hours.current = currentHours;
|
|
122
|
+
_minutes.current = currentMinutes;
|
|
123
|
+
setCalendarOpen(false);
|
|
124
|
+
};
|
|
125
|
+
// useEffects
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (isNaN(_year.current))
|
|
128
|
+
return;
|
|
129
|
+
const years = [];
|
|
130
|
+
// Son 20 yıl
|
|
131
|
+
for (let i = _year.current - 20; i <= _year.current; i++) {
|
|
132
|
+
years.push({ value: i, text: `${i}` });
|
|
133
|
+
}
|
|
134
|
+
// Önümüzdeki 20 yıl
|
|
135
|
+
for (let i = _year.current + 1; i <= _year.current + 20; i++) {
|
|
136
|
+
years.push({ value: i, text: `${i}` });
|
|
137
|
+
}
|
|
138
|
+
setYears(years);
|
|
139
|
+
}, []);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
// Sıfırlama işlemi...
|
|
142
|
+
setCalendarClassName(["calendar-wrapper"]);
|
|
143
|
+
const screenCenter = window.innerHeight / 2 + 100;
|
|
144
|
+
const rect = _beginDate.current?.getBoundingClientRect();
|
|
145
|
+
const direction = rect && rect.top > screenCenter ? "bottom" : "top";
|
|
146
|
+
if (calendarOpen) {
|
|
147
|
+
setCalendarClassName((prev) => [...prev, direction, "opened"]);
|
|
148
|
+
const calendar = [];
|
|
149
|
+
const beginDateValue = _beginDate.current?.value || "";
|
|
150
|
+
const date = {
|
|
151
|
+
input: {
|
|
152
|
+
begin: new Date(beginDateValue),
|
|
153
|
+
},
|
|
154
|
+
current: {
|
|
155
|
+
firstDay: new Date(_year.current, _month.current, 1), // Geçerli ayın ilk günü
|
|
156
|
+
lastDay: new Date(_year.current, _month.current + 1, 0), // Geçerli ayın son günü
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
const startingDay = date.current.firstDay.getDay() === 0 ? 7 : date.current.firstDay.getDay();
|
|
160
|
+
const endDay = date.current.lastDay.getDay() === 0 ? 7 : date.current.lastDay.getDay();
|
|
161
|
+
for (let i = 1; i < startingDay; i++) {
|
|
162
|
+
calendar.push(React.createElement("span", { key: `prev-${i}`, className: "empty-day" }));
|
|
163
|
+
}
|
|
164
|
+
for (let i = date.current.firstDay.getDate(); i <= date.current.lastDay.getDate(); i++) {
|
|
165
|
+
const isSelected = !isNaN(date.input.begin.getTime())
|
|
166
|
+
? date.input.begin.getFullYear() == _year.current &&
|
|
167
|
+
date.input.begin.getMonth() == _month.current &&
|
|
168
|
+
i == _day.current
|
|
169
|
+
: _currentDate.getFullYear() == _year.current &&
|
|
170
|
+
_currentDate.getMonth() == _month.current &&
|
|
171
|
+
i == _day.current;
|
|
172
|
+
calendar.push(React.createElement("span", { key: `current-${i}`, ...(isSelected ? { className: "selection-day" } : {}), onClick: () => {
|
|
173
|
+
_day.current = i;
|
|
174
|
+
updateDateInput(_year.current, _month.current, _day.current);
|
|
175
|
+
setDateTrigger((prev) => !prev);
|
|
176
|
+
} },
|
|
177
|
+
React.createElement("span", null, i)));
|
|
178
|
+
}
|
|
179
|
+
for (let i = endDay; i < 7; i++) {
|
|
180
|
+
calendar.push(React.createElement("span", { key: `next-${i}`, className: "empty-day" }));
|
|
181
|
+
}
|
|
182
|
+
// Takvim nesneleri ekleniyor.
|
|
183
|
+
setCalendar(calendar);
|
|
184
|
+
// Takvim paneli için olay dinleyileri ekleniyor.
|
|
185
|
+
document.addEventListener("click", handleClickOutSide);
|
|
186
|
+
document.addEventListener("keydown", handleKeys);
|
|
187
|
+
// Dinleyicileri kaldır ve zamanlayıcıyı temizle.
|
|
188
|
+
return () => {
|
|
189
|
+
document.removeEventListener("click", handleClickOutSide);
|
|
190
|
+
document.removeEventListener("keydown", handleKeys);
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
setCalendarClassName((prev) => [...prev, direction, "closed"]);
|
|
195
|
+
}
|
|
196
|
+
}, [dateTrigger, calendarOpen]);
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
const generateList = (count, current, setFunc) => {
|
|
199
|
+
const items = Array.from({ length: count }, (_, i) => (React.createElement("li", { ref: (element) => count === 24
|
|
200
|
+
? (_hoursLiElements.current[i] = element)
|
|
201
|
+
: (_minutesLiElements.current[i] = element), key: i, ...(current === i ? { className: "selection-time" } : {}), onClick: () => {
|
|
202
|
+
if (count === 24) {
|
|
203
|
+
setTimeTrigger((prev) => !prev);
|
|
204
|
+
_hours.current = i;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
setTimeTrigger((prev) => !prev);
|
|
208
|
+
_minutes.current = i;
|
|
209
|
+
}
|
|
210
|
+
} },
|
|
211
|
+
React.createElement("span", null,
|
|
212
|
+
React.createElement("span", null, i.toString().padStart(2, "0"))))));
|
|
213
|
+
setFunc(items);
|
|
214
|
+
};
|
|
215
|
+
// Listeler oluşturuyor...
|
|
216
|
+
generateList(24, _hours.current, setHours);
|
|
217
|
+
generateList(60, _minutes.current, setMinutes);
|
|
218
|
+
// Input güncelleniyor...
|
|
219
|
+
updateDateInput(_year.current, _month.current, _day.current, _hours.current, _minutes.current);
|
|
220
|
+
if (!clockOpen)
|
|
221
|
+
return;
|
|
222
|
+
// Seçim sonrasında en yukarı getirme işlemi için aşağıda yer alan kodlar yazılmıştır
|
|
223
|
+
const hourLiElement = _hoursLiElements.current[_hours.current];
|
|
224
|
+
const minuteLiElement = _minutesLiElements.current[_minutes.current];
|
|
225
|
+
if (hourLiElement) {
|
|
226
|
+
_hoursListElement.current?.scrollTo({
|
|
227
|
+
top: hourLiElement.offsetTop - _hoursListElement.current.offsetTop - 8,
|
|
228
|
+
behavior: "smooth",
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (minuteLiElement) {
|
|
232
|
+
_minutesListElement.current?.scrollTo({
|
|
233
|
+
top: minuteLiElement.offsetTop - _minutesListElement.current.offsetTop - 8,
|
|
234
|
+
behavior: "smooth",
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}, [timeTrigger, calendarOpen, clockOpen]);
|
|
238
|
+
return (React.createElement("div", { className: "ar-date-picker" },
|
|
239
|
+
React.createElement(Input, { ref: _beginDate, type: clockOpen ? "datetime-local" : "date", onKeyDown: (event) => event.code == "Space" && event.preventDefault(), onChange: (event) => {
|
|
240
|
+
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
241
|
+
if (attributes.disabled)
|
|
242
|
+
return;
|
|
243
|
+
(() => {
|
|
244
|
+
const value = event.target.value;
|
|
245
|
+
const [date, time] = value.split("T");
|
|
246
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
247
|
+
const hours = time ? time.split(".")[0].split(":").map(Number)[0] : 0;
|
|
248
|
+
const minutes = time ? time.split(".")[0].split(":").map(Number)[1] : 0;
|
|
249
|
+
_year.current = year;
|
|
250
|
+
_month.current = month - 1;
|
|
251
|
+
_day.current = day;
|
|
252
|
+
if (hours || minutes) {
|
|
253
|
+
_hours.current = hours;
|
|
254
|
+
_minutes.current = minutes;
|
|
255
|
+
}
|
|
256
|
+
setDateTrigger((prev) => !prev);
|
|
257
|
+
setTimeTrigger((prev) => !prev);
|
|
258
|
+
})();
|
|
259
|
+
}, onClick: (event) => {
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
setCalendarOpen(true);
|
|
262
|
+
}, autoComplete: "off" }),
|
|
263
|
+
React.createElement("div", { ref: _arCalendar, className: calendarClassName.map((className) => className).join(" ") },
|
|
264
|
+
React.createElement("div", { className: "header" },
|
|
265
|
+
React.createElement("div", { className: "select-field" },
|
|
266
|
+
React.createElement("div", { className: "prev" },
|
|
267
|
+
React.createElement("span", { onClick: () => {
|
|
268
|
+
_year.current -= 1;
|
|
269
|
+
setDateTrigger((prev) => !prev);
|
|
270
|
+
} }, "«"),
|
|
271
|
+
React.createElement("span", { onClick: () => {
|
|
272
|
+
if (_month.current <= 0) {
|
|
273
|
+
_year.current -= 1;
|
|
274
|
+
_month.current = 12;
|
|
275
|
+
}
|
|
276
|
+
_month.current -= 1;
|
|
277
|
+
updateDateInput(_year.current, _month.current, _day.current);
|
|
278
|
+
setDateTrigger((prev) => !prev);
|
|
279
|
+
} }, "‹")),
|
|
280
|
+
React.createElement("div", { className: "selects" },
|
|
281
|
+
React.createElement(Select, { defaultValueIndex: months.findIndex((month) => month.value == _month.current), variant: "borderless", options: months, onChange: (option) => {
|
|
282
|
+
_month.current = option?.value;
|
|
283
|
+
updateDateInput(_year.current, _month.current, _day.current);
|
|
284
|
+
setDateTrigger((prev) => !prev);
|
|
285
|
+
}, placeholder: "Ay" }),
|
|
286
|
+
React.createElement(Select, { variant: "borderless", defaultValueIndex: years.findIndex((year) => year.value == _year.current), options: years, onChange: (option) => {
|
|
287
|
+
_year.current = option?.value;
|
|
288
|
+
updateDateInput(_year.current, _month.current, _day.current);
|
|
289
|
+
setDateTrigger((prev) => !prev);
|
|
290
|
+
}, placeholder: "Y\u0131l" })),
|
|
291
|
+
React.createElement("div", { className: "next" },
|
|
292
|
+
React.createElement("span", { onClick: () => {
|
|
293
|
+
if (_month.current >= 11) {
|
|
294
|
+
_year.current += 1;
|
|
295
|
+
_month.current = -1;
|
|
296
|
+
}
|
|
297
|
+
_month.current += 1;
|
|
298
|
+
updateDateInput(_year.current, _month.current, _day.current);
|
|
299
|
+
setDateTrigger((prev) => !prev);
|
|
300
|
+
} }, "›"),
|
|
301
|
+
React.createElement("span", { onClick: () => {
|
|
302
|
+
_year.current += 1;
|
|
303
|
+
updateDateInput(_year.current, _month.current, _day.current);
|
|
304
|
+
setDateTrigger((prev) => !prev);
|
|
305
|
+
} }, "»")))),
|
|
306
|
+
React.createElement("div", { className: "content" }, !isNaN(_month.current) && !isNaN(_year.current) ? (React.createElement("div", { className: "calendar" },
|
|
307
|
+
React.createElement("div", { className: "weekdays" }, weekdays.map((weekday, index) => (React.createElement("span", { key: index }, weekday)))),
|
|
308
|
+
React.createElement("div", { className: "days" }, calendar))) : (React.createElement(Alert, { status: "warning" }, "Ay veya y\u0131l se\u00E7imi yapman\u0131z gerekmektedir."))),
|
|
309
|
+
React.createElement("div", { className: "footer" },
|
|
310
|
+
React.createElement("div", null,
|
|
311
|
+
React.createElement(Button, { variant: "borderless", onClick: () => setNow() }, "\u015Eimdi"),
|
|
312
|
+
React.createElement(Button, { variant: "borderless", status: !clockOpen ? "primary" : "danger", onClick: () => {
|
|
313
|
+
_clockOpen.current = !_clockOpen.current;
|
|
314
|
+
setClockOpen((prev) => !prev);
|
|
315
|
+
} }, "Saat")),
|
|
316
|
+
React.createElement("div", null, !clockOpen && okayButton())),
|
|
317
|
+
React.createElement("div", { className: `clock ${clockOpen ? "active" : "passive"}` },
|
|
318
|
+
React.createElement("div", { className: "header" },
|
|
319
|
+
_hours.current.toString().padStart(2, "0"),
|
|
320
|
+
" : ",
|
|
321
|
+
_minutes.current.toString().padStart(2, "0")),
|
|
322
|
+
React.createElement("div", { className: "content" },
|
|
323
|
+
React.createElement("ul", { ref: _hoursListElement }, hours),
|
|
324
|
+
React.createElement("ul", { ref: _minutesListElement }, minutes)),
|
|
325
|
+
clockOpen && React.createElement("div", { className: "footer" }, okayButton())))));
|
|
326
|
+
};
|
|
327
|
+
DatePicker.displayName = "DatePicker";
|
|
328
|
+
export default DatePicker;
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import IButtonProps from "../button/IProps";
|
|
3
3
|
import { Variants } from "../../../libs/types";
|
|
4
4
|
import { IGlobalProps } from "../../../libs/types/IGlobalProps";
|
|
5
|
-
interface IProps extends Omit<IGlobalProps, "children">, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size"> {
|
|
5
|
+
interface IProps extends Omit<IGlobalProps, "children" | "disabled">, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size"> {
|
|
6
6
|
button?: IButtonProps;
|
|
7
7
|
addon?: {
|
|
8
8
|
variant?: Variants;
|
|
@@ -2,45 +2,29 @@
|
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import "../../../assets/css/components/form/input/input.css";
|
|
4
4
|
import Button from "../button";
|
|
5
|
-
|
|
5
|
+
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
6
|
+
const Input = forwardRef(({ variant = "outlined", status = "light", size = "normal", icon, border = { radius: "sm" }, button, addon, ...attributes }, ref) => {
|
|
6
7
|
// variables
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// input wrapper className
|
|
13
|
-
if (icon && icon.element) {
|
|
14
|
-
_inputWrapperClassName += ` icon`;
|
|
15
|
-
_inputWrapperClassName += ` icon-${icon.position ?? "start"}`;
|
|
16
|
-
}
|
|
17
|
-
// input className
|
|
18
|
-
if (variant)
|
|
19
|
-
_inputClassName += `${variant}`;
|
|
20
|
-
if (status)
|
|
21
|
-
_inputClassName += ` ${status}`;
|
|
22
|
-
// border radius
|
|
23
|
-
_inputClassName += ` border-radius-${border.radius}`;
|
|
8
|
+
const _wrapperClassName = ["ar-input-wrapper"];
|
|
9
|
+
const _addonBeforeClassName = ["addon-before"];
|
|
10
|
+
const _addonAfterClassName = ["addon-after"];
|
|
11
|
+
const _inputClassName = [];
|
|
12
|
+
_inputClassName.push(...Utils.GetClassName(variant, status, border, size, icon, attributes.className));
|
|
24
13
|
// addon className
|
|
25
14
|
if (addon) {
|
|
26
|
-
_wrapperClassName
|
|
27
|
-
|
|
28
|
-
_addonBeforeClassName
|
|
29
|
-
_addonAfterClassName
|
|
30
|
-
|
|
31
|
-
_addonBeforeClassName
|
|
32
|
-
_addonAfterClassName
|
|
33
|
-
// border radius
|
|
34
|
-
_addonBeforeClassName += ` border-radius-${border?.radius || "sm"}`;
|
|
35
|
-
_addonAfterClassName += ` border-radius-${border?.radius || "sm"}`;
|
|
15
|
+
_wrapperClassName.push("addon");
|
|
16
|
+
_addonBeforeClassName.push(`${addon.variant || "filled"}`);
|
|
17
|
+
_addonBeforeClassName.push(`${status}`);
|
|
18
|
+
_addonAfterClassName.push(`${addon.variant || "filled"}`);
|
|
19
|
+
_addonAfterClassName.push(`${status}`);
|
|
20
|
+
_addonBeforeClassName.push(`border-radius-${border.radius}`);
|
|
21
|
+
_addonAfterClassName.push(`border-radius-${border.radius}`);
|
|
36
22
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
addon?.before && React.createElement("span", { className: _addonBeforeClassName }, addon?.before),
|
|
41
|
-
React.createElement("div", { className: _inputWrapperClassName },
|
|
23
|
+
return (React.createElement("div", { className: _wrapperClassName.map((c) => c).join(" ") },
|
|
24
|
+
addon?.before && (React.createElement("span", { className: _addonBeforeClassName.map((c) => c).join(" ") }, addon?.before)),
|
|
25
|
+
React.createElement("div", { className: "ar-input" },
|
|
42
26
|
icon?.element && React.createElement("span", { className: "icon-element" }, icon.element),
|
|
43
|
-
React.createElement("input", { ref: ref, ...attributes, size: 20, className: _inputClassName, onChange: (event) => {
|
|
27
|
+
React.createElement("input", { ref: ref, ...attributes, size: 20, className: _inputClassName.map((c) => c).join(" "), onChange: (event) => {
|
|
44
28
|
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
45
29
|
if (attributes.disabled)
|
|
46
30
|
return;
|
|
@@ -57,7 +41,7 @@ const Input = forwardRef(({ variant = "outlined", status = "light", icon, border
|
|
|
57
41
|
}
|
|
58
42
|
})();
|
|
59
43
|
} })),
|
|
60
|
-
addon?.after && React.createElement("span", { className: _addonAfterClassName }, addon?.after),
|
|
44
|
+
addon?.after && (React.createElement("span", { className: _addonAfterClassName.map((c) => c).join(" ") }, addon?.after)),
|
|
61
45
|
button && (React.createElement(Button, { ...button, status: status, border: { radius: border.radius }, disabled: attributes.disabled }))));
|
|
62
46
|
});
|
|
63
47
|
Input.displayName = "Input";
|
|
@@ -5,9 +5,9 @@ import "../../../assets/css/components/form/select/select.css";
|
|
|
5
5
|
import Chip from "../../data-display/chip";
|
|
6
6
|
import Checkbox from "../checkbox";
|
|
7
7
|
import Paragraph from "../../data-display/typography/paragraph/Paragraph";
|
|
8
|
-
const Select = ({ variant = "outlined", status, border, options, onChange, multiple, defaultValueIndex, ...attributes }) => {
|
|
8
|
+
const Select = ({ variant = "outlined", status, border = { radius: "sm" }, options, onChange, multiple, defaultValueIndex, ...attributes }) => {
|
|
9
9
|
// refs
|
|
10
|
-
let _selectionClassName =
|
|
10
|
+
let _selectionClassName = "selections";
|
|
11
11
|
const _arSelect = useRef(null);
|
|
12
12
|
const _singleInput = useRef(null);
|
|
13
13
|
const _multipleInput = useRef(null);
|
|
@@ -19,18 +19,18 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
19
19
|
let _selectedItemIndex = useRef(0);
|
|
20
20
|
// states
|
|
21
21
|
const [optionsOpen, setOptionsOpen] = useState(false);
|
|
22
|
+
let [optionsClassName, setOptionsClassName] = useState(["options", "closed"]);
|
|
22
23
|
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
23
24
|
const [searchText, setSearchText] = useState("");
|
|
24
25
|
const [selection, setSelection] = useState(undefined);
|
|
25
26
|
const [selections, setSelections] = useState([]);
|
|
26
27
|
const [navigationIndex, setNavigationIndex] = useState(0);
|
|
27
|
-
let [optionsClassName, setOptionsClassName] = useState(["options", "closed"]);
|
|
28
28
|
// selection className
|
|
29
29
|
if (variant)
|
|
30
30
|
_selectionClassName += ` ${variant}`;
|
|
31
31
|
_selectionClassName += multiple ? ` ${status?.color || "light"}` : status || "light";
|
|
32
32
|
// border
|
|
33
|
-
_selectionClassName += ` border-radius-${border
|
|
33
|
+
_selectionClassName += ` border-radius-${border.radius}`;
|
|
34
34
|
_selectionClassName += ` border-style-solid}`;
|
|
35
35
|
// methods
|
|
36
36
|
const handleClickOutSide = (event) => {
|
|
@@ -39,6 +39,40 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
39
39
|
setOptionsOpen(false);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
const handleKeys = (event) => {
|
|
43
|
+
const key = event.key;
|
|
44
|
+
const optionItems = _optionItems.current.filter((optionItem) => optionItem !== null);
|
|
45
|
+
if (key === "ArrowUp" || key === "ArrowLeft") {
|
|
46
|
+
setNavigationIndex((prev) => {
|
|
47
|
+
let result = 0;
|
|
48
|
+
if (prev > 0)
|
|
49
|
+
result = prev - 1;
|
|
50
|
+
if (prev === 0)
|
|
51
|
+
result = optionItems.length - 1;
|
|
52
|
+
_navigationIndex.current = result;
|
|
53
|
+
return result;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (key === "ArrowDown" || key === "ArrowRight") {
|
|
57
|
+
setNavigationIndex((prev) => {
|
|
58
|
+
let result = 0;
|
|
59
|
+
if (prev === optionItems.length - 1)
|
|
60
|
+
result = 0;
|
|
61
|
+
if (prev < optionItems.length - 1)
|
|
62
|
+
result = prev + 1;
|
|
63
|
+
_navigationIndex.current = result;
|
|
64
|
+
return result;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else if (key === "Enter") {
|
|
68
|
+
if (_navigationIndex.current === -1)
|
|
69
|
+
return;
|
|
70
|
+
optionItems[_navigationIndex.current]?.click();
|
|
71
|
+
}
|
|
72
|
+
else if (key === "Escape") {
|
|
73
|
+
setOptionsOpen(false);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
42
76
|
const handleItemSelected = (option, index) => {
|
|
43
77
|
// Multiple
|
|
44
78
|
if (multiple) {
|
|
@@ -77,41 +111,8 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
77
111
|
_optionItems.current[index]?.classList.add("selectedItem");
|
|
78
112
|
}
|
|
79
113
|
};
|
|
80
|
-
const handleKeys = (event) => {
|
|
81
|
-
const key = event.key;
|
|
82
|
-
const optionItems = _optionItems.current.filter((optionItem) => optionItem !== null);
|
|
83
|
-
if (key === "ArrowUp" || key === "ArrowLeft") {
|
|
84
|
-
setNavigationIndex((prev) => {
|
|
85
|
-
let result = 0;
|
|
86
|
-
if (prev > 0)
|
|
87
|
-
result = prev - 1;
|
|
88
|
-
if (prev === 0)
|
|
89
|
-
result = optionItems.length - 1;
|
|
90
|
-
_navigationIndex.current = result;
|
|
91
|
-
return result;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else if (key === "ArrowDown" || key === "ArrowRight") {
|
|
95
|
-
setNavigationIndex((prev) => {
|
|
96
|
-
let result = 0;
|
|
97
|
-
if (prev === optionItems.length - 1)
|
|
98
|
-
result = 0;
|
|
99
|
-
if (prev < optionItems.length - 1)
|
|
100
|
-
result = prev + 1;
|
|
101
|
-
_navigationIndex.current = result;
|
|
102
|
-
return result;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else if (key === "Enter") {
|
|
106
|
-
if (_navigationIndex.current === -1)
|
|
107
|
-
return;
|
|
108
|
-
optionItems[_navigationIndex.current]?.click();
|
|
109
|
-
}
|
|
110
|
-
else if (key === "Escape") {
|
|
111
|
-
setOptionsOpen(false);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
114
|
// effects
|
|
115
|
+
useEffect(() => setFilteredOptions(options), [options]);
|
|
115
116
|
useEffect(() => {
|
|
116
117
|
const optionItems = _optionItems.current.filter((optionItem) => optionItem !== null);
|
|
117
118
|
const screenCenter = window.innerHeight / 2 + 100;
|
|
@@ -131,7 +132,7 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
131
132
|
_singleInput.current.value = "";
|
|
132
133
|
_singleInput.current.placeholder = selection?.text || attributes.placeholder || "";
|
|
133
134
|
}
|
|
134
|
-
optionItems[_selectedItemIndex.current]
|
|
135
|
+
optionItems[_selectedItemIndex.current]?.scrollIntoView({
|
|
135
136
|
behavior: "smooth",
|
|
136
137
|
block: "start",
|
|
137
138
|
});
|
|
@@ -168,7 +169,7 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
168
169
|
}, [optionsOpen]);
|
|
169
170
|
useEffect(() => {
|
|
170
171
|
// Arama kriterlerine uygun olan değerleri bir state e gönderiyoruz.
|
|
171
|
-
setFilteredOptions(options
|
|
172
|
+
setFilteredOptions(options?.filter((option) => {
|
|
172
173
|
if (!optionsOpen)
|
|
173
174
|
return option;
|
|
174
175
|
return option.text.toLowerCase().includes(searchText.toLowerCase());
|
|
@@ -211,7 +212,7 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
211
212
|
multiple ? (React.createElement("div", { className: _selectionClassName, onClick: () => setOptionsOpen((x) => !x) },
|
|
212
213
|
React.createElement("div", { className: "items" }, selections.length > 0 ? (selections.map((selection, index) => (React.createElement(Chip, { key: index, variant: status?.selected?.variant || "filled", status: status?.selected?.color || status?.color, text: selection.text })))) : (React.createElement("span", { className: `placeholder ${status?.color || "light"}` }, attributes.placeholder))))) : (
|
|
213
214
|
// Single
|
|
214
|
-
React.createElement(Input, { ref: _singleInput, variant: variant, status: status || "light", onClick: () => setOptionsOpen((
|
|
215
|
+
React.createElement(Input, { ref: _singleInput, variant: variant, status: status || "light", border: { radius: border.radius }, onClick: () => setOptionsOpen((prev) => !prev), onChange: () => !optionsOpen && setOptionsOpen(true), onKeyUp: (event) => {
|
|
215
216
|
if (event.key === "Enter")
|
|
216
217
|
return;
|
|
217
218
|
// Arama yapmak için kullanılan state bu kısımda dolduruluyor.
|
|
@@ -242,7 +243,7 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
|
|
|
242
243
|
// Arama yapmak için kullanılan state bu kısımda dolduruluyor.
|
|
243
244
|
setSearchText(event.currentTarget.value);
|
|
244
245
|
} }))),
|
|
245
|
-
filteredOptions
|
|
246
|
+
filteredOptions?.length > 0 ? (React.createElement("ul", null, filteredOptions?.map((option, index) => {
|
|
246
247
|
const isItem = selections.some((selection) => selection.value === option.value);
|
|
247
248
|
return (React.createElement("li", { ref: (element) => (_optionItems.current[index] = element), key: index, onClick: () => handleItemSelected(option, index) },
|
|
248
249
|
multiple && (React.createElement(Checkbox, { checked: isItem, status: isItem ? status?.selected?.color || status?.color : "light", disabled: true })),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import React, { useRef } from "react";
|
|
2
3
|
import "../../../assets/css/components/form/switch/switch.css";
|
|
3
|
-
const Switch = ({ label, status = "primary", border, ...attributes }) => {
|
|
4
|
+
const Switch = ({ label, status = "primary", border = { radius: "pill" }, ...attributes }) => {
|
|
4
5
|
// refs
|
|
5
6
|
let _switch = useRef(null);
|
|
6
7
|
// variables
|
|
@@ -11,8 +12,8 @@ const Switch = ({ label, status = "primary", border, ...attributes }) => {
|
|
|
11
12
|
_switchClassName += ` light`;
|
|
12
13
|
// border
|
|
13
14
|
_switchClassName += ` border-style-solid`;
|
|
14
|
-
_switchClassName += ` border-radius-${border
|
|
15
|
-
_handleClassName += ` border-radius-${border
|
|
15
|
+
_switchClassName += ` border-radius-${border.radius}`;
|
|
16
|
+
_handleClassName += ` border-radius-${border.radius}`;
|
|
16
17
|
return (React.createElement("div", { className: _wrapperClassName },
|
|
17
18
|
React.createElement("label", null,
|
|
18
19
|
React.createElement("input", { type: attributes.type || "checkbox", ...attributes, size: 0, onChange: (event) => {
|
|
@@ -5,7 +5,7 @@ const Header = ({ logo, menu }) => {
|
|
|
5
5
|
return (React.createElement("header", null,
|
|
6
6
|
React.createElement("div", { className: "ar-header-with-wrap" },
|
|
7
7
|
typeof logo === "string" ? React.createElement("h1", null, logo) : logo,
|
|
8
|
-
React.createElement(Menu, {
|
|
8
|
+
React.createElement(Menu, { data: menu, variant: "horizontal" }))));
|
|
9
9
|
};
|
|
10
10
|
Header.displayName = "Layout.Header";
|
|
11
11
|
export default Header;
|
|
@@ -3,8 +3,8 @@ import React from "react";
|
|
|
3
3
|
import { useLayout } from "../../libs/core/application/hooks";
|
|
4
4
|
const LSider = () => {
|
|
5
5
|
// hooks
|
|
6
|
-
const { options } = useLayout();
|
|
7
|
-
const sider = options
|
|
6
|
+
const { config: options } = useLayout();
|
|
7
|
+
const sider = options.layout.sider.left;
|
|
8
8
|
if (!sider?.active)
|
|
9
9
|
return null;
|
|
10
10
|
return React.createElement("aside", { className: "ar-aside left" }, sider.element);
|
|
@@ -3,9 +3,9 @@ import React from "react";
|
|
|
3
3
|
import { useLayout } from "../../libs/core/application/hooks";
|
|
4
4
|
const RSider = () => {
|
|
5
5
|
// hooks
|
|
6
|
-
const { options } = useLayout();
|
|
7
|
-
const sider = options
|
|
8
|
-
if (!sider
|
|
6
|
+
const { config: options } = useLayout();
|
|
7
|
+
const sider = options.layout.sider.right;
|
|
8
|
+
if (!sider.active)
|
|
9
9
|
return null;
|
|
10
10
|
return React.createElement("aside", { className: "ar-aside right" }, sider.element);
|
|
11
11
|
};
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import Footer from "./Footer";
|
|
4
3
|
import "../../assets/css/components/layout/layout.css";
|
|
5
4
|
import Header from "./Header";
|
|
6
5
|
import Section from "./Section";
|
|
7
|
-
import { LayoutProvider } from "../../libs/core/application/contexts/Layout";
|
|
8
6
|
import Main from "./Main";
|
|
9
7
|
import LSider from "./LSider";
|
|
10
8
|
import RSider from "./RSider";
|
|
11
9
|
const Layout = ({ children }) => {
|
|
12
|
-
return (React.createElement(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}))));
|
|
10
|
+
return (React.createElement("div", { className: "ar-layout" }, React.Children.map(children, (child) => {
|
|
11
|
+
if (!React.isValidElement(child))
|
|
12
|
+
return;
|
|
13
|
+
return child;
|
|
14
|
+
})));
|
|
18
15
|
};
|
|
19
16
|
Layout.Header = Header;
|
|
20
17
|
Layout.Main = Main;
|