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.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __export } from "./chunk-CTAAG5j7.js";
|
|
2
|
-
import { Popover, Store, StoreScope, TableSettingsContext, TableSettingsProvider, configureTableTheme, defaultClasses, globalTableTheme, mergeThemes, throttle } from "./tableSettings-
|
|
2
|
+
import { Popover, Store, StoreScope, TableSettingsContext, TableSettingsProvider, configureTableTheme, defaultClasses, globalTableTheme, mergeThemes, throttle } from "./tableSettings-BRhj6F3f.js";
|
|
3
3
|
import "./csvExporter-DRm4V8We.js";
|
|
4
4
|
import { Fragment, cloneElement, createContext, forwardRef, memo, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { castDraft } from "immer";
|
|
6
6
|
import { ClassNames, css } from "@emotion/react";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
8
8
|
import { nanoid } from "nanoid";
|
|
9
|
-
import {
|
|
9
|
+
import { addDays, differenceInCalendarMonths, isBefore, isToday, startOfDay as startOfDay$1 } from "date-fns";
|
|
10
10
|
|
|
11
11
|
//#region src/misc/tableContext.ts
|
|
12
12
|
const TableContext = createContext(null);
|
|
@@ -244,7 +244,6 @@ const IconButton = (props) => {
|
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/theme/defaultTheme/textField.tsx
|
|
246
246
|
const TextField = ({ startIcon, endIcon, className: className$2, inputRef, onBlur,...props }) => {
|
|
247
|
-
const [focus, setFocus] = useState(false);
|
|
248
247
|
return /* @__PURE__ */ jsxs("div", {
|
|
249
248
|
className: className$2,
|
|
250
249
|
css: [{
|
|
@@ -252,10 +251,11 @@ const TextField = ({ startIcon, endIcon, className: className$2, inputRef, onBlu
|
|
|
252
251
|
display: "flex",
|
|
253
252
|
alignItems: "center",
|
|
254
253
|
border: "1px solid var(--table-textfield-border, var(--table-border, #777777))",
|
|
255
|
-
borderRadius: 4
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
borderRadius: 4,
|
|
255
|
+
"&:focus-within": {
|
|
256
|
+
border: "2px solid var(--primaryMain)",
|
|
257
|
+
margin: -1
|
|
258
|
+
}
|
|
259
259
|
}],
|
|
260
260
|
children: [
|
|
261
261
|
startIcon,
|
|
@@ -263,11 +263,7 @@ const TextField = ({ startIcon, endIcon, className: className$2, inputRef, onBlu
|
|
|
263
263
|
ref: inputRef,
|
|
264
264
|
...props,
|
|
265
265
|
value: props.value ?? "",
|
|
266
|
-
|
|
267
|
-
onBlur: (event) => {
|
|
268
|
-
setFocus(false);
|
|
269
|
-
onBlur?.(event);
|
|
270
|
-
},
|
|
266
|
+
onBlur,
|
|
271
267
|
css: {
|
|
272
268
|
minWidth: 0,
|
|
273
269
|
width: "100%",
|
|
@@ -638,7 +634,9 @@ function AutoFocusTextField(props) {
|
|
|
638
634
|
const ref = useRef(null);
|
|
639
635
|
const { isActive } = useContext(FilterControlContext);
|
|
640
636
|
useLayoutEffect(() => {
|
|
641
|
-
if (isActive && ref.current)
|
|
637
|
+
if (isActive && ref.current) setTimeout(() => {
|
|
638
|
+
ref.current?.focus();
|
|
639
|
+
});
|
|
642
640
|
}, [isActive]);
|
|
643
641
|
return /* @__PURE__ */ jsx(TextField$1, {
|
|
644
642
|
...props,
|
|
@@ -921,6 +919,430 @@ function CombinedFilter({ columnIds: inputColumnIds,...props }) {
|
|
|
921
919
|
}, columnId)) });
|
|
922
920
|
}
|
|
923
921
|
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/vendor/dayzed/utils.ts
|
|
924
|
+
/**
|
|
925
|
+
* This is intended to be used to compose event handlers
|
|
926
|
+
* They are executed in order until one of them calls
|
|
927
|
+
* `event.preventDefault()`. Not sure this is the best
|
|
928
|
+
* way to do this, but it seems legit...
|
|
929
|
+
* @param {Function} fns the event hanlder functions
|
|
930
|
+
* @return {Function} the event handler to add to an element
|
|
931
|
+
*/
|
|
932
|
+
function composeEventHandlers(...fns) {
|
|
933
|
+
return (event, ...args) => fns.some((fn) => {
|
|
934
|
+
if (fn) fn(event, ...args);
|
|
935
|
+
return event.defaultPrevented;
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Throws a helpful error message for required properties. Useful
|
|
940
|
+
* to be used as a default in destructuring or object params.
|
|
941
|
+
* @param {String} fnName the function name
|
|
942
|
+
* @param {String} propName the prop name
|
|
943
|
+
*/
|
|
944
|
+
function requiredProp(fnName, propName) {
|
|
945
|
+
throw new Error(`The property "${propName}" is required in "${fnName}"`);
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Takes a calendars array and figures out the number of months to subtract
|
|
949
|
+
* based on the current offset and the minDate allowed.
|
|
950
|
+
* @param {Object} param The param object
|
|
951
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
952
|
+
* @param {Number} param.offset The num of months to be subtracted
|
|
953
|
+
* @param {Date} param.minDate The earliest date we are allow to subtract back to
|
|
954
|
+
* @returns {Number} The number of months to subtract
|
|
955
|
+
*/
|
|
956
|
+
function subtractMonth({ calendars, offset, minDate }) {
|
|
957
|
+
if (offset > 1 && minDate) {
|
|
958
|
+
const { firstDayOfMonth } = calendars[0];
|
|
959
|
+
const diffInMonths = differenceInCalendarMonths(firstDayOfMonth, minDate);
|
|
960
|
+
if (diffInMonths < offset) offset = diffInMonths;
|
|
961
|
+
}
|
|
962
|
+
return offset;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Takes a calendars array and figures out the number of months to add
|
|
966
|
+
* based on the current offset and the maxDate allowed.
|
|
967
|
+
* @param {Object} param The param object
|
|
968
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
969
|
+
* @param {Number} param.offset The num of months to be added
|
|
970
|
+
* @param {Date} param.maxDate The furthest date we are allow to add forward to
|
|
971
|
+
* @returns {Number} The number of months to add
|
|
972
|
+
*/
|
|
973
|
+
function addMonth({ calendars, offset, maxDate }) {
|
|
974
|
+
if (offset > 1 && maxDate) {
|
|
975
|
+
const { lastDayOfMonth } = calendars[calendars.length - 1];
|
|
976
|
+
const diffInMonths = differenceInCalendarMonths(maxDate, lastDayOfMonth);
|
|
977
|
+
if (diffInMonths < offset) offset = diffInMonths;
|
|
978
|
+
}
|
|
979
|
+
return offset;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Takes a calendars array and figures out if the back button should be
|
|
983
|
+
* disabled based on the minDate allowed.
|
|
984
|
+
* @param {Object} param The param object
|
|
985
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
986
|
+
* @param {Date} param.minDate The earliest date available
|
|
987
|
+
* @returns {Boolean} Whether the back button should be disabled.
|
|
988
|
+
*/
|
|
989
|
+
function isBackDisabled({ calendars, minDate }) {
|
|
990
|
+
if (!minDate) return false;
|
|
991
|
+
const { firstDayOfMonth } = calendars[0];
|
|
992
|
+
if (isBefore(addDays(firstDayOfMonth, -1), minDate)) return true;
|
|
993
|
+
return false;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Takes a calendars array and figures out if the forward button should be
|
|
997
|
+
* disabled based on the maxDate allowed.
|
|
998
|
+
* @param {Object} param The param object
|
|
999
|
+
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
1000
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1001
|
+
* @returns {Boolean} Whether the forward button should be disabled.
|
|
1002
|
+
*/
|
|
1003
|
+
function isForwardDisabled({ calendars, maxDate }) {
|
|
1004
|
+
if (!maxDate) return false;
|
|
1005
|
+
const { lastDayOfMonth } = calendars[calendars.length - 1];
|
|
1006
|
+
if (isBefore(maxDate, addDays(lastDayOfMonth, 1))) return true;
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Figures out the months data needed based off the number of monthsToDisplay
|
|
1011
|
+
* and other options provided.
|
|
1012
|
+
* @param {Object} param The param object
|
|
1013
|
+
* @param {Date} param.date The date to start the calendar at
|
|
1014
|
+
* @param {Array.<Date>} param.selected An array of dates currently selected
|
|
1015
|
+
* @param {Number} param.monthsToDisplay The number of months to return in the calendar view
|
|
1016
|
+
* @param {Number} param.offset The number of months to offset based off the param.date given
|
|
1017
|
+
* @param {Date} param.minDate The earliest date available
|
|
1018
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1019
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1020
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1021
|
+
* @returns {Array.<Object>} An array of objects with month data
|
|
1022
|
+
*/
|
|
1023
|
+
function getCalendars({ date, selected, monthsToDisplay, offset, minDate, maxDate, firstDayOfWeek, showOutsideDays }) {
|
|
1024
|
+
const months = [];
|
|
1025
|
+
const startDate = getStartDate(date, minDate, maxDate);
|
|
1026
|
+
for (let i = 0; i < monthsToDisplay; i++) {
|
|
1027
|
+
const calendarDates = getMonths({
|
|
1028
|
+
month: startDate.getMonth() + i + offset,
|
|
1029
|
+
year: startDate.getFullYear(),
|
|
1030
|
+
selectedDates: selected,
|
|
1031
|
+
minDate,
|
|
1032
|
+
maxDate,
|
|
1033
|
+
firstDayOfWeek,
|
|
1034
|
+
showOutsideDays
|
|
1035
|
+
});
|
|
1036
|
+
months.push(calendarDates);
|
|
1037
|
+
}
|
|
1038
|
+
return months;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Figures out the actual start date based on
|
|
1042
|
+
* the min and max dates available.
|
|
1043
|
+
* @param {Date} date The we want to start the calendar at
|
|
1044
|
+
* @param {Date} minDate The earliest date available to start at
|
|
1045
|
+
* @param {Date} maxDate The latest date available to start at
|
|
1046
|
+
* @returns {Date} The actual start date
|
|
1047
|
+
*/
|
|
1048
|
+
function getStartDate(date, minDate, maxDate) {
|
|
1049
|
+
let startDate = startOfDay$1(date);
|
|
1050
|
+
if (minDate) {
|
|
1051
|
+
const minDateNormalized = startOfDay$1(minDate);
|
|
1052
|
+
if (isBefore(startDate, minDateNormalized)) startDate = minDateNormalized;
|
|
1053
|
+
}
|
|
1054
|
+
if (maxDate) {
|
|
1055
|
+
const maxDateNormalized = startOfDay$1(maxDate);
|
|
1056
|
+
if (isBefore(maxDateNormalized, startDate)) startDate = maxDateNormalized;
|
|
1057
|
+
}
|
|
1058
|
+
return startDate;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Figures what week/day data to return for the given month
|
|
1062
|
+
* and year. Adds flags to day data if found in the given selectedDates,
|
|
1063
|
+
* if is selectable inside the given min and max dates, or is today.
|
|
1064
|
+
* @param {Object} param The param object
|
|
1065
|
+
* @param {Number} param.month The month to grab data for
|
|
1066
|
+
* @param {Number} param.year The year to grab data for
|
|
1067
|
+
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
1068
|
+
* @param {Date} param.minDate The earliest date available
|
|
1069
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1070
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1071
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1072
|
+
* @returns {Object} The data for the selected month/year
|
|
1073
|
+
*/
|
|
1074
|
+
function getMonths({ month, year, selectedDates, minDate, maxDate, firstDayOfWeek, showOutsideDays }) {
|
|
1075
|
+
const daysMonthYear = getNumDaysMonthYear(month, year);
|
|
1076
|
+
const daysInMonth = daysMonthYear.daysInMonth;
|
|
1077
|
+
month = daysMonthYear.month;
|
|
1078
|
+
year = daysMonthYear.year;
|
|
1079
|
+
const dates = [];
|
|
1080
|
+
for (let day = 1; day <= daysInMonth; day++) {
|
|
1081
|
+
const date = new Date(year, month, day);
|
|
1082
|
+
const dateObj = {
|
|
1083
|
+
date,
|
|
1084
|
+
selected: isSelected(selectedDates, date),
|
|
1085
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
1086
|
+
today: isToday(date),
|
|
1087
|
+
prevMonth: false,
|
|
1088
|
+
nextMonth: false
|
|
1089
|
+
};
|
|
1090
|
+
dates.push(dateObj);
|
|
1091
|
+
}
|
|
1092
|
+
const firstDayOfMonth = new Date(year, month, 1);
|
|
1093
|
+
const lastDayOfMonth = new Date(year, month, daysInMonth);
|
|
1094
|
+
const frontWeekBuffer = fillFrontWeek({
|
|
1095
|
+
firstDayOfMonth,
|
|
1096
|
+
minDate,
|
|
1097
|
+
maxDate,
|
|
1098
|
+
selectedDates,
|
|
1099
|
+
firstDayOfWeek,
|
|
1100
|
+
showOutsideDays
|
|
1101
|
+
});
|
|
1102
|
+
const backWeekBuffer = fillBackWeek({
|
|
1103
|
+
lastDayOfMonth,
|
|
1104
|
+
minDate,
|
|
1105
|
+
maxDate,
|
|
1106
|
+
selectedDates,
|
|
1107
|
+
firstDayOfWeek,
|
|
1108
|
+
showOutsideDays
|
|
1109
|
+
});
|
|
1110
|
+
dates.unshift(...frontWeekBuffer);
|
|
1111
|
+
dates.push(...backWeekBuffer);
|
|
1112
|
+
const weeks = getWeeks(dates);
|
|
1113
|
+
return {
|
|
1114
|
+
firstDayOfMonth,
|
|
1115
|
+
lastDayOfMonth,
|
|
1116
|
+
month,
|
|
1117
|
+
year,
|
|
1118
|
+
weeks
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Fill front week with either empty buffer or dates from previous month,
|
|
1123
|
+
* depending on showOutsideDays flag
|
|
1124
|
+
* @param {Object} param The param object
|
|
1125
|
+
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
1126
|
+
* @param {Date} param.minDate The earliest date available
|
|
1127
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1128
|
+
* @param {Date} param.firstDayOfMonth First day of the month
|
|
1129
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1130
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1131
|
+
* @returns {Array.<Date>} Buffer to fill front week
|
|
1132
|
+
*/
|
|
1133
|
+
function fillFrontWeek({ firstDayOfMonth, minDate, maxDate, selectedDates, firstDayOfWeek, showOutsideDays }) {
|
|
1134
|
+
const dates = [];
|
|
1135
|
+
let firstDay = (firstDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
1136
|
+
if (showOutsideDays) {
|
|
1137
|
+
const lastDayOfPrevMonth = addDays(firstDayOfMonth, -1);
|
|
1138
|
+
const prevDate = lastDayOfPrevMonth.getDate();
|
|
1139
|
+
const prevDateMonth = lastDayOfPrevMonth.getMonth();
|
|
1140
|
+
const prevDateYear = lastDayOfPrevMonth.getFullYear();
|
|
1141
|
+
let counter = 0;
|
|
1142
|
+
while (counter < firstDay) {
|
|
1143
|
+
const date = new Date(prevDateYear, prevDateMonth, prevDate - counter);
|
|
1144
|
+
const dateObj = {
|
|
1145
|
+
date,
|
|
1146
|
+
selected: isSelected(selectedDates, date),
|
|
1147
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
1148
|
+
today: false,
|
|
1149
|
+
prevMonth: true,
|
|
1150
|
+
nextMonth: false
|
|
1151
|
+
};
|
|
1152
|
+
dates.unshift(dateObj);
|
|
1153
|
+
counter++;
|
|
1154
|
+
}
|
|
1155
|
+
} else while (firstDay > 0) {
|
|
1156
|
+
dates.unshift("");
|
|
1157
|
+
firstDay--;
|
|
1158
|
+
}
|
|
1159
|
+
return dates;
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Fill back weeks with either empty buffer or dates from next month,
|
|
1163
|
+
* depending on showOutsideDays flag
|
|
1164
|
+
* @param {Object} param The param object
|
|
1165
|
+
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
1166
|
+
* @param {Date} param.minDate The earliest date available
|
|
1167
|
+
* @param {Date} param.maxDate The furthest date available
|
|
1168
|
+
* @param {Date} param.lastDayOfMonth Last day of the month
|
|
1169
|
+
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
1170
|
+
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
1171
|
+
* @returns {Array.<Date>} Buffer to fill back week
|
|
1172
|
+
*/
|
|
1173
|
+
function fillBackWeek({ lastDayOfMonth, minDate, maxDate, selectedDates, firstDayOfWeek, showOutsideDays }) {
|
|
1174
|
+
const dates = [];
|
|
1175
|
+
let lastDay = (lastDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
1176
|
+
if (showOutsideDays) {
|
|
1177
|
+
const firstDayOfNextMonth = addDays(lastDayOfMonth, 1);
|
|
1178
|
+
const nextDateMonth = firstDayOfNextMonth.getMonth();
|
|
1179
|
+
const nextDateYear = firstDayOfNextMonth.getFullYear();
|
|
1180
|
+
let counter = 0;
|
|
1181
|
+
while (counter < 6 - lastDay) {
|
|
1182
|
+
const date = new Date(nextDateYear, nextDateMonth, 1 + counter);
|
|
1183
|
+
const dateObj = {
|
|
1184
|
+
date,
|
|
1185
|
+
selected: isSelected(selectedDates, date),
|
|
1186
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
1187
|
+
today: false,
|
|
1188
|
+
prevMonth: false,
|
|
1189
|
+
nextMonth: true
|
|
1190
|
+
};
|
|
1191
|
+
dates.push(dateObj);
|
|
1192
|
+
counter++;
|
|
1193
|
+
}
|
|
1194
|
+
} else while (lastDay < 6) {
|
|
1195
|
+
dates.push("");
|
|
1196
|
+
lastDay++;
|
|
1197
|
+
}
|
|
1198
|
+
return dates;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Normalizes month (could be overflow) and year pairs and returns the
|
|
1202
|
+
* normalized month and year along with the number of days in the month.
|
|
1203
|
+
* @param {Number} month The month to normalize
|
|
1204
|
+
* @param {Number} year The year to normalize
|
|
1205
|
+
* @returns {Object} The normalized month and year along with the number of days in the month
|
|
1206
|
+
*/
|
|
1207
|
+
function getNumDaysMonthYear(month, year) {
|
|
1208
|
+
const normalizedMonthYear = new Date(year, month, 1);
|
|
1209
|
+
month = normalizedMonthYear.getMonth();
|
|
1210
|
+
year = normalizedMonthYear.getFullYear();
|
|
1211
|
+
return {
|
|
1212
|
+
daysInMonth: 32 - new Date(year, month, 32).getDate(),
|
|
1213
|
+
month,
|
|
1214
|
+
year
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Takes an array of dates, and turns them into a multi dimensional
|
|
1219
|
+
* array with 7 entries for each week.
|
|
1220
|
+
* @param {Array.<Object>} dates An array of dates
|
|
1221
|
+
* @returns {Array} The weeks as a multi dimensional array
|
|
1222
|
+
*/
|
|
1223
|
+
function getWeeks(dates) {
|
|
1224
|
+
const weeksLength = Math.ceil(dates.length / 7);
|
|
1225
|
+
const weeks = [];
|
|
1226
|
+
for (let i = 0; i < weeksLength; i++) {
|
|
1227
|
+
weeks[i] = [];
|
|
1228
|
+
for (let x = 0; x < 7; x++) weeks[i].push(dates[i * 7 + x]);
|
|
1229
|
+
}
|
|
1230
|
+
return weeks;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Normalizes dates to the beginning of the day,
|
|
1234
|
+
* then checks to see if the day given is found
|
|
1235
|
+
* in the selectedDates.
|
|
1236
|
+
* @param {Array.<Date>} selectedDates An array of dates currently selected
|
|
1237
|
+
* @param {Date} date The date to search with against selectedDates
|
|
1238
|
+
* @returns {Boolean} Whether day is found in selectedDates
|
|
1239
|
+
*/
|
|
1240
|
+
function isSelected(selectedDates, date) {
|
|
1241
|
+
selectedDates = Array.isArray(selectedDates) ? selectedDates : [selectedDates];
|
|
1242
|
+
return selectedDates.some((selectedDate) => {
|
|
1243
|
+
if (selectedDate instanceof Date && startOfDay$1(selectedDate).getTime() === startOfDay$1(date).getTime()) return true;
|
|
1244
|
+
return false;
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Checks to see if the date given is
|
|
1249
|
+
* between the min and max dates.
|
|
1250
|
+
* @param {Date} minDate The earliest date available
|
|
1251
|
+
* @param {Date} maxDate The furthest date available
|
|
1252
|
+
* @param {Date} date The date to compare with
|
|
1253
|
+
* @returns {Boolean} Whether the date is between min and max date
|
|
1254
|
+
*/
|
|
1255
|
+
function isSelectable(minDate, maxDate, date) {
|
|
1256
|
+
if (minDate && isBefore(date, minDate) || maxDate && isBefore(maxDate, date)) return false;
|
|
1257
|
+
return true;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region src/vendor/dayzed/dayzed.ts
|
|
1262
|
+
function isOffsetControlled(propOffset) {
|
|
1263
|
+
return propOffset !== void 0;
|
|
1264
|
+
}
|
|
1265
|
+
function getOffset(prop, state) {
|
|
1266
|
+
return isOffsetControlled(prop) ? prop : state;
|
|
1267
|
+
}
|
|
1268
|
+
function getDateProps(onDateSelected, { onClick, dateObj = requiredProp("getDateProps", "dateObj"),...rest } = {}) {
|
|
1269
|
+
return {
|
|
1270
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
1271
|
+
onDateSelected?.(dateObj, event);
|
|
1272
|
+
}),
|
|
1273
|
+
disabled: !dateObj.selectable,
|
|
1274
|
+
"aria-label": dateObj.date.toDateString(),
|
|
1275
|
+
"aria-pressed": dateObj.selected,
|
|
1276
|
+
role: "button",
|
|
1277
|
+
...rest
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
function getBackProps({ minDate, offsetMonth, handleOffsetChanged }, { onClick, offset = 1, calendars = requiredProp("getBackProps", "calendars"),...rest } = {}) {
|
|
1281
|
+
return {
|
|
1282
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
1283
|
+
handleOffsetChanged(offsetMonth - subtractMonth({
|
|
1284
|
+
calendars,
|
|
1285
|
+
offset,
|
|
1286
|
+
minDate
|
|
1287
|
+
}));
|
|
1288
|
+
}),
|
|
1289
|
+
disabled: isBackDisabled({
|
|
1290
|
+
calendars,
|
|
1291
|
+
minDate
|
|
1292
|
+
}),
|
|
1293
|
+
"aria-label": `Go back ${offset} month${offset === 1 ? "" : "s"}`,
|
|
1294
|
+
...rest
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function getForwardProps({ maxDate, offsetMonth, handleOffsetChanged }, { onClick, offset = 1, calendars = requiredProp("getForwardProps", "calendars"),...rest } = {}) {
|
|
1298
|
+
return {
|
|
1299
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
1300
|
+
handleOffsetChanged(offsetMonth + addMonth({
|
|
1301
|
+
calendars,
|
|
1302
|
+
offset,
|
|
1303
|
+
maxDate
|
|
1304
|
+
}));
|
|
1305
|
+
}),
|
|
1306
|
+
disabled: isForwardDisabled({
|
|
1307
|
+
calendars,
|
|
1308
|
+
maxDate
|
|
1309
|
+
}),
|
|
1310
|
+
"aria-label": `Go forward ${offset} month${offset === 1 ? "" : "s"}`,
|
|
1311
|
+
...rest
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
function useDayzed({ date = /* @__PURE__ */ new Date(), maxDate, minDate, monthsToDisplay = 1, firstDayOfWeek = 0, showOutsideDays = false, offset, onDateSelected, onOffsetChanged = () => {}, selected }) {
|
|
1315
|
+
const [stateOffset, setStateOffset] = useState(0);
|
|
1316
|
+
const offsetMonth = getOffset(offset, stateOffset);
|
|
1317
|
+
function handleOffsetChanged(newOffset) {
|
|
1318
|
+
if (!isOffsetControlled(offset)) setStateOffset(newOffset);
|
|
1319
|
+
onOffsetChanged(newOffset);
|
|
1320
|
+
}
|
|
1321
|
+
return {
|
|
1322
|
+
calendars: getCalendars({
|
|
1323
|
+
date,
|
|
1324
|
+
selected: Array.isArray(selected) ? selected : selected ? [selected] : [],
|
|
1325
|
+
monthsToDisplay,
|
|
1326
|
+
minDate,
|
|
1327
|
+
maxDate,
|
|
1328
|
+
offset: offsetMonth,
|
|
1329
|
+
firstDayOfWeek,
|
|
1330
|
+
showOutsideDays
|
|
1331
|
+
}),
|
|
1332
|
+
getDateProps: getDateProps.bind(null, onDateSelected),
|
|
1333
|
+
getBackProps: getBackProps.bind(null, {
|
|
1334
|
+
minDate,
|
|
1335
|
+
offsetMonth,
|
|
1336
|
+
handleOffsetChanged
|
|
1337
|
+
}),
|
|
1338
|
+
getForwardProps: getForwardProps.bind(null, {
|
|
1339
|
+
maxDate,
|
|
1340
|
+
offsetMonth,
|
|
1341
|
+
handleOffsetChanged
|
|
1342
|
+
})
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
|
|
924
1346
|
//#endregion
|
|
925
1347
|
//#region src/misc/defaults.ts
|
|
926
1348
|
function defaults(first, ...more) {
|
|
@@ -1346,7 +1768,7 @@ function DatePicker(props) {
|
|
|
1346
1768
|
children: label
|
|
1347
1769
|
}, index);
|
|
1348
1770
|
});
|
|
1349
|
-
const { calendars, getBackProps, getForwardProps, getDateProps } = useDayzed({
|
|
1771
|
+
const { calendars, getBackProps: getBackProps$1, getForwardProps: getForwardProps$1, getDateProps: getDateProps$1 } = useDayzed({
|
|
1350
1772
|
onDateSelected: () => void 0,
|
|
1351
1773
|
firstDayOfWeek,
|
|
1352
1774
|
showOutsideDays: true,
|
|
@@ -1445,7 +1867,7 @@ function DatePicker(props) {
|
|
|
1445
1867
|
children: [
|
|
1446
1868
|
/* @__PURE__ */ jsx(IconButton$1, {
|
|
1447
1869
|
type: "button",
|
|
1448
|
-
...getBackProps({ calendars }),
|
|
1870
|
+
...getBackProps$1({ calendars }),
|
|
1449
1871
|
children: /* @__PURE__ */ jsx(ChevronRight$1, { css: { transform: "rotate3d(0, 0, 1, 180deg)" } })
|
|
1450
1872
|
}),
|
|
1451
1873
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -1458,7 +1880,7 @@ function DatePicker(props) {
|
|
|
1458
1880
|
}),
|
|
1459
1881
|
/* @__PURE__ */ jsx(IconButton$1, {
|
|
1460
1882
|
type: "button",
|
|
1461
|
-
...getForwardProps({ calendars }),
|
|
1883
|
+
...getForwardProps$1({ calendars }),
|
|
1462
1884
|
children: /* @__PURE__ */ jsx(ChevronRight$1, {})
|
|
1463
1885
|
})
|
|
1464
1886
|
]
|
|
@@ -1536,7 +1958,7 @@ function DatePicker(props) {
|
|
|
1536
1958
|
selected,
|
|
1537
1959
|
preSelected
|
|
1538
1960
|
}),
|
|
1539
|
-
...getDateProps({ dateObj: dateObject }),
|
|
1961
|
+
...getDateProps$1({ dateObj: dateObject }),
|
|
1540
1962
|
onClick: () => {
|
|
1541
1963
|
if (dirty) if (min) set("calendar", min, date);
|
|
1542
1964
|
else set("calendar", date, max);
|
|
@@ -2284,6 +2706,7 @@ function calcItems(state) {
|
|
|
2284
2706
|
return castArray((filter.filterBy ?? ((x) => x))(column.value(item.value), item.value)).some((value) => filter.test(filterValue, value));
|
|
2285
2707
|
});
|
|
2286
2708
|
if (isActive && item.parentId !== void 0 && item.parentId !== null) {
|
|
2709
|
+
activeSet.add(item.parentId);
|
|
2287
2710
|
if (revealFiltered && Array.from(filters.entries()).some(([id$1, filter]) => {
|
|
2288
2711
|
const filterValue = filterValues.get(id$1);
|
|
2289
2712
|
return !!filter && filterValue !== void 0 && filter.isActive(filterValue);
|
|
@@ -2292,7 +2715,6 @@ function calcItems(state) {
|
|
|
2292
2715
|
draft.expanded.add(item.parentId);
|
|
2293
2716
|
} else if (!draft.expanded.has(item.parentId)) isActive = false;
|
|
2294
2717
|
}
|
|
2295
|
-
if (isActive && item.parentId !== void 0 && item.parentId !== null) activeSet.add(item.parentId);
|
|
2296
2718
|
if (isActive) activeItemsById.set(item.id, item);
|
|
2297
2719
|
return isActive;
|
|
2298
2720
|
}).reverse();
|
|
@@ -3219,7 +3641,7 @@ function ExpandControl({ itemId, hasDeferredChildren }) {
|
|
|
3219
3641
|
function SelectComponent({ itemId }) {
|
|
3220
3642
|
const table = useTableContext();
|
|
3221
3643
|
const Checkbox$1 = useTheme((t) => t.components.Checkbox);
|
|
3222
|
-
const isSelected = table.useState((state) => {
|
|
3644
|
+
const isSelected$1 = table.useState((state) => {
|
|
3223
3645
|
const itemIds = itemId ? [itemId] : Array.from(state.activeItemsById.keys());
|
|
3224
3646
|
return state.activeItemsById.size > 0 && itemIds.every((itemId$1) => state.selection.has(itemId$1));
|
|
3225
3647
|
});
|
|
@@ -3236,9 +3658,9 @@ function SelectComponent({ itemId }) {
|
|
|
3236
3658
|
range = item ? [item] : activeItems;
|
|
3237
3659
|
}
|
|
3238
3660
|
const newSelection = new Set(selection);
|
|
3239
|
-
for (const item of range) if (isSelected) newSelection.delete(item.id);
|
|
3661
|
+
for (const item of range) if (isSelected$1) newSelection.delete(item.id);
|
|
3240
3662
|
else newSelection.add(item.id);
|
|
3241
|
-
if (selectSyncChildren && isSelected) {
|
|
3663
|
+
if (selectSyncChildren && isSelected$1) {
|
|
3242
3664
|
for (const ancestor of getAncestors(activeItemsById, ...range)) newSelection.delete(ancestor);
|
|
3243
3665
|
for (const descendant of getDescendants(...range)) newSelection.delete(descendant);
|
|
3244
3666
|
}
|
|
@@ -3255,7 +3677,7 @@ function SelectComponent({ itemId }) {
|
|
|
3255
3677
|
justifySelf: "start",
|
|
3256
3678
|
color: "#c9cfda"
|
|
3257
3679
|
},
|
|
3258
|
-
checked: isSelected,
|
|
3680
|
+
checked: isSelected$1,
|
|
3259
3681
|
onChange: toggle$1
|
|
3260
3682
|
});
|
|
3261
3683
|
}
|