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