@prt-ts/fluent-react-table-v2 9.44.3-build.1.0 → 9.46.7-build.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/index.cjs.js +2197 -0
- package/index.esm.js +4 -8
- package/package.json +10 -11
- package/src/lib/types/TableView.d.ts +1 -1
- /package/{index.esm.d.ts → index.cjs.d.ts} +0 -0
package/index.cjs.js
ADDED
|
@@ -0,0 +1,2197 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactDnd = require('react-dnd');
|
|
8
|
+
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
9
|
+
var reactComponents = require('@fluentui/react-components');
|
|
10
|
+
var reactTable = require('@tanstack/react-table');
|
|
11
|
+
var reactVirtual = require('react-virtual');
|
|
12
|
+
var reactDatepickerCompat = require('@fluentui/react-datepicker-compat');
|
|
13
|
+
|
|
14
|
+
function _interopNamespace(e) {
|
|
15
|
+
if (e && e.__esModule) return e;
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n["default"] = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
|
+
|
|
34
|
+
const useStaticStyles = reactComponents.makeStaticStyles({
|
|
35
|
+
"*": {
|
|
36
|
+
boxSizing: "border-box",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const useTableStaticStyles = reactComponents.makeStyles({
|
|
40
|
+
tableContainer: Object.assign(Object.assign({ height: "650px", width: "100%" }, reactComponents.shorthands.overflow("hidden", "auto")), {
|
|
41
|
+
/* width */
|
|
42
|
+
":hover": Object.assign({}, reactComponents.shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "6px", height: "4px" }, reactComponents.shorthands.borderRadius("50%")),
|
|
43
|
+
/* Track */
|
|
44
|
+
"::-webkit-scrollbar-track": {
|
|
45
|
+
"background-color": "#f1f1f1",
|
|
46
|
+
},
|
|
47
|
+
/* Handle */
|
|
48
|
+
"::-webkit-scrollbar-thumb": {
|
|
49
|
+
"background-color": "#888",
|
|
50
|
+
},
|
|
51
|
+
/* Handle on hover */
|
|
52
|
+
"::-webkit-scrollbar-thumb:hover": {
|
|
53
|
+
"background-color": "#555",
|
|
54
|
+
} }),
|
|
55
|
+
table: {
|
|
56
|
+
width: "100%",
|
|
57
|
+
borderCollapse: "collapse",
|
|
58
|
+
},
|
|
59
|
+
tFoot: {
|
|
60
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground1,
|
|
61
|
+
color: reactComponents.tokens.colorNeutralForeground1,
|
|
62
|
+
position: "sticky",
|
|
63
|
+
bottom: 0,
|
|
64
|
+
left: 0,
|
|
65
|
+
width: "100%",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const usePaginationStyle = reactComponents.makeStyles({
|
|
70
|
+
paginationContainer: Object.assign({ width: "100%", backgroundColor: reactComponents.tokens.colorNeutralBackground2Hover }, reactComponents.shorthands.padding("5px")),
|
|
71
|
+
wrapper: {
|
|
72
|
+
columnGap: "0.2rem",
|
|
73
|
+
display: "flex",
|
|
74
|
+
alignItems: "center",
|
|
75
|
+
alignContent: "center",
|
|
76
|
+
justifyContent: "space-between",
|
|
77
|
+
// if smaller size display flex column
|
|
78
|
+
"@media screen and (max-width: 640px)": {
|
|
79
|
+
flexDirection: "column",
|
|
80
|
+
rowGap: "0.2rem",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
pageBtnContainer: {
|
|
84
|
+
display: "flex",
|
|
85
|
+
columnGap: "3px",
|
|
86
|
+
},
|
|
87
|
+
pageBtn: {
|
|
88
|
+
minWidth: "1.5rem",
|
|
89
|
+
minHeight: "1.5rem",
|
|
90
|
+
alignContent: "center",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
},
|
|
93
|
+
pageSelectionWrapper: {
|
|
94
|
+
minWidth: "1.5rem",
|
|
95
|
+
},
|
|
96
|
+
pageSelectionDropdown: {
|
|
97
|
+
minWidth: "100%",
|
|
98
|
+
},
|
|
99
|
+
pageSizeInput: {
|
|
100
|
+
minWidth: "1.5rem",
|
|
101
|
+
width: "4rem",
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const IconDirectionContext = React__namespace.createContext(undefined);
|
|
106
|
+
const IconDirectionContextDefaultValue = {};
|
|
107
|
+
IconDirectionContext.Provider;
|
|
108
|
+
const useIconContext = () => React__namespace.useContext(IconDirectionContext) ? React__namespace.useContext(IconDirectionContext) : IconDirectionContextDefaultValue;
|
|
109
|
+
|
|
110
|
+
// ----
|
|
111
|
+
// Heads up!
|
|
112
|
+
// These constants are global and will be shared between Griffel instances.
|
|
113
|
+
// Any change in them should happen only in a MAJOR version. If it happens,
|
|
114
|
+
// please change "__NAMESPACE_PREFIX__" to include a version.
|
|
115
|
+
const __GLOBAL__ = typeof window === 'undefined' ? global : window;
|
|
116
|
+
const __NAMESPACE_PREFIX__ = '@griffel/';
|
|
117
|
+
function getGlobalVar(name, defaultValue) {
|
|
118
|
+
if (!__GLOBAL__[Symbol.for(__NAMESPACE_PREFIX__ + name)]) {
|
|
119
|
+
__GLOBAL__[Symbol.for(__NAMESPACE_PREFIX__ + name)] = defaultValue;
|
|
120
|
+
}
|
|
121
|
+
return __GLOBAL__[Symbol.for(__NAMESPACE_PREFIX__ + name)];
|
|
122
|
+
}
|
|
123
|
+
/** @internal */
|
|
124
|
+
const DEBUG_RESET_CLASSES = /*#__PURE__*/getGlobalVar('DEBUG_RESET_CLASSES', {});
|
|
125
|
+
/** @internal */
|
|
126
|
+
const DEFINITION_LOOKUP_TABLE = /*#__PURE__*/getGlobalVar('DEFINITION_LOOKUP_TABLE', {});
|
|
127
|
+
// ----
|
|
128
|
+
/** @internal */
|
|
129
|
+
const DATA_BUCKET_ATTR = 'data-make-styles-bucket';
|
|
130
|
+
/** @internal */
|
|
131
|
+
const RESET_HASH_PREFIX = 'r';
|
|
132
|
+
/** @internal */
|
|
133
|
+
const SEQUENCE_HASH_LENGTH = 7;
|
|
134
|
+
/** @internal */
|
|
135
|
+
const SEQUENCE_PREFIX = '___';
|
|
136
|
+
/** @internal */
|
|
137
|
+
const DEBUG_SEQUENCE_SEPARATOR = '_';
|
|
138
|
+
/** @internal */
|
|
139
|
+
const SEQUENCE_SIZE = process.env.NODE_ENV === 'production' ? SEQUENCE_PREFIX.length + SEQUENCE_HASH_LENGTH : SEQUENCE_PREFIX.length + SEQUENCE_HASH_LENGTH + DEBUG_SEQUENCE_SEPARATOR.length + SEQUENCE_HASH_LENGTH;
|
|
140
|
+
// indexes for values in LookupItem tuple
|
|
141
|
+
/** @internal */
|
|
142
|
+
const LOOKUP_DEFINITIONS_INDEX = 0;
|
|
143
|
+
/** @internal */
|
|
144
|
+
const LOOKUP_DIR_INDEX = 1;
|
|
145
|
+
|
|
146
|
+
/* eslint-disable */
|
|
147
|
+
// Inspired by https://github.com/garycourt/murmurhash-js
|
|
148
|
+
// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
|
|
149
|
+
function murmur2(str) {
|
|
150
|
+
// 'm' and 'r' are mixing constants generated offline.
|
|
151
|
+
// They're not really 'magic', they just happen to work well.
|
|
152
|
+
// const m = 0x5bd1e995;
|
|
153
|
+
// const r = 24;
|
|
154
|
+
// Initialize the hash
|
|
155
|
+
var h = 0; // Mix 4 bytes at a time into the hash
|
|
156
|
+
|
|
157
|
+
var k,
|
|
158
|
+
i = 0,
|
|
159
|
+
len = str.length;
|
|
160
|
+
|
|
161
|
+
for (; len >= 4; ++i, len -= 4) {
|
|
162
|
+
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
|
|
163
|
+
k =
|
|
164
|
+
/* Math.imul(k, m): */
|
|
165
|
+
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
|
|
166
|
+
k ^=
|
|
167
|
+
/* k >>> r: */
|
|
168
|
+
k >>> 24;
|
|
169
|
+
h =
|
|
170
|
+
/* Math.imul(k, m): */
|
|
171
|
+
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
|
|
172
|
+
/* Math.imul(h, m): */
|
|
173
|
+
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
174
|
+
} // Handle the last few bytes of the input array
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
switch (len) {
|
|
178
|
+
case 3:
|
|
179
|
+
h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
|
|
180
|
+
|
|
181
|
+
case 2:
|
|
182
|
+
h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
|
|
183
|
+
|
|
184
|
+
case 1:
|
|
185
|
+
h ^= str.charCodeAt(i) & 0xff;
|
|
186
|
+
h =
|
|
187
|
+
/* Math.imul(h, m): */
|
|
188
|
+
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
189
|
+
} // Do a few final mixes of the hash to ensure the last few
|
|
190
|
+
// bytes are well-incorporated.
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
h ^= h >>> 13;
|
|
194
|
+
h =
|
|
195
|
+
/* Math.imul(h, m): */
|
|
196
|
+
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
197
|
+
return ((h ^ h >>> 15) >>> 0).toString(36);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function padEndHash(value) {
|
|
201
|
+
const hashLength = value.length;
|
|
202
|
+
if (hashLength === SEQUENCE_HASH_LENGTH) {
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
for (let i = hashLength; i < SEQUENCE_HASH_LENGTH; i++) {
|
|
206
|
+
value += '0';
|
|
207
|
+
}
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
function hashSequence(classes, dir, sequenceIds = []) {
|
|
211
|
+
if (process.env.NODE_ENV === 'production') {
|
|
212
|
+
return SEQUENCE_PREFIX + padEndHash(murmur2(classes + dir));
|
|
213
|
+
}
|
|
214
|
+
return SEQUENCE_PREFIX + padEndHash(murmur2(classes + dir)) + DEBUG_SEQUENCE_SEPARATOR + padEndHash(murmur2(sequenceIds.join('')));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Reduces a classname map for slot to a classname string. Uses classnames according to text directions.
|
|
219
|
+
*
|
|
220
|
+
* @private
|
|
221
|
+
*/
|
|
222
|
+
function reduceToClassName(classMap, dir) {
|
|
223
|
+
let className = '';
|
|
224
|
+
// eslint-disable-next-line guard-for-in
|
|
225
|
+
for (const propertyHash in classMap) {
|
|
226
|
+
const classNameMapping = classMap[propertyHash];
|
|
227
|
+
if (classNameMapping) {
|
|
228
|
+
const hasRTLClassName = Array.isArray(classNameMapping);
|
|
229
|
+
if (dir === 'rtl') {
|
|
230
|
+
className += (hasRTLClassName ? classNameMapping[1] : classNameMapping) + ' ';
|
|
231
|
+
} else {
|
|
232
|
+
className += (hasRTLClassName ? classNameMapping[0] : classNameMapping) + ' ';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return className.slice(0, -1);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Reduces classname maps for slots to classname strings. Registers them in a definition cache to be used by
|
|
240
|
+
* `mergeClasses()`.
|
|
241
|
+
*
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
function reduceToClassNameForSlots(classesMapBySlot, dir) {
|
|
245
|
+
const classNamesForSlots = {};
|
|
246
|
+
// eslint-disable-next-line guard-for-in
|
|
247
|
+
for (const slotName in classesMapBySlot) {
|
|
248
|
+
const slotClasses = reduceToClassName(classesMapBySlot[slotName], dir);
|
|
249
|
+
// Handles a case when there are no classes in a set i.e. "makeStyles({ root: {} })"
|
|
250
|
+
if (slotClasses === '') {
|
|
251
|
+
classNamesForSlots[slotName] = '';
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const sequenceHash = hashSequence(slotClasses, dir);
|
|
255
|
+
const resultSlotClasses = sequenceHash + ' ' + slotClasses;
|
|
256
|
+
DEFINITION_LOOKUP_TABLE[sequenceHash] = [classesMapBySlot[slotName], dir];
|
|
257
|
+
classNamesForSlots[slotName] = resultSlotClasses;
|
|
258
|
+
}
|
|
259
|
+
return classNamesForSlots;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Contains a mapping of previously resolved sequences of atomic classnames
|
|
263
|
+
const mergeClassesCachedResults = {};
|
|
264
|
+
function mergeClasses() {
|
|
265
|
+
// arguments are parsed manually to avoid double loops as TS & Babel transforms rest via an additional loop
|
|
266
|
+
// @see https://babeljs.io/docs/en/babel-plugin-transform-parameters
|
|
267
|
+
/* eslint-disable prefer-rest-params */
|
|
268
|
+
let dir = null;
|
|
269
|
+
let resultClassName = '';
|
|
270
|
+
// Is used as a cache key to avoid object merging
|
|
271
|
+
let sequenceMatch = '';
|
|
272
|
+
const sequencesIds = new Array(arguments.length);
|
|
273
|
+
let containsResetClassName = '';
|
|
274
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
275
|
+
const className = arguments[i];
|
|
276
|
+
if (typeof className === 'string' && className !== '') {
|
|
277
|
+
// All classes generated by `makeStyles()` are prefixed by a sequence hash, this allows to identify class sets
|
|
278
|
+
// without parsing each className in a string
|
|
279
|
+
const sequenceIndex = className.indexOf(SEQUENCE_PREFIX);
|
|
280
|
+
if (sequenceIndex === -1) {
|
|
281
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
282
|
+
className.split(' ').forEach(entry => {
|
|
283
|
+
if (entry.startsWith(RESET_HASH_PREFIX) && DEBUG_RESET_CLASSES[entry]) {
|
|
284
|
+
if (containsResetClassName) {
|
|
285
|
+
// eslint-disable-next-line no-console
|
|
286
|
+
console.error('mergeClasses(): a passed string contains multiple classes produced by makeResetStyles (' + `${className} & ${resultClassName}, this will lead to non-deterministic behavior. Learn more:` + 'https://griffel.js.org/react/api/make-reset-styles#limitations' + '\n' + `Source string: ${className}`);
|
|
287
|
+
} else {
|
|
288
|
+
containsResetClassName = entry;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
resultClassName += className + ' ';
|
|
294
|
+
} else {
|
|
295
|
+
const sequenceId = className.substr(sequenceIndex, SEQUENCE_SIZE);
|
|
296
|
+
// Handles a case with mixed classnames, i.e. "ui-button ATOMIC_CLASSES"
|
|
297
|
+
if (sequenceIndex > 0) {
|
|
298
|
+
resultClassName += className.slice(0, sequenceIndex);
|
|
299
|
+
}
|
|
300
|
+
sequenceMatch += sequenceId;
|
|
301
|
+
sequencesIds[i] = sequenceId;
|
|
302
|
+
}
|
|
303
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
304
|
+
if (className.indexOf(SEQUENCE_PREFIX, sequenceIndex + 1) !== -1) {
|
|
305
|
+
// eslint-disable-next-line no-console
|
|
306
|
+
console.error('mergeClasses(): a passed string contains multiple identifiers of atomic classes (classes that start ' + `with "${SEQUENCE_PREFIX}"), it's possible that passed classes were concatenated in a wrong way. ` + `Source string: ${className}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// .slice() there allows to avoid trailing space for non-atomic classes
|
|
312
|
+
// "ui-button ui-flex " => "ui-button ui-flex"
|
|
313
|
+
if (sequenceMatch === '') {
|
|
314
|
+
return resultClassName.slice(0, -1);
|
|
315
|
+
}
|
|
316
|
+
// It's safe to reuse results to avoid continuous merging as results are stable
|
|
317
|
+
// "__seq1 ... __seq2 ..." => "__seq12 ..."
|
|
318
|
+
const mergeClassesResult = mergeClassesCachedResults[sequenceMatch];
|
|
319
|
+
if (mergeClassesResult !== undefined) {
|
|
320
|
+
return resultClassName + mergeClassesResult;
|
|
321
|
+
}
|
|
322
|
+
const sequenceMappings = [];
|
|
323
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
324
|
+
const sequenceId = sequencesIds[i];
|
|
325
|
+
if (sequenceId) {
|
|
326
|
+
const sequenceMapping = DEFINITION_LOOKUP_TABLE[sequenceId];
|
|
327
|
+
if (sequenceMapping) {
|
|
328
|
+
sequenceMappings.push(sequenceMapping[LOOKUP_DEFINITIONS_INDEX]);
|
|
329
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
330
|
+
if (dir !== null && dir !== sequenceMapping[LOOKUP_DIR_INDEX]) {
|
|
331
|
+
// eslint-disable-next-line no-console
|
|
332
|
+
console.error(`mergeClasses(): a passed string contains an identifier (${sequenceId}) that has different direction ` + `(dir="${sequenceMapping[1] ? 'rtl' : 'ltr'}") setting than other classes. This is not supported. ` + `Source string: ${arguments[i]}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
dir = sequenceMapping[LOOKUP_DIR_INDEX];
|
|
336
|
+
} else {
|
|
337
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
338
|
+
// eslint-disable-next-line no-console
|
|
339
|
+
console.error(`mergeClasses(): a passed string contains an identifier (${sequenceId}) that does not match any entry ` + `in cache. Source string: ${arguments[i]}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// eslint-disable-next-line prefer-spread
|
|
345
|
+
const resultDefinitions = Object.assign.apply(Object,
|
|
346
|
+
// .assign() mutates the first object, we can't mutate mappings as it will produce invalid results later
|
|
347
|
+
[{}].concat(sequenceMappings));
|
|
348
|
+
let atomicClassNames = reduceToClassName(resultDefinitions, dir);
|
|
349
|
+
// Each merge of classes generates a new sequence of atomic classes that needs to be registered
|
|
350
|
+
const newSequenceHash = hashSequence(atomicClassNames, dir, sequencesIds);
|
|
351
|
+
atomicClassNames = newSequenceHash + ' ' + atomicClassNames;
|
|
352
|
+
mergeClassesCachedResults[sequenceMatch] = atomicClassNames;
|
|
353
|
+
DEFINITION_LOOKUP_TABLE[newSequenceHash] = [resultDefinitions, dir];
|
|
354
|
+
return resultClassName + atomicClassNames;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const sequenceDetails = {};
|
|
358
|
+
const cssRules = /*#__PURE__*/new Set();
|
|
359
|
+
const debugData = {
|
|
360
|
+
getChildrenSequences: debugSequenceHash => {
|
|
361
|
+
const key = Object.keys(mergeClassesCachedResults).find(key => mergeClassesCachedResults[key].startsWith(debugSequenceHash));
|
|
362
|
+
if (key) {
|
|
363
|
+
// key of the mergeClasses cache contains merge order
|
|
364
|
+
return key.split(SEQUENCE_PREFIX).filter(sequence => sequence.length).map(sequence => SEQUENCE_PREFIX + sequence);
|
|
365
|
+
}
|
|
366
|
+
return [];
|
|
367
|
+
},
|
|
368
|
+
addCSSRule: rule => {
|
|
369
|
+
cssRules.add(rule);
|
|
370
|
+
},
|
|
371
|
+
addSequenceDetails: (classNamesForSlots, sourceURL) => {
|
|
372
|
+
Object.entries(classNamesForSlots).forEach(([slotName, sequenceHash]) => {
|
|
373
|
+
sequenceDetails[sequenceHash.substring(0, SEQUENCE_SIZE)] = {
|
|
374
|
+
slotName,
|
|
375
|
+
sourceURL
|
|
376
|
+
};
|
|
377
|
+
});
|
|
378
|
+
},
|
|
379
|
+
getCSSRules: () => {
|
|
380
|
+
return Array.from(cssRules);
|
|
381
|
+
},
|
|
382
|
+
getSequenceDetails: sequenceHash => {
|
|
383
|
+
return sequenceDetails[sequenceHash];
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
function getDirectionalClassName(classes, direction) {
|
|
388
|
+
return Array.isArray(classes) ? direction === 'rtl' ? classes[1] : classes[0] : classes;
|
|
389
|
+
}
|
|
390
|
+
function getDebugClassNames(lookupItem, parentLookupItem, parentDebugClassNames, overridingSiblings) {
|
|
391
|
+
const classesMapping = lookupItem[0];
|
|
392
|
+
const direction = lookupItem[1];
|
|
393
|
+
return Object.entries(classesMapping).map(([propertyHash, classes]) => {
|
|
394
|
+
const className = getDirectionalClassName(classes, direction);
|
|
395
|
+
let overriddenBy;
|
|
396
|
+
if (parentDebugClassNames && parentLookupItem) {
|
|
397
|
+
const matching = parentDebugClassNames.find(({
|
|
398
|
+
className: parentClassName
|
|
399
|
+
}) => parentClassName === className);
|
|
400
|
+
if (!matching && parentLookupItem[0][propertyHash]) {
|
|
401
|
+
// parent node does not have current className (style), but has current selector:
|
|
402
|
+
// style is overriden in current merging by another rule in sibling node
|
|
403
|
+
overriddenBy = getDirectionalClassName(parentLookupItem[0][propertyHash], parentLookupItem[1]);
|
|
404
|
+
} else if (matching && parentLookupItem[0][propertyHash]) {
|
|
405
|
+
// parent node has current className (style), and has current selector:
|
|
406
|
+
// case 1. style is not overriden during current merging; it may be overriden in higher level of merging
|
|
407
|
+
// case 2. style is overriden in current merging by exactly the same rule in sibling nodes
|
|
408
|
+
const siblingHasSameRule = overridingSiblings ? overridingSiblings.filter(({
|
|
409
|
+
debugClassNames
|
|
410
|
+
}) => debugClassNames.filter(({
|
|
411
|
+
className: siblingClassName
|
|
412
|
+
}) => siblingClassName === className).length > 0).length > 0 : false;
|
|
413
|
+
overriddenBy = siblingHasSameRule ? matching.className // case 2
|
|
414
|
+
: matching.overriddenBy; // case 1
|
|
415
|
+
} else if (!matching && !parentLookupItem[0][propertyHash]) {
|
|
416
|
+
// parent node does not have current className (style), and does not have current selector:
|
|
417
|
+
// this case is not possible
|
|
418
|
+
overriddenBy = undefined;
|
|
419
|
+
} else if (matching && !parentLookupItem[0][propertyHash]) {
|
|
420
|
+
// parent node has current className (style), but does not have current selector:
|
|
421
|
+
// this case is not possible
|
|
422
|
+
overriddenBy = undefined;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
className,
|
|
427
|
+
overriddenBy
|
|
428
|
+
};
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function getDebugTree(debugSequenceHash, parentNode) {
|
|
433
|
+
const lookupItem = DEFINITION_LOOKUP_TABLE[debugSequenceHash];
|
|
434
|
+
if (lookupItem === undefined) {
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
437
|
+
const parentLookupItem = parentNode ? DEFINITION_LOOKUP_TABLE[parentNode.sequenceHash] : undefined;
|
|
438
|
+
const debugClassNames = getDebugClassNames(lookupItem, parentLookupItem, parentNode === null || parentNode === void 0 ? void 0 : parentNode.debugClassNames, parentNode === null || parentNode === void 0 ? void 0 : parentNode.children);
|
|
439
|
+
const node = {
|
|
440
|
+
sequenceHash: debugSequenceHash,
|
|
441
|
+
direction: lookupItem[1],
|
|
442
|
+
children: [],
|
|
443
|
+
debugClassNames
|
|
444
|
+
};
|
|
445
|
+
const childrenSequences = debugData.getChildrenSequences(node.sequenceHash);
|
|
446
|
+
childrenSequences.reverse() // first process the overriding children that are merged last
|
|
447
|
+
.forEach(sequence => {
|
|
448
|
+
const child = getDebugTree(sequence, node);
|
|
449
|
+
if (child) {
|
|
450
|
+
node.children.push(child);
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
// if it's leaf (makeStyle node), get css rules
|
|
454
|
+
if (!node.children.length) {
|
|
455
|
+
node.rules = {};
|
|
456
|
+
node.debugClassNames.forEach(({
|
|
457
|
+
className
|
|
458
|
+
}) => {
|
|
459
|
+
const mapData = debugData.getSequenceDetails(debugSequenceHash);
|
|
460
|
+
if (mapData) {
|
|
461
|
+
node.slot = mapData.slotName;
|
|
462
|
+
node.sourceURL = mapData.sourceURL;
|
|
463
|
+
}
|
|
464
|
+
const cssRule = debugData.getCSSRules().find(cssRule => {
|
|
465
|
+
return cssRule.includes(className);
|
|
466
|
+
});
|
|
467
|
+
node.rules[className] = cssRule;
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return node;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function injectDevTools(document) {
|
|
474
|
+
const window = document.defaultView;
|
|
475
|
+
if (!window || window.__GRIFFEL_DEVTOOLS__) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const devtools = {
|
|
479
|
+
getInfo: element => {
|
|
480
|
+
const rootDebugSequenceHash = Array.from(element.classList).find(className => className.startsWith(SEQUENCE_PREFIX));
|
|
481
|
+
if (rootDebugSequenceHash === undefined) {
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
return getDebugTree(rootDebugSequenceHash);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
Object.defineProperty(window, '__GRIFFEL_DEVTOOLS__', {
|
|
488
|
+
configurable: false,
|
|
489
|
+
enumerable: false,
|
|
490
|
+
get() {
|
|
491
|
+
return devtools;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const isDevToolsEnabled = /*#__PURE__*/(() => {
|
|
497
|
+
var _a;
|
|
498
|
+
// Accessing "window.sessionStorage" causes an exception when third party cookies are blocked
|
|
499
|
+
// https://stackoverflow.com/questions/30481516/iframe-in-chrome-error-failed-to-read-localstorage-from-window-access-deni
|
|
500
|
+
try {
|
|
501
|
+
return Boolean(typeof window !== 'undefined' && ((_a = window.sessionStorage) === null || _a === void 0 ? void 0 : _a.getItem('__GRIFFEL_DEVTOOLS__')));
|
|
502
|
+
} catch (e) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
})();
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @internal
|
|
509
|
+
*
|
|
510
|
+
* @param entry - CSS bucket entry that can be either a string or an array
|
|
511
|
+
* @returns An array where the first element is the CSS rule
|
|
512
|
+
*/
|
|
513
|
+
function normalizeCSSBucketEntry(entry) {
|
|
514
|
+
if (!Array.isArray(entry)) {
|
|
515
|
+
return [entry];
|
|
516
|
+
}
|
|
517
|
+
if (process.env.NODE_ENV !== 'production' && entry.length > 2) {
|
|
518
|
+
throw new Error('CSS Bucket contains an entry with greater than 2 items, please report this to https://github.com/microsoft/griffel/issues');
|
|
519
|
+
}
|
|
520
|
+
return entry;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function createIsomorphicStyleSheet(styleElement, bucketName, elementAttributes) {
|
|
524
|
+
// no CSSStyleSheet in SSR, just append rules here for server render
|
|
525
|
+
const __cssRulesForSSR = [];
|
|
526
|
+
elementAttributes[DATA_BUCKET_ATTR] = bucketName;
|
|
527
|
+
if (styleElement) {
|
|
528
|
+
for (const attrName in elementAttributes) {
|
|
529
|
+
styleElement.setAttribute(attrName, elementAttributes[attrName]);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
function insertRule(rule) {
|
|
533
|
+
if (styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) {
|
|
534
|
+
return styleElement.sheet.insertRule(rule, styleElement.sheet.cssRules.length);
|
|
535
|
+
}
|
|
536
|
+
return __cssRulesForSSR.push(rule);
|
|
537
|
+
}
|
|
538
|
+
return {
|
|
539
|
+
elementAttributes,
|
|
540
|
+
insertRule,
|
|
541
|
+
element: styleElement,
|
|
542
|
+
bucketName,
|
|
543
|
+
cssRules() {
|
|
544
|
+
if (styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) {
|
|
545
|
+
return Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText);
|
|
546
|
+
}
|
|
547
|
+
return __cssRulesForSSR;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Ordered style buckets using their short pseudo name.
|
|
554
|
+
*
|
|
555
|
+
* @internal
|
|
556
|
+
*/
|
|
557
|
+
const styleBucketOrdering = [
|
|
558
|
+
// reset styles
|
|
559
|
+
'r',
|
|
560
|
+
// catch-all
|
|
561
|
+
'd',
|
|
562
|
+
// link
|
|
563
|
+
'l',
|
|
564
|
+
// visited
|
|
565
|
+
'v',
|
|
566
|
+
// focus-within
|
|
567
|
+
'w',
|
|
568
|
+
// focus
|
|
569
|
+
'f',
|
|
570
|
+
// focus-visible
|
|
571
|
+
'i',
|
|
572
|
+
// hover
|
|
573
|
+
'h',
|
|
574
|
+
// active
|
|
575
|
+
'a',
|
|
576
|
+
// at rules for reset styles
|
|
577
|
+
's',
|
|
578
|
+
// keyframes
|
|
579
|
+
'k',
|
|
580
|
+
// at-rules
|
|
581
|
+
't',
|
|
582
|
+
// @media rules
|
|
583
|
+
'm',
|
|
584
|
+
// @container rules
|
|
585
|
+
'c'];
|
|
586
|
+
// avoid repeatedly calling `indexOf`to determine order during new insertions
|
|
587
|
+
const styleBucketOrderingMap = /*#__PURE__*/styleBucketOrdering.reduce((acc, cur, j) => {
|
|
588
|
+
acc[cur] = j;
|
|
589
|
+
return acc;
|
|
590
|
+
}, {});
|
|
591
|
+
/**
|
|
592
|
+
* Lazily adds a `<style>` bucket to the `<head>`. This will ensure that the style buckets are ordered.
|
|
593
|
+
*/
|
|
594
|
+
function getStyleSheetForBucket(bucketName, targetDocument, insertionPoint, renderer, metadata = {}) {
|
|
595
|
+
const isMediaBucket = bucketName === 'm';
|
|
596
|
+
const stylesheetKey = isMediaBucket ? bucketName + metadata['m'] : bucketName;
|
|
597
|
+
if (!renderer.stylesheets[stylesheetKey]) {
|
|
598
|
+
const tag = targetDocument && targetDocument.createElement('style');
|
|
599
|
+
const stylesheet = createIsomorphicStyleSheet(tag, bucketName, {
|
|
600
|
+
...renderer.styleElementAttributes,
|
|
601
|
+
...(isMediaBucket && {
|
|
602
|
+
media: metadata['m']
|
|
603
|
+
})
|
|
604
|
+
});
|
|
605
|
+
renderer.stylesheets[stylesheetKey] = stylesheet;
|
|
606
|
+
if (targetDocument && tag) {
|
|
607
|
+
targetDocument.head.insertBefore(tag, findInsertionPoint(targetDocument, insertionPoint, bucketName, renderer, metadata));
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return renderer.stylesheets[stylesheetKey];
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Finds an element before which the new bucket style element should be inserted following the bucket sort order.
|
|
614
|
+
*
|
|
615
|
+
* @param targetDocument - A document
|
|
616
|
+
* @param insertionPoint - An element that will be used as an initial insertion point
|
|
617
|
+
* @param targetBucket - The bucket that should be inserted to DOM
|
|
618
|
+
* @param renderer - Griffel renderer
|
|
619
|
+
* @param metadata - metadata for CSS rule
|
|
620
|
+
* @returns - Smallest style element with greater sort order than the current bucket
|
|
621
|
+
*/
|
|
622
|
+
function findInsertionPoint(targetDocument, insertionPoint, targetBucket, renderer, metadata) {
|
|
623
|
+
const targetOrder = styleBucketOrderingMap[targetBucket];
|
|
624
|
+
// Similar to javascript sort comparators where
|
|
625
|
+
// a positive value is increasing sort order
|
|
626
|
+
// a negative value is decreasing sort order
|
|
627
|
+
let comparer = el => targetOrder - styleBucketOrderingMap[el.getAttribute(DATA_BUCKET_ATTR)];
|
|
628
|
+
let styleElements = targetDocument.head.querySelectorAll(`[${DATA_BUCKET_ATTR}]`);
|
|
629
|
+
if (targetBucket === 'm' && metadata) {
|
|
630
|
+
const mediaElements = targetDocument.head.querySelectorAll(`[${DATA_BUCKET_ATTR}="${targetBucket}"]`);
|
|
631
|
+
// only reduce the scope of the search and change comparer
|
|
632
|
+
// if there are other media buckets already on the page
|
|
633
|
+
if (mediaElements.length) {
|
|
634
|
+
styleElements = mediaElements;
|
|
635
|
+
comparer = el => renderer.compareMediaQueries(metadata['m'], el.media);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
const length = styleElements.length;
|
|
639
|
+
let index = length - 1;
|
|
640
|
+
while (index >= 0) {
|
|
641
|
+
const styleElement = styleElements.item(index);
|
|
642
|
+
if (comparer(styleElement) > 0) {
|
|
643
|
+
return styleElement.nextSibling;
|
|
644
|
+
}
|
|
645
|
+
index--;
|
|
646
|
+
}
|
|
647
|
+
if (length > 0) {
|
|
648
|
+
return styleElements.item(0);
|
|
649
|
+
}
|
|
650
|
+
return insertionPoint ? insertionPoint.nextSibling : null;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Suffixes to be ignored in case of error
|
|
655
|
+
*/
|
|
656
|
+
const ignoreSuffixes = /*#__PURE__*/['-moz-placeholder', '-moz-focus-inner', '-moz-focusring', '-ms-input-placeholder', '-moz-read-write', '-moz-read-only'].join('|');
|
|
657
|
+
const ignoreSuffixesRegex = /*#__PURE__*/new RegExp(`:(${ignoreSuffixes})`);
|
|
658
|
+
/**
|
|
659
|
+
* @internal
|
|
660
|
+
*
|
|
661
|
+
* Calls `sheet.insertRule` and catches errors related to browser prefixes.
|
|
662
|
+
*/
|
|
663
|
+
function safeInsertRule(sheet, ruleCSS) {
|
|
664
|
+
try {
|
|
665
|
+
sheet.insertRule(ruleCSS);
|
|
666
|
+
} catch (e) {
|
|
667
|
+
// We've disabled these warnings due to false-positive errors with browser prefixes
|
|
668
|
+
if (process.env.NODE_ENV !== 'production' && !ignoreSuffixesRegex.test(ruleCSS)) {
|
|
669
|
+
// eslint-disable-next-line no-console
|
|
670
|
+
console.error(`There was a problem inserting the following rule: "${ruleCSS}"`, e);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
let lastIndex = 0;
|
|
676
|
+
/** @internal */
|
|
677
|
+
const defaultCompareMediaQueries = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
678
|
+
/**
|
|
679
|
+
* Creates a new instances of a renderer.
|
|
680
|
+
*
|
|
681
|
+
* @public
|
|
682
|
+
*/
|
|
683
|
+
function createDOMRenderer(targetDocument = typeof document === 'undefined' ? undefined : document, options = {}) {
|
|
684
|
+
const {
|
|
685
|
+
unstable_filterCSSRule,
|
|
686
|
+
insertionPoint,
|
|
687
|
+
styleElementAttributes,
|
|
688
|
+
compareMediaQueries = defaultCompareMediaQueries
|
|
689
|
+
} = options;
|
|
690
|
+
const renderer = {
|
|
691
|
+
insertionCache: {},
|
|
692
|
+
stylesheets: {},
|
|
693
|
+
styleElementAttributes: Object.freeze(styleElementAttributes),
|
|
694
|
+
compareMediaQueries,
|
|
695
|
+
id: `d${lastIndex++}`,
|
|
696
|
+
insertCSSRules(cssRules) {
|
|
697
|
+
// eslint-disable-next-line guard-for-in
|
|
698
|
+
for (const styleBucketName in cssRules) {
|
|
699
|
+
const cssRulesForBucket = cssRules[styleBucketName];
|
|
700
|
+
// This is a hot path in rendering styles: ".length" is cached in "l" var to avoid accesses the property
|
|
701
|
+
for (let i = 0, l = cssRulesForBucket.length; i < l; i++) {
|
|
702
|
+
const [ruleCSS, metadata] = normalizeCSSBucketEntry(cssRulesForBucket[i]);
|
|
703
|
+
const sheet = getStyleSheetForBucket(styleBucketName, targetDocument, insertionPoint || null, renderer, metadata);
|
|
704
|
+
if (renderer.insertionCache[ruleCSS]) {
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
renderer.insertionCache[ruleCSS] = styleBucketName;
|
|
708
|
+
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
|
|
709
|
+
debugData.addCSSRule(ruleCSS);
|
|
710
|
+
}
|
|
711
|
+
if (unstable_filterCSSRule) {
|
|
712
|
+
if (unstable_filterCSSRule(ruleCSS)) {
|
|
713
|
+
safeInsertRule(sheet, ruleCSS);
|
|
714
|
+
}
|
|
715
|
+
} else {
|
|
716
|
+
safeInsertRule(sheet, ruleCSS);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
if (targetDocument && process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
|
|
723
|
+
injectDevTools(targetDocument);
|
|
724
|
+
}
|
|
725
|
+
return renderer;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// TODO: duplicated from https://github.com/lahmatiy/react-render-tracker/blob/main/src/publisher/react-integration/utils/stackTrace.ts
|
|
729
|
+
// once it is published as a standalone npm package, remove this file
|
|
730
|
+
// Adopted version of StackTrace-Parser
|
|
731
|
+
// https://github.com/errwischt/stacktrace-parser/blob/master/src/stack-trace-parser.js
|
|
732
|
+
const UNKNOWN_FUNCTION = '<unknown>';
|
|
733
|
+
function parseStackTraceLine(line) {
|
|
734
|
+
return parseChrome(line) || parseGecko(line) || parseJSC(line);
|
|
735
|
+
}
|
|
736
|
+
const chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)?\)?\s*$/i;
|
|
737
|
+
const chromeRe2 = /^\s*at ()((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)\s*$/i;
|
|
738
|
+
const chromeEvalRe = /\((\S*)\)/;
|
|
739
|
+
function parseChrome(line) {
|
|
740
|
+
const parts = chromeRe.exec(line) || chromeRe2.exec(line);
|
|
741
|
+
if (!parts) {
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
let loc = parts[2];
|
|
745
|
+
const isNative = loc && loc.indexOf('native') === 0; // start of line
|
|
746
|
+
const isEval = loc && loc.indexOf('eval') === 0; // start of line
|
|
747
|
+
const submatch = chromeEvalRe.exec(loc);
|
|
748
|
+
if (isEval && submatch != null) {
|
|
749
|
+
// throw out eval line/column and use top-most line/column number
|
|
750
|
+
loc = submatch[1]; // url
|
|
751
|
+
}
|
|
752
|
+
return {
|
|
753
|
+
loc: !isNative ? parts[2] : null,
|
|
754
|
+
name: parts[1] || UNKNOWN_FUNCTION
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
const geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)\s*$/i;
|
|
758
|
+
const geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
759
|
+
function parseGecko(line) {
|
|
760
|
+
const parts = geckoRe.exec(line);
|
|
761
|
+
if (!parts) {
|
|
762
|
+
return null;
|
|
763
|
+
}
|
|
764
|
+
let loc = parts[3];
|
|
765
|
+
const isEval = loc && loc.indexOf(' > eval') > -1;
|
|
766
|
+
const submatch = geckoEvalRe.exec(loc);
|
|
767
|
+
if (isEval && submatch != null) {
|
|
768
|
+
// throw out eval line/column and use top-most line number
|
|
769
|
+
loc = submatch[1];
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
loc: parts[3],
|
|
773
|
+
name: parts[1] || UNKNOWN_FUNCTION
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
const javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?)\s*$/i;
|
|
777
|
+
function parseJSC(line) {
|
|
778
|
+
const parts = javaScriptCoreRe.exec(line);
|
|
779
|
+
if (!parts) {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
return {
|
|
783
|
+
loc: parts[3],
|
|
784
|
+
name: parts[1] || UNKNOWN_FUNCTION
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function getSourceURLfromError() {
|
|
789
|
+
const stacks = String(new Error().stack).split('\n');
|
|
790
|
+
const userMakeStyleCallLine = findUserMakeStyleCallInStacks(stacks);
|
|
791
|
+
if (userMakeStyleCallLine === undefined) {
|
|
792
|
+
return undefined;
|
|
793
|
+
}
|
|
794
|
+
const result = parseStackTraceLine(userMakeStyleCallLine);
|
|
795
|
+
return result === null || result === void 0 ? void 0 : result.loc;
|
|
796
|
+
}
|
|
797
|
+
function findUserMakeStyleCallInStacks(stacks) {
|
|
798
|
+
for (let i = stacks.length - 1; i >= 0; --i) {
|
|
799
|
+
if (stacks[i].includes('at getSourceURLfromError')) {
|
|
800
|
+
// The error stacks look like:
|
|
801
|
+
// getSourceURLfromError
|
|
802
|
+
// makeStyles/__styles in griffel core
|
|
803
|
+
// makeStyles/__styles in griffel react
|
|
804
|
+
// user makeStyles call
|
|
805
|
+
return stacks[i + 3];
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return undefined;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Default implementation of insertion factory. Inserts styles only once per renderer and performs
|
|
813
|
+
* insertion immediately after styles computation.
|
|
814
|
+
*
|
|
815
|
+
* @internal
|
|
816
|
+
*/
|
|
817
|
+
const insertionFactory$1 = () => {
|
|
818
|
+
const insertionCache = {};
|
|
819
|
+
return function insertStyles(renderer, cssRules) {
|
|
820
|
+
if (insertionCache[renderer.id] === undefined) {
|
|
821
|
+
renderer.insertCSSRules(cssRules);
|
|
822
|
+
insertionCache[renderer.id] = true;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* A version of makeStyles() that accepts build output as an input and skips all runtime transforms.
|
|
829
|
+
*
|
|
830
|
+
* @internal
|
|
831
|
+
*/
|
|
832
|
+
function __styles$1(classesMapBySlot, cssRules, factory = insertionFactory$1) {
|
|
833
|
+
const insertStyles = factory();
|
|
834
|
+
let ltrClassNamesForSlots = null;
|
|
835
|
+
let rtlClassNamesForSlots = null;
|
|
836
|
+
let sourceURL;
|
|
837
|
+
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
|
|
838
|
+
sourceURL = getSourceURLfromError();
|
|
839
|
+
}
|
|
840
|
+
function computeClasses(options) {
|
|
841
|
+
const {
|
|
842
|
+
dir,
|
|
843
|
+
renderer
|
|
844
|
+
} = options;
|
|
845
|
+
const isLTR = dir === 'ltr';
|
|
846
|
+
if (isLTR) {
|
|
847
|
+
if (ltrClassNamesForSlots === null) {
|
|
848
|
+
ltrClassNamesForSlots = reduceToClassNameForSlots(classesMapBySlot, dir);
|
|
849
|
+
}
|
|
850
|
+
} else {
|
|
851
|
+
if (rtlClassNamesForSlots === null) {
|
|
852
|
+
rtlClassNamesForSlots = reduceToClassNameForSlots(classesMapBySlot, dir);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
insertStyles(renderer, cssRules);
|
|
856
|
+
const classNamesForSlots = isLTR ? ltrClassNamesForSlots : rtlClassNamesForSlots;
|
|
857
|
+
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
|
|
858
|
+
debugData.addSequenceDetails(classNamesForSlots, sourceURL);
|
|
859
|
+
}
|
|
860
|
+
return classNamesForSlots;
|
|
861
|
+
}
|
|
862
|
+
return computeClasses;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Verifies if an application can use DOM.
|
|
867
|
+
*/
|
|
868
|
+
function canUseDOM() {
|
|
869
|
+
return typeof window !== 'undefined' && !!(window.document && window.document.createElement);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
const useInsertionEffect =
|
|
873
|
+
// @ts-expect-error Hack to make sure that `useInsertionEffect` will not cause bundling issues in older React versions
|
|
874
|
+
// eslint-disable-next-line no-useless-concat
|
|
875
|
+
React__namespace['useInsertion' + 'Effect'] ? React__namespace['useInsertion' + 'Effect'] : undefined;
|
|
876
|
+
|
|
877
|
+
const insertionFactory = () => {
|
|
878
|
+
const insertionCache = {};
|
|
879
|
+
return function insert(renderer, cssRules) {
|
|
880
|
+
// Even if `useInsertionEffect` is available, we can use it on a client only as it will not be executed in SSR
|
|
881
|
+
if (useInsertionEffect && canUseDOM()) {
|
|
882
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
883
|
+
useInsertionEffect(() => {
|
|
884
|
+
renderer.insertCSSRules(cssRules);
|
|
885
|
+
}, [renderer, cssRules]);
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
if (insertionCache[renderer.id] === undefined) {
|
|
889
|
+
renderer.insertCSSRules(cssRules);
|
|
890
|
+
insertionCache[renderer.id] = true;
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* @private
|
|
897
|
+
*/
|
|
898
|
+
const RendererContext = /*#__PURE__*/React__namespace.createContext( /*#__PURE__*/createDOMRenderer());
|
|
899
|
+
/**
|
|
900
|
+
* Returns an instance of current makeStyles() renderer.
|
|
901
|
+
*
|
|
902
|
+
* @private Exported as "useRenderer_unstable" use it on own risk. Can be changed or removed without a notice.
|
|
903
|
+
*/
|
|
904
|
+
function useRenderer() {
|
|
905
|
+
return React__namespace.useContext(RendererContext);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* @private
|
|
910
|
+
*/
|
|
911
|
+
const TextDirectionContext = /*#__PURE__*/React__namespace.createContext('ltr');
|
|
912
|
+
/**
|
|
913
|
+
* Returns current directionality of the element's text.
|
|
914
|
+
*
|
|
915
|
+
* @private
|
|
916
|
+
*/
|
|
917
|
+
function useTextDirection() {
|
|
918
|
+
return React__namespace.useContext(TextDirectionContext);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* A version of makeStyles() that accepts build output as an input and skips all runtime transforms.
|
|
923
|
+
*
|
|
924
|
+
* @internal
|
|
925
|
+
*/
|
|
926
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
927
|
+
function __styles(classesMapBySlot, cssRules) {
|
|
928
|
+
const getStyles = __styles$1(classesMapBySlot, cssRules, insertionFactory);
|
|
929
|
+
return function useClasses() {
|
|
930
|
+
const dir = useTextDirection();
|
|
931
|
+
const renderer = useRenderer();
|
|
932
|
+
return getStyles({
|
|
933
|
+
dir,
|
|
934
|
+
renderer
|
|
935
|
+
});
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
const useRootStyles = __styles({
|
|
940
|
+
"root": {
|
|
941
|
+
"mc9l5x": "f1w7gpdv",
|
|
942
|
+
"Bg96gwp": "fez10in",
|
|
943
|
+
"ycbfsm": "fg4l7m0"
|
|
944
|
+
},
|
|
945
|
+
"rtl": {
|
|
946
|
+
"Bz10aip": "f13rod7r"
|
|
947
|
+
}
|
|
948
|
+
}, {
|
|
949
|
+
"d": [".f1w7gpdv{display:inline;}", ".fez10in{line-height:0;}", ".f13rod7r{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);transform:scaleX(-1);}"],
|
|
950
|
+
"t": ["@media (forced-colors: active){.fg4l7m0{forced-color-adjust:auto;}}"]
|
|
951
|
+
});
|
|
952
|
+
const useIconState = (props, options) => {
|
|
953
|
+
const {
|
|
954
|
+
title,
|
|
955
|
+
primaryFill = "currentColor",
|
|
956
|
+
...rest
|
|
957
|
+
} = props;
|
|
958
|
+
const state = {
|
|
959
|
+
...rest,
|
|
960
|
+
title: undefined,
|
|
961
|
+
fill: primaryFill
|
|
962
|
+
};
|
|
963
|
+
const styles = useRootStyles();
|
|
964
|
+
const iconContext = useIconContext();
|
|
965
|
+
state.className = mergeClasses(styles.root, (options === null || options === void 0 ? void 0 : options.flipInRtl) && (iconContext === null || iconContext === void 0 ? void 0 : iconContext.textDirection) === 'rtl' && styles.rtl, state.className);
|
|
966
|
+
if (title) {
|
|
967
|
+
state['aria-label'] = title;
|
|
968
|
+
}
|
|
969
|
+
if (!state['aria-label'] && !state['aria-labelledby']) {
|
|
970
|
+
state['aria-hidden'] = true;
|
|
971
|
+
} else {
|
|
972
|
+
state['role'] = 'img';
|
|
973
|
+
}
|
|
974
|
+
return state;
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
const createFluentIcon = (displayName, width, paths, options) => {
|
|
978
|
+
const viewBoxWidth = width === "1em" ? "20" : width;
|
|
979
|
+
const Icon = React__namespace.forwardRef((props, ref) => {
|
|
980
|
+
const state = {
|
|
981
|
+
...useIconState(props, {
|
|
982
|
+
flipInRtl: options === null || options === void 0 ? void 0 : options.flipInRtl
|
|
983
|
+
}),
|
|
984
|
+
ref,
|
|
985
|
+
width,
|
|
986
|
+
height: width,
|
|
987
|
+
viewBox: `0 0 ${viewBoxWidth} ${viewBoxWidth}`,
|
|
988
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
989
|
+
};
|
|
990
|
+
return React__namespace.createElement("svg", state, ...paths.map(d => React__namespace.createElement("path", {
|
|
991
|
+
d,
|
|
992
|
+
fill: state.fill
|
|
993
|
+
})));
|
|
994
|
+
});
|
|
995
|
+
Icon.displayName = displayName;
|
|
996
|
+
return Icon;
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
const ArrowNextFilled = /*#__PURE__*/createFluentIcon('ArrowNextFilled', "1em", ["M13.75 4.75c.38 0 .7.28.74.65l.01.1v9a.75.75 0 0 1-1.5.1V5.5c0-.41.34-.75.75-.75Zm-8.28.22a.75.75 0 0 1 .98-.07l.08.07 4.5 4.5c.27.27.3.68.07.98l-.07.08-4.5 4.5a.75.75 0 0 1-1.13-.98l.07-.08L9.44 10 5.47 6.03a.75.75 0 0 1 0-1.06Z"], {
|
|
1000
|
+
flipInRtl: true
|
|
1001
|
+
});
|
|
1002
|
+
const ArrowPreviousFilled = /*#__PURE__*/createFluentIcon('ArrowPreviousFilled', "1em", ["M6 4.75c-.38 0-.7.28-.74.65l-.01.1v9a.75.75 0 0 0 1.5.1V5.5A.75.75 0 0 0 6 4.75Zm8.28.22a.75.75 0 0 0-.98-.07l-.08.07-4.5 4.5a.75.75 0 0 0-.07.98l.07.08 4.5 4.5a.75.75 0 0 0 1.13-.98l-.07-.08L10.31 10l3.97-3.97c.3-.3.3-.77 0-1.06Z"], {
|
|
1003
|
+
flipInRtl: true
|
|
1004
|
+
});
|
|
1005
|
+
const ArrowStepInLeftRegular = /*#__PURE__*/createFluentIcon('ArrowStepInLeftRegular', "1em", ["M5 10a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM4 8a2 2 0 1 1 0 4 2 2 0 0 1 0-4Zm14 2a.5.5 0 0 1-.5.5H9.7l3.15 3.15a.5.5 0 0 1-.7.7l-4-4a.5.5 0 0 1 0-.7l4-4a.5.5 0 0 1 .7.7L9.71 9.5h7.79c.28 0 .5.22.5.5Z"]);
|
|
1006
|
+
const ArrowStepInRightRegular = /*#__PURE__*/createFluentIcon('ArrowStepInRightRegular', "1em", ["M15 10a1 1 0 1 0 2 0 1 1 0 0 0-2 0Zm1 2a2 2 0 1 1 0-4 2 2 0 0 1 0 4ZM2 10c0-.28.22-.5.5-.5h7.8L7.14 6.35a.5.5 0 1 1 .7-.7l4 4c.2.2.2.5 0 .7l-4 4a.5.5 0 0 1-.7-.7l3.14-3.15H2.5A.5.5 0 0 1 2 10Z"]);
|
|
1007
|
+
|
|
1008
|
+
const ChevronDownFilled = /*#__PURE__*/createFluentIcon('ChevronDownFilled', "1em", ["M15.8 7.73c.28.3.27.78-.03 1.06l-5.25 5a.75.75 0 0 1-1.04 0l-5.25-5a.75.75 0 0 1 1.04-1.08L10 12.2l4.73-4.5a.75.75 0 0 1 1.06.02Z"]);
|
|
1009
|
+
const ChevronDownRegular = /*#__PURE__*/createFluentIcon('ChevronDownRegular', "1em", ["M15.85 7.65c.2.2.2.5 0 .7l-5.46 5.49a.55.55 0 0 1-.78 0L4.15 8.35a.5.5 0 1 1 .7-.7L10 12.8l5.15-5.16c.2-.2.5-.2.7 0Z"]);
|
|
1010
|
+
const ChevronRightFilled = /*#__PURE__*/createFluentIcon('ChevronRightFilled', "1em", ["M7.73 4.2a.75.75 0 0 1 1.06.03l5 5.25c.28.3.28.75 0 1.04l-5 5.25a.75.75 0 1 1-1.08-1.04L12.2 10l-4.5-4.73a.75.75 0 0 1 .02-1.06Z"]);
|
|
1011
|
+
const ChevronRightRegular = /*#__PURE__*/createFluentIcon('ChevronRightRegular', "1em", ["M7.65 4.15c.2-.2.5-.2.7 0l5.49 5.46c.21.22.21.57 0 .78l-5.49 5.46a.5.5 0 0 1-.7-.7L12.8 10 7.65 4.85a.5.5 0 0 1 0-.7Z"]);
|
|
1012
|
+
const ColumnEditFilled = /*#__PURE__*/createFluentIcon('ColumnEditFilled', "1em", ["M3 3.5c0-.28.22-.5.5-.5H4a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-.5a.5.5 0 0 1 0-1H4a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-.5a.5.5 0 0 1-.5-.5ZM9 3a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h.22l.21-.84a3.2 3.2 0 0 1 .84-1.49L13 11.94V5a2 2 0 0 0-2-2H9Zm6 2v4.94l-1 1V5c0-1.1.9-2 2-2h.5a.5.5 0 0 1 0 1H16a1 1 0 0 0-1 1Zm-4.02 10.38 4.83-4.83a1.87 1.87 0 1 1 2.64 2.64l-4.83 4.83a2.2 2.2 0 0 1-1.02.58l-1.5.37a.89.89 0 0 1-1.07-1.07l.37-1.5c.1-.39.3-.74.58-1.02Z"]);
|
|
1013
|
+
const ColumnEditRegular = /*#__PURE__*/createFluentIcon('ColumnEditRegular', "1em", ["M3 3.5c0-.28.22-.5.5-.5H4a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-.5a.5.5 0 0 1 0-1H4a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-.5a.5.5 0 0 1-.5-.5ZM9 4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h.47l-.04.16-.21.84H9a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v6.94l-1 1V5a1 1 0 0 0-1-1H9Zm6 1v4.94l-1 1V5c0-1.1.9-2 2-2h.5a.5.5 0 0 1 0 1H16a1 1 0 0 0-1 1Zm-4.02 10.38 4.83-4.83a1.87 1.87 0 1 1 2.64 2.64l-4.83 4.83a2.2 2.2 0 0 1-1.02.58l-1.5.37a.89.89 0 0 1-1.07-1.07l.37-1.5c.1-.39.3-.74.58-1.02Z"]);
|
|
1014
|
+
const DragFilled = /*#__PURE__*/createFluentIcon('DragFilled', "1em", ["M10 2c.2 0 .39.08.53.22l1.5 1.5a.75.75 0 0 1-1.06 1.06l-.22-.22v1.69a.75.75 0 0 1-1.5 0V4.56l-.22.22a.75.75 0 0 1-1.06-1.06l1.5-1.5A.75.75 0 0 1 10 2Zm2 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm-9.78-.53a.75.75 0 0 0 0 1.06l1.5 1.5a.75.75 0 0 0 1.06-1.06l-.22-.22h1.69a.75.75 0 0 0 0-1.5H4.56l.22-.22a.75.75 0 0 0-1.06-1.06l-1.5 1.5ZM10 18c.2 0 .39-.08.53-.22l1.5-1.5a.75.75 0 1 0-1.06-1.06l-.22.22v-1.69a.75.75 0 0 0-1.5 0v1.69l-.22-.22a.75.75 0 0 0-1.06 1.06l1.5 1.5c.14.14.33.22.53.22Zm7.78-8.53a.75.75 0 0 1 0 1.06l-1.5 1.5a.75.75 0 1 1-1.06-1.06l.22-.22h-1.69a.75.75 0 0 1 0-1.5h1.69l-.22-.22a.75.75 0 0 1 1.06-1.06l1.5 1.5Z"]);
|
|
1015
|
+
const DragRegular = /*#__PURE__*/createFluentIcon('DragRegular', "1em", ["M9.65 2.15c.2-.2.5-.2.7 0l2 2a.5.5 0 0 1-.7.7L10.5 3.71V6.5a.5.5 0 0 1-1 0V3.7L8.35 4.86a.5.5 0 1 1-.7-.7l2-2ZM10 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0-1a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm5.85 1.35 2-2a.5.5 0 0 0 0-.7l-2-2a.5.5 0 0 0-.7.7l1.14 1.15H13.5a.5.5 0 0 0 0 1h2.8l-1.15 1.15a.5.5 0 0 0 .7.7Zm-5.5 5.5 2-2a.5.5 0 0 0-.7-.7l-1.15 1.14V13.5a.5.5 0 0 0-1 0v2.8l-1.15-1.15a.5.5 0 0 0-.7.7l2 2c.2.2.5.2.7 0Zm-8.2-7.5a.5.5 0 0 1 0-.7l2-2a.5.5 0 1 1 .7.7L3.71 9.5H6.5a.5.5 0 0 1 0 1H3.7l1.15 1.15a.5.5 0 0 1-.7.7l-2-2Z"]);
|
|
1016
|
+
const FilterFilled = /*#__PURE__*/createFluentIcon('FilterFilled', "1em", ["M12.25 13.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5h4.5Zm2-4.25a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5h8.5Zm2-4.25a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1 0-1.5h12.5Z"]);
|
|
1017
|
+
const FilterRegular = /*#__PURE__*/createFluentIcon('FilterRegular', "1em", ["M7.5 13h5a.5.5 0 0 1 .09 1H7.5a.5.5 0 0 1-.09-1h5.09-5Zm-2-4h9a.5.5 0 0 1 .09 1H5.5a.5.5 0 0 1-.09-1h9.09-9Zm-2-4h13a.5.5 0 0 1 .09 1H3.5a.5.5 0 0 1-.09-1H16.5h-13Z"]);
|
|
1018
|
+
const FilterDismissFilled = /*#__PURE__*/createFluentIcon('FilterDismissFilled', "1em", ["M11.73 10.25A5.46 5.46 0 0 0 14 11c0 .41-.34.75-.75.75h-8.5a.75.75 0 0 1 0-1.5h6.98ZM9.03 6c.04.52.16 1.03.34 1.5H2.75a.75.75 0 0 1 0-1.5h6.27ZM12 15.25a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h4.5c.41 0 .75-.34.75-.75ZM14.5 10a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Zm1.85-6.35c.2.2.2.5 0 .7L15.21 5.5l1.14 1.15a.5.5 0 0 1-.7.7L14.5 6.21l-1.15 1.14a.5.5 0 0 1-.7-.7l1.14-1.15-1.14-1.15a.5.5 0 0 1 .7-.7l1.15 1.14 1.15-1.14c.2-.2.5-.2.7 0Z"]);
|
|
1019
|
+
|
|
1020
|
+
const GroupFilled = /*#__PURE__*/createFluentIcon('GroupFilled', "1em", ["M7 4.5c0 .36-.07.7-.2 1H10c.28 0 .5.22.5.5v2H10a2 2 0 0 0-2 2v.5H6a.5.5 0 0 1-.5-.5V6.8a2.5 2.5 0 0 1-1.5.15V10c0 1.1.9 2 2 2h2v2c0 1.1.9 2 2 2h3.05a2.51 2.51 0 0 1 .16-1.5H10a.5.5 0 0 1-.5-.5v-2h.5a2 2 0 0 0 2-2v-.5h2c.28 0 .5.22.5.5v3.2a2.5 2.5 0 0 1 1.5-.15V10a2 2 0 0 0-2-2h-2V6a2 2 0 0 0-2-2H6.95c.03.16.05.33.05.5Zm3.5 5v.5a.5.5 0 0 1-.5.5h-.5V10c0-.28.22-.5.5-.5h.5ZM6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm11 11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0-11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm-11 11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z"]);
|
|
1021
|
+
const GroupRegular = /*#__PURE__*/createFluentIcon('GroupRegular', "1em", ["M7 4.5c0 .17-.02.34-.05.5H10a1 1 0 0 1 1 1v2h-1a2 2 0 0 0-2 2v1H6a1 1 0 0 1-1-1V6.95a2.51 2.51 0 0 1-1 0V10c0 1.1.9 2 2 2h2v2c0 1.1.9 2 2 2h3.05a2.51 2.51 0 0 1 0-1H10a1 1 0 0 1-1-1v-2h1a2 2 0 0 0 2-2V9h2a1 1 0 0 1 1 1v3.05a2.51 2.51 0 0 1 1 0V10a2 2 0 0 0-2-2h-2V6a2 2 0 0 0-2-2H6.95c.03.16.05.33.05.5ZM11 9v1a1 1 0 0 1-1 1H9v-1a1 1 0 0 1 1-1h1ZM6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm11 11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0-11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm-11 11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z"]);
|
|
1022
|
+
const GroupDismissFilled = /*#__PURE__*/createFluentIcon('GroupDismissFilled', "1em", ["M7 4.5c0 .36-.07.7-.2 1H10c.28 0 .5.22.5.5v2H10a2 2 0 0 0-2 2v.5H6a.5.5 0 0 1-.5-.5V6.8a2.5 2.5 0 0 1-1.5.15V10c0 1.1.9 2 2 2h2v2a2 2 0 0 0 1.16 1.81 5.51 5.51 0 0 1 .34-3.6V10c0-.28.22-.5.5-.5h2.2a5.48 5.48 0 0 1 3.61-.34A2 2 0 0 0 14 8h-2V6a2 2 0 0 0-2-2H6.95c.03.16.05.33.05.5Zm-1 0a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm11 0a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm-11 11a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm13-1a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-2.65-1.15a.5.5 0 0 0-.7-.7l-1.15 1.14-1.15-1.14a.5.5 0 0 0-.7.7l1.14 1.15-1.14 1.15a.5.5 0 0 0 .7.7l1.15-1.14 1.15 1.14a.5.5 0 0 0 .7-.7l-1.14-1.15 1.14-1.15Z"]);
|
|
1023
|
+
const GroupListRegular = /*#__PURE__*/createFluentIcon('GroupListRegular', "1em", ["M2.5 3a.5.5 0 0 0-.5.5v5c0 .28.22.5.5.5h2a.5.5 0 0 0 0-1H3V4h1.5a.5.5 0 0 0 0-1h-2Zm0 8a.5.5 0 0 0-.5.5v5c0 .28.22.5.5.5h2a.5.5 0 0 0 0-1H3v-4h1.5a.5.5 0 0 0 0-1h-2ZM6 4.5c0-.28.22-.5.5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5Zm.5 7.5a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1h-11ZM6 7.5c0-.28.22-.5.5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5Zm.5 7.5a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1h-11Z"]);
|
|
1024
|
+
const NextRegular = /*#__PURE__*/createFluentIcon('NextRegular', "1em", ["M17 3.5a.5.5 0 0 0-1 0v13a.5.5 0 1 0 1 0v-13ZM3 4.25c0-1 1.12-1.6 1.95-1.04l8.5 5.71c.73.5.73 1.57 0 2.07l-8.5 5.8A1.25 1.25 0 0 1 3 15.75V4.25Zm1.39-.2a.25.25 0 0 0-.39.2v11.5c0 .2.23.32.4.2l8.49-5.78a.25.25 0 0 0 0-.42l-8.5-5.7Z"]);
|
|
1025
|
+
|
|
1026
|
+
const PinRegular = /*#__PURE__*/createFluentIcon('PinRegular', "1em", ["M10.12 3.14a2 2 0 0 1 3.2-.52l4.06 4.05a2 2 0 0 1-.52 3.2l-3.46 1.74a1.5 1.5 0 0 0-.72.78L11.25 16a1 1 0 0 1-1.64.33L7 13.7 3.7 17H3v-.7L6.3 13l-2.62-2.61a1 1 0 0 1 .34-1.64L7.6 7.32c.34-.14.62-.4.78-.72l1.73-3.46Zm2.5.18a1 1 0 0 0-1.6.26L9.29 7.04a2.5 2.5 0 0 1-1.31 1.2L4.39 9.69l5.93 5.93 1.43-3.59a2.5 2.5 0 0 1 1.2-1.3l3.46-1.74a1 1 0 0 0 .26-1.6l-4.05-4.06Z"]);
|
|
1027
|
+
const PinOffRegular = /*#__PURE__*/createFluentIcon('PinOffRegular', "1em", ["M2.85 2.15a.5.5 0 1 0-.7.7L6.9 7.6 4.02 8.75a1 1 0 0 0-.34 1.64L6.3 13 3 16.3v.7h.7L7 13.7l2.61 2.62a1 1 0 0 0 1.64-.34l1.15-2.88 4.75 4.75a.5.5 0 0 0 .7-.7l-15-15Zm8.78 10.18-1.31 3.28-5.93-5.93 3.28-1.3 3.96 3.95Zm1.33-1.62-.08.04.74.75 3.24-1.62a2 2 0 0 0 .52-3.2l-4.05-4.06a2 2 0 0 0-3.2.52L8.5 6.38l.75.74.04-.08 1.73-3.45a1 1 0 0 1 1.6-.26l4.05 4.05a1 1 0 0 1-.26 1.6l-3.45 1.73Z"]);
|
|
1028
|
+
const PreviousRegular = /*#__PURE__*/createFluentIcon('PreviousRegular', "1em", ["M3 3.5a.5.5 0 0 1 1 0v13a.5.5 0 0 1-1 0v-13Zm14 .75c0-1-1.12-1.6-1.95-1.04l-8.5 5.71c-.73.5-.73 1.57 0 2.07l8.5 5.8c.83.56 1.95-.03 1.95-1.04V4.25Zm-1.39-.2c.17-.12.39 0 .39.2v11.5c0 .2-.22.32-.4.2l-8.49-5.78a.25.25 0 0 1 0-.42l8.5-5.7Z"]);
|
|
1029
|
+
const SaveFilled = /*#__PURE__*/createFluentIcon('SaveFilled', "1em", ["M3 5c0-1.1.9-2 2-2h1v3.5C6 7.33 6.67 8 7.5 8h4c.83 0 1.5-.67 1.5-1.5V3h.38a2 2 0 0 1 1.41.59l1.62 1.62A2 2 0 0 1 17 6.62V15a2 2 0 0 1-2 2v-5.5c0-.83-.67-1.5-1.5-1.5h-7c-.83 0-1.5.67-1.5 1.5V17a2 2 0 0 1-2-2V5Zm9-2H7v3.5c0 .28.22.5.5.5h4a.5.5 0 0 0 .5-.5V3Zm2 8.5V17H6v-5.5c0-.28.22-.5.5-.5h7c.28 0 .5.22.5.5Z"]);
|
|
1030
|
+
const SaveRegular = /*#__PURE__*/createFluentIcon('SaveRegular', "1em", ["M3 5c0-1.1.9-2 2-2h8.38a2 2 0 0 1 1.41.59l1.62 1.62A2 2 0 0 1 17 6.62V15a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm2-1a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1v-4.5c0-.83.67-1.5 1.5-1.5h7c.83 0 1.5.67 1.5 1.5V16a1 1 0 0 0 1-1V6.62a1 1 0 0 0-.3-.7L14.1 4.28a1 1 0 0 0-.71-.29H13v2.5c0 .83-.67 1.5-1.5 1.5h-4A1.5 1.5 0 0 1 6 6.5V4H5Zm2 0v2.5c0 .28.22.5.5.5h4a.5.5 0 0 0 .5-.5V4H7Zm7 12v-4.5a.5.5 0 0 0-.5-.5h-7a.5.5 0 0 0-.5.5V16h8Z"]);
|
|
1031
|
+
const SearchFilled = /*#__PURE__*/createFluentIcon('SearchFilled', "1em", ["M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-.98 1.13l-.08-.07-4.15-4.15A5.5 5.5 0 1 1 8.5 3Zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z"]);
|
|
1032
|
+
const SearchRegular = /*#__PURE__*/createFluentIcon('SearchRegular', "1em", ["M8.5 3a5.5 5.5 0 0 1 4.23 9.02l4.12 4.13a.5.5 0 0 1-.63.76l-.07-.06-4.13-4.12A5.5 5.5 0 1 1 8.5 3Zm0 1a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9Z"]);
|
|
1033
|
+
|
|
1034
|
+
const TableSimpleCheckmarkFilled = /*#__PURE__*/createFluentIcon('TableSimpleCheckmarkFilled', "1em", ["M14 17h-3.5v-6.5H17V14a3 3 0 0 1-3 3Zm3-7.5h-6.5V3H14a3 3 0 0 1 3 3v3.5Zm-7.5 0V3H6a3 3 0 0 0-3 3v3.5h6.5Zm0 7.5v-6.5H3V14a3 3 0 0 0 3 3h3.5Zm5.85-3.9a.5.5 0 0 0-.7-.7l-1.4 1.4-.4-.4a.5.5 0 0 0-.7.7l.75.75c.2.2.5.2.7 0l1.75-1.75Z"]);
|
|
1035
|
+
const TableSimpleCheckmarkRegular = /*#__PURE__*/createFluentIcon('TableSimpleCheckmarkRegular', "1em", ["M6 3a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V6a3 3 0 0 0-3-3H6ZM4 6c0-1.1.9-2 2-2h3.5v5.5H4V6Zm6.5 3.5V4H14a2 2 0 0 1 2 2v3.5h-5.5Zm-6.5 1h5.5V16H6a2 2 0 0 1-2-2v-3.5Zm10.86 1.4c.2.2.2.5 0 .7l-1.75 1.75a.5.5 0 0 1-.71 0l-.75-.75a.5.5 0 0 1 .7-.7l.4.4 1.4-1.4c.2-.2.51-.2.7 0Z"]);
|
|
1036
|
+
const TextSortAscendingFilled = /*#__PURE__*/createFluentIcon('TextSortAscendingFilled', "1em", ["M6.7 2.5a.75.75 0 0 0-1.4 0L3.03 9a.75.75 0 0 0 1.42.5l.34-1h2.4l.34 1A.75.75 0 0 0 8.96 9L6.7 2.5ZM6 5.04 6.68 7H5.32L6 5.04ZM4 11a.75.75 0 0 0 0 1.5h2.53l-3.14 4.3A.75.75 0 0 0 4 18h4a.75.75 0 0 0 0-1.5H5.47l3.14-4.3A.75.75 0 0 0 8 11H4Zm10.25-9c.41 0 .75.34.75.75v12.57l1.45-1.58a.75.75 0 0 1 1.1 1.02l-2.75 3a.75.75 0 0 1-1.1 0l-2.75-3a.75.75 0 0 1 1.1-1.02l1.45 1.58V2.75c0-.41.34-.75.75-.75Z"]);
|
|
1037
|
+
const TextSortDescendingFilled = /*#__PURE__*/createFluentIcon('TextSortDescendingFilled', "1em", ["M4 2a.75.75 0 1 0 0 1.5h2.53L3.39 7.8A.75.75 0 0 0 4 9h4a.75.75 0 0 0 0-1.5H5.47l3.14-4.3A.75.75 0 0 0 8 2H4Zm2.7 8.5a.75.75 0 0 0-1.4 0L3.03 17a.75.75 0 1 0 1.42.5l.34-1h2.4l.34 1a.75.75 0 1 0 1.42-.5L6.7 10.5ZM6 13.04 6.68 15H5.32L6 13.04ZM14.25 2c.41 0 .75.34.75.75v12.57l1.45-1.58a.75.75 0 0 1 1.1 1.02l-2.75 3a.75.75 0 0 1-1.1 0l-2.75-3a.75.75 0 0 1 1.1-1.02l1.45 1.58V2.75c0-.41.34-.75.75-.75Z"]);
|
|
1038
|
+
|
|
1039
|
+
const Album24Regular = /*#__PURE__*/createFluentIcon('Album24Regular', "24", ["M10 9c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V9Zm2-.5a.5.5 0 0 0-.5.5v1c0 .28.22.5.5.5h4a.5.5 0 0 0 .5-.5V9a.5.5 0 0 0-.5-.5h-4ZM4 4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4Zm16 1.5c.28 0 .5.22.5.5v12a.5.5 0 0 1-.5.5H7.5v-13H20Zm-16 0h2v13H4a.5.5 0 0 1-.5-.5V6c0-.28.22-.5.5-.5Z"], {
|
|
1040
|
+
flipInRtl: true
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
const ArrowSortDown20Filled = /*#__PURE__*/createFluentIcon('ArrowSortDown20Filled', "20", ["M9.75 17c.23 0 .45-.1.59-.28l2.94-2.94a.75.75 0 0 0-1.06-1.06l-1.72 1.71V3.75a.75.75 0 0 0-1.5 0v10.7L7.28 12.7a.75.75 0 1 0-1.06 1.06l3 3.01c.15.15.34.22.53.22Z"]);
|
|
1044
|
+
const ArrowSortDown20Regular = /*#__PURE__*/createFluentIcon('ArrowSortDown20Regular', "20", ["m10 15.29 2.65-2.64a.5.5 0 0 1 .7.7L9.9 16.82a.5.5 0 0 1-.74.03h-.01l-3.5-3.5a.5.5 0 1 1 .71-.7L9 15.29V3.5a.5.5 0 0 1 1 0v11.79Z"]);
|
|
1045
|
+
const ArrowSortUp20Filled = /*#__PURE__*/createFluentIcon('ArrowSortUp20Filled', "20", ["M9.75 3c.23 0 .45.1.59.28l2.94 2.94a.75.75 0 0 1-1.06 1.06L10.5 5.57v10.68a.75.75 0 0 1-1.5 0V5.55L7.28 7.3a.75.75 0 1 1-1.06-1.06l3-3.01A.73.73 0 0 1 9.75 3Z"]);
|
|
1046
|
+
const ArrowSortUp20Regular = /*#__PURE__*/createFluentIcon('ArrowSortUp20Regular', "20", ["M9 4.71 6.35 7.35a.5.5 0 1 1-.7-.7L9.1 3.18a.5.5 0 0 1 .74-.03h.01l3.5 3.5a.5.5 0 1 1-.71.7L10 4.71V16.5a.5.5 0 0 1-1 0V4.71Z"]);
|
|
1047
|
+
|
|
1048
|
+
const CodeTextOff16Filled = /*#__PURE__*/createFluentIcon('CodeTextOff16Filled', "16", ["M13.25 7h-3a.75.75 0 0 1 0-1.5h3a.75.75 0 0 1 0 1.5Zm-3.5-3h4.5a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0 0 1.5Zm-1 7.5h-7a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5Zm-2-7.5a.75.75 0 0 0 0-1.5H4.62L6.12 4h.63Zm8.1 10.15-13-13a.5.5 0 0 0-.7.7l.64.65h-.04a.75.75 0 0 0 0 1.5h1.54l1.5 1.5h-.04a.75.75 0 0 0 0 1.5h1.54l1.5 1.5H3.75a.75.75 0 0 0 0 1.5h5.54l4.86 4.85a.5.5 0 0 0 .7 0 .5.5 0 0 0 0-.7Z"]);
|
|
1049
|
+
const CodeTextOff16Regular = /*#__PURE__*/createFluentIcon('CodeTextOff16Regular', "16", ["m6.12 4-1-1H7a.5.5 0 0 1 0 1h-.88ZM9.5 4h5a.5.5 0 0 0 0-1h-5a.5.5 0 0 0 0 1Zm.5 2a.5.5 0 0 0 0 1h3.5a.5.5 0 0 0 0-1H10Zm-1 6H1.5a.5.5 0 0 0 0 1H9a.5.5 0 0 0 0-1Zm5.85 2.15-13-13a.5.5 0 0 0-.7.7L2.29 3H1.5a.5.5 0 0 0 0 1h1.8l2 2h-.8a.5.5 0 0 0 0 1h1.8l2 2H3.5a.5.5 0 0 0 0 1h5.8l4.85 4.85a.5.5 0 0 0 .7 0 .5.5 0 0 0 0-.7Z"]);
|
|
1050
|
+
|
|
1051
|
+
const Dismiss24Regular = /*#__PURE__*/createFluentIcon('Dismiss24Regular', "24", ["m4.4 4.55.07-.08a.75.75 0 0 1 .98-.07l.08.07L12 10.94l6.47-6.47a.75.75 0 1 1 1.06 1.06L13.06 12l6.47 6.47c.27.27.3.68.07.98l-.07.08a.75.75 0 0 1-.98.07l-.08-.07L12 13.06l-6.47 6.47a.75.75 0 0 1-1.06-1.06L10.94 12 4.47 5.53a.75.75 0 0 1-.07-.98l.07-.08-.07.08Z"]);
|
|
1052
|
+
|
|
1053
|
+
const DocumentSearch24Regular = /*#__PURE__*/createFluentIcon('DocumentSearch24Regular', "24", ["M4 4c0-1.1.9-2 2-2h6.17a2 2 0 0 1 1.42.59L19.4 8.4A2 2 0 0 1 20 9.83V20a2 2 0 0 1-2 2h-4.02c-.05-.36-.21-.7-.5-.99l-.5-.51H18a.5.5 0 0 0 .5-.5V10H14a2 2 0 0 1-2-2V3.5H6a.5.5 0 0 0-.5.5v7.1c-.53.09-1.03.26-1.5.5V4Zm10 4.5h3.38L13.5 4.62V8c0 .28.22.5.5.5ZM6.5 21c.97 0 1.87-.3 2.6-.83l2.62 2.61a.75.75 0 1 0 1.06-1.06l-2.61-2.61A4.5 4.5 0 1 0 6.5 21Zm0-1.5a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z"]);
|
|
1054
|
+
|
|
1055
|
+
const Save20Filled = /*#__PURE__*/createFluentIcon('Save20Filled', "20", ["M3 5c0-1.1.9-2 2-2h1v3.5C6 7.33 6.67 8 7.5 8h4c.83 0 1.5-.67 1.5-1.5V3h.38a2 2 0 0 1 1.41.59l1.62 1.62A2 2 0 0 1 17 6.62V15a2 2 0 0 1-2 2v-5.5c0-.83-.67-1.5-1.5-1.5h-7c-.83 0-1.5.67-1.5 1.5V17a2 2 0 0 1-2-2V5Zm9-2H7v3.5c0 .28.22.5.5.5h4a.5.5 0 0 0 .5-.5V3Zm2 8.5V17H6v-5.5c0-.28.22-.5.5-.5h7c.28 0 .5.22.5.5Z"]);
|
|
1056
|
+
const Search24Regular = /*#__PURE__*/createFluentIcon('Search24Regular', "24", ["M4.5 10a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0ZM10 3a7 7 0 1 0 4.4 12.45l5.32 5.33a.75.75 0 1 0 1.06-1.06l-5.33-5.33A7 7 0 0 0 10 3Z"]);
|
|
1057
|
+
|
|
1058
|
+
const ViewDesktop20Filled = /*#__PURE__*/createFluentIcon('ViewDesktop20Filled', "20", ["M1.96 4.5c0-.83.67-1.5 1.5-1.5H16.4c.83 0 1.5.67 1.5 1.5v8c0 .83-.67 1.5-1.5 1.5H12v2.01h1.5a.5.5 0 0 1 0 1h-7a.5.5 0 1 1 0-1H8V14H3.46a1.5 1.5 0 0 1-1.5-1.5v-8ZM9 14v2.01h2V14H9ZM4 5.5v6c0 .28.22.5.5.5h1a.5.5 0 0 0 .5-.5v-6a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5Zm3 0v6c0 .28.22.5.5.5h8a.5.5 0 0 0 .5-.5v-6a.5.5 0 0 0-.5-.5h-8a.5.5 0 0 0-.5.5Z"]);
|
|
1059
|
+
const ViewDesktop20Regular = /*#__PURE__*/createFluentIcon('ViewDesktop20Regular', "20", ["M4 5.5c0-.28.22-.5.5-.5h1c.27 0 .5.22.5.5v6a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-6ZM7.5 5a.5.5 0 0 0-.5.5v6c0 .28.22.5.5.5h8a.5.5 0 0 0 .5-.5v-6a.5.5 0 0 0-.5-.5h-8Zm-5.54-.5c0-.83.67-1.5 1.5-1.5H16.4c.83 0 1.5.67 1.5 1.5v8c0 .83-.67 1.5-1.5 1.5H12v2.01h1.5a.5.5 0 0 1 0 1h-7a.5.5 0 1 1 0-1H8V14H3.46a1.5 1.5 0 0 1-1.5-1.5v-8ZM9 14v2.01h2V14H9ZM3.46 4a.5.5 0 0 0-.5.5v8c0 .28.23.5.5.5H16.4a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5H3.46Z"]);
|
|
1060
|
+
|
|
1061
|
+
const iconFilledClassName = "fui-Icon-filled";
|
|
1062
|
+
const iconRegularClassName = "fui-Icon-regular";
|
|
1063
|
+
|
|
1064
|
+
const useBundledIconStyles = __styles({
|
|
1065
|
+
"root": {
|
|
1066
|
+
"mc9l5x": "fjseox"
|
|
1067
|
+
},
|
|
1068
|
+
"visible": {
|
|
1069
|
+
"mc9l5x": "f1w7gpdv"
|
|
1070
|
+
}
|
|
1071
|
+
}, {
|
|
1072
|
+
"d": [".fjseox{display:none;}", ".f1w7gpdv{display:inline;}"]
|
|
1073
|
+
});
|
|
1074
|
+
const bundleIcon = (FilledIcon, RegularIcon) => {
|
|
1075
|
+
const Component = props => {
|
|
1076
|
+
const {
|
|
1077
|
+
className,
|
|
1078
|
+
filled,
|
|
1079
|
+
...rest
|
|
1080
|
+
} = props;
|
|
1081
|
+
const styles = useBundledIconStyles();
|
|
1082
|
+
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(FilledIcon, Object.assign({}, rest, {
|
|
1083
|
+
className: mergeClasses(styles.root, filled && styles.visible, iconFilledClassName, className)
|
|
1084
|
+
})), React__namespace.createElement(RegularIcon, Object.assign({}, rest, {
|
|
1085
|
+
className: mergeClasses(styles.root, !filled && styles.visible, iconRegularClassName, className)
|
|
1086
|
+
})));
|
|
1087
|
+
};
|
|
1088
|
+
Component.displayName = "CompoundIcon";
|
|
1089
|
+
return Component;
|
|
1090
|
+
};
|
|
1091
|
+
var bundleIcon$1 = bundleIcon;
|
|
1092
|
+
|
|
1093
|
+
const range = (from, to, step = 1) => {
|
|
1094
|
+
var _a;
|
|
1095
|
+
return (_a = [...Array(Math.floor((to - from) / step) + 1)]) === null || _a === void 0 ? void 0 : _a.map((_, i) => from + i * step);
|
|
1096
|
+
};
|
|
1097
|
+
const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
|
|
1098
|
+
const Pagination = (props) => {
|
|
1099
|
+
const { table, pageSizeOptions = [10, 20, 50, 100, 1000] } = props;
|
|
1100
|
+
const pageSizeSelectionId = reactComponents.useId("page-size-selector");
|
|
1101
|
+
const styles = usePaginationStyle();
|
|
1102
|
+
const totalNumberOfPage = table.getPageCount();
|
|
1103
|
+
const currentPage = table.getState().pagination.pageIndex;
|
|
1104
|
+
const pageSize = table.getState().pagination.pageSize;
|
|
1105
|
+
const pageSelectionOptions = React.useMemo(() => {
|
|
1106
|
+
let start = currentPage - Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
1107
|
+
let end = currentPage + Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
1108
|
+
if (start < 1) {
|
|
1109
|
+
start = 1;
|
|
1110
|
+
end = totalNumberOfPage > DEFAULT_NUMBER_OF_PAGE_BTN
|
|
1111
|
+
? DEFAULT_NUMBER_OF_PAGE_BTN
|
|
1112
|
+
: totalNumberOfPage;
|
|
1113
|
+
}
|
|
1114
|
+
else if (end > totalNumberOfPage) {
|
|
1115
|
+
const possibleStart = totalNumberOfPage - DEFAULT_NUMBER_OF_PAGE_BTN + 1;
|
|
1116
|
+
start = possibleStart < 1 ? 1 : possibleStart;
|
|
1117
|
+
end = totalNumberOfPage;
|
|
1118
|
+
}
|
|
1119
|
+
const currentPageOptions = end - start >= 0 ? range(start, end) : [];
|
|
1120
|
+
return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
|
|
1121
|
+
}, [totalNumberOfPage, currentPage]);
|
|
1122
|
+
return (jsxRuntime.jsx("div", { className: styles.paginationContainer, children: jsxRuntime.jsxs("div", { className: styles.wrapper, children: [jsxRuntime.jsx("div", { className: styles.pageSelectionWrapper, children: jsxRuntime.jsx(reactComponents.Dropdown, { id: pageSizeSelectionId, size: "small", selectedOptions: [`${pageSize}`], placeholder: "Select Page Size", value: table.getState().pagination.pageSize.toString(), onOptionSelect: (_, data) => { var _a; return table.setPageSize(Number(+((_a = data.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]))); }, className: styles.pageSelectionDropdown, "aria-label": "Select Page Size", children: pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : pageSizeOptions.map((option) => (jsxRuntime.jsx(reactComponents.Option, { value: `${option}`, children: `${option}` }, option))) }) }), jsxRuntime.jsxs("div", { className: styles.pageBtnContainer, children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("span", { children: ["Page", " ", jsxRuntime.jsxs("strong", { children: [table.getState().pagination.pageIndex + 1, " of", " ", table.getPageCount()] })] }), jsxRuntime.jsxs("span", { children: [" ", "| Go to page:", " ", jsxRuntime.jsx(reactComponents.Input, { type: "number", size: "small", value: `${table.getState().pagination.pageIndex + 1}`, onChange: (e, data) => {
|
|
1123
|
+
const page = data.value ? Number(e.target.value) - 1 : 0;
|
|
1124
|
+
if (page >= 0 && page < table.getPageCount()) {
|
|
1125
|
+
table.setPageIndex(page);
|
|
1126
|
+
}
|
|
1127
|
+
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete: "off", autoCorrect: "off" })] })] }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(PreviousRegular, {}), "aria-label": "Go to first page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(ArrowPreviousFilled, {}), "aria-label": "Go to previous page" }), pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.map((option, index) => (jsxRuntime.jsx(reactComponents.Button, { shape: "circular", appearance: option - 1 === currentPage ? "primary" : undefined, onClick: () => table.setPageIndex(option - 1), "aria-label": `Show Page ${option}`, size: "small", className: styles.pageBtn, children: option }, index))), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), icon: jsxRuntime.jsx(ArrowNextFilled, {}), "aria-label": "Go to next page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", shape: "circular", className: styles.pageBtn, onClick: () => table.setPageIndex(table.getPageCount() - 1), disabled: !table.getCanNextPage(), icon: jsxRuntime.jsx(NextRegular, {}), "aria-label": "Go to last page" })] })] }) }));
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
bundleIcon$1(SaveFilled, SaveRegular);
|
|
1131
|
+
bundleIcon$1(TableSimpleCheckmarkFilled, TableSimpleCheckmarkRegular);
|
|
1132
|
+
bundleIcon$1(SearchFilled, SearchRegular);
|
|
1133
|
+
bundleIcon$1(FilterFilled, FilterRegular);
|
|
1134
|
+
const ClearFilterIcon = bundleIcon$1(CodeTextOff16Filled, CodeTextOff16Regular);
|
|
1135
|
+
const ToggleSelectColumnIcon = bundleIcon$1(ColumnEditFilled, ColumnEditRegular);
|
|
1136
|
+
const ToggleGroupColumnIcon = bundleIcon$1(GroupFilled, GroupRegular);
|
|
1137
|
+
const GroupCollapsedIcon = bundleIcon$1(ChevronRightFilled, ChevronRightRegular);
|
|
1138
|
+
const GroupExpandedIcon = bundleIcon$1(ChevronDownRegular, ChevronDownFilled);
|
|
1139
|
+
bundleIcon$1(DragFilled, DragRegular);
|
|
1140
|
+
|
|
1141
|
+
const useGridHeaderStyles = reactComponents.makeStyles({
|
|
1142
|
+
tableTopHeaderContainer: Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "flex-end", width: "100%", backgroundColor: reactComponents.tokens.colorBrandBackground2Hover }, reactComponents.shorthands.padding("5px")),
|
|
1143
|
+
tableTopHeaderLeft: {
|
|
1144
|
+
display: "flex",
|
|
1145
|
+
justifyContent: "flex-start",
|
|
1146
|
+
},
|
|
1147
|
+
tableTopHeaderRight: Object.assign({ display: "flex", justifyContent: "flex-end" }, reactComponents.shorthands.gap("3px")),
|
|
1148
|
+
tableTopHeaderColumnTogglePopover: {
|
|
1149
|
+
display: "flex",
|
|
1150
|
+
flexDirection: "column",
|
|
1151
|
+
justifyContent: "flex-start",
|
|
1152
|
+
alignItems: "flex-start",
|
|
1153
|
+
width: "100%",
|
|
1154
|
+
height: "100%",
|
|
1155
|
+
},
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
const GridHeader = (props) => {
|
|
1159
|
+
const { table, gridTitle, globalFilter, setGlobalFilter, dispatch, drawerState } = props;
|
|
1160
|
+
const styles = useGridHeaderStyles();
|
|
1161
|
+
return (jsxRuntime.jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsxRuntime.jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxRuntime.jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsxRuntime.jsx(reactComponents.Divider, { vertical: true }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1162
|
+
if (column.id === 'select')
|
|
1163
|
+
return null;
|
|
1164
|
+
if (column.id === 'id')
|
|
1165
|
+
return null;
|
|
1166
|
+
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: column.getIsGrouped(), onChange: column.getToggleGroupingHandler(), disabled: !column.getCanGroup() || !column.getIsVisible(), label: jsxRuntime.jsx("span", { children: column.columnDef.id }) }, column.id));
|
|
1167
|
+
})] }) })] }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Column Visibility', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleSelectColumnIcon, {}), "aria-label": "Toggle Column Visibility" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Toggle Columns" }), jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsAllColumnsVisible(), onChange: table.getToggleAllColumnsVisibilityHandler(), label: 'Toggle All' }), jsxRuntime.jsx(reactComponents.Divider, {}), table.getAllLeafColumns().map((column) => {
|
|
1168
|
+
if (column.id === 'select')
|
|
1169
|
+
return null;
|
|
1170
|
+
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
|
|
1171
|
+
})] }) })] }), jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Table Views Management', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { onClick: () => {
|
|
1172
|
+
dispatch({ type: "TOGGLE_VIEW_DRAWER" });
|
|
1173
|
+
}, icon: jsxRuntime.jsx(Album24Regular, {}), "aria-label": "View Menu" }) }), jsxRuntime.jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), className: "p-2 font-lg shadow border border-block", placeholder: "Search all columns...", drawerState: drawerState, dispatch: dispatch })] })] }));
|
|
1174
|
+
};
|
|
1175
|
+
// A debounced input react component
|
|
1176
|
+
function DebouncedInput({ value: initialValue, onChange, debounce = 500, drawerState, dispatch, }) {
|
|
1177
|
+
const [value, setValue] = React__namespace.useState('');
|
|
1178
|
+
React__namespace.useEffect(() => {
|
|
1179
|
+
setValue(initialValue);
|
|
1180
|
+
}, [initialValue]);
|
|
1181
|
+
React__namespace.useEffect(() => {
|
|
1182
|
+
const timeout = setTimeout(() => {
|
|
1183
|
+
onChange(value);
|
|
1184
|
+
}, debounce);
|
|
1185
|
+
return () => clearTimeout(timeout);
|
|
1186
|
+
}, [value, onChange, debounce]);
|
|
1187
|
+
return (jsxRuntime.jsx(reactComponents.Input, { placeholder: "Search Keyword", value: value, onChange: (_, data) => setValue(data.value), type: "search", autoComplete: "off", contentBefore: jsxRuntime.jsx(Search24Regular, {}), style: { width: '300px' }, contentAfter: jsxRuntime.jsx(reactComponents.Tooltip, { content: drawerState.isFilterDrawerOpen ? 'Close Filter Window' : 'Open Advance Filter', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", icon: drawerState.isFilterDrawerOpen ? jsxRuntime.jsx(FilterDismissFilled, {}) : jsxRuntime.jsx(FilterFilled, {}), "aria-label": "View Menu", onClick: () => {
|
|
1188
|
+
dispatch({ type: "TOGGLE_FILTER_DRAWER" });
|
|
1189
|
+
} }) }) }));
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
const arrIncludesSome = (row, columnId, value) => {
|
|
1193
|
+
// Rank the item
|
|
1194
|
+
const rowValue = row.getValue(columnId);
|
|
1195
|
+
const passed = Array.isArray(value) &&
|
|
1196
|
+
((value === null || value === void 0 ? void 0 : value.length) === 0 || value.includes(`${rowValue}`));
|
|
1197
|
+
return passed;
|
|
1198
|
+
};
|
|
1199
|
+
const dateRange = (row, columnId, value) => {
|
|
1200
|
+
// filter by date range
|
|
1201
|
+
const rowValue = row.getValue(columnId);
|
|
1202
|
+
// compare the date range
|
|
1203
|
+
// case if no start date or end date is selected
|
|
1204
|
+
// case if start date is selected
|
|
1205
|
+
// case if end date is selected
|
|
1206
|
+
if (!value || value.length === 0) {
|
|
1207
|
+
return true;
|
|
1208
|
+
}
|
|
1209
|
+
else if (value.length === 2 && value[0] && !value[1]) {
|
|
1210
|
+
return typeof rowValue.getMonth === 'function' && rowValue >= value[0];
|
|
1211
|
+
}
|
|
1212
|
+
else if (value.length === 2 && !value[0] && value[1]) {
|
|
1213
|
+
return typeof rowValue.getMonth === 'function' && rowValue <= value[1];
|
|
1214
|
+
}
|
|
1215
|
+
else if (value.length === 2 && !value[0] && !value[1]) {
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
const passed = typeof rowValue.getMonth === 'function' && value[0] <= rowValue && rowValue <= value[1];
|
|
1219
|
+
return passed;
|
|
1220
|
+
};
|
|
1221
|
+
const date = (row, columnId, value) => {
|
|
1222
|
+
var _a;
|
|
1223
|
+
// filter by date range
|
|
1224
|
+
const rowValue = row.getValue(columnId);
|
|
1225
|
+
// compare the date range
|
|
1226
|
+
// case if no start date or end date is selected
|
|
1227
|
+
// case if start date is selected
|
|
1228
|
+
// case if end date is selected
|
|
1229
|
+
if (!value) {
|
|
1230
|
+
return true;
|
|
1231
|
+
}
|
|
1232
|
+
const passed = typeof rowValue.getMonth === 'function' && ((_a = new Date(value)) === null || _a === void 0 ? void 0 : _a.toDateString()) === (rowValue === null || rowValue === void 0 ? void 0 : rowValue.toDateString());
|
|
1233
|
+
return passed;
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
const getLeafColumns = (columns) => {
|
|
1237
|
+
if (!columns || !columns.length) {
|
|
1238
|
+
return [];
|
|
1239
|
+
}
|
|
1240
|
+
return columns.reduce((totalItems, col) => {
|
|
1241
|
+
if (!col.columns) {
|
|
1242
|
+
totalItems.push(col);
|
|
1243
|
+
}
|
|
1244
|
+
return totalItems.concat(getLeafColumns(col.columns));
|
|
1245
|
+
}, []);
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
const useGridContainer = (props, ref) => {
|
|
1249
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1250
|
+
const { columns, data, rowSelectionMode } = props;
|
|
1251
|
+
const [pagination, setPagination] = React__namespace.useState({
|
|
1252
|
+
pageSize: props.pageSize || 10,
|
|
1253
|
+
pageIndex: 0,
|
|
1254
|
+
});
|
|
1255
|
+
const [sorting, setSorting] = React__namespace.useState((_a = props.sortingState) !== null && _a !== void 0 ? _a : []);
|
|
1256
|
+
const [columnFilters, setColumnFilters] = React__namespace.useState((_b = props.columnFilterState) !== null && _b !== void 0 ? _b : []);
|
|
1257
|
+
const [globalFilter, setGlobalFilter] = React__namespace.useState((_c = props.defaultGlobalFilter) !== null && _c !== void 0 ? _c : '');
|
|
1258
|
+
const [grouping, setGrouping] = React__namespace.useState((_d = props.groupingState) !== null && _d !== void 0 ? _d : []);
|
|
1259
|
+
const [rowSelection, setRowSelection] = React__namespace.useState((_e = props.rowSelectionState) !== null && _e !== void 0 ? _e : {});
|
|
1260
|
+
const [columnVisibility, setColumnVisibility] = React__namespace.useState((_f = props.columnVisibility) !== null && _f !== void 0 ? _f : {});
|
|
1261
|
+
const [columnOrder, setColumnOrder] = React__namespace.useState(() => {
|
|
1262
|
+
if (props.columnOrderState) {
|
|
1263
|
+
return props.columnOrderState;
|
|
1264
|
+
}
|
|
1265
|
+
const leafColumns = getLeafColumns(columns);
|
|
1266
|
+
return leafColumns.map((col) => col.id);
|
|
1267
|
+
});
|
|
1268
|
+
const [expanded, setExpanded] = React__namespace.useState((_g = props.expandedState) !== null && _g !== void 0 ? _g : {});
|
|
1269
|
+
const [columnPinning, setColumnPinning] = React__namespace.useState((_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {});
|
|
1270
|
+
const [columnSizing, setColumnSizing] = React__namespace.useState({});
|
|
1271
|
+
const table = reactTable.useReactTable({
|
|
1272
|
+
columns: columns,
|
|
1273
|
+
data,
|
|
1274
|
+
filterFns: {
|
|
1275
|
+
arrIncludesSome: arrIncludesSome,
|
|
1276
|
+
inDateRange: dateRange,
|
|
1277
|
+
matchDate: date,
|
|
1278
|
+
},
|
|
1279
|
+
initialState: {
|
|
1280
|
+
expanded: true,
|
|
1281
|
+
},
|
|
1282
|
+
state: {
|
|
1283
|
+
pagination,
|
|
1284
|
+
sorting,
|
|
1285
|
+
columnFilters,
|
|
1286
|
+
globalFilter,
|
|
1287
|
+
grouping,
|
|
1288
|
+
expanded,
|
|
1289
|
+
rowSelection,
|
|
1290
|
+
columnOrder,
|
|
1291
|
+
columnVisibility,
|
|
1292
|
+
columnPinning,
|
|
1293
|
+
columnSizing,
|
|
1294
|
+
},
|
|
1295
|
+
columnResizeMode: 'onChange',
|
|
1296
|
+
enableRowSelection: rowSelectionMode !== undefined,
|
|
1297
|
+
enableMultiRowSelection: rowSelectionMode === 'multiple',
|
|
1298
|
+
enableFilters: true,
|
|
1299
|
+
enableGlobalFilter: true,
|
|
1300
|
+
enableColumnFilters: true,
|
|
1301
|
+
filterFromLeafRows: true,
|
|
1302
|
+
autoResetExpanded: false,
|
|
1303
|
+
onRowSelectionChange: setRowSelection,
|
|
1304
|
+
onPaginationChange: setPagination,
|
|
1305
|
+
onSortingChange: setSorting,
|
|
1306
|
+
onColumnFiltersChange: setColumnFilters,
|
|
1307
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
1308
|
+
onGroupingChange: setGrouping,
|
|
1309
|
+
onColumnOrderChange: setColumnOrder,
|
|
1310
|
+
onExpandedChange: setExpanded,
|
|
1311
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
1312
|
+
onColumnPinningChange: setColumnPinning,
|
|
1313
|
+
onColumnSizingChange: setColumnSizing,
|
|
1314
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
1315
|
+
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
1316
|
+
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
1317
|
+
getFilteredRowModel: reactTable.getFilteredRowModel(),
|
|
1318
|
+
getGroupedRowModel: reactTable.getGroupedRowModel(),
|
|
1319
|
+
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
|
1320
|
+
getFacetedUniqueValues: reactTable.getFacetedUniqueValues(),
|
|
1321
|
+
getFacetedMinMaxValues: reactTable.getFacetedMinMaxValues(),
|
|
1322
|
+
});
|
|
1323
|
+
const tableViews = React__namespace.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
|
|
1324
|
+
const resetToDefaultView = () => {
|
|
1325
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1326
|
+
const defaultTableState = {
|
|
1327
|
+
pagination: {
|
|
1328
|
+
pageSize: props.pageSize || 10,
|
|
1329
|
+
pageIndex: 0,
|
|
1330
|
+
},
|
|
1331
|
+
sorting: (_a = props.sortingState) !== null && _a !== void 0 ? _a : [],
|
|
1332
|
+
columnFilters: (_b = props.columnFilterState) !== null && _b !== void 0 ? _b : [],
|
|
1333
|
+
globalFilter: (_c = props.defaultGlobalFilter) !== null && _c !== void 0 ? _c : '',
|
|
1334
|
+
grouping: (_d = props.groupingState) !== null && _d !== void 0 ? _d : [],
|
|
1335
|
+
expanded: (_e = props.expandedState) !== null && _e !== void 0 ? _e : {},
|
|
1336
|
+
rowSelection: (_f = props.rowSelectionState) !== null && _f !== void 0 ? _f : {},
|
|
1337
|
+
columnOrder: (() => {
|
|
1338
|
+
if (props.columnOrderState) {
|
|
1339
|
+
return props.columnOrderState;
|
|
1340
|
+
}
|
|
1341
|
+
const leafColumns = getLeafColumns(columns);
|
|
1342
|
+
return leafColumns.map((col) => col.id);
|
|
1343
|
+
})(),
|
|
1344
|
+
columnVisibility: (_g = props.columnVisibility) !== null && _g !== void 0 ? _g : {},
|
|
1345
|
+
columnPinning: (_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {},
|
|
1346
|
+
columnSizing: {},
|
|
1347
|
+
rowPinning: {},
|
|
1348
|
+
columnSizingInfo: {
|
|
1349
|
+
"startOffset": null,
|
|
1350
|
+
"startSize": null,
|
|
1351
|
+
"deltaOffset": null,
|
|
1352
|
+
"deltaPercentage": null,
|
|
1353
|
+
"isResizingColumn": false,
|
|
1354
|
+
"columnSizingStart": []
|
|
1355
|
+
},
|
|
1356
|
+
};
|
|
1357
|
+
return applyTableState(defaultTableState);
|
|
1358
|
+
};
|
|
1359
|
+
const applyTableState = (tableState) => {
|
|
1360
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1361
|
+
if (tableState) {
|
|
1362
|
+
// set table state
|
|
1363
|
+
console.log('tableState', tableState);
|
|
1364
|
+
setSorting((_a = tableState.sorting) !== null && _a !== void 0 ? _a : []);
|
|
1365
|
+
setColumnFilters((_b = tableState.columnFilters) !== null && _b !== void 0 ? _b : []);
|
|
1366
|
+
setGlobalFilter((_c = tableState.globalFilter) !== null && _c !== void 0 ? _c : '');
|
|
1367
|
+
setGrouping((_d = tableState.grouping) !== null && _d !== void 0 ? _d : []);
|
|
1368
|
+
setExpanded((_e = tableState.expanded) !== null && _e !== void 0 ? _e : {});
|
|
1369
|
+
setRowSelection((_f = tableState.rowSelection) !== null && _f !== void 0 ? _f : {});
|
|
1370
|
+
setColumnOrder((_g = tableState.columnOrder) !== null && _g !== void 0 ? _g : []);
|
|
1371
|
+
setColumnVisibility((_h = tableState.columnVisibility) !== null && _h !== void 0 ? _h : {});
|
|
1372
|
+
setColumnPinning((_j = tableState.columnPinning) !== null && _j !== void 0 ? _j : {});
|
|
1373
|
+
setColumnSizing((_k = tableState.columnSizing) !== null && _k !== void 0 ? _k : {});
|
|
1374
|
+
setTimeout(() => {
|
|
1375
|
+
var _a;
|
|
1376
|
+
setPagination((_a = tableState.pagination) !== null && _a !== void 0 ? _a : {
|
|
1377
|
+
pageSize: props.pageSize || 10,
|
|
1378
|
+
pageIndex: 0,
|
|
1379
|
+
});
|
|
1380
|
+
}, 10);
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
return false;
|
|
1384
|
+
};
|
|
1385
|
+
React__namespace.useImperativeHandle(ref, () => {
|
|
1386
|
+
return {
|
|
1387
|
+
table,
|
|
1388
|
+
getTableState: table.getState,
|
|
1389
|
+
applyTableState,
|
|
1390
|
+
resetToDefaultView
|
|
1391
|
+
};
|
|
1392
|
+
},
|
|
1393
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1394
|
+
[table]);
|
|
1395
|
+
const headerMenu = React__namespace.useMemo(() => {
|
|
1396
|
+
if (props.headerMenu) {
|
|
1397
|
+
const selectedRows = (table === null || table === void 0 ? void 0 : table.getSelectedRowModel().flatRows.map((row) => row.original)) || [];
|
|
1398
|
+
return props.headerMenu(selectedRows);
|
|
1399
|
+
}
|
|
1400
|
+
return null;
|
|
1401
|
+
},
|
|
1402
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1403
|
+
[props.headerMenu, rowSelection]);
|
|
1404
|
+
// add event listeners to listen ctrl + shift + t and log current table state
|
|
1405
|
+
React__namespace.useEffect(() => {
|
|
1406
|
+
const handleKeyDown = (event) => {
|
|
1407
|
+
if (event.ctrlKey && event.altKey && event.key === 'c') {
|
|
1408
|
+
event.preventDefault();
|
|
1409
|
+
const tableState = table.getState();
|
|
1410
|
+
// log table state to console
|
|
1411
|
+
console.log(tableState);
|
|
1412
|
+
// save table state to local storage
|
|
1413
|
+
localStorage.setItem('hotkey_table_state_temp', JSON.stringify(tableState));
|
|
1414
|
+
// copy table state to clipboard
|
|
1415
|
+
navigator.clipboard.writeText(JSON.stringify(tableState));
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
1419
|
+
return () => {
|
|
1420
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
1421
|
+
};
|
|
1422
|
+
}, [table]);
|
|
1423
|
+
return {
|
|
1424
|
+
table,
|
|
1425
|
+
globalFilter,
|
|
1426
|
+
tableViews,
|
|
1427
|
+
headerMenu,
|
|
1428
|
+
setGlobalFilter,
|
|
1429
|
+
resetToDefaultView,
|
|
1430
|
+
applyTableState
|
|
1431
|
+
};
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
const useTableHeaderStyles = reactComponents.makeStyles({
|
|
1435
|
+
tHead: {
|
|
1436
|
+
zIndex: 1,
|
|
1437
|
+
backgroundColor: reactComponents.tokens.colorNeutralStroke2,
|
|
1438
|
+
color: reactComponents.tokens.colorNeutralForeground1,
|
|
1439
|
+
position: "sticky",
|
|
1440
|
+
top: 0,
|
|
1441
|
+
width: "100%",
|
|
1442
|
+
boxShadow: reactComponents.tokens.shadow2,
|
|
1443
|
+
},
|
|
1444
|
+
tHeadRow: {
|
|
1445
|
+
backgroundColor: reactComponents.tokens.colorNeutralStroke2,
|
|
1446
|
+
},
|
|
1447
|
+
tHeadCell: Object.assign({ zIndex: 99, position: 'relative', fontSize: reactComponents.tokens.fontSizeBase300, fontWeight: reactComponents.tokens.fontWeightBold, minWidth: '1rem' }, reactComponents.shorthands.padding('2px', '4px')),
|
|
1448
|
+
tHeadNonLeafCell: Object.assign({}, reactComponents.shorthands.borderBottom('1px', 'solid', reactComponents.tokens.colorNeutralBackground1)),
|
|
1449
|
+
tHeadCellDraggable: {
|
|
1450
|
+
height: '100%',
|
|
1451
|
+
cursor: 'grab',
|
|
1452
|
+
},
|
|
1453
|
+
tHeadCellDragging: {
|
|
1454
|
+
opacity: 0.5,
|
|
1455
|
+
cursor: 'grabbing',
|
|
1456
|
+
},
|
|
1457
|
+
tHeadCellOver: Object.assign({ backgroundColor: reactComponents.tokens.colorNeutralStroke1 }, reactComponents.shorthands.border(reactComponents.tokens.strokeWidthThin, 'dashed', reactComponents.tokens.colorBrandBackground2Pressed)),
|
|
1458
|
+
tLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'space-between', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', width: '100%', height: '100%', minWidth: '1rem' }, reactComponents.shorthands.padding('3px', '4px')),
|
|
1459
|
+
tNonLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'center', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', width: '100%', minWidth: '1rem' }, reactComponents.shorthands.padding('3px', '4px')),
|
|
1460
|
+
tHeadContentBtn: Object.assign(Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.padding('0px', '0px', '0px', '0px')), { display: 'flex' }), reactComponents.shorthands.gap('5px')), { alignContent: 'space-between', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', width: '100%', height: '100%', minWidth: '1rem' }),
|
|
1461
|
+
tHeadMenuPopover: Object.assign(Object.assign({}, reactComponents.shorthands.padding('0px', '0px', '0px', '0px')), { width: '300px' }),
|
|
1462
|
+
resizer: Object.assign(Object.assign({}, reactComponents.shorthands.borderRight('1px', 'solid', reactComponents.tokens.colorNeutralBackground1)), { width: '8px', position: 'absolute', top: 0, right: 0, bottom: 0, cursor: 'col-resize', resize: 'horizontal', ':hover': {
|
|
1463
|
+
borderRightWidth: '4px',
|
|
1464
|
+
borderRightColor: reactComponents.tokens.colorNeutralBackground2Pressed,
|
|
1465
|
+
} }),
|
|
1466
|
+
resizerActive: {
|
|
1467
|
+
borderRightWidth: '4px',
|
|
1468
|
+
borderRightColor: reactComponents.tokens.colorNeutralBackground2Pressed,
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
const useCheckboxFilterStyles = reactComponents.makeStyles({
|
|
1473
|
+
searchInput: {
|
|
1474
|
+
width: '90%',
|
|
1475
|
+
marginBottom: '8px',
|
|
1476
|
+
marginLeft: '10px',
|
|
1477
|
+
marginRight: '10px',
|
|
1478
|
+
},
|
|
1479
|
+
searchContainer: Object.assign(Object.assign(Object.assign({ display: 'flex', flexDirection: 'column', maxHeight: '300px', width: '100%' }, reactComponents.shorthands.overflow('auto', 'auto')), reactComponents.shorthands.padding('0px', "0px", "2px", '0px')), { '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, reactComponents.shorthands.borderRadius('50%')),
|
|
1480
|
+
/* Track */
|
|
1481
|
+
'::-webkit-scrollbar-track': {
|
|
1482
|
+
'background-color': '#f1f1f1',
|
|
1483
|
+
},
|
|
1484
|
+
/* Handle */
|
|
1485
|
+
'::-webkit-scrollbar-thumb': {
|
|
1486
|
+
'background-color': '#888',
|
|
1487
|
+
},
|
|
1488
|
+
/* Handle on hover */
|
|
1489
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
1490
|
+
'background-color': '#555',
|
|
1491
|
+
} }),
|
|
1492
|
+
});
|
|
1493
|
+
const FilterMultiSelectCheckbox = ({ column, table, }) => {
|
|
1494
|
+
var _a, _b, _c;
|
|
1495
|
+
const firstValue = (_a = table
|
|
1496
|
+
.getPreFilteredRowModel()
|
|
1497
|
+
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
|
|
1498
|
+
const columnFilterValue = column.getFilterValue();
|
|
1499
|
+
const [filterOptions, setFilterOptions] = React__namespace.useState([]);
|
|
1500
|
+
React__namespace.useEffect(() => {
|
|
1501
|
+
const uniqueSortedOptions = typeof firstValue === 'number' || !isNaN(firstValue)
|
|
1502
|
+
? Array.from(column.getFacetedUniqueValues().keys()).sort((a, b) => Number(a) - Number(b))
|
|
1503
|
+
: Array.from(column.getFacetedUniqueValues().keys()).sort();
|
|
1504
|
+
setFilterOptions(uniqueSortedOptions);
|
|
1505
|
+
},
|
|
1506
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1507
|
+
[column.getFacetedUniqueValues()]);
|
|
1508
|
+
const [localColumnFilterValue, setLocalColumnFilterValue] = React__namespace.useState('');
|
|
1509
|
+
const filterOptionsFiltered = React__namespace.useMemo(() => {
|
|
1510
|
+
if (!localColumnFilterValue)
|
|
1511
|
+
return filterOptions;
|
|
1512
|
+
return filterOptions.filter((option) => {
|
|
1513
|
+
var _a, _b, _c;
|
|
1514
|
+
return (_b = (_a = `${option}`) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes((_c = `${localColumnFilterValue}`) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
1515
|
+
});
|
|
1516
|
+
}, [localColumnFilterValue, filterOptions]);
|
|
1517
|
+
const filterContainer = React__namespace.useRef(null);
|
|
1518
|
+
const rowVirtualizer = reactVirtual.useVirtual({
|
|
1519
|
+
parentRef: filterContainer,
|
|
1520
|
+
size: filterOptionsFiltered.length,
|
|
1521
|
+
overscan: 15,
|
|
1522
|
+
});
|
|
1523
|
+
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
1524
|
+
const paddingTop = virtualRows.length > 0 ? ((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[0]) === null || _b === void 0 ? void 0 : _b.start) || 0 : 0;
|
|
1525
|
+
const paddingBottom = virtualRows.length > 0
|
|
1526
|
+
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
1527
|
+
: 0;
|
|
1528
|
+
const allOptionChecked = (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0 &&
|
|
1529
|
+
(columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) !== (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length)
|
|
1530
|
+
? 'mixed'
|
|
1531
|
+
: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) === (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) &&
|
|
1532
|
+
(filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) > 0;
|
|
1533
|
+
const styles = useCheckboxFilterStyles();
|
|
1534
|
+
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(reactComponents.Input, { type: 'search', value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsxRuntime.jsxs("div", { ref: filterContainer, className: styles.searchContainer, children: [paddingTop > 0 && (jsxRuntime.jsx("span", { style: { paddingTop: `${paddingTop}px` } })), jsxRuntime.jsx(reactComponents.Checkbox, { checked: allOptionChecked, onChange: () => {
|
|
1535
|
+
if ((columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0) {
|
|
1536
|
+
column.setFilterValue(undefined);
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
column.setFilterValue([
|
|
1540
|
+
...((filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.map((x) => `${x}`)) || []),
|
|
1541
|
+
]);
|
|
1542
|
+
}, label: '(Toggle All)' }, `toggle-all-${column.id}`), virtualRows.map((row) => {
|
|
1543
|
+
var _a;
|
|
1544
|
+
const value = `${filterOptionsFiltered[row.index]}`;
|
|
1545
|
+
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: (_a = columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) !== null && _a !== void 0 ? _a : false, onChange: () => {
|
|
1546
|
+
if (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) {
|
|
1547
|
+
column.setFilterValue((old) => old === null || old === void 0 ? void 0 : old.filter((v) => v !== value));
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
column.setFilterValue((old) => [
|
|
1551
|
+
...(old || []),
|
|
1552
|
+
value,
|
|
1553
|
+
]);
|
|
1554
|
+
}, label: value }, `${column.id}-${row.index}`));
|
|
1555
|
+
}), paddingBottom > 0 && (jsxRuntime.jsx("span", { style: { paddingBottom: `${paddingBottom}px` } }))] }, 'filter-multi-select-checkbox')] }));
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
const useRadioFilterStyles = reactComponents.makeStyles({
|
|
1559
|
+
searchInput: {
|
|
1560
|
+
width: '90%',
|
|
1561
|
+
marginBottom: '8px',
|
|
1562
|
+
marginLeft: '10px',
|
|
1563
|
+
marginRight: '10px',
|
|
1564
|
+
},
|
|
1565
|
+
searchContainer: Object.assign(Object.assign({ display: 'flex', flexDirection: 'column', maxHeight: '300px', width: '100%' }, reactComponents.shorthands.overflow('auto', 'auto')), { '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, reactComponents.shorthands.borderRadius('50%')),
|
|
1566
|
+
/* Track */
|
|
1567
|
+
'::-webkit-scrollbar-track': {
|
|
1568
|
+
'background-color': '#f1f1f1',
|
|
1569
|
+
},
|
|
1570
|
+
/* Handle */
|
|
1571
|
+
'::-webkit-scrollbar-thumb': {
|
|
1572
|
+
'background-color': '#888',
|
|
1573
|
+
},
|
|
1574
|
+
/* Handle on hover */
|
|
1575
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
1576
|
+
'background-color': '#555',
|
|
1577
|
+
} }),
|
|
1578
|
+
});
|
|
1579
|
+
const FilterSelectRadio = ({ column, table, }) => {
|
|
1580
|
+
var _a, _b, _c;
|
|
1581
|
+
const firstValue = (_a = table
|
|
1582
|
+
.getPreFilteredRowModel()
|
|
1583
|
+
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
|
|
1584
|
+
const columnFilterValue = column.getFilterValue();
|
|
1585
|
+
const [filterOptions, setFilterOptions] = React__namespace.useState([]);
|
|
1586
|
+
React__namespace.useEffect(() => {
|
|
1587
|
+
const uniqueSortedOptions = typeof firstValue === 'number' || !isNaN(firstValue)
|
|
1588
|
+
? Array.from(column.getFacetedUniqueValues().keys()).sort((a, b) => Number(a) - Number(b))
|
|
1589
|
+
: Array.from(column.getFacetedUniqueValues().keys()).sort();
|
|
1590
|
+
setFilterOptions(uniqueSortedOptions);
|
|
1591
|
+
},
|
|
1592
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1593
|
+
[column.getFacetedUniqueValues()]);
|
|
1594
|
+
const [localColumnFilterValue, setLocalColumnFilterValue] = React__namespace.useState('');
|
|
1595
|
+
const filterOptionsFiltered = React__namespace.useMemo(() => {
|
|
1596
|
+
if (!localColumnFilterValue)
|
|
1597
|
+
return filterOptions;
|
|
1598
|
+
return filterOptions.filter((option) => {
|
|
1599
|
+
var _a, _b, _c;
|
|
1600
|
+
return (_b = (_a = `${option}`) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes((_c = `${localColumnFilterValue}`) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
1601
|
+
});
|
|
1602
|
+
}, [localColumnFilterValue, filterOptions]);
|
|
1603
|
+
const filterContainer = React__namespace.useRef(null);
|
|
1604
|
+
const rowVirtualizer = reactVirtual.useVirtual({
|
|
1605
|
+
parentRef: filterContainer,
|
|
1606
|
+
size: filterOptionsFiltered.length,
|
|
1607
|
+
overscan: 15,
|
|
1608
|
+
});
|
|
1609
|
+
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
1610
|
+
const paddingTop = virtualRows.length > 0 ? ((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[0]) === null || _b === void 0 ? void 0 : _b.start) || 0 : 0;
|
|
1611
|
+
const paddingBottom = virtualRows.length > 0
|
|
1612
|
+
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
1613
|
+
: 0;
|
|
1614
|
+
const styles = useRadioFilterStyles();
|
|
1615
|
+
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(reactComponents.Input, { value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsxRuntime.jsxs("div", { ref: filterContainer, className: styles.searchContainer, children: [paddingTop > 0 && jsxRuntime.jsx("div", { style: { paddingTop: `${paddingTop}px` } }), jsxRuntime.jsxs(reactComponents.RadioGroup, { layout: "vertical", value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || '', onChange: (_, data) => {
|
|
1616
|
+
if (data.value === '') {
|
|
1617
|
+
column.setFilterValue([]);
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
column.setFilterValue([data.value]);
|
|
1621
|
+
}, children: [jsxRuntime.jsx(reactComponents.Radio, { value: '', label: 'None' }), virtualRows.map((row) => {
|
|
1622
|
+
const value = filterOptionsFiltered[row.index];
|
|
1623
|
+
return jsxRuntime.jsx(reactComponents.Radio, { value: value, label: value }, value);
|
|
1624
|
+
})] }), paddingBottom > 0 && (jsxRuntime.jsx("div", { style: { paddingBottom: `${paddingBottom}px` } }))] })] }));
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
const useNumberRangeFilterStyles$2 = reactComponents.makeStyles({
|
|
1628
|
+
searchInput: {
|
|
1629
|
+
width: '100%',
|
|
1630
|
+
},
|
|
1631
|
+
searchInputField: {
|
|
1632
|
+
width: '100%',
|
|
1633
|
+
flexGrow: 1,
|
|
1634
|
+
},
|
|
1635
|
+
searchContainer: {
|
|
1636
|
+
display: 'flex',
|
|
1637
|
+
marginBottom: '8px',
|
|
1638
|
+
marginLeft: '10px',
|
|
1639
|
+
marginRight: '10px',
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
const FilterNumberRange = (props) => {
|
|
1643
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1644
|
+
const { column } = props;
|
|
1645
|
+
const columnFilterValue = column.getFilterValue();
|
|
1646
|
+
const min = Number((_b = (_a = column.getFacetedMinMaxValues()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '');
|
|
1647
|
+
const max = Number((_d = (_c = column.getFacetedMinMaxValues()) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : '');
|
|
1648
|
+
const handleMinChange = (e, data) => {
|
|
1649
|
+
const value = Number(data.value);
|
|
1650
|
+
column.setFilterValue((old) => [value, old === null || old === void 0 ? void 0 : old[1]]);
|
|
1651
|
+
};
|
|
1652
|
+
const handleMaxChange = (e, data) => {
|
|
1653
|
+
const value = Number(data.value);
|
|
1654
|
+
column.setFilterValue((old) => [old === null || old === void 0 ? void 0 : old[0], value]);
|
|
1655
|
+
};
|
|
1656
|
+
const styles = useNumberRangeFilterStyles$2();
|
|
1657
|
+
return (jsxRuntime.jsxs("div", { className: styles.searchContainer, children: [jsxRuntime.jsx(reactComponents.Field, { label: 'Min:', size: "small", className: styles.searchInputField, children: jsxRuntime.jsx(reactComponents.Input, { type: "number", value: `${(columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || ''}`, min: min, max: max, onChange: handleMinChange, className: styles.searchInput, placeholder: `Min ${((_e = column.getFacetedMinMaxValues()) === null || _e === void 0 ? void 0 : _e[0])
|
|
1658
|
+
? `(${(_f = column.getFacetedMinMaxValues()) === null || _f === void 0 ? void 0 : _f[0]})`
|
|
1659
|
+
: ''}` }) }), jsxRuntime.jsx(reactComponents.Field, { label: 'Max:', size: "small", className: styles.searchInputField, children: jsxRuntime.jsx(reactComponents.Input, { type: "number", value: `${(columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[1]) || ''}`, min: min, max: max, onChange: handleMaxChange, className: styles.searchInput, placeholder: `Max ${((_g = column.getFacetedMinMaxValues()) === null || _g === void 0 ? void 0 : _g[1])
|
|
1660
|
+
? `(${(_h = column.getFacetedMinMaxValues()) === null || _h === void 0 ? void 0 : _h[1]})`
|
|
1661
|
+
: ''}` }) })] }));
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
const useNumberRangeFilterStyles$1 = reactComponents.makeStyles({
|
|
1665
|
+
searchInput: {
|
|
1666
|
+
width: '100%',
|
|
1667
|
+
},
|
|
1668
|
+
searchInputField: {
|
|
1669
|
+
width: '100%',
|
|
1670
|
+
flexGrow: 1,
|
|
1671
|
+
},
|
|
1672
|
+
searchContainer: {
|
|
1673
|
+
display: 'flex',
|
|
1674
|
+
flexDirection: 'column',
|
|
1675
|
+
marginBottom: '8px',
|
|
1676
|
+
marginLeft: '10px',
|
|
1677
|
+
marginRight: '10px',
|
|
1678
|
+
},
|
|
1679
|
+
});
|
|
1680
|
+
const FilterDateRange = (props) => {
|
|
1681
|
+
var _a, _b, _c, _d;
|
|
1682
|
+
const { column } = props;
|
|
1683
|
+
const columnFilterValue = column.getFilterValue();
|
|
1684
|
+
const min = (_b = (_a = column.getFacetedMinMaxValues()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : undefined;
|
|
1685
|
+
const max = (_d = (_c = column.getFacetedMinMaxValues()) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : undefined;
|
|
1686
|
+
const handleMinChange = (date) => {
|
|
1687
|
+
if (!date) {
|
|
1688
|
+
column.setFilterValue((old) => [undefined, old === null || old === void 0 ? void 0 : old[1]]);
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
column.setFilterValue((old) => [date, old === null || old === void 0 ? void 0 : old[1]]);
|
|
1692
|
+
};
|
|
1693
|
+
const handleMaxChange = (date) => {
|
|
1694
|
+
if (!date) {
|
|
1695
|
+
column.setFilterValue((old) => [old === null || old === void 0 ? void 0 : old[0], undefined]);
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
column.setFilterValue((old) => [old === null || old === void 0 ? void 0 : old[0], date]);
|
|
1699
|
+
};
|
|
1700
|
+
const styles = useNumberRangeFilterStyles$1();
|
|
1701
|
+
return (jsxRuntime.jsxs("div", { className: styles.searchContainer, children: [jsxRuntime.jsx(reactComponents.Field, { label: 'From Date:', size: "small", className: styles.searchInputField, children: jsxRuntime.jsx(reactDatepickerCompat.DatePicker, { value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || null, min: min, max: max, onSelectDate: handleMinChange, className: styles.searchInput, placeholder: `From Date`, size: 'small', allowTextInput: true }) }), jsxRuntime.jsx(reactComponents.Field, { label: 'To Date:', size: "small", className: styles.searchInputField, children: jsxRuntime.jsx(reactDatepickerCompat.DatePicker, { value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[1]) || null, min: min, max: max, onSelectDate: handleMaxChange, className: styles.searchInput, placeholder: `To Date`, size: 'small', allowTextInput: true }) })] }));
|
|
1702
|
+
};
|
|
1703
|
+
|
|
1704
|
+
const useNumberRangeFilterStyles = reactComponents.makeStyles({
|
|
1705
|
+
searchInput: {
|
|
1706
|
+
width: '100%',
|
|
1707
|
+
},
|
|
1708
|
+
searchInputField: {
|
|
1709
|
+
width: '100%',
|
|
1710
|
+
flexGrow: 1,
|
|
1711
|
+
},
|
|
1712
|
+
searchContainer: {
|
|
1713
|
+
display: 'flex',
|
|
1714
|
+
flexDirection: 'column',
|
|
1715
|
+
marginBottom: '8px',
|
|
1716
|
+
marginLeft: '10px',
|
|
1717
|
+
marginRight: '10px',
|
|
1718
|
+
},
|
|
1719
|
+
});
|
|
1720
|
+
const FilterDate = (props) => {
|
|
1721
|
+
var _a, _b, _c, _d;
|
|
1722
|
+
const { column } = props;
|
|
1723
|
+
const columnFilterValue = column.getFilterValue();
|
|
1724
|
+
const min = (_b = (_a = column.getFacetedMinMaxValues()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : undefined;
|
|
1725
|
+
const max = (_d = (_c = column.getFacetedMinMaxValues()) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : undefined;
|
|
1726
|
+
const onDateSelect = (date) => {
|
|
1727
|
+
if (!date) {
|
|
1728
|
+
column.setFilterValue(undefined);
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
column.setFilterValue(date);
|
|
1732
|
+
};
|
|
1733
|
+
const styles = useNumberRangeFilterStyles();
|
|
1734
|
+
return (jsxRuntime.jsx("div", { className: styles.searchContainer, children: jsxRuntime.jsx(reactDatepickerCompat.DatePicker, { value: columnFilterValue || null, min: min, max: max, onSelectDate: onDateSelect, className: styles.searchInput, placeholder: `Select a date`, size: 'small', allowTextInput: true }) }));
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
const useFilterStyles = reactComponents.makeStyles({
|
|
1738
|
+
searchInput: {
|
|
1739
|
+
width: '100%',
|
|
1740
|
+
},
|
|
1741
|
+
searchInputField: {
|
|
1742
|
+
width: '100%',
|
|
1743
|
+
flexGrow: 1,
|
|
1744
|
+
},
|
|
1745
|
+
searchContainer: {
|
|
1746
|
+
display: 'flex',
|
|
1747
|
+
marginBottom: '8px',
|
|
1748
|
+
marginLeft: '10px',
|
|
1749
|
+
marginRight: '10px',
|
|
1750
|
+
},
|
|
1751
|
+
});
|
|
1752
|
+
const Filter = ({ column, table, }) => {
|
|
1753
|
+
var _a, _b;
|
|
1754
|
+
const filterFunctionName = column.columnDef.filterFn;
|
|
1755
|
+
const styles = useFilterStyles();
|
|
1756
|
+
switch (filterFunctionName) {
|
|
1757
|
+
case 'arrIncludesSome':
|
|
1758
|
+
return jsxRuntime.jsx(FilterMultiSelectCheckbox, { column: column, table: table });
|
|
1759
|
+
case 'arrIncludesAll':
|
|
1760
|
+
case 'arrIncludes':
|
|
1761
|
+
return jsxRuntime.jsx(FilterSelectRadio, { column: column, table: table });
|
|
1762
|
+
case 'inNumberRange':
|
|
1763
|
+
return jsxRuntime.jsx(FilterNumberRange, { column: column, table: table });
|
|
1764
|
+
case 'inDateRange': {
|
|
1765
|
+
const firstValue = (_a = table
|
|
1766
|
+
.getPreFilteredRowModel()
|
|
1767
|
+
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
|
|
1768
|
+
if (typeof firstValue.getMonth === 'function') {
|
|
1769
|
+
return jsxRuntime.jsx(FilterDateRange, { column: column, table: table });
|
|
1770
|
+
}
|
|
1771
|
+
break;
|
|
1772
|
+
}
|
|
1773
|
+
case 'matchDate': {
|
|
1774
|
+
const firstValue = (_b = table
|
|
1775
|
+
.getPreFilteredRowModel()
|
|
1776
|
+
.flatRows[0]) === null || _b === void 0 ? void 0 : _b.getValue(column.id);
|
|
1777
|
+
if (typeof firstValue.getMonth === 'function') {
|
|
1778
|
+
return jsxRuntime.jsx(FilterDate, { column: column, table: table });
|
|
1779
|
+
}
|
|
1780
|
+
break;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
return (jsxRuntime.jsx("div", { className: styles.searchContainer, children: jsxRuntime.jsx(reactComponents.Field, { size: 'small', className: styles.searchInputField, children: jsxRuntime.jsx(reactComponents.Input, { value: (column.getFilterValue() || ''), onChange: (_, data) => {
|
|
1784
|
+
column.setFilterValue(data.value);
|
|
1785
|
+
}, placeholder: "Search Keyword...", size: "small", className: styles.searchInput }) }) }));
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
const useFilterDrawerStyles$1 = reactComponents.makeStyles({
|
|
1789
|
+
drawerBody: Object.assign(Object.assign({}, reactComponents.shorthands.overflow('hidden', 'auto')), {
|
|
1790
|
+
/* width */
|
|
1791
|
+
':hover': Object.assign({}, reactComponents.shorthands.overflow('auto', 'auto')), '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, reactComponents.shorthands.borderRadius('50%')),
|
|
1792
|
+
/* Track */
|
|
1793
|
+
'::-webkit-scrollbar-track': {
|
|
1794
|
+
'background-color': '#f1f1f1',
|
|
1795
|
+
},
|
|
1796
|
+
/* Handle */
|
|
1797
|
+
'::-webkit-scrollbar-thumb': {
|
|
1798
|
+
'background-color': '#888',
|
|
1799
|
+
},
|
|
1800
|
+
/* Handle on hover */
|
|
1801
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
1802
|
+
'background-color': '#555',
|
|
1803
|
+
} }),
|
|
1804
|
+
});
|
|
1805
|
+
const FilterDrawer = ({ drawerState, dispatch, table }) => {
|
|
1806
|
+
const headerGroups = table.getHeaderGroups();
|
|
1807
|
+
const styles = useFilterDrawerStyles$1();
|
|
1808
|
+
const resetAllFilters = React__namespace.useCallback(() => {
|
|
1809
|
+
table.setGlobalFilter('');
|
|
1810
|
+
table.resetColumnFilters();
|
|
1811
|
+
}, [table]);
|
|
1812
|
+
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState.isFilterDrawerOpen, separator: true, children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Advanced Filters" }) }), jsxRuntime.jsx(reactComponents.DrawerBody, { className: styles.drawerBody, children: headerGroups.map((headerGroup) => {
|
|
1813
|
+
const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
|
|
1814
|
+
if (!canApplyFilter)
|
|
1815
|
+
return null;
|
|
1816
|
+
return headerGroup.headers.map((header) => {
|
|
1817
|
+
const canFilter = header.column.getCanFilter();
|
|
1818
|
+
if (!canFilter)
|
|
1819
|
+
return null;
|
|
1820
|
+
return (jsxRuntime.jsx("div", { children: header.column.getCanFilter() && (jsxRuntime.jsxs("div", { style: {
|
|
1821
|
+
marginTop: "20px",
|
|
1822
|
+
}, children: [jsxRuntime.jsxs(reactComponents.Caption1Stronger, { children: ["Filter by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }), jsxRuntime.jsx(Filter, { column: header.column, table: table })] }, 'filter-group')) }, header.column.id));
|
|
1823
|
+
});
|
|
1824
|
+
}) }), jsxRuntime.jsx(reactComponents.DrawerFooter, { children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ClearFilterIcon, {}), onClick: resetAllFilters, style: { width: "100%" }, children: "Clear All Filters" }) })] }));
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1827
|
+
const SortAscIcon = bundleIcon$1(ArrowSortDown20Filled, ArrowSortDown20Regular);
|
|
1828
|
+
const SortDescIcon = bundleIcon$1(ArrowSortUp20Filled, ArrowSortUp20Regular);
|
|
1829
|
+
const reorderColumn = (draggedColumnId, targetColumnId, columnOrder) => {
|
|
1830
|
+
columnOrder.splice(columnOrder.indexOf(targetColumnId), 0, columnOrder.splice(columnOrder.indexOf(draggedColumnId), 1)[0]);
|
|
1831
|
+
return [...columnOrder];
|
|
1832
|
+
};
|
|
1833
|
+
function HeaderCell({ header, table, hideMenu, headerDepth, totalNumberOfHeaderDepth, }) {
|
|
1834
|
+
var _a;
|
|
1835
|
+
const { getState, setColumnOrder } = table;
|
|
1836
|
+
const { columnOrder } = getState();
|
|
1837
|
+
const { column } = header;
|
|
1838
|
+
const [{ isOver }, dropRef] = reactDnd.useDrop({
|
|
1839
|
+
accept: "column",
|
|
1840
|
+
drop: (draggedColumn) => {
|
|
1841
|
+
const newColumnOrder = reorderColumn(draggedColumn.id, column.id, columnOrder);
|
|
1842
|
+
setColumnOrder(newColumnOrder);
|
|
1843
|
+
},
|
|
1844
|
+
collect: (monitor) => ({
|
|
1845
|
+
isOver: monitor.isOver(),
|
|
1846
|
+
}),
|
|
1847
|
+
});
|
|
1848
|
+
const [{ isDragging }, dragRef, previewRef] = reactDnd.useDrag({
|
|
1849
|
+
collect: (monitor) => ({
|
|
1850
|
+
isDragging: monitor.isDragging(),
|
|
1851
|
+
}),
|
|
1852
|
+
item: () => column,
|
|
1853
|
+
type: "column",
|
|
1854
|
+
});
|
|
1855
|
+
const styles = useTableHeaderStyles();
|
|
1856
|
+
const canDragDrop = headerDepth === totalNumberOfHeaderDepth && !header.isPlaceholder;
|
|
1857
|
+
const isLeafHeaders = headerDepth === totalNumberOfHeaderDepth;
|
|
1858
|
+
if (header.isPlaceholder) {
|
|
1859
|
+
return (jsxRuntime.jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, children: header.column.getCanResize() && (jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) })) }));
|
|
1860
|
+
}
|
|
1861
|
+
return (jsxRuntime.jsxs("th", { colSpan: header.colSpan, className: reactComponents.mergeClasses(styles.tHeadCell, isLeafHeaders || header.isPlaceholder ? undefined
|
|
1862
|
+
: styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging, isOver && isLeafHeaders && styles.tHeadCellOver), children: [jsxRuntime.jsx("div", { className: styles.tHeadCellDraggable, ref: canDragDrop ? dropRef : undefined, children: jsxRuntime.jsxs("div", { className: isLeafHeaders
|
|
1863
|
+
? styles.tLeafHeadCellContent
|
|
1864
|
+
: styles.tNonLeafHeadCellContent, ref: canDragDrop ? dragRef : undefined, children: [jsxRuntime.jsx("div", { ref: canDragDrop ? previewRef : undefined, children: header.isPlaceholder ? null : (jsxRuntime.jsxs(reactComponents.Button, { style: {
|
|
1865
|
+
display: 'flex',
|
|
1866
|
+
alignItems: 'center',
|
|
1867
|
+
justifyContent: 'left',
|
|
1868
|
+
flex: 1,
|
|
1869
|
+
}, onClick: (e) => {
|
|
1870
|
+
if (!header.column.getCanSort())
|
|
1871
|
+
return;
|
|
1872
|
+
header.column.toggleSorting(header.column.getIsSorted() === 'asc', e.ctrlKey);
|
|
1873
|
+
}, onDoubleClick: () => {
|
|
1874
|
+
if (!header.column.getCanGroup())
|
|
1875
|
+
return;
|
|
1876
|
+
header.column.getToggleGroupingHandler()();
|
|
1877
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
|
|
1878
|
+
asc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortAscIcon, {}) })),
|
|
1879
|
+
desc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortDescIcon, {}) })),
|
|
1880
|
+
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsxRuntime.jsx("strong", { children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }), header.column.getIsGrouped() && jsxRuntime.jsx(GroupListRegular, {}), header.column.getIsFiltered() && (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(FilterFilled, {}) })), header.column.getIsPinned() && jsxRuntime.jsx(PinRegular, {})] })) }), jsxRuntime.jsx(HeaderMenu, { header: header, table: table, hideMenu: hideMenu })] }) }), header.column.getCanResize() && (jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }))] }));
|
|
1881
|
+
}
|
|
1882
|
+
function HeaderMenu(props) {
|
|
1883
|
+
const { header, table, hideMenu } = props;
|
|
1884
|
+
const styles = useTableHeaderStyles();
|
|
1885
|
+
if (hideMenu || header.isPlaceholder)
|
|
1886
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }));
|
|
1887
|
+
const canHavePopOver = header.column.getCanSort() ||
|
|
1888
|
+
header.column.getCanGroup() ||
|
|
1889
|
+
header.column.getCanFilter();
|
|
1890
|
+
if (!canHavePopOver)
|
|
1891
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }));
|
|
1892
|
+
return (jsxRuntime.jsxs(reactComponents.Menu, { children: [jsxRuntime.jsx(reactComponents.MenuTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.MenuButton, { appearance: "transparent", "aria-label": "View Column Actions" }) }), jsxRuntime.jsx(reactComponents.MenuPopover, { className: styles.tHeadMenuPopover, children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [header.column.getCanSort() && (jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [jsxRuntime.jsxs(reactComponents.MenuGroupHeader, { children: ["Sort by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: (e) => {
|
|
1893
|
+
var _a;
|
|
1894
|
+
const isControlKeySelected = e.ctrlKey;
|
|
1895
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(false, isControlKeySelected);
|
|
1896
|
+
}, icon: jsxRuntime.jsx(TextSortAscendingFilled, {}), disabled: header.column.getIsSorted() === 'asc', children: "Sort A to Z" }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: (e) => {
|
|
1897
|
+
var _a;
|
|
1898
|
+
const isControlKeySelected = e.ctrlKey;
|
|
1899
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(true, isControlKeySelected);
|
|
1900
|
+
}, icon: jsxRuntime.jsx(TextSortDescendingFilled, {}), disabled: header.column.getIsSorted() === 'desc', children: "Sort Z to A" }), jsxRuntime.jsx(reactComponents.MenuDivider, {})] }, 'sort-group')), header.column.getCanGroup() && (jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [jsxRuntime.jsxs(reactComponents.MenuGroupHeader, { children: ["Group by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }), !header.column.getIsGrouped() && (jsxRuntime.jsxs(reactComponents.MenuItem, { onClick: () => header.column.getToggleGroupingHandler()(), icon: jsxRuntime.jsx(GroupFilled, {}), children: ["Group by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] })), header.column.getIsGrouped() && (jsxRuntime.jsxs(reactComponents.MenuItem, { onClick: () => header.column.getToggleGroupingHandler()(), icon: jsxRuntime.jsx(GroupDismissFilled, {}), children: ["Remove Grouping on", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] })), jsxRuntime.jsx(reactComponents.MenuDivider, {})] }, 'grouping-group')), header.column.getCanSort() && (jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [jsxRuntime.jsxs(reactComponents.MenuGroupHeader, { children: ["Pin Column", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: () => {
|
|
1901
|
+
var _a;
|
|
1902
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('left');
|
|
1903
|
+
}, icon: jsxRuntime.jsx(ArrowStepInLeftRegular, {}), disabled: header.column.getIsPinned() === 'left', children: "To Left" }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: () => {
|
|
1904
|
+
var _a;
|
|
1905
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('right');
|
|
1906
|
+
}, icon: jsxRuntime.jsx(ArrowStepInRightRegular, {}), disabled: header.column.getIsPinned() === 'right', children: "To Right" }), ['left', 'right'].includes(header.column.getIsPinned()) && (jsxRuntime.jsx(reactComponents.MenuItem, { onClick: () => {
|
|
1907
|
+
var _a;
|
|
1908
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin(false);
|
|
1909
|
+
}, icon: jsxRuntime.jsx(PinOffRegular, {}), children: "Unpin Column" })), jsxRuntime.jsx(reactComponents.MenuDivider, {})] }, 'pin columns')), header.column.getCanFilter() && (jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [jsxRuntime.jsxs(reactComponents.MenuGroupHeader, { children: ["Filter by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }), jsxRuntime.jsx(Filter, { column: header.column, table: table })] }, 'filter-group'))] }) })] }));
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
function HeaderRow(props) {
|
|
1913
|
+
const styles = useTableHeaderStyles();
|
|
1914
|
+
const { table, headerGroup, rowSelectionMode, headerGroupsLength } = props;
|
|
1915
|
+
return (jsxRuntime.jsxs("tr", { className: styles.tHeadRow, children: [rowSelectionMode === 'multiple' && (jsxRuntime.jsx("th", { style: { width: '1rem' }, "aria-label": "Select All Row Column", children: headerGroup.depth === headerGroupsLength - 1 && (jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsSomeRowsSelected()
|
|
1916
|
+
? 'mixed'
|
|
1917
|
+
: table.getIsAllRowsSelected(), onChange: table.getToggleAllRowsSelectedHandler(), "aria-label": "Select All Rows", title: 'Select All Rows' })) })), rowSelectionMode === 'single' && (jsxRuntime.jsx("th", { style: { width: '1rem' }, "aria-label": "Select All Row Column", children: ' ' })), headerGroup.headers.map((header) => {
|
|
1918
|
+
return (jsxRuntime.jsx(HeaderCell, { header: header, table: table, hideMenu: headerGroup.depth !== headerGroupsLength - 1, headerDepth: headerGroup.depth, totalNumberOfHeaderDepth: headerGroupsLength - 1 }, header.id));
|
|
1919
|
+
})] }, headerGroup.id));
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
function TableHeader(props) {
|
|
1923
|
+
const styles = useTableHeaderStyles();
|
|
1924
|
+
const { table, headerGroups, rowSelectionMode } = props;
|
|
1925
|
+
return (jsxRuntime.jsx("thead", { className: styles.tHead, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxRuntime.jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) }));
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
const useLoadingStyles = reactComponents.makeStyles({
|
|
1929
|
+
invertedWrapper: {
|
|
1930
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground1,
|
|
1931
|
+
},
|
|
1932
|
+
row: Object.assign(Object.assign({ alignItems: "center", display: "grid", paddingBottom: "10px", position: "relative" }, reactComponents.shorthands.gap("10px")), { gridTemplateColumns: "min-content 20% 15% 30% 29%" }),
|
|
1933
|
+
});
|
|
1934
|
+
|
|
1935
|
+
const Loading = (props) => {
|
|
1936
|
+
const { numberOfItems = 16, numberOfColumns = 5 } = props;
|
|
1937
|
+
const styles = useLoadingStyles();
|
|
1938
|
+
return (jsxRuntime.jsx("div", { className: styles.invertedWrapper, children: jsxRuntime.jsx(reactComponents.Skeleton, { children: [...Array(numberOfItems)].map((_, i) => (jsxRuntime.jsx("div", { className: styles.row, children: [...Array(numberOfColumns)].map((_, i) => {
|
|
1939
|
+
if (i === 0) {
|
|
1940
|
+
return jsxRuntime.jsx(reactComponents.SkeletonItem, { shape: "circle", size: 24 }, i);
|
|
1941
|
+
}
|
|
1942
|
+
return jsxRuntime.jsx(reactComponents.SkeletonItem, { size: 16 }, i);
|
|
1943
|
+
}) }, i))) }) }));
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
const useNoItemGridStyles = reactComponents.makeStyles({
|
|
1947
|
+
wrapper: {
|
|
1948
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground1,
|
|
1949
|
+
display: "flex",
|
|
1950
|
+
flexWrap: "wrap",
|
|
1951
|
+
alignContent: "center",
|
|
1952
|
+
justifyContent: "center",
|
|
1953
|
+
minHeight: "300px",
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1957
|
+
const NoItemGrid = ({ message }) => {
|
|
1958
|
+
const styles = useNoItemGridStyles();
|
|
1959
|
+
return (jsxRuntime.jsx("div", { className: styles.wrapper, children: jsxRuntime.jsx("div", { children: message ? message : jsxRuntime.jsx(reactComponents.Subtitle2Stronger, { children: "No Data to Show." }) }) }));
|
|
1960
|
+
};
|
|
1961
|
+
|
|
1962
|
+
const useNoFilterMatchStyles = reactComponents.makeStyles({
|
|
1963
|
+
wrapper: {
|
|
1964
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground1,
|
|
1965
|
+
display: "flex",
|
|
1966
|
+
flexDirection: "column",
|
|
1967
|
+
flexWrap: "wrap",
|
|
1968
|
+
alignContent: "center",
|
|
1969
|
+
justifyContent: "center",
|
|
1970
|
+
minHeight: "300px",
|
|
1971
|
+
},
|
|
1972
|
+
iconWrapper: {
|
|
1973
|
+
display: "flex",
|
|
1974
|
+
flexWrap: "wrap",
|
|
1975
|
+
alignContent: "center",
|
|
1976
|
+
justifyContent: "center",
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
|
|
1980
|
+
const NoSearchResult = ({ message }) => {
|
|
1981
|
+
const styles = useNoFilterMatchStyles();
|
|
1982
|
+
return (jsxRuntime.jsxs("div", { className: styles.wrapper, children: [jsxRuntime.jsx("div", { className: styles.iconWrapper, children: jsxRuntime.jsx(DocumentSearch24Regular, {}) }), jsxRuntime.jsx("div", { children: message ? message : jsxRuntime.jsx(reactComponents.Subtitle2Stronger, { children: "No item found that matches your search term." }) })] }));
|
|
1983
|
+
};
|
|
1984
|
+
|
|
1985
|
+
const useTableBodyStyles = reactComponents.makeStyles({
|
|
1986
|
+
tBody: Object.assign(Object.assign({}, reactComponents.shorthands.padding("0px", "0px", "0px", "0px")), { zIndex: 0 }),
|
|
1987
|
+
tBodyRow: Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.padding("0px", "0px", "0px", "0px")), reactComponents.shorthands.borderBottom(reactComponents.tokens.strokeWidthThin, "solid", reactComponents.tokens.colorNeutralStroke1)), {
|
|
1988
|
+
// ":nth-child(even)": {
|
|
1989
|
+
// backgroundColor: tokens.colorNeutralBackground2,
|
|
1990
|
+
// },
|
|
1991
|
+
":hover": {
|
|
1992
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground2Hover,
|
|
1993
|
+
} }),
|
|
1994
|
+
tBodySelectedRow: Object.assign(Object.assign({ backgroundColor: reactComponents.tokens.colorBrandBackground2 }, reactComponents.shorthands.borderBottom(reactComponents.tokens.strokeWidthThin, "solid", reactComponents.tokens.colorNeutralStroke1)), { ":hover": {
|
|
1995
|
+
backgroundColor: reactComponents.tokens.colorBrandBackground2Hover,
|
|
1996
|
+
} }),
|
|
1997
|
+
tBodyCell: Object.assign(Object.assign({ backgroundColor: "transparent" }, reactComponents.shorthands.padding("2px", "4px")), { minHeight: "35px", height: "35px" }),
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
function TableCell({ cell, row }) {
|
|
2001
|
+
var _a;
|
|
2002
|
+
const styles = useTableBodyStyles();
|
|
2003
|
+
const tdStyle = {
|
|
2004
|
+
width: cell.column.getSize(),
|
|
2005
|
+
};
|
|
2006
|
+
if (cell.getIsPlaceholder()) {
|
|
2007
|
+
return jsxRuntime.jsx("td", { style: tdStyle, className: styles.tBodyCell }, cell.id);
|
|
2008
|
+
}
|
|
2009
|
+
if (cell.getIsGrouped()) {
|
|
2010
|
+
return (jsxRuntime.jsx("td", { style: tdStyle, className: styles.tBodyCell, children: jsxRuntime.jsx(reactComponents.Button, { onClick: row.getToggleExpandedHandler(), style: {
|
|
2011
|
+
cursor: row.getCanExpand() ? 'pointer' : 'normal',
|
|
2012
|
+
textAlign: 'left',
|
|
2013
|
+
}, appearance: "transparent", icon: row.getIsExpanded() ? jsxRuntime.jsx(GroupExpandedIcon, {}) : jsxRuntime.jsx(GroupCollapsedIcon, {}), children: jsxRuntime.jsxs("strong", { children: [reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()), " (", row.subRows.length, ")"] }) }) }, cell.id));
|
|
2014
|
+
}
|
|
2015
|
+
if (cell.getIsAggregated()) {
|
|
2016
|
+
return (jsxRuntime.jsx("td", { style: tdStyle, className: styles.tBodyCell, children: jsxRuntime.jsx("strong", { children: reactTable.flexRender((_a = cell.column.columnDef.aggregatedCell) !== null && _a !== void 0 ? _a : cell.column.columnDef.cell, cell.getContext()) }) }, cell.id));
|
|
2017
|
+
}
|
|
2018
|
+
return (jsxRuntime.jsx("td", { style: tdStyle, className: styles.tBodyCell, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
function TableRow({ row, rowSelectionMode }) {
|
|
2022
|
+
const styles = useTableBodyStyles();
|
|
2023
|
+
return (jsxRuntime.jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
2024
|
+
? styles.tBodySelectedRow
|
|
2025
|
+
: styles.tBodyRow, children: [rowSelectionMode === 'multiple' && (jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: row.getIsSomeSelected()
|
|
2026
|
+
? 'mixed'
|
|
2027
|
+
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) })), rowSelectionMode === 'single' && (jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) })), row.getVisibleCells().map((cell) => (jsxRuntime.jsx(TableCell, { cell: cell, row: row }, cell.id)))] }, row.id));
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
function TableBody(props) {
|
|
2031
|
+
var _a, _b;
|
|
2032
|
+
const styles = useTableBodyStyles();
|
|
2033
|
+
const { rows, rowSelectionMode, virtualRows, totalSize } = props;
|
|
2034
|
+
const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[0]) === null || _a === void 0 ? void 0 : _a.start) || 0 : 0;
|
|
2035
|
+
const paddingBottom = virtualRows.length > 0
|
|
2036
|
+
? totalSize - (((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0)
|
|
2037
|
+
: 0;
|
|
2038
|
+
return (jsxRuntime.jsxs("tbody", { className: styles.tBody, children: [paddingTop > 0 && (jsxRuntime.jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsxRuntime.jsx("td", { style: { height: `${paddingTop}px` } }) })), virtualRows.map((virtualRow) => {
|
|
2039
|
+
const row = rows[virtualRow.index];
|
|
2040
|
+
return (jsxRuntime.jsx(TableRow, { row: row, rowSelectionMode: rowSelectionMode }, row.id));
|
|
2041
|
+
}), paddingBottom > 0 && (jsxRuntime.jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsxRuntime.jsx("td", { style: { height: `${paddingBottom}px` } }) }))] }));
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
const TableContainer = (props) => {
|
|
2045
|
+
var _a, _b;
|
|
2046
|
+
const styles = useTableStaticStyles();
|
|
2047
|
+
const { table, rowSelectionMode } = props;
|
|
2048
|
+
const tableContainerRef = React__namespace.useRef(null);
|
|
2049
|
+
const { rows } = table.getRowModel();
|
|
2050
|
+
const rowVirtualizer = reactVirtual.useVirtual({
|
|
2051
|
+
parentRef: tableContainerRef,
|
|
2052
|
+
size: rows.length,
|
|
2053
|
+
overscan: 5,
|
|
2054
|
+
});
|
|
2055
|
+
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
2056
|
+
const headerGroups = table.getHeaderGroups();
|
|
2057
|
+
// utilities
|
|
2058
|
+
const isLoading = props.isLoading && virtualRows.length === 0;
|
|
2059
|
+
const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
2060
|
+
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && virtualRows.length === 0;
|
|
2061
|
+
return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, { rows: rows, virtualRows: virtualRows, rowSelectionMode: rowSelectionMode, totalSize: totalSize }), rowSelectionMode === 'multiple' &&
|
|
2062
|
+
!isLoading &&
|
|
2063
|
+
!noItems &&
|
|
2064
|
+
!noSearchResult && (jsxRuntime.jsx("tfoot", { className: styles.tFoot, children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("td", { className: "p-1", children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsSomePageRowsSelected()
|
|
2065
|
+
? 'mixed'
|
|
2066
|
+
: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler(), "aria-label": "Select All Current Page Rows", title: 'Select All Current Page Rows' }) }), jsxRuntime.jsxs("td", { colSpan: 20, children: [table.getIsAllPageRowsSelected() ? 'Unselect' : 'Select', " All Current Page Rows (", table.getRowModel().rows.length, ")"] })] }) }))] }), isLoading && jsxRuntime.jsx(Loading, {}), noItems && jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }), noSearchResult && jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage })] }));
|
|
2067
|
+
};
|
|
2068
|
+
|
|
2069
|
+
const ViewSaveForm = (props) => {
|
|
2070
|
+
const [errorMessage, setErrorMessage] = React__namespace.useState('');
|
|
2071
|
+
const [isFormOpen, setIsFormOpen] = React__namespace.useState(false);
|
|
2072
|
+
const inputRef = React__namespace.useRef(null);
|
|
2073
|
+
const checkboxRef = React__namespace.useRef(null);
|
|
2074
|
+
if (!isFormOpen) {
|
|
2075
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactComponents.MenuList, { children: jsxRuntime.jsx(reactComponents.MenuItemRadio, { name: 'view-manager', value: 'View Manager', onClick: () => setIsFormOpen(true), icon: jsxRuntime.jsx(Save20Filled, {}), children: "Save Current View" }) }), jsxRuntime.jsx(reactComponents.Divider, {})] }));
|
|
2076
|
+
}
|
|
2077
|
+
return (jsxRuntime.jsxs("div", { style: {
|
|
2078
|
+
boxSizing: 'border-box',
|
|
2079
|
+
padding: '0.4rem',
|
|
2080
|
+
border: '1px solid #ccc',
|
|
2081
|
+
marginBottom: '0.5rem'
|
|
2082
|
+
}, children: [jsxRuntime.jsx(reactComponents.Caption1Stronger, { children: "Enter View Details" }), jsxRuntime.jsx(reactComponents.Field, { label: "View Name", validationMessage: errorMessage, validationState: errorMessage ? "error" : undefined, hint: jsxRuntime.jsx(jsxRuntime.Fragment, { children: "Give your view a name and save it." }), children: jsxRuntime.jsx(reactComponents.Input, { ref: inputRef, placeholder: "View Name" }) }), jsxRuntime.jsx(reactComponents.Field, { hint: jsxRuntime.jsx(jsxRuntime.Fragment, { children: "Global view is accessible to everybody in the system." }), children: jsxRuntime.jsx(reactComponents.Checkbox, { ref: checkboxRef, label: "Set as global view" }) }), jsxRuntime.jsxs("div", { style: {
|
|
2083
|
+
display: 'flex',
|
|
2084
|
+
flexWrap: 'wrap',
|
|
2085
|
+
gap: '0.5rem'
|
|
2086
|
+
}, children: [jsxRuntime.jsx(reactComponents.Button, { onClick: () => {
|
|
2087
|
+
setIsFormOpen(false);
|
|
2088
|
+
setErrorMessage('');
|
|
2089
|
+
}, children: "Cancel" }), jsxRuntime.jsx(reactComponents.Button, { appearance: 'primary', onClick: () => {
|
|
2090
|
+
var _a, _b, _c;
|
|
2091
|
+
if (!((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
2092
|
+
setErrorMessage('View name is required');
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
const viewName = inputRef.current.value;
|
|
2096
|
+
const isGlobal = (_b = checkboxRef.current) === null || _b === void 0 ? void 0 : _b.checked;
|
|
2097
|
+
const tableView = {
|
|
2098
|
+
id: Math.random() * 100,
|
|
2099
|
+
viewName: viewName,
|
|
2100
|
+
tableState: props.getTableState(),
|
|
2101
|
+
isGlobal: isGlobal,
|
|
2102
|
+
isViewOwner: true
|
|
2103
|
+
};
|
|
2104
|
+
(_c = props === null || props === void 0 ? void 0 : props.onSave) === null || _c === void 0 ? void 0 : _c.call(props, tableView);
|
|
2105
|
+
setErrorMessage('');
|
|
2106
|
+
setIsFormOpen(false);
|
|
2107
|
+
}, children: "Save" })] })] }));
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
const useFilterDrawerStyles = reactComponents.makeStyles({
|
|
2111
|
+
drawerBody: Object.assign(Object.assign({}, reactComponents.shorthands.overflow('hidden', 'auto')), {
|
|
2112
|
+
/* width */
|
|
2113
|
+
':hover': Object.assign({}, reactComponents.shorthands.overflow('auto', 'auto')), '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, reactComponents.shorthands.borderRadius('50%')),
|
|
2114
|
+
/* Track */
|
|
2115
|
+
'::-webkit-scrollbar-track': {
|
|
2116
|
+
'background-color': '#f1f1f1',
|
|
2117
|
+
},
|
|
2118
|
+
/* Handle */
|
|
2119
|
+
'::-webkit-scrollbar-thumb': {
|
|
2120
|
+
'background-color': '#888',
|
|
2121
|
+
},
|
|
2122
|
+
/* Handle on hover */
|
|
2123
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
2124
|
+
'background-color': '#555',
|
|
2125
|
+
} }),
|
|
2126
|
+
});
|
|
2127
|
+
const ViewsDrawer = (props) => {
|
|
2128
|
+
const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView, onTableViewSave } = props;
|
|
2129
|
+
const styles = useFilterDrawerStyles();
|
|
2130
|
+
const [checkedValues, setCheckedValues] = React__namespace.useState({ font: ["calibri"] });
|
|
2131
|
+
const onChange = (e, { name, checkedItems }) => {
|
|
2132
|
+
setCheckedValues((s) => (Object.assign(Object.assign({}, s), { [name]: checkedItems })));
|
|
2133
|
+
};
|
|
2134
|
+
// const resetAllFilters = React.useCallback(() => {
|
|
2135
|
+
// table.setGlobalFilter('');
|
|
2136
|
+
// table.resetColumnFilters();
|
|
2137
|
+
// }, [table]);
|
|
2138
|
+
// const resetAllGrouping = React.useCallback(() => {
|
|
2139
|
+
// table.resetGrouping();
|
|
2140
|
+
// }, [table]);
|
|
2141
|
+
// const clearAllSelection = React.useCallback(() => {
|
|
2142
|
+
// table.toggleAllRowsSelected(false);
|
|
2143
|
+
// }, [table]);
|
|
2144
|
+
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState.isViewsDrawerOpen, separator: true, children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_VIEW_DRAWER" }) }), children: "Table Views" }) }), jsxRuntime.jsxs(reactComponents.DrawerBody, { className: styles.drawerBody, children: [onTableViewSave && jsxRuntime.jsx(ViewSaveForm, { mode: 'create', getTableState: table.getState, onSave: onTableViewSave }), jsxRuntime.jsxs(reactComponents.MenuList, { checkedValues: checkedValues, onCheckedValueChange: onChange, children: [jsxRuntime.jsx(reactComponents.MenuItemRadio, { name: 'table-views', value: 'Default View', icon: jsxRuntime.jsx(ViewDesktop20Filled, {}), onClick: resetToGridDefaultView, children: "Default View" }), tableViews.length > 0 && jsxRuntime.jsx(reactComponents.MenuDivider, { children: "Additional Views" }), tableViews.map((view) => {
|
|
2145
|
+
return (jsxRuntime.jsxs("div", { style: {
|
|
2146
|
+
display: 'flex',
|
|
2147
|
+
justifyContent: 'space-between',
|
|
2148
|
+
alignItems: 'center',
|
|
2149
|
+
width: '100%',
|
|
2150
|
+
}, children: [jsxRuntime.jsx(reactComponents.MenuItemRadio, { name: "table-views", value: view.viewName, onClick: () => applyTableState(view.tableState), icon: jsxRuntime.jsx(ViewDesktop20Regular, {}), children: view.viewName }), props.onTableViewDelete && (view === null || view === void 0 ? void 0 : view.isViewOwner) && (jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => { var _a; return (_a = props.onTableViewDelete) === null || _a === void 0 ? void 0 : _a.call(props, view); } }))] }, view.id + view.viewName));
|
|
2151
|
+
})] })] }), jsxRuntime.jsx(reactComponents.DrawerFooter, { children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [jsxRuntime.jsx(reactComponents.MenuDivider, {}), jsxRuntime.jsx(reactComponents.MenuItem, { icon: jsxRuntime.jsx(ClearFilterIcon, {}), onClick: resetToGridDefaultView, children: "Reset to Default View" })] }) })] }));
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2154
|
+
const TableActions = {
|
|
2155
|
+
TOGGLE_FILTER_DRAWER: 'TOGGLE_FILTER_DRAWER',
|
|
2156
|
+
TOGGLE_VIEW_DRAWER: 'TOGGLE_VIEW_DRAWER',
|
|
2157
|
+
OPEN_FILTER_DRAWER: 'OPEN_FILTER_DRAWER',
|
|
2158
|
+
OPEN_VIEW_DRAWER: 'OPEN_VIEW_DRAWER',
|
|
2159
|
+
CLOSE_FILTER_DRAWER: 'CLOSE_FILTER_DRAWER',
|
|
2160
|
+
CLOSE_VIEW_DRAWER: 'CLOSE_VIEW_DRAWER',
|
|
2161
|
+
};
|
|
2162
|
+
// write a reducer function to handle the state of the table
|
|
2163
|
+
function tableReducer(state, action) {
|
|
2164
|
+
switch (action.type) {
|
|
2165
|
+
case TableActions.TOGGLE_FILTER_DRAWER:
|
|
2166
|
+
return Object.assign(Object.assign({}, state), { isFilterDrawerOpen: !state.isFilterDrawerOpen });
|
|
2167
|
+
case TableActions.TOGGLE_VIEW_DRAWER:
|
|
2168
|
+
return Object.assign(Object.assign({}, state), { isViewsDrawerOpen: !state.isViewsDrawerOpen });
|
|
2169
|
+
case TableActions.OPEN_FILTER_DRAWER:
|
|
2170
|
+
return Object.assign(Object.assign({}, state), { isFilterDrawerOpen: true });
|
|
2171
|
+
case TableActions.OPEN_VIEW_DRAWER:
|
|
2172
|
+
return Object.assign(Object.assign({}, state), { isViewsDrawerOpen: true });
|
|
2173
|
+
case TableActions.CLOSE_FILTER_DRAWER:
|
|
2174
|
+
return Object.assign(Object.assign({}, state), { isFilterDrawerOpen: false });
|
|
2175
|
+
case TableActions.CLOSE_VIEW_DRAWER:
|
|
2176
|
+
return Object.assign(Object.assign({}, state), { isViewsDrawerOpen: false });
|
|
2177
|
+
default:
|
|
2178
|
+
return state;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
function AdvancedTable(props, ref) {
|
|
2183
|
+
useStaticStyles();
|
|
2184
|
+
const { table, globalFilter, headerMenu, tableViews, setGlobalFilter, resetToDefaultView, applyTableState } = useGridContainer(props, ref);
|
|
2185
|
+
const [drawerState, dispatch] = React__namespace.useReducer(tableReducer, {
|
|
2186
|
+
isFilterDrawerOpen: false,
|
|
2187
|
+
isViewsDrawerOpen: false
|
|
2188
|
+
});
|
|
2189
|
+
return (jsxRuntime.jsxs(reactDnd.DndProvider, { backend: reactDndHtml5Backend.HTML5Backend, children: [jsxRuntime.jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState, drawerState: drawerState, dispatch: dispatch }), jsxRuntime.jsxs("div", { style: { display: 'flex' }, children: [jsxRuntime.jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, rowSelectionMode: props.rowSelectionMode, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsxRuntime.jsx(FilterDrawer, { drawerState: drawerState, dispatch: dispatch, table: table }), jsxRuntime.jsx(ViewsDrawer, { table: table, drawerState: drawerState, dispatch: dispatch, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView, onTableViewSave: props.onTableViewSave, onTableViewDelete: props.onTableViewDelete })] }), jsxRuntime.jsx(Pagination, { table: table, pageSizeOptions: props.pageSizeOptions })] }));
|
|
2190
|
+
}
|
|
2191
|
+
const ForwardedAdvancedTable = React__namespace.forwardRef(AdvancedTable);
|
|
2192
|
+
|
|
2193
|
+
Object.defineProperty(exports, 'createColumnHelper', {
|
|
2194
|
+
enumerable: true,
|
|
2195
|
+
get: function () { return reactTable.createColumnHelper; }
|
|
2196
|
+
});
|
|
2197
|
+
exports.Table = ForwardedAdvancedTable;
|