@react-fabric/data 1.0.0-beta.61 → 1.0.0-beta.62

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.
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@react-fabric/core');
4
- var ar = require('./ar.json.js');
5
- var en = require('./en.json.js');
4
+ var data$1 = require('./ar/data.json.js');
5
+ var data = require('./en/data.json.js');
6
6
 
7
7
  /*
8
8
  * React Fabric
@@ -28,6 +28,6 @@ var en = require('./en.json.js');
28
28
  */
29
29
 
30
30
  core.addTranslationBundle("data", {
31
- en: en.default,
32
- ar: ar.default
31
+ en: data.default,
32
+ ar: data$1.default
33
33
  });
package/dist/cjs/index.js CHANGED
@@ -5,6 +5,7 @@ var CheckList = require('./checklist/CheckList.js');
5
5
  var Histogram = require('./histogram/Histogram.js');
6
6
  var JsonViewer = require('./json/JsonViewer.js');
7
7
  var Pagination = require('./pagination/Pagination.js');
8
+ var HtmlTable = require('./table/HtmlTable.js');
8
9
  var Table = require('./table/Table.js');
9
10
  var TreePanel = require('./tree/TreePanel.js');
10
11
  var Gallery = require('./virtual/Gallery.js');
@@ -18,6 +19,7 @@ exports.CheckList = CheckList.CheckList;
18
19
  exports.Histogram = Histogram.Histogram;
19
20
  exports.JsonViewer = JsonViewer.JsonViewer;
20
21
  exports.Pagination = Pagination.Pagination;
22
+ exports.HtmlTable = HtmlTable.HtmlTable;
21
23
  exports.Table = Table.Table;
22
24
  exports.TreePanel = TreePanel.TreePanel;
23
25
  exports.VirtualGallery = Gallery.VirtualGallery;
@@ -33,7 +33,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
33
33
  onClick: function onClick() {
34
34
  return onPageChange(pg);
35
35
  },
36
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
36
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
37
37
  children: pg + 1
38
38
  }, pg);
39
39
  }), mid && /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -44,7 +44,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
44
44
  onClick: function onClick() {
45
45
  return onPageChange(pg);
46
46
  },
47
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
47
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
48
48
  children: pg + 1
49
49
  }, pg);
50
50
  }), last && /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -55,7 +55,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
55
55
  onClick: function onClick() {
56
56
  return onPageChange(pg);
57
57
  },
58
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
58
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
59
59
  children: pg + 1
60
60
  }, pg);
61
61
  })]
@@ -67,7 +67,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
67
67
  onClick: function onClick() {
68
68
  return onPageChange(0);
69
69
  },
70
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
70
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === 0 && "pointer-events-none text-tint-300"),
71
71
  children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
72
72
  icon: "icon-[mdi--chevron-double-left]",
73
73
  rtlFlip: true
@@ -76,7 +76,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
76
76
  onClick: function onClick() {
77
77
  return onPageChange(page - 1);
78
78
  },
79
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
79
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === 0 && "pointer-events-none text-tint-300"),
80
80
  children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
81
81
  icon: "icon-[mdi--chevron-left]",
82
82
  rtlFlip: true
@@ -88,7 +88,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
88
88
  onClick: function onClick() {
89
89
  return onPageChange(page + 1);
90
90
  },
91
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
91
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
92
92
  children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
93
93
  icon: "icon-[mdi--chevron-right]",
94
94
  rtlFlip: true
