@unbxd-ui/unbxd-react-components 0.2.145-beta.4 → 0.2.145-beta.6
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 +1 -1
- package/components/Accordian/Accordian.stories.js +140 -116
- package/components/Button/Button.stories.js +166 -59
- package/components/DataLoader/DataLoader.stories.js +176 -53
- package/components/Form/stories/Checkbox.stories.js +131 -38
- package/components/Form/stories/Dropdown.stories.js +321 -91
- package/components/Form/stories/FileUploader.stories.js +177 -18
- package/components/Form/stories/Input.stories.js +112 -0
- package/components/Form/stories/RangeSlider.stories.js +160 -62
- package/components/Form/stories/SearchableDropdown.stories.js +189 -0
- package/components/Form/stories/ServerPaginatedDropdown.stories.js +370 -0
- package/components/Form/stories/Textarea.stories.js +112 -32
- package/components/Form/stories/Toggle.stories.js +191 -13
- package/components/InlineModal/InlineModal.stories.js +238 -43
- package/components/List/List.stories.js +238 -0
- package/components/Modal/Modal.stories.js +274 -36
- package/components/NotificationComponent/NotificationComponent.stories.js +169 -18
- package/components/ProgressBar/ProgressBar.css +0 -0
- package/components/ProgressBar/ProgressBar.stories.js +202 -9
- package/components/Table/BaseTable.js +84 -353
- package/components/Table/Table.js +5 -357
- package/components/Table/Table.stories.js +825 -157
- package/components/Table/TableChild.js +372 -0
- package/components/Table/TableConstants.js +15 -0
- package/components/Table/hooks/usePrevious.js +14 -0
- package/components/Table/index.js +13 -0
- package/components/Table/tableCore.css +1 -1
- package/components/TableOld/BaseTable.js +373 -0
- package/components/TableOld/PaginationComponent.js +86 -0
- package/components/TableOld/TableOld.js +367 -0
- package/components/TableOld/index.js +15 -0
- package/components/TabsComponent/TabsComponent.stories.js +290 -52
- package/components/Tooltip/Tooltip.stories.js +208 -14
- package/components/core.css +2 -2
- package/components/index.js +7 -0
- package/index.js +6 -0
- package/package.json +28 -18
- package/components/Button/DropdownButton.stories.js +0 -48
- package/components/Form/stories/DragDropFileUploader.stories.js +0 -25
- package/components/Form/stories/FormDefault.stories.js +0 -114
- package/components/Form/stories/RadioList.stories.js +0 -52
- package/components/Form/stories/TextInput.stories.js +0 -75
- package/components/Form/stories/form.stories.js +0 -232
- package/components/List/list.stories.js +0 -35
- package/core/dataLoader.stories.js +0 -118
|
@@ -4,194 +4,862 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports["default"] = exports.
|
|
7
|
+
exports["default"] = exports.ServerSidePagination = exports.SelectableRows = exports.RefreshTable = exports.NoPagination = exports.NoDataDefault = exports.Default = exports.CustomStyling = exports.CustomNoDataComponent = exports.CustomColumnFormatting = exports.BottomPagination = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _Table = _interopRequireDefault(require("./Table"));
|
|
10
|
-
var _DataLoader = _interopRequireDefault(require("../DataLoader"));
|
|
11
10
|
var _dataLoader = _interopRequireDefault(require("../../core/dataLoader"));
|
|
12
|
-
var _Form = require("../Form");
|
|
13
|
-
var _Constants = require("../../../public/Constants");
|
|
14
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
13
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
22
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
15
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24
16
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
25
17
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
26
18
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
// Custom CheckBoxRow component for stories
|
|
20
|
+
var CustomCheckBoxRow = function CustomCheckBoxRow(_ref) {
|
|
21
|
+
var selected = _ref.selected,
|
|
22
|
+
onSelectionChange = _ref.onSelectionChange,
|
|
23
|
+
_ref$isCell = _ref.isCell,
|
|
24
|
+
isCell = _ref$isCell === void 0 ? false : _ref$isCell,
|
|
25
|
+
row = _ref.row;
|
|
26
|
+
var handleChange = function handleChange(e) {
|
|
27
|
+
if (isCell && row) {
|
|
28
|
+
onSelectionChange(row, e.target.checked);
|
|
29
|
+
} else {
|
|
30
|
+
onSelectionChange(null, e.target.checked);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/_react["default"].createElement("input", {
|
|
34
|
+
type: "checkbox",
|
|
35
|
+
checked: selected,
|
|
36
|
+
onChange: handleChange,
|
|
37
|
+
style: {
|
|
38
|
+
width: '16px',
|
|
39
|
+
height: '16px',
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
accentColor: '#007bff'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
38
44
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
|
|
46
|
+
// Set up request configurations for server-side examples
|
|
47
|
+
_dataLoader["default"].addRequestConfig('getUsers', {
|
|
48
|
+
url: 'https://jsonplaceholder.typicode.com/users',
|
|
49
|
+
method: 'GET'
|
|
50
|
+
});
|
|
51
|
+
_dataLoader["default"].addRequestConfig('getPosts', {
|
|
52
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
53
|
+
method: 'GET'
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Sample data for stories
|
|
57
|
+
var sampleRecords = [{
|
|
58
|
+
id: 1,
|
|
59
|
+
name: 'John Doe',
|
|
60
|
+
email: 'john.doe@example.com',
|
|
61
|
+
age: 30,
|
|
62
|
+
department: 'Engineering',
|
|
63
|
+
salary: 75000
|
|
64
|
+
}, {
|
|
65
|
+
id: 2,
|
|
66
|
+
name: 'Jane Smith',
|
|
67
|
+
email: 'jane.smith@example.com',
|
|
68
|
+
age: 28,
|
|
69
|
+
department: 'Marketing',
|
|
70
|
+
salary: 65000
|
|
71
|
+
}, {
|
|
72
|
+
id: 3,
|
|
73
|
+
name: 'Bob Johnson',
|
|
74
|
+
email: 'bob.johnson@example.com',
|
|
75
|
+
age: 35,
|
|
76
|
+
department: 'Sales',
|
|
77
|
+
salary: 80000
|
|
78
|
+
}, {
|
|
79
|
+
id: 4,
|
|
80
|
+
name: 'Alice Brown',
|
|
81
|
+
email: 'alice.brown@example.com',
|
|
82
|
+
age: 32,
|
|
83
|
+
department: 'Engineering',
|
|
84
|
+
salary: 78000
|
|
85
|
+
}, {
|
|
86
|
+
id: 5,
|
|
87
|
+
name: 'Charlie Wilson',
|
|
88
|
+
email: 'charlie.wilson@example.com',
|
|
89
|
+
age: 29,
|
|
90
|
+
department: 'HR',
|
|
91
|
+
salary: 60000
|
|
92
|
+
}, {
|
|
93
|
+
id: 6,
|
|
94
|
+
name: 'Diana Davis',
|
|
95
|
+
email: 'diana.davis@example.com',
|
|
96
|
+
age: 31,
|
|
97
|
+
department: 'Marketing',
|
|
98
|
+
salary: 67000
|
|
99
|
+
}, {
|
|
100
|
+
id: 7,
|
|
101
|
+
name: 'Edward Miller',
|
|
102
|
+
email: 'edward.miller@example.com',
|
|
103
|
+
age: 33,
|
|
104
|
+
department: 'Sales',
|
|
105
|
+
salary: 82000
|
|
106
|
+
}, {
|
|
107
|
+
id: 8,
|
|
108
|
+
name: 'Fiona Garcia',
|
|
109
|
+
email: 'fiona.garcia@example.com',
|
|
110
|
+
age: 27,
|
|
111
|
+
department: 'Engineering',
|
|
112
|
+
salary: 72000
|
|
113
|
+
}, {
|
|
114
|
+
id: 9,
|
|
115
|
+
name: 'George Martinez',
|
|
116
|
+
email: 'george.martinez@example.com',
|
|
117
|
+
age: 34,
|
|
118
|
+
department: 'HR',
|
|
119
|
+
salary: 62000
|
|
120
|
+
}, {
|
|
121
|
+
id: 10,
|
|
122
|
+
name: 'Helen Taylor',
|
|
123
|
+
email: 'helen.taylor@example.com',
|
|
124
|
+
age: 30,
|
|
125
|
+
department: 'Marketing',
|
|
126
|
+
salary: 68000
|
|
127
|
+
}, {
|
|
128
|
+
id: 11,
|
|
129
|
+
name: 'Isaac Thompson',
|
|
130
|
+
email: 'isaac.thompson@example.com',
|
|
131
|
+
age: 36,
|
|
132
|
+
department: 'Engineering',
|
|
133
|
+
salary: 79000
|
|
134
|
+
}, {
|
|
135
|
+
id: 12,
|
|
136
|
+
name: 'Julia White',
|
|
137
|
+
email: 'julia.white@example.com',
|
|
138
|
+
age: 26,
|
|
139
|
+
department: 'HR',
|
|
140
|
+
salary: 61000
|
|
141
|
+
}, {
|
|
142
|
+
id: 13,
|
|
143
|
+
name: 'Kevin Harris',
|
|
144
|
+
email: 'kevin.harris@example.com',
|
|
145
|
+
age: 38,
|
|
146
|
+
department: 'Sales',
|
|
147
|
+
salary: 85000
|
|
148
|
+
}, {
|
|
149
|
+
id: 14,
|
|
150
|
+
name: 'Laura Lewis',
|
|
151
|
+
email: 'laura.lewis@example.com',
|
|
152
|
+
age: 29,
|
|
153
|
+
department: 'Marketing',
|
|
154
|
+
salary: 66000
|
|
155
|
+
}, {
|
|
156
|
+
id: 15,
|
|
157
|
+
name: 'Michael Young',
|
|
158
|
+
email: 'michael.young@example.com',
|
|
159
|
+
age: 40,
|
|
160
|
+
department: 'Engineering',
|
|
161
|
+
salary: 88000
|
|
162
|
+
}, {
|
|
163
|
+
id: 16,
|
|
164
|
+
name: 'Natalie Hall',
|
|
165
|
+
email: 'natalie.hall@example.com',
|
|
166
|
+
age: 31,
|
|
167
|
+
department: 'HR',
|
|
168
|
+
salary: 63000
|
|
169
|
+
}, {
|
|
170
|
+
id: 17,
|
|
171
|
+
name: 'Oliver Allen',
|
|
172
|
+
email: 'oliver.allen@example.com',
|
|
173
|
+
age: 28,
|
|
174
|
+
department: 'Sales',
|
|
175
|
+
salary: 81000
|
|
176
|
+
}, {
|
|
177
|
+
id: 18,
|
|
178
|
+
name: 'Patricia King',
|
|
179
|
+
email: 'patricia.king@example.com',
|
|
180
|
+
age: 33,
|
|
181
|
+
department: 'Marketing',
|
|
182
|
+
salary: 69000
|
|
183
|
+
}, {
|
|
184
|
+
id: 19,
|
|
185
|
+
name: 'Quentin Scott',
|
|
186
|
+
email: 'quentin.scott@example.com',
|
|
187
|
+
age: 35,
|
|
188
|
+
department: 'Engineering',
|
|
189
|
+
salary: 76000
|
|
190
|
+
}, {
|
|
191
|
+
id: 20,
|
|
192
|
+
name: 'Rachel Adams',
|
|
193
|
+
email: 'rachel.adams@example.com',
|
|
194
|
+
age: 30,
|
|
195
|
+
department: 'HR',
|
|
196
|
+
salary: 64000
|
|
197
|
+
}];
|
|
198
|
+
|
|
199
|
+
// Sample column configurations
|
|
200
|
+
var basicColumnConfigs = [{
|
|
201
|
+
name: 'Name',
|
|
202
|
+
selector: function selector(row) {
|
|
203
|
+
return row.name;
|
|
204
|
+
},
|
|
205
|
+
sortable: true,
|
|
206
|
+
width: '200px'
|
|
207
|
+
}, {
|
|
208
|
+
name: 'Email',
|
|
209
|
+
selector: function selector(row) {
|
|
210
|
+
return row.email;
|
|
211
|
+
},
|
|
212
|
+
sortable: true,
|
|
213
|
+
width: '250px'
|
|
214
|
+
}, {
|
|
215
|
+
name: 'Age',
|
|
216
|
+
selector: function selector(row) {
|
|
217
|
+
return row.age;
|
|
218
|
+
},
|
|
219
|
+
sortable: true,
|
|
220
|
+
width: '100px'
|
|
221
|
+
}, {
|
|
222
|
+
name: 'Department',
|
|
223
|
+
selector: function selector(row) {
|
|
224
|
+
return row.department;
|
|
225
|
+
},
|
|
226
|
+
sortable: true,
|
|
227
|
+
width: '150px'
|
|
228
|
+
}, {
|
|
229
|
+
name: 'Salary',
|
|
230
|
+
selector: function selector(row) {
|
|
231
|
+
return "$".concat(row.salary.toLocaleString());
|
|
232
|
+
},
|
|
233
|
+
sortable: true,
|
|
234
|
+
width: '120px'
|
|
235
|
+
}];
|
|
236
|
+
var postsColumnConfigs = [{
|
|
237
|
+
name: 'Post ID',
|
|
238
|
+
selector: function selector(row) {
|
|
239
|
+
return row.id;
|
|
240
|
+
},
|
|
241
|
+
sortable: true,
|
|
242
|
+
width: '100px'
|
|
243
|
+
}, {
|
|
244
|
+
name: 'Title',
|
|
245
|
+
selector: function selector(row) {
|
|
246
|
+
return row.title;
|
|
247
|
+
},
|
|
248
|
+
sortable: true,
|
|
249
|
+
width: '300px',
|
|
250
|
+
cell: function cell(row) {
|
|
251
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
252
|
+
style: {
|
|
253
|
+
fontWeight: '500',
|
|
254
|
+
color: '#2c3e50',
|
|
255
|
+
lineHeight: '1.4'
|
|
256
|
+
}
|
|
257
|
+
}, row.title);
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
name: 'Body',
|
|
261
|
+
selector: function selector(row) {
|
|
262
|
+
return row.body;
|
|
263
|
+
},
|
|
264
|
+
sortable: true,
|
|
265
|
+
width: '400px',
|
|
266
|
+
cell: function cell(row) {
|
|
267
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
268
|
+
style: {
|
|
269
|
+
color: '#666',
|
|
270
|
+
fontSize: '13px',
|
|
271
|
+
lineHeight: '1.3',
|
|
272
|
+
maxHeight: '60px',
|
|
273
|
+
overflow: 'hidden',
|
|
274
|
+
textOverflow: 'ellipsis'
|
|
275
|
+
}
|
|
276
|
+
}, row.body);
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
name: 'User ID',
|
|
280
|
+
selector: function selector(row) {
|
|
281
|
+
return row.userId;
|
|
282
|
+
},
|
|
283
|
+
sortable: true,
|
|
284
|
+
width: '100px',
|
|
285
|
+
cell: function cell(row) {
|
|
286
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
287
|
+
style: {
|
|
288
|
+
padding: '4px 8px',
|
|
289
|
+
borderRadius: '12px',
|
|
290
|
+
fontSize: '12px',
|
|
291
|
+
fontWeight: '500',
|
|
292
|
+
backgroundColor: '#e3f2fd',
|
|
293
|
+
color: '#1976d2'
|
|
294
|
+
}
|
|
295
|
+
}, "User ", row.userId);
|
|
296
|
+
}
|
|
297
|
+
}];
|
|
298
|
+
var _default = exports["default"] = {
|
|
299
|
+
title: 'Components/Table',
|
|
300
|
+
component: _Table["default"],
|
|
301
|
+
parameters: {
|
|
302
|
+
layout: 'padded',
|
|
303
|
+
docs: {
|
|
304
|
+
description: {
|
|
305
|
+
component: 'A comprehensive table component that supports client-side and server-side pagination, sorting, searching, expandable rows, and more.'
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
tags: ['autodocs'],
|
|
310
|
+
argTypes: {
|
|
311
|
+
records: {
|
|
312
|
+
control: 'object',
|
|
313
|
+
description: 'Array of data records to display in the table'
|
|
314
|
+
},
|
|
315
|
+
columnConfigs: {
|
|
316
|
+
control: 'object',
|
|
317
|
+
description: 'Array of column configurations defining table structure'
|
|
318
|
+
},
|
|
319
|
+
paginationType: {
|
|
320
|
+
control: 'select',
|
|
321
|
+
options: ['', 'CLIENT', 'SERVER'],
|
|
322
|
+
description: 'Type of pagination to use (empty for no pagination)'
|
|
323
|
+
},
|
|
324
|
+
pagination: {
|
|
325
|
+
control: 'boolean',
|
|
326
|
+
description: 'Whether to show pagination controls'
|
|
327
|
+
},
|
|
328
|
+
expandableRows: {
|
|
329
|
+
control: 'boolean',
|
|
330
|
+
description: 'Whether rows can be expanded to show additional content'
|
|
331
|
+
},
|
|
332
|
+
selectableRows: {
|
|
333
|
+
control: 'boolean',
|
|
334
|
+
description: 'Whether rows can be selected with checkboxes'
|
|
335
|
+
},
|
|
336
|
+
showSelectableRows: {
|
|
337
|
+
control: 'boolean',
|
|
338
|
+
description: 'Whether to show selectable rows with checkboxes'
|
|
339
|
+
},
|
|
340
|
+
customClassName: {
|
|
341
|
+
control: 'text',
|
|
342
|
+
description: 'Additional CSS classes for styling'
|
|
343
|
+
},
|
|
344
|
+
noDataDescription: {
|
|
345
|
+
control: 'text',
|
|
346
|
+
description: 'Description text shown when no data is available'
|
|
347
|
+
},
|
|
348
|
+
noDataHeading: {
|
|
349
|
+
control: 'text',
|
|
350
|
+
description: 'Heading text shown when no data is available'
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}; // Template for stories
|
|
354
|
+
var Template = function Template(args) {
|
|
355
|
+
return /*#__PURE__*/_react["default"].createElement(_Table["default"], args);
|
|
55
356
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/* eslint-enable react/prop-types */
|
|
68
|
-
}, {
|
|
69
|
-
label: "first_name",
|
|
70
|
-
key: "name",
|
|
71
|
-
sortable: true,
|
|
72
|
-
valueFormatter: function valueFormatter(_ref3) {
|
|
73
|
-
var record = _ref3.record;
|
|
74
|
-
var first_name = record.first_name,
|
|
75
|
-
last_name = record.last_name;
|
|
76
|
-
return "".concat(first_name, " ").concat(last_name);
|
|
77
|
-
}
|
|
78
|
-
}];
|
|
79
|
-
return columnConfigs;
|
|
357
|
+
|
|
358
|
+
// Basic table with client-side pagination
|
|
359
|
+
var Default = exports.Default = Template.bind({});
|
|
360
|
+
Default.args = {
|
|
361
|
+
records: sampleRecords,
|
|
362
|
+
columnConfigs: basicColumnConfigs,
|
|
363
|
+
paginationType: 'CLIENT',
|
|
364
|
+
pagination: true,
|
|
365
|
+
customClassName: 'custom-table'
|
|
80
366
|
};
|
|
81
367
|
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
todoData = _useState2[0],
|
|
90
|
-
setTodoData = _useState2[1];
|
|
91
|
-
var title = todoData.title,
|
|
92
|
-
completed = todoData.completed;
|
|
93
|
-
_dataLoader["default"].addRequestConfig("getTodoById", {
|
|
94
|
-
method: "GET",
|
|
95
|
-
url: function url(params) {
|
|
96
|
-
return "https://jsonplaceholder.typicode.com/todos/".concat(params.id);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
var onDataLoaded = function onDataLoaded(_ref4) {
|
|
100
|
-
var _ref5 = _slicedToArray(_ref4, 1),
|
|
101
|
-
todoData = _ref5[0];
|
|
102
|
-
setTodoData(todoData);
|
|
103
|
-
};
|
|
104
|
-
var requests = [{
|
|
105
|
-
requestId: "getTodoById",
|
|
106
|
-
urlParams: {
|
|
107
|
-
id: id
|
|
108
|
-
}
|
|
109
|
-
}];
|
|
110
|
-
return /*#__PURE__*/_react["default"].createElement(_DataLoader["default"], {
|
|
111
|
-
requests: requests,
|
|
112
|
-
onDataLoaded: onDataLoaded
|
|
113
|
-
}, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("b", null, "Title:"), " ", title, " "), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("b", null, "Status:"), " ", completed ? "Completed" : "Not Completed", " "));
|
|
368
|
+
// Table without pagination
|
|
369
|
+
var NoPagination = exports.NoPagination = Template.bind({});
|
|
370
|
+
NoPagination.args = {
|
|
371
|
+
records: sampleRecords,
|
|
372
|
+
columnConfigs: basicColumnConfigs,
|
|
373
|
+
pagination: false,
|
|
374
|
+
customClassName: 'custom-table'
|
|
114
375
|
};
|
|
115
|
-
/* eslint-enable react/prop-types */
|
|
116
376
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
377
|
+
// Table with custom styling
|
|
378
|
+
var CustomStyling = exports.CustomStyling = Template.bind({});
|
|
379
|
+
CustomStyling.args = {
|
|
380
|
+
records: sampleRecords,
|
|
381
|
+
columnConfigs: basicColumnConfigs,
|
|
382
|
+
paginationType: 'CLIENT',
|
|
383
|
+
pagination: true,
|
|
384
|
+
customClassName: 'custom-table-styled'
|
|
122
385
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
386
|
+
|
|
387
|
+
// Table with no data
|
|
388
|
+
var NoDataDefault = exports.NoDataDefault = Template.bind({});
|
|
389
|
+
NoDataDefault.args = {
|
|
390
|
+
records: [],
|
|
391
|
+
columnConfigs: basicColumnConfigs,
|
|
392
|
+
paginationType: 'CLIENT',
|
|
393
|
+
pagination: true,
|
|
394
|
+
customClassName: 'custom-table'
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// Table with custom no data component
|
|
398
|
+
var CustomNoDataComponent = exports.CustomNoDataComponent = function CustomNoDataComponent() {
|
|
399
|
+
var _useState = (0, _react.useState)(false),
|
|
400
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
401
|
+
hasData = _useState2[0],
|
|
402
|
+
setHasData = _useState2[1];
|
|
403
|
+
var CustomNoData = function CustomNoData(_ref2) {
|
|
404
|
+
var description = _ref2.description,
|
|
405
|
+
heading = _ref2.heading;
|
|
406
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
407
|
+
style: {
|
|
408
|
+
padding: '40px 20px',
|
|
409
|
+
textAlign: 'center',
|
|
410
|
+
backgroundColor: '#f8f9fa',
|
|
411
|
+
borderRadius: '8px',
|
|
412
|
+
border: '2px dashed #dee2e6',
|
|
413
|
+
margin: '20px'
|
|
414
|
+
}
|
|
415
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
416
|
+
style: {
|
|
417
|
+
fontSize: '48px',
|
|
418
|
+
color: '#6c757d',
|
|
419
|
+
marginBottom: '16px'
|
|
420
|
+
}
|
|
421
|
+
}, "\uD83D\uDCCA"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
422
|
+
style: {
|
|
423
|
+
fontSize: '20px',
|
|
424
|
+
fontWeight: 'bold',
|
|
425
|
+
color: '#495057',
|
|
426
|
+
marginBottom: '8px'
|
|
427
|
+
}
|
|
428
|
+
}, heading || 'No Data Available'), /*#__PURE__*/_react["default"].createElement("div", {
|
|
429
|
+
style: {
|
|
430
|
+
fontSize: '14px',
|
|
431
|
+
color: '#6c757d',
|
|
432
|
+
marginBottom: '20px',
|
|
433
|
+
lineHeight: '1.5'
|
|
434
|
+
}
|
|
435
|
+
}, description || 'There are no records to display at the moment.'), /*#__PURE__*/_react["default"].createElement("div", {
|
|
436
|
+
style: {
|
|
437
|
+
display: 'flex',
|
|
438
|
+
gap: '12px',
|
|
439
|
+
justifyContent: 'center',
|
|
440
|
+
flexWrap: 'wrap'
|
|
441
|
+
}
|
|
442
|
+
}));
|
|
443
|
+
};
|
|
444
|
+
var CustomNoDataWithIcon = function CustomNoDataWithIcon(_ref3) {
|
|
445
|
+
var description = _ref3.description,
|
|
446
|
+
heading = _ref3.heading;
|
|
447
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
448
|
+
style: {
|
|
449
|
+
padding: '60px 20px',
|
|
450
|
+
textAlign: 'center',
|
|
451
|
+
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
452
|
+
borderRadius: '12px',
|
|
453
|
+
color: 'white',
|
|
454
|
+
margin: '20px'
|
|
455
|
+
}
|
|
456
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
457
|
+
style: {
|
|
458
|
+
fontSize: '64px',
|
|
459
|
+
marginBottom: '16px'
|
|
460
|
+
}
|
|
461
|
+
}, "\uD83D\uDD0D"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
462
|
+
style: {
|
|
463
|
+
fontSize: '24px',
|
|
464
|
+
fontWeight: 'bold',
|
|
465
|
+
marginBottom: '12px'
|
|
466
|
+
}
|
|
467
|
+
}, heading || 'No Results Found'), /*#__PURE__*/_react["default"].createElement("div", {
|
|
468
|
+
style: {
|
|
469
|
+
fontSize: '16px',
|
|
470
|
+
opacity: '0.9',
|
|
471
|
+
marginBottom: '24px',
|
|
472
|
+
lineHeight: '1.6'
|
|
473
|
+
}
|
|
474
|
+
}, description || 'We couldn\'t find any data matching your criteria.'), /*#__PURE__*/_react["default"].createElement("div", {
|
|
475
|
+
style: {
|
|
476
|
+
display: 'flex',
|
|
477
|
+
gap: '16px',
|
|
478
|
+
justifyContent: 'center',
|
|
479
|
+
flexWrap: 'wrap'
|
|
480
|
+
}
|
|
481
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
482
|
+
onClick: function onClick() {
|
|
483
|
+
return setHasData(true);
|
|
484
|
+
},
|
|
485
|
+
style: {
|
|
486
|
+
padding: '12px 24px',
|
|
487
|
+
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
|
488
|
+
color: 'white',
|
|
489
|
+
border: '2px solid rgba(255, 255, 255, 0.3)',
|
|
490
|
+
borderRadius: '8px',
|
|
491
|
+
cursor: 'pointer',
|
|
492
|
+
fontSize: '14px',
|
|
493
|
+
fontWeight: '500',
|
|
494
|
+
transition: 'all 0.3s ease'
|
|
495
|
+
},
|
|
496
|
+
onMouseOver: function onMouseOver(e) {
|
|
497
|
+
e.target.style.backgroundColor = 'rgba(255, 255, 255, 0.3)';
|
|
498
|
+
e.target.style.borderColor = 'rgba(255, 255, 255, 0.5)';
|
|
499
|
+
},
|
|
500
|
+
onMouseOut: function onMouseOut(e) {
|
|
501
|
+
e.target.style.backgroundColor = 'rgba(255, 255, 255, 0.2)';
|
|
502
|
+
e.target.style.borderColor = 'rgba(255, 255, 255, 0.3)';
|
|
503
|
+
}
|
|
504
|
+
}, "Try Again"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
505
|
+
onClick: function onClick() {
|
|
506
|
+
return setHasData(false);
|
|
507
|
+
},
|
|
508
|
+
style: {
|
|
509
|
+
padding: '12px 24px',
|
|
510
|
+
backgroundColor: 'transparent',
|
|
511
|
+
color: 'white',
|
|
512
|
+
border: '2px solid rgba(255, 255, 255, 0.3)',
|
|
513
|
+
borderRadius: '8px',
|
|
514
|
+
cursor: 'pointer',
|
|
515
|
+
fontSize: '14px',
|
|
516
|
+
fontWeight: '500',
|
|
517
|
+
transition: 'all 0.3s ease'
|
|
518
|
+
},
|
|
519
|
+
onMouseOver: function onMouseOver(e) {
|
|
520
|
+
e.target.style.backgroundColor = 'rgba(255, 255, 255, 0.1)';
|
|
521
|
+
},
|
|
522
|
+
onMouseOut: function onMouseOut(e) {
|
|
523
|
+
e.target.style.backgroundColor = 'transparent';
|
|
524
|
+
}
|
|
525
|
+
}, "Clear")));
|
|
526
|
+
};
|
|
527
|
+
var CustomNoDataMinimal = function CustomNoDataMinimal(_ref4) {
|
|
528
|
+
var description = _ref4.description,
|
|
529
|
+
heading = _ref4.heading;
|
|
530
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
531
|
+
style: {
|
|
532
|
+
padding: '80px 20px',
|
|
533
|
+
textAlign: 'center',
|
|
534
|
+
backgroundColor: '#ffffff',
|
|
535
|
+
borderRadius: '8px',
|
|
536
|
+
border: '1px solid #e9ecef',
|
|
537
|
+
margin: '20px'
|
|
538
|
+
}
|
|
539
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
540
|
+
style: {
|
|
541
|
+
width: '80px',
|
|
542
|
+
height: '80px',
|
|
543
|
+
margin: '0 auto 24px',
|
|
544
|
+
borderRadius: '50%',
|
|
545
|
+
backgroundColor: '#f8f9fa',
|
|
546
|
+
display: 'flex',
|
|
547
|
+
alignItems: 'center',
|
|
548
|
+
justifyContent: 'center',
|
|
549
|
+
fontSize: '32px',
|
|
550
|
+
color: '#adb5bd'
|
|
551
|
+
}
|
|
552
|
+
}, "\uD83D\uDCCB"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
553
|
+
style: {
|
|
554
|
+
fontSize: '18px',
|
|
555
|
+
fontWeight: '600',
|
|
556
|
+
color: '#343a40',
|
|
557
|
+
marginBottom: '8px'
|
|
558
|
+
}
|
|
559
|
+
}, heading || 'Empty State'), /*#__PURE__*/_react["default"].createElement("div", {
|
|
560
|
+
style: {
|
|
561
|
+
fontSize: '14px',
|
|
562
|
+
color: '#6c757d',
|
|
563
|
+
marginBottom: '32px',
|
|
564
|
+
maxWidth: '300px',
|
|
565
|
+
marginLeft: 'auto',
|
|
566
|
+
marginRight: 'auto',
|
|
567
|
+
lineHeight: '1.5'
|
|
568
|
+
}
|
|
569
|
+
}, description || 'This table is currently empty. Add some data to get started.'), /*#__PURE__*/_react["default"].createElement("button", {
|
|
570
|
+
onClick: function onClick() {
|
|
571
|
+
return setHasData(true);
|
|
572
|
+
},
|
|
573
|
+
style: {
|
|
574
|
+
padding: '10px 20px',
|
|
575
|
+
backgroundColor: '#007bff',
|
|
576
|
+
color: 'white',
|
|
577
|
+
border: 'none',
|
|
578
|
+
borderRadius: '6px',
|
|
579
|
+
cursor: 'pointer',
|
|
580
|
+
fontSize: '14px',
|
|
581
|
+
fontWeight: '500',
|
|
582
|
+
transition: 'background-color 0.2s ease'
|
|
583
|
+
},
|
|
584
|
+
onMouseOver: function onMouseOver(e) {
|
|
585
|
+
e.target.style.backgroundColor = '#0056b3';
|
|
586
|
+
},
|
|
587
|
+
onMouseOut: function onMouseOut(e) {
|
|
588
|
+
e.target.style.backgroundColor = '#007bff';
|
|
589
|
+
}
|
|
590
|
+
}, "Add Sample Data"));
|
|
591
|
+
};
|
|
592
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
593
|
+
style: {
|
|
594
|
+
marginBottom: '2rem'
|
|
595
|
+
}
|
|
596
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
597
|
+
style: {
|
|
598
|
+
marginTop: '1rem',
|
|
599
|
+
display: 'flex',
|
|
600
|
+
gap: '1rem',
|
|
601
|
+
flexWrap: 'wrap'
|
|
602
|
+
}
|
|
603
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
604
|
+
style: {
|
|
605
|
+
marginBottom: '3rem'
|
|
606
|
+
}
|
|
607
|
+
}, /*#__PURE__*/_react["default"].createElement("h4", {
|
|
608
|
+
style: {
|
|
609
|
+
marginBottom: '1rem',
|
|
610
|
+
color: '#495057'
|
|
611
|
+
}
|
|
612
|
+
}, "Custom No Data Component"), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
|
|
613
|
+
records: hasData ? sampleRecords : [],
|
|
614
|
+
columnConfigs: basicColumnConfigs,
|
|
615
|
+
paginationType: "CLIENT",
|
|
616
|
+
pagination: true,
|
|
617
|
+
customClassName: "custom-table",
|
|
618
|
+
CustomNoDataComponent: CustomNoData
|
|
619
|
+
})));
|
|
130
620
|
};
|
|
131
|
-
|
|
132
|
-
|
|
621
|
+
|
|
622
|
+
// Interactive example with state management
|
|
623
|
+
var SelectableRows = exports.SelectableRows = function SelectableRows() {
|
|
624
|
+
var _useState3 = (0, _react.useState)([]),
|
|
133
625
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var
|
|
137
|
-
|
|
626
|
+
selectedRows = _useState4[0],
|
|
627
|
+
setSelectedRows = _useState4[1];
|
|
628
|
+
var handleSelectionChange = function handleSelectionChange(rows) {
|
|
629
|
+
setSelectedRows(rows);
|
|
630
|
+
console.log('Selected rows:', rows);
|
|
138
631
|
};
|
|
139
|
-
|
|
632
|
+
|
|
633
|
+
// Create a mock API response formatter for the sample data
|
|
634
|
+
var responseFormatter = function responseFormatter(response) {
|
|
140
635
|
return {
|
|
141
|
-
|
|
636
|
+
entries: response || [],
|
|
637
|
+
total: response ? 20 : 0
|
|
142
638
|
};
|
|
143
|
-
}
|
|
144
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
639
|
+
};
|
|
640
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
641
|
+
style: {
|
|
642
|
+
marginBottom: '1rem'
|
|
643
|
+
}
|
|
644
|
+
}, /*#__PURE__*/_react["default"].createElement("h3", null, "Table with Selectable Rows"), /*#__PURE__*/_react["default"].createElement("p", null, "This table allows you to select rows using checkboxes with server-side implementation."), selectedRows.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
|
|
645
|
+
style: {
|
|
646
|
+
marginTop: '8px',
|
|
647
|
+
padding: '8px 12px',
|
|
648
|
+
backgroundColor: '#e3f2fd',
|
|
649
|
+
borderRadius: '4px',
|
|
650
|
+
fontSize: '14px'
|
|
651
|
+
}
|
|
652
|
+
}, "Selected: ", selectedRows.length, " row(s) with ids - ", selectedRows.map(function (row) {
|
|
653
|
+
return row.id;
|
|
654
|
+
}).join(', '))), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
|
|
655
|
+
columnConfigs: postsColumnConfigs,
|
|
656
|
+
paginationType: "SERVER",
|
|
657
|
+
pagination: true,
|
|
658
|
+
showSelectableRows: true,
|
|
659
|
+
setSelectedRow: handleSelectionChange,
|
|
660
|
+
CheckBoxRow: CustomCheckBoxRow,
|
|
661
|
+
customClassName: "custom-table",
|
|
662
|
+
apiInfo: {
|
|
663
|
+
pageNoKey: '_page',
|
|
664
|
+
perPageKey: '_limit',
|
|
665
|
+
searchBy: 'q',
|
|
666
|
+
requestId: 'getPosts',
|
|
667
|
+
responseFormatter: responseFormatter,
|
|
668
|
+
requestParam: {
|
|
669
|
+
_page: 1,
|
|
670
|
+
_limit: 10,
|
|
671
|
+
q: ''
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
onApiError: function onApiError(error) {
|
|
675
|
+
return console.error('API Error:', error);
|
|
676
|
+
}
|
|
152
677
|
}));
|
|
153
678
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
679
|
+
|
|
680
|
+
// Table with custom column formatting
|
|
681
|
+
var CustomColumnFormatting = exports.CustomColumnFormatting = Template.bind({});
|
|
682
|
+
CustomColumnFormatting.args = {
|
|
683
|
+
records: sampleRecords,
|
|
684
|
+
columnConfigs: [{
|
|
685
|
+
name: 'Employee Name',
|
|
686
|
+
sortable: true,
|
|
687
|
+
cell: function cell(row) {
|
|
688
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
689
|
+
style: {
|
|
690
|
+
display: 'flex',
|
|
691
|
+
alignItems: 'center',
|
|
692
|
+
gap: '8px'
|
|
693
|
+
}
|
|
694
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
695
|
+
style: {
|
|
696
|
+
width: '32px',
|
|
697
|
+
height: '32px',
|
|
698
|
+
borderRadius: '50%',
|
|
699
|
+
backgroundColor: '#007bff',
|
|
700
|
+
display: 'flex',
|
|
701
|
+
alignItems: 'center',
|
|
702
|
+
justifyContent: 'center',
|
|
703
|
+
color: 'white',
|
|
704
|
+
fontSize: '14px',
|
|
705
|
+
fontWeight: 'bold'
|
|
706
|
+
}
|
|
707
|
+
}, row.name.charAt(0)), /*#__PURE__*/_react["default"].createElement("span", null, row.name));
|
|
708
|
+
},
|
|
709
|
+
width: '200px'
|
|
710
|
+
}, {
|
|
711
|
+
name: 'Email',
|
|
712
|
+
selector: function selector(row) {
|
|
713
|
+
return row.email;
|
|
714
|
+
},
|
|
715
|
+
sortable: true,
|
|
716
|
+
width: '250px'
|
|
717
|
+
}, {
|
|
718
|
+
name: 'Department',
|
|
719
|
+
selector: function selector(row) {
|
|
720
|
+
return row.department;
|
|
721
|
+
},
|
|
722
|
+
sortable: true,
|
|
723
|
+
cell: function cell(row) {
|
|
724
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
725
|
+
style: {
|
|
726
|
+
padding: '4px 8px',
|
|
727
|
+
borderRadius: '12px',
|
|
728
|
+
fontSize: '12px',
|
|
729
|
+
fontWeight: '500',
|
|
730
|
+
backgroundColor: row.department === 'Engineering' ? '#e3f2fd' : row.department === 'Marketing' ? '#f3e5f5' : row.department === 'Sales' ? '#e8f5e8' : '#fff3e0',
|
|
731
|
+
color: row.department === 'Engineering' ? '#1976d2' : row.department === 'Marketing' ? '#7b1fa2' : row.department === 'Sales' ? '#388e3c' : '#f57c00'
|
|
732
|
+
}
|
|
733
|
+
}, row.department);
|
|
734
|
+
},
|
|
735
|
+
width: '150px'
|
|
736
|
+
}, {
|
|
737
|
+
name: 'Salary',
|
|
738
|
+
selector: function selector(row) {
|
|
739
|
+
return row.salary;
|
|
740
|
+
},
|
|
741
|
+
sortable: true,
|
|
742
|
+
cell: function cell(row) {
|
|
743
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
744
|
+
style: {
|
|
745
|
+
fontWeight: 'bold',
|
|
746
|
+
color: row.salary > 75000 ? '#4caf50' : '#ff9800'
|
|
747
|
+
}
|
|
748
|
+
}, "$", row.salary.toLocaleString());
|
|
749
|
+
},
|
|
750
|
+
width: '120px'
|
|
751
|
+
}],
|
|
752
|
+
paginationType: 'CLIENT',
|
|
753
|
+
pagination: true,
|
|
754
|
+
customClassName: 'custom-table'
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
// Table with different pagination positions
|
|
758
|
+
var BottomPagination = exports.BottomPagination = Template.bind({});
|
|
759
|
+
BottomPagination.args = {
|
|
760
|
+
records: sampleRecords,
|
|
761
|
+
columnConfigs: basicColumnConfigs,
|
|
762
|
+
paginationType: 'CLIENT',
|
|
763
|
+
pagination: true,
|
|
764
|
+
customClassName: 'custom-table bottom-pagination'
|
|
160
765
|
};
|
|
161
|
-
|
|
162
|
-
|
|
766
|
+
|
|
767
|
+
// Server-side table with posts data
|
|
768
|
+
var ServerSidePagination = exports.ServerSidePagination = function ServerSidePagination() {
|
|
769
|
+
var _useState5 = (0, _react.useState)([]),
|
|
163
770
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var onSearchChange = function onSearchChange(value) {
|
|
171
|
-
setSearchBy(value);
|
|
172
|
-
};
|
|
771
|
+
selectedRows = _useState6[0],
|
|
772
|
+
setSelectedRows = _useState6[1];
|
|
773
|
+
var _useState7 = (0, _react.useState)(false),
|
|
774
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
775
|
+
refreshTrigger = _useState8[0],
|
|
776
|
+
setRefreshTrigger = _useState8[1];
|
|
173
777
|
var responseFormatter = function responseFormatter(response) {
|
|
174
|
-
return
|
|
175
|
-
entries: response
|
|
176
|
-
|
|
778
|
+
return {
|
|
779
|
+
entries: response || [],
|
|
780
|
+
total: response ? 30 : 0
|
|
781
|
+
};
|
|
782
|
+
};
|
|
783
|
+
var handleRefresh = function handleRefresh() {
|
|
784
|
+
setRefreshTrigger(!refreshTrigger);
|
|
177
785
|
};
|
|
178
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
786
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
787
|
+
style: {
|
|
788
|
+
marginBottom: '1rem'
|
|
789
|
+
}
|
|
790
|
+
}, /*#__PURE__*/_react["default"].createElement("h3", null, "Server-Side Posts Table"), /*#__PURE__*/_react["default"].createElement("p", null, "This table fetches posts data from JSONPlaceholder API with custom formatting."), /*#__PURE__*/_react["default"].createElement("div", {
|
|
791
|
+
style: {
|
|
792
|
+
display: 'flex',
|
|
793
|
+
gap: '1rem',
|
|
794
|
+
alignItems: 'center',
|
|
795
|
+
marginTop: '8px'
|
|
796
|
+
}
|
|
797
|
+
}, selectedRows.length > 0 && /*#__PURE__*/_react["default"].createElement("span", {
|
|
798
|
+
style: {
|
|
799
|
+
fontSize: '14px',
|
|
800
|
+
color: '#666'
|
|
801
|
+
}
|
|
802
|
+
}, "Selected: ", selectedRows.length, " post(s)"))), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
|
|
803
|
+
columnConfigs: postsColumnConfigs,
|
|
183
804
|
paginationType: "SERVER",
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
805
|
+
pagination: true,
|
|
806
|
+
showSelectableRows: true,
|
|
807
|
+
setSelectedRow: setSelectedRows,
|
|
808
|
+
CheckBoxRow: CustomCheckBoxRow,
|
|
809
|
+
refreshData: refreshTrigger,
|
|
810
|
+
customClassName: "custom-table",
|
|
811
|
+
apiInfo: {
|
|
812
|
+
pageNoKey: '_page',
|
|
813
|
+
perPageKey: '_limit',
|
|
814
|
+
searchBy: 'q',
|
|
815
|
+
requestId: 'getPosts',
|
|
816
|
+
responseFormatter: responseFormatter
|
|
817
|
+
},
|
|
818
|
+
onApiError: function onApiError(error) {
|
|
819
|
+
return console.error('API Error:', error);
|
|
820
|
+
}
|
|
188
821
|
}));
|
|
189
822
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
823
|
+
|
|
824
|
+
// Table with refresh functionality
|
|
825
|
+
var RefreshTable = exports.RefreshTable = function RefreshTable() {
|
|
826
|
+
var _useState9 = (0, _react.useState)(sampleRecords),
|
|
827
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
828
|
+
data = _useState0[0],
|
|
829
|
+
setData = _useState0[1];
|
|
830
|
+
var _useState1 = (0, _react.useState)(0),
|
|
831
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
832
|
+
refreshCount = _useState10[0],
|
|
833
|
+
setRefreshCount = _useState10[1];
|
|
834
|
+
var handleRefresh = function handleRefresh() {
|
|
835
|
+
setRefreshCount(function (prev) {
|
|
836
|
+
return prev + 1;
|
|
837
|
+
});
|
|
838
|
+
// Simulate data refresh
|
|
839
|
+
setData([].concat(sampleRecords).sort(function () {
|
|
840
|
+
return Math.random() - 0.5;
|
|
841
|
+
}));
|
|
842
|
+
};
|
|
843
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
844
|
+
style: {
|
|
845
|
+
marginBottom: '1rem'
|
|
195
846
|
}
|
|
196
|
-
}
|
|
847
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
848
|
+
onClick: handleRefresh,
|
|
849
|
+
style: {
|
|
850
|
+
padding: '8px 16px',
|
|
851
|
+
backgroundColor: '#28a745',
|
|
852
|
+
color: 'white',
|
|
853
|
+
border: 'none',
|
|
854
|
+
borderRadius: '4px',
|
|
855
|
+
cursor: 'pointer'
|
|
856
|
+
}
|
|
857
|
+
}, "Refresh Data (Refresh Count: ", refreshCount, ")")), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
|
|
858
|
+
records: data,
|
|
859
|
+
columnConfigs: basicColumnConfigs,
|
|
860
|
+
paginationType: "CLIENT",
|
|
861
|
+
pagination: true,
|
|
862
|
+
refreshData: refreshCount,
|
|
863
|
+
customClassName: "custom-table"
|
|
864
|
+
}));
|
|
197
865
|
};
|