hrnet-datatable-tiago 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,84 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # hrnet-datatable
2
+
3
+ A React datatable component with search, multi-column sort, and pagination. Built as part of the WealthHealth HRnet project (OpenClassrooms P12).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install hrnet-datatable
9
+ ```
10
+
11
+ Requires React 18 or higher as a peer dependency.
12
+
13
+ ## Usage
14
+
15
+ ```jsx
16
+ import { DataTable } from "hrnet-datatable";
17
+
18
+ const columns = [
19
+ { key: "firstName", label: "First Name" },
20
+ { key: "lastName", label: "Last Name" },
21
+ { key: "startDate", label: "Start Date" },
22
+ { key: "department", label: "Department" },
23
+ ];
24
+
25
+ function EmployeeList({ employees }) {
26
+ return <DataTable data={employees} columns={columns} />;
27
+ }
28
+ ```
29
+
30
+ ## Props
31
+
32
+ | Prop | Type | Required | Description |
33
+ | --------- | ------- | -------- | -------------------- |
34
+ | `data` | `array` | yes | Array of row objects |
35
+ | `columns` | `array` | yes | Column definitions |
36
+
37
+ ### Column definition
38
+
39
+ ```js
40
+ { key: "firstName", label: "First Name" }
41
+ ```
42
+
43
+ - `key` — the property name on each row object
44
+ - `label` — the column header text
45
+
46
+ ## Features
47
+
48
+ **Search** — filters across all columns simultaneously. Resets to page 1 on each keystroke.
49
+
50
+ **Multi-column sort** — click a column header to sort ascending, click again for descending, click a third time to remove that sort. When multiple columns are sorted, each header displays a priority number so the order is clear.
51
+
52
+ **Pagination** — choose between 10, 25, 50, or 100 rows per page.
53
+
54
+ **Mobile card layout** — below 1024px the table switches to a card-per-row layout. A row of sort chips replaces the column headers so sorting stays accessible.
55
+
56
+ ## Development
57
+
58
+ This package is built as an ES module library with Vite.
59
+
60
+ ```bash
61
+ npm run dev # dev server (for isolated component development)
62
+ npm run build # build the library to dist/
63
+ npm run test # run unit tests with Vitest
64
+ ```
65
+
66
+ Unit tests cover: initial state, search/filter, sort cycle (asc → desc → removed), multi-column sort with priority ordering, clearSorts, and pagination.
67
+
68
+ ## Local usage without npm publish
69
+
70
+ In a sibling React project, add a Vite alias to point directly at the source:
71
+
72
+ ```js
73
+ // vite.config.js
74
+ import { resolve } from "path";
75
+
76
+ export default defineConfig({
77
+ resolve: {
78
+ alias: {
79
+ "hrnet-datatable": resolve(__dirname, "../hrnet-datatable/src/index.js"),
80
+ },
81
+ dedupe: ["react", "react-dom"],
82
+ },
83
+ });
84
+ ```
@@ -0,0 +1 @@
1
+ .global-container{width:100%;padding:0 24px 24px;overflow-x:auto}.datatable-controls{display:flex;justify-content:space-between;align-items:center;padding:16px 0 8px;gap:16px}.page-size-control{display:flex;align-items:center;gap:8px;font-size:14px}.page-size-control select{font-size:14px;padding:2px 4px;cursor:pointer;outline:none}.clear-sorts-btn{padding:4px 12px;border-radius:4px;font-size:13px;cursor:pointer;border:1px solid #c0392b;color:#c0392b;background:transparent;transition:background .15s,color .15s;white-space:nowrap}.clear-sorts-btn:hover{background:#c0392b;color:#fff}.search-container{display:flex;justify-content:flex-end}.search-container input{padding:6px 4px;width:220px;font-size:16px;outline:none}table{width:100%;border-collapse:collapse;font-size:14px}thead th{padding:10px 12px;text-align:left;font-weight:600;white-space:nowrap;cursor:pointer}.sortable-th{-webkit-user-select:none;user-select:none}.sort-arrow{margin-left:6px;font-size:16px}tbody tr{transition:background .1s ease-in-out}tbody td{padding:10px 12px;white-space:nowrap}.datatable-footer{display:flex;justify-content:space-between;align-items:center;padding:16px 0 8px;gap:16px;flex-wrap:wrap}.datatable-info{font-size:14px}.datatable-pagination{display:flex;align-items:center;gap:4px}.datatable-pagination button{min-width:34px;height:34px;padding:0 8px;font-size:14px;border-radius:3px;cursor:pointer;transition:background .15s,color .15s}.datatable-pagination button:disabled{cursor:not-allowed}.pagination-ellipsis{display:flex;align-items:center;padding:0 4px;font-size:14px;-webkit-user-select:none;user-select:none}.sort-controls{display:none}@media(max-width:1440px){table,thead{font-size:12px}thead th,tbody td{padding:6px}}@media(max-width:1024px){.datatable-controls{flex-direction:column;align-items:stretch;gap:8px}.sort-controls{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 0 4px}.sort-controls-label{font-size:14px;font-weight:600;flex-shrink:0}.sort-chip{padding:4px 12px;border-radius:16px;font-size:13px;cursor:pointer;border:1px solid #aaa;background:transparent;transition:background .15s,color .15s}.sort-chip--active{background:#5b700f;color:#fff;border-color:#5b700f}.search-container input{width:100%}table,tbody,tr,td{display:block;width:100%;font-size:16px}thead{display:none}tr{margin-bottom:12px}td{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;text-align:right}td:before{content:attr(data-label);font-weight:600;text-align:left;flex-shrink:0;padding-right:16px}.datatable-footer{flex-direction:column;align-items:center;gap:12px}}
@@ -0,0 +1,501 @@
1
+ import ne, { useState as q, useMemo as Q } from "react";
2
+ var J = { exports: {} }, F = {};
3
+ /**
4
+ * @license React
5
+ * react-jsx-runtime.production.js
6
+ *
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var K;
13
+ function ae() {
14
+ if (K) return F;
15
+ K = 1;
16
+ var m = Symbol.for("react.transitional.element"), d = Symbol.for("react.fragment");
17
+ function _(g, i, s) {
18
+ var h = null;
19
+ if (s !== void 0 && (h = "" + s), i.key !== void 0 && (h = "" + i.key), "key" in i) {
20
+ s = {};
21
+ for (var b in i)
22
+ b !== "key" && (s[b] = i[b]);
23
+ } else s = i;
24
+ return i = s.ref, {
25
+ $$typeof: m,
26
+ type: g,
27
+ key: h,
28
+ ref: i !== void 0 ? i : null,
29
+ props: s
30
+ };
31
+ }
32
+ return F.Fragment = d, F.jsx = _, F.jsxs = _, F;
33
+ }
34
+ var z = {};
35
+ /**
36
+ * @license React
37
+ * react-jsx-runtime.development.js
38
+ *
39
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
40
+ *
41
+ * This source code is licensed under the MIT license found in the
42
+ * LICENSE file in the root directory of this source tree.
43
+ */
44
+ var ee;
45
+ function se() {
46
+ return ee || (ee = 1, process.env.NODE_ENV !== "production" && (function() {
47
+ function m(e) {
48
+ if (e == null) return null;
49
+ if (typeof e == "function")
50
+ return e.$$typeof === W ? null : e.displayName || e.name || null;
51
+ if (typeof e == "string") return e;
52
+ switch (e) {
53
+ case O:
54
+ return "Fragment";
55
+ case r:
56
+ return "Profiler";
57
+ case S:
58
+ return "StrictMode";
59
+ case p:
60
+ return "Suspense";
61
+ case v:
62
+ return "SuspenseList";
63
+ case G:
64
+ return "Activity";
65
+ case D:
66
+ return "ViewTransition";
67
+ }
68
+ if (typeof e == "object")
69
+ switch (typeof e.tag == "number" && console.error(
70
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
71
+ ), e.$$typeof) {
72
+ case I:
73
+ return "Portal";
74
+ case E:
75
+ return e.displayName || "Context";
76
+ case o:
77
+ return (e._context.displayName || "Context") + ".Consumer";
78
+ case T:
79
+ var t = e.render;
80
+ return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
81
+ case N:
82
+ return t = e.displayName || null, t !== null ? t : m(e.type) || "Memo";
83
+ case f:
84
+ t = e._payload, e = e._init;
85
+ try {
86
+ return m(e(t));
87
+ } catch {
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+ function d(e) {
93
+ return "" + e;
94
+ }
95
+ function _(e) {
96
+ try {
97
+ d(e);
98
+ var t = !1;
99
+ } catch {
100
+ t = !0;
101
+ }
102
+ if (t) {
103
+ t = console;
104
+ var a = t.error, l = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
105
+ return a.call(
106
+ t,
107
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
108
+ l
109
+ ), d(e);
110
+ }
111
+ }
112
+ function g(e) {
113
+ if (e === O) return "<>";
114
+ if (typeof e == "object" && e !== null && e.$$typeof === f)
115
+ return "<...>";
116
+ try {
117
+ var t = m(e);
118
+ return t ? "<" + t + ">" : "<...>";
119
+ } catch {
120
+ return "<...>";
121
+ }
122
+ }
123
+ function i() {
124
+ var e = y.A;
125
+ return e === null ? null : e.getOwner();
126
+ }
127
+ function s() {
128
+ return Error("react-stack-top-frame");
129
+ }
130
+ function h(e) {
131
+ if (P.call(e, "key")) {
132
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
133
+ if (t && t.isReactWarning) return !1;
134
+ }
135
+ return e.key !== void 0;
136
+ }
137
+ function b(e, t) {
138
+ function a() {
139
+ U || (U = !0, console.error(
140
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
141
+ t
142
+ ));
143
+ }
144
+ a.isReactWarning = !0, Object.defineProperty(e, "key", {
145
+ get: a,
146
+ configurable: !0
147
+ });
148
+ }
149
+ function u() {
150
+ var e = m(this.type);
151
+ return V[e] || (V[e] = !0, console.error(
152
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
153
+ )), e = this.props.ref, e !== void 0 ? e : null;
154
+ }
155
+ function A(e, t, a, l, w, j) {
156
+ var c = a.ref;
157
+ return e = {
158
+ $$typeof: R,
159
+ type: e,
160
+ key: t,
161
+ props: a,
162
+ _owner: l
163
+ }, (c !== void 0 ? c : null) !== null ? Object.defineProperty(e, "ref", {
164
+ enumerable: !1,
165
+ get: u
166
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
167
+ configurable: !1,
168
+ enumerable: !1,
169
+ writable: !0,
170
+ value: 0
171
+ }), Object.defineProperty(e, "_debugInfo", {
172
+ configurable: !1,
173
+ enumerable: !1,
174
+ writable: !0,
175
+ value: null
176
+ }), Object.defineProperty(e, "_debugStack", {
177
+ configurable: !1,
178
+ enumerable: !1,
179
+ writable: !0,
180
+ value: w
181
+ }), Object.defineProperty(e, "_debugTask", {
182
+ configurable: !1,
183
+ enumerable: !1,
184
+ writable: !0,
185
+ value: j
186
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
187
+ }
188
+ function C(e, t, a, l, w, j) {
189
+ var c = t.children;
190
+ if (c !== void 0)
191
+ if (l)
192
+ if (L(c)) {
193
+ for (l = 0; l < c.length; l++)
194
+ $(c[l]);
195
+ Object.freeze && Object.freeze(c);
196
+ } else
197
+ console.error(
198
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
199
+ );
200
+ else $(c);
201
+ if (P.call(t, "key")) {
202
+ c = m(e);
203
+ var Y = Object.keys(t).filter(function(te) {
204
+ return te !== "key";
205
+ });
206
+ l = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", Z[c + l] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
207
+ `A props object containing a "key" prop is being spread into JSX:
208
+ let props = %s;
209
+ <%s {...props} />
210
+ React keys must be passed directly to JSX without using spread:
211
+ let props = %s;
212
+ <%s key={someKey} {...props} />`,
213
+ l,
214
+ c,
215
+ Y,
216
+ c
217
+ ), Z[c + l] = !0);
218
+ }
219
+ if (c = null, a !== void 0 && (_(a), c = "" + a), h(t) && (_(t.key), c = "" + t.key), "key" in t) {
220
+ a = {};
221
+ for (var X in t)
222
+ X !== "key" && (a[X] = t[X]);
223
+ } else a = t;
224
+ return c && b(
225
+ a,
226
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
227
+ ), A(
228
+ e,
229
+ c,
230
+ a,
231
+ i(),
232
+ w,
233
+ j
234
+ );
235
+ }
236
+ function $(e) {
237
+ x(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === f && (e._payload.status === "fulfilled" ? x(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
238
+ }
239
+ function x(e) {
240
+ return typeof e == "object" && e !== null && e.$$typeof === R;
241
+ }
242
+ var k = ne, R = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), o = Symbol.for("react.consumer"), E = Symbol.for("react.context"), T = Symbol.for("react.forward_ref"), p = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), N = Symbol.for("react.memo"), f = Symbol.for("react.lazy"), G = Symbol.for("react.activity"), D = Symbol.for("react.view_transition"), W = Symbol.for("react.client.reference"), y = k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, L = Array.isArray, M = console.createTask ? console.createTask : function() {
243
+ return null;
244
+ };
245
+ k = {
246
+ react_stack_bottom_frame: function(e) {
247
+ return e();
248
+ }
249
+ };
250
+ var U, V = {}, B = k.react_stack_bottom_frame.bind(
251
+ k,
252
+ s
253
+ )(), H = M(g(s)), Z = {};
254
+ z.Fragment = O, z.jsx = function(e, t, a) {
255
+ var l = 1e4 > y.recentlyCreatedOwnerStacks++;
256
+ if (l) {
257
+ var w = Error.stackTraceLimit;
258
+ Error.stackTraceLimit = 10;
259
+ var j = Error("react-stack-top-frame");
260
+ Error.stackTraceLimit = w;
261
+ } else j = B;
262
+ return C(
263
+ e,
264
+ t,
265
+ a,
266
+ !1,
267
+ j,
268
+ l ? M(g(e)) : H
269
+ );
270
+ }, z.jsxs = function(e, t, a) {
271
+ var l = 1e4 > y.recentlyCreatedOwnerStacks++;
272
+ if (l) {
273
+ var w = Error.stackTraceLimit;
274
+ Error.stackTraceLimit = 10;
275
+ var j = Error("react-stack-top-frame");
276
+ Error.stackTraceLimit = w;
277
+ } else j = B;
278
+ return C(
279
+ e,
280
+ t,
281
+ a,
282
+ !0,
283
+ j,
284
+ l ? M(g(e)) : H
285
+ );
286
+ };
287
+ })()), z;
288
+ }
289
+ var re;
290
+ function oe() {
291
+ return re || (re = 1, process.env.NODE_ENV === "production" ? J.exports = ae() : J.exports = se()), J.exports;
292
+ }
293
+ var n = oe();
294
+ function ie(m, d) {
295
+ const [_, g] = q(""), [i, s] = q([]), [h, b] = q(1), [u, A] = q(10);
296
+ function C(p) {
297
+ g(p), b(1);
298
+ }
299
+ function $(p) {
300
+ s((v) => {
301
+ const N = v.find((f) => f.key === p);
302
+ return N ? N.direction === "asc" ? v.map(
303
+ (f) => f.key === p ? { ...f, direction: "desc" } : f
304
+ ) : v.filter((f) => f.key !== p) : [...v, { key: p, direction: "asc" }];
305
+ }), b(1);
306
+ }
307
+ function x() {
308
+ s([]), b(1);
309
+ }
310
+ function k(p) {
311
+ A(p), b(1);
312
+ }
313
+ const R = Q(() => {
314
+ if (!_.trim()) return m;
315
+ const p = _.toLowerCase();
316
+ return m.filter(
317
+ (v) => d.some(
318
+ (N) => String(v[N.key] ?? "").toLowerCase().includes(p)
319
+ )
320
+ );
321
+ }, [m, _, d]), I = Q(() => {
322
+ if (i.length === 0) return R;
323
+ const p = Object.fromEntries(
324
+ d.map((v) => [v.key, v.type ?? "string"])
325
+ );
326
+ return [...R].sort((v, N) => {
327
+ for (const { key: f, direction: G } of i) {
328
+ const D = v[f] ?? "", W = N[f] ?? "";
329
+ let y;
330
+ if (p[f] === "date") {
331
+ const P = (L) => {
332
+ const [M, U, V] = String(L).split("/");
333
+ return new Date(Number(V), Number(M) - 1, Number(U)).getTime();
334
+ };
335
+ y = P(D) - P(W);
336
+ } else {
337
+ const P = String(D).toLowerCase(), L = String(W).toLowerCase();
338
+ y = P < L ? -1 : P > L ? 1 : 0;
339
+ }
340
+ if (y !== 0) return G === "asc" ? y : -y;
341
+ }
342
+ return 0;
343
+ });
344
+ }, [R, i, d]), O = m.length, S = I.length, r = Math.max(1, Math.ceil(S / u)), o = S === 0 ? 0 : (h - 1) * u + 1, E = Math.min(h * u, S);
345
+ return {
346
+ sorted: I.slice(
347
+ (h - 1) * u,
348
+ h * u
349
+ ),
350
+ totalEntries: O,
351
+ totalFiltered: S,
352
+ totalPages: r,
353
+ startEntry: o,
354
+ endEntry: E,
355
+ search: _,
356
+ setSearch: C,
357
+ sorts: i,
358
+ handleSort: $,
359
+ clearSorts: x,
360
+ currentPage: h,
361
+ setCurrentPage: b,
362
+ pageSize: u,
363
+ handlePageSize: k
364
+ };
365
+ }
366
+ function ce({ data: m = [], columns: d = [] }) {
367
+ const {
368
+ search: _,
369
+ setSearch: g,
370
+ sorted: i,
371
+ sorts: s,
372
+ handleSort: h,
373
+ clearSorts: b,
374
+ currentPage: u,
375
+ setCurrentPage: A,
376
+ pageSize: C,
377
+ handlePageSize: $,
378
+ totalPages: x,
379
+ totalFiltered: k,
380
+ totalEntries: R,
381
+ startEntry: I,
382
+ endEntry: O
383
+ } = ie(m, d), S = () => {
384
+ if (x <= 7)
385
+ return Array.from({ length: x }, (o, E) => E + 1);
386
+ const r = [1];
387
+ u > 3 && r.push("...");
388
+ for (let o = Math.max(2, u - 1); o <= Math.min(x - 1, u + 1); o++)
389
+ r.push(o);
390
+ return u < x - 2 && r.push("..."), r.push(x), r;
391
+ };
392
+ return /* @__PURE__ */ n.jsxs("div", { className: "global-container", children: [
393
+ /* @__PURE__ */ n.jsxs("div", { className: "datatable-controls", children: [
394
+ /* @__PURE__ */ n.jsxs("div", { className: "page-size-control", children: [
395
+ /* @__PURE__ */ n.jsx("label", { htmlFor: "page-size", children: "Show" }),
396
+ " ",
397
+ /* @__PURE__ */ n.jsx(
398
+ "select",
399
+ {
400
+ "data-testid": "select-page-size",
401
+ id: "page-size",
402
+ value: C,
403
+ onChange: (r) => $(r.target.value),
404
+ children: [10, 25, 50, 100].map((r) => /* @__PURE__ */ n.jsx("option", { value: r, children: r }, r))
405
+ }
406
+ ),
407
+ " ",
408
+ "entries"
409
+ ] }),
410
+ s.length > 0 && /* @__PURE__ */ n.jsx("button", { className: "clear-sorts-btn", onClick: b, children: "✕ Clear sorts" }),
411
+ /* @__PURE__ */ n.jsx("div", { className: "search-container", children: /* @__PURE__ */ n.jsx(
412
+ "input",
413
+ {
414
+ "data-testid": "input-search",
415
+ type: "text",
416
+ id: "input-search",
417
+ placeholder: "Search...",
418
+ value: _,
419
+ onChange: (r) => g(r.target.value)
420
+ }
421
+ ) })
422
+ ] }),
423
+ /* @__PURE__ */ n.jsxs("div", { className: "sort-controls", children: [
424
+ /* @__PURE__ */ n.jsx("span", { className: "sort-controls-label", children: "Sort by:" }),
425
+ d.map((r) => {
426
+ const o = s.find((T) => T.key === r.key), E = s.findIndex((T) => T.key === r.key) + 1;
427
+ return /* @__PURE__ */ n.jsxs(
428
+ "button",
429
+ {
430
+ className: `sort-chip${o ? " sort-chip--active" : ""}`,
431
+ onClick: () => h(r.key),
432
+ children: [
433
+ r.label,
434
+ o ? o.direction === "asc" ? " ↑" : " ↓" : "",
435
+ o && s.length > 1 && /* @__PURE__ */ n.jsx("sup", { children: E })
436
+ ]
437
+ },
438
+ r.key
439
+ );
440
+ })
441
+ ] }),
442
+ /* @__PURE__ */ n.jsxs("table", { children: [
443
+ /* @__PURE__ */ n.jsx("thead", { children: /* @__PURE__ */ n.jsx("tr", { children: d.map((r) => {
444
+ const o = s.find((T) => T.key === r.key), E = s.findIndex((T) => T.key === r.key) + 1;
445
+ return /* @__PURE__ */ n.jsxs(
446
+ "th",
447
+ {
448
+ className: `sortable-th${o ? " active-sort" : ""}`,
449
+ onClick: () => h(r.key),
450
+ children: [
451
+ r.label,
452
+ /* @__PURE__ */ n.jsx("span", { className: "sort-arrow", children: o ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
453
+ o.direction === "asc" ? " ↑" : " ↓",
454
+ s.length > 1 && /* @__PURE__ */ n.jsx("sup", { children: E })
455
+ ] }) : " ↕" })
456
+ ]
457
+ },
458
+ r.key
459
+ );
460
+ }) }) }),
461
+ /* @__PURE__ */ n.jsx("tbody", { children: i.length === 0 ? /* @__PURE__ */ n.jsx("tr", { children: /* @__PURE__ */ n.jsx("td", { colSpan: d.length, style: { textAlign: "center" }, children: "No entries found" }) }) : i.map((r, o) => /* @__PURE__ */ n.jsx("tr", { children: d.map((E) => /* @__PURE__ */ n.jsx("td", { "data-label": E.label, children: r[E.key] }, E.key)) }, o)) })
462
+ ] }),
463
+ /* @__PURE__ */ n.jsxs("div", { className: "datatable-footer", children: [
464
+ /* @__PURE__ */ n.jsx("div", { className: "datatable-info", children: k === 0 ? "No entries found" : `Showing ${I} to ${O} of ${k} entries${k !== R ? ` (filtered from ${R} total entries)` : ""}` }),
465
+ /* @__PURE__ */ n.jsxs("div", { className: "datatable-pagination", children: [
466
+ /* @__PURE__ */ n.jsx(
467
+ "button",
468
+ {
469
+ "data-testid": "btn-previous",
470
+ onClick: () => A((r) => Math.max(1, r - 1)),
471
+ disabled: u === 1,
472
+ children: "Previous"
473
+ }
474
+ ),
475
+ S().map(
476
+ (r, o) => r === "..." ? /* @__PURE__ */ n.jsx("span", { className: "pagination-ellipsis", children: "…" }, `ellipsis-${o}`) : /* @__PURE__ */ n.jsx(
477
+ "button",
478
+ {
479
+ onClick: () => A(r),
480
+ className: u === r ? "active-page" : "",
481
+ children: r
482
+ },
483
+ r
484
+ )
485
+ ),
486
+ /* @__PURE__ */ n.jsx(
487
+ "button",
488
+ {
489
+ "data-testid": "btn-next",
490
+ onClick: () => A((r) => Math.min(x, r + 1)),
491
+ disabled: u === x,
492
+ children: "Next"
493
+ }
494
+ )
495
+ ] })
496
+ ] })
497
+ ] });
498
+ }
499
+ export {
500
+ ce as DataTable
501
+ };
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "hrnet-datatable-tiago",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "React datatable component with search, multi-sort and pagination",
5
+ "main": "dist/hrnet-datatable.es.js",
6
+ "module": "dist/hrnet-datatable.es.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/hrnet-datatable.es.js",
10
+ "require": "./dist/hrnet-datatable.es.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "dev": "vite",
18
+ "build": "vite build",
19
+ "preview": "vite preview",
20
+ "test": "vitest"
21
+ },
22
+ "peerDependencies": {
23
+ "react": ">=18.0.0",
24
+ "react-dom": ">=18.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@testing-library/dom": "^10.4.2",
28
+ "@testing-library/react": "^16.3.3",
29
+ "@vitejs/plugin-react": "4.0.0",
30
+ "jsdom": "^30.1.1",
31
+ "react": "^19.0.0",
32
+ "react-dom": "^19.0.0",
33
+ "vite": "^6.0.0",
34
+ "vitest": "^5.0.3"
35
+ },
36
+ "keywords": [
37
+ "react",
38
+ "datatable",
39
+ "hrnet"
40
+ ],
41
+ "author": "Tiago Lima",
42
+ "license": "ISC"
43
+ }