tabulify 1.0.8 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  var React = require('react');
4
4
 
5
+ var getUniqueId = function (prefix) {
6
+ return "".concat(prefix !== null && prefix !== void 0 ? prefix : 'id', "-").concat(Date.now(), "-").concat(Math.random().toString(36).substring(2, 9));
7
+ };
8
+
5
9
  // Table Component
6
10
  var Table = function (_a) {
7
11
  var columns = _a.columns, dataSource = _a.dataSource, rowSelection = _a.rowSelection, pagination = _a.pagination, key = _a.key, className = _a.className, onRowClick = _a.onRowClick;
@@ -22,8 +26,8 @@ var Table = function (_a) {
22
26
  React.createElement("thead", { className: "tabulify-head" },
23
27
  React.createElement("tr", null,
24
28
  rowSelection && React.createElement("th", null),
25
- columns.map(function (column) { return (React.createElement("th", { key: [column.key, Math.random].join('-') }, column.title)); }))),
26
- React.createElement("tbody", { className: "tabulify-body" }, paginatedData.map(function (record, index) { return (React.createElement("tr", { key: [record[key], Math.random].join('-'), onClick: function () { return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record[key]); } }, columns.map(function (column) { return (React.createElement("td", { key: [column.key, Math.random].join('-') }, column.render
29
+ columns.map(function (column) { return (React.createElement("th", { key: getUniqueId(column.key) }, column.title)); }))),
30
+ React.createElement("tbody", { className: "tabulify-body" }, paginatedData.map(function (record, index) { return (React.createElement("tr", { key: getUniqueId(record[key]), onClick: function () { return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record[key]); } }, columns.map(function (column) { return (React.createElement("td", { key: getUniqueId(column.key) }, column.render
27
31
  ? column.render(record[column.dataIndex], record, index)
28
32
  : record[column.dataIndex])); }))); }))),
29
33
  pagination && (React.createElement("div", { className: "tabulify-pagination" }, Array.from({ length: Math.ceil(pagination.total / pageSize) }, function (_, i) { return i + 1; }).map(function (page) { return (React.createElement("button", { key: page, className: currentPage === page ? 'active' : '', onClick: function () { return handlePageChange(page); } }, page)); })))));
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/components/Table.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { TableProps } from './Table.types';\n\n// Table Component\nconst Table = <T,>({\n columns,\n dataSource,\n rowSelection,\n pagination,\n key,\n className,\n onRowClick,\n}: TableProps<T>) => {\n const [currentPage, setCurrentPage] = useState(pagination?.current || 1);\n\n const pageSize = pagination?.pageSize || dataSource.length;\n\n // Handle pagination\n const handlePageChange = (page: number) => {\n setCurrentPage(page);\n pagination?.onChange?.(page);\n };\n\n // Paginate data\n const paginatedData = pagination\n ? dataSource.slice((currentPage - 1) * pageSize, currentPage * pageSize)\n : dataSource;\n\n return (\n <>\n <table className={className}>\n <thead className=\"tabulify-head\">\n <tr>\n {rowSelection && <th></th>}\n {columns.map((column) => (\n <th key={[column.key, Math.random].join('-')}>{column.title}</th>\n ))}\n </tr>\n </thead>\n <tbody className=\"tabulify-body\">\n {paginatedData.map((record, index) => (\n <tr\n key={[record[key], Math.random].join('-')}\n onClick={() => onRowClick?.(record[key])}\n >\n {columns.map((column) => (\n <td key={[column.key, Math.random].join('-')}>\n {column.render\n ? column.render(record[column.dataIndex], record, index)\n : (record[column.dataIndex] as React.ReactNode)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n {pagination && (\n <div className=\"tabulify-pagination\">\n {Array.from(\n { length: Math.ceil(pagination.total / pageSize) },\n (_, i) => i + 1\n ).map((page) => (\n <button\n key={page}\n className={currentPage === page ? 'active' : ''}\n onClick={() => handlePageChange(page)}\n >\n {page}\n </button>\n ))}\n </div>\n )}\n </>\n );\n};\n\nexport default Table;\n"],"names":["useState"],"mappings":";;;;AAGA;AACM,IAAA,KAAK,GAAG,UAAK,EAQH,EAAA;AAPd,IAAA,IAAA,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,YAAY,kBAAA,EACZ,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,SAAS,GAAA,EAAA,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AK,GAAG,QAAQ,CAAC,EAAE,EAClD,UAAC,CAAC,EAAE,CAAC,EAAA,EAAK,OAAA,CAAC,GAAG,CAAC,CAAL,EAAK,CAChB,CAAC,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,QACd,KACE,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,WAAW,KAAK,IAAI,GAAG,QAAQ,GAAG,EAAE,EAC/C,OAAO,EAAE,cAAM,OAAA,gBAAgB,CAAC,IAAI,CAAC,GAAA,EAAA,EAEpC,IAAI,CACE,IACV,CAAC,CACE,CACP,CACA;AAEP;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/components/utils.ts","../src/components/Table.tsx"],"sourcesContent":["export const getUniqueId = (prefix: unknown): string =>\n `${prefix ?? 'id'}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n","import React, { useState } from 'react';\nimport { TableProps } from './Table.types';\nimport { getUniqueId } from './utils';\n\n// Table Component\nconst Table = <T,>({\n columns,\n dataSource,\n rowSelection,\n pagination,\n key,\n className,\n onRowClick,\n}: TableProps<T>) => {\n const [currentPage, setCurrentPage] = useState(pagination?.current || 1);\n\n const pageSize = pagination?.pageSize || dataSource.length;\n\n // Handle pagination\n const handlePageChange = (page: number) => {\n setCurrentPage(page);\n pagination?.onChange?.(page);\n };\n\n // Paginate data\n const paginatedData = pagination\n ? dataSource.slice((currentPage - 1) * pageSize, currentPage * pageSize)\n : dataSource;\n\n return (\n <>\n <table className={className}>\n <thead className=\"tabulify-head\">\n <tr>\n {rowSelection && <th></th>}\n {columns.map((column) => (\n <th key={getUniqueId(column.key)}>{column.title}</th>\n ))}\n </tr>\n </thead>\n <tbody className=\"tabulify-body\">\n {paginatedData.map((record, index) => (\n <tr\n key={getUniqueId(record[key])}\n onClick={() => onRowClick?.(record[key])}\n >\n {columns.map((column) => (\n <td key={getUniqueId(column.key)}>\n {column.render\n ? column.render(record[column.dataIndex], record, index)\n : (record[column.dataIndex] as React.ReactNode)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n {pagination && (\n <div className=\"tabulify-pagination\">\n {Array.from(\n { length: Math.ceil(pagination.total / pageSize) },\n (_, i) => i + 1\n ).map((page) => (\n <button\n key={page}\n className={currentPage === page ? 'active' : ''}\n onClick={() => handlePageChange(page)}\n >\n {page}\n </button>\n ))}\n </div>\n )}\n </>\n );\n};\n\nexport default Table;\n"],"names":["useState"],"mappings":";;;;AAAO,IAAM,WAAW,GAAG,UAAC,MAAe,EAAA;AACzC,IAAA,OAAA,EAAG,CAAA,MAAA,CAAA,MAAM,KAAN,IAAA,IAAA,MAAM,KAAN,KAAA,CAAA,GAAA,MAAM,GAAI,IAAI,EAAI,GAAA,CAAA,CAAA,MAAA,CAAA,IAAI,CAAC,GAAG,EAAE,EAAI,GAAA,CAAA,CAAA,MAAA,CAAA,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE;AAA/E,CAA+E;;ACGjF;AACM,IAAA,KAAK,GAAG,UAAK,EAQH,EAAA;AAPd,IAAA,IAAA,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,YAAY,kBAAA,EACZ,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA;IAEJ,IAAA,EAAA,GAAgCA,cAAQ,CAAC,CAAA,UAAU,KAAV,IAAA,IAAA,UAAU,uBAAV,UAAU,CAAE,OAAO,KAAI,CAAC,CAAC,EAAjE,WAAW,QAAA,EAAE,cAAc,QAAsC;AAExE,IAAA,IAAM,QAAQ,GAAG,CAAA,UAAU,aAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,QAAQ,KAAI,UAAU,CAAC,MAAM;;I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{
4
+ return "".concat(prefix !== null && prefix !== void 0 ? prefix : 'id', "-").concat(Date.now(), "-").concat(Math.random().toString(36).substring(2, 9));
5
+ };
6
+
3
7
  // Table Component
4
8
  var Table = function (_a) {
5
9
  var columns = _a.columns, dataSource = _a.dataSource, rowSelection = _a.rowSelection, pagination = _a.pagination, key = _a.key, className = _a.className, onRowClick = _a.onRowClick;
@@ -20,8 +24,8 @@ var Table = function (_a) {
20
24
  React.createElement("thead", { className: "tabulify-head" },
21
25
  React.createElement("tr", null,
22
26
  rowSelection && React.createElement("th", null),
23
- columns.map(function (column) { return (React.createElement("th", { key: [column.key, Math.random].join('-') }, column.title)); }))),
24
- React.createElement("tbody", { className: "tabulify-body" }, paginatedData.map(function (record, index) { return (React.createElement("tr", { key: [record[key], Math.random].join('-'), onClick: function () { return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record[key]); } }, columns.map(function (column) { return (React.createElement("td", { key: [column.key, Math.random].join('-') }, column.render
27
+ columns.map(function (column) { return (React.createElement("th", { key: getUniqueId(column.key) }, column.title)); }))),
28
+ React.createElement("tbody", { className: "tabulify-body" }, paginatedData.map(function (record, index) { return (React.createElement("tr", { key: getUniqueId(record[key]), onClick: function () { return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record[key]); } }, columns.map(function (column) { return (React.createElement("td", { key: getUniqueId(column.key) }, column.render
25
29
  ? column.render(record[column.dataIndex], record, index)
26
30
  : record[column.dataIndex])); }))); }))),
27
31
  pagination && (React.createElement("div", { className: "tabulify-pagination" }, Array.from({ length: Math.ceil(pagination.total / pageSize) }, function (_, i) { return i + 1; }).map(function (page) { return (React.createElement("button", { key: page, className: currentPage === page ? 'active' : '', onClick: function () { return handlePageChange(page); } }, page)); })))));
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/components/Table.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { TableProps } from './Table.types';\n\n// Table Component\nconst Table = <T,>({\n columns,\n dataSource,\n rowSelection,\n pagination,\n key,\n className,\n onRowClick,\n}: TableProps<T>) => {\n const [currentPage, setCurrentPage] = useState(pagination?.current || 1);\n\n const pageSize = pagination?.pageSize || dataSource.length;\n\n // Handle pagination\n const handlePageChange = (page: number) => {\n setCurrentPage(page);\n pagination?.onChange?.(page);\n };\n\n // Paginate data\n const paginatedData = pagination\n ? dataSource.slice((currentPage - 1) * pageSize, currentPage * pageSize)\n : dataSource;\n\n return (\n <>\n <table className={className}>\n <thead className=\"tabulify-head\">\n <tr>\n {rowSelection && <th></th>}\n {columns.map((column) => (\n <th key={[column.key, Math.random].join('-')}>{column.title}</th>\n ))}\n </tr>\n </thead>\n <tbody className=\"tabulify-body\">\n {paginatedData.map((record, index) => (\n <tr\n key={[record[key], Math.random].join('-')}\n onClick={() => onRowClick?.(record[key])}\n >\n {columns.map((column) => (\n <td key={[column.key, Math.random].join('-')}>\n {column.render\n ? column.render(record[column.dataIndex], record, index)\n : (record[column.dataIndex] as React.ReactNode)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n {pagination && (\n <div className=\"tabulify-pagination\">\n {Array.from(\n { length: Math.ceil(pagination.total / pageSize) },\n (_, i) => i + 1\n ).map((page) => (\n <button\n key={page}\n className={currentPage === page ? 'active' : ''}\n onClick={() => handlePageChange(page)}\n >\n {page}\n </button>\n ))}\n </div>\n )}\n </>\n );\n};\n\nexport default Table;\n"],"names":[],"mappings":";;AAGA;AACM,IAAA,KAAK,GAAG,UAAK,EAQH,EAAA;AAPd,IAAA,IAAA,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,YAAY,kBAAA,EACZ,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA;IAEJ,IAAA,EAAA,GAAgC,QAAQ,CAAC,CAAA,UAAU,KAAV,IAAA,IAAA,UAAU,uBAAV,UAAU,CAAE,OAAO,KA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AA,QACd,KACE,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,WAAW,KAAK,IAAI,GAAG,QAAQ,GAAG,EAAE,EAC/C,OAAO,EAAE,cAAM,OAAA,gBAAgB,CAAC,IAAI,CAAC,GAAA,EAAA,EAEpC,IAAI,CACE,IACV,CAAC,CACE,CACP,CACA;AAEP;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/components/utils.ts","../src/components/Table.tsx"],"sourcesContent":["export const getUniqueId = (prefix: unknown): string =>\n `${prefix ?? 'id'}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n","import React, { useState } from 'react';\nimport { TableProps } from './Table.types';\nimport { getUniqueId } from './utils';\n\n// Table Component\nconst Table = <T,>({\n columns,\n dataSource,\n rowSelection,\n pagination,\n key,\n className,\n onRowClick,\n}: TableProps<T>) => {\n const [currentPage, setCurrentPage] = useState(pagination?.current || 1);\n\n const pageSize = pagination?.pageSize || dataSource.length;\n\n // Handle pagination\n const handlePageChange = (page: number) => {\n setCurrentPage(page);\n pagination?.onChange?.(page);\n };\n\n // Paginate data\n const paginatedData = pagination\n ? dataSource.slice((currentPage - 1) * pageSize, currentPage * pageSize)\n : dataSource;\n\n return (\n <>\n <table className={className}>\n <thead className=\"tabulify-head\">\n <tr>\n {rowSelection && <th></th>}\n {columns.map((column) => (\n <th key={getUniqueId(column.key)}>{column.title}</th>\n ))}\n </tr>\n </thead>\n <tbody className=\"tabulify-body\">\n {paginatedData.map((record, index) => (\n <tr\n key={getUniqueId(record[key])}\n onClick={() => onRowClick?.(record[key])}\n >\n {columns.map((column) => (\n <td key={getUniqueId(column.key)}>\n {column.render\n ? column.render(record[column.dataIndex], record, index)\n : (record[column.dataIndex] as React.ReactNode)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n {pagination && (\n <div className=\"tabulify-pagination\">\n {Array.from(\n { length: Math.ceil(pagination.total / pageSize) },\n (_, i) => i + 1\n ).map((page) => (\n <button\n key={page}\n className={currentPage === page ? 'active' : ''}\n onClick={() => handlePageChange(page)}\n >\n {page}\n </button>\n ))}\n </div>\n )}\n </>\n );\n};\n\nexport default Table;\n"],"names":[],"mappings":";;AAAO,IAAM,WAAW,GAAG,UAAC,MAAe,EAAA;AACzC,IAAA,OAAA,EAAG,CAAA,MAAA,CAAA,MAAM,KAAN,IAAA,IAAA,MAAM,KAAN,KAAA,CAAA,GAAA,MAAM,GAAI,IAAI,EAAI,GAAA,CAAA,CAAA,MAAA,CAAA,IAAI,CAAC,GAAG,EAAE,EAAI,GAAA,CAAA,CAAA,MAAA,CAAA,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE;AAA/E,CAA+E;;ACGjF;AACM,IAAA,KAAK,GAAG,UAAK,EAQH,EAAA;AAPd,IAAA,IAAA,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,YAAY,kBAAA,EACZ,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA;IAEJ,IAAA,EAAA,GAAgC,QAAQ,CAAC,CAAA,UAAU,KAAV,IAAA,IAAA,UAAU,uBAAV,UAAU,CAAE,OAAO,KAAI,CAAC,CAAC,EAAjE,WAAW,QAAA,EAAE,cAAc,QAAsC;AAExE,IAAA,IAAM,QAAQ,GAAG,CAAA,UAAU,aAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,QAAQ,KAAI,UAAU,CAAC,MAAM;;IAG1D,IAAM,gBAAgB,GAAG,UAAC,IAAY,EAAA;;QACpC,cAAc,CAAC,IAAI,CAAC;QACpB,CAAA,EAAA,GAAA,UAAU,KAAV,IAAA,IAAA,UAAU,KAAV,KAAA,CAAA,GAAA,KAAA,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,CAAC,CAAC,CAAA,EAAA,EAAA,EAEvC,OAAO,CAAC,GAAG,CAAC,UAAC,MAAM,EAAA,EAAK,QACvB,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,EAC7B,EAAA,MAAM,CAAC;AACN,kBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK;AACvD,kBAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAqB,CAC9C,EALkB,EAMxB,CAAC,CACC,IACN,CAAC,CACI,CACF;AACP,QAAA,UAAU,KACT,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,IACjC,KAAK,CAAC,IAAI,CACT,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,QAAQ,CAAC,EAAE,EAClD,UAAC,CAAC,EAAE,CAAC,EAAA,EAAK,OAAA,CAAC,GAAG,CAAC,CAAL,EAAK,CAChB,CAAC,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,QACd,KACE,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,WAAW,KAAK,IAAI,GAAG,QAAQ,GAAG,EAAE,EAC/C,OAAO,EAAE,cAAM,OAAA,gBAAgB,CAAC,IAAI,CAAC,GAAA,EAAA,EAEpC,IAAI,CACE,IACV,CAAC,CACE,CACP,CACA;AAEP;;;;"}
@@ -0,0 +1 @@
1
+ export declare const getUniqueId: (prefix: unknown) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabulify",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "description": "A lightweight and customizable React table component.",
6
6
  "main": "dist/index.js",