@@ -97,7 +97,7 @@ var Pagination = /*#__PURE__*/react.memo(function (_ref) {
97
97
  onClick: function onClick() {
98
98
  return onPageChange(totalPages - 1);
99
99
  },
100
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
100
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
101
101
  children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
102
102
  icon: "icon-[mdi--chevron-double-right]",
103
103
  rtlFlip: true
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
+ var core = require('@react-fabric/core');
5
+ var utilities = require('@react-fabric/utilities');
6
+ var classNames = require('classnames');
7
+ var react = require('react');
8
+ var usePagination = require('../hooks/usePagination.js');
9
+ var Pagination = require('../pagination/Pagination.js');
10
+ var jsxRuntime = require('react/jsx-runtime');
11
+
12
+ 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; }
13
+ 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; }
14
+ var HtmlTable = function HtmlTable(_ref) {
15
+ var data = _ref.data,
16
+ columns = _ref.columns,
17
+ _ref$paginationSize = _ref.paginationSize,
18
+ paginationSize = _ref$paginationSize === void 0 ? 25 : _ref$paginationSize,
19
+ className = _ref.className;
20
+ var paginator = usePagination.usePagination({
21
+ totalRecords: data.length,
22
+ perPage: paginationSize
23
+ });
24
+ var startIndex = react.useMemo(function () {
25
+ return paginator.page * paginationSize;
26
+ }, [paginator.page, paginationSize]);
27
+ var dataPage = react.useMemo(function () {
28
+ return paginationSize > 0 ? data.slice(startIndex, startIndex + paginationSize) : data;
29
+ }, [data, paginationSize, startIndex]);
30
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
31
+ className: className,
32
+ children: [/*#__PURE__*/jsxRuntime.jsxs("table", {
33
+ className: "table-fixed border-spacing-1 border-separate w-full text-sm",
34
+ children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
35
+ className: "sticky top-0 z-1",
36
+ children: /*#__PURE__*/jsxRuntime.jsx("tr", {
37
+ children: columns.map(function (col, idx) {
38
+ var _ref2, _col$headRenderer;
39
+ return /*#__PURE__*/jsxRuntime.jsx("th", {
40
+ className: "text-start truncate bg-accent-100 px-2 py-1 font-medium text-accent-800",
41
+ style: {
42
+ width: col.width,
43
+ maxWidth: col.maxWidth
44
+ },
45
+ children: (_ref2 = (_col$headRenderer = col.headRenderer) !== null && _col$headRenderer !== void 0 ? _col$headRenderer : col.label) !== null && _ref2 !== void 0 ? _ref2 : " "
46
+ }, idx);
47
+ })
48
+ })
49
+ }), /*#__PURE__*/jsxRuntime.jsx("tbody", {
50
+ className: "bg-alternate",
51
+ children: dataPage.map(function (row, idx) {
52
+ return /*#__PURE__*/jsxRuntime.jsx("tr", {
53
+ children: columns.map(function (col, cidx) {
54
+ var _col$renderer, _col$renderer2;
55
+ return /*#__PURE__*/jsxRuntime.jsx("td", {
56
+ className: classNames("px-2 py-1 truncate", col.align === "center" && "text-center", col.align === "end" && "text-end", col.className),
57
+ style: {
58
+ width: col.width,
59
+ maxWidth: col.maxWidth
60
+ },
61
+ children: (_col$renderer = (_col$renderer2 = col.renderer) === null || _col$renderer2 === void 0 ? void 0 : _col$renderer2.call(col, utilities.getByPath(row, col.id.toString()), row, startIndex + idx)) !== null && _col$renderer !== void 0 ? _col$renderer : utilities.getByPath(row, col.id.toString())
62
+ }, "".concat(idx, "-").concat(cidx));
63
+ })
64
+ }, idx);
65
+ })
66
+ })]
67
+ }), paginationSize > 0 && /*#__PURE__*/jsxRuntime.jsx(core.Footer, {
68
+ flex: true,
69
+ justify: "end",
70
+ className: "px-2 py-1 sticky bottom-0 bg-tint-50",
71
+ children: /*#__PURE__*/jsxRuntime.jsx(Pagination.Pagination, _objectSpread({
72
+ minimal: true
73
+ }, paginator))
74
+ })]
75
+ });
76
+ };
77
+
78
+ exports.HtmlTable = HtmlTable;
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import { addTranslationBundle } from '@react-fabric/core';
4
- import ar from './ar.json.js';
5
- import en from './en.json.js';
4
+ import ar from './ar/data.json.js';
5
+ import en from './en/data.json.js';
6
6
 
