funda-ui 4.3.355 → 4.3.721
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/DynamicFields/index.d.ts +1 -0
- package/DynamicFields/index.js +23 -3
- package/EventCalendar/index.css +150 -106
- package/EventCalendar/index.d.ts +11 -2
- package/EventCalendar/index.js +835 -151
- package/EventCalendarTimeline/index.css +293 -251
- package/EventCalendarTimeline/index.d.ts +18 -9
- package/EventCalendarTimeline/index.js +1077 -505
- package/MultipleCheckboxes/index.d.ts +1 -0
- package/MultipleCheckboxes/index.js +17 -7
- package/MultipleSelect/index.d.ts +4 -0
- package/MultipleSelect/index.js +54 -8
- package/NativeSelect/index.js +1 -0
- package/Radio/index.d.ts +2 -1
- package/Radio/index.js +54 -24
- package/Select/index.js +115 -42
- package/Table/index.js +27 -3
- package/lib/cjs/DynamicFields/index.d.ts +1 -0
- package/lib/cjs/DynamicFields/index.js +23 -3
- package/lib/cjs/EventCalendar/index.d.ts +11 -2
- package/lib/cjs/EventCalendar/index.js +835 -151
- package/lib/cjs/EventCalendarTimeline/index.d.ts +18 -9
- package/lib/cjs/EventCalendarTimeline/index.js +1077 -505
- package/lib/cjs/MultipleCheckboxes/index.d.ts +1 -0
- package/lib/cjs/MultipleCheckboxes/index.js +17 -7
- package/lib/cjs/MultipleSelect/index.d.ts +4 -0
- package/lib/cjs/MultipleSelect/index.js +54 -8
- package/lib/cjs/NativeSelect/index.js +1 -0
- package/lib/cjs/Radio/index.d.ts +2 -1
- package/lib/cjs/Radio/index.js +54 -24
- package/lib/cjs/Select/index.js +115 -42
- package/lib/cjs/Table/index.js +27 -3
- package/lib/css/EventCalendar/index.css +150 -106
- package/lib/css/EventCalendarTimeline/index.css +293 -251
- package/lib/esm/DynamicFields/index.tsx +28 -3
- package/lib/esm/EventCalendar/index.scss +172 -104
- package/lib/esm/EventCalendar/index.tsx +272 -139
- package/lib/esm/EventCalendarTimeline/index.scss +275 -213
- package/lib/esm/EventCalendarTimeline/index.tsx +706 -708
- package/lib/esm/MultipleCheckboxes/index.tsx +18 -5
- package/lib/esm/MultipleSelect/ItemList.tsx +1 -0
- package/lib/esm/MultipleSelect/index.tsx +103 -52
- package/lib/esm/NativeSelect/index.tsx +2 -0
- package/lib/esm/Radio/index.tsx +68 -27
- package/lib/esm/Select/index.tsx +236 -65
- package/lib/esm/Table/Table.tsx +1 -0
- package/lib/esm/Table/TableCell.tsx +6 -0
- package/lib/esm/Table/table-utils/ToggleSelection.tsx +17 -2
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { useState, useEffect, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
2
2
|
|
|
3
|
+
import { getTodayDate, getCalendarDate, isValidDate, padZero } from 'funda-utils/dist/cjs/date';
|
|
3
4
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
4
5
|
import ModalDialog from 'funda-modaldialog';
|
|
5
6
|
|
|
@@ -11,10 +12,16 @@ export interface EventsValueConfig {
|
|
|
11
12
|
time: string,
|
|
12
13
|
data: string,
|
|
13
14
|
eventStyles?: React.CSSProperties;
|
|
15
|
+
callback?: () => void;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
export interface TimelineCellListConfig {
|
|
19
|
+
date: string;
|
|
20
|
+
list: EventsValueConfig[];
|
|
21
|
+
}
|
|
16
22
|
|
|
17
23
|
export type EventCalendarProps = {
|
|
24
|
+
contentRef?: React.ForwardedRef<any>;
|
|
18
25
|
calendarWrapperClassName?: string;
|
|
19
26
|
customTodayDate?: string;
|
|
20
27
|
eventsValue?: any[];
|
|
@@ -24,8 +31,11 @@ export type EventCalendarProps = {
|
|
|
24
31
|
langMonthsFull?: string[];
|
|
25
32
|
langToday?: string;
|
|
26
33
|
iconRemove?: React.ReactNode | string;
|
|
34
|
+
iconAdd?: React.ReactNode | string;
|
|
27
35
|
cellCloseBtnClassName?: string;
|
|
28
36
|
cellCloseBtnLabel?: string | React.ReactNode;
|
|
37
|
+
cellAddBtnClassName?: string;
|
|
38
|
+
cellAddBtnLabel?: string | React.ReactNode;
|
|
29
39
|
onChangeDate?: (e: any, currentData: any) => void;
|
|
30
40
|
onChangeMonth?: (currentData: any) => void;
|
|
31
41
|
onChangeYear?: (currentData: any) => void;
|
|
@@ -45,9 +55,9 @@ export type EventCalendarProps = {
|
|
|
45
55
|
modalSubmitBtnLabel?: string | React.ReactNode;
|
|
46
56
|
modalSubmitDeleteBtnClassName?: string;
|
|
47
57
|
modalSubmitDeleteBtnLabel?: string | React.ReactNode;
|
|
48
|
-
onModalEditOpen?: (currentData: any, openwin: any) => void;
|
|
58
|
+
onModalEditOpen?: (currentData: any, openwin: any, type: 'normal' | 'new') => void;
|
|
49
59
|
onModalEditClose?: (currentData: any) => void;
|
|
50
|
-
onModalDeleteOpen?: (currentData: any) => void;
|
|
60
|
+
onModalDeleteOpen?: (currentData: any, openwin: any) => void;
|
|
51
61
|
onModalDeleteClose?: (currentData: any) => void;
|
|
52
62
|
onModalEditEvent?: (currentData: any, closewin: any) => void;
|
|
53
63
|
onModalDeleteEvent?: (currentData: any, closewin: any) => void;
|
|
@@ -62,6 +72,7 @@ export type EventCalendarProps = {
|
|
|
62
72
|
|
|
63
73
|
const EventCalendar = (props: EventCalendarProps) => {
|
|
64
74
|
const {
|
|
75
|
+
contentRef,
|
|
65
76
|
calendarWrapperClassName,
|
|
66
77
|
customTodayDate,
|
|
67
78
|
eventsValue,
|
|
@@ -70,7 +81,6 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
70
81
|
langMonths,
|
|
71
82
|
langMonthsFull,
|
|
72
83
|
langToday,
|
|
73
|
-
iconRemove,
|
|
74
84
|
onChangeDate,
|
|
75
85
|
onChangeMonth,
|
|
76
86
|
onChangeYear,
|
|
@@ -78,8 +88,12 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
78
88
|
onListRenderComplete,
|
|
79
89
|
|
|
80
90
|
//
|
|
91
|
+
iconRemove,
|
|
92
|
+
iconAdd,
|
|
81
93
|
cellCloseBtnClassName,
|
|
82
94
|
cellCloseBtnLabel,
|
|
95
|
+
cellAddBtnClassName,
|
|
96
|
+
cellAddBtnLabel,
|
|
83
97
|
|
|
84
98
|
//
|
|
85
99
|
modalMaskOpacity,
|
|
@@ -114,7 +128,7 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
114
128
|
const MONTHS = langMonths || ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
|
|
115
129
|
const MONTHS_FULL = langMonthsFull || ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
116
130
|
|
|
117
|
-
const [val, setVal] = useState<
|
|
131
|
+
const [val, setVal] = useState<TimelineCellListConfig[]>([]);
|
|
118
132
|
|
|
119
133
|
const now = useMemo(() => new Date(), []);
|
|
120
134
|
const [date, setDate] = useState<Date>(now);
|
|
@@ -136,31 +150,70 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
136
150
|
|
|
137
151
|
// modal dialog
|
|
138
152
|
const EVENTS_ENABLED = typeof modalContent !== 'undefined';
|
|
153
|
+
const EVENTS_DELETE_ENABLED = typeof modalDeleteContent !== 'undefined';
|
|
139
154
|
const [showEdit, setShowEdit] = useState<boolean>(false);
|
|
140
155
|
const [showDelete, setShowDelete] = useState<boolean>(false);
|
|
141
156
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
// Open temporary storage for pop-ups
|
|
158
|
+
const [tableCellId, setTableCellId] = useState<number>(-1);
|
|
159
|
+
|
|
160
|
+
// exposes the following methods
|
|
161
|
+
useImperativeHandle(
|
|
162
|
+
contentRef,
|
|
163
|
+
() => ({
|
|
164
|
+
gridInit: () => {
|
|
165
|
+
|
|
166
|
+
},
|
|
167
|
+
gridReset: (cb?: any) => {
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
[contentRef],
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
// helper buttons
|
|
176
|
+
const _delBtn = () => <>
|
|
177
|
+
{iconRemove ? <>{iconRemove}</> : <><svg width="20px" height="20px" viewBox="0 0 24 24" fill="none"><path fillRule="evenodd" clipRule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10ZM8 11a1 1 0 1 0 0 2h8a1 1 0 1 0 0-2H8Z" fill="#000" /></svg></>}
|
|
178
|
+
{cellCloseBtnLabel || ''}
|
|
179
|
+
</>;
|
|
180
|
+
|
|
181
|
+
const _addBtn = () => <>
|
|
182
|
+
{iconAdd ? <>{iconAdd}</> : <><svg width="20px" height="20px" viewBox="0 0 32 32"><g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd"><g transform="translate(-102.000000, -1037.000000)" fill="#000000"><path d="M124,1054 L119,1054 L119,1059 C119,1059.55 118.552,1060 118,1060 C117.448,1060 117,1059.55 117,1059 L117,1054 L112,1054 C111.448,1054 111,1053.55 111,1053 C111,1052.45 111.448,1052 112,1052 L117,1052 L117,1047 C117,1046.45 117.448,1046 118,1046 C118.552,1046 119,1046.45 119,1047 L119,1052 L124,1052 C124.552,1052 125,1052.45 125,1053 C125,1053.55 124.552,1054 124,1054 L124,1054 Z M130,1037 L106,1037 C103.791,1037 102,1038.79 102,1041 L102,1065 C102,1067.21 103.791,1069 106,1069 L130,1069 C132.209,1069 134,1067.21 134,1065 L134,1041 C134,1038.79 132.209,1037 130,1037 L130,1037 Z"></path></g></g></svg></>}
|
|
183
|
+
{cellAddBtnLabel || ''}
|
|
184
|
+
</>;
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
const queryItemObj = () => {
|
|
189
|
+
const _perData = val.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(`${year}-${month + 1}-${day}`));
|
|
190
|
+
|
|
191
|
+
let _currentData: any = undefined;
|
|
192
|
+
if (_perData[0]) {
|
|
193
|
+
const _items = _perData[0].list;
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if (tableCellId === -1) {
|
|
197
|
+
// add new
|
|
198
|
+
_currentData = {
|
|
199
|
+
id: 0,
|
|
200
|
+
date: getCalendarDate(`${year}-${month + 1}-${day}`)
|
|
201
|
+
};
|
|
202
|
+
} else {
|
|
203
|
+
// edit or delete
|
|
204
|
+
_currentData = _items.filter((item: any) => item.id == tableCellId)[0];
|
|
205
|
+
}
|
|
206
|
+
|
|
147
207
|
}
|
|
148
208
|
|
|
209
|
+
return _perData[0] ? _currentData : {
|
|
210
|
+
id: 0,
|
|
211
|
+
date: getCalendarDate(`${year}-${month + 1}-${day}`)
|
|
212
|
+
};
|
|
149
213
|
};
|
|
150
214
|
|
|
151
|
-
const isValidDate = (v: string) => {
|
|
152
|
-
return !(String(new window.Date(v) as any).toLowerCase() === 'invalid date');
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const dateFormat = (v: Date | String) => {
|
|
156
|
-
const date = typeof v === 'string' ? new window.Date(v.replace(/-/g, "/")) : v; // fix "Invalid date in safari"
|
|
157
|
-
return date;
|
|
158
|
-
};
|
|
159
215
|
|
|
160
|
-
|
|
161
|
-
return getCalendarDate(new Date() as any);
|
|
162
|
-
};
|
|
163
|
-
|
|
216
|
+
|
|
164
217
|
|
|
165
218
|
// cell
|
|
166
219
|
const getCells = (type: 'none' | 'forward' | 'back' = 'none') => {
|
|
@@ -239,29 +292,6 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
239
292
|
};
|
|
240
293
|
|
|
241
294
|
|
|
242
|
-
function getCalendarDate(v: string, padZeroEnabled: boolean = true) {
|
|
243
|
-
if (typeof v === 'undefined') return '';
|
|
244
|
-
|
|
245
|
-
// yyyy-MM-dd
|
|
246
|
-
const date = typeof v === 'string' ? new Date(v.replace(/-/g, "/")) : v; // fix "Invalid date in safari"
|
|
247
|
-
const padZero = (num: number): string => {
|
|
248
|
-
if (padZeroEnabled) {
|
|
249
|
-
return num < 10 ? '0' + num : num.toString();
|
|
250
|
-
} else {
|
|
251
|
-
return num.toString();
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
};
|
|
255
|
-
const year = date.getFullYear();
|
|
256
|
-
const month = padZero(date.getMonth() + 1);
|
|
257
|
-
const day = padZero(date.getDate());
|
|
258
|
-
const hours = padZero(date.getHours());
|
|
259
|
-
const minutes = padZero(date.getMinutes());
|
|
260
|
-
const res = `${year}-${month}-${day}`;
|
|
261
|
-
return res;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
295
|
function setTodayDate(inputDate: Date) {
|
|
266
296
|
setDay(inputDate.getDate());
|
|
267
297
|
setMonth(inputDate.getMonth());
|
|
@@ -436,47 +466,52 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
436
466
|
<>
|
|
437
467
|
|
|
438
468
|
<div className={combinedCls(
|
|
439
|
-
"e-
|
|
469
|
+
"e-cal-normal__wrapper",
|
|
440
470
|
calendarWrapperClassName
|
|
441
471
|
)}>
|
|
442
472
|
|
|
443
473
|
|
|
444
474
|
{/*++++++++++++++++ MAIN ++++++++++++++++*/}
|
|
445
|
-
<div className="e-
|
|
446
|
-
<button tabIndex={-1} type="button" className="e-
|
|
475
|
+
<div className="e-cal-normal__header bg-body-tertiary">
|
|
476
|
+
<button tabIndex={-1} type="button" className="e-cal-normal__btn e-cal-normal__btn--prev" onClick={handlePrevChange}>
|
|
447
477
|
<svg width="20px" height="20px" viewBox="0 0 24 24" fill="none">
|
|
448
478
|
<path d="M14.2893 5.70708C13.8988 5.31655 13.2657 5.31655 12.8751 5.70708L7.98768 10.5993C7.20729 11.3805 7.2076 12.6463 7.98837 13.427L12.8787 18.3174C13.2693 18.7079 13.9024 18.7079 14.293 18.3174C14.6835 17.9269 14.6835 17.2937 14.293 16.9032L10.1073 12.7175C9.71678 12.327 9.71678 11.6939 10.1073 11.3033L14.2893 7.12129C14.6799 6.73077 14.6799 6.0976 14.2893 5.70708Z" fill="#000" />
|
|
449
479
|
</svg>
|
|
450
480
|
</button>
|
|
451
|
-
<div className="e-
|
|
452
|
-
<button tabIndex={-1} type="button" className={`e-
|
|
481
|
+
<div className="e-cal-normal__header__btns">
|
|
482
|
+
<button tabIndex={-1} type="button" className={`e-cal-normal__btn ${winMonth ? 'active' : ''}`} onClick={handleShowWinMonth}>
|
|
453
483
|
{MONTHS[month]}
|
|
454
484
|
<svg width="12px" height="12px" viewBox="0 0 24 24"><path d="M11.178 19.569a.998.998 0 0 0 1.644 0l9-13A.999.999 0 0 0 21 5H3a1.002 1.002 0 0 0-.822 1.569l9 13z" fill="#000000" /></svg>
|
|
455
485
|
</button>
|
|
456
|
-
<button tabIndex={-1} type="button" className={`e-
|
|
486
|
+
<button tabIndex={-1} type="button" className={`e-cal-normal__btn ${winYear ? 'active' : ''}`} onClick={handleShowWinYear}>
|
|
457
487
|
{year}
|
|
458
488
|
<svg width="12px" height="12px" viewBox="0 0 24 24"><path d="M11.178 19.569a.998.998 0 0 0 1.644 0l9-13A.999.999 0 0 0 21 5H3a1.002 1.002 0 0 0-.822 1.569l9 13z" fill="#000000" /></svg>
|
|
459
489
|
</button>
|
|
460
490
|
</div>
|
|
461
|
-
<button tabIndex={-1} type="button" className="e-
|
|
491
|
+
<button tabIndex={-1} type="button" className="e-cal-normal__btn e-cal-normal__btn--next" onClick={handleNextChange}>
|
|
462
492
|
<svg width="20px" height="20px" viewBox="0 0 24 24" fill="none">
|
|
463
493
|
<path d="M9.71069 18.2929C10.1012 18.6834 10.7344 18.6834 11.1249 18.2929L16.0123 13.4006C16.7927 12.6195 16.7924 11.3537 16.0117 10.5729L11.1213 5.68254C10.7308 5.29202 10.0976 5.29202 9.70708 5.68254C9.31655 6.07307 9.31655 6.70623 9.70708 7.09676L13.8927 11.2824C14.2833 11.6729 14.2833 12.3061 13.8927 12.6966L9.71069 16.8787C9.32016 17.2692 9.32016 17.9023 9.71069 18.2929Z" fill="#000" />
|
|
464
494
|
</svg>
|
|
465
495
|
</button>
|
|
466
496
|
</div>
|
|
467
|
-
<div className="e-
|
|
497
|
+
<div className="e-cal-normal__body">
|
|
468
498
|
|
|
469
499
|
{/* week */}
|
|
470
|
-
<div className="e-
|
|
500
|
+
<div className="e-cal-normal__row">
|
|
471
501
|
{WEEK.map((s: string, i: number) => (
|
|
472
|
-
<div
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
502
|
+
<div
|
|
503
|
+
className={combinedCls(
|
|
504
|
+
'e-cal-normal__cell e-cal-normal__day e-cal-normal__day--week e-cal-normal__day--disabled bg-secondary-subtle empty',
|
|
505
|
+
{
|
|
506
|
+
'last-cell': i === WEEK.length-1
|
|
507
|
+
}
|
|
508
|
+
)}
|
|
509
|
+
key={i}
|
|
510
|
+
data-week={i}
|
|
511
|
+
dangerouslySetInnerHTML={{
|
|
512
|
+
__html: s
|
|
513
|
+
}}
|
|
514
|
+
/>
|
|
480
515
|
))}
|
|
481
516
|
</div>
|
|
482
517
|
{/* /week */}
|
|
@@ -494,17 +529,21 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
494
529
|
const __backFillNum: number[] = getBackFill();
|
|
495
530
|
|
|
496
531
|
|
|
497
|
-
return <div key={'row' + item.row} className="e-
|
|
532
|
+
return <div key={'row' + item.row} className="e-cal-normal__row">
|
|
498
533
|
{item.col.map((dayIndex: number | null, i: number) => {
|
|
499
534
|
const d = typeof dayIndex === 'number' ? dayIndex - (startDay - 2) : 0;
|
|
500
535
|
const _currentData = val.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(`${year}-${month + 1}-${d}`));
|
|
501
536
|
const isLastCol = i === item.col.length-1;
|
|
502
537
|
|
|
503
|
-
|
|
538
|
+
|
|
504
539
|
// date
|
|
505
540
|
let _dateShow = d > 0 ? `${year}-${month+1}-${d}` : '';
|
|
506
541
|
|
|
507
|
-
|
|
542
|
+
const isForward = isFirstRow && __forwardFillNum && typeof __forwardFillNum[i] !== 'undefined';
|
|
543
|
+
const isBack = isLastRow && __backFillNum && typeof __backFillNum[i - item.col.filter(Boolean).length] !== 'undefined';
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
if (isForward && _dateShow === '') {
|
|
508
547
|
if (month + 1 === 1) {
|
|
509
548
|
_dateShow = `${year-1}-12-${__forwardFillNum[i]}`;
|
|
510
549
|
} else {
|
|
@@ -512,18 +551,125 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
512
551
|
}
|
|
513
552
|
}
|
|
514
553
|
|
|
515
|
-
if (
|
|
554
|
+
if (isBack && _dateShow === '') {
|
|
516
555
|
if (month + 1 === 12) {
|
|
517
556
|
_dateShow = `${year+1}-1-${__backFillNum[i-item.col.filter(Boolean).length]}`;
|
|
518
557
|
} else {
|
|
519
558
|
_dateShow = `${year}-${month + 2}-${__backFillNum[i-item.col.filter(Boolean).length]}`;
|
|
520
559
|
}
|
|
521
560
|
}
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
const _eventContent = () => {
|
|
564
|
+
|
|
565
|
+
if (
|
|
566
|
+
_currentData.length === 0 ||
|
|
567
|
+
!Array.isArray(_currentData) ||
|
|
568
|
+
typeof _currentData[0].list === 'undefined'
|
|
569
|
+
) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
//
|
|
574
|
+
const _items = _currentData[0].list;
|
|
575
|
+
|
|
576
|
+
return _items.map((cellItem: any, cellItemIndex: number) => {
|
|
577
|
+
|
|
578
|
+
return <div
|
|
579
|
+
className={combinedCls(
|
|
580
|
+
`e-cal-normal__cell-item e-cal-normal__cell-item-${cellItemIndex}`,
|
|
581
|
+
{
|
|
582
|
+
'first': cellItemIndex === 0,
|
|
583
|
+
'last': cellItemIndex === _items.length-1
|
|
584
|
+
}
|
|
585
|
+
)}
|
|
586
|
+
key={`cell-item-${cellItemIndex}}`}
|
|
587
|
+
data-date={getCalendarDate(_dateShow)}
|
|
588
|
+
data-day={padZero(d)}
|
|
589
|
+
data-week={i}
|
|
590
|
+
onClick={(e: React.MouseEvent) => {
|
|
591
|
+
e.stopPropagation();
|
|
592
|
+
|
|
593
|
+
// update cell data
|
|
594
|
+
setTableCellId(cellItem.id);
|
|
595
|
+
|
|
596
|
+
// Callback
|
|
597
|
+
cellItem.callback?.();
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
if (d > 0) {
|
|
601
|
+
handleDayChange(e, d); // update current day
|
|
602
|
+
|
|
603
|
+
onChangeDate?.(e, cellItem);
|
|
604
|
+
|
|
605
|
+
if (EVENTS_ENABLED) {
|
|
606
|
+
onModalEditOpen?.(cellItem, () => setShowEdit(true), 'normal');
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}}
|
|
610
|
+
>
|
|
611
|
+
|
|
612
|
+
{/* ITEM */}
|
|
613
|
+
<div
|
|
614
|
+
className="e-cal-normal__day__event"
|
|
615
|
+
style={typeof cellItem !== 'undefined' && (cellItem as any).eventStyles !== 'undefined' ? cellItem.eventStyles : {}}
|
|
616
|
+
dangerouslySetInnerHTML={{
|
|
617
|
+
__html: cellItem.data
|
|
618
|
+
}}
|
|
619
|
+
></div>
|
|
620
|
+
{/* /ITEM */}
|
|
621
|
+
|
|
622
|
+
{/* DELETE BUTTON */}
|
|
623
|
+
<div
|
|
624
|
+
className={`e-cal-normal__day__eventdel ${cellCloseBtnClassName || ''}`}
|
|
625
|
+
>
|
|
626
|
+
<a
|
|
627
|
+
href="#"
|
|
628
|
+
tabIndex={-1}
|
|
629
|
+
className="align-middle"
|
|
630
|
+
data-date={getCalendarDate(_dateShow)}
|
|
631
|
+
data-day={padZero(d)}
|
|
632
|
+
data-week={i}
|
|
633
|
+
onClick={(e: React.MouseEvent) => {
|
|
634
|
+
e.preventDefault();
|
|
635
|
+
e.stopPropagation();
|
|
636
|
+
|
|
637
|
+
// update cell data
|
|
638
|
+
setTableCellId(cellItem.id);
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
const _existsContent = cellItem;
|
|
642
|
+
|
|
643
|
+
//
|
|
644
|
+
if (d > 0) {
|
|
645
|
+
handleDayChange(e, d); // update current day
|
|
646
|
+
|
|
647
|
+
onChangeDate?.(e, {
|
|
648
|
+
id: 0,
|
|
649
|
+
date: getCalendarDate(`${year}-${month + 1}-${d}`)
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
if (EVENTS_DELETE_ENABLED) {
|
|
653
|
+
onModalDeleteOpen?.(_existsContent, () => setShowDelete(true));
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
}}
|
|
658
|
+
>
|
|
659
|
+
{_delBtn()}
|
|
660
|
+
</a>
|
|
661
|
+
|
|
662
|
+
</div>
|
|
663
|
+
{/* /DELETE BUTTON */}
|
|
664
|
+
</div>
|
|
665
|
+
});
|
|
666
|
+
};
|
|
667
|
+
|
|
522
668
|
|
|
523
669
|
return (
|
|
524
670
|
<div
|
|
525
671
|
className={combinedCls(
|
|
526
|
-
'e-
|
|
672
|
+
'e-cal-normal__cell e-cal-normal__day',
|
|
527
673
|
{
|
|
528
674
|
'empty': d <= 0,
|
|
529
675
|
'today': d === now.getDate(),
|
|
@@ -545,66 +691,73 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
545
691
|
onClick={(e: React.MouseEvent) => {
|
|
546
692
|
//
|
|
547
693
|
onCellClick?.(e);
|
|
548
|
-
|
|
694
|
+
|
|
549
695
|
if (d > 0) {
|
|
550
|
-
handleDayChange(e, d);
|
|
551
|
-
|
|
552
|
-
onChangeDate?.(e, _currentData.length === 0 ? {
|
|
553
|
-
id: 0,
|
|
554
|
-
date: getCalendarDate(`${year}-${month + 1}-${d}`)
|
|
555
|
-
} : _currentData[0]);
|
|
556
|
-
|
|
557
|
-
if (EVENTS_ENABLED) {
|
|
558
|
-
onModalEditOpen?.(_currentData.length === 0 ? {
|
|
559
|
-
id: 0,
|
|
560
|
-
date: getCalendarDate(`${year}-${month + 1}-${d}`)
|
|
561
|
-
} : _currentData[0], () => setShowEdit(true));
|
|
562
|
-
}
|
|
696
|
+
handleDayChange(e, d); // update current day
|
|
697
|
+
onChangeDate?.(e, null);
|
|
563
698
|
}
|
|
564
699
|
}}
|
|
700
|
+
|
|
565
701
|
>
|
|
566
702
|
|
|
567
703
|
{/* forward fill */}
|
|
568
|
-
{
|
|
704
|
+
{isForward ? <><span className="disabled">{__forwardFillNum[i]}</span></> : null}
|
|
569
705
|
|
|
570
706
|
{/* day */}
|
|
571
707
|
{d > 0 ? <span>{d}</span> : null}
|
|
572
708
|
|
|
573
709
|
{/* back fill */}
|
|
574
|
-
{
|
|
710
|
+
{isBack? <span className="disabled">{__backFillNum[i-item.col.filter(Boolean).length]}</span> : null}
|
|
575
711
|
|
|
576
712
|
{/*++++++++++++++++ EVENT ++++++++++++++++*/}
|
|
577
|
-
{
|
|
578
|
-
|
|
579
|
-
className="e-cal__day__event"
|
|
580
|
-
style={typeof _currentData[0] !== 'undefined' && (_currentData[0] as any).eventStyles !== 'undefined' ? _currentData[0].eventStyles : {}}
|
|
581
|
-
dangerouslySetInnerHTML={{
|
|
582
|
-
__html: _currentData[0].data
|
|
583
|
-
}}
|
|
584
|
-
></div>
|
|
713
|
+
{_eventContent()}
|
|
714
|
+
{/*++++++++++++++++ /EVENT ++++++++++++++++*/}
|
|
585
715
|
|
|
716
|
+
{/* ADD BUTTON */}
|
|
717
|
+
{isForward || isBack ? null : <>
|
|
586
718
|
<div
|
|
587
|
-
className={`e-
|
|
719
|
+
className={`e-cal-normal__day__eventadd ${cellAddBtnClassName || ''}`}
|
|
588
720
|
>
|
|
589
|
-
<a
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
721
|
+
<a
|
|
722
|
+
href="#"
|
|
723
|
+
tabIndex={-1}
|
|
724
|
+
className="align-middle"
|
|
725
|
+
data-date={getCalendarDate(_dateShow)}
|
|
726
|
+
data-day={padZero(d)}
|
|
727
|
+
data-week={i}
|
|
728
|
+
onClick={(e: React.MouseEvent) => {
|
|
729
|
+
e.preventDefault();
|
|
730
|
+
e.stopPropagation();
|
|
731
|
+
|
|
732
|
+
// update cell data
|
|
733
|
+
setTableCellId(-1);
|
|
734
|
+
|
|
735
|
+
//
|
|
736
|
+
if (d > 0) {
|
|
737
|
+
handleDayChange(e, d); // update current day
|
|
738
|
+
|
|
739
|
+
onChangeDate?.(e, {
|
|
740
|
+
id: 0,
|
|
741
|
+
date: getCalendarDate(`${year}-${month + 1}-${d}`)
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
if (EVENTS_ENABLED) {
|
|
745
|
+
onModalEditOpen?.({
|
|
746
|
+
id: 0,
|
|
747
|
+
date: getCalendarDate(`${year}-${month + 1}-${d}`)
|
|
748
|
+
}, () => setShowEdit(true), 'new');
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}}
|
|
752
|
+
>
|
|
753
|
+
{_addBtn()}
|
|
601
754
|
</a>
|
|
602
755
|
|
|
603
756
|
</div>
|
|
757
|
+
</>}
|
|
758
|
+
{/* /ADD BUTTON */}
|
|
759
|
+
|
|
604
760
|
|
|
605
|
-
|
|
606
|
-
</> : null}
|
|
607
|
-
{/*++++++++++++++++ /EVENT ++++++++++++++++*/}
|
|
608
761
|
</div>
|
|
609
762
|
);
|
|
610
763
|
})}
|
|
@@ -619,12 +772,12 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
619
772
|
|
|
620
773
|
|
|
621
774
|
{/*++++++++++++++++ MONTH SELECTION TAB ++++++++++++++++*/}
|
|
622
|
-
<div className={`e-
|
|
623
|
-
<div className="e-
|
|
775
|
+
<div className={`e-cal-normal__month-wrapper shadow p-3 mb-5 bg-body-tertiary rounded ${winMonth ? 'active' : ''}`}>
|
|
776
|
+
<div className="e-cal-normal__month-container">
|
|
624
777
|
{MONTHS_FULL.map((month, index) => {
|
|
625
778
|
return <div
|
|
626
779
|
data-month={padZero(index+1)}
|
|
627
|
-
className={`e-
|
|
780
|
+
className={`e-cal-normal__month ${selectedMonth === index ? ' selected' : ''}`}
|
|
628
781
|
key={month + index}
|
|
629
782
|
onClick={() => { handleMonthChange(index) }}
|
|
630
783
|
>{month}</div>
|
|
@@ -634,12 +787,12 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
634
787
|
{/*++++++++++++++++ /MONTH SELECTION TAB ++++++++++++++++*/}
|
|
635
788
|
|
|
636
789
|
{/*++++++++++++++++ YEAR SELECTION TAB ++++++++++++++++*/}
|
|
637
|
-
<div className={`e-
|
|
638
|
-
<div className="e-
|
|
790
|
+
<div className={`e-cal-normal__year-wrapper shadow p-3 mb-5 bg-body-tertiary rounded ${winYear ? 'active' : ''}`}>
|
|
791
|
+
<div className="e-cal-normal__year-container bg-body-tertiary">
|
|
639
792
|
{yearsArray.map((year, index) => {
|
|
640
793
|
return <div
|
|
641
794
|
data-year={year}
|
|
642
|
-
className={`e-
|
|
795
|
+
className={`e-cal-normal__year ${selectedYear === year ? ' selected' : ''}`}
|
|
643
796
|
key={year + index}
|
|
644
797
|
onClick={() => { handleYearChange(year) }}
|
|
645
798
|
>{year}</div>
|
|
@@ -652,8 +805,8 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
652
805
|
|
|
653
806
|
|
|
654
807
|
{/*++++++++++++++++ TODAY SELECTION TAB ++++++++++++++++*/}
|
|
655
|
-
<div className="e-
|
|
656
|
-
<button tabIndex={-1} type="button" className="e-
|
|
808
|
+
<div className="e-cal-normal__today-wrapper p-2 bg-body-tertiary">
|
|
809
|
+
<button tabIndex={-1} type="button" className="e-cal-normal__btn e-cal-normal__btn--today" onClick={handleTodayChange}>
|
|
657
810
|
{langToday || 'Today'}
|
|
658
811
|
</button>
|
|
659
812
|
</div>
|
|
@@ -680,21 +833,11 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
680
833
|
|
|
681
834
|
setTimeout(() => {
|
|
682
835
|
setShowDelete(false);
|
|
683
|
-
|
|
684
|
-
const _currentData = val.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(`${year}-${month + 1}-${day}`));
|
|
685
|
-
onModalDeleteClose?.(_currentData.length === 0 ? {
|
|
686
|
-
id: 0,
|
|
687
|
-
date: getCalendarDate(`${year}-${month + 1}-${day}`)
|
|
688
|
-
} : _currentData[0]);
|
|
836
|
+
onModalDeleteClose?.(queryItemObj());
|
|
689
837
|
}, 350);
|
|
690
838
|
}}
|
|
691
839
|
onSubmit={async (e: any, closewin: Function, data: any) => {
|
|
692
|
-
|
|
693
|
-
const _currentData = val.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(`${year}-${month + 1}-${day}`));
|
|
694
|
-
onModalDeleteEvent?.(_currentData.length === 0 ? {
|
|
695
|
-
id: 0,
|
|
696
|
-
date: getCalendarDate(`${year}-${month + 1}-${day}`)
|
|
697
|
-
} : _currentData[0], closewin);
|
|
840
|
+
onModalDeleteEvent?.(queryItemObj(), closewin);
|
|
698
841
|
|
|
699
842
|
}}
|
|
700
843
|
>
|
|
@@ -720,21 +863,11 @@ const EventCalendar = (props: EventCalendarProps) => {
|
|
|
720
863
|
onClose={(e) => {
|
|
721
864
|
setTimeout(() => {
|
|
722
865
|
setShowEdit(false);
|
|
723
|
-
|
|
724
|
-
const _currentData = val.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(`${year}-${month + 1}-${day}`));
|
|
725
|
-
onModalEditClose?.(_currentData.length === 0 ? {
|
|
726
|
-
id: 0,
|
|
727
|
-
date: getCalendarDate(`${year}-${month + 1}-${day}`)
|
|
728
|
-
} : _currentData[0]);
|
|
866
|
+
onModalEditClose?.(queryItemObj());
|
|
729
867
|
}, 350);
|
|
730
868
|
}}
|
|
731
869
|
onSubmit={async (e: any, closewin: Function, data: any) => {
|
|
732
|
-
|
|
733
|
-
const _currentData = val.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(`${year}-${month + 1}-${day}`));
|
|
734
|
-
onModalEditEvent?.(_currentData.length === 0 ? {
|
|
735
|
-
id: 0,
|
|
736
|
-
date: getCalendarDate(`${year}-${month + 1}-${day}`)
|
|
737
|
-
} : _currentData[0], closewin);
|
|
870
|
+
onModalEditEvent?.(queryItemObj(), closewin);
|
|
738
871
|
|
|
739
872
|
}}
|
|
740
873
|
>
|