@ayseaistudio/ui-components 3.6.1 → 3.8.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/dist/Calendar/Calendar.d.ts +41 -0
- package/dist/Calendar/Calendar.js +338 -0
- package/dist/Calendar/index.d.ts +1 -0
- package/dist/Calendar/index.js +1 -0
- package/dist/Calendar/style.css +217 -0
- package/dist/CalendarYearDay/CalendarYearDay.d.ts +4 -2
- package/dist/CalendarYearDay/CalendarYearDay.js +10 -42
- package/dist/CalendarYearDay/style.css +65 -117
- package/dist/Checkbox/Checkbox.d.ts +0 -1
- package/dist/Checkbox/Checkbox.js +27 -14
- package/dist/InputField/InputField.js +29 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "./style.css";
|
|
4
|
+
interface Props {
|
|
5
|
+
property1?: "medium" | "small";
|
|
6
|
+
className?: any;
|
|
7
|
+
tertiaryButtonIcon?: React.JSX.Element;
|
|
8
|
+
override?: React.JSX.Element;
|
|
9
|
+
showPrevButton?: boolean;
|
|
10
|
+
showNextButton?: boolean;
|
|
11
|
+
padToSixWeeks?: boolean;
|
|
12
|
+
disableOutsideDays?: boolean;
|
|
13
|
+
month?: number;
|
|
14
|
+
year?: number;
|
|
15
|
+
value?: Date | null;
|
|
16
|
+
onChange?: (date: Date) => void;
|
|
17
|
+
selectionMode?: "single" | "multiple" | "week" | string;
|
|
18
|
+
values?: Date[];
|
|
19
|
+
onChangeMultiple?: (dates: Date[]) => void;
|
|
20
|
+
appointmentDates?: Date[];
|
|
21
|
+
onDaySelection?: (dates: Date[]) => void;
|
|
22
|
+
maxDate?: Date;
|
|
23
|
+
highlightWeekSelection?: boolean;
|
|
24
|
+
selectionVariant?: "single" | "multi" | "week";
|
|
25
|
+
}
|
|
26
|
+
export declare const Calendar: {
|
|
27
|
+
({ property1, className, tertiaryButtonIcon, override, showPrevButton, showNextButton, padToSixWeeks, disableOutsideDays, month, year, value, onChange, selectionMode, values, onChangeMultiple, appointmentDates, onDaySelection, maxDate, highlightWeekSelection, selectionVariant, }: Props): React.JSX.Element;
|
|
28
|
+
propTypes: {
|
|
29
|
+
property1: PropTypes.Requireable<string>;
|
|
30
|
+
divideDashedWrapperDivideHorizontalDivide: PropTypes.Requireable<string>;
|
|
31
|
+
tertiaryButtonIcon: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
32
|
+
override: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
33
|
+
showPrevButton: PropTypes.Requireable<boolean>;
|
|
34
|
+
showNextButton: PropTypes.Requireable<boolean>;
|
|
35
|
+
month: PropTypes.Requireable<number>;
|
|
36
|
+
year: PropTypes.Requireable<number>;
|
|
37
|
+
highlightWeekSelection: PropTypes.Requireable<boolean>;
|
|
38
|
+
selectionVariant: PropTypes.Requireable<string>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { IconChevronRight } from "@tabler/icons-react";
|
|
5
|
+
import { IconChevronLeft } from "@tabler/icons-react";
|
|
6
|
+
import "./style.css";
|
|
7
|
+
import { Label } from "../Label/Label";
|
|
8
|
+
import { TertiaryButton } from "../TertiaryButton/TertiaryButton";
|
|
9
|
+
import { CalendarYearDay } from "../CalendarYearDay/CalendarYearDay";
|
|
10
|
+
const normalizeVariantInput = (value) => {
|
|
11
|
+
if (!value)
|
|
12
|
+
return undefined;
|
|
13
|
+
const normalized = value.toLowerCase();
|
|
14
|
+
if (normalized === "single")
|
|
15
|
+
return "single";
|
|
16
|
+
if (normalized === "multi" || normalized === "multiple")
|
|
17
|
+
return "multi";
|
|
18
|
+
if (normalized === "week" || normalized === "weekly")
|
|
19
|
+
return "week";
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
|
22
|
+
export const Calendar = ({ property1, className, tertiaryButtonIcon = (_jsx(IconChevronLeft, { size: 20, color: "#6D6D6D" })), override = _jsx(IconChevronRight, { size: 20, color: "#6D6D6D" }), showPrevButton = true, showNextButton = true, padToSixWeeks = true, disableOutsideDays = false, month, year, value, onChange, selectionMode, values, onChangeMultiple, appointmentDates = [], onDaySelection, maxDate, highlightWeekSelection = true, selectionVariant, }) => {
|
|
23
|
+
const effectiveVariant = React.useMemo(() => {
|
|
24
|
+
// Accept both selectionVariant and selectionMode, with case-insensitive + legacy aliases
|
|
25
|
+
const fromVariant = normalizeVariantInput(selectionVariant);
|
|
26
|
+
const fromMode = normalizeVariantInput(selectionMode);
|
|
27
|
+
if (fromVariant)
|
|
28
|
+
return fromVariant;
|
|
29
|
+
if (fromMode)
|
|
30
|
+
return fromMode;
|
|
31
|
+
return "multi";
|
|
32
|
+
}, [selectionVariant, selectionMode]);
|
|
33
|
+
const [selectedDay, setSelectedDay] = React.useState(null);
|
|
34
|
+
const [selectedDays, setSelectedDays] = React.useState([]);
|
|
35
|
+
const [selectedWeekRange, setSelectedWeekRange] = React.useState(null);
|
|
36
|
+
const today = new Date();
|
|
37
|
+
const [currentMonth, setCurrentMonth] = React.useState(month ?? today.getMonth());
|
|
38
|
+
const [currentYear, setCurrentYear] = React.useState(year ?? today.getFullYear());
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
if (year !== undefined && year !== currentYear) {
|
|
41
|
+
setCurrentYear(year);
|
|
42
|
+
}
|
|
43
|
+
}, [year]);
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (month !== undefined && month !== currentMonth) {
|
|
46
|
+
setCurrentMonth(month);
|
|
47
|
+
}
|
|
48
|
+
}, [month]);
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (effectiveVariant !== "single")
|
|
51
|
+
return; // ignore single value in other modes
|
|
52
|
+
if (value instanceof Date) {
|
|
53
|
+
setCurrentMonth(value.getMonth());
|
|
54
|
+
setCurrentYear(value.getFullYear());
|
|
55
|
+
setSelectedDay(value.getDate());
|
|
56
|
+
}
|
|
57
|
+
}, [value, effectiveVariant]);
|
|
58
|
+
// Controlled multiple values support (when provided)
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (effectiveVariant !== "multi")
|
|
61
|
+
return;
|
|
62
|
+
if (Array.isArray(values) && values.length > 0) {
|
|
63
|
+
// sync month/year to first value for visibility
|
|
64
|
+
const first = values[0];
|
|
65
|
+
if (first instanceof Date) {
|
|
66
|
+
setCurrentMonth(first.getMonth());
|
|
67
|
+
setCurrentYear(first.getFullYear());
|
|
68
|
+
}
|
|
69
|
+
// take only current month days for highlighting
|
|
70
|
+
const currentMonthDays = values
|
|
71
|
+
.filter(d => d.getFullYear() === currentYear && d.getMonth() === currentMonth)
|
|
72
|
+
.map(d => d.getDate());
|
|
73
|
+
setSelectedDays(currentMonthDays);
|
|
74
|
+
}
|
|
75
|
+
}, [values, currentMonth, currentYear, effectiveVariant]);
|
|
76
|
+
// Notify parent component when selection changes
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
if (onDaySelection) {
|
|
79
|
+
if (selectedDays.length > 0) {
|
|
80
|
+
const dates = selectedDays
|
|
81
|
+
.sort((a, b) => a - b)
|
|
82
|
+
.map(d => new Date(currentYear, currentMonth, d));
|
|
83
|
+
onDaySelection(dates);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
onDaySelection([]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, [selectedDays, currentYear, currentMonth]);
|
|
90
|
+
// Reset selection when variant changes
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (effectiveVariant === "single") {
|
|
93
|
+
setSelectedDays([]);
|
|
94
|
+
setSelectedWeekRange(null);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
setSelectedDay(null);
|
|
98
|
+
if (effectiveVariant !== "week") {
|
|
99
|
+
setSelectedWeekRange(null);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, [effectiveVariant]);
|
|
103
|
+
// Verilen bir tarih için randevu sayısını bul ve badge'e dönüştür
|
|
104
|
+
const getAppointmentCountForDate = (checkDate) => {
|
|
105
|
+
let count = 0;
|
|
106
|
+
for (const appointmentDate of appointmentDates) {
|
|
107
|
+
if (appointmentDate.getFullYear() === checkDate.getFullYear() &&
|
|
108
|
+
appointmentDate.getMonth() === checkDate.getMonth() &&
|
|
109
|
+
appointmentDate.getDate() === checkDate.getDate()) {
|
|
110
|
+
count += 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return count;
|
|
114
|
+
};
|
|
115
|
+
const buildWeekFromDate = React.useCallback((cellDate) => {
|
|
116
|
+
const dayOfWeek = (cellDate.getDay() + 6) % 7; // convert Sunday=0 to Monday=0
|
|
117
|
+
const monday = new Date(cellDate);
|
|
118
|
+
monday.setDate(cellDate.getDate() - dayOfWeek);
|
|
119
|
+
return Array.from({ length: 7 }, (_, i) => new Date(monday.getFullYear(), monday.getMonth(), monday.getDate() + i));
|
|
120
|
+
}, []);
|
|
121
|
+
// Sync week selection when a single value is provided in week mode
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
if (effectiveVariant !== "week")
|
|
124
|
+
return;
|
|
125
|
+
if (!(value instanceof Date))
|
|
126
|
+
return;
|
|
127
|
+
setCurrentMonth(value.getMonth());
|
|
128
|
+
setCurrentYear(value.getFullYear());
|
|
129
|
+
const resolvedWeek = buildWeekFromDate(value);
|
|
130
|
+
const currentMonthDays = resolvedWeek
|
|
131
|
+
.filter((d) => d.getFullYear() === value.getFullYear() && d.getMonth() === value.getMonth())
|
|
132
|
+
.map((d) => d.getDate());
|
|
133
|
+
setSelectedDays(currentMonthDays);
|
|
134
|
+
setSelectedWeekRange({ start: resolvedWeek[0], end: resolvedWeek[resolvedWeek.length - 1] });
|
|
135
|
+
}, [value, effectiveVariant, buildWeekFromDate]);
|
|
136
|
+
const isSameDay = (d1, d2) => d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate();
|
|
137
|
+
const getWeekRangeMeta = React.useCallback((cellDate) => {
|
|
138
|
+
if (!selectedWeekRange)
|
|
139
|
+
return { inRange: false, isStart: false, isEnd: false };
|
|
140
|
+
const { start, end } = selectedWeekRange;
|
|
141
|
+
const time = cellDate.getTime();
|
|
142
|
+
const inRange = time >= start.getTime() && time <= end.getTime();
|
|
143
|
+
const isStart = isSameDay(cellDate, start);
|
|
144
|
+
const isEnd = isSameDay(cellDate, end);
|
|
145
|
+
return { inRange, isStart, isEnd };
|
|
146
|
+
}, [selectedWeekRange]);
|
|
147
|
+
const handleSelectDate = React.useCallback((cellDate, isCurrentMonth, weekDates) => {
|
|
148
|
+
if (disableOutsideDays && !isCurrentMonth)
|
|
149
|
+
return;
|
|
150
|
+
if (maxDate && cellDate > maxDate)
|
|
151
|
+
return;
|
|
152
|
+
if (effectiveVariant === "single") {
|
|
153
|
+
setCurrentMonth(cellDate.getMonth());
|
|
154
|
+
setCurrentYear(cellDate.getFullYear());
|
|
155
|
+
setSelectedDay(cellDate.getDate());
|
|
156
|
+
onChange?.(cellDate);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (effectiveVariant === "week") {
|
|
160
|
+
const resolvedWeek = weekDates ?? buildWeekFromDate(cellDate);
|
|
161
|
+
setCurrentMonth(cellDate.getMonth());
|
|
162
|
+
setCurrentYear(cellDate.getFullYear());
|
|
163
|
+
const currentMonthDays = resolvedWeek
|
|
164
|
+
.filter((d) => d.getFullYear() === cellDate.getFullYear() && d.getMonth() === cellDate.getMonth())
|
|
165
|
+
.map((d) => d.getDate());
|
|
166
|
+
setSelectedDays(currentMonthDays);
|
|
167
|
+
setSelectedWeekRange({ start: resolvedWeek[0], end: resolvedWeek[resolvedWeek.length - 1] });
|
|
168
|
+
onChangeMultiple?.(resolvedWeek);
|
|
169
|
+
onDaySelection?.(resolvedWeek);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// multi
|
|
173
|
+
if (!isCurrentMonth) {
|
|
174
|
+
setCurrentMonth(cellDate.getMonth());
|
|
175
|
+
setCurrentYear(cellDate.getFullYear());
|
|
176
|
+
setSelectedDays([]);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
setSelectedDays((prev) => {
|
|
180
|
+
const dayNum = cellDate.getDate();
|
|
181
|
+
const next = prev.includes(dayNum) ? prev.filter((d) => d !== dayNum) : [...prev, dayNum];
|
|
182
|
+
onChangeMultiple?.(next
|
|
183
|
+
.sort((a, b) => a - b)
|
|
184
|
+
.map((d) => new Date(cellDate.getFullYear(), cellDate.getMonth(), d)));
|
|
185
|
+
return next;
|
|
186
|
+
});
|
|
187
|
+
}, [buildWeekFromDate, disableOutsideDays, effectiveVariant, onChange, onChangeMultiple, onDaySelection, maxDate]);
|
|
188
|
+
const getStatusForDay = (day, cellDate) => {
|
|
189
|
+
if (effectiveVariant === "week" && selectedWeekRange) {
|
|
190
|
+
const { isStart, isEnd } = getWeekRangeMeta(cellDate);
|
|
191
|
+
if (isStart || isEnd)
|
|
192
|
+
return "selected";
|
|
193
|
+
}
|
|
194
|
+
if (day.currentMonth && (selectedDays.includes(day.day) || day.day === selectedDay)) {
|
|
195
|
+
return "selected";
|
|
196
|
+
}
|
|
197
|
+
return "default";
|
|
198
|
+
};
|
|
199
|
+
const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
|
|
200
|
+
const firstDayOfMonth = new Date(currentYear, currentMonth, 1).getDay();
|
|
201
|
+
const emptyDays = (firstDayOfMonth === 0 ? 6 : firstDayOfMonth - 1);
|
|
202
|
+
const monthNames = [
|
|
203
|
+
"Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran",
|
|
204
|
+
"Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
|
|
205
|
+
];
|
|
206
|
+
const prevMonth = () => {
|
|
207
|
+
if (currentMonth === 0) {
|
|
208
|
+
setCurrentMonth(11);
|
|
209
|
+
setCurrentYear(currentYear - 1);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
setCurrentMonth(currentMonth - 1);
|
|
213
|
+
}
|
|
214
|
+
if (effectiveVariant !== "single") {
|
|
215
|
+
setSelectedDays([]);
|
|
216
|
+
setSelectedWeekRange(null);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
setSelectedDay(1);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
const nextMonth = () => {
|
|
223
|
+
if (currentMonth === 11) {
|
|
224
|
+
setCurrentMonth(0);
|
|
225
|
+
setCurrentYear(currentYear + 1);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
setCurrentMonth(currentMonth + 1);
|
|
229
|
+
}
|
|
230
|
+
if (effectiveVariant !== "single") {
|
|
231
|
+
setSelectedDays([]);
|
|
232
|
+
setSelectedWeekRange(null);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
setSelectedDay(1);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const prevMonthDays = new Date(currentYear, currentMonth, 0).getDate(); // önceki ayın son günü
|
|
239
|
+
const weeks = [];
|
|
240
|
+
let currentWeek = [];
|
|
241
|
+
// Ayın başındaki boşlukları önceki ayın günleriyle doldur
|
|
242
|
+
for (let i = emptyDays - 1; i >= 0; i--) {
|
|
243
|
+
currentWeek.push({ day: prevMonthDays - i, currentMonth: false });
|
|
244
|
+
}
|
|
245
|
+
// Günleri ekle
|
|
246
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
247
|
+
currentWeek.push({ day: d, currentMonth: true });
|
|
248
|
+
if (currentWeek.length === 7) {
|
|
249
|
+
weeks.push(currentWeek);
|
|
250
|
+
currentWeek = [];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Son haftayı doldur (sonraki ayın günleriyle)
|
|
254
|
+
let nextDay = 1;
|
|
255
|
+
if (currentWeek.length > 0) {
|
|
256
|
+
while (currentWeek.length < 7) {
|
|
257
|
+
currentWeek.push({ day: nextDay++, currentMonth: false });
|
|
258
|
+
}
|
|
259
|
+
weeks.push(currentWeek);
|
|
260
|
+
}
|
|
261
|
+
// 6 haftaya tamamla (önceki/sonraki ay günleriyle)
|
|
262
|
+
if (padToSixWeeks) {
|
|
263
|
+
while (weeks.length < 6) {
|
|
264
|
+
const newWeek = [];
|
|
265
|
+
for (let i = 0; i < 7; i++) {
|
|
266
|
+
newWeek.push({ day: nextDay++, currentMonth: false });
|
|
267
|
+
}
|
|
268
|
+
weeks.push(newWeek);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// Ensure at least 5 weeks; add extra week(s) only until 5
|
|
273
|
+
while (weeks.length < 5) {
|
|
274
|
+
const newWeek = [];
|
|
275
|
+
for (let i = 0; i < 7; i++) {
|
|
276
|
+
newWeek.push({ day: nextDay++, currentMonth: false });
|
|
277
|
+
}
|
|
278
|
+
weeks.push(newWeek);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return (_jsxs("div", { className: `calendar ${className} ${property1 ? `size-${property1}` : ""}`, children: [_jsxs("div", { className: "top", children: [showPrevButton && (_jsx(TertiaryButton, { color: "black", leftIcon: tertiaryButtonIcon, size: "large", status: "default", onClick: prevMonth, "aria-label": "\u00D6nceki ay" })), _jsxs("div", { className: "label-13", children: [_jsx(Label, { bold: "on", className: "label-14", color: "black", size: "large", spacing: "on", stroke: "off", text: monthNames[currentMonth], version: "primary" }), _jsx(Label, { bold: "on", className: "label-14-year", color: "black", size: "small", spacing: "off", stroke: "off", text: currentYear.toString(), version: "secondary" })] }), showNextButton && (_jsx(TertiaryButton, { color: "black", leftIcon: override, size: "large", status: "default", onClick: nextMonth, "aria-label": "Sonraki ay" }))] }), _jsx("div", { className: "divide-dashed-12" }), _jsxs("div", { className: "days", children: [_jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "Pzt.", version: "primary" }), _jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "Sal.", version: "primary" }), _jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "\u00C7ar.", version: "primary" }), _jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "Per.", version: "primary" }), _jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "Cum.", version: "primary" }), _jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "Cmt.", version: "primary" }), _jsx(Label, { bold: "off", className: "label-15", color: "black", size: "small", spacing: "on", stroke: "off", text: "Pzr.", version: "primary" })] }), _jsx("div", { className: "weeks", children: weeks.map((week, wi) => {
|
|
282
|
+
const isWeekMode = effectiveVariant === "week";
|
|
283
|
+
const weekHasSelection = highlightWeekSelection && !isWeekMode && week.some((d) => d.currentMonth && ((selectedDays || []).includes(d.day) || d.day === selectedDay));
|
|
284
|
+
return (_jsx("div", { className: `week${weekHasSelection ? " selected-week" : ""}${isWeekMode ? " week-mode" : ""}`, children: week.map((day, di) => {
|
|
285
|
+
const cellKey = `w${wi}-d${di}`;
|
|
286
|
+
const isToday = day.currentMonth &&
|
|
287
|
+
day.day === today.getDate() &&
|
|
288
|
+
currentMonth === today.getMonth() &&
|
|
289
|
+
currentYear === today.getFullYear();
|
|
290
|
+
// Hücre için gerçek tarihi hesapla (önceki/sonraki aylar dahil)
|
|
291
|
+
let cellYear = currentYear;
|
|
292
|
+
let cellMonth = currentMonth;
|
|
293
|
+
if (!day.currentMonth) {
|
|
294
|
+
if (wi === 0) {
|
|
295
|
+
// İlk hafta ve mevcut ay dışı ise: önceki ay
|
|
296
|
+
if (currentMonth === 0) {
|
|
297
|
+
cellMonth = 11;
|
|
298
|
+
cellYear = currentYear - 1;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
cellMonth = currentMonth - 1;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
if (currentMonth === 11) {
|
|
306
|
+
cellMonth = 0;
|
|
307
|
+
cellYear = currentYear + 1;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
cellMonth = currentMonth + 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const cellDate = new Date(cellYear, cellMonth, day.day);
|
|
315
|
+
const taskCount = getAppointmentCountForDate(cellDate);
|
|
316
|
+
const weekDates = buildWeekFromDate(cellDate);
|
|
317
|
+
const weekMeta = effectiveVariant === "week" ? getWeekRangeMeta(cellDate) : { inRange: false, isStart: false, isEnd: false };
|
|
318
|
+
const isWeekRangeCell = effectiveVariant === "week" && weekMeta.inRange;
|
|
319
|
+
const isDisabled = !isWeekRangeCell && ((disableOutsideDays && !day.currentMonth) || (maxDate && cellDate > maxDate));
|
|
320
|
+
const status = effectiveVariant === "week" && (weekMeta.isStart || weekMeta.isEnd)
|
|
321
|
+
? "selected"
|
|
322
|
+
: getStatusForDay(day, cellDate);
|
|
323
|
+
return day ? (_jsx("div", { className: `calendar-year-day-clickable${isDisabled ? " disabled" : ""}${weekMeta.inRange ? " week-range" : ""}${weekMeta.isStart ? " week-start" : ""}${weekMeta.isEnd ? " week-end" : ""}`, onClick: () => handleSelectDate(cellDate, day.currentMonth, weekDates), children: _jsx(CalendarYearDay, { className: `calendar-year-day-instance ${day.currentMonth ? 'current-month' : 'other-month'}${isToday ? ' today' : ''}`, size: "medium", status: status, text: day.day.toString(), taskCount: taskCount, version: day.currentMonth ? "month-day" : "different-month-day" }) }, cellKey)) : (_jsx("div", { className: "calendar-year-day-empty" }, cellKey));
|
|
324
|
+
}) }, `week-${wi}`));
|
|
325
|
+
}) })] }));
|
|
326
|
+
};
|
|
327
|
+
Calendar.propTypes = {
|
|
328
|
+
property1: PropTypes.oneOf(["medium"]),
|
|
329
|
+
divideDashedWrapperDivideHorizontalDivide: PropTypes.string,
|
|
330
|
+
tertiaryButtonIcon: PropTypes.element,
|
|
331
|
+
override: PropTypes.element,
|
|
332
|
+
showPrevButton: PropTypes.bool,
|
|
333
|
+
showNextButton: PropTypes.bool,
|
|
334
|
+
month: PropTypes.number,
|
|
335
|
+
year: PropTypes.number,
|
|
336
|
+
highlightWeekSelection: PropTypes.bool,
|
|
337
|
+
selectionVariant: PropTypes.oneOf(["single", "multi", "week"]),
|
|
338
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Calendar } from "./Calendar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Calendar } from "./Calendar";
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
.calendar {
|
|
2
|
+
align-items: flex-start;
|
|
3
|
+
background-color: #ffffff;
|
|
4
|
+
border: 1px solid;
|
|
5
|
+
border-color: #e7e7e7;
|
|
6
|
+
border-radius: 20px;
|
|
7
|
+
box-shadow: var(--drop-shadow-low);
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
flex: 0 0 auto;
|
|
11
|
+
gap: 4px;
|
|
12
|
+
padding: 8px;
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.calendar-year-day-clickable {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.calendar .top {
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
align-self: stretch;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex: 0 0 auto;
|
|
26
|
+
gap: 8px;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
position: relative;
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.divide-dashed-12 {
|
|
33
|
+
align-self: stretch !important;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
width: 100% !important;
|
|
37
|
+
border-top: 1px dashed #E7E7E7;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.calendar .tertiary-button-3 {
|
|
41
|
+
flex: 0 0 auto !important;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.calendar .label-13 {
|
|
47
|
+
align-items: center;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex: 1;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
flex-grow: 1;
|
|
52
|
+
position: relative;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.calendar .label-14 {
|
|
56
|
+
display: flex !important;
|
|
57
|
+
padding: 0 !important;
|
|
58
|
+
|
|
59
|
+
width: 100% !important;
|
|
60
|
+
}
|
|
61
|
+
.calendar .label-14-year {
|
|
62
|
+
align-self: stretch !important;
|
|
63
|
+
display: flex !important;
|
|
64
|
+
flex: 0 0 auto !important;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
width: 100% !important;
|
|
68
|
+
padding: 0 !important;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
.calendar .days {
|
|
73
|
+
align-items: center;
|
|
74
|
+
display: flex;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
position: relative;
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: 20px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.calendar .label-15 {
|
|
82
|
+
flex: 0 0 calc(100% / 7);
|
|
83
|
+
text-align: center;
|
|
84
|
+
display: flex !important;
|
|
85
|
+
width: 38px !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.weeks {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
width: 100%;
|
|
92
|
+
gap: 6px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.calendar .week {
|
|
96
|
+
align-items: center;
|
|
97
|
+
display: grid;
|
|
98
|
+
grid-template-columns: repeat(7, 1fr);
|
|
99
|
+
gap: 4px;
|
|
100
|
+
position: relative;
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: auto;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.calendar .week.week-mode {
|
|
106
|
+
gap: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.calendar .week.selected-week {
|
|
110
|
+
background-color: rgba(113, 163, 13, 0.1);
|
|
111
|
+
border-radius: 8px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.calendar .calendar-year-day-clickable.week-range {
|
|
115
|
+
background-color: rgba(113, 163, 13, 0.1);
|
|
116
|
+
border-radius: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.calendar .calendar-year-day-clickable.week-range .calendar-year-day-instance {
|
|
120
|
+
background: transparent !important;
|
|
121
|
+
border: none !important;
|
|
122
|
+
outline: none !important;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.calendar .calendar-year-day-clickable.week-range .calendar-year-day {
|
|
126
|
+
border: none !important;
|
|
127
|
+
outline: none !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.calendar .calendar-year-day-clickable.week-range .calendar-year-day-label,
|
|
131
|
+
.calendar .calendar-year-day-clickable.week-range .calendar-year-day-label .text-wrapper {
|
|
132
|
+
color: rgba(61, 61, 61, 1) !important;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.calendar .calendar-year-day-clickable.week-range.week-start {
|
|
136
|
+
border-top-left-radius: 10px;
|
|
137
|
+
border-bottom-left-radius: 10px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.calendar .calendar-year-day-clickable.week-range.week-end {
|
|
141
|
+
border-top-right-radius: 10px;
|
|
142
|
+
border-bottom-right-radius: 10px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.calendar .calendar-year-day-clickable.week-range.week-start .calendar-year-day-instance.selected,
|
|
146
|
+
.calendar .calendar-year-day-clickable.week-range.week-end .calendar-year-day-instance.selected {
|
|
147
|
+
background-color: #b1e635 !important;
|
|
148
|
+
border: 1px solid #b1e635 !important;
|
|
149
|
+
color: #1f1f1f !important;
|
|
150
|
+
opacity: 1 !important; /* keep edge days visible even when disabled */
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
.calendar .calendar-year-day-clickable.week-range.week-start .calendar-year-day-instance.selected .calendar-year-day-label,
|
|
155
|
+
.calendar .calendar-year-day-clickable.week-range.week-end .calendar-year-day-instance.selected .calendar-year-day-label {
|
|
156
|
+
color: #1f1f1f !important;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* When a whole week is highlighted, make the selected day blend with the row.
|
|
160
|
+
Keep a subtle border so the selected cell is still noticeable. */
|
|
161
|
+
.calendar .week.selected-week .calendar-year-day-4 {
|
|
162
|
+
background-color: transparent !important;
|
|
163
|
+
border: none !important;
|
|
164
|
+
border-radius: 8px; /* keep radius to match the week */
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
.calendar-year-day,
|
|
169
|
+
.calendar-year-day-empty {
|
|
170
|
+
width: 36px;
|
|
171
|
+
height: 36px;
|
|
172
|
+
display: flex;
|
|
173
|
+
align-items: center;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.calendar .calendar-year-day-instance.selected {
|
|
178
|
+
background-color: #b1e635 !important;
|
|
179
|
+
color: #2f2f2f !important;
|
|
180
|
+
border-radius: 8px;
|
|
181
|
+
border: 1px solid rgba(113, 163, 13, 0.1) !important;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.calendar .calendar-year-day-2 {
|
|
185
|
+
align-self: stretch !important;
|
|
186
|
+
display: flex !important;
|
|
187
|
+
height: 36px !important;
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
width: 100% !important;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
.calendar .calendar-year-day-3 {
|
|
195
|
+
color: #b0b0b0 !important;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.calendar .calendar-year-day-instance.today {
|
|
199
|
+
border: 1px solid rgba(113, 163, 13, 0.2);
|
|
200
|
+
border-radius: 8px;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.calendar .calendar-year-day-4 {
|
|
204
|
+
background-color: #b1e635 !important;
|
|
205
|
+
flex: 1 !important;
|
|
206
|
+
flex-grow: 1 !important;
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
width: unset !important;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
.calendar .icons-9 {
|
|
214
|
+
height: 20px !important;
|
|
215
|
+
position: relative !important;
|
|
216
|
+
width: 20px !important;
|
|
217
|
+
}
|
|
@@ -3,16 +3,18 @@ import "./style.css";
|
|
|
3
3
|
interface Props {
|
|
4
4
|
size: "large" | "medium";
|
|
5
5
|
version: "month-day" | "different-month-day";
|
|
6
|
-
status
|
|
6
|
+
status?: "default" | "selected" | "focus";
|
|
7
7
|
className: any;
|
|
8
8
|
text: string;
|
|
9
|
+
taskCount?: number;
|
|
9
10
|
}
|
|
10
11
|
export declare const CalendarYearDay: {
|
|
11
|
-
({ size, version, status, className, text, }: Props): React.JSX.Element;
|
|
12
|
+
({ size, version, status, className, text, taskCount, }: Props): React.JSX.Element;
|
|
12
13
|
propTypes: {
|
|
13
14
|
size: PropTypes.Requireable<string>;
|
|
14
15
|
version: PropTypes.Requireable<string>;
|
|
15
16
|
status: PropTypes.Requireable<string>;
|
|
17
|
+
taskCount: PropTypes.Requireable<number>;
|
|
16
18
|
};
|
|
17
19
|
};
|
|
18
20
|
export {};
|
|
@@ -1,54 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import "./style.css";
|
|
4
|
-
import { Badge } from "../Badge";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { Badge } from "../Badge/Badge";
|
|
5
|
+
import { Label } from "../Label/Label";
|
|
6
|
+
export const CalendarYearDay = ({ size, version, status, className, text, taskCount, }) => {
|
|
7
|
+
const dayStatus = status ?? "default";
|
|
8
8
|
const getBadgeCount = () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return 1;
|
|
12
|
-
case "two-task":
|
|
13
|
-
return 2;
|
|
14
|
-
case "three-task":
|
|
15
|
-
return 3;
|
|
16
|
-
case "four-task":
|
|
17
|
-
return 4;
|
|
18
|
-
case "five-task":
|
|
19
|
-
return 5;
|
|
20
|
-
default:
|
|
21
|
-
return 0;
|
|
9
|
+
if (typeof taskCount === "number") {
|
|
10
|
+
return Math.max(0, Math.min(taskCount, 5));
|
|
22
11
|
}
|
|
23
|
-
|
|
24
|
-
const getTertiaryButtonClass = () => {
|
|
25
|
-
if (size === "medium") {
|
|
26
|
-
return ["five-task", "focus", "selected"].includes(status) ? "class-5" : "class-3";
|
|
27
|
-
}
|
|
28
|
-
// size === "large"
|
|
29
|
-
if (status === "selected")
|
|
30
|
-
return "class-4";
|
|
31
|
-
if (version === "month-day" && ["five-task", "focus"].includes(status))
|
|
32
|
-
return "class-4";
|
|
33
|
-
return "class-3";
|
|
12
|
+
return 0;
|
|
34
13
|
};
|
|
35
14
|
const badgeCount = getBadgeCount();
|
|
36
|
-
|
|
37
|
-
const tertiaryButtonClass = getTertiaryButtonClass();
|
|
38
|
-
return (_jsxs("div", { className: `calendar-year-day ${status} ${version} size-0-${size} ${className}`, children: [showTertiaryButton && (_jsx(TertiaryButton, { className: tertiaryButtonClass, color: "black", size: size === "medium" ? "medium" : "large", status: version === "different-month-day" ? "disabled" : "default", text: text })), badgeCount > 0 && (_jsx("div", { className: "frame", children: Array.from({ length: badgeCount }).map((_, idx) => (_jsx(Badge, { size: "XX-small", color: "grey", className: "instance-node" }, idx))) })), status === "on-date" && (_jsx(PrimaryButton, { className: `${size === "medium" ? "class-5" : "class-4"}`, color: "black", size: size === "medium" ? "medium" : "large", status: "default", text: text }))] }));
|
|
15
|
+
return (_jsxs("button", { type: "button", "aria-pressed": dayStatus === "selected", className: `calendar-year-day ${dayStatus} ${version} size-0-${size} ${className}`, children: [_jsx(Label, { className: "calendar-year-day-label", bold: "off", color: "black", size: "medium", spacing: "off", stroke: "off", text: text, version: "primary" }), badgeCount > 0 && (_jsx("div", { className: "badge-container", children: Array.from({ length: badgeCount }).map((_, idx) => (_jsx(Badge, { size: "XX-small", color: "grey", className: "instance-node" }, idx))) }))] }));
|
|
39
16
|
};
|
|
40
17
|
CalendarYearDay.propTypes = {
|
|
41
18
|
size: PropTypes.oneOf(["large", "medium"]),
|
|
42
19
|
version: PropTypes.oneOf(["month-day", "different-month-day"]),
|
|
43
|
-
status: PropTypes.oneOf([
|
|
44
|
-
|
|
45
|
-
"non-task",
|
|
46
|
-
"one-task",
|
|
47
|
-
"selected",
|
|
48
|
-
"focus",
|
|
49
|
-
"four-task",
|
|
50
|
-
"three-task",
|
|
51
|
-
"five-task",
|
|
52
|
-
"on-date",
|
|
53
|
-
]),
|
|
20
|
+
status: PropTypes.oneOf(["default", "selected", "focus"]),
|
|
21
|
+
taskCount: PropTypes.number,
|
|
54
22
|
};
|
|
@@ -1,152 +1,100 @@
|
|
|
1
1
|
.calendar-year-day {
|
|
2
|
+
appearance: none;
|
|
2
3
|
align-items: center;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.calendar-year-day .class {
|
|
8
|
-
margin-bottom: -1.00px !important;
|
|
9
|
-
margin-left: -0.50px !important;
|
|
10
|
-
margin-right: -0.50px !important;
|
|
11
|
-
margin-top: -3.00px !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.calendar-year-day .class-2 {
|
|
15
|
-
margin-bottom: -1.00px !important;
|
|
16
|
-
margin-top: -3.00px !important;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.calendar-year-day .class-3 {
|
|
20
|
-
align-self: stretch !important;
|
|
21
|
-
display: flex !important;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.calendar-year-day .class-4 {
|
|
25
|
-
align-self: stretch !important;
|
|
26
|
-
display: flex !important;
|
|
27
|
-
height: 44px !important;
|
|
28
|
-
left: unset !important;
|
|
29
|
-
top: unset !important;
|
|
30
|
-
width: 100% !important;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.calendar-year-day .class-5 {
|
|
34
|
-
align-self: stretch !important;
|
|
35
|
-
display: flex !important;
|
|
36
|
-
height: 36px !important;
|
|
37
|
-
left: unset !important;
|
|
38
|
-
top: unset !important;
|
|
39
|
-
width: 100% !important;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.calendar-year-day .frame {
|
|
43
|
-
align-items: flex-start;
|
|
44
|
-
flex: 0 0 auto;
|
|
45
|
-
gap: 2px;
|
|
46
|
-
position: relative;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.calendar-year-day.non-task {
|
|
50
|
-
justify-content: space-around;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.calendar-year-day.focus {
|
|
54
|
-
border: 1px solid;
|
|
55
|
-
border-radius: 8px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.calendar-year-day.on-date {
|
|
59
|
-
background-color: #e7e7e7;
|
|
60
|
-
border-radius: 8px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.calendar-year-day.month-day {
|
|
64
|
-
display: flex;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.calendar-year-day.size-0-medium {
|
|
68
|
-
display: flex;
|
|
69
|
-
width: 36px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.calendar-year-day.selected {
|
|
73
|
-
background-color: #e7e7e7;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
background-color: transparent;
|
|
6
|
+
border: 1px solid transparent;
|
|
74
7
|
border-radius: 8px;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
background-color: #eeeeee;
|
|
79
|
-
border-color: #b0b0b0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.calendar-year-day.size-0-medium.one-task {
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
font: inherit;
|
|
83
11
|
height: 36px;
|
|
12
|
+
padding: 0;
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 36px;
|
|
15
|
+
transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
|
|
84
16
|
}
|
|
85
17
|
|
|
86
|
-
.calendar-year-day.
|
|
18
|
+
.calendar-year-day.size-0-large {
|
|
87
19
|
height: 44px;
|
|
20
|
+
width: 44px;
|
|
88
21
|
}
|
|
89
22
|
|
|
90
|
-
.calendar-year-day.
|
|
91
|
-
|
|
23
|
+
.calendar-year-day.different-month-day {
|
|
24
|
+
color: #b0b0b0;
|
|
92
25
|
}
|
|
93
26
|
|
|
94
|
-
.calendar-year-day.
|
|
95
|
-
|
|
27
|
+
.calendar-year-day.selected {
|
|
28
|
+
background-color: rgba(177, 230, 53, 1);
|
|
29
|
+
border-color: rgba(177, 230, 53, 1);
|
|
30
|
+
border: 1px solid rgba(113, 163, 13, 0.1) !important;
|
|
31
|
+
color: #1f1f1f;
|
|
96
32
|
}
|
|
97
33
|
|
|
98
|
-
.calendar-year-day.
|
|
99
|
-
background-color: #e7e7e7;
|
|
100
|
-
border-color: #888888;
|
|
101
|
-
}
|
|
34
|
+
.calendar-year-day.selected .text-wrapper {
|
|
102
35
|
|
|
103
|
-
|
|
104
|
-
height: 44px;
|
|
36
|
+
color: rgba(48, 48, 48, 1);
|
|
105
37
|
}
|
|
106
38
|
|
|
107
|
-
.calendar-year-day.
|
|
108
|
-
|
|
39
|
+
.calendar-year-day.focus {
|
|
40
|
+
border-color: #9ad11d;
|
|
109
41
|
}
|
|
110
42
|
|
|
111
|
-
.calendar-year-day.
|
|
112
|
-
|
|
43
|
+
.calendar-year-day.today {
|
|
44
|
+
border-color: rgba(152, 211, 23, 1);
|
|
113
45
|
}
|
|
114
46
|
|
|
115
|
-
.calendar-year-day
|
|
116
|
-
|
|
47
|
+
.calendar-year-day:focus-visible {
|
|
48
|
+
outline: 2px solid rgba(152, 211, 23, 0.6);
|
|
49
|
+
outline-offset: 2px;
|
|
117
50
|
}
|
|
118
51
|
|
|
119
|
-
.calendar-year-day.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
52
|
+
.calendar-year-day .calendar-year-day-label {
|
|
53
|
+
display: flex !important;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
width: 100%;
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
color: #2f2f2f;
|
|
125
59
|
}
|
|
126
60
|
|
|
127
|
-
.calendar-year-day.
|
|
128
|
-
|
|
61
|
+
.calendar-year-day .badge-container {
|
|
62
|
+
position: relative;
|
|
63
|
+
display: flex;
|
|
64
|
+
gap: 2px;
|
|
129
65
|
}
|
|
130
66
|
|
|
131
|
-
.calendar-year-day.
|
|
132
|
-
|
|
67
|
+
.calendar-year-day .badge-container .instance-node {
|
|
68
|
+
width: 4px !important;
|
|
69
|
+
height: 4px !important;
|
|
70
|
+
min-width: 4px !important;
|
|
71
|
+
min-height: 4px !important;
|
|
72
|
+
max-width: 4px !important;
|
|
73
|
+
max-height: 4px !important;
|
|
74
|
+
border-radius: 50% !important;
|
|
75
|
+
background-color: rgba(61, 61, 61, 1) !important;
|
|
76
|
+
padding: 0 !important;
|
|
77
|
+
border: none !important;
|
|
78
|
+
box-sizing: border-box !important;
|
|
79
|
+
display: block !important;
|
|
80
|
+
transform: none !important;
|
|
81
|
+
scale: 1 !important;
|
|
82
|
+
line-height: 4px !important;
|
|
83
|
+
font-size: 0 !important;
|
|
133
84
|
}
|
|
134
85
|
|
|
135
|
-
.calendar-year-day.
|
|
136
|
-
|
|
86
|
+
.calendar-year-day.different-month-day .badge-container .instance-node {
|
|
87
|
+
background-color: rgba(209, 209, 209, 1) !important;
|
|
137
88
|
}
|
|
138
89
|
|
|
139
|
-
.calendar-year-day.
|
|
140
|
-
|
|
90
|
+
.calendar-year-day.different-month-day {
|
|
91
|
+
cursor: default;
|
|
141
92
|
}
|
|
142
93
|
|
|
143
|
-
.calendar-year-day.
|
|
144
|
-
|
|
94
|
+
.calendar-year-day.different-month-day .calendar-year-day-label .text-wrapper {
|
|
95
|
+
color: #b0b0b0;
|
|
145
96
|
}
|
|
146
97
|
|
|
147
|
-
.calendar-year-day.
|
|
148
|
-
|
|
149
|
-
display: flex;
|
|
150
|
-
justify-content: center;
|
|
151
|
-
width: 100%;
|
|
98
|
+
.calendar-year-day.selected .calendar-year-day-label {
|
|
99
|
+
color: #1a1a1a;
|
|
152
100
|
}
|
|
@@ -14,7 +14,6 @@ export declare const Checkbox: {
|
|
|
14
14
|
({ text, size, status, color, className, fieldClassName, onClick, onChange, }: Props): React.JSX.Element;
|
|
15
15
|
propTypes: {
|
|
16
16
|
text: PropTypes.Requireable<string>;
|
|
17
|
-
withText: PropTypes.Requireable<boolean>;
|
|
18
17
|
size: PropTypes.Requireable<string>;
|
|
19
18
|
status: PropTypes.Requireable<string>;
|
|
20
19
|
color: PropTypes.Requireable<string>;
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import { useReducer } from "react";
|
|
3
|
+
import { useReducer, useEffect } from "react";
|
|
4
4
|
import "./style.css";
|
|
5
5
|
import { IconCheck } from "@tabler/icons-react";
|
|
6
|
-
export const Checkbox = ({ text, size, status, color, className, fieldClassName, onClick, onChange, }) => {
|
|
7
|
-
const
|
|
6
|
+
export const Checkbox = ({ text, size, status, color, className = "", fieldClassName = "", onClick, onChange, }) => {
|
|
7
|
+
const [state, dispatch] = useReducer(reducer, {
|
|
8
8
|
size: size ?? "large",
|
|
9
|
-
status: status ?? "
|
|
9
|
+
status: status ?? "default",
|
|
10
10
|
color: color ?? "black",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
});
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
dispatch({
|
|
14
|
+
type: "sync",
|
|
15
|
+
payload: {
|
|
16
|
+
size: size ?? "large",
|
|
17
|
+
status: status ?? "default",
|
|
18
|
+
color: color ?? "black",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}, [size, status, color]);
|
|
22
|
+
return (_jsxs("div", { className: `checkbox ${state.size} ${state.color} ${state.status} ${className}`, onMouseEnter: () => dispatch("mouse_enter"), onMouseLeave: () => dispatch("mouse_leave"), onClick: () => {
|
|
23
|
+
if (status === undefined) {
|
|
24
|
+
dispatch("click");
|
|
25
|
+
}
|
|
19
26
|
onClick?.();
|
|
20
27
|
onChange?.();
|
|
21
|
-
}, children: [_jsx("div", { className: `field ${fieldClassName}`, children: state.status === "selected" && (_jsx(IconCheck, { className:
|
|
28
|
+
}, children: [_jsx("div", { className: `field ${fieldClassName}`, children: state.status === "selected" && (_jsx(IconCheck, { className: state.size === "large"
|
|
29
|
+
? "class"
|
|
30
|
+
: state.size === "x-small"
|
|
31
|
+
? "class-2"
|
|
32
|
+
: "class-3", color: ["lime", "mauve"].includes(state.color) ? "#3D3D3D" : "#F1F1F1" })) }), text && _jsx("div", { className: "text", children: text })] }));
|
|
22
33
|
};
|
|
23
34
|
function reducer(state, action) {
|
|
35
|
+
if (typeof action === "object" && action.type === "sync") {
|
|
36
|
+
return { ...state, ...action.payload };
|
|
37
|
+
}
|
|
24
38
|
switch (action) {
|
|
25
39
|
case "mouse_enter":
|
|
26
40
|
return state.status === "default" ? { ...state, status: "hover" } : state;
|
|
@@ -34,7 +48,6 @@ function reducer(state, action) {
|
|
|
34
48
|
}
|
|
35
49
|
Checkbox.propTypes = {
|
|
36
50
|
text: PropTypes.string,
|
|
37
|
-
withText: PropTypes.bool,
|
|
38
51
|
size: PropTypes.oneOf(["large", "x-small", "medium", "small"]),
|
|
39
52
|
status: PropTypes.oneOf(["default", "selected", "hover"]),
|
|
40
53
|
color: PropTypes.oneOf(["mauve", "lime", "black", "blue", "galliano", "red"]),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import React, { useReducer, useRef, useState } from "react";
|
|
3
|
+
import React, { useEffect, useReducer, useRef, useState } from "react";
|
|
4
4
|
import "./style.css";
|
|
5
5
|
import { IconEyeOff, IconEye, IconX, IconAlertSquareRounded } from "@tabler/icons-react";
|
|
6
6
|
const initialState = (size, status, radius) => ({
|
|
@@ -17,6 +17,8 @@ const reducer = (state, action) => {
|
|
|
17
17
|
return { size, radius, status: "active" };
|
|
18
18
|
case "mouse_leave":
|
|
19
19
|
return { ...state, status: "default" };
|
|
20
|
+
case "set_active":
|
|
21
|
+
return { size, radius, status: "active" };
|
|
20
22
|
default:
|
|
21
23
|
return state;
|
|
22
24
|
}
|
|
@@ -25,6 +27,7 @@ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, left
|
|
|
25
27
|
const [state, dispatch] = useReducer(reducer, initialState(size, status, radius));
|
|
26
28
|
const [inputValue, setInputValue] = useState(defaultValue);
|
|
27
29
|
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
30
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
28
31
|
const containerRef = useRef(null);
|
|
29
32
|
const isControlled = value !== undefined;
|
|
30
33
|
const handleInputChange = (event) => {
|
|
@@ -41,6 +44,22 @@ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, left
|
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
46
|
const currentValue = isControlled ? value : inputValue;
|
|
47
|
+
const hasValue = !!currentValue && currentValue.length > 0;
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (hasValue && isFocused && state.status !== "active" && state.status !== "disabled") {
|
|
50
|
+
dispatch("set_active");
|
|
51
|
+
}
|
|
52
|
+
}, [hasValue, isFocused, state.status]);
|
|
53
|
+
const handleFocusInternal = (event) => {
|
|
54
|
+
setIsFocused(true);
|
|
55
|
+
dispatch("set_active");
|
|
56
|
+
onFocus?.(event);
|
|
57
|
+
};
|
|
58
|
+
const handleBlurInternal = (event) => {
|
|
59
|
+
setIsFocused(false);
|
|
60
|
+
dispatch("mouse_leave");
|
|
61
|
+
onBlur?.(event);
|
|
62
|
+
};
|
|
44
63
|
const handleClear = () => {
|
|
45
64
|
if (isControlled) {
|
|
46
65
|
onClear?.();
|
|
@@ -55,7 +74,15 @@ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, left
|
|
|
55
74
|
onRequestPopupOpen?.(containerRef.current);
|
|
56
75
|
};
|
|
57
76
|
// selection is handled by parent when using external popup
|
|
58
|
-
return (_jsxs("div", { className: `input-field size-2-${state.size} ${className}`, ref: containerRef, onMouseLeave: () =>
|
|
77
|
+
return (_jsxs("div", { className: `input-field size-2-${state.size} ${className}`, ref: containerRef, onMouseLeave: () => {
|
|
78
|
+
if (hasValue && isFocused)
|
|
79
|
+
return;
|
|
80
|
+
dispatch("mouse_leave");
|
|
81
|
+
}, onMouseEnter: () => {
|
|
82
|
+
if (hasValue && isFocused)
|
|
83
|
+
return;
|
|
84
|
+
dispatch("mouse_enter");
|
|
85
|
+
}, onClick: () => dispatch("click"), children: [withHeader && (_jsx("div", { className: `frame ${["active", "default", "disabled", "hover"].includes(state.status) ? frameClassName : ""}`, children: _jsx("div", { className: `label-2 ${state.status}`, children: headerText }) })), _jsxs("div", { className: `input-fields size-4-${state.size} status-0-${state.status}`, onClick: toggleDropdown, children: [leftIcon && React.cloneElement(leftIcon, { color: getStatusColor(state.status) }), _jsx("input", { type: isPassword ? (isPasswordVisible ? "text" : "password") : "text", placeholder: text, value: currentValue, onChange: handleInputChange, onFocus: handleFocusInternal, onBlur: handleBlurInternal, onKeyDown: onKeyDown, className: `input-field-placeholder size-${state.size} ${state.status === "alert" ? "alert" : ""}`, style: {
|
|
59
86
|
backgroundColor: "transparent",
|
|
60
87
|
border: "none",
|
|
61
88
|
flex: 1,
|
package/dist/index.d.ts
CHANGED
|
@@ -40,3 +40,4 @@ export { InfoTooltip } from "./InfoTooltip/InfoTooltip";
|
|
|
40
40
|
export { ColorFlag } from "./ColorFlag/ColorFlag";
|
|
41
41
|
export { CallCenterTasks } from "./CallCenterTasks/CallCenterTasks";
|
|
42
42
|
export { Breadcrumbs } from "./Breadcrumbs/Breadcrumbs";
|
|
43
|
+
export { Calendar } from "./Calendar/Calendar";
|
package/dist/index.js
CHANGED
|
@@ -40,3 +40,4 @@ export { InfoTooltip } from "./InfoTooltip/InfoTooltip";
|
|
|
40
40
|
export { ColorFlag } from "./ColorFlag/ColorFlag";
|
|
41
41
|
export { CallCenterTasks } from "./CallCenterTasks/CallCenterTasks";
|
|
42
42
|
export { Breadcrumbs } from "./Breadcrumbs/Breadcrumbs";
|
|
43
|
+
export { Calendar } from "./Calendar/Calendar";
|