schummar-table 1.0.0-beta.2 → 1.0.0-beta.4
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/README.md +10 -1
- package/dist/index.cjs +131 -1888
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -91
- package/dist/index.d.ts +2 -91
- package/dist/index.js +20 -1778
- package/dist/index.js.map +1 -1
- package/dist/mantineTheme.cjs +212 -0
- package/dist/mantineTheme.cjs.map +1 -0
- package/dist/mantineTheme.d.cts +10 -0
- package/dist/mantineTheme.d.ts +10 -0
- package/dist/mantineTheme.js +210 -0
- package/dist/mantineTheme.js.map +1 -0
- package/dist/mui4Theme.d.cts +1 -1
- package/dist/mui4Theme.d.ts +1 -1
- package/dist/mui5Theme.d.cts +1 -1
- package/dist/mui5Theme.d.ts +1 -1
- package/dist/{types-Cppu6jsI.d.cts → types--I5JSyno.d.cts} +104 -6
- package/dist/{types-ZTz8TVGe.d.ts → types-BFFYueFE.d.ts} +104 -6
- package/dist/useTheme-BxEsZbTm.cjs +1985 -0
- package/dist/useTheme-BxEsZbTm.cjs.map +1 -0
- package/dist/useTheme-C2MxW5qw.js +1793 -0
- package/dist/useTheme-C2MxW5qw.js.map +1 -0
- package/package.json +25 -5
- package/skills/schummar-table-upgrade/SKILL.md +44 -2
package/dist/index.cjs
CHANGED
|
@@ -1,664 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
3
2
|
const require_tableTheme = require("./tableTheme-CSqMIpLB.cjs");
|
|
3
|
+
const require_useTheme = require("./useTheme-BxEsZbTm.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
6
6
|
let _emotion_react = require("@emotion/react");
|
|
7
|
-
let _emotion_cache = require("@emotion/cache");
|
|
8
|
-
_emotion_cache = require_rolldown_runtime.__toESM(_emotion_cache, 1);
|
|
9
|
-
let _emotion_serialize = require("@emotion/serialize");
|
|
10
|
-
let _emotion_utils = require("@emotion/utils");
|
|
11
7
|
let react_dom = require("react-dom");
|
|
12
|
-
let temporal_polyfill = require("temporal-polyfill");
|
|
13
|
-
let date_fns = require("date-fns");
|
|
14
8
|
let _tanstack_react_virtual = require("@tanstack/react-virtual");
|
|
15
|
-
//#region src/theme/defaultTheme/defaultColors.ts
|
|
16
|
-
const defaultColors = {
|
|
17
|
-
primary: {
|
|
18
|
-
main: "#1976d2",
|
|
19
|
-
light: "#42a5f5",
|
|
20
|
-
contrastText: "#fff"
|
|
21
|
-
},
|
|
22
|
-
secondary: {
|
|
23
|
-
main: "#9c27b0",
|
|
24
|
-
light: "#ba68c8",
|
|
25
|
-
contrastText: "#fff"
|
|
26
|
-
},
|
|
27
|
-
blocked: {
|
|
28
|
-
main: "#f44336",
|
|
29
|
-
light: "#f26257",
|
|
30
|
-
contrastText: "#fff"
|
|
31
|
-
},
|
|
32
|
-
background: "#ffffff",
|
|
33
|
-
text: "inherit",
|
|
34
|
-
border: "#777",
|
|
35
|
-
borderLight: "#eee"
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/components/spinnner.tsx
|
|
39
|
-
function Spinner({ className }) {
|
|
40
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
41
|
-
className,
|
|
42
|
-
css: _emotion_react.css`
|
|
43
|
-
display: inline-block;
|
|
44
|
-
position: relative;
|
|
45
|
-
width: 1em;
|
|
46
|
-
height: 1em;
|
|
47
|
-
|
|
48
|
-
div {
|
|
49
|
-
box-sizing: border-box;
|
|
50
|
-
display: block;
|
|
51
|
-
position: absolute;
|
|
52
|
-
width: 0.8em;
|
|
53
|
-
height: 0.8em;
|
|
54
|
-
margin: 0.1em;
|
|
55
|
-
border: 0.1em solid #fff;
|
|
56
|
-
border-radius: 50%;
|
|
57
|
-
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
58
|
-
border-color: currentColor transparent transparent transparent;
|
|
59
|
-
}
|
|
60
|
-
div:nth-of-type(1) {
|
|
61
|
-
animation-delay: -0.45s;
|
|
62
|
-
}
|
|
63
|
-
div:nth-of-type(2) {
|
|
64
|
-
animation-delay: -0.3s;
|
|
65
|
-
}
|
|
66
|
-
div:nth-of-type(3) {
|
|
67
|
-
animation-delay: -0.15s;
|
|
68
|
-
}
|
|
69
|
-
@keyframes lds-ring {
|
|
70
|
-
0% {
|
|
71
|
-
transform: rotate(0deg);
|
|
72
|
-
}
|
|
73
|
-
100% {
|
|
74
|
-
transform: rotate(360deg);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
`,
|
|
78
|
-
children: [
|
|
79
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {}),
|
|
80
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {}),
|
|
81
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {})
|
|
82
|
-
]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/theme/defaultTheme/badge.tsx
|
|
87
|
-
const Badge = ({ badgeContent, children }) => {
|
|
88
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("span", {
|
|
89
|
-
css: {
|
|
90
|
-
display: "inline-flex",
|
|
91
|
-
position: "relative",
|
|
92
|
-
flexShrink: 0,
|
|
93
|
-
verticalAlign: "middle"
|
|
94
|
-
},
|
|
95
|
-
children: [children, /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
96
|
-
css: [{
|
|
97
|
-
top: 0,
|
|
98
|
-
right: 0,
|
|
99
|
-
transform: "scale(1) translate(50%, -50%)",
|
|
100
|
-
transformOrigin: "100% 0%",
|
|
101
|
-
height: 20,
|
|
102
|
-
display: "flex",
|
|
103
|
-
padding: "0 6px",
|
|
104
|
-
zIndex: 1,
|
|
105
|
-
position: "absolute",
|
|
106
|
-
flexWrap: "wrap",
|
|
107
|
-
minWidth: 20,
|
|
108
|
-
transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
109
|
-
alignItems: "center",
|
|
110
|
-
lineHeight: 1,
|
|
111
|
-
alignContent: "center",
|
|
112
|
-
borderRadius: 10,
|
|
113
|
-
justifyContent: "center",
|
|
114
|
-
fontSize: "0.8em"
|
|
115
|
-
}, !badgeContent && {
|
|
116
|
-
transform: "scale(0) translate(50%, -50%)",
|
|
117
|
-
transition: "transform 195ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
|
|
118
|
-
}],
|
|
119
|
-
children: badgeContent
|
|
120
|
-
})]
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/theme/defaultTheme/button.tsx
|
|
125
|
-
const Button = ({ startIcon, children, variant = "text", ...props }) => {
|
|
126
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("button", {
|
|
127
|
-
css: [
|
|
128
|
-
{
|
|
129
|
-
padding: `var(--spacing) calc(var(--spacing) * 2)`,
|
|
130
|
-
display: "inline-flex",
|
|
131
|
-
alignItems: "center",
|
|
132
|
-
transition: "background-color 150ms",
|
|
133
|
-
border: "none",
|
|
134
|
-
cursor: "pointer",
|
|
135
|
-
background: "transparent",
|
|
136
|
-
borderRadius: 4,
|
|
137
|
-
"&:active:not(:disabled)": { transform: "scale3d(0.95, 0.95, 1)" }
|
|
138
|
-
},
|
|
139
|
-
variant === "text" && { "&:hover": { background: "rgba(0, 0, 0, 0.1)" } },
|
|
140
|
-
variant === "outlined" && {
|
|
141
|
-
border: "1px solid var(--table-button-border, var(--table-border, #777777))",
|
|
142
|
-
"&:disabled": { borderColor: "var(--table-button-border-disabled, #eeeeee)" }
|
|
143
|
-
},
|
|
144
|
-
variant === "contained" && {
|
|
145
|
-
color: "var(--primaryContrastText)",
|
|
146
|
-
backgroundColor: "var(--primaryMain)",
|
|
147
|
-
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%)",
|
|
148
|
-
"&:hover": { filter: "brightness(0.9)" },
|
|
149
|
-
"&:disabled": {
|
|
150
|
-
filter: "grayscale()",
|
|
151
|
-
opacity: .5
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
...props,
|
|
156
|
-
children: [startIcon && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
157
|
-
css: { marginRight: `calc(var(--spacing) * 2)` },
|
|
158
|
-
children: startIcon
|
|
159
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", { children })]
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/misc/helpers.ts
|
|
164
|
-
var helpers_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
165
|
-
asNumber: () => asNumber,
|
|
166
|
-
asNumberOrArray: () => asNumberOrArray,
|
|
167
|
-
asString: () => asString,
|
|
168
|
-
asStringOrArray: () => asStringOrArray,
|
|
169
|
-
castArray: () => castArray,
|
|
170
|
-
cx: () => cx,
|
|
171
|
-
defaultEquals: () => defaultEquals,
|
|
172
|
-
flatMap: () => flatMap,
|
|
173
|
-
getAncestors: () => getAncestors,
|
|
174
|
-
getDescendants: () => getDescendants,
|
|
175
|
-
identity: () => identity$1,
|
|
176
|
-
intersect: () => intersect,
|
|
177
|
-
isTruthy: () => isTruthy,
|
|
178
|
-
orderBy: () => orderBy,
|
|
179
|
-
subStringMatch: () => subStringMatch,
|
|
180
|
-
toSingles: () => toSingles,
|
|
181
|
-
uniq: () => uniq
|
|
182
|
-
});
|
|
183
|
-
const flatMap = (array, flatMap) => {
|
|
184
|
-
return [...array].flatMap(flatMap);
|
|
185
|
-
};
|
|
186
|
-
const orderBy = (array, selectors = [], direction = [], locale, options) => {
|
|
187
|
-
if (selectors.length === 0) selectors = [(t) => t];
|
|
188
|
-
return [...array].sort((a, b) => {
|
|
189
|
-
for (let i = 0; i < selectors.length; i++) {
|
|
190
|
-
const _a = selectors[i]?.(a);
|
|
191
|
-
const _b = selectors[i]?.(b);
|
|
192
|
-
const _direction = direction[i] === "desc" ? -1 : 1;
|
|
193
|
-
const _locale = locale?.[i];
|
|
194
|
-
const _options = options?.[i];
|
|
195
|
-
if (typeof _a === "string" && typeof _b === "string") {
|
|
196
|
-
const result = _a.localeCompare(_b, _locale, _options);
|
|
197
|
-
if (result !== 0) return result * _direction;
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
if (_a > _b) return _direction;
|
|
201
|
-
if (_a < _b) return -_direction;
|
|
202
|
-
}
|
|
203
|
-
return 0;
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
const uniq = (array) => {
|
|
207
|
-
const set = /* @__PURE__ */ new Set();
|
|
208
|
-
for (const t of array) set.add(t);
|
|
209
|
-
return Array.from(set);
|
|
210
|
-
};
|
|
211
|
-
const intersect = (a, b) => {
|
|
212
|
-
const result = /* @__PURE__ */ new Set();
|
|
213
|
-
for (const x of a) if (b.has(x)) result.add(x);
|
|
214
|
-
return result;
|
|
215
|
-
};
|
|
216
|
-
const getAncestors = (activeItemsById, ...items) => {
|
|
217
|
-
const result = /* @__PURE__ */ new Set();
|
|
218
|
-
const find = ({ parentId }) => {
|
|
219
|
-
const parent = parentId !== void 0 && parentId !== null ? activeItemsById.get(parentId) : void 0;
|
|
220
|
-
if (parent && !result.has(parent.id)) {
|
|
221
|
-
result.add(parent.id);
|
|
222
|
-
find(parent);
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
items.forEach(find);
|
|
226
|
-
return result;
|
|
227
|
-
};
|
|
228
|
-
const getDescendants = (...items) => {
|
|
229
|
-
const result = /* @__PURE__ */ new Set();
|
|
230
|
-
const find = (item) => {
|
|
231
|
-
for (const child of item.children) if (!result.has(child.id)) {
|
|
232
|
-
result.add(child.id);
|
|
233
|
-
find(child);
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
items.forEach(find);
|
|
237
|
-
return result;
|
|
238
|
-
};
|
|
239
|
-
const identity$1 = (x) => x;
|
|
240
|
-
const asString = (x) => {
|
|
241
|
-
if (Array.isArray(x)) return x.map(asString).join(", ");
|
|
242
|
-
if (x === null || x === void 0) return "";
|
|
243
|
-
if (x instanceof Object) return JSON.stringify(x);
|
|
244
|
-
return String(x);
|
|
245
|
-
};
|
|
246
|
-
const asStringOrArray = (x) => {
|
|
247
|
-
if (Array.isArray(x)) return x.map(asString);
|
|
248
|
-
return asString(x);
|
|
249
|
-
};
|
|
250
|
-
const asNumber = (x) => {
|
|
251
|
-
const n = Number(x);
|
|
252
|
-
return Number.isNaN(n) ? null : n;
|
|
253
|
-
};
|
|
254
|
-
const asNumberOrArray = (x) => {
|
|
255
|
-
if (Array.isArray(x)) return x.map(asNumber);
|
|
256
|
-
return asNumber(x);
|
|
257
|
-
};
|
|
258
|
-
const defaultEquals = (a, b) => a === b;
|
|
259
|
-
const subStringMatch = (a, b) => a.toLowerCase().includes(b.toLowerCase());
|
|
260
|
-
const castArray = (a) => Array.isArray(a) ? a : [a];
|
|
261
|
-
const cx = (...classNames) => classNames.flatMap((entry) => {
|
|
262
|
-
if (!entry) return [];
|
|
263
|
-
if (typeof entry === "string") return [entry];
|
|
264
|
-
return Object.entries(entry).filter(([, predicate]) => predicate).map(([className]) => className);
|
|
265
|
-
}).join(" ");
|
|
266
|
-
function isTruthy(x) {
|
|
267
|
-
return !!x;
|
|
268
|
-
}
|
|
269
|
-
/** The single values of a `SingleOrMultiple` value. */
|
|
270
|
-
function toSingles(value) {
|
|
271
|
-
if (Array.isArray(value)) return value;
|
|
272
|
-
if (value instanceof Set) return [...value];
|
|
273
|
-
return [value];
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/theme/emotion.ts
|
|
277
|
-
const isServer = typeof document === "undefined";
|
|
278
|
-
const isSerialized = (x) => typeof x.name === "string" && typeof x.styles === "string";
|
|
279
|
-
/**
|
|
280
|
-
* Turns emotion styles into a class name without re-serializing them on every call: serialized styles
|
|
281
|
-
* are keyed by their hash, objects and functions by identity. Styles are inserted on the client only.
|
|
282
|
-
*/
|
|
283
|
-
function createClassNameOf(cache, theme) {
|
|
284
|
-
const classNames = /* @__PURE__ */ new Map();
|
|
285
|
-
const ids = /* @__PURE__ */ new WeakMap();
|
|
286
|
-
let nextId = 0;
|
|
287
|
-
const keyOf = (style) => {
|
|
288
|
-
if (style === null || style === void 0 || typeof style === "boolean") return "";
|
|
289
|
-
if (typeof style !== "object" && typeof style !== "function") return `${typeof style}:${String(style)}`;
|
|
290
|
-
if (typeof style === "object" && isSerialized(style)) return `s:${style.name}`;
|
|
291
|
-
let id = ids.get(style);
|
|
292
|
-
if (id === void 0) ids.set(style, id = nextId++);
|
|
293
|
-
return `o:${id}`;
|
|
294
|
-
};
|
|
295
|
-
return (...styles) => {
|
|
296
|
-
const key = JSON.stringify(styles.map(keyOf));
|
|
297
|
-
let className = classNames.get(key);
|
|
298
|
-
if (className === void 0) {
|
|
299
|
-
const serialized = (0, _emotion_serialize.serializeStyles)(styles, cache.registered, theme);
|
|
300
|
-
if (!isServer) (0, _emotion_utils.insertStyles)(cache, serialized, false);
|
|
301
|
-
className = serialized.styles ? `${cache.key}-${serialized.name}` : "";
|
|
302
|
-
if (classNames.size > 5e3) classNames.clear();
|
|
303
|
-
classNames.set(key, className);
|
|
304
|
-
}
|
|
305
|
-
return className;
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
let standaloneAppCache;
|
|
309
|
-
const getStandaloneAppCache = () => standaloneAppCache ??= (0, _emotion_cache.default)({ key: "css" });
|
|
310
|
-
const libraryClassNameOf = /* @__PURE__ */ new WeakMap();
|
|
311
|
-
/**
|
|
312
|
-
* For the library's own styles. They go into a separate cache that is prepended to the document, so
|
|
313
|
-
* user styles of equal specificity (emotion or plain CSS) always override them. It inherits the app
|
|
314
|
-
* cache's nonce and container.
|
|
315
|
-
*/
|
|
316
|
-
function useLibraryClassName() {
|
|
317
|
-
const appCache = (0, _emotion_react.__unsafe_useEmotionCache)() ?? getStandaloneAppCache();
|
|
318
|
-
return (0, react.useMemo)(() => {
|
|
319
|
-
let classNameOf = libraryClassNameOf.get(appCache);
|
|
320
|
-
if (!classNameOf) {
|
|
321
|
-
if (!isServer && appCache.sheet.tags.length === 0) (0, _emotion_utils.insertStyles)(appCache, (0, _emotion_serialize.serializeStyles)(["--schummar-table: 1;"]), false);
|
|
322
|
-
classNameOf = createClassNameOf((0, _emotion_cache.default)({
|
|
323
|
-
key: `${appCache.key}-st`,
|
|
324
|
-
prepend: true,
|
|
325
|
-
nonce: appCache.nonce,
|
|
326
|
-
container: appCache.sheet.container
|
|
327
|
-
}), void 0);
|
|
328
|
-
libraryClassNameOf.set(appCache, classNameOf);
|
|
329
|
-
}
|
|
330
|
-
return classNameOf;
|
|
331
|
-
}, [appCache]);
|
|
332
|
-
}
|
|
333
|
-
const userClassNameOf = /* @__PURE__ */ new WeakMap();
|
|
334
|
-
/**
|
|
335
|
-
* For user supplied styles, and for library styles that must beat a theme component's own styles:
|
|
336
|
-
* the app's emotion cache, with its theme for function interpolations.
|
|
337
|
-
*/
|
|
338
|
-
function useUserClassName() {
|
|
339
|
-
const appCache = (0, _emotion_react.__unsafe_useEmotionCache)() ?? getStandaloneAppCache();
|
|
340
|
-
const theme = (0, _emotion_react.useTheme)();
|
|
341
|
-
return (0, react.useMemo)(() => {
|
|
342
|
-
let byTheme = userClassNameOf.get(appCache);
|
|
343
|
-
if (!byTheme) userClassNameOf.set(appCache, byTheme = /* @__PURE__ */ new WeakMap());
|
|
344
|
-
let classNameOf = byTheme.get(theme);
|
|
345
|
-
if (!classNameOf) byTheme.set(theme, classNameOf = createClassNameOf(appCache, theme));
|
|
346
|
-
return classNameOf;
|
|
347
|
-
}, [appCache, theme]);
|
|
348
|
-
}
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/theme/defaultTheme/checkbox.tsx
|
|
351
|
-
const labelCss = (0, _emotion_react.css)({
|
|
352
|
-
padding: "calc(var(--spacing) * 1.8)",
|
|
353
|
-
display: "flex",
|
|
354
|
-
color: "currentcolor",
|
|
355
|
-
userSelect: "none",
|
|
356
|
-
"& input": {
|
|
357
|
-
appearance: "none",
|
|
358
|
-
margin: 0
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
const disabledCss = (0, _emotion_react.css)({ color: "rgba(0, 0, 0, 0.26)" });
|
|
362
|
-
const iconCss = (0, _emotion_react.css)({
|
|
363
|
-
fontSize: "1.25rem",
|
|
364
|
-
width: "1em",
|
|
365
|
-
height: "1em",
|
|
366
|
-
fill: "currentColor"
|
|
367
|
-
});
|
|
368
|
-
const checkedIconCss = (0, _emotion_react.css)({ fill: "var(--primaryMain)" });
|
|
369
|
-
const Checkbox = ({ className, ...props }) => {
|
|
370
|
-
const libraryClass = useLibraryClassName();
|
|
371
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("label", {
|
|
372
|
-
className: cx(libraryClass(labelCss), props.disabled && libraryClass(disabledCss), className),
|
|
373
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("input", {
|
|
374
|
-
type: "checkbox",
|
|
375
|
-
...props
|
|
376
|
-
}), props.checked ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
|
|
377
|
-
className: libraryClass(iconCss, checkedIconCss),
|
|
378
|
-
focusable: "false",
|
|
379
|
-
viewBox: "0 0 24 24",
|
|
380
|
-
"aria-hidden": "true",
|
|
381
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { 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" })
|
|
382
|
-
}) : /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
|
|
383
|
-
className: libraryClass(iconCss),
|
|
384
|
-
focusable: "false",
|
|
385
|
-
viewBox: "0 0 24 24",
|
|
386
|
-
"aria-hidden": "true",
|
|
387
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { 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" })
|
|
388
|
-
})]
|
|
389
|
-
});
|
|
390
|
-
};
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region src/theme/defaultTheme/iconButton.tsx
|
|
393
|
-
const iconButtonCss = (0, _emotion_react.css)({
|
|
394
|
-
padding: "var(--spacing)",
|
|
395
|
-
borderRadius: "50%",
|
|
396
|
-
display: "inline-flex",
|
|
397
|
-
justifyContent: "center",
|
|
398
|
-
alignItems: "center",
|
|
399
|
-
transition: "background-color 150ms",
|
|
400
|
-
border: "none",
|
|
401
|
-
cursor: "pointer",
|
|
402
|
-
color: "inherit",
|
|
403
|
-
background: "transparent",
|
|
404
|
-
"&:hover": { backgroundColor: "rgba(0, 0, 0, 0.04)" },
|
|
405
|
-
"&:active": { transformColor: "scale3d(0.95, 0.95, 1)" }
|
|
406
|
-
});
|
|
407
|
-
const IconButton = ({ className, ...props }) => {
|
|
408
|
-
const libraryClass = useLibraryClassName();
|
|
409
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("button", {
|
|
410
|
-
className: cx(libraryClass(iconButtonCss), className),
|
|
411
|
-
...props
|
|
412
|
-
});
|
|
413
|
-
};
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region src/theme/defaultTheme/textField.tsx
|
|
416
|
-
const TextField = ({ startIcon, endIcon, className, inputRef, onBlur, ...props }) => {
|
|
417
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
418
|
-
className,
|
|
419
|
-
css: [{
|
|
420
|
-
flex: 1,
|
|
421
|
-
display: "flex",
|
|
422
|
-
alignItems: "center",
|
|
423
|
-
border: "1px solid var(--table-textfield-border, var(--table-border, #777777))",
|
|
424
|
-
borderRadius: 4,
|
|
425
|
-
"&:focus-within": {
|
|
426
|
-
border: "2px solid var(--primaryMain)",
|
|
427
|
-
margin: -1
|
|
428
|
-
}
|
|
429
|
-
}],
|
|
430
|
-
children: [
|
|
431
|
-
startIcon,
|
|
432
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("input", {
|
|
433
|
-
ref: inputRef,
|
|
434
|
-
...props,
|
|
435
|
-
value: props.value ?? "",
|
|
436
|
-
onBlur,
|
|
437
|
-
css: {
|
|
438
|
-
minWidth: 0,
|
|
439
|
-
width: "100%",
|
|
440
|
-
flex: 1,
|
|
441
|
-
border: "none",
|
|
442
|
-
outline: "none",
|
|
443
|
-
borderRadius: 4,
|
|
444
|
-
padding: "calc(var(--spacing) * 2)",
|
|
445
|
-
paddingLeft: startIcon ? 0 : void 0,
|
|
446
|
-
paddingRight: endIcon ? 0 : void 0,
|
|
447
|
-
transition: "outline 500ms"
|
|
448
|
-
}
|
|
449
|
-
}),
|
|
450
|
-
endIcon
|
|
451
|
-
]
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
//#endregion
|
|
455
|
-
//#region src/theme/defaultTheme/defaultComponents.ts
|
|
456
|
-
const defaultComponents = {
|
|
457
|
-
IconButton,
|
|
458
|
-
Checkbox,
|
|
459
|
-
Popover: require_tableTheme.Popover,
|
|
460
|
-
Button,
|
|
461
|
-
Badge,
|
|
462
|
-
TextField,
|
|
463
|
-
Spinner
|
|
464
|
-
};
|
|
465
|
-
//#endregion
|
|
466
|
-
//#region src/theme/defaultTheme/defaultIcons.tsx
|
|
467
|
-
const IconDefaultStyle = (0, _emotion_react.css)({
|
|
468
|
-
width: "1.5em",
|
|
469
|
-
height: "1.5em",
|
|
470
|
-
color: "inherit"
|
|
471
|
-
});
|
|
472
|
-
function Icon(svg) {
|
|
473
|
-
return function IconComponent(props) {
|
|
474
|
-
const libraryClass = useLibraryClassName();
|
|
475
|
-
return (0, react.cloneElement)(svg, {
|
|
476
|
-
...props,
|
|
477
|
-
className: cx(libraryClass(IconDefaultStyle), props.className)
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region src/theme/defaultTheme/index.tsx
|
|
483
|
-
const defaultTableTheme = {
|
|
484
|
-
text: {
|
|
485
|
-
selectColumns: "Select visible columns",
|
|
486
|
-
showAllColumns: "Show all",
|
|
487
|
-
hideAllColumns: "Hide all",
|
|
488
|
-
noResults: "No results",
|
|
489
|
-
exportTitle: "Export",
|
|
490
|
-
exportCopy: "To clipboard",
|
|
491
|
-
exportDownload: "Download",
|
|
492
|
-
today: "Today",
|
|
493
|
-
thisWeek: "This week",
|
|
494
|
-
thisMonth: "This month",
|
|
495
|
-
thisYear: "This year",
|
|
496
|
-
lastSevenDays: "Last 7 days",
|
|
497
|
-
lastThirtyDays: "Last 30 days",
|
|
498
|
-
clearFilters: "Clear all filters",
|
|
499
|
-
reset: "Reset",
|
|
500
|
-
loading: "Loading",
|
|
501
|
-
deselectAll: "Deselect all",
|
|
502
|
-
resetAll: "Reset table state",
|
|
503
|
-
rangeMin: "Min",
|
|
504
|
-
rangeMax: "Max",
|
|
505
|
-
calendarWeek: "Wk",
|
|
506
|
-
hiddenColumnFilters: "Filters of hidden columns"
|
|
507
|
-
},
|
|
508
|
-
components: defaultComponents,
|
|
509
|
-
icons: {
|
|
510
|
-
Settings: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
511
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
512
|
-
height: "24px",
|
|
513
|
-
viewBox: "0 0 24 24",
|
|
514
|
-
width: "24px",
|
|
515
|
-
fill: "currentColor",
|
|
516
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
517
|
-
d: "M0 0h24v24H0V0z",
|
|
518
|
-
fill: "none"
|
|
519
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { d: "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z" })]
|
|
520
|
-
})),
|
|
521
|
-
Export: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
522
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
523
|
-
enableBackground: "new 0 0 24 24",
|
|
524
|
-
height: "24px",
|
|
525
|
-
viewBox: "0 0 24 24",
|
|
526
|
-
width: "24px",
|
|
527
|
-
fill: "currentColor",
|
|
528
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("g", { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("rect", {
|
|
529
|
-
fill: "none",
|
|
530
|
-
height: "24",
|
|
531
|
-
width: "24"
|
|
532
|
-
}) }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("g", { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { 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" }) })]
|
|
533
|
-
})),
|
|
534
|
-
Clipboard: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
535
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
536
|
-
height: "24px",
|
|
537
|
-
viewBox: "0 0 24 24",
|
|
538
|
-
width: "24px",
|
|
539
|
-
fill: "currentColor",
|
|
540
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
541
|
-
d: "M0 0h24v24H0V0z",
|
|
542
|
-
fill: "none"
|
|
543
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { 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" })]
|
|
544
|
-
})),
|
|
545
|
-
ChevronRight: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
546
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
547
|
-
height: "24px",
|
|
548
|
-
viewBox: "0 0 24 24",
|
|
549
|
-
width: "24px",
|
|
550
|
-
fill: "currentColor",
|
|
551
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
552
|
-
d: "M0 0h24v24H0V0z",
|
|
553
|
-
fill: "none"
|
|
554
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z" })]
|
|
555
|
-
})),
|
|
556
|
-
Search: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
557
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
558
|
-
height: "24px",
|
|
559
|
-
viewBox: "0 0 24 24",
|
|
560
|
-
width: "24px",
|
|
561
|
-
fill: "currentColor",
|
|
562
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
563
|
-
d: "M0 0h24v24H0V0z",
|
|
564
|
-
fill: "none"
|
|
565
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { 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" })]
|
|
566
|
-
})),
|
|
567
|
-
Clear: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
568
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
569
|
-
height: "24px",
|
|
570
|
-
viewBox: "0 0 24 24",
|
|
571
|
-
width: "24px",
|
|
572
|
-
fill: "currentColor",
|
|
573
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
574
|
-
d: "M0 0h24v24H0V0z",
|
|
575
|
-
fill: "none"
|
|
576
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { 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" })]
|
|
577
|
-
})),
|
|
578
|
-
ArrowDropDown: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
579
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
580
|
-
height: "24px",
|
|
581
|
-
viewBox: "0 0 24 24",
|
|
582
|
-
width: "24px",
|
|
583
|
-
fill: "currentColor",
|
|
584
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
585
|
-
d: "M0 0h24v24H0V0z",
|
|
586
|
-
fill: "none"
|
|
587
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { d: "M7 10l5 5 5-5H7z" })]
|
|
588
|
-
})),
|
|
589
|
-
FilterList: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
|
|
590
|
-
viewBox: "0 0 24 24",
|
|
591
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
592
|
-
fill: "currentColor",
|
|
593
|
-
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"
|
|
594
|
-
})
|
|
595
|
-
})),
|
|
596
|
-
ArrowUpward: Icon(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("svg", {
|
|
597
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
598
|
-
height: "24px",
|
|
599
|
-
viewBox: "0 0 24 24",
|
|
600
|
-
width: "24px",
|
|
601
|
-
fill: "currentColor",
|
|
602
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", {
|
|
603
|
-
d: "M0 0h24v24H0V0z",
|
|
604
|
-
fill: "none"
|
|
605
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" })]
|
|
606
|
-
}))
|
|
607
|
-
},
|
|
608
|
-
colors: defaultColors,
|
|
609
|
-
spacing: "5px"
|
|
610
|
-
};
|
|
611
|
-
//#endregion
|
|
612
|
-
//#region src/hooks/useTheme.ts
|
|
613
|
-
const ThemeContext = (0, react.createContext)(null);
|
|
614
|
-
/** default < TableSettingsProvider < table props, merged once per change instead of per consumer. */
|
|
615
|
-
function useTableTheme(props) {
|
|
616
|
-
const { theme: contextTheme } = (0, react.useContext)(require_tableTheme.TableSettingsContext);
|
|
617
|
-
const { text, classes, styles, components, icons, colors, spacing } = props;
|
|
618
|
-
return (0, react.useMemo)(() => require_tableTheme.mergeThemes(defaultTableTheme, contextTheme, {
|
|
619
|
-
text,
|
|
620
|
-
classes,
|
|
621
|
-
styles,
|
|
622
|
-
components,
|
|
623
|
-
icons,
|
|
624
|
-
colors,
|
|
625
|
-
spacing
|
|
626
|
-
}), [
|
|
627
|
-
contextTheme,
|
|
628
|
-
text,
|
|
629
|
-
classes,
|
|
630
|
-
styles,
|
|
631
|
-
components,
|
|
632
|
-
icons,
|
|
633
|
-
colors,
|
|
634
|
-
spacing
|
|
635
|
-
]);
|
|
636
|
-
}
|
|
637
|
-
function useTheme(selector) {
|
|
638
|
-
const tableTheme = (0, react.useContext)(ThemeContext);
|
|
639
|
-
const { theme: contextTheme } = (0, react.useContext)(require_tableTheme.TableSettingsContext);
|
|
640
|
-
const fallback = (0, react.useMemo)(() => tableTheme ? void 0 : require_tableTheme.mergeThemes(defaultTableTheme, contextTheme), [tableTheme, contextTheme]);
|
|
641
|
-
return selector(tableTheme ?? fallback);
|
|
642
|
-
}
|
|
643
|
-
/** The theme with a column's own classes and styles layered on top. */
|
|
644
|
-
function columnTheme(theme, column) {
|
|
645
|
-
if (!column?.classes && !column?.styles) return theme;
|
|
646
|
-
return {
|
|
647
|
-
...theme,
|
|
648
|
-
classes: {
|
|
649
|
-
...theme.classes,
|
|
650
|
-
...column.classes
|
|
651
|
-
},
|
|
652
|
-
styles: {
|
|
653
|
-
...theme.styles,
|
|
654
|
-
...column.styles
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
//#endregion
|
|
659
9
|
//#region src/components/autoFocusTextField.tsx
|
|
660
10
|
function AutoFocusTextField(props) {
|
|
661
|
-
const TextField = useTheme((t) => t.components.TextField);
|
|
11
|
+
const TextField = require_useTheme.useTheme((t) => t.components.TextField);
|
|
662
12
|
const ref = (0, react.useRef)(null);
|
|
663
13
|
(0, react.useLayoutEffect)(() => {
|
|
664
14
|
const timeout = setTimeout(() => ref.current?.focus());
|
|
@@ -674,1120 +24,6 @@ function AutoFocusTextField(props) {
|
|
|
674
24
|
});
|
|
675
25
|
}
|
|
676
26
|
//#endregion
|
|
677
|
-
//#region src/misc/defaults.ts
|
|
678
|
-
function defaults(first, ...more) {
|
|
679
|
-
return more.reduce((acc, source) => {
|
|
680
|
-
const copy = { ...acc };
|
|
681
|
-
for (const [key, value] of Object.entries(source)) copy[key] ??= value;
|
|
682
|
-
return copy;
|
|
683
|
-
}, first);
|
|
684
|
-
}
|
|
685
|
-
//#endregion
|
|
686
|
-
//#region src/theme/useCssVariables.ts
|
|
687
|
-
function useCssVariables() {
|
|
688
|
-
return useTheme(({ spacing, colors }) => {
|
|
689
|
-
return {
|
|
690
|
-
"--spacing": spacing,
|
|
691
|
-
"--primaryMain": colors.primary.main,
|
|
692
|
-
"--primaryLight": colors.primary.light,
|
|
693
|
-
"--primaryContrastText": colors.primary.contrastText,
|
|
694
|
-
"--secondaryMain": colors.secondary.main,
|
|
695
|
-
"--secondaryLight": colors.secondary.light,
|
|
696
|
-
"--secondaryContrastText": colors.secondary.contrastText,
|
|
697
|
-
"--blockedMain": colors.blocked.main,
|
|
698
|
-
"--blockedLight": colors.blocked.light,
|
|
699
|
-
"--blockedContrastText": colors.blocked.contrastText,
|
|
700
|
-
"--table-background-color": colors.background,
|
|
701
|
-
"--table-text-color": colors.text,
|
|
702
|
-
"--table-border-color": colors.border,
|
|
703
|
-
"--table-border-light-color": colors.borderLight
|
|
704
|
-
};
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
//#endregion
|
|
708
|
-
//#region src/vendor/dayzed/utils.ts
|
|
709
|
-
/**
|
|
710
|
-
* This is intended to be used to compose event handlers
|
|
711
|
-
* They are executed in order until one of them calls
|
|
712
|
-
* `event.preventDefault()`. Not sure this is the best
|
|
713
|
-
* way to do this, but it seems legit...
|
|
714
|
-
* @param {Function} fns the event hanlder functions
|
|
715
|
-
* @return {Function} the event handler to add to an element
|
|
716
|
-
*/
|
|
717
|
-
function composeEventHandlers(...fns) {
|
|
718
|
-
return (event, ...args) => fns.some((fn) => {
|
|
719
|
-
if (fn) fn(event, ...args);
|
|
720
|
-
return event.defaultPrevented;
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Throws a helpful error message for required properties. Useful
|
|
725
|
-
* to be used as a default in destructuring or object params.
|
|
726
|
-
* @param {String} fnName the function name
|
|
727
|
-
* @param {String} propName the prop name
|
|
728
|
-
*/
|
|
729
|
-
function requiredProp(fnName, propName) {
|
|
730
|
-
throw new Error(`The property "${propName}" is required in "${fnName}"`);
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Takes a calendars array and figures out the number of months to subtract
|
|
734
|
-
* based on the current offset and the minDate allowed.
|
|
735
|
-
* @param {Object} param The param object
|
|
736
|
-
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
737
|
-
* @param {Number} param.offset The num of months to be subtracted
|
|
738
|
-
* @param {Date} param.minDate The earliest date we are allow to subtract back to
|
|
739
|
-
* @returns {Number} The number of months to subtract
|
|
740
|
-
*/
|
|
741
|
-
function subtractMonth({ calendars, offset, minDate }) {
|
|
742
|
-
if (offset > 1 && minDate) {
|
|
743
|
-
const { firstDayOfMonth } = calendars[0];
|
|
744
|
-
const diffInMonths = (0, date_fns.differenceInCalendarMonths)(firstDayOfMonth, minDate);
|
|
745
|
-
if (diffInMonths < offset) offset = diffInMonths;
|
|
746
|
-
}
|
|
747
|
-
return offset;
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Takes a calendars array and figures out the number of months to add
|
|
751
|
-
* based on the current offset and the maxDate allowed.
|
|
752
|
-
* @param {Object} param The param object
|
|
753
|
-
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
754
|
-
* @param {Number} param.offset The num of months to be added
|
|
755
|
-
* @param {Date} param.maxDate The furthest date we are allow to add forward to
|
|
756
|
-
* @returns {Number} The number of months to add
|
|
757
|
-
*/
|
|
758
|
-
function addMonth({ calendars, offset, maxDate }) {
|
|
759
|
-
if (offset > 1 && maxDate) {
|
|
760
|
-
const { lastDayOfMonth } = calendars[calendars.length - 1];
|
|
761
|
-
const diffInMonths = (0, date_fns.differenceInCalendarMonths)(maxDate, lastDayOfMonth);
|
|
762
|
-
if (diffInMonths < offset) offset = diffInMonths;
|
|
763
|
-
}
|
|
764
|
-
return offset;
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* Takes a calendars array and figures out if the back button should be
|
|
768
|
-
* disabled based on the minDate allowed.
|
|
769
|
-
* @param {Object} param The param object
|
|
770
|
-
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
771
|
-
* @param {Date} param.minDate The earliest date available
|
|
772
|
-
* @returns {Boolean} Whether the back button should be disabled.
|
|
773
|
-
*/
|
|
774
|
-
function isBackDisabled({ calendars, minDate }) {
|
|
775
|
-
if (!minDate) return false;
|
|
776
|
-
const { firstDayOfMonth } = calendars[0];
|
|
777
|
-
const firstDayOfMonthMinusOne = (0, date_fns.addDays)(firstDayOfMonth, -1);
|
|
778
|
-
if ((0, date_fns.isBefore)(firstDayOfMonthMinusOne, minDate)) return true;
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Takes a calendars array and figures out if the forward button should be
|
|
783
|
-
* disabled based on the maxDate allowed.
|
|
784
|
-
* @param {Object} param The param object
|
|
785
|
-
* @param {Array} param.calendars The calendars array created by the getCalendars function
|
|
786
|
-
* @param {Date} param.maxDate The furthest date available
|
|
787
|
-
* @returns {Boolean} Whether the forward button should be disabled.
|
|
788
|
-
*/
|
|
789
|
-
function isForwardDisabled({ calendars, maxDate }) {
|
|
790
|
-
if (!maxDate) return false;
|
|
791
|
-
const { lastDayOfMonth } = calendars[calendars.length - 1];
|
|
792
|
-
const lastDayOfMonthPlusOne = (0, date_fns.addDays)(lastDayOfMonth, 1);
|
|
793
|
-
if ((0, date_fns.isBefore)(maxDate, lastDayOfMonthPlusOne)) return true;
|
|
794
|
-
return false;
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Figures out the months data needed based off the number of monthsToDisplay
|
|
798
|
-
* and other options provided.
|
|
799
|
-
* @param {Object} param The param object
|
|
800
|
-
* @param {Date} param.date The date to start the calendar at
|
|
801
|
-
* @param {Array.<Date>} param.selected An array of dates currently selected
|
|
802
|
-
* @param {Number} param.monthsToDisplay The number of months to return in the calendar view
|
|
803
|
-
* @param {Number} param.offset The number of months to offset based off the param.date given
|
|
804
|
-
* @param {Date} param.minDate The earliest date available
|
|
805
|
-
* @param {Date} param.maxDate The furthest date available
|
|
806
|
-
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
807
|
-
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
808
|
-
* @returns {Array.<Object>} An array of objects with month data
|
|
809
|
-
*/
|
|
810
|
-
function getCalendars({ date, selected, monthsToDisplay, offset, minDate, maxDate, firstDayOfWeek, showOutsideDays }) {
|
|
811
|
-
const months = [];
|
|
812
|
-
const startDate = getStartDate(date, minDate, maxDate);
|
|
813
|
-
for (let i = 0; i < monthsToDisplay; i++) {
|
|
814
|
-
const calendarDates = getMonths({
|
|
815
|
-
month: startDate.getMonth() + i + offset,
|
|
816
|
-
year: startDate.getFullYear(),
|
|
817
|
-
selectedDates: selected,
|
|
818
|
-
minDate,
|
|
819
|
-
maxDate,
|
|
820
|
-
firstDayOfWeek,
|
|
821
|
-
showOutsideDays
|
|
822
|
-
});
|
|
823
|
-
months.push(calendarDates);
|
|
824
|
-
}
|
|
825
|
-
return months;
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* Figures out the actual start date based on
|
|
829
|
-
* the min and max dates available.
|
|
830
|
-
* @param {Date} date The we want to start the calendar at
|
|
831
|
-
* @param {Date} minDate The earliest date available to start at
|
|
832
|
-
* @param {Date} maxDate The latest date available to start at
|
|
833
|
-
* @returns {Date} The actual start date
|
|
834
|
-
*/
|
|
835
|
-
function getStartDate(date, minDate, maxDate) {
|
|
836
|
-
let startDate = (0, date_fns.startOfDay)(date);
|
|
837
|
-
if (minDate) {
|
|
838
|
-
const minDateNormalized = (0, date_fns.startOfDay)(minDate);
|
|
839
|
-
if ((0, date_fns.isBefore)(startDate, minDateNormalized)) startDate = minDateNormalized;
|
|
840
|
-
}
|
|
841
|
-
if (maxDate) {
|
|
842
|
-
const maxDateNormalized = (0, date_fns.startOfDay)(maxDate);
|
|
843
|
-
if ((0, date_fns.isBefore)(maxDateNormalized, startDate)) startDate = maxDateNormalized;
|
|
844
|
-
}
|
|
845
|
-
return startDate;
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Figures what week/day data to return for the given month
|
|
849
|
-
* and year. Adds flags to day data if found in the given selectedDates,
|
|
850
|
-
* if is selectable inside the given min and max dates, or is today.
|
|
851
|
-
* @param {Object} param The param object
|
|
852
|
-
* @param {Number} param.month The month to grab data for
|
|
853
|
-
* @param {Number} param.year The year to grab data for
|
|
854
|
-
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
855
|
-
* @param {Date} param.minDate The earliest date available
|
|
856
|
-
* @param {Date} param.maxDate The furthest date available
|
|
857
|
-
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
858
|
-
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
859
|
-
* @returns {Object} The data for the selected month/year
|
|
860
|
-
*/
|
|
861
|
-
function getMonths({ month, year, selectedDates, minDate, maxDate, firstDayOfWeek, showOutsideDays }) {
|
|
862
|
-
const daysMonthYear = getNumDaysMonthYear(month, year);
|
|
863
|
-
const daysInMonth = daysMonthYear.daysInMonth;
|
|
864
|
-
month = daysMonthYear.month;
|
|
865
|
-
year = daysMonthYear.year;
|
|
866
|
-
const dates = [];
|
|
867
|
-
for (let day = 1; day <= daysInMonth; day++) {
|
|
868
|
-
const date = new Date(year, month, day);
|
|
869
|
-
const dateObj = {
|
|
870
|
-
date,
|
|
871
|
-
selected: isSelected(selectedDates, date),
|
|
872
|
-
selectable: isSelectable(minDate, maxDate, date),
|
|
873
|
-
today: (0, date_fns.isToday)(date),
|
|
874
|
-
prevMonth: false,
|
|
875
|
-
nextMonth: false
|
|
876
|
-
};
|
|
877
|
-
dates.push(dateObj);
|
|
878
|
-
}
|
|
879
|
-
const firstDayOfMonth = new Date(year, month, 1);
|
|
880
|
-
const lastDayOfMonth = new Date(year, month, daysInMonth);
|
|
881
|
-
const frontWeekBuffer = fillFrontWeek({
|
|
882
|
-
firstDayOfMonth,
|
|
883
|
-
minDate,
|
|
884
|
-
maxDate,
|
|
885
|
-
selectedDates,
|
|
886
|
-
firstDayOfWeek,
|
|
887
|
-
showOutsideDays
|
|
888
|
-
});
|
|
889
|
-
const backWeekBuffer = fillBackWeek({
|
|
890
|
-
lastDayOfMonth,
|
|
891
|
-
minDate,
|
|
892
|
-
maxDate,
|
|
893
|
-
selectedDates,
|
|
894
|
-
firstDayOfWeek,
|
|
895
|
-
showOutsideDays
|
|
896
|
-
});
|
|
897
|
-
dates.unshift(...frontWeekBuffer);
|
|
898
|
-
dates.push(...backWeekBuffer);
|
|
899
|
-
const weeks = getWeeks(dates);
|
|
900
|
-
return {
|
|
901
|
-
firstDayOfMonth,
|
|
902
|
-
lastDayOfMonth,
|
|
903
|
-
month,
|
|
904
|
-
year,
|
|
905
|
-
weeks
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Fill front week with either empty buffer or dates from previous month,
|
|
910
|
-
* depending on showOutsideDays flag
|
|
911
|
-
* @param {Object} param The param object
|
|
912
|
-
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
913
|
-
* @param {Date} param.minDate The earliest date available
|
|
914
|
-
* @param {Date} param.maxDate The furthest date available
|
|
915
|
-
* @param {Date} param.firstDayOfMonth First day of the month
|
|
916
|
-
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
917
|
-
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
918
|
-
* @returns {Array.<Date>} Buffer to fill front week
|
|
919
|
-
*/
|
|
920
|
-
function fillFrontWeek({ firstDayOfMonth, minDate, maxDate, selectedDates, firstDayOfWeek, showOutsideDays }) {
|
|
921
|
-
const dates = [];
|
|
922
|
-
let firstDay = (firstDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
923
|
-
if (showOutsideDays) {
|
|
924
|
-
const lastDayOfPrevMonth = (0, date_fns.addDays)(firstDayOfMonth, -1);
|
|
925
|
-
const prevDate = lastDayOfPrevMonth.getDate();
|
|
926
|
-
const prevDateMonth = lastDayOfPrevMonth.getMonth();
|
|
927
|
-
const prevDateYear = lastDayOfPrevMonth.getFullYear();
|
|
928
|
-
let counter = 0;
|
|
929
|
-
while (counter < firstDay) {
|
|
930
|
-
const date = new Date(prevDateYear, prevDateMonth, prevDate - counter);
|
|
931
|
-
const dateObj = {
|
|
932
|
-
date,
|
|
933
|
-
selected: isSelected(selectedDates, date),
|
|
934
|
-
selectable: isSelectable(minDate, maxDate, date),
|
|
935
|
-
today: false,
|
|
936
|
-
prevMonth: true,
|
|
937
|
-
nextMonth: false
|
|
938
|
-
};
|
|
939
|
-
dates.unshift(dateObj);
|
|
940
|
-
counter++;
|
|
941
|
-
}
|
|
942
|
-
} else while (firstDay > 0) {
|
|
943
|
-
dates.unshift("");
|
|
944
|
-
firstDay--;
|
|
945
|
-
}
|
|
946
|
-
return dates;
|
|
947
|
-
}
|
|
948
|
-
/**
|
|
949
|
-
* Fill back weeks with either empty buffer or dates from next month,
|
|
950
|
-
* depending on showOutsideDays flag
|
|
951
|
-
* @param {Object} param The param object
|
|
952
|
-
* @param {Array.<Date>} param.selectedDates An array of dates currently selected
|
|
953
|
-
* @param {Date} param.minDate The earliest date available
|
|
954
|
-
* @param {Date} param.maxDate The furthest date available
|
|
955
|
-
* @param {Date} param.lastDayOfMonth Last day of the month
|
|
956
|
-
* @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)
|
|
957
|
-
* @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months
|
|
958
|
-
* @returns {Array.<Date>} Buffer to fill back week
|
|
959
|
-
*/
|
|
960
|
-
function fillBackWeek({ lastDayOfMonth, minDate, maxDate, selectedDates, firstDayOfWeek, showOutsideDays }) {
|
|
961
|
-
const dates = [];
|
|
962
|
-
let lastDay = (lastDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
|
|
963
|
-
if (showOutsideDays) {
|
|
964
|
-
const firstDayOfNextMonth = (0, date_fns.addDays)(lastDayOfMonth, 1);
|
|
965
|
-
const nextDateMonth = firstDayOfNextMonth.getMonth();
|
|
966
|
-
const nextDateYear = firstDayOfNextMonth.getFullYear();
|
|
967
|
-
let counter = 0;
|
|
968
|
-
while (counter < 6 - lastDay) {
|
|
969
|
-
const date = new Date(nextDateYear, nextDateMonth, 1 + counter);
|
|
970
|
-
const dateObj = {
|
|
971
|
-
date,
|
|
972
|
-
selected: isSelected(selectedDates, date),
|
|
973
|
-
selectable: isSelectable(minDate, maxDate, date),
|
|
974
|
-
today: false,
|
|
975
|
-
prevMonth: false,
|
|
976
|
-
nextMonth: true
|
|
977
|
-
};
|
|
978
|
-
dates.push(dateObj);
|
|
979
|
-
counter++;
|
|
980
|
-
}
|
|
981
|
-
} else while (lastDay < 6) {
|
|
982
|
-
dates.push("");
|
|
983
|
-
lastDay++;
|
|
984
|
-
}
|
|
985
|
-
return dates;
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* Normalizes month (could be overflow) and year pairs and returns the
|
|
989
|
-
* normalized month and year along with the number of days in the month.
|
|
990
|
-
* @param {Number} month The month to normalize
|
|
991
|
-
* @param {Number} year The year to normalize
|
|
992
|
-
* @returns {Object} The normalized month and year along with the number of days in the month
|
|
993
|
-
*/
|
|
994
|
-
function getNumDaysMonthYear(month, year) {
|
|
995
|
-
const normalizedMonthYear = new Date(year, month, 1);
|
|
996
|
-
month = normalizedMonthYear.getMonth();
|
|
997
|
-
year = normalizedMonthYear.getFullYear();
|
|
998
|
-
return {
|
|
999
|
-
daysInMonth: 32 - new Date(year, month, 32).getDate(),
|
|
1000
|
-
month,
|
|
1001
|
-
year
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Takes an array of dates, and turns them into a multi dimensional
|
|
1006
|
-
* array with 7 entries for each week.
|
|
1007
|
-
* @param {Array.<Object>} dates An array of dates
|
|
1008
|
-
* @returns {Array} The weeks as a multi dimensional array
|
|
1009
|
-
*/
|
|
1010
|
-
function getWeeks(dates) {
|
|
1011
|
-
const weeksLength = Math.ceil(dates.length / 7);
|
|
1012
|
-
const weeks = [];
|
|
1013
|
-
for (let i = 0; i < weeksLength; i++) {
|
|
1014
|
-
weeks[i] = [];
|
|
1015
|
-
for (let x = 0; x < 7; x++) weeks[i].push(dates[i * 7 + x]);
|
|
1016
|
-
}
|
|
1017
|
-
return weeks;
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* Normalizes dates to the beginning of the day,
|
|
1021
|
-
* then checks to see if the day given is found
|
|
1022
|
-
* in the selectedDates.
|
|
1023
|
-
* @param {Array.<Date>} selectedDates An array of dates currently selected
|
|
1024
|
-
* @param {Date} date The date to search with against selectedDates
|
|
1025
|
-
* @returns {Boolean} Whether day is found in selectedDates
|
|
1026
|
-
*/
|
|
1027
|
-
function isSelected(selectedDates, date) {
|
|
1028
|
-
selectedDates = Array.isArray(selectedDates) ? selectedDates : [selectedDates];
|
|
1029
|
-
return selectedDates.some((selectedDate) => {
|
|
1030
|
-
if (selectedDate instanceof Date && (0, date_fns.startOfDay)(selectedDate).getTime() === (0, date_fns.startOfDay)(date).getTime()) return true;
|
|
1031
|
-
return false;
|
|
1032
|
-
});
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* Checks to see if the date given is
|
|
1036
|
-
* between the min and max dates.
|
|
1037
|
-
* @param {Date} minDate The earliest date available
|
|
1038
|
-
* @param {Date} maxDate The furthest date available
|
|
1039
|
-
* @param {Date} date The date to compare with
|
|
1040
|
-
* @returns {Boolean} Whether the date is between min and max date
|
|
1041
|
-
*/
|
|
1042
|
-
function isSelectable(minDate, maxDate, date) {
|
|
1043
|
-
if (minDate && (0, date_fns.isBefore)(date, minDate) || maxDate && (0, date_fns.isBefore)(maxDate, date)) return false;
|
|
1044
|
-
return true;
|
|
1045
|
-
}
|
|
1046
|
-
//#endregion
|
|
1047
|
-
//#region src/vendor/dayzed/dayzed.ts
|
|
1048
|
-
function isOffsetControlled(propOffset) {
|
|
1049
|
-
return propOffset !== void 0;
|
|
1050
|
-
}
|
|
1051
|
-
function getOffset(prop, state) {
|
|
1052
|
-
return isOffsetControlled(prop) ? prop : state;
|
|
1053
|
-
}
|
|
1054
|
-
function getDateProps(onDateSelected, { onClick, dateObj = requiredProp("getDateProps", "dateObj"), ...rest } = {}) {
|
|
1055
|
-
return {
|
|
1056
|
-
onClick: composeEventHandlers(onClick, (event) => {
|
|
1057
|
-
onDateSelected?.(dateObj, event);
|
|
1058
|
-
}),
|
|
1059
|
-
disabled: !dateObj.selectable,
|
|
1060
|
-
"aria-label": dateObj.date.toDateString(),
|
|
1061
|
-
"aria-pressed": dateObj.selected,
|
|
1062
|
-
role: "button",
|
|
1063
|
-
...rest
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
function getBackProps({ minDate, offsetMonth, handleOffsetChanged }, { onClick, offset = 1, calendars = requiredProp("getBackProps", "calendars"), ...rest } = {}) {
|
|
1067
|
-
return {
|
|
1068
|
-
onClick: composeEventHandlers(onClick, () => {
|
|
1069
|
-
handleOffsetChanged(offsetMonth - subtractMonth({
|
|
1070
|
-
calendars,
|
|
1071
|
-
offset,
|
|
1072
|
-
minDate
|
|
1073
|
-
}));
|
|
1074
|
-
}),
|
|
1075
|
-
disabled: isBackDisabled({
|
|
1076
|
-
calendars,
|
|
1077
|
-
minDate
|
|
1078
|
-
}),
|
|
1079
|
-
"aria-label": `Go back ${offset} month${offset === 1 ? "" : "s"}`,
|
|
1080
|
-
...rest
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
function getForwardProps({ maxDate, offsetMonth, handleOffsetChanged }, { onClick, offset = 1, calendars = requiredProp("getForwardProps", "calendars"), ...rest } = {}) {
|
|
1084
|
-
return {
|
|
1085
|
-
onClick: composeEventHandlers(onClick, () => {
|
|
1086
|
-
handleOffsetChanged(offsetMonth + addMonth({
|
|
1087
|
-
calendars,
|
|
1088
|
-
offset,
|
|
1089
|
-
maxDate
|
|
1090
|
-
}));
|
|
1091
|
-
}),
|
|
1092
|
-
disabled: isForwardDisabled({
|
|
1093
|
-
calendars,
|
|
1094
|
-
maxDate
|
|
1095
|
-
}),
|
|
1096
|
-
"aria-label": `Go forward ${offset} month${offset === 1 ? "" : "s"}`,
|
|
1097
|
-
...rest
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
function useDayzed({ date = /* @__PURE__ */ new Date(), maxDate, minDate, monthsToDisplay = 1, firstDayOfWeek = 0, showOutsideDays = false, offset, onDateSelected, onOffsetChanged = () => {}, selected }) {
|
|
1101
|
-
const [stateOffset, setStateOffset] = (0, react.useState)(0);
|
|
1102
|
-
const offsetMonth = getOffset(offset, stateOffset);
|
|
1103
|
-
function handleOffsetChanged(newOffset) {
|
|
1104
|
-
if (!isOffsetControlled(offset)) setStateOffset(newOffset);
|
|
1105
|
-
onOffsetChanged(newOffset);
|
|
1106
|
-
}
|
|
1107
|
-
return {
|
|
1108
|
-
calendars: getCalendars({
|
|
1109
|
-
date,
|
|
1110
|
-
selected: Array.isArray(selected) ? selected : selected ? [selected] : [],
|
|
1111
|
-
monthsToDisplay,
|
|
1112
|
-
minDate,
|
|
1113
|
-
maxDate,
|
|
1114
|
-
offset: offsetMonth,
|
|
1115
|
-
firstDayOfWeek,
|
|
1116
|
-
showOutsideDays
|
|
1117
|
-
}),
|
|
1118
|
-
getDateProps: getDateProps.bind(null, onDateSelected),
|
|
1119
|
-
getBackProps: getBackProps.bind(null, {
|
|
1120
|
-
minDate,
|
|
1121
|
-
offsetMonth,
|
|
1122
|
-
handleOffsetChanged
|
|
1123
|
-
}),
|
|
1124
|
-
getForwardProps: getForwardProps.bind(null, {
|
|
1125
|
-
maxDate,
|
|
1126
|
-
offsetMonth,
|
|
1127
|
-
handleOffsetChanged
|
|
1128
|
-
})
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
//#endregion
|
|
1132
|
-
//#region src/hooks/useLatestRef.ts
|
|
1133
|
-
function useLatestRef(value) {
|
|
1134
|
-
const latestValue = (0, react.useRef)(value);
|
|
1135
|
-
(0, react.useEffect)(() => {
|
|
1136
|
-
latestValue.current = value;
|
|
1137
|
-
}, [value]);
|
|
1138
|
-
return latestValue;
|
|
1139
|
-
}
|
|
1140
|
-
//#endregion
|
|
1141
|
-
//#region src/misc/debounce.ts
|
|
1142
|
-
function debounce(function_, ms) {
|
|
1143
|
-
let lastArgs;
|
|
1144
|
-
let timeout;
|
|
1145
|
-
function run() {
|
|
1146
|
-
const args = lastArgs;
|
|
1147
|
-
lastArgs = void 0;
|
|
1148
|
-
timeout = void 0;
|
|
1149
|
-
function_(...args);
|
|
1150
|
-
}
|
|
1151
|
-
return Object.assign(function(...args) {
|
|
1152
|
-
lastArgs = args;
|
|
1153
|
-
if (timeout) clearTimeout(timeout);
|
|
1154
|
-
timeout = setTimeout(run, ms);
|
|
1155
|
-
}, {
|
|
1156
|
-
flush() {
|
|
1157
|
-
if (timeout) {
|
|
1158
|
-
clearTimeout(timeout);
|
|
1159
|
-
run();
|
|
1160
|
-
}
|
|
1161
|
-
},
|
|
1162
|
-
cancel() {
|
|
1163
|
-
if (timeout) {
|
|
1164
|
-
clearTimeout(timeout);
|
|
1165
|
-
timeout = void 0;
|
|
1166
|
-
lastArgs = void 0;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
//#endregion
|
|
1172
|
-
//#region src/components/dateInput.tsx
|
|
1173
|
-
const className$1 = "schummar-table-date-input";
|
|
1174
|
-
const defaultDate$1 = new Date(1970, 0, 1);
|
|
1175
|
-
const isIncludedType$1 = (type) => type === "day" || type === "month" || type === "year";
|
|
1176
|
-
const maxValues$1 = {
|
|
1177
|
-
day: 31,
|
|
1178
|
-
month: 12,
|
|
1179
|
-
year: 9999
|
|
1180
|
-
};
|
|
1181
|
-
const tabNext$1 = (event, id) => {
|
|
1182
|
-
const all = Array.from(document.querySelectorAll(`.${className$1}-${id}`));
|
|
1183
|
-
const next = all[all.indexOf(event) + 1];
|
|
1184
|
-
if (next instanceof HTMLElement) next.focus();
|
|
1185
|
-
};
|
|
1186
|
-
function buildDate(value, baseDate = /* @__PURE__ */ new Date()) {
|
|
1187
|
-
const date = new Date(baseDate);
|
|
1188
|
-
if (value.year) date.setFullYear(Number(value.year));
|
|
1189
|
-
if (value.month) date.setMonth(Number(value.month) - 1);
|
|
1190
|
-
if (value.day) date.setDate(Number(value.day));
|
|
1191
|
-
return date;
|
|
1192
|
-
}
|
|
1193
|
-
function DateInput({ value, onChange, locale }) {
|
|
1194
|
-
const id = (0, react.useId)();
|
|
1195
|
-
const [localValue, setLocalValue] = (0, react.useState)();
|
|
1196
|
-
const latestValue = useLatestRef(value);
|
|
1197
|
-
const commit = (0, react.useMemo)(() => debounce((localValue = {}, value, onChange) => {
|
|
1198
|
-
if (value !== latestValue.current) return;
|
|
1199
|
-
const date = buildDate(localValue, value ?? void 0);
|
|
1200
|
-
setLocalValue(void 0);
|
|
1201
|
-
onChange(isNaN(date.getTime()) ? null : date);
|
|
1202
|
-
}, 100), []);
|
|
1203
|
-
const format = (0, react.useMemo)(() => new Intl.DateTimeFormat(locale, {
|
|
1204
|
-
day: "2-digit",
|
|
1205
|
-
month: "2-digit",
|
|
1206
|
-
year: "numeric"
|
|
1207
|
-
}), [locale]);
|
|
1208
|
-
let parts;
|
|
1209
|
-
try {
|
|
1210
|
-
parts = format.formatToParts(value ?? defaultDate$1);
|
|
1211
|
-
} catch {
|
|
1212
|
-
parts = format.formatToParts(defaultDate$1);
|
|
1213
|
-
}
|
|
1214
|
-
const isEmpty = !value;
|
|
1215
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
1216
|
-
css: {
|
|
1217
|
-
display: "flex",
|
|
1218
|
-
alignItems: "baseline"
|
|
1219
|
-
},
|
|
1220
|
-
children: parts.map(({ type, value: partValue }, index) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Fragment, { children: isIncludedType$1(type) ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("input", {
|
|
1221
|
-
className: `${className$1}-${id}`,
|
|
1222
|
-
css: {
|
|
1223
|
-
boxSizing: "content-box",
|
|
1224
|
-
overflow: "visible",
|
|
1225
|
-
border: "none",
|
|
1226
|
-
borderBottom: "2px solid transparent",
|
|
1227
|
-
outline: "none",
|
|
1228
|
-
fontSize: "inherit",
|
|
1229
|
-
backgroundColor: "inherit",
|
|
1230
|
-
color: "inherit",
|
|
1231
|
-
"::placeholder": {
|
|
1232
|
-
color: "inherit",
|
|
1233
|
-
opacity: .5
|
|
1234
|
-
},
|
|
1235
|
-
"&:focus": { borderBottom: "2px solid var(--primaryMain)" }
|
|
1236
|
-
},
|
|
1237
|
-
style: { width: `${String(maxValues$1[type]).length}ch` },
|
|
1238
|
-
placeholder: "".padEnd(String(maxValues$1[type]).length, "0"),
|
|
1239
|
-
value: localValue?.[type] ?? (isEmpty ? "" : partValue),
|
|
1240
|
-
onChange: (event) => {
|
|
1241
|
-
const input = event.target.value;
|
|
1242
|
-
if (!/^\d*$/.test(input)) return;
|
|
1243
|
-
const newValue = {
|
|
1244
|
-
...localValue,
|
|
1245
|
-
[type]: input
|
|
1246
|
-
};
|
|
1247
|
-
if (Number(input) > maxValues$1[type]) newValue[type] = String(maxValues$1[type]);
|
|
1248
|
-
setLocalValue(newValue);
|
|
1249
|
-
if (input.length >= String(maxValues$1[type]).length) setTimeout(() => tabNext$1(event.target, id));
|
|
1250
|
-
},
|
|
1251
|
-
onFocus: (event) => {
|
|
1252
|
-
commit.cancel();
|
|
1253
|
-
event.target.select();
|
|
1254
|
-
},
|
|
1255
|
-
onBlur: () => {
|
|
1256
|
-
commit(localValue, value, onChange);
|
|
1257
|
-
}
|
|
1258
|
-
}) : type === "literal" ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", { children: partValue }) : null }, index))
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
//#endregion
|
|
1262
|
-
//#region src/components/text.tsx
|
|
1263
|
-
function Text({ id }) {
|
|
1264
|
-
const text = useTheme((t) => t.text[id]);
|
|
1265
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_emotion_react_jsx_runtime.Fragment, { children: text });
|
|
1266
|
-
}
|
|
1267
|
-
//#endregion
|
|
1268
|
-
//#region src/components/timeInput.tsx
|
|
1269
|
-
const className = "schummar-table-time-input";
|
|
1270
|
-
const defaultDate = new Date(1970, 0, 1);
|
|
1271
|
-
const isIncludedType = (type) => type === "hour" || type === "minute" || type === "second";
|
|
1272
|
-
const maxValues = {
|
|
1273
|
-
hour: 23,
|
|
1274
|
-
minute: 59,
|
|
1275
|
-
second: 59
|
|
1276
|
-
};
|
|
1277
|
-
const tabNext = (event, id) => {
|
|
1278
|
-
const all = Array.from(document.querySelectorAll(`.${className}-${id}`));
|
|
1279
|
-
const next = all[all.indexOf(event) + 1];
|
|
1280
|
-
if (next instanceof HTMLElement) next.focus();
|
|
1281
|
-
};
|
|
1282
|
-
function buildTime(value, baseDate = /* @__PURE__ */ new Date()) {
|
|
1283
|
-
const date = new Date(baseDate);
|
|
1284
|
-
if (value.hour) date.setHours(Number(value.hour));
|
|
1285
|
-
if (value.minute) date.setMinutes(Number(value.minute));
|
|
1286
|
-
if (value.second) date.setSeconds(Number(value.second));
|
|
1287
|
-
return date;
|
|
1288
|
-
}
|
|
1289
|
-
function TimeInput({ value, onChange, locale, showSeconds = true }) {
|
|
1290
|
-
const id = (0, react.useId)();
|
|
1291
|
-
const [localValue, setLocalValue] = (0, react.useState)();
|
|
1292
|
-
const latestValue = useLatestRef(value);
|
|
1293
|
-
const commit = (0, react.useMemo)(() => debounce((localValue = {}, value, onChange) => {
|
|
1294
|
-
if (value !== latestValue.current) return;
|
|
1295
|
-
const date = buildTime(localValue, value ?? void 0);
|
|
1296
|
-
setLocalValue(void 0);
|
|
1297
|
-
onChange(isNaN(date.getTime()) ? null : date);
|
|
1298
|
-
}, 100), []);
|
|
1299
|
-
const format = (0, react.useMemo)(() => new Intl.DateTimeFormat(locale, {
|
|
1300
|
-
hour: "2-digit",
|
|
1301
|
-
minute: "2-digit",
|
|
1302
|
-
second: showSeconds ? "2-digit" : void 0
|
|
1303
|
-
}), [locale]);
|
|
1304
|
-
let parts;
|
|
1305
|
-
try {
|
|
1306
|
-
parts = format.formatToParts(value ?? defaultDate);
|
|
1307
|
-
} catch {
|
|
1308
|
-
parts = format.formatToParts(defaultDate);
|
|
1309
|
-
}
|
|
1310
|
-
const isEmpty = !value;
|
|
1311
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
1312
|
-
css: {
|
|
1313
|
-
display: "flex",
|
|
1314
|
-
alignItems: "baseline"
|
|
1315
|
-
},
|
|
1316
|
-
children: parts.map(({ type, value: partValue }, index) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Fragment, { children: isIncludedType(type) ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("input", {
|
|
1317
|
-
className: `${className}-${id}`,
|
|
1318
|
-
css: {
|
|
1319
|
-
boxSizing: "content-box",
|
|
1320
|
-
overflow: "visible",
|
|
1321
|
-
border: "none",
|
|
1322
|
-
borderBottom: "2px solid transparent",
|
|
1323
|
-
outline: "none",
|
|
1324
|
-
fontSize: "inherit",
|
|
1325
|
-
backgroundColor: "inherit",
|
|
1326
|
-
color: "inherit",
|
|
1327
|
-
"::placeholder": {
|
|
1328
|
-
color: "inherit",
|
|
1329
|
-
opacity: .5
|
|
1330
|
-
},
|
|
1331
|
-
"&:focus": { borderBottom: "2px solid var(--primaryMain)" }
|
|
1332
|
-
},
|
|
1333
|
-
style: { width: `${String(maxValues[type]).length}ch` },
|
|
1334
|
-
placeholder: "".padEnd(String(maxValues[type]).length, "0"),
|
|
1335
|
-
value: localValue?.[type] ?? (isEmpty ? "" : partValue),
|
|
1336
|
-
onChange: (event) => {
|
|
1337
|
-
const input = event.target.value;
|
|
1338
|
-
if (!/^\d*$/.test(input)) return;
|
|
1339
|
-
const newValue = {
|
|
1340
|
-
...localValue,
|
|
1341
|
-
[type]: input
|
|
1342
|
-
};
|
|
1343
|
-
if (Number(input) > maxValues[type]) newValue[type] = String(maxValues[type]);
|
|
1344
|
-
setLocalValue(newValue);
|
|
1345
|
-
if (input.length >= String(maxValues[type]).length) setTimeout(() => tabNext(event.target, id));
|
|
1346
|
-
},
|
|
1347
|
-
onFocus: (event) => {
|
|
1348
|
-
commit.cancel();
|
|
1349
|
-
event.target.select();
|
|
1350
|
-
},
|
|
1351
|
-
onBlur: () => {
|
|
1352
|
-
commit(localValue, value, onChange);
|
|
1353
|
-
}
|
|
1354
|
-
}) : type === "literal" ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", { children: partValue }) : null }, index))
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
//#endregion
|
|
1358
|
-
//#region src/components/datePicker.tsx
|
|
1359
|
-
const DatePickerContext = (0, react.createContext)({});
|
|
1360
|
-
function DatePickerProvider({ children, ...props }) {
|
|
1361
|
-
const value = (0, react.useMemo)(() => props, [JSON.stringify(props)]);
|
|
1362
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(DatePickerContext.Provider, {
|
|
1363
|
-
value,
|
|
1364
|
-
children
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
const weekDays = [
|
|
1368
|
-
0,
|
|
1369
|
-
1,
|
|
1370
|
-
2,
|
|
1371
|
-
3,
|
|
1372
|
-
4,
|
|
1373
|
-
5,
|
|
1374
|
-
6
|
|
1375
|
-
];
|
|
1376
|
-
/** Rounds a date down to the start of the day. */
|
|
1377
|
-
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
1378
|
-
/** Rounds a date up to the end of the day. */
|
|
1379
|
-
const endOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1, 0, 0, 0, -1);
|
|
1380
|
-
const lastDays = (days) => {
|
|
1381
|
-
const now = /* @__PURE__ */ new Date();
|
|
1382
|
-
const min = new Date(now);
|
|
1383
|
-
min.setDate(min.getDate() - days + 1);
|
|
1384
|
-
return {
|
|
1385
|
-
min: startOfDay(min),
|
|
1386
|
-
max: endOfDay(now)
|
|
1387
|
-
};
|
|
1388
|
-
};
|
|
1389
|
-
const today = () => lastDays(1);
|
|
1390
|
-
const thisWeek = (delta = 0, firstDayOfWeek = 1) => {
|
|
1391
|
-
const min = /* @__PURE__ */ new Date(/* @__PURE__ */ new Date());
|
|
1392
|
-
let diff = min.getDay() - firstDayOfWeek;
|
|
1393
|
-
if (diff < 0) diff += 7;
|
|
1394
|
-
min.setDate(min.getDate() - diff + delta * 7);
|
|
1395
|
-
const max = new Date(min);
|
|
1396
|
-
max.setDate(max.getDate() + 6);
|
|
1397
|
-
return {
|
|
1398
|
-
min: startOfDay(min),
|
|
1399
|
-
max: endOfDay(max)
|
|
1400
|
-
};
|
|
1401
|
-
};
|
|
1402
|
-
const thisMonth = (delta = 0) => {
|
|
1403
|
-
const min = /* @__PURE__ */ new Date(/* @__PURE__ */ new Date());
|
|
1404
|
-
min.setDate(1);
|
|
1405
|
-
min.setMonth(min.getMonth() + delta);
|
|
1406
|
-
const max = new Date(min);
|
|
1407
|
-
max.setMonth(max.getMonth() + 1);
|
|
1408
|
-
max.setDate(max.getDate() - 1);
|
|
1409
|
-
return {
|
|
1410
|
-
min: startOfDay(min),
|
|
1411
|
-
max: endOfDay(max)
|
|
1412
|
-
};
|
|
1413
|
-
};
|
|
1414
|
-
const thisYear = (delta = 0) => {
|
|
1415
|
-
const min = /* @__PURE__ */ new Date(/* @__PURE__ */ new Date());
|
|
1416
|
-
min.setDate(1);
|
|
1417
|
-
min.setMonth(0);
|
|
1418
|
-
min.setFullYear(min.getFullYear() + delta);
|
|
1419
|
-
const max = new Date(min);
|
|
1420
|
-
max.setFullYear(max.getFullYear() + 1);
|
|
1421
|
-
max.setDate(max.getDate() - 1);
|
|
1422
|
-
return {
|
|
1423
|
-
min: startOfDay(min),
|
|
1424
|
-
max: endOfDay(max)
|
|
1425
|
-
};
|
|
1426
|
-
};
|
|
1427
|
-
const getCalendarWeek = (date) => {
|
|
1428
|
-
const tz = temporal_polyfill.Temporal.Now.timeZoneId();
|
|
1429
|
-
return temporal_polyfill.Temporal.Instant.fromEpochMilliseconds(date.getTime()).toZonedDateTimeISO(tz).weekOfYear ?? 0;
|
|
1430
|
-
};
|
|
1431
|
-
const commonQuickOptions = {
|
|
1432
|
-
today: {
|
|
1433
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "today" }),
|
|
1434
|
-
value: today
|
|
1435
|
-
},
|
|
1436
|
-
thisWeek: {
|
|
1437
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "thisWeek" }),
|
|
1438
|
-
value: (props) => thisWeek(0, props.firstDayOfWeek)
|
|
1439
|
-
},
|
|
1440
|
-
thisMonth: {
|
|
1441
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "thisMonth" }),
|
|
1442
|
-
value: () => thisMonth()
|
|
1443
|
-
},
|
|
1444
|
-
thisYear: {
|
|
1445
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "thisYear" }),
|
|
1446
|
-
value: () => thisYear()
|
|
1447
|
-
},
|
|
1448
|
-
lastSevenDays: {
|
|
1449
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "lastSevenDays" }),
|
|
1450
|
-
value: () => lastDays(7)
|
|
1451
|
-
},
|
|
1452
|
-
lastThirtyDays: {
|
|
1453
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "lastThirtyDays" }),
|
|
1454
|
-
value: () => lastDays(30)
|
|
1455
|
-
}
|
|
1456
|
-
};
|
|
1457
|
-
/** Returns whether two dates and/or date ranges intersect. Intersection is considered per day. */
|
|
1458
|
-
function dateIntersect(a, b) {
|
|
1459
|
-
if (a instanceof Date) a = {
|
|
1460
|
-
min: a,
|
|
1461
|
-
max: a
|
|
1462
|
-
};
|
|
1463
|
-
if (b instanceof Date) b = {
|
|
1464
|
-
min: b,
|
|
1465
|
-
max: b
|
|
1466
|
-
};
|
|
1467
|
-
if (!a?.min || !a.max || !b?.min || !b.max) return false;
|
|
1468
|
-
return !(endOfDay(a.max) < startOfDay(b.min) || startOfDay(a.min) > endOfDay(b.max));
|
|
1469
|
-
}
|
|
1470
|
-
function dateClamp(date, min, max) {
|
|
1471
|
-
if (min && date < min) return min;
|
|
1472
|
-
if (max && date > max) return max;
|
|
1473
|
-
return date;
|
|
1474
|
-
}
|
|
1475
|
-
function getValueForComparison(value) {
|
|
1476
|
-
if (!value) return value;
|
|
1477
|
-
if (value instanceof Date) return value.getTime();
|
|
1478
|
-
return `${value.min?.getTime()}-${value.max?.getTime()}`;
|
|
1479
|
-
}
|
|
1480
|
-
function DatePicker(props) {
|
|
1481
|
-
const { value, rangeSelect, locale, firstDayOfWeek = 1, defaultDateInView, quickOptions = ["today", "thisWeek"], noReset, minDate, maxDate, showCalendarWeek, blockedRanges = [], showTime } = defaults(props, (0, react.useContext)(DatePickerContext));
|
|
1482
|
-
function onChange(value, source) {
|
|
1483
|
-
if (value instanceof Date) value = dateClamp(value, minDate, maxDate);
|
|
1484
|
-
else if (value) value = {
|
|
1485
|
-
min: dateClamp(value.min, minDate, maxDate),
|
|
1486
|
-
max: dateClamp(value.max, minDate, maxDate)
|
|
1487
|
-
};
|
|
1488
|
-
props.onChange(value, source);
|
|
1489
|
-
}
|
|
1490
|
-
const Button = useTheme((t) => t.components.Button);
|
|
1491
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
1492
|
-
const ChevronRight = useTheme((t) => t.icons.ChevronRight);
|
|
1493
|
-
const cssVariables = useCssVariables();
|
|
1494
|
-
function getDayCssStyles({ disabled, prevMonth, nextMonth, today, blocked, selected, preSelected }) {
|
|
1495
|
-
return [
|
|
1496
|
-
{
|
|
1497
|
-
padding: 10,
|
|
1498
|
-
border: "none",
|
|
1499
|
-
background: "transparent",
|
|
1500
|
-
cursor: disabled ? void 0 : "pointer",
|
|
1501
|
-
font: "inherit",
|
|
1502
|
-
color: "inherit"
|
|
1503
|
-
},
|
|
1504
|
-
(prevMonth || nextMonth) && { color: "var(--date-picker-disemphasized, #bdbdbd)" },
|
|
1505
|
-
today && { outline: "1px solid var(--secondaryMain)" },
|
|
1506
|
-
blocked && {
|
|
1507
|
-
background: "var(--blockedMain)",
|
|
1508
|
-
color: "var(--blockedContrastText)"
|
|
1509
|
-
},
|
|
1510
|
-
selected && {
|
|
1511
|
-
background: "var(--primaryMain)",
|
|
1512
|
-
color: "var(--primaryContrastText)"
|
|
1513
|
-
},
|
|
1514
|
-
blocked && selected && {
|
|
1515
|
-
position: "relative",
|
|
1516
|
-
"::before": {
|
|
1517
|
-
content: "\"\"",
|
|
1518
|
-
position: "absolute",
|
|
1519
|
-
top: 0,
|
|
1520
|
-
right: 0,
|
|
1521
|
-
bottom: 0,
|
|
1522
|
-
left: 0,
|
|
1523
|
-
background: "var(--blockedMain)",
|
|
1524
|
-
clipPath: "polygon(0 0, 0 50%, 50% 0)"
|
|
1525
|
-
}
|
|
1526
|
-
},
|
|
1527
|
-
preSelected && {
|
|
1528
|
-
background: "var(--primaryLight)",
|
|
1529
|
-
color: "var(--primaryContrastText)"
|
|
1530
|
-
}
|
|
1531
|
-
];
|
|
1532
|
-
}
|
|
1533
|
-
const mountTime = (0, react.useMemo)(() => /* @__PURE__ */ new Date(), []);
|
|
1534
|
-
const [dirty, setDirty] = (0, react.useState)();
|
|
1535
|
-
const [hovered, setHovered] = (0, react.useState)();
|
|
1536
|
-
const [dateInViewLocal, setDateInViewLocal] = (0, react.useState)(defaultDateInView ?? mountTime);
|
|
1537
|
-
const dateInView = props.dateInView ?? dateInViewLocal;
|
|
1538
|
-
function setDateInView(date) {
|
|
1539
|
-
setDateInViewLocal(date);
|
|
1540
|
-
props.onDateInViewChange?.(date);
|
|
1541
|
-
}
|
|
1542
|
-
const min = dirty ? dirty.min : value instanceof Date ? value : value?.min;
|
|
1543
|
-
const max = dirty ? dirty.max : value instanceof Date ? value : value?.max;
|
|
1544
|
-
const resolvedQuickOptions = [...quickOptions, ...noReset ? [] : [{
|
|
1545
|
-
label: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "reset" }),
|
|
1546
|
-
value: null
|
|
1547
|
-
}]].map((option, index) => {
|
|
1548
|
-
if (option instanceof Function) return option((value) => {
|
|
1549
|
-
setDirty(void 0);
|
|
1550
|
-
onChange(value, "quickOption");
|
|
1551
|
-
});
|
|
1552
|
-
const { label, value } = typeof option === "string" ? commonQuickOptions[option] : option;
|
|
1553
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Button, {
|
|
1554
|
-
variant: "text",
|
|
1555
|
-
type: "button",
|
|
1556
|
-
css: { color: "inherit" },
|
|
1557
|
-
onClick: () => {
|
|
1558
|
-
setDirty(void 0);
|
|
1559
|
-
if (value instanceof Function) onChange(value(props), "quickOption");
|
|
1560
|
-
else onChange(value, "quickOption");
|
|
1561
|
-
},
|
|
1562
|
-
children: label
|
|
1563
|
-
}, index);
|
|
1564
|
-
});
|
|
1565
|
-
const { calendars, getBackProps, getForwardProps, getDateProps } = useDayzed({
|
|
1566
|
-
onDateSelected: () => void 0,
|
|
1567
|
-
firstDayOfWeek,
|
|
1568
|
-
showOutsideDays: true,
|
|
1569
|
-
date: dateInView,
|
|
1570
|
-
onOffsetChanged: (offset) => setDateInView(new Date(dateInView.getFullYear(), dateInView.getMonth() + offset)),
|
|
1571
|
-
offset: 0,
|
|
1572
|
-
minDate,
|
|
1573
|
-
maxDate
|
|
1574
|
-
});
|
|
1575
|
-
const now = (0, react.useMemo)(() => startOfDay(/* @__PURE__ */ new Date()), []);
|
|
1576
|
-
const formatWeekday = (0, react.useMemo)(() => {
|
|
1577
|
-
const { format } = new Intl.DateTimeFormat(locale, { weekday: "short" });
|
|
1578
|
-
return (weekDay) => format(new Date(Date.UTC(2021, 7, (weekDay + firstDayOfWeek) % 7 + 1)));
|
|
1579
|
-
}, [locale, firstDayOfWeek]);
|
|
1580
|
-
(0, react.useEffect)(() => setDateInView(value === null ? defaultDateInView ?? mountTime : value instanceof Date ? value : value.max), [
|
|
1581
|
-
getValueForComparison(value),
|
|
1582
|
-
getValueForComparison(defaultDateInView),
|
|
1583
|
-
mountTime
|
|
1584
|
-
]);
|
|
1585
|
-
(0, react.useEffect)(() => {
|
|
1586
|
-
if (!rangeSelect) setDirty(void 0);
|
|
1587
|
-
}, [rangeSelect]);
|
|
1588
|
-
function set(source, min, max, edit) {
|
|
1589
|
-
if (!rangeSelect) {
|
|
1590
|
-
onChange(min ?? null, source);
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
if (min && max && min > max) {
|
|
1594
|
-
if (edit === "min") max = min;
|
|
1595
|
-
else if (edit === "max") min = max;
|
|
1596
|
-
else [min, max] = [max, min];
|
|
1597
|
-
}
|
|
1598
|
-
if (!min === !max) {
|
|
1599
|
-
setDirty(void 0);
|
|
1600
|
-
onChange(min && max ? {
|
|
1601
|
-
min,
|
|
1602
|
-
max: endOfDay(max)
|
|
1603
|
-
} : null, source);
|
|
1604
|
-
} else setDirty({
|
|
1605
|
-
min,
|
|
1606
|
-
max
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
|
-
const formatMonth = (0, react.useMemo)(() => {
|
|
1610
|
-
const { format } = new Intl.DateTimeFormat(locale, { month: "long" });
|
|
1611
|
-
return (month) => format(new Date(2021, month));
|
|
1612
|
-
}, [locale]);
|
|
1613
|
-
const formatYear = (0, react.useMemo)(() => {
|
|
1614
|
-
const { format } = new Intl.DateTimeFormat(locale, { year: "numeric" });
|
|
1615
|
-
return (year) => format(new Date(year, 0, 1));
|
|
1616
|
-
}, [locale]);
|
|
1617
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
1618
|
-
css: [cssVariables, { color: "var(--table-text-color)" }],
|
|
1619
|
-
children: [
|
|
1620
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
1621
|
-
css: {
|
|
1622
|
-
display: "grid",
|
|
1623
|
-
gridAutoFlow: "column",
|
|
1624
|
-
justifyContent: "center",
|
|
1625
|
-
alignItems: "center",
|
|
1626
|
-
gap: "calc(var(--spacing) * 4)",
|
|
1627
|
-
"& > div": {
|
|
1628
|
-
display: "flex",
|
|
1629
|
-
flexDirection: "column",
|
|
1630
|
-
alignItems: "center"
|
|
1631
|
-
}
|
|
1632
|
-
},
|
|
1633
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(DateInput, {
|
|
1634
|
-
value: min ?? null,
|
|
1635
|
-
onChange: (newMin) => set("input", newMin ?? void 0, max, "min"),
|
|
1636
|
-
locale
|
|
1637
|
-
}), showTime && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(TimeInput, {
|
|
1638
|
-
value: min ?? null,
|
|
1639
|
-
onChange: (newMin) => set("input", newMin ?? void 0, max, "min"),
|
|
1640
|
-
locale,
|
|
1641
|
-
showSeconds: typeof showTime === "boolean" ? true : showTime.showSeconds
|
|
1642
|
-
})] }), rangeSelect && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(_emotion_react_jsx_runtime.Fragment, { children: [" - ", /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(DateInput, {
|
|
1643
|
-
value: max ?? null,
|
|
1644
|
-
onChange: (newMax) => set("input", min, newMax ?? void 0, "max"),
|
|
1645
|
-
locale
|
|
1646
|
-
}), showTime && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(TimeInput, {
|
|
1647
|
-
value: max ?? null,
|
|
1648
|
-
onChange: (newMax) => set("input", min, newMax ?? void 0, "max"),
|
|
1649
|
-
locale,
|
|
1650
|
-
showSeconds: typeof showTime === "boolean" ? true : showTime.showSeconds
|
|
1651
|
-
})] })] })]
|
|
1652
|
-
}),
|
|
1653
|
-
calendars.map(({ month, year, weeks }) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
1654
|
-
css: { display: "grid" },
|
|
1655
|
-
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
1656
|
-
css: {
|
|
1657
|
-
margin: "calc(var(--spacing) * 4) 0",
|
|
1658
|
-
display: "grid",
|
|
1659
|
-
gridAutoFlow: "column",
|
|
1660
|
-
justifyContent: "space-between",
|
|
1661
|
-
alignItems: "center"
|
|
1662
|
-
},
|
|
1663
|
-
children: [
|
|
1664
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(IconButton, {
|
|
1665
|
-
type: "button",
|
|
1666
|
-
...getBackProps({ calendars }),
|
|
1667
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ChevronRight, { css: { transform: "rotate3d(0, 0, 1, 180deg)" } })
|
|
1668
|
-
}),
|
|
1669
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
1670
|
-
css: { display: "flex" },
|
|
1671
|
-
children: [
|
|
1672
|
-
formatMonth(month),
|
|
1673
|
-
" ",
|
|
1674
|
-
formatYear(year)
|
|
1675
|
-
]
|
|
1676
|
-
}),
|
|
1677
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(IconButton, {
|
|
1678
|
-
type: "button",
|
|
1679
|
-
...getForwardProps({ calendars }),
|
|
1680
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ChevronRight, {})
|
|
1681
|
-
})
|
|
1682
|
-
]
|
|
1683
|
-
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
1684
|
-
css: {
|
|
1685
|
-
justifySelf: "center",
|
|
1686
|
-
display: "grid",
|
|
1687
|
-
gridTemplateColumns: "repeat(8, max-content)"
|
|
1688
|
-
},
|
|
1689
|
-
children: [
|
|
1690
|
-
showCalendarWeek ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
1691
|
-
css: {
|
|
1692
|
-
justifySelf: "center",
|
|
1693
|
-
padding: 10,
|
|
1694
|
-
borderRight: "1px solid var(--date-picker-separator, var(--table-border, #bdbdbd))"
|
|
1695
|
-
},
|
|
1696
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Text, { id: "calendarWeek" })
|
|
1697
|
-
}) : /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {}),
|
|
1698
|
-
weekDays.map((_v, weekDay) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
1699
|
-
css: {
|
|
1700
|
-
justifySelf: "center",
|
|
1701
|
-
padding: 10
|
|
1702
|
-
},
|
|
1703
|
-
children: formatWeekday(weekDay)
|
|
1704
|
-
}, weekDay)),
|
|
1705
|
-
weeks.map((week, index) => {
|
|
1706
|
-
const weekStart = week[0];
|
|
1707
|
-
const weekEnd = week[6];
|
|
1708
|
-
const weekDisabled = !rangeSelect || minDate && weekEnd.date < minDate || maxDate && weekStart.date > maxDate;
|
|
1709
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(react.Fragment, { children: [showCalendarWeek ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("button", {
|
|
1710
|
-
type: "button",
|
|
1711
|
-
css: {
|
|
1712
|
-
padding: 10,
|
|
1713
|
-
border: "none",
|
|
1714
|
-
background: "transparent",
|
|
1715
|
-
cursor: weekDisabled ? void 0 : "pointer",
|
|
1716
|
-
font: "inherit",
|
|
1717
|
-
borderRight: "1px solid var(--date-picker-separator, var(--table-border, #bdbdbd))",
|
|
1718
|
-
color: "inherit"
|
|
1719
|
-
},
|
|
1720
|
-
onClick: () => {
|
|
1721
|
-
if (weekDisabled) return;
|
|
1722
|
-
set("calendarWeek", minDate && weekStart.date < minDate ? minDate : weekStart.date, maxDate && weekEnd.date > maxDate ? maxDate : weekEnd.date);
|
|
1723
|
-
},
|
|
1724
|
-
onPointerOver: () => !weekDisabled && setHovered({
|
|
1725
|
-
min: weekStart.date,
|
|
1726
|
-
max: weekEnd.date
|
|
1727
|
-
}),
|
|
1728
|
-
onPointerOut: () => !weekDisabled && setHovered(void 0),
|
|
1729
|
-
children: getCalendarWeek(weekEnd.date)
|
|
1730
|
-
}) : /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {}), week.map((dateObject, dayIndex) => {
|
|
1731
|
-
if (!dateObject) return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {}, dayIndex);
|
|
1732
|
-
const { prevMonth, nextMonth, date } = dateObject;
|
|
1733
|
-
const today = startOfDay(date).getTime() === now.getTime();
|
|
1734
|
-
const disabled = minDate && date < minDate || maxDate && date > maxDate;
|
|
1735
|
-
const selected = date.getTime() === min?.getTime() || min && max && dateIntersect(date, {
|
|
1736
|
-
min,
|
|
1737
|
-
max
|
|
1738
|
-
});
|
|
1739
|
-
const preSelected = !selected && !disabled && (dateIntersect(date, hovered) || min && !max && hovered && dateIntersect(date, min <= hovered.min ? {
|
|
1740
|
-
min,
|
|
1741
|
-
max: hovered.min
|
|
1742
|
-
} : {
|
|
1743
|
-
min: hovered.max,
|
|
1744
|
-
max: min
|
|
1745
|
-
}));
|
|
1746
|
-
const blocked = blockedRanges.some((range) => dateIntersect(date, range));
|
|
1747
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("button", {
|
|
1748
|
-
type: "button",
|
|
1749
|
-
css: getDayCssStyles({
|
|
1750
|
-
disabled,
|
|
1751
|
-
prevMonth,
|
|
1752
|
-
nextMonth,
|
|
1753
|
-
today,
|
|
1754
|
-
blocked,
|
|
1755
|
-
selected,
|
|
1756
|
-
preSelected
|
|
1757
|
-
}),
|
|
1758
|
-
...getDateProps({ dateObj: dateObject }),
|
|
1759
|
-
onClick: () => {
|
|
1760
|
-
if (dirty) {
|
|
1761
|
-
if (min) set("calendar", min, date);
|
|
1762
|
-
else set("calendar", date, max);
|
|
1763
|
-
} else set("calendar", date);
|
|
1764
|
-
},
|
|
1765
|
-
onPointerOver: () => setHovered({
|
|
1766
|
-
min: date,
|
|
1767
|
-
max: date
|
|
1768
|
-
}),
|
|
1769
|
-
onPointerOut: () => setHovered(void 0),
|
|
1770
|
-
disabled,
|
|
1771
|
-
children: date.getDate()
|
|
1772
|
-
}, `${index}-${dayIndex}`);
|
|
1773
|
-
})] }, index);
|
|
1774
|
-
})
|
|
1775
|
-
]
|
|
1776
|
-
})]
|
|
1777
|
-
}, `${month}${year}`)),
|
|
1778
|
-
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
1779
|
-
css: {
|
|
1780
|
-
marginTop: "var(--spacing)",
|
|
1781
|
-
display: "grid",
|
|
1782
|
-
gridAutoFlow: "column",
|
|
1783
|
-
justifyContent: "center"
|
|
1784
|
-
},
|
|
1785
|
-
children: resolvedQuickOptions
|
|
1786
|
-
})
|
|
1787
|
-
]
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
//#endregion
|
|
1791
27
|
//#region src/state/context.ts
|
|
1792
28
|
/** Full table state. Changes on every state change: rows and cells must not consume it. */
|
|
1793
29
|
const TableContext = (0, react.createContext)(null);
|
|
@@ -2043,12 +279,12 @@ function useExpanded(props, itemsById, matching) {
|
|
|
2043
279
|
};
|
|
2044
280
|
if (props.expandOnlyOne && value.size > 1) {
|
|
2045
281
|
const deepest = [...value].map((id) => itemsById.get(id)).filter((item) => item !== void 0).sort((a, b) => b.depth - a.depth)[0];
|
|
2046
|
-
const branch = deepest ? getAncestors(itemsById, deepest).add(deepest.id) : /* @__PURE__ */ new Set();
|
|
282
|
+
const branch = deepest ? require_useTheme.getAncestors(itemsById, deepest).add(deepest.id) : /* @__PURE__ */ new Set();
|
|
2047
283
|
if ([...value].some((id) => !branch.has(id))) return branch;
|
|
2048
284
|
}
|
|
2049
285
|
for (const id of value) {
|
|
2050
286
|
const item = itemsById.get(id);
|
|
2051
|
-
if (item) getAncestors(itemsById, item).forEach(add);
|
|
287
|
+
if (item) require_useTheme.getAncestors(itemsById, item).forEach(add);
|
|
2052
288
|
}
|
|
2053
289
|
if (props.items !== void 0) {
|
|
2054
290
|
for (const id of value) if (!itemsById.has(id)) {
|
|
@@ -2080,18 +316,20 @@ const isActiveFilter = (filter, value) => filter !== void 0 && value !== void 0
|
|
|
2080
316
|
function filteredColumns(props, visibleColumns) {
|
|
2081
317
|
return props.enableHiddenColumnFilters ? props.columns : visibleColumns;
|
|
2082
318
|
}
|
|
319
|
+
/** Adds controlled values and defaults. Returns `stored` itself when there are none. */
|
|
320
|
+
function withFilterDefaults(stored, columns) {
|
|
321
|
+
let result = stored;
|
|
322
|
+
for (const { id, filter } of columns) {
|
|
323
|
+
const value = filter?.value !== void 0 || stored.has(id) ? filter?.value : filter?.defaultValue;
|
|
324
|
+
if (value === void 0) continue;
|
|
325
|
+
if (result === stored) result = new Map(stored);
|
|
326
|
+
result.set(id, value);
|
|
327
|
+
}
|
|
328
|
+
return result;
|
|
329
|
+
}
|
|
2083
330
|
function useFilters(props, visibleColumns, items) {
|
|
2084
331
|
const [stored, setFilterValues, setFilterValuesInternal] = useControllableState(props.filterValues, () => props.defaultFilterValues ?? /* @__PURE__ */ new Map(), props.onFilterValuesChange);
|
|
2085
|
-
const filterValues = (0, react.useMemo)(() =>
|
|
2086
|
-
let result = stored;
|
|
2087
|
-
for (const { id, filter } of props.columns) {
|
|
2088
|
-
const value = filter?.value !== void 0 || stored.has(id) ? filter?.value : filter?.defaultValue;
|
|
2089
|
-
if (value === void 0) continue;
|
|
2090
|
-
if (result === stored) result = new Map(stored);
|
|
2091
|
-
result.set(id, value);
|
|
2092
|
-
}
|
|
2093
|
-
return result;
|
|
2094
|
-
}, [stored, props.columns]);
|
|
332
|
+
const filterValues = (0, react.useMemo)(() => withFilterDefaults(stored, props.columns), [stored, props.columns]);
|
|
2095
333
|
const applied = filteredColumns(props, visibleColumns);
|
|
2096
334
|
return {
|
|
2097
335
|
stored,
|
|
@@ -2359,7 +597,7 @@ const defaultProps = {
|
|
|
2359
597
|
} }
|
|
2360
598
|
};
|
|
2361
599
|
const identity = (value) => value;
|
|
2362
|
-
const defaultSortBy = (v) => typeof v === "number" || v instanceof Date ? v : asString(v);
|
|
600
|
+
const defaultSortBy = (v) => typeof v === "number" || v instanceof Date ? v : require_useTheme.asString(v);
|
|
2363
601
|
function normalizeId(id) {
|
|
2364
602
|
return id instanceof Function ? id : (item) => item[id];
|
|
2365
603
|
}
|
|
@@ -2384,7 +622,7 @@ function normalizeColumns(columns, defaultColumnProps, columnProps, disableSort)
|
|
|
2384
622
|
exportHeader: column.exportHeader ?? defaults.exportHeader ?? id,
|
|
2385
623
|
footer: column.footer ?? defaults.footer ?? null,
|
|
2386
624
|
value: column.value,
|
|
2387
|
-
renderCell: column.renderCell ?? defaults.renderCell ?? asString,
|
|
625
|
+
renderCell: column.renderCell ?? defaults.renderCell ?? require_useTheme.asString,
|
|
2388
626
|
exportCell: column.exportCell ?? defaults.exportCell ?? defaultSerializer,
|
|
2389
627
|
sortBy: column.sortBy ?? defaults.sortBy ?? [defaultSortBy],
|
|
2390
628
|
disableSort: column.disableSort ?? defaults.disableSort ?? disableSort ?? false,
|
|
@@ -2395,7 +633,7 @@ function normalizeColumns(columns, defaultColumnProps, columnProps, disableSort)
|
|
|
2395
633
|
filterBy: column.filterBy ?? defaults.filterBy ?? identity,
|
|
2396
634
|
filter: column.filter ?? defaults.filter,
|
|
2397
635
|
width: column.width ?? defaults.width,
|
|
2398
|
-
displaySize: displaySize !== void 0 ? castArray(displaySize) : void 0
|
|
636
|
+
displaySize: displaySize !== void 0 ? require_useTheme.castArray(displaySize) : void 0
|
|
2399
637
|
};
|
|
2400
638
|
});
|
|
2401
639
|
}
|
|
@@ -2504,7 +742,7 @@ function withEntry(map, key, value) {
|
|
|
2504
742
|
/** `isReset`: whether this state replaces one that got reset. */
|
|
2505
743
|
function useTable(raw, onReset, isReset = false) {
|
|
2506
744
|
const { props, displaySize } = useTableProps(raw);
|
|
2507
|
-
const theme = useTableTheme(props);
|
|
745
|
+
const theme = require_useTheme.useTableTheme(props);
|
|
2508
746
|
const columns = useColumns(props, displaySize);
|
|
2509
747
|
const sort = useSort(props, columns.activeColumns);
|
|
2510
748
|
const { items, itemsById } = useItems(props, sort.criteria);
|
|
@@ -2650,8 +888,8 @@ function useTable(raw, onReset, isReset = false) {
|
|
|
2650
888
|
for (const item of range) if (isSelected) next.delete(item.id);
|
|
2651
889
|
else next.add(item.id);
|
|
2652
890
|
if (props.selectSyncChildren && isSelected) {
|
|
2653
|
-
for (const id of getAncestors(activeItemsById, ...range)) next.delete(id);
|
|
2654
|
-
for (const id of getDescendants(...range)) next.delete(id);
|
|
891
|
+
for (const id of require_useTheme.getAncestors(activeItemsById, ...range)) next.delete(id);
|
|
892
|
+
for (const id of require_useTheme.getDescendants(...range)) next.delete(id);
|
|
2655
893
|
}
|
|
2656
894
|
lastSelectedId.current = itemId;
|
|
2657
895
|
selection.setSelection(next);
|
|
@@ -2666,11 +904,11 @@ function useTable(raw, onReset, isReset = false) {
|
|
|
2666
904
|
const next = new Set(state.expanded);
|
|
2667
905
|
if (props.expandOnlyOne) {
|
|
2668
906
|
next.clear();
|
|
2669
|
-
for (const id of item ? getAncestors(activeItemsById, item) : []) next.add(id);
|
|
907
|
+
for (const id of item ? require_useTheme.getAncestors(activeItemsById, item) : []) next.add(id);
|
|
2670
908
|
}
|
|
2671
909
|
if (isExpanded) {
|
|
2672
910
|
next.delete(itemId);
|
|
2673
|
-
for (const id of item ? getDescendants(item) : []) next.delete(id);
|
|
911
|
+
for (const id of item ? require_useTheme.getDescendants(item) : []) next.delete(id);
|
|
2674
912
|
} else next.add(itemId);
|
|
2675
913
|
expanded.setExpanded(next);
|
|
2676
914
|
patchState({ expanded: next });
|
|
@@ -2838,8 +1076,8 @@ function ResizeHandle() {
|
|
|
2838
1076
|
});
|
|
2839
1077
|
}
|
|
2840
1078
|
function ResizeHandleView({ enabled, ...props }) {
|
|
2841
|
-
const className = useTheme((theme) => theme.classes?.columnDivider);
|
|
2842
|
-
const styles = useTheme((theme) => theme.styles?.columnDivider);
|
|
1079
|
+
const className = require_useTheme.useTheme((theme) => theme.classes?.columnDivider);
|
|
1080
|
+
const styles = require_useTheme.useTheme((theme) => theme.styles?.columnDivider);
|
|
2843
1081
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
2844
1082
|
className,
|
|
2845
1083
|
css: [{
|
|
@@ -3015,11 +1253,11 @@ const chevronCss = (0, _emotion_react.css)({
|
|
|
3015
1253
|
});
|
|
3016
1254
|
const expandedChevronCss = (0, _emotion_react.css)({ transform: "rotate3d(0, 0, 1, 90deg)" });
|
|
3017
1255
|
function ExpandControl({ itemId, expanded, hasChildren, hasDeferredChildren }) {
|
|
3018
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
3019
|
-
const Spinner = useTheme((t) => t.components.Spinner);
|
|
3020
|
-
const ChevronRight = useTheme((t) => t.icons.ChevronRight);
|
|
1256
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
1257
|
+
const Spinner = require_useTheme.useTheme((t) => t.components.Spinner);
|
|
1258
|
+
const ChevronRight = require_useTheme.useTheme((t) => t.icons.ChevronRight);
|
|
3021
1259
|
const actions = useTableActions();
|
|
3022
|
-
const libraryClass = useLibraryClassName();
|
|
1260
|
+
const libraryClass = require_useTheme.useLibraryClassName();
|
|
3023
1261
|
function toggle(event) {
|
|
3024
1262
|
event.preventDefault();
|
|
3025
1263
|
event.stopPropagation();
|
|
@@ -3042,8 +1280,8 @@ const checkboxCss = (0, _emotion_react.css)({
|
|
|
3042
1280
|
});
|
|
3043
1281
|
const SelectComponent = (0, react.memo)(function SelectComponent({ itemId }) {
|
|
3044
1282
|
const selected = (0, react.useContext)(SelectionContext).has(itemId);
|
|
3045
|
-
const Checkbox = useTheme((t) => t.components.Checkbox);
|
|
3046
|
-
const overrideClass = useUserClassName();
|
|
1283
|
+
const Checkbox = require_useTheme.useTheme((t) => t.components.Checkbox);
|
|
1284
|
+
const overrideClass = require_useTheme.useUserClassName();
|
|
3047
1285
|
const actions = useTableActions();
|
|
3048
1286
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Checkbox, {
|
|
3049
1287
|
className: overrideClass(checkboxCss),
|
|
@@ -3052,8 +1290,8 @@ const SelectComponent = (0, react.memo)(function SelectComponent({ itemId }) {
|
|
|
3052
1290
|
});
|
|
3053
1291
|
});
|
|
3054
1292
|
function SelectAll() {
|
|
3055
|
-
const Checkbox = useTheme((t) => t.components.Checkbox);
|
|
3056
|
-
const overrideClass = useUserClassName();
|
|
1293
|
+
const Checkbox = require_useTheme.useTheme((t) => t.components.Checkbox);
|
|
1294
|
+
const overrideClass = require_useTheme.useUserClassName();
|
|
3057
1295
|
const { activeItems, selection, actions } = useTableContext();
|
|
3058
1296
|
const selected = activeItems.length > 0 && activeItems.every((item) => selection.has(item.id));
|
|
3059
1297
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Checkbox, {
|
|
@@ -3124,35 +1362,35 @@ const rowCss = (0, _emotion_react.css)({
|
|
|
3124
1362
|
gridTemplateColumns: "subgrid"
|
|
3125
1363
|
});
|
|
3126
1364
|
function useRowStyles(theme, columns) {
|
|
3127
|
-
const libraryClass = useLibraryClassName();
|
|
3128
|
-
const userClass = useUserClassName();
|
|
1365
|
+
const libraryClass = require_useTheme.useLibraryClassName();
|
|
1366
|
+
const userClass = require_useTheme.useUserClassName();
|
|
3129
1367
|
return (0, react.useMemo)(() => {
|
|
3130
1368
|
const cellClassOf = ({ classes, styles }, baseClass) => {
|
|
3131
1369
|
const { cell: cellClass, evenCell, oddCell } = classes ?? {};
|
|
3132
1370
|
const { cell: cellStyle, evenCell: evenStyle, oddCell: oddStyle } = styles ?? {};
|
|
3133
1371
|
if (!(cellClass instanceof Function) && !(cellStyle instanceof Function)) {
|
|
3134
|
-
const even = cx(baseClass, cellClass, evenCell, userClass(cellStyle, evenStyle));
|
|
3135
|
-
const odd = cx(baseClass, cellClass, oddCell, userClass(cellStyle, oddStyle));
|
|
1372
|
+
const even = require_useTheme.cx(baseClass, cellClass, evenCell, userClass(cellStyle, evenStyle));
|
|
1373
|
+
const odd = require_useTheme.cx(baseClass, cellClass, oddCell, userClass(cellStyle, oddStyle));
|
|
3136
1374
|
return (_value, index) => index % 2 === 0 ? even : odd;
|
|
3137
1375
|
}
|
|
3138
1376
|
return (value, index) => {
|
|
3139
1377
|
const isEven = index % 2 === 0;
|
|
3140
|
-
return cx(baseClass, cellClass instanceof Function ? cellClass(value, index) : cellClass, isEven ? evenCell : oddCell, userClass(cellStyle instanceof Function ? cellStyle(value, index) : cellStyle, isEven ? evenStyle : oddStyle));
|
|
1378
|
+
return require_useTheme.cx(baseClass, cellClass instanceof Function ? cellClass(value, index) : cellClass, isEven ? evenCell : oddCell, userClass(cellStyle instanceof Function ? cellStyle(value, index) : cellStyle, isEven ? evenStyle : oddStyle));
|
|
3141
1379
|
};
|
|
3142
1380
|
};
|
|
3143
1381
|
const elementClassOf = (baseClass, className, style) => {
|
|
3144
1382
|
if (!(className instanceof Function) && !(style instanceof Function)) {
|
|
3145
|
-
const result = cx(baseClass, className, userClass(style));
|
|
1383
|
+
const result = require_useTheme.cx(baseClass, className, userClass(style));
|
|
3146
1384
|
return () => result;
|
|
3147
1385
|
}
|
|
3148
|
-
return (value, index) => cx(baseClass, className instanceof Function ? className(value, index) : className, userClass(style instanceof Function ? style(value, index) : style));
|
|
1386
|
+
return (value, index) => require_useTheme.cx(baseClass, className instanceof Function ? className(value, index) : className, userClass(style instanceof Function ? style(value, index) : style));
|
|
3149
1387
|
};
|
|
3150
1388
|
const cellBase = libraryClass(require_tableTheme.defaultClasses.cell);
|
|
3151
1389
|
return {
|
|
3152
1390
|
row: elementClassOf(libraryClass(rowCss), theme.classes?.row, theme.styles?.row),
|
|
3153
1391
|
fillCell: cellClassOf(theme, libraryClass(require_tableTheme.defaultClasses.cellFill)),
|
|
3154
1392
|
firstCell: cellClassOf(theme, libraryClass(require_tableTheme.defaultClasses.cell, require_tableTheme.defaultClasses.firstCell)),
|
|
3155
|
-
cells: new Map(columns.map((column) => [column.id, cellClassOf(columnTheme(theme, column), cellBase)])),
|
|
1393
|
+
cells: new Map(columns.map((column) => [column.id, cellClassOf(require_useTheme.columnTheme(theme, column), cellBase)])),
|
|
3156
1394
|
details: elementClassOf(libraryClass(require_tableTheme.defaultClasses.details), theme.classes?.details, theme.styles?.details),
|
|
3157
1395
|
text: libraryClass(require_tableTheme.defaultClasses.text)
|
|
3158
1396
|
};
|
|
@@ -3166,8 +1404,8 @@ function useRowStyles(theme, columns) {
|
|
|
3166
1404
|
//#endregion
|
|
3167
1405
|
//#region src/components/clearFiltersButton.tsx
|
|
3168
1406
|
function ClearFiltersButton() {
|
|
3169
|
-
const Button = useTheme((t) => t.components.Button);
|
|
3170
|
-
const textClearFilters = useTheme((t) => t.text.clearFilters);
|
|
1407
|
+
const Button = require_useTheme.useTheme((t) => t.components.Button);
|
|
1408
|
+
const textClearFilters = require_useTheme.useTheme((t) => t.text.clearFilters);
|
|
3171
1409
|
const actions = useTableActions();
|
|
3172
1410
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
3173
1411
|
css: require_tableTheme.defaultClasses.clearFiltersButton,
|
|
@@ -3184,7 +1422,7 @@ function ColumnFooter() {
|
|
|
3184
1422
|
const columnId = useColumnContext();
|
|
3185
1423
|
const { activeColumns } = useTableStructure();
|
|
3186
1424
|
const column = activeColumns.find((column) => column.id === columnId);
|
|
3187
|
-
const { classes, styles } = useTheme((theme) => columnTheme(theme, column));
|
|
1425
|
+
const { classes, styles } = require_useTheme.useTheme((theme) => require_useTheme.columnTheme(theme, column));
|
|
3188
1426
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
3189
1427
|
className: classes?.footerCell,
|
|
3190
1428
|
css: [require_tableTheme.defaultClasses.footerCell, styles?.footerCell],
|
|
@@ -3195,8 +1433,8 @@ function ColumnFooter() {
|
|
|
3195
1433
|
//#region src/components/tableFooter.tsx
|
|
3196
1434
|
const TableFooter = (0, react.memo)(function TableFooter() {
|
|
3197
1435
|
const { props, visibleColumns, activeColumns, filterValues } = useTableStructure();
|
|
3198
|
-
const classes = useTheme((t) => t.classes?.footerCell);
|
|
3199
|
-
const styles = useTheme((t) => t.styles?.footerCell);
|
|
1436
|
+
const classes = require_useTheme.useTheme((t) => t.classes?.footerCell);
|
|
1437
|
+
const styles = require_useTheme.useTheme((t) => t.styles?.footerCell);
|
|
3200
1438
|
const { stickyFooter, enableClearFiltersButton } = props;
|
|
3201
1439
|
const hasActiveFilters = filteredColumns(props, visibleColumns).some((column) => isActiveFilter(column.filter, filterValues.get(column.id)));
|
|
3202
1440
|
const hasFooter = activeColumns.some((column) => column.footer);
|
|
@@ -3238,7 +1476,7 @@ function FilterPanel({ column, close }) {
|
|
|
3238
1476
|
const [draft, setDraft] = (0, react.useState)();
|
|
3239
1477
|
const { filter } = column;
|
|
3240
1478
|
const delay = filter?.debounce ?? 0;
|
|
3241
|
-
const commit = (0, react.useMemo)(() => debounce((value) => {
|
|
1479
|
+
const commit = (0, react.useMemo)(() => require_useTheme.debounce((value) => {
|
|
3242
1480
|
actions.setFilterValue(column.id, value);
|
|
3243
1481
|
setDraft(void 0);
|
|
3244
1482
|
}, delay), [
|
|
@@ -3249,7 +1487,7 @@ function FilterPanel({ column, close }) {
|
|
|
3249
1487
|
(0, react.useEffect)(() => () => commit.flush(), [commit]);
|
|
3250
1488
|
const getValues = (0, react.useMemo)(() => {
|
|
3251
1489
|
let values;
|
|
3252
|
-
return () => values ??= uniq(items.flatMap((item) => toSingles(column.filterBy(column.value(item.value), item.value))));
|
|
1490
|
+
return () => values ??= require_useTheme.uniq(items.flatMap((item) => require_useTheme.toSingles(column.filterBy(column.value(item.value), item.value))));
|
|
3253
1491
|
}, [items, column]);
|
|
3254
1492
|
if (!filter) return null;
|
|
3255
1493
|
function onChange(value) {
|
|
@@ -3273,9 +1511,9 @@ function FilterControl() {
|
|
|
3273
1511
|
const { filterValues, visibleColumns, actions } = useTableStructure();
|
|
3274
1512
|
const columnId = useColumnContext();
|
|
3275
1513
|
const column = visibleColumns.find((column) => column.id === columnId);
|
|
3276
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
3277
|
-
const FilterList = useTheme((t) => t.icons.FilterList);
|
|
3278
|
-
const ArrowDropDown = useTheme((t) => t.icons.ArrowDropDown);
|
|
1514
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
1515
|
+
const FilterList = require_useTheme.useTheme((t) => t.icons.FilterList);
|
|
1516
|
+
const ArrowDropDown = require_useTheme.useTheme((t) => t.icons.ArrowDropDown);
|
|
3279
1517
|
const [anchor, setAnchor] = (0, react.useState)(null);
|
|
3280
1518
|
if (!column?.filter) return null;
|
|
3281
1519
|
const isActive = isActiveFilter(column.filter, filterValues.get(columnId));
|
|
@@ -3299,10 +1537,10 @@ function FilterControl() {
|
|
|
3299
1537
|
})] });
|
|
3300
1538
|
}
|
|
3301
1539
|
function FilterPopover({ anchor, onClose, column, children }) {
|
|
3302
|
-
const Popover = useTheme((t) => t.components.Popover);
|
|
3303
|
-
const classes = useTheme((t) => t.classes);
|
|
3304
|
-
const styles = useTheme((t) => t.styles);
|
|
3305
|
-
const cssVariables = useCssVariables();
|
|
1540
|
+
const Popover = require_useTheme.useTheme((t) => t.components.Popover);
|
|
1541
|
+
const classes = require_useTheme.useTheme((t) => t.classes);
|
|
1542
|
+
const styles = require_useTheme.useTheme((t) => t.styles);
|
|
1543
|
+
const cssVariables = require_useTheme.useCssVariables();
|
|
3306
1544
|
const filterClassNames = column?.filter?.classNames;
|
|
3307
1545
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
3308
1546
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -3323,8 +1561,8 @@ function FilterPopover({ anchor, onClose, column, children }) {
|
|
|
3323
1561
|
function SortComponent({ children }) {
|
|
3324
1562
|
const { sort, activeColumns, props, actions } = useTableStructure();
|
|
3325
1563
|
const columnId = useColumnContext();
|
|
3326
|
-
const Badge = useTheme((t) => t.components.Badge);
|
|
3327
|
-
const ArrowUpward = useTheme((t) => t.icons.ArrowUpward);
|
|
1564
|
+
const Badge = require_useTheme.useTheme((t) => t.components.Badge);
|
|
1565
|
+
const ArrowUpward = require_useTheme.useTheme((t) => t.icons.ArrowUpward);
|
|
3328
1566
|
const sortIndex = sort.findIndex((s) => s.columnId === columnId);
|
|
3329
1567
|
const direction = sort[sortIndex]?.direction;
|
|
3330
1568
|
const index = sortIndex >= 0 && sort.length > 1 ? sortIndex + 1 : void 0;
|
|
@@ -3377,7 +1615,7 @@ function ColumnHeader() {
|
|
|
3377
1615
|
const columnId = useColumnContext();
|
|
3378
1616
|
const { activeColumns } = useTableStructure();
|
|
3379
1617
|
const column = activeColumns.find((column) => column.id === columnId);
|
|
3380
|
-
const { classes, styles } = useTheme((theme) => columnTheme(theme, column));
|
|
1618
|
+
const { classes, styles } = require_useTheme.useTheme((theme) => require_useTheme.columnTheme(theme, column));
|
|
3381
1619
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
3382
1620
|
"data-column-header": "",
|
|
3383
1621
|
className: classes?.headerCell,
|
|
@@ -3417,17 +1655,17 @@ function FormControlLabel({ control, label, disabled }) {
|
|
|
3417
1655
|
//#endregion
|
|
3418
1656
|
//#region src/components/columnSelection.tsx
|
|
3419
1657
|
function ColumnSelection() {
|
|
3420
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
3421
|
-
const Popover = useTheme((t) => t.components.Popover);
|
|
3422
|
-
const Checkbox = useTheme((t) => t.components.Checkbox);
|
|
3423
|
-
const Button = useTheme((t) => t.components.Button);
|
|
3424
|
-
const Settings = useTheme((t) => t.icons.Settings);
|
|
3425
|
-
const selectColumns = useTheme((t) => t.text.selectColumns);
|
|
3426
|
-
const resetAll = useTheme((t) => t.text.resetAll);
|
|
3427
|
-
const showAll = useTheme((t) => t.text.showAllColumns);
|
|
3428
|
-
const hideAll = useTheme((t) => t.text.hideAllColumns);
|
|
3429
|
-
const classes = useTheme((t) => t.classes);
|
|
3430
|
-
const cssVariables = useCssVariables();
|
|
1658
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
1659
|
+
const Popover = require_useTheme.useTheme((t) => t.components.Popover);
|
|
1660
|
+
const Checkbox = require_useTheme.useTheme((t) => t.components.Checkbox);
|
|
1661
|
+
const Button = require_useTheme.useTheme((t) => t.components.Button);
|
|
1662
|
+
const Settings = require_useTheme.useTheme((t) => t.icons.Settings);
|
|
1663
|
+
const selectColumns = require_useTheme.useTheme((t) => t.text.selectColumns);
|
|
1664
|
+
const resetAll = require_useTheme.useTheme((t) => t.text.resetAll);
|
|
1665
|
+
const showAll = require_useTheme.useTheme((t) => t.text.showAllColumns);
|
|
1666
|
+
const hideAll = require_useTheme.useTheme((t) => t.text.hideAllColumns);
|
|
1667
|
+
const classes = require_useTheme.useTheme((t) => t.classes);
|
|
1668
|
+
const cssVariables = require_useTheme.useCssVariables();
|
|
3431
1669
|
const { columns, hiddenColumns, actions } = useTableStructure();
|
|
3432
1670
|
const [anchorElement, setAnchorElement] = (0, react.useState)(null);
|
|
3433
1671
|
const toggle = (column, state) => {
|
|
@@ -3490,16 +1728,16 @@ function ColumnSelection() {
|
|
|
3490
1728
|
function Export() {
|
|
3491
1729
|
const { exporters: contextExporters } = (0, react.useContext)(require_tableTheme.TableSettingsContext);
|
|
3492
1730
|
const { props, actions } = useTableStructure();
|
|
3493
|
-
const Button = useTheme((t) => t.components.Button);
|
|
3494
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
3495
|
-
const Popover = useTheme((t) => t.components.Popover);
|
|
3496
|
-
const ExportIcon = useTheme((t) => t.icons.Export);
|
|
3497
|
-
const Clipboard = useTheme((t) => t.icons.Clipboard);
|
|
3498
|
-
const exportTitle = useTheme((t) => t.text.exportTitle);
|
|
3499
|
-
const exportCopy = useTheme((t) => t.text.exportCopy);
|
|
3500
|
-
const exportDownload = useTheme((t) => t.text.exportDownload);
|
|
3501
|
-
const classes = useTheme((t) => t.classes);
|
|
3502
|
-
const cssVariables = useCssVariables();
|
|
1731
|
+
const Button = require_useTheme.useTheme((t) => t.components.Button);
|
|
1732
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
1733
|
+
const Popover = require_useTheme.useTheme((t) => t.components.Popover);
|
|
1734
|
+
const ExportIcon = require_useTheme.useTheme((t) => t.icons.Export);
|
|
1735
|
+
const Clipboard = require_useTheme.useTheme((t) => t.icons.Clipboard);
|
|
1736
|
+
const exportTitle = require_useTheme.useTheme((t) => t.text.exportTitle);
|
|
1737
|
+
const exportCopy = require_useTheme.useTheme((t) => t.text.exportCopy);
|
|
1738
|
+
const exportDownload = require_useTheme.useTheme((t) => t.text.exportDownload);
|
|
1739
|
+
const classes = require_useTheme.useTheme((t) => t.classes);
|
|
1740
|
+
const cssVariables = require_useTheme.useCssVariables();
|
|
3503
1741
|
const { all, exporters } = typeof props.enableExport === "boolean" || props.enableExport === void 0 ? {
|
|
3504
1742
|
all: false,
|
|
3505
1743
|
exporters: contextExporters
|
|
@@ -3571,10 +1809,10 @@ function Export() {
|
|
|
3571
1809
|
/** Lets users edit the filters of columns that are not visible, see `enableHiddenColumnFilters`. */
|
|
3572
1810
|
function HiddenColumnFilters() {
|
|
3573
1811
|
const { props, visibleColumns, filterValues, actions } = useTableStructure();
|
|
3574
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
3575
|
-
const Button = useTheme((t) => t.components.Button);
|
|
3576
|
-
const FilterList = useTheme((t) => t.icons.FilterList);
|
|
3577
|
-
const title = useTheme((t) => t.text.hiddenColumnFilters);
|
|
1812
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
1813
|
+
const Button = require_useTheme.useTheme((t) => t.components.Button);
|
|
1814
|
+
const FilterList = require_useTheme.useTheme((t) => t.icons.FilterList);
|
|
1815
|
+
const title = require_useTheme.useTheme((t) => t.text.hiddenColumnFilters);
|
|
3578
1816
|
const [anchor, setAnchor] = (0, react.useState)(null);
|
|
3579
1817
|
const [selected, setSelected] = (0, react.useState)();
|
|
3580
1818
|
const columns = props.columns.filter((column) => column.filter && !visibleColumns.some((visible) => visible.id === column.id));
|
|
@@ -3634,8 +1872,8 @@ function HiddenColumnFilters() {
|
|
|
3634
1872
|
//#region src/components/tableHeader.tsx
|
|
3635
1873
|
const TableHeader = (0, react.memo)(function TableHeader() {
|
|
3636
1874
|
const { props, visibleColumns } = useTableStructure();
|
|
3637
|
-
const classes = useTheme((t) => t.classes?.headerCell);
|
|
3638
|
-
const styles = useTheme((t) => t.styles?.headerCell);
|
|
1875
|
+
const classes = require_useTheme.useTheme((t) => t.classes?.headerCell);
|
|
1876
|
+
const styles = require_useTheme.useTheme((t) => t.styles?.headerCell);
|
|
3639
1877
|
const { stickyHeader, enableSelection, enableColumnSelection, enableExport } = props;
|
|
3640
1878
|
const { enableHiddenColumnFilters } = props;
|
|
3641
1879
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
@@ -3720,6 +1958,7 @@ function useScrollRoot(tableRef, probe) {
|
|
|
3720
1958
|
return root;
|
|
3721
1959
|
}
|
|
3722
1960
|
function VirtualWindow({ virtualizer, renderRow, measure }) {
|
|
1961
|
+
"use no memo";
|
|
3723
1962
|
const items = virtualizer.getVirtualItems();
|
|
3724
1963
|
const scheduler = (0, react.useContext)(CellSchedulerContext);
|
|
3725
1964
|
(0, react.useLayoutEffect)(() => {
|
|
@@ -3751,6 +1990,7 @@ function virtualizerOptions({ count, getKey, options, scrollMargin }) {
|
|
|
3751
1990
|
};
|
|
3752
1991
|
}
|
|
3753
1992
|
function ElementRows(props) {
|
|
1993
|
+
"use no memo";
|
|
3754
1994
|
const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
|
|
3755
1995
|
...virtualizerOptions(props),
|
|
3756
1996
|
getScrollElement: () => props.root
|
|
@@ -3762,6 +2002,7 @@ function ElementRows(props) {
|
|
|
3762
2002
|
});
|
|
3763
2003
|
}
|
|
3764
2004
|
function WindowRows(props) {
|
|
2005
|
+
"use no memo";
|
|
3765
2006
|
const virtualizer = (0, _tanstack_react_virtual.useWindowVirtualizer)(virtualizerOptions(props));
|
|
3766
2007
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(VirtualWindow, {
|
|
3767
2008
|
virtualizer,
|
|
@@ -3796,9 +2037,9 @@ function VirtualRows({ tableRef, ...props }) {
|
|
|
3796
2037
|
//#region src/components/tableGrid.tsx
|
|
3797
2038
|
function TableGrid({ hidden }) {
|
|
3798
2039
|
const state = useTableContext();
|
|
3799
|
-
const theme = useTheme((t) => t);
|
|
2040
|
+
const theme = require_useTheme.useTheme((t) => t);
|
|
3800
2041
|
const { props, visibleColumns, columnWidths, activeItems, expanded } = state;
|
|
3801
|
-
const cssVariables = useCssVariables();
|
|
2042
|
+
const cssVariables = require_useTheme.useCssVariables();
|
|
3802
2043
|
const tableRef = (0, react.useRef)(null);
|
|
3803
2044
|
const debugRenderRef = (0, react.useRef)(props.debugRender);
|
|
3804
2045
|
debugRenderRef.current = props.debugRender;
|
|
@@ -3889,7 +2130,7 @@ function TableGrid({ hidden }) {
|
|
|
3889
2130
|
//#region src/components/tableLoadingState.tsx
|
|
3890
2131
|
function TableLoadingState({ isHydrated }) {
|
|
3891
2132
|
const [showLoading, setShowLoading] = (0, react.useState)(false);
|
|
3892
|
-
const loadingText = useTheme((t) => t.text.loading);
|
|
2133
|
+
const loadingText = require_useTheme.useTheme((t) => t.text.loading);
|
|
3893
2134
|
(0, react.useEffect)(() => {
|
|
3894
2135
|
const handle = setTimeout(() => setShowLoading(true), 500);
|
|
3895
2136
|
return () => clearTimeout(handle);
|
|
@@ -3911,7 +2152,7 @@ function TableWithState({ props, tableRef, onReset, isReset }) {
|
|
|
3911
2152
|
const table = useTable(props, onReset, isReset);
|
|
3912
2153
|
const { context, structure, actions, theme, isHydrated } = table;
|
|
3913
2154
|
useTableImperativeHandle(tableRef, table);
|
|
3914
|
-
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ThemeContext.Provider, {
|
|
2155
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_useTheme.ThemeContext.Provider, {
|
|
3915
2156
|
value: theme,
|
|
3916
2157
|
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(TableActionsContext.Provider, {
|
|
3917
2158
|
value: actions,
|
|
@@ -3965,7 +2206,7 @@ function DateFilterComponent({ value = null, onChange, close, options: { locale,
|
|
|
3965
2206
|
padding: "calc(var(--spacing) * 2)",
|
|
3966
2207
|
display: "grid"
|
|
3967
2208
|
},
|
|
3968
|
-
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(DatePicker, {
|
|
2209
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_useTheme.DatePicker, {
|
|
3969
2210
|
rangeSelect: !singleSelect,
|
|
3970
2211
|
value: value ?? null,
|
|
3971
2212
|
onChange: (value, source) => {
|
|
@@ -3985,7 +2226,7 @@ function DateFilterComponent({ value = null, onChange, close, options: { locale,
|
|
|
3985
2226
|
}
|
|
3986
2227
|
const dateFilter = defineFilter({
|
|
3987
2228
|
isActive: (value) => !!value,
|
|
3988
|
-
test: (value, input) => toSingles(input).some((x) => dateIntersect(value, toDate(x))),
|
|
2229
|
+
test: (value, input) => require_useTheme.toSingles(input).some((x) => require_useTheme.dateIntersect(value, toDate(x))),
|
|
3989
2230
|
Component: DateFilterComponent
|
|
3990
2231
|
});
|
|
3991
2232
|
//#endregion
|
|
@@ -4001,8 +2242,8 @@ const parseNumber = (value) => {
|
|
|
4001
2242
|
return Number.isNaN(asNumber) ? null : asNumber;
|
|
4002
2243
|
};
|
|
4003
2244
|
function NumberField({ value: commitedValue = null, onChange, ...textFieldProps }) {
|
|
4004
|
-
const locale = useTheme((t) => t.locale);
|
|
4005
|
-
const TextField = useTheme((t) => t.components.TextField);
|
|
2245
|
+
const locale = require_useTheme.useTheme((t) => t.locale);
|
|
2246
|
+
const TextField = require_useTheme.useTheme((t) => t.components.TextField);
|
|
4006
2247
|
const [value = printNumber(commitedValue, locale), setValue] = (0, react.useState)();
|
|
4007
2248
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(TextField, {
|
|
4008
2249
|
value,
|
|
@@ -4023,8 +2264,8 @@ function NumberField({ value: commitedValue = null, onChange, ...textFieldProps
|
|
|
4023
2264
|
//#endregion
|
|
4024
2265
|
//#region src/filters/rangeFilter.tsx
|
|
4025
2266
|
function RangeFilterComponent({ value, onChange, options: { min, max }, getValues }) {
|
|
4026
|
-
const rangeMinText = useTheme((t) => t.text.rangeMin);
|
|
4027
|
-
const rangeMaxText = useTheme((t) => t.text.rangeMax);
|
|
2267
|
+
const rangeMinText = require_useTheme.useTheme((t) => t.text.rangeMin);
|
|
2268
|
+
const rangeMaxText = require_useTheme.useTheme((t) => t.text.rangeMax);
|
|
4028
2269
|
const [minValue, maxValue] = (0, react.useMemo)(() => {
|
|
4029
2270
|
if (typeof min === "number" && typeof max === "number") return [min, max];
|
|
4030
2271
|
let minValue;
|
|
@@ -4092,7 +2333,7 @@ const rangeFilter = defineFilter({
|
|
|
4092
2333
|
if (!value || value[0] === null && value[1] === null) return true;
|
|
4093
2334
|
const min = value[0] ?? Number.NEGATIVE_INFINITY;
|
|
4094
2335
|
const max = value[1] ?? Number.POSITIVE_INFINITY;
|
|
4095
|
-
return toSingles(input).some((x) => (typeof x === "number" || typeof x === "bigint") && x >= min && x <= max);
|
|
2336
|
+
return require_useTheme.toSingles(input).some((x) => (typeof x === "number" || typeof x === "bigint") && x >= min && x <= max);
|
|
4096
2337
|
},
|
|
4097
2338
|
Component: RangeFilterComponent
|
|
4098
2339
|
});
|
|
@@ -4164,16 +2405,16 @@ function toggle(set, value, singleSelect) {
|
|
|
4164
2405
|
else newSet.add(value);
|
|
4165
2406
|
return newSet;
|
|
4166
2407
|
}
|
|
4167
|
-
function SelectFilterComponent({ value: currentValue, onChange, options: { options: providedOptions, stringValue = asString, render = stringValue, singleSelect, hideSearchField, hideResetButton, virtual }, getValues }) {
|
|
4168
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
4169
|
-
const Checkbox = useTheme((t) => t.components.Checkbox);
|
|
4170
|
-
const Button = useTheme((t) => t.components.Button);
|
|
4171
|
-
const Search = useTheme((t) => t.icons.Search);
|
|
4172
|
-
const Clear = useTheme((t) => t.icons.Clear);
|
|
4173
|
-
const deselectAll = useTheme((t) => t.text.deselectAll);
|
|
4174
|
-
const noResults = useTheme((t) => t.text.noResults);
|
|
2408
|
+
function SelectFilterComponent({ value: currentValue, onChange, options: { options: providedOptions, stringValue = require_useTheme.asString, render = stringValue, singleSelect, hideSearchField, hideResetButton, virtual }, getValues }) {
|
|
2409
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
2410
|
+
const Checkbox = require_useTheme.useTheme((t) => t.components.Checkbox);
|
|
2411
|
+
const Button = require_useTheme.useTheme((t) => t.components.Button);
|
|
2412
|
+
const Search = require_useTheme.useTheme((t) => t.icons.Search);
|
|
2413
|
+
const Clear = require_useTheme.useTheme((t) => t.icons.Clear);
|
|
2414
|
+
const deselectAll = require_useTheme.useTheme((t) => t.text.deselectAll);
|
|
2415
|
+
const noResults = require_useTheme.useTheme((t) => t.text.noResults);
|
|
4175
2416
|
const value = currentValue ?? /* @__PURE__ */ new Set();
|
|
4176
|
-
const options = (0, react.useMemo)(() => providedOptions ? uniq(providedOptions) : orderBy(getValues()), [providedOptions, getValues]);
|
|
2417
|
+
const options = (0, react.useMemo)(() => providedOptions ? require_useTheme.uniq(providedOptions) : require_useTheme.orderBy(getValues()), [providedOptions, getValues]);
|
|
4177
2418
|
const [query, setQuery] = (0, react.useState)("");
|
|
4178
2419
|
const [initialValue] = (0, react.useState)(value);
|
|
4179
2420
|
const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));
|
|
@@ -4236,7 +2477,7 @@ function SelectFilterComponent({ value: currentValue, onChange, options: { optio
|
|
|
4236
2477
|
/** Accepts any value; typing `options`, `defaultValue`, `render` etc. narrows it. */
|
|
4237
2478
|
const selectFilter = defineFilter({
|
|
4238
2479
|
isActive: (value) => value.size > 0,
|
|
4239
|
-
test: (value, input) => toSingles(input).some((x) => value.has(x)),
|
|
2480
|
+
test: (value, input) => require_useTheme.toSingles(input).some((x) => value.has(x)),
|
|
4240
2481
|
Component: SelectFilterComponent
|
|
4241
2482
|
});
|
|
4242
2483
|
//#endregion
|
|
@@ -4247,9 +2488,9 @@ const compares = {
|
|
|
4247
2488
|
exact: (itemValue, filterValue) => itemValue.toLowerCase() === filterValue.toLowerCase()
|
|
4248
2489
|
};
|
|
4249
2490
|
function TextFilterComponent({ value, onChange, close, options }) {
|
|
4250
|
-
const IconButton = useTheme((t) => t.components.IconButton);
|
|
4251
|
-
const Search = useTheme((t) => t.icons.Search);
|
|
4252
|
-
const Clear = useTheme((t) => t.icons.Clear);
|
|
2491
|
+
const IconButton = require_useTheme.useTheme((t) => t.components.IconButton);
|
|
2492
|
+
const Search = require_useTheme.useTheme((t) => t.icons.Search);
|
|
2493
|
+
const Clear = require_useTheme.useTheme((t) => t.icons.Clear);
|
|
4253
2494
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
4254
2495
|
css: {
|
|
4255
2496
|
padding: `calc(var(--spacing) * 2)`,
|
|
@@ -4273,7 +2514,7 @@ const textFilter = defineFilter({
|
|
|
4273
2514
|
isActive: (value) => !!value,
|
|
4274
2515
|
test(value, input, { compare = "contains" }) {
|
|
4275
2516
|
const match = typeof compare === "function" ? compare : compares[compare];
|
|
4276
|
-
return toSingles(input).some((x) => x !== null && x !== void 0 && match(String(x), value));
|
|
2517
|
+
return require_useTheme.toSingles(input).some((x) => x !== null && x !== void 0 && match(String(x), value));
|
|
4277
2518
|
},
|
|
4278
2519
|
debounce: 300,
|
|
4279
2520
|
Component: TextFilterComponent
|
|
@@ -4299,43 +2540,45 @@ const termMatch = (text, query) => {
|
|
|
4299
2540
|
//#endregion
|
|
4300
2541
|
exports.AutoFocusTextField = AutoFocusTextField;
|
|
4301
2542
|
exports.ColumnContext = ColumnContext;
|
|
4302
|
-
exports.DatePicker = DatePicker;
|
|
4303
|
-
exports.DatePickerProvider = DatePickerProvider;
|
|
2543
|
+
exports.DatePicker = require_useTheme.DatePicker;
|
|
2544
|
+
exports.DatePickerProvider = require_useTheme.DatePickerProvider;
|
|
2545
|
+
exports.DatePickerQuickOptions = require_useTheme.DatePickerQuickOptions;
|
|
2546
|
+
exports.DefaultDatePicker = require_useTheme.DefaultDatePicker;
|
|
4304
2547
|
exports.Table = Table;
|
|
4305
2548
|
exports.TableActionsContext = TableActionsContext;
|
|
4306
2549
|
exports.TableContext = TableContext;
|
|
4307
2550
|
exports.TableSettingsContext = require_tableTheme.TableSettingsContext;
|
|
4308
2551
|
exports.TableSettingsProvider = require_tableTheme.TableSettingsProvider;
|
|
4309
2552
|
exports.TableStructureContext = TableStructureContext;
|
|
4310
|
-
exports.commonQuickOptions = commonQuickOptions;
|
|
4311
|
-
exports.dateClamp = dateClamp;
|
|
2553
|
+
exports.commonQuickOptions = require_useTheme.commonQuickOptions;
|
|
2554
|
+
exports.dateClamp = require_useTheme.dateClamp;
|
|
4312
2555
|
exports.dateFilter = dateFilter;
|
|
4313
|
-
exports.dateIntersect = dateIntersect;
|
|
2556
|
+
exports.dateIntersect = require_useTheme.dateIntersect;
|
|
4314
2557
|
exports.defineFilter = defineFilter;
|
|
4315
|
-
exports.endOfDay = endOfDay;
|
|
4316
|
-
exports.getCalendarWeek = getCalendarWeek;
|
|
2558
|
+
exports.endOfDay = require_useTheme.endOfDay;
|
|
2559
|
+
exports.getCalendarWeek = require_useTheme.getCalendarWeek;
|
|
4317
2560
|
Object.defineProperty(exports, "helpers", {
|
|
4318
2561
|
enumerable: true,
|
|
4319
2562
|
get: function() {
|
|
4320
|
-
return helpers_exports;
|
|
2563
|
+
return require_useTheme.helpers_exports;
|
|
4321
2564
|
}
|
|
4322
2565
|
});
|
|
4323
|
-
exports.lastDays = lastDays;
|
|
2566
|
+
exports.lastDays = require_useTheme.lastDays;
|
|
4324
2567
|
exports.mergeThemes = require_tableTheme.mergeThemes;
|
|
4325
2568
|
exports.rangeFilter = rangeFilter;
|
|
4326
2569
|
exports.selectFilter = selectFilter;
|
|
4327
|
-
exports.startOfDay = startOfDay;
|
|
2570
|
+
exports.startOfDay = require_useTheme.startOfDay;
|
|
4328
2571
|
exports.termMatch = termMatch;
|
|
4329
2572
|
exports.textFilter = textFilter;
|
|
4330
2573
|
exports.textMatch = textMatch;
|
|
4331
|
-
exports.thisMonth = thisMonth;
|
|
4332
|
-
exports.thisWeek = thisWeek;
|
|
4333
|
-
exports.thisYear = thisYear;
|
|
4334
|
-
exports.today = today;
|
|
2574
|
+
exports.thisMonth = require_useTheme.thisMonth;
|
|
2575
|
+
exports.thisWeek = require_useTheme.thisWeek;
|
|
2576
|
+
exports.thisYear = require_useTheme.thisYear;
|
|
2577
|
+
exports.today = require_useTheme.today;
|
|
4335
2578
|
exports.useColumnContext = useColumnContext;
|
|
4336
2579
|
exports.useTableActions = useTableActions;
|
|
4337
2580
|
exports.useTableContext = useTableContext;
|
|
4338
2581
|
exports.useTableStructure = useTableStructure;
|
|
4339
|
-
exports.useTheme = useTheme;
|
|
2582
|
+
exports.useTheme = require_useTheme.useTheme;
|
|
4340
2583
|
|
|
4341
2584
|
//# sourceMappingURL=index.cjs.map
|