funuicss 3.5.7 β 3.5.8
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/css/fun.css +2 -1
- package/index.d.ts +2 -0
- package/index.js +5 -1
- package/js/firebase/Auth.d.ts +191 -0
- package/js/firebase/Auth.js +746 -0
- package/js/firebase/FireStore.d.ts +54 -0
- package/js/firebase/FireStore.js +285 -0
- package/package.json +2 -1
- package/ui/table/Table.d.ts +2 -1
- package/ui/table/Table.js +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DocumentData, QueryConstraint, DocumentReference, Firestore } from 'firebase/firestore';
|
|
2
|
+
export interface DocWithId extends Record<string, any> {
|
|
3
|
+
id: string;
|
|
4
|
+
}
|
|
5
|
+
export interface QueryResponse {
|
|
6
|
+
message?: string;
|
|
7
|
+
data: DocWithId[];
|
|
8
|
+
}
|
|
9
|
+
export interface SingleDocResponse {
|
|
10
|
+
message?: string;
|
|
11
|
+
data: DocumentData | string;
|
|
12
|
+
id?: string;
|
|
13
|
+
}
|
|
14
|
+
type CollectionName = string;
|
|
15
|
+
type DocumentId = string;
|
|
16
|
+
/**
|
|
17
|
+
* Recursively formats Firestore Timestamps into ISO strings.
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatTimestamps: (data: DocumentData) => DocumentData;
|
|
20
|
+
export declare const FunFireStore: {
|
|
21
|
+
/**
|
|
22
|
+
* π₯ Fetch all documents from a collection
|
|
23
|
+
*/
|
|
24
|
+
getDocs: (db: Firestore, collectionName: CollectionName, docsLimit?: number, extraQueries?: QueryConstraint[]) => Promise<DocWithId[]>;
|
|
25
|
+
/**
|
|
26
|
+
* π Real-time listener for a single document
|
|
27
|
+
*/
|
|
28
|
+
getDoc: (db: Firestore, collectionName: CollectionName, id: DocumentId) => Promise<SingleDocResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* π Fetch a single document (no listener)
|
|
31
|
+
*/
|
|
32
|
+
getDocOnce: (db: Firestore, collectionName: CollectionName, id: DocumentId) => Promise<SingleDocResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* π Custom query with constraints
|
|
35
|
+
*/
|
|
36
|
+
query: (db: Firestore, collectionName: CollectionName, queries?: QueryConstraint[], docsLimit?: number) => Promise<QueryResponse>;
|
|
37
|
+
/**
|
|
38
|
+
* β Add new document (auto ID)
|
|
39
|
+
*/
|
|
40
|
+
addDocument: (db: Firestore, collectionName: CollectionName, data: DocumentData) => Promise<DocumentReference>;
|
|
41
|
+
/**
|
|
42
|
+
* π§© Set or merge a document with a custom ID
|
|
43
|
+
*/
|
|
44
|
+
setDoc: (db: Firestore, collectionName: CollectionName, id: DocumentId, data: DocumentData) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* π Update a document
|
|
47
|
+
*/
|
|
48
|
+
update: (db: Firestore, collectionName: CollectionName, id: DocumentId, data: Partial<DocumentData>) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* β Delete a document
|
|
51
|
+
*/
|
|
52
|
+
delete: (db: Firestore, collectionName: CollectionName, id: DocumentId) => Promise<string>;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.FunFireStore = exports.formatTimestamps = void 0;
|
|
60
|
+
var firestore_1 = require("firebase/firestore");
|
|
61
|
+
/* -------------------------------------------------------------------------- */
|
|
62
|
+
/* π§ Timestamp Formatting Helper */
|
|
63
|
+
/* -------------------------------------------------------------------------- */
|
|
64
|
+
/**
|
|
65
|
+
* Recursively formats Firestore Timestamps into ISO strings.
|
|
66
|
+
*/
|
|
67
|
+
var formatTimestamps = function (data) {
|
|
68
|
+
if (!data || typeof data !== 'object')
|
|
69
|
+
return data;
|
|
70
|
+
var formatted = Array.isArray(data) ? [] : {};
|
|
71
|
+
for (var key in data) {
|
|
72
|
+
var value = data[key];
|
|
73
|
+
if (value instanceof firestore_1.Timestamp) {
|
|
74
|
+
formatted[key] = value.toDate().toISOString();
|
|
75
|
+
}
|
|
76
|
+
else if (Array.isArray(value)) {
|
|
77
|
+
formatted[key] = value.map(function (v) { return (0, exports.formatTimestamps)(v); });
|
|
78
|
+
}
|
|
79
|
+
else if (value && typeof value === 'object') {
|
|
80
|
+
formatted[key] = (0, exports.formatTimestamps)(value);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
formatted[key] = value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return formatted;
|
|
87
|
+
};
|
|
88
|
+
exports.formatTimestamps = formatTimestamps;
|
|
89
|
+
/* -------------------------------------------------------------------------- */
|
|
90
|
+
/* β‘ Firestore Utilities */
|
|
91
|
+
/* -------------------------------------------------------------------------- */
|
|
92
|
+
exports.FunFireStore = {
|
|
93
|
+
/**
|
|
94
|
+
* π₯ Fetch all documents from a collection
|
|
95
|
+
*/
|
|
96
|
+
getDocs: function (db_1, collectionName_1, docsLimit_1) {
|
|
97
|
+
var args_1 = [];
|
|
98
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
99
|
+
args_1[_i - 3] = arguments[_i];
|
|
100
|
+
}
|
|
101
|
+
return __awaiter(void 0, __spreadArray([db_1, collectionName_1, docsLimit_1], args_1, true), void 0, function (db, collectionName, docsLimit, extraQueries) {
|
|
102
|
+
var constraints, q, snapshot, err_1, error;
|
|
103
|
+
if (extraQueries === void 0) { extraQueries = []; }
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0:
|
|
107
|
+
_a.trys.push([0, 2, , 3]);
|
|
108
|
+
constraints = __spreadArray([], extraQueries, true);
|
|
109
|
+
if (docsLimit)
|
|
110
|
+
constraints.push((0, firestore_1.limit)(docsLimit));
|
|
111
|
+
q = firestore_1.query.apply(void 0, __spreadArray([(0, firestore_1.collection)(db, collectionName)], constraints, false));
|
|
112
|
+
return [4 /*yield*/, (0, firestore_1.getDocs)(q)];
|
|
113
|
+
case 1:
|
|
114
|
+
snapshot = _a.sent();
|
|
115
|
+
return [2 /*return*/, snapshot.docs.map(function (d) { return (__assign({ id: d.id }, (0, exports.formatTimestamps)(d.data()))); })];
|
|
116
|
+
case 2:
|
|
117
|
+
err_1 = _a.sent();
|
|
118
|
+
error = err_1;
|
|
119
|
+
throw new Error("Error fetching documents from ".concat(collectionName, ": ").concat(error.message));
|
|
120
|
+
case 3: return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* π Real-time listener for a single document
|
|
127
|
+
*/
|
|
128
|
+
getDoc: function (db, collectionName, id) {
|
|
129
|
+
return new Promise(function (resolve, reject) {
|
|
130
|
+
var unsub = (0, firestore_1.onSnapshot)((0, firestore_1.doc)(db, collectionName, id), function (snap) {
|
|
131
|
+
var data = snap.data();
|
|
132
|
+
resolve(data
|
|
133
|
+
? { id: snap.id, data: (0, exports.formatTimestamps)(data) }
|
|
134
|
+
: { message: 'No data found', data: '' });
|
|
135
|
+
}, function (err) { return reject(new Error("Error fetching document: ".concat(err.message))); });
|
|
136
|
+
// β
Auto-unsubscribe after first snapshot to avoid memory leaks
|
|
137
|
+
setTimeout(function () { return unsub(); }, 10000);
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* π Fetch a single document (no listener)
|
|
142
|
+
*/
|
|
143
|
+
getDocOnce: function (db, collectionName, id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
|
+
var snap, data, err_2, error;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0:
|
|
148
|
+
_a.trys.push([0, 2, , 3]);
|
|
149
|
+
return [4 /*yield*/, (0, firestore_1.getDoc)((0, firestore_1.doc)(db, collectionName, id))];
|
|
150
|
+
case 1:
|
|
151
|
+
snap = _a.sent();
|
|
152
|
+
data = snap.data();
|
|
153
|
+
return [2 /*return*/, data
|
|
154
|
+
? { id: snap.id, data: (0, exports.formatTimestamps)(data) }
|
|
155
|
+
: { message: 'No data found', data: '' }];
|
|
156
|
+
case 2:
|
|
157
|
+
err_2 = _a.sent();
|
|
158
|
+
error = err_2;
|
|
159
|
+
throw new Error("Error fetching document: ".concat(error.message));
|
|
160
|
+
case 3: return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); },
|
|
164
|
+
/**
|
|
165
|
+
* π Custom query with constraints
|
|
166
|
+
*/
|
|
167
|
+
query: function (db_1, collectionName_1) {
|
|
168
|
+
var args_1 = [];
|
|
169
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
170
|
+
args_1[_i - 2] = arguments[_i];
|
|
171
|
+
}
|
|
172
|
+
return __awaiter(void 0, __spreadArray([db_1, collectionName_1], args_1, true), void 0, function (db, collectionName, queries, docsLimit) {
|
|
173
|
+
var constraints, q, snapshot, data, err_3, error;
|
|
174
|
+
if (queries === void 0) { queries = []; }
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
_a.trys.push([0, 2, , 3]);
|
|
179
|
+
constraints = __spreadArray([], queries, true);
|
|
180
|
+
if (docsLimit)
|
|
181
|
+
constraints.push((0, firestore_1.limit)(docsLimit));
|
|
182
|
+
q = firestore_1.query.apply(void 0, __spreadArray([(0, firestore_1.collection)(db, collectionName)], constraints, false));
|
|
183
|
+
return [4 /*yield*/, (0, firestore_1.getDocs)(q)];
|
|
184
|
+
case 1:
|
|
185
|
+
snapshot = _a.sent();
|
|
186
|
+
if (!snapshot.empty) {
|
|
187
|
+
data = snapshot.docs.map(function (d) { return (__assign({ id: d.id }, (0, exports.formatTimestamps)(d.data()))); });
|
|
188
|
+
return [2 /*return*/, { data: data }];
|
|
189
|
+
}
|
|
190
|
+
return [2 /*return*/, { message: 'No data', data: [] }];
|
|
191
|
+
case 2:
|
|
192
|
+
err_3 = _a.sent();
|
|
193
|
+
error = err_3;
|
|
194
|
+
throw new Error("Error querying ".concat(collectionName, ": ").concat(error.message));
|
|
195
|
+
case 3: return [2 /*return*/];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
/**
|
|
201
|
+
* β Add new document (auto ID)
|
|
202
|
+
*/
|
|
203
|
+
addDocument: function (db, collectionName, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
204
|
+
var docRef, err_4, error;
|
|
205
|
+
return __generator(this, function (_a) {
|
|
206
|
+
switch (_a.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
_a.trys.push([0, 2, , 3]);
|
|
209
|
+
return [4 /*yield*/, (0, firestore_1.addDoc)((0, firestore_1.collection)(db, collectionName), __assign(__assign({}, data), { createdAt: (0, firestore_1.serverTimestamp)(), updatedAt: (0, firestore_1.serverTimestamp)() }))];
|
|
210
|
+
case 1:
|
|
211
|
+
docRef = _a.sent();
|
|
212
|
+
// await updateDoc(docRef, { [assignKey]: docRef.id });
|
|
213
|
+
return [2 /*return*/, docRef];
|
|
214
|
+
case 2:
|
|
215
|
+
err_4 = _a.sent();
|
|
216
|
+
error = err_4;
|
|
217
|
+
throw new Error("Error adding document: ".concat(error.message));
|
|
218
|
+
case 3: return [2 /*return*/];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}); },
|
|
222
|
+
/**
|
|
223
|
+
* π§© Set or merge a document with a custom ID
|
|
224
|
+
*/
|
|
225
|
+
setDoc: function (db, collectionName, id, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
+
var err_5, error;
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
switch (_a.label) {
|
|
229
|
+
case 0:
|
|
230
|
+
_a.trys.push([0, 2, , 3]);
|
|
231
|
+
return [4 /*yield*/, (0, firestore_1.setDoc)((0, firestore_1.doc)(db, collectionName, id), __assign(__assign({}, data), { updatedAt: (0, firestore_1.serverTimestamp)(), createdAt: (0, firestore_1.serverTimestamp)() }), { merge: true })];
|
|
232
|
+
case 1:
|
|
233
|
+
_a.sent();
|
|
234
|
+
return [3 /*break*/, 3];
|
|
235
|
+
case 2:
|
|
236
|
+
err_5 = _a.sent();
|
|
237
|
+
error = err_5;
|
|
238
|
+
throw new Error("Error setting document: ".concat(error.message));
|
|
239
|
+
case 3: return [2 /*return*/];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}); },
|
|
243
|
+
/**
|
|
244
|
+
* π Update a document
|
|
245
|
+
*/
|
|
246
|
+
update: function (db, collectionName, id, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
247
|
+
var err_6, error;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
_a.trys.push([0, 2, , 3]);
|
|
252
|
+
return [4 /*yield*/, (0, firestore_1.updateDoc)((0, firestore_1.doc)(db, collectionName, id), __assign(__assign({}, data), { updatedAt: (0, firestore_1.serverTimestamp)() }))];
|
|
253
|
+
case 1:
|
|
254
|
+
_a.sent();
|
|
255
|
+
return [3 /*break*/, 3];
|
|
256
|
+
case 2:
|
|
257
|
+
err_6 = _a.sent();
|
|
258
|
+
error = err_6;
|
|
259
|
+
throw new Error("Error updating document: ".concat(error.message));
|
|
260
|
+
case 3: return [2 /*return*/];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}); },
|
|
264
|
+
/**
|
|
265
|
+
* β Delete a document
|
|
266
|
+
*/
|
|
267
|
+
delete: function (db, collectionName, id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
268
|
+
var err_7, error;
|
|
269
|
+
return __generator(this, function (_a) {
|
|
270
|
+
switch (_a.label) {
|
|
271
|
+
case 0:
|
|
272
|
+
_a.trys.push([0, 2, , 3]);
|
|
273
|
+
return [4 /*yield*/, (0, firestore_1.deleteDoc)((0, firestore_1.doc)(db, collectionName, id))];
|
|
274
|
+
case 1:
|
|
275
|
+
_a.sent();
|
|
276
|
+
return [2 /*return*/, "\u2705 Document \"".concat(id, "\" successfully deleted")];
|
|
277
|
+
case 2:
|
|
278
|
+
err_7 = _a.sent();
|
|
279
|
+
error = err_7;
|
|
280
|
+
throw new Error("Error deleting document: ".concat(error.message));
|
|
281
|
+
case 3: return [2 /*return*/];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}); },
|
|
285
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.
|
|
2
|
+
"version": "3.5.8",
|
|
3
3
|
"name": "funuicss",
|
|
4
4
|
"description": "React and Next.js component UI Library for creating Easy and good looking websites with fewer lines of code. Elevate your web development experience with our cutting-edge React/Next.js component UI Library. Craft stunning websites effortlessly, boasting both seamless functionality and aesthetic appealβall achieved with minimal lines of code. Unleash the power of simplicity and style in your projects!",
|
|
5
5
|
"main": "index.js",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"aos": "^2.3.4",
|
|
46
46
|
"dayjs": "^1.11.13",
|
|
47
|
+
"firebase": "^12.3.0",
|
|
47
48
|
"framer-motion": "^12.23.6",
|
|
48
49
|
"hls.js": "^1.6.5",
|
|
49
50
|
"next": "^13.4.4",
|
package/ui/table/Table.d.ts
CHANGED
|
@@ -36,8 +36,9 @@ type TableProps = {
|
|
|
36
36
|
}[];
|
|
37
37
|
filterableFields?: string[];
|
|
38
38
|
prioritizeSearchFields?: string[];
|
|
39
|
+
onRowClick?: (data: any) => void;
|
|
39
40
|
};
|
|
40
41
|
export default function Table({ children, funcss, bordered, noStripped, hoverable, title, showTotal, light, dark, head, body, data, isLoading, right, hideExport, height, pageSize, // Default page size,
|
|
41
42
|
customColumns, filterableFields, // New prop
|
|
42
|
-
emptyResponse, filterOnchange, clearSearch, prioritizeSearchFields, ...rest }: TableProps): React.JSX.Element;
|
|
43
|
+
emptyResponse, filterOnchange, clearSearch, prioritizeSearchFields, onRowClick, ...rest }: TableProps): React.JSX.Element;
|
|
43
44
|
export {};
|
package/ui/table/Table.js
CHANGED
|
@@ -95,7 +95,7 @@ function Table(_a) {
|
|
|
95
95
|
var _b, _c;
|
|
96
96
|
var children = _a.children, funcss = _a.funcss, bordered = _a.bordered, noStripped = _a.noStripped, hoverable = _a.hoverable, _d = _a.title, title = _d === void 0 ? "" : _d, showTotal = _a.showTotal, light = _a.light, dark = _a.dark, head = _a.head, body = _a.body, data = _a.data, _e = _a.isLoading, isLoading = _e === void 0 ? false : _e, right = _a.right, hideExport = _a.hideExport, height = _a.height, _f = _a.pageSize, pageSize = _f === void 0 ? data ? 10 : 0 : _f, // Default page size,
|
|
97
97
|
customColumns = _a.customColumns, filterableFields = _a.filterableFields, // New prop
|
|
98
|
-
emptyResponse = _a.emptyResponse, filterOnchange = _a.filterOnchange, clearSearch = _a.clearSearch, _g = _a.prioritizeSearchFields, prioritizeSearchFields = _g === void 0 ? [] : _g, rest = __rest(_a, ["children", "funcss", "bordered", "noStripped", "hoverable", "title", "showTotal", "light", "dark", "head", "body", "data", "isLoading", "right", "hideExport", "height", "pageSize", "customColumns", "filterableFields", "emptyResponse", "filterOnchange", "clearSearch", "prioritizeSearchFields"]);
|
|
98
|
+
emptyResponse = _a.emptyResponse, filterOnchange = _a.filterOnchange, clearSearch = _a.clearSearch, _g = _a.prioritizeSearchFields, prioritizeSearchFields = _g === void 0 ? [] : _g, onRowClick = _a.onRowClick, rest = __rest(_a, ["children", "funcss", "bordered", "noStripped", "hoverable", "title", "showTotal", "light", "dark", "head", "body", "data", "isLoading", "right", "hideExport", "height", "pageSize", "customColumns", "filterableFields", "emptyResponse", "filterOnchange", "clearSearch", "prioritizeSearchFields", "onRowClick"]);
|
|
99
99
|
// Check if data is null or undefined before accessing its properties
|
|
100
100
|
// Replace this in your component
|
|
101
101
|
var _h = (0, react_1.useState)(''), search = _h[0], setSearch = _h[1];
|
|
@@ -278,7 +278,7 @@ function Table(_a) {
|
|
|
278
278
|
var results = (0, Query_1.getAdvancedFilteredData)(filteredData, searchQuery, data, getNestedValue, prioritizeSearchFields);
|
|
279
279
|
var shouldSlice = !searchQuery || results.length > 10;
|
|
280
280
|
return (shouldSlice ? results.slice(startIndex, endIndex) : results)
|
|
281
|
-
.map(function (mdoc, index) { return (React.createElement("tr", { className: 'animated slide-up', key: index },
|
|
281
|
+
.map(function (mdoc, index) { return (React.createElement("tr", { className: 'animated slide-up', key: index, onClick: onRowClick ? function () { return onRowClick(mdoc); } : undefined },
|
|
282
282
|
data.fields.map(function (fdoc, findex) {
|
|
283
283
|
var _a;
|
|
284
284
|
return (React.createElement(Data_1.default, { key: fdoc, funcss: data.funcss ? ((_a = data === null || data === void 0 ? void 0 : data.funcss) === null || _a === void 0 ? void 0 : _a[findex]) || '' : '' }, getNestedValue(mdoc, fdoc)));
|