7
7
  /*
8
8
  * React Fabric
package/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ export { CheckList } from './checklist/CheckList.js';
5
5
  export { Histogram } from './histogram/Histogram.js';
6
6
  export { JsonViewer } from './json/JsonViewer.js';
7
7
  export { Pagination } from './pagination/Pagination.js';
8
+ export { HtmlTable } from './table/HtmlTable.js';
8
9
  export { Table } from './table/Table.js';
9
10
  export { TreePanel } from './tree/TreePanel.js';
10
11
  export { VirtualGallery } from './virtual/Gallery.js';
@@ -33,7 +33,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
33
33
  onClick: function onClick() {
34
34
  return onPageChange(pg);
35
35
  },
36
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
36
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
37
37
  children: pg + 1
38
38
  }, pg);
39
39
  }), mid && /*#__PURE__*/jsx("span", {
@@ -44,7 +44,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
44
44
  onClick: function onClick() {
45
45
  return onPageChange(pg);
46
46
  },
47
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
47
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
48
48
  children: pg + 1
49
49
  }, pg);
50
50
  }), last && /*#__PURE__*/jsx("span", {
@@ -55,7 +55,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
55
55
  onClick: function onClick() {
56
56
  return onPageChange(pg);
57
57
  },
58
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
58
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
59
59
  children: pg + 1
60
60
  }, pg);
61
61
  })]
@@ -67,7 +67,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
67
67
  onClick: function onClick() {
68
68
  return onPageChange(0);
69
69
  },
