schummar-table 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1284 -800
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mui4Theme.js +1 -1
- package/dist/cjs/mui4Theme.js.map +1 -1
- package/dist/cjs/mui5Theme.js +1 -1
- package/dist/cjs/mui5Theme.js.map +1 -1
- package/dist/cjs/tableTheme.js +9 -458
- package/dist/cjs/tableTheme.js.map +1 -1
- package/dist/es/index.js +2080 -1600
- package/dist/es/index.js.map +1 -1
- package/dist/es/mui4Theme.js +2 -2
- package/dist/es/mui4Theme.js.map +1 -1
- package/dist/es/mui5Theme.js +2 -2
- package/dist/es/mui5Theme.js.map +1 -1
- package/dist/es/tableTheme.js +8 -458
- package/dist/es/tableTheme.js.map +1 -1
- package/dist/types/components/dateFilter.d.ts +3 -2
- package/dist/types/components/dateInput.d.ts +5 -0
- package/dist/types/components/datePicker.d.ts +10 -0
- package/dist/types/components/selectFilter.d.ts +4 -0
- package/dist/types/components/textFilter.d.ts +4 -1
- package/dist/types/hooks/useTheme.d.ts +2 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/theme/mui4Theme/index.d.ts +2 -2
- package/dist/types/theme/mui5Theme/index.d.ts +2 -2
- package/dist/types/theme/tableTheme.d.ts +2 -2
- package/dist/types/types.d.ts +27 -13
- package/package.json +1 -5
package/dist/cjs/index.js
CHANGED
|
@@ -33,461 +33,165 @@ var __objRest = (source, exclude) => {
|
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports[Symbol.toStringTag] = "Module";
|
|
35
35
|
var react = require("react");
|
|
36
|
+
var react$1 = require("schummar-state/react");
|
|
36
37
|
var tableTheme = require("./tableTheme.js");
|
|
37
38
|
var jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
38
39
|
var dayzed = require("dayzed");
|
|
39
40
|
var immer = require("immer");
|
|
40
|
-
var react$
|
|
41
|
-
require("@emotion/react");
|
|
41
|
+
var react$2 = require("@emotion/react");
|
|
42
42
|
require("react-dom");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
class Queue {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.q = new Array();
|
|
46
|
+
this.isRunning = false;
|
|
47
|
+
}
|
|
48
|
+
run(job, replace) {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
if (replace) {
|
|
51
|
+
this.q = [];
|
|
52
|
+
}
|
|
53
|
+
this.q.push({ job, resolve, reject });
|
|
54
|
+
if (!this.isRunning)
|
|
55
|
+
this.start();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async start() {
|
|
59
|
+
this.isRunning = true;
|
|
60
|
+
let next;
|
|
61
|
+
while (next = this.q.shift()) {
|
|
62
|
+
try {
|
|
63
|
+
const result = await next.job();
|
|
64
|
+
next.resolve(result);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
next.reject(e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this.isRunning = false;
|
|
70
|
+
}
|
|
46
71
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
72
|
+
const KEYS = ["sort", "selection", "expanded", "hiddenColumns", "filterValues", "columnWidths", "columnOrder"];
|
|
73
|
+
const storageName = (id) => `schummar-table_state-v1_${id}`;
|
|
74
|
+
function stringify(value) {
|
|
75
|
+
function prepare(value2) {
|
|
76
|
+
if (value2 instanceof Date) {
|
|
77
|
+
return { __date: value2.toJSON() };
|
|
51
78
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const {
|
|
55
|
-
visible
|
|
56
|
-
} = react.useContext(tableTheme.PopoverContext);
|
|
57
|
-
react.useLayoutEffect(() => {
|
|
58
|
-
if (visible && ref.current) {
|
|
59
|
-
ref.current.focus();
|
|
79
|
+
if (value2 instanceof Set) {
|
|
80
|
+
return { __set: Array.from(value2).map(prepare) };
|
|
60
81
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"--primaryLight": state.theme.colors.primary.light,
|
|
72
|
-
"--primaryContrastText": state.theme.colors.primary.contrastText,
|
|
73
|
-
"--secondaryMain": state.theme.colors.secondary.main,
|
|
74
|
-
"--secondaryLight": state.theme.colors.secondary.light,
|
|
75
|
-
"--secondaryContrastText": state.theme.colors.secondary.contrastText
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
const weekDays = [0, 1, 2, 3, 4, 5, 6];
|
|
79
|
-
const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
80
|
-
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
81
|
-
const endOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1, 0, 0, 0, -1);
|
|
82
|
-
function dateIntersect(a, b) {
|
|
83
|
-
if (a instanceof Date) {
|
|
84
|
-
a = {
|
|
85
|
-
min: a,
|
|
86
|
-
max: a
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (b instanceof Date) {
|
|
90
|
-
b = {
|
|
91
|
-
min: b,
|
|
92
|
-
max: b
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
if (!(a == null ? void 0 : a.min) || !a.max || !(b == null ? void 0 : b.min) || !b.max) {
|
|
96
|
-
return false;
|
|
82
|
+
if (value2 instanceof Map) {
|
|
83
|
+
return { __map: Array.from(value2.entries()).map((entry) => entry.map(prepare)) };
|
|
84
|
+
}
|
|
85
|
+
if (value2 instanceof Array) {
|
|
86
|
+
return value2.map(prepare);
|
|
87
|
+
}
|
|
88
|
+
if (value2 instanceof Object) {
|
|
89
|
+
return Object.fromEntries(Object.entries(value2).map(([k, v]) => [k, prepare(v)]));
|
|
90
|
+
}
|
|
91
|
+
return value2;
|
|
97
92
|
}
|
|
98
|
-
return
|
|
93
|
+
return JSON.stringify(prepare(value));
|
|
99
94
|
}
|
|
100
|
-
function
|
|
101
|
-
value,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
locale,
|
|
105
|
-
firstDayOfWeek = 0
|
|
106
|
-
}) {
|
|
107
|
-
const {
|
|
108
|
-
components: {
|
|
109
|
-
IconButton
|
|
110
|
-
},
|
|
111
|
-
icons: {
|
|
112
|
-
ChevronRight
|
|
95
|
+
function parse(value) {
|
|
96
|
+
return JSON.parse(value, (_key, value2) => {
|
|
97
|
+
if (value2 instanceof Object && "__date" in value2) {
|
|
98
|
+
return new Date(value2.__date);
|
|
113
99
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const {
|
|
122
|
-
calendars,
|
|
123
|
-
getBackProps,
|
|
124
|
-
getForwardProps,
|
|
125
|
-
getDateProps
|
|
126
|
-
} = dayzed.useDayzed({
|
|
127
|
-
onDateSelected: () => void 0,
|
|
128
|
-
firstDayOfWeek,
|
|
129
|
-
showOutsideDays: true,
|
|
130
|
-
date: dateInView,
|
|
131
|
-
onOffsetChanged: (offset) => setDateInView(new Date(dateInView.getFullYear(), dateInView.getMonth() + offset)),
|
|
132
|
-
offset: 0
|
|
100
|
+
if (value2 instanceof Object && "__set" in value2) {
|
|
101
|
+
return new Set(value2.__set);
|
|
102
|
+
}
|
|
103
|
+
if (value2 instanceof Object && "__map" in value2) {
|
|
104
|
+
return new Map(value2.__map);
|
|
105
|
+
}
|
|
106
|
+
return value2;
|
|
133
107
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
})), jsxRuntime.jsxs("div", {
|
|
166
|
-
css: {
|
|
167
|
-
display: "flex"
|
|
168
|
-
},
|
|
169
|
-
children: [jsxRuntime.jsx(MonthSelector, {
|
|
170
|
-
value: month,
|
|
171
|
-
onChange: (month2) => setDateInView(new Date(year, month2)),
|
|
172
|
-
locale
|
|
173
|
-
}), jsxRuntime.jsx(YearSelector, {
|
|
174
|
-
value: year,
|
|
175
|
-
onChange: (year2) => setDateInView(new Date(year2, month))
|
|
176
|
-
})]
|
|
177
|
-
}), jsxRuntime.jsx(IconButton, __spreadProps(__spreadValues({}, getForwardProps({
|
|
178
|
-
calendars
|
|
179
|
-
})), {
|
|
180
|
-
children: jsxRuntime.jsx(ChevronRight, {})
|
|
181
|
-
}))]
|
|
182
|
-
}), jsxRuntime.jsxs("div", {
|
|
183
|
-
css: {
|
|
184
|
-
display: "grid",
|
|
185
|
-
gridTemplateColumns: "repeat(7, max-content)",
|
|
186
|
-
fontWeight: "bold"
|
|
187
|
-
},
|
|
188
|
-
children: [weekDays.map((_v, weekDay) => jsxRuntime.jsx("div", {
|
|
189
|
-
css: {
|
|
190
|
-
justifySelf: "center",
|
|
191
|
-
marginBottom: "var(--spacing)"
|
|
192
|
-
},
|
|
193
|
-
children: formatWeekday(weekDay)
|
|
194
|
-
}, weekDay)), weeks.map((week, index) => week.map((dateObj, dayIndex) => {
|
|
195
|
-
if (!dateObj) {
|
|
196
|
-
return jsxRuntime.jsx("div", {});
|
|
197
|
-
}
|
|
198
|
-
const {
|
|
199
|
-
prevMonth,
|
|
200
|
-
nextMonth,
|
|
201
|
-
date,
|
|
202
|
-
today: today2
|
|
203
|
-
} = dateObj;
|
|
204
|
-
const selected = date.getTime() === (min == null ? void 0 : min.getTime()) || min && max && dateIntersect(date, {
|
|
205
|
-
min,
|
|
206
|
-
max
|
|
207
|
-
});
|
|
208
|
-
const preSelected = !selected && (date.getTime() === (hovered == null ? void 0 : hovered.getTime()) || min && !max && hovered && dateIntersect(date, min <= hovered ? {
|
|
209
|
-
min,
|
|
210
|
-
max: hovered
|
|
211
|
-
} : {
|
|
212
|
-
min: hovered,
|
|
213
|
-
max: min
|
|
214
|
-
}));
|
|
215
|
-
return jsxRuntime.jsx("button", __spreadProps(__spreadValues({
|
|
216
|
-
css: [{
|
|
217
|
-
padding: 10,
|
|
218
|
-
border: "1px solid transparent",
|
|
219
|
-
background: "transparent",
|
|
220
|
-
cursor: "pointer"
|
|
221
|
-
}, (prevMonth || nextMonth) && {
|
|
222
|
-
color: tableTheme.gray
|
|
223
|
-
}, today2 && {
|
|
224
|
-
border: "1px solid var(--secondaryMain)"
|
|
225
|
-
}, selected && {
|
|
226
|
-
background: "var(--primaryMain)",
|
|
227
|
-
color: "var(--primaryContrastText)"
|
|
228
|
-
}, preSelected && {
|
|
229
|
-
background: "var(--primaryLight)",
|
|
230
|
-
color: "var(--primaryContrastText)"
|
|
231
|
-
}]
|
|
232
|
-
}, getDateProps({
|
|
233
|
-
dateObj
|
|
234
|
-
})), {
|
|
235
|
-
onClick: () => {
|
|
236
|
-
if (!rangeSelect) {
|
|
237
|
-
setCurrentMin(void 0);
|
|
238
|
-
onChange(date);
|
|
239
|
-
} else if (min && !max) {
|
|
240
|
-
setCurrentMin(void 0);
|
|
241
|
-
if (date > min) {
|
|
242
|
-
onChange({
|
|
243
|
-
min,
|
|
244
|
-
max: date
|
|
245
|
-
});
|
|
246
|
-
} else {
|
|
247
|
-
onChange({
|
|
248
|
-
min: date,
|
|
249
|
-
max: min
|
|
250
|
-
});
|
|
108
|
+
}
|
|
109
|
+
function useTableStateStorage() {
|
|
110
|
+
const table = useTableContext();
|
|
111
|
+
const [isHydrated, setIsHydrated] = react.useState(false);
|
|
112
|
+
react.useEffect(() => {
|
|
113
|
+
const { persist } = table.getState().props;
|
|
114
|
+
if (!persist) {
|
|
115
|
+
setIsHydrated(true);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let isCanceled = false;
|
|
119
|
+
(async () => {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
try {
|
|
122
|
+
const { storage, id, include, exclude } = persist;
|
|
123
|
+
const json = await storage.getItem(storageName(id));
|
|
124
|
+
if (isCanceled || !json)
|
|
125
|
+
return;
|
|
126
|
+
const data = parse(json);
|
|
127
|
+
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "load", json, data);
|
|
128
|
+
table.update((state) => {
|
|
129
|
+
var _a2, _b2, _c, _d;
|
|
130
|
+
for (const key of KEYS) {
|
|
131
|
+
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key)) && key in data) {
|
|
132
|
+
if (key === "filterValues") {
|
|
133
|
+
for (const [id2, value] of data[key]) {
|
|
134
|
+
if ((_b2 = (_a2 = state.filters.get(id2)) == null ? void 0 : _a2.persist) != null ? _b2 : true) {
|
|
135
|
+
state.filterValues.set(id2, value);
|
|
136
|
+
}
|
|
251
137
|
}
|
|
252
138
|
} else {
|
|
253
|
-
|
|
139
|
+
state[key] = data[key];
|
|
140
|
+
if (key === "expanded" || key === "hiddenColumns" || key === "selection" || key === "sort") {
|
|
141
|
+
(_d = (_c = state.props)[`on${key.slice(0, 1).toUpperCase() + key.slice(1)}Change`]) == null ? void 0 : _d.call(_c, data[key]);
|
|
142
|
+
}
|
|
254
143
|
}
|
|
255
|
-
},
|
|
256
|
-
onPointerOver: () => setHovered(date),
|
|
257
|
-
onPointerOut: () => setHovered(void 0),
|
|
258
|
-
children: date.getDate()
|
|
259
|
-
}), `${index}-${dayIndex}`);
|
|
260
|
-
}))]
|
|
261
|
-
})]
|
|
262
|
-
}, `${month}${year}`))
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
function MonthSelector({
|
|
266
|
-
value,
|
|
267
|
-
onChange,
|
|
268
|
-
locale
|
|
269
|
-
}) {
|
|
270
|
-
const {
|
|
271
|
-
components: {
|
|
272
|
-
Popover
|
|
273
|
-
}
|
|
274
|
-
} = useTheme();
|
|
275
|
-
const cssVariables = useCssVariables();
|
|
276
|
-
const [anchor, setAnchor] = react.useState();
|
|
277
|
-
const formatMonth = react.useMemo(() => {
|
|
278
|
-
const {
|
|
279
|
-
format
|
|
280
|
-
} = new Intl.DateTimeFormat(locale, {
|
|
281
|
-
month: "long"
|
|
282
|
-
});
|
|
283
|
-
return (month) => format(new Date(2021, month));
|
|
284
|
-
}, [locale]);
|
|
285
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
286
|
-
children: [jsxRuntime.jsx("button", {
|
|
287
|
-
css: {
|
|
288
|
-
border: "none",
|
|
289
|
-
background: "transparent",
|
|
290
|
-
fontSize: "inherit",
|
|
291
|
-
cursor: "pointer"
|
|
292
|
-
},
|
|
293
|
-
onClick: (e) => setAnchor(e.currentTarget),
|
|
294
|
-
children: formatMonth(value)
|
|
295
|
-
}), jsxRuntime.jsx(Popover, {
|
|
296
|
-
open: !!anchor,
|
|
297
|
-
anchorEl: anchor != null ? anchor : null,
|
|
298
|
-
onClose: () => setAnchor(void 0),
|
|
299
|
-
align: "center",
|
|
300
|
-
css: cssVariables,
|
|
301
|
-
children: jsxRuntime.jsx("div", {
|
|
302
|
-
css: {
|
|
303
|
-
display: "grid"
|
|
304
|
-
},
|
|
305
|
-
children: months.map((month) => jsxRuntime.jsx("button", {
|
|
306
|
-
css: [{
|
|
307
|
-
padding: "var(--spacing)",
|
|
308
|
-
border: "none",
|
|
309
|
-
background: "transparent",
|
|
310
|
-
"&:hover": {
|
|
311
|
-
background: "var(--primaryLight)"
|
|
312
144
|
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
})
|
|
320
|
-
})]
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
function YearSelector({
|
|
324
|
-
value,
|
|
325
|
-
onChange,
|
|
326
|
-
locale
|
|
327
|
-
}) {
|
|
328
|
-
const [input, setInput] = react.useState();
|
|
329
|
-
const ref = react.useRef(null);
|
|
330
|
-
function apply() {
|
|
331
|
-
onChange(Number(input));
|
|
332
|
-
setInput(void 0);
|
|
333
|
-
}
|
|
334
|
-
const formatYear = react.useMemo(() => {
|
|
335
|
-
const {
|
|
336
|
-
format
|
|
337
|
-
} = new Intl.DateTimeFormat(locale, {
|
|
338
|
-
year: "numeric"
|
|
339
|
-
});
|
|
340
|
-
return (year) => format(new Date(year, 0, 1));
|
|
341
|
-
}, [locale]);
|
|
342
|
-
react.useLayoutEffect(() => {
|
|
343
|
-
var _a;
|
|
344
|
-
return (_a = ref.current) == null ? void 0 : _a.focus();
|
|
345
|
-
}, [ref.current]);
|
|
346
|
-
if (input === void 0) {
|
|
347
|
-
return jsxRuntime.jsx("div", {
|
|
348
|
-
onClick: () => setInput(String(value)),
|
|
349
|
-
children: formatYear(value)
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
return jsxRuntime.jsx("input", {
|
|
353
|
-
ref,
|
|
354
|
-
css: {
|
|
355
|
-
width: "4ch"
|
|
356
|
-
},
|
|
357
|
-
value: input,
|
|
358
|
-
onChange: (e) => {
|
|
359
|
-
if (e.target.value.match(/^\d{0,4}$/)) {
|
|
360
|
-
setInput(e.target.value);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.error("Failed to load table state:", e);
|
|
149
|
+
} finally {
|
|
150
|
+
setIsHydrated(true);
|
|
361
151
|
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
function convertDate(x) {
|
|
368
|
-
if (x instanceof Date)
|
|
369
|
-
return x;
|
|
370
|
-
if (typeof x === "number" || typeof x === "string")
|
|
371
|
-
return new Date(x);
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
function convertDateOrRange(x) {
|
|
375
|
-
if (x instanceof Object && "min" in x && "max" in x) {
|
|
376
|
-
const range = {
|
|
377
|
-
min: convertDate(x.min),
|
|
378
|
-
max: convertDate(x.max)
|
|
152
|
+
})();
|
|
153
|
+
return () => {
|
|
154
|
+
isCanceled = true;
|
|
379
155
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
},
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
}));
|
|
420
|
-
const formatDate = react.useMemo(() => {
|
|
421
|
-
const {
|
|
422
|
-
format
|
|
423
|
-
} = new Intl.DateTimeFormat(locale, {
|
|
424
|
-
dateStyle: "medium"
|
|
425
|
-
});
|
|
426
|
-
return format;
|
|
427
|
-
}, [locale]);
|
|
428
|
-
return jsxRuntime.jsxs("div", {
|
|
429
|
-
css: {
|
|
430
|
-
padding: "calc(var(--spacing) * 2)",
|
|
431
|
-
display: "grid"
|
|
432
|
-
},
|
|
433
|
-
children: [!singleSelect && jsxRuntime.jsxs("div", {
|
|
434
|
-
css: {
|
|
435
|
-
marginBottom: "var(--spacing)",
|
|
436
|
-
display: "flex",
|
|
437
|
-
justifyContent: "center"
|
|
438
|
-
},
|
|
439
|
-
children: [value ? formatDate(value instanceof Date ? value : value.min) : "", " -", " ", value ? formatDate(value instanceof Date ? value : value.max) : ""]
|
|
440
|
-
}), jsxRuntime.jsx(DatePicker, {
|
|
441
|
-
rangeSelect: !singleSelect,
|
|
442
|
-
value,
|
|
443
|
-
onChange,
|
|
444
|
-
locale,
|
|
445
|
-
firstDayOfWeek
|
|
446
|
-
}), jsxRuntime.jsxs("div", {
|
|
447
|
-
css: {
|
|
448
|
-
marginTop: "var(--spacing)",
|
|
449
|
-
display: "grid",
|
|
450
|
-
gridAutoFlow: "column",
|
|
451
|
-
justifyContent: "center"
|
|
452
|
-
},
|
|
453
|
-
children: [jsxRuntime.jsx(Button, {
|
|
454
|
-
variant: "text",
|
|
455
|
-
onClick: () => onChange(today()),
|
|
456
|
-
children: text.today
|
|
457
|
-
}), jsxRuntime.jsx(Button, {
|
|
458
|
-
variant: "text",
|
|
459
|
-
onClick: () => onChange(thisWeek(firstDayOfWeek)),
|
|
460
|
-
children: text.thisWeek
|
|
461
|
-
}), jsxRuntime.jsx(Button, {
|
|
462
|
-
variant: "text",
|
|
463
|
-
onClick: () => onChange(null),
|
|
464
|
-
children: text.reset
|
|
465
|
-
})]
|
|
466
|
-
})]
|
|
467
|
-
});
|
|
156
|
+
}, []);
|
|
157
|
+
react.useEffect(() => {
|
|
158
|
+
if (!isHydrated)
|
|
159
|
+
return;
|
|
160
|
+
const q = new Queue();
|
|
161
|
+
return table.subscribe((state) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
if (!state.props.persist)
|
|
164
|
+
return;
|
|
165
|
+
const { storage, id, include, exclude } = state.props.persist;
|
|
166
|
+
const data = {};
|
|
167
|
+
for (const key of KEYS) {
|
|
168
|
+
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key))) {
|
|
169
|
+
if (key === "filterValues") {
|
|
170
|
+
data[key] = /* @__PURE__ */ new Map();
|
|
171
|
+
for (const [id2, value] of state.filterValues) {
|
|
172
|
+
if ((_b = (_a = state.filters.get(id2)) == null ? void 0 : _a.persist) != null ? _b : true) {
|
|
173
|
+
data.filterValues.set(id2, value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
data[key] = state[key];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { storage, id, data };
|
|
182
|
+
}, (props) => {
|
|
183
|
+
var _a, _b;
|
|
184
|
+
if (!props)
|
|
185
|
+
return;
|
|
186
|
+
const { storage, id, data } = props;
|
|
187
|
+
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "save", data, stringify(data));
|
|
188
|
+
q.run(async () => {
|
|
189
|
+
await storage.setItem(storageName(id), stringify(data));
|
|
190
|
+
}, true);
|
|
191
|
+
}, { throttle: 1e3 });
|
|
192
|
+
}, [isHydrated]);
|
|
193
|
+
return isHydrated;
|
|
468
194
|
}
|
|
469
|
-
const today = () => {
|
|
470
|
-
const today2 = startOfDay(new Date());
|
|
471
|
-
return {
|
|
472
|
-
min: today2,
|
|
473
|
-
max: today2
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
|
-
const thisWeek = (firstDayOfWeek = 0) => {
|
|
477
|
-
const now = new Date();
|
|
478
|
-
const min = new Date(now);
|
|
479
|
-
let diff = min.getDay() - firstDayOfWeek;
|
|
480
|
-
if (diff < 0) {
|
|
481
|
-
diff += 7;
|
|
482
|
-
}
|
|
483
|
-
min.setDate(min.getDate() - diff);
|
|
484
|
-
const max = new Date(min);
|
|
485
|
-
max.setDate(max.getDate() + 6);
|
|
486
|
-
return {
|
|
487
|
-
min: startOfDay(min),
|
|
488
|
-
max: endOfDay(max)
|
|
489
|
-
};
|
|
490
|
-
};
|
|
491
195
|
const flatMap = (arr, flatMap2) => {
|
|
492
196
|
return [...arr].reduce((out, cur) => out.concat(flatMap2(cur)), []);
|
|
493
197
|
};
|
|
@@ -564,184 +268,8 @@ const cx = (...classNames) => classNames.flatMap((entry) => {
|
|
|
564
268
|
return [];
|
|
565
269
|
if (typeof entry === "string")
|
|
566
270
|
return [entry];
|
|
567
|
-
return Object.entries(entry).filter(([, predicate]) => predicate).map(([
|
|
271
|
+
return Object.entries(entry).filter(([, predicate]) => predicate).map(([className2]) => className2);
|
|
568
272
|
}).join(" ");
|
|
569
|
-
function FormControlLabel({
|
|
570
|
-
control,
|
|
571
|
-
label,
|
|
572
|
-
disabled
|
|
573
|
-
}) {
|
|
574
|
-
return jsxRuntime.jsxs("label", {
|
|
575
|
-
css: [{
|
|
576
|
-
display: "flex",
|
|
577
|
-
alignItems: "center",
|
|
578
|
-
cursor: "pointer",
|
|
579
|
-
userSelect: "none",
|
|
580
|
-
"& > *": {
|
|
581
|
-
cursor: "pointer"
|
|
582
|
-
}
|
|
583
|
-
}, disabled && {
|
|
584
|
-
color: "rgba(0, 0, 0, 0.26)"
|
|
585
|
-
}],
|
|
586
|
-
children: [control, jsxRuntime.jsx("span", {
|
|
587
|
-
css: {
|
|
588
|
-
marginLeft: "var(--spacing)"
|
|
589
|
-
},
|
|
590
|
-
children: label
|
|
591
|
-
})]
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
class Queue {
|
|
595
|
-
constructor() {
|
|
596
|
-
this.q = new Array();
|
|
597
|
-
this.isRunning = false;
|
|
598
|
-
}
|
|
599
|
-
run(job, replace) {
|
|
600
|
-
return new Promise((resolve, reject) => {
|
|
601
|
-
if (replace) {
|
|
602
|
-
this.q = [];
|
|
603
|
-
}
|
|
604
|
-
this.q.push({ job, resolve, reject });
|
|
605
|
-
if (!this.isRunning)
|
|
606
|
-
this.start();
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
async start() {
|
|
610
|
-
this.isRunning = true;
|
|
611
|
-
let next;
|
|
612
|
-
while (next = this.q.shift()) {
|
|
613
|
-
try {
|
|
614
|
-
const result = await next.job();
|
|
615
|
-
next.resolve(result);
|
|
616
|
-
} catch (e) {
|
|
617
|
-
next.reject(e);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
this.isRunning = false;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
const KEYS = ["sort", "selection", "expanded", "hiddenColumns", "filterValues", "columnWidths", "columnOrder"];
|
|
624
|
-
function stringify(value) {
|
|
625
|
-
function prepare(value2) {
|
|
626
|
-
if (value2 instanceof Date) {
|
|
627
|
-
return { __date: value2.toJSON() };
|
|
628
|
-
}
|
|
629
|
-
if (value2 instanceof Set) {
|
|
630
|
-
return { __set: Array.from(value2).map(prepare) };
|
|
631
|
-
}
|
|
632
|
-
if (value2 instanceof Map) {
|
|
633
|
-
return { __map: Array.from(value2.entries()).map((entry) => entry.map(prepare)) };
|
|
634
|
-
}
|
|
635
|
-
if (value2 instanceof Array) {
|
|
636
|
-
return value2.map(prepare);
|
|
637
|
-
}
|
|
638
|
-
if (value2 instanceof Object) {
|
|
639
|
-
return Object.fromEntries(Object.entries(value2).map(([k, v]) => [k, prepare(v)]));
|
|
640
|
-
}
|
|
641
|
-
return value2;
|
|
642
|
-
}
|
|
643
|
-
return JSON.stringify(prepare(value));
|
|
644
|
-
}
|
|
645
|
-
function parse(value) {
|
|
646
|
-
return JSON.parse(value, (_key, value2) => {
|
|
647
|
-
if (value2 instanceof Object && "__date" in value2) {
|
|
648
|
-
return new Date(value2.__date);
|
|
649
|
-
}
|
|
650
|
-
if (value2 instanceof Object && "__set" in value2) {
|
|
651
|
-
return new Set(value2.__set);
|
|
652
|
-
}
|
|
653
|
-
if (value2 instanceof Object && "__map" in value2) {
|
|
654
|
-
return new Map(value2.__map);
|
|
655
|
-
}
|
|
656
|
-
return value2;
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
function useTableStateStorage() {
|
|
660
|
-
const table = useTableContext();
|
|
661
|
-
const [isHydrated, setIsHydrated] = react.useState(false);
|
|
662
|
-
react.useEffect(() => {
|
|
663
|
-
const { persist } = table.getState().props;
|
|
664
|
-
if (!persist) {
|
|
665
|
-
setIsHydrated(true);
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
let isCanceled = false;
|
|
669
|
-
(async () => {
|
|
670
|
-
var _a, _b;
|
|
671
|
-
try {
|
|
672
|
-
const { storage, id = "table", include, exclude } = persist;
|
|
673
|
-
const json = await storage.getItem(`${id}_state`);
|
|
674
|
-
if (isCanceled || !json)
|
|
675
|
-
return;
|
|
676
|
-
const data = parse(json);
|
|
677
|
-
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "load", json, data);
|
|
678
|
-
table.update((state) => {
|
|
679
|
-
var _a2, _b2, _c, _d;
|
|
680
|
-
for (const key of KEYS) {
|
|
681
|
-
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key)) && key in data) {
|
|
682
|
-
if (key === "filterValues") {
|
|
683
|
-
for (const [id2, value] of data[key]) {
|
|
684
|
-
if ((_b2 = (_a2 = state.filters.get(id2)) == null ? void 0 : _a2.persist) != null ? _b2 : true) {
|
|
685
|
-
state.filterValues.set(id2, value);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
} else {
|
|
689
|
-
state[key] = data[key];
|
|
690
|
-
if (key === "expanded" || key === "hiddenColumns" || key === "selection" || key === "sort") {
|
|
691
|
-
(_d = (_c = state.props)[`on${key.slice(0, 1).toUpperCase() + key.slice(1)}Change`]) == null ? void 0 : _d.call(_c, data[key]);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
} catch (e) {
|
|
698
|
-
console.error("Failed to load table state:", e);
|
|
699
|
-
} finally {
|
|
700
|
-
setIsHydrated(true);
|
|
701
|
-
}
|
|
702
|
-
})();
|
|
703
|
-
return () => {
|
|
704
|
-
isCanceled = true;
|
|
705
|
-
};
|
|
706
|
-
}, []);
|
|
707
|
-
react.useEffect(() => {
|
|
708
|
-
if (!isHydrated)
|
|
709
|
-
return;
|
|
710
|
-
const q = new Queue();
|
|
711
|
-
return table.subscribe((state) => {
|
|
712
|
-
var _a, _b;
|
|
713
|
-
if (!state.props.persist)
|
|
714
|
-
return;
|
|
715
|
-
const { storage, id = "table", include, exclude } = state.props.persist;
|
|
716
|
-
const data = {};
|
|
717
|
-
for (const key of KEYS) {
|
|
718
|
-
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key))) {
|
|
719
|
-
if (key === "filterValues") {
|
|
720
|
-
data[key] = /* @__PURE__ */ new Map();
|
|
721
|
-
for (const [id2, value] of state.filterValues) {
|
|
722
|
-
if ((_b = (_a = state.filters.get(id2)) == null ? void 0 : _a.persist) != null ? _b : true) {
|
|
723
|
-
data.filterValues.set(id2, value);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
} else {
|
|
727
|
-
data[key] = state[key];
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
return { storage, id, data };
|
|
732
|
-
}, (props) => {
|
|
733
|
-
var _a, _b;
|
|
734
|
-
if (!props)
|
|
735
|
-
return;
|
|
736
|
-
const { storage, id, data } = props;
|
|
737
|
-
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "save", data, stringify(data));
|
|
738
|
-
q.run(async () => {
|
|
739
|
-
await storage.setItem(`${id}_state`, stringify(data));
|
|
740
|
-
}, true);
|
|
741
|
-
}, { throttle: 1e3 });
|
|
742
|
-
}, [isHydrated]);
|
|
743
|
-
return isHydrated;
|
|
744
|
-
}
|
|
745
273
|
function calcItems(state) {
|
|
746
274
|
react.useEffect(() => state.addReaction((state2) => [
|
|
747
275
|
state2.props.items,
|
|
@@ -1004,12 +532,10 @@ function syncSelections(table) {
|
|
|
1004
532
|
}
|
|
1005
533
|
function useTableState(_props) {
|
|
1006
534
|
const props = calcProps(_props);
|
|
1007
|
-
const theme = tableTheme.useTableTheme(props);
|
|
1008
535
|
const state = react.useMemo(() => {
|
|
1009
536
|
var _a, _b, _c, _d;
|
|
1010
537
|
return new react$1.Store({
|
|
1011
538
|
props,
|
|
1012
|
-
theme,
|
|
1013
539
|
sort: (_a = props.defaultSort) != null ? _a : [],
|
|
1014
540
|
selection: (_b = props.defaultSelection) != null ? _b : /* @__PURE__ */ new Set(),
|
|
1015
541
|
expanded: (_c = props.defaultExpanded) != null ? _c : /* @__PURE__ */ new Set(),
|
|
@@ -1049,11 +575,22 @@ function useTableState(_props) {
|
|
|
1049
575
|
state2.columnOrder.splice(index, 0, column.id);
|
|
1050
576
|
}
|
|
1051
577
|
}
|
|
1052
|
-
state2.theme = theme;
|
|
1053
578
|
});
|
|
1054
579
|
}, [state, props]);
|
|
1055
580
|
return state;
|
|
1056
581
|
}
|
|
582
|
+
function useCssVariables() {
|
|
583
|
+
const theme = useTheme();
|
|
584
|
+
return {
|
|
585
|
+
"--spacing": theme.spacing,
|
|
586
|
+
"--primaryMain": theme.colors.primary.main,
|
|
587
|
+
"--primaryLight": theme.colors.primary.light,
|
|
588
|
+
"--primaryContrastText": theme.colors.primary.contrastText,
|
|
589
|
+
"--secondaryMain": theme.colors.secondary.main,
|
|
590
|
+
"--secondaryLight": theme.colors.secondary.light,
|
|
591
|
+
"--secondaryContrastText": theme.colors.secondary.contrastText
|
|
592
|
+
};
|
|
593
|
+
}
|
|
1057
594
|
const ColumnHeaderContext = new react$1.StoreScope({
|
|
1058
595
|
items: /* @__PURE__ */ new Map()
|
|
1059
596
|
});
|
|
@@ -1192,15 +729,40 @@ function ColumnHeader(props) {
|
|
|
1192
729
|
children: props.children
|
|
1193
730
|
}));
|
|
1194
731
|
}
|
|
732
|
+
function FormControlLabel({
|
|
733
|
+
control,
|
|
734
|
+
label,
|
|
735
|
+
disabled
|
|
736
|
+
}) {
|
|
737
|
+
return jsxRuntime.jsxs("label", {
|
|
738
|
+
css: [{
|
|
739
|
+
display: "flex",
|
|
740
|
+
alignItems: "center",
|
|
741
|
+
cursor: "pointer",
|
|
742
|
+
userSelect: "none",
|
|
743
|
+
"& > *": {
|
|
744
|
+
cursor: "pointer"
|
|
745
|
+
}
|
|
746
|
+
}, disabled && {
|
|
747
|
+
color: "rgba(0, 0, 0, 0.26)"
|
|
748
|
+
}],
|
|
749
|
+
children: [control, jsxRuntime.jsx("span", {
|
|
750
|
+
css: {
|
|
751
|
+
marginLeft: "var(--spacing)"
|
|
752
|
+
},
|
|
753
|
+
children: label
|
|
754
|
+
})]
|
|
755
|
+
});
|
|
756
|
+
}
|
|
1195
757
|
function ColumnSelection() {
|
|
1196
758
|
const {
|
|
1197
759
|
components: {
|
|
1198
|
-
IconButton,
|
|
760
|
+
IconButton: IconButton2,
|
|
1199
761
|
Popover,
|
|
1200
|
-
Checkbox
|
|
762
|
+
Checkbox: Checkbox2
|
|
1201
763
|
},
|
|
1202
764
|
icons: {
|
|
1203
|
-
Settings
|
|
765
|
+
Settings: Settings2
|
|
1204
766
|
},
|
|
1205
767
|
text
|
|
1206
768
|
} = useTheme();
|
|
@@ -1229,9 +791,9 @@ function ColumnSelection() {
|
|
|
1229
791
|
onHiddenColumnsChange == null ? void 0 : onHiddenColumnsChange(newValue);
|
|
1230
792
|
};
|
|
1231
793
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1232
|
-
children: [jsxRuntime.jsx(
|
|
794
|
+
children: [jsxRuntime.jsx(IconButton2, {
|
|
1233
795
|
onClick: (e) => setAnchorEl(anchorEl ? null : e.currentTarget),
|
|
1234
|
-
children: jsxRuntime.jsx(
|
|
796
|
+
children: jsxRuntime.jsx(Settings2, {})
|
|
1235
797
|
}), jsxRuntime.jsx(Popover, {
|
|
1236
798
|
anchorEl,
|
|
1237
799
|
open: !!anchorEl,
|
|
@@ -1248,7 +810,7 @@ function ColumnSelection() {
|
|
|
1248
810
|
},
|
|
1249
811
|
children: text.selectColumns
|
|
1250
812
|
}), columns.map((column) => jsxRuntime.jsx(FormControlLabel, {
|
|
1251
|
-
control: jsxRuntime.jsx(
|
|
813
|
+
control: jsxRuntime.jsx(Checkbox2, {
|
|
1252
814
|
checked: !hiddenColumns.has(column.id),
|
|
1253
815
|
onChange: () => toggle2(column),
|
|
1254
816
|
disabled: column.cannotHide
|
|
@@ -1271,17 +833,17 @@ function csvExport(data, { sepPrefix, separator = ",", quote = '"', eol = "\n" }
|
|
|
1271
833
|
return (sepPrefix ? `SEP=${separator}
|
|
1272
834
|
` : "") + cells.map((line) => line.join(separator)).join(eol);
|
|
1273
835
|
}
|
|
1274
|
-
function Export() {
|
|
836
|
+
function Export$1() {
|
|
1275
837
|
const table = useTableContext();
|
|
1276
838
|
const {
|
|
1277
839
|
components: {
|
|
1278
|
-
Button,
|
|
1279
|
-
IconButton,
|
|
840
|
+
Button: Button2,
|
|
841
|
+
IconButton: IconButton2,
|
|
1280
842
|
Popover
|
|
1281
843
|
},
|
|
1282
844
|
icons: {
|
|
1283
845
|
Export: Export2,
|
|
1284
|
-
Clipboard
|
|
846
|
+
Clipboard: Clipboard2
|
|
1285
847
|
},
|
|
1286
848
|
text
|
|
1287
849
|
} = useTheme();
|
|
@@ -1307,7 +869,7 @@ function Export() {
|
|
|
1307
869
|
document.body.removeChild(a);
|
|
1308
870
|
};
|
|
1309
871
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1310
|
-
children: [jsxRuntime.jsx(
|
|
872
|
+
children: [jsxRuntime.jsx(IconButton2, {
|
|
1311
873
|
onClick: (e) => setAnchor(anchor ? null : e.currentTarget),
|
|
1312
874
|
children: jsxRuntime.jsx(Export2, {
|
|
1313
875
|
css: !!anchor && {
|
|
@@ -1334,11 +896,11 @@ function Export() {
|
|
|
1334
896
|
marginBottom: "var(--spacing)"
|
|
1335
897
|
},
|
|
1336
898
|
children: text.exportTitle
|
|
1337
|
-
}), jsxRuntime.jsx(
|
|
1338
|
-
startIcon: jsxRuntime.jsx(
|
|
899
|
+
}), jsxRuntime.jsx(Button2, {
|
|
900
|
+
startIcon: jsxRuntime.jsx(Clipboard2, {}),
|
|
1339
901
|
onClick: copy,
|
|
1340
902
|
children: text.exportCopy
|
|
1341
|
-
}), jsxRuntime.jsx(
|
|
903
|
+
}), jsxRuntime.jsx(Button2, {
|
|
1342
904
|
startIcon: jsxRuntime.jsx(Export2, {}),
|
|
1343
905
|
onClick: download,
|
|
1344
906
|
children: text.exportDownload
|
|
@@ -1353,12 +915,12 @@ function FilterControl() {
|
|
|
1353
915
|
const columnId = useColumnContext();
|
|
1354
916
|
const {
|
|
1355
917
|
components: {
|
|
1356
|
-
IconButton,
|
|
918
|
+
IconButton: IconButton2,
|
|
1357
919
|
Popover
|
|
1358
920
|
},
|
|
1359
921
|
icons: {
|
|
1360
|
-
FilterList,
|
|
1361
|
-
ArrowDropDown
|
|
922
|
+
FilterList: FilterList2,
|
|
923
|
+
ArrowDropDown: ArrowDropDown2
|
|
1362
924
|
}
|
|
1363
925
|
} = useTheme();
|
|
1364
926
|
const cssVariables = useCssVariables();
|
|
@@ -1391,13 +953,13 @@ function FilterControl() {
|
|
|
1391
953
|
e.preventDefault();
|
|
1392
954
|
return false;
|
|
1393
955
|
},
|
|
1394
|
-
children: jsxRuntime.jsx(
|
|
956
|
+
children: jsxRuntime.jsx(IconButton2, {
|
|
1395
957
|
css: [{
|
|
1396
958
|
color: "#b0bac9"
|
|
1397
959
|
}, isActive && {
|
|
1398
960
|
color: "var(--primaryMain) !important"
|
|
1399
961
|
}],
|
|
1400
|
-
children: isActive ? jsxRuntime.jsx(
|
|
962
|
+
children: isActive ? jsxRuntime.jsx(FilterList2, {}) : jsxRuntime.jsx(ArrowDropDown2, {})
|
|
1401
963
|
})
|
|
1402
964
|
}), jsxRuntime.jsx("div", {
|
|
1403
965
|
onPointerDown: (e) => {
|
|
@@ -1459,10 +1021,10 @@ function ResizeHandle() {
|
|
|
1459
1021
|
onDoubleClick: enabled ? onDoubleClick : void 0
|
|
1460
1022
|
});
|
|
1461
1023
|
}
|
|
1462
|
-
function ResizeHandleView(
|
|
1463
|
-
var
|
|
1024
|
+
function ResizeHandleView(_a) {
|
|
1025
|
+
var _b = _a, {
|
|
1464
1026
|
enabled
|
|
1465
|
-
} =
|
|
1027
|
+
} = _b, props = __objRest(_b, [
|
|
1466
1028
|
"enabled"
|
|
1467
1029
|
]);
|
|
1468
1030
|
return jsxRuntime.jsx("div", __spreadValues({
|
|
@@ -1518,11 +1080,11 @@ function ExpandControl({
|
|
|
1518
1080
|
}) {
|
|
1519
1081
|
const {
|
|
1520
1082
|
components: {
|
|
1521
|
-
IconButton,
|
|
1522
|
-
Spinner
|
|
1083
|
+
IconButton: IconButton2,
|
|
1084
|
+
Spinner: Spinner2
|
|
1523
1085
|
},
|
|
1524
1086
|
icons: {
|
|
1525
|
-
ChevronRight
|
|
1087
|
+
ChevronRight: ChevronRight2
|
|
1526
1088
|
}
|
|
1527
1089
|
} = useTheme();
|
|
1528
1090
|
const table = useTableContext();
|
|
@@ -1561,13 +1123,13 @@ function ExpandControl({
|
|
|
1561
1123
|
}
|
|
1562
1124
|
}
|
|
1563
1125
|
if (isExpanded && hasDeferredChildren && !hasChildren) {
|
|
1564
|
-
return jsxRuntime.jsx(
|
|
1126
|
+
return jsxRuntime.jsx(Spinner2, {
|
|
1565
1127
|
css: {
|
|
1566
1128
|
margin: "0 var(--spacing)"
|
|
1567
1129
|
}
|
|
1568
1130
|
});
|
|
1569
1131
|
}
|
|
1570
|
-
return jsxRuntime.jsx(
|
|
1132
|
+
return jsxRuntime.jsx(IconButton2, {
|
|
1571
1133
|
onClick: toggle2,
|
|
1572
1134
|
children: jsxRuntime.jsx("span", {
|
|
1573
1135
|
css: {
|
|
@@ -1575,7 +1137,7 @@ function ExpandControl({
|
|
|
1575
1137
|
transition: "all 300ms",
|
|
1576
1138
|
transform: isExpanded ? "rotate3d(0, 0, 1, 90deg)" : "rotate3d(0, 0, 1, 0deg)"
|
|
1577
1139
|
},
|
|
1578
|
-
children: jsxRuntime.jsx(
|
|
1140
|
+
children: jsxRuntime.jsx(ChevronRight2, {})
|
|
1579
1141
|
})
|
|
1580
1142
|
});
|
|
1581
1143
|
}
|
|
@@ -1585,7 +1147,7 @@ function SelectComponent({
|
|
|
1585
1147
|
const table = useTableContext();
|
|
1586
1148
|
const {
|
|
1587
1149
|
components: {
|
|
1588
|
-
Checkbox
|
|
1150
|
+
Checkbox: Checkbox2
|
|
1589
1151
|
}
|
|
1590
1152
|
} = useTheme();
|
|
1591
1153
|
const isSelected = table.useState((state) => {
|
|
@@ -1639,7 +1201,7 @@ function SelectComponent({
|
|
|
1639
1201
|
state.lastSelectedId = itemId;
|
|
1640
1202
|
});
|
|
1641
1203
|
}
|
|
1642
|
-
return jsxRuntime.jsx(
|
|
1204
|
+
return jsxRuntime.jsx(Checkbox2, {
|
|
1643
1205
|
css: {
|
|
1644
1206
|
justifySelf: "start",
|
|
1645
1207
|
color: "#c9cfda"
|
|
@@ -1659,7 +1221,7 @@ const Row = react.memo(function Row2({
|
|
|
1659
1221
|
const table = useTableContext();
|
|
1660
1222
|
const divRef = react.useRef(null);
|
|
1661
1223
|
const {
|
|
1662
|
-
className,
|
|
1224
|
+
className: className2,
|
|
1663
1225
|
indent,
|
|
1664
1226
|
hasChildren,
|
|
1665
1227
|
hasDeferredChildren,
|
|
@@ -1697,11 +1259,11 @@ const Row = react.memo(function Row2({
|
|
|
1697
1259
|
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render row", itemId);
|
|
1698
1260
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1699
1261
|
children: [jsxRuntime.jsx("div", {
|
|
1700
|
-
className,
|
|
1262
|
+
className: className2,
|
|
1701
1263
|
css: [tableTheme.defaultClasses.cellFill],
|
|
1702
1264
|
ref: divRef
|
|
1703
1265
|
}), jsxRuntime.jsxs("div", {
|
|
1704
|
-
className,
|
|
1266
|
+
className: className2,
|
|
1705
1267
|
css: [tableTheme.defaultClasses.cell, tableTheme.defaultClasses.firstCell],
|
|
1706
1268
|
children: [jsxRuntime.jsx("div", {
|
|
1707
1269
|
css: {
|
|
@@ -1720,7 +1282,7 @@ const Row = react.memo(function Row2({
|
|
|
1720
1282
|
rowIndex
|
|
1721
1283
|
})
|
|
1722
1284
|
}, columnId)), jsxRuntime.jsx("div", {
|
|
1723
|
-
className,
|
|
1285
|
+
className: className2,
|
|
1724
1286
|
css: [tableTheme.defaultClasses.cellFill]
|
|
1725
1287
|
})]
|
|
1726
1288
|
});
|
|
@@ -1732,10 +1294,10 @@ function SortComponent({
|
|
|
1732
1294
|
const columnId = useColumnContext();
|
|
1733
1295
|
const {
|
|
1734
1296
|
components: {
|
|
1735
|
-
Badge
|
|
1297
|
+
Badge: Badge2
|
|
1736
1298
|
},
|
|
1737
1299
|
icons: {
|
|
1738
|
-
ArrowUpward
|
|
1300
|
+
ArrowUpward: ArrowUpward2
|
|
1739
1301
|
}
|
|
1740
1302
|
} = useTheme();
|
|
1741
1303
|
const {
|
|
@@ -1789,7 +1351,7 @@ function SortComponent({
|
|
|
1789
1351
|
onContextMenu: (e) => toggle2(e, true),
|
|
1790
1352
|
children: [jsxRuntime.jsx("div", {
|
|
1791
1353
|
children
|
|
1792
|
-
}), jsxRuntime.jsx(
|
|
1354
|
+
}), jsxRuntime.jsx(Badge2, {
|
|
1793
1355
|
badgeContent: index,
|
|
1794
1356
|
children: jsxRuntime.jsx("span", {
|
|
1795
1357
|
css: [{
|
|
@@ -1800,7 +1362,7 @@ function SortComponent({
|
|
|
1800
1362
|
}, direction === "desc" && {
|
|
1801
1363
|
transform: "rotate3d(0, 0, 1, 180deg)"
|
|
1802
1364
|
}],
|
|
1803
|
-
children: jsxRuntime.jsx(
|
|
1365
|
+
children: jsxRuntime.jsx(ArrowUpward2, {})
|
|
1804
1366
|
})
|
|
1805
1367
|
})]
|
|
1806
1368
|
});
|
|
@@ -1849,15 +1411,15 @@ const relativeOffset = (x, y) => {
|
|
|
1849
1411
|
return relativeOffset(x.offsetParent, y) + x.offsetTop;
|
|
1850
1412
|
return 0;
|
|
1851
1413
|
};
|
|
1852
|
-
function Virtualized(
|
|
1853
|
-
var
|
|
1414
|
+
function Virtualized(_c) {
|
|
1415
|
+
var _d = _c, {
|
|
1854
1416
|
header,
|
|
1855
1417
|
children
|
|
1856
|
-
} =
|
|
1418
|
+
} = _d, props = __objRest(_d, [
|
|
1857
1419
|
"header",
|
|
1858
1420
|
"children"
|
|
1859
1421
|
]);
|
|
1860
|
-
var _a, _b,
|
|
1422
|
+
var _a, _b, _c2, _d2;
|
|
1861
1423
|
const table = useTableContext();
|
|
1862
1424
|
const virtual = table.useState("props.virtual");
|
|
1863
1425
|
const probeRef = react.useRef(null);
|
|
@@ -1925,145 +1487,1064 @@ function Virtualized(_e) {
|
|
|
1925
1487
|
if (!virtual || !probeRef.current)
|
|
1926
1488
|
return;
|
|
1927
1489
|
window.addEventListener("scroll", incCounter, true);
|
|
1490
|
+
window.addEventListener("resize", incCounter, true);
|
|
1928
1491
|
return () => {
|
|
1929
1492
|
window.removeEventListener("scroll", incCounter, true);
|
|
1493
|
+
window.removeEventListener("resize", incCounter, true);
|
|
1930
1494
|
};
|
|
1931
1495
|
}, [probeRef.current, incCounter]);
|
|
1932
|
-
(
|
|
1496
|
+
(_d2 = (_c2 = table.getState().props).debugRender) == null ? void 0 : _d2.call(_c2, `Virtualalized render ${from} to ${to}`);
|
|
1933
1497
|
return jsxRuntime.jsxs("div", __spreadProps(__spreadValues({}, props), {
|
|
1934
1498
|
children: [header, virtual && jsxRuntime.jsx("div", {
|
|
1935
1499
|
style: {
|
|
1936
1500
|
gridColumn: "1 / -1",
|
|
1937
1501
|
height: before
|
|
1938
1502
|
},
|
|
1939
|
-
ref: probeRef
|
|
1940
|
-
}), children(itemIds, from), virtual && jsxRuntime.jsx("div", {
|
|
1941
|
-
style: {
|
|
1942
|
-
gridColumn: "1 / -1",
|
|
1943
|
-
height: after
|
|
1944
|
-
}
|
|
1503
|
+
ref: probeRef
|
|
1504
|
+
}), children(itemIds, from), virtual && jsxRuntime.jsx("div", {
|
|
1505
|
+
style: {
|
|
1506
|
+
gridColumn: "1 / -1",
|
|
1507
|
+
height: after
|
|
1508
|
+
}
|
|
1509
|
+
})]
|
|
1510
|
+
}));
|
|
1511
|
+
}
|
|
1512
|
+
const TableContext = react.createContext(null);
|
|
1513
|
+
const ColumnContext = react.createContext(null);
|
|
1514
|
+
function useTableContext() {
|
|
1515
|
+
const value = react.useContext(TableContext);
|
|
1516
|
+
if (!value)
|
|
1517
|
+
throw Error("No table context available");
|
|
1518
|
+
return value;
|
|
1519
|
+
}
|
|
1520
|
+
function useColumnContext() {
|
|
1521
|
+
const value = react.useContext(ColumnContext);
|
|
1522
|
+
if (value === null)
|
|
1523
|
+
throw Error("No column context available");
|
|
1524
|
+
return value;
|
|
1525
|
+
}
|
|
1526
|
+
function Table(props) {
|
|
1527
|
+
var _a, _b;
|
|
1528
|
+
const table = useTableState(props);
|
|
1529
|
+
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table");
|
|
1530
|
+
return jsxRuntime.jsx(TableContext.Provider, {
|
|
1531
|
+
value: table,
|
|
1532
|
+
children: jsxRuntime.jsx(TableLoadingState, {})
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
function TableLoadingState() {
|
|
1536
|
+
const {
|
|
1537
|
+
text
|
|
1538
|
+
} = useTheme();
|
|
1539
|
+
const isHydrated = useTableStateStorage();
|
|
1540
|
+
const [showLoading, setShowLoading] = react.useState(false);
|
|
1541
|
+
react.useEffect(() => {
|
|
1542
|
+
const handle = setTimeout(() => setShowLoading(true), 500);
|
|
1543
|
+
return () => clearTimeout(handle);
|
|
1544
|
+
});
|
|
1545
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1546
|
+
children: [!isHydrated && showLoading && jsxRuntime.jsx("div", {
|
|
1547
|
+
children: text.loading
|
|
1548
|
+
}), jsxRuntime.jsx(TableInner, {
|
|
1549
|
+
hidden: !isHydrated
|
|
1550
|
+
})]
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
const TableInner = react.memo(function TableInner2({
|
|
1554
|
+
hidden
|
|
1555
|
+
}) {
|
|
1556
|
+
var _a, _b;
|
|
1557
|
+
const table = useTableContext();
|
|
1558
|
+
const fullWidth = table.useState("props.fullWidth");
|
|
1559
|
+
const activeColumns = table.useState((state) => state.activeColumns.map((column) => ({
|
|
1560
|
+
id: column.id,
|
|
1561
|
+
width: column.width,
|
|
1562
|
+
classes: column.classes,
|
|
1563
|
+
header: column.header
|
|
1564
|
+
})));
|
|
1565
|
+
const columnWidths = table.useState("columnWidths", {
|
|
1566
|
+
throttle: 16
|
|
1567
|
+
});
|
|
1568
|
+
const columnStyleOverride = table.useState("columnStyleOverride", {
|
|
1569
|
+
throttle: 16
|
|
1570
|
+
});
|
|
1571
|
+
const defaultWidth = table.useState("props.defaultWidth");
|
|
1572
|
+
const classes = table.useState("props.classes");
|
|
1573
|
+
const stickyHeader = table.useState("props.stickyHeader");
|
|
1574
|
+
const enableSelection = table.useState("props.enableSelection");
|
|
1575
|
+
const enableColumnSelection = table.useState("props.enableColumnSelection");
|
|
1576
|
+
const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
|
|
1577
|
+
const cssVariables = useCssVariables();
|
|
1578
|
+
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
1579
|
+
return jsxRuntime.jsx(Virtualized, {
|
|
1580
|
+
className: classes == null ? void 0 : classes.table,
|
|
1581
|
+
css: [cssVariables, tableTheme.defaultClasses.table, {
|
|
1582
|
+
gridTemplateColumns: [
|
|
1583
|
+
fullWidth === "right" || fullWidth === true ? "auto" : "0",
|
|
1584
|
+
"max-content",
|
|
1585
|
+
...activeColumns.map((column) => {
|
|
1586
|
+
var _a2, _b2, _c;
|
|
1587
|
+
return (_c = (_b2 = (_a2 = columnWidths.get(column.id)) != null ? _a2 : column.width) != null ? _b2 : defaultWidth) != null ? _c : "max-content";
|
|
1588
|
+
}),
|
|
1589
|
+
fullWidth === "left" || fullWidth === true ? "auto" : "0"
|
|
1590
|
+
].join(" ")
|
|
1591
|
+
}, hidden && {
|
|
1592
|
+
visibility: "hidden"
|
|
1593
|
+
}],
|
|
1594
|
+
header: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1595
|
+
children: [jsxRuntime.jsx("div", {
|
|
1596
|
+
className: classes == null ? void 0 : classes.headerCell,
|
|
1597
|
+
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
1598
|
+
}), jsxRuntime.jsxs("div", {
|
|
1599
|
+
className: classes == null ? void 0 : classes.headerCell,
|
|
1600
|
+
css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
|
|
1601
|
+
children: [enableSelection && jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && jsxRuntime.jsx(ColumnSelection, {}), enableExport && jsxRuntime.jsx(Export$1, {}), jsxRuntime.jsx(ResizeHandleView, {})]
|
|
1602
|
+
}), jsxRuntime.jsx(ColumnHeaderContext.Provider, {
|
|
1603
|
+
children: activeColumns.map((column) => {
|
|
1604
|
+
var _a2;
|
|
1605
|
+
return jsxRuntime.jsx(ColumnContext.Provider, {
|
|
1606
|
+
value: column.id,
|
|
1607
|
+
children: jsxRuntime.jsxs(ColumnHeader, {
|
|
1608
|
+
className: cx(classes == null ? void 0 : classes.headerCell, (_a2 = column.classes) == null ? void 0 : _a2.headerCell),
|
|
1609
|
+
css: [tableTheme.defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
|
|
1610
|
+
children: [jsxRuntime.jsx(SortComponent, {
|
|
1611
|
+
children: column.header
|
|
1612
|
+
}), jsxRuntime.jsx("div", {
|
|
1613
|
+
css: {
|
|
1614
|
+
flex: 1
|
|
1615
|
+
}
|
|
1616
|
+
}), jsxRuntime.jsx(FilterControl, {}), jsxRuntime.jsx(ResizeHandle, {})]
|
|
1617
|
+
}, column.id)
|
|
1618
|
+
}, column.id);
|
|
1619
|
+
})
|
|
1620
|
+
}), jsxRuntime.jsx("div", {
|
|
1621
|
+
className: classes == null ? void 0 : classes.headerCell,
|
|
1622
|
+
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
1623
|
+
})]
|
|
1624
|
+
}),
|
|
1625
|
+
children: (itemIds, startIndex) => itemIds.map((itemId, index) => jsxRuntime.jsx(Row, {
|
|
1626
|
+
itemId,
|
|
1627
|
+
rowIndex: startIndex + index
|
|
1628
|
+
}, itemId))
|
|
1629
|
+
});
|
|
1630
|
+
});
|
|
1631
|
+
const defaultColors = {
|
|
1632
|
+
primary: { main: "#1976d2", light: "#42a5f5", contrastText: "#fff" },
|
|
1633
|
+
secondary: { main: "#9c27b0", light: "#ba68c8", contrastText: "#fff" }
|
|
1634
|
+
};
|
|
1635
|
+
function Spinner({
|
|
1636
|
+
className: className2
|
|
1637
|
+
}) {
|
|
1638
|
+
return jsxRuntime.jsxs("div", {
|
|
1639
|
+
className: className2,
|
|
1640
|
+
css: react$2.css`
|
|
1641
|
+
display: inline-block;
|
|
1642
|
+
position: relative;
|
|
1643
|
+
width: 1em;
|
|
1644
|
+
height: 1em;
|
|
1645
|
+
|
|
1646
|
+
div {
|
|
1647
|
+
box-sizing: border-box;
|
|
1648
|
+
display: block;
|
|
1649
|
+
position: absolute;
|
|
1650
|
+
width: 0.8em;
|
|
1651
|
+
height: 0.8em;
|
|
1652
|
+
margin: 0.1em;
|
|
1653
|
+
border: 0.1em solid #fff;
|
|
1654
|
+
border-radius: 50%;
|
|
1655
|
+
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
1656
|
+
border-color: currentColor transparent transparent transparent;
|
|
1657
|
+
}
|
|
1658
|
+
div:nth-of-type(1) {
|
|
1659
|
+
animation-delay: -0.45s;
|
|
1660
|
+
}
|
|
1661
|
+
div:nth-of-type(2) {
|
|
1662
|
+
animation-delay: -0.3s;
|
|
1663
|
+
}
|
|
1664
|
+
div:nth-of-type(3) {
|
|
1665
|
+
animation-delay: -0.15s;
|
|
1666
|
+
}
|
|
1667
|
+
@keyframes lds-ring {
|
|
1668
|
+
0% {
|
|
1669
|
+
transform: rotate(0deg);
|
|
1670
|
+
}
|
|
1671
|
+
100% {
|
|
1672
|
+
transform: rotate(360deg);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
`,
|
|
1676
|
+
children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", {})]
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
const Badge = ({
|
|
1680
|
+
badgeContent,
|
|
1681
|
+
children
|
|
1682
|
+
}) => {
|
|
1683
|
+
if (!open)
|
|
1684
|
+
return null;
|
|
1685
|
+
return jsxRuntime.jsxs("span", {
|
|
1686
|
+
css: {
|
|
1687
|
+
display: "inline-flex",
|
|
1688
|
+
position: "relative",
|
|
1689
|
+
flexShrink: 0,
|
|
1690
|
+
verticalAlign: "middle"
|
|
1691
|
+
},
|
|
1692
|
+
children: [children, jsxRuntime.jsx("span", {
|
|
1693
|
+
css: [{
|
|
1694
|
+
top: 0,
|
|
1695
|
+
right: 0,
|
|
1696
|
+
transform: "scale(1) translate(50%, -50%)",
|
|
1697
|
+
transformOrigin: "100% 0%",
|
|
1698
|
+
height: 20,
|
|
1699
|
+
display: "flex",
|
|
1700
|
+
padding: "0 6px",
|
|
1701
|
+
zIndex: 1,
|
|
1702
|
+
position: "absolute",
|
|
1703
|
+
flexWrap: "wrap",
|
|
1704
|
+
minWidth: 20,
|
|
1705
|
+
transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
1706
|
+
alignItems: "center",
|
|
1707
|
+
lineHeight: 1,
|
|
1708
|
+
alignContent: "center",
|
|
1709
|
+
borderRadius: 10,
|
|
1710
|
+
justifyContent: "center",
|
|
1711
|
+
fontSize: "0.8em"
|
|
1712
|
+
}, !badgeContent && {
|
|
1713
|
+
transform: "scale(0) translate(50%, -50%)",
|
|
1714
|
+
transition: "transform 195ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
|
|
1715
|
+
}],
|
|
1716
|
+
children: badgeContent
|
|
1717
|
+
})]
|
|
1718
|
+
});
|
|
1719
|
+
};
|
|
1720
|
+
const Button = (_e) => {
|
|
1721
|
+
var _f = _e, {
|
|
1722
|
+
startIcon,
|
|
1723
|
+
children,
|
|
1724
|
+
variant = "text"
|
|
1725
|
+
} = _f, props = __objRest(_f, [
|
|
1726
|
+
"startIcon",
|
|
1727
|
+
"children",
|
|
1728
|
+
"variant"
|
|
1729
|
+
]);
|
|
1730
|
+
return jsxRuntime.jsxs("button", __spreadProps(__spreadValues({
|
|
1731
|
+
css: [{
|
|
1732
|
+
padding: `var(--spacing) calc(var(--spacing) * 2)`,
|
|
1733
|
+
display: "inline-flex",
|
|
1734
|
+
alignItems: "center",
|
|
1735
|
+
transition: "background-color 150ms",
|
|
1736
|
+
border: "none",
|
|
1737
|
+
cursor: "pointer",
|
|
1738
|
+
background: "transparent",
|
|
1739
|
+
borderRadius: 4,
|
|
1740
|
+
"&:active:not(:disabled)": {
|
|
1741
|
+
transform: "scale3d(0.95, 0.95, 1)"
|
|
1742
|
+
}
|
|
1743
|
+
}, variant === "text" && {
|
|
1744
|
+
"&:hover": {
|
|
1745
|
+
background: "rgba(0, 0, 0, 0.1)"
|
|
1746
|
+
}
|
|
1747
|
+
}, variant === "outlined" && {
|
|
1748
|
+
border: `1px solid ${tableTheme.darkGray}`,
|
|
1749
|
+
"&:disabled": {
|
|
1750
|
+
borderColor: tableTheme.lightGray
|
|
1751
|
+
}
|
|
1752
|
+
}, variant === "contained" && {
|
|
1753
|
+
color: "var(--primaryContrastText)",
|
|
1754
|
+
backgroundColor: "var(--primaryMain)",
|
|
1755
|
+
boxShadow: "0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%)",
|
|
1756
|
+
"&:hover": {
|
|
1757
|
+
filter: "brightness(0.9)"
|
|
1758
|
+
},
|
|
1759
|
+
"&:disabled": {
|
|
1760
|
+
filter: "grayscale()",
|
|
1761
|
+
opacity: 0.5
|
|
1762
|
+
}
|
|
1763
|
+
}]
|
|
1764
|
+
}, props), {
|
|
1765
|
+
children: [startIcon && jsxRuntime.jsx("span", {
|
|
1766
|
+
css: {
|
|
1767
|
+
marginRight: `calc(var(--spacing) * 2)`
|
|
1768
|
+
},
|
|
1769
|
+
children: startIcon
|
|
1770
|
+
}), jsxRuntime.jsx("span", {
|
|
1771
|
+
children
|
|
1772
|
+
})]
|
|
1773
|
+
}));
|
|
1774
|
+
};
|
|
1775
|
+
const Checkbox = (_g) => {
|
|
1776
|
+
var _h = _g, {
|
|
1777
|
+
className: className2
|
|
1778
|
+
} = _h, props = __objRest(_h, [
|
|
1779
|
+
"className"
|
|
1780
|
+
]);
|
|
1781
|
+
return jsxRuntime.jsxs("label", {
|
|
1782
|
+
css: [{
|
|
1783
|
+
padding: "calc(var(--spacing) * 1.8)",
|
|
1784
|
+
display: "flex",
|
|
1785
|
+
color: "currentcolor",
|
|
1786
|
+
userSelect: "none",
|
|
1787
|
+
"& input": {
|
|
1788
|
+
appearance: "none",
|
|
1789
|
+
margin: 0
|
|
1790
|
+
}
|
|
1791
|
+
}, props.disabled && {
|
|
1792
|
+
color: "rgba(0, 0, 0, 0.26)"
|
|
1793
|
+
}],
|
|
1794
|
+
className: className2,
|
|
1795
|
+
children: [jsxRuntime.jsx("input", __spreadValues({
|
|
1796
|
+
type: "checkbox"
|
|
1797
|
+
}, props)), props.checked ? jsxRuntime.jsx("svg", {
|
|
1798
|
+
css: {
|
|
1799
|
+
fontSize: "1.25rem",
|
|
1800
|
+
width: "1em",
|
|
1801
|
+
height: "1em",
|
|
1802
|
+
fill: "var(--primaryMain)"
|
|
1803
|
+
},
|
|
1804
|
+
focusable: "false",
|
|
1805
|
+
viewBox: "0 0 24 24",
|
|
1806
|
+
"aria-hidden": "true",
|
|
1807
|
+
children: jsxRuntime.jsx("path", {
|
|
1808
|
+
d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
|
|
1809
|
+
})
|
|
1810
|
+
}) : jsxRuntime.jsx("svg", {
|
|
1811
|
+
css: {
|
|
1812
|
+
fontSize: "1.25rem",
|
|
1813
|
+
width: "1em",
|
|
1814
|
+
height: "1em",
|
|
1815
|
+
fill: "currentColor"
|
|
1816
|
+
},
|
|
1817
|
+
focusable: "false",
|
|
1818
|
+
viewBox: "0 0 24 24",
|
|
1819
|
+
"aria-hidden": "true",
|
|
1820
|
+
children: jsxRuntime.jsx("path", {
|
|
1821
|
+
d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
|
|
1822
|
+
})
|
|
1823
|
+
})]
|
|
1824
|
+
});
|
|
1825
|
+
};
|
|
1826
|
+
const IconButton = (props) => {
|
|
1827
|
+
return jsxRuntime.jsx("button", __spreadValues({
|
|
1828
|
+
css: {
|
|
1829
|
+
padding: "var(--spacing)",
|
|
1830
|
+
borderRadius: "50%",
|
|
1831
|
+
display: "inline-flex",
|
|
1832
|
+
justifyContent: "center",
|
|
1833
|
+
alignItems: "center",
|
|
1834
|
+
transition: "background-color 150ms",
|
|
1835
|
+
border: "none",
|
|
1836
|
+
cursor: "pointer",
|
|
1837
|
+
color: "inherit",
|
|
1838
|
+
background: "transparent",
|
|
1839
|
+
"&:hover": {
|
|
1840
|
+
backgroundColor: "rgba(0, 0, 0, 0.04)"
|
|
1841
|
+
},
|
|
1842
|
+
"&:active": {
|
|
1843
|
+
transformColor: "scale3d(0.95, 0.95, 1)"
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
}, props));
|
|
1847
|
+
};
|
|
1848
|
+
const TextField = (_i) => {
|
|
1849
|
+
var _j = _i, {
|
|
1850
|
+
endIcon,
|
|
1851
|
+
className: className2,
|
|
1852
|
+
inputRef
|
|
1853
|
+
} = _j, props = __objRest(_j, [
|
|
1854
|
+
"endIcon",
|
|
1855
|
+
"className",
|
|
1856
|
+
"inputRef"
|
|
1857
|
+
]);
|
|
1858
|
+
var _a;
|
|
1859
|
+
const [focus, setFocus] = react.useState(false);
|
|
1860
|
+
return jsxRuntime.jsx("div", {
|
|
1861
|
+
className: className2,
|
|
1862
|
+
css: {
|
|
1863
|
+
display: "flex"
|
|
1864
|
+
},
|
|
1865
|
+
children: jsxRuntime.jsxs("span", {
|
|
1866
|
+
css: [{
|
|
1867
|
+
flex: 1,
|
|
1868
|
+
display: "flex",
|
|
1869
|
+
alignItems: "center",
|
|
1870
|
+
border: `1px solid ${tableTheme.darkGray}`,
|
|
1871
|
+
borderRadius: 4
|
|
1872
|
+
}, focus && {
|
|
1873
|
+
border: "2px solid var(--primaryMain)",
|
|
1874
|
+
margin: -1
|
|
1875
|
+
}],
|
|
1876
|
+
children: [jsxRuntime.jsx("input", __spreadProps(__spreadValues({
|
|
1877
|
+
ref: inputRef
|
|
1878
|
+
}, props), {
|
|
1879
|
+
value: (_a = props.value) != null ? _a : "",
|
|
1880
|
+
onFocus: () => setFocus(true),
|
|
1881
|
+
onBlur: () => setFocus(false),
|
|
1882
|
+
css: {
|
|
1883
|
+
flex: 1,
|
|
1884
|
+
border: "none",
|
|
1885
|
+
outline: "none",
|
|
1886
|
+
borderRadius: 4,
|
|
1887
|
+
padding: "calc(var(--spacing) * 2)",
|
|
1888
|
+
paddingRight: 0,
|
|
1889
|
+
transition: "outline 500ms"
|
|
1890
|
+
}
|
|
1891
|
+
})), endIcon]
|
|
1892
|
+
})
|
|
1893
|
+
});
|
|
1894
|
+
};
|
|
1895
|
+
const defaultComponents = {
|
|
1896
|
+
IconButton,
|
|
1897
|
+
Checkbox,
|
|
1898
|
+
Popover: tableTheme.Popover,
|
|
1899
|
+
Button,
|
|
1900
|
+
Badge,
|
|
1901
|
+
TextField,
|
|
1902
|
+
Spinner
|
|
1903
|
+
};
|
|
1904
|
+
const IconDefaultStyle = react$2.css({
|
|
1905
|
+
width: "1.5em",
|
|
1906
|
+
height: "1.5em",
|
|
1907
|
+
color: "inherit"
|
|
1908
|
+
});
|
|
1909
|
+
function Icon(svg) {
|
|
1910
|
+
return (props) => jsxRuntime.jsx(react$2.ClassNames, {
|
|
1911
|
+
children: ({
|
|
1912
|
+
css: css2
|
|
1913
|
+
}) => react.cloneElement(svg, __spreadProps(__spreadValues({}, props), {
|
|
1914
|
+
className: css2(IconDefaultStyle, props.className)
|
|
1915
|
+
}))
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
const Settings = Icon(jsxRuntime.jsxs("svg", {
|
|
1919
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1920
|
+
height: "24px",
|
|
1921
|
+
viewBox: "0 0 24 24",
|
|
1922
|
+
width: "24px",
|
|
1923
|
+
fill: "currentColor",
|
|
1924
|
+
children: [jsxRuntime.jsx("path", {
|
|
1925
|
+
d: "M0 0h24v24H0V0z",
|
|
1926
|
+
fill: "none"
|
|
1927
|
+
}), jsxRuntime.jsx("path", {
|
|
1928
|
+
d: "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"
|
|
1929
|
+
})]
|
|
1930
|
+
}));
|
|
1931
|
+
const Export = Icon(jsxRuntime.jsxs("svg", {
|
|
1932
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1933
|
+
enableBackground: "new 0 0 24 24",
|
|
1934
|
+
height: "24px",
|
|
1935
|
+
viewBox: "0 0 24 24",
|
|
1936
|
+
width: "24px",
|
|
1937
|
+
fill: "currentColor",
|
|
1938
|
+
children: [jsxRuntime.jsx("g", {
|
|
1939
|
+
children: jsxRuntime.jsx("rect", {
|
|
1940
|
+
fill: "none",
|
|
1941
|
+
height: "24",
|
|
1942
|
+
width: "24"
|
|
1943
|
+
})
|
|
1944
|
+
}), jsxRuntime.jsx("g", {
|
|
1945
|
+
children: jsxRuntime.jsx("path", {
|
|
1946
|
+
d: "M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"
|
|
1947
|
+
})
|
|
1948
|
+
})]
|
|
1949
|
+
}));
|
|
1950
|
+
const Clipboard = Icon(jsxRuntime.jsxs("svg", {
|
|
1951
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1952
|
+
height: "24px",
|
|
1953
|
+
viewBox: "0 0 24 24",
|
|
1954
|
+
width: "24px",
|
|
1955
|
+
fill: "currentColor",
|
|
1956
|
+
children: [jsxRuntime.jsx("path", {
|
|
1957
|
+
d: "M0 0h24v24H0V0z",
|
|
1958
|
+
fill: "none"
|
|
1959
|
+
}), jsxRuntime.jsx("path", {
|
|
1960
|
+
d: "M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"
|
|
1961
|
+
})]
|
|
1962
|
+
}));
|
|
1963
|
+
const ChevronRight = Icon(jsxRuntime.jsxs("svg", {
|
|
1964
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1965
|
+
height: "24px",
|
|
1966
|
+
viewBox: "0 0 24 24",
|
|
1967
|
+
width: "24px",
|
|
1968
|
+
fill: "currentColor",
|
|
1969
|
+
children: [jsxRuntime.jsx("path", {
|
|
1970
|
+
d: "M0 0h24v24H0V0z",
|
|
1971
|
+
fill: "none"
|
|
1972
|
+
}), jsxRuntime.jsx("path", {
|
|
1973
|
+
d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"
|
|
1974
|
+
})]
|
|
1975
|
+
}));
|
|
1976
|
+
const Search = Icon(jsxRuntime.jsxs("svg", {
|
|
1977
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1978
|
+
height: "24px",
|
|
1979
|
+
viewBox: "0 0 24 24",
|
|
1980
|
+
width: "24px",
|
|
1981
|
+
fill: "currentColor",
|
|
1982
|
+
children: [jsxRuntime.jsx("path", {
|
|
1983
|
+
d: "M0 0h24v24H0V0z",
|
|
1984
|
+
fill: "none"
|
|
1985
|
+
}), jsxRuntime.jsx("path", {
|
|
1986
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
|
1987
|
+
})]
|
|
1988
|
+
}));
|
|
1989
|
+
const Clear = Icon(jsxRuntime.jsxs("svg", {
|
|
1990
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1991
|
+
height: "24px",
|
|
1992
|
+
viewBox: "0 0 24 24",
|
|
1993
|
+
width: "24px",
|
|
1994
|
+
fill: "currentColor",
|
|
1995
|
+
children: [jsxRuntime.jsx("path", {
|
|
1996
|
+
d: "M0 0h24v24H0V0z",
|
|
1997
|
+
fill: "none"
|
|
1998
|
+
}), jsxRuntime.jsx("path", {
|
|
1999
|
+
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
2000
|
+
})]
|
|
2001
|
+
}));
|
|
2002
|
+
const ArrowDropDown = Icon(jsxRuntime.jsxs("svg", {
|
|
2003
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2004
|
+
height: "24px",
|
|
2005
|
+
viewBox: "0 0 24 24",
|
|
2006
|
+
width: "24px",
|
|
2007
|
+
fill: "currentColor",
|
|
2008
|
+
children: [jsxRuntime.jsx("path", {
|
|
2009
|
+
d: "M0 0h24v24H0V0z",
|
|
2010
|
+
fill: "none"
|
|
2011
|
+
}), jsxRuntime.jsx("path", {
|
|
2012
|
+
d: "M7 10l5 5 5-5H7z"
|
|
2013
|
+
})]
|
|
2014
|
+
}));
|
|
2015
|
+
const FilterList = Icon(jsxRuntime.jsx("svg", {
|
|
2016
|
+
viewBox: "0 0 24 24",
|
|
2017
|
+
children: jsxRuntime.jsx("path", {
|
|
2018
|
+
fill: "currentColor",
|
|
2019
|
+
d: "M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z"
|
|
2020
|
+
})
|
|
2021
|
+
}));
|
|
2022
|
+
const ArrowUpward = Icon(jsxRuntime.jsxs("svg", {
|
|
2023
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2024
|
+
height: "24px",
|
|
2025
|
+
viewBox: "0 0 24 24",
|
|
2026
|
+
width: "24px",
|
|
2027
|
+
fill: "currentColor",
|
|
2028
|
+
children: [jsxRuntime.jsx("path", {
|
|
2029
|
+
d: "M0 0h24v24H0V0z",
|
|
2030
|
+
fill: "none"
|
|
2031
|
+
}), jsxRuntime.jsx("path", {
|
|
2032
|
+
d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"
|
|
2033
|
+
})]
|
|
2034
|
+
}));
|
|
2035
|
+
const defaultIcons = {
|
|
2036
|
+
Settings,
|
|
2037
|
+
Export,
|
|
2038
|
+
Clipboard,
|
|
2039
|
+
ChevronRight,
|
|
2040
|
+
Search,
|
|
2041
|
+
Clear,
|
|
2042
|
+
ArrowDropDown,
|
|
2043
|
+
FilterList,
|
|
2044
|
+
ArrowUpward
|
|
2045
|
+
};
|
|
2046
|
+
const defaultTexts = {
|
|
2047
|
+
selectColumns: "Select visible columns",
|
|
2048
|
+
noResults: "No results",
|
|
2049
|
+
exportTitle: "Export",
|
|
2050
|
+
exportCopy: "To clipboard",
|
|
2051
|
+
exportDownload: "Download",
|
|
2052
|
+
today: "Today",
|
|
2053
|
+
thisWeek: "This week",
|
|
2054
|
+
reset: "Reset",
|
|
2055
|
+
loading: "Loading",
|
|
2056
|
+
selected: (count) => `${count} selected`
|
|
2057
|
+
};
|
|
2058
|
+
const defaultTableTheme = {
|
|
2059
|
+
text: defaultTexts,
|
|
2060
|
+
components: defaultComponents,
|
|
2061
|
+
icons: defaultIcons,
|
|
2062
|
+
colors: defaultColors,
|
|
2063
|
+
spacing: "5px"
|
|
2064
|
+
};
|
|
2065
|
+
const emptyStore = new react$1.Store(void 0);
|
|
2066
|
+
function useTheme() {
|
|
2067
|
+
var _a, _b;
|
|
2068
|
+
const table = react.useContext(TableContext);
|
|
2069
|
+
const localTheme = (_b = (_a = table == null ? void 0 : table.useState((state) => ({
|
|
2070
|
+
text: state.props.text,
|
|
2071
|
+
classes: state.props.classes,
|
|
2072
|
+
components: state.props.components,
|
|
2073
|
+
icons: state.props.icons,
|
|
2074
|
+
colors: state.props.colors,
|
|
2075
|
+
spacing: state.props.spacing
|
|
2076
|
+
}))) != null ? _a : emptyStore.useState()) != null ? _b : {};
|
|
2077
|
+
const contextTableTheme = react.useContext(tableTheme.TableThemeContext);
|
|
2078
|
+
return tableTheme.mergeThemes(defaultTableTheme, tableTheme.globalTableTheme, contextTableTheme, localTheme);
|
|
2079
|
+
}
|
|
2080
|
+
function AutoFocusTextField(props) {
|
|
2081
|
+
const {
|
|
2082
|
+
components: {
|
|
2083
|
+
TextField: TextField2
|
|
2084
|
+
}
|
|
2085
|
+
} = useTheme();
|
|
2086
|
+
const ref = react.useRef(null);
|
|
2087
|
+
const {
|
|
2088
|
+
visible
|
|
2089
|
+
} = react.useContext(tableTheme.PopoverContext);
|
|
2090
|
+
react.useLayoutEffect(() => {
|
|
2091
|
+
if (visible && ref.current) {
|
|
2092
|
+
ref.current.focus();
|
|
2093
|
+
}
|
|
2094
|
+
}, [visible]);
|
|
2095
|
+
return jsxRuntime.jsx(TextField2, __spreadProps(__spreadValues({}, props), {
|
|
2096
|
+
inputRef: ref
|
|
2097
|
+
}));
|
|
2098
|
+
}
|
|
2099
|
+
const className = "schummar-table-date-input";
|
|
2100
|
+
const defaultDate = new Date(1970, 0, 1);
|
|
2101
|
+
const isIncludedType = (type) => type === "day" || type === "month" || type === "year";
|
|
2102
|
+
const defaultLengths = {
|
|
2103
|
+
day: 2,
|
|
2104
|
+
month: 2,
|
|
2105
|
+
year: 4
|
|
2106
|
+
};
|
|
2107
|
+
const maxLengths = {
|
|
2108
|
+
day: 2,
|
|
2109
|
+
month: 2,
|
|
2110
|
+
year: Infinity
|
|
2111
|
+
};
|
|
2112
|
+
const length = (type, value) => Math.max(value.length, defaultLengths[type]);
|
|
2113
|
+
const tabNext = (e) => {
|
|
2114
|
+
const all = Array.from(document.querySelectorAll(`.${className}`));
|
|
2115
|
+
const index = all.indexOf(e);
|
|
2116
|
+
const next = all[(index + 1) % all.length];
|
|
2117
|
+
if (next instanceof HTMLElement) {
|
|
2118
|
+
next.focus();
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
function DateInput({
|
|
2122
|
+
value,
|
|
2123
|
+
onChange,
|
|
2124
|
+
locale
|
|
2125
|
+
}) {
|
|
2126
|
+
const [override, setOverride] = react.useState();
|
|
2127
|
+
const commit = () => {
|
|
2128
|
+
if (!override) {
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
setOverride(void 0);
|
|
2132
|
+
if (!override.value) {
|
|
2133
|
+
onChange(null);
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
2136
|
+
const newValue = value ? new Date(value) : new Date();
|
|
2137
|
+
if (override.type === "day") {
|
|
2138
|
+
newValue.setDate(Number(override.value));
|
|
2139
|
+
} else if (override.type === "month") {
|
|
2140
|
+
newValue.setMonth(Number(override.value) - 1);
|
|
2141
|
+
} else if (override.type === "year") {
|
|
2142
|
+
newValue.setFullYear(Number(override.value));
|
|
2143
|
+
}
|
|
2144
|
+
onChange(newValue);
|
|
2145
|
+
};
|
|
2146
|
+
const format = react.useMemo(() => new Intl.DateTimeFormat(locale, {
|
|
2147
|
+
day: "2-digit",
|
|
2148
|
+
month: "2-digit",
|
|
2149
|
+
year: "numeric"
|
|
2150
|
+
}), [locale]);
|
|
2151
|
+
const parts = format.formatToParts(value != null ? value : defaultDate);
|
|
2152
|
+
const isEmpty = !value;
|
|
2153
|
+
return jsxRuntime.jsx("div", {
|
|
2154
|
+
css: {
|
|
2155
|
+
display: "flex",
|
|
2156
|
+
alignItems: "baseline"
|
|
2157
|
+
},
|
|
2158
|
+
children: parts.map(({
|
|
2159
|
+
type,
|
|
2160
|
+
value: value2
|
|
2161
|
+
}, index) => jsxRuntime.jsx(react.Fragment, {
|
|
2162
|
+
children: isIncludedType(type) ? jsxRuntime.jsx("input", {
|
|
2163
|
+
className,
|
|
2164
|
+
css: {
|
|
2165
|
+
width: `${length(type, value2)}ch`,
|
|
2166
|
+
boxSizing: "content-box",
|
|
2167
|
+
overflow: "visible",
|
|
2168
|
+
border: "none",
|
|
2169
|
+
borderBottom: "2px solid transparent",
|
|
2170
|
+
outline: "none",
|
|
2171
|
+
fontSize: "inherit",
|
|
2172
|
+
"&:focus": {
|
|
2173
|
+
borderBottom: "2px solid var(--primaryMain)"
|
|
2174
|
+
}
|
|
2175
|
+
},
|
|
2176
|
+
placeholder: "".padEnd(length(type, value2), "0"),
|
|
2177
|
+
value: (override == null ? void 0 : override.type) === type ? override.value : !isEmpty ? value2 : "",
|
|
2178
|
+
onChange: (e) => {
|
|
2179
|
+
setOverride({
|
|
2180
|
+
type,
|
|
2181
|
+
value: e.target.value
|
|
2182
|
+
});
|
|
2183
|
+
if (e.target.value.length >= maxLengths[type]) {
|
|
2184
|
+
setTimeout(() => tabNext(e.target));
|
|
2185
|
+
}
|
|
2186
|
+
},
|
|
2187
|
+
onFocus: (e) => e.target.select(),
|
|
2188
|
+
onBlur: commit
|
|
2189
|
+
}) : type === "literal" ? jsxRuntime.jsx("span", {
|
|
2190
|
+
children: value2
|
|
2191
|
+
}) : null
|
|
2192
|
+
}, index))
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
const weekDays = [0, 1, 2, 3, 4, 5, 6];
|
|
2196
|
+
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
2197
|
+
const endOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1, 0, 0, 0, -1);
|
|
2198
|
+
const today = () => {
|
|
2199
|
+
const today2 = startOfDay(new Date());
|
|
2200
|
+
return {
|
|
2201
|
+
min: today2,
|
|
2202
|
+
max: today2
|
|
2203
|
+
};
|
|
2204
|
+
};
|
|
2205
|
+
const thisWeek = (firstDayOfWeek = 0) => {
|
|
2206
|
+
const now = new Date();
|
|
2207
|
+
const min = new Date(now);
|
|
2208
|
+
let diff = min.getDay() - firstDayOfWeek;
|
|
2209
|
+
if (diff < 0) {
|
|
2210
|
+
diff += 7;
|
|
2211
|
+
}
|
|
2212
|
+
min.setDate(min.getDate() - diff);
|
|
2213
|
+
const max = new Date(min);
|
|
2214
|
+
max.setDate(max.getDate() + 6);
|
|
2215
|
+
return {
|
|
2216
|
+
min: startOfDay(min),
|
|
2217
|
+
max: endOfDay(max)
|
|
2218
|
+
};
|
|
2219
|
+
};
|
|
2220
|
+
function dateIntersect(a, b) {
|
|
2221
|
+
if (a instanceof Date) {
|
|
2222
|
+
a = {
|
|
2223
|
+
min: a,
|
|
2224
|
+
max: a
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
if (b instanceof Date) {
|
|
2228
|
+
b = {
|
|
2229
|
+
min: b,
|
|
2230
|
+
max: b
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
if (!(a == null ? void 0 : a.min) || !a.max || !(b == null ? void 0 : b.min) || !b.max) {
|
|
2234
|
+
return false;
|
|
2235
|
+
}
|
|
2236
|
+
return !(endOfDay(a.max) < startOfDay(b.min) || startOfDay(a.min) > endOfDay(b.max));
|
|
2237
|
+
}
|
|
2238
|
+
function DatePicker({
|
|
2239
|
+
value,
|
|
2240
|
+
onChange,
|
|
2241
|
+
rangeSelect,
|
|
2242
|
+
locale,
|
|
2243
|
+
firstDayOfWeek = 0
|
|
2244
|
+
}) {
|
|
2245
|
+
const {
|
|
2246
|
+
components: {
|
|
2247
|
+
Button: Button2,
|
|
2248
|
+
IconButton: IconButton2
|
|
2249
|
+
},
|
|
2250
|
+
icons: {
|
|
2251
|
+
ChevronRight: ChevronRight2
|
|
2252
|
+
},
|
|
2253
|
+
text
|
|
2254
|
+
} = useTheme();
|
|
2255
|
+
const [baseDate] = react.useState(new Date());
|
|
2256
|
+
const [dateInView, setDateInView] = react.useState(baseDate);
|
|
2257
|
+
const [dirty, setDirty] = react.useState();
|
|
2258
|
+
const [hovered, setHovered] = react.useState();
|
|
2259
|
+
const min = dirty ? dirty.min : value instanceof Date ? value : value == null ? void 0 : value.min;
|
|
2260
|
+
const max = dirty ? dirty.max : value instanceof Date ? value : value == null ? void 0 : value.max;
|
|
2261
|
+
const {
|
|
2262
|
+
calendars,
|
|
2263
|
+
getBackProps,
|
|
2264
|
+
getForwardProps,
|
|
2265
|
+
getDateProps
|
|
2266
|
+
} = dayzed.useDayzed({
|
|
2267
|
+
onDateSelected: () => void 0,
|
|
2268
|
+
firstDayOfWeek,
|
|
2269
|
+
showOutsideDays: true,
|
|
2270
|
+
date: dateInView,
|
|
2271
|
+
onOffsetChanged: (offset) => setDateInView(new Date(dateInView.getFullYear(), dateInView.getMonth() + offset)),
|
|
2272
|
+
offset: 0
|
|
2273
|
+
});
|
|
2274
|
+
const formatWeekday = react.useMemo(() => {
|
|
2275
|
+
const {
|
|
2276
|
+
format
|
|
2277
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
2278
|
+
weekday: "short"
|
|
2279
|
+
});
|
|
2280
|
+
return (weekDay) => format(new Date(Date.UTC(2021, 5, weekDay)));
|
|
2281
|
+
}, [locale]);
|
|
2282
|
+
react.useEffect(() => setDateInView(value === null ? new Date() : value instanceof Date ? value : value.max), [value]);
|
|
2283
|
+
react.useEffect(() => {
|
|
2284
|
+
if (!rangeSelect) {
|
|
2285
|
+
setDirty(void 0);
|
|
2286
|
+
}
|
|
2287
|
+
}, [rangeSelect]);
|
|
2288
|
+
function set(min2, max2, edit) {
|
|
2289
|
+
if (!rangeSelect) {
|
|
2290
|
+
onChange(min2 != null ? min2 : null);
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
if (min2 && max2 && min2 > max2) {
|
|
2294
|
+
if (edit === "min") {
|
|
2295
|
+
max2 = min2;
|
|
2296
|
+
} else if (edit === "max") {
|
|
2297
|
+
min2 = max2;
|
|
2298
|
+
} else {
|
|
2299
|
+
[min2, max2] = [max2, min2];
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
if (!min2 === !max2) {
|
|
2303
|
+
setDirty(void 0);
|
|
2304
|
+
onChange(min2 && max2 ? {
|
|
2305
|
+
min: min2,
|
|
2306
|
+
max: max2
|
|
2307
|
+
} : null);
|
|
2308
|
+
} else {
|
|
2309
|
+
setDirty({
|
|
2310
|
+
min: min2,
|
|
2311
|
+
max: max2
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
const formatMonth = react.useMemo(() => {
|
|
2316
|
+
const {
|
|
2317
|
+
format
|
|
2318
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
2319
|
+
month: "long"
|
|
2320
|
+
});
|
|
2321
|
+
return (month) => format(new Date(2021, month));
|
|
2322
|
+
}, [locale]);
|
|
2323
|
+
const formatYear = react.useMemo(() => {
|
|
2324
|
+
const {
|
|
2325
|
+
format
|
|
2326
|
+
} = new Intl.DateTimeFormat(locale, {
|
|
2327
|
+
year: "numeric"
|
|
2328
|
+
});
|
|
2329
|
+
return (year) => format(new Date(year, 0, 1));
|
|
2330
|
+
}, [locale]);
|
|
2331
|
+
return jsxRuntime.jsxs("div", {
|
|
2332
|
+
children: [jsxRuntime.jsxs("div", {
|
|
2333
|
+
css: {
|
|
2334
|
+
display: "grid",
|
|
2335
|
+
gridAutoFlow: "column",
|
|
2336
|
+
justifyContent: "center",
|
|
2337
|
+
alignItems: "baseline",
|
|
2338
|
+
gap: "var(--spacing)"
|
|
2339
|
+
},
|
|
2340
|
+
children: [jsxRuntime.jsx(DateInput, {
|
|
2341
|
+
value: min != null ? min : null,
|
|
2342
|
+
onChange: (date) => set(date != null ? date : void 0, max, "min"),
|
|
2343
|
+
locale
|
|
2344
|
+
}), rangeSelect && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2345
|
+
children: [" - ", jsxRuntime.jsx(DateInput, {
|
|
2346
|
+
value: max != null ? max : null,
|
|
2347
|
+
onChange: (date) => set(min, date != null ? date : void 0, "max"),
|
|
2348
|
+
locale
|
|
2349
|
+
})]
|
|
2350
|
+
})]
|
|
2351
|
+
}), calendars.map(({
|
|
2352
|
+
month,
|
|
2353
|
+
year,
|
|
2354
|
+
weeks
|
|
2355
|
+
}) => jsxRuntime.jsxs("div", {
|
|
2356
|
+
css: {
|
|
2357
|
+
display: "grid"
|
|
2358
|
+
},
|
|
2359
|
+
children: [jsxRuntime.jsxs("div", {
|
|
2360
|
+
css: {
|
|
2361
|
+
margin: "calc(var(--spacing) * 4) 0",
|
|
2362
|
+
display: "grid",
|
|
2363
|
+
gridAutoFlow: "column",
|
|
2364
|
+
justifyContent: "space-between",
|
|
2365
|
+
alignItems: "center"
|
|
2366
|
+
},
|
|
2367
|
+
children: [jsxRuntime.jsx(IconButton2, __spreadProps(__spreadValues({}, getBackProps({
|
|
2368
|
+
calendars
|
|
2369
|
+
})), {
|
|
2370
|
+
children: jsxRuntime.jsx(ChevronRight2, {
|
|
2371
|
+
css: {
|
|
2372
|
+
transform: "rotate3d(0, 0, 1, 180deg)"
|
|
2373
|
+
}
|
|
2374
|
+
})
|
|
2375
|
+
})), jsxRuntime.jsxs("div", {
|
|
2376
|
+
css: {
|
|
2377
|
+
display: "flex"
|
|
2378
|
+
},
|
|
2379
|
+
children: [formatMonth(month), " ", formatYear(year)]
|
|
2380
|
+
}), jsxRuntime.jsx(IconButton2, __spreadProps(__spreadValues({}, getForwardProps({
|
|
2381
|
+
calendars
|
|
2382
|
+
})), {
|
|
2383
|
+
children: jsxRuntime.jsx(ChevronRight2, {})
|
|
2384
|
+
}))]
|
|
2385
|
+
}), jsxRuntime.jsxs("div", {
|
|
2386
|
+
css: {
|
|
2387
|
+
justifySelf: "center",
|
|
2388
|
+
display: "grid",
|
|
2389
|
+
gridTemplateColumns: "repeat(7, max-content)",
|
|
2390
|
+
fontWeight: "bold"
|
|
2391
|
+
},
|
|
2392
|
+
children: [weekDays.map((_v, weekDay) => jsxRuntime.jsx("div", {
|
|
2393
|
+
css: {
|
|
2394
|
+
justifySelf: "center",
|
|
2395
|
+
marginBottom: "var(--spacing)"
|
|
2396
|
+
},
|
|
2397
|
+
children: formatWeekday(weekDay)
|
|
2398
|
+
}, weekDay)), weeks.map((week, index) => week.map((dateObj, dayIndex) => {
|
|
2399
|
+
if (!dateObj) {
|
|
2400
|
+
return jsxRuntime.jsx("div", {});
|
|
2401
|
+
}
|
|
2402
|
+
const {
|
|
2403
|
+
prevMonth,
|
|
2404
|
+
nextMonth,
|
|
2405
|
+
date,
|
|
2406
|
+
today: today2
|
|
2407
|
+
} = dateObj;
|
|
2408
|
+
const selected = date.getTime() === (min == null ? void 0 : min.getTime()) || min && max && dateIntersect(date, {
|
|
2409
|
+
min,
|
|
2410
|
+
max
|
|
2411
|
+
});
|
|
2412
|
+
const preSelected = !selected && (date.getTime() === (hovered == null ? void 0 : hovered.getTime()) || min && !max && hovered && dateIntersect(date, min <= hovered ? {
|
|
2413
|
+
min,
|
|
2414
|
+
max: hovered
|
|
2415
|
+
} : {
|
|
2416
|
+
min: hovered,
|
|
2417
|
+
max: min
|
|
2418
|
+
}));
|
|
2419
|
+
return jsxRuntime.jsx("button", __spreadProps(__spreadValues({
|
|
2420
|
+
css: [{
|
|
2421
|
+
padding: 10,
|
|
2422
|
+
border: "1px solid transparent",
|
|
2423
|
+
background: "transparent",
|
|
2424
|
+
cursor: "pointer"
|
|
2425
|
+
}, (prevMonth || nextMonth) && {
|
|
2426
|
+
color: tableTheme.gray
|
|
2427
|
+
}, today2 && {
|
|
2428
|
+
border: "1px solid var(--secondaryMain)"
|
|
2429
|
+
}, selected && {
|
|
2430
|
+
background: "var(--primaryMain)",
|
|
2431
|
+
color: "var(--primaryContrastText)"
|
|
2432
|
+
}, preSelected && {
|
|
2433
|
+
background: "var(--primaryLight)",
|
|
2434
|
+
color: "var(--primaryContrastText)"
|
|
2435
|
+
}]
|
|
2436
|
+
}, getDateProps({
|
|
2437
|
+
dateObj
|
|
2438
|
+
})), {
|
|
2439
|
+
onClick: () => {
|
|
2440
|
+
if (dirty) {
|
|
2441
|
+
if (min)
|
|
2442
|
+
set(min, date);
|
|
2443
|
+
else
|
|
2444
|
+
set(date, max);
|
|
2445
|
+
} else {
|
|
2446
|
+
set(date);
|
|
2447
|
+
}
|
|
2448
|
+
},
|
|
2449
|
+
onPointerOver: () => setHovered(date),
|
|
2450
|
+
onPointerOut: () => setHovered(void 0),
|
|
2451
|
+
children: date.getDate()
|
|
2452
|
+
}), `${index}-${dayIndex}`);
|
|
2453
|
+
}))]
|
|
2454
|
+
})]
|
|
2455
|
+
}, `${month}${year}`)), jsxRuntime.jsxs("div", {
|
|
2456
|
+
css: {
|
|
2457
|
+
marginTop: "var(--spacing)",
|
|
2458
|
+
display: "grid",
|
|
2459
|
+
gridAutoFlow: "column",
|
|
2460
|
+
justifyContent: "center"
|
|
2461
|
+
},
|
|
2462
|
+
children: [jsxRuntime.jsx(Button2, {
|
|
2463
|
+
variant: "text",
|
|
2464
|
+
onClick: () => {
|
|
2465
|
+
setDirty(void 0);
|
|
2466
|
+
onChange(today());
|
|
2467
|
+
},
|
|
2468
|
+
children: text.today
|
|
2469
|
+
}), jsxRuntime.jsx(Button2, {
|
|
2470
|
+
variant: "text",
|
|
2471
|
+
onClick: () => {
|
|
2472
|
+
setDirty(void 0);
|
|
2473
|
+
onChange(thisWeek(firstDayOfWeek));
|
|
2474
|
+
},
|
|
2475
|
+
children: text.thisWeek
|
|
2476
|
+
}), jsxRuntime.jsx(Button2, {
|
|
2477
|
+
variant: "text",
|
|
2478
|
+
onClick: () => {
|
|
2479
|
+
setDirty(void 0);
|
|
2480
|
+
onChange(null);
|
|
2481
|
+
},
|
|
2482
|
+
children: text.reset
|
|
2483
|
+
})]
|
|
1945
2484
|
})]
|
|
1946
|
-
})
|
|
2485
|
+
});
|
|
1947
2486
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
return value;
|
|
2487
|
+
function convertDate(x) {
|
|
2488
|
+
if (x instanceof Date)
|
|
2489
|
+
return x;
|
|
2490
|
+
if (typeof x === "number" || typeof x === "string")
|
|
2491
|
+
return new Date(x);
|
|
2492
|
+
return null;
|
|
1955
2493
|
}
|
|
1956
|
-
function
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2494
|
+
function convertDateOrRange(x) {
|
|
2495
|
+
if (x instanceof Object && "min" in x && "max" in x) {
|
|
2496
|
+
const range = {
|
|
2497
|
+
min: convertDate(x.min),
|
|
2498
|
+
max: convertDate(x.max)
|
|
2499
|
+
};
|
|
2500
|
+
return range.min && range.max ? range : null;
|
|
2501
|
+
}
|
|
2502
|
+
return convertDate(x);
|
|
1961
2503
|
}
|
|
1962
|
-
function
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
return jsxRuntime.jsx(TableContext.Provider, {
|
|
1967
|
-
value: table,
|
|
1968
|
-
children: jsxRuntime.jsx(TableLoadingState, {})
|
|
1969
|
-
});
|
|
2504
|
+
function convertDateOrArray(x) {
|
|
2505
|
+
if (x instanceof Array)
|
|
2506
|
+
return x.map(convertDateOrRange).filter(Boolean);
|
|
2507
|
+
return convertDateOrRange(x);
|
|
1970
2508
|
}
|
|
1971
|
-
function
|
|
2509
|
+
function DateFilter(_k) {
|
|
2510
|
+
var _l = _k, {
|
|
2511
|
+
locale,
|
|
2512
|
+
firstDayOfWeek,
|
|
2513
|
+
singleSelect,
|
|
2514
|
+
filterBy = convertDateOrArray
|
|
2515
|
+
} = _l, props = __objRest(_l, [
|
|
2516
|
+
"locale",
|
|
2517
|
+
"firstDayOfWeek",
|
|
2518
|
+
"singleSelect",
|
|
2519
|
+
"filterBy"
|
|
2520
|
+
]);
|
|
1972
2521
|
const {
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2522
|
+
value = null,
|
|
2523
|
+
onChange
|
|
2524
|
+
} = useFilter(__spreadProps(__spreadValues({}, props), {
|
|
2525
|
+
filterBy,
|
|
2526
|
+
id: "dateFilter",
|
|
2527
|
+
isActive(filterValue) {
|
|
2528
|
+
return !!filterValue;
|
|
2529
|
+
},
|
|
2530
|
+
test(filterValue, value2) {
|
|
2531
|
+
return dateIntersect(filterValue, value2);
|
|
2532
|
+
}
|
|
2533
|
+
}));
|
|
2534
|
+
return jsxRuntime.jsx("div", {
|
|
2535
|
+
css: {
|
|
2536
|
+
padding: "calc(var(--spacing) * 2)",
|
|
2537
|
+
display: "grid"
|
|
2538
|
+
},
|
|
2539
|
+
children: jsxRuntime.jsx(DatePicker, {
|
|
2540
|
+
rangeSelect: !singleSelect,
|
|
2541
|
+
value,
|
|
2542
|
+
onChange,
|
|
2543
|
+
locale,
|
|
2544
|
+
firstDayOfWeek
|
|
2545
|
+
})
|
|
1987
2546
|
});
|
|
1988
2547
|
}
|
|
1989
|
-
const TableInner = react.memo(function TableInner2({
|
|
1990
|
-
hidden
|
|
1991
|
-
}) {
|
|
1992
|
-
var _a, _b;
|
|
1993
|
-
const table = useTableContext();
|
|
1994
|
-
const fullWidth = table.useState("props.fullWidth");
|
|
1995
|
-
const activeColumns = table.useState((state) => state.activeColumns.map((column) => ({
|
|
1996
|
-
id: column.id,
|
|
1997
|
-
width: column.width,
|
|
1998
|
-
classes: column.classes,
|
|
1999
|
-
header: column.header
|
|
2000
|
-
})));
|
|
2001
|
-
const columnWidths = table.useState("columnWidths", {
|
|
2002
|
-
throttle: 16
|
|
2003
|
-
});
|
|
2004
|
-
const columnStyleOverride = table.useState("columnStyleOverride", {
|
|
2005
|
-
throttle: 16
|
|
2006
|
-
});
|
|
2007
|
-
const defaultWidth = table.useState("props.defaultWidth");
|
|
2008
|
-
const classes = table.useState("props.classes");
|
|
2009
|
-
const stickyHeader = table.useState("props.stickyHeader");
|
|
2010
|
-
const enableSelection = table.useState("props.enableSelection");
|
|
2011
|
-
const enableColumnSelection = table.useState("props.enableColumnSelection");
|
|
2012
|
-
const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
|
|
2013
|
-
const cssVariables = useCssVariables();
|
|
2014
|
-
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
2015
|
-
return jsxRuntime.jsx(Virtualized, {
|
|
2016
|
-
className: classes == null ? void 0 : classes.table,
|
|
2017
|
-
css: [cssVariables, tableTheme.defaultClasses.table, {
|
|
2018
|
-
gridTemplateColumns: [
|
|
2019
|
-
fullWidth === "right" || fullWidth === true ? "auto" : "0",
|
|
2020
|
-
"max-content",
|
|
2021
|
-
...activeColumns.map((column) => {
|
|
2022
|
-
var _a2, _b2, _c;
|
|
2023
|
-
return (_c = (_b2 = (_a2 = columnWidths.get(column.id)) != null ? _a2 : column.width) != null ? _b2 : defaultWidth) != null ? _c : "max-content";
|
|
2024
|
-
}),
|
|
2025
|
-
fullWidth === "left" || fullWidth === true ? "auto" : "0"
|
|
2026
|
-
].join(" ")
|
|
2027
|
-
}, hidden && {
|
|
2028
|
-
visibility: "hidden"
|
|
2029
|
-
}],
|
|
2030
|
-
header: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2031
|
-
children: [jsxRuntime.jsx("div", {
|
|
2032
|
-
className: classes == null ? void 0 : classes.headerCell,
|
|
2033
|
-
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
2034
|
-
}), jsxRuntime.jsxs("div", {
|
|
2035
|
-
className: classes == null ? void 0 : classes.headerCell,
|
|
2036
|
-
css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
|
|
2037
|
-
children: [enableSelection && jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && jsxRuntime.jsx(ColumnSelection, {}), enableExport && jsxRuntime.jsx(Export, {}), jsxRuntime.jsx(ResizeHandleView, {})]
|
|
2038
|
-
}), jsxRuntime.jsx(ColumnHeaderContext.Provider, {
|
|
2039
|
-
children: activeColumns.map((column) => {
|
|
2040
|
-
var _a2;
|
|
2041
|
-
return jsxRuntime.jsx(ColumnContext.Provider, {
|
|
2042
|
-
value: column.id,
|
|
2043
|
-
children: jsxRuntime.jsxs(ColumnHeader, {
|
|
2044
|
-
className: cx(classes == null ? void 0 : classes.headerCell, (_a2 = column.classes) == null ? void 0 : _a2.headerCell),
|
|
2045
|
-
css: [tableTheme.defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
|
|
2046
|
-
children: [jsxRuntime.jsx(SortComponent, {
|
|
2047
|
-
children: column.header
|
|
2048
|
-
}), jsxRuntime.jsx("div", {
|
|
2049
|
-
css: {
|
|
2050
|
-
flex: 1
|
|
2051
|
-
}
|
|
2052
|
-
}), jsxRuntime.jsx(FilterControl, {}), jsxRuntime.jsx(ResizeHandle, {})]
|
|
2053
|
-
}, column.id)
|
|
2054
|
-
}, column.id);
|
|
2055
|
-
})
|
|
2056
|
-
}), jsxRuntime.jsx("div", {
|
|
2057
|
-
className: classes == null ? void 0 : classes.headerCell,
|
|
2058
|
-
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
2059
|
-
})]
|
|
2060
|
-
}),
|
|
2061
|
-
children: (itemIds, startIndex) => itemIds.map((itemId, index) => jsxRuntime.jsx(Row, {
|
|
2062
|
-
itemId,
|
|
2063
|
-
rowIndex: startIndex + index
|
|
2064
|
-
}, itemId))
|
|
2065
|
-
});
|
|
2066
|
-
});
|
|
2067
2548
|
function toggle(set, value, singleSelect) {
|
|
2068
2549
|
const newSet = new Set(singleSelect ? [] : set);
|
|
2069
2550
|
if (set.has(value)) {
|
|
@@ -2073,13 +2554,13 @@ function toggle(set, value, singleSelect) {
|
|
|
2073
2554
|
}
|
|
2074
2555
|
return newSet;
|
|
2075
2556
|
}
|
|
2076
|
-
function SelectFilter(
|
|
2077
|
-
var
|
|
2557
|
+
function SelectFilter(_m) {
|
|
2558
|
+
var _n = _m, {
|
|
2078
2559
|
options: providedOptions,
|
|
2079
2560
|
stringValue = asString,
|
|
2080
2561
|
render = stringValue,
|
|
2081
2562
|
singleSelect
|
|
2082
|
-
} =
|
|
2563
|
+
} = _n, props = __objRest(_n, [
|
|
2083
2564
|
"options",
|
|
2084
2565
|
"stringValue",
|
|
2085
2566
|
"render",
|
|
@@ -2087,12 +2568,12 @@ function SelectFilter(_g) {
|
|
|
2087
2568
|
]);
|
|
2088
2569
|
const {
|
|
2089
2570
|
components: {
|
|
2090
|
-
IconButton,
|
|
2091
|
-
Checkbox
|
|
2571
|
+
IconButton: IconButton2,
|
|
2572
|
+
Checkbox: Checkbox2
|
|
2092
2573
|
},
|
|
2093
2574
|
icons: {
|
|
2094
|
-
Search,
|
|
2095
|
-
Clear
|
|
2575
|
+
Search: Search2,
|
|
2576
|
+
Clear: Clear2
|
|
2096
2577
|
},
|
|
2097
2578
|
text
|
|
2098
2579
|
} = useTheme();
|
|
@@ -2131,9 +2612,9 @@ function SelectFilter(_g) {
|
|
|
2131
2612
|
children: [jsxRuntime.jsx(AutoFocusTextField, {
|
|
2132
2613
|
value: query,
|
|
2133
2614
|
onChange: (e) => setQuery(e.target.value),
|
|
2134
|
-
endIcon: jsxRuntime.jsx(
|
|
2615
|
+
endIcon: jsxRuntime.jsx(IconButton2, {
|
|
2135
2616
|
onClick: () => setQuery(""),
|
|
2136
|
-
children: !query ? jsxRuntime.jsx(
|
|
2617
|
+
children: !query ? jsxRuntime.jsx(Search2, {}) : jsxRuntime.jsx(Clear2, {})
|
|
2137
2618
|
}),
|
|
2138
2619
|
css: {
|
|
2139
2620
|
marginBottom: "var(--spacing)"
|
|
@@ -2145,7 +2626,7 @@ function SelectFilter(_g) {
|
|
|
2145
2626
|
},
|
|
2146
2627
|
children: [jsxRuntime.jsx(FormControlLabel, {
|
|
2147
2628
|
disabled: value.size === 0,
|
|
2148
|
-
control: jsxRuntime.jsx(
|
|
2629
|
+
control: jsxRuntime.jsx(Checkbox2, {
|
|
2149
2630
|
disabled: value.size === 0,
|
|
2150
2631
|
checked: value.size > 0,
|
|
2151
2632
|
onChange: () => onChange(/* @__PURE__ */ new Set())
|
|
@@ -2154,7 +2635,7 @@ function SelectFilter(_g) {
|
|
|
2154
2635
|
children: ["<", text.selected(value.size), ">"]
|
|
2155
2636
|
})
|
|
2156
2637
|
}), filtered.map((option, index) => jsxRuntime.jsx(FormControlLabel, {
|
|
2157
|
-
control: jsxRuntime.jsx(
|
|
2638
|
+
control: jsxRuntime.jsx(Checkbox2, {
|
|
2158
2639
|
checked: value.has(option),
|
|
2159
2640
|
onChange: () => onChange(toggle(value, option, singleSelect))
|
|
2160
2641
|
}),
|
|
@@ -2193,7 +2674,6 @@ function debounce(fn, ms) {
|
|
|
2193
2674
|
});
|
|
2194
2675
|
}
|
|
2195
2676
|
function useFilter(impl) {
|
|
2196
|
-
var _a;
|
|
2197
2677
|
const table = useTableContext();
|
|
2198
2678
|
const columnId = useColumnContext();
|
|
2199
2679
|
react.useEffect(() => {
|
|
@@ -2215,7 +2695,7 @@ function useFilter(impl) {
|
|
|
2215
2695
|
state.filters.delete(columnId);
|
|
2216
2696
|
});
|
|
2217
2697
|
};
|
|
2218
|
-
}, [table, columnId,
|
|
2698
|
+
}, [table, columnId, impl]);
|
|
2219
2699
|
const value = table.useState((state) => state.filterValues.get(columnId));
|
|
2220
2700
|
const [dirtyValue, setDirtyValue] = react.useState();
|
|
2221
2701
|
const implRef = react.useRef(impl);
|
|
@@ -2262,21 +2742,21 @@ const termMatch = (text, query) => {
|
|
|
2262
2742
|
}
|
|
2263
2743
|
return true;
|
|
2264
2744
|
};
|
|
2265
|
-
function TextFilter(
|
|
2266
|
-
var
|
|
2745
|
+
function TextFilter(_o) {
|
|
2746
|
+
var _p = _o, {
|
|
2267
2747
|
compare = textMatch,
|
|
2268
2748
|
filterBy = asStringOrArray
|
|
2269
|
-
} =
|
|
2749
|
+
} = _p, props = __objRest(_p, [
|
|
2270
2750
|
"compare",
|
|
2271
2751
|
"filterBy"
|
|
2272
2752
|
]);
|
|
2273
2753
|
const {
|
|
2274
2754
|
components: {
|
|
2275
|
-
IconButton
|
|
2755
|
+
IconButton: IconButton2
|
|
2276
2756
|
},
|
|
2277
2757
|
icons: {
|
|
2278
|
-
Search,
|
|
2279
|
-
Clear
|
|
2758
|
+
Search: Search2,
|
|
2759
|
+
Clear: Clear2
|
|
2280
2760
|
}
|
|
2281
2761
|
} = useTheme();
|
|
2282
2762
|
const {
|
|
@@ -2300,9 +2780,9 @@ function TextFilter(_i) {
|
|
|
2300
2780
|
children: jsxRuntime.jsx(AutoFocusTextField, {
|
|
2301
2781
|
value,
|
|
2302
2782
|
onChange: (e) => onChange(e.target.value),
|
|
2303
|
-
endIcon: jsxRuntime.jsx(
|
|
2783
|
+
endIcon: jsxRuntime.jsx(IconButton2, {
|
|
2304
2784
|
onClick: () => onChange(""),
|
|
2305
|
-
children: !value ? jsxRuntime.jsx(
|
|
2785
|
+
children: !value ? jsxRuntime.jsx(Search2, {}) : jsxRuntime.jsx(Clear2, {})
|
|
2306
2786
|
})
|
|
2307
2787
|
})
|
|
2308
2788
|
});
|
|
@@ -2314,10 +2794,14 @@ exports.mergeThemes = tableTheme.mergeThemes;
|
|
|
2314
2794
|
exports.AutoFocusTextField = AutoFocusTextField;
|
|
2315
2795
|
exports.ColumnContext = ColumnContext;
|
|
2316
2796
|
exports.DateFilter = DateFilter;
|
|
2797
|
+
exports.DatePicker = DatePicker;
|
|
2317
2798
|
exports.SelectFilter = SelectFilter;
|
|
2318
2799
|
exports.Table = Table;
|
|
2319
2800
|
exports.TableContext = TableContext;
|
|
2320
2801
|
exports.TextFilter = TextFilter;
|
|
2802
|
+
exports.dateIntersect = dateIntersect;
|
|
2803
|
+
exports.endOfDay = endOfDay;
|
|
2804
|
+
exports.startOfDay = startOfDay;
|
|
2321
2805
|
exports.termMatch = termMatch;
|
|
2322
2806
|
exports.textMatch = textMatch;
|
|
2323
2807
|
exports.useColumnContext = useColumnContext;
|