schummar-table 0.5.0-beta-1 → 0.5.0-beta-2
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/cjs/index.js +3802 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mui4Theme.js +93 -4
- package/dist/cjs/mui4Theme.js.map +1 -1
- package/dist/cjs/mui5Theme.js +97 -4
- package/dist/cjs/mui5Theme.js.map +1 -1
- package/dist/es/index.js +3783 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/mui4Theme.js +92 -0
- package/dist/es/mui4Theme.js.map +1 -0
- package/dist/es/mui5Theme.js +96 -0
- package/dist/es/mui5Theme.js.map +1 -0
- package/dist/tableTheme.js +1990 -0
- package/dist/tableTheme.js.map +1 -0
- package/package.json +9 -9
- package/dist/assets/tableTheme.0eb513b0.js +0 -215
- package/dist/assets/tableTheme.0eb513b0.js.map +0 -1
- package/dist/assets/tableTheme.65fea986.js +0 -214
- package/dist/assets/tableTheme.65fea986.js.map +0 -1
- package/dist/assets/vendor.a5ec605d.js +0 -2475
- package/dist/assets/vendor.a5ec605d.js.map +0 -1
- package/dist/assets/vendor.c9c3328b.js +0 -2464
- package/dist/assets/vendor.c9c3328b.js.map +0 -1
- package/dist/cjs/schummar-table.js +0 -1042
- package/dist/cjs/schummar-table.js.map +0 -1
- package/dist/esm/mui4Theme.js +0 -6
- package/dist/esm/mui4Theme.js.map +0 -1
- package/dist/esm/mui5Theme.js +0 -6
- package/dist/esm/mui5Theme.js.map +0 -1
- package/dist/esm/schummar-table.js +0 -1041
- package/dist/esm/schummar-table.js.map +0 -1
|
@@ -0,0 +1,3802 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a2, b2) => {
|
|
10
|
+
for (var prop in b2 || (b2 = {}))
|
|
11
|
+
if (__hasOwnProp.call(b2, prop))
|
|
12
|
+
__defNormalProp(a2, prop, b2[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b2)) {
|
|
15
|
+
if (__propIsEnum.call(b2, prop))
|
|
16
|
+
__defNormalProp(a2, prop, b2[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a2;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports[Symbol.toStringTag] = "Module";
|
|
35
|
+
var require$$0 = require("react");
|
|
36
|
+
var tableTheme = require("../tableTheme.js");
|
|
37
|
+
require("react-dom");
|
|
38
|
+
function _interopDefaultLegacy(e2) {
|
|
39
|
+
return e2 && typeof e2 === "object" && "default" in e2 ? e2 : { "default": e2 };
|
|
40
|
+
}
|
|
41
|
+
var require$$0__default = /* @__PURE__ */ _interopDefaultLegacy(require$$0);
|
|
42
|
+
var propTypes = { exports: {} };
|
|
43
|
+
var ReactPropTypesSecret$1 = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
44
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
45
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
46
|
+
function emptyFunction() {
|
|
47
|
+
}
|
|
48
|
+
function emptyFunctionWithReset() {
|
|
49
|
+
}
|
|
50
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
51
|
+
var factoryWithThrowingShims = function() {
|
|
52
|
+
function shim2(props, propName, componentName, location, propFullName, secret) {
|
|
53
|
+
if (secret === ReactPropTypesSecret) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
var err = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
|
|
57
|
+
err.name = "Invariant Violation";
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
shim2.isRequired = shim2;
|
|
61
|
+
function getShim() {
|
|
62
|
+
return shim2;
|
|
63
|
+
}
|
|
64
|
+
var ReactPropTypes = {
|
|
65
|
+
array: shim2,
|
|
66
|
+
bigint: shim2,
|
|
67
|
+
bool: shim2,
|
|
68
|
+
func: shim2,
|
|
69
|
+
number: shim2,
|
|
70
|
+
object: shim2,
|
|
71
|
+
string: shim2,
|
|
72
|
+
symbol: shim2,
|
|
73
|
+
any: shim2,
|
|
74
|
+
arrayOf: getShim,
|
|
75
|
+
element: shim2,
|
|
76
|
+
elementType: shim2,
|
|
77
|
+
instanceOf: getShim,
|
|
78
|
+
node: shim2,
|
|
79
|
+
objectOf: getShim,
|
|
80
|
+
oneOf: getShim,
|
|
81
|
+
oneOfType: getShim,
|
|
82
|
+
shape: getShim,
|
|
83
|
+
exact: getShim,
|
|
84
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
85
|
+
resetWarningCache: emptyFunction
|
|
86
|
+
};
|
|
87
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
88
|
+
return ReactPropTypes;
|
|
89
|
+
};
|
|
90
|
+
{
|
|
91
|
+
propTypes.exports = factoryWithThrowingShims();
|
|
92
|
+
}
|
|
93
|
+
var PropTypes = propTypes.exports;
|
|
94
|
+
function _extends() {
|
|
95
|
+
_extends = Object.assign || function(target) {
|
|
96
|
+
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
97
|
+
var source = arguments[i2];
|
|
98
|
+
for (var key in source) {
|
|
99
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
100
|
+
target[key] = source[key];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return target;
|
|
105
|
+
};
|
|
106
|
+
return _extends.apply(this, arguments);
|
|
107
|
+
}
|
|
108
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
109
|
+
if (source == null)
|
|
110
|
+
return {};
|
|
111
|
+
var target = {};
|
|
112
|
+
var sourceKeys = Object.keys(source);
|
|
113
|
+
var key, i2;
|
|
114
|
+
for (i2 = 0; i2 < sourceKeys.length; i2++) {
|
|
115
|
+
key = sourceKeys[i2];
|
|
116
|
+
if (excluded.indexOf(key) >= 0)
|
|
117
|
+
continue;
|
|
118
|
+
target[key] = source[key];
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
function toInteger(dirtyNumber) {
|
|
123
|
+
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
124
|
+
return NaN;
|
|
125
|
+
}
|
|
126
|
+
var number = Number(dirtyNumber);
|
|
127
|
+
if (isNaN(number)) {
|
|
128
|
+
return number;
|
|
129
|
+
}
|
|
130
|
+
return number < 0 ? Math.ceil(number) : Math.floor(number);
|
|
131
|
+
}
|
|
132
|
+
function toDate(argument) {
|
|
133
|
+
if (arguments.length < 1) {
|
|
134
|
+
throw new TypeError("1 argument required, but only " + arguments.length + " present");
|
|
135
|
+
}
|
|
136
|
+
var argStr = Object.prototype.toString.call(argument);
|
|
137
|
+
if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") {
|
|
138
|
+
return new Date(argument.getTime());
|
|
139
|
+
} else if (typeof argument === "number" || argStr === "[object Number]") {
|
|
140
|
+
return new Date(argument);
|
|
141
|
+
} else {
|
|
142
|
+
if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") {
|
|
143
|
+
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule");
|
|
144
|
+
console.warn(new Error().stack);
|
|
145
|
+
}
|
|
146
|
+
return new Date(NaN);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function addDays(dirtyDate, dirtyAmount) {
|
|
150
|
+
if (arguments.length < 2) {
|
|
151
|
+
throw new TypeError("2 arguments required, but only " + arguments.length + " present");
|
|
152
|
+
}
|
|
153
|
+
var date = toDate(dirtyDate);
|
|
154
|
+
var amount = toInteger(dirtyAmount);
|
|
155
|
+
date.setDate(date.getDate() + amount);
|
|
156
|
+
return date;
|
|
157
|
+
}
|
|
158
|
+
function isBefore(dirtyDate, dirtyDateToCompare) {
|
|
159
|
+
if (arguments.length < 2) {
|
|
160
|
+
throw new TypeError("2 arguments required, but only " + arguments.length + " present");
|
|
161
|
+
}
|
|
162
|
+
var date = toDate(dirtyDate);
|
|
163
|
+
var dateToCompare = toDate(dirtyDateToCompare);
|
|
164
|
+
return date.getTime() < dateToCompare.getTime();
|
|
165
|
+
}
|
|
166
|
+
function startOfDay$1(dirtyDate) {
|
|
167
|
+
if (arguments.length < 1) {
|
|
168
|
+
throw new TypeError("1 argument required, but only " + arguments.length + " present");
|
|
169
|
+
}
|
|
170
|
+
var date = toDate(dirtyDate);
|
|
171
|
+
date.setHours(0, 0, 0, 0);
|
|
172
|
+
return date;
|
|
173
|
+
}
|
|
174
|
+
function isSameDay(dirtyDateLeft, dirtyDateRight) {
|
|
175
|
+
if (arguments.length < 2) {
|
|
176
|
+
throw new TypeError("2 arguments required, but only " + arguments.length + " present");
|
|
177
|
+
}
|
|
178
|
+
var dateLeftStartOfDay = startOfDay$1(dirtyDateLeft);
|
|
179
|
+
var dateRightStartOfDay = startOfDay$1(dirtyDateRight);
|
|
180
|
+
return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
|
|
181
|
+
}
|
|
182
|
+
function isToday(dirtyDate) {
|
|
183
|
+
if (arguments.length < 1) {
|
|
184
|
+
throw new TypeError("1 argument required, but only " + arguments.length + " present");
|
|
185
|
+
}
|
|
186
|
+
return isSameDay(dirtyDate, Date.now());
|
|
187
|
+
}
|
|
188
|
+
function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
|
|
189
|
+
if (arguments.length < 2) {
|
|
190
|
+
throw new TypeError("2 arguments required, but only " + arguments.length + " present");
|
|
191
|
+
}
|
|
192
|
+
var dateLeft = toDate(dirtyDateLeft);
|
|
193
|
+
var dateRight = toDate(dirtyDateRight);
|
|
194
|
+
var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
|
|
195
|
+
var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
|
|
196
|
+
return yearDiff * 12 + monthDiff;
|
|
197
|
+
}
|
|
198
|
+
function composeEventHandlers() {
|
|
199
|
+
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
200
|
+
fns[_key] = arguments[_key];
|
|
201
|
+
}
|
|
202
|
+
return function(event) {
|
|
203
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
204
|
+
args[_key2 - 1] = arguments[_key2];
|
|
205
|
+
}
|
|
206
|
+
return fns.some(function(fn2) {
|
|
207
|
+
fn2 && fn2.apply(void 0, [event].concat(args));
|
|
208
|
+
return event.defaultPrevented;
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function requiredProp(fnName, propName) {
|
|
213
|
+
throw new Error('The property "' + propName + '" is required in "' + fnName + '"');
|
|
214
|
+
}
|
|
215
|
+
function subtractMonth(_ref) {
|
|
216
|
+
var calendars = _ref.calendars, offset = _ref.offset, minDate = _ref.minDate;
|
|
217
|
+
if (offset > 1 && minDate) {
|
|
218
|
+
var firstDayOfMonth = calendars[0].firstDayOfMonth;
|
|
219
|
+
var diffInMonths = differenceInCalendarMonths(firstDayOfMonth, minDate);
|
|
220
|
+
if (diffInMonths < offset) {
|
|
221
|
+
offset = diffInMonths;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return offset;
|
|
225
|
+
}
|
|
226
|
+
function addMonth(_ref2) {
|
|
227
|
+
var calendars = _ref2.calendars, offset = _ref2.offset, maxDate = _ref2.maxDate;
|
|
228
|
+
if (offset > 1 && maxDate) {
|
|
229
|
+
var lastDayOfMonth = calendars[calendars.length - 1].lastDayOfMonth;
|
|
230
|
+
var diffInMonths = differenceInCalendarMonths(maxDate, lastDayOfMonth);
|
|
231
|
+
if (diffInMonths < offset) {
|
|
232
|
+
offset = diffInMonths;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return offset;
|
|
236
|
+
}
|
|
237
|
+
function isBackDisabled(_ref3) {
|
|
238
|
+
var calendars = _ref3.calendars, minDate = _ref3.minDate;
|
|
239
|
+
if (!minDate) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
var firstDayOfMonth = calendars[0].firstDayOfMonth;
|
|
243
|
+
var firstDayOfMonthMinusOne = addDays(firstDayOfMonth, -1);
|
|
244
|
+
if (isBefore(firstDayOfMonthMinusOne, minDate)) {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
function isForwardDisabled(_ref4) {
|
|
250
|
+
var calendars = _ref4.calendars, maxDate = _ref4.maxDate;
|
|
251
|
+
if (!maxDate) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
var lastDayOfMonth = calendars[calendars.length - 1].lastDayOfMonth;
|
|
255
|
+
var lastDayOfMonthPlusOne = addDays(lastDayOfMonth, 1);
|
|
256
|
+
if (isBefore(maxDate, lastDayOfMonthPlusOne)) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
function getCalendars(_ref5) {
|
|
262
|
+
var date = _ref5.date, selected = _ref5.selected, monthsToDisplay = _ref5.monthsToDisplay, offset = _ref5.offset, minDate = _ref5.minDate, maxDate = _ref5.maxDate, firstDayOfWeek = _ref5.firstDayOfWeek, showOutsideDays = _ref5.showOutsideDays;
|
|
263
|
+
var months2 = [];
|
|
264
|
+
var startDate = getStartDate(date, minDate, maxDate);
|
|
265
|
+
for (var i2 = 0; i2 < monthsToDisplay; i2++) {
|
|
266
|
+
var calendarDates = getMonths({
|
|
267
|
+
month: startDate.getMonth() + i2 + offset,
|
|
268
|
+
year: startDate.getFullYear(),
|
|
269
|
+
selectedDates: selected,
|
|
270
|
+
minDate,
|
|
271
|
+
maxDate,
|
|
272
|
+
firstDayOfWeek,
|
|
273
|
+
showOutsideDays
|
|
274
|
+
});
|
|
275
|
+
months2.push(calendarDates);
|
|
276
|
+
}
|
|
277
|
+
return months2;
|
|
278
|
+
}
|
|
279
|
+
function getStartDate(date, minDate, maxDate) {
|
|
280
|
+
var startDate = startOfDay$1(date);
|
|
281
|
+
if (minDate) {
|
|
282
|
+
var minDateNormalized = startOfDay$1(minDate);
|
|
283
|
+
if (isBefore(startDate, minDateNormalized)) {
|
|
284
|
+
startDate = minDateNormalized;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (maxDate) {
|
|
288
|
+
var maxDateNormalized = startOfDay$1(maxDate);
|
|
289
|
+
if (isBefore(maxDateNormalized, startDate)) {
|
|
290
|
+
startDate = maxDateNormalized;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return startDate;
|
|
294
|
+
}
|
|
295
|
+
function getMonths(_ref6) {
|
|
296
|
+
var month = _ref6.month, year = _ref6.year, selectedDates = _ref6.selectedDates, minDate = _ref6.minDate, maxDate = _ref6.maxDate, firstDayOfWeek = _ref6.firstDayOfWeek, showOutsideDays = _ref6.showOutsideDays;
|
|
297
|
+
var daysMonthYear = getNumDaysMonthYear(month, year);
|
|
298
|
+
var daysInMonth = daysMonthYear.daysInMonth;
|
|
299
|
+
month = daysMonthYear.month;
|
|
300
|
+
year = daysMonthYear.year;
|
|
301
|
+
var dates = [];
|
|
302
|
+
for (var day = 1; day <= daysInMonth; day++) {
|
|
303
|
+
var date = new Date(year, month, day);
|
|
304
|
+
var dateObj = {
|
|
305
|
+
date,
|
|
306
|
+
selected: isSelected(selectedDates, date),
|
|
307
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
308
|
+
today: isToday(date),
|
|
309
|
+
prevMonth: false,
|
|
310
|
+
nextMonth: false
|
|
311
|
+
};
|
|
312
|
+
dates.push(dateObj);
|
|
313
|
+
}
|
|
314
|
+
var firstDayOfMonth = new Date(year, month, 1);
|
|
315
|
+
var lastDayOfMonth = new Date(year, month, daysInMonth);
|
|
316
|
+
var frontWeekBuffer = fillFrontWeek({
|
|
317
|
+
firstDayOfMonth,
|
|
318
|
+
minDate,
|
|
319
|
+
maxDate,
|
|
320
|
+
selectedDates,
|
|
321
|
+
firstDayOfWeek,
|
|
322
|
+
showOutsideDays
|
|
323
|
+
});
|
|
324
|
+
var backWeekBuffer = fillBackWeek({
|
|
325
|
+
lastDayOfMonth,
|
|
326
|
+
minDate,
|
|
327
|
+
maxDate,
|
|
328
|
+
selectedDates,
|
|
329
|
+
firstDayOfWeek,
|
|
330
|
+
showOutsideDays
|
|
331
|
+
});
|
|
332
|
+
dates.unshift.apply(dates, frontWeekBuffer);
|
|
333
|
+
dates.push.apply(dates, backWeekBuffer);
|
|
334
|
+
var weeks = getWeeks(dates);
|
|
335
|
+
return {
|
|
336
|
+
firstDayOfMonth,
|
|
337
|
+
lastDayOfMonth,
|
|
338
|
+
month,
|
|
339
|
+
year,
|
|
340
|
+
weeks
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function fillFrontWeek(_ref7) {
|
|
344
|
+
var firstDayOfMonth = _ref7.firstDayOfMonth, minDate = _ref7.minDate, maxDate = _ref7.maxDate, selectedDates = _ref7.selectedDates, firstDayOfWeek = _ref7.firstDayOfWeek, showOutsideDays = _ref7.showOutsideDays;
|
|
345
|
+
var dates = [];
|
|
346
|
+
var firstDay = (firstDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
347
|
+
if (showOutsideDays) {
|
|
348
|
+
var lastDayOfPrevMonth = addDays(firstDayOfMonth, -1);
|
|
349
|
+
var prevDate = lastDayOfPrevMonth.getDate();
|
|
350
|
+
var prevDateMonth = lastDayOfPrevMonth.getMonth();
|
|
351
|
+
var prevDateYear = lastDayOfPrevMonth.getFullYear();
|
|
352
|
+
var counter = 0;
|
|
353
|
+
while (counter < firstDay) {
|
|
354
|
+
var date = new Date(prevDateYear, prevDateMonth, prevDate - counter);
|
|
355
|
+
var dateObj = {
|
|
356
|
+
date,
|
|
357
|
+
selected: isSelected(selectedDates, date),
|
|
358
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
359
|
+
today: false,
|
|
360
|
+
prevMonth: true,
|
|
361
|
+
nextMonth: false
|
|
362
|
+
};
|
|
363
|
+
dates.unshift(dateObj);
|
|
364
|
+
counter++;
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
while (firstDay > 0) {
|
|
368
|
+
dates.unshift("");
|
|
369
|
+
firstDay--;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return dates;
|
|
373
|
+
}
|
|
374
|
+
function fillBackWeek(_ref8) {
|
|
375
|
+
var lastDayOfMonth = _ref8.lastDayOfMonth, minDate = _ref8.minDate, maxDate = _ref8.maxDate, selectedDates = _ref8.selectedDates, firstDayOfWeek = _ref8.firstDayOfWeek, showOutsideDays = _ref8.showOutsideDays;
|
|
376
|
+
var dates = [];
|
|
377
|
+
var lastDay = (lastDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
378
|
+
if (showOutsideDays) {
|
|
379
|
+
var firstDayOfNextMonth = addDays(lastDayOfMonth, 1);
|
|
380
|
+
var nextDateMonth = firstDayOfNextMonth.getMonth();
|
|
381
|
+
var nextDateYear = firstDayOfNextMonth.getFullYear();
|
|
382
|
+
var counter = 0;
|
|
383
|
+
while (counter < 6 - lastDay) {
|
|
384
|
+
var date = new Date(nextDateYear, nextDateMonth, 1 + counter);
|
|
385
|
+
var dateObj = {
|
|
386
|
+
date,
|
|
387
|
+
selected: isSelected(selectedDates, date),
|
|
388
|
+
selectable: isSelectable(minDate, maxDate, date),
|
|
389
|
+
today: false,
|
|
390
|
+
prevMonth: false,
|
|
391
|
+
nextMonth: true
|
|
392
|
+
};
|
|
393
|
+
dates.push(dateObj);
|
|
394
|
+
counter++;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
while (lastDay < 6) {
|
|
398
|
+
dates.push("");
|
|
399
|
+
lastDay++;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return dates;
|
|
403
|
+
}
|
|
404
|
+
function getNumDaysMonthYear(month, year) {
|
|
405
|
+
var normalizedMonthYear = new Date(year, month, 1);
|
|
406
|
+
month = normalizedMonthYear.getMonth();
|
|
407
|
+
year = normalizedMonthYear.getFullYear();
|
|
408
|
+
var daysInMonth = 32 - new Date(year, month, 32).getDate();
|
|
409
|
+
return {
|
|
410
|
+
daysInMonth,
|
|
411
|
+
month,
|
|
412
|
+
year
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function getWeeks(dates) {
|
|
416
|
+
var weeksLength = Math.ceil(dates.length / 7);
|
|
417
|
+
var weeks = [];
|
|
418
|
+
for (var i2 = 0; i2 < weeksLength; i2++) {
|
|
419
|
+
weeks[i2] = [];
|
|
420
|
+
for (var x2 = 0; x2 < 7; x2++) {
|
|
421
|
+
weeks[i2].push(dates[i2 * 7 + x2]);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return weeks;
|
|
425
|
+
}
|
|
426
|
+
function isSelected(selectedDates, date) {
|
|
427
|
+
selectedDates = Array.isArray(selectedDates) ? selectedDates : [selectedDates];
|
|
428
|
+
return selectedDates.some(function(selectedDate) {
|
|
429
|
+
if (selectedDate instanceof Date && startOfDay$1(selectedDate).getTime() === startOfDay$1(date).getTime()) {
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
return false;
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function isSelectable(minDate, maxDate, date) {
|
|
436
|
+
if (minDate && isBefore(date, minDate) || maxDate && isBefore(maxDate, date)) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
function isOffsetControlled(propOffset) {
|
|
442
|
+
return propOffset !== void 0;
|
|
443
|
+
}
|
|
444
|
+
function getOffset(prop, state) {
|
|
445
|
+
return isOffsetControlled(prop) ? prop : state;
|
|
446
|
+
}
|
|
447
|
+
function getDateProps(onDateSelected, _temp) {
|
|
448
|
+
var _ref = _temp === void 0 ? {} : _temp, onClick = _ref.onClick, _ref$dateObj = _ref.dateObj, dateObj = _ref$dateObj === void 0 ? requiredProp("getDateProps", "dateObj") : _ref$dateObj, rest = _objectWithoutPropertiesLoose(_ref, ["onClick", "dateObj"]);
|
|
449
|
+
return _extends({
|
|
450
|
+
onClick: composeEventHandlers(onClick, function(event) {
|
|
451
|
+
onDateSelected(dateObj, event);
|
|
452
|
+
}),
|
|
453
|
+
disabled: !dateObj.selectable,
|
|
454
|
+
"aria-label": dateObj.date.toDateString(),
|
|
455
|
+
"aria-pressed": dateObj.selected,
|
|
456
|
+
role: "button"
|
|
457
|
+
}, rest);
|
|
458
|
+
}
|
|
459
|
+
function getBackProps(_ref2, _temp2) {
|
|
460
|
+
var minDate = _ref2.minDate, offsetMonth = _ref2.offsetMonth, handleOffsetChanged = _ref2.handleOffsetChanged;
|
|
461
|
+
var _ref3 = _temp2 === void 0 ? {} : _temp2, onClick = _ref3.onClick, _ref3$offset = _ref3.offset, offset = _ref3$offset === void 0 ? 1 : _ref3$offset, _ref3$calendars = _ref3.calendars, calendars = _ref3$calendars === void 0 ? requiredProp("getBackProps", "calendars") : _ref3$calendars, rest = _objectWithoutPropertiesLoose(_ref3, ["onClick", "offset", "calendars"]);
|
|
462
|
+
return _extends({
|
|
463
|
+
onClick: composeEventHandlers(onClick, function() {
|
|
464
|
+
handleOffsetChanged(offsetMonth - subtractMonth({
|
|
465
|
+
calendars,
|
|
466
|
+
offset,
|
|
467
|
+
minDate
|
|
468
|
+
}));
|
|
469
|
+
}),
|
|
470
|
+
disabled: isBackDisabled({
|
|
471
|
+
calendars,
|
|
472
|
+
offset,
|
|
473
|
+
minDate
|
|
474
|
+
}),
|
|
475
|
+
"aria-label": "Go back " + offset + " month" + (offset === 1 ? "" : "s")
|
|
476
|
+
}, rest);
|
|
477
|
+
}
|
|
478
|
+
function getForwardProps(_ref4, _temp3) {
|
|
479
|
+
var maxDate = _ref4.maxDate, offsetMonth = _ref4.offsetMonth, handleOffsetChanged = _ref4.handleOffsetChanged;
|
|
480
|
+
var _ref5 = _temp3 === void 0 ? {} : _temp3, onClick = _ref5.onClick, _ref5$offset = _ref5.offset, offset = _ref5$offset === void 0 ? 1 : _ref5$offset, _ref5$calendars = _ref5.calendars, calendars = _ref5$calendars === void 0 ? requiredProp("getForwardProps", "calendars") : _ref5$calendars, rest = _objectWithoutPropertiesLoose(_ref5, ["onClick", "offset", "calendars"]);
|
|
481
|
+
return _extends({
|
|
482
|
+
onClick: composeEventHandlers(onClick, function() {
|
|
483
|
+
handleOffsetChanged(offsetMonth + addMonth({
|
|
484
|
+
calendars,
|
|
485
|
+
offset,
|
|
486
|
+
maxDate
|
|
487
|
+
}));
|
|
488
|
+
}),
|
|
489
|
+
disabled: isForwardDisabled({
|
|
490
|
+
calendars,
|
|
491
|
+
offset,
|
|
492
|
+
maxDate
|
|
493
|
+
}),
|
|
494
|
+
"aria-label": "Go forward " + offset + " month" + (offset === 1 ? "" : "s")
|
|
495
|
+
}, rest);
|
|
496
|
+
}
|
|
497
|
+
function useDayzed(_ref6) {
|
|
498
|
+
var _ref6$date = _ref6.date, date = _ref6$date === void 0 ? new Date() : _ref6$date, maxDate = _ref6.maxDate, minDate = _ref6.minDate, _ref6$monthsToDisplay = _ref6.monthsToDisplay, monthsToDisplay = _ref6$monthsToDisplay === void 0 ? 1 : _ref6$monthsToDisplay, _ref6$firstDayOfWeek = _ref6.firstDayOfWeek, firstDayOfWeek = _ref6$firstDayOfWeek === void 0 ? 0 : _ref6$firstDayOfWeek, _ref6$showOutsideDays = _ref6.showOutsideDays, showOutsideDays = _ref6$showOutsideDays === void 0 ? false : _ref6$showOutsideDays, offset = _ref6.offset, onDateSelected = _ref6.onDateSelected, _ref6$onOffsetChanged = _ref6.onOffsetChanged, onOffsetChanged = _ref6$onOffsetChanged === void 0 ? function() {
|
|
499
|
+
} : _ref6$onOffsetChanged, selected = _ref6.selected;
|
|
500
|
+
var _useState = require$$0.useState(0), stateOffset = _useState[0], setStateOffset = _useState[1];
|
|
501
|
+
var offsetMonth = getOffset(offset, stateOffset);
|
|
502
|
+
function handleOffsetChanged(newOffset) {
|
|
503
|
+
if (!isOffsetControlled(offset)) {
|
|
504
|
+
setStateOffset(newOffset);
|
|
505
|
+
}
|
|
506
|
+
onOffsetChanged(newOffset);
|
|
507
|
+
}
|
|
508
|
+
var calendars = getCalendars({
|
|
509
|
+
date,
|
|
510
|
+
selected,
|
|
511
|
+
monthsToDisplay,
|
|
512
|
+
minDate,
|
|
513
|
+
maxDate,
|
|
514
|
+
offset: offsetMonth,
|
|
515
|
+
firstDayOfWeek,
|
|
516
|
+
showOutsideDays
|
|
517
|
+
});
|
|
518
|
+
return {
|
|
519
|
+
calendars,
|
|
520
|
+
getDateProps: getDateProps.bind(null, onDateSelected),
|
|
521
|
+
getBackProps: getBackProps.bind(null, {
|
|
522
|
+
minDate,
|
|
523
|
+
offsetMonth,
|
|
524
|
+
handleOffsetChanged
|
|
525
|
+
}),
|
|
526
|
+
getForwardProps: getForwardProps.bind(null, {
|
|
527
|
+
maxDate,
|
|
528
|
+
offsetMonth,
|
|
529
|
+
handleOffsetChanged
|
|
530
|
+
})
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
({
|
|
534
|
+
render: PropTypes.func,
|
|
535
|
+
children: PropTypes.func,
|
|
536
|
+
date: PropTypes.instanceOf(Date),
|
|
537
|
+
maxDate: PropTypes.instanceOf(Date),
|
|
538
|
+
minDate: PropTypes.instanceOf(Date),
|
|
539
|
+
monthsToDisplay: PropTypes.number,
|
|
540
|
+
firstDayOfWeek: PropTypes.number,
|
|
541
|
+
showOutsideDays: PropTypes.bool,
|
|
542
|
+
offset: PropTypes.number,
|
|
543
|
+
onDateSelected: PropTypes.func.isRequired,
|
|
544
|
+
onOffsetChanged: PropTypes.func,
|
|
545
|
+
selected: PropTypes.oneOfType([PropTypes.arrayOf(Date), PropTypes.instanceOf(Date)])
|
|
546
|
+
});
|
|
547
|
+
function useCssVariables() {
|
|
548
|
+
const table = useTableContext();
|
|
549
|
+
return table.useState((state) => ({
|
|
550
|
+
"--spacing": state.theme.spacing,
|
|
551
|
+
"--primaryMain": state.theme.colors.primary.main,
|
|
552
|
+
"--primaryLight": state.theme.colors.primary.light,
|
|
553
|
+
"--primaryContrastText": state.theme.colors.primary.contrastText,
|
|
554
|
+
"--secondaryMain": state.theme.colors.secondary.main,
|
|
555
|
+
"--secondaryLight": state.theme.colors.secondary.light,
|
|
556
|
+
"--secondaryContrastText": state.theme.colors.secondary.contrastText
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
const weekDays = [0, 1, 2, 3, 4, 5, 6];
|
|
560
|
+
const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
561
|
+
const startOfDay = (d2) => new Date(d2.getFullYear(), d2.getMonth(), d2.getDate());
|
|
562
|
+
const endOfDay = (d2) => new Date(d2.getFullYear(), d2.getMonth(), d2.getDate() + 1, 0, 0, 0, -1);
|
|
563
|
+
const today = () => {
|
|
564
|
+
const today2 = startOfDay(new Date());
|
|
565
|
+
return {
|
|
566
|
+
min: today2,
|
|
567
|
+
max: today2
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
function dateIntersect(a2, b2) {
|
|
571
|
+
if (a2 instanceof Date) {
|
|
572
|
+
a2 = {
|
|
573
|
+
min: a2,
|
|
574
|
+
max: a2
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (b2 instanceof Date) {
|
|
578
|
+
b2 = {
|
|
579
|
+
min: b2,
|
|
580
|
+
max: b2
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
if (!(a2 == null ? void 0 : a2.min) || !a2.max || !(b2 == null ? void 0 : b2.min) || !b2.max) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
return !(endOfDay(a2.max) < startOfDay(b2.min) || startOfDay(a2.min) > endOfDay(b2.max));
|
|
587
|
+
}
|
|
588
|
+
function DatePicker({
|
|
589
|
+
value,
|
|
590
|
+
onChange,
|
|
591
|
+
rangeSelect,
|
|
592
|
+
locale,
|
|
593
|
+
firstDayOfWeek = 0
|
|
594
|
+
}) {
|
|
595
|
+
const {
|
|
596
|
+
components: {
|
|
597
|
+
IconButton
|
|
598
|
+
},
|
|
599
|
+
icons: {
|
|
600
|
+
ChevronRight
|
|
601
|
+
}
|
|
602
|
+
} = useTheme();
|
|
603
|
+
const [baseDate] = require$$0.useState(new Date());
|
|
604
|
+
const [dateInView, setDateInView] = require$$0.useState(baseDate);
|
|
605
|
+
const [currentMin, setCurrentMin] = require$$0.useState();
|
|
606
|
+
const [hovered, setHovered] = require$$0.useState();
|
|
607
|
+
const min = currentMin != null ? currentMin : value instanceof Date ? value : value == null ? void 0 : value.min;
|
|
608
|
+
const max = currentMin ? void 0 : value instanceof Date ? value : value == null ? void 0 : value.max;
|
|
609
|
+
const {
|
|
610
|
+
calendars,
|
|
611
|
+
getBackProps: getBackProps2,
|
|
612
|
+
getForwardProps: getForwardProps2,
|
|
613
|
+
getDateProps: getDateProps2
|
|
614
|
+
} = useDayzed({
|
|
615
|
+
onDateSelected: () => void 0,
|
|
616
|
+
firstDayOfWeek,
|
|
617
|
+
showOutsideDays: true,
|
|
618
|
+
date: dateInView,
|
|
619
|
+
onOffsetChanged: (offset) => setDateInView(new Date(dateInView.getFullYear(), dateInView.getMonth() + offset)),
|
|
620
|
+
offset: 0
|
|
621
|
+
});
|
|
622
|
+
const formatWeekday = require$$0.useMemo(() => {
|
|
623
|
+
const {
|
|
624
|
+
format
|
|
625
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
626
|
+
weekday: "short"
|
|
627
|
+
});
|
|
628
|
+
return (weekDay) => format(new Date(Date.UTC(2021, 5, weekDay)));
|
|
629
|
+
}, [locale]);
|
|
630
|
+
require$$0.useEffect(() => setDateInView(value === null ? new Date() : value instanceof Date ? value : value.max), [value]);
|
|
631
|
+
return tableTheme.jsx("div", {
|
|
632
|
+
children: calendars.map(({
|
|
633
|
+
month,
|
|
634
|
+
year,
|
|
635
|
+
weeks
|
|
636
|
+
}) => tableTheme.jsxs("div", {
|
|
637
|
+
children: [tableTheme.jsxs("div", {
|
|
638
|
+
css: {
|
|
639
|
+
margin: "calc(var(--spacing) * 4) 0",
|
|
640
|
+
display: "grid",
|
|
641
|
+
gridAutoFlow: "column",
|
|
642
|
+
justifyContent: "space-between",
|
|
643
|
+
alignItems: "center"
|
|
644
|
+
},
|
|
645
|
+
children: [tableTheme.jsx(IconButton, __spreadProps(__spreadValues({}, getBackProps2({
|
|
646
|
+
calendars
|
|
647
|
+
})), {
|
|
648
|
+
children: tableTheme.jsx(ChevronRight, {
|
|
649
|
+
css: {
|
|
650
|
+
transform: "rotate3d(0, 0, 1, 180deg)"
|
|
651
|
+
}
|
|
652
|
+
})
|
|
653
|
+
})), tableTheme.jsxs("div", {
|
|
654
|
+
css: {
|
|
655
|
+
display: "flex"
|
|
656
|
+
},
|
|
657
|
+
children: [tableTheme.jsx(MonthSelector, {
|
|
658
|
+
value: month,
|
|
659
|
+
onChange: (month2) => setDateInView(new Date(year, month2)),
|
|
660
|
+
locale
|
|
661
|
+
}), tableTheme.jsx(YearSelector, {
|
|
662
|
+
value: year,
|
|
663
|
+
onChange: (year2) => setDateInView(new Date(year2, month))
|
|
664
|
+
})]
|
|
665
|
+
}), tableTheme.jsx(IconButton, __spreadProps(__spreadValues({}, getForwardProps2({
|
|
666
|
+
calendars
|
|
667
|
+
})), {
|
|
668
|
+
children: tableTheme.jsx(ChevronRight, {})
|
|
669
|
+
}))]
|
|
670
|
+
}), tableTheme.jsxs("div", {
|
|
671
|
+
css: {
|
|
672
|
+
display: "grid",
|
|
673
|
+
gridTemplateColumns: "repeat(7, max-content)",
|
|
674
|
+
fontWeight: "bold"
|
|
675
|
+
},
|
|
676
|
+
children: [weekDays.map((_v, weekDay) => tableTheme.jsx("div", {
|
|
677
|
+
css: {
|
|
678
|
+
justifySelf: "center",
|
|
679
|
+
marginBottom: "var(--spacing)"
|
|
680
|
+
},
|
|
681
|
+
children: formatWeekday(weekDay)
|
|
682
|
+
}, weekDay)), weeks.map((week, index) => week.map((dateObj, dayIndex) => {
|
|
683
|
+
if (!dateObj) {
|
|
684
|
+
return tableTheme.jsx("div", {});
|
|
685
|
+
}
|
|
686
|
+
const {
|
|
687
|
+
prevMonth,
|
|
688
|
+
nextMonth,
|
|
689
|
+
date,
|
|
690
|
+
today: today2
|
|
691
|
+
} = dateObj;
|
|
692
|
+
const selected = date.getTime() === (min == null ? void 0 : min.getTime()) || min && max && dateIntersect(date, {
|
|
693
|
+
min,
|
|
694
|
+
max
|
|
695
|
+
});
|
|
696
|
+
const preSelected = !selected && (date.getTime() === (hovered == null ? void 0 : hovered.getTime()) || min && !max && hovered && dateIntersect(date, min <= hovered ? {
|
|
697
|
+
min,
|
|
698
|
+
max: hovered
|
|
699
|
+
} : {
|
|
700
|
+
min: hovered,
|
|
701
|
+
max: min
|
|
702
|
+
}));
|
|
703
|
+
return tableTheme.jsx("button", __spreadProps(__spreadValues({
|
|
704
|
+
css: [{
|
|
705
|
+
padding: 10,
|
|
706
|
+
border: "1px solid transparent",
|
|
707
|
+
background: "transparent",
|
|
708
|
+
cursor: "pointer"
|
|
709
|
+
}, (prevMonth || nextMonth) && {
|
|
710
|
+
color: tableTheme.gray
|
|
711
|
+
}, today2 && {
|
|
712
|
+
border: "1px solid var(--secondaryMain)"
|
|
713
|
+
}, selected && {
|
|
714
|
+
background: "var(--primaryMain)",
|
|
715
|
+
color: "var(--primaryContrastText)"
|
|
716
|
+
}, preSelected && {
|
|
717
|
+
background: "var(--primaryLight)",
|
|
718
|
+
color: "var(--primaryContrastText)"
|
|
719
|
+
}]
|
|
720
|
+
}, getDateProps2({
|
|
721
|
+
dateObj
|
|
722
|
+
})), {
|
|
723
|
+
onClick: () => {
|
|
724
|
+
if (!rangeSelect) {
|
|
725
|
+
setCurrentMin(void 0);
|
|
726
|
+
onChange(date);
|
|
727
|
+
} else if (min && !max) {
|
|
728
|
+
setCurrentMin(void 0);
|
|
729
|
+
if (date > min) {
|
|
730
|
+
onChange({
|
|
731
|
+
min,
|
|
732
|
+
max: date
|
|
733
|
+
});
|
|
734
|
+
} else {
|
|
735
|
+
onChange({
|
|
736
|
+
min: date,
|
|
737
|
+
max: min
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
} else {
|
|
741
|
+
setCurrentMin(date);
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
onPointerOver: () => setHovered(date),
|
|
745
|
+
onPointerOut: () => setHovered(void 0),
|
|
746
|
+
children: date.getDate()
|
|
747
|
+
}), `${index}-${dayIndex}`);
|
|
748
|
+
}))]
|
|
749
|
+
})]
|
|
750
|
+
}, `${month}${year}`))
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
function MonthSelector({
|
|
754
|
+
value,
|
|
755
|
+
onChange,
|
|
756
|
+
locale
|
|
757
|
+
}) {
|
|
758
|
+
const {
|
|
759
|
+
components: {
|
|
760
|
+
Popover
|
|
761
|
+
}
|
|
762
|
+
} = useTheme();
|
|
763
|
+
const cssVariables = useCssVariables();
|
|
764
|
+
const [anchor, setAnchor] = require$$0.useState();
|
|
765
|
+
const formatMonth = require$$0.useMemo(() => {
|
|
766
|
+
const {
|
|
767
|
+
format
|
|
768
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
769
|
+
month: "long"
|
|
770
|
+
});
|
|
771
|
+
return (month) => format(new Date(2021, month));
|
|
772
|
+
}, [locale]);
|
|
773
|
+
return tableTheme.jsxs(tableTheme.Fragment, {
|
|
774
|
+
children: [tableTheme.jsx("button", {
|
|
775
|
+
css: {
|
|
776
|
+
border: "none",
|
|
777
|
+
background: "transparent",
|
|
778
|
+
fontSize: "inherit",
|
|
779
|
+
cursor: "pointer"
|
|
780
|
+
},
|
|
781
|
+
onClick: (e2) => setAnchor(e2.currentTarget),
|
|
782
|
+
children: formatMonth(value)
|
|
783
|
+
}), tableTheme.jsx(Popover, {
|
|
784
|
+
open: !!anchor,
|
|
785
|
+
anchorEl: anchor != null ? anchor : null,
|
|
786
|
+
onClose: () => setAnchor(void 0),
|
|
787
|
+
align: "center",
|
|
788
|
+
css: cssVariables,
|
|
789
|
+
children: tableTheme.jsx("div", {
|
|
790
|
+
css: {
|
|
791
|
+
display: "grid"
|
|
792
|
+
},
|
|
793
|
+
children: months.map((month) => tableTheme.jsx("button", {
|
|
794
|
+
css: [{
|
|
795
|
+
padding: "var(--spacing)",
|
|
796
|
+
border: "none",
|
|
797
|
+
background: "transparent",
|
|
798
|
+
"&:hover": {
|
|
799
|
+
background: "var(--primaryLight)"
|
|
800
|
+
}
|
|
801
|
+
}, month === value && {
|
|
802
|
+
background: "var(--primaryMain)"
|
|
803
|
+
}],
|
|
804
|
+
onClick: () => onChange(month),
|
|
805
|
+
children: formatMonth(month)
|
|
806
|
+
}, month))
|
|
807
|
+
})
|
|
808
|
+
})]
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
function YearSelector({
|
|
812
|
+
value,
|
|
813
|
+
onChange,
|
|
814
|
+
locale
|
|
815
|
+
}) {
|
|
816
|
+
const [input, setInput] = require$$0.useState();
|
|
817
|
+
function apply() {
|
|
818
|
+
onChange(Number(input));
|
|
819
|
+
setInput(void 0);
|
|
820
|
+
}
|
|
821
|
+
const formatYear = require$$0.useMemo(() => {
|
|
822
|
+
const {
|
|
823
|
+
format
|
|
824
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
825
|
+
year: "numeric"
|
|
826
|
+
});
|
|
827
|
+
return (year) => format(new Date(year, 0, 1));
|
|
828
|
+
}, [locale]);
|
|
829
|
+
if (input === void 0) {
|
|
830
|
+
return tableTheme.jsx("div", {
|
|
831
|
+
onClick: () => setInput(String(value)),
|
|
832
|
+
children: formatYear(value)
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
return tableTheme.jsx("input", {
|
|
836
|
+
css: {
|
|
837
|
+
width: "4ch"
|
|
838
|
+
},
|
|
839
|
+
value: input,
|
|
840
|
+
onChange: (e2) => {
|
|
841
|
+
if (e2.target.value.match(/^\d{0,4}$/)) {
|
|
842
|
+
setInput(e2.target.value);
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
onBlur: apply,
|
|
846
|
+
onKeyPress: (e2) => e2.key === "Enter" && apply()
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
function convertDate(x2) {
|
|
850
|
+
if (x2 instanceof Date)
|
|
851
|
+
return x2;
|
|
852
|
+
if (typeof x2 === "number" || typeof x2 === "string")
|
|
853
|
+
return new Date(x2);
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
function convertDateOrRange(x2) {
|
|
857
|
+
if (x2 instanceof Object && "min" in x2 && "max" in x2) {
|
|
858
|
+
const range = {
|
|
859
|
+
min: convertDate(x2.min),
|
|
860
|
+
max: convertDate(x2.max)
|
|
861
|
+
};
|
|
862
|
+
return range.min && range.max ? range : null;
|
|
863
|
+
}
|
|
864
|
+
return convertDate(x2);
|
|
865
|
+
}
|
|
866
|
+
function convertDateOrArray(x2) {
|
|
867
|
+
if (x2 instanceof Array)
|
|
868
|
+
return x2.map(convertDateOrRange).filter(Boolean);
|
|
869
|
+
return convertDateOrRange(x2);
|
|
870
|
+
}
|
|
871
|
+
function DateFilter(_a) {
|
|
872
|
+
var _b = _a, {
|
|
873
|
+
locale,
|
|
874
|
+
firstDayOfWeek,
|
|
875
|
+
singleSelect,
|
|
876
|
+
filterBy = convertDateOrArray
|
|
877
|
+
} = _b, props = __objRest(_b, [
|
|
878
|
+
"locale",
|
|
879
|
+
"firstDayOfWeek",
|
|
880
|
+
"singleSelect",
|
|
881
|
+
"filterBy"
|
|
882
|
+
]);
|
|
883
|
+
const {
|
|
884
|
+
components: {
|
|
885
|
+
Button
|
|
886
|
+
},
|
|
887
|
+
text
|
|
888
|
+
} = useTheme();
|
|
889
|
+
const {
|
|
890
|
+
value = null,
|
|
891
|
+
onChange
|
|
892
|
+
} = useFilter(__spreadProps(__spreadValues({}, props), {
|
|
893
|
+
filterBy,
|
|
894
|
+
id: "dateFilter",
|
|
895
|
+
isActive(filterValue) {
|
|
896
|
+
return !!filterValue;
|
|
897
|
+
},
|
|
898
|
+
test(filterValue, value2) {
|
|
899
|
+
return dateIntersect(filterValue, value2);
|
|
900
|
+
}
|
|
901
|
+
}));
|
|
902
|
+
const formatDate = require$$0.useMemo(() => {
|
|
903
|
+
const {
|
|
904
|
+
format
|
|
905
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
906
|
+
dateStyle: "medium"
|
|
907
|
+
});
|
|
908
|
+
return format;
|
|
909
|
+
}, [locale]);
|
|
910
|
+
return tableTheme.jsxs("div", {
|
|
911
|
+
css: {
|
|
912
|
+
padding: "calc(var(--spacing) * 2)",
|
|
913
|
+
display: "grid",
|
|
914
|
+
gap: "var(--spacing)",
|
|
915
|
+
justifyItems: "center"
|
|
916
|
+
},
|
|
917
|
+
children: [tableTheme.jsxs("div", {
|
|
918
|
+
css: {
|
|
919
|
+
marginBottom: "var(--spacing)",
|
|
920
|
+
display: "grid",
|
|
921
|
+
gridAutoFlow: "column",
|
|
922
|
+
gap: "calc(var(--spacing) * 4)",
|
|
923
|
+
justifyContent: "space-between",
|
|
924
|
+
alignItems: "center"
|
|
925
|
+
},
|
|
926
|
+
children: [tableTheme.jsx("div", {
|
|
927
|
+
css: {
|
|
928
|
+
minWidth: "22ch"
|
|
929
|
+
},
|
|
930
|
+
children: !value ? text.dateFilter : value instanceof Date ? formatDate(value) : [formatDate(value.min), formatDate(value.max)].join(" - ")
|
|
931
|
+
}), tableTheme.jsxs("div", {
|
|
932
|
+
css: {
|
|
933
|
+
display: "grid",
|
|
934
|
+
gridAutoFlow: "column",
|
|
935
|
+
gap: "var(--spacing)"
|
|
936
|
+
},
|
|
937
|
+
children: [tableTheme.jsx(Button, {
|
|
938
|
+
variant: "contained",
|
|
939
|
+
onClick: () => onChange(today()),
|
|
940
|
+
children: text.today
|
|
941
|
+
}), tableTheme.jsx(Button, {
|
|
942
|
+
variant: "contained",
|
|
943
|
+
onClick: () => onChange(null),
|
|
944
|
+
children: text.reset
|
|
945
|
+
})]
|
|
946
|
+
})]
|
|
947
|
+
}), tableTheme.jsx(DatePicker, {
|
|
948
|
+
rangeSelect: !singleSelect,
|
|
949
|
+
value,
|
|
950
|
+
onChange,
|
|
951
|
+
locale,
|
|
952
|
+
firstDayOfWeek
|
|
953
|
+
})]
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
const flatMap = (arr, flatMap2) => {
|
|
957
|
+
return [...arr].reduce((out, cur) => out.concat(flatMap2(cur)), []);
|
|
958
|
+
};
|
|
959
|
+
const orderBy = (arr, selectors = [], direction = []) => {
|
|
960
|
+
if (selectors.length === 0)
|
|
961
|
+
selectors = [(t2) => t2];
|
|
962
|
+
return [...arr].sort((a2, b2) => {
|
|
963
|
+
var _a, _b;
|
|
964
|
+
for (let i2 = 0; i2 < selectors.length; i2++) {
|
|
965
|
+
const _a2 = (_a = selectors[i2]) == null ? void 0 : _a.call(selectors, a2);
|
|
966
|
+
const _b2 = (_b = selectors[i2]) == null ? void 0 : _b.call(selectors, b2);
|
|
967
|
+
const dir = direction[i2] === "desc" ? -1 : 1;
|
|
968
|
+
if (_a2 > _b2)
|
|
969
|
+
return dir;
|
|
970
|
+
if (_a2 < _b2)
|
|
971
|
+
return -dir;
|
|
972
|
+
}
|
|
973
|
+
return 0;
|
|
974
|
+
});
|
|
975
|
+
};
|
|
976
|
+
const uniq = (arr) => {
|
|
977
|
+
const set = /* @__PURE__ */ new Set();
|
|
978
|
+
for (const t2 of arr)
|
|
979
|
+
set.add(t2);
|
|
980
|
+
return [...set.values()];
|
|
981
|
+
};
|
|
982
|
+
const intersect = (a2, b2) => {
|
|
983
|
+
const result = /* @__PURE__ */ new Set();
|
|
984
|
+
for (const x2 of a2)
|
|
985
|
+
if (b2.has(x2))
|
|
986
|
+
result.add(x2);
|
|
987
|
+
return result;
|
|
988
|
+
};
|
|
989
|
+
const getAncestors = (activeItemsById, ...items) => {
|
|
990
|
+
const result = /* @__PURE__ */ new Set();
|
|
991
|
+
const find = ({ parentId }) => {
|
|
992
|
+
const parent = parentId ? activeItemsById.get(parentId) : void 0;
|
|
993
|
+
if (parent && !result.has(parent.id)) {
|
|
994
|
+
result.add(parent.id);
|
|
995
|
+
find(parent);
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
items.forEach(find);
|
|
999
|
+
return result;
|
|
1000
|
+
};
|
|
1001
|
+
const getDescendants = (...items) => {
|
|
1002
|
+
const result = /* @__PURE__ */ new Set();
|
|
1003
|
+
const find = (item) => {
|
|
1004
|
+
for (const child of item.children) {
|
|
1005
|
+
if (!result.has(child.id)) {
|
|
1006
|
+
result.add(child.id);
|
|
1007
|
+
find(child);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
items.forEach(find);
|
|
1012
|
+
return result;
|
|
1013
|
+
};
|
|
1014
|
+
const asString = (x2) => {
|
|
1015
|
+
if (x2 instanceof Array)
|
|
1016
|
+
return x2.map(asString).join(", ");
|
|
1017
|
+
if (x2 instanceof Object)
|
|
1018
|
+
return JSON.stringify(x2);
|
|
1019
|
+
return String(x2 != null ? x2 : "");
|
|
1020
|
+
};
|
|
1021
|
+
const asStringOrArray = (x2) => {
|
|
1022
|
+
if (x2 instanceof Array)
|
|
1023
|
+
return x2.map(asString);
|
|
1024
|
+
return asString(x2);
|
|
1025
|
+
};
|
|
1026
|
+
const castArray = (a2) => a2 instanceof Array ? a2 : [a2];
|
|
1027
|
+
function FormControlLabel({
|
|
1028
|
+
control,
|
|
1029
|
+
label
|
|
1030
|
+
}) {
|
|
1031
|
+
return tableTheme.jsxs("label", {
|
|
1032
|
+
css: {
|
|
1033
|
+
display: "flex",
|
|
1034
|
+
alignItems: "center",
|
|
1035
|
+
cursor: "pointer",
|
|
1036
|
+
userSelect: "none",
|
|
1037
|
+
"& > *": {
|
|
1038
|
+
cursor: "pointer"
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
children: [control, tableTheme.jsx("span", {
|
|
1042
|
+
css: {
|
|
1043
|
+
marginLeft: "var(--spacing)"
|
|
1044
|
+
},
|
|
1045
|
+
children: label
|
|
1046
|
+
})]
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
class Queue {
|
|
1050
|
+
constructor() {
|
|
1051
|
+
this.q = new Array();
|
|
1052
|
+
this.isRunning = false;
|
|
1053
|
+
}
|
|
1054
|
+
run(job, replace) {
|
|
1055
|
+
return new Promise((resolve, reject) => {
|
|
1056
|
+
if (replace) {
|
|
1057
|
+
this.q = [];
|
|
1058
|
+
}
|
|
1059
|
+
this.q.push({ job, resolve, reject });
|
|
1060
|
+
if (!this.isRunning)
|
|
1061
|
+
this.start();
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
async start() {
|
|
1065
|
+
this.isRunning = true;
|
|
1066
|
+
let next;
|
|
1067
|
+
while (next = this.q.shift()) {
|
|
1068
|
+
try {
|
|
1069
|
+
const result = await next.job();
|
|
1070
|
+
next.resolve(result);
|
|
1071
|
+
} catch (e2) {
|
|
1072
|
+
next.reject(e2);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
this.isRunning = false;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
const KEYS = ["sort", "selection", "expanded", "hiddenColumns", "filterValues", "columnWidths", "columnOrder"];
|
|
1079
|
+
function stringify(value) {
|
|
1080
|
+
function prepare(value2) {
|
|
1081
|
+
if (value2 instanceof Date) {
|
|
1082
|
+
return { __date: value2.toJSON() };
|
|
1083
|
+
}
|
|
1084
|
+
if (value2 instanceof Set) {
|
|
1085
|
+
return { __set: Array.from(value2).map(prepare) };
|
|
1086
|
+
}
|
|
1087
|
+
if (value2 instanceof Map) {
|
|
1088
|
+
return { __map: Array.from(value2.entries()).map((entry) => entry.map(prepare)) };
|
|
1089
|
+
}
|
|
1090
|
+
if (value2 instanceof Array) {
|
|
1091
|
+
return value2.map(prepare);
|
|
1092
|
+
}
|
|
1093
|
+
if (value2 instanceof Object) {
|
|
1094
|
+
return Object.fromEntries(Object.entries(value2).map(([k2, v2]) => [k2, prepare(v2)]));
|
|
1095
|
+
}
|
|
1096
|
+
return value2;
|
|
1097
|
+
}
|
|
1098
|
+
return JSON.stringify(prepare(value));
|
|
1099
|
+
}
|
|
1100
|
+
function parse(value) {
|
|
1101
|
+
return JSON.parse(value, (_key, value2) => {
|
|
1102
|
+
if (value2 instanceof Object && "__date" in value2) {
|
|
1103
|
+
return new Date(value2.__date);
|
|
1104
|
+
}
|
|
1105
|
+
if (value2 instanceof Object && "__set" in value2) {
|
|
1106
|
+
return new Set(value2.__set);
|
|
1107
|
+
}
|
|
1108
|
+
if (value2 instanceof Object && "__map" in value2) {
|
|
1109
|
+
return new Map(value2.__map);
|
|
1110
|
+
}
|
|
1111
|
+
return value2;
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
function useTableStateStorage() {
|
|
1115
|
+
const table = useTableContext();
|
|
1116
|
+
const [isHydrated, setIsHydrated] = require$$0.useState(false);
|
|
1117
|
+
require$$0.useEffect(() => {
|
|
1118
|
+
const { persist } = table.getState().props;
|
|
1119
|
+
if (!persist) {
|
|
1120
|
+
setIsHydrated(true);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
let isCanceled = false;
|
|
1124
|
+
(async () => {
|
|
1125
|
+
var _a, _b;
|
|
1126
|
+
try {
|
|
1127
|
+
const { storage, id = "table", include, exclude } = persist;
|
|
1128
|
+
const json = await storage.getItem(`${id}_state`);
|
|
1129
|
+
if (isCanceled || !json)
|
|
1130
|
+
return;
|
|
1131
|
+
const data = parse(json);
|
|
1132
|
+
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "load", json, data);
|
|
1133
|
+
table.update((state) => {
|
|
1134
|
+
var _a2, _b2, _c, _d;
|
|
1135
|
+
for (const key of KEYS) {
|
|
1136
|
+
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key)) && key in data) {
|
|
1137
|
+
if (key === "filterValues") {
|
|
1138
|
+
for (const [id2, value] of data[key]) {
|
|
1139
|
+
if ((_b2 = (_a2 = state.filters.get(id2)) == null ? void 0 : _a2.persist) != null ? _b2 : true) {
|
|
1140
|
+
state.filterValues.set(id2, value);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
} else {
|
|
1144
|
+
state[key] = data[key];
|
|
1145
|
+
if (key === "expanded" || key === "hiddenColumns" || key === "selection" || key === "sort") {
|
|
1146
|
+
(_d = (_c = state.props)[`on${key.slice(0, 1).toUpperCase() + key.slice(1)}Change`]) == null ? void 0 : _d.call(_c, data[key]);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
} catch (e2) {
|
|
1153
|
+
console.error("Failed to load table state:", e2);
|
|
1154
|
+
} finally {
|
|
1155
|
+
setIsHydrated(true);
|
|
1156
|
+
}
|
|
1157
|
+
})();
|
|
1158
|
+
return () => {
|
|
1159
|
+
isCanceled = true;
|
|
1160
|
+
};
|
|
1161
|
+
}, []);
|
|
1162
|
+
require$$0.useEffect(() => {
|
|
1163
|
+
if (!isHydrated)
|
|
1164
|
+
return;
|
|
1165
|
+
const q2 = new Queue();
|
|
1166
|
+
return table.subscribe((state) => {
|
|
1167
|
+
var _a, _b;
|
|
1168
|
+
if (!state.props.persist)
|
|
1169
|
+
return;
|
|
1170
|
+
const { storage, id = "table", include, exclude } = state.props.persist;
|
|
1171
|
+
const data = {};
|
|
1172
|
+
for (const key of KEYS) {
|
|
1173
|
+
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key))) {
|
|
1174
|
+
if (key === "filterValues") {
|
|
1175
|
+
data[key] = /* @__PURE__ */ new Map();
|
|
1176
|
+
for (const [id2, value] of state.filterValues) {
|
|
1177
|
+
if ((_b = (_a = state.filters.get(id2)) == null ? void 0 : _a.persist) != null ? _b : true) {
|
|
1178
|
+
data.filterValues.set(id2, value);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
} else {
|
|
1182
|
+
data[key] = state[key];
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return { storage, id, data };
|
|
1187
|
+
}, (props) => {
|
|
1188
|
+
var _a, _b;
|
|
1189
|
+
if (!props)
|
|
1190
|
+
return;
|
|
1191
|
+
const { storage, id, data } = props;
|
|
1192
|
+
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "save", data, stringify(data));
|
|
1193
|
+
q2.run(async () => {
|
|
1194
|
+
await storage.setItem(`${id}_state`, stringify(data));
|
|
1195
|
+
}, true);
|
|
1196
|
+
}, { throttle: 1e3 });
|
|
1197
|
+
}, [isHydrated]);
|
|
1198
|
+
return isHydrated;
|
|
1199
|
+
}
|
|
1200
|
+
function n$2(n2) {
|
|
1201
|
+
for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e2 = 1; e2 < r2; e2++)
|
|
1202
|
+
t2[e2 - 1] = arguments[e2];
|
|
1203
|
+
throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) {
|
|
1204
|
+
return "'" + n3 + "'";
|
|
1205
|
+
}).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
|
|
1206
|
+
}
|
|
1207
|
+
function r$2(n2) {
|
|
1208
|
+
return !!n2 && !!n2[Q];
|
|
1209
|
+
}
|
|
1210
|
+
function t$2(n2) {
|
|
1211
|
+
return !!n2 && (function(n3) {
|
|
1212
|
+
if (!n3 || typeof n3 != "object")
|
|
1213
|
+
return false;
|
|
1214
|
+
var r2 = Object.getPrototypeOf(n3);
|
|
1215
|
+
if (r2 === null)
|
|
1216
|
+
return true;
|
|
1217
|
+
var t2 = Object.hasOwnProperty.call(r2, "constructor") && r2.constructor;
|
|
1218
|
+
return t2 === Object || typeof t2 == "function" && Function.toString.call(t2) === Z;
|
|
1219
|
+
}(n2) || Array.isArray(n2) || !!n2[L] || !!n2.constructor[L] || s(n2) || v$1(n2));
|
|
1220
|
+
}
|
|
1221
|
+
function i(n2, r2, t2) {
|
|
1222
|
+
t2 === void 0 && (t2 = false), o(n2) === 0 ? (t2 ? Object.keys : nn)(n2).forEach(function(e2) {
|
|
1223
|
+
t2 && typeof e2 == "symbol" || r2(e2, n2[e2], n2);
|
|
1224
|
+
}) : n2.forEach(function(t3, e2) {
|
|
1225
|
+
return r2(e2, t3, n2);
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
function o(n2) {
|
|
1229
|
+
var r2 = n2[Q];
|
|
1230
|
+
return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v$1(n2) ? 3 : 0;
|
|
1231
|
+
}
|
|
1232
|
+
function u$2(n2, r2) {
|
|
1233
|
+
return o(n2) === 2 ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2);
|
|
1234
|
+
}
|
|
1235
|
+
function a(n2, r2) {
|
|
1236
|
+
return o(n2) === 2 ? n2.get(r2) : n2[r2];
|
|
1237
|
+
}
|
|
1238
|
+
function f(n2, r2, t2) {
|
|
1239
|
+
var e2 = o(n2);
|
|
1240
|
+
e2 === 2 ? n2.set(r2, t2) : e2 === 3 ? (n2.delete(r2), n2.add(t2)) : n2[r2] = t2;
|
|
1241
|
+
}
|
|
1242
|
+
function c(n2, r2) {
|
|
1243
|
+
return n2 === r2 ? n2 !== 0 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2;
|
|
1244
|
+
}
|
|
1245
|
+
function s(n2) {
|
|
1246
|
+
return X && n2 instanceof Map;
|
|
1247
|
+
}
|
|
1248
|
+
function v$1(n2) {
|
|
1249
|
+
return q$2 && n2 instanceof Set;
|
|
1250
|
+
}
|
|
1251
|
+
function p$2(n2) {
|
|
1252
|
+
return n2.o || n2.t;
|
|
1253
|
+
}
|
|
1254
|
+
function l$1(n2) {
|
|
1255
|
+
if (Array.isArray(n2))
|
|
1256
|
+
return Array.prototype.slice.call(n2);
|
|
1257
|
+
var r2 = rn(n2);
|
|
1258
|
+
delete r2[Q];
|
|
1259
|
+
for (var t2 = nn(r2), e2 = 0; e2 < t2.length; e2++) {
|
|
1260
|
+
var i2 = t2[e2], o2 = r2[i2];
|
|
1261
|
+
o2.writable === false && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] });
|
|
1262
|
+
}
|
|
1263
|
+
return Object.create(Object.getPrototypeOf(n2), r2);
|
|
1264
|
+
}
|
|
1265
|
+
function d(n2, e2) {
|
|
1266
|
+
return e2 === void 0 && (e2 = false), y(n2) || r$2(n2) || !t$2(n2) ? n2 : (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h$2), Object.freeze(n2), e2 && i(n2, function(n3, r2) {
|
|
1267
|
+
return d(r2, true);
|
|
1268
|
+
}, true), n2);
|
|
1269
|
+
}
|
|
1270
|
+
function h$2() {
|
|
1271
|
+
n$2(2);
|
|
1272
|
+
}
|
|
1273
|
+
function y(n2) {
|
|
1274
|
+
return n2 == null || typeof n2 != "object" || Object.isFrozen(n2);
|
|
1275
|
+
}
|
|
1276
|
+
function b(r2) {
|
|
1277
|
+
var t2 = tn[r2];
|
|
1278
|
+
return t2 || n$2(18, r2), t2;
|
|
1279
|
+
}
|
|
1280
|
+
function m$1(n2, r2) {
|
|
1281
|
+
tn[n2] || (tn[n2] = r2);
|
|
1282
|
+
}
|
|
1283
|
+
function _() {
|
|
1284
|
+
return U;
|
|
1285
|
+
}
|
|
1286
|
+
function j(n2, r2) {
|
|
1287
|
+
r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2);
|
|
1288
|
+
}
|
|
1289
|
+
function O(n2) {
|
|
1290
|
+
g(n2), n2.p.forEach(S), n2.p = null;
|
|
1291
|
+
}
|
|
1292
|
+
function g(n2) {
|
|
1293
|
+
n2 === U && (U = n2.l);
|
|
1294
|
+
}
|
|
1295
|
+
function w$1(n2) {
|
|
1296
|
+
return U = { p: [], l: U, h: n2, m: true, _: 0 };
|
|
1297
|
+
}
|
|
1298
|
+
function S(n2) {
|
|
1299
|
+
var r2 = n2[Q];
|
|
1300
|
+
r2.i === 0 || r2.i === 1 ? r2.j() : r2.O = true;
|
|
1301
|
+
}
|
|
1302
|
+
function P(r2, e2) {
|
|
1303
|
+
e2._ = e2.p.length;
|
|
1304
|
+
var i2 = e2.p[0], o2 = r2 !== void 0 && r2 !== i2;
|
|
1305
|
+
return e2.h.g || b("ES5").S(e2, r2, o2), o2 ? (i2[Q].P && (O(e2), n$2(4)), t$2(r2) && (r2 = M(e2, r2), e2.l || x(e2, r2)), e2.u && b("Patches").M(i2[Q].t, r2, e2.u, e2.s)) : r2 = M(e2, i2, []), O(e2), e2.u && e2.v(e2.u, e2.s), r2 !== H ? r2 : void 0;
|
|
1306
|
+
}
|
|
1307
|
+
function M(n2, r2, t2) {
|
|
1308
|
+
if (y(r2))
|
|
1309
|
+
return r2;
|
|
1310
|
+
var e2 = r2[Q];
|
|
1311
|
+
if (!e2)
|
|
1312
|
+
return i(r2, function(i2, o3) {
|
|
1313
|
+
return A(n2, e2, r2, i2, o3, t2);
|
|
1314
|
+
}, true), r2;
|
|
1315
|
+
if (e2.A !== n2)
|
|
1316
|
+
return r2;
|
|
1317
|
+
if (!e2.P)
|
|
1318
|
+
return x(n2, e2.t, true), e2.t;
|
|
1319
|
+
if (!e2.I) {
|
|
1320
|
+
e2.I = true, e2.A._--;
|
|
1321
|
+
var o2 = e2.i === 4 || e2.i === 5 ? e2.o = l$1(e2.k) : e2.o;
|
|
1322
|
+
i(e2.i === 3 ? new Set(o2) : o2, function(r3, i2) {
|
|
1323
|
+
return A(n2, e2, o2, r3, i2, t2);
|
|
1324
|
+
}), x(n2, o2, false), t2 && n2.u && b("Patches").R(e2, t2, n2.u, n2.s);
|
|
1325
|
+
}
|
|
1326
|
+
return e2.o;
|
|
1327
|
+
}
|
|
1328
|
+
function A(e2, i2, o2, a2, c2, s2) {
|
|
1329
|
+
if (r$2(c2)) {
|
|
1330
|
+
var v2 = M(e2, c2, s2 && i2 && i2.i !== 3 && !u$2(i2.D, a2) ? s2.concat(a2) : void 0);
|
|
1331
|
+
if (f(o2, a2, v2), !r$2(v2))
|
|
1332
|
+
return;
|
|
1333
|
+
e2.m = false;
|
|
1334
|
+
}
|
|
1335
|
+
if (t$2(c2) && !y(c2)) {
|
|
1336
|
+
if (!e2.h.F && e2._ < 1)
|
|
1337
|
+
return;
|
|
1338
|
+
M(e2, c2), i2 && i2.A.l || x(e2, c2);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
function x(n2, r2, t2) {
|
|
1342
|
+
t2 === void 0 && (t2 = false), n2.h.F && n2.m && d(r2, t2);
|
|
1343
|
+
}
|
|
1344
|
+
function z(n2, r2) {
|
|
1345
|
+
var t2 = n2[Q];
|
|
1346
|
+
return (t2 ? p$2(t2) : n2)[r2];
|
|
1347
|
+
}
|
|
1348
|
+
function I(n2, r2) {
|
|
1349
|
+
if (r2 in n2)
|
|
1350
|
+
for (var t2 = Object.getPrototypeOf(n2); t2; ) {
|
|
1351
|
+
var e2 = Object.getOwnPropertyDescriptor(t2, r2);
|
|
1352
|
+
if (e2)
|
|
1353
|
+
return e2;
|
|
1354
|
+
t2 = Object.getPrototypeOf(t2);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
function k$1(n2) {
|
|
1358
|
+
n2.P || (n2.P = true, n2.l && k$1(n2.l));
|
|
1359
|
+
}
|
|
1360
|
+
function E(n2) {
|
|
1361
|
+
n2.o || (n2.o = l$1(n2.t));
|
|
1362
|
+
}
|
|
1363
|
+
function R(n2, r2, t2) {
|
|
1364
|
+
var e2 = s(r2) ? b("MapSet").N(r2, t2) : v$1(r2) ? b("MapSet").T(r2, t2) : n2.g ? function(n3, r3) {
|
|
1365
|
+
var t3 = Array.isArray(n3), e3 = { i: t3 ? 1 : 0, A: r3 ? r3.A : _(), P: false, I: false, D: {}, l: r3, t: n3, k: null, o: null, j: null, C: false }, i2 = e3, o2 = en;
|
|
1366
|
+
t3 && (i2 = [e3], o2 = on);
|
|
1367
|
+
var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy;
|
|
1368
|
+
return e3.k = f2, e3.j = a2, f2;
|
|
1369
|
+
}(r2, t2) : b("ES5").J(r2, t2);
|
|
1370
|
+
return (t2 ? t2.A : _()).p.push(e2), e2;
|
|
1371
|
+
}
|
|
1372
|
+
function D(e2) {
|
|
1373
|
+
return r$2(e2) || n$2(22, e2), function n2(r2) {
|
|
1374
|
+
if (!t$2(r2))
|
|
1375
|
+
return r2;
|
|
1376
|
+
var e3, u2 = r2[Q], c2 = o(r2);
|
|
1377
|
+
if (u2) {
|
|
1378
|
+
if (!u2.P && (u2.i < 4 || !b("ES5").K(u2)))
|
|
1379
|
+
return u2.t;
|
|
1380
|
+
u2.I = true, e3 = F(r2, c2), u2.I = false;
|
|
1381
|
+
} else
|
|
1382
|
+
e3 = F(r2, c2);
|
|
1383
|
+
return i(e3, function(r3, t2) {
|
|
1384
|
+
u2 && a(u2.t, r3) === t2 || f(e3, r3, n2(t2));
|
|
1385
|
+
}), c2 === 3 ? new Set(e3) : e3;
|
|
1386
|
+
}(e2);
|
|
1387
|
+
}
|
|
1388
|
+
function F(n2, r2) {
|
|
1389
|
+
switch (r2) {
|
|
1390
|
+
case 2:
|
|
1391
|
+
return new Map(n2);
|
|
1392
|
+
case 3:
|
|
1393
|
+
return Array.from(n2);
|
|
1394
|
+
}
|
|
1395
|
+
return l$1(n2);
|
|
1396
|
+
}
|
|
1397
|
+
function T() {
|
|
1398
|
+
function e2(n2) {
|
|
1399
|
+
if (!t$2(n2))
|
|
1400
|
+
return n2;
|
|
1401
|
+
if (Array.isArray(n2))
|
|
1402
|
+
return n2.map(e2);
|
|
1403
|
+
if (s(n2))
|
|
1404
|
+
return new Map(Array.from(n2.entries()).map(function(n3) {
|
|
1405
|
+
return [n3[0], e2(n3[1])];
|
|
1406
|
+
}));
|
|
1407
|
+
if (v$1(n2))
|
|
1408
|
+
return new Set(Array.from(n2).map(e2));
|
|
1409
|
+
var r2 = Object.create(Object.getPrototypeOf(n2));
|
|
1410
|
+
for (var i2 in n2)
|
|
1411
|
+
r2[i2] = e2(n2[i2]);
|
|
1412
|
+
return u$2(n2, L) && (r2[L] = n2[L]), r2;
|
|
1413
|
+
}
|
|
1414
|
+
function f2(n2) {
|
|
1415
|
+
return r$2(n2) ? e2(n2) : n2;
|
|
1416
|
+
}
|
|
1417
|
+
var c2 = "add";
|
|
1418
|
+
m$1("Patches", { $: function(r2, t2) {
|
|
1419
|
+
return t2.forEach(function(t3) {
|
|
1420
|
+
for (var i2 = t3.path, u2 = t3.op, f3 = r2, s2 = 0; s2 < i2.length - 1; s2++) {
|
|
1421
|
+
var v2 = o(f3), p2 = "" + i2[s2];
|
|
1422
|
+
v2 !== 0 && v2 !== 1 || p2 !== "__proto__" && p2 !== "constructor" || n$2(24), typeof f3 == "function" && p2 === "prototype" && n$2(24), typeof (f3 = a(f3, p2)) != "object" && n$2(15, i2.join("/"));
|
|
1423
|
+
}
|
|
1424
|
+
var l2 = o(f3), d2 = e2(t3.value), h2 = i2[i2.length - 1];
|
|
1425
|
+
switch (u2) {
|
|
1426
|
+
case "replace":
|
|
1427
|
+
switch (l2) {
|
|
1428
|
+
case 2:
|
|
1429
|
+
return f3.set(h2, d2);
|
|
1430
|
+
case 3:
|
|
1431
|
+
n$2(16);
|
|
1432
|
+
default:
|
|
1433
|
+
return f3[h2] = d2;
|
|
1434
|
+
}
|
|
1435
|
+
case c2:
|
|
1436
|
+
switch (l2) {
|
|
1437
|
+
case 1:
|
|
1438
|
+
return h2 === "-" ? f3.push(d2) : f3.splice(h2, 0, d2);
|
|
1439
|
+
case 2:
|
|
1440
|
+
return f3.set(h2, d2);
|
|
1441
|
+
case 3:
|
|
1442
|
+
return f3.add(d2);
|
|
1443
|
+
default:
|
|
1444
|
+
return f3[h2] = d2;
|
|
1445
|
+
}
|
|
1446
|
+
case "remove":
|
|
1447
|
+
switch (l2) {
|
|
1448
|
+
case 1:
|
|
1449
|
+
return f3.splice(h2, 1);
|
|
1450
|
+
case 2:
|
|
1451
|
+
return f3.delete(h2);
|
|
1452
|
+
case 3:
|
|
1453
|
+
return f3.delete(t3.value);
|
|
1454
|
+
default:
|
|
1455
|
+
return delete f3[h2];
|
|
1456
|
+
}
|
|
1457
|
+
default:
|
|
1458
|
+
n$2(17, u2);
|
|
1459
|
+
}
|
|
1460
|
+
}), r2;
|
|
1461
|
+
}, R: function(n2, r2, t2, e3) {
|
|
1462
|
+
switch (n2.i) {
|
|
1463
|
+
case 0:
|
|
1464
|
+
case 4:
|
|
1465
|
+
case 2:
|
|
1466
|
+
return function(n3, r3, t3, e4) {
|
|
1467
|
+
var o2 = n3.t, s2 = n3.o;
|
|
1468
|
+
i(n3.D, function(n4, i2) {
|
|
1469
|
+
var v2 = a(o2, n4), p2 = a(s2, n4), l2 = i2 ? u$2(o2, n4) ? "replace" : c2 : "remove";
|
|
1470
|
+
if (v2 !== p2 || l2 !== "replace") {
|
|
1471
|
+
var d2 = r3.concat(n4);
|
|
1472
|
+
t3.push(l2 === "remove" ? { op: l2, path: d2 } : { op: l2, path: d2, value: p2 }), e4.push(l2 === c2 ? { op: "remove", path: d2 } : l2 === "remove" ? { op: c2, path: d2, value: f2(v2) } : { op: "replace", path: d2, value: f2(v2) });
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
}(n2, r2, t2, e3);
|
|
1476
|
+
case 5:
|
|
1477
|
+
case 1:
|
|
1478
|
+
return function(n3, r3, t3, e4) {
|
|
1479
|
+
var i2 = n3.t, o2 = n3.D, u2 = n3.o;
|
|
1480
|
+
if (u2.length < i2.length) {
|
|
1481
|
+
var a2 = [u2, i2];
|
|
1482
|
+
i2 = a2[0], u2 = a2[1];
|
|
1483
|
+
var s2 = [e4, t3];
|
|
1484
|
+
t3 = s2[0], e4 = s2[1];
|
|
1485
|
+
}
|
|
1486
|
+
for (var v2 = 0; v2 < i2.length; v2++)
|
|
1487
|
+
if (o2[v2] && u2[v2] !== i2[v2]) {
|
|
1488
|
+
var p2 = r3.concat([v2]);
|
|
1489
|
+
t3.push({ op: "replace", path: p2, value: f2(u2[v2]) }), e4.push({ op: "replace", path: p2, value: f2(i2[v2]) });
|
|
1490
|
+
}
|
|
1491
|
+
for (var l2 = i2.length; l2 < u2.length; l2++) {
|
|
1492
|
+
var d2 = r3.concat([l2]);
|
|
1493
|
+
t3.push({ op: c2, path: d2, value: f2(u2[l2]) });
|
|
1494
|
+
}
|
|
1495
|
+
i2.length < u2.length && e4.push({ op: "replace", path: r3.concat(["length"]), value: i2.length });
|
|
1496
|
+
}(n2, r2, t2, e3);
|
|
1497
|
+
case 3:
|
|
1498
|
+
return function(n3, r3, t3, e4) {
|
|
1499
|
+
var i2 = n3.t, o2 = n3.o, u2 = 0;
|
|
1500
|
+
i2.forEach(function(n4) {
|
|
1501
|
+
if (!o2.has(n4)) {
|
|
1502
|
+
var i3 = r3.concat([u2]);
|
|
1503
|
+
t3.push({ op: "remove", path: i3, value: n4 }), e4.unshift({ op: c2, path: i3, value: n4 });
|
|
1504
|
+
}
|
|
1505
|
+
u2++;
|
|
1506
|
+
}), u2 = 0, o2.forEach(function(n4) {
|
|
1507
|
+
if (!i2.has(n4)) {
|
|
1508
|
+
var o3 = r3.concat([u2]);
|
|
1509
|
+
t3.push({ op: c2, path: o3, value: n4 }), e4.unshift({ op: "remove", path: o3, value: n4 });
|
|
1510
|
+
}
|
|
1511
|
+
u2++;
|
|
1512
|
+
});
|
|
1513
|
+
}(n2, r2, t2, e3);
|
|
1514
|
+
}
|
|
1515
|
+
}, M: function(n2, r2, t2, e3) {
|
|
1516
|
+
t2.push({ op: "replace", path: [], value: r2 === H ? void 0 : r2 }), e3.push({ op: "replace", path: [], value: n2 });
|
|
1517
|
+
} });
|
|
1518
|
+
}
|
|
1519
|
+
function C() {
|
|
1520
|
+
function r2(n2, r3) {
|
|
1521
|
+
function t2() {
|
|
1522
|
+
this.constructor = n2;
|
|
1523
|
+
}
|
|
1524
|
+
a2(n2, r3), n2.prototype = (t2.prototype = r3.prototype, new t2());
|
|
1525
|
+
}
|
|
1526
|
+
function e2(n2) {
|
|
1527
|
+
n2.o || (n2.D = /* @__PURE__ */ new Map(), n2.o = new Map(n2.t));
|
|
1528
|
+
}
|
|
1529
|
+
function o2(n2) {
|
|
1530
|
+
n2.o || (n2.o = /* @__PURE__ */ new Set(), n2.t.forEach(function(r3) {
|
|
1531
|
+
if (t$2(r3)) {
|
|
1532
|
+
var e3 = R(n2.A.h, r3, n2);
|
|
1533
|
+
n2.p.set(r3, e3), n2.o.add(e3);
|
|
1534
|
+
} else
|
|
1535
|
+
n2.o.add(r3);
|
|
1536
|
+
}));
|
|
1537
|
+
}
|
|
1538
|
+
function u2(r3) {
|
|
1539
|
+
r3.O && n$2(3, JSON.stringify(p$2(r3)));
|
|
1540
|
+
}
|
|
1541
|
+
var a2 = function(n2, r3) {
|
|
1542
|
+
return (a2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n3, r4) {
|
|
1543
|
+
n3.__proto__ = r4;
|
|
1544
|
+
} || function(n3, r4) {
|
|
1545
|
+
for (var t2 in r4)
|
|
1546
|
+
r4.hasOwnProperty(t2) && (n3[t2] = r4[t2]);
|
|
1547
|
+
})(n2, r3);
|
|
1548
|
+
}, f2 = function() {
|
|
1549
|
+
function n2(n3, r3) {
|
|
1550
|
+
return this[Q] = { i: 2, l: r3, A: r3 ? r3.A : _(), P: false, I: false, o: void 0, D: void 0, t: n3, k: this, C: false, O: false }, this;
|
|
1551
|
+
}
|
|
1552
|
+
r2(n2, Map);
|
|
1553
|
+
var o3 = n2.prototype;
|
|
1554
|
+
return Object.defineProperty(o3, "size", { get: function() {
|
|
1555
|
+
return p$2(this[Q]).size;
|
|
1556
|
+
} }), o3.has = function(n3) {
|
|
1557
|
+
return p$2(this[Q]).has(n3);
|
|
1558
|
+
}, o3.set = function(n3, r3) {
|
|
1559
|
+
var t2 = this[Q];
|
|
1560
|
+
return u2(t2), p$2(t2).has(n3) && p$2(t2).get(n3) === r3 || (e2(t2), k$1(t2), t2.D.set(n3, true), t2.o.set(n3, r3), t2.D.set(n3, true)), this;
|
|
1561
|
+
}, o3.delete = function(n3) {
|
|
1562
|
+
if (!this.has(n3))
|
|
1563
|
+
return false;
|
|
1564
|
+
var r3 = this[Q];
|
|
1565
|
+
return u2(r3), e2(r3), k$1(r3), r3.t.has(n3) ? r3.D.set(n3, false) : r3.D.delete(n3), r3.o.delete(n3), true;
|
|
1566
|
+
}, o3.clear = function() {
|
|
1567
|
+
var n3 = this[Q];
|
|
1568
|
+
u2(n3), p$2(n3).size && (e2(n3), k$1(n3), n3.D = /* @__PURE__ */ new Map(), i(n3.t, function(r3) {
|
|
1569
|
+
n3.D.set(r3, false);
|
|
1570
|
+
}), n3.o.clear());
|
|
1571
|
+
}, o3.forEach = function(n3, r3) {
|
|
1572
|
+
var t2 = this;
|
|
1573
|
+
p$2(this[Q]).forEach(function(e3, i2) {
|
|
1574
|
+
n3.call(r3, t2.get(i2), i2, t2);
|
|
1575
|
+
});
|
|
1576
|
+
}, o3.get = function(n3) {
|
|
1577
|
+
var r3 = this[Q];
|
|
1578
|
+
u2(r3);
|
|
1579
|
+
var i2 = p$2(r3).get(n3);
|
|
1580
|
+
if (r3.I || !t$2(i2))
|
|
1581
|
+
return i2;
|
|
1582
|
+
if (i2 !== r3.t.get(n3))
|
|
1583
|
+
return i2;
|
|
1584
|
+
var o4 = R(r3.A.h, i2, r3);
|
|
1585
|
+
return e2(r3), r3.o.set(n3, o4), o4;
|
|
1586
|
+
}, o3.keys = function() {
|
|
1587
|
+
return p$2(this[Q]).keys();
|
|
1588
|
+
}, o3.values = function() {
|
|
1589
|
+
var n3, r3 = this, t2 = this.keys();
|
|
1590
|
+
return (n3 = {})[V] = function() {
|
|
1591
|
+
return r3.values();
|
|
1592
|
+
}, n3.next = function() {
|
|
1593
|
+
var n4 = t2.next();
|
|
1594
|
+
return n4.done ? n4 : { done: false, value: r3.get(n4.value) };
|
|
1595
|
+
}, n3;
|
|
1596
|
+
}, o3.entries = function() {
|
|
1597
|
+
var n3, r3 = this, t2 = this.keys();
|
|
1598
|
+
return (n3 = {})[V] = function() {
|
|
1599
|
+
return r3.entries();
|
|
1600
|
+
}, n3.next = function() {
|
|
1601
|
+
var n4 = t2.next();
|
|
1602
|
+
if (n4.done)
|
|
1603
|
+
return n4;
|
|
1604
|
+
var e3 = r3.get(n4.value);
|
|
1605
|
+
return { done: false, value: [n4.value, e3] };
|
|
1606
|
+
}, n3;
|
|
1607
|
+
}, o3[V] = function() {
|
|
1608
|
+
return this.entries();
|
|
1609
|
+
}, n2;
|
|
1610
|
+
}(), c2 = function() {
|
|
1611
|
+
function n2(n3, r3) {
|
|
1612
|
+
return this[Q] = { i: 3, l: r3, A: r3 ? r3.A : _(), P: false, I: false, o: void 0, t: n3, k: this, p: /* @__PURE__ */ new Map(), O: false, C: false }, this;
|
|
1613
|
+
}
|
|
1614
|
+
r2(n2, Set);
|
|
1615
|
+
var t2 = n2.prototype;
|
|
1616
|
+
return Object.defineProperty(t2, "size", { get: function() {
|
|
1617
|
+
return p$2(this[Q]).size;
|
|
1618
|
+
} }), t2.has = function(n3) {
|
|
1619
|
+
var r3 = this[Q];
|
|
1620
|
+
return u2(r3), r3.o ? !!r3.o.has(n3) || !(!r3.p.has(n3) || !r3.o.has(r3.p.get(n3))) : r3.t.has(n3);
|
|
1621
|
+
}, t2.add = function(n3) {
|
|
1622
|
+
var r3 = this[Q];
|
|
1623
|
+
return u2(r3), this.has(n3) || (o2(r3), k$1(r3), r3.o.add(n3)), this;
|
|
1624
|
+
}, t2.delete = function(n3) {
|
|
1625
|
+
if (!this.has(n3))
|
|
1626
|
+
return false;
|
|
1627
|
+
var r3 = this[Q];
|
|
1628
|
+
return u2(r3), o2(r3), k$1(r3), r3.o.delete(n3) || !!r3.p.has(n3) && r3.o.delete(r3.p.get(n3));
|
|
1629
|
+
}, t2.clear = function() {
|
|
1630
|
+
var n3 = this[Q];
|
|
1631
|
+
u2(n3), p$2(n3).size && (o2(n3), k$1(n3), n3.o.clear());
|
|
1632
|
+
}, t2.values = function() {
|
|
1633
|
+
var n3 = this[Q];
|
|
1634
|
+
return u2(n3), o2(n3), n3.o.values();
|
|
1635
|
+
}, t2.entries = function() {
|
|
1636
|
+
var n3 = this[Q];
|
|
1637
|
+
return u2(n3), o2(n3), n3.o.entries();
|
|
1638
|
+
}, t2.keys = function() {
|
|
1639
|
+
return this.values();
|
|
1640
|
+
}, t2[V] = function() {
|
|
1641
|
+
return this.values();
|
|
1642
|
+
}, t2.forEach = function(n3, r3) {
|
|
1643
|
+
for (var t3 = this.values(), e3 = t3.next(); !e3.done; )
|
|
1644
|
+
n3.call(r3, e3.value, e3.value, this), e3 = t3.next();
|
|
1645
|
+
}, n2;
|
|
1646
|
+
}();
|
|
1647
|
+
m$1("MapSet", { N: function(n2, r3) {
|
|
1648
|
+
return new f2(n2, r3);
|
|
1649
|
+
}, T: function(n2, r3) {
|
|
1650
|
+
return new c2(n2, r3);
|
|
1651
|
+
} });
|
|
1652
|
+
}
|
|
1653
|
+
function K(n2) {
|
|
1654
|
+
return n2;
|
|
1655
|
+
}
|
|
1656
|
+
var G, U, W = typeof Symbol != "undefined" && typeof Symbol("x") == "symbol", X = typeof Map != "undefined", q$2 = typeof Set != "undefined", B = typeof Proxy != "undefined" && Proxy.revocable !== void 0 && typeof Reflect != "undefined", H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G), L = W ? Symbol.for("immer-draftable") : "__$immer_draftable", Q = W ? Symbol.for("immer-state") : "__$immer_state", V = typeof Symbol != "undefined" && Symbol.iterator || "@@iterator", Z = "" + Object.prototype.constructor, nn = typeof Reflect != "undefined" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(n2) {
|
|
1657
|
+
return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2));
|
|
1658
|
+
} : Object.getOwnPropertyNames, rn = Object.getOwnPropertyDescriptors || function(n2) {
|
|
1659
|
+
var r2 = {};
|
|
1660
|
+
return nn(n2).forEach(function(t2) {
|
|
1661
|
+
r2[t2] = Object.getOwnPropertyDescriptor(n2, t2);
|
|
1662
|
+
}), r2;
|
|
1663
|
+
}, tn = {}, en = { get: function(n2, r2) {
|
|
1664
|
+
if (r2 === Q)
|
|
1665
|
+
return n2;
|
|
1666
|
+
var e2 = p$2(n2);
|
|
1667
|
+
if (!u$2(e2, r2))
|
|
1668
|
+
return function(n3, r3, t2) {
|
|
1669
|
+
var e3, i3 = I(r3, t2);
|
|
1670
|
+
return i3 ? "value" in i3 ? i3.value : (e3 = i3.get) === null || e3 === void 0 ? void 0 : e3.call(n3.k) : void 0;
|
|
1671
|
+
}(n2, e2, r2);
|
|
1672
|
+
var i2 = e2[r2];
|
|
1673
|
+
return n2.I || !t$2(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = R(n2.A.h, i2, n2)) : i2;
|
|
1674
|
+
}, has: function(n2, r2) {
|
|
1675
|
+
return r2 in p$2(n2);
|
|
1676
|
+
}, ownKeys: function(n2) {
|
|
1677
|
+
return Reflect.ownKeys(p$2(n2));
|
|
1678
|
+
}, set: function(n2, r2, t2) {
|
|
1679
|
+
var e2 = I(p$2(n2), r2);
|
|
1680
|
+
if (e2 == null ? void 0 : e2.set)
|
|
1681
|
+
return e2.set.call(n2.k, t2), true;
|
|
1682
|
+
if (!n2.P) {
|
|
1683
|
+
var i2 = z(p$2(n2), r2), o2 = i2 == null ? void 0 : i2[Q];
|
|
1684
|
+
if (o2 && o2.t === t2)
|
|
1685
|
+
return n2.o[r2] = t2, n2.D[r2] = false, true;
|
|
1686
|
+
if (c(t2, i2) && (t2 !== void 0 || u$2(n2.t, r2)))
|
|
1687
|
+
return true;
|
|
1688
|
+
E(n2), k$1(n2);
|
|
1689
|
+
}
|
|
1690
|
+
return n2.o[r2] === t2 && typeof t2 != "number" && (t2 !== void 0 || r2 in n2.o) || (n2.o[r2] = t2, n2.D[r2] = true, true);
|
|
1691
|
+
}, deleteProperty: function(n2, r2) {
|
|
1692
|
+
return z(n2.t, r2) !== void 0 || r2 in n2.t ? (n2.D[r2] = false, E(n2), k$1(n2)) : delete n2.D[r2], n2.o && delete n2.o[r2], true;
|
|
1693
|
+
}, getOwnPropertyDescriptor: function(n2, r2) {
|
|
1694
|
+
var t2 = p$2(n2), e2 = Reflect.getOwnPropertyDescriptor(t2, r2);
|
|
1695
|
+
return e2 ? { writable: true, configurable: n2.i !== 1 || r2 !== "length", enumerable: e2.enumerable, value: t2[r2] } : e2;
|
|
1696
|
+
}, defineProperty: function() {
|
|
1697
|
+
n$2(11);
|
|
1698
|
+
}, getPrototypeOf: function(n2) {
|
|
1699
|
+
return Object.getPrototypeOf(n2.t);
|
|
1700
|
+
}, setPrototypeOf: function() {
|
|
1701
|
+
n$2(12);
|
|
1702
|
+
} }, on = {};
|
|
1703
|
+
i(en, function(n2, r2) {
|
|
1704
|
+
on[n2] = function() {
|
|
1705
|
+
return arguments[0] = arguments[0][0], r2.apply(this, arguments);
|
|
1706
|
+
};
|
|
1707
|
+
}), on.deleteProperty = function(r2, t2) {
|
|
1708
|
+
return on.set.call(this, r2, t2, void 0);
|
|
1709
|
+
}, on.set = function(r2, t2, e2) {
|
|
1710
|
+
return en.set.call(this, r2[0], t2, e2, r2[0]);
|
|
1711
|
+
};
|
|
1712
|
+
var un = function() {
|
|
1713
|
+
function e2(r2) {
|
|
1714
|
+
var e3 = this;
|
|
1715
|
+
this.g = B, this.F = true, this.produce = function(r3, i3, o2) {
|
|
1716
|
+
if (typeof r3 == "function" && typeof i3 != "function") {
|
|
1717
|
+
var u2 = i3;
|
|
1718
|
+
i3 = r3;
|
|
1719
|
+
var a2 = e3;
|
|
1720
|
+
return function(n2) {
|
|
1721
|
+
var r4 = this;
|
|
1722
|
+
n2 === void 0 && (n2 = u2);
|
|
1723
|
+
for (var t2 = arguments.length, e4 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++)
|
|
1724
|
+
e4[o3 - 1] = arguments[o3];
|
|
1725
|
+
return a2.produce(n2, function(n3) {
|
|
1726
|
+
var t3;
|
|
1727
|
+
return (t3 = i3).call.apply(t3, [r4, n3].concat(e4));
|
|
1728
|
+
});
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
var f2;
|
|
1732
|
+
if (typeof i3 != "function" && n$2(6), o2 !== void 0 && typeof o2 != "function" && n$2(7), t$2(r3)) {
|
|
1733
|
+
var c2 = w$1(e3), s2 = R(e3, r3, void 0), v2 = true;
|
|
1734
|
+
try {
|
|
1735
|
+
f2 = i3(s2), v2 = false;
|
|
1736
|
+
} finally {
|
|
1737
|
+
v2 ? O(c2) : g(c2);
|
|
1738
|
+
}
|
|
1739
|
+
return typeof Promise != "undefined" && f2 instanceof Promise ? f2.then(function(n2) {
|
|
1740
|
+
return j(c2, o2), P(n2, c2);
|
|
1741
|
+
}, function(n2) {
|
|
1742
|
+
throw O(c2), n2;
|
|
1743
|
+
}) : (j(c2, o2), P(f2, c2));
|
|
1744
|
+
}
|
|
1745
|
+
if (!r3 || typeof r3 != "object") {
|
|
1746
|
+
if ((f2 = i3(r3)) === void 0 && (f2 = r3), f2 === H && (f2 = void 0), e3.F && d(f2, true), o2) {
|
|
1747
|
+
var p2 = [], l2 = [];
|
|
1748
|
+
b("Patches").M(r3, f2, p2, l2), o2(p2, l2);
|
|
1749
|
+
}
|
|
1750
|
+
return f2;
|
|
1751
|
+
}
|
|
1752
|
+
n$2(21, r3);
|
|
1753
|
+
}, this.produceWithPatches = function(n2, r3) {
|
|
1754
|
+
if (typeof n2 == "function")
|
|
1755
|
+
return function(r4) {
|
|
1756
|
+
for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++)
|
|
1757
|
+
i4[o3 - 1] = arguments[o3];
|
|
1758
|
+
return e3.produceWithPatches(r4, function(r5) {
|
|
1759
|
+
return n2.apply(void 0, [r5].concat(i4));
|
|
1760
|
+
});
|
|
1761
|
+
};
|
|
1762
|
+
var t2, i3, o2 = e3.produce(n2, r3, function(n3, r4) {
|
|
1763
|
+
t2 = n3, i3 = r4;
|
|
1764
|
+
});
|
|
1765
|
+
return typeof Promise != "undefined" && o2 instanceof Promise ? o2.then(function(n3) {
|
|
1766
|
+
return [n3, t2, i3];
|
|
1767
|
+
}) : [o2, t2, i3];
|
|
1768
|
+
}, typeof (r2 == null ? void 0 : r2.useProxies) == "boolean" && this.setUseProxies(r2.useProxies), typeof (r2 == null ? void 0 : r2.autoFreeze) == "boolean" && this.setAutoFreeze(r2.autoFreeze);
|
|
1769
|
+
}
|
|
1770
|
+
var i2 = e2.prototype;
|
|
1771
|
+
return i2.createDraft = function(e3) {
|
|
1772
|
+
t$2(e3) || n$2(8), r$2(e3) && (e3 = D(e3));
|
|
1773
|
+
var i3 = w$1(this), o2 = R(this, e3, void 0);
|
|
1774
|
+
return o2[Q].C = true, g(i3), o2;
|
|
1775
|
+
}, i2.finishDraft = function(r2, t2) {
|
|
1776
|
+
var e3 = r2 && r2[Q];
|
|
1777
|
+
var i3 = e3.A;
|
|
1778
|
+
return j(i3, t2), P(void 0, i3);
|
|
1779
|
+
}, i2.setAutoFreeze = function(n2) {
|
|
1780
|
+
this.F = n2;
|
|
1781
|
+
}, i2.setUseProxies = function(r2) {
|
|
1782
|
+
r2 && !B && n$2(20), this.g = r2;
|
|
1783
|
+
}, i2.applyPatches = function(n2, t2) {
|
|
1784
|
+
var e3;
|
|
1785
|
+
for (e3 = t2.length - 1; e3 >= 0; e3--) {
|
|
1786
|
+
var i3 = t2[e3];
|
|
1787
|
+
if (i3.path.length === 0 && i3.op === "replace") {
|
|
1788
|
+
n2 = i3.value;
|
|
1789
|
+
break;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
e3 > -1 && (t2 = t2.slice(e3 + 1));
|
|
1793
|
+
var o2 = b("Patches").$;
|
|
1794
|
+
return r$2(n2) ? o2(n2, t2) : this.produce(n2, function(n3) {
|
|
1795
|
+
return o2(n3, t2);
|
|
1796
|
+
});
|
|
1797
|
+
}, e2;
|
|
1798
|
+
}(), an = new un(), fn = an.produce;
|
|
1799
|
+
an.produceWithPatches.bind(an);
|
|
1800
|
+
an.setAutoFreeze.bind(an);
|
|
1801
|
+
an.setUseProxies.bind(an);
|
|
1802
|
+
var pn = an.applyPatches.bind(an);
|
|
1803
|
+
an.createDraft.bind(an);
|
|
1804
|
+
an.finishDraft.bind(an);
|
|
1805
|
+
var react = function equal(a2, b2) {
|
|
1806
|
+
if (a2 === b2)
|
|
1807
|
+
return true;
|
|
1808
|
+
if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
|
|
1809
|
+
if (a2.constructor !== b2.constructor)
|
|
1810
|
+
return false;
|
|
1811
|
+
var length, i2, keys;
|
|
1812
|
+
if (Array.isArray(a2)) {
|
|
1813
|
+
length = a2.length;
|
|
1814
|
+
if (length != b2.length)
|
|
1815
|
+
return false;
|
|
1816
|
+
for (i2 = length; i2-- !== 0; )
|
|
1817
|
+
if (!equal(a2[i2], b2[i2]))
|
|
1818
|
+
return false;
|
|
1819
|
+
return true;
|
|
1820
|
+
}
|
|
1821
|
+
if (a2 instanceof Map && b2 instanceof Map) {
|
|
1822
|
+
if (a2.size !== b2.size)
|
|
1823
|
+
return false;
|
|
1824
|
+
for (i2 of a2.entries())
|
|
1825
|
+
if (!b2.has(i2[0]))
|
|
1826
|
+
return false;
|
|
1827
|
+
for (i2 of a2.entries())
|
|
1828
|
+
if (!equal(i2[1], b2.get(i2[0])))
|
|
1829
|
+
return false;
|
|
1830
|
+
return true;
|
|
1831
|
+
}
|
|
1832
|
+
if (a2 instanceof Set && b2 instanceof Set) {
|
|
1833
|
+
if (a2.size !== b2.size)
|
|
1834
|
+
return false;
|
|
1835
|
+
for (i2 of a2.entries())
|
|
1836
|
+
if (!b2.has(i2[0]))
|
|
1837
|
+
return false;
|
|
1838
|
+
return true;
|
|
1839
|
+
}
|
|
1840
|
+
if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
|
|
1841
|
+
length = a2.length;
|
|
1842
|
+
if (length != b2.length)
|
|
1843
|
+
return false;
|
|
1844
|
+
for (i2 = length; i2-- !== 0; )
|
|
1845
|
+
if (a2[i2] !== b2[i2])
|
|
1846
|
+
return false;
|
|
1847
|
+
return true;
|
|
1848
|
+
}
|
|
1849
|
+
if (a2.constructor === RegExp)
|
|
1850
|
+
return a2.source === b2.source && a2.flags === b2.flags;
|
|
1851
|
+
if (a2.valueOf !== Object.prototype.valueOf)
|
|
1852
|
+
return a2.valueOf() === b2.valueOf();
|
|
1853
|
+
if (a2.toString !== Object.prototype.toString)
|
|
1854
|
+
return a2.toString() === b2.toString();
|
|
1855
|
+
keys = Object.keys(a2);
|
|
1856
|
+
length = keys.length;
|
|
1857
|
+
if (length !== Object.keys(b2).length)
|
|
1858
|
+
return false;
|
|
1859
|
+
for (i2 = length; i2-- !== 0; )
|
|
1860
|
+
if (!Object.prototype.hasOwnProperty.call(b2, keys[i2]))
|
|
1861
|
+
return false;
|
|
1862
|
+
for (i2 = length; i2-- !== 0; ) {
|
|
1863
|
+
var key = keys[i2];
|
|
1864
|
+
if (key === "_owner" && a2.$$typeof) {
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1867
|
+
if (!equal(a2[key], b2[key]))
|
|
1868
|
+
return false;
|
|
1869
|
+
}
|
|
1870
|
+
return true;
|
|
1871
|
+
}
|
|
1872
|
+
return a2 !== a2 && b2 !== b2;
|
|
1873
|
+
};
|
|
1874
|
+
function createSelector(stringSelector) {
|
|
1875
|
+
const parts = stringSelector.split(".");
|
|
1876
|
+
return (state) => parts.reduce((v2, p2) => v2 instanceof Object && p2 in v2 ? v2[p2] : void 0, state);
|
|
1877
|
+
}
|
|
1878
|
+
function setWithSelector(state, stringSelector, value) {
|
|
1879
|
+
const parts = stringSelector.split(".");
|
|
1880
|
+
const prefix = parts.slice(0, -1);
|
|
1881
|
+
const last = parts[parts.length - 1];
|
|
1882
|
+
for (const part of prefix) {
|
|
1883
|
+
if (state instanceof Object && part in state) {
|
|
1884
|
+
state = state[part];
|
|
1885
|
+
} else {
|
|
1886
|
+
throw Error(`Could not set ${stringSelector} because path ${stringSelector} doesn't exist`);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
if (state instanceof Object) {
|
|
1890
|
+
state[last] = value;
|
|
1891
|
+
} else {
|
|
1892
|
+
throw Error(`Could not set ${stringSelector} because path ${stringSelector} doesn't exist`);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
function throttle$1(fn2, ms) {
|
|
1896
|
+
let last = 0;
|
|
1897
|
+
let lastArgs;
|
|
1898
|
+
let timeout;
|
|
1899
|
+
function run() {
|
|
1900
|
+
const args = lastArgs;
|
|
1901
|
+
last = Date.now();
|
|
1902
|
+
lastArgs = void 0;
|
|
1903
|
+
timeout = void 0;
|
|
1904
|
+
fn2(...args);
|
|
1905
|
+
}
|
|
1906
|
+
return function(...args) {
|
|
1907
|
+
const now = Date.now();
|
|
1908
|
+
lastArgs = args;
|
|
1909
|
+
if (timeout)
|
|
1910
|
+
;
|
|
1911
|
+
else if (now < last + ms) {
|
|
1912
|
+
timeout = setTimeout(run, last + ms - now);
|
|
1913
|
+
} else {
|
|
1914
|
+
run();
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
const RESTART_UPDATE = Symbol("RESTART_UPDATE");
|
|
1919
|
+
class Store$1 {
|
|
1920
|
+
constructor(state, { log = (...data) => console.error(...data) } = {}) {
|
|
1921
|
+
this.state = state;
|
|
1922
|
+
this.subscriptions = /* @__PURE__ */ new Set();
|
|
1923
|
+
this.batchCounter = 0;
|
|
1924
|
+
this.reactions = /* @__PURE__ */ new Set();
|
|
1925
|
+
this.patches = new Array();
|
|
1926
|
+
d(state, true);
|
|
1927
|
+
C();
|
|
1928
|
+
T();
|
|
1929
|
+
this.options = {
|
|
1930
|
+
log
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
getState() {
|
|
1934
|
+
return this.state;
|
|
1935
|
+
}
|
|
1936
|
+
update(update) {
|
|
1937
|
+
this.state = fn(this.state, (draft) => update(draft, this.state), (patches) => this.patches.push(...patches));
|
|
1938
|
+
this.notify();
|
|
1939
|
+
}
|
|
1940
|
+
set(state) {
|
|
1941
|
+
this.state = fn(this.state, () => state, (patches) => this.patches.push(...patches));
|
|
1942
|
+
this.notify();
|
|
1943
|
+
}
|
|
1944
|
+
applyPatches(patches) {
|
|
1945
|
+
this.state = pn(this.state, patches);
|
|
1946
|
+
this.patches.push(...patches);
|
|
1947
|
+
this.notify();
|
|
1948
|
+
}
|
|
1949
|
+
batchUpdates(fn2) {
|
|
1950
|
+
try {
|
|
1951
|
+
this.batchCounter++;
|
|
1952
|
+
fn2();
|
|
1953
|
+
} finally {
|
|
1954
|
+
this.batchCounter--;
|
|
1955
|
+
if (this.batchCounter === 0) {
|
|
1956
|
+
this.notify();
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
subscribe(...args) {
|
|
1961
|
+
let selector, listener, options;
|
|
1962
|
+
if (args[1] instanceof Function) {
|
|
1963
|
+
[selector, listener, options] = args;
|
|
1964
|
+
if (typeof selector === "string") {
|
|
1965
|
+
selector = createSelector(selector);
|
|
1966
|
+
}
|
|
1967
|
+
} else {
|
|
1968
|
+
[selector, listener, options] = [(x2) => x2, ...args];
|
|
1969
|
+
}
|
|
1970
|
+
const { runNow = true, throttle: throttle2 = 0, compare = react } = options !== null && options !== void 0 ? options : {};
|
|
1971
|
+
const throttledListener = throttle2 ? throttle$1(listener, throttle2) : listener;
|
|
1972
|
+
let value = selector(this.state);
|
|
1973
|
+
const internalListener = (state, _patches, init) => {
|
|
1974
|
+
try {
|
|
1975
|
+
this.lock = "subscription";
|
|
1976
|
+
const oldValue = value;
|
|
1977
|
+
value = selector(state);
|
|
1978
|
+
if (!init && compare(value, oldValue))
|
|
1979
|
+
return;
|
|
1980
|
+
(init ? listener : throttledListener)(value, oldValue, this.state);
|
|
1981
|
+
} catch (e2) {
|
|
1982
|
+
this.options.log("Failed to execute listener:", e2);
|
|
1983
|
+
} finally {
|
|
1984
|
+
delete this.lock;
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
this.subscriptions.add(internalListener);
|
|
1988
|
+
if (runNow)
|
|
1989
|
+
internalListener(this.state, [], true);
|
|
1990
|
+
return () => {
|
|
1991
|
+
this.subscriptions.delete(internalListener);
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
addReaction(...args) {
|
|
1995
|
+
let selector, reaction, options;
|
|
1996
|
+
if (args[1] instanceof Function) {
|
|
1997
|
+
[selector, reaction, options] = args;
|
|
1998
|
+
if (typeof selector === "string") {
|
|
1999
|
+
selector = createSelector(selector);
|
|
2000
|
+
}
|
|
2001
|
+
} else {
|
|
2002
|
+
[selector, reaction, options] = [(x2) => x2, ...args];
|
|
2003
|
+
}
|
|
2004
|
+
const { runNow = true, compare = react } = options !== null && options !== void 0 ? options : {};
|
|
2005
|
+
let value = selector(this.state);
|
|
2006
|
+
const internalListener = (init) => {
|
|
2007
|
+
let hasChanged = false;
|
|
2008
|
+
try {
|
|
2009
|
+
this.lock = "reaction";
|
|
2010
|
+
const oldValue = value;
|
|
2011
|
+
value = selector(this.state);
|
|
2012
|
+
if (!init && compare(value, oldValue))
|
|
2013
|
+
return;
|
|
2014
|
+
this.state = fn(this.state, (draft) => reaction(value, draft, this.state, oldValue), (patches) => {
|
|
2015
|
+
hasChanged = true;
|
|
2016
|
+
this.patches.push(...patches);
|
|
2017
|
+
});
|
|
2018
|
+
} catch (e2) {
|
|
2019
|
+
this.options.log("Failed to execute reaction:", e2);
|
|
2020
|
+
} finally {
|
|
2021
|
+
delete this.lock;
|
|
2022
|
+
}
|
|
2023
|
+
if (hasChanged && !init)
|
|
2024
|
+
throw RESTART_UPDATE;
|
|
2025
|
+
if (hasChanged && init)
|
|
2026
|
+
this.notify();
|
|
2027
|
+
};
|
|
2028
|
+
this.reactions.add(internalListener);
|
|
2029
|
+
if (runNow)
|
|
2030
|
+
internalListener(true);
|
|
2031
|
+
return () => {
|
|
2032
|
+
this.reactions.delete(internalListener);
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
subscribePatches(listener) {
|
|
2036
|
+
const internalListener = (_state, patches) => {
|
|
2037
|
+
try {
|
|
2038
|
+
listener(patches);
|
|
2039
|
+
} catch (e2) {
|
|
2040
|
+
this.options.log("Failed to execute patch listener:", e2);
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
this.subscriptions.add(internalListener);
|
|
2044
|
+
return () => {
|
|
2045
|
+
this.subscriptions.delete(internalListener);
|
|
2046
|
+
};
|
|
2047
|
+
}
|
|
2048
|
+
checkLock() {
|
|
2049
|
+
if (this.lock === "reaction") {
|
|
2050
|
+
throw Error("You cannot call update from within a reaction. Use the passed draft instead.");
|
|
2051
|
+
} else if (this.lock === "subscription") {
|
|
2052
|
+
throw Error("You cannot call update from within a subscription.");
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
notify() {
|
|
2056
|
+
if (this.batchCounter > 0 || this.patches.length === 0)
|
|
2057
|
+
return;
|
|
2058
|
+
try {
|
|
2059
|
+
for (const reaction of this.reactions) {
|
|
2060
|
+
reaction();
|
|
2061
|
+
}
|
|
2062
|
+
} catch (e2) {
|
|
2063
|
+
return this.notify();
|
|
2064
|
+
}
|
|
2065
|
+
const patches = this.patches;
|
|
2066
|
+
this.patches = [];
|
|
2067
|
+
this.batchUpdates(() => {
|
|
2068
|
+
for (const subscription of this.subscriptions) {
|
|
2069
|
+
subscription(this.state, patches);
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
var withSelector = { exports: {} };
|
|
2075
|
+
var withSelector_production_min = {};
|
|
2076
|
+
var shim = { exports: {} };
|
|
2077
|
+
var useSyncExternalStoreShim_production_min = {};
|
|
2078
|
+
/**
|
|
2079
|
+
* @license React
|
|
2080
|
+
* use-sync-external-store-shim.production.min.js
|
|
2081
|
+
*
|
|
2082
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2083
|
+
*
|
|
2084
|
+
* This source code is licensed under the MIT license found in the
|
|
2085
|
+
* LICENSE file in the root directory of this source tree.
|
|
2086
|
+
*/
|
|
2087
|
+
var e = require$$0__default["default"];
|
|
2088
|
+
function h$1(a2, b2) {
|
|
2089
|
+
return a2 === b2 && (a2 !== 0 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
|
|
2090
|
+
}
|
|
2091
|
+
var k = typeof Object.is === "function" ? Object.is : h$1, l = e.useState, m = e.useEffect, n$1 = e.useLayoutEffect, p$1 = e.useDebugValue;
|
|
2092
|
+
function q$1(a2, b2) {
|
|
2093
|
+
var d2 = b2(), f2 = l({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
|
|
2094
|
+
n$1(function() {
|
|
2095
|
+
c2.value = d2;
|
|
2096
|
+
c2.getSnapshot = b2;
|
|
2097
|
+
r$1(c2) && g2({ inst: c2 });
|
|
2098
|
+
}, [a2, d2, b2]);
|
|
2099
|
+
m(function() {
|
|
2100
|
+
r$1(c2) && g2({ inst: c2 });
|
|
2101
|
+
return a2(function() {
|
|
2102
|
+
r$1(c2) && g2({ inst: c2 });
|
|
2103
|
+
});
|
|
2104
|
+
}, [a2]);
|
|
2105
|
+
p$1(d2);
|
|
2106
|
+
return d2;
|
|
2107
|
+
}
|
|
2108
|
+
function r$1(a2) {
|
|
2109
|
+
var b2 = a2.getSnapshot;
|
|
2110
|
+
a2 = a2.value;
|
|
2111
|
+
try {
|
|
2112
|
+
var d2 = b2();
|
|
2113
|
+
return !k(a2, d2);
|
|
2114
|
+
} catch (f2) {
|
|
2115
|
+
return true;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
function t$1(a2, b2) {
|
|
2119
|
+
return b2();
|
|
2120
|
+
}
|
|
2121
|
+
var u$1 = typeof window === "undefined" || typeof window.document === "undefined" || typeof window.document.createElement === "undefined" ? t$1 : q$1;
|
|
2122
|
+
useSyncExternalStoreShim_production_min.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : u$1;
|
|
2123
|
+
{
|
|
2124
|
+
shim.exports = useSyncExternalStoreShim_production_min;
|
|
2125
|
+
}
|
|
2126
|
+
/**
|
|
2127
|
+
* @license React
|
|
2128
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
2129
|
+
*
|
|
2130
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2131
|
+
*
|
|
2132
|
+
* This source code is licensed under the MIT license found in the
|
|
2133
|
+
* LICENSE file in the root directory of this source tree.
|
|
2134
|
+
*/
|
|
2135
|
+
var h = require$$0__default["default"], n = shim.exports;
|
|
2136
|
+
function p(a2, b2) {
|
|
2137
|
+
return a2 === b2 && (a2 !== 0 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
|
|
2138
|
+
}
|
|
2139
|
+
var q = typeof Object.is === "function" ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
|
|
2140
|
+
withSelector_production_min.useSyncExternalStoreWithSelector = function(a2, b2, e2, l2, g2) {
|
|
2141
|
+
var c2 = t(null);
|
|
2142
|
+
if (c2.current === null) {
|
|
2143
|
+
var f2 = { hasValue: false, value: null };
|
|
2144
|
+
c2.current = f2;
|
|
2145
|
+
} else
|
|
2146
|
+
f2 = c2.current;
|
|
2147
|
+
c2 = v(function() {
|
|
2148
|
+
function a3(a4) {
|
|
2149
|
+
if (!c3) {
|
|
2150
|
+
c3 = true;
|
|
2151
|
+
d3 = a4;
|
|
2152
|
+
a4 = l2(a4);
|
|
2153
|
+
if (g2 !== void 0 && f2.hasValue) {
|
|
2154
|
+
var b3 = f2.value;
|
|
2155
|
+
if (g2(b3, a4))
|
|
2156
|
+
return k2 = b3;
|
|
2157
|
+
}
|
|
2158
|
+
return k2 = a4;
|
|
2159
|
+
}
|
|
2160
|
+
b3 = k2;
|
|
2161
|
+
if (q(d3, a4))
|
|
2162
|
+
return b3;
|
|
2163
|
+
var e3 = l2(a4);
|
|
2164
|
+
if (g2 !== void 0 && g2(b3, e3))
|
|
2165
|
+
return b3;
|
|
2166
|
+
d3 = a4;
|
|
2167
|
+
return k2 = e3;
|
|
2168
|
+
}
|
|
2169
|
+
var c3 = false, d3, k2, m2 = e2 === void 0 ? null : e2;
|
|
2170
|
+
return [function() {
|
|
2171
|
+
return a3(b2());
|
|
2172
|
+
}, m2 === null ? void 0 : function() {
|
|
2173
|
+
return a3(m2());
|
|
2174
|
+
}];
|
|
2175
|
+
}, [b2, e2, l2, g2]);
|
|
2176
|
+
var d2 = r(a2, c2[0], c2[1]);
|
|
2177
|
+
u(function() {
|
|
2178
|
+
f2.hasValue = true;
|
|
2179
|
+
f2.value = d2;
|
|
2180
|
+
}, [d2]);
|
|
2181
|
+
w(d2);
|
|
2182
|
+
return d2;
|
|
2183
|
+
};
|
|
2184
|
+
{
|
|
2185
|
+
withSelector.exports = withSelector_production_min;
|
|
2186
|
+
}
|
|
2187
|
+
function useStoreState(store, ...args) {
|
|
2188
|
+
var _a, _b, _c, _d;
|
|
2189
|
+
let selector, options;
|
|
2190
|
+
if (args[0] instanceof Function) {
|
|
2191
|
+
selector = args[0];
|
|
2192
|
+
options = (_a = args[1]) !== null && _a !== void 0 ? _a : {};
|
|
2193
|
+
} else if (typeof args[0] === "string") {
|
|
2194
|
+
selector = createSelector(args[0]);
|
|
2195
|
+
options = (_b = args[1]) !== null && _b !== void 0 ? _b : {};
|
|
2196
|
+
} else {
|
|
2197
|
+
selector = (x2) => x2;
|
|
2198
|
+
options = (_c = args[0]) !== null && _c !== void 0 ? _c : {};
|
|
2199
|
+
}
|
|
2200
|
+
const subscribe = require$$0.useCallback((listener) => {
|
|
2201
|
+
return store.subscribe((x2) => x2, listener, {
|
|
2202
|
+
throttle: options.throttle,
|
|
2203
|
+
runNow: false,
|
|
2204
|
+
compare: (a2, b2) => a2 === b2
|
|
2205
|
+
});
|
|
2206
|
+
}, [store, options.throttle]);
|
|
2207
|
+
const value = withSelector.exports.useSyncExternalStoreWithSelector(subscribe, () => store.getState(), void 0, selector, (_d = options.compare) !== null && _d !== void 0 ? _d : react);
|
|
2208
|
+
require$$0.useDebugValue(value);
|
|
2209
|
+
return value;
|
|
2210
|
+
}
|
|
2211
|
+
function useStoreProp(store, selector) {
|
|
2212
|
+
const value = useStoreState(store, selector);
|
|
2213
|
+
const update = (value2) => store.update((state) => setWithSelector(state, selector, value2));
|
|
2214
|
+
return [value, update];
|
|
2215
|
+
}
|
|
2216
|
+
class Store extends Store$1 {
|
|
2217
|
+
useState(...args) {
|
|
2218
|
+
return useStoreState(this, ...args);
|
|
2219
|
+
}
|
|
2220
|
+
useProp(selector) {
|
|
2221
|
+
return useStoreProp(this, selector);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
class StoreScope {
|
|
2225
|
+
constructor(defaultValue) {
|
|
2226
|
+
this.defaultValue = defaultValue;
|
|
2227
|
+
this.Provider = ({ children, store }) => {
|
|
2228
|
+
const _store = require$$0.useMemo(() => store !== null && store !== void 0 ? store : new Store(this.defaultValue), [store]);
|
|
2229
|
+
return tableTheme.jsx$1(this.context.Provider, Object.assign({ value: _store }, { children }), void 0);
|
|
2230
|
+
};
|
|
2231
|
+
this.withScope = (Component) => {
|
|
2232
|
+
return (args) => tableTheme.jsx$1(this.Provider, { children: tableTheme.jsx$1(Component, Object.assign({}, args), void 0) }, void 0);
|
|
2233
|
+
};
|
|
2234
|
+
this.context = require$$0.createContext(new Store(defaultValue));
|
|
2235
|
+
}
|
|
2236
|
+
useStore() {
|
|
2237
|
+
return require$$0.useContext(this.context);
|
|
2238
|
+
}
|
|
2239
|
+
useState(...args) {
|
|
2240
|
+
const store = this.useStore();
|
|
2241
|
+
return useStoreState(store, ...args);
|
|
2242
|
+
}
|
|
2243
|
+
useProp(selector) {
|
|
2244
|
+
const store = this.useStore();
|
|
2245
|
+
return useStoreProp(store, selector);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
function calcItems(state) {
|
|
2249
|
+
require$$0.useEffect(() => state.addReaction((state2) => [
|
|
2250
|
+
state2.props.items,
|
|
2251
|
+
state2.props.id,
|
|
2252
|
+
state2.props.parentId,
|
|
2253
|
+
state2.props.revealFiltered,
|
|
2254
|
+
state2.sort,
|
|
2255
|
+
state2.filters,
|
|
2256
|
+
state2.filterValues,
|
|
2257
|
+
state2.activeColumns,
|
|
2258
|
+
state2.expanded
|
|
2259
|
+
], ([items = [], id, parentId, revealFiltered, sort, filters, filterValues, activeColumns], draft) => {
|
|
2260
|
+
const tableItems = items.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
2261
|
+
id: id(item),
|
|
2262
|
+
parentId: parentId == null ? void 0 : parentId(item),
|
|
2263
|
+
children: []
|
|
2264
|
+
}));
|
|
2265
|
+
let sorted;
|
|
2266
|
+
if (sort.length === 0) {
|
|
2267
|
+
sorted = tableItems;
|
|
2268
|
+
} else {
|
|
2269
|
+
const selectors = flatMap(sort, (sort2) => {
|
|
2270
|
+
const column = activeColumns.find((column2) => column2.id === sort2.columnId);
|
|
2271
|
+
if (!column)
|
|
2272
|
+
return [];
|
|
2273
|
+
const sortBy = column.sortBy instanceof Array ? column.sortBy : [column.sortBy];
|
|
2274
|
+
return sortBy.map((sortBy2) => ({ selector: (item) => sortBy2(column.value(item), item), direction: sort2.direction }));
|
|
2275
|
+
}).filter(Boolean);
|
|
2276
|
+
sorted = orderBy(tableItems, selectors.map((x2) => x2.selector), selectors.map((x2) => x2.direction));
|
|
2277
|
+
}
|
|
2278
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
2279
|
+
for (const item of sorted) {
|
|
2280
|
+
lookup.set(item.id, item);
|
|
2281
|
+
}
|
|
2282
|
+
for (const item of sorted) {
|
|
2283
|
+
const parent = item.parentId !== void 0 ? lookup.get(item.parentId) : void 0;
|
|
2284
|
+
parent == null ? void 0 : parent.children.push(item);
|
|
2285
|
+
}
|
|
2286
|
+
const allItems = new Array();
|
|
2287
|
+
const allItemsById = /* @__PURE__ */ new Map();
|
|
2288
|
+
const traverse = (items2) => {
|
|
2289
|
+
for (const item of items2) {
|
|
2290
|
+
allItems.push(item);
|
|
2291
|
+
allItemsById.set(item.id, item);
|
|
2292
|
+
traverse(item.children);
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
traverse(sorted.filter((item) => item.parentId === void 0));
|
|
2296
|
+
let expandedChanged = false;
|
|
2297
|
+
const activeItemsById = /* @__PURE__ */ new Map();
|
|
2298
|
+
const activeSet = /* @__PURE__ */ new Set();
|
|
2299
|
+
const activeItems = [...allItems].reverse().filter((item) => {
|
|
2300
|
+
let isActive = activeSet.has(item.id);
|
|
2301
|
+
isActive || (isActive = activeColumns.every((column) => {
|
|
2302
|
+
var _a;
|
|
2303
|
+
const filter = filters.get(column.id);
|
|
2304
|
+
if (!filter)
|
|
2305
|
+
return true;
|
|
2306
|
+
const filterValue = filterValues.get(column.id);
|
|
2307
|
+
if (filterValue === void 0 || !filter.isActive(filterValue))
|
|
2308
|
+
return true;
|
|
2309
|
+
const filterBy = (_a = filter.filterBy) != null ? _a : (x2) => x2;
|
|
2310
|
+
const value = filterBy(column.value(item), item);
|
|
2311
|
+
return castArray(value).some((value2) => filter.test(filterValue, value2));
|
|
2312
|
+
}));
|
|
2313
|
+
if (isActive && item.parentId !== void 0) {
|
|
2314
|
+
if (revealFiltered && [...filters.entries()].some(([id2, filter]) => {
|
|
2315
|
+
const filterValue = filterValues.get(id2);
|
|
2316
|
+
return !!filter && filterValue !== void 0 && filter.isActive(filterValue);
|
|
2317
|
+
})) {
|
|
2318
|
+
expandedChanged || (expandedChanged = !draft.expanded.has(item.parentId));
|
|
2319
|
+
draft.expanded.add(item.parentId);
|
|
2320
|
+
} else if (!draft.expanded.has(item.parentId)) {
|
|
2321
|
+
isActive = false;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
if (isActive && item.parentId !== void 0) {
|
|
2325
|
+
activeSet.add(item.parentId);
|
|
2326
|
+
}
|
|
2327
|
+
if (isActive) {
|
|
2328
|
+
activeItemsById.set(item.id, item);
|
|
2329
|
+
}
|
|
2330
|
+
return isActive;
|
|
2331
|
+
}).reverse();
|
|
2332
|
+
draft.items = K(allItems);
|
|
2333
|
+
draft.itemsById = K(allItemsById);
|
|
2334
|
+
draft.activeItems = K(activeItems);
|
|
2335
|
+
draft.activeItemsById = K(activeItemsById);
|
|
2336
|
+
if (expandedChanged) {
|
|
2337
|
+
setTimeout(() => {
|
|
2338
|
+
var _a, _b;
|
|
2339
|
+
(_b = (_a = state.getState().props).onExpandedChange) == null ? void 0 : _b.call(_a, state.getState().expanded);
|
|
2340
|
+
});
|
|
2341
|
+
}
|
|
2342
|
+
}, { runNow: true }), [state]);
|
|
2343
|
+
}
|
|
2344
|
+
const noopParentId = () => void 0;
|
|
2345
|
+
function calcProps(props) {
|
|
2346
|
+
const columnCache = require$$0.useRef(/* @__PURE__ */ new Map());
|
|
2347
|
+
return require$$0.useMemo(() => {
|
|
2348
|
+
var _c, _d, _e, _f, _g, _h;
|
|
2349
|
+
let id;
|
|
2350
|
+
if (props.id instanceof Function) {
|
|
2351
|
+
id = props.id;
|
|
2352
|
+
} else {
|
|
2353
|
+
id = (item) => item[props.id];
|
|
2354
|
+
}
|
|
2355
|
+
let parentId;
|
|
2356
|
+
if (props.parentId instanceof Function) {
|
|
2357
|
+
parentId = props.parentId;
|
|
2358
|
+
} else if (typeof props.parentId === "string") {
|
|
2359
|
+
parentId = (item) => item[props.parentId];
|
|
2360
|
+
} else {
|
|
2361
|
+
parentId = noopParentId;
|
|
2362
|
+
}
|
|
2363
|
+
let inputColumns;
|
|
2364
|
+
if (props.columns instanceof Function) {
|
|
2365
|
+
inputColumns = props.columns((value, column) => __spreadProps(__spreadValues({}, column), { value }));
|
|
2366
|
+
} else {
|
|
2367
|
+
inputColumns = props.columns.map((column) => __spreadProps(__spreadValues({}, column), { dependecies: void 0 }));
|
|
2368
|
+
}
|
|
2369
|
+
const newColumnCache = /* @__PURE__ */ new Map();
|
|
2370
|
+
const columns = inputColumns.map(function(_a, index) {
|
|
2371
|
+
var _b = _a, {
|
|
2372
|
+
id: id2,
|
|
2373
|
+
header = null,
|
|
2374
|
+
renderCell = asString,
|
|
2375
|
+
exportCell = asString,
|
|
2376
|
+
sortBy = (v2) => typeof v2 === "number" || v2 instanceof Date ? v2 : String(v2),
|
|
2377
|
+
dependencies = []
|
|
2378
|
+
} = _b, props2 = __objRest(_b, [
|
|
2379
|
+
"id",
|
|
2380
|
+
"header",
|
|
2381
|
+
"renderCell",
|
|
2382
|
+
"exportCell",
|
|
2383
|
+
"sortBy",
|
|
2384
|
+
"dependencies"
|
|
2385
|
+
]);
|
|
2386
|
+
var _a2;
|
|
2387
|
+
const [depsInCache, columnInCache] = (_a2 = columnCache.current.get(id2 != null ? id2 : index)) != null ? _a2 : [];
|
|
2388
|
+
let column;
|
|
2389
|
+
if (depsInCache && columnInCache && depsInCache.length === dependencies.length && depsInCache.every((x2, i2) => dependencies[i2] === x2)) {
|
|
2390
|
+
column = columnInCache;
|
|
2391
|
+
} else {
|
|
2392
|
+
column = __spreadValues({
|
|
2393
|
+
id: id2 != null ? id2 : index,
|
|
2394
|
+
header,
|
|
2395
|
+
renderCell,
|
|
2396
|
+
exportCell,
|
|
2397
|
+
sortBy,
|
|
2398
|
+
dependencies
|
|
2399
|
+
}, props2);
|
|
2400
|
+
}
|
|
2401
|
+
newColumnCache.set(id2 != null ? id2 : index, [dependencies, column]);
|
|
2402
|
+
return column;
|
|
2403
|
+
});
|
|
2404
|
+
columnCache.current = newColumnCache;
|
|
2405
|
+
let copy;
|
|
2406
|
+
if (props.enableExport === true || props.enableExport instanceof Object && props.enableExport.copy === true) {
|
|
2407
|
+
copy = { separator: " " };
|
|
2408
|
+
} else if (props.enableExport && props.enableExport.copy instanceof Object) {
|
|
2409
|
+
copy = props.enableExport.copy;
|
|
2410
|
+
}
|
|
2411
|
+
let download;
|
|
2412
|
+
if (props.enableExport === true || props.enableExport instanceof Object && props.enableExport.download === true) {
|
|
2413
|
+
download = { sepPrefix: true };
|
|
2414
|
+
} else if (props.enableExport && props.enableExport.download instanceof Object) {
|
|
2415
|
+
download = props.enableExport.download;
|
|
2416
|
+
}
|
|
2417
|
+
const enableExport = { copy, download };
|
|
2418
|
+
return __spreadProps(__spreadValues({}, props), {
|
|
2419
|
+
id,
|
|
2420
|
+
parentId,
|
|
2421
|
+
columns,
|
|
2422
|
+
enableSelection: (_c = props.enableSelection) != null ? _c : true,
|
|
2423
|
+
selectSyncChildren: (_d = props.selectSyncChildren) != null ? _d : true,
|
|
2424
|
+
stickyHeader: (_e = props.stickyHeader) != null ? _e : true,
|
|
2425
|
+
enableExport,
|
|
2426
|
+
enableColumnSelection: (_f = props.enableColumnSelection) != null ? _f : true,
|
|
2427
|
+
enableColumnResize: (_g = props.enableColumnResize) != null ? _g : true,
|
|
2428
|
+
enableColumnReorder: (_h = props.enableColumnReorder) != null ? _h : true
|
|
2429
|
+
});
|
|
2430
|
+
}, [props]);
|
|
2431
|
+
}
|
|
2432
|
+
function cleanupState(state) {
|
|
2433
|
+
require$$0.useEffect(() => state.addReaction((state2) => [state2.props.columns, state2.itemsById, state2.activeItemsById, state2.activeColumns], ([columns, itemsById, activeItemsById, activeColumns], draft) => {
|
|
2434
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2435
|
+
const columnIds = new Set(columns.map((column) => column.id));
|
|
2436
|
+
const activeColumnIds = new Set(activeColumns.map((column) => column.id));
|
|
2437
|
+
const newSort = draft.sort.filter((s2) => activeColumnIds.has(s2.columnId));
|
|
2438
|
+
if (newSort.length < draft.sort.length) {
|
|
2439
|
+
draft.sort = newSort;
|
|
2440
|
+
(_b = (_a = draft.props).onSortChange) == null ? void 0 : _b.call(_a, newSort);
|
|
2441
|
+
}
|
|
2442
|
+
for (const id of draft.filters.keys()) {
|
|
2443
|
+
if (!activeColumnIds.has(id))
|
|
2444
|
+
draft.filters.delete(id);
|
|
2445
|
+
}
|
|
2446
|
+
for (const id of draft.filterValues.keys()) {
|
|
2447
|
+
if (!activeColumnIds.has(id))
|
|
2448
|
+
draft.filterValues.delete(id);
|
|
2449
|
+
}
|
|
2450
|
+
for (const id of draft.hiddenColumns.keys()) {
|
|
2451
|
+
if (!columnIds.has(id))
|
|
2452
|
+
draft.hiddenColumns.delete(id);
|
|
2453
|
+
}
|
|
2454
|
+
for (const id of draft.columnWidths.keys()) {
|
|
2455
|
+
if (!columnIds.has(id))
|
|
2456
|
+
draft.columnWidths.delete(id);
|
|
2457
|
+
}
|
|
2458
|
+
for (const id of draft.columnOrder) {
|
|
2459
|
+
if (!columnIds.has(id))
|
|
2460
|
+
draft.columnOrder = draft.columnOrder.filter((x2) => x2 !== id);
|
|
2461
|
+
}
|
|
2462
|
+
if (draft.props.items) {
|
|
2463
|
+
const newSelection = intersect(draft.selection, activeItemsById);
|
|
2464
|
+
if (newSelection.size !== draft.selection.size) {
|
|
2465
|
+
draft.selection = newSelection;
|
|
2466
|
+
(_d = (_c = draft.props).onSelectionChange) == null ? void 0 : _d.call(_c, newSelection);
|
|
2467
|
+
}
|
|
2468
|
+
const newExpanded = intersect(draft.expanded, itemsById);
|
|
2469
|
+
if (newExpanded.size < draft.expanded.size) {
|
|
2470
|
+
draft.expanded = newExpanded;
|
|
2471
|
+
(_f = (_e = draft.props).onExpandedChange) == null ? void 0 : _f.call(_e, newExpanded);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
}, { runNow: true }), [state]);
|
|
2475
|
+
}
|
|
2476
|
+
function filterColumns(state) {
|
|
2477
|
+
require$$0.useEffect(() => state.addReaction((state2) => [state2.props.columns, state2.hiddenColumns, state2.columnOrder], ([columns, hiddenColumns, columnOrder], draft) => {
|
|
2478
|
+
draft.activeColumns = orderBy(columns.filter((column) => !hiddenColumns.has(column.id)), [(column) => columnOrder.indexOf(column.id)]);
|
|
2479
|
+
}, { runNow: true }), [state]);
|
|
2480
|
+
}
|
|
2481
|
+
function syncSelections(state) {
|
|
2482
|
+
require$$0.useEffect(() => state.addReaction((state2) => [state2.props.selectSyncChildren, state2.selection, state2.activeItems], ([selectSyncChildren, selection, activeItems], state2) => {
|
|
2483
|
+
var _a, _b;
|
|
2484
|
+
if (!selectSyncChildren)
|
|
2485
|
+
return;
|
|
2486
|
+
const newSelection = new Set(selection);
|
|
2487
|
+
for (const item of activeItems) {
|
|
2488
|
+
if (item.parentId !== void 0 && newSelection.has(item.parentId)) {
|
|
2489
|
+
newSelection.add(item.id);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
if (newSelection.size !== selection.size) {
|
|
2493
|
+
state2.selection = newSelection;
|
|
2494
|
+
(_b = (_a = state2.props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
|
|
2495
|
+
}
|
|
2496
|
+
}, { runNow: true }), [state]);
|
|
2497
|
+
}
|
|
2498
|
+
function useTableState(_props) {
|
|
2499
|
+
const props = calcProps(_props);
|
|
2500
|
+
const theme = tableTheme.useTableTheme(props);
|
|
2501
|
+
const state = require$$0.useMemo(() => {
|
|
2502
|
+
var _a, _b, _c, _d;
|
|
2503
|
+
return new Store({
|
|
2504
|
+
props,
|
|
2505
|
+
theme,
|
|
2506
|
+
sort: (_a = props.defaultSort) != null ? _a : [],
|
|
2507
|
+
selection: (_b = props.defaultSelection) != null ? _b : /* @__PURE__ */ new Set(),
|
|
2508
|
+
expanded: (_c = props.defaultExpanded) != null ? _c : /* @__PURE__ */ new Set(),
|
|
2509
|
+
rowHeights: /* @__PURE__ */ new Map(),
|
|
2510
|
+
filters: /* @__PURE__ */ new Map(),
|
|
2511
|
+
filterValues: /* @__PURE__ */ new Map(),
|
|
2512
|
+
hiddenColumns: (_d = props.defaultHiddenColumns) != null ? _d : /* @__PURE__ */ new Set(),
|
|
2513
|
+
columnWidths: /* @__PURE__ */ new Map(),
|
|
2514
|
+
columnOrder: props.columns.map((column) => column.id),
|
|
2515
|
+
columnStyleOverride: /* @__PURE__ */ new Map(),
|
|
2516
|
+
activeColumns: [],
|
|
2517
|
+
items: [],
|
|
2518
|
+
itemsById: /* @__PURE__ */ new Map(),
|
|
2519
|
+
activeItems: [],
|
|
2520
|
+
activeItemsById: /* @__PURE__ */ new Map(),
|
|
2521
|
+
lastSelectedId: void 0
|
|
2522
|
+
});
|
|
2523
|
+
}, []);
|
|
2524
|
+
filterColumns(state);
|
|
2525
|
+
calcItems(state);
|
|
2526
|
+
syncSelections(state);
|
|
2527
|
+
cleanupState(state);
|
|
2528
|
+
require$$0.useEffect(() => {
|
|
2529
|
+
state.update((state2) => {
|
|
2530
|
+
state2.props = K(props);
|
|
2531
|
+
if (props.sort)
|
|
2532
|
+
state2.sort = props.sort;
|
|
2533
|
+
if (props.selection)
|
|
2534
|
+
state2.selection = props.selection;
|
|
2535
|
+
if (props.expanded)
|
|
2536
|
+
state2.expanded = props.expanded;
|
|
2537
|
+
if (props.hiddenColumns)
|
|
2538
|
+
state2.hiddenColumns = props.hiddenColumns;
|
|
2539
|
+
for (const column of props.columns) {
|
|
2540
|
+
if (!state2.columnOrder.includes(column.id)) {
|
|
2541
|
+
const index = props.columns.indexOf(column);
|
|
2542
|
+
state2.columnOrder.splice(index, 0, column.id);
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
state2.theme = theme;
|
|
2546
|
+
});
|
|
2547
|
+
}, [state, props]);
|
|
2548
|
+
return state;
|
|
2549
|
+
}
|
|
2550
|
+
const ColumnHeaderContext = new StoreScope({
|
|
2551
|
+
items: /* @__PURE__ */ new Map()
|
|
2552
|
+
});
|
|
2553
|
+
function ColumnHeader(props) {
|
|
2554
|
+
const ref = require$$0.useRef(null);
|
|
2555
|
+
const columnId = useColumnContext();
|
|
2556
|
+
const table = useTableContext();
|
|
2557
|
+
const enabled = table.useState("props.enableColumnReorder");
|
|
2558
|
+
const store = ColumnHeaderContext.useStore();
|
|
2559
|
+
const draggingStart = require$$0.useRef();
|
|
2560
|
+
const clone = require$$0.useRef();
|
|
2561
|
+
require$$0.useEffect(() => {
|
|
2562
|
+
const div = ref.current;
|
|
2563
|
+
if (!div)
|
|
2564
|
+
return;
|
|
2565
|
+
store.update((state) => {
|
|
2566
|
+
state.items.set(columnId, K(div));
|
|
2567
|
+
});
|
|
2568
|
+
return () => {
|
|
2569
|
+
store.update((state) => {
|
|
2570
|
+
state.items.delete(columnId);
|
|
2571
|
+
});
|
|
2572
|
+
};
|
|
2573
|
+
}, [ref.current, store, columnId]);
|
|
2574
|
+
function calcTargetIndex(offsetLeft) {
|
|
2575
|
+
var _a, _b, _c;
|
|
2576
|
+
const cols = table.getState().columnOrder.map((id) => ({
|
|
2577
|
+
id,
|
|
2578
|
+
div: store.getState().items.get(id)
|
|
2579
|
+
}));
|
|
2580
|
+
const otherCols = cols.filter((col) => col.id !== columnId);
|
|
2581
|
+
const firstOffsetleft = (_c = (_b = (_a = cols.find((col) => col.div)) == null ? void 0 : _a.div) == null ? void 0 : _b.offsetLeft) != null ? _c : 0;
|
|
2582
|
+
let sum = 0;
|
|
2583
|
+
const targetIndex = otherCols.findIndex((col) => {
|
|
2584
|
+
var _a2, _b2;
|
|
2585
|
+
const width = (_b2 = (_a2 = col.div) == null ? void 0 : _a2.offsetWidth) != null ? _b2 : 0;
|
|
2586
|
+
if (sum + width / 2 > offsetLeft - firstOffsetleft)
|
|
2587
|
+
return true;
|
|
2588
|
+
sum += width;
|
|
2589
|
+
return false;
|
|
2590
|
+
});
|
|
2591
|
+
return targetIndex === -1 ? otherCols.length : targetIndex;
|
|
2592
|
+
}
|
|
2593
|
+
function onPointerDown(e2) {
|
|
2594
|
+
const div = ref.current;
|
|
2595
|
+
if (!div)
|
|
2596
|
+
return;
|
|
2597
|
+
draggingStart.current = {
|
|
2598
|
+
mouseX: e2.clientX,
|
|
2599
|
+
bounds: div.getBoundingClientRect()
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
function onPointerMove(e2) {
|
|
2603
|
+
table.update((state) => {
|
|
2604
|
+
const div = ref.current;
|
|
2605
|
+
if (!div || draggingStart.current === void 0 || Math.abs(e2.clientX - draggingStart.current.mouseX) < 5)
|
|
2606
|
+
return;
|
|
2607
|
+
e2.stopPropagation();
|
|
2608
|
+
div.setPointerCapture(e2.pointerId);
|
|
2609
|
+
if (!clone.current) {
|
|
2610
|
+
clone.current = div.cloneNode(true);
|
|
2611
|
+
document.body.append(clone.current);
|
|
2612
|
+
for (const [key, value] of Object.entries(getComputedStyle(div))) {
|
|
2613
|
+
try {
|
|
2614
|
+
clone.current.style[key] = value;
|
|
2615
|
+
} catch {
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
Object.assign(clone.current.style, {
|
|
2619
|
+
pointerEvents: "none",
|
|
2620
|
+
position: "fixed",
|
|
2621
|
+
boxShadow: "0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%)",
|
|
2622
|
+
left: `${draggingStart.current.bounds.left}px`,
|
|
2623
|
+
top: `${draggingStart.current.bounds.top}px`
|
|
2624
|
+
});
|
|
2625
|
+
div.style.color = "rgba(0, 0, 0, 0.2)";
|
|
2626
|
+
}
|
|
2627
|
+
clone.current.style.left = `${draggingStart.current.bounds.left + e2.clientX - draggingStart.current.mouseX}px`;
|
|
2628
|
+
const index = state.columnOrder.indexOf(columnId);
|
|
2629
|
+
const targetIndex = calcTargetIndex(div.offsetLeft + e2.clientX - draggingStart.current.mouseX);
|
|
2630
|
+
const columns = table.getState().columnOrder.map((id, index2) => {
|
|
2631
|
+
var _a, _b;
|
|
2632
|
+
return {
|
|
2633
|
+
id,
|
|
2634
|
+
index: index2,
|
|
2635
|
+
width: (_b = (_a = store.getState().items.get(id)) == null ? void 0 : _a.offsetWidth) != null ? _b : 0
|
|
2636
|
+
};
|
|
2637
|
+
});
|
|
2638
|
+
state.columnOrder.forEach((id, i2) => {
|
|
2639
|
+
let offset = 0;
|
|
2640
|
+
if (i2 === index) {
|
|
2641
|
+
if (targetIndex > index) {
|
|
2642
|
+
offset = columns.slice(index + 1, targetIndex + 1).reduce((sum, col) => sum + col.width, 0);
|
|
2643
|
+
} else if (targetIndex < index) {
|
|
2644
|
+
offset = -columns.slice(targetIndex, index).reduce((sum, col) => sum + col.width, 0);
|
|
2645
|
+
}
|
|
2646
|
+
} else if (i2 >= targetIndex && i2 < index) {
|
|
2647
|
+
offset = div.offsetWidth;
|
|
2648
|
+
} else if (i2 > index && i2 <= targetIndex) {
|
|
2649
|
+
offset = -div.offsetWidth;
|
|
2650
|
+
}
|
|
2651
|
+
state.columnStyleOverride.set(id, {
|
|
2652
|
+
transition: "transform 500ms",
|
|
2653
|
+
transform: `translate3d(${offset}px, 0, 0)`,
|
|
2654
|
+
zIndex: i2 === index ? 1 : void 0
|
|
2655
|
+
});
|
|
2656
|
+
});
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
function onPointerUp(e2) {
|
|
2660
|
+
table.update((state) => {
|
|
2661
|
+
var _a;
|
|
2662
|
+
const div = ref.current;
|
|
2663
|
+
if (!div || draggingStart.current === void 0)
|
|
2664
|
+
return;
|
|
2665
|
+
const index = state.columnOrder.indexOf(columnId);
|
|
2666
|
+
const targetIndex = calcTargetIndex(div.offsetLeft + e2.clientX - draggingStart.current.mouseX);
|
|
2667
|
+
state.columnOrder.splice(index, 1);
|
|
2668
|
+
state.columnOrder.splice(targetIndex, 0, columnId);
|
|
2669
|
+
(_a = clone.current) == null ? void 0 : _a.remove();
|
|
2670
|
+
div.style.color = "";
|
|
2671
|
+
state.columnStyleOverride.clear();
|
|
2672
|
+
draggingStart.current = void 0;
|
|
2673
|
+
clone.current = void 0;
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
return tableTheme.jsx("div", __spreadProps(__spreadValues({}, props), {
|
|
2677
|
+
css: {
|
|
2678
|
+
position: "relative",
|
|
2679
|
+
userSelect: "none"
|
|
2680
|
+
},
|
|
2681
|
+
ref,
|
|
2682
|
+
onPointerDown: enabled ? onPointerDown : void 0,
|
|
2683
|
+
onPointerMove: enabled ? onPointerMove : void 0,
|
|
2684
|
+
onPointerUp: enabled ? onPointerUp : void 0,
|
|
2685
|
+
children: props.children
|
|
2686
|
+
}));
|
|
2687
|
+
}
|
|
2688
|
+
function ColumnSelection() {
|
|
2689
|
+
const {
|
|
2690
|
+
components: {
|
|
2691
|
+
IconButton,
|
|
2692
|
+
Popover,
|
|
2693
|
+
Checkbox
|
|
2694
|
+
},
|
|
2695
|
+
icons: {
|
|
2696
|
+
Settings
|
|
2697
|
+
},
|
|
2698
|
+
text
|
|
2699
|
+
} = useTheme();
|
|
2700
|
+
const cssVariables = useCssVariables();
|
|
2701
|
+
const table = useTableContext();
|
|
2702
|
+
const columns = table.useState("props.columns");
|
|
2703
|
+
const hiddenColumns = table.useState("hiddenColumns");
|
|
2704
|
+
const [anchorEl, setAnchorEl] = require$$0.useState(null);
|
|
2705
|
+
const toggle2 = (column) => {
|
|
2706
|
+
const {
|
|
2707
|
+
props: {
|
|
2708
|
+
hiddenColumns: controlledHiddenColumns,
|
|
2709
|
+
onHiddenColumnsChange
|
|
2710
|
+
}
|
|
2711
|
+
} = table.getState();
|
|
2712
|
+
const newValue = new Set(hiddenColumns);
|
|
2713
|
+
if (hiddenColumns.has(column.id))
|
|
2714
|
+
newValue.delete(column.id);
|
|
2715
|
+
else
|
|
2716
|
+
newValue.add(column.id);
|
|
2717
|
+
if (!controlledHiddenColumns) {
|
|
2718
|
+
table.update((state) => {
|
|
2719
|
+
state.hiddenColumns = newValue;
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
onHiddenColumnsChange == null ? void 0 : onHiddenColumnsChange(newValue);
|
|
2723
|
+
};
|
|
2724
|
+
return tableTheme.jsxs(tableTheme.Fragment, {
|
|
2725
|
+
children: [tableTheme.jsx(IconButton, {
|
|
2726
|
+
onClick: (e2) => setAnchorEl(anchorEl ? null : e2.currentTarget),
|
|
2727
|
+
children: tableTheme.jsx(Settings, {})
|
|
2728
|
+
}), tableTheme.jsx(Popover, {
|
|
2729
|
+
anchorEl,
|
|
2730
|
+
open: !!anchorEl,
|
|
2731
|
+
onClose: () => setAnchorEl(null),
|
|
2732
|
+
css: cssVariables,
|
|
2733
|
+
children: tableTheme.jsxs("div", {
|
|
2734
|
+
css: {
|
|
2735
|
+
padding: `calc(var(--spacing) * 2)`,
|
|
2736
|
+
display: "grid"
|
|
2737
|
+
},
|
|
2738
|
+
children: [tableTheme.jsx("div", {
|
|
2739
|
+
css: {
|
|
2740
|
+
marginBottom: "var(--spacing)"
|
|
2741
|
+
},
|
|
2742
|
+
children: text.selectColumns
|
|
2743
|
+
}), columns.map((column) => tableTheme.jsx(FormControlLabel, {
|
|
2744
|
+
control: tableTheme.jsx(Checkbox, {
|
|
2745
|
+
checked: !hiddenColumns.has(column.id),
|
|
2746
|
+
onChange: () => toggle2(column),
|
|
2747
|
+
disabled: column.cannotHide
|
|
2748
|
+
}),
|
|
2749
|
+
label: column.header
|
|
2750
|
+
}, column.id))]
|
|
2751
|
+
})
|
|
2752
|
+
})]
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
function csvExport(data, { sepPrefix, separator = ",", quote = '"', eol = "\n" } = {}) {
|
|
2756
|
+
const cells = data.map((line) => line.map((value) => {
|
|
2757
|
+
if (typeof value === "number")
|
|
2758
|
+
return String(value);
|
|
2759
|
+
if (![separator, quote, eol].some((c2) => value.includes(c2)))
|
|
2760
|
+
return value;
|
|
2761
|
+
const clean = value.replace(new RegExp(quote, "g"), `${quote}${quote}`);
|
|
2762
|
+
return `${quote}${clean}${quote}`;
|
|
2763
|
+
}));
|
|
2764
|
+
return (sepPrefix ? `SEP=${separator}
|
|
2765
|
+
` : "") + cells.map((line) => line.join(separator)).join(eol);
|
|
2766
|
+
}
|
|
2767
|
+
function Export() {
|
|
2768
|
+
const table = useTableContext();
|
|
2769
|
+
const {
|
|
2770
|
+
components: {
|
|
2771
|
+
Button,
|
|
2772
|
+
IconButton,
|
|
2773
|
+
Popover
|
|
2774
|
+
},
|
|
2775
|
+
icons: {
|
|
2776
|
+
Export: Export2,
|
|
2777
|
+
Clipboard
|
|
2778
|
+
},
|
|
2779
|
+
text
|
|
2780
|
+
} = useTheme();
|
|
2781
|
+
const cssVariables = useCssVariables();
|
|
2782
|
+
const [anchor, setAnchor] = require$$0.useState(null);
|
|
2783
|
+
const generate = (options) => {
|
|
2784
|
+
const {
|
|
2785
|
+
activeColumns,
|
|
2786
|
+
activeItems
|
|
2787
|
+
} = table.getState();
|
|
2788
|
+
const data = [activeColumns.map((column) => String(column.id)), ...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item), item)))];
|
|
2789
|
+
return csvExport(data, options);
|
|
2790
|
+
};
|
|
2791
|
+
const copy = () => {
|
|
2792
|
+
navigator.clipboard.writeText(generate(table.getState().props.enableExport.copy));
|
|
2793
|
+
};
|
|
2794
|
+
const download = () => {
|
|
2795
|
+
const a2 = document.createElement("a");
|
|
2796
|
+
a2.href = "data:text/csv;charset=utf-8," + encodeURIComponent(generate(table.getState().props.enableExport.download));
|
|
2797
|
+
a2.download = "export.csv";
|
|
2798
|
+
document.body.appendChild(a2);
|
|
2799
|
+
a2.click();
|
|
2800
|
+
document.body.removeChild(a2);
|
|
2801
|
+
};
|
|
2802
|
+
return tableTheme.jsxs(tableTheme.Fragment, {
|
|
2803
|
+
children: [tableTheme.jsx(IconButton, {
|
|
2804
|
+
onClick: (e2) => setAnchor(anchor ? null : e2.currentTarget),
|
|
2805
|
+
children: tableTheme.jsx(Export2, {})
|
|
2806
|
+
}), tableTheme.jsx(Popover, {
|
|
2807
|
+
open: !!anchor,
|
|
2808
|
+
onClose: () => setAnchor(null),
|
|
2809
|
+
anchorEl: anchor,
|
|
2810
|
+
css: cssVariables,
|
|
2811
|
+
children: tableTheme.jsxs("div", {
|
|
2812
|
+
css: {
|
|
2813
|
+
padding: `calc(var(--spacing) * 2)`,
|
|
2814
|
+
display: "grid",
|
|
2815
|
+
justifyItems: "stretch",
|
|
2816
|
+
gap: "var(--spacing)",
|
|
2817
|
+
"& > *": {
|
|
2818
|
+
justifyContent: "start"
|
|
2819
|
+
}
|
|
2820
|
+
},
|
|
2821
|
+
children: [tableTheme.jsx("div", {
|
|
2822
|
+
css: {
|
|
2823
|
+
marginBottom: "var(--spacing)"
|
|
2824
|
+
},
|
|
2825
|
+
children: text.exportTitle
|
|
2826
|
+
}), tableTheme.jsx(Button, {
|
|
2827
|
+
startIcon: tableTheme.jsx(Clipboard, {}),
|
|
2828
|
+
onClick: copy,
|
|
2829
|
+
children: text.exportCopy
|
|
2830
|
+
}), tableTheme.jsx(Button, {
|
|
2831
|
+
startIcon: tableTheme.jsx(Export2, {}),
|
|
2832
|
+
onClick: download,
|
|
2833
|
+
children: text.exportDownload
|
|
2834
|
+
})]
|
|
2835
|
+
})
|
|
2836
|
+
})]
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
function useTheme() {
|
|
2840
|
+
const table = useTableContext();
|
|
2841
|
+
return table.useState("theme");
|
|
2842
|
+
}
|
|
2843
|
+
function FilterControl() {
|
|
2844
|
+
const table = useTableContext();
|
|
2845
|
+
const columnId = useColumnContext();
|
|
2846
|
+
const {
|
|
2847
|
+
components: {
|
|
2848
|
+
IconButton,
|
|
2849
|
+
Popover
|
|
2850
|
+
},
|
|
2851
|
+
icons: {
|
|
2852
|
+
FilterList,
|
|
2853
|
+
ArrowDropDown
|
|
2854
|
+
}
|
|
2855
|
+
} = useTheme();
|
|
2856
|
+
const cssVariables = useCssVariables();
|
|
2857
|
+
const [anchor, setAnchor] = require$$0.useState(null);
|
|
2858
|
+
const isActive = table.useState((state) => {
|
|
2859
|
+
const filter2 = state.filters.get(columnId);
|
|
2860
|
+
const filterValue = state.filterValues.get(columnId);
|
|
2861
|
+
return filter2 !== void 0 && filterValue !== void 0 && filter2.isActive(filterValue);
|
|
2862
|
+
});
|
|
2863
|
+
const filter = table.useState((state) => {
|
|
2864
|
+
var _a;
|
|
2865
|
+
return (_a = state.activeColumns.find((column) => column.id === columnId)) == null ? void 0 : _a.filter;
|
|
2866
|
+
});
|
|
2867
|
+
if (!filter)
|
|
2868
|
+
return null;
|
|
2869
|
+
return tableTheme.jsxs(tableTheme.Fragment, {
|
|
2870
|
+
children: [tableTheme.jsx(IconButton, {
|
|
2871
|
+
onClick: (e2) => setAnchor(e2.currentTarget),
|
|
2872
|
+
css: [isActive && {
|
|
2873
|
+
color: "white !important",
|
|
2874
|
+
backgroundColor: "var(--primaryMain) !important"
|
|
2875
|
+
}],
|
|
2876
|
+
children: isActive ? tableTheme.jsx(FilterList, {}) : tableTheme.jsx(ArrowDropDown, {})
|
|
2877
|
+
}), tableTheme.jsx("div", {
|
|
2878
|
+
onPointerDown: (e2) => {
|
|
2879
|
+
e2.stopPropagation();
|
|
2880
|
+
},
|
|
2881
|
+
onPointerMove: (e2) => {
|
|
2882
|
+
e2.stopPropagation();
|
|
2883
|
+
},
|
|
2884
|
+
children: tableTheme.jsx(Popover, {
|
|
2885
|
+
open: true,
|
|
2886
|
+
hidden: !anchor,
|
|
2887
|
+
onClose: () => setAnchor(null),
|
|
2888
|
+
anchorEl: anchor != null ? anchor : document.body,
|
|
2889
|
+
css: cssVariables,
|
|
2890
|
+
children: filter
|
|
2891
|
+
})
|
|
2892
|
+
})]
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
function ResizeHandle() {
|
|
2896
|
+
const table = useTableContext();
|
|
2897
|
+
const columnId = useColumnContext();
|
|
2898
|
+
const enabled = table.useState("props.enableColumnResize");
|
|
2899
|
+
function onPointerDown(e2) {
|
|
2900
|
+
e2.stopPropagation();
|
|
2901
|
+
const div = e2.target;
|
|
2902
|
+
div.setPointerCapture(e2.pointerId);
|
|
2903
|
+
}
|
|
2904
|
+
function onPointerMove(e2) {
|
|
2905
|
+
e2.stopPropagation();
|
|
2906
|
+
const div = e2.target;
|
|
2907
|
+
if (!div.hasPointerCapture(e2.pointerId))
|
|
2908
|
+
return;
|
|
2909
|
+
const parent = div.parentElement;
|
|
2910
|
+
const width = Math.max(e2.clientX - parent.getBoundingClientRect().left + 5, 50);
|
|
2911
|
+
table.update((state) => {
|
|
2912
|
+
state.columnWidths.set(columnId, `${width}px`);
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
function onPointerUp(e2) {
|
|
2916
|
+
e2.stopPropagation();
|
|
2917
|
+
const div = e2.target;
|
|
2918
|
+
div.releasePointerCapture(e2.pointerId);
|
|
2919
|
+
}
|
|
2920
|
+
function onDoubleClick(e2) {
|
|
2921
|
+
table.update((state) => {
|
|
2922
|
+
if (e2.getModifierState("Control")) {
|
|
2923
|
+
state.columnWidths.delete(columnId);
|
|
2924
|
+
} else {
|
|
2925
|
+
state.columnWidths.set(columnId, "max-content");
|
|
2926
|
+
}
|
|
2927
|
+
});
|
|
2928
|
+
}
|
|
2929
|
+
return tableTheme.jsx("div", {
|
|
2930
|
+
css: {
|
|
2931
|
+
alignSelf: "stretch",
|
|
2932
|
+
padding: "0 5px",
|
|
2933
|
+
cursor: enabled ? "col-resize" : "initial",
|
|
2934
|
+
display: "flex",
|
|
2935
|
+
alignItems: "center",
|
|
2936
|
+
"&:after": {
|
|
2937
|
+
content: '""',
|
|
2938
|
+
width: 1,
|
|
2939
|
+
height: "1.2em",
|
|
2940
|
+
background: "currentColor",
|
|
2941
|
+
transition: "transform 300ms"
|
|
2942
|
+
}
|
|
2943
|
+
},
|
|
2944
|
+
onPointerDown: enabled ? onPointerDown : void 0,
|
|
2945
|
+
onPointerMove: enabled ? onPointerMove : void 0,
|
|
2946
|
+
onPointerUp: enabled ? onPointerUp : void 0,
|
|
2947
|
+
onDoubleClick: enabled ? onDoubleClick : void 0
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
const Cell = require$$0.memo(function Cell2({
|
|
2951
|
+
itemId,
|
|
2952
|
+
rowIndex
|
|
2953
|
+
}) {
|
|
2954
|
+
var _a, _b;
|
|
2955
|
+
const table = useTableContext();
|
|
2956
|
+
const columnId = useColumnContext();
|
|
2957
|
+
const {
|
|
2958
|
+
css
|
|
2959
|
+
} = useTheme();
|
|
2960
|
+
const column = table.useState((state) => state.activeColumns.find((column2) => column2.id === columnId));
|
|
2961
|
+
const item = table.useState((state) => state.activeItemsById.get(itemId));
|
|
2962
|
+
const columnStyleOverride = table.useState((state) => state.columnStyleOverride.get(columnId), {
|
|
2963
|
+
throttle: 16
|
|
2964
|
+
});
|
|
2965
|
+
if (!column || !item)
|
|
2966
|
+
return null;
|
|
2967
|
+
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render cell", itemId, columnId);
|
|
2968
|
+
const classNames = [...calcClassNames(css, item, rowIndex), ...calcClassNames(column == null ? void 0 : column.css, item, rowIndex)];
|
|
2969
|
+
const content = column.renderCell(column.value(item), item);
|
|
2970
|
+
return tableTheme.jsx("div", {
|
|
2971
|
+
css: [tableTheme.defaultClasses.cell, classNames, columnStyleOverride],
|
|
2972
|
+
children: typeof content === "string" ? tableTheme.jsx("span", {
|
|
2973
|
+
css: tableTheme.defaultClasses.text,
|
|
2974
|
+
children: content
|
|
2975
|
+
}) : content
|
|
2976
|
+
});
|
|
2977
|
+
});
|
|
2978
|
+
function ExpandControl({
|
|
2979
|
+
itemId,
|
|
2980
|
+
hasDeferredChildren
|
|
2981
|
+
}) {
|
|
2982
|
+
const {
|
|
2983
|
+
components: {
|
|
2984
|
+
IconButton,
|
|
2985
|
+
Spinner
|
|
2986
|
+
},
|
|
2987
|
+
icons: {
|
|
2988
|
+
ChevronRight
|
|
2989
|
+
}
|
|
2990
|
+
} = useTheme();
|
|
2991
|
+
const table = useTableContext();
|
|
2992
|
+
const isExpanded = table.useState((state) => state.expanded.has(itemId));
|
|
2993
|
+
const hasChildren = table.useState((state) => {
|
|
2994
|
+
var _a;
|
|
2995
|
+
return !!((_a = state.activeItemsById.get(itemId)) == null ? void 0 : _a.children.length);
|
|
2996
|
+
});
|
|
2997
|
+
function toggle2() {
|
|
2998
|
+
const {
|
|
2999
|
+
props: {
|
|
3000
|
+
expanded: controlledExpanded,
|
|
3001
|
+
expandOnlyOne,
|
|
3002
|
+
onExpandedChange
|
|
3003
|
+
},
|
|
3004
|
+
expanded,
|
|
3005
|
+
activeItemsById
|
|
3006
|
+
} = table.getState();
|
|
3007
|
+
const newExpanded = new Set(expanded);
|
|
3008
|
+
if (expandOnlyOne)
|
|
3009
|
+
newExpanded.clear();
|
|
3010
|
+
if (isExpanded)
|
|
3011
|
+
newExpanded.delete(itemId);
|
|
3012
|
+
else {
|
|
3013
|
+
newExpanded.add(itemId);
|
|
3014
|
+
const item = activeItemsById.get(itemId);
|
|
3015
|
+
for (const ancestor of item ? getAncestors(activeItemsById, item) : []) {
|
|
3016
|
+
newExpanded.add(ancestor);
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
onExpandedChange == null ? void 0 : onExpandedChange(newExpanded);
|
|
3020
|
+
if (!controlledExpanded) {
|
|
3021
|
+
table.update((state) => {
|
|
3022
|
+
state.expanded = newExpanded;
|
|
3023
|
+
});
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
if (isExpanded && hasDeferredChildren && !hasChildren) {
|
|
3027
|
+
return tableTheme.jsx(Spinner, {
|
|
3028
|
+
css: {
|
|
3029
|
+
margin: "0 var(--spacing)"
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
return tableTheme.jsx(IconButton, {
|
|
3034
|
+
onClick: toggle2,
|
|
3035
|
+
children: tableTheme.jsx("span", {
|
|
3036
|
+
css: {
|
|
3037
|
+
display: "inline-flex",
|
|
3038
|
+
transition: "all 300ms",
|
|
3039
|
+
transform: isExpanded ? "rotate3d(0, 0, 1, 90deg)" : "rotate3d(0, 0, 1, 0deg)"
|
|
3040
|
+
},
|
|
3041
|
+
children: tableTheme.jsx(ChevronRight, {})
|
|
3042
|
+
})
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
function SelectComponent({
|
|
3046
|
+
itemId
|
|
3047
|
+
}) {
|
|
3048
|
+
const table = useTableContext();
|
|
3049
|
+
const {
|
|
3050
|
+
components: {
|
|
3051
|
+
Checkbox
|
|
3052
|
+
}
|
|
3053
|
+
} = useTheme();
|
|
3054
|
+
const isSelected2 = table.useState((state) => {
|
|
3055
|
+
const itemIds = itemId ? [itemId] : [...state.activeItemsById.keys()];
|
|
3056
|
+
return state.activeItemsById.size > 0 && itemIds.every((itemId2) => state.selection.has(itemId2));
|
|
3057
|
+
});
|
|
3058
|
+
function toggle2(e2) {
|
|
3059
|
+
const mouseEvent = e2.nativeEvent;
|
|
3060
|
+
const {
|
|
3061
|
+
activeItems,
|
|
3062
|
+
activeItemsById,
|
|
3063
|
+
lastSelectedId,
|
|
3064
|
+
selection,
|
|
3065
|
+
props: {
|
|
3066
|
+
selectSyncChildren,
|
|
3067
|
+
selection: controlledSelection,
|
|
3068
|
+
onSelectionChange
|
|
3069
|
+
}
|
|
3070
|
+
} = table.getState();
|
|
3071
|
+
let range;
|
|
3072
|
+
if (mouseEvent.shiftKey && itemId) {
|
|
3073
|
+
const a2 = lastSelectedId ? activeItems.findIndex((i2) => lastSelectedId === i2.id) : 0;
|
|
3074
|
+
const b2 = activeItems.findIndex((item) => item.id === itemId);
|
|
3075
|
+
range = activeItems.slice(Math.min(a2, b2), Math.max(a2, b2) + 1);
|
|
3076
|
+
} else {
|
|
3077
|
+
const item = itemId ? activeItemsById.get(itemId) : void 0;
|
|
3078
|
+
range = item ? [item] : activeItems;
|
|
3079
|
+
}
|
|
3080
|
+
const newSelection = new Set(selection);
|
|
3081
|
+
for (const item of range) {
|
|
3082
|
+
if (isSelected2)
|
|
3083
|
+
newSelection.delete(item.id);
|
|
3084
|
+
else
|
|
3085
|
+
newSelection.add(item.id);
|
|
3086
|
+
}
|
|
3087
|
+
if (selectSyncChildren && isSelected2) {
|
|
3088
|
+
for (const ancestor of getAncestors(activeItemsById, ...range)) {
|
|
3089
|
+
newSelection.delete(ancestor);
|
|
3090
|
+
}
|
|
3091
|
+
for (const descendant of getDescendants(...range)) {
|
|
3092
|
+
newSelection.delete(descendant);
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
onSelectionChange == null ? void 0 : onSelectionChange(newSelection);
|
|
3096
|
+
if (!controlledSelection) {
|
|
3097
|
+
table.update((state) => {
|
|
3098
|
+
state.selection = newSelection;
|
|
3099
|
+
});
|
|
3100
|
+
}
|
|
3101
|
+
table.update((state) => {
|
|
3102
|
+
state.lastSelectedId = itemId;
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
return tableTheme.jsx(Checkbox, {
|
|
3106
|
+
css: {
|
|
3107
|
+
justifySelf: "start",
|
|
3108
|
+
color: "inherit"
|
|
3109
|
+
},
|
|
3110
|
+
checked: isSelected2,
|
|
3111
|
+
onChange: toggle2
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3114
|
+
function calcClassNames(css, item, index) {
|
|
3115
|
+
return [(css == null ? void 0 : css.cell) instanceof Function ? css.cell(item, index) : css == null ? void 0 : css.cell, index % 2 === 0 && (css == null ? void 0 : css.evenCell), index % 2 === 1 && (css == null ? void 0 : css.oddCell)];
|
|
3116
|
+
}
|
|
3117
|
+
const Row = require$$0.memo(function Row2({
|
|
3118
|
+
itemId,
|
|
3119
|
+
rowIndex
|
|
3120
|
+
}) {
|
|
3121
|
+
var _a, _b;
|
|
3122
|
+
const table = useTableContext();
|
|
3123
|
+
const divRef = require$$0.useRef(null);
|
|
3124
|
+
const {
|
|
3125
|
+
className,
|
|
3126
|
+
indent,
|
|
3127
|
+
hasChildren,
|
|
3128
|
+
hasDeferredChildren,
|
|
3129
|
+
columnIds,
|
|
3130
|
+
enableSelection,
|
|
3131
|
+
rowAction
|
|
3132
|
+
} = table.useState((state) => {
|
|
3133
|
+
var _a2, _b2;
|
|
3134
|
+
const item = state.activeItemsById.get(itemId);
|
|
3135
|
+
const index = !item ? -1 : state.activeItems.indexOf(item);
|
|
3136
|
+
return {
|
|
3137
|
+
className: calcClassNames(state.props.css, item, index),
|
|
3138
|
+
indent: item ? getAncestors(state.activeItemsById, item).size : 0,
|
|
3139
|
+
hasChildren: !!(item == null ? void 0 : item.children.length),
|
|
3140
|
+
hasDeferredChildren: item && ((_b2 = (_a2 = state.props).hasDeferredChildren) == null ? void 0 : _b2.call(_a2, item)),
|
|
3141
|
+
columnIds: state.activeColumns.map((column) => column.id),
|
|
3142
|
+
enableSelection: state.props.enableSelection,
|
|
3143
|
+
rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item, index) : null : state.props.rowAction
|
|
3144
|
+
};
|
|
3145
|
+
});
|
|
3146
|
+
require$$0.useEffect(() => {
|
|
3147
|
+
const div = divRef.current;
|
|
3148
|
+
if (!div)
|
|
3149
|
+
return;
|
|
3150
|
+
const o2 = new ResizeObserver(() => {
|
|
3151
|
+
if (!document.contains(div))
|
|
3152
|
+
return;
|
|
3153
|
+
table.update((state) => {
|
|
3154
|
+
state.rowHeights.set(itemId, div.offsetHeight);
|
|
3155
|
+
});
|
|
3156
|
+
});
|
|
3157
|
+
o2.observe(div);
|
|
3158
|
+
return () => o2.disconnect();
|
|
3159
|
+
}, [divRef.current]);
|
|
3160
|
+
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render row", itemId);
|
|
3161
|
+
return tableTheme.jsxs(tableTheme.Fragment, {
|
|
3162
|
+
children: [tableTheme.jsx("div", {
|
|
3163
|
+
css: [tableTheme.defaultClasses.cellFill, className],
|
|
3164
|
+
ref: divRef
|
|
3165
|
+
}), tableTheme.jsxs("div", {
|
|
3166
|
+
css: [tableTheme.defaultClasses.cell, tableTheme.defaultClasses.firstCell, className],
|
|
3167
|
+
children: [tableTheme.jsx("div", {
|
|
3168
|
+
css: {
|
|
3169
|
+
width: indent * 20
|
|
3170
|
+
}
|
|
3171
|
+
}), enableSelection && tableTheme.jsx(SelectComponent, {
|
|
3172
|
+
itemId
|
|
3173
|
+
}), (hasChildren || hasDeferredChildren) && tableTheme.jsx(ExpandControl, {
|
|
3174
|
+
itemId,
|
|
3175
|
+
hasDeferredChildren
|
|
3176
|
+
}), rowAction]
|
|
3177
|
+
}), columnIds.map((columnId) => tableTheme.jsx(ColumnContext.Provider, {
|
|
3178
|
+
value: columnId,
|
|
3179
|
+
children: tableTheme.jsx(Cell, {
|
|
3180
|
+
itemId,
|
|
3181
|
+
rowIndex
|
|
3182
|
+
})
|
|
3183
|
+
}, columnId)), tableTheme.jsx("div", {
|
|
3184
|
+
css: [tableTheme.defaultClasses.cellFill, className]
|
|
3185
|
+
})]
|
|
3186
|
+
});
|
|
3187
|
+
});
|
|
3188
|
+
function SortComponent({
|
|
3189
|
+
children
|
|
3190
|
+
}) {
|
|
3191
|
+
const table = useTableContext();
|
|
3192
|
+
const columnId = useColumnContext();
|
|
3193
|
+
const {
|
|
3194
|
+
components: {
|
|
3195
|
+
Badge
|
|
3196
|
+
},
|
|
3197
|
+
icons: {
|
|
3198
|
+
ArrowUpward
|
|
3199
|
+
}
|
|
3200
|
+
} = useTheme();
|
|
3201
|
+
const {
|
|
3202
|
+
direction,
|
|
3203
|
+
index
|
|
3204
|
+
} = table.useState((state) => {
|
|
3205
|
+
var _a, _b;
|
|
3206
|
+
const index2 = (_a = state.sort.findIndex((s2) => s2.columnId === columnId)) != null ? _a : -1;
|
|
3207
|
+
return {
|
|
3208
|
+
direction: (_b = state.sort[index2]) == null ? void 0 : _b.direction,
|
|
3209
|
+
index: index2 >= 0 && state.sort.length > 1 ? index2 + 1 : void 0
|
|
3210
|
+
};
|
|
3211
|
+
});
|
|
3212
|
+
function toggle2(e2) {
|
|
3213
|
+
const {
|
|
3214
|
+
props: {
|
|
3215
|
+
sort: controlledSort,
|
|
3216
|
+
onSortChange
|
|
3217
|
+
}
|
|
3218
|
+
} = table.getState();
|
|
3219
|
+
const newDirection = direction === "asc" ? "desc" : "asc";
|
|
3220
|
+
const newSort = (e2.getModifierState("Control") ? table.getState().sort.filter((s2) => s2.columnId !== columnId) : []).concat({
|
|
3221
|
+
columnId,
|
|
3222
|
+
direction: newDirection
|
|
3223
|
+
});
|
|
3224
|
+
onSortChange == null ? void 0 : onSortChange(newSort);
|
|
3225
|
+
if (!controlledSort) {
|
|
3226
|
+
table.update((state) => {
|
|
3227
|
+
state.sort = newSort;
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
return tableTheme.jsxs("div", {
|
|
3232
|
+
css: {
|
|
3233
|
+
userSelect: "none",
|
|
3234
|
+
display: "grid",
|
|
3235
|
+
gridTemplateColumns: "minmax(0, 1fr) max-content",
|
|
3236
|
+
alignItems: "center",
|
|
3237
|
+
cursor: "pointer",
|
|
3238
|
+
"& > div": {
|
|
3239
|
+
overflow: "hidden",
|
|
3240
|
+
textOverflow: "ellipsis"
|
|
3241
|
+
}
|
|
3242
|
+
},
|
|
3243
|
+
onClick: toggle2,
|
|
3244
|
+
children: [tableTheme.jsx("div", {
|
|
3245
|
+
children
|
|
3246
|
+
}), tableTheme.jsx(Badge, {
|
|
3247
|
+
badgeContent: index,
|
|
3248
|
+
children: tableTheme.jsx("span", {
|
|
3249
|
+
css: [{
|
|
3250
|
+
transition: "all 300ms",
|
|
3251
|
+
fontSize: "0.8em"
|
|
3252
|
+
}, !direction && {
|
|
3253
|
+
opacity: 0
|
|
3254
|
+
}, direction === "desc" && {
|
|
3255
|
+
transform: "rotate3d(0, 0, 1, 180deg)"
|
|
3256
|
+
}],
|
|
3257
|
+
children: tableTheme.jsx(ArrowUpward, {})
|
|
3258
|
+
})
|
|
3259
|
+
})]
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
function throttle(fn2, ms) {
|
|
3263
|
+
let last = 0;
|
|
3264
|
+
let lastArgs;
|
|
3265
|
+
let timeout;
|
|
3266
|
+
function run() {
|
|
3267
|
+
const args = lastArgs;
|
|
3268
|
+
last = Date.now();
|
|
3269
|
+
lastArgs = void 0;
|
|
3270
|
+
timeout = void 0;
|
|
3271
|
+
fn2(...args);
|
|
3272
|
+
}
|
|
3273
|
+
return Object.assign(function(...args) {
|
|
3274
|
+
const now = Date.now();
|
|
3275
|
+
lastArgs = args;
|
|
3276
|
+
if (timeout)
|
|
3277
|
+
;
|
|
3278
|
+
else if (now < last + ms) {
|
|
3279
|
+
timeout = setTimeout(run, last + ms - now);
|
|
3280
|
+
} else {
|
|
3281
|
+
run();
|
|
3282
|
+
}
|
|
3283
|
+
}, {
|
|
3284
|
+
flush() {
|
|
3285
|
+
if (lastArgs) {
|
|
3286
|
+
run();
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
const onAncestorScroll = (x2, onScroll) => {
|
|
3292
|
+
const find = (x22) => x22.parentElement ? [x22.parentElement, ...find(x22.parentElement)] : [document];
|
|
3293
|
+
const ancestors = find(x2);
|
|
3294
|
+
for (const ancestor of ancestors) {
|
|
3295
|
+
ancestor.addEventListener("scroll", onScroll);
|
|
3296
|
+
}
|
|
3297
|
+
return () => {
|
|
3298
|
+
for (const ancestor of ancestors) {
|
|
3299
|
+
ancestor.removeEventListener("scroll", onScroll);
|
|
3300
|
+
}
|
|
3301
|
+
};
|
|
3302
|
+
};
|
|
3303
|
+
const findScrollRoot = (x2) => {
|
|
3304
|
+
const parent = x2.parentElement;
|
|
3305
|
+
if (!parent)
|
|
3306
|
+
return document.documentElement;
|
|
3307
|
+
if (parent.scrollHeight > parent.clientHeight)
|
|
3308
|
+
return parent;
|
|
3309
|
+
return findScrollRoot(parent);
|
|
3310
|
+
};
|
|
3311
|
+
const relativeOffset = (x2, y2) => {
|
|
3312
|
+
if (x2.offsetParent === y2.offsetParent || !x2.offsetParent)
|
|
3313
|
+
return x2.offsetTop - y2.offsetTop;
|
|
3314
|
+
if (x2.offsetParent instanceof HTMLElement)
|
|
3315
|
+
return relativeOffset(x2.offsetParent, y2) + x2.offsetTop;
|
|
3316
|
+
return 0;
|
|
3317
|
+
};
|
|
3318
|
+
function Virtualized(_c) {
|
|
3319
|
+
var _d = _c, {
|
|
3320
|
+
header,
|
|
3321
|
+
children
|
|
3322
|
+
} = _d, props = __objRest(_d, [
|
|
3323
|
+
"header",
|
|
3324
|
+
"children"
|
|
3325
|
+
]);
|
|
3326
|
+
var _a, _b, _c2, _d2;
|
|
3327
|
+
const table = useTableContext();
|
|
3328
|
+
const virtual = table.useState("props.virtual");
|
|
3329
|
+
const probeRef = require$$0.useRef(null);
|
|
3330
|
+
const [, setCounter] = require$$0.useState(0);
|
|
3331
|
+
const {
|
|
3332
|
+
itemIds = [],
|
|
3333
|
+
from = 0,
|
|
3334
|
+
to,
|
|
3335
|
+
before = 0,
|
|
3336
|
+
after = 0
|
|
3337
|
+
} = table.useState((state) => {
|
|
3338
|
+
var _a2;
|
|
3339
|
+
const itemIds2 = state.activeItems.map((item) => item.id);
|
|
3340
|
+
const root = probeRef.current && findScrollRoot(probeRef.current);
|
|
3341
|
+
if (!state.props.virtual)
|
|
3342
|
+
return {
|
|
3343
|
+
itemIds: itemIds2
|
|
3344
|
+
};
|
|
3345
|
+
if (!probeRef.current || !root || !document.contains(root))
|
|
3346
|
+
return {};
|
|
3347
|
+
const {
|
|
3348
|
+
rowHeight,
|
|
3349
|
+
initalRowHeight,
|
|
3350
|
+
overscan = 200,
|
|
3351
|
+
overscanTop,
|
|
3352
|
+
overscanBottom
|
|
3353
|
+
} = (_a2 = state.props.virtual instanceof Object ? state.props.virtual : void 0) != null ? _a2 : {};
|
|
3354
|
+
let totalHeight = 0;
|
|
3355
|
+
const rowHeights = itemIds2.map((itemId, index) => {
|
|
3356
|
+
var _a3, _b2;
|
|
3357
|
+
const h2 = (_b2 = (_a3 = rowHeight != null ? rowHeight : state.rowHeights.get(itemId)) != null ? _a3 : initalRowHeight) != null ? _b2 : index === 0 ? 100 : totalHeight / index;
|
|
3358
|
+
totalHeight += h2;
|
|
3359
|
+
return h2;
|
|
3360
|
+
});
|
|
3361
|
+
const probeOffset = relativeOffset(probeRef.current, root);
|
|
3362
|
+
const headerHeight = probeRef.current.offsetTop;
|
|
3363
|
+
const topOfTable = root.scrollTop - probeOffset + headerHeight;
|
|
3364
|
+
const bottomOfTable = topOfTable + root.clientHeight - headerHeight;
|
|
3365
|
+
let from2 = 0, to2 = itemIds2.length, before2 = 0, after2 = 0;
|
|
3366
|
+
for (const h2 of rowHeights) {
|
|
3367
|
+
if (before2 + h2 > topOfTable - (overscanTop != null ? overscanTop : overscan))
|
|
3368
|
+
break;
|
|
3369
|
+
from2++;
|
|
3370
|
+
before2 += h2;
|
|
3371
|
+
}
|
|
3372
|
+
for (const h2 of rowHeights.reverse()) {
|
|
3373
|
+
if (after2 + h2 > totalHeight - bottomOfTable - (overscanBottom != null ? overscanBottom : overscan))
|
|
3374
|
+
break;
|
|
3375
|
+
to2--;
|
|
3376
|
+
after2 += h2;
|
|
3377
|
+
}
|
|
3378
|
+
return {
|
|
3379
|
+
itemIds: itemIds2.slice(from2, to2),
|
|
3380
|
+
from: from2,
|
|
3381
|
+
to: to2,
|
|
3382
|
+
before: before2,
|
|
3383
|
+
after: after2
|
|
3384
|
+
};
|
|
3385
|
+
});
|
|
3386
|
+
const throttleScroll = (_b = (_a = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a.throttleScroll) != null ? _b : 500;
|
|
3387
|
+
const incCounter = require$$0.useMemo(() => throttle(() => setCounter((c2) => c2 + 1), throttleScroll), [throttleScroll]);
|
|
3388
|
+
require$$0.useEffect(() => {
|
|
3389
|
+
if (!virtual || !probeRef.current)
|
|
3390
|
+
return;
|
|
3391
|
+
return onAncestorScroll(probeRef.current, incCounter);
|
|
3392
|
+
}, [probeRef.current, incCounter]);
|
|
3393
|
+
(_d2 = (_c2 = table.getState().props).debugRender) == null ? void 0 : _d2.call(_c2, `Virtualalized render ${from} to ${to}`);
|
|
3394
|
+
return tableTheme.jsxs("div", __spreadProps(__spreadValues({}, props), {
|
|
3395
|
+
children: [header, virtual && tableTheme.jsx("div", {
|
|
3396
|
+
style: {
|
|
3397
|
+
gridColumn: "1 / -1",
|
|
3398
|
+
height: before
|
|
3399
|
+
},
|
|
3400
|
+
ref: probeRef
|
|
3401
|
+
}), children(itemIds, from), virtual && tableTheme.jsx("div", {
|
|
3402
|
+
style: {
|
|
3403
|
+
gridColumn: "1 / -1",
|
|
3404
|
+
height: after
|
|
3405
|
+
}
|
|
3406
|
+
})]
|
|
3407
|
+
}));
|
|
3408
|
+
}
|
|
3409
|
+
const TableContext = require$$0.createContext(null);
|
|
3410
|
+
const ColumnContext = require$$0.createContext(null);
|
|
3411
|
+
function useTableContext() {
|
|
3412
|
+
const value = require$$0.useContext(TableContext);
|
|
3413
|
+
if (!value)
|
|
3414
|
+
throw Error("No table context available");
|
|
3415
|
+
return value;
|
|
3416
|
+
}
|
|
3417
|
+
function useColumnContext() {
|
|
3418
|
+
const value = require$$0.useContext(ColumnContext);
|
|
3419
|
+
if (value === null)
|
|
3420
|
+
throw Error("No column context available");
|
|
3421
|
+
return value;
|
|
3422
|
+
}
|
|
3423
|
+
function Table(props) {
|
|
3424
|
+
var _a, _b;
|
|
3425
|
+
const table = useTableState(props);
|
|
3426
|
+
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table");
|
|
3427
|
+
return tableTheme.jsx(TableContext.Provider, {
|
|
3428
|
+
value: table,
|
|
3429
|
+
children: tableTheme.jsx(TableLoadingState, {})
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
function TableLoadingState() {
|
|
3433
|
+
const {
|
|
3434
|
+
text
|
|
3435
|
+
} = useTheme();
|
|
3436
|
+
const isHydrated = useTableStateStorage();
|
|
3437
|
+
const [showLoading, setShowLoading] = require$$0.useState(false);
|
|
3438
|
+
require$$0.useEffect(() => {
|
|
3439
|
+
const handle = setTimeout(() => setShowLoading(true), 500);
|
|
3440
|
+
return () => clearTimeout(handle);
|
|
3441
|
+
});
|
|
3442
|
+
return tableTheme.jsxs(tableTheme.Fragment, {
|
|
3443
|
+
children: [!isHydrated && showLoading && tableTheme.jsx("div", {
|
|
3444
|
+
children: text.loading
|
|
3445
|
+
}), tableTheme.jsx(TableInner, {
|
|
3446
|
+
hidden: !isHydrated
|
|
3447
|
+
})]
|
|
3448
|
+
});
|
|
3449
|
+
}
|
|
3450
|
+
const TableInner = require$$0.memo(function TableInner2({
|
|
3451
|
+
hidden
|
|
3452
|
+
}) {
|
|
3453
|
+
var _a, _b;
|
|
3454
|
+
const table = useTableContext();
|
|
3455
|
+
const fullWidth = table.useState("props.fullWidth");
|
|
3456
|
+
const activeColumns = table.useState((state) => state.activeColumns.map((column) => ({
|
|
3457
|
+
id: column.id,
|
|
3458
|
+
width: column.width,
|
|
3459
|
+
css: column.css,
|
|
3460
|
+
header: column.header
|
|
3461
|
+
})));
|
|
3462
|
+
const columnWidths = table.useState("columnWidths", {
|
|
3463
|
+
throttle: 16
|
|
3464
|
+
});
|
|
3465
|
+
const columnStyleOverride = table.useState("columnStyleOverride", {
|
|
3466
|
+
throttle: 16
|
|
3467
|
+
});
|
|
3468
|
+
const defaultWidth = table.useState("props.defaultWidth");
|
|
3469
|
+
const css = table.useState("props.css");
|
|
3470
|
+
const stickyHeader = table.useState("props.stickyHeader");
|
|
3471
|
+
const enableSelection = table.useState("props.enableSelection");
|
|
3472
|
+
const enableColumnSelection = table.useState("props.enableColumnSelection");
|
|
3473
|
+
const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
|
|
3474
|
+
const cssVariables = useCssVariables();
|
|
3475
|
+
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
3476
|
+
return tableTheme.jsx(Virtualized, {
|
|
3477
|
+
css: [cssVariables, tableTheme.defaultClasses.table, css == null ? void 0 : css.table, {
|
|
3478
|
+
gridTemplateColumns: [
|
|
3479
|
+
fullWidth === "right" || fullWidth === true ? "auto" : "0",
|
|
3480
|
+
"max-content",
|
|
3481
|
+
...activeColumns.map((column) => {
|
|
3482
|
+
var _a2, _b2, _c;
|
|
3483
|
+
return (_c = (_b2 = (_a2 = columnWidths.get(column.id)) != null ? _a2 : column.width) != null ? _b2 : defaultWidth) != null ? _c : "max-content";
|
|
3484
|
+
}),
|
|
3485
|
+
fullWidth === "left" || fullWidth === true ? "auto" : "0"
|
|
3486
|
+
].join(" ")
|
|
3487
|
+
}, hidden && {
|
|
3488
|
+
visibility: "hidden"
|
|
3489
|
+
}],
|
|
3490
|
+
header: tableTheme.jsxs(tableTheme.Fragment, {
|
|
3491
|
+
children: [tableTheme.jsx("div", {
|
|
3492
|
+
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, css == null ? void 0 : css.headerCell]
|
|
3493
|
+
}), tableTheme.jsxs("div", {
|
|
3494
|
+
css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky, css == null ? void 0 : css.headerCell],
|
|
3495
|
+
children: [enableSelection && tableTheme.jsx(SelectComponent, {}), enableColumnSelection && tableTheme.jsx(ColumnSelection, {}), enableExport && tableTheme.jsx(Export, {})]
|
|
3496
|
+
}), tableTheme.jsx(ColumnHeaderContext.Provider, {
|
|
3497
|
+
children: activeColumns.map((column) => {
|
|
3498
|
+
var _a2;
|
|
3499
|
+
return tableTheme.jsx(ColumnContext.Provider, {
|
|
3500
|
+
value: column.id,
|
|
3501
|
+
children: tableTheme.jsxs(ColumnHeader, {
|
|
3502
|
+
css: [tableTheme.defaultClasses.headerCell, css == null ? void 0 : css.headerCell, (_a2 = column.css) == null ? void 0 : _a2.headerCell, columnStyleOverride.get(column.id), stickyHeader && tableTheme.defaultClasses.sticky],
|
|
3503
|
+
children: [tableTheme.jsx(FilterControl, {}), tableTheme.jsx(SortComponent, {
|
|
3504
|
+
children: column.header
|
|
3505
|
+
}), tableTheme.jsx("div", {
|
|
3506
|
+
css: {
|
|
3507
|
+
flex: 1
|
|
3508
|
+
}
|
|
3509
|
+
}), tableTheme.jsx(ResizeHandle, {})]
|
|
3510
|
+
}, column.id)
|
|
3511
|
+
}, column.id);
|
|
3512
|
+
})
|
|
3513
|
+
}), tableTheme.jsx("div", {
|
|
3514
|
+
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, css == null ? void 0 : css.headerCell]
|
|
3515
|
+
})]
|
|
3516
|
+
}),
|
|
3517
|
+
children: (itemIds, startIndex) => itemIds.map((itemId, index) => tableTheme.jsx(Row, {
|
|
3518
|
+
itemId,
|
|
3519
|
+
rowIndex: startIndex + index
|
|
3520
|
+
}, itemId))
|
|
3521
|
+
});
|
|
3522
|
+
});
|
|
3523
|
+
function toggle(set, value, singleSelect) {
|
|
3524
|
+
const newSet = new Set(singleSelect ? [] : set);
|
|
3525
|
+
if (set.has(value)) {
|
|
3526
|
+
newSet.delete(value);
|
|
3527
|
+
} else {
|
|
3528
|
+
newSet.add(value);
|
|
3529
|
+
}
|
|
3530
|
+
return newSet;
|
|
3531
|
+
}
|
|
3532
|
+
function SelectFilter(_e) {
|
|
3533
|
+
var _f = _e, {
|
|
3534
|
+
options: providedOptions,
|
|
3535
|
+
stringValue = asString,
|
|
3536
|
+
render = stringValue,
|
|
3537
|
+
singleSelect
|
|
3538
|
+
} = _f, props = __objRest(_f, [
|
|
3539
|
+
"options",
|
|
3540
|
+
"stringValue",
|
|
3541
|
+
"render",
|
|
3542
|
+
"singleSelect"
|
|
3543
|
+
]);
|
|
3544
|
+
const {
|
|
3545
|
+
components: {
|
|
3546
|
+
TextField,
|
|
3547
|
+
Button,
|
|
3548
|
+
IconButton,
|
|
3549
|
+
Checkbox
|
|
3550
|
+
},
|
|
3551
|
+
icons: {
|
|
3552
|
+
Search,
|
|
3553
|
+
Clear
|
|
3554
|
+
},
|
|
3555
|
+
text
|
|
3556
|
+
} = useTheme();
|
|
3557
|
+
const table = useTableContext();
|
|
3558
|
+
const columnId = useColumnContext();
|
|
3559
|
+
const options = table.useState((state) => {
|
|
3560
|
+
var _a;
|
|
3561
|
+
if (providedOptions)
|
|
3562
|
+
return uniq(providedOptions);
|
|
3563
|
+
const column = state.activeColumns.find((column2) => column2.id === columnId);
|
|
3564
|
+
if (!column)
|
|
3565
|
+
return [];
|
|
3566
|
+
const filterBy = (_a = props.filterBy) != null ? _a : (x2) => x2;
|
|
3567
|
+
return uniq(flatMap(state.items, (item) => castArray(filterBy(column.value(item), item))));
|
|
3568
|
+
});
|
|
3569
|
+
const [query, setQuery] = require$$0.useState("");
|
|
3570
|
+
const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));
|
|
3571
|
+
const {
|
|
3572
|
+
value = /* @__PURE__ */ new Set(),
|
|
3573
|
+
onChange
|
|
3574
|
+
} = useFilter(__spreadProps(__spreadValues({}, props), {
|
|
3575
|
+
id: "selectFilter",
|
|
3576
|
+
isActive(filterValue) {
|
|
3577
|
+
return filterValue.size > 0;
|
|
3578
|
+
},
|
|
3579
|
+
test(filterValue, value2) {
|
|
3580
|
+
return filterValue.has(value2);
|
|
3581
|
+
}
|
|
3582
|
+
}));
|
|
3583
|
+
return tableTheme.jsxs("div", {
|
|
3584
|
+
css: {
|
|
3585
|
+
padding: "calc(var(--spacing) * 2)",
|
|
3586
|
+
display: "grid",
|
|
3587
|
+
gap: "var(--spacing)"
|
|
3588
|
+
},
|
|
3589
|
+
children: [tableTheme.jsxs("div", {
|
|
3590
|
+
css: {
|
|
3591
|
+
marginBottom: "var(--spacing)",
|
|
3592
|
+
display: "grid",
|
|
3593
|
+
gridAutoFlow: "column",
|
|
3594
|
+
gap: "var(--spacing)",
|
|
3595
|
+
justifyContent: "space-between",
|
|
3596
|
+
alignItems: "center"
|
|
3597
|
+
},
|
|
3598
|
+
children: [tableTheme.jsx("div", {
|
|
3599
|
+
children: text.selectFilter
|
|
3600
|
+
}), tableTheme.jsx(Button, {
|
|
3601
|
+
variant: "contained",
|
|
3602
|
+
onClick: () => onChange(/* @__PURE__ */ new Set()),
|
|
3603
|
+
disabled: value.size === 0,
|
|
3604
|
+
children: text.reset
|
|
3605
|
+
})]
|
|
3606
|
+
}), tableTheme.jsx(TextField, {
|
|
3607
|
+
value: query,
|
|
3608
|
+
onChange: (e2) => setQuery(e2.target.value),
|
|
3609
|
+
endIcon: tableTheme.jsx(IconButton, {
|
|
3610
|
+
onClick: () => setQuery(""),
|
|
3611
|
+
children: !query ? tableTheme.jsx(Search, {}) : tableTheme.jsx(Clear, {})
|
|
3612
|
+
}),
|
|
3613
|
+
css: {
|
|
3614
|
+
marginBottom: "var(--spacing)"
|
|
3615
|
+
}
|
|
3616
|
+
}), filtered.map((option, index) => tableTheme.jsx(FormControlLabel, {
|
|
3617
|
+
control: tableTheme.jsx(Checkbox, {
|
|
3618
|
+
checked: value.has(option),
|
|
3619
|
+
onChange: () => onChange(toggle(value, option, singleSelect))
|
|
3620
|
+
}),
|
|
3621
|
+
label: render(option)
|
|
3622
|
+
}, index)), filtered.length === 0 && tableTheme.jsx("span", {
|
|
3623
|
+
css: {
|
|
3624
|
+
textAlign: "center"
|
|
3625
|
+
},
|
|
3626
|
+
children: text.noResults
|
|
3627
|
+
})]
|
|
3628
|
+
});
|
|
3629
|
+
}
|
|
3630
|
+
function debounce(fn2, ms) {
|
|
3631
|
+
let lastArgs;
|
|
3632
|
+
let timeout;
|
|
3633
|
+
function run() {
|
|
3634
|
+
const args = lastArgs;
|
|
3635
|
+
lastArgs = void 0;
|
|
3636
|
+
timeout = void 0;
|
|
3637
|
+
fn2(...args);
|
|
3638
|
+
}
|
|
3639
|
+
return Object.assign(function(...args) {
|
|
3640
|
+
lastArgs = args;
|
|
3641
|
+
if (timeout) {
|
|
3642
|
+
clearTimeout(timeout);
|
|
3643
|
+
}
|
|
3644
|
+
timeout = setTimeout(run, ms);
|
|
3645
|
+
}, {
|
|
3646
|
+
flush() {
|
|
3647
|
+
if (timeout) {
|
|
3648
|
+
clearTimeout(timeout);
|
|
3649
|
+
run();
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3652
|
+
});
|
|
3653
|
+
}
|
|
3654
|
+
function useFilter(impl) {
|
|
3655
|
+
var _a;
|
|
3656
|
+
const table = useTableContext();
|
|
3657
|
+
const columnId = useColumnContext();
|
|
3658
|
+
require$$0.useEffect(() => {
|
|
3659
|
+
table.update((state) => {
|
|
3660
|
+
if (impl.defaultValue !== void 0) {
|
|
3661
|
+
state.filterValues.set(columnId, impl.defaultValue);
|
|
3662
|
+
}
|
|
3663
|
+
});
|
|
3664
|
+
}, []);
|
|
3665
|
+
require$$0.useEffect(() => {
|
|
3666
|
+
table.update((state) => {
|
|
3667
|
+
state.filters.set(columnId, K(impl));
|
|
3668
|
+
if (impl.value !== void 0) {
|
|
3669
|
+
state.filterValues.set(columnId, impl.value);
|
|
3670
|
+
}
|
|
3671
|
+
});
|
|
3672
|
+
return () => {
|
|
3673
|
+
table.update((state) => {
|
|
3674
|
+
state.filters.delete(columnId);
|
|
3675
|
+
});
|
|
3676
|
+
};
|
|
3677
|
+
}, [table, columnId, ...(_a = impl.dependencies) != null ? _a : [impl]]);
|
|
3678
|
+
const value = table.useState((state) => state.filterValues.get(columnId));
|
|
3679
|
+
const [dirtyValue, setDirtyValue] = require$$0.useState();
|
|
3680
|
+
const implRef = require$$0.useRef(impl);
|
|
3681
|
+
require$$0.useLayoutEffect(() => {
|
|
3682
|
+
implRef.current = impl;
|
|
3683
|
+
});
|
|
3684
|
+
const delayedUpdate = require$$0.useMemo(() => debounce((value2) => {
|
|
3685
|
+
const { value: controlledValue, onChange: onChange2 } = implRef.current;
|
|
3686
|
+
if (controlledValue === void 0) {
|
|
3687
|
+
table.update((state) => {
|
|
3688
|
+
state.filterValues.set(columnId, value2);
|
|
3689
|
+
});
|
|
3690
|
+
}
|
|
3691
|
+
onChange2 == null ? void 0 : onChange2(value2);
|
|
3692
|
+
}, 500), [table]);
|
|
3693
|
+
function onChange(value2) {
|
|
3694
|
+
setDirtyValue(value2);
|
|
3695
|
+
delayedUpdate(value2);
|
|
3696
|
+
}
|
|
3697
|
+
require$$0.useEffect(() => delayedUpdate.flush(), [delayedUpdate]);
|
|
3698
|
+
return {
|
|
3699
|
+
value: dirtyValue != null ? dirtyValue : value,
|
|
3700
|
+
onChange
|
|
3701
|
+
};
|
|
3702
|
+
}
|
|
3703
|
+
const textMatch = (text, query) => {
|
|
3704
|
+
text = text.toLowerCase();
|
|
3705
|
+
query = query.toLowerCase();
|
|
3706
|
+
return query.split(/\s+/).every((part) => termMatch(text, part));
|
|
3707
|
+
};
|
|
3708
|
+
const termMatch = (text, query) => {
|
|
3709
|
+
let i2 = 0;
|
|
3710
|
+
outer:
|
|
3711
|
+
for (const char of query) {
|
|
3712
|
+
for (; i2 < text.length; i2++) {
|
|
3713
|
+
if (text[i2] === char) {
|
|
3714
|
+
i2++;
|
|
3715
|
+
continue outer;
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
return false;
|
|
3719
|
+
}
|
|
3720
|
+
return true;
|
|
3721
|
+
};
|
|
3722
|
+
function TextFilter(_g) {
|
|
3723
|
+
var _h = _g, {
|
|
3724
|
+
compare = textMatch,
|
|
3725
|
+
filterBy = asStringOrArray
|
|
3726
|
+
} = _h, props = __objRest(_h, [
|
|
3727
|
+
"compare",
|
|
3728
|
+
"filterBy"
|
|
3729
|
+
]);
|
|
3730
|
+
const {
|
|
3731
|
+
components: {
|
|
3732
|
+
TextField,
|
|
3733
|
+
IconButton,
|
|
3734
|
+
Button
|
|
3735
|
+
},
|
|
3736
|
+
icons: {
|
|
3737
|
+
Search,
|
|
3738
|
+
Clear
|
|
3739
|
+
},
|
|
3740
|
+
text
|
|
3741
|
+
} = useTheme();
|
|
3742
|
+
const {
|
|
3743
|
+
value = "",
|
|
3744
|
+
onChange
|
|
3745
|
+
} = useFilter(__spreadProps(__spreadValues({}, props), {
|
|
3746
|
+
filterBy,
|
|
3747
|
+
id: "textFilter",
|
|
3748
|
+
isActive(filterValue) {
|
|
3749
|
+
return !!filterValue;
|
|
3750
|
+
},
|
|
3751
|
+
test(filterValue, value2) {
|
|
3752
|
+
return compare(value2, filterValue);
|
|
3753
|
+
}
|
|
3754
|
+
}));
|
|
3755
|
+
return tableTheme.jsxs("div", {
|
|
3756
|
+
css: {
|
|
3757
|
+
padding: `calc(var(--spacing) * 2)`,
|
|
3758
|
+
display: "grid",
|
|
3759
|
+
gap: "var(--spacing)"
|
|
3760
|
+
},
|
|
3761
|
+
children: [tableTheme.jsxs("div", {
|
|
3762
|
+
css: {
|
|
3763
|
+
marginBottom: "var(--spacing)",
|
|
3764
|
+
display: "grid",
|
|
3765
|
+
gridAutoFlow: "column",
|
|
3766
|
+
gap: "var(--spacing)",
|
|
3767
|
+
justifyContent: "space-between",
|
|
3768
|
+
alignItems: "center"
|
|
3769
|
+
},
|
|
3770
|
+
children: [tableTheme.jsx("div", {
|
|
3771
|
+
children: text.textFilter
|
|
3772
|
+
}), tableTheme.jsx(Button, {
|
|
3773
|
+
variant: "contained",
|
|
3774
|
+
onClick: () => onChange(""),
|
|
3775
|
+
disabled: !value,
|
|
3776
|
+
children: text.reset
|
|
3777
|
+
})]
|
|
3778
|
+
}), tableTheme.jsx(TextField, {
|
|
3779
|
+
value,
|
|
3780
|
+
onChange: (e2) => onChange(e2.target.value),
|
|
3781
|
+
endIcon: tableTheme.jsx(IconButton, {
|
|
3782
|
+
onClick: () => onChange(""),
|
|
3783
|
+
children: !value ? tableTheme.jsx(Search, {}) : tableTheme.jsx(Clear, {})
|
|
3784
|
+
})
|
|
3785
|
+
})]
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3788
|
+
exports.TableThemeContext = tableTheme.TableThemeContext;
|
|
3789
|
+
exports.configureTableTheme = tableTheme.configureTableTheme;
|
|
3790
|
+
exports.ColumnContext = ColumnContext;
|
|
3791
|
+
exports.DateFilter = DateFilter;
|
|
3792
|
+
exports.SelectFilter = SelectFilter;
|
|
3793
|
+
exports.Table = Table;
|
|
3794
|
+
exports.TableContext = TableContext;
|
|
3795
|
+
exports.TextFilter = TextFilter;
|
|
3796
|
+
exports.termMatch = termMatch;
|
|
3797
|
+
exports.textMatch = textMatch;
|
|
3798
|
+
exports.useColumnContext = useColumnContext;
|
|
3799
|
+
exports.useFilter = useFilter;
|
|
3800
|
+
exports.useTableContext = useTableContext;
|
|
3801
|
+
exports.useTheme = useTheme;
|
|
3802
|
+
//# sourceMappingURL=index.js.map
|