nntc-ui 0.0.66 → 0.0.67
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/index.css +7 -0
- package/index.d.ts +3 -0
- package/index.js +278 -58
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -829,6 +829,13 @@
|
|
|
829
829
|
height: 44px;
|
|
830
830
|
background-color: var(--theme-date-range);
|
|
831
831
|
}
|
|
832
|
+
.calendarPopover_monthCellSelectionFirst {
|
|
833
|
+
left: 50%;
|
|
834
|
+
width: 50%;
|
|
835
|
+
}
|
|
836
|
+
.calendarPopover_monthCellSelectionLast {
|
|
837
|
+
width: 50%;
|
|
838
|
+
}
|
|
832
839
|
|
|
833
840
|
/* src/components/common/ColorPicker/colorPicker.module.css */
|
|
834
841
|
.colorPicker_root {
|
package/index.d.ts
CHANGED
|
@@ -66,8 +66,11 @@ declare function Select(props: UiProps<Props$l> & DetailedHTMLProps<InputHTMLAtt
|
|
|
66
66
|
|
|
67
67
|
type Variant$6 = 'filled' | 'outlined';
|
|
68
68
|
type Size$9 = 'medium' | 'small';
|
|
69
|
+
type ValueType = 'date' | 'year';
|
|
69
70
|
interface Props$k {
|
|
70
71
|
variant?: Variant$6;
|
|
72
|
+
isPeriod?: boolean;
|
|
73
|
+
valueType?: ValueType;
|
|
71
74
|
componentSize?: Size$9;
|
|
72
75
|
fullWidth?: boolean;
|
|
73
76
|
placeholder?: string;
|
package/index.js
CHANGED
|
@@ -897,6 +897,8 @@ __export(calendarPopover_exports, {
|
|
|
897
897
|
default: () => calendarPopover_default,
|
|
898
898
|
month: () => month,
|
|
899
899
|
monthCellSelection: () => monthCellSelection,
|
|
900
|
+
monthCellSelectionFirst: () => monthCellSelectionFirst,
|
|
901
|
+
monthCellSelectionLast: () => monthCellSelectionLast,
|
|
900
902
|
navigationArrow: () => navigationArrow,
|
|
901
903
|
navigationContainer: () => navigationContainer,
|
|
902
904
|
navigationTitle: () => navigationTitle,
|
|
@@ -919,6 +921,8 @@ var cellSelection = "calendarPopover_cellSelection";
|
|
|
919
921
|
var cellSelectionFirst = "calendarPopover_cellSelectionFirst";
|
|
920
922
|
var cellSelectionLast = "calendarPopover_cellSelectionLast";
|
|
921
923
|
var monthCellSelection = "calendarPopover_monthCellSelection";
|
|
924
|
+
var monthCellSelectionFirst = "calendarPopover_monthCellSelectionFirst";
|
|
925
|
+
var monthCellSelectionLast = "calendarPopover_monthCellSelectionLast";
|
|
922
926
|
var calendarPopover_default = {
|
|
923
927
|
root: root7,
|
|
924
928
|
buttonsContainer,
|
|
@@ -935,14 +939,25 @@ var calendarPopover_default = {
|
|
|
935
939
|
cellSelection,
|
|
936
940
|
cellSelectionFirst,
|
|
937
941
|
cellSelectionLast,
|
|
938
|
-
monthCellSelection
|
|
942
|
+
monthCellSelection,
|
|
943
|
+
monthCellSelectionFirst,
|
|
944
|
+
monthCellSelectionLast
|
|
939
945
|
};
|
|
940
946
|
|
|
941
947
|
// src/components/common/DateTime/ui/CalendarPopover/CalendarPopover.tsx
|
|
942
948
|
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
943
949
|
function CalendarPopover(props) {
|
|
944
|
-
const {
|
|
945
|
-
|
|
950
|
+
const {
|
|
951
|
+
componentSize,
|
|
952
|
+
isPeriod = true,
|
|
953
|
+
valueType = "date",
|
|
954
|
+
initStartDate,
|
|
955
|
+
initEndDate,
|
|
956
|
+
changeDates,
|
|
957
|
+
onClear,
|
|
958
|
+
classes
|
|
959
|
+
} = props;
|
|
960
|
+
const [viewType, setViewType] = useState4(valueType === "year" ? "yearsRange" : "month");
|
|
946
961
|
const [currentItem, setCurrentItem] = useState4({
|
|
947
962
|
year: dayjs().year(),
|
|
948
963
|
month: dayjs().month()
|
|
@@ -951,8 +966,10 @@ function CalendarPopover(props) {
|
|
|
951
966
|
const [endDate, setEndDate] = useState4(initEndDate ? dayjs(initEndDate).startOf("D").valueOf() : void 0);
|
|
952
967
|
const startDateMonth = useMemo2(() => startDate ? dayjs(startDate).startOf("M").valueOf() : void 0, [startDate]);
|
|
953
968
|
const endDateMonth = useMemo2(() => endDate ? dayjs(endDate).startOf("M").valueOf() : void 0, [endDate]);
|
|
969
|
+
const startYear = useMemo2(() => startDate ? dayjs(startDate).year() : void 0, [startDate]);
|
|
970
|
+
const endYear = useMemo2(() => endDate ? dayjs(endDate).year() : void 0, [endDate]);
|
|
954
971
|
const currentDate = useMemo2(
|
|
955
|
-
() => dayjs(new Date(currentItem.year, currentItem.month, 1)).startOf(viewType === "
|
|
972
|
+
() => dayjs(new Date(currentItem.year, currentItem.month, 1)).startOf(viewType === "month" ? "M" : "y"),
|
|
956
973
|
[currentItem, viewType]
|
|
957
974
|
);
|
|
958
975
|
const daysInMonth = currentDate.daysInMonth();
|
|
@@ -965,13 +982,33 @@ function CalendarPopover(props) {
|
|
|
965
982
|
if (!startDate && !endDate) {
|
|
966
983
|
onClear?.();
|
|
967
984
|
changeDates();
|
|
968
|
-
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (valueType === "year") {
|
|
988
|
+
if (!isPeriod && startDate) {
|
|
989
|
+
changeDates(dayjs(startDate).format("YYYY"));
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
if (isPeriod && startDate && endDate) {
|
|
993
|
+
changeDates(dayjs(startDate).format("YYYY"), dayjs(endDate).format("YYYY"));
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
if (!isPeriod && startDate) {
|
|
999
|
+
changeDates(dayjs(startDate).format());
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
if (isPeriod && startDate && endDate) {
|
|
969
1003
|
changeDates(dayjs(startDate).format(), dayjs(endDate).format());
|
|
970
1004
|
}
|
|
971
|
-
}, [startDate, endDate]);
|
|
1005
|
+
}, [startDate, endDate, isPeriod, valueType, changeDates, onClear]);
|
|
972
1006
|
const changeCurrentItem = useCallback3(
|
|
973
1007
|
(count) => () => {
|
|
974
|
-
const
|
|
1008
|
+
const baseDate = dayjs(new Date(currentItem.year, currentItem.month, 1));
|
|
1009
|
+
const step = viewType === "yearsRange" ? count * 20 : count;
|
|
1010
|
+
const unit = viewType === "month" ? "month" : "year";
|
|
1011
|
+
const tempDate = baseDate.add(step, unit);
|
|
975
1012
|
setCurrentItem({
|
|
976
1013
|
month: tempDate.month(),
|
|
977
1014
|
year: tempDate.year()
|
|
@@ -979,19 +1016,85 @@ function CalendarPopover(props) {
|
|
|
979
1016
|
},
|
|
980
1017
|
[viewType, currentItem]
|
|
981
1018
|
);
|
|
982
|
-
const changeViewType = useCallback3(
|
|
1019
|
+
const changeViewType = useCallback3(() => {
|
|
1020
|
+
if (valueType === "year") {
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
if (viewType === "month") {
|
|
1024
|
+
setViewType("year");
|
|
1025
|
+
} else if (viewType === "year") {
|
|
1026
|
+
setViewType("yearsRange");
|
|
1027
|
+
} else {
|
|
1028
|
+
setViewType("month");
|
|
1029
|
+
}
|
|
1030
|
+
}, [viewType, valueType]);
|
|
1031
|
+
const openMonthView = useCallback3(
|
|
983
1032
|
(date) => () => {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1033
|
+
setCurrentItem({ month: date.month(), year: date.year() });
|
|
1034
|
+
setViewType("month");
|
|
1035
|
+
},
|
|
1036
|
+
[]
|
|
1037
|
+
);
|
|
1038
|
+
const setYear = useCallback3(
|
|
1039
|
+
(cellYear) => () => {
|
|
1040
|
+
const cellDate = dayjs(new Date(cellYear, 0, 1)).startOf("y").valueOf();
|
|
1041
|
+
if (!isPeriod) {
|
|
1042
|
+
if (startDate === cellDate) {
|
|
1043
|
+
setStartDate(void 0);
|
|
1044
|
+
} else {
|
|
1045
|
+
setStartDate(cellDate);
|
|
1046
|
+
}
|
|
1047
|
+
setEndDate(void 0);
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
if (startDate && endDate) {
|
|
1051
|
+
if (cellDate === startDate) {
|
|
1052
|
+
setStartDate(void 0);
|
|
1053
|
+
} else if (cellDate === endDate) {
|
|
1054
|
+
setEndDate(void 0);
|
|
1055
|
+
} else {
|
|
1056
|
+
setStartDate(cellDate);
|
|
1057
|
+
setEndDate(void 0);
|
|
1058
|
+
}
|
|
1059
|
+
} else if (startDate) {
|
|
1060
|
+
if (cellDate === startDate) {
|
|
1061
|
+
setStartDate(void 0);
|
|
1062
|
+
} else if (cellDate < startDate) {
|
|
1063
|
+
setEndDate(startDate);
|
|
1064
|
+
setStartDate(cellDate);
|
|
1065
|
+
} else {
|
|
1066
|
+
setEndDate(cellDate);
|
|
1067
|
+
}
|
|
1068
|
+
} else if (endDate) {
|
|
1069
|
+
if (cellDate === endDate) {
|
|
1070
|
+
setEndDate(void 0);
|
|
1071
|
+
} else if (cellDate < endDate) {
|
|
1072
|
+
setStartDate(cellDate);
|
|
1073
|
+
} else {
|
|
1074
|
+
setStartDate(endDate);
|
|
1075
|
+
setEndDate(cellDate);
|
|
1076
|
+
}
|
|
987
1077
|
} else {
|
|
988
|
-
|
|
1078
|
+
setStartDate(cellDate);
|
|
989
1079
|
}
|
|
990
1080
|
},
|
|
991
|
-
[
|
|
1081
|
+
[startDate, endDate, isPeriod]
|
|
992
1082
|
);
|
|
1083
|
+
const yearsRangeStart = useMemo2(() => {
|
|
1084
|
+
const year = currentDate.year();
|
|
1085
|
+
return Math.floor(year / 20) * 20;
|
|
1086
|
+
}, [currentDate]);
|
|
993
1087
|
const setDate = useCallback3(
|
|
994
1088
|
(cellDate) => () => {
|
|
1089
|
+
if (!isPeriod) {
|
|
1090
|
+
if (startDate === cellDate) {
|
|
1091
|
+
setStartDate(void 0);
|
|
1092
|
+
} else {
|
|
1093
|
+
setStartDate(cellDate);
|
|
1094
|
+
}
|
|
1095
|
+
setEndDate(void 0);
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
995
1098
|
if (startDate && endDate) {
|
|
996
1099
|
if (cellDate === startDate) {
|
|
997
1100
|
setStartDate(void 0);
|
|
@@ -1023,7 +1126,7 @@ function CalendarPopover(props) {
|
|
|
1023
1126
|
setStartDate(cellDate);
|
|
1024
1127
|
}
|
|
1025
1128
|
},
|
|
1026
|
-
[startDate, endDate]
|
|
1129
|
+
[startDate, endDate, isPeriod]
|
|
1027
1130
|
);
|
|
1028
1131
|
const reset = useCallback3((e) => {
|
|
1029
1132
|
setStartDate(void 0);
|
|
@@ -1043,7 +1146,7 @@ function CalendarPopover(props) {
|
|
|
1043
1146
|
return /* @__PURE__ */ jsxs6("div", { className: classNames2(root7, calendarPopover_exports[componentSize], classes?.root), children: [
|
|
1044
1147
|
/* @__PURE__ */ jsx13("div", { className: classNames2(buttonsContainer, classes?.buttonsContainer), children: /* @__PURE__ */ jsxs6(ButtonsGroup, { fillEvenly: true, children: [
|
|
1045
1148
|
/* @__PURE__ */ jsx13(Button, { size: "small", variant: "text", textSecondary: true, tabIndex: -1, onClick: reset, children: "\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C" }),
|
|
1046
|
-
/* @__PURE__ */ jsx13(Button, { size: "small", variant: "text", textSecondary: true, tabIndex: -1, onClick: today, children: "\u0421\u0435\u0433\u043E\u0434\u043D\u044F" })
|
|
1149
|
+
valueType === "date" && /* @__PURE__ */ jsx13(Button, { size: "small", variant: "text", textSecondary: true, tabIndex: -1, onClick: today, children: "\u0421\u0435\u0433\u043E\u0434\u043D\u044F" })
|
|
1047
1150
|
] }) }),
|
|
1048
1151
|
/* @__PURE__ */ jsxs6("div", { className: classNames2(navigationContainer, classes?.navigationContainer), children: [
|
|
1049
1152
|
/* @__PURE__ */ jsx13(
|
|
@@ -1060,8 +1163,12 @@ function CalendarPopover(props) {
|
|
|
1060
1163
|
{
|
|
1061
1164
|
type: "button",
|
|
1062
1165
|
className: classNames2(button2, navigationValue, classes?.navigationValue),
|
|
1063
|
-
onClick: changeViewType
|
|
1064
|
-
children: /* @__PURE__ */
|
|
1166
|
+
onClick: changeViewType,
|
|
1167
|
+
children: /* @__PURE__ */ jsxs6(Typography, { variant: "subtitle1", className: classNames2(navigationTitle, classes?.navigationTitle), children: [
|
|
1168
|
+
viewType === "month" && currentDate.format("MMMM YYYY"),
|
|
1169
|
+
viewType === "year" && currentDate.format("YYYY"),
|
|
1170
|
+
viewType === "yearsRange" && `${yearsRangeStart} - ${yearsRangeStart + 19}`
|
|
1171
|
+
] })
|
|
1065
1172
|
}
|
|
1066
1173
|
),
|
|
1067
1174
|
/* @__PURE__ */ jsx13(
|
|
@@ -1074,61 +1181,158 @@ function CalendarPopover(props) {
|
|
|
1074
1181
|
}
|
|
1075
1182
|
)
|
|
1076
1183
|
] }),
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1184
|
+
/* @__PURE__ */ jsxs6("div", { className: classNames2(cellsContainer, classes?.cellsContainer), children: [
|
|
1185
|
+
viewType === "yearsRange" && /* @__PURE__ */ jsx13(Fragment2, { children: [...Array(20)].map((__, index) => {
|
|
1186
|
+
const cellYear = yearsRangeStart + index;
|
|
1187
|
+
const handleClick = valueType === "year" ? setYear(cellYear) : () => {
|
|
1188
|
+
setCurrentItem({ month: 0, year: cellYear });
|
|
1189
|
+
setViewType("year");
|
|
1190
|
+
};
|
|
1191
|
+
const showCircle = valueType === "year";
|
|
1192
|
+
const isCircleActive = showCircle && startYear !== void 0 && (cellYear === startYear || cellYear === endYear);
|
|
1193
|
+
let isYearInRange = false;
|
|
1194
|
+
let isFirstInRange = false;
|
|
1195
|
+
let isLastInRange = false;
|
|
1196
|
+
if (startYear !== void 0) {
|
|
1197
|
+
if (!isPeriod) {
|
|
1198
|
+
if (valueType === "date" && cellYear === startYear) {
|
|
1199
|
+
isYearInRange = true;
|
|
1200
|
+
}
|
|
1201
|
+
} else if (endYear !== void 0) {
|
|
1202
|
+
if (startYear === endYear) {
|
|
1203
|
+
if (cellYear === startYear) {
|
|
1204
|
+
isYearInRange = true;
|
|
1205
|
+
}
|
|
1206
|
+
} else if (cellYear >= startYear && cellYear <= endYear) {
|
|
1207
|
+
isYearInRange = true;
|
|
1208
|
+
if (cellYear === startYear) {
|
|
1209
|
+
isFirstInRange = true;
|
|
1210
|
+
} else if (cellYear === endYear) {
|
|
1211
|
+
isLastInRange = true;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1097
1216
|
return /* @__PURE__ */ jsxs6(
|
|
1098
1217
|
"button",
|
|
1099
1218
|
{
|
|
1100
1219
|
type: "button",
|
|
1101
1220
|
className: classNames2(button2, cell, classes?.cell),
|
|
1102
|
-
onClick:
|
|
1221
|
+
onClick: handleClick,
|
|
1103
1222
|
children: [
|
|
1104
|
-
|
|
1105
|
-
|
|
1223
|
+
isCircleActive && /* @__PURE__ */ jsx13("span", { className: classNames2(cellCircle, classes?.cellCircle) }),
|
|
1224
|
+
isYearInRange && /* @__PURE__ */ jsx13(
|
|
1106
1225
|
"span",
|
|
1107
1226
|
{
|
|
1108
1227
|
className: classNames2(
|
|
1109
1228
|
cellSelection,
|
|
1110
1229
|
classes?.cellSelection,
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1230
|
+
isFirstInRange && cellSelectionFirst,
|
|
1231
|
+
isFirstInRange && classes?.cellSelectionFirst,
|
|
1232
|
+
isLastInRange && cellSelectionLast,
|
|
1233
|
+
isLastInRange && classes?.cellSelectionLast
|
|
1115
1234
|
)
|
|
1116
1235
|
}
|
|
1117
1236
|
),
|
|
1118
|
-
/* @__PURE__ */ jsx13(
|
|
1119
|
-
|
|
1237
|
+
/* @__PURE__ */ jsx13(Typography, { variant: "subtitle1", className: classNames2(cellData, classes?.cellData), children: cellYear })
|
|
1238
|
+
]
|
|
1239
|
+
},
|
|
1240
|
+
`cell-year-${cellYear}`
|
|
1241
|
+
);
|
|
1242
|
+
}) }),
|
|
1243
|
+
viewType === "year" && /* @__PURE__ */ jsx13(Fragment2, { children: [...Array(12)].map((__, index) => {
|
|
1244
|
+
const cellDate = currentDate.add(index, "M");
|
|
1245
|
+
const cellDateValue = cellDate.valueOf();
|
|
1246
|
+
const isMonthSelected = isPeriod ? startDateMonth !== void 0 && endDateMonth !== void 0 && cellDateValue >= startDateMonth && cellDateValue <= endDateMonth : startDateMonth !== void 0 && cellDateValue === startDateMonth;
|
|
1247
|
+
let isMonthInRange = false;
|
|
1248
|
+
let isFirstMonthInRange = false;
|
|
1249
|
+
let isLastMonthInRange = false;
|
|
1250
|
+
if (isPeriod && valueType === "date" && startDateMonth !== void 0 && endDateMonth !== void 0) {
|
|
1251
|
+
if (startDateMonth === endDateMonth) {
|
|
1252
|
+
if (cellDateValue === startDateMonth) {
|
|
1253
|
+
isMonthInRange = true;
|
|
1254
|
+
}
|
|
1255
|
+
} else if (cellDateValue >= startDateMonth && cellDateValue <= endDateMonth) {
|
|
1256
|
+
isMonthInRange = true;
|
|
1257
|
+
if (cellDateValue === startDateMonth) {
|
|
1258
|
+
isFirstMonthInRange = true;
|
|
1259
|
+
} else if (cellDateValue === endDateMonth) {
|
|
1260
|
+
isLastMonthInRange = true;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
} else if (!isPeriod && valueType === "date" && startDateMonth !== void 0) {
|
|
1264
|
+
if (cellDateValue === startDateMonth) {
|
|
1265
|
+
isMonthInRange = true;
|
|
1266
|
+
}
|
|
1267
|
+
} else {
|
|
1268
|
+
isMonthInRange = isMonthSelected;
|
|
1269
|
+
}
|
|
1270
|
+
return /* @__PURE__ */ jsxs6(
|
|
1271
|
+
"button",
|
|
1272
|
+
{
|
|
1273
|
+
type: "button",
|
|
1274
|
+
className: classNames2(button2, cell, month, classes?.cell, classes?.month),
|
|
1275
|
+
onClick: openMonthView(cellDate),
|
|
1276
|
+
children: [
|
|
1277
|
+
isMonthInRange && /* @__PURE__ */ jsx13(
|
|
1278
|
+
"span",
|
|
1120
1279
|
{
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1280
|
+
className: classNames2(
|
|
1281
|
+
monthCellSelection,
|
|
1282
|
+
classes?.monthCellSelection,
|
|
1283
|
+
isFirstMonthInRange && monthCellSelectionFirst,
|
|
1284
|
+
isFirstMonthInRange && classes?.monthCellSelectionFirst,
|
|
1285
|
+
isLastMonthInRange && monthCellSelectionLast,
|
|
1286
|
+
isLastMonthInRange && classes?.monthCellSelectionLast
|
|
1287
|
+
)
|
|
1124
1288
|
}
|
|
1125
|
-
)
|
|
1289
|
+
),
|
|
1290
|
+
/* @__PURE__ */ jsx13(Typography, { variant: "subtitle1", className: classNames2(cellData, classes?.cellData), children: cellDate.format("MMMM") })
|
|
1126
1291
|
]
|
|
1127
1292
|
},
|
|
1128
1293
|
`cell-${index}`
|
|
1129
1294
|
);
|
|
1130
|
-
})
|
|
1131
|
-
|
|
1295
|
+
}) }),
|
|
1296
|
+
viewType === "month" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1297
|
+
[...Array(emptyCellsCount)].map((__, index) => /* @__PURE__ */ jsx13("div", { className: classNames2(cell, classes?.cell) }, `empty-cell-${index}`)),
|
|
1298
|
+
[...Array(daysInMonth)].map((__, index) => {
|
|
1299
|
+
const cellDate = currentDate.add(index, "d").valueOf();
|
|
1300
|
+
return /* @__PURE__ */ jsxs6(
|
|
1301
|
+
"button",
|
|
1302
|
+
{
|
|
1303
|
+
type: "button",
|
|
1304
|
+
className: classNames2(button2, cell, classes?.cell),
|
|
1305
|
+
onClick: setDate(cellDate),
|
|
1306
|
+
children: [
|
|
1307
|
+
(cellDate === startDate || cellDate === endDate) && /* @__PURE__ */ jsx13("span", { className: classNames2(cellCircle, classes?.cellCircle) }),
|
|
1308
|
+
startDate !== void 0 && endDate !== void 0 && cellDate >= startDate && cellDate <= endDate && /* @__PURE__ */ jsx13(
|
|
1309
|
+
"span",
|
|
1310
|
+
{
|
|
1311
|
+
className: classNames2(
|
|
1312
|
+
cellSelection,
|
|
1313
|
+
classes?.cellSelection,
|
|
1314
|
+
cellDate === startDate && cellSelectionFirst,
|
|
1315
|
+
cellDate === startDate && classes?.cellSelectionFirst,
|
|
1316
|
+
cellDate === endDate && cellSelectionLast,
|
|
1317
|
+
cellDate === endDate && classes?.cellSelectionLast
|
|
1318
|
+
)
|
|
1319
|
+
}
|
|
1320
|
+
),
|
|
1321
|
+
/* @__PURE__ */ jsx13(
|
|
1322
|
+
Typography,
|
|
1323
|
+
{
|
|
1324
|
+
variant: "subtitle1",
|
|
1325
|
+
className: classNames2(cellData, classes?.cellData),
|
|
1326
|
+
children: `${index + 1}`
|
|
1327
|
+
}
|
|
1328
|
+
)
|
|
1329
|
+
]
|
|
1330
|
+
},
|
|
1331
|
+
`cell-${index}`
|
|
1332
|
+
);
|
|
1333
|
+
})
|
|
1334
|
+
] })
|
|
1335
|
+
] })
|
|
1132
1336
|
] });
|
|
1133
1337
|
}
|
|
1134
1338
|
|
|
@@ -1137,6 +1341,8 @@ import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
|
1137
1341
|
function DateTime(props) {
|
|
1138
1342
|
const {
|
|
1139
1343
|
variant = "filled",
|
|
1344
|
+
isPeriod = false,
|
|
1345
|
+
valueType = "date",
|
|
1140
1346
|
componentSize = "medium",
|
|
1141
1347
|
fullWidth: fullWidth2,
|
|
1142
1348
|
placeholder,
|
|
@@ -1148,10 +1354,19 @@ function DateTime(props) {
|
|
|
1148
1354
|
ref,
|
|
1149
1355
|
...inputProps
|
|
1150
1356
|
} = props;
|
|
1151
|
-
const [stateValues, setStateValues] = useState5(
|
|
1357
|
+
const [stateValues, setStateValues] = useState5(
|
|
1358
|
+
values !== void 0 ? values : defaultValues
|
|
1359
|
+
);
|
|
1360
|
+
useEffect4(() => {
|
|
1361
|
+
if (values !== void 0) {
|
|
1362
|
+
setStateValues(values);
|
|
1363
|
+
}
|
|
1364
|
+
}, [values]);
|
|
1152
1365
|
useEffect4(() => {
|
|
1153
|
-
|
|
1154
|
-
|
|
1366
|
+
if (values === void 0 && defaultValues !== void 0) {
|
|
1367
|
+
setStateValues(defaultValues);
|
|
1368
|
+
}
|
|
1369
|
+
}, [defaultValues, values]);
|
|
1155
1370
|
const inputRef = useRef3(null);
|
|
1156
1371
|
const popoverTargetRef = useRef3(null);
|
|
1157
1372
|
const inputClickHandler = useCallback4(
|
|
@@ -1162,8 +1377,9 @@ function DateTime(props) {
|
|
|
1162
1377
|
[popoverTargetRef]
|
|
1163
1378
|
);
|
|
1164
1379
|
const changeDates = (newStartDate, newEndDate) => {
|
|
1165
|
-
|
|
1166
|
-
|
|
1380
|
+
const newValues = isPeriod ? [newStartDate, newEndDate] : [newStartDate];
|
|
1381
|
+
setStateValues(newValues);
|
|
1382
|
+
onValueChange?.(newValues);
|
|
1167
1383
|
};
|
|
1168
1384
|
return /* @__PURE__ */ jsxs7(
|
|
1169
1385
|
"div",
|
|
@@ -1185,7 +1401,9 @@ function DateTime(props) {
|
|
|
1185
1401
|
className: classnames7(input3, classes?.input),
|
|
1186
1402
|
placeholder,
|
|
1187
1403
|
...inputProps,
|
|
1188
|
-
value:
|
|
1404
|
+
value: stateValues?.[0] ? isPeriod && stateValues[1] ? `${dayjs2(stateValues[0]).format(valueType === "year" ? "YYYY" : "DD.MM.YYYY")} - ${dayjs2(
|
|
1405
|
+
stateValues[1]
|
|
1406
|
+
).format(valueType === "year" ? "YYYY" : "DD.MM.YYYY")}` : `${dayjs2(stateValues[0]).format(valueType === "year" ? "YYYY" : "DD.MM.YYYY")}` : "",
|
|
1189
1407
|
onChange: () => {
|
|
1190
1408
|
},
|
|
1191
1409
|
onClick: inputClickHandler
|
|
@@ -1203,6 +1421,8 @@ function DateTime(props) {
|
|
|
1203
1421
|
{
|
|
1204
1422
|
classes,
|
|
1205
1423
|
componentSize,
|
|
1424
|
+
isPeriod,
|
|
1425
|
+
valueType,
|
|
1206
1426
|
initStartDate: stateValues?.[0],
|
|
1207
1427
|
initEndDate: stateValues?.[1],
|
|
1208
1428
|
changeDates,
|