free-grid-react 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tony Tom K
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/Grid.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { GridProps } from './types';
2
+ export declare function Grid<T extends {
3
+ id?: string | number;
4
+ } | any>({ data, columns, showHeader, renderChildView, selectable, selectedIds, onSelectionChange, pagination, className, id, }: GridProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ :root{--fg-border-color: #e0e0e0;--fg-header-bg: #ffffff;--fg-header-text: rgba(0, 0, 0, .87);--fg-row-hover: rgba(0, 0, 0, .04);--fg-row-selected: rgba(25, 118, 210, .08);--fg-row-border: #e0e0e0;--fg-text-color: rgba(0, 0, 0, .87);--fg-primary-color: #1976d2;--fg-font-family: "Roboto", "Helvetica", "Arial", sans-serif;--fg-transition: background-color .2s cubic-bezier(.4, 0, .2, 1) 0ms}.free-grid-container{width:100%;border:1px solid var(--fg-border-color);border-radius:4px;overflow:hidden;font-family:var(--fg-font-family);background:#fff;display:flex;flex-direction:column}.free-grid-header{background:var(--fg-header-bg);border-bottom:1px solid var(--fg-border-color);font-weight:700;color:var(--fg-header-text);font-size:.875rem}.free-grid-header-cell{padding:12px 16px;display:flex;align-items:center;position:relative}.free-grid-header-cell:not(:last-child):after{content:"";position:absolute;right:0;top:25%;height:50%;width:1px;background-color:var(--fg-border-color)}.free-grid-body{display:flex;flex-direction:column;overflow-y:auto}.free-grid-row{border-bottom:1px solid var(--fg-row-border);transition:var(--fg-transition);color:var(--fg-text-color);font-size:.875rem;min-height:52px}.free-grid-row:last-child{border-bottom:none}.free-grid-row.expandable{cursor:pointer}.free-grid-row:hover,.free-grid-row.expanded{background-color:var(--fg-row-hover)}.free-grid-cell{padding:8px 16px;display:flex;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.free-grid-checkbox-cell{width:50px;flex:none!important;justify-content:center}.free-grid-checkbox{width:18px;height:18px;cursor:pointer;accent-color:var(--fg-primary-color)}.free-grid-footer{padding:8px 16px;border-top:1px solid var(--fg-border-color);display:flex;justify-content:flex-end;align-items:center;font-size:.875rem;color:var(--fg-text-color);gap:24px}.free-grid-pagination{display:flex;align-items:center;gap:16px}.free-grid-pagination-actions{display:flex;gap:8px}.free-grid-icon-button{background:none;border:none;cursor:pointer;padding:4px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:var(--fg-transition);color:#0000008a}.free-grid-icon-button:hover:not(:disabled){background-color:#0000000a}.free-grid-icon-button:disabled{color:#00000042;cursor:default}.free-grid-child-view{padding:24px;background-color:#fcfcfc;border-bottom:1px solid var(--fg-border-color);animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}
@@ -0,0 +1,2 @@
1
+ export * from './index'
2
+ export {}
@@ -0,0 +1,372 @@
1
+ import B, { useState as re } from "react";
2
+ var O = { exports: {} }, g = {};
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 G;
13
+ function te() {
14
+ if (G) return g;
15
+ G = 1;
16
+ var f = Symbol.for("react.transitional.element"), E = Symbol.for("react.fragment");
17
+ function b(p, u, d) {
18
+ var m = null;
19
+ if (d !== void 0 && (m = "" + d), u.key !== void 0 && (m = "" + u.key), "key" in u) {
20
+ d = {};
21
+ for (var l in u)
22
+ l !== "key" && (d[l] = u[l]);
23
+ } else d = u;
24
+ return u = d.ref, {
25
+ $$typeof: f,
26
+ type: p,
27
+ key: m,
28
+ ref: u !== void 0 ? u : null,
29
+ props: d
30
+ };
31
+ }
32
+ return g.Fragment = E, g.jsx = b, g.jsxs = b, g;
33
+ }
34
+ var k = {};
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 V;
45
+ function ae() {
46
+ return V || (V = 1, process.env.NODE_ENV !== "production" && (function() {
47
+ function f(e) {
48
+ if (e == null) return null;
49
+ if (typeof e == "function")
50
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
51
+ if (typeof e == "string") return e;
52
+ switch (e) {
53
+ case t:
54
+ return "Fragment";
55
+ case i:
56
+ return "Profiler";
57
+ case c:
58
+ return "StrictMode";
59
+ case C:
60
+ return "Suspense";
61
+ case N:
62
+ return "SuspenseList";
63
+ case Z:
64
+ return "Activity";
65
+ }
66
+ if (typeof e == "object")
67
+ switch (typeof e.tag == "number" && console.error(
68
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
+ ), e.$$typeof) {
70
+ case S:
71
+ return "Portal";
72
+ case y:
73
+ return e.displayName || "Context";
74
+ case v:
75
+ return (e._context.displayName || "Context") + ".Consumer";
76
+ case h:
77
+ var r = e.render;
78
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
+ case H:
80
+ return r = e.displayName || null, r !== null ? r : f(e.type) || "Memo";
81
+ case Y:
82
+ r = e._payload, e = e._init;
83
+ try {
84
+ return f(e(r));
85
+ } catch {
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+ function E(e) {
91
+ return "" + e;
92
+ }
93
+ function b(e) {
94
+ try {
95
+ E(e);
96
+ var r = !1;
97
+ } catch {
98
+ r = !0;
99
+ }
100
+ if (r) {
101
+ r = console;
102
+ var a = r.error, s = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
+ return a.call(
104
+ r,
105
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
+ s
107
+ ), E(e);
108
+ }
109
+ }
110
+ function p(e) {
111
+ if (e === t) return "<>";
112
+ if (typeof e == "object" && e !== null && e.$$typeof === Y)
113
+ return "<...>";
114
+ try {
115
+ var r = f(e);
116
+ return r ? "<" + r + ">" : "<...>";
117
+ } catch {
118
+ return "<...>";
119
+ }
120
+ }
121
+ function u() {
122
+ var e = F.A;
123
+ return e === null ? null : e.getOwner();
124
+ }
125
+ function d() {
126
+ return Error("react-stack-top-frame");
127
+ }
128
+ function m(e) {
129
+ if (z.call(e, "key")) {
130
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
131
+ if (r && r.isReactWarning) return !1;
132
+ }
133
+ return e.key !== void 0;
134
+ }
135
+ function l(e, r) {
136
+ function a() {
137
+ I || (I = !0, console.error(
138
+ "%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)",
139
+ r
140
+ ));
141
+ }
142
+ a.isReactWarning = !0, Object.defineProperty(e, "key", {
143
+ get: a,
144
+ configurable: !0
145
+ });
146
+ }
147
+ function P() {
148
+ var e = f(this.type);
149
+ return W[e] || (W[e] = !0, console.error(
150
+ "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."
151
+ )), e = this.props.ref, e !== void 0 ? e : null;
152
+ }
153
+ function $(e, r, a, s, A, M) {
154
+ var o = a.ref;
155
+ return e = {
156
+ $$typeof: w,
157
+ type: e,
158
+ key: r,
159
+ props: a,
160
+ _owner: s
161
+ }, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
162
+ enumerable: !1,
163
+ get: P
164
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
165
+ configurable: !1,
166
+ enumerable: !1,
167
+ writable: !0,
168
+ value: 0
169
+ }), Object.defineProperty(e, "_debugInfo", {
170
+ configurable: !1,
171
+ enumerable: !1,
172
+ writable: !0,
173
+ value: null
174
+ }), Object.defineProperty(e, "_debugStack", {
175
+ configurable: !1,
176
+ enumerable: !1,
177
+ writable: !0,
178
+ value: A
179
+ }), Object.defineProperty(e, "_debugTask", {
180
+ configurable: !1,
181
+ enumerable: !1,
182
+ writable: !0,
183
+ value: M
184
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
185
+ }
186
+ function R(e, r, a, s, A, M) {
187
+ var o = r.children;
188
+ if (o !== void 0)
189
+ if (s)
190
+ if (K(o)) {
191
+ for (s = 0; s < o.length; s++)
192
+ T(o[s]);
193
+ Object.freeze && Object.freeze(o);
194
+ } else
195
+ console.error(
196
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
197
+ );
198
+ else T(o);
199
+ if (z.call(r, "key")) {
200
+ o = f(e);
201
+ var x = Object.keys(r).filter(function(ee) {
202
+ return ee !== "key";
203
+ });
204
+ s = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", J[o + s] || (x = 0 < x.length ? "{" + x.join(": ..., ") + ": ...}" : "{}", console.error(
205
+ `A props object containing a "key" prop is being spread into JSX:
206
+ let props = %s;
207
+ <%s {...props} />
208
+ React keys must be passed directly to JSX without using spread:
209
+ let props = %s;
210
+ <%s key={someKey} {...props} />`,
211
+ s,
212
+ o,
213
+ x,
214
+ o
215
+ ), J[o + s] = !0);
216
+ }
217
+ if (o = null, a !== void 0 && (b(a), o = "" + a), m(r) && (b(r.key), o = "" + r.key), "key" in r) {
218
+ a = {};
219
+ for (var D in r)
220
+ D !== "key" && (a[D] = r[D]);
221
+ } else a = r;
222
+ return o && l(
223
+ a,
224
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
225
+ ), $(
226
+ e,
227
+ o,
228
+ a,
229
+ u(),
230
+ A,
231
+ M
232
+ );
233
+ }
234
+ function T(e) {
235
+ j(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === Y && (e._payload.status === "fulfilled" ? j(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
236
+ }
237
+ function j(e) {
238
+ return typeof e == "object" && e !== null && e.$$typeof === w;
239
+ }
240
+ var _ = B, w = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), t = Symbol.for("react.fragment"), c = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), v = Symbol.for("react.consumer"), y = Symbol.for("react.context"), h = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), Y = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), Q = Symbol.for("react.client.reference"), F = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, K = Array.isArray, L = console.createTask ? console.createTask : function() {
241
+ return null;
242
+ };
243
+ _ = {
244
+ react_stack_bottom_frame: function(e) {
245
+ return e();
246
+ }
247
+ };
248
+ var I, W = {}, U = _.react_stack_bottom_frame.bind(
249
+ _,
250
+ d
251
+ )(), q = L(p(d)), J = {};
252
+ k.Fragment = t, k.jsx = function(e, r, a) {
253
+ var s = 1e4 > F.recentlyCreatedOwnerStacks++;
254
+ return R(
255
+ e,
256
+ r,
257
+ a,
258
+ !1,
259
+ s ? Error("react-stack-top-frame") : U,
260
+ s ? L(p(e)) : q
261
+ );
262
+ }, k.jsxs = function(e, r, a) {
263
+ var s = 1e4 > F.recentlyCreatedOwnerStacks++;
264
+ return R(
265
+ e,
266
+ r,
267
+ a,
268
+ !0,
269
+ s ? Error("react-stack-top-frame") : U,
270
+ s ? L(p(e)) : q
271
+ );
272
+ };
273
+ })()), k;
274
+ }
275
+ var X;
276
+ function ne() {
277
+ return X || (X = 1, process.env.NODE_ENV === "production" ? O.exports = te() : O.exports = ae()), O.exports;
278
+ }
279
+ var n = ne();
280
+ function oe({
281
+ data: f,
282
+ columns: E,
283
+ showHeader: b = !0,
284
+ renderChildView: p,
285
+ selectable: u,
286
+ selectedIds: d = [],
287
+ onSelectionChange: m,
288
+ pagination: l,
289
+ className: P = "",
290
+ id: $
291
+ }) {
292
+ const [R, T] = re(/* @__PURE__ */ new Set()), j = (t, c) => {
293
+ const i = c.id !== void 0 ? c.id : t, v = new Set(R);
294
+ v.has(i) ? v.delete(i) : v.add(i), T(v);
295
+ }, _ = (t) => {
296
+ m && (t.target.checked ? m(f.map((c, i) => c.id !== void 0 ? c.id : i)) : m([]));
297
+ }, w = (t, c) => {
298
+ if (t.stopPropagation(), !m) return;
299
+ const i = new Set(d);
300
+ t.target.checked ? i.add(c) : i.delete(c), m(Array.from(i));
301
+ }, S = {
302
+ display: "grid",
303
+ gridTemplateColumns: `${u ? "50px " : ""}${E.map((t) => t.width ? typeof t.width == "number" ? `${t.width}px` : t.width : t.flex ? `${t.flex}fr` : "1fr").join(" ")}`
304
+ };
305
+ return /* @__PURE__ */ n.jsxs("div", { className: `free-grid-container ${P}`, id: $, children: [
306
+ b && /* @__PURE__ */ n.jsxs("div", { className: "free-grid-header", style: S, children: [
307
+ u && /* @__PURE__ */ n.jsx("div", { className: "free-grid-header-cell free-grid-checkbox-cell", children: /* @__PURE__ */ n.jsx(
308
+ "input",
309
+ {
310
+ type: "checkbox",
311
+ className: "free-grid-checkbox",
312
+ onChange: _,
313
+ checked: f.length > 0 && d.length === f.length
314
+ }
315
+ ) }),
316
+ E.map((t, c) => /* @__PURE__ */ n.jsx("div", { className: "free-grid-header-cell", children: t.header }, `header-${c}`))
317
+ ] }),
318
+ /* @__PURE__ */ n.jsx("div", { className: "free-grid-body", children: f.map((t, c) => {
319
+ const i = t.id !== void 0 ? t.id : c, v = R.has(i), y = d.includes(i);
320
+ return /* @__PURE__ */ n.jsxs(B.Fragment, { children: [
321
+ /* @__PURE__ */ n.jsxs(
322
+ "div",
323
+ {
324
+ className: `free-grid-row ${p ? "expandable" : ""} ${v ? "expanded" : ""} ${y ? "selected" : ""}`,
325
+ style: S,
326
+ onClick: () => p && j(c, t),
327
+ children: [
328
+ u && /* @__PURE__ */ n.jsx("div", { className: "free-grid-cell free-grid-checkbox-cell", children: /* @__PURE__ */ n.jsx(
329
+ "input",
330
+ {
331
+ type: "checkbox",
332
+ className: "free-grid-checkbox",
333
+ checked: y,
334
+ onChange: (h) => w(h, i),
335
+ onClick: (h) => h.stopPropagation()
336
+ }
337
+ ) }),
338
+ E.map((h, C) => {
339
+ const N = t[h.key];
340
+ return /* @__PURE__ */ n.jsx("div", { className: "free-grid-cell", children: h.render ? h.render(N, t) : N }, `cell-${c}-${C}`);
341
+ })
342
+ ]
343
+ }
344
+ ),
345
+ v && p && /* @__PURE__ */ n.jsx("div", { className: "free-grid-child-view", children: p(t) })
346
+ ] }, `row-${i}`);
347
+ }) }),
348
+ l && /* @__PURE__ */ n.jsx("div", { className: "free-grid-footer", children: /* @__PURE__ */ n.jsxs("div", { className: "free-grid-pagination", children: [
349
+ /* @__PURE__ */ n.jsxs("span", { children: [
350
+ Math.min((l.page - 1) * l.pageSize + 1, l.total),
351
+ "-",
352
+ Math.min(l.page * l.pageSize, l.total),
353
+ " of ",
354
+ l.total
355
+ ] }),
356
+ /* @__PURE__ */ n.jsxs("div", { className: "free-grid-pagination-actions", children: [
357
+ /* @__PURE__ */ n.jsx("button", { className: "free-grid-icon-button", disabled: l.page <= 1, children: /* @__PURE__ */ n.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n.jsx("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) }) }),
358
+ /* @__PURE__ */ n.jsx(
359
+ "button",
360
+ {
361
+ className: "free-grid-icon-button",
362
+ disabled: l.page * l.pageSize >= l.total,
363
+ children: /* @__PURE__ */ n.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n.jsx("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) })
364
+ }
365
+ )
366
+ ] })
367
+ ] }) })
368
+ ] });
369
+ }
370
+ export {
371
+ oe as Grid
372
+ };
@@ -0,0 +1,22 @@
1
+ (function(E,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(E=typeof globalThis<"u"?globalThis:E||self,_(E.FreeGrid={},E.React))})(this,(function(E,_){"use strict";var w={exports:{}},T={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var W;function Z(){if(W)return T;W=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function x(p,u,d){var m=null;if(d!==void 0&&(m=""+d),u.key!==void 0&&(m=""+u.key),"key"in u){d={};for(var l in u)l!=="key"&&(d[l]=u[l])}else d=u;return u=d.ref,{$$typeof:f,type:p,key:m,ref:u!==void 0?u:null,props:d}}return T.Fragment=b,T.jsx=x,T.jsxs=x,T}var j={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var U;function Q(){return U||(U=1,process.env.NODE_ENV!=="production"&&(function(){function f(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ne?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case t:return"Fragment";case i:return"Profiler";case c:return"StrictMode";case F:return"Suspense";case P:return"SuspenseList";case te:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case O:return"Portal";case A:return e.displayName||"Context";case h:return(e._context.displayName||"Context")+".Consumer";case v:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case re:return r=e.displayName||null,r!==null?r:f(e.type)||"Memo";case M:r=e._payload,e=e._init;try{return f(e(r))}catch{}}return null}function b(e){return""+e}function x(e){try{b(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),b(e)}}function p(e){if(e===t)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===M)return"<...>";try{var r=f(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function u(){var e=L.A;return e===null?null:e.getOwner()}function d(){return Error("react-stack-top-frame")}function m(e){if(J.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function l(e,r){function a(){q||(q=!0,console.error("%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)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function $(){var e=f(this.type);return V[e]||(V[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function Y(e,r,a,s,C,z){var o=a.ref;return e={$$typeof:N,type:e,key:r,props:a,_owner:s},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:$}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function k(e,r,a,s,C,z){var o=r.children;if(o!==void 0)if(s)if(ae(o)){for(s=0;s<o.length;s++)y(o[s]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(o);if(J.call(r,"key")){o=f(e);var g=Object.keys(r).filter(function(se){return se!=="key"});s=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",H[o+s]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,s,o,g,o),H[o+s]=!0)}if(o=null,a!==void 0&&(x(a),o=""+a),m(r)&&(x(r.key),o=""+r.key),"key"in r){a={};for(var I in r)I!=="key"&&(a[I]=r[I])}else a=r;return o&&l(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),Y(e,o,a,u(),C,z)}function y(e){S(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===M&&(e._payload.status==="fulfilled"?S(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function S(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var R=_,N=Symbol.for("react.transitional.element"),O=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),A=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),re=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),te=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),L=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,ae=Array.isArray,D=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var q,V={},X=R.react_stack_bottom_frame.bind(R,d)(),B=D(p(d)),H={};j.Fragment=t,j.jsx=function(e,r,a){var s=1e4>L.recentlyCreatedOwnerStacks++;return k(e,r,a,!1,s?Error("react-stack-top-frame"):X,s?D(p(e)):B)},j.jsxs=function(e,r,a){var s=1e4>L.recentlyCreatedOwnerStacks++;return k(e,r,a,!0,s?Error("react-stack-top-frame"):X,s?D(p(e)):B)}})()),j}var G;function K(){return G||(G=1,process.env.NODE_ENV==="production"?w.exports=Z():w.exports=Q()),w.exports}var n=K();function ee({data:f,columns:b,showHeader:x=!0,renderChildView:p,selectable:u,selectedIds:d=[],onSelectionChange:m,pagination:l,className:$="",id:Y}){const[k,y]=_.useState(new Set),S=(t,c)=>{const i=c.id!==void 0?c.id:t,h=new Set(k);h.has(i)?h.delete(i):h.add(i),y(h)},R=t=>{m&&(t.target.checked?m(f.map((c,i)=>c.id!==void 0?c.id:i)):m([]))},N=(t,c)=>{if(t.stopPropagation(),!m)return;const i=new Set(d);t.target.checked?i.add(c):i.delete(c),m(Array.from(i))},O={display:"grid",gridTemplateColumns:`${u?"50px ":""}${b.map(t=>t.width?typeof t.width=="number"?`${t.width}px`:t.width:t.flex?`${t.flex}fr`:"1fr").join(" ")}`};return n.jsxs("div",{className:`free-grid-container ${$}`,id:Y,children:[x&&n.jsxs("div",{className:"free-grid-header",style:O,children:[u&&n.jsx("div",{className:"free-grid-header-cell free-grid-checkbox-cell",children:n.jsx("input",{type:"checkbox",className:"free-grid-checkbox",onChange:R,checked:f.length>0&&d.length===f.length})}),b.map((t,c)=>n.jsx("div",{className:"free-grid-header-cell",children:t.header},`header-${c}`))]}),n.jsx("div",{className:"free-grid-body",children:f.map((t,c)=>{const i=t.id!==void 0?t.id:c,h=k.has(i),A=d.includes(i);return n.jsxs(_.Fragment,{children:[n.jsxs("div",{className:`free-grid-row ${p?"expandable":""} ${h?"expanded":""} ${A?"selected":""}`,style:O,onClick:()=>p&&S(c,t),children:[u&&n.jsx("div",{className:"free-grid-cell free-grid-checkbox-cell",children:n.jsx("input",{type:"checkbox",className:"free-grid-checkbox",checked:A,onChange:v=>N(v,i),onClick:v=>v.stopPropagation()})}),b.map((v,F)=>{const P=t[v.key];return n.jsx("div",{className:"free-grid-cell",children:v.render?v.render(P,t):P},`cell-${c}-${F}`)})]}),h&&p&&n.jsx("div",{className:"free-grid-child-view",children:p(t)})]},`row-${i}`)})}),l&&n.jsx("div",{className:"free-grid-footer",children:n.jsxs("div",{className:"free-grid-pagination",children:[n.jsxs("span",{children:[Math.min((l.page-1)*l.pageSize+1,l.total),"-",Math.min(l.page*l.pageSize,l.total)," of ",l.total]}),n.jsxs("div",{className:"free-grid-pagination-actions",children:[n.jsx("button",{className:"free-grid-icon-button",disabled:l.page<=1,children:n.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),n.jsx("button",{className:"free-grid-icon-button",disabled:l.page*l.pageSize>=l.total,children:n.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})})]})]})})]})}E.Grid=ee,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,2 @@
1
+ export * from './Grid';
2
+ export * from './types';
@@ -0,0 +1,24 @@
1
+ export interface Column<T> {
2
+ key: keyof T | string;
3
+ header: React.ReactNode;
4
+ width?: string | number;
5
+ flex?: number;
6
+ render?: (value: any, item: T) => React.ReactNode;
7
+ }
8
+ export interface GridProps<T> {
9
+ data: T[];
10
+ columns: Column<T>[];
11
+ showHeader?: boolean;
12
+ rowHeight?: string | number;
13
+ renderChildView?: (item: T) => React.ReactNode;
14
+ selectable?: boolean;
15
+ selectedIds?: (string | number)[];
16
+ onSelectionChange?: (ids: (string | number)[]) => void;
17
+ pagination?: {
18
+ total: number;
19
+ page: number;
20
+ pageSize: number;
21
+ };
22
+ className?: string;
23
+ id?: string;
24
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "free-grid-react",
3
+ "version": "0.1.0",
4
+ "description": "A lightweight, high-performance React grid component built with CSS Grid and TypeScript.",
5
+ "author": "Tony Tom K",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "react",
9
+ "grid",
10
+ "table",
11
+ "typescript",
12
+ "vite",
13
+ "flexbox",
14
+ "mui-style"
15
+ ],
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "development": "./src/index.ts",
20
+ "import": "./dist/free-grid.js",
21
+ "require": "./dist/free-grid.umd.cjs"
22
+ },
23
+ "./src/Grid.css": "./src/Grid.css",
24
+ "./free-grid.css": "./dist/free-grid.css"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "scripts": {
30
+ "dev": "vite",
31
+ "build": "tsc && vite build",
32
+ "preview": "vite preview"
33
+ },
34
+ "peerDependencies": {
35
+ "react": "^18.0.0 || ^19.0.0",
36
+ "react-dom": "^18.0.0 || ^19.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^25.5.0",
40
+ "@types/react": "^19.0.0",
41
+ "@types/react-dom": "^19.0.0",
42
+ "@vitejs/plugin-react": "^4.3.4",
43
+ "react": "^19.0.0",
44
+ "react-dom": "^19.0.0",
45
+ "typescript": "^5.7.2",
46
+ "vite": "^6.0.5",
47
+ "vite-plugin-dts": "^4.4.0"
48
+ }
49
+ }