jc-react-datatable 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jc-react-datatable.css +263 -0
- package/dist/jc-react-datatable.es.js +894 -1469
- package/dist/jc-react-datatable.umd.js +1077 -51
- package/package.json +6 -4
- package/dist/style.css +0 -1
|
@@ -1,51 +1,1077 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("react-is")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "react-is"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.JCReactDatatable = {}, global.jsxRuntime, global.React, global.require$$0));
|
|
3
|
+
})(this, (function(exports2, jsxRuntime, React, require$$0) {
|
|
4
|
+
"use strict";
|
|
5
|
+
function getDefaultExportFromCjs(x) {
|
|
6
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
7
|
+
}
|
|
8
|
+
var propTypes = { exports: {} };
|
|
9
|
+
var objectAssign;
|
|
10
|
+
var hasRequiredObjectAssign;
|
|
11
|
+
function requireObjectAssign() {
|
|
12
|
+
if (hasRequiredObjectAssign) return objectAssign;
|
|
13
|
+
hasRequiredObjectAssign = 1;
|
|
14
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
15
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
16
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
17
|
+
function toObject(val) {
|
|
18
|
+
if (val === null || val === void 0) {
|
|
19
|
+
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
20
|
+
}
|
|
21
|
+
return Object(val);
|
|
22
|
+
}
|
|
23
|
+
function shouldUseNative() {
|
|
24
|
+
try {
|
|
25
|
+
if (!Object.assign) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
var test1 = new String("abc");
|
|
29
|
+
test1[5] = "de";
|
|
30
|
+
if (Object.getOwnPropertyNames(test1)[0] === "5") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
var test2 = {};
|
|
34
|
+
for (var i = 0; i < 10; i++) {
|
|
35
|
+
test2["_" + String.fromCharCode(i)] = i;
|
|
36
|
+
}
|
|
37
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
|
|
38
|
+
return test2[n];
|
|
39
|
+
});
|
|
40
|
+
if (order2.join("") !== "0123456789") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
var test3 = {};
|
|
44
|
+
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
45
|
+
test3[letter] = letter;
|
|
46
|
+
});
|
|
47
|
+
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
} catch (err) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
objectAssign = shouldUseNative() ? Object.assign : function(target, source) {
|
|
56
|
+
var from;
|
|
57
|
+
var to = toObject(target);
|
|
58
|
+
var symbols;
|
|
59
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
60
|
+
from = Object(arguments[s]);
|
|
61
|
+
for (var key in from) {
|
|
62
|
+
if (hasOwnProperty.call(from, key)) {
|
|
63
|
+
to[key] = from[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (getOwnPropertySymbols) {
|
|
67
|
+
symbols = getOwnPropertySymbols(from);
|
|
68
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
69
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
70
|
+
to[symbols[i]] = from[symbols[i]];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return to;
|
|
76
|
+
};
|
|
77
|
+
return objectAssign;
|
|
78
|
+
}
|
|
79
|
+
var ReactPropTypesSecret_1;
|
|
80
|
+
var hasRequiredReactPropTypesSecret;
|
|
81
|
+
function requireReactPropTypesSecret() {
|
|
82
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
83
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
84
|
+
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
85
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
86
|
+
return ReactPropTypesSecret_1;
|
|
87
|
+
}
|
|
88
|
+
var has;
|
|
89
|
+
var hasRequiredHas;
|
|
90
|
+
function requireHas() {
|
|
91
|
+
if (hasRequiredHas) return has;
|
|
92
|
+
hasRequiredHas = 1;
|
|
93
|
+
has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
94
|
+
return has;
|
|
95
|
+
}
|
|
96
|
+
var checkPropTypes_1;
|
|
97
|
+
var hasRequiredCheckPropTypes;
|
|
98
|
+
function requireCheckPropTypes() {
|
|
99
|
+
if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
|
100
|
+
hasRequiredCheckPropTypes = 1;
|
|
101
|
+
var printWarning = function() {
|
|
102
|
+
};
|
|
103
|
+
if (process.env.NODE_ENV !== "production") {
|
|
104
|
+
var ReactPropTypesSecret = /* @__PURE__ */ requireReactPropTypesSecret();
|
|
105
|
+
var loggedTypeFailures = {};
|
|
106
|
+
var has2 = /* @__PURE__ */ requireHas();
|
|
107
|
+
printWarning = function(text) {
|
|
108
|
+
var message = "Warning: " + text;
|
|
109
|
+
if (typeof console !== "undefined") {
|
|
110
|
+
console.error(message);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
throw new Error(message);
|
|
114
|
+
} catch (x) {
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
119
|
+
if (process.env.NODE_ENV !== "production") {
|
|
120
|
+
for (var typeSpecName in typeSpecs) {
|
|
121
|
+
if (has2(typeSpecs, typeSpecName)) {
|
|
122
|
+
var error;
|
|
123
|
+
try {
|
|
124
|
+
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
125
|
+
var err = Error(
|
|
126
|
+
(componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
|
|
127
|
+
);
|
|
128
|
+
err.name = "Invariant Violation";
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
132
|
+
} catch (ex) {
|
|
133
|
+
error = ex;
|
|
134
|
+
}
|
|
135
|
+
if (error && !(error instanceof Error)) {
|
|
136
|
+
printWarning(
|
|
137
|
+
(componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
141
|
+
loggedTypeFailures[error.message] = true;
|
|
142
|
+
var stack = getStack ? getStack() : "";
|
|
143
|
+
printWarning(
|
|
144
|
+
"Failed " + location + " type: " + error.message + (stack != null ? stack : "")
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
checkPropTypes.resetWarningCache = function() {
|
|
152
|
+
if (process.env.NODE_ENV !== "production") {
|
|
153
|
+
loggedTypeFailures = {};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
checkPropTypes_1 = checkPropTypes;
|
|
157
|
+
return checkPropTypes_1;
|
|
158
|
+
}
|
|
159
|
+
var factoryWithTypeCheckers;
|
|
160
|
+
var hasRequiredFactoryWithTypeCheckers;
|
|
161
|
+
function requireFactoryWithTypeCheckers() {
|
|
162
|
+
if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
|
163
|
+
hasRequiredFactoryWithTypeCheckers = 1;
|
|
164
|
+
var ReactIs = require$$0;
|
|
165
|
+
var assign = requireObjectAssign();
|
|
166
|
+
var ReactPropTypesSecret = /* @__PURE__ */ requireReactPropTypesSecret();
|
|
167
|
+
var has2 = /* @__PURE__ */ requireHas();
|
|
168
|
+
var checkPropTypes = /* @__PURE__ */ requireCheckPropTypes();
|
|
169
|
+
var printWarning = function() {
|
|
170
|
+
};
|
|
171
|
+
if (process.env.NODE_ENV !== "production") {
|
|
172
|
+
printWarning = function(text) {
|
|
173
|
+
var message = "Warning: " + text;
|
|
174
|
+
if (typeof console !== "undefined") {
|
|
175
|
+
console.error(message);
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
throw new Error(message);
|
|
179
|
+
} catch (x) {
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function emptyFunctionThatReturnsNull() {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
187
|
+
var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
|
188
|
+
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
189
|
+
function getIteratorFn(maybeIterable) {
|
|
190
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
191
|
+
if (typeof iteratorFn === "function") {
|
|
192
|
+
return iteratorFn;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
var ANONYMOUS = "<<anonymous>>";
|
|
196
|
+
var ReactPropTypes = {
|
|
197
|
+
array: createPrimitiveTypeChecker("array"),
|
|
198
|
+
bigint: createPrimitiveTypeChecker("bigint"),
|
|
199
|
+
bool: createPrimitiveTypeChecker("boolean"),
|
|
200
|
+
func: createPrimitiveTypeChecker("function"),
|
|
201
|
+
number: createPrimitiveTypeChecker("number"),
|
|
202
|
+
object: createPrimitiveTypeChecker("object"),
|
|
203
|
+
string: createPrimitiveTypeChecker("string"),
|
|
204
|
+
symbol: createPrimitiveTypeChecker("symbol"),
|
|
205
|
+
any: createAnyTypeChecker(),
|
|
206
|
+
arrayOf: createArrayOfTypeChecker,
|
|
207
|
+
element: createElementTypeChecker(),
|
|
208
|
+
elementType: createElementTypeTypeChecker(),
|
|
209
|
+
instanceOf: createInstanceTypeChecker,
|
|
210
|
+
node: createNodeChecker(),
|
|
211
|
+
objectOf: createObjectOfTypeChecker,
|
|
212
|
+
oneOf: createEnumTypeChecker,
|
|
213
|
+
oneOfType: createUnionTypeChecker,
|
|
214
|
+
shape: createShapeTypeChecker,
|
|
215
|
+
exact: createStrictShapeTypeChecker
|
|
216
|
+
};
|
|
217
|
+
function is(x, y) {
|
|
218
|
+
if (x === y) {
|
|
219
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
220
|
+
} else {
|
|
221
|
+
return x !== x && y !== y;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function PropTypeError(message, data) {
|
|
225
|
+
this.message = message;
|
|
226
|
+
this.data = data && typeof data === "object" ? data : {};
|
|
227
|
+
this.stack = "";
|
|
228
|
+
}
|
|
229
|
+
PropTypeError.prototype = Error.prototype;
|
|
230
|
+
function createChainableTypeChecker(validate) {
|
|
231
|
+
if (process.env.NODE_ENV !== "production") {
|
|
232
|
+
var manualPropTypeCallCache = {};
|
|
233
|
+
var manualPropTypeWarningCount = 0;
|
|
234
|
+
}
|
|
235
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
236
|
+
componentName = componentName || ANONYMOUS;
|
|
237
|
+
propFullName = propFullName || propName;
|
|
238
|
+
if (secret !== ReactPropTypesSecret) {
|
|
239
|
+
if (throwOnDirectAccess) {
|
|
240
|
+
var err = new Error(
|
|
241
|
+
"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
|
|
242
|
+
);
|
|
243
|
+
err.name = "Invariant Violation";
|
|
244
|
+
throw err;
|
|
245
|
+
} else if (process.env.NODE_ENV !== "production" && typeof console !== "undefined") {
|
|
246
|
+
var cacheKey = componentName + ":" + propName;
|
|
247
|
+
if (!manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors
|
|
248
|
+
manualPropTypeWarningCount < 3) {
|
|
249
|
+
printWarning(
|
|
250
|
+
"You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."
|
|
251
|
+
);
|
|
252
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
253
|
+
manualPropTypeWarningCount++;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (props[propName] == null) {
|
|
258
|
+
if (isRequired) {
|
|
259
|
+
if (props[propName] === null) {
|
|
260
|
+
return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
|
|
261
|
+
}
|
|
262
|
+
return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
} else {
|
|
266
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
270
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
271
|
+
return chainedCheckType;
|
|
272
|
+
}
|
|
273
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
274
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
275
|
+
var propValue = props[propName];
|
|
276
|
+
var propType = getPropType(propValue);
|
|
277
|
+
if (propType !== expectedType) {
|
|
278
|
+
var preciseType = getPreciseType(propValue);
|
|
279
|
+
return new PropTypeError(
|
|
280
|
+
"Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."),
|
|
281
|
+
{ expectedType }
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
return createChainableTypeChecker(validate);
|
|
287
|
+
}
|
|
288
|
+
function createAnyTypeChecker() {
|
|
289
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
290
|
+
}
|
|
291
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
292
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
293
|
+
if (typeof typeChecker !== "function") {
|
|
294
|
+
return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
|
|
295
|
+
}
|
|
296
|
+
var propValue = props[propName];
|
|
297
|
+
if (!Array.isArray(propValue)) {
|
|
298
|
+
var propType = getPropType(propValue);
|
|
299
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
|
|
300
|
+
}
|
|
301
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
302
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
|
|
303
|
+
if (error instanceof Error) {
|
|
304
|
+
return error;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
return createChainableTypeChecker(validate);
|
|
310
|
+
}
|
|
311
|
+
function createElementTypeChecker() {
|
|
312
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
313
|
+
var propValue = props[propName];
|
|
314
|
+
if (!isValidElement(propValue)) {
|
|
315
|
+
var propType = getPropType(propValue);
|
|
316
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
return createChainableTypeChecker(validate);
|
|
321
|
+
}
|
|
322
|
+
function createElementTypeTypeChecker() {
|
|
323
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
324
|
+
var propValue = props[propName];
|
|
325
|
+
if (!ReactIs.isValidElementType(propValue)) {
|
|
326
|
+
var propType = getPropType(propValue);
|
|
327
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
return createChainableTypeChecker(validate);
|
|
332
|
+
}
|
|
333
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
334
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
335
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
336
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
337
|
+
var actualClassName = getClassName(props[propName]);
|
|
338
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
return createChainableTypeChecker(validate);
|
|
343
|
+
}
|
|
344
|
+
function createEnumTypeChecker(expectedValues) {
|
|
345
|
+
if (!Array.isArray(expectedValues)) {
|
|
346
|
+
if (process.env.NODE_ENV !== "production") {
|
|
347
|
+
if (arguments.length > 1) {
|
|
348
|
+
printWarning(
|
|
349
|
+
"Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."
|
|
350
|
+
);
|
|
351
|
+
} else {
|
|
352
|
+
printWarning("Invalid argument supplied to oneOf, expected an array.");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return emptyFunctionThatReturnsNull;
|
|
356
|
+
}
|
|
357
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
358
|
+
var propValue = props[propName];
|
|
359
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
360
|
+
if (is(propValue, expectedValues[i])) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
365
|
+
var type = getPreciseType(value);
|
|
366
|
+
if (type === "symbol") {
|
|
367
|
+
return String(value);
|
|
368
|
+
}
|
|
369
|
+
return value;
|
|
370
|
+
});
|
|
371
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
|
|
372
|
+
}
|
|
373
|
+
return createChainableTypeChecker(validate);
|
|
374
|
+
}
|
|
375
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
376
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
377
|
+
if (typeof typeChecker !== "function") {
|
|
378
|
+
return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
|
|
379
|
+
}
|
|
380
|
+
var propValue = props[propName];
|
|
381
|
+
var propType = getPropType(propValue);
|
|
382
|
+
if (propType !== "object") {
|
|
383
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
|
|
384
|
+
}
|
|
385
|
+
for (var key in propValue) {
|
|
386
|
+
if (has2(propValue, key)) {
|
|
387
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
|
388
|
+
if (error instanceof Error) {
|
|
389
|
+
return error;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
return createChainableTypeChecker(validate);
|
|
396
|
+
}
|
|
397
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
398
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
399
|
+
process.env.NODE_ENV !== "production" ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0;
|
|
400
|
+
return emptyFunctionThatReturnsNull;
|
|
401
|
+
}
|
|
402
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
403
|
+
var checker = arrayOfTypeCheckers[i];
|
|
404
|
+
if (typeof checker !== "function") {
|
|
405
|
+
printWarning(
|
|
406
|
+
"Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i + "."
|
|
407
|
+
);
|
|
408
|
+
return emptyFunctionThatReturnsNull;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
412
|
+
var expectedTypes = [];
|
|
413
|
+
for (var i2 = 0; i2 < arrayOfTypeCheckers.length; i2++) {
|
|
414
|
+
var checker2 = arrayOfTypeCheckers[i2];
|
|
415
|
+
var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
416
|
+
if (checkerResult == null) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
if (checkerResult.data && has2(checkerResult.data, "expectedType")) {
|
|
420
|
+
expectedTypes.push(checkerResult.data.expectedType);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
|
|
424
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
|
|
425
|
+
}
|
|
426
|
+
return createChainableTypeChecker(validate);
|
|
427
|
+
}
|
|
428
|
+
function createNodeChecker() {
|
|
429
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
430
|
+
if (!isNode(props[propName])) {
|
|
431
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
|
|
432
|
+
}
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return createChainableTypeChecker(validate);
|
|
436
|
+
}
|
|
437
|
+
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
438
|
+
return new PropTypeError(
|
|
439
|
+
(componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`."
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
443
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
444
|
+
var propValue = props[propName];
|
|
445
|
+
var propType = getPropType(propValue);
|
|
446
|
+
if (propType !== "object") {
|
|
447
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
|
|
448
|
+
}
|
|
449
|
+
for (var key in shapeTypes) {
|
|
450
|
+
var checker = shapeTypes[key];
|
|
451
|
+
if (typeof checker !== "function") {
|
|
452
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
453
|
+
}
|
|
454
|
+
var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
|
455
|
+
if (error) {
|
|
456
|
+
return error;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
return createChainableTypeChecker(validate);
|
|
462
|
+
}
|
|
463
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
464
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
465
|
+
var propValue = props[propName];
|
|
466
|
+
var propType = getPropType(propValue);
|
|
467
|
+
if (propType !== "object") {
|
|
468
|
+
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
|
|
469
|
+
}
|
|
470
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
471
|
+
for (var key in allKeys) {
|
|
472
|
+
var checker = shapeTypes[key];
|
|
473
|
+
if (has2(shapeTypes, key) && typeof checker !== "function") {
|
|
474
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
475
|
+
}
|
|
476
|
+
if (!checker) {
|
|
477
|
+
return new PropTypeError(
|
|
478
|
+
"Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ")
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
|
482
|
+
if (error) {
|
|
483
|
+
return error;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return null;
|
|
487
|
+
}
|
|
488
|
+
return createChainableTypeChecker(validate);
|
|
489
|
+
}
|
|
490
|
+
function isNode(propValue) {
|
|
491
|
+
switch (typeof propValue) {
|
|
492
|
+
case "number":
|
|
493
|
+
case "string":
|
|
494
|
+
case "undefined":
|
|
495
|
+
return true;
|
|
496
|
+
case "boolean":
|
|
497
|
+
return !propValue;
|
|
498
|
+
case "object":
|
|
499
|
+
if (Array.isArray(propValue)) {
|
|
500
|
+
return propValue.every(isNode);
|
|
501
|
+
}
|
|
502
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
506
|
+
if (iteratorFn) {
|
|
507
|
+
var iterator = iteratorFn.call(propValue);
|
|
508
|
+
var step;
|
|
509
|
+
if (iteratorFn !== propValue.entries) {
|
|
510
|
+
while (!(step = iterator.next()).done) {
|
|
511
|
+
if (!isNode(step.value)) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
} else {
|
|
516
|
+
while (!(step = iterator.next()).done) {
|
|
517
|
+
var entry = step.value;
|
|
518
|
+
if (entry) {
|
|
519
|
+
if (!isNode(entry[1])) {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
return true;
|
|
529
|
+
default:
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function isSymbol(propType, propValue) {
|
|
534
|
+
if (propType === "symbol") {
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
if (!propValue) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
if (propValue["@@toStringTag"] === "Symbol") {
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
if (typeof Symbol === "function" && propValue instanceof Symbol) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
function getPropType(propValue) {
|
|
549
|
+
var propType = typeof propValue;
|
|
550
|
+
if (Array.isArray(propValue)) {
|
|
551
|
+
return "array";
|
|
552
|
+
}
|
|
553
|
+
if (propValue instanceof RegExp) {
|
|
554
|
+
return "object";
|
|
555
|
+
}
|
|
556
|
+
if (isSymbol(propType, propValue)) {
|
|
557
|
+
return "symbol";
|
|
558
|
+
}
|
|
559
|
+
return propType;
|
|
560
|
+
}
|
|
561
|
+
function getPreciseType(propValue) {
|
|
562
|
+
if (typeof propValue === "undefined" || propValue === null) {
|
|
563
|
+
return "" + propValue;
|
|
564
|
+
}
|
|
565
|
+
var propType = getPropType(propValue);
|
|
566
|
+
if (propType === "object") {
|
|
567
|
+
if (propValue instanceof Date) {
|
|
568
|
+
return "date";
|
|
569
|
+
} else if (propValue instanceof RegExp) {
|
|
570
|
+
return "regexp";
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return propType;
|
|
574
|
+
}
|
|
575
|
+
function getPostfixForTypeWarning(value) {
|
|
576
|
+
var type = getPreciseType(value);
|
|
577
|
+
switch (type) {
|
|
578
|
+
case "array":
|
|
579
|
+
case "object":
|
|
580
|
+
return "an " + type;
|
|
581
|
+
case "boolean":
|
|
582
|
+
case "date":
|
|
583
|
+
case "regexp":
|
|
584
|
+
return "a " + type;
|
|
585
|
+
default:
|
|
586
|
+
return type;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function getClassName(propValue) {
|
|
590
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
591
|
+
return ANONYMOUS;
|
|
592
|
+
}
|
|
593
|
+
return propValue.constructor.name;
|
|
594
|
+
}
|
|
595
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
596
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
597
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
598
|
+
return ReactPropTypes;
|
|
599
|
+
};
|
|
600
|
+
return factoryWithTypeCheckers;
|
|
601
|
+
}
|
|
602
|
+
var factoryWithThrowingShims;
|
|
603
|
+
var hasRequiredFactoryWithThrowingShims;
|
|
604
|
+
function requireFactoryWithThrowingShims() {
|
|
605
|
+
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
|
606
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
|
607
|
+
var ReactPropTypesSecret = /* @__PURE__ */ requireReactPropTypesSecret();
|
|
608
|
+
function emptyFunction() {
|
|
609
|
+
}
|
|
610
|
+
function emptyFunctionWithReset() {
|
|
611
|
+
}
|
|
612
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
613
|
+
factoryWithThrowingShims = function() {
|
|
614
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
615
|
+
if (secret === ReactPropTypesSecret) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
var err = new Error(
|
|
619
|
+
"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
|
|
620
|
+
);
|
|
621
|
+
err.name = "Invariant Violation";
|
|
622
|
+
throw err;
|
|
623
|
+
}
|
|
624
|
+
shim.isRequired = shim;
|
|
625
|
+
function getShim() {
|
|
626
|
+
return shim;
|
|
627
|
+
}
|
|
628
|
+
var ReactPropTypes = {
|
|
629
|
+
array: shim,
|
|
630
|
+
bigint: shim,
|
|
631
|
+
bool: shim,
|
|
632
|
+
func: shim,
|
|
633
|
+
number: shim,
|
|
634
|
+
object: shim,
|
|
635
|
+
string: shim,
|
|
636
|
+
symbol: shim,
|
|
637
|
+
any: shim,
|
|
638
|
+
arrayOf: getShim,
|
|
639
|
+
element: shim,
|
|
640
|
+
elementType: shim,
|
|
641
|
+
instanceOf: getShim,
|
|
642
|
+
node: shim,
|
|
643
|
+
objectOf: getShim,
|
|
644
|
+
oneOf: getShim,
|
|
645
|
+
oneOfType: getShim,
|
|
646
|
+
shape: getShim,
|
|
647
|
+
exact: getShim,
|
|
648
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
649
|
+
resetWarningCache: emptyFunction
|
|
650
|
+
};
|
|
651
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
652
|
+
return ReactPropTypes;
|
|
653
|
+
};
|
|
654
|
+
return factoryWithThrowingShims;
|
|
655
|
+
}
|
|
656
|
+
var hasRequiredPropTypes;
|
|
657
|
+
function requirePropTypes() {
|
|
658
|
+
if (hasRequiredPropTypes) return propTypes.exports;
|
|
659
|
+
hasRequiredPropTypes = 1;
|
|
660
|
+
if (process.env.NODE_ENV !== "production") {
|
|
661
|
+
var ReactIs = require$$0;
|
|
662
|
+
var throwOnDirectAccess = true;
|
|
663
|
+
propTypes.exports = /* @__PURE__ */ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
664
|
+
} else {
|
|
665
|
+
propTypes.exports = /* @__PURE__ */ requireFactoryWithThrowingShims()();
|
|
666
|
+
}
|
|
667
|
+
return propTypes.exports;
|
|
668
|
+
}
|
|
669
|
+
var propTypesExports = /* @__PURE__ */ requirePropTypes();
|
|
670
|
+
const PropTypes = /* @__PURE__ */ getDefaultExportFromCjs(propTypesExports);
|
|
671
|
+
const ColumnFilter = ({ column, filterValue, setFilter, onClose }) => {
|
|
672
|
+
const [value, setValue] = React.useState(filterValue || "");
|
|
673
|
+
React.useEffect(() => {
|
|
674
|
+
const handler = setTimeout(() => {
|
|
675
|
+
setFilter(column.key, value);
|
|
676
|
+
}, 300);
|
|
677
|
+
return () => {
|
|
678
|
+
clearTimeout(handler);
|
|
679
|
+
};
|
|
680
|
+
}, [value, column.key, setFilter]);
|
|
681
|
+
if (!column.searchable) return null;
|
|
682
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "jc-datatable-filter", children: [
|
|
683
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
684
|
+
"input",
|
|
685
|
+
{
|
|
686
|
+
autoFocus: true,
|
|
687
|
+
type: "text",
|
|
688
|
+
placeholder: `Search ${column.header}...`,
|
|
689
|
+
value,
|
|
690
|
+
onChange: (e) => setValue(e.target.value),
|
|
691
|
+
className: "jc-datatable-filter-input",
|
|
692
|
+
"aria-label": `Filter by ${column.header}`
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "jc-datatable-filter-close", onClick: onClose, "aria-label": "Close filter", children: "×" })
|
|
696
|
+
] });
|
|
697
|
+
};
|
|
698
|
+
ColumnFilter.propTypes = {
|
|
699
|
+
column: PropTypes.object.isRequired,
|
|
700
|
+
filterValue: PropTypes.any,
|
|
701
|
+
setFilter: PropTypes.func.isRequired,
|
|
702
|
+
onClose: PropTypes.func.isRequired
|
|
703
|
+
};
|
|
704
|
+
const TableHeader = ({ columns, sortConfig, requestSort, filters, setFilter }) => {
|
|
705
|
+
const [activeFilter, setActiveFilter] = React.useState(null);
|
|
706
|
+
const toggleFilter = (e, key) => {
|
|
707
|
+
e.stopPropagation();
|
|
708
|
+
setActiveFilter(activeFilter === key ? null : key);
|
|
709
|
+
};
|
|
710
|
+
const getSortIndicator = (column) => {
|
|
711
|
+
if (!sortConfig || sortConfig.key !== column.key) {
|
|
712
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "jc-datatable-sort-icon", children: "↕" });
|
|
713
|
+
}
|
|
714
|
+
return sortConfig.direction === "asc" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "jc-datatable-sort-icon active", children: "↑" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "jc-datatable-sort-icon active", children: "↓" });
|
|
715
|
+
};
|
|
716
|
+
return /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "jc-datatable-thead", children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: columns.map((column, index) => {
|
|
717
|
+
const isLastColumn = index === columns.length - 1;
|
|
718
|
+
const isFirstColumn = index === 0;
|
|
719
|
+
let popoverClass = "jc-datatable-filter-popover";
|
|
720
|
+
if (isLastColumn) popoverClass += " right-aligned";
|
|
721
|
+
if (isFirstColumn) popoverClass += " left-aligned";
|
|
722
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
723
|
+
"th",
|
|
724
|
+
{
|
|
725
|
+
className: `jc-datatable-th ${column.sortable ? "sortable" : ""}`,
|
|
726
|
+
style: {
|
|
727
|
+
width: column.width,
|
|
728
|
+
minWidth: column.minWidth || column.width,
|
|
729
|
+
maxWidth: column.maxWidth
|
|
730
|
+
},
|
|
731
|
+
onClick: () => column.sortable && requestSort(column.key),
|
|
732
|
+
children: [
|
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "jc-datatable-th-content", children: [
|
|
734
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: column.header }),
|
|
735
|
+
column.sortable && getSortIndicator(column),
|
|
736
|
+
column.searchable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
737
|
+
"button",
|
|
738
|
+
{
|
|
739
|
+
className: `jc-datatable-filter-trigger ${filters[column.key] ? "active" : ""}`,
|
|
740
|
+
onClick: (e) => toggleFilter(e, column.key),
|
|
741
|
+
"aria-label": `Filter ${column.header}`,
|
|
742
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z" }) })
|
|
743
|
+
}
|
|
744
|
+
)
|
|
745
|
+
] }),
|
|
746
|
+
activeFilter === column.key && /* @__PURE__ */ jsxRuntime.jsx("div", { className: popoverClass, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
747
|
+
ColumnFilter,
|
|
748
|
+
{
|
|
749
|
+
column,
|
|
750
|
+
filterValue: filters[column.key],
|
|
751
|
+
setFilter,
|
|
752
|
+
onClose: () => setActiveFilter(null)
|
|
753
|
+
}
|
|
754
|
+
) })
|
|
755
|
+
]
|
|
756
|
+
},
|
|
757
|
+
column.key
|
|
758
|
+
);
|
|
759
|
+
}) }) });
|
|
760
|
+
};
|
|
761
|
+
TableHeader.propTypes = {
|
|
762
|
+
columns: PropTypes.array.isRequired,
|
|
763
|
+
sortConfig: PropTypes.shape({
|
|
764
|
+
key: PropTypes.string,
|
|
765
|
+
direction: PropTypes.oneOf(["asc", "desc"])
|
|
766
|
+
}),
|
|
767
|
+
requestSort: PropTypes.func.isRequired,
|
|
768
|
+
filters: PropTypes.object.isRequired,
|
|
769
|
+
setFilter: PropTypes.func.isRequired
|
|
770
|
+
};
|
|
771
|
+
function get(obj, path, defaultValue = void 0) {
|
|
772
|
+
if (!path || !obj) return defaultValue;
|
|
773
|
+
const value = path.split(".").reduce((acc, part) => {
|
|
774
|
+
return acc && acc[part] !== void 0 ? acc[part] : void 0;
|
|
775
|
+
}, obj);
|
|
776
|
+
return value !== void 0 ? value : defaultValue;
|
|
777
|
+
}
|
|
778
|
+
const TableBody = ({ data, columns, loading, onRowClick, noDataText }) => {
|
|
779
|
+
if (loading) {
|
|
780
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "jc-datatable-tbody", children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsxs("td", { colSpan: columns.length, className: "jc-datatable-loading-cell", children: [
|
|
781
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "jc-datatable-spinner" }),
|
|
782
|
+
"Loading..."
|
|
783
|
+
] }) }) });
|
|
784
|
+
}
|
|
785
|
+
if (!data || data.length === 0) {
|
|
786
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "jc-datatable-tbody", children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: columns.length, className: "jc-datatable-empty-cell", children: noDataText || "No records found" }) }) });
|
|
787
|
+
}
|
|
788
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "jc-datatable-tbody", children: data.map((row, rowIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
789
|
+
"tr",
|
|
790
|
+
{
|
|
791
|
+
className: `jc-datatable-tr ${onRowClick ? "clickable" : ""}`,
|
|
792
|
+
onClick: () => onRowClick && onRowClick(row),
|
|
793
|
+
children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
794
|
+
"td",
|
|
795
|
+
{
|
|
796
|
+
className: "jc-datatable-td",
|
|
797
|
+
"data-label": column.header,
|
|
798
|
+
children: column.render ? column.render(row, rowIndex) : get(row, column.key)
|
|
799
|
+
},
|
|
800
|
+
`${row.id || rowIndex}-${column.key}`
|
|
801
|
+
))
|
|
802
|
+
},
|
|
803
|
+
row.id || rowIndex
|
|
804
|
+
)) });
|
|
805
|
+
};
|
|
806
|
+
TableBody.propTypes = {
|
|
807
|
+
data: PropTypes.array.isRequired,
|
|
808
|
+
columns: PropTypes.array.isRequired,
|
|
809
|
+
loading: PropTypes.bool,
|
|
810
|
+
onRowClick: PropTypes.func,
|
|
811
|
+
noDataText: PropTypes.string
|
|
812
|
+
};
|
|
813
|
+
const Pagination = ({
|
|
814
|
+
currentPage,
|
|
815
|
+
totalPages,
|
|
816
|
+
pageSize,
|
|
817
|
+
setPageSize,
|
|
818
|
+
nextPage,
|
|
819
|
+
prevPage,
|
|
820
|
+
totalItems,
|
|
821
|
+
pageSizeOptions = [5, 10, 20, 50]
|
|
822
|
+
}) => {
|
|
823
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "jc-datatable-pagination", children: [
|
|
824
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "jc-datatable-pagination-info", children: [
|
|
825
|
+
"Showing ",
|
|
826
|
+
(currentPage - 1) * pageSize + 1,
|
|
827
|
+
" to ",
|
|
828
|
+
Math.min(currentPage * pageSize, totalItems),
|
|
829
|
+
" of ",
|
|
830
|
+
totalItems,
|
|
831
|
+
" entries"
|
|
832
|
+
] }),
|
|
833
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "jc-datatable-pagination-controls", children: [
|
|
834
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
835
|
+
"select",
|
|
836
|
+
{
|
|
837
|
+
value: pageSize,
|
|
838
|
+
onChange: (e) => setPageSize(Number(e.target.value)),
|
|
839
|
+
className: "jc-datatable-page-size-select",
|
|
840
|
+
"aria-label": "Select page size",
|
|
841
|
+
children: pageSizeOptions.map((size) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: size, children: [
|
|
842
|
+
size,
|
|
843
|
+
" / page"
|
|
844
|
+
] }, size))
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
848
|
+
"button",
|
|
849
|
+
{
|
|
850
|
+
onClick: prevPage,
|
|
851
|
+
disabled: currentPage === 1,
|
|
852
|
+
className: "jc-datatable-pagination-btn",
|
|
853
|
+
"aria-label": "Previous page",
|
|
854
|
+
children: "Previous"
|
|
855
|
+
}
|
|
856
|
+
),
|
|
857
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "jc-datatable-pagination-pages", children: [
|
|
858
|
+
"Page ",
|
|
859
|
+
currentPage,
|
|
860
|
+
" of ",
|
|
861
|
+
totalPages
|
|
862
|
+
] }),
|
|
863
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
864
|
+
"button",
|
|
865
|
+
{
|
|
866
|
+
onClick: nextPage,
|
|
867
|
+
disabled: currentPage === totalPages,
|
|
868
|
+
className: "jc-datatable-pagination-btn",
|
|
869
|
+
"aria-label": "Next page",
|
|
870
|
+
children: "Next"
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
] })
|
|
874
|
+
] });
|
|
875
|
+
};
|
|
876
|
+
Pagination.propTypes = {
|
|
877
|
+
currentPage: PropTypes.number.isRequired,
|
|
878
|
+
totalPages: PropTypes.number.isRequired,
|
|
879
|
+
pageSize: PropTypes.number.isRequired,
|
|
880
|
+
setPageSize: PropTypes.func.isRequired,
|
|
881
|
+
nextPage: PropTypes.func.isRequired,
|
|
882
|
+
prevPage: PropTypes.func.isRequired,
|
|
883
|
+
totalItems: PropTypes.number.isRequired,
|
|
884
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.number)
|
|
885
|
+
};
|
|
886
|
+
const useSort = (data, columns, initialSort = null) => {
|
|
887
|
+
const [sortConfig, setSortConfig] = React.useState(initialSort);
|
|
888
|
+
const requestSort = (key) => {
|
|
889
|
+
let direction = "asc";
|
|
890
|
+
if (sortConfig && sortConfig.key === key && sortConfig.direction === "asc") {
|
|
891
|
+
direction = "desc";
|
|
892
|
+
}
|
|
893
|
+
setSortConfig({ key, direction });
|
|
894
|
+
};
|
|
895
|
+
const sortedData = React.useMemo(() => {
|
|
896
|
+
if (!sortConfig) return data;
|
|
897
|
+
const column = columns.find((col) => col.key === sortConfig.key);
|
|
898
|
+
if (!column) return data;
|
|
899
|
+
const sortableItems = [...data];
|
|
900
|
+
return sortableItems.sort((a, b) => {
|
|
901
|
+
if (column.sortFn) {
|
|
902
|
+
return sortConfig.direction === "asc" ? column.sortFn(a, b) : column.sortFn(b, a);
|
|
903
|
+
}
|
|
904
|
+
const aValue = get(a, column.key);
|
|
905
|
+
const bValue = get(b, column.key);
|
|
906
|
+
if (aValue < bValue) {
|
|
907
|
+
return sortConfig.direction === "asc" ? -1 : 1;
|
|
908
|
+
}
|
|
909
|
+
if (aValue > bValue) {
|
|
910
|
+
return sortConfig.direction === "asc" ? 1 : -1;
|
|
911
|
+
}
|
|
912
|
+
return 0;
|
|
913
|
+
});
|
|
914
|
+
}, [data, sortConfig, columns]);
|
|
915
|
+
return { sortedData, sortConfig, requestSort };
|
|
916
|
+
};
|
|
917
|
+
const useFilter = (data, columns) => {
|
|
918
|
+
const [filters, setFilters] = React.useState({});
|
|
919
|
+
const setFilter = (key, value) => {
|
|
920
|
+
setFilters((prev) => ({
|
|
921
|
+
...prev,
|
|
922
|
+
[key]: value
|
|
923
|
+
}));
|
|
924
|
+
};
|
|
925
|
+
const filteredData = React.useMemo(() => {
|
|
926
|
+
return data.filter((row) => {
|
|
927
|
+
return Object.keys(filters).every((key) => {
|
|
928
|
+
const filterValue = filters[key];
|
|
929
|
+
if (!filterValue) return true;
|
|
930
|
+
const column = columns.find((col) => col.key === key);
|
|
931
|
+
if (!column) return true;
|
|
932
|
+
const rowValue = get(row, key);
|
|
933
|
+
if (column.filterFn) {
|
|
934
|
+
return column.filterFn(rowValue, filterValue, row);
|
|
935
|
+
}
|
|
936
|
+
return String(rowValue || "").toLowerCase().includes(String(filterValue).toLowerCase());
|
|
937
|
+
});
|
|
938
|
+
});
|
|
939
|
+
}, [data, filters, columns]);
|
|
940
|
+
return { filteredData, filters, setFilter };
|
|
941
|
+
};
|
|
942
|
+
const usePagination = (data, enabled = true, initialPageSize = 10) => {
|
|
943
|
+
const [currentPage, setCurrentPage] = React.useState(1);
|
|
944
|
+
const [pageSize, setPageSize] = React.useState(initialPageSize);
|
|
945
|
+
React.useEffect(() => {
|
|
946
|
+
setCurrentPage(1);
|
|
947
|
+
}, [data.length, pageSize]);
|
|
948
|
+
const totalItems = data.length;
|
|
949
|
+
const totalPages = enabled ? Math.ceil(totalItems / pageSize) : 1;
|
|
950
|
+
const paginatedData = React.useMemo(() => {
|
|
951
|
+
if (!enabled) return data;
|
|
952
|
+
const start = (currentPage - 1) * pageSize;
|
|
953
|
+
return data.slice(start, start + pageSize);
|
|
954
|
+
}, [data, currentPage, pageSize, enabled]);
|
|
955
|
+
const nextPage = () => {
|
|
956
|
+
if (currentPage < totalPages) {
|
|
957
|
+
setCurrentPage((prev) => prev + 1);
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
const prevPage = () => {
|
|
961
|
+
if (currentPage > 1) {
|
|
962
|
+
setCurrentPage((prev) => prev - 1);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
const setPage = (page) => {
|
|
966
|
+
const p = Math.max(1, Math.min(page, totalPages));
|
|
967
|
+
setCurrentPage(p);
|
|
968
|
+
};
|
|
969
|
+
return {
|
|
970
|
+
paginatedData,
|
|
971
|
+
currentPage,
|
|
972
|
+
totalPages,
|
|
973
|
+
pageSize,
|
|
974
|
+
totalItems,
|
|
975
|
+
setPage,
|
|
976
|
+
setPageSize,
|
|
977
|
+
nextPage,
|
|
978
|
+
prevPage
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
const DataTable = ({
|
|
982
|
+
columns,
|
|
983
|
+
data,
|
|
984
|
+
loading = false,
|
|
985
|
+
pagination = true,
|
|
986
|
+
pageSizeOptions = [5, 10, 20, 50],
|
|
987
|
+
defaultPageSize = 10,
|
|
988
|
+
onRowClick,
|
|
989
|
+
noDataText = "No records found",
|
|
990
|
+
className = "",
|
|
991
|
+
maxHeight
|
|
992
|
+
}) => {
|
|
993
|
+
const { filteredData, filters, setFilter } = useFilter(data, columns);
|
|
994
|
+
const { sortedData, sortConfig, requestSort } = useSort(filteredData, columns);
|
|
995
|
+
const {
|
|
996
|
+
paginatedData,
|
|
997
|
+
currentPage,
|
|
998
|
+
totalPages,
|
|
999
|
+
pageSize,
|
|
1000
|
+
setPageSize,
|
|
1001
|
+
nextPage,
|
|
1002
|
+
prevPage,
|
|
1003
|
+
totalItems
|
|
1004
|
+
} = usePagination(sortedData, pagination, defaultPageSize);
|
|
1005
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `jc-datatable-wrapper ${className || ""}`, children: [
|
|
1006
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1007
|
+
"div",
|
|
1008
|
+
{
|
|
1009
|
+
className: "jc-datatable-container",
|
|
1010
|
+
style: maxHeight ? { maxHeight, overflowY: "auto" } : {},
|
|
1011
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "jc-datatable-table", children: [
|
|
1012
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1013
|
+
TableHeader,
|
|
1014
|
+
{
|
|
1015
|
+
columns,
|
|
1016
|
+
sortConfig,
|
|
1017
|
+
requestSort,
|
|
1018
|
+
filters,
|
|
1019
|
+
setFilter
|
|
1020
|
+
}
|
|
1021
|
+
),
|
|
1022
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1023
|
+
TableBody,
|
|
1024
|
+
{
|
|
1025
|
+
data: pagination ? paginatedData : sortedData,
|
|
1026
|
+
columns,
|
|
1027
|
+
loading,
|
|
1028
|
+
onRowClick,
|
|
1029
|
+
noDataText
|
|
1030
|
+
}
|
|
1031
|
+
)
|
|
1032
|
+
] })
|
|
1033
|
+
}
|
|
1034
|
+
),
|
|
1035
|
+
pagination && !loading && data.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1036
|
+
Pagination,
|
|
1037
|
+
{
|
|
1038
|
+
currentPage,
|
|
1039
|
+
totalPages,
|
|
1040
|
+
pageSize,
|
|
1041
|
+
setPageSize,
|
|
1042
|
+
nextPage,
|
|
1043
|
+
prevPage,
|
|
1044
|
+
totalItems,
|
|
1045
|
+
pageSizeOptions
|
|
1046
|
+
}
|
|
1047
|
+
)
|
|
1048
|
+
] });
|
|
1049
|
+
};
|
|
1050
|
+
DataTable.propTypes = {
|
|
1051
|
+
columns: PropTypes.arrayOf(
|
|
1052
|
+
PropTypes.shape({
|
|
1053
|
+
key: PropTypes.string.isRequired,
|
|
1054
|
+
header: PropTypes.string.isRequired,
|
|
1055
|
+
width: PropTypes.string,
|
|
1056
|
+
minWidth: PropTypes.string,
|
|
1057
|
+
maxWidth: PropTypes.string,
|
|
1058
|
+
sortable: PropTypes.bool,
|
|
1059
|
+
searchable: PropTypes.bool,
|
|
1060
|
+
render: PropTypes.func,
|
|
1061
|
+
sortFn: PropTypes.func,
|
|
1062
|
+
filterFn: PropTypes.func
|
|
1063
|
+
})
|
|
1064
|
+
).isRequired,
|
|
1065
|
+
data: PropTypes.array.isRequired,
|
|
1066
|
+
loading: PropTypes.bool,
|
|
1067
|
+
pagination: PropTypes.bool,
|
|
1068
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
|
|
1069
|
+
defaultPageSize: PropTypes.number,
|
|
1070
|
+
onRowClick: PropTypes.func,
|
|
1071
|
+
noDataText: PropTypes.string,
|
|
1072
|
+
className: PropTypes.string,
|
|
1073
|
+
maxHeight: PropTypes.string
|
|
1074
|
+
};
|
|
1075
|
+
exports2.DataTable = DataTable;
|
|
1076
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1077
|
+
}));
|