70
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
70
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === 0 && "pointer-events-none text-tint-300"),
71
71
  children: /*#__PURE__*/jsx(Icon, {
72
72
  icon: "icon-[mdi--chevron-double-left]",
73
73
  rtlFlip: true
@@ -76,7 +76,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
76
76
  onClick: function onClick() {
77
77
  return onPageChange(page - 1);
78
78
  },
79
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
79
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === 0 && "pointer-events-none text-tint-300"),
80
80
  children: /*#__PURE__*/jsx(Icon, {
81
81
  icon: "icon-[mdi--chevron-left]",
82
82
  rtlFlip: true
@@ -88,7 +88,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
88
88
  onClick: function onClick() {
89
89
  return onPageChange(page + 1);
90
90
  },
91
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
91
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
92
92
  children: /*#__PURE__*/jsx(Icon, {
93
93
  icon: "icon-[mdi--chevron-right]",
94
94
  rtlFlip: true
@@ -97,7 +97,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
97
97
  onClick: function onClick() {
98
98
  return onPageChange(totalPages - 1);
99
99
  },
100
- className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
100
+ className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
101
101
  children: /*#__PURE__*/jsx(Icon, {
102
102
  icon: "icon-[mdi--chevron-double-right]",
103
103
  rtlFlip: true
@@ -0,0 +1,78 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import { Footer } from '@react-fabric/core';
5
+ import { getByPath } from '@react-fabric/utilities';
6
+ import classNames from 'classnames';
7
+ import { useMemo } from 'react';
8
+ import { usePagination } from '../hooks/usePagination.js';
9
+ import { Pagination } from '../pagination/Pagination.js';
10
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
+
12
+ 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; }
13
+ 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; }
14
+ var HtmlTable = function HtmlTable(_ref) {
15
+ var data = _ref.data,
16
+ columns = _ref.columns,
17
+ _ref$paginationSize = _ref.paginationSize,
18
+ paginationSize = _ref$paginationSize === void 0 ? 25 : _ref$paginationSize,
19
+ className = _ref.className;
20
+ var paginator = usePagination({
21
+ totalRecords: data.length,
22
+ perPage: paginationSize
23
+ });
24
+ var startIndex = useMemo(function () {
25
+ return paginator.page * paginationSize;
26
+ }, [paginator.page, paginationSize]);
27
+ var dataPage = useMemo(function () {
28
+ return paginationSize > 0 ? data.slice(startIndex, startIndex + paginationSize) : data;
29
+ }, [data, paginationSize, startIndex]);
30
+ return /*#__PURE__*/jsxs("div", {
31
+ className: className,
32
+ children: [/*#__PURE__*/jsxs("table", {
33
+ className: "table-fixed border-spacing-1 border-separate w-full text-sm",
34
+ children: [/*#__PURE__*/jsx("thead", {
35
+ className: "sticky top-0 z-1",
36
+ children: /*#__PURE__*/jsx("tr", {
37
+ children: columns.map(function (col, idx) {
38
+ var _ref2, _col$headRenderer;
39
+ return /*#__PURE__*/jsx("th", {
40
+ className: "text-start truncate bg-accent-100 px-2 py-1 font-medium text-accent-800",
41
+ style: {
42
+ width: col.width,
43
+ maxWidth: col.maxWidth
44
+ },
45
+ children: (_ref2 = (_col$headRenderer = col.headRenderer) !== null && _col$headRenderer !== void 0 ? _col$headRenderer : col.label) !== null && _ref2 !== void 0 ? _ref2 : " "
46
+ }, idx);
47
+ })
48
+ })
49
+ }), /*#__PURE__*/jsx("tbody", {
50
+ className: "bg-alternate",
51
+ children: dataPage.map(function (row, idx) {
52
+ return /*#__PURE__*/jsx("tr", {
53
+ children: columns.map(function (col, cidx) {
54
+ var _col$renderer, _col$renderer2;
55
+ return /*#__PURE__*/jsx("td", {
56
+ className: classNames("px-2 py-1 truncate", col.align === "center" && "text-center", col.align === "end" && "text-end", col.className),
57
+ style: {
58
+ width: col.width,
59
+ maxWidth: col.maxWidth
60
+ },
61
+ children: (_col$renderer = (_col$renderer2 = col.renderer) === null || _col$renderer2 === void 0 ? void 0 : _col$renderer2.call(col, getByPath(row, col.id.toString()), row, startIndex + idx)) !== null && _col$renderer !== void 0 ? _col$renderer : getByPath(row, col.id.toString())
62
+ }, "".concat(idx, "-").concat(cidx));
63
+ })
64
+ }, idx);
65
+ })
66
+ })]
67
+ }), paginationSize > 0 && /*#__PURE__*/jsx(Footer, {
68
+ flex: true,
69
+ justify: "end",
70
+ className: "px-2 py-1 sticky bottom-0 bg-tint-50",
71
+ children: /*#__PURE__*/jsx(Pagination, _objectSpread({
72
+ minimal: true
73
+ }, paginator))
74
+ })]
75
+ });
76
+ };
77
+
78
+ export { HtmlTable };
@@ -3,6 +3,7 @@ export { CheckList } from "./checklist/CheckList";
3
3
  export { Histogram } from "./histogram/Histogram";
4
4
  export { JsonViewer } from "./json/JsonViewer";
5
5
  export { Pagination } from "./pagination/Pagination";
6
+ export { HtmlTable } from "./table/HtmlTable";
6
7
  export { Table } from "./table/Table";
7
8
  export { type TableColumn, type TableRef } from "./table/types";
8
9
  export { TreePanel } from "./tree/TreePanel";
@@ -0,0 +1,21 @@
1
+ interface Props<T = KeyValue> {
2
+ data: T[];
3
+ columns: Array<{
4
+ id: keyof T;
5
+ label?: string;
6
+ width?: number | string;
7
+ maxWidth?: number | string;
8
+ align?: "start" | "center" | "end";
9
+ className?: string;
10
+ headRenderer?: React.ReactNode;
11
+ renderer?: (value: any, row: T, index: number) => React.ReactNode;
12
+ }>;
13
+ /**
14
+ * Number of pagination buttons to show, default is 25
15
+ * If set to 0, pagination will be hidden
16
+ */
17
+ paginationSize?: number;
18
+ className?: string;
19
+ }
20
+ export declare const HtmlTable: <T extends KeyValue = KeyValue>({ data, columns, paginationSize, className, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/data",
3
- "version": "1.0.0-beta.61",
3
+ "version": "1.0.0-beta.62",
4
4
  "description": "RUF: Data package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -35,10 +35,10 @@
35
35
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
36
  },
37
37
  "dependencies": {
38
- "@react-fabric/core": "^1.0.0-beta.61",
39
- "@react-fabric/date": "^1.0.0-beta.61",
40
- "@react-fabric/form": "^1.0.0-beta.61",
41
- "@react-fabric/utilities": "^1.0.0-beta.61",
38
+ "@react-fabric/core": "^1.0.0-beta.62",
39
+ "@react-fabric/date": "^1.0.0-beta.62",
40
+ "@react-fabric/form": "^1.0.0-beta.62",
41
+ "@react-fabric/utilities": "^1.0.0-beta.62",
42
42
  "@tanstack/react-virtual": "~3.13.12",
43
43
  "classnames": "~2.5.1",
44
44
  "color": "~5.0.2",
@@ -54,5 +54,5 @@
54
54
  "node": ">=18.12.0",
55
55
  "npm": ">=8.19.0"
56
56
  },
57
- "gitHead": "a0b0c571bf9c189fa3355bbc3b896ecc4b9d6a04"
57
+ "gitHead": "9dce2fd9bb753d67e3f8adbf50be257b4bc64242"
58
58
  }
package/src/i18n/index.ts CHANGED
@@ -22,7 +22,7 @@
22
22
  */
23
23
 
24
24
  import { addTranslationBundle } from "@react-fabric/core";
25
- import ar from "./ar.json";
26
- import en from "./en.json";
25
+ import ar from "./ar/data.json";
26
+ import en from "./en/data.json";
27
27
 
28
28
  addTranslationBundle("data", { en, ar });
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ export { CheckList } from "./checklist/CheckList";
27
27
  export { Histogram } from "./histogram/Histogram";
28
28
  export { JsonViewer } from "./json/JsonViewer";
29
29
  export { Pagination } from "./pagination/Pagination";
30
+ export { HtmlTable } from "./table/HtmlTable";
30
31
  export { Table } from "./table/Table";
31
32
  export { type TableColumn, type TableRef } from "./table/types";
32
33
  export { TreePanel } from "./tree/TreePanel";
@@ -70,7 +70,7 @@ export const Pagination = memo(
70
70
  key={pg}
71
71
  onClick={() => onPageChange(pg)}
72
72
  className={classNames(
73
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
73
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
74
74
  page === pg && "bg-primary-500 text-white pointer-events-none",
75
75
  )}
76
76
  >
@@ -87,7 +87,7 @@ export const Pagination = memo(
87
87
  key={pg}
88
88
  onClick={() => onPageChange(pg)}
89
89
  className={classNames(
90
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
90
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
91
91
  page === pg && "bg-primary-500 text-white pointer-events-none",
92
92
  )}
93
93
  >
@@ -104,7 +104,7 @@ export const Pagination = memo(
104
104
  key={pg}
105
105
  onClick={() => onPageChange(pg)}
106
106
  className={classNames(
107
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
107
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
108
108
  page === pg && "bg-primary-500 text-white pointer-events-none",
109
109
  )}
110
110
  >
@@ -121,7 +121,7 @@ export const Pagination = memo(
121
121
  <button
122
122
  onClick={() => onPageChange(0)}
123
123
  className={classNames(
124
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
124
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
125
125
  page === 0 && "pointer-events-none text-tint-300",
126
126
  )}
127
127
  >
@@ -130,7 +130,7 @@ export const Pagination = memo(
130
130
  <button
131
131
  onClick={() => onPageChange(page - 1)}
132
132
  className={classNames(
133
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
133
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
134
134
  page === 0 && "pointer-events-none text-tint-300",
135
135
  )}
136
136
  >
@@ -145,7 +145,7 @@ export const Pagination = memo(
145
145
  <button
146
146
  onClick={() => onPageChange(page + 1)}
147
147
  className={classNames(
148
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
148
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
149
149
  page + 1 >= totalPages && "pointer-events-none text-tint-300",
150
150
  )}
151
151
  >
@@ -154,7 +154,7 @@ export const Pagination = memo(
154
154
  <button
155
155
  onClick={() => onPageChange(totalPages - 1)}
156
156
  className={classNames(
157
- "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full",
157
+ "leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer",
158
158
  page + 1 >= totalPages && "pointer-events-none text-tint-300",
159
159
  )}
160
160
  >
@@ -0,0 +1,128 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2026 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import { Footer } from "@react-fabric/core";
25
+ import { getByPath } from "@react-fabric/utilities";
26
+ import classNames from "classnames";
27
+ import { useMemo } from "react";
28
+ import { usePagination } from "../hooks/usePagination";
29
+ import { Pagination } from "../pagination/Pagination";
30
+
31
+ interface Props<T = KeyValue> {
32
+ data: T[];
33
+ columns: Array<{
34
+ id: keyof T;
35
+ label?: string;
36
+ width?: number | string;
37
+ maxWidth?: number | string;
38
+ align?: "start" | "center" | "end";
39
+ className?: string;
40
+ headRenderer?: React.ReactNode;
41
+ renderer?: (value: any, row: T, index: number) => React.ReactNode;
42
+ }>;
43
+ /**
44
+ * Number of pagination buttons to show, default is 25
45
+ * If set to 0, pagination will be hidden
46
+ */
47
+ paginationSize?: number;
48
+
49
+ className?: string;
50
+ }
51
+
52
+ export const HtmlTable = <T extends KeyValue = KeyValue>({
53
+ data,
54
+ columns,
55
+ paginationSize = 25,
56
+ className,
57
+ }: Props<T>) => {
58
+ const paginator = usePagination({
59
+ totalRecords: data.length,
60
+ perPage: paginationSize,
61
+ });
62
+
63
+ const startIndex = useMemo(
64
+ () => paginator.page * paginationSize,
65
+ [paginator.page, paginationSize],
66
+ );
67
+
68
+ const dataPage = useMemo(
69
+ () =>
70
+ paginationSize > 0
71
+ ? data.slice(startIndex, startIndex + paginationSize)
72
+ : data,
73
+ [data, paginationSize, startIndex],
74
+ );
75
+
76
+ return (
77
+ <div className={className}>
78
+ <table className="table-fixed border-spacing-1 border-separate w-full text-sm">
79
+ <thead className="sticky top-0 z-1">
80
+ <tr>
81
+ {columns.map((col, idx) => (
82
+ <th
83
+ key={idx}
84
+ className="text-start truncate bg-accent-100 px-2 py-1 font-medium text-accent-800"
85
+ style={{ width: col.width, maxWidth: col.maxWidth }}
86
+ >
87
+ {col.headRenderer ?? col.label ?? " "}
88
+ </th>
89
+ ))}
90
+ </tr>
91
+ </thead>
92
+ <tbody className="bg-alternate">
93
+ {dataPage.map((row, idx) => (
94
+ <tr key={idx}>
95
+ {columns.map((col, cidx) => (
96
+ <td
97
+ key={`${idx}-${cidx}`}
98
+ className={classNames(
99
+ "px-2 py-1 truncate",
100
+ col.align === "center" && "text-center",
101
+ col.align === "end" && "text-end",
102
+ col.className,
103
+ )}
104
+ style={{ width: col.width, maxWidth: col.maxWidth }}
105
+ >
106
+ {col.renderer?.(
107
+ getByPath(row, col.id.toString()),
108
+ row,
109
+ startIndex + idx,
110
+ ) ?? getByPath(row, col.id.toString())}
111
+ </td>
112
+ ))}
113
+ </tr>
114
+ ))}
115
+ </tbody>
116
+ </table>
117
+ {paginationSize > 0 && (
118
+ <Footer
119
+ flex
120
+ justify="end"
121
+ className="px-2 py-1 sticky bottom-0 bg-tint-50"
122
+ >
123
+ <Pagination minimal {...paginator} />
124
+ </Footer>
125
+ )}
126
+ </div>
127
+ );
128
+ };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes