schummar-table 0.48.1 → 0.49.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/index.cjs +434 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +433 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -11,8 +11,8 @@ let __emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
|
11
11
|
__emotion_react_jsx_runtime = require_chunk.__toESM(__emotion_react_jsx_runtime);
|
|
12
12
|
let nanoid = require("nanoid");
|
|
13
13
|
nanoid = require_chunk.__toESM(nanoid);
|
|
14
|
-
let
|
|
15
|
-
|
|
14
|
+
let date_fns = require("date-fns");
|
|
15
|
+
date_fns = require_chunk.__toESM(date_fns);
|
|
16
16
|
|
|
17
17
|
//#region src/misc/tableContext.ts
|
|
18
18
|
const TableContext = (0, react.createContext)(null);
|
|
@@ -927,6 +927,430 @@ function CombinedFilter({ columnIds: inputColumnIds,...props }) {
|
|
|
927
927
|
}, columnId)) });
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
+
//#endregion
|
|
931
|
+
//#region src/vendor/dayzed/utils.ts
|
|
932
|
+
/**
|
|
933
|
+
* This is intended to be used to compose event handlers
|
|
934
|
+
* They are executed in order until one of them calls
|
|
935
|
+
* `event.preventDefault()`. Not sure this is the best
|
|
936
|
+
* way to do this, but it seems legit...
|
|
937
|
+
* @param {Function} fns the event hanlder functions
|
|
938
|
+
* @return {Function} the event handler to add to an element
|
|
939
|
+
*/
|
|
940
|
+
function composeEventHandlers(...fns) {
|
|
941
|
+
return (event, ...args) => fns.some((fn) => {
|
|
942
|
+
if (fn) fn(event, ...args);
|
|
943
|
+
return event.defaultPrevented;
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Throws a helpful error message for required properties. Useful
|
|
948
|
+
* to be used as a default in destructuring or object params.
|
|
949
|
+
* @param {String} fnName the function name
|
|
950
|
+
* @param {String} propName the prop name
|
|
951
|
+
*/
|
|
952
|
+
function requiredProp(fnName, propName) {
|
|
953
|
+
throw new Error(`The property "${propName}" is required in "${fnName}"`);
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Takes a calendars array and figures out the number of months to subtract
|
|
957
|
+
* based on the current offset and the minDate allowed.
|
|
958
|
+
* @param {Object} param The param object
|
|
959
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
960
|
+
* @param {Number} param.offset The num of months to be subtracted
|
|
961
|
+
* @param {Date} param.minDate The earliest date we are allow to subtract back to
|
|
962
|
+
* @returns {Number} The number of months to subtract
|
|
963
|
+
*/
|
|
964
|
+
function subtractMonth({ calendars, offset, minDate }) {
|
|
965
|
+
if (offset > 1 && minDate) {
|
|
966
|
+
const { firstDayOfMonth } = calendars[0];
|
|
967
|
+
const diffInMonths = (0, date_fns.differenceInCalendarMonths)(firstDayOfMonth, minDate);
|
|
968
|
+
if (diffInMonths < offset) offset = diffInMonths;
|
|
969
|
+
}
|
|
970
|
+
return offset;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Takes a calendars array and figures out the number of months to add
|
|
974
|
+
* based on the current offset and the maxDate allowed.
|
|
975
|
+
* @param {Object} param The param object
|
|
976
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
977
|
+
* @param {Number} param.offset The num of months to be added
|
|
978
|
+
* @param {Date} param.maxDate The furthest date we are allow to add forward to
|
|
979
|
+
* @returns {Number} The number of months to add
|
|
980
|
+
*/
|
|
981
|
+
function addMonth({ calendars, offset, maxDate }) {
|
|
982
|
+
if (offset > 1 && maxDate) {
|
|
983
|
+
const { lastDayOfMonth } = calendars[calendars.length - 1];
|
|
984
|
+
const diffInMonths = (0, date_fns.differenceInCalendarMonths)(maxDate, lastDayOfMonth);
|
|
985
|
+
if (diffInMonths < offset) offset = diffInMonths;
|
|
986
|
+
}
|
|
987
|
+
return offset;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Takes a calendars array and figures out if the back button should be
|
|
991
|
+
* disabled based on the minDate allowed.
|
|
992
|
+
* @param {Object} param The param object
|
|
993
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
994
|
+
* @param {Date} param.minDate The earliest date available
|
|
995
|
+
* @returns {Boolean} Whether the back button should be disabled.
|
|
996
|
+
*/
|
|
997
|
+
function isBackDisabled({ calendars, minDate }) {
|
|
998
|
+
if (!minDate) return false;
|
|
999
|
+
const { firstDayOfMonth } = calendars[0];
|
|
1000
|
+
if ((0, date_fns.isBefore)((0, date_fns.addDays)(firstDayOfMonth, -1), minDate)) return true;
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Takes a calendars array and figures out if the forward button should be
|
|
1005
|
+
* disabled based on the maxDate allowed.
|
|
1006
|
+
* @param {Object} param The param object
|
|
1007
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
1008
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1009
|
+
* @returns {Boolean} Whether the forward button should be disabled.
|
|
1010
|
+
*/
|
|
1011
|
+
function isForwardDisabled({ calendars, maxDate }) {
|
|
1012
|
+
if (!maxDate) return false;
|
|
1013
|
+
const { lastDayOfMonth } = calendars[calendars.length - 1];
|
|
1014
|
+
if ((0, date_fns.isBefore)(maxDate, (0, date_fns.addDays)(lastDayOfMonth, 1))) return true;
|
|
1015
|
+
return false;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Figures out the months data needed based off the number of monthsToDisplay
|
|
1019
|
+
* and other options provided.
|
|
1020
|
+
* @param {Object} param The param object
|
|
1021
|
+
* @param {Date} param.date The date to start the calendar at
|
|
1022
|
+
* @param {Array.<Date>} param.selected An array of dates currently selected
|
|
1023
|
+
* @param {Number} param.monthsToDisplay The number of months to return in the calendar view
|
|
1024
|
+
* @param {Number} param.offset The number of months to offset based off the param.date given
|
|
1025
|
+
* @param {Date} param.minDate The earliest date available
|
|
1026
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1027
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1028
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1029
|
+
* @returns {Array.<Object>} An array of objects with month data
|
|
1030
|
+
*/
|
|
1031
|
+
function getCalendars({ date, selected, monthsToDisplay, offset, minDate, maxDate, firstDayOfWeek, showOutsideDays }) {
|
|
1032
|
+
const months = [];
|
|
1033
|
+
const startDate = getStartDate(date, minDate, maxDate);
|
|
1034
|
+
for (let i = 0; i < monthsToDisplay; i++) {
|
|
1035
|
+
const calendarDates = getMonths({
|
|
1036
|
+
month: startDate.getMonth() + i + offset,
|
|
1037
|
+
year: startDate.getFullYear(),
|
|
1038
|
+
selectedDates: selected,
|
|
1039
|
+
minDate,
|
|
1040
|
+
maxDate,
|
|
1041
|
+
firstDayOfWeek,
|
|
1042
|
+
showOutsideDays
|
|
1043
|
+
});
|
|
1044
|
+
months.push(calendarDates);
|
|
1045
|
+
}
|
|
1046
|
+
return months;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Figures out the actual start date based on
|
|
1050
|
+
* the min and max dates available.
|
|
1051
|
+
* @param {Date} date The we want to start the calendar at
|
|
1052
|
+
* @param {Date} minDate The earliest date available to start at
|
|
1053
|
+
* @param {Date} maxDate The latest date available to start at
|
|
1054
|
+
* @returns {Date} The actual start date
|
|
1055
|
+
*/
|
|
1056
|
+
function getStartDate(date, minDate, maxDate) {
|
|
1057
|
+
let startDate = (0, date_fns.startOfDay)(date);
|
|
1058
|
+
if (minDate) {
|
|
1059
|
+
const minDateNormalized = (0, date_fns.startOfDay)(minDate);
|
|
1060
|
+
if ((0, date_fns.isBefore)(startDate, minDateNormalized)) startDate = minDateNormalized;
|
|
1061
|
+
}
|
|
1062
|
+
if (maxDate) {
|
|
1063
|
+
const maxDateNormalized = (0, date_fns.startOfDay)(maxDate);
|
|
1064
|
+
if ((0, date_fns.isBefore)(maxDateNormalized, startDate)) startDate = maxDateNormalized;
|
|
1065
|
+
}
|
|
1066
|
+
return startDate;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Figures what week/day data to return for the given month
|
|
1070
|
+
* and year. Adds flags to day data if found in the given selectedDates,
|
|
1071
|
+
* if is selectable inside the given min and max dates, or is today.
|
|
1072
|
+
* @param {Object} param The param object
|
|
1073
|
+
* @param {Number} param.month The month to grab data for
|
|
1074
|
+
* @param {Number} param.year The year to grab data for
|
|
1075
|
+
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
1076
|
+
* @param {Date} param.minDate The earliest date available
|
|
1077
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1078
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1079
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1080
|
+
* @returns {Object} The data for the selected month/year
|
|
1081
|
+
*/
|
|
1082
|
+
function getMonths({ month, year, selectedDates, minDate, maxDate, firstDayOfWeek, showOutsideDays }) {
|
|
1083
|
+
const daysMonthYear = getNumDaysMonthYear(month, year);
|
|
1084
|
+
const daysInMonth = daysMonthYear.daysInMonth;
|
|
1085
|
+
month = daysMonthYear.month;
|
|
1086
|
+
year = daysMonthYear.year;
|
|
1087
|
+
const dates = [];
|
|
1088
|
+
for (let day = 1; day <= daysInMonth; day++) {
|
|
1089
|
+
const date = new Date(year, month, day);
|
|
1090
|
+
const dateObj = {
|
|
1091
|
+
date,
|
|
1092
|
+
selected: isSelected(selectedDates, date),
|
|
1093
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
1094
|
+
today: (0, date_fns.isToday)(date),
|
|
1095
|
+
prevMonth: false,
|
|
1096
|
+
nextMonth: false
|
|
1097
|
+
};
|
|
1098
|
+
dates.push(dateObj);
|
|
1099
|
+
}
|
|
1100
|
+
const firstDayOfMonth = new Date(year, month, 1);
|
|
1101
|
+
const lastDayOfMonth = new Date(year, month, daysInMonth);
|
|
1102
|
+
const frontWeekBuffer = fillFrontWeek({
|
|
1103
|
+
firstDayOfMonth,
|
|
1104
|
+
minDate,
|
|
1105
|
+
maxDate,
|
|
1106
|
+
selectedDates,
|
|
1107
|
+
firstDayOfWeek,
|
|
1108
|
+
showOutsideDays
|
|
1109
|
+
});
|
|
1110
|
+
const backWeekBuffer = fillBackWeek({
|
|
1111
|
+
lastDayOfMonth,
|
|
1112
|
+
minDate,
|
|
1113
|
+
maxDate,
|
|
1114
|
+
selectedDates,
|
|
1115
|
+
firstDayOfWeek,
|
|
1116
|
+
showOutsideDays
|
|
1117
|
+
});
|
|
1118
|
+
dates.unshift(...frontWeekBuffer);
|
|
1119
|
+
dates.push(...backWeekBuffer);
|
|
1120
|
+
const weeks = getWeeks(dates);
|
|
1121
|
+
return {
|
|
1122
|
+
firstDayOfMonth,
|
|
1123
|
+
lastDayOfMonth,
|
|
1124
|
+
month,
|
|
1125
|
+
year,
|
|
1126
|
+
weeks
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Fill front week with either empty buffer or dates from previous month,
|
|
1131
|
+
* depending on showOutsideDays flag
|
|
1132
|
+
* @param {Object} param The param object
|
|
1133
|
+
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
1134
|
+
* @param {Date} param.minDate The earliest date available
|
|
1135
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1136
|
+
* @param {Date} param.firstDayOfMonth First day of the month
|
|
1137
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1138
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1139
|
+
* @returns {Array.<Date>} Buffer to fill front week
|
|
1140
|
+
*/
|
|
1141
|
+
function fillFrontWeek({ firstDayOfMonth, minDate, maxDate, selectedDates, firstDayOfWeek, showOutsideDays }) {
|
|
1142
|
+
const dates = [];
|
|
1143
|
+
let firstDay = (firstDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
1144
|
+
if (showOutsideDays) {
|
|
1145
|
+
const lastDayOfPrevMonth = (0, date_fns.addDays)(firstDayOfMonth, -1);
|
|
1146
|
+
const prevDate = lastDayOfPrevMonth.getDate();
|
|
1147
|
+
const prevDateMonth = lastDayOfPrevMonth.getMonth();
|
|
1148
|
+
const prevDateYear = lastDayOfPrevMonth.getFullYear();
|
|
1149
|
+
let counter = 0;
|
|
1150
|
+
while (counter < firstDay) {
|
|
1151
|
+
const date = new Date(prevDateYear, prevDateMonth, prevDate - counter);
|
|
1152
|
+
const dateObj = {
|
|
1153
|
+
date,
|
|
1154
|
+
selected: isSelected(selectedDates, date),
|
|
1155
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
1156
|
+
today: false,
|
|
1157
|
+
prevMonth: true,
|
|
1158
|
+
nextMonth: false
|
|
1159
|
+
};
|
|
1160
|
+
dates.unshift(dateObj);
|
|
1161
|
+
counter++;
|
|
1162
|
+
}
|
|
1163
|
+
} else while (firstDay > 0) {
|
|
1164
|
+
dates.unshift("");
|
|
1165
|
+
firstDay--;
|
|
1166
|
+
}
|
|
1167
|
+
return dates;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Fill back weeks with either empty buffer or dates from next month,
|
|
1171
|
+
* depending on showOutsideDays flag
|
|
1172
|
+
* @param {Object} param The param object
|
|
1173
|
+
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
1174
|
+
* @param {Date} param.minDate The earliest date available
|
|
1175
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1176
|
+
* @param {Date} param.lastDayOfMonth Last day of the month
|
|
1177
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1178
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1179
|
+
* @returns {Array.<Date>} Buffer to fill back week
|
|
1180
|
+
*/
|
|
1181
|
+
function fillBackWeek({ lastDayOfMonth, minDate, maxDate, selectedDates, firstDayOfWeek, showOutsideDays }) {
|
|
1182
|
+
const dates = [];
|
|
1183
|
+
let lastDay = (lastDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
1184
|
+
if (showOutsideDays) {
|
|
1185
|
+
const firstDayOfNextMonth = (0, date_fns.addDays)(lastDayOfMonth, 1);
|
|
1186
|
+
const nextDateMonth = firstDayOfNextMonth.getMonth();
|
|
1187
|
+
const nextDateYear = firstDayOfNextMonth.getFullYear();
|
|
1188
|
+
let counter = 0;
|
|
1189
|
+
while (counter < 6 - lastDay) {
|
|
1190
|
+
const date = new Date(nextDateYear, nextDateMonth, 1 + counter);
|
|
1191
|
+
const dateObj = {
|
|
1192
|
+
date,
|
|
1193
|
+
selected: isSelected(selectedDates, date),
|
|
1194
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
1195
|
+
today: false,
|
|
1196
|
+
prevMonth: false,
|
|
1197
|
+
nextMonth: true
|
|
1198
|
+
};
|
|
1199
|
+
dates.push(dateObj);
|
|
1200
|
+
counter++;
|
|
1201
|
+
}
|
|
1202
|
+
} else while (lastDay < 6) {
|
|
1203
|
+
dates.push("");
|
|
1204
|
+
lastDay++;
|
|
1205
|
+
}
|
|
1206
|
+
return dates;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Normalizes month (could be overflow) and year pairs and returns the
|
|
1210
|
+
* normalized month and year along with the number of days in the month.
|
|
1211
|
+
* @param {Number} month The month to normalize
|
|
1212
|
+
* @param {Number} year The year to normalize
|
|
1213
|
+
* @returns {Object} The normalized month and year along with the number of days in the month
|
|
1214
|
+
*/
|
|
1215
|
+
function getNumDaysMonthYear(month, year) {
|
|
1216
|
+
const normalizedMonthYear = new Date(year, month, 1);
|
|
1217
|
+
month = normalizedMonthYear.getMonth();
|
|
1218
|
+
year = normalizedMonthYear.getFullYear();
|
|
1219
|
+
return {
|
|
1220
|
+
daysInMonth: 32 - new Date(year, month, 32).getDate(),
|
|
1221
|
+
month,
|
|
1222
|
+
year
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Takes an array of dates, and turns them into a multi dimensional
|
|
1227
|
+
* array with 7 entries for each week.
|
|
1228
|
+
* @param {Array.<Object>} dates An array of dates
|
|
1229
|
+
* @returns {Array} The weeks as a multi dimensional array
|
|
1230
|
+
*/
|
|
1231
|
+
function getWeeks(dates) {
|
|
1232
|
+
const weeksLength = Math.ceil(dates.length / 7);
|
|
1233
|
+
const weeks = [];
|
|
1234
|
+
for (let i = 0; i < weeksLength; i++) {
|
|
1235
|
+
weeks[i] = [];
|
|
1236
|
+
for (let x = 0; x < 7; x++) weeks[i].push(dates[i * 7 + x]);
|
|
1237
|
+
}
|
|
1238
|
+
return weeks;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Normalizes dates to the beginning of the day,
|
|
1242
|
+
* then checks to see if the day given is found
|
|
1243
|
+
* in the selectedDates.
|
|
1244
|
+
* @param {Array.<Date>} selectedDates An array of dates currently selected
|
|
1245
|
+
* @param {Date} date The date to search with against selectedDates
|
|
1246
|
+
* @returns {Boolean} Whether day is found in selectedDates
|
|
1247
|
+
*/
|
|
1248
|
+
function isSelected(selectedDates, date) {
|
|
1249
|
+
selectedDates = Array.isArray(selectedDates) ? selectedDates : [selectedDates];
|
|
1250
|
+
return selectedDates.some((selectedDate) => {
|
|
1251
|
+
if (selectedDate instanceof Date && (0, date_fns.startOfDay)(selectedDate).getTime() === (0, date_fns.startOfDay)(date).getTime()) return true;
|
|
1252
|
+
return false;
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Checks to see if the date given is
|
|
1257
|
+
* between the min and max dates.
|
|
1258
|
+
* @param {Date} minDate The earliest date available
|
|
1259
|
+
* @param {Date} maxDate The furthest date available
|
|
1260
|
+
* @param {Date} date The date to compare with
|
|
1261
|
+
* @returns {Boolean} Whether the date is between min and max date
|
|
1262
|
+
*/
|
|
1263
|
+
function isSelectable(minDate, maxDate, date) {
|
|
1264
|
+
if (minDate && (0, date_fns.isBefore)(date, minDate) || maxDate && (0, date_fns.isBefore)(maxDate, date)) return false;
|
|
1265
|
+
return true;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
//#endregion
|
|
1269
|
+
//#region src/vendor/dayzed/dayzed.ts
|
|
1270
|
+
function isOffsetControlled(propOffset) {
|
|
1271
|
+
return propOffset !== void 0;
|
|
1272
|
+
}
|
|
1273
|
+
function getOffset(prop, state) {
|
|
1274
|
+
return isOffsetControlled(prop) ? prop : state;
|
|
1275
|
+
}
|
|
1276
|
+
function getDateProps(onDateSelected, { onClick, dateObj = requiredProp("getDateProps", "dateObj"),...rest } = {}) {
|
|
1277
|
+
return {
|
|
1278
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
1279
|
+
onDateSelected?.(dateObj, event);
|
|
1280
|
+
}),
|
|
1281
|
+
disabled: !dateObj.selectable,
|
|
1282
|
+
"aria-label": dateObj.date.toDateString(),
|
|
1283
|
+
"aria-pressed": dateObj.selected,
|
|
1284
|
+
role: "button",
|
|
1285
|
+
...rest
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
function getBackProps({ minDate, offsetMonth, handleOffsetChanged }, { onClick, offset = 1, calendars = requiredProp("getBackProps", "calendars"),...rest } = {}) {
|
|
1289
|
+
return {
|
|
1290
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
1291
|
+
handleOffsetChanged(offsetMonth - subtractMonth({
|
|
1292
|
+
calendars,
|
|
1293
|
+
offset,
|
|
1294
|
+
minDate
|
|
1295
|
+
}));
|
|
1296
|
+
}),
|
|
1297
|
+
disabled: isBackDisabled({
|
|
1298
|
+
calendars,
|
|
1299
|
+
minDate
|
|
1300
|
+
}),
|
|
1301
|
+
"aria-label": `Go back ${offset} month${offset === 1 ? "" : "s"}`,
|
|
1302
|
+
...rest
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
function getForwardProps({ maxDate, offsetMonth, handleOffsetChanged }, { onClick, offset = 1, calendars = requiredProp("getForwardProps", "calendars"),...rest } = {}) {
|
|
1306
|
+
return {
|
|
1307
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
1308
|
+
handleOffsetChanged(offsetMonth + addMonth({
|
|
1309
|
+
calendars,
|
|
1310
|
+
offset,
|
|
1311
|
+
maxDate
|
|
1312
|
+
}));
|
|
1313
|
+
}),
|
|
1314
|
+
disabled: isForwardDisabled({
|
|
1315
|
+
calendars,
|
|
1316
|
+
maxDate
|
|
1317
|
+
}),
|
|
1318
|
+
"aria-label": `Go forward ${offset} month${offset === 1 ? "" : "s"}`,
|
|
1319
|
+
...rest
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
function useDayzed({ date = /* @__PURE__ */ new Date(), maxDate, minDate, monthsToDisplay = 1, firstDayOfWeek = 0, showOutsideDays = false, offset, onDateSelected, onOffsetChanged = () => {}, selected }) {
|
|
1323
|
+
const [stateOffset, setStateOffset] = (0, react.useState)(0);
|
|
1324
|
+
const offsetMonth = getOffset(offset, stateOffset);
|
|
1325
|
+
function handleOffsetChanged(newOffset) {
|
|
1326
|
+
if (!isOffsetControlled(offset)) setStateOffset(newOffset);
|
|
1327
|
+
onOffsetChanged(newOffset);
|
|
1328
|
+
}
|
|
1329
|
+
return {
|
|
1330
|
+
calendars: getCalendars({
|
|
1331
|
+
date,
|
|
1332
|
+
selected: Array.isArray(selected) ? selected : selected ? [selected] : [],
|
|
1333
|
+
monthsToDisplay,
|
|
1334
|
+
minDate,
|
|
1335
|
+
maxDate,
|
|
1336
|
+
offset: offsetMonth,
|
|
1337
|
+
firstDayOfWeek,
|
|
1338
|
+
showOutsideDays
|
|
1339
|
+
}),
|
|
1340
|
+
getDateProps: getDateProps.bind(null, onDateSelected),
|
|
1341
|
+
getBackProps: getBackProps.bind(null, {
|
|
1342
|
+
minDate,
|
|
1343
|
+
offsetMonth,
|
|
1344
|
+
handleOffsetChanged
|
|
1345
|
+
}),
|
|
1346
|
+
getForwardProps: getForwardProps.bind(null, {
|
|
1347
|
+
maxDate,
|
|
1348
|
+
offsetMonth,
|
|
1349
|
+
handleOffsetChanged
|
|
1350
|
+
})
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
|
|
930
1354
|
//#endregion
|
|
931
1355
|
//#region src/misc/defaults.ts
|
|
932
1356
|
function defaults(first, ...more) {
|
|
@@ -1352,7 +1776,7 @@ function DatePicker(props) {
|
|
|
1352
1776
|
children: label
|
|
1353
1777
|
}, index);
|
|
1354
1778
|
});
|
|
1355
|
-
const { calendars, getBackProps, getForwardProps, getDateProps } =
|
|
1779
|
+
const { calendars, getBackProps: getBackProps$1, getForwardProps: getForwardProps$1, getDateProps: getDateProps$1 } = useDayzed({
|
|
1356
1780
|
onDateSelected: () => void 0,
|
|
1357
1781
|
firstDayOfWeek,
|
|
1358
1782
|
showOutsideDays: true,
|
|
@@ -1451,7 +1875,7 @@ function DatePicker(props) {
|
|
|
1451
1875
|
children: [
|
|
1452
1876
|
/* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(IconButton$1, {
|
|
1453
1877
|
type: "button",
|
|
1454
|
-
...getBackProps({ calendars }),
|
|
1878
|
+
...getBackProps$1({ calendars }),
|
|
1455
1879
|
children: /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(ChevronRight$1, { css: { transform: "rotate3d(0, 0, 1, 180deg)" } })
|
|
1456
1880
|
}),
|
|
1457
1881
|
/* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsxs)("div", {
|
|
@@ -1464,7 +1888,7 @@ function DatePicker(props) {
|
|
|
1464
1888
|
}),
|
|
1465
1889
|
/* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(IconButton$1, {
|
|
1466
1890
|
type: "button",
|
|
1467
|
-
...getForwardProps({ calendars }),
|
|
1891
|
+
...getForwardProps$1({ calendars }),
|
|
1468
1892
|
children: /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(ChevronRight$1, {})
|
|
1469
1893
|
})
|
|
1470
1894
|
]
|
|
@@ -1542,7 +1966,7 @@ function DatePicker(props) {
|
|
|
1542
1966
|
selected,
|
|
1543
1967
|
preSelected
|
|
1544
1968
|
}),
|
|
1545
|
-
...getDateProps({ dateObj: dateObject }),
|
|
1969
|
+
...getDateProps$1({ dateObj: dateObject }),
|
|
1546
1970
|
onClick: () => {
|
|
1547
1971
|
if (dirty) if (min) set("calendar", min, date);
|
|
1548
1972
|
else set("calendar", date, max);
|
|
@@ -3225,7 +3649,7 @@ function ExpandControl({ itemId, hasDeferredChildren }) {
|
|
|
3225
3649
|
function SelectComponent({ itemId }) {
|
|
3226
3650
|
const table = useTableContext();
|
|
3227
3651
|
const Checkbox$1 = useTheme((t) => t.components.Checkbox);
|
|
3228
|
-
const isSelected = table.useState((state) => {
|
|
3652
|
+
const isSelected$1 = table.useState((state) => {
|
|
3229
3653
|
const itemIds = itemId ? [itemId] : Array.from(state.activeItemsById.keys());
|
|
3230
3654
|
return state.activeItemsById.size > 0 && itemIds.every((itemId$1) => state.selection.has(itemId$1));
|
|
3231
3655
|
});
|
|
@@ -3242,9 +3666,9 @@ function SelectComponent({ itemId }) {
|
|
|
3242
3666
|
range = item ? [item] : activeItems;
|
|
3243
3667
|
}
|
|
3244
3668
|
const newSelection = new Set(selection);
|
|
3245
|
-
for (const item of range) if (isSelected) newSelection.delete(item.id);
|
|
3669
|
+
for (const item of range) if (isSelected$1) newSelection.delete(item.id);
|
|
3246
3670
|
else newSelection.add(item.id);
|
|
3247
|
-
if (selectSyncChildren && isSelected) {
|
|
3671
|
+
if (selectSyncChildren && isSelected$1) {
|
|
3248
3672
|
for (const ancestor of getAncestors(activeItemsById, ...range)) newSelection.delete(ancestor);
|
|
3249
3673
|
for (const descendant of getDescendants(...range)) newSelection.delete(descendant);
|
|
3250
3674
|
}
|
|
@@ -3261,7 +3685,7 @@ function SelectComponent({ itemId }) {
|
|
|
3261
3685
|
justifySelf: "start",
|
|
3262
3686
|
color: "#c9cfda"
|
|
3263
3687
|
},
|
|
3264
|
-
checked: isSelected,
|
|
3688
|
+
checked: isSelected$1,
|
|
3265
3689
|
onChange: toggle$1
|
|
3266
3690
|
});
|
|
3267
3691
|
